Example usage for org.eclipse.jface.viewers IDecoration addPrefix

List of usage examples for org.eclipse.jface.viewers IDecoration addPrefix

Introduction

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

Prototype

void addPrefix(String prefix);

Source Link

Document

Adds a prefix to the element's label.

Usage

From source file:com.aptana.git.ui.internal.GitLightweightDecorator.java

License:Open Source License

private void decorateFolder(IDecoration decoration, IResource resource) {
    GitRepository repo = getRepo(resource);
    if (repo == null)
        return;/* w  w w.j av a2 s  .  c  o  m*/

    if (repo.resourceOrChildHasChanges(resource)) {
        decoration.addPrefix(DIRTY_PREFIX);
    }
}

From source file:com.aptana.git.ui.internal.GitLightweightDecorator.java

License:Open Source License

private void decorateFile(IDecoration decoration, final IResource resource) {
    IFile file = (IFile) resource;//  w  ww  . j a va 2  s.  c  o m
    GitRepository repo = getRepo(resource);
    if (repo == null)
        return;

    ChangedFile changed = repo.getChangedFileForResource(file);
    if (changed == null) {
        return;
    }

    ImageDescriptor overlay = null;
    // Unstaged trumps staged when decorating. One file may have both staged and unstaged changes.
    if (changed.hasUnstagedChanges()) {
        decoration.setForegroundColor(GitColors.redFG());
        decoration.setBackgroundColor(GitColors.redBG());
        if (changed.getStatus() == ChangedFile.Status.NEW) {
            overlay = untrackedImage();
        } else if (changed.getStatus() == ChangedFile.Status.UNMERGED) {
            overlay = conflictImage();
        }
    } else if (changed.hasStagedChanges()) {
        decoration.setForegroundColor(GitColors.greenFG());
        decoration.setBackgroundColor(GitColors.greenBG());
        if (changed.getStatus() == ChangedFile.Status.DELETED) {
            overlay = stagedRemovedImage();
        } else if (changed.getStatus() == ChangedFile.Status.NEW) {
            overlay = stagedAddedImage();
        }
    }
    decoration.addPrefix(DIRTY_PREFIX);
    if (overlay != null)
        decoration.addOverlay(overlay);
}

From source file:com.microsoft.tfs.client.eclipse.ui.decorators.TFSLabelDecorator.java

License:Open Source License

/**
 * This decorator allows us to paint based on the pending changes cache. (it
 * will decorate adds, checkouts, locks, etc.)
 *
 * @param resource//from  ww  w .  j  a v a  2  s  .c  o  m
 *        The IResource to decorate
 * @param decoration
 *        The IDecoration which will be decorated
 * @param repository
 *        The TFSRepository for this item
 * @param resourcePath
 *        The local path to the resource for querying the pending changes
 *        cache
 */
private void decorateFromFilePendingChanges(final IResource resource, final IDecoration decoration,
        final TFSRepository repository, final String resourcePath) {
    final PendingChange pendingChange = repository.getPendingChangeCache()
            .getPendingChangeByLocalPath(resourcePath);

    // no pending changes, don't alter any decorations
    if (pendingChange == null || pendingChange.getChangeType() == null) {
        return;
    }

    final ChangeType pendingChangeType = pendingChange.getChangeType();

    // handle adds
    if (pendingChangeType.contains(ChangeType.ADD)) {
        decoration.addOverlay(imageHelper.getImageDescriptor(ADD_ICON));
        decoration.addPrefix("+"); //$NON-NLS-1$
    }
    // edits
    else if (pendingChangeType.contains(ChangeType.EDIT)) {
        decoration.addOverlay(imageHelper.getImageDescriptor(EDIT_ICON));
        decoration.addPrefix(">"); //$NON-NLS-1$
    }
    // non-edit locks
    else if (pendingChangeType.contains(ChangeType.LOCK)) {
        decoration.addOverlay(imageHelper.getImageDescriptor(LOCK_ICON));
    }
    // arbitrary pending changes just get a something
    else if (!pendingChangeType.isEmpty()) {
        decoration.addOverlay(imageHelper.getImageDescriptor(CHANGE_ICON));
    }
}

From source file:com.safi.workshop.navigator.DirtyDecorator.java

License:Open Source License

private void doDecorate(IDecoration decoration, DirtyMode mode) {
    String iconPath = null;/*from ww  w  . j av a 2s . c  o  m*/
    switch (mode) {

    case NOT_COMMITTED:
        decoration.addPrefix(">");
    case COMMITTED:
        iconPath = syncedIcon;
        break;
    case NOT_PERSISTED:
        iconPath = nonPersistedIcon;

    }
    ImageDescriptor descriptor = imageMap.get(iconPath);
    if (descriptor == null) {
        URL url = Platform.find(Platform.getBundle("AsteriskSafletDesigner.diagram"), new Path(iconPath)); // NON-NLS-1
        if (url == null)
            return;
        descriptor = ImageDescriptor.createFromURL(url);
        imageMap.put(iconPath, descriptor);
    }
    decoration.addOverlay(descriptor, IDecoration.BOTTOM_LEFT);
}

From source file:com.vectrace.MercurialEclipse.team.ResourceDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration d) {
    IResource resource = (IResource) element;
    IProject project = resource.getProject();
    if (project == null || !project.isAccessible()) {
        return;//from  w w w . j  a va 2  s.  c om
    }

    try {
        if (!MercurialTeamProvider.isHgTeamProviderFor(project)) {
            return;
        }

        if (!STATUS_CACHE.isStatusKnown(project)) {
            // simply wait until the cache sends us an event
            d.addOverlay(DecoratorImages.NOT_TRACKED);
            if (resource == project) {
                d.addSuffix(" [Hg status pending...]");
            }
            return;
        }

        ImageDescriptor overlay = null;
        StringBuilder prefix = new StringBuilder(2);
        Integer output = STATUS_CACHE.getStatus(resource);
        if (output != null) {
            overlay = decorate(output.intValue(), prefix, d, colorise);
        } else {
            if (resource.getType() == IResource.FILE) {
                overlay = decorate(MercurialStatusCache.BIT_IGNORE, prefix, d, colorise);
            }
            // empty folder, do nothing
        }
        if (overlay != null) {
            d.addOverlay(overlay);
        }

        if (!showChangeset) {
            if (resource.getType() == IResource.PROJECT || shouldCheckSubrepo(resource)) {
                d.addSuffix(getSuffixForContainer((IContainer) resource));
            }
        } else {
            addChangesetInfo(d, resource, project, prefix);
        }

        // we want a prefix, even if no changeset is displayed
        if (prefix.length() > 0) {
            d.addPrefix(prefix.toString());
        }
    } catch (Exception e) {
        MercurialEclipsePlugin.logError(e);
    }
}

From source file:de.jcup.egradle.eclipse.decorators.EGradleProjectDecorator.java

License:Apache License

@Override
public void decorate(Object element, IDecoration decoration) {
    /* no decoration when plugin is not running */
    if (Activator.getDefault() == null) {
        return;/*from   w  ww  . ja  v a  2  s  . c  o m*/
    }

    /* no decoration when workbench is not running */
    if (!PlatformUI.isWorkbenchRunning()) {
        return;
    }

    /* do not decoratore if its not a project */
    if (!(element instanceof IProject)) {
        return;
    }

    IProject p = (IProject) element;
    File rootFolder = EGradleUtil.getRootProjectFolderWithoutErrorHandling();
    if (rootFolder == null) {
        return;
    }
    if (EGradleUtil.hasVirtualRootProjectNature(p)) {
        decoration.addPrefix("EGradle ");
        decoration.addSuffix(" (" + rootFolder.getName() + ")");
        decorateImage(decoration);
        /* Because the virtual root project is not hosted in SCM - at least with GIT, there is always an
         * ugly question icon at IDecoration.BOTTOM_RIGHT . To avoid this
         * we simply render an empty deocorator here. This is okay, because diff 
         * changes in project are rendered as usual
         */
        decoration.addOverlay(emptyDecoratorDescriptor, IDecoration.BOTTOM_RIGHT);
        return;
    }

    /* we simply check if the project is inside root project */
    try {
        if (!isSubprojectOfCurrentRootProject(p)) {
            return;
        }
        if (EGradleUtil.getPreferences().isSubProjectIconDecorationEnabled()) {
            decorateImage(decoration);
        }
    } catch (CoreException e) {
        EGradleUtil.log(e);
    }

}

From source file:de.jcup.egradle.eclipse.ide.decorators.EGradleProjectDecorator.java

License:Apache License

@Override
public void decorate(Object element, IDecoration decoration) {
    /* no decoration when plugin is not running */
    if (IDEActivator.getDefault() == null) {
        return;/*w  w  w.j  a va 2  s .c o m*/
    }

    /* no decoration when workbench is not running */
    if (!PlatformUI.isWorkbenchRunning()) {
        return;
    }

    /* do not decoratore if its not a project */
    if (!(element instanceof IProject)) {
        return;
    }

    IProject p = (IProject) element;
    File rootFolder = getRootProjectFolderWithoutErrorHandling();
    if (rootFolder == null) {
        return;
    }
    if (hasVirtualRootProjectNature(p)) {
        decoration.addPrefix("EGradle ");
        decoration.addSuffix(" (" + rootFolder.getName() + ")");
        decorateImage(decoration);
        /*
         * Because the virtual root project is not hosted in SCM - at least
         * with GIT, there is always an ugly question icon at
         * IDecoration.BOTTOM_RIGHT . To avoid this we simply render an
         * empty deocorator here. This is okay, because diff changes in
         * project are rendered as usual
         */
        decoration.addOverlay(emptyDecoratorDescriptor, IDecoration.BOTTOM_RIGHT);
        return;
    }

    /* we simply check if the project is inside root project */
    try {
        if (!isSubprojectOfCurrentRootProject(p)) {
            return;
        }
        if (IDEUtil.getPreferences().isSubProjectIconDecorationEnabled()) {
            decorateImage(decoration);
        }
    } catch (CoreException e) {
        IDEUtil.logError("Was not able to decorate sub project:" + p, e);
    }

}

From source file:net.sf.freeqda.view.projectview.TextNodeLightweightDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    TextNode text = (TextNode) element;//from w  w w .j a  va 2  s . c o m
    if (text.isActivated()) {
        decoration.addPrefix(PREFIX_ACTIVATED);
    } else {
        decoration.addPrefix(PREFIX_DEACTIVATED);
    }

    if (text.getCodeCounter() > 0)
        decoration.addSuffix(CODE_COUNT_PREFIX + text.getCodeCounter() + CODE_COUNT_POSTFIX);
}

From source file:net.sourceforge.eclipseccase.ui.ClearCaseDecorator.java

License:Open Source License

/**
 * Adds decoration for checked out state.
 * //from  ww w.ja va  2 s .c o  m
 * @param decoration
 */
private static void decorateCheckedOut(IDecoration decoration, String version) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateCheckedOut"); //$NON-NLS-1$
    }
    if (ClearCaseUIPreferences.decorateClearCaseElements())
        decoration.addOverlay(IMG_DESC_ELEMENT_BG, IDecoration.TOP_LEFT + IDecoration.UNDERLAY);
    decoration.addOverlay(IMG_DESC_CHECKED_OUT);
    if (ClearCaseUIPreferences.decorateElementStatesWithTextPrefix()) {
        decoration.addPrefix(ClearCaseUI.getTextPrefixDirty());
    }

    if (ClearCaseUIPreferences.decorateElementsWithVersionInfo() && null != version) {
        decoration.addSuffix("  " + version); //$NON-NLS-1$
    }
}

From source file:net.sourceforge.eclipseccase.ui.ClearCaseDecorator.java

License:Open Source License

/**
 * Adds decoration for dirty state./*  ww w  . j a  v a 2s.c om*/
 * 
 * @param decoration
 */
private static void decorateDirty(IDecoration decoration) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateDirty"); //$NON-NLS-1$
    }
    if (ClearCaseUIPreferences.decorateClearCaseElements())
        decoration.addOverlay(IMG_DESC_ELEMENT_BG, IDecoration.TOP_LEFT + IDecoration.UNDERLAY);
    decoration.addOverlay(IMG_DESC_DIRTY);
    if (ClearCaseUIPreferences.decorateElementStatesWithTextPrefix()) {
        decoration.addPrefix(ClearCaseUI.getTextPrefixDirty());
    }
}