List of usage examples for org.eclipse.jface.viewers TreeViewer setAutoExpandLevel
public void setAutoExpandLevel(int level)
From source file:org.cs3.pdt.editor.internal.views.lightweightOutline.NonNaturePrologOutline.java
License:Open Source License
public void setInput(Object information) { if (model == null) { return;//from w w w.j a va2s . c o m } String fileName = editor.getPrologFileName(); Map<String, OutlineModuleElement> modules; TreeViewer treeViewer = getTreeViewer(); if (!fileName.isEmpty()) { Object[] expandedElements = null; try { modules = PDTOutlineQuery.getProgramElementsForFile(fileName); model.update(modules, fileName); expandedElements = treeViewer.getExpandedElements(); treeViewer.setInput(model); treeViewer.setAutoExpandLevel(EXPANDING_LEVEL); } catch (Exception e) { Debug.report(e); } if (treeViewer != null) { treeViewer.refresh(); if (expandedElements != null && expandedElements.length > 0) { treeViewer.setExpandedElements(expandedElements); } } } }
From source file:org.cs3.pdt.editor.internal.views.lightweightOutline.PrologOutlineInformationControl.java
License:Open Source License
/** * {@inheritDoc}// w ww . j a v a 2 s . c o m */ @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); treeViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { gotoSelectedElement(); } }); // Hard-coded filters treeViewer.addFilter(new NamePatternFilter(this, this.getMatcher())); fInnerLabelProvider = new OutlineLabelProvider(); treeViewer.setLabelProvider(fInnerLabelProvider); fLexicalSortingAction = new LexicalSortingAction(/*this,*/ treeViewer); fOutlineContentProvider = new OutlineContentProvider(); treeViewer.setContentProvider(fOutlineContentProvider); fOutlineSorter = new ViewerComparator(); treeViewer.setComparator(fOutlineSorter); treeViewer.setAutoExpandLevel(2); return treeViewer; }
From source file:org.cs3.pdt.internal.views.lightweightOutline.NonNaturePrologOutline.java
License:Open Source License
@Override public void createControl(Composite parent) { super.createControl(parent); TreeViewer viewer = getTreeViewer(); contentProvider = new OutlineContentProvider(); viewer.setContentProvider(contentProvider); labelProvider = new OutlineLabelProvider(); // labelProvider = new DecoratingLabelProvider(new OutlineLabelProvider(), // PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); viewer.setLabelProvider(labelProvider); // viewer.addSelectionChangedListener(this); viewer.addDoubleClickListener(this); viewer.getControl().addListener(SWT.Show, new Listener() { @Override//from ww w . jav a 2s . c o m public void handleEvent(Event event) { getSite().getShell().getDisplay().asyncExec(new Runnable() { @Override public void run() { setInput(null); } }); } }); model = new PrologSourceFileModel(new HashMap<String, OutlineModuleElement>()); viewer.setInput(model); viewer.setAutoExpandLevel(EXPANDING_LEVEL); IActionBars actionBars = getSite().getActionBars(); IToolBarManager toolBarManager = actionBars.getToolBarManager(); // Action action = new LexicalSortingAction(viewer); // toolBarManager.add(action); Action action = new ToggleSortAction(getTreeViewer()); toolBarManager.add(action); ToggleFilterAction action2 = new ToggleFilterAction("Hide private predicates", ImageRepository.getImageDescriptor(ImageRepository.PE_PROTECTED), ImageRepository.getImageDescriptor(ImageRepository.FILTER_PRIVATE), viewer, new HidePrivatePredicatesFilter(), PDTPlugin.getDefault().getPreferenceStore(), PDT.PREF_OUTLINE_FILTER_PRIVATE); toolBarManager.add(action2); ToggleFilterAction action3 = new ToggleFilterAction("Hide system predicates", ImageRepository.getImageDescriptor(ImageRepository.NO_FILTER_SYSTEM), ImageRepository.getImageDescriptor(ImageRepository.FILTER_SYSTEM), viewer, new HideSystemPredicatesFilter(), PDTPlugin.getDefault().getPreferenceStore(), PDT.PREF_OUTLINE_FILTER_SYSTEM); toolBarManager.add(action3); // action = new FilterActionMenu(this); // toolBarManager.add(action); hookContextMenu(parent); setInput(editor.getEditorInput()); PrologRuntimeUIPlugin.getDefault().getPrologInterfaceService().registerConsultListener(this); PrologRuntimeUIPlugin.getDefault().getPrologInterfaceService().registerActivePrologInterfaceListener(this); PDTCommonPlugin.getDefault().registerPifStartListener(this); }
From source file:org.ebayopensource.vjet.eclipse.internal.ui.typehierarchy.VjoHierarchyInformationControl.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 o m TreeViewer treeViewer = new TreeViewer(tree); treeViewer.addFilter(new ViewerFilter() { public boolean select(Viewer viewer, Object parentElement, Object element) { return element instanceof IType; } }); fLifeCycle = new TypeHierarchyLifeCycle(false); treeViewer.setSorter(new HierarchyViewerSorter(fLifeCycle)); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); fLabelProvider = new VjoHierarchyLabelProvider(fLifeCycle, getPreferenceStore()); fLabelProvider.setFilter(new ViewerFilter() { public boolean select(Viewer viewer, Object parentElement, Object element) { return hasFocusMethod((IType) element); } }); fLabelProvider.setTextFlags(ScriptElementLabels.ALL_DEFAULT | ScriptElementLabels.T_POST_QUALIFIED); fLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null)); treeViewer.setLabelProvider(fLabelProvider); treeViewer.getTree().addKeyListener(getKeyAdapter()); return treeViewer; }
From source file:org.eclipse.ajdt.internal.ui.editor.outline.AJOutlineInformationControl.java
License:Open Source License
/** * {@inheritDoc}//from w w w. j av a 2 s . c o m */ 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()); fForegroundColor = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); 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)); // AspectJ Change begin //treeViewer.setLabelProvider(fInnerLabelProvider); treeViewer.setLabelProvider(new DecoratingJavaLabelProvider(fInnerLabelProvider)); // AspectJ Change end fLexicalSortingAction = new LexicalSortingAction(treeViewer); fSortByDefiningTypeAction = new SortByDefiningTypeAction(treeViewer); fShowOnlyMainTypeAction = new ShowOnlyMainTypeAction(treeViewer); fOutlineContentProvider = new OutlineContentProvider(false); treeViewer.setContentProvider(fOutlineContentProvider); fOutlineSorter = new OutlineSorter(); treeViewer.setComparator(fOutlineSorter); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); treeViewer.getTree().addKeyListener(getKeyAdapter()); return treeViewer; }
From source file:org.eclipse.bpel.ui.dialogs.SchemaImportDialog.java
License:Open Source License
protected void createImportLocation(Composite parent) { fGroup = new Group(parent, SWT.SHADOW_ETCHED_IN); fGroup.setText(Messages.SchemaImportDialog_4); GridLayout layout = new GridLayout(1, true); GridData data = new GridData(); data.grabExcessVerticalSpace = false; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; fGroup.setLayout(layout);/*from w w w.j a va2s. co m*/ fGroup.setLayoutData(data); Composite container = new Composite(fGroup, SWT.NONE); layout = new GridLayout(); layout.makeColumnsEqualWidth = true; layout.numColumns = 4; container.setLayout(layout); data = new GridData(); data.grabExcessVerticalSpace = false; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.CENTER; container.setLayoutData(data); createRadioButton(container, Messages.SchemaImportDialog_5, BID_BROWSE_RESOURCE, KIND == BID_BROWSE_RESOURCE); createRadioButton(container, Messages.SchemaImportDialog_6, BID_BROWSE_FILE, KIND == BID_BROWSE_FILE); createRadioButton(container, Messages.SchemaImportDialog_7, BID_BROWSE_URL, KIND == BID_BROWSE_URL); // Add WSIL option fBtnWSIL = createRadioButton(container, Messages.SchemaImportDialog_15, BID_BROWSE_WSIL, KIND == BID_BROWSE_WSIL); // Create location variant fLocationComposite = new Composite(fGroup, SWT.NONE); layout = new GridLayout(); layout.numColumns = 3; fLocationComposite.setLayout(layout); data = new GridData(); data.grabExcessVerticalSpace = true; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; fLocationComposite.setLayoutData(data); Label location = new Label(fLocationComposite, SWT.NONE); location.setText(Messages.SchemaImportDialog_8); fLocation = new Text(fLocationComposite, SWT.BORDER); fLocation.setText(EMPTY); data = new GridData(); data.grabExcessVerticalSpace = false; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; fLocation.setLayoutData(data); fLocation.addListener(SWT.FocusOut, new Listener() { public void handleEvent(Event event) { String loc = fLocation.getText(); if (loc.length() > 0) { attemptLoad(loc); } } }); fLocation.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent event) { if (event.keyCode == SWT.CR) { attemptLoad(fLocation.getText()); event.doit = false; } } public void keyReleased(KeyEvent e) { return; } }); fBrowseButton = createButton(fLocationComposite, BID_BROWSE, Messages.SchemaImportDialog_9, false); // End of location variant // Start Resource Variant fResourceComposite = new FileSelectionGroup(fGroup, new Listener() { public void handleEvent(Event event) { IResource resource = fResourceComposite.getSelectedResource(); if (resource != null && resource.getType() == IResource.FILE) { // only attempt to load a resource which is not a container attemptLoad((IFile) resource); return; } markEmptySelection(); } }, Messages.SchemaImportDialog_10, IBPELUIConstants.EXTENSION_DOT_XSD + "," + IBPELUIConstants.EXTENSION_DOT_WSDL); //$NON-NLS-1$ TreeViewer viewer = fResourceComposite.getTreeViewer(); viewer.setAutoExpandLevel(2); // End resource variant // create WSIL UI widgets createWSILStructure(fGroup); }
From source file:org.eclipse.bpmn2.modeler.ui.property.dialogs.DefaultSchemaImportDialog.java
License:Open Source License
protected void createImportLocation(Composite parent) { fKindGroup = new Group(parent, SWT.SHADOW_ETCHED_IN); fKindGroup.setText(Messages.SchemaImportDialog_Import_Source_Title); GridLayout layout = new GridLayout(1, true); GridData data = new GridData(); data.grabExcessVerticalSpace = false; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; fKindGroup.setLayout(layout);//from www. ja v a 2s . c o m fKindGroup.setLayoutData(data); fKindButtonComposite = new Composite(fKindGroup, SWT.NONE); layout = new GridLayout(); layout.makeColumnsEqualWidth = true; layout.numColumns = 4; fKindButtonComposite.setLayout(layout); data = new GridData(); data.grabExcessVerticalSpace = false; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.CENTER; fKindButtonComposite.setLayoutData(data); fBtnResource = createRadioButton(fKindButtonComposite, Messages.SchemaImportDialog_Workspace_Button, BID_BROWSE_WORKSPACE, fImportSource == BID_BROWSE_WORKSPACE); createRadioButton(fKindButtonComposite, Messages.SchemaImportDialog_File_System_Button, BID_BROWSE_FILE, fImportSource == BID_BROWSE_FILE); createRadioButton(fKindButtonComposite, Messages.SchemaImportDialog_URL_Button, BID_BROWSE_URL, fImportSource == BID_BROWSE_URL); // Create location variant fLocationComposite = new Composite(fKindGroup, SWT.NONE); layout = new GridLayout(); layout.numColumns = 3; fLocationComposite.setLayout(layout); data = new GridData(); data.grabExcessVerticalSpace = true; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; fLocationComposite.setLayoutData(data); fLocationLabel = new Label(fLocationComposite, SWT.NONE); fLocationLabel.setText(Messages.SchemaImportDialog_Location_Label); fLocation = new Text(fLocationComposite, SWT.BORDER); fLocation.setText(EMPTY); data = new GridData(); data.grabExcessVerticalSpace = false; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; fLocation.setLayoutData(data); // fLocation.addListener(SWT.FocusOut, new Listener() { // // public void handleEvent(Event event) { // String loc = fLocation.getText(); // if (loc.length() > 0) { // attemptLoad(loc); // } // } // }); fLocation.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent event) { if (fImportType == BID_IMPORT_JAVA) { } else if (event.keyCode == SWT.CR) { attemptLoad(fLocation.getText()); event.doit = false; } } public void keyReleased(KeyEvent e) { if (fImportType == BID_IMPORT_JAVA) { String s = fLocation.getText(); if (s != null && s.length() > 1) { if (!s.equals(fLocationText)) { fLocationText = s; attemptLoad(s); } } } } }); fBrowseButton = createButton(fLocationComposite, BID_BROWSE, Messages.SchemaImportDialog_Browse_Button, false); // End of location variant // Start Resource Variant fResourceComposite = new FileSelectionGroup(fKindGroup, new Listener() { public void handleEvent(Event event) { IResource resource = fResourceComposite.getSelectedResource(); if (resource != null && resource.getType() == IResource.FILE) { // only attempt to load a resource which is not a control attemptLoad((IFile) resource); return; } markEmptySelection(); } }, Messages.SchemaImportDialog_Select_Resource_Title, resourceFilter); //$NON-NLS-1$ TreeViewer viewer = fResourceComposite.getTreeViewer(); viewer.setAutoExpandLevel(2); // End resource variant }
From source file:org.eclipse.bpmn2.modeler.ui.property.dialogs.SchemaImportDialog.java
License:Open Source License
protected void createImportLocation(Composite parent) { fKindGroup = new Group(parent, SWT.SHADOW_ETCHED_IN); fKindGroup.setText(Messages.SchemaImportDialog_4); GridLayout layout = new GridLayout(1, true); GridData data = new GridData(); data.grabExcessVerticalSpace = false; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; fKindGroup.setLayout(layout);//from ww w .j av a2s .c o m fKindGroup.setLayoutData(data); fKindButtonComposite = new Composite(fKindGroup, SWT.NONE); layout = new GridLayout(); layout.makeColumnsEqualWidth = true; layout.numColumns = 4; fKindButtonComposite.setLayout(layout); data = new GridData(); data.grabExcessVerticalSpace = false; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.CENTER; fKindButtonComposite.setLayoutData(data); fBtnResource = createRadioButton(fKindButtonComposite, Messages.SchemaImportDialog_5, BID_BROWSE_WORKSPACE, fImportSource == BID_BROWSE_WORKSPACE); createRadioButton(fKindButtonComposite, Messages.SchemaImportDialog_6, BID_BROWSE_FILE, fImportSource == BID_BROWSE_FILE); createRadioButton(fKindButtonComposite, Messages.SchemaImportDialog_7, BID_BROWSE_URL, fImportSource == BID_BROWSE_URL); // Add WSIL option fBtnWSIL = createRadioButton(fKindButtonComposite, Messages.SchemaImportDialog_15, BID_BROWSE_WSIL, fImportSource == BID_BROWSE_WSIL); // Create location variant fLocationComposite = new Composite(fKindGroup, SWT.NONE); layout = new GridLayout(); layout.numColumns = 3; fLocationComposite.setLayout(layout); data = new GridData(); data.grabExcessVerticalSpace = true; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; fLocationComposite.setLayoutData(data); fLocationLabel = new Label(fLocationComposite, SWT.NONE); fLocationLabel.setText(Messages.SchemaImportDialog_8); fLocation = new Text(fLocationComposite, SWT.BORDER); fLocation.setText(EMPTY); data = new GridData(); data.grabExcessVerticalSpace = false; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; fLocation.setLayoutData(data); // fLocation.addListener(SWT.FocusOut, new Listener() { // // public void handleEvent(Event event) { // String loc = fLocation.getText(); // if (loc.length() > 0) { // attemptLoad(loc); // } // } // }); fLocation.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent event) { if (fImportType == BID_IMPORT_JAVA) { } else if (event.keyCode == SWT.CR) { attemptLoad(fLocation.getText()); event.doit = false; } } public void keyReleased(KeyEvent e) { if (fImportType == BID_IMPORT_JAVA) { String s = fLocation.getText(); if (s != null && s.length() > 1) { if (!s.equals(fLocationText)) { fLocationText = s; attemptLoad(s); } } } } }); fBrowseButton = createButton(fLocationComposite, BID_BROWSE, Messages.SchemaImportDialog_9, false); // End of location variant // Start Resource Variant fResourceComposite = new FileSelectionGroup(fKindGroup, new Listener() { public void handleEvent(Event event) { IResource resource = fResourceComposite.getSelectedResource(); if (resource != null && resource.getType() == IResource.FILE) { // only attempt to load a resource which is not a control attemptLoad((IFile) resource); return; } markEmptySelection(); } }, Messages.SchemaImportDialog_10, resourceFilter); //$NON-NLS-1$ TreeViewer viewer = fResourceComposite.getTreeViewer(); viewer.setAutoExpandLevel(2); // End resource variant // create WSIL UI widgets createWSILStructure(fKindGroup); }
From source file:org.eclipse.cdt.internal.ui.text.COutlineInformationControl.java
License:Open Source License
/** * {@inheritDoc}//from w w w .j a v a 2 s .c o m */ @Override protected TreeViewer createTreeViewer(Composite parent, int treeStyle) { TreeViewer treeViewer = new ProblemTreeViewer(parent, treeStyle); final Tree tree = treeViewer.getTree(); tree.setLayoutData(new GridData(GridData.FILL_BOTH)); fOutlineContentProvider = new CContentOutlinerProvider(treeViewer); treeViewer.setContentProvider(fOutlineContentProvider); fSortingAction = new LexicalSortingAction(treeViewer, ".isChecked"); //$NON-NLS-1$ treeViewer.addFilter(new NamePatternFilter()); long textFlags = TEXT_FLAGS; if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS)) textFlags = textFlags | CElementLabels.M_SIMPLE_NAME | CElementLabels.F_SIMPLE_NAME; treeViewer.setLabelProvider( new DecoratingCLabelProvider(new AppearanceAwareLabelProvider(textFlags, IMAGE_FLAGS), true)); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); return treeViewer; }
From source file:org.eclipse.dltk.internal.ui.typehierarchy.HierarchyInformationControl.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 a v a2s . co m TreeViewer treeViewer = new TreeViewer(tree); treeViewer.addFilter(new ViewerFilter() { public boolean select(Viewer viewer, Object parentElement, Object element) { return element instanceof IType || element instanceof CumulativeType; } }); fLifeCycle = new TypeHierarchyLifeCycle(false); treeViewer.setSorter(new HierarchyViewerSorter(fLifeCycle)); treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); fLabelProvider = new HierarchyLabelProvider(fLifeCycle, getPreferenceStore()); fLabelProvider.setFilter(new ViewerFilter() { public boolean select(Viewer viewer, Object parentElement, Object element) { return hasFocusMethod((IType) element); } }); fLabelProvider.setTextFlags(ScriptElementLabels.ALL_DEFAULT | ScriptElementLabels.T_POST_QUALIFIED); fLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null)); treeViewer.setLabelProvider(fLabelProvider); treeViewer.getTree().addKeyListener(getKeyAdapter()); return treeViewer; }