Example usage for org.eclipse.jface.viewers DecorationContext DecorationContext

List of usage examples for org.eclipse.jface.viewers DecorationContext DecorationContext

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers DecorationContext DecorationContext.

Prototype

public DecorationContext() 

Source Link

Document

Create a decoration context.

Usage

From source file:ext.org.eclipse.jdt.internal.ui.packageview.HierarchicalDecorationContext.java

License:Open Source License

public static IDecorationContext getContext() {
    if (fgContext == null) {
        DecorationContext context = new DecorationContext();
        context.putProperty(SynchronizationStateTester.PROP_TESTER,
                new HierarchicalSynchronizationStateTester());
        fgContext = context;/*w ww .  j a va 2s .c o m*/
    }
    return fgContext;
}

From source file:org.eclipse.egit.ui.internal.decorators.DecorationResult.java

License:Open Source License

public IDecorationContext getDecorationContext() {
    return new DecorationContext();
}

From source file:org.eclipse.jubula.client.ui.provider.DecoratingCellLabelProvider.java

License:Open Source License

/**
 * Create a decoration context for the receiver that has a
 * LocalResourceManager./*from w w  w.j  a v  a  2  s .c  om*/
 * 
 * @return the DefaultDecorationContext
 */
private IDecorationContext createDefaultDecorationContext() {
    return new DecorationContext();
}

From source file:org.eclipse.m2e.core.ui.internal.wizards.MavenPomSelectionComponent.java

License:Open Source License

public void init(String queryText, String queryType, IProject project, Set<ArtifactKey> artifacts,
        Set<ArtifactKey> managed) {
    this.queryType = queryType;
    this.project = project;

    if (queryText != null) {
        searchText.setText(queryText);//from   w w w.ja va  2s . co m
    }

    if (artifacts != null) {
        for (ArtifactKey a : artifacts) {
            artifactKeys.add(a.getGroupId() + ":" + a.getArtifactId()); //$NON-NLS-1$
            artifactKeys.add(a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion()); //$NON-NLS-1$ //$NON-NLS-2$
        }
    }
    if (managed != null) {
        for (ArtifactKey a : managed) {
            managedKeys.add(a.getGroupId() + ":" + a.getArtifactId()); //$NON-NLS-1$
            managedKeys.add(a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion()); //$NON-NLS-1$ //$NON-NLS-2$
        }
    }

    searchResultViewer.setContentProvider(new SearchResultContentProvider());

    SearchResultLabelProvider labelProvider = new SearchResultLabelProvider(artifactKeys, managedKeys);
    DecoratingStyledCellLabelProvider decoratingLabelProvider = new DecoratingStyledCellLabelProvider(
            labelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null);
    DecorationContext decorationContext = new DecorationContext();
    if (project != null) {
        decorationContext.putProperty(PROP_DECORATION_CONTEXT_PROJECT, project);
    }
    decoratingLabelProvider.setDecorationContext(decorationContext);
    searchResultViewer.setLabelProvider(decoratingLabelProvider);

    searchResultViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (!selection.isEmpty()) {
                List<IndexedArtifactFile> files = getSelectedIndexedArtifactFiles(selection);

                ArtifactFilterManager filterManager = MavenPluginActivator.getDefault()
                        .getArifactFilterManager();

                for (IndexedArtifactFile file : files) {
                    ArtifactKey key = (ArtifactKey) file.getAdapter(ArtifactKey.class);
                    IStatus status = filterManager.filter(MavenPomSelectionComponent.this.project, key);
                    if (!status.isOK()) {
                        setStatus(IStatus.ERROR, status.getMessage());
                        return; // TODO not nice to exit method like this
                    }
                }

                if (files.size() == 1) {
                    IndexedArtifactFile f = files.get(0);
                    // int severity = artifactKeys.contains(f.group + ":" + f.artifact) ? IStatus.ERROR : IStatus.OK;
                    int severity = IStatus.OK;
                    String date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT)
                            .format(f.date);
                    setStatus(severity, NLS.bind(Messages.MavenPomSelectionComponent_detail1, f.fname,
                            (f.size != -1 ? NLS.bind(Messages.MavenPomSelectionComponent_details2, date, f.size)
                                    : date)));
                } else {
                    setStatus(IStatus.OK,
                            NLS.bind(Messages.MavenPomSelectionComponent_selected, selection.size()));
                }
            } else {
                setStatus(IStatus.ERROR, Messages.MavenPomSelectionComponent_nosel);
            }
        }
    });
    setupClassifiers();
    setStatus(IStatus.ERROR, ""); //$NON-NLS-1$
    scheduleSearch(queryText, false);
}

From source file:org.eclipse.team.internal.ui.mapping.CommonViewerAdvisor.java

License:Open Source License

/**
 * Create the advisor using the given configuration
 * @param parent the parent/*  w  ww.  j  av a2 s .  co  m*/
 * @param configuration the configuration
 */
public CommonViewerAdvisor(Composite parent, ISynchronizePageConfiguration configuration) {
    super(configuration);
    final CommonViewer viewer = CommonViewerAdvisor.createViewer(parent, configuration, this);
    TeamUI.getTeamContentProviderManager().addPropertyChangeListener(this);
    configuration.addPropertyChangeListener(this);
    GridData data = new GridData(GridData.FILL_BOTH);
    viewer.getControl().setLayoutData(data);
    viewer.getNavigatorContentService().addListener(this);
    initializeViewer(viewer);
    IBaseLabelProvider provider = viewer.getLabelProvider();
    if (provider instanceof DecoratingLabelProvider) {
        DecoratingLabelProvider dlp = (DecoratingLabelProvider) provider;
        ILabelDecorator decorator = ((SynchronizePageConfiguration) configuration).getLabelDecorator();
        if (decorator != null) {
            ILabelProvider lp = dlp.getLabelProvider();
            dlp = new DecoratingLabelProvider(new DecoratingLabelProvider(lp, decorator),
                    PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
            viewer.setLabelProvider(dlp);
        }
        DecorationContext decorationContext = new DecorationContext();
        decorationContext.putProperty(SynchronizationStateTester.PROP_TESTER, new SynchronizationStateTester() {
            public boolean isStateDecorationEnabled() {
                return false;
            }
        });
        dlp.setDecorationContext(decorationContext);
    } else if (provider instanceof DecoratingStyledCellLabelProvider) {
        DecoratingStyledCellLabelProvider dsclp = (DecoratingStyledCellLabelProvider) provider;
        ILabelDecorator decorator = ((SynchronizePageConfiguration) configuration).getLabelDecorator();
        if (decorator != null) {
            IStyledLabelProvider slp = dsclp.getStyledStringProvider();
            dsclp = new DecoratingStyledCellLabelProvider(
                    new MyDecoratingStyledCellLabelProvider(slp, decorator),
                    PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), null);
            viewer.setLabelProvider(dsclp);
        }
        DecorationContext decorationContext = new DecorationContext();
        decorationContext.putProperty(SynchronizationStateTester.PROP_TESTER, new SynchronizationStateTester() {
            public boolean isStateDecorationEnabled() {
                return false;
            }
        });
        dsclp.setDecorationContext(decorationContext);
    }
}