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

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

Introduction

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

Prototype

int BOTTOM_LEFT

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

Click Source Link

Document

Constant for the bottom left quadrant.

Usage

From source file:org.overture.ide.ui.navigator.ProblemLabelDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IResource) {
        IResource resource = (IResource) element;
        if (resource instanceof IProject) {
            if (!((IProject) resource).isOpen())
                return;
        }/*  w  w  w . j a v  a  2 s. c  o m*/

        try {
            if (!resource.exists()) {
                return;//Nothing to do then.
            }
            IMarker[] markers = resource.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
            if (markers.length > 0) {
                if (containsSeverity(markers, IMarker.SEVERITY_ERROR)) {
                    Image image = FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage();
                    decoration.addOverlay(DecorationOverlayIcon.createFromImage(image),
                            IDecoration.BOTTOM_LEFT);
                } else if (containsSeverity(markers, IMarker.SEVERITY_WARNING)) {
                    Image image = FieldDecorationRegistry.getDefault()
                            .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage();
                    decoration.addOverlay(DecorationOverlayIcon.createFromImage(image),
                            IDecoration.BOTTOM_LEFT);
                }
            }

        } catch (CoreException e) {
            VdmUIPlugin.log("Faild to decorate element: " + element, e);
        }

    }

}

From source file:org.parallelj.designer.validation.decorators.ParallelJProjectIconDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (!(element instanceof IJavaProject)) {
        return;//from ww  w.  j  av  a 2s .c  o m
    }
    if (this.projectDecorationImageDescriptor == null) {
        this.projectDecorationImageDescriptor = DiagramValidationPlugin.getImageDescriptor(DECORATOR_PATH);
    }
    if (this.projectDecorationImageDescriptor != null) {
        decoration.addOverlay(this.projectDecorationImageDescriptor, IDecoration.BOTTOM_LEFT);
    }
}

From source file:org.python.pydev.navigator.decorator.ProblemsLabelDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    int errorState = getErrorState(element);
    if (errorState == IMarker.SEVERITY_ERROR) {
        decoration.addOverlay(PydevPlugin.getImageCache().getDescriptor(UIConstants.ERROR_DECORATION),
                IDecoration.BOTTOM_LEFT);

    } else if (errorState == IMarker.SEVERITY_WARNING) {
        decoration.addOverlay(PydevPlugin.getImageCache().getDescriptor(UIConstants.WARNING_DECORATION),
                IDecoration.BOTTOM_LEFT);
    }/*from  w  w  w .  j  av  a  2  s . c  o  m*/
}

From source file:org.python.pydev.navigator.PythonLabelProvider.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
 *///from w  w w. j ava2 s. c o m
public Image getImage(Object element) {
    if (element instanceof PythonProjectSourceFolder) {
        return SharedUiPlugin.getImageCache().get(UIConstants.PROJECT_SOURCE_FOLDER_ICON);
    }
    if (element instanceof PythonSourceFolder) {
        return SharedUiPlugin.getImageCache().get(UIConstants.SOURCE_FOLDER_ICON);
    }
    if (element instanceof PythonFolder) {
        PythonFolder folder = (PythonFolder) element;
        IFolder actualObject = folder.getActualObject();
        if (actualObject != null) {
            final String[] validInitFiles = FileTypesPreferencesPage.getValidInitFiles();

            for (String init : validInitFiles) {
                if (actualObject.getFile(init).exists()) {
                    if (checkParentsHaveInit(folder, validInitFiles)) {
                        return SharedUiPlugin.getImageCache().get(UIConstants.FOLDER_PACKAGE_ICON);
                    } else {
                        break;
                    }
                }
            }
        }
        return provider.getImage(actualObject);
    }
    if (element instanceof PythonNode) {
        PythonNode node = (PythonNode) element;
        return node.entry.getImage();
    }
    if (element instanceof IWrappedResource) {
        IWrappedResource resource = (IWrappedResource) element;
        Object actualObject = resource.getActualObject();
        if (actualObject instanceof IFile) {
            IFile iFile = (IFile) actualObject;
            final String name = iFile.getName();

            if (name.indexOf('.') == -1) {
                try {
                    if (PythonPathHelper.markAsPyDevFileIfDetected(iFile)) {
                        if (FileTypesPreferencesPage.isCythonFile(name)) {
                            return SharedUiPlugin.getImageCache().get(UIConstants.CYTHON_FILE_ICON);
                        }
                        return SharedUiPlugin.getImageCache().get(UIConstants.PY_FILE_ICON);
                    }
                } catch (Exception e) {
                    //Ignore
                }
            }
            if (FileTypesPreferencesPage.isCythonFile(name)) {
                return SharedUiPlugin.getImageCache().get(UIConstants.CYTHON_FILE_ICON);
            }

            if (name.startsWith("__init__.") && PythonPathHelper.isValidSourceFile(name)) {
                return PyTitlePreferencesPage.getInitIcon();
            } else {
                IProject project = iFile.getProject();
                try {
                    if (project.hasNature(PythonNature.DJANGO_NATURE_ID)) {
                        String djangoModulesHandling = PyTitlePreferencesPage.getDjangoModulesHandling();
                        if (djangoModulesHandling == PyTitlePreferencesPage.TITLE_EDITOR_DJANGO_MODULES_SHOW_PARENT_AND_DECORATE
                                || djangoModulesHandling == PyTitlePreferencesPage.TITLE_EDITOR_DJANGO_MODULES_DECORATE) {

                            if (PyTitlePreferencesPage.isDjangoModuleToDecorate(name)) {
                                return PyTitlePreferencesPage.getDjangoModuleIcon(name);
                            }
                        }
                    }
                } catch (CoreException e) {
                    Log.log(e);
                }
            }
        }
        return provider.getImage(actualObject);
    }
    if (element instanceof ProjectConfigError) {
        return SharedUiPlugin.getImageCache().get(UIConstants.ERROR);
    }
    if (element instanceof TreeNode<?>) {
        TreeNode<?> treeNode = (TreeNode<?>) element;
        LabelAndImage data = (LabelAndImage) treeNode.getData();
        return data.image;
    }
    if (element instanceof IFile) {
        IFile iFile = (IFile) element;
        String name = iFile.getName();
        if (FileTypesPreferencesPage.isCythonFile(name)) {
            return SharedUiPlugin.getImageCache().get(UIConstants.CYTHON_FILE_ICON);
        }

    }
    if (element instanceof IProject) {
        IProject project = (IProject) element;
        if (!project.isOpen()) {
            return null;
        }
        IMarker[] markers;
        try {
            markers = project.findMarkers(PythonBaseModelProvider.PYDEV_PACKAGE_EXPORER_PROBLEM_MARKER, true,
                    0);
        } catch (CoreException e1) {
            Log.log(e1);
            return null;
        }
        if (markers == null || markers.length == 0) {
            return null;
        }

        //We have errors: make them explicit.
        if (projectWithError == null) {
            synchronized (lock) {
                //we must recheck again (if 2 got here and 1 got the lock while the other was waiting, when
                //the other enters the lock, it does not need to recalculated).
                if (projectWithError == null) {
                    //Note on double-checked locking idiom: http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html.
                    //(would not work as expected on java 1.4)
                    Image image = provider.getImage(element);
                    try {
                        DecorationOverlayIcon decorationOverlayIcon = new DecorationOverlayIcon(image,
                                SharedUiPlugin.getImageCache().getDescriptor(UIConstants.ERROR_SMALL),
                                IDecoration.BOTTOM_LEFT);
                        projectWithError = decorationOverlayIcon.createImage();
                    } catch (Exception e) {
                        Log.log("Unable to create error decoration for project icon.", e);
                        projectWithError = image;
                    }
                }
            }
        }

        return projectWithError;
    }

    if (element instanceof IWorkingSet) {
        return SharedUiPlugin.getImageCache().get(UIConstants.WORKING_SET);
    }
    return null;
}

From source file:org.robotframework.ide.eclipse.main.plugin.launch.tabs.SuitesToRunCompositeTest.java

License:Apache License

@Test
public void whenLabelProviderIsAskedForImageOfNonExistingFolderSuite_folderImageWithErrorIconIsReturned() {
    final CheckboxTreeViewerLabelProvider provider = new CheckboxTreeViewerLabelProvider();

    final IResource resource = mock(IResource.class);
    when(resource.getType()).thenReturn(IResource.FOLDER);
    when(resource.exists()).thenReturn(false);
    final SuiteLaunchElement suiteElement = new SuiteLaunchElement(resource);

    final Image expectedImage = ImagesManager
            .getImage(new DecorationOverlayIcon(ImagesManager.getImage(RedImages.getFolderImage()),
                    RedImages.getErrorImage(), IDecoration.BOTTOM_LEFT));

    assertThat(provider.getImage(suiteElement)).isEqualTo(expectedImage);
}

From source file:org.robotframework.ide.eclipse.main.plugin.launch.tabs.SuitesToRunCompositeTest.java

License:Apache License

@Test
public void whenLabelProviderIsAskedForImageOfNonExistingFileSuite_fileImageWithErrorIconIsReturned() {
    final CheckboxTreeViewerLabelProvider provider = new CheckboxTreeViewerLabelProvider();

    final IResource resource = mock(IResource.class);
    when(resource.getType()).thenReturn(IResource.FILE);
    when(resource.exists()).thenReturn(false);
    final SuiteLaunchElement suiteElement = new SuiteLaunchElement(resource);

    final Image expectedImage = ImagesManager
            .getImage(new DecorationOverlayIcon(ImagesManager.getImage(RedImages.getRobotFileImage()),
                    RedImages.getErrorImage(), IDecoration.BOTTOM_LEFT));

    assertThat(provider.getImage(suiteElement)).isEqualTo(expectedImage);
}

From source file:org.robotframework.ide.eclipse.main.plugin.launch.tabs.SuitesToRunCompositeTest.java

License:Apache License

@Test
public void whenLabelProviderIsAskedForImageOfNonExistingTestCase_testCaseImageWithErrorIconIsReturned() {
    final CheckboxTreeViewerLabelProvider provider = new CheckboxTreeViewerLabelProvider();

    final TestCaseLaunchElement testElement = new TestCaseLaunchElement(null, "test", true, true);

    final Image expectedImage = ImagesManager
            .getImage(new DecorationOverlayIcon(ImagesManager.getImage(RedImages.getTestCaseImage()),
                    RedImages.getErrorImage(), IDecoration.BOTTOM_LEFT));

    assertThat(provider.getImage(testElement)).isEqualTo(expectedImage);
}

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  va 2 s. c  o  m*/
        }
    } 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  w  w .  j a va 2  s .c  o m
 * @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.springframework.ide.eclipse.ui.SpringLabelDecorator.java

License:Open Source License

protected final void addErrorOverlay(IDecoration decoration, int severity) {
    if (severity == IMarker.SEVERITY_WARNING) {
        decoration.addOverlay(SpringUIImages.DESC_OVR_WARNING, IDecoration.BOTTOM_LEFT);
    } else if (severity == IMarker.SEVERITY_ERROR) {
        decoration.addOverlay(SpringUIImages.DESC_OVR_ERROR, IDecoration.BOTTOM_LEFT);
    }/*from   w  w  w.j a va 2  s .  c om*/
}