org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider Java Examples

The following examples show how to use org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider. 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: WizardUtils.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
public static IBaseLabelProvider getPostQualifiedLabelProvider() {
	return new DelegatingStyledCellLabelProvider(new JavaElementLabelProvider(
			JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_SMALL_ICONS)) {
		@Override
		protected StyledString getStyledText(Object element) {
			String nameWithQualifier = getStyledStringProvider().getStyledText(element).getString() + " ";
			int separatorIndex = nameWithQualifier.indexOf('-');

			if (separatorIndex == -1)
				return new StyledString(nameWithQualifier);

			StyledString name = new StyledString(nameWithQualifier.substring(0, separatorIndex));
			String qualifier = nameWithQualifier.substring(separatorIndex);
			return name.append(new StyledString(qualifier, StyledString.QUALIFIER_STYLER));
		};
	};
}
 
Example #2
Source File: SelectExamplePage.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void createTreeViewer(Composite container) {
	viewer = new TreeViewer(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
	viewer.setContentProvider(new ExampleContentProvider());
	viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new ExampleLabelProvider()));
	viewer.addSelectionChangedListener(this);
}
 
Example #3
Source File: StructureElementLabelProvider.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static DelegatingStyledCellLabelProvider createLangLabelProvider() {
	StructureElementLabelProvider labelProvider = LangUIPlugin_Actual.getStructureElementLabelProvider();
	// We wrap the base LabelProvider with a DelegatingStyledCellLabelProvider because for some reason
	// that prevents flicker problems when changing selection in Windows classic themes
	// Might not be necessary in the future.
	return new DelegatingStyledCellLabelProvider(labelProvider);
}
 
Example #4
Source File: ExternalLibraryPreferencePage.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected Control createContents(final Composite parent) {
	this.setSize(new Point(600, 600));

	final BuiltInLibrariesLabelProvider labelProvider = new BuiltInLibrariesLabelProvider(projectExplorerhelper);
	final Composite control = new Composite(parent, NONE);
	control.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).create());
	control.setLayoutData(fillDefaults().align(FILL, FILL).create());

	viewer = new TreeViewerBuilder(singletonList(""), contentProvider.get())
			.setVirtual(true)
			.setHeaderVisible(false)
			.setUseHashlookup(true)
			.setHasBorder(true)
			.setColumnWeights(asList(1))
			.setLabelProvider(new DelegatingStyledCellLabelProvider(labelProvider))
			.build(control);

	setViewerInput();

	final Composite subComposite = new Composite(control, NONE);
	subComposite.setLayout(GridLayoutFactory.fillDefaults().create());
	subComposite.setLayoutData(fillDefaults().align(END, TOP).create());

	final Button install = createEnabledPushButton(subComposite, "Install npm...",
			"Runs 'npm install' with the given package and version. Uses 'yarn add' in a yarn workspace.",
			new InstallNpmDependencyButtonListener(this::updateLocations,
					libManager, validatorHelper, semverHelper, statusHelper, this::getSelectedNodeModulesURI));

	final Button uninstall = createEnabledPushButton(subComposite, "Uninstall npm...",
			"Runs 'npm uninstall' with the given package and version. Uses 'yarn remove' in a yarn workspace.",
			new UninstallNpmDependencyButtonListener(this::updateLocations,
					libManager, validatorHelper, statusHelper, this::getSelectedNpm));

	createPlaceHolderLabel(subComposite);

	createPlaceHolderLabel(subComposite);

	createEnabledPushButton(subComposite, "Re-Build node_modules",
			"Cleans the type information from the IDE and then re-build the type information of all node_modules.",
			new RereigsterAllNpmsButtonListener(this::reregisterNpms, statusHelper));

	createEnabledPushButton(subComposite, "Clean node_modules",
			"Runs 'npm clean' on all node_modules folders. Uses 'yarn clean' in a yarn workspace.",
			new CleanAllNpmsButtonListener(this::cleanNpms, statusHelper));

	viewer.addSelectionChangedListener(new ISelectionChangedListener() {

		@Override
		public void selectionChanged(final /* @Nullable */ SelectionChangedEvent event) {
			install.setEnabled(false);
			uninstall.setEnabled(false);

			Object selectedItem = getSelectedItem();
			if (selectedItem instanceof SafeURI) {
				install.setEnabled(true);
			}
			if (selectedItem instanceof IN4JSProject) {
				uninstall.setEnabled(true);
			}
		}
	});

	control.requestLayout();

	return control;
}
 
Example #5
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 #6
Source File: XtextCallHierarchyViewPart.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected IBaseLabelProvider createHierarchyLabelProvider() {
	return new DelegatingStyledCellLabelProvider(hierarchyLabelProvider);
}
 
Example #7
Source File: DefaultCallHierarchyViewPart.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected IBaseLabelProvider createHierarchyLabelProvider() {
	return new DelegatingStyledCellLabelProvider(hierarchyLabelProvider);
}
 
