List of usage examples for org.eclipse.jface.viewers AbstractTreeViewer ALL_LEVELS
int ALL_LEVELS
To view the source code for org.eclipse.jface.viewers AbstractTreeViewer ALL_LEVELS.
Click Source Link
From source file:fr.sanofi.fcl4transmart.model.classes.workUI.geneExpression.LoadDataUI.java
License:Open Source License
@Override public Composite createUI(Composite parent) { this.display = WorkPart.display(); Shell shell = new Shell(this.display); shell.setSize(50, 100);//from w w w . j a va2 s .c o m GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; shell.setLayout(gridLayout); ProgressBar pb = new ProgressBar(shell, SWT.HORIZONTAL | SWT.INDETERMINATE); pb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label searching = new Label(shell, SWT.NONE); searching.setText("Searching..."); shell.open(); this.isSearching = true; new Thread() { public void run() { testTm_cz = RetrieveData.testTm_czConnection(); testTm_lz = RetrieveData.testTm_lzConnection(); testDeapp = RetrieveData.testDeappConnection(); root = new TreeNode("Dataset explorer", null, false); studyTree = new StudyTree(root); topNodeController = new TopNodeController(root, dataType, studyTree); root = topNodeController.buildTree(); topNode = dataType.getStudy().getTopNode(); isSearching = false; } }.start(); this.display = WorkPart.display(); while (this.isSearching) { if (!display.readAndDispatch()) { display.sleep(); } } shell.close(); Composite composite = new Composite(parent, SWT.NONE); GridLayout gd = new GridLayout(); gd.numColumns = 1; gd.horizontalSpacing = 0; gd.verticalSpacing = 0; composite.setLayout(gd); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); ScrolledComposite scroller = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); scroller.setLayoutData(new GridData(GridData.FILL_BOTH)); gd = new GridLayout(); gd.numColumns = 1; gd.horizontalSpacing = 0; gd.verticalSpacing = 0; scroller.setLayout(gd); scroller.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite scrolledComposite = new Composite(scroller, SWT.NONE); scroller.setContent(scrolledComposite); GridLayout layout = new GridLayout(); layout.numColumns = 1; scrolledComposite.setLayout(layout); scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); this.topNode = this.dataType.getStudy().getTopNode(); if (topNode != null && topNode.compareTo("") != 0) { viewer = new TreeViewer(scrolledComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(new StudyContentProvider()); viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); viewer.setInput(this.studyTree); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalAlignment = SWT.FILL; gridData.verticalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.heightHint = 300; gridData.widthHint = 250; this.viewer.getControl().setLayoutData(gridData); viewer.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return element.toString(); } @Override public Color getBackground(Object element) { if (((TreeNode) element).isStudyRoot()) { return new Color(Display.getCurrent(), 237, 91, 67); } if (((TreeNode) element).isLabel()) { return new Color(Display.getCurrent(), 212, 212, 212); } return null; } }); } else { Label label = new Label(scrolledComposite, SWT.NONE); label.setText("Please first choose a study node in the description data type"); } Button button = new Button(scrolledComposite, SWT.PUSH); button.setText("Load"); if (topNode != null && topNode.compareTo("") != 0) { if (this.testTm_cz && this.testTm_lz && this.testDeapp) { button.addListener(SWT.Selection, new LoadGeneExpressionDataListener(this, this.dataType)); Label dbLabel = new Label(scrolledComposite, SWT.NONE); dbLabel.setText("You are connected to database '" + PreferencesHandler.getDb() + "'"); } else { button.setEnabled(false); Label warn = new Label(scrolledComposite, SWT.NONE); warn.setText("Warning: connection to database is not possible"); } } else { button.setEnabled(false); } scrolledComposite.setSize(scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); return composite; }
From source file:fr.sanofi.fcl4transmart.model.classes.workUI.geneExpression.SetStudyTreeUI.java
License:Open Source License
@Override public Composite createUI(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout gd = new GridLayout(); gd.numColumns = 1;/*from ww w . j a v a 2 s . c o m*/ gd.horizontalSpacing = 0; gd.verticalSpacing = 0; composite.setLayout(gd); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); ScrolledComposite scroller = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); scroller.setLayoutData(new GridData(GridData.FILL_BOTH)); gd = new GridLayout(); gd.numColumns = 1; gd.horizontalSpacing = 0; gd.verticalSpacing = 0; scroller.setLayout(gd); scroller.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite scrolledComposite = new Composite(scroller, SWT.NONE); scroller.setContent(scrolledComposite); GridLayout layout = new GridLayout(); layout.numColumns = 1; scrolledComposite.setLayout(layout); scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite body = new Composite(scrolledComposite, SWT.NONE); body.setLayoutData(new GridData(GridData.FILL_BOTH)); gd = new GridLayout(); gd.numColumns = 2; gd.horizontalSpacing = 5; gd.verticalSpacing = 5; body.setLayout(gd); this.root = new TreeNode(this.dataType.getStudy().toString(), null, false); this.initiate(); this.studyTree = new StudyTree(root); viewer = new TreeViewer(body, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(new StudyContentProvider()); viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); viewer.setInput(this.studyTree); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalAlignment = SWT.FILL; gridData.verticalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.heightHint = 300; gridData.widthHint = 250; this.viewer.getControl().setLayoutData(gridData); Composite leftPart = new Composite(body, SWT.NONE); gd = new GridLayout(); gd.numColumns = 2; gd.horizontalSpacing = 5; gd.verticalSpacing = 5; leftPart.setLayout(gd); gridData = new GridData(); leftPart.setLayoutData(new GridData()); Label newTextLabel = new Label(leftPart, SWT.NONE); newTextLabel.setText("Free text"); newTextLabel.setLayoutData(new GridData()); this.newTextField = new Text(leftPart, SWT.BORDER); gridData = new GridData(); gridData.widthHint = 100; this.newTextField.setLayoutData(gridData); Button addText = new Button(leftPart, SWT.PUSH); addText.setText("Add free text"); addText.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { // TODO Auto-generated method stub IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); TreeNode node; if (selection.iterator().hasNext()) { node = (TreeNode) selection.iterator().next(); } else { displayMessage("Select a node first"); return; } if (node.hasChildren()) { displayMessage("A node can only have one child"); return; } if (newTextField.getText().compareTo("") == 0) { displayMessage("Choose a node name first"); return; } node.addChild(new TreeNode(newTextField.getText(), node, false)); viewer.setExpandedState(node, true); viewer.refresh(); } }); @SuppressWarnings("unused") Label space = new Label(leftPart, SWT.NONE); Label newLabelLabel = new Label(leftPart, SWT.NONE); newLabelLabel.setText("Choose property"); gridData = new GridData(); gridData.horizontalAlignment = SWT.FILL; gridData.verticalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; newLabelLabel.setLayoutData(new GridData(GridData.FILL_BOTH)); this.newLabelField = new Combo(leftPart, SWT.DROP_DOWN | SWT.BORDER | SWT.WRAP); this.newLabelField.addListener(SWT.KeyDown, new Listener() { public void handleEvent(Event event) { event.doit = false; } }); gridData = new GridData(); gridData.widthHint = 100; this.newLabelField.setLayoutData(gridData); //add the different properties this.newLabelField.add("subject_id"); this.newLabelField.add("site_id"); this.newLabelField.add("SAMPLE_ID"); this.newLabelField.add("PLATFORM"); this.newLabelField.add("TISSUETYPE"); this.newLabelField.add("ATTR1"); this.newLabelField.add("ATTR2"); Button addChild = new Button(leftPart, SWT.PUSH); addChild.setText("Add property"); addChild.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { // TODO Auto-generated method stub IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); TreeNode node; if (selection.iterator().hasNext()) { node = (TreeNode) selection.iterator().next(); } else { displayMessage("Select a node first"); return; } if (node.hasChildren()) { displayMessage("A node can only have one child"); return; } if (newLabelField.getText().compareTo("") == 0) { displayMessage("Choose a property first"); return; } node.addChild(new TreeNode(newLabelField.getText(), node, false)); viewer.setExpandedState(node, true); viewer.refresh(); } }); @SuppressWarnings("unused") Label space2 = new Label(leftPart, SWT.NONE); Button remove = new Button(leftPart, SWT.PUSH); remove.setText("Remove a node"); remove.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); TreeNode node; if (selection.iterator().hasNext()) { node = (TreeNode) selection.iterator().next(); } else { displayMessage("Select a node first"); return; } if (node.getParent() == null) { displayMessage("Root can not be removed"); return; } node.getParent().removeChild(node); viewer.refresh(); } }); Button ok = new Button(scrolledComposite, SWT.PUSH); ok.setText("OK"); ok.addListener(SWT.Selection, new SetStudyTreeListener(this, this.dataType)); scrolledComposite.setSize(scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); return composite; }
From source file:fr.sanofi.fcl4transmart.model.classes.workUI.HDData.SetStudyTreeUI.java
License:Open Source License
@Override public Composite createUI(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout gd = new GridLayout(); gd.numColumns = 1;//ww w . j ava2 s . c o m gd.horizontalSpacing = 0; gd.verticalSpacing = 0; composite.setLayout(gd); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); ScrolledComposite scroller = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); scroller.setLayoutData(new GridData(GridData.FILL_BOTH)); gd = new GridLayout(); gd.numColumns = 1; gd.horizontalSpacing = 0; gd.verticalSpacing = 0; scroller.setLayout(gd); scroller.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite scrolledComposite = new Composite(scroller, SWT.NONE); scroller.setContent(scrolledComposite); GridLayout layout = new GridLayout(); layout.numColumns = 1; scrolledComposite.setLayout(layout); scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite body = new Composite(scrolledComposite, SWT.NONE); body.setLayoutData(new GridData(GridData.FILL_BOTH)); gd = new GridLayout(); gd.numColumns = 2; gd.horizontalSpacing = 5; gd.verticalSpacing = 5; body.setLayout(gd); this.root = new TreeNode(this.dataType.getStudy().toString(), null, false); this.initiate(); this.studyTree = new StudyTree(root); viewer = new TreeViewer(body, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(new StudyContentProvider()); viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); viewer.setInput(this.studyTree); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalAlignment = SWT.FILL; gridData.verticalAlignment = SWT.FILL; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.heightHint = 300; gridData.widthHint = 250; this.viewer.getControl().setLayoutData(gridData); Composite leftPart = new Composite(body, SWT.NONE); gd = new GridLayout(); gd.numColumns = 1; gd.horizontalSpacing = 5; gd.verticalSpacing = 10; leftPart.setLayout(gd); leftPart.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite freeTextPart = new Composite(leftPart, SWT.NONE); gd = new GridLayout(); gd.numColumns = 2; gd.horizontalSpacing = 5; gd.verticalSpacing = 5; freeTextPart.setLayout(gd); Label newTextLabel = new Label(freeTextPart, SWT.NONE); newTextLabel.setText("Free text"); newTextLabel.setLayoutData(new GridData()); gridData = new GridData(); gridData.widthHint = 120; newTextLabel.setLayoutData(gridData); this.newTextField = new Text(freeTextPart, SWT.BORDER); gridData = new GridData(); gridData.widthHint = 110; this.newTextField.setLayoutData(gridData); Button addText = new Button(freeTextPart, SWT.PUSH); addText.setText("Add free text"); addText.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); TreeNode node; if (selection.iterator().hasNext()) { node = (TreeNode) selection.iterator().next(); } else { displayMessage("Select a node first"); return; } if (node.hasChildren()) { displayMessage("A node can only have one child"); return; } if (newTextField.getText().compareTo("") == 0) { displayMessage("Choose a node name first"); return; } node.addChild(new TreeNode(newTextField.getText(), node, false)); viewer.setExpandedState(node, true); viewer.refresh(); } }); Composite propPart = new Composite(leftPart, SWT.NONE); gd = new GridLayout(); gd.numColumns = 2; gd.horizontalSpacing = 5; gd.verticalSpacing = 5; propPart.setLayout(gd); Label newLabelLabel = new Label(propPart, SWT.NONE); newLabelLabel.setText("Choose property"); gridData = new GridData(); gridData.widthHint = 120; newLabelLabel.setLayoutData(gridData); this.newLabelField = new Combo(propPart, SWT.DROP_DOWN | SWT.BORDER | SWT.WRAP); this.newLabelField.addListener(SWT.KeyDown, new Listener() { public void handleEvent(Event event) { event.doit = false; } }); //add the different properties this.newLabelField.add("PLATFORM"); this.newLabelField.add("TISSUETYPE"); this.newLabelField.add("ATTR1"); this.newLabelField.add("ATTR2"); gridData = new GridData(); gridData.widthHint = 100; this.newLabelField.setLayoutData(gridData); Button addChild = new Button(propPart, SWT.PUSH); addChild.setText("Add property"); addChild.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); TreeNode node; if (selection.iterator().hasNext()) { node = (TreeNode) selection.iterator().next(); } else { displayMessage("Select a node first"); return; } if (node.hasChildren()) { displayMessage("A node can only have one child"); return; } if (newLabelField.getText().compareTo("") == 0) { displayMessage("Choose a property first"); return; } node.addChild(new TreeNode(newLabelField.getText(), node, false)); viewer.setExpandedState(node, true); viewer.refresh(); } }); @SuppressWarnings("unused") Label space2 = new Label(leftPart, SWT.NONE); Button remove = new Button(leftPart, SWT.PUSH); remove.setText("Remove a node"); remove.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); TreeNode node; if (selection.iterator().hasNext()) { node = (TreeNode) selection.iterator().next(); } else { displayMessage("Select a node first"); return; } if (node.getParent() == null) { displayMessage("Root can not be removed"); return; } node.getParent().removeChild(node); viewer.refresh(); } }); Button ok = new Button(scrolledComposite, SWT.PUSH); ok.setText("OK"); ok.addListener(SWT.Selection, this.setTreeListener); scrolledComposite.setSize(scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); return composite; }
From source file:gov.nasa.ensemble.common.ui.view.page.TreeViewerPage.java
License:Open Source License
protected void applyExpandHeuristic(String key, String stringToMatch) { ITreeContentProvider cp = (ITreeContentProvider) treeViewer.getContentProvider(); final Object[] rootChildren = cp.getElements(null); if (rootChildren != null && rootChildren.length != 0) { if (rootChildren.length <= 25 && !CommonUtils.isNullOrEmpty(stringToMatch)) { for (Object object : rootChildren) { treeViewer.expandToLevel(object, AbstractTreeViewer.ALL_LEVELS); }/*w ww . ja va 2 s.c om*/ } else { treeViewer.collapseAll(); } } }
From source file:gov.redhawk.ui.editor.FormOutlinePage.java
License:Open Source License
/** * Creates the control.//w w w. j a va 2 s . c o m * * @param parent the parent */ @Override public void createControl(final Composite parent) { final Tree widget = new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); this.treeViewer = new TreeViewer(widget); this.treeViewer.addSelectionChangedListener(this); this.treeViewer.setContentProvider(createContentProvider()); this.treeViewer.setLabelProvider(createLabelProvider()); this.viewerComparator = createOutlineSorter(); if (this.sorted) { this.treeViewer.setComparator(this.viewerComparator); } else { this.treeViewer.setComparator(null); } this.treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); this.treeViewer.setUseHashlookup(true); this.treeViewer.setInput(this.fEditor.getEditingDomain().getResourceSet()); }
From source file:gov.redhawk.ui.views.monitor.ports.PortMonitorView.java
License:Open Source License
/** * @since 3.0/*w ww . ja va2 s. c o m*/ */ public void addMonitor(final ScaPortContainer portContainer) { PortSupplierMonitor monitor = findMonitor(portContainer); if (monitor == null) { monitor = PortsFactory.eINSTANCE.createPortSupplierMonitor(); monitor.setPortContainer(portContainer); this.input.getMonitors().add(monitor); } monitor.fetchStats(); this.viewer.reveal(monitor); this.viewer.expandToLevel(monitor, AbstractTreeViewer.ALL_LEVELS); }
From source file:gov.redhawk.ui.views.monitor.ports.PortMonitorView.java
License:Open Source License
public void addMonitor(final ScaPort<?, ?> port) { PortMonitor portMonitor = findMonitor(port); if (portMonitor == null) { portMonitor = PortsFactory.eINSTANCE.createPortMonitor(); portMonitor.setPort(port);//from ww w . j ava 2s .co m this.input.getMonitors().add(portMonitor); } portMonitor.fetchStats(); this.viewer.reveal(portMonitor); this.viewer.expandToLevel(portMonitor, AbstractTreeViewer.ALL_LEVELS); }
From source file:gradle4eclipse.actions.TreeDoubleClickAction.java
License:Open Source License
public void run() { ISelection selection = viewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); if (obj instanceof TreeObject && !(obj instanceof TreeParent)) RunCommand.getInstance().run(((TreeObject) obj).getRun(), true); if (viewer.getExpandedState(obj)) viewer.collapseToLevel(obj, AbstractTreeViewer.ALL_LEVELS); else/*w w w . ja va 2 s . co m*/ viewer.expandToLevel(obj, 1); }
From source file:io.usethesource.impulse.editor.OutlineInformationControl.java
License:Open Source License
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);//from w w w . j av a 2s. c om final TreeViewer treeViewer = new OutlineTreeViewer(tree); // Hard-coded filters fLexicalSortingAction = new LexicalSortingAction(treeViewer); // JJV: this code is broken: // if (fElementFilter != null) // treeViewer.addFilter(fElementFilter); fForegroundColor = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); // RMF 7/7/2006 - oops, fLanguage is still null at this point, b/c createTreeViewer() gets called from super ctor and field inits haven't happened yet... fLanguage = ((UniversalEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor()).getLanguage(); fOutlineContentProvider = new ModelTreeContentProvider(null); fOutlineContentProvider.setInfoControl(this); fLangLabelProvider = ServiceFactory.getInstance().getLabelProvider(fLanguage); fElemImageProvider = ServiceFactory.getInstance().getElementImageProvider(fLanguage); // JJV; commented out because untested // fElementFilter= (ViewerFilter) ExtensionPointFactory.createExtensionPoint(fLanguage, ILanguageService.VIEWER_FILTER_SERVICE); fInnerLabelProvider = new OutlineLabelProvider(fLangLabelProvider, fElemImageProvider, fOutlineContentProvider.fShowInheritedMembers, fShowStorage, fForegroundColor); fInnerLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(fLanguage)); // IDecoratorManager decoratorMgr= PlatformUI.getWorkbench().getDecoratorManager(); // if (decoratorMgr.getEnabled("org.eclipse.jdt.ui.override.decorator")) //$NON-NLS-1$ // fInnerLabelProvider.addLabelDecorator(new OverrideIndicatorLabelDecorator(null)); treeViewer.setLabelProvider(fInnerLabelProvider); treeViewer.addFilter(new NamePatternFilter()); // fSortByDefiningTypeAction= new SortByDefiningTypeAction(treeViewer); // fShowOnlyMainTypeAction= new ShowOnlyMainTypeAction(treeViewer); treeViewer.setContentProvider(fOutlineContentProvider); fOutlineSorter = new OutlineSorter(); treeViewer.setSorter(fOutlineSorter); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); treeViewer.getTree().addKeyListener(getKeyAdapter()); return treeViewer; }
From source file:msi.gama.lang.gaml.ui.editor.toolbar.GamlQuickOutlinePopup.java
@Override protected TreeViewer createTreeViewer(final Composite parent, final int style) { final TreeViewer viewer = super.createTreeViewer(parent, style); viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); return viewer; }