List of usage examples for org.eclipse.jface.viewers IDecoration addSuffix
void addSuffix(String suffix);
From source file:br.ufmg.dcc.tabuleta.decorators.LightWeightDecorator.java
License:Open Source License
/** * Decorates elements belonging to the concern model in the JDT views. * @param pElement The element being decorated * @param pDecoration The decoration to add to the element's label * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) *///from ww w . j a va 2s . c o m public void decorate(Object pElement, IDecoration pDecoration) { boolean lDoDecorateSuffix = false; boolean lDoDecorateFont = false; List<String> lConcerns = new ArrayList<String>(); //Get the names of the concerns from the concern model String[] lConcernNames = Tabuleta.getDefault().getConcernModel().getConcernNames(); //For each concern, get the elements it contains for (String lConcernName : lConcernNames) { Set<Object> lCurrentConcernElements = Tabuleta.getDefault().getConcernModel().getElements(lConcernName); //if pElement is an element of the current concern //add the name of the concern to the list of concerns pElement belongs to if (lCurrentConcernElements.contains(pElement)) { int lDegree = Tabuleta.getDefault().getConcernModel().getDegree(lConcernName, pElement); int lThreshold = Tabuleta.getDefault().getPreferenceStore() .getInt(ConcernMapperPreferencePage.P_FILTER_THRESHOLD); boolean lFilter = Tabuleta.getDefault().getPreferenceStore() .getBoolean(ConcernMapperPreferencePage.P_FILTER_ENABLED); if ((lDegree >= lThreshold) || !lFilter) { lConcerns.add(lConcernName); lDoDecorateSuffix = true; lDoDecorateFont = true; } } else { if (getAllParents(lCurrentConcernElements, lConcernName).contains(pElement)) { lDoDecorateFont = true; } } } //sort the concerns in alphabetical order Collections.sort(lConcerns); //add the decorations if (lDoDecorateSuffix && Tabuleta.getDefault().getPreferenceStore() .getBoolean(ConcernMapperPreferencePage.P_SUFFIX_ENABLED)) { pDecoration.addSuffix(" " + lConcerns.toString()); } if (lDoDecorateFont && Tabuleta.getDefault().getPreferenceStore() .getBoolean(ConcernMapperPreferencePage.P_BOLD_ENABLED)) { pDecoration.setFont(PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry() .getBold("Text Font")); } }
From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.DockerFoundryDecorator.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 && CloudServerUtil.isCloudFoundryServer(s)) { IModule[] modules = moduleServer.getModule(); if (modules != null && modules.length == 1) { DockerFoundryServer server = getCloudFoundryServer(moduleServer.getServer()); if (server == null || !server.isConnected()) { return; }//www .j ava 2s . co m DockerFoundryApplicationModule 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) { // 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(Messages.DockerFoundryDecorator_SUFFIX_DEPLOYED_AS, application.getName())); } else { // decoration.addSuffix(Messages.DockerFoundryDecorator_SUFFIX_NOT_DEPLOYED); } if (module.getErrorMessage() != null) { decoration.addOverlay(DockerFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT); } } } } else if (element instanceof Server) { Server server = (Server) element; if (CloudServerUtil.isCloudFoundryServer(server)) { DockerFoundryServer cfServer = getCloudFoundryServer(server); if (cfServer != null && cfServer.getUsername() != null) { // 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$ // // } // } List<CloudServerURL> cloudUrls = CloudUiUtil .getAllUrls(cfServer.getBehaviour().getServer().getServerType().getId()); String url = cfServer.getUrl(); // decoration.addSuffix(NLS.bind(" {0}", // cfServer.getUsername())); for (CloudServerURL cloudUrl : cloudUrls) { if (cloudUrl.getUrl().equals(url)) { decoration.addSuffix(NLS.bind(" - {0}", cloudUrl.getUrl())); //$NON-NLS-1$ break; } } } } } }
From source file:com.amazonaws.eclipse.codedeploy.explorer.DeploymentGroupNodeDecorator.java
License:Apache License
public void decorate(Object element, IDecoration decoration) { if (element instanceof DeploymentGroupNode) { DeploymentGroupNode node = (DeploymentGroupNode) element; DeploymentInfo mostRecentDeployment = node.getMostRecentDeployment(); if (mostRecentDeployment != null) { decoration.addSuffix(" (" + mostRecentDeployment.getStatus() + ")"); }/* w ww . ja v a 2s.co m*/ } }
From source file:com.amazonaws.eclipse.explorer.cloudfront.DistributionDecorator.java
License:Apache License
public void decorate(Object element, IDecoration decoration) { if (element instanceof DistributionNode) { DistributionNode distributionNode = (DistributionNode) element; String origin = createOriginString(distributionNode.getDistributionSummary().getS3Origin(), distributionNode.getDistributionSummary().getCustomOrigin()); decoration.addSuffix(" " + origin); } else if (element instanceof StreamingDistributionNode) { StreamingDistributionNode distributionNode = (StreamingDistributionNode) element; String origin = createOriginString(distributionNode.getDistributionSummary().getS3Origin(), null); decoration.addSuffix(" " + origin); }/* w w w . j a v a 2 s . c o m*/ }
From source file:com.amazonaws.eclipse.explorer.dynamodb.DynamoDBTableNodeDecorator.java
License:Apache License
public void decorate(Object element, IDecoration decoration) { if (element instanceof DynamoDBTableNode) { DynamoDBTableNode dynamoDBTableNode = (DynamoDBTableNode) element; TableStatus tableStatus = dynamoDBTableNode.getTableStatus(); if (null != tableStatus) { decoration.addSuffix(" (" + tableStatus.toString() + ")"); }/*from w ww .j a v a 2 s . c o m*/ } }
From source file:com.amazonaws.eclipse.explorer.rds.DatabaseDecorator.java
License:Apache License
public void decorate(Object element, IDecoration decoration) { if (element instanceof DatabaseNode) { DatabaseNode databaseNode = (DatabaseNode) element; String engine = databaseNode.getDBInstance().getEngine(); String version = databaseNode.getDBInstance().getEngineVersion(); decoration.addSuffix(" [" + engine + " " + version + "]"); } else {//from ww w . ja va2s. co m System.out.println("Decorating: " + element); } }
From source file:com.amazonaws.eclipse.opsworks.explorer.ExplorerNodeDecorator.java
License:Apache License
public void decorate(Object element, IDecoration decoration) { if (element instanceof LayerElementNode) { List<Instance> instances = ((LayerElementNode) element).getInstancesInLayer(); int count = instances == null ? 0 : instances.size(); if (count > 1) { decoration.addSuffix(" (" + count + " instances)"); } else {/* ww w.jav a 2 s . com*/ decoration.addSuffix(" (" + count + " instance)"); } } if (element instanceof Instance) { Instance node = (Instance) element; decoration.addSuffix(String.format(" %s (%s)", node.getPublicIp(), node.getStatus())); } if (element instanceof App) { App node = (App) element; String appTypeName = APP_TYPES_MAPPING.get(node.getType()); if (appTypeName != null) { decoration.addSuffix(" (" + appTypeName + ")"); } } }
From source file:com.android.ide.eclipse.adt.internal.project.FolderDecorator.java
License:Open Source License
public void doDecoration(IDecoration decoration, String suffix) { decoration.addOverlay(mDescriptor, IDecoration.TOP_LEFT); if (suffix != null) { decoration.addSuffix(suffix); }//from w w w . ja v a2 s . c o m }
From source file:com.android.ide.eclipse.adt.project.FolderDecorator.java
License:Open Source License
public void doDecoration(IDecoration decoration, String suffix) { decoration.addOverlay(mDescriptor, IDecoration.TOP_LEFT); if (suffix != null) { decoration.addSuffix(suffix); // this is broken as it changes the color of the whole text, not only of the decoration. // TODO: figure out how to change the color of the decoration only. // ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme(); // ColorRegistry registry = theme.getColorRegistry(); // decoration.setForegroundColor( // registry.get("org.eclipse.jdt.ui.ColoredLabels.decorations")); //$NON-NLS-1$ }//from w w w . jav a 2 s .co m }
From source file:com.aptana.git.ui.internal.GitLightweightDecorator.java
License:Open Source License
private void decorateProject(IDecoration decoration, final IResource resource) { GitRepository repo = getRepo(resource); if (repo == null) { return;// www .j a va 2 s .co m } String branch = repo.currentBranch(); // Adds a temporal cache per repo/branch for this data so we // don't recalculate for a ton of projects, Just store it for like a second...? RepoBranch repoBranch = new RepoBranch(repo, branch); TimestampedString result = cache.get(repoBranch); if (result != null && !result.isOlderThan(1000)) { decoration.addSuffix(result.string); return; } cache.remove(repoBranch); StringBuilder builder = new StringBuilder(); builder.append(" ["); //$NON-NLS-1$ builder.append(branch); String[] commits = repo.commitsAhead(branch); if (commits != null && commits.length > 0) { builder.append('+').append(commits.length); } else { // Happens way less frequently. usually only if you've fetched but haven't merged (which usually happens // when you pull on one branch and then switch back to another that had changes not yet merged in yet) commits = repo.commitsBehind(branch); if (commits != null && commits.length > 0) builder.append('-').append(commits.length); } builder.append(']'); String value = builder.toString(); cache.put(repoBranch, new TimestampedString(value)); decoration.addSuffix(value); }