Example #8
Source File: ReferencesInBinaryStatusContextViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void createControl(Composite parent) {
	fForm= new ViewForm(parent, SWT.BORDER | SWT.FLAT);
	fForm.marginWidth= 0;
	fForm.marginHeight= 0;

	fLabel= new CLabel(fForm, SWT.NONE);
	fLabel.setText(RefactoringMessages.ReferencesInBinaryStatusContextViewer_title);
	fForm.setTopLeft(fLabel);

	Composite composite= new Composite(fForm, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	GridLayout layout= new GridLayout(1, false);
	layout.marginWidth= 0;
	layout.marginHeight= 0;
	composite.setLayout(layout);


	fTreeViewer= new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
	final AppearanceAwareLabelProvider labelProvider= new AppearanceAwareLabelProvider();
	fTreeViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(labelProvider));
	fTreeViewer.setComparator(new ViewerComparator() {
		private Collator fCollator= Collator.getInstance();
		@Override
		public int compare(Viewer viewer, Object e1, Object e2) {
			String l1= labelProvider.getText(e1);
			String l2= labelProvider.getText(e2);
			return fCollator.compare(l1, l2);
		}
	});
	fTreeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

	fButton= new Button(composite, SWT.PUSH);
	fButton.setText(RefactoringMessages.ReferencesInBinaryStatusContextViewer_show_as_search_button);
	GridData layoutData= new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
	layoutData.widthHint= SWTUtil.getButtonWidthHint(fButton);
	fButton.setLayoutData(layoutData);
	fButton.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			fillInSearchView();
		}
	});
	fButton.setEnabled(false);

	fForm.setContent(composite);

	Dialog.applyDialogFont(parent);
}
 
Example #9
Source File: ReportPropertySheetPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void createControl( Composite parent )
{
	container = new Composite( parent, SWT.NONE );
	GridLayout layout = new GridLayout( );
	layout.marginWidth = layout.marginHeight = 0;
	container.setLayout( layout );
	title = new TabbedPropertyTitle( container,
			FormWidgetFactory.getInstance( ) );
	title.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );

	title.setActions( new Action[]{
			new GroupSortingAction( ),
			new AlphabeticSortingAction( ),
			new LocalModelAction( )
	} );

	Composite viewerContainer = new Composite( container, SWT.NONE );
	layout = new GridLayout( );
	layout.marginWidth = 10;
	layout.marginHeight = 3;
	viewerContainer.setLayout( layout );
	viewerContainer.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	viewer = new CustomTreeViewer( viewerContainer, SWT.FULL_SELECTION );
	tableTree = viewer.getTree( );
	tableTree.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	tableTree.setHeaderVisible( true );
	tableTree.setLinesVisible( true );

	viewer.setContentProvider( provider );

	TreeViewerColumn tvc1 = new TreeViewerColumn( viewer, SWT.NONE );
	tvc1.getColumn( ).setText( COLUMN_TITLE_PROPERTY );
	tvc1.getColumn( ).setWidth( 300 );
	tvc1.setLabelProvider( new DelegatingStyledCellLabelProvider( new ReportPropertySheetNameLabelProvider( ) ) );

	TreeViewerColumn tvc2 = new TreeViewerColumn( viewer, SWT.NONE );
	tvc2.getColumn( ).setText( COLUMN_TITLE_VALUE );
	tvc2.getColumn( ).setWidth( 400 );
	tvc2.setLabelProvider( new DelegatingStyledCellLabelProvider( new ReportPropertySheetValueLabelProvider( ) ) );

	AlphabeticallyViewSorter sorter = new AlphabeticallyViewSorter( );
	sorter.setAscending( true );
	viewer.setSorter( sorter );

	hookControl( );

	// create a new table tree editor
	tableTreeEditor = new TreeEditor( tableTree );

	// create the editor listener
	createEditorListener( );

	handleGlobalAction( );

	// suport the mediator
	SessionHandleAdapter.getInstance( )
			.getMediator( moduleHandle )
			.addColleague( this );

	FormWidgetFactory.getInstance( ).paintFormStyle( parent );
	FormWidgetFactory.getInstance( ).adapt( parent );

	IWorkbenchPage page = getSite( ).getPage( );

	MementoBuilder builder = new MementoBuilder( );
	if ( ( propertySheetMemento = builder.getRootMemento( )
			.getChild( IPageLayout.ID_PROP_SHEET ) ) == null )
	{
		propertySheetMemento = builder.getRootMemento( )
				.createChild( IPageLayout.ID_PROP_SHEET,
						MementoElement.Type_View );
	}

	if ( ( viewerMemento = propertySheetMemento.getChild( propertyViewerID ) ) == null )
	{
		viewerMemento = propertySheetMemento.createChild( propertyViewerID,
				MementoElement.Type_Viewer );
	}

	page.addSelectionListener( this );
	// handleSelectionChanged( page.getSelection( ) );
}
 
Example #10
Source File: AdvancePropertyDescriptor.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Control createControl( Composite parent )
{
	container = new Composite( parent, SWT.NONE );
	GridLayout layout = UIUtil.createGridLayoutWithoutMargin( 1, false );
	layout.marginTop = 2;
	layout.marginWidth = layout.marginBottom = 1;
	container.setLayout( layout );
	container.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	initSortingType( );

	viewer = new CustomTreeViewer( container, SWT.FULL_SELECTION );

	tableTree = viewer.getTree( );
	GridData gd = new GridData( GridData.FILL_BOTH );
	tableTree.setLayoutData( gd );
	tableTree.setHeaderVisible( true );
	tableTree.setLinesVisible( true );

	viewer.setContentProvider( provider.getContentProvier( ) );

	TreeViewerColumn tvc1 = new TreeViewerColumn( viewer, SWT.NONE );
	tvc1.getColumn( ).setText( COLUMN_TITLE_PROPERTY );
	tvc1.getColumn( ).setWidth( 300 );
	tvc1.setLabelProvider( new DelegatingStyledCellLabelProvider( provider.getNameLabelProvier( ) ) );

	TreeViewerColumn tvc2 = new TreeViewerColumn( viewer, SWT.NONE );
	tvc2.getColumn( ).setText( COLUMN_TITLE_VALUE );
	tvc2.getColumn( ).setWidth( 400 );
	tvc2.setLabelProvider( new DelegatingStyledCellLabelProvider( provider.getValueLabelProvier( ) ) );

	AlphabeticallyViewSorter sorter = new AlphabeticallyViewSorter( );
	sorter.setAscending( true );
	viewer.setSorter( sorter );

	hookControl( );

	// create a new table tree editor
	tableTreeEditor = new TreeEditor( tableTree );

	// create the editor listener
	createEditorListener( );

	MementoBuilder builder = new MementoBuilder( );
	if ( ( propertySheetMemento = builder.getRootMemento( )
			.getChild( IPageLayout.ID_PROP_SHEET ) ) == null )
	{
		propertySheetMemento = builder.getRootMemento( )
				.createChild( IPageLayout.ID_PROP_SHEET,
						MementoElement.Type_View );
	}

	if ( ( viewerMemento = propertySheetMemento.getChild( propertyViewerID ) ) == null )
	{
		viewerMemento = propertySheetMemento.createChild( propertyViewerID,
				MementoElement.Type_Viewer );
	}

	return container;
}
 
Example #11
Source File: ImportBosArchiveControlSupplier.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private Composite createTree(Composite parent) {
    final Composite fileTreeGroup = new Composite(parent, SWT.NONE);
    fileTreeGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 5).create());
    fileTreeGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    viewer = new TreeViewer(fileTreeGroup,
            SWT.VIRTUAL | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(600, SWT.DEFAULT).create());
    provider = new ArchiveTreeContentProvider(viewer);
    viewer.setContentProvider(provider);
    viewer.setUseHashlookup(true); // important for lazy behavior!
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(6, true));
    layout.addColumnData(new ColumnWeightData(2, true));
    viewer.getTree().setLayout(layout);
    ColumnViewerToolTipSupport.enableFor(viewer);

    final TreeViewerColumn archiveColumn = new TreeViewerColumn(viewer, SWT.NONE);
    archiveColumn.getColumn().setText(Messages.archiveColumn);
    archiveColumn.setLabelProvider(new DelegatingStyledCellLabelProvider(new ImportModelLabelProvider(
            new ImportModelStyler())));

    final TreeViewerColumn actionColumn = new TreeViewerColumn(viewer, SWT.NONE);
    actionColumn.getColumn().setText(Messages.actionColumn);
    actionColumn.setLabelProvider(new LabelProviderBuilder<>()
            .withTextProvider(this::getActionText)
            .createColumnLabelProvider());
    actionColumn.setEditingSupport(new ImportActionEditingSupport(viewer));

    final Composite buttonsComposite = new Composite(fileTreeGroup, SWT.NONE);
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(5, 2).create());
    buttonsComposite.setLayoutData(
            GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).create());

    importActionSelector = new ImportActionSelector(viewer);
    overwriteButton = new ButtonWidget.Builder()
            .withLabel(Messages.overwriteAll)
            .alignLeft()
            .fill()
            .grabHorizontalSpace()
            .minimumWidth(BUTTON_WIDTH)
            .onClick(importActionSelector::selectOverwriteAll)
            .createIn(buttonsComposite);
    overwriteButton.disable();

    keepAllButton = new ButtonWidget.Builder()
            .withLabel(Messages.keepAll)
            .alignLeft()
            .fill()
            .minimumWidth(BUTTON_WIDTH)
            .grabHorizontalSpace()
            .onClick(importActionSelector::selectKeepAll)
            .createIn(buttonsComposite);
    keepAllButton.disable();

    return fileTreeGroup;
}