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

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

Introduction

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

Prototype

int TOP_LEFT

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

Click Source Link

Document

Constants for placement of image decorations.

Usage

From source file:org.sourcepit.b2eclipse.provider.LabelProviderForPreview.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    final StyledString label = new StyledString();
    Node node = ((Node) cell.getElement());

    if (node instanceof NodeProject) {
        label.append(node.getName());/*from w w  w .  j  a  v  a 2s  .co  m*/
        cell.setImage(PlatformUI.getWorkbench().getSharedImages()
                .getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT));
    }

    if (node instanceof NodeModuleProject) {
        label.append(node.getName() + " ");
        label.append(Messages.msgModuleProject, StyledString.DECORATIONS_STYLER);
        cell.setImage(PlatformUI.getWorkbench().getSharedImages()
                .getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT));
    }

    if (node instanceof NodeWorkingSet) {
        ImageRegistry imageRegistry = Activator.getDefault().getImageRegistry();
        String key = "foo";
        Image i = imageRegistry.get(key);
        if (i == null) {
            DecorationOverlayIcon icon = new DecorationOverlayIcon(
                    Activator.getImageFromPath("org.eclipse.ui", "$nl$/icons/full/obj16/fldr_obj.gif"),
                    AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.jdt.ui",
                            "$nl$/icons/full/ovr16/java_ovr.gif"),
                    IDecoration.TOP_LEFT);
            imageRegistry.put(key, icon.createImage());
        }
        label.append(node.getName());
        cell.setImage(imageRegistry.get(key));
        // TODO maybe find a better icon
    }

    cell.setText(label.toString());
    cell.setStyleRanges(label.getStyleRanges());

    super.update(cell);
}

From source file:org.springframework.ide.eclipse.aop.ui.decorator.AopReferenceModelImageDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    // add the orange triangle to the icon if this method,
    // class or aspect is advised
    if ((element instanceof IMethod || element instanceof SourceType)) {
        IJavaElement je = (IJavaElement) element;
        IJavaProject jp = je.getJavaProject();
        // only query the model if the element is in an Spring project
        if ((jp != null) && SpringCoreUtils.isSpringProject(jp.getProject())) {
            if (je instanceof IMethod && Activator.getModel().isAdvised(je)) {
                decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ADVICE, IDecoration.TOP_LEFT);
            }//from   w  w  w  . j  a  va2  s .c  om
        }
    } else if (element instanceof BeanMethodReferenceNode
            && Activator.getModel().isAdvised(((BeanMethodReferenceNode) element).getJavaElement())) {
        decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ADVICE, IDecoration.TOP_LEFT);
    } else if (element instanceof AdviceAopTargetMethodNode) {
        decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ADVICE, IDecoration.TOP_LEFT);
    } else if (element instanceof AdviceAopTargetBeanNode) {
        decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ADVICE, IDecoration.TOP_LEFT);
    } else if (element instanceof BeanReferenceNode
            && Activator.getModel().isAdvised(((BeanReferenceNode) element).getBean())) {
        decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ADVICE, IDecoration.TOP_LEFT);
    } else if (element instanceof AdvisedAopSourceMethodNode) {
        if (Activator.getModel().isAdvised(((AdvisedAopSourceMethodNode) element).getReference().getSource()))
            decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ADVICE, IDecoration.TOP_LEFT);
    } else if (element instanceof AdviceRootAopReferenceNode) {
        List<IAopReference> references = ((AdviceRootAopReferenceNode) element).getReference();
        for (IAopReference reference : references) {
            if (reference.getDefinition() instanceof IAnnotationAopDefinition) {
                decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ANNOTATION, IDecoration.BOTTOM_LEFT);
                break;
            }
        }
    } else if (element instanceof AdvisedAopSourceNode) {
        IAopReference reference = ((AdvisedAopSourceNode) element).getReference();
        if (reference.getDefinition() instanceof IAnnotationAopDefinition) {
            decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ANNOTATION, IDecoration.BOTTOM_LEFT);
        }
    } else if (element instanceof AdviceDeclareParentAopSourceNode) {
        IAopReference reference = ((AdviceDeclareParentAopSourceNode) element).getReference();
        if (reference.getDefinition() instanceof IAnnotationAopDefinition) {
            decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ANNOTATION, IDecoration.BOTTOM_LEFT);
        }
    } else if (element instanceof AdvisedDeclareParentAopSourceNode) {
        IAopReference reference = ((AdvisedDeclareParentAopSourceNode) element).getReference();
        if (reference.getDefinition() instanceof IAnnotationAopDefinition) {
            decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ANNOTATION, IDecoration.BOTTOM_LEFT);
        }
    }
    // add overlay to IBeans
    else if (element instanceof IBean) {
        IBean bean = (IBean) element;
        if (Activator.getModel().isAdvised(bean)) {
            decoration.addOverlay(AopReferenceModelImages.DESC_OVR_ADVICE, IDecoration.TOP_LEFT);
        }
    }

    if (element instanceof IReferenceNode && ((IReferenceNode) element).getReferenceParticipant() != null) {
        super.decorate(((IReferenceNode) element).getReferenceParticipant(), decoration);
    }
}

From source file:org.springframework.ide.eclipse.beans.ui.model.BeansModelLabelDecorator.java

License:Open Source License

/**
 * Adds decorations to {@link Bean}s.//from w  ww  .  ja v  a2  s  .com
 * @since 2.0.1
 */
private void decorateBean(Bean bean, IDecoration decoration) {
    BeanDefinition bd = bean.getBeanDefinition();
    if (bean.isChildBean()) {
        decoration.addOverlay(BeansUIImages.DESC_OVR_CHILD, IDecoration.TOP_RIGHT);
    }
    if (bean.isFactory()) {
        decoration.addOverlay(BeansUIImages.DESC_OVR_FACTORY, IDecoration.TOP_LEFT);
    }
    if (bean.isAbstract()) {
        decoration.addOverlay(BeansUIImages.DESC_OVR_ABSTRACT, IDecoration.BOTTOM_RIGHT);
    }
    if (!bean.isSingleton()) {
        decoration.addOverlay(BeansUIImages.DESC_OVR_PROTOTYPE, IDecoration.BOTTOM_RIGHT);
    }
    if (bd instanceof AnnotatedBeanDefinition) {
        decoration.addOverlay(BeansUIImages.DESC_OVR_ANNOTATION, IDecoration.BOTTOM_LEFT);
    }
}

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

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    /**/*from   w w  w  .j a  v a  2  s.co 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("feature")) {
        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.totori.decorators.StepsFileDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    /**//from w ww. j av a 2  s  . 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: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 .  j  a  va  2s  . c  om*/
    }
    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());
}