List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer
public TreeViewer(Composite parent, int style)
From source file:com.google.dart.tools.internal.search.ui.SearchMatchPage.java
License:Open Source License
@Override public void createControl(Composite parent) { initFilters();//w w w . jav a2 s . co m viewer = new TreeViewer(parent, SWT.FULL_SELECTION); viewer.setContentProvider(CONTENT_PROVIDER); // NB(scheglov): don't attempt to share label provider - it is not allowed in JFace viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new SearchLabelProvider())); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); openSelectedElement(selection); } }); // update colors preferences = DartToolsPlugin.getDefault().getCombinedPreferenceStore(); preferences.addPropertyChangeListener(propertyChangeListener); updateColors(); SWTUtil.bindJFaceResourcesFontToControl(viewer.getControl()); }
From source file:com.google.dart.tools.internal.search.ui.SearchResultPage_NEW.java
License:Open Source License
@Override public void createControl(Composite parent) { initFilters();//from w ww. java2 s. co m viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.MULTI); viewer.setContentProvider(CONTENT_PROVIDER); // NB(scheglov): don't attempt to share label provider - it is not allowed in JFace viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new SearchLabelProvider())); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); openSelectedElement(selection); } }); // update colors preferences = DartToolsPlugin.getDefault().getCombinedPreferenceStore(); preferences.addPropertyChangeListener(propertyChangeListener); updateColors(); SWTUtil.bindJFaceResourcesFontToControl(viewer.getControl()); }
From source file:com.google.dart.tools.search.internal.ui.SearchMatchPage.java
License:Open Source License
@Override public void createControl(Composite parent) { viewer = new TreeViewer(parent, SWT.FULL_SELECTION); viewer.setContentProvider(CONTENT_PROVIDER); viewer.setLabelProvider(LABEL_PROVIDER); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override//from ww w . jav a2s. c o m public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); openSelectedElement(selection); } }); SearchView.updateColors(viewer.getControl()); SWTUtil.bindJFaceResourcesFontToControl(viewer.getControl()); }
From source file:com.google.dart.tools.search.ui.text.AbstractTextSearchViewPage.java
License:Open Source License
/** * Creates the tree viewer to be shown on this page. Clients may override this method. * /*from w ww. j a v a 2 s . com*/ * @param parent the parent widget * @return returns a newly created <code>TreeViewer</code>. */ protected TreeViewer createTreeViewer(Composite parent) { return new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); }
From source file:com.google.dart.tools.ui.internal.testing.DartUnitViewPage.java
License:Open Source License
@Override public void createControl(Composite parent) { treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); treeViewer.setAutoExpandLevel(2);// w w w . j a va2 s . c o m if (project != null) { treeViewer.setLabelProvider(new WorkbenchLabelProvider()); treeViewer.setContentProvider(new TestsContentProvider(project)); treeViewer.setComparator(new ViewerComparator(String.CASE_INSENSITIVE_ORDER)); treeViewer.setInput(project); } }
From source file:com.google.dart.tools.ui.internal.typehierarchy.TypeHierarchyViewPart.java
License:Open Source License
private Control createTypeViewerControl(Composite parent) { typesViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); Tree tree = typesViewer.getTree();/*from w ww . j ava 2 s .co m*/ typesViewer.setContentProvider(new TypeHierarchyContentProvider()); typesViewer.setLabelProvider(new HierarchyLabelProvider(Predicates.alwaysFalse())); // register "viewer" as selection provide for this view IViewSite site = getViewSite(); site.setSelectionProvider(typesViewer); // configure actions actionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenViewActionGroup(site), new RefactorActionGroup(site), new DartSearchActionGroup(site) }); // configure actions { IActionBars actionBars = site.getActionBars(); actionGroups.fillActionBars(actionBars); } // prepare context menu MenuManager manager = new MenuManager(); manager.setRemoveAllWhenShown(true); manager.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager m) { contextMenuAboutToShow(m); } }); contextMenu = manager.createContextMenu(tree); tree.setMenu(contextMenu); typesViewer.addPostSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object selectedElement = structuredSelection.getFirstElement(); methodsViewer.setInputType(selectedElement); } } }); typesViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { fOpenAction.run((IStructuredSelection) selection); } } }); return tree; }
From source file:com.google.devtools.depan.eclipse.ui.nodes.viewers.GraphNodeViewer.java
License:Apache License
/** * Can be overridden to provide a customized tree viewer. * For example, the derived type {@link CheckNodeTreeView} * uses a {@code CheckboxTreeViewer}.//from w w w. j a v a2s . c om */ protected TreeViewer createTreeViewer(Composite parent) { int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL; TreeViewer result = new TreeViewer(parent, style); result.setLabelProvider(new WorkbenchLabelProvider()); result.setContentProvider(new BaseWorkbenchContentProvider()); result.setComparator(SORTER); setupHierarchyMenu(result); return result; }
From source file:com.google.devtools.depan.platform.eclipse.ui.widgets.Binop.java
License:Apache License
public Binop(Composite parent, int style, WorkbenchPart part, TCreator<T> creator) { super(parent, style); this.creator = creator; int numColumns = 2; GridLayout g = new GridLayout(); g.numColumns = numColumns;//from ww w . j a v a2 s.c o m g.makeColumnsEqualWidth = false; this.setLayout(g); // {{{ // buttons Composite buttons = new Composite(this, SWT.NONE); GridLayout buttonsLayout = new GridLayout(); buttons.setLayout(buttonsLayout); buttons.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true)); Button and = new Button(buttons, SWT.PUSH); and.setText("AND"); and.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); and.setImage(PlatformResources.IMAGE_AND); and.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { newTree(Operators.AND); } @Override public void widgetSelected(SelectionEvent e) { newTree(Operators.AND); } }); Button or = new Button(buttons, SWT.PUSH); or.setText("OR"); or.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); or.setImage(PlatformResources.IMAGE_OR); or.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { newTree(Operators.OR); } @Override public void widgetSelected(SelectionEvent e) { newTree(Operators.OR); } }); Button xor = new Button(buttons, SWT.PUSH); xor.setText("XOR"); xor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); xor.setImage(PlatformResources.IMAGE_XOR); xor.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { newTree(Operators.XOR); } @Override public void widgetSelected(SelectionEvent e) { newTree(Operators.XOR); } }); Button not = new Button(buttons, SWT.PUSH); not.setText("NOT"); not.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); not.setImage(PlatformResources.IMAGE_NOT); not.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { newTree(Operators.NOT); } @Override public void widgetSelected(SelectionEvent e) { newTree(Operators.NOT); } }); Button delete = new Button(buttons, SWT.PUSH); delete.setText("Delete tree"); delete.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); delete.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void widgetSelected(SelectionEvent e) { Object o = ((ITreeSelection) treeViewer.getSelection()).getFirstElement(); if (null != o && o instanceof Tree) { deleteTree((Tree) o); } } }); // }}} // {{{ Composite editor = new Composite(this, SWT.NONE); GridLayout g2 = new GridLayout(); editor.setLayout(g2); editor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 5)); expression = new Text(editor, SWT.BORDER | SWT.MULTI); expression.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); treeViewer = new TreeViewer(editor, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); treeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); part.getSite().setSelectionProvider(treeViewer); Platform.getAdapterManager().registerAdapters(this, Tree.class); treeViewer.setLabelProvider(new WorkbenchLabelProvider()); treeViewer.setContentProvider(new BaseWorkbenchContentProvider()); treeViewer.setInput(rootTree); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override @SuppressWarnings("unchecked") public void selectionChanged(SelectionChangedEvent event) { Object o = ((ITreeSelection) treeViewer.getSelection()).getFirstElement(); if (null != o && o instanceof Tree) { selectedTree = (Tree<T>) o; } } }); // }}} Button createView = new Button(this, SWT.PUSH); createView.setText("Create View"); createView.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, numColumns, 1)); createView.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { apply(); } @Override public void widgetSelected(SelectionEvent e) { apply(); } }); }
From source file:com.google.devtools.depan.resource_doc.eclipse.ui.widgets.ProjectResourceControl.java
License:Apache License
protected DrillDownComposite setupContainerControl(Composite parent) { DrillDownComposite result = new DrillDownComposite(parent, SWT.BORDER); containerViewer = new TreeViewer(result, SWT.NONE); result.setChildTree(containerViewer); containerViewer.setContentProvider(new WorkbenchContentProvider()); containerViewer.setLabelProvider(new WorkbenchLabelProvider()); containerViewer.setComparator(new ViewerComparator()); containerViewer.setUseHashlookup(true); containerViewer.setInput(prepareInput()); return result; }
From source file:com.google.eclipse.javascript.jstestdriver.ui.view.TestResultsPanel.java
License:Apache License
public TestResultsPanel(final IWorkbenchPage workbenchPage, Composite parent, int style) { super(parent, style); testCaseOpener = new TestCaseOpener(ServiceLocator.getService(LoadedSourceFileLibrary.class)); IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager(); MessageConsole messageConsole = new MessageConsole("JSTestDriver", null); messageConsole.activate();/*from w w w. j a va2 s . c om*/ messageConsoleStream = new MessageConsoleStream(messageConsole); consoleManager.addConsoles(new IConsole[] { messageConsole }); setLayout(new GridLayout(3, true)); GridData layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.verticalAlignment = SWT.FILL; layoutData.horizontalAlignment = SWT.FILL; setLayoutData(layoutData); testRunResult = new EclipseJstdTestRunResult(); GridData totalRunLabelData = new GridData(); totalRunLabelData.grabExcessHorizontalSpace = true; totalRunLabelData.horizontalAlignment = SWT.FILL; totalRunLabel = new Label(this, SWT.CENTER); totalRunLabel.setText("Run : 0 / 0"); totalRunLabel.setLayoutData(totalRunLabelData); GridData otherLabelData = new GridData(); otherLabelData.horizontalAlignment = SWT.FILL; errorsLabel = new Label(this, SWT.CENTER); errorsLabel.setText("Errors : 0"); errorsLabel.setLayoutData(otherLabelData); failuresLabel = new Label(this, SWT.CENTER); failuresLabel.setText("Failed : 0"); failuresLabel.setLayoutData(otherLabelData); GridData progressIndicatorData = new GridData(); progressIndicatorData.horizontalSpan = 4; progressIndicatorData.horizontalAlignment = SWT.FILL; progressIndicatorData.verticalAlignment = SWT.FILL; progressIndicatorData.heightHint = 20; progressIndicatorData.minimumWidth = 180; testProgressIndicator = new TestResultProgressBar(this, SWT.NONE); testProgressIndicator.setLayoutData(progressIndicatorData); SashForm resultsSashForm = new SashForm(this, SWT.VERTICAL); GridData sashFormData = new GridData(); sashFormData.horizontalSpan = 3; sashFormData.horizontalAlignment = SWT.FILL; sashFormData.grabExcessHorizontalSpace = true; sashFormData.grabExcessVerticalSpace = true; sashFormData.heightHint = 340; sashFormData.verticalAlignment = SWT.FILL; resultsSashForm.setLayoutData(sashFormData); testResultsTree = new TreeViewer(resultsSashForm, SWT.NONE); testResultsTree.getTree().setLayoutData(sashFormData); testResultsTree.setLabelProvider(new TestResultsTreeLabelProvider()); testResultsTree.setContentProvider(new TestResultsTreeContentProvider()); testResultsTree.setInput(testRunResult); testResultsTree.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { testDetailsText.setText(""); TreeSelection selection = (TreeSelection) event.getSelection(); currentSelection = selection.getFirstElement(); if (currentSelection instanceof EclipseJstdTestResult) { EclipseJstdTestResult result = (EclipseJstdTestResult) currentSelection; StringBuilder details = new StringBuilder(); result.writeDetails(details); testDetailsText.setText(details.toString()); } } }); testResultsTree.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { if (currentSelection instanceof EclipseJstdTestResult) { EclipseJstdTestResult selected = (EclipseJstdTestResult) currentSelection; IProject project = null; try { String projectName = lastLaunchConfiguration .getAttribute(LaunchConfigurationConstants.PROJECT_NAME, ""); project = new ProjectHelper().getProject(projectName); } catch (CoreException e) { logger.log(Level.WARNING, "Could not read project name from launch configuration.", e); } testCaseOpener.openTestSource(project, selected.getResult(), workbenchPage); return; } } }); GridData testDetailsData = new GridData(); testDetailsData.horizontalSpan = 3; testDetailsData.grabExcessHorizontalSpace = true; testDetailsData.heightHint = 100; testDetailsData.verticalAlignment = SWT.FILL; testDetailsData.horizontalAlignment = SWT.FILL; testDetailsText = new Text(resultsSashForm, SWT.MULTI | SWT.WRAP); testDetailsText.setLayoutData(testDetailsData); }