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

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

Introduction

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

Prototype

int BOTTOM_RIGHT

To view the source code for org.eclipse.jface.viewers IDecoration BOTTOM_RIGHT.

Click Source Link

Document

Constant for the bottom right quadrant.

Usage

From source file:org.talend.mdm.repository.ui.navigator.MDMServerDecorator.java

License:Open Source License

private void decorateModifiedObject(IRepositoryViewObject viewObj, IDecoration decoration) {
    CommandStack stack = CommandManager.getInstance().findCommandStack(viewObj.getId());
    if (stack != null) {
        ICommand command = stack.getValidDeployCommand();
        switch (command.getCommandType()) {
        case ICommand.CMD_ADD:
            decoration.addOverlay(IMG_NEW, IDecoration.BOTTOM_RIGHT);
            return;
        case ICommand.CMD_DELETE:
            decoration.addOverlay(IMG_DELETE, IDecoration.BOTTOM_RIGHT);
            return;
        case ICommand.CMD_MODIFY:
        case ICommand.CMD_RENAME:
            decoration.addPrefix("> "); //$NON-NLS-1$
            decoration.addOverlay(IMG_MODIFY, IDecoration.BOTTOM_RIGHT);
            return;

        }//from w  w w.j  a  va 2  s  .  c  o m
    }
}

From source file:org.ukku.geps.ui.utils.ImageLib.java

License:Open Source License

public static ImageDescriptor createIcon(Image originalImg, ImageDescriptor decorateImg) {
    return new DecorationOverlayIcon(originalImg, decorateImg, IDecoration.BOTTOM_RIGHT);
}

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;//from  w w w .jav  a 2  s .  c  o  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());
}