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

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

Introduction

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

Prototype

void addOverlay(ImageDescriptor overlay, int quadrant);

Source Link

Document

Adds an overlay to the element's image.

Usage

From source file:org.totori.decorators.StepsFileDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    /**//from w w  w . java  2s. c o m
     * Checks that the element is an IResource with the 'Read-only' attribute
     * and adds the decorator based on the specified image description and the
     * integer representation of the placement option.
     */
    IResource resource = (IResource) element;
    if (resource.getFileExtension().equalsIgnoreCase("rb") && resource.getName().endsWith("_steps")) {
        URL url = FileLocator.find(Platform.getBundle("org.totori"), new Path(iconPath), null); //NON-NLS-1

        if (url == null)
            return;
        descriptor = ImageDescriptor.createFromURL(url);
        quadrant = IDecoration.TOP_LEFT;
        decoration.addOverlay(descriptor, quadrant);
    }
}

From source file:org.xtuml.bp.ui.explorer.decorators.SynchronizationDecorator.java

License:Apache License

@Override
public void decorate(Object element, IDecoration decoration) {
    // rather than check the class for the isSynchronizedMethod through
    // reflection, only consider the known classes
    if (!isSynchronized(element)) {
        int v_dialect = Pref_c.Getactiondialect("bridgepoint_prefs_default_action_language_dialect");

        if ((v_dialect == Actiondialect_c.masl)) {
            // For MASL projects we automatically synchronize
            if (element instanceof SystemModel_c) {
                SystemModel_c sys = (SystemModel_c) element;
                PullSynchronizationChanges sync = new PullSynchronizationChanges(false, sys);
                sync.run(null);/*from  w  ww  .ja v a2s  .c o  m*/
            }
        } else {
            decoration.addOverlay(SYNC_OVERLAY, IDecoration.BOTTOM_LEFT);
        }
    }
}

From source file:tinyos.dlrc.properties.source.SourceFolderDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IAdaptable) {
        IFolder folder = (IFolder) ((IAdaptable) element).getAdapter(IFolder.class);
        if (folder != null) {
            IProject project = folder.getProject();
            try {
                if (project.hasNature(TinyOSCore.NATURE_ID)) {
                    TinyOSPlugin plugin = TinyOSPlugin.getDefault();
                    if (plugin != null) {
                        NesCPath path = plugin.getPaths(project);
                        IFolder[] folders = path.getSourceFolders();
                        for (IFolder check : folders) {
                            if (check.equals(folder)) {
                                decoration.addOverlay(image, IDecoration.TOP_RIGHT);
                                return;
                            }/*w w  w .  j  a va  2s .com*/
                        }
                    }
                }
            } catch (CoreException ex) {
                // swallow, it is not *that* important that the icons are correct...
            }
        }
    }
}

From source file:ts.eclipse.ide.internal.ui.navigator.BuildpathIndicatorLabelDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    ImageDescriptor overlay = getOverlay(element);
    if (overlay != null) {
        decoration.addOverlay(overlay, IDecoration.TOP_RIGHT);
    }/* w w  w  .  j a v a  2  s  . c o m*/
}

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;//  w  ww.  j  a va  2  s.  com
    }
    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");
    }/*from w  w w .  ja v a2 s .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());
    }
}