Java Code Examples for org.eclipse.jface.viewers.TreeViewer#addFilter()
The following examples show how to use
org.eclipse.jface.viewers.TreeViewer#addFilter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickOutlinePopup.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected TreeViewer createTreeViewer(Composite parent, int style) { Tree tree = new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI)); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = tree.getItemHeight() * 12; tree.setLayoutData(gd); final TreeViewer treeViewer = new TreeViewer(tree); treeViewer.addFilter(new NamePatternFilter()); treeViewer.setContentProvider(contentProvider); filterAndSorter.setComparator(comparator); contentProvider.setFilterAndSorter(filterAndSorter); treeViewer.setLabelProvider(labelProvider); treeViewer.setAutoExpandLevel(2); return treeViewer; }
Example 2
Source File: BusinessObjectList.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void createViewer(Composite parent, AbstractBdmFormPage formPage) { viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true).create()); formPage.getToolkit().adapt(viewer.getTree()); viewer.getTree().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, BUSINESS_OBJECT_LIST_VIEWER_ID); viewer.addFilter(createSearchFilter()); viewer.addDoubleClickListener(e -> { viewer.setExpandedState(selectionObservable.getValue(), !viewer.getExpandedState(selectionObservable.getValue())); }); ColumnViewerToolTipSupport.enableFor(viewer); TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(1, true)); viewer.getTree().setLayout(layout); viewer.setUseHashlookup(true); createBusinessObjectColumn(viewer, formPage); viewer.setContentProvider(new BusinessObjectTreeContentProvider()); viewer.setComparator(new BusinessObjectViewerComparator()); viewer.setInput(input); addDNDSupport(formPage); selectionObservable = ViewerProperties.singleSelection(Object.class).observe(viewer); }
Example 3
Source File: QueryEditionControl.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private TreeViewer createQueryViewer(Composite parent) { TreeViewer queryViewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); queryViewer.getTree() .setLayoutData(GridDataFactory.fillDefaults().grab(false, true).hint(300, SWT.DEFAULT).create()); queryViewer.getTree().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, QUERY_LIST_VIEWER_ID); formPage.getToolkit().adapt(queryViewer.getTree()); ColumnViewerToolTipSupport.enableFor(queryViewer); queryViewer.setUseHashlookup(true); queryViewer.addFilter(createSearchFilter()); queryViewer.addDoubleClickListener(e -> { queryViewer.setExpandedState(querySelectedObservable.getValue(), !viewer.getExpandedState(querySelectedObservable.getValue())); }); TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(1, true)); queryViewer.getTree().setLayout(layout); createQueryNameColumn(queryViewer); provider = new QueryContentProvider(); queryViewer.setContentProvider(provider); return queryViewer; }
Example 4
Source File: ActorMappingConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void createMappingTree(final Composite listComposite) { mappingTree = new TreeViewer(listComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE | SWT.V_SCROLL); mappingTree.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mappingTree.setContentProvider(new AdapterFactoryContentProvider(adapterFactory) { @Override public Object[] getElements(final Object object) { if (object instanceof Collection) { return ((Collection) object).toArray(); } return super.getElements(object); } }); mappingTree.setLabelProvider(new ActorMappingStyledTreeLabelProvider(adapterFactory, deployedOrganization)); mappingTree.addSelectionChangedListener(this); mappingTree.addDoubleClickListener(this); mappingTree.addFilter(new ViewerFilter() { @Override public boolean select(final Viewer viewer, final Object parentElement, final Object element) { return (element instanceof String || element instanceof MembershipType) || ((ITreeContentProvider) mappingTree.getContentProvider()).hasChildren(element); } }); }
Example 5
Source File: AbstractOutlineFilterAction.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Should we hide things? */ protected void setActionEnabled(boolean enableAction) { BaseOutlinePage p = this.page.get(); if (p != null) { p.getStore().setValue(preference, enableAction); if (filter == null) { filter = createFilter(); } TreeViewer treeViewer = p.getTreeViewer(); if (treeViewer != null) { if (enableAction) { treeViewer.addFilter(filter); } else { treeViewer.removeFilter(filter); } } } }
Example 6
Source File: JavaEditorBreadcrumb.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void configureDropDownViewer(TreeViewer viewer, Object input) { viewer.setContentProvider(createDropDownContentProvider()); viewer.setLabelProvider(createDropDownLabelProvider()); viewer.setComparator(new JavaElementComparator()); viewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer1, Object parentElement, Object element) { if (element instanceof IMember) { if (((IMember) element).getElementName().startsWith("<")) { //$NON-NLS-1$ // filter out <clinit> return false; } } return true; } }); if (SHOW_LIBRARIES_NODE) viewer.addFilter(new EmptyLibraryContainerFilter()); JavaUIHelp.setHelp(viewer, IJavaHelpContextIds.JAVA_EDITOR_BREADCRUMB); }
Example 7
Source File: AbstractInformationControl.java From typescript.java with MIT License | 6 votes |
/** * Creates tree viewer to manage content * * @param parent * parent control */ private void createTreeViewer(Composite parent) { int style = SWT.H_SCROLL | SWT.V_SCROLL; // Create the tree Tree widget = new Tree(parent, style); // Configure the layout GridData data = new GridData(GridData.FILL_BOTH); data.heightHint = widget.getItemHeight() * 12; widget.setLayoutData(data); treeViewer = new TreeViewer(widget); namePatternFilter = new QuickOutlineNamePatternFilter(); treeViewer.addFilter(namePatternFilter); treeContentProvider = getContentProvider(); treeViewer.setContentProvider(treeContentProvider); treeLabelProvider = getLabelProvider(); treeViewer.setLabelProvider(treeLabelProvider); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); treeViewer.setUseHashlookup(true); treeViewer.setInput(getInitialInput()); }
Example 8
Source File: JavaOutlineInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected TreeViewer createTreeViewer(Composite parent, int style) { Tree tree= new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI)); GridData gd= new GridData(GridData.FILL_BOTH); gd.heightHint= tree.getItemHeight() * 12; tree.setLayoutData(gd); final TreeViewer treeViewer= new OutlineTreeViewer(tree); // Hard-coded filters treeViewer.addFilter(new NamePatternFilter()); treeViewer.addFilter(new MemberFilter()); fInnerLabelProvider= new OutlineLabelProvider(); fInnerLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null)); IDecoratorManager decoratorMgr= PlatformUI.getWorkbench().getDecoratorManager(); if (decoratorMgr.getEnabled("org.eclipse.jdt.ui.override.decorator")) //$NON-NLS-1$ fInnerLabelProvider.addLabelDecorator(new OverrideIndicatorLabelDecorator(null)); treeViewer.setLabelProvider(new ColoringLabelProvider(fInnerLabelProvider)); fLexicalSortingAction= new LexicalSortingAction(treeViewer); fSortByDefiningTypeAction= new SortByDefiningTypeAction(treeViewer); fShowOnlyMainTypeAction= new ShowOnlyMainTypeAction(treeViewer); fCategoryFilterActionGroup= new CategoryFilterActionGroup(treeViewer, getId(), getInputForCategories()); fOutlineContentProvider= new OutlineContentProvider(false); treeViewer.setContentProvider(fOutlineContentProvider); fOutlineSorter= new OutlineSorter(); treeViewer.setComparator(fOutlineSorter); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); treeViewer.getTree().addKeyListener(getKeyAdapter()); return treeViewer; }
Example 9
Source File: DialogPackageExplorer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public Control createControl(Composite parent) { fPackageViewer= new TreeViewer(parent, SWT.MULTI); fPackageViewer.setComparer(WorkingSetModel.COMPARER); fPackageViewer.addFilter(new PackageFilter()); fPackageViewer.setComparator(new ExtendedJavaElementSorter()); fPackageViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { Object element= ((IStructuredSelection)event.getSelection()).getFirstElement(); if (fPackageViewer.isExpandable(element)) { fPackageViewer.setExpandedState(element, !fPackageViewer.getExpandedState(element)); } else { if (element instanceof CPListElementAttribute) { CPListElementAttribute attribute= (CPListElementAttribute)element; if (attribute.getKey().equals(CPListElement.OUTPUT)) { fActionGroup.getEditOutputFolderAction().run(); } } } } }); MenuManager menuMgr= new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(this); fContextMenu= menuMgr.createContextMenu(fPackageViewer.getTree()); fPackageViewer.getTree().setMenu(fContextMenu); parent.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { fContextMenu.dispose(); } }); return fPackageViewer.getControl(); }
Example 10
Source File: JavaWorkingSetPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void configureTree(TreeViewer tree) { tree.setContentProvider(new JavaWorkingSetPageContentProvider()); AppearanceAwareLabelProvider javaElementLabelProvider= new AppearanceAwareLabelProvider( AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.P_COMPRESSED, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS ); tree.setLabelProvider(new DecoratingJavaLabelProvider(javaElementLabelProvider)); tree.setComparator(new JavaElementComparator()); tree.addFilter(new EmptyInnerPackageFilter()); tree.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot())); if (getSelection() == null) return; Object[] selection= getInitialTreeSelection(); if (selection.length > 0) { try { tree.getTree().setRedraw(false); for (int i= 0; i < selection.length; i++) { tree.expandToLevel(selection[i], 0); } tree.setSelection(new StructuredSelection(selection)); } finally { tree.getTree().setRedraw(true); } } }
Example 11
Source File: TreeSelectionDialog.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override protected Control createDialogArea(Composite parent) { Control composite = super.createDialogArea(parent); if (composite instanceof Composite) { updateCompositeLayout((Composite) composite); } TreeViewer treeViewer = getTreeViewer(); treeViewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { return matchItemToShowInTree(element); } }); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); treeViewer.expandAll(); if (this.initialFilter.length() > 0) { this.text.setText(this.initialFilter); this.text.setSelection(this.initialFilter.length()); this.setFilter(this.initialFilter, new NullProgressMonitor(), true); } notifyViewCreated(); onControlCreated.call(this.text); onControlCreated.call(this.getTreeViewer()); return composite; }
Example 12
Source File: BonitaTreeViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void addFilters(final TreeViewer treeViewer) { treeViewer.addFilter(new DatatypesViewFilter()); treeViewer.addFilter(new DecisionTableViewFilter()); treeViewer.addFilter(new TextAnnotationAttachmentViewFilter()); treeViewer.addFilter(new EmptyExpressionViewFilter()); treeViewer.addFilter(new EmptySearchIndexViewFilter()); treeViewer.addFilter(new EmptyOperationViewFilter()); treeViewer.addFilter(new EmptyContractInputMappingViewerFilter()); treeViewer.addFilter(new MainProcessFormMappingViewerFilter()); }
Example 13
Source File: MoveConnectorWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void createProcessTreeControl(final EMFDataBindingContext dbc, final Composite parent) { final Label label = new Label(parent, SWT.NONE); label.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create()); label.setText(Messages.chooseTargetStepOrProcess); final TreeViewer processTreeViewer = new FilteredTree(parent, SWT.BORDER | SWT.SINGLE, new PatternFilter(), true).getViewer(); processTreeViewer.getControl().getParent().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 300).create()); processTreeViewer.setLabelProvider(new ElementLabelProvider(adapterFactory)); processTreeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); processTreeViewer.addFilter(new ConnectableElementViewerFilter(sourceProcess)); processTreeViewer.setInput(ModelHelper.getMainProcess(sourceProcess)); processTreeViewer.expandAll(); dbc.bindValue(ViewersObservables.observeSingleSelection(processTreeViewer), targetLocationObservable, updateValueStrategy().withValidator(selectionValidator()).create(), null); }
Example 14
Source File: CustomElementSelectionDialog.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected Control createDialogArea(Composite parent) { CustomElementSelectionForm form = new CustomElementSelectionForm(parent, SWT.FILL); form.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); TreeViewer v = form.getTreeViewer(); for (ViewerFilter filter : filters) { v.addFilter(filter); } this.treeViewer = v; WorkbenchContentProvider contentProvider = new WorkbenchContentProvider(); ILabelProvider labelProvider = new WorkbenchLabelProvider(); this.treeViewer.setContentProvider(contentProvider); this.treeViewer.setLabelProvider(labelProvider); this.treeViewer.setComparator(new ViewerComparator()); this.treeViewer.setAutoExpandLevel(this.getAutoExpandLevel()); form.setElementLabel(this.elementLabel); this.elementNameInput = form.getElementInput(); form.getElementInput().addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(SuffixText.TEXT_PROPERTY) || evt.getPropertyName().equals(SuffixText.SUFFIX_PROPERTY)) { validateElementInput(); elementInputChanged(); } } }); return form; }
Example 15
Source File: NewRemoteFolderWizardMainPage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Creates the UI part of the page. * * @param parent the parent of the created widgets */ public void createControl(Composite parent) { Composite composite = createComposite(parent, 1); // set F1 help PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CREATE_REMOTE_FOLDER_PAGE); Listener listener = new Listener() { public void handleEvent(Event event) { validateFields(); } }; // the text field for the parent folder createLabel(composite, Policy.bind("NewRemoteFolderWizardMainPage.selectParentUrl")); //$NON-NLS-1$ urlParentText = createTextField(composite); urlParentText.addListener(SWT.Selection, listener); urlParentText.addListener(SWT.Modify, listener); urlParentText.setEditable(false); // Create drill down. DrillDownComposite drillDown = new DrillDownComposite(composite, SWT.BORDER); GridData spec = new GridData(GridData.FILL_BOTH); spec.widthHint = LIST_WIDTH; spec.heightHint = LIST_HEIGHT; drillDown.setLayoutData(spec); // Create tree viewer inside drill down. viewer = new TreeViewer(drillDown, SWT.H_SCROLL | SWT.V_SCROLL); drillDown.setChildTree(viewer); viewer.setLabelProvider(new WorkbenchLabelProvider()); RemoteContentProvider remoteContentProvider = new RemoteContentProvider(); remoteContentProvider.setUseDeferredContentManager(false); viewer.setContentProvider(remoteContentProvider); viewer.setInput(new AllRootsElement()); viewer.addFilter(RepositoryFilters.FOLDERS_ONLY); viewer.addSelectionChangedListener(treeSelectionChangedListener); // the text field for the folder name createLabel(composite, Policy.bind("NewRemoteFolderWizardMainPage.folderName")); //$NON-NLS-1$ folderNameText = createTextField(composite); folderNameText.addListener(SWT.Selection, listener); folderNameText.addListener(SWT.Modify, listener); validateFields(); folderNameText.setFocus(); setControl(composite); // set the initial selection in the tree if (parentFolder != null) { List itemsToExpand = new ArrayList(); ISVNRemoteFolder remoteParent = parentFolder.getParent(); while (remoteParent != null) { if (remoteParent.getParent() == null) itemsToExpand.add(0, remoteParent.getRepository()); else itemsToExpand.add(0, remoteParent); remoteParent = remoteParent.getParent(); } viewer.setExpandedElements(itemsToExpand.toArray()); if (parentFolder.getParent() == null) viewer.setSelection(new StructuredSelection(parentFolder.getRepository()), true); else viewer.setSelection(new StructuredSelection(parentFolder), true); } }
Example 16
Source File: MoveRemoteResourceWizardMainPage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Creates the UI part of the page. * * @param parent the parent of the created widgets */ public void createControl(Composite parent) { Composite composite = createComposite(parent, 1); // set F1 help PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.MOVE_RENAME_REMOTE_RESOURCE_PAGE); Listener listener = new Listener() { public void handleEvent(Event event) { resourceName = resourceNameText.getText(); validateFields(); } }; // the text field for the parent folder createLabel(composite, Policy.bind("MoveRemoteResourceWizardMainPage.selectParentUrl")); //$NON-NLS-1$ urlParentText = createTextField(composite); urlParentText.addListener(SWT.Selection, listener); urlParentText.addListener(SWT.Modify, listener); urlParentText.setEditable(false); // Create drill down. DrillDownComposite drillDown = new DrillDownComposite(composite, SWT.BORDER); GridData spec = new GridData(GridData.FILL_BOTH); spec.widthHint = LIST_WIDTH; spec.heightHint = LIST_HEIGHT; drillDown.setLayoutData(spec); // Create tree viewer inside drill down. viewer = new TreeViewer(drillDown, SWT.H_SCROLL | SWT.V_SCROLL); drillDown.setChildTree(viewer); viewer.setLabelProvider(new WorkbenchLabelProvider()); viewer.setContentProvider(new RemoteContentProvider()); viewer.setInput(new AllRootsElement()); viewer.addFilter(RepositoryFilters.FOLDERS_ONLY); viewer.addSelectionChangedListener(treeSelectionChangedListener); // the text field for the resource name createLabel(composite, Policy.bind("MoveRemoteResourceWizardMainPage.resourceName")); //$NON-NLS-1$ resourceNameText = createTextField(composite); resourceNameText.addListener(SWT.Selection, listener); resourceNameText.addListener(SWT.Modify, listener); resourceNameText.setText(resourceName); validateFields(); resourceNameText.setFocus(); setControl(composite); // set the initial selection in the tree if (parentFolder != null) { Object toSelect = null; if (parentFolder.getParent() == null) { // the root folder : select the repository toSelect = parentFolder.getRepository(); } else toSelect = parentFolder; viewer.expandToLevel(toSelect,0); viewer.setSelection(new StructuredSelection(toSelect),true); } }
Example 17
Source File: AbstractWorkingSetWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void createTree(Composite parent) { Label label= new Label(parent, SWT.NONE); label.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false)); label.setText(WorkingSetMessages.JavaWorkingSetPage_workspace_content); fTree= new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); fTree.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); fTree.addFilter(new AddedElementsFilter()); fTree.setUseHashlookup(true); configureTree(fTree); fTreeContentProvider= (ITreeContentProvider) fTree.getContentProvider(); }
Example 18
Source File: CheckoutWizardSelectionPage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public void createControl(Composite parent) { Composite outerContainer = new Composite(parent,SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1; outerContainer.setLayout(layout); outerContainer.setLayoutData( new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); treeViewer = new TreeViewer(outerContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER); RepositoryContentProvider contentProvider = new RepositoryContentProvider(); treeViewer.setContentProvider(contentProvider); treeViewer.addFilter(RepositoryFilters.FOLDERS_ONLY); treeViewer.setLabelProvider(new WorkbenchLabelProvider()); treeViewer.setInput(repositoryLocation); GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL); data.heightHint = LIST_HEIGHT_HINT; data.widthHint = LIST_WIDTH_HINT; treeViewer.getControl().setLayoutData(data); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { CheckoutWizard wizard = (CheckoutWizard)getWizard(); ArrayList folderArray = new ArrayList(); IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection(); Iterator iter = selection.iterator(); while (iter.hasNext()) { Object object = iter.next(); if (object instanceof ISVNRemoteFolder || object instanceof ISVNRepositoryLocation) { if (object instanceof ISVNRepositoryLocation) folderArray.add(((ISVNRepositoryLocation)object).getRootFolder()); else folderArray.add(object); } } ISVNRemoteFolder[] remoteFolders = new ISVNRemoteFolder[folderArray.size()]; folderArray.toArray(remoteFolders); wizard.setRemoteFolders(remoteFolders); setPageComplete(!treeViewer.getSelection().isEmpty()); } }); final Action refreshAction = new Action(Policy.bind("RepositoriesView.refreshPopup"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_REFRESH)) { //$NON-NLS-1$ public void run() { refreshViewerNode(); } }; MenuManager menuMgr = new MenuManager(); Tree tree = treeViewer.getTree(); Menu menu = menuMgr.createContextMenu(tree); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { manager.add(refreshAction); } }); menuMgr.setRemoveAllWhenShown(true); tree.setMenu(menu); setMessage(Policy.bind("CheckoutWizardSelectionPage.text")); //$NON-NLS-1$ setControl(outerContainer); }
Example 19
Source File: TexOutlinePage.java From texlipse with Eclipse Public License 1.0 | 4 votes |
/** * Creates the control ie. creates all the stuff that matters and * is visible in the outline. * * Actions must be created before menus and toolbars. * * @param parent */ public void createControl(Composite parent) { super.createControl(parent); // create the context actions createActions(); // initialize the tree viewer TreeViewer viewer = getTreeViewer(); filter = new TexOutlineFilter(); viewer.setContentProvider(new TexContentProvider(filter)); viewer.setLabelProvider(new TexLabelProvider()); viewer.setComparer(new TexOutlineNodeComparer()); // get and apply the preferences this.getOutlinePreferences(); viewer.addFilter(filter); // set the selection listener viewer.addSelectionChangedListener(this); // enable drag'n'drop support TexOutlineDNDAdapter dndAdapter = new TexOutlineDNDAdapter(viewer, this); int ops = DND.DROP_COPY | DND.DROP_MOVE; Transfer[] transfers = new Transfer[] {TextTransfer.getInstance()}; viewer.addDragSupport(ops, transfers, dndAdapter); viewer.addDropSupport(ops, transfers, dndAdapter); // enable copy-paste initCopyPaste(viewer); // create the menu bar and the context menu createToolbar(); resetToolbarButtons(); createContextMenu(); // finally set the input if (this.input != null) { viewer.setInput(this.input.getRootNodes()); // set update button status and also the context actions outlineActions.get(ACTION_UPDATE).setEnabled(false); outlineActions.get(ACTION_COPY).setEnabled(true); outlineActions.get(ACTION_CUT).setEnabled(true); outlineActions.get(ACTION_PASTE).setEnabled(true); outlineActions.get(ACTION_DELETE).setEnabled(true); } }