List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer
public TreeViewer(Tree tree)
From source file:com.reprezen.swagedit.core.editor.outline.QuickOutline.java
License:Open Source License
protected TreeViewer createTreeViewer(Composite parent) { final Tree tree = new Tree(parent, SWT.SINGLE); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = tree.getItemHeight(); tree.setLayoutData(gd);//from w ww .j av a2s . c o m final TreeViewer treeViewer = new TreeViewer(tree); treeViewer.setContentProvider(new OutlineContentProvider()); treeViewer.setLabelProvider(new OutlineStyledLabelProvider()); treeViewer.addFilter(new NamePatternFilter()); // Using ALL_LEVELS will cause editor to hang on large specs treeViewer.setAutoExpandLevel(2); treeViewer.setUseHashlookup(true); tree.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyPressed(KeyEvent e) { if (isInvocationEvent(e)) { e.doit = false; handleMultiView(); } else if (e.keyCode == SWT.CR) { handleSelection(); QuickOutline.this.close(); } } }); tree.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { super.mouseDown(e); } public void mouseUp(MouseEvent e) { if (tree.getSelectionCount() < 1) { return; } if (e.button != 1) { return; } if (tree.equals(e.getSource())) { Object o = tree.getItem(new Point(e.x, e.y)); TreeItem selection = tree.getSelection()[0]; if (selection.equals(o)) { handleSelection(); } } } }); tree.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { // do nothing } public void widgetDefaultSelected(SelectionEvent e) { handleSelection(); } }); return treeViewer; }
From source file:com.rohanclan.snippets.views.SnipTreeView.java
License:Open Source License
public void createPartControl(Composite parent) { //Create a grid layout object so the text and treeviewer GridLayout layout = new GridLayout(); layout.numColumns = 1;//from w w w . j a va2 s .c o m layout.verticalSpacing = 2; layout.marginWidth = 0; layout.marginHeight = 2; parent.setLayout(layout); //Create a "label" to display information in. I'm //using a text field instead of a lable so you can //copy-paste out of it. text = new Text(parent, SWT.READ_ONLY | SWT.SINGLE | SWT.BORDER); // layout the text field above the treeviewer GridData layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.horizontalAlignment = GridData.FILL; text.setLayoutData(layoutData); //Create the tree viewer as a child of the composite parent treeViewer = new TreeViewer(parent); treeViewer.setContentProvider(new SnipTreeViewContentProvider(getRootInput())); labelProvider = new SnipTreeViewLabelProvider(); treeViewer.setLabelProvider(labelProvider); treeViewer.setUseHashlookup(true); //layout the tree viewer below the text field layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; treeViewer.getControl().setLayoutData(layoutData); previewLabel = new Label(parent, SWT.WRAP); GridData gridData = new GridData(); gridData.horizontalSpan = 2; previewLabel.setLayoutData(gridData); previewLabel.setText("Preview "); preview = new Text(parent, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); // layout the text field above the treeviewer layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.heightHint = 100; layoutData.horizontalAlignment = GridData.FILL; preview.setLayoutData(layoutData); //Create menu, toolbars, filters createActions(); createMenus(); createToolbar(); createContextMenu(); hookListeners(); treeViewer.setInput(getRootInput()); //treeViewer.expandAll(); }
From source file:com.runwaysdk.manager.view.RelationshipTabBuilder.java
License:Open Source License
public void build(final IRelationshipStrategy command) { for (MdRelationshipDAOIF mdRelationship : command.getMdRelationships(mdBusiness)) { final String type = mdRelationship.definesType(); // Prepare Tree context menu: Edit relationship action // Create the CTabItem and the Tree Widget CTabItem item = new CTabItem(tabFolder, SWT.NONE); item.setText(mdRelationship.getDisplayLabel(Localizer.getLocale()) + " " + command.getTabPostfix()); item.setShowClose(false);/*w w w . j a v a 2 s.com*/ final TreeViewer viewer = new TreeViewer(tabFolder); viewer.setContentProvider(new RelationshipContentProvider(mdRelationship.definesType(), command)); viewer.setLabelProvider(new KeyLabelProvider()); viewer.setInput(input); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { new EditAction(Localizer.getMessage("EDIT"), viewer, module).run(); } }); // Add the Context menu to the Tree Widget MenuManager manager = new MenuManager(); viewer.getControl().setMenu(manager.createContextMenu(viewer.getControl())); manager.add(new EditRelationshipAction(Localizer.getMessage("EDIT_RELATIONSHIP"), viewer, command, type, module)); manager.add(new EditAction(Localizer.getMessage("EDIT"), viewer, module)); manager.add(new NewRelationshipCommand(Localizer.getMessage("ADD"), viewer, command, mdRelationship, module)); item.setControl(viewer.getControl()); } }
From source file:com.siteview.mde.internal.ui.commands.CommandList.java
License:Open Source License
private void createTree(Composite parent) { Composite c = fCCP.createComposite(parent, GridData.FILL_BOTH, 1, true, 5); Section section = fToolkit.createSection(c, ExpandableComposite.TITLE_BAR); section.setText(MDEUIMessages.CommandList_groupName); section.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite comp = fCCP.createComposite(section); ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); ToolBar toolbar = toolBarManager.createControl(section); final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); toolbar.setCursor(handCursor);//from ww w.java 2s .c o m toolBarManager.add(new CollapseAction() { public void run() { fTreeViewer.collapseAll(); } }); toolbar.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { handCursor.dispose(); } }); fToolkit.adapt(toolbar, true, true); toolbar.setBackground(null); section.setTextClient(toolbar); toolBarManager.update(true); createFilterText(comp); Tree tree = fToolkit.createTree(comp, SWT.V_SCROLL | SWT.H_SCROLL); tree.setLayout(new GridLayout()); GridData gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 200; tree.setLayoutData(gd); fTreeViewer = new TreeViewer(tree); fContentProvider = new CommandTreeContentProvider(fCCP.getCommandService()); fTreeViewer.setContentProvider(fContentProvider); fTreeViewer.setLabelProvider(new CommandTreeLabelProvider()); fTreeViewer.setComparator(new CommandTreeComparator()); fTreeViewer.addFilter(new WildcardFilter()); fTreeViewer.setInput(new Object()); fTreeViewer.addSelectionChangedListener(fCCP); section.setClient(comp); }
From source file:com.siteview.mde.internal.ui.editor.FormOutlinePage.java
License:Open Source License
public void createControl(Composite parent) { Tree widget = new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); fTreeViewer = new TreeViewer(widget); fTreeViewer.addSelectionChangedListener(this); fTreeViewer.setContentProvider(createContentProvider()); fTreeViewer.setLabelProvider(createLabelProvider()); fViewerComparator = createOutlineSorter(); if (fSorted)//from w w w .ja v a 2 s . c o m fTreeViewer.setComparator(fViewerComparator); else fTreeViewer.setComparator(null); fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); fTreeViewer.setUseHashlookup(true); fTreeViewer.setInput(fEditor); IBaseModel model = fEditor.getAggregateModel(); if (model instanceof IModelChangeProvider) ((IModelChangeProvider) model).addModelChangedListener(this); }
From source file:com.siteview.mde.internal.ui.editor.monitor.LoopDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*w w w. j av a 2 s . c o m*/ layout.marginWidth = layout.marginHeight = 9; container.setLayout(layout); GridData gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 300; gd.heightHint = 300; container.setLayoutData(gd); fLoopViewer = new TreeViewer(container); fLoopViewer.setContentProvider(new ContentProvider()); fLoopViewer.setLabelProvider(new LoopLabelProvider()); Tree tree = fLoopViewer.getTree(); gd = new GridData(GridData.FILL_BOTH); tree.setLayoutData(gd); fLoopViewer.setInput(MDEPlugin.getDefault()); fLoopViewer.expandAll(); getShell().setText(MDEUIMessages.LoopDialog_title); return container; }
From source file:com.siteview.mde.internal.ui.editor.outline.QuickOutlinePopupDialog.java
License:Open Source License
private void createUIWidgetTreeViewer(Composite parent) { // NOTE: Instructions to implement for PDE form pages: // Need to call PDEFormEditor.getFormOutline() // Specify PDE form editor as input // Need to adjust commandId="com.siteview.mde.ui.quickOutline" // scope: contextId="org.eclipse.ui.textEditorScope" // SEE org.eclipse.ui.contexts.window // TODO: MP: QO: LOW: Implement bi-directional support between form and source page for manifest 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);/*w w w. j a v a 2s. c o m*/ // Create the tree viewer fTreeViewer = new TreeViewer(widget); // Add the name pattern filter fNamePatternFilter = new QuickOutlineNamePatternFilter(); fTreeViewer.addFilter(fNamePatternFilter); // Set the content provider fTreeContentProvider = fOutlineContentCreator.createOutlineContentProvider(); fTreeViewer.setContentProvider(fTreeContentProvider); // Set the label provider fTreeLabelProvider = fOutlineContentCreator.createOutlineLabelProvider(); fTreeViewer.setLabelProvider(fTreeLabelProvider); // Create the outline sorter (to be set on the sort action) fTreeViewerComparator = fOutlineContentCreator.createOutlineComparator(); // Set the comparator to null (sort action will be disabled initially // because of this) // Create the default outline sorter (Most like this will just return // null to indicate sorting disabled fTreeViewerDefaultComparator = fOutlineContentCreator.createDefaultOutlineComparator(); fTreeViewer.setComparator(fTreeViewerDefaultComparator); fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); fTreeViewer.setUseHashlookup(true); fTreeViewer.setInput(fOutlineContentCreator.getOutlineInput()); }
From source file:com.siteview.mde.internal.ui.launcher.PluginStatusDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridData gd = new GridData(GridData.FILL_BOTH); gd.widthHint = 400;/*ww w .j ava 2 s.co m*/ gd.heightHint = 300; container.setLayoutData(gd); Label label = new Label(container, SWT.NONE); label.setText(MDEUIMessages.PluginStatusDialog_label); treeViewer = new TreeViewer(container); treeViewer.setContentProvider(new ContentProvider()); treeViewer.setLabelProvider(MDEPlugin.getDefault().getLabelProvider()); treeViewer.setComparator(new ViewerComparator()); treeViewer.setInput(fInput); treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); getShell().setText(MDEUIMessages.PluginStatusDialog_pluginValidation); Dialog.applyDialogFont(container); return container; }
From source file:com.siteview.mde.internal.ui.shared.target.TargetLocationsGroup.java
License:Open Source License
/** * Sets up the tree viewer using the given tree * @param tree// w ww . jav a 2s . co m */ private void initializeTreeViewer(Tree tree) { fTreeViewer = new TreeViewer(tree); fTreeViewer.setContentProvider(new BundleContainerContentProvider()); fTreeViewer.setLabelProvider(new StyledBundleLabelProvider(true, false)); fTreeViewer.setComparator(new ViewerComparator() { public int compare(Viewer viewer, Object e1, Object e2) { // Status at the end of the list if (e1 instanceof IStatus && !(e2 instanceof IStatus)) { return 1; } if (e2 instanceof IStatus && !(e1 instanceof IStatus)) { return -1; } return super.compare(viewer, e1, e2); } }); fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateButtons(); } }); fTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (!event.getSelection().isEmpty()) { handleEdit(); } } }); fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); }
From source file:com.siteview.mde.internal.ui.wizards.WizardTreeSelectionPage.java
License:Open Source License
public void createControl(Composite parent) { // top level group Composite container = new Composite(parent, SWT.NULL); FillLayout flayout = new FillLayout(); flayout.marginWidth = 5;// w ww .ja v a 2 s. c o m flayout.marginHeight = 5; container.setLayout(flayout); SashForm rootSash = new SashForm(container, SWT.VERTICAL); SashForm outerSash = new SashForm(rootSash, SWT.HORIZONTAL); GridLayout layout = new GridLayout(); layout.numColumns = 2; // tree pane Tree tree = new Tree(outerSash, SWT.BORDER); categoryTreeViewer = new TreeViewer(tree); categoryTreeViewer.setContentProvider(new TreeContentProvider()); categoryTreeViewer.setLabelProvider(ElementLabelProvider.INSTANCE); categoryTreeViewer.setComparator(new WizardCollectionComparator(baseCategory)); categoryTreeViewer.addSelectionChangedListener(this); // wizard actions pane Table table = new Table(outerSash, SWT.BORDER); new TableColumn(table, SWT.NONE); TableLayout tlayout = new TableLayout(); tlayout.addColumnData(new ColumnWeightData(100)); table.setLayout(tlayout); wizardSelectionViewer = new TableViewer(table); wizardSelectionViewer.setContentProvider(new ListContentProvider()); wizardSelectionViewer.setLabelProvider(ListUtil.TABLE_LABEL_PROVIDER); wizardSelectionViewer.setComparator(ListUtil.NAME_COMPARATOR); wizardSelectionViewer.addSelectionChangedListener(this); wizardSelectionViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { BusyIndicator.showWhile(wizardSelectionViewer.getControl().getDisplay(), new Runnable() { public void run() { selectionChanged(new SelectionChangedEvent(wizardSelectionViewer, wizardSelectionViewer.getSelection())); advanceToNextPage(); } }); } }); // the new composite below is needed in order to make the label span the two // defined columns of outerContainer Composite descriptionComposite = new Composite(rootSash, SWT.NONE); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; descriptionComposite.setLayout(layout); createDescriptionIn(descriptionComposite); initializeViewers(); rootSash.setWeights(new int[] { 70, 30 }); setControl(container); }