Java Code Examples for org.eclipse.jface.viewers.TreeViewer#setAutoExpandLevel()

The following examples show how to use org.eclipse.jface.viewers.TreeViewer#setAutoExpandLevel() . 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 vote down vote up
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: AbstractInformationControl.java    From typescript.java with MIT License 6 votes vote down vote up
/**
 * 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 3
Source File: AbstractSelectTreeViewer.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param parent
 *            Parent composite
 * @param checkboxTree
 *            <code>TriStateFilteredTree</code> wrapping a
 *            <code>CheckboxTreeViewer</code>
 * @param legendColumnIndex
 *            index of the legend column (-1 if none)
 */
private AbstractSelectTreeViewer(Composite parent, TriStateFilteredCheckboxTree checkboxTree,
        int legendIndex, String id) {
    super(parent, checkboxTree.getViewer());

    TreeViewer treeViewer = checkboxTree.getViewer();
    treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    treeViewer.setComparator(COMPARATOR);
    if (treeViewer instanceof CheckboxTreeViewer) {
        ((CheckboxTreeViewer) treeViewer).addCheckStateListener(new CheckStateChangedListener());
    }
    treeViewer.addSelectionChangedListener(new TreeViewerSelectionListener());
    checkboxTree.getFilterControl().addModifyListener(e -> saveViewContext());
    fCheckboxTree = checkboxTree;
    fLegendIndex = legendIndex;
    fId = id;
    fLogCategory = fId + LOG_CATEGORY_SUFFIX;
    setLabelProvider(new DataProviderTreeLabelProvider());
    fInstanceId = INSTANCE_ID_SEQUENCE.incrementAndGet();
}
 
Example 4
Source File: AbstractSelectTreeViewer2.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param parent
 *            Parent composite
 * @param checkboxTree
 *            <code>TriStateFilteredTree</code> wrapping a
 *            <code>CheckboxTreeViewer</code>
 * @param legendColumnIndex
 *            index of the legend column (-1 if none)
 */
private AbstractSelectTreeViewer2(Composite parent, TriStateFilteredCheckboxTree checkboxTree,
        int legendIndex, String id) {
    super(parent, checkboxTree.getViewer());

    TreeViewer treeViewer = checkboxTree.getViewer();
    treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    treeViewer.setComparator(COMPARATOR);
    if (treeViewer instanceof CheckboxTreeViewer) {
        ((CheckboxTreeViewer) treeViewer).addCheckStateListener(new CheckStateChangedListener());
    }
    treeViewer.addSelectionChangedListener(new TreeViewerSelectionListener());
    checkboxTree.getFilterControl().addModifyListener(e -> saveViewContext());
    fCheckboxTree = checkboxTree;
    fLegendIndex = legendIndex;
    fId = id;
    fLogCategory = fId + LOG_CATEGORY_SUFFIX;
    fInstanceId = INSTANCE_ID_SEQUENCE.incrementAndGet();
    setLabelProvider(new DataProviderTreeLabelProvider());
}
 
Example 5
Source File: DriverSelectionDialog.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea ( final Composite parent )
{
    setTitle ( "Select driver" );
    setMessage ( "Choose a driver from the world model" );

    final Composite composite = (Composite)super.createDialogArea ( parent );

    final ObservablesManager mgr = new ObservablesManager ();

    final TreeViewer viewer = new TreeViewer ( composite );
    viewer.setAutoExpandLevel ( 2 );
    viewer.getControl ().setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) );
    viewer.addDoubleClickListener ( new IDoubleClickListener () {

        @Override
        public void doubleClick ( final DoubleClickEvent event )
        {
            handleDoubleClick ();
        }
    } );

    mgr.runAndCollect ( new Runnable () {

        @Override
        public void run ()
        {
            createDataModel ( viewer );
        }
    } );

    return composite;
}
 
Example 6
Source File: AbstractCallHierarchyViewPart.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected TreeViewer createCallHierarchyViewer(Composite parent) {
	TreeViewer treeViewer = new TreeViewer(parent);
	treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
	treeViewer.setUseHashlookup(true);
	treeViewer.setAutoExpandLevel(2);
	treeViewer.setLabelProvider(createHierarchyLabelProvider());
	treeViewer.setContentProvider(createHierarchyContentProvider());
	return treeViewer;
}
 
Example 7
Source File: JsonContentOutlinePage.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
    super.createControl(parent);

    TreeViewer viewer = getTreeViewer();
    viewer.setContentProvider(new OutlineContentProvider());
    viewer.setLabelProvider(new OutlineStyledLabelProvider());
    viewer.addSelectionChangedListener(this);
    viewer.setAutoExpandLevel(2);
    viewer.setUseHashlookup(true);

    if (currentInput != null) {
        setInput(currentInput);
    }
}
 
Example 8
Source File: JavaOutlineInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@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: CubeGroupContent.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void createDataField( )
{
	Composite dataField = new Composite( this, SWT.NONE );
	dataField.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	dataField.setLayout( new GridLayout( ) );

	Label dataLabel = new Label( dataField, SWT.NONE );
	dataLabel.setText( Messages.getString( "GroupsPage.Label.DataField" ) ); //$NON-NLS-1$
	dataFieldsViewer = new TreeViewer( dataField, SWT.SINGLE
			| SWT.H_SCROLL
			| SWT.V_SCROLL
			| SWT.BORDER );
	cubeLabelProvider = getCubeLabelProvider( );
	cubeLabelProvider.setProivderViewer( true );
	dataFieldsViewer.setLabelProvider( cubeLabelProvider );
	dataFieldsViewer.setContentProvider( dataContentProvider );
	dataFieldsViewer.setAutoExpandLevel( 3 );
	GridData gd = new GridData( GridData.FILL_BOTH );
	dataFieldsViewer.getTree( ).setLayoutData( gd );
	( (GridData) dataFieldsViewer.getTree( ).getLayoutData( ) ).heightHint = 250;
	( (GridData) dataFieldsViewer.getTree( ).getLayoutData( ) ).widthHint = 200;
	dataFieldsViewer.addSelectionChangedListener( new ISelectionChangedListener( ) {

		public void selectionChanged( SelectionChangedEvent event )
		{
			updateButtons( );
		}

	} );

	final DragSource fieldsSource = new DragSource( dataFieldsViewer.getTree( ),
			operations );
	fieldsSource.setTransfer( types );
	fieldsSource.addDragListener( new CustomDragListener( dataFieldsViewer ) );

}
 
