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

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

Introduction

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

Prototype

void addSuffix(String suffix);

Source Link

Document

Adds a suffix to the element's label.

Usage

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

License:Open Source License

/**
 * Adds decoration for hijaced state./*w  ww. j  av  a  2  s. com*/
 * 
 * @param decoration
 */
private static void decorateHijacked(IDecoration decoration, String version) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateHijacked"); //$NON-NLS-1$
    }
    if (ClearCaseUIPreferences.decorateClearCaseElements())
        decoration.addOverlay(IMG_DESC_ELEMENT_BG, IDecoration.TOP_LEFT + IDecoration.UNDERLAY);
    if (ClearCaseUIPreferences.decorateHijackedElements()) {
        decoration.addOverlay(IMG_DESC_HIJACKED);
    }
    if (ClearCaseUIPreferences.decorateElementStatesWithTextPrefix()) {
        decoration.addPrefix(ClearCaseUI.getTextPrefixHijacked());
    }
    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 links.//from   w ww  .j  a  va2 s.  c o  m
 * 
 * @param decoration
 * @param isLinkTargetCheckedOut
 */
private static void decorateLink(IDecoration decoration, String linkTarget, boolean isValidLinkTarget,
        boolean isLinkTargetCheckedOut) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateLink"); //$NON-NLS-1$
    }
    if (ClearCaseUIPreferences.decorateClearCaseElements())
        decoration.addOverlay(IMG_DESC_ELEMENT_BG, IDecoration.TOP_LEFT + IDecoration.UNDERLAY);
    if (isLinkTargetCheckedOut) {
        decoration.addOverlay(IMG_DESC_CHECKED_OUT);
    } else if (isValidLinkTarget) {
        decoration.addOverlay(IMG_DESC_LINK);
    } else {
        decoration.addOverlay(IMG_DESC_LINK_WARNING);
    }

    decoration.addSuffix(" --> " + linkTarget); //$NON-NLS-1$
}

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

License:Open Source License

/**
 * Adds decoration for the version.//from  w  w w . j a  va  2  s . c  o m
 * 
 * @param decoration
 */
private static void decorateVersion(IDecoration decoration, String version) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateVersion"); //$NON-NLS-1$
    }
    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 the view name.//  w  w w  .j av a 2  s .c  o m
 * 
 * @param decoration
 */
private static void decorateViewName(IDecoration decoration, String viewName) {
    if (ClearCaseUI.DEBUG_DECORATION) {
        ClearCaseUI.trace(DECORATOR, "  decorateViewName"); //$NON-NLS-1$
    }
    if (ClearCaseUIPreferences.decorateProjectsWithViewInfo() && null != viewName) {
        decoration.addSuffix(" [" + viewName + "]"); //$NON-NLS-1$ //$NON-NLS-2$
    }
}

From source file:nexcore.tool.uml.ui.project.explorer.ExplorerDecorator.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object,
 *      org.eclipse.jface.viewers.IDecoration)
 *///from w w w. ja va 2s  .  c o m
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IProject) {
        IProject project = (IProject) element;
        if (UMLNature.hasUMLNature(project)) {
            decoration.addOverlay(
                    UiCorePlugin.getImageDescriptor(IConstantImageRegistry.LOCATION_OVER_DECORATOR));
        }
        return;
    }

    ITreeNode treeNode = null;
    if (!(element instanceof ITreeNode)) {
        return;
    } else {
        treeNode = (ITreeNode) element;
    }
    EObject eobject = treeNode.getEObject();

    Resource resource = null;
    if (eobject == null) {
        return;
    }

    if (element instanceof ITreeNode) {
        // TODO pns ??  ?  .
        // createValidationDecorator(eobject, decoration);
    }

    //        if (ALMPreference.useCollaboration() && ProjectUtil.useCollaboration(eobject)) {
    //            if (MetaContentUtil.hasMetaContent(eobject)) {
    //                decoration.addOverlay(UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_NCP_DECORATOR),
    //                    IDecoration.BOTTOM_RIGHT);
    //            }
    //        }

    if (eobject instanceof Model) {
        resource = eobject.eResource();
        // 2011-10-26 nspark
        // ?? ?  ?? ? ? 
        Model model = (Model) eobject;
        for (ProfileApplication profileApplication : model.getProfileApplications()) {
            if (profileApplication.getAppliedProfile() != null) {
                Profile newProfile = profileApplication.getAppliedProfile();
                if (newProfile.eIsProxy()) {
                    decoration.addOverlay(
                            UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_ERROR_OVER));
                    break;
                }
            }
        }
        boolean active = treeNode.isActive();
        if (!active) {
            decoration.addOverlay(UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_CLOSE_MODEL));
        }
    } else if (element instanceof UMLFileTreeNode) {
        resource = eobject.eResource();

        // 2011-08-03 nspark
        // project explorer ? ???   ? ? 
        boolean validationCheck = UiCorePlugin.getDefault().getPreferenceStore()
                .getBoolean("MODEL_VALIDATION_CHECK");
        if (validationCheck) {
            if (element instanceof UMLFileTreeNode) {
                treeNode = (UMLFileTreeNode) element;
                boolean isValid = treeNode.isValid();
                if (!isValid) {
                    decoration.addOverlay(
                            UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_WARNING_OVER));
                }
            }
        }
    } else if (eobject instanceof Diagram) {

        // 2011-08-09 ?
        // diagram? (dangling)  ? ? 
        Diagram diagram = (Diagram) eobject;

        boolean isValid = true;
        for (Iterator<AbstractNode> iter = diagram.getNodeList().iterator(); iter.hasNext();) {
            AbstractNode abstractNode = iter.next();
            if (NodeType.NOTE.equals(abstractNode.getNodeType())) {
                return;
            }

            EObject umlModel = abstractNode.getUmlModel();
            if (umlModel == null) {
                isValid = false;
            } else if (DomainUtil.isProxy(umlModel)) {
                isValid = false;
            }
        }

        if (!isValid) {
            decoration
                    .addOverlay(UiCorePlugin.getImageDescriptor(IConstantImageRegistry.ICONNAME_WARNING_OVER));
        }
    } else {
        return;
    }

    if (resource == null) {
        return;
    }

    if (resource.isModified()) {
        decoration.addSuffix(UICoreConstant.PROJECT_CONSTANTS__BLANK + UICoreConstant.PROJECT_CONSTANTS__STAR);
    } else {
        // crossReference ?? dirty ? ?
        if (resource.getContents() != null && resource.getContents().size() > 0) {
            EObject contents = resource.getContents().get(0);
            boolean dirtyOfCrossReference = ResourceManager.getInstance().isDirtyOfCrossReference(contents);
            if (dirtyOfCrossReference) {
                decoration.addSuffix(
                        UICoreConstant.PROJECT_CONSTANTS__BLANK + UICoreConstant.PROJECT_CONSTANTS__STAR);
            } else {
                decoration.addSuffix(UICoreConstant.PROJECT_CONSTANTS__EMPTY_STRING);
            }
        } else {
            decoration.addSuffix(UICoreConstant.PROJECT_CONSTANTS__EMPTY_STRING);
        }
    }
}

From source file:org.apache.hadoop.eclipse.ui.internal.hdfs.HDFSLightweightLabelDecorator.java

License:Apache License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IResource) {
        IResource r = (IResource) element;
        URI locationURI = r.getLocationURI();
        if (locationURI != null && HDFSURI.SCHEME.equals(locationURI.getScheme())) {
            try {
                if (r instanceof IProject) {
                    final HDFSManager hdfsManager = HDFSManager.INSTANCE;
                    HDFSServer server = hdfsManager.getServer(locationURI.toString());
                    if (server != null) {
                        String serverUrl = server.getUri();
                        String userId = server.getUserId();
                        if (userId == null) {
                            try {
                                userId = hdfsManager.getClient(serverUrl).getDefaultUserAndGroupIds().get(0);
                            } catch (Throwable e) {
                                userId = null;
                            }// w  w w  . jav a  2  s .  c o  m
                        }
                        if (userId == null)
                            userId = "";
                        else
                            userId = userId + "@";
                        if (serverUrl != null) {
                            try {
                                URI uri = new URI(serverUrl);
                                serverUrl = serverUrl.substring(uri.getScheme().length() + 3);
                            } catch (Throwable e) {
                            }
                        }
                        if (serverUrl.endsWith("/"))
                            serverUrl = serverUrl.substring(0, serverUrl.length() - 1);
                        decoration.addSuffix(" " + userId + serverUrl);
                        if (server.getStatusCode() == ServerStatus.DISCONNECTED_VALUE)
                            decoration.addOverlay(org.apache.hadoop.eclipse.ui.Activator.IMAGE_OFFLINE_OVR);
                        else
                            decoration.addOverlay(org.apache.hadoop.eclipse.ui.Activator.IMAGE_ONLINE_OVR);
                    } else
                        decoration.addSuffix(" [Unknown server]");
                } else
                    decorate((HDFSFileStore) EFS.getStore(locationURI), decoration);
            } catch (CoreException e) {
                logger.debug(e.getMessage(), e);
            }
        }
    }
}

From source file:org.apache.sling.ide.eclipse.ui.internal.JcrNodeDecorator.java

License:Apache License

@Override
public void decorate(Object element, IDecoration decoration) {

    if (element instanceof JcrNode) {
        JcrNode node = (JcrNode) element;
        if (node.getPrimaryType() != null) {
            decoration.addSuffix(" [" + node.getPrimaryType() + "]");
        }//w w  w  .j a v a  2s .  c  o  m

        if (node instanceof SyncDir) {
            decoration.addOverlay(SharedImages.CONTENT_OVERLAY, IDecoration.BOTTOM_RIGHT);
        }
    }
}

From source file:org.cloudfoundry.ide.eclipse.internal.server.ui.CloudFoundryDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof ModuleServer) {
        ModuleServer moduleServer = (ModuleServer) element;
        IServer s = moduleServer.getServer();
        if (s != null && isCloudFoundryServerType(s)) {
            IModule[] modules = moduleServer.getModule();
            if (modules != null && modules.length == 1) {
                CloudFoundryServer server = getCloudFoundryServer(moduleServer.getServer());
                if (server == null || !server.isConnected()) {
                    return;

                }//from ww w.  j ava  2  s  . com
                ApplicationModule module = server.getApplication(modules[0]);
                if (module.getLocalModule() != null) {
                    // show local information?
                }

                CloudApplication application = module.getApplication();
                // if (application != null) {
                // decoration.addSuffix(NLS.bind("  [{0}, {1}, {2}]",
                // new Object[]{application.getName(),
                // getAppStateString(application.getState()),
                // application.getUris()}));
                // } else if (module.getName() != null) {
                // decoration.addSuffix(NLS.bind("  [{0}]",
                // module.getName()));
                // }
                if (application != null) {
                    decoration.addSuffix(NLS.bind(" - Deployed as {0}", application.getName()));
                } else {
                    decoration.addSuffix(" - Not Deployed");
                }

                if (module.getErrorMessage() != null) {
                    decoration.addOverlay(CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT);
                }
            }
        }
    } else if (element instanceof Server) {
        Server server = (Server) element;
        if (isCloudFoundryServerType(server)) {
            CloudFoundryServer cfServer = getCloudFoundryServer(server);
            if (cfServer != null && cfServer.getUsername() != null) {
                // decoration.addSuffix(NLS.bind("  [{0}, {1}]",
                // cfServer.getUsername(), cfServer.getUrl()));
                List<CloudURL> cloudUrls = CloudUiUtil
                        .getAllUrls(cfServer.getBehaviour().getServer().getServerType().getId());
                String url = cfServer.getUrl();
                //               decoration.addSuffix(NLS.bind("  {0}", cfServer.getUsername()));
                for (CloudURL cloudUrl : cloudUrls) {
                    if (cloudUrl.getUrl().equals(url)) {
                        decoration.addSuffix(NLS.bind(" - {0}", cloudUrl.getUrl()));
                        break;
                    }
                }
            }
        }
    }
}

From source file:org.cloudfoundry.ide.eclipse.server.ui.internal.CloudFoundryDecorator.java

License:Open Source License

public void decorate(Object element, final IDecoration decoration) {
    if (element instanceof ModuleServer) {
        ModuleServer moduleServer = (ModuleServer) element;
        IServer s = moduleServer.getServer();
        if (s != null && CloudServerUtil.isCloudFoundryServer(s)) {
            IModule[] modules = moduleServer.getModule();
            if (modules != null && modules.length == 1) {
                CloudFoundryServer server = getCloudFoundryServer(moduleServer.getServer());
                if (server == null || !server.isConnected()) {
                    return;

                }// w w  w .  j av a  2  s.  c  om
                CloudFoundryApplicationModule module = server.getExistingCloudModule(modules[0]);

                // module may no longer exist
                if (module == null) {
                    return;
                }

                if (module.getLocalModule() != null) {
                    // show local information?
                }

                CloudApplication application = module.getApplication();
                if (application != null) {
                    String deployedAppName = application.getName();
                    IModule localModule = module.getLocalModule();
                    // Only show "Deployed as" when the local module name does not match the deployed app name.
                    if (localModule != null && !localModule.getName().equals(deployedAppName)) {
                        decoration.addSuffix(
                                NLS.bind(Messages.CloudFoundryDecorator_SUFFIX_DEPLOYED_AS, deployedAppName));
                    } else {
                        decoration.addSuffix(Messages.CloudFoundryDecorator_SUFFIX_DEPLOYED);
                    }
                } else {
                    decoration.addSuffix(Messages.CloudFoundryDecorator_SUFFIX_NOT_DEPLOYED);
                }

                if (module.getErrorMessage() != null) {
                    decoration.addOverlay(CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT);
                }
            }
        }
    } else if (element instanceof Server) {
        Server server = (Server) element;
        if (CloudServerUtil.isCloudFoundryServer(server)) {
            final CloudFoundryServer cfServer = getCloudFoundryServer(server);
            if (cfServer != null && cfServer.getUsername() != null) {
                // This now runs on a non UI thread, so we need to join this
                // update to a UI thread.
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        // decoration.addSuffix(NLS.bind("  [{0}, {1}]",
                        // cfServer.getUsername(), cfServer.getUrl()));
                        if (cfServer.hasCloudSpace()) {
                            CloudFoundrySpace clSpace = cfServer.getCloudFoundrySpace();
                            if (clSpace != null) {
                                decoration.addSuffix(
                                        NLS.bind(" - {0} - {1}", clSpace.getOrgName(), clSpace.getSpaceName())); //$NON-NLS-1$
                            }
                        }
                        try {
                            List<AbstractCloudFoundryUrl> cloudUrls = CloudServerUIUtil.getAllUrls(
                                    cfServer.getBehaviour().getServer().getServerType().getId(), null);
                            String url = cfServer.getUrl();
                            // decoration.addSuffix(NLS.bind("  {0}",
                            // cfServer.getUsername()));
                            for (AbstractCloudFoundryUrl cloudUrl : cloudUrls) {
                                if (cloudUrl.getUrl().equals(url)) {
                                    decoration.addSuffix(NLS.bind(" - {0}", cloudUrl.getUrl())); //$NON-NLS-1$
                                    break;
                                }
                            }
                        } catch (CoreException e) {
                            CloudFoundryServerUiPlugin.logError(e);
                        }
                    }
                });
            }
        }
    }
}

From source file:org.cs3.pdt.navigator.internal.decorators.EntryPointDecoratorContributor.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (!(element instanceof IFile)) {
        return;//from   w w w.j a  va  2  s. com
    }

    PDTCommonPlugin.getDefault().addDecorator(this);

    IFile file = (IFile) element;
    try {
        if (file.exists()) {
            String isEntryPoint = file.getPersistentProperty(PDTCommonPlugin.ENTRY_POINT_KEY);

            if (isEntryPoint != null && isEntryPoint.equalsIgnoreCase("true")) {
                decoration.addOverlay(ImageRepository.getImageDescriptor(ImageRepository.PROLOG_ENTRY_POINT));
                decoration.addSuffix(ENTRY_POINT_SUFFIX);
            }
        }

    } catch (CoreException e) {
        e.printStackTrace();
    }

}