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

The following examples show how to use org.eclipse.jface.viewers.TreeViewer#setLabelProvider() . 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: MSyncWizardOverviewPage.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
  public void createControl(Composite parent) {
  	
      container = new Composite(parent, SWT.NONE);
      GridLayout layout = new GridLayout();
      container.setLayout(layout);
      // required to avoid an error in the system
      setControl(container);
      
      treeViewer = new TreeViewer(container, SWT.BORDER);
      treeViewer.setContentProvider(new TreeContentProvider());
      treeViewer.setLabelProvider(new MendeleyTreeLabelProvider());
      
      Tree tree = treeViewer.getTree();
      tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
      
      container.setEnabled(true);
      treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
	
	@Override
	public void selectionChanged(SelectionChangedEvent event) {
		treeViewer.getTree().deselect(treeViewer.getTree().getSelection()[0]);
	}
});
      
  }
 
Example 2
Source File: JavaWorkingSetPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void configureTree(TreeViewer tree) {
	tree.setContentProvider(new JavaWorkingSetPageContentProvider());

	AppearanceAwareLabelProvider javaElementLabelProvider=
		new AppearanceAwareLabelProvider(
			AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.P_COMPRESSED,
			AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS
		);

	tree.setLabelProvider(new DecoratingJavaLabelProvider(javaElementLabelProvider));
	tree.setComparator(new JavaElementComparator());
	tree.addFilter(new EmptyInnerPackageFilter());

	tree.setInput(JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()));

	if (getSelection() == null)
		return;

	Object[] selection= getInitialTreeSelection();
	if (selection.length > 0) {
		try {
			tree.getTree().setRedraw(false);

			for (int i= 0; i < selection.length; i++) {
				tree.expandToLevel(selection[i], 0);
			}
			tree.setSelection(new StructuredSelection(selection));
		} finally {
			tree.getTree().setRedraw(true);
		}
	}
}
 
Example 3
Source File: TsfTraceAnalysisView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.
 */
@Override
public void createPartControl(Composite parent) {
    final SashForm sashForm = new SashForm(parent, SWT.NONE);
    final SashForm sashForm2 = new SashForm(sashForm, SWT.NONE);

    tsfviewer = new TimeGraphViewer(sashForm2, SWT.NONE);
    tsfviewer.setTimeGraphProvider(new TsfImplProvider());
    tsfviewer2 = new TimeGraphViewer(sashForm2, SWT.NONE);
    tsfviewer2.setTimeGraphProvider(new TsfImplProvider());

    viewer = new TreeViewer(sashForm, SWT.MULTI | SWT.H_SCROLL
            | SWT.V_SCROLL);
    drillDownAdapter = new DrillDownAdapter(viewer);
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setComparator(new ViewerComparator());
    viewer.setInput(getViewSite());

    sashForm.setWeights(new int[] { 5, 1 });
    sashForm2.setWeights(new int[] { 1, 1 });

    fact = new TraceModelImplFactory();
    ITimeGraphEntry[] traceArr = fact.createTraces();
    tsfviewer.setInput(traceArr);
    tsfviewer.addSelectionListener(this);
    tsfviewer.addRangeListener(this);
    tsfviewer.setTimeFormat(TimeFormat.CALENDAR);

    tsfviewer2.setInput(traceArr);
    tsfviewer2.addSelectionListener(this);
    tsfviewer2.addRangeListener(this);
    // tsfviewer2.setTimeFormat(TimeGraphViewer.timeFormat.epoch);

    makeActions();
    hookContextMenu();
    hookDoubleClickAction();
    contributeToActionBars();
}
 
Example 4
Source File: MoveConnectorWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createProcessTreeControl(final EMFDataBindingContext dbc, final Composite parent) {
    final Label label = new Label(parent, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
    label.setText(Messages.chooseTargetStepOrProcess);

    final TreeViewer processTreeViewer = new FilteredTree(parent, SWT.BORDER | SWT.SINGLE, new PatternFilter(), true).getViewer();
    processTreeViewer.getControl().getParent().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 300).create());
    processTreeViewer.setLabelProvider(new ElementLabelProvider(adapterFactory));
    processTreeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    processTreeViewer.addFilter(new ConnectableElementViewerFilter(sourceProcess));
    processTreeViewer.setInput(ModelHelper.getMainProcess(sourceProcess));
    processTreeViewer.expandAll();
    dbc.bindValue(ViewersObservables.observeSingleSelection(processTreeViewer), targetLocationObservable,
            updateValueStrategy().withValidator(selectionValidator()).create(), null);
}
 
Example 5
Source File: DiagramPartitioningBreadcrumbViewer.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected TreeViewer createDiagramViewer(final Composite composite, Diagram diagram) {
	TreeViewer viewer = new TreeViewer(composite);
	viewer.setLabelProvider(new AdapterFactoryLabelProvider(new SGraphItemProviderAdapterFactory()));
	viewer.setContentProvider(new AdapterFactoryContentProvider(new BreadcrumbItemProviderAdapterFactory()));
	EObject element = diagram.getElement();
	viewer.setInput(element);
	viewer.addSelectionChangedListener(this);
	return viewer;
}
 
Example 6
Source File: ModelSortPageableTreeExample.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public static void main(String[] args) {

		Display display = new Display();
		Shell shell = new Shell(display);
		GridLayout layout = new GridLayout(1, false);
		shell.setLayout(layout);

		final List<Team> items = createList();

		// 1) Create pageable tree with 10 items per page
		// This SWT Component create internally a SWT Tree+JFace TreeViewer
		int pageSize = 10;
		PageableTree pageableTree = new PageableTree(shell, SWT.BORDER,
				SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, pageSize);
		pageableTree.setLayoutData(new GridData(GridData.FILL_BOTH));

		// 2) Initialize the tree viewer + SWT Tree
		TreeViewer viewer = pageableTree.getViewer();
		viewer.setContentProvider(TeamContentProvider.getInstance());
		viewer.setLabelProvider(new LabelProvider());

		Tree tree = viewer.getTree();
		tree.setHeaderVisible(true);
		tree.setLinesVisible(true);

		// 3) Create Tree columns with sort of paginated list.
		createColumns(viewer);

		// 3) Set current page to 0 to refresh the tree
		pageableTree.setPageLoader(new PageResultLoaderList<Team>(items));
		pageableTree.setCurrentPage(0);

		shell.setSize(400, 250);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
 
Example 7
Source File: OutlineDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createOutline(final Composite viewersComposite) {
    outline = new TreeViewer(viewersComposite);
    outline.getTree().setLayoutData(GridDataFactory.fillDefaults().hint(300,200).create());
    outline.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
    outline.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    final ViewerFilter[] filters = {new OutlineFilter()};
    outline.setFilters(filters);
    outline.setInput(ModelHelper.getParentProcess((EObject) elementToDisplay.get(0)));
}
 
Example 8
Source File: XMPPSessionDisplayComposite.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void configureViewer(TreeViewer viewer) {
  viewer.setContentProvider(new SessionContentProvider(new RosterContentProvider()));

  viewer.setLabelProvider(new TreeLabelProvider());
  viewer.setComparator(new SessionComparator(new RosterComparator()));
  viewer.setUseHashlookup(true);
}
 
Example 9
Source File: M2DocFileSelectionDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    fileText = createFilePathComposite(container, defaultFileName);

    final TreeViewer containerTreeViewer = new TreeViewer(container, SWT.BORDER);
    Tree tree = containerTreeViewer.getTree();
    final GridData gdTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gdTable.minimumWidth = TABLE_MINIMUM_WIDTH;
    gdTable.minimumHeight = TABLE_MINIMUM_HEIGHT;
    tree.setLayoutData(gdTable);
    containerTreeViewer.setContentProvider(new WorkbenchContentProvider() {
        @Override
        public Object[] getChildren(Object element) {
            final List<Object> res = new ArrayList<>();
            for (Object obj : super.getChildren(element)) {
                if (obj instanceof IContainer
                    || (obj instanceof IFile && fileExtension.equals(((IFile) obj).getFileExtension()))) {
                    res.add(obj);
                }
            }
            return res.toArray();
        }
    });
    containerTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
    containerTreeViewer.addSelectionChangedListener(new ContainerSelectionChangedListener());
    containerTreeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
    if (defaultFileName != null && !defaultFileName.isEmpty()) {
        final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(defaultFileName));
        containerTreeViewer.setSelection(new StructuredSelection(file));
    }

    return container;
}
 
Example 10
Source File: WorkspaceDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite composite = (Composite) super.createDialogArea(parent);

	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	composite.setLayout(layout);
	final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
	composite.setLayoutData(data);

	getShell().setText(Messages.getString("dialog.WorkspaceDialog.shell"));

	wsTreeViewer = new TreeViewer(composite, SWT.BORDER);
	final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
	gd.widthHint = 550;
	gd.heightHint = 250;
	wsTreeViewer.getTree().setLayoutData(gd);

	wsTreeViewer.setContentProvider(new LocationPageContentProvider());
	wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
	wsTreeViewer.setInput(ResourcesPlugin.getWorkspace());

	final Composite group = new Composite(composite, SWT.NONE);
	layout = new GridLayout(2, false);
	layout.marginWidth = 0;
	group.setLayout(layout);
	group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

	final Label label = new Label(group, SWT.NONE);
	label.setLayoutData(new GridData());
	label.setText(Messages.getString("dialog.WorkspaceDialog.label"));

	wsFilenameText = new Text(group, SWT.BORDER);
	wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

	setupListeners();

	return parent;
}
 
Example 11
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 12
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 13
Source File: SVNDecoratorPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Preview(Composite composite) {
          SWTUtils.createLabel(composite, Policy.bind("SVNDecoratorPreferencesPage.preview"));  //$NON-NLS-1$
	fImageCache= new LocalResourceManager(JFaceResources.getResources());
	fViewer = new TreeViewer(composite);
	GridData data = SWTUtils.createHVFillGridData();
	data.heightHint = 225;
	fViewer.getControl().setLayoutData(data);
	fViewer.setContentProvider(this);
	fViewer.setLabelProvider(this);
	fViewer.setInput(ROOT);
	fViewer.expandAll();
}
 
Example 14
Source File: TmDbManagerDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new <code>TreeViewer</code>.
 * @param parent
 *            the parent <code>Composite</code>.
 * @return the <code>TreeViewer</code>.
 */
protected TreeViewer createTreeViewer(Composite parent) {
	final TreeViewer viewer = new TreeViewer(parent, SWT.BORDER);
	addListeners(viewer);
	viewer.setLabelProvider(new TreeLableProvider());
	viewer.setContentProvider(new TreeContentProvider());
	return viewer;
}
 
Example 15
Source File: UpdateWizardPage.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public void createControl(final Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		GridLayout gridLayout = new GridLayout();
		gridLayout.marginWidth = 0;
		gridLayout.marginHeight = 0;
		composite.setLayout(gridLayout);
		
		treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
		GridData data = new GridData(GridData.FILL_BOTH);
		Tree tree = treeViewer.getTree();
		tree.setLayoutData(data);
		tree.setHeaderVisible(true);
		
		IUColumnConfig[] columns = getColumnConfig();		
		for (int i = 0; i < columns.length; i++) {
			TreeColumn tc = new TreeColumn(tree, SWT.LEFT, i);
			tc.setResizable(true);
			tc.setText(columns[i].getColumnTitle());
			tc.setWidth(columns[i].getWidthInPixels(tree));
		}
		
		contentProvider = new ProvElementContentProvider();
		treeViewer.setContentProvider(contentProvider);
		labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell());
		treeViewer.setLabelProvider(labelProvider);
		
		setControl(composite);
		
		final Runnable runnable = new Runnable() {
			public void run() {				
//				updateStatus(input, operation);
				setDrilldownElements(input, operation);
				treeViewer.setInput(input);
			}
		};
		
		if (operation != null && !operation.hasResolved()) {
			try {
				getContainer().run(true, false, new IRunnableWithProgress() {
					public void run(IProgressMonitor monitor) {
						operation.resolveModal(monitor);
						parent.getDisplay().asyncExec(runnable);
					}
				});
			} catch (Exception e) {
				StatusManager.getManager().handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e));
			}
		} else {
			runnable.run();
		}
	}
 
Example 16
Source File: ReferenceSearchViewPage.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
	pagebook = new PageBook(parent, SWT.NULL);
	pagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
	busyLabel = new Table(pagebook, SWT.NONE);
	TableItem item = new TableItem(busyLabel, SWT.NONE);
	item.setText(Messages.ReferenceSearchViewPage_busyLabel);
	busyLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	control = new Composite(pagebook, SWT.NULL);
	control.setLayoutData(new GridData(GridData.FILL_BOTH));
	control.setSize(100, 100);
	control.setLayout(new FillLayout());
	viewer = new TreeViewer(control, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.setContentProvider(contentProvider);
	viewer.setLabelProvider(labelProvider);
	viewer.setComparator(sorter);
	createOpenAndLinkWithEditorHandler();
	IToolBarManager tbm = getSite().getActionBars().getToolBarManager();
	fillToolbar(tbm);
	tbm.update(true);
	pagebook.showPage(control);
	isBusyShowing = false;
	queryListener = createQueryListener();
	NewSearchUI.addQueryListener(queryListener);

	menu = new MenuManager("#PopUp"); //$NON-NLS-1$
	menu.setRemoveAllWhenShown(true);
	menu.setParent(getSite().getActionBars().getMenuManager());
	menu.addMenuListener(mgr -> {
		fillContextMenu(mgr);
		part.fillContextMenu(mgr);
	});

	viewer.getControl().setMenu(menu.createContextMenu(viewer.getControl()));
	viewer.getControl().addKeyListener(KeyListener.keyPressedAdapter(e -> {
		if (e.keyCode == SWT.DEL) {
			removeSelectedMatchesAction.run();
		} else if ((e.stateMask | SWT.COMMAND) != 0 && e.keyCode == 'c') {
			copyAction.run();
		}
	}));
}
 
Example 17
Source File: N4IDEXpectView.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void createPartControl(Composite parent) {

	FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
	fillLayout.marginHeight = 5;
	fillLayout.marginWidth = 5;
	parent.setLayout(fillLayout);

	// main container
	container = new Composite(parent, SWT.BORDER);
	container.setLayout(new FillLayout());

	// create container for stack trace data
	Composite stacktraceDataContainer = new Composite(parent, SWT.BORDER);

	FormLayout formLayout = new FormLayout();
	formLayout.marginHeight = 5;
	formLayout.marginWidth = 5;
	formLayout.spacing = 5;
	stacktraceDataContainer.setLayout(formLayout);

	Composite stackLabelContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
	stackLabelContainer.setLayout(new GridLayout());

	FormData stackLabelFormData = new FormData();
	stackLabelFormData.top = new FormAttachment(0);
	stackLabelFormData.left = new FormAttachment(0);
	stackLabelFormData.right = new FormAttachment(100);
	stackLabelFormData.bottom = new FormAttachment(20);
	stackLabelContainer.setLayoutData(stackLabelFormData);

	Composite stackTraceContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
	stackTraceContainer.setLayout(new FillLayout());

	FormData stackTraceFormData = new FormData();
	stackTraceFormData.top = new FormAttachment(stackLabelContainer);
	stackTraceFormData.left = new FormAttachment(0);
	stackTraceFormData.right = new FormAttachment(100);
	stackTraceFormData.bottom = new FormAttachment(100);
	stackTraceContainer.setLayoutData(stackTraceFormData);

	// Create viewer for test tree in main container
	testTreeViewer = new TreeViewer(container);
	testTreeViewer.setContentProvider(new XpectContentProvider());
	testTreeViewer.setLabelProvider(new XpectLabelProvider(this.testsExecutionStatus));
	testTreeViewer.setInput(null);

	// create stack trace label
	stacktraceLabel = new Label(stackLabelContainer, SWT.SHADOW_OUT);
	FontData fontData = stacktraceLabel.getFont().getFontData()[0];
	Display display = Display.getCurrent();
	// may be null if outside the UI thread
	if (display == null)
		display = Display.getDefault();
	Font font = new Font(display, new FontData(fontData.getName(), fontData
			.getHeight(), SWT.BOLD));
	// Make stack trace label bold
	stacktraceLabel.setFont(font);

	stacktraceLabel.setText(NO_TRACE_MSG);

	// create stack trace console
	MessageConsole messageConsole = new MessageConsole("trace", null);
	stacktraceConsole = new TraceConsole(messageConsole);
	stacktraceConsoleViewer = new TextConsoleViewer(stackTraceContainer, messageConsole);

	// context menu
	getSite().setSelectionProvider(testTreeViewer);
	MenuManager contextMenu = new MenuManager();
	contextMenu.setRemoveAllWhenShown(true);
	getSite().registerContextMenu(contextMenu, testTreeViewer);
	Control control = testTreeViewer.getControl();
	Menu menu = contextMenu.createContextMenu(control);
	control.setMenu(menu);
	activateContext();

	createSelectionActions();

}
 
Example 18
Source File: UpdateWizardPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public void createControl(final Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		GridLayout gridLayout = new GridLayout();
		gridLayout.marginWidth = 0;
		gridLayout.marginHeight = 0;
		composite.setLayout(gridLayout);
		
		treeViewer = new TreeViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
		GridData data = new GridData(GridData.FILL_BOTH);
		Tree tree = treeViewer.getTree();
		tree.setLayoutData(data);
		tree.setHeaderVisible(true);
		
		IUColumnConfig[] columns = getColumnConfig();		
		for (int i = 0; i < columns.length; i++) {
			TreeColumn tc = new TreeColumn(tree, SWT.LEFT, i);
			tc.setResizable(true);
			tc.setText(columns[i].getColumnTitle());
			tc.setWidth(columns[i].getWidthInPixels(tree));
		}
		
		contentProvider = new ProvElementContentProvider();
		treeViewer.setContentProvider(contentProvider);
		labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell());
		treeViewer.setLabelProvider(labelProvider);
		
		setControl(composite);
		
		final Runnable runnable = new Runnable() {
			public void run() {				
//				updateStatus(input, operation);
				setDrilldownElements(input, operation);
				treeViewer.setInput(input);
			}
		};
		
		if (operation != null && !operation.hasResolved()) {
			try {
				getContainer().run(true, false, new IRunnableWithProgress() {
					public void run(IProgressMonitor monitor) {
						operation.resolveModal(monitor);
						parent.getDisplay().asyncExec(runnable);
					}
				});
			} catch (Exception e) {
				StatusManager.getManager().handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e));
			}
		} else {
			runnable.run();
		}
	}
 
Example 19
Source File: ReportLayoutEditorBreadcrumb.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void configureDropDownViewer( TreeViewer viewer, Object input )
{
	BreadcrumbViewTreeProvider provier = new BreadcrumbViewTreeProvider( getEditor( ) );
	viewer.setContentProvider( provier );
	viewer.setLabelProvider( provier );
}
 
Example 20
Source File: CheckoutWizardSelectionPage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void createControl(Composite parent) {
	Composite outerContainer = new Composite(parent,SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	outerContainer.setLayout(layout);
	outerContainer.setLayoutData(
	new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));

	treeViewer = new TreeViewer(outerContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER);
	RepositoryContentProvider contentProvider = new RepositoryContentProvider();
       treeViewer.setContentProvider(contentProvider);
       treeViewer.addFilter(RepositoryFilters.FOLDERS_ONLY);
       treeViewer.setLabelProvider(new WorkbenchLabelProvider());
       treeViewer.setInput(repositoryLocation);

	GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
	data.heightHint = LIST_HEIGHT_HINT;
	data.widthHint = LIST_WIDTH_HINT;
	treeViewer.getControl().setLayoutData(data);

	treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			CheckoutWizard wizard = (CheckoutWizard)getWizard();
			ArrayList folderArray = new ArrayList();
			IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
			Iterator iter = selection.iterator();
			while (iter.hasNext()) {
				Object object = iter.next();
				if (object instanceof ISVNRemoteFolder || object instanceof ISVNRepositoryLocation) {
					if (object instanceof ISVNRepositoryLocation) folderArray.add(((ISVNRepositoryLocation)object).getRootFolder());
					else folderArray.add(object);
				}
			}
			ISVNRemoteFolder[] remoteFolders = new ISVNRemoteFolder[folderArray.size()];
			folderArray.toArray(remoteFolders);
			wizard.setRemoteFolders(remoteFolders);
			setPageComplete(!treeViewer.getSelection().isEmpty());
		}
	});
	
       final Action refreshAction = new Action(Policy.bind("RepositoriesView.refreshPopup"), SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_REFRESH)) { //$NON-NLS-1$
           public void run() {
           	refreshViewerNode();
           }
       };
       MenuManager menuMgr = new MenuManager();
       Tree tree = treeViewer.getTree();
       Menu menu = menuMgr.createContextMenu(tree);
       menuMgr.addMenuListener(new IMenuListener() {
           public void menuAboutToShow(IMenuManager manager) {
               manager.add(refreshAction);
           }

       });
       menuMgr.setRemoveAllWhenShown(true);
       tree.setMenu(menu);

	setMessage(Policy.bind("CheckoutWizardSelectionPage.text")); //$NON-NLS-1$

	setControl(outerContainer);
}