Example 10
Source File: BaseOutlinePage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Parsed partition creates an outline that shows imports/classes/methods
 */
protected void createParsedOutline() {
    final TreeViewer tree = getTreeViewer();
    IDocumentProvider provider = editorView.getDocumentProvider();
    document = provider.getDocument(editorView.getEditorInput());
    tree.setAutoExpandLevel(2);
    tree.setContentProvider(new ParsedContentProvider());
    tree.setLabelProvider(new ParsedLabelProvider(imageCache));
    tree.setInput(getOutlineModel().getRoot());
}
 
Example 11
Source File: TreeSelectionDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@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: AbstractContentOutlinePage.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected TreeViewer createTreeViewer(Composite parent) {
	treeViewer = new TreeViewer(parent, SWT.MULTI);
	
	treeViewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
	// TODO: allow certain StructureElements to not be initially expanded
	treeViewer.setUseHashlookup(true);
	
	setupTreeViewerListeners();
	createTreeViewerMenu();
	
	return treeViewer;
}
 
Example 13
Source File: MasterSelectionDialog.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected Control createDialogArea ( final Composite parent )
{
    setTitle ( "Select master server" );
    setMessage ( "Choose a master server from the world model" );

    final Composite composite = (Composite)super.createDialogArea ( parent );

    final Composite wrapper = new Composite ( composite, SWT.NONE );
    wrapper.setLayout ( new GridLayout ( 1, true ) );
    wrapper.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) );

    final ObservablesManager mgr = new ObservablesManager ();

    final TreeViewer viewer = new TreeViewer ( wrapper );
    viewer.setAutoExpandLevel ( 2 );
    viewer.getControl ().setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true, 1, 1 ) );
    viewer.addDoubleClickListener ( new IDoubleClickListener () {

        @Override
        public void doubleClick ( final DoubleClickEvent event )
        {
            handleDoubleClick ();
        }
    } );

    final Button add = new Button ( wrapper, SWT.RADIO );
    add.setText ( "Add master server" );
    add.setToolTipText ( "Assign the component to the selected master server in addition" );

    this.replace = new Button ( wrapper, SWT.RADIO );
    this.replace.setText ( "Replace all master servers" );
    this.replace.setToolTipText ( "Assign the component soley to the selected master server" );
    this.replace.setSelection ( true );

    this.delete = new Button ( wrapper, SWT.RADIO );
    this.delete.setText ( "Remove master server" );
    this.delete.setToolTipText ( "Un-assign the component from the selected master server" );

    mgr.runAndCollect ( new Runnable () {

        @Override
        public void run ()
        {
            createDataModel ( viewer );
        }
    } );

    if ( this.lastSelection != null )
    {
        viewer.setSelection ( new StructuredSelection ( this.lastSelection ) );
        viewer.reveal ( this.lastSelection );
    }

    return composite;
}
 
Example 14
Source File: CodeRecommendationResultsView.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public CodeRecommendationResultsView() {
	super(SWT.NONE);
	setBackgroundMode(SWT.INHERIT_FORCE);
	setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
	setLayout(new FillLayout(SWT.HORIZONTAL));

	treeViewer = new TreeViewer(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
	treeViewer.setAutoExpandLevel(3);
	Tree tree = treeViewer.getTree();
	tree.setHeaderVisible(true);

	TreeViewerColumn treeViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
	TreeColumn trclmnCodeRecommendations = treeViewerColumn.getColumn();
	trclmnCodeRecommendations.setResizable(false);
	trclmnCodeRecommendations.setText("Code recommendations");

	treeViewer.setContentProvider(contentProvider = new TreeContentProvider());
	treeViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(labelProvider = new TreeLabelProvider()));

	tree.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			TreeItem item = (TreeItem) e.item;
			Object data = item.getData();

			if (data instanceof ICodeRecommendationElement) {
				ICodeRecommendationElement element = (ICodeRecommendationElement) data;
				eventManager.invoke(l -> l.onCodeRecommendationSelected(element));
			}
		}
	});

	treeViewer.addDoubleClickListener(new IDoubleClickListener() {
		@Override
		public void doubleClick(DoubleClickEvent event) {
			TreeViewer viewer = (TreeViewer) event.getViewer();
			IStructuredSelection thisSelection = (IStructuredSelection) event.getSelection();
			Object selectedNode = thisSelection.getFirstElement();
			if (selectedNode instanceof CodeRecommendationTarget) {
				CodeRecommendationTarget target = (CodeRecommendationTarget) selectedNode;

				eventManager.invoke(l -> l.onTargetDoubleClicked(target));
			}
		}
	});

	createContextMenu(treeViewer);
}
 
Example 15
Source File: GamlQuickOutlinePopup.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected TreeViewer createTreeViewer(final Composite parent, final int style) {
	final TreeViewer viewer = super.createTreeViewer(parent, style);
	viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
	return viewer;
}