Search in sources :

Example 1 with DecorationOverlayIcon

use of org.eclipse.jface.viewers.DecorationOverlayIcon in project hale by halestudio.

the class InstanceValidationReportDetailsPage method createControls.

/**
 * @see CustomReportDetailsPage#createControls(Composite)
 */
@Override
public Control createControls(Composite parent) {
    // filtered tree sets itself GridData, so set layout to gridlayout
    parent.setLayout(GridLayoutFactory.fillDefaults().create());
    // create pattern filter for FilteredTree
    PatternFilter filter = new TreePathPatternFilter();
    filter.setIncludeLeadingWildcard(true);
    // create FilteredTree
    FilteredTree filteredTree = new TreePathFilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
    treeViewer = filteredTree.getViewer();
    // set content provider
    contentProvider = new InstanceValidationReportDetailsContentProvider();
    treeViewer.setContentProvider(contentProvider);
    // set label provider
    treeViewer.setLabelProvider(new InstanceValidationReportDetailsLabelProvider(contentProvider));
    // set comparator
    treeViewer.setComparator(new ViewerComparator() {

        /**
         * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
         */
        @Override
        public int category(Object element) {
            if (element instanceof QName || element instanceof Definition<?>)
                // Path
                return 0;
            else if (element instanceof String)
                // Category
                return 1;
            else
                // InstanceValidationMessage
                return 2;
        }
    });
    // add menu on right-click
    MenuManager menuMgr = new MenuManager();
    Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            if (getValidSelection() == null)
                return;
            // selection is valid, offer link to transformed data view
            manager.add(new ShowExampleAction());
        }
    });
    // remove previous menus
    menuMgr.setRemoveAllWhenShown(true);
    // add menu to tree
    treeViewer.getTree().setMenu(menu);
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            showSelectionInDataView();
        }
    });
    Image noReportBaseImage = InstanceValidationUIPlugin.getDefault().getImageRegistry().get(InstanceValidationUIPlugin.IMG_INSTANCE_VALIDATION);
    reportImage = new DecorationOverlayIcon(noReportBaseImage, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING), IDecoration.BOTTOM_LEFT).createImage();
    return filteredTree;
}
Also used : DecorationOverlayIcon(org.eclipse.jface.viewers.DecorationOverlayIcon) TreePathPatternFilter(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathPatternFilter) PatternFilter(org.eclipse.ui.dialogs.PatternFilter) TreePathFilteredTree(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) QName(javax.xml.namespace.QName) Definition(eu.esdihumboldt.hale.common.schema.model.Definition) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) TreePathFilteredTree(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree) Image(org.eclipse.swt.graphics.Image) IMenuListener(org.eclipse.jface.action.IMenuListener) TreePathPatternFilter(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathPatternFilter) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IMenuManager(org.eclipse.jface.action.IMenuManager)

Example 2 with DecorationOverlayIcon

use of org.eclipse.jface.viewers.DecorationOverlayIcon in project xtext-eclipse by eclipse.

the class XtextEditorErrorTickUpdater method updateEditorImage.

protected void updateEditorImage(XtextEditor xtextEditor) {
    Severity severity = getSeverity(xtextEditor);
    if (severity != null && severity != Severity.INFO) {
        ImageDescriptor descriptor = severity == Severity.ERROR ? XtextPluginImages.DESC_OVR_ERROR : XtextPluginImages.DESC_OVR_WARNING;
        DecorationOverlayIcon decorationOverlayIcon = new DecorationOverlayIcon(defaultImage, descriptor, IDecoration.BOTTOM_LEFT);
        scheduleUpdateEditor(decorationOverlayIcon);
    } else {
        scheduleUpdateEditor(defaultImage);
    }
}
Also used : DecorationOverlayIcon(org.eclipse.jface.viewers.DecorationOverlayIcon) Severity(org.eclipse.xtext.diagnostics.Severity) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 3 with DecorationOverlayIcon

use of org.eclipse.jface.viewers.DecorationOverlayIcon in project dsl-devkit by dsldevkit.

the class PreferenceCategory method getImage.

/**
 * {@inheritDoc}
 */
@Override
public Image getImage() {
    final Image categoryImage = getUndecoratedImage();
    if (hasRules() && hasOnlyMandatoryRules()) {
        final ImageDescriptor[] descriptors = new ImageDescriptor[ValidPreferenceConstants.DECORATION_QUADRANTS_COUNT];
        descriptors[IDecoration.BOTTOM_RIGHT] = ValidPreferenceConstants.LOCK_OVERLAY_IMAGE_DESCRIPTOR;
        // Overlay custom image over base image
        return getImageManager().createImage(new DecorationOverlayIcon(categoryImage, descriptors));
    } else {
        // No decoration
        return categoryImage;
    }
}
Also used : DecorationOverlayIcon(org.eclipse.jface.viewers.DecorationOverlayIcon) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image)

Example 4 with DecorationOverlayIcon

use of org.eclipse.jface.viewers.DecorationOverlayIcon in project egit by eclipse.

the class ProblemLabelDecorator method getDecoratedImage.

private Image getDecoratedImage(Image base, String teamImageId) {
    ImageDescriptor overlay = TeamImages.getImageDescriptor(teamImageId);
    DecorationOverlayIcon decorated = new DecorationOverlayIcon(base, overlay, IDecoration.BOTTOM_LEFT);
    return (Image) this.resourceManager.get(decorated);
}
Also used : DecorationOverlayIcon(org.eclipse.jface.viewers.DecorationOverlayIcon) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image)

Example 5 with DecorationOverlayIcon

use of org.eclipse.jface.viewers.DecorationOverlayIcon in project tdq-studio-se by Talend.

the class UdiLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    if (element instanceof IFolder) {
        return ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
    }
    if (element instanceof IFile) {
        IndicatorDefinition findUdi = IndicatorResourceFileHelper.getInstance().findIndDefinition((IFile) element);
        boolean validStatus = TaggedValueHelper.getValidStatus(findUdi);
        ImageDescriptor imageDescriptor = ImageLib.getImageDescriptor(ImageLib.IND_DEFINITION);
        if (!validStatus) {
            ImageDescriptor warnImg = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_WARN_TSK);
            DecorationOverlayIcon icon = new DecorationOverlayIcon(imageDescriptor.createImage(), warnImg, IDecoration.BOTTOM_RIGHT);
            imageDescriptor = icon;
        }
        return imageDescriptor.createImage();
    }
    if (element instanceof File) {
        return ImageLib.getImage(ImageLib.JAR_FILE);
    }
    return null;
}
Also used : DecorationOverlayIcon(org.eclipse.jface.viewers.DecorationOverlayIcon) IFile(org.eclipse.core.resources.IFile) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) File(java.io.File) IFile(org.eclipse.core.resources.IFile) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

DecorationOverlayIcon (org.eclipse.jface.viewers.DecorationOverlayIcon)18 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)14 Image (org.eclipse.swt.graphics.Image)9 IFile (org.eclipse.core.resources.IFile)3 IFolder (org.eclipse.core.resources.IFolder)3 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)2 Severity (org.eclipse.xtext.diagnostics.Severity)2 CompositeMultiImageDescriptor (com.archimatetool.editor.ui.components.CompositeMultiImageDescriptor)1 Definition (eu.esdihumboldt.hale.common.schema.model.Definition)1 TreePathFilteredTree (eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree)1 TreePathPatternFilter (eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathPatternFilter)1 File (java.io.File)1 QName (javax.xml.namespace.QName)1 CoreException (org.eclipse.core.runtime.CoreException)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 Action (org.eclipse.jface.action.Action)1 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 IAction (org.eclipse.jface.action.IAction)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1