Changeset 1182 for trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/view
- Timestamp:
- 12/06/11 21:40:11 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.modelica.mdt.ui/src/org/modelica/mdt/ui/view/ModelicaContentOutlinePage.java
r1104 r1182 25 25 package org.modelica.mdt.ui.view; 26 26 27 import java.util.ArrayList; 27 28 import java.util.Collection; 28 29 import java.util.Hashtable; … … 90 91 import org.modelica.mdt.ui.ModelicaElementChangeListener; 91 92 92 public class ModelicaContentOutlinePage extends ContentOutlinePage 93 { 93 public class ModelicaContentOutlinePage extends ContentOutlinePage { 94 94 static Object[] NO_CHILDREN= new Object[0]; 95 static IPreferenceStore prefStore = UIPlugin.getDefault().getPreferenceStore(); 95 96 96 97 ModelicaEditor fEditor = null; … … 110 111 111 112 private CompositeActionGroup fActionGroups; 112 113 113 114 private IPreferenceStore fCorePreferenceStore = CorePlugin.getDefault().getPreferenceStore(); 114 115 … … 168 169 } 169 170 171 @Override 170 172 public Object[] getChildren(Object parent) { 173 // TODO: Use a better name for this property and don't hard-code it here. Use modern-style enum. 174 String filterProtectedProperty = "MemberFilterActionGroup.org.modelica.mdt.ui.ModelicaContentOutlinePage.1"; 175 boolean shouldFilterProtected = false; 176 177 if (prefStore.contains(filterProtectedProperty)) { 178 shouldFilterProtected = prefStore.getBoolean(filterProtectedProperty); 179 } 180 else { 181 // We are not storing a preference for this filter, so we disable it, i.e., no filtering. 182 } 183 184 Object[] result = NO_CHILDREN; 185 171 186 if (parent instanceof IParent) { 172 IParent c= (IParent) parent; 173 try 174 { 175 Collection<? extends IModelicaElement> z = c.getChildren(); 176 IModelicaElement[] arr = new IModelicaElement[z.size()]; 177 int i = 0; 178 for (IModelicaElement el : z) 179 { 180 arr[i++] = el; 187 try { 188 Collection<? extends IModelicaElement> children = ((IParent)parent).getChildren(); 189 List<IModelicaElement> filteredChildren = new ArrayList<IModelicaElement>(); 190 for (IModelicaElement el : children) { 191 if (shouldFilterProtected && el.getVisibility() == IModelicaElement.Visibility.PROTECTED) { 192 // Filter out this protected item. 193 } 194 else { 195 filteredChildren.add(el); 196 } 181 197 } 182 return arr; //filter(arr); 198 199 result = filteredChildren.toArray(); 183 200 } 184 catch (Exception x) 185 { 201 catch (Exception x) { 186 202 x.printStackTrace(); 187 203 } 188 204 } 189 return NO_CHILDREN; 190 } 191 205 206 return result; 207 } 208 209 @Override 192 210 public Object[] getElements(Object parent) { 193 211 return getChildren(parent); 194 212 } 195 213 214 @Override 196 215 public Object getParent(Object child) { 197 216 if (child instanceof IModelicaElement) { … … 202 221 } 203 222 223 @Override 204 224 public boolean hasChildren(Object parent) { 205 225 if (parent instanceof IParent) { … … 221 241 } 222 242 243 @Override 223 244 public void dispose() 224 245 { … … 231 252 * @see IContentProvider#inputChanged(Viewer, Object, Object) 232 253 */ 254 @Override 233 255 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 234 256 boolean isMO= (newInput instanceof IModelicaFile); … … 296 318 * @see TreeViewer#internalExpandToLevel 297 319 */ 320 @Override 298 321 protected void internalExpandToLevel(Widget node, int level) { 299 322 if (node instanceof Item) { … … 348 371 * @see org.eclipse.jface.viewers.AbstractTreeViewer#isExpandable(java.lang.Object) 349 372 */ 373 @Override 350 374 public boolean isExpandable(Object element) { 351 375 if (hasFilters()) { … … 416 440 } 417 441 442 @Override 418 443 public void run() { 419 444 valueChanged(isChecked(), true); … … 423 448 setChecked(on); 424 449 BusyIndicator.showWhile(fOutlineViewer.getControl().getDisplay(), new Runnable() { 450 @Override 425 451 public void run() { 426 452 if (on) … … 430 456 } 431 457 }); 432 458 433 459 if (store) fCorePreferenceStore.setValue("ModeilcaEditor.Outline.LexicalSortingAction.isChecked", on); //$NON-NLS-1$ 434 460 435 461 } 436 462 } … … 461 487 * Runs the action. 462 488 */ 489 @Override 463 490 public void run() 464 491 { … … 498 525 fEditor= editor; 499 526 fPropertyChangeListener= new IPropertyChangeListener() { 527 @Override 500 528 public void propertyChange(PropertyChangeEvent event) { 501 529 doPropertyChange(event); … … 508 536 if (fOutlineViewer != null) { 509 537 // TODO! FIXME! update only if is a sort action! if (event.getProperty() ) { 510 538 fOutlineViewer.refresh(false); 511 539 //} 512 540 } 513 541 } 514 542 515 543 /* (non-Modelicadoc) 516 544 * Method declared on Page 517 545 */ 546 @Override 518 547 public void init(IPageSite pageSite) { 519 548 super.init(pageSite); … … 523 552 * @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener) 524 553 */ 554 @Override 525 555 public void addSelectionChangedListener(ISelectionChangedListener listener) { 526 556 if (fOutlineViewer != null) … … 533 563 * @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener) 534 564 */ 565 @Override 535 566 public void removeSelectionChangedListener(ISelectionChangedListener listener) { 536 567 if (fOutlineViewer != null) … … 543 574 * @see ISelectionProvider#setSelection(ISelection) 544 575 */ 576 @Override 545 577 public void setSelection(ISelection selection) { 546 578 if (fOutlineViewer != null) … … 551 583 * @see ISelectionProvider#getSelection() 552 584 */ 585 @Override 553 586 public ISelection getSelection() { 554 587 if (fOutlineViewer == null) … … 596 629 * @see IPage#createControl 597 630 */ 631 @Override 598 632 public void createControl(Composite parent) { 599 633 … … 604 638 // use a non decorating label provider for outline! 605 639 // fOutlineViewer.setLabelProvider(new DecoratingLabelProvider( 606 607 640 // new WorkbenchLabelProvider(), UIPlugin.getDefault().getWorkbench() 641 // .getDecoratorManager().getLabelDecorator())); 608 642 fOutlineViewer.setLabelProvider(new WorkbenchLabelProvider()); 609 643 … … 623 657 manager.setRemoveAllWhenShown(true); 624 658 manager.addMenuListener(new IMenuListener() { 659 @Override 625 660 public void menuAboutToShow(IMenuManager m) { 626 661 contextMenuAboutToShow(m); … … 635 670 updateSelectionProvider(site); 636 671 637 // we must create the groups after we have set the selection provider to the site672 // we must create the groups after we have set the selection provider to the site 638 673 fActionGroups= new CompositeActionGroup(new ActionGroup[] {}); 639 674 640 // register global actions675 // register global actions 641 676 IActionBars actionBars= site.getActionBars(); 642 677 actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, fEditor.getAction(ITextEditorActionConstants.UNDO)); … … 652 687 fActionGroups.fillActionBars(actionBars); 653 688 654 // Custom filter group689 // Custom filter group 655 690 fCustomFiltersActionGroup= new CustomFiltersActionGroup("org.modelica.mdt.ui.ModelicaContentOutlinePage", fOutlineViewer); //$NON-NLS-1$ 656 691 … … 671 706 } 672 707 708 @Override 673 709 public void dispose() { 674 710 … … 708 744 } 709 745 746 @Override 710 747 public Control getControl() { 711 748 if (fOutlineViewer != null) … … 739 776 public IAction getAction(String actionID) { 740 777 Assert.isNotNull(actionID); 741 return (IAction)fActions.get(actionID);778 return fActions.get(actionID); 742 779 } 743 780 … … 751 788 if (key == IModelicaElement.class) { 752 789 return new IShowInTargetList() { 790 @Override 753 791 public String[] getShowInTargetIds() { 754 792 return new String[] { UIPlugin.ID_PROJECTSVIEW }; … … 800 838 * @see Page#setFocus() 801 839 */ 840 @Override 802 841 public void setFocus() { 803 842 if (fOutlineViewer != null) … … 817 856 if (element != null && element instanceof IModelicaClass) 818 857 if(((IModelicaClass)element).getRestriction() == IModelicaClass.Restriction.TYPE || 819 820 858 ((IModelicaClass)element).getRestriction() == IModelicaClass.Restriction.UNIONTYPE) 859 return true; 821 860 } 822 861 catch (Exception e) { … … 833 872 protected IShowInSource getShowInSource() { 834 873 return new IShowInSource() { 874 @Override 835 875 public ShowInContext getShowInContext() { 836 876 return new ShowInContext(null, getSite().getSelectionProvider().getSelection()); … … 846 886 protected IShowInTarget getShowInTarget() { 847 887 return new IShowInTarget() { 888 @Override 848 889 public boolean show(ShowInContext context) { 849 890 ISelection sel= context.getSelection(); … … 864 905 }; 865 906 } 866 867 907 908 868 909 protected void handleOpen(OpenEvent event) 869 910 { … … 887 928 } 888 929 } 889 930 890 931 891 932 }
Note: See TracChangeset
for help on using the changeset viewer.