List of usage examples for org.eclipse.jface.viewers IDecoration addSuffix
void addSuffix(String suffix);
From source file:unc.lib.cdr.workbench.views.OriginalAndDivDecorator.java
License:Apache License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof OriginalStub) { decorateOriginalStub((OriginalStub) element, decoration); return;// www . ja v a 2s. co m } OriginalFileStore r = null; boolean isDiv = false; boolean isFile = false; // added/captured, queued/staged BR List<String> labels = new ArrayList<String>(); if (element instanceof OriginalFileStore) { r = (OriginalFileStore) element; if (r.isAttached()) { IFileInfo info = r.fetchInfo(); if (info.exists() && !info.isDirectory()) isFile = true; } // add prefix of "../" to these when not under volume root if (r.getWrapped().getParent() != null) { if (r.getOriginalStub().getStores().contains(r)) { if (!r.getOriginalStub().getVolumeRootStore().getWrapped().equals(r.getWrapped().getParent())) { decoration.addPrefix(".../"); } } } } else if (DivTypeImpl.class.isInstance(element)) { isDiv = true; DivType d = (DivType) element; if (METSConstants.Div_File.equals(d.getTYPE())) { isFile = true; } Object adapted = Platform.getAdapterManager().getAdapter(d, OriginalFileStore.class); if (adapted != null && adapted instanceof OriginalFileStore) { r = (OriginalFileStore) adapted; } // Descriptions Decor boolean hasUserEdited = false; boolean hasCrosswalked = false; for (MdSecType md : d.getDmdSec()) { String st = md.getSTATUS(); if (METSConstants.MD_STATUS_CROSSWALK_LINKED.equals(st) || METSConstants.MD_STATUS_CROSSWALK_USER_LINKED.equals(st)) { hasCrosswalked = true; } else if (METSConstants.MD_STATUS_USER_EDITED.equals(st)) { hasUserEdited = true; } } if (hasUserEdited) { decoration.addOverlay(Icon.UserEditedDecor.getImageDescriptor(), IDecoration.TOP_RIGHT); } else if (hasCrosswalked) { decoration.addOverlay(Icon.CrosswalkedDecor.getImageDescriptor(), IDecoration.TOP_RIGHT); } // ACL Decor boolean hasCrosswalkedACL = false; boolean hasUserACL = false; for (MdSecType md : d.getMdSec()) { if (MetsPackage.eINSTANCE.getAmdSecType_RightsMD().equals(md.eContainingFeature())) { String st = md.getSTATUS(); if (METSConstants.MD_STATUS_CROSSWALK_LINKED.equals(st) || METSConstants.MD_STATUS_CROSSWALK_USER_LINKED.equals(st)) { hasCrosswalkedACL = true; } else if (METSConstants.MD_STATUS_USER_EDITED.equals(st)) { hasUserACL = true; } } } if (hasUserACL) { decoration.addOverlay(Icon.ACLDecor.getImageDescriptor(), IDecoration.TOP_LEFT); } else if (hasCrosswalkedACL) { decoration.addOverlay(Icon.ACLGrayDecor.getImageDescriptor(), IDecoration.TOP_LEFT); } // add labels for links of which this div is the object for (SmLinkType sml : METSUtils.getObjectLinks(d)) { labels.add(METSConstants.getLinkForArcRole(sml.getArcrole()).label); } } ImageDescriptor overlay = null; if (r != null && r.getProject() != null && r.getProject().isOpen()) { boolean captured = false; if (r.isAttached() && isFile) { long byteLength = r.fetchInfo().getLength(); labels.add(IResourceConstants.humanReadableByteCount(byteLength, true)); } if (r.getMetsDivType() != null) { captured = true; if (!isDiv) { labels.add("captured"); } } // staged location == original location SharedStagingArea prestage = StagingPlugin.getDefault().getStages() .findMatchingArea(r.getWrapped().toURI()); if (prestage != null && r.getStagingLocatorType() == null) { labels.add("pre-staged: " + prestage.getName()); } if (r.getStagingLocatorType() != null) { // captured file (original or the div) overlay = Icon.StagedDecor.getImageDescriptor(); URI uri = URI.create(r.getStagingLocatorType().getHref()); if (uri.isAbsolute()) { labels.add("staged"); } else { labels.add("locally staged"); } } else { if (captured && isFile) { overlay = Icon.CaptureDecor.getImageDescriptor(); labels.add("queued"); } } } else { if (isDiv) { labels.add("added"); } } if (overlay != null) { decoration.addOverlay(overlay, IDecoration.BOTTOM_RIGHT); } StringBuilder sb = new StringBuilder(); if (labels.size() > 0) { sb.append(" ["); sb.append(labels.remove(0)); for (String label : labels) { sb.append(" ").append(label); } sb.append("]"); } decoration.addSuffix(sb.toString()); }
From source file:unc.lib.cdr.workbench.views.OriginalAndDivDecorator.java
License:Apache License
private void decorateOriginalStub(OriginalStub stub, IDecoration decoration) { decoration.addPrefix("Originals on "); List<String> labels = new ArrayList<String>(); // ejected overlay for detached disks if (!stub.isAttached()) { decoration.addOverlay(Icon.EjectedDecore.getImageDescriptor(), IDecoration.TOP_RIGHT); labels.add("ejected"); }// w w w. j av a 2s . c o m labels.add(stub.getVolumeType()); if (labels.size() > 0) { // decoration.setForegroundColor(org.eclipse.swt.graphics.); StringBuilder sb = new StringBuilder(); sb.append(" ["); sb.append(labels.remove(0)); for (String label : labels) { sb.append(" ").append(label); } sb.append("]"); decoration.addSuffix(sb.toString()); } }
From source file:unc.lib.cdr.workbench.xwalk.MetadataCompartmentDecorator.java
License:Apache License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof MetadataCompartment) { MetadataCompartment mc = (MetadataCompartment) element; decoration.addSuffix(" " + mc.metadataSections.size() + " records"); }/*from ww w .ja v a 2s . c om*/ }