Example usage for org.eclipse.jface.viewers DecorationOverlayIcon DecorationOverlayIcon

List of usage examples for org.eclipse.jface.viewers DecorationOverlayIcon DecorationOverlayIcon

Introduction

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

Prototype

public DecorationOverlayIcon(ImageDescriptor baseImageDescriptor, ImageDescriptor overlayImageDescriptor,
        int quadrant) 

Source Link

Document

Create a decoration overlay icon that will place the given overlay icon in the given quadrant of the base image descriptor.

Usage

From source file:org.eclipse.babel.editor.util.UIUtils.java

License:Open Source License

/**
 * @return Image for the icon which indicates a key that has missing
 *         translations//  ww  w  .  ja v a 2s  .  com
 */
public static Image getMissingTranslationImage() {
    Image result = ResourceManager.getImage(IMAGE_KEY_MISSING_TRANSLATION);
    if (result == null) {
        Image image = getImage(UIUtils.IMAGE_KEY);
        ImageDescriptor missing = ImageDescriptor.createFromImage(UIUtils.getImage(UIUtils.IMAGE_ERROR));
        result = new DecorationOverlayIcon(image, missing, IDecoration.BOTTOM_RIGHT).createImage();
        ResourceManager.addImage(IMAGE_KEY_MISSING_TRANSLATION, result);
    }
    return result;
}

From source file:org.eclipse.babel.editor.util.UIUtils.java

License:Open Source License

/**
 * @return Image for the icon which indicates a key that is unused
 *//* w  w  w. j  a v  a  2s.c o m*/
public static Image getUnusedTranslationsImage() {
    Image result = ResourceManager.getImage(IMAGE_KEY_UNUSED_TRANSLATION);
    if (result == null) {
        Image image = getImage(UIUtils.IMAGE_UNUSED_TRANSLATION);
        ImageDescriptor missing = ImageDescriptor.createFromImage(getImage(UIUtils.IMAGE_WARNING));
        result = new DecorationOverlayIcon(image, missing, IDecoration.BOTTOM_RIGHT).createImage();
        ResourceManager.addImage(IMAGE_KEY_UNUSED_TRANSLATION, result);
    }
    return result;
}

From source file:org.eclipse.babel.editor.util.UIUtils.java

License:Open Source License

/**
 * @return Image for the icon which indicates a key that has missing
 *         translations and is unused//w  ww  .  j  a  va  2s.c om
 */
public static Image getMissingAndUnusedTranslationsImage() {
    Image result = ResourceManager.getImage(IMAGE_KEY_MISSING_UNUSED_TRANSLATION);
    if (result == null) {
        Image image = getImage(UIUtils.IMAGE_UNUSED_TRANSLATION);
        ImageDescriptor missing = ImageDescriptor.createFromImage(getImage(UIUtils.IMAGE_ERROR));
        result = new DecorationOverlayIcon(image, missing, IDecoration.BOTTOM_RIGHT).createImage();
        ResourceManager.addImage(IMAGE_KEY_MISSING_UNUSED_TRANSLATION, result);
    }
    return result;
}

From source file:org.eclipse.babel.editor.util.UIUtils.java

License:Open Source License

/**
 * @return Image for the icon which indicates a key that has duplicate
 *         entries/*from   w w  w. j ava 2  s. co m*/
 */
public static Image getDuplicateEntryImage() {
    Image result = ResourceManager.getImage(IMAGE_KEY_DUPLICATE_ENTRY_TRANSLATION);
    if (result == null) {
        Image image = getImage(UIUtils.IMAGE_KEY);
        ImageDescriptor missing = ImageDescriptor.createFromImage(getImage(UIUtils.IMAGE_WARNING));
        result = new DecorationOverlayIcon(image, missing, IDecoration.BOTTOM_RIGHT).createImage();
        ResourceManager.addImage(IMAGE_KEY_DUPLICATE_ENTRY_TRANSLATION, result);
    }
    return result;
}

From source file:org.eclipse.babel.editor.util.UIUtils.java

License:Open Source License

/**
 * @return Image for the icon which indicates a key that has duplicate
 *         entries and is unused/*from  w ww  . j  a v a  2 s . co m*/
 */
public static Image getDuplicateEntryAndUnusedTranslationsImage() {
    Image result = ResourceManager.getImage(IMAGE_KEY_UNUSED_DUPLICATE_ENTRY_TRANSLATION);
    if (result == null) {
        Image image = getImage(UIUtils.IMAGE_UNUSED_TRANSLATION);
        ImageDescriptor missing = ImageDescriptor.createFromImage(getImage(UIUtils.IMAGE_DUPLICATE));
        result = new DecorationOverlayIcon(image, missing, IDecoration.BOTTOM_RIGHT).createImage();
        ResourceManager.addImage(IMAGE_KEY_UNUSED_DUPLICATE_ENTRY_TRANSLATION, result);
    }
    return result;
}

From source file:org.eclipse.babel.tapiji.tools.core.ui.decorators.ExcludedResource.java

License:Open Source License

@Override
public Image decorateImage(Image image, Object element) {
    if (decorate(element)) {
        DecorationOverlayIcon overlayIcon = new DecorationOverlayIcon(image,
                Activator.getImageDescriptor(ImageUtils.IMAGE_EXCLUDED_RESOURCE_OFF), IDecoration.TOP_RIGHT);
        return overlayIcon.createImage();
    } else {//  w w  w. ja v  a 2 s  .  c  o m
        return image;
    }
}

From source file:org.eclipse.cft.server.ui.internal.editor.ApplicationMasterPart.java

License:Open Source License

private void createApplicationsSection() {
    Section section = getSection();//w  ww  . j  a  va 2s. c om
    section.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(section);
    section.setText(Messages.COMMONTXT_APPLICATIONS);
    section.setDescription(Messages.ApplicationMasterPart_TEXT_APP_DESCRIP);
    section.setExpanded(true);

    Composite client = toolkit.createComposite(section);
    client.setLayout(new GridLayout());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(client);
    section.setClient(client);

    Composite headerComposite = toolkit.createComposite(section, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 0;
    rowLayout.marginBottom = 0;
    headerComposite.setLayout(rowLayout);
    headerComposite.setBackground(null);

    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    toolBarManager.createControl(headerComposite);

    applicationsViewer = new TableViewer(toolkit.createTable(client, SWT.NONE));
    applicationsViewer.setContentProvider(new TreeContentProvider());
    applicationsViewer.setLabelProvider(new ServerLabelProvider() {
        @Override
        public Image getImage(Object element) {
            Image image = super.getImage(element);

            if (element instanceof IModule) {
                IModule module = (IModule) element;
                CloudFoundryApplicationModule appModule = editorPage.getCloudServer()
                        .getExistingCloudModule(module);
                if (appModule != null && appModule.getStatus() != null && !appModule.getStatus().isOK()) {
                    if (appModule.getStatus().getSeverity() == IStatus.ERROR) {
                        return CloudFoundryImages.getImage(new DecorationOverlayIcon(image,
                                CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT));
                    } else if (appModule.getStatus().getSeverity() == IStatus.WARNING) {
                        return CloudFoundryImages.getImage(new DecorationOverlayIcon(image,
                                CloudFoundryImages.OVERLAY_WARNING, IDecoration.BOTTOM_LEFT));
                    }
                }
            }

            return image;
        }

        @Override
        public String getText(Object element) {
            // This is the WTP module name (usually, it's the workspace
            // project name)
            String moduleName = super.getText(element);

            // However, the user has the option to specify a different name
            // when pushing an app, which is used as the cf app name. If
            // they are different, and the
            // corresponding workspace project is accessible, show both.
            // Otherwise, show the cf app name.

            if (element instanceof IModule) {

                IModule module = (IModule) element;

                // Find the corresponding Cloud Foundry-aware application
                // Module.
                CloudFoundryApplicationModule appModule = cloudServer.getExistingCloudModule((IModule) element);

                if (appModule != null) {
                    String cfAppName = appModule.getDeployedApplicationName();

                    if (cfAppName != null) {

                        // Be sure not to show a null WTP module name,
                        // although
                        // that should not be encountered
                        if (moduleName != null && !cfAppName.equals(moduleName)
                                && CloudFoundryProperties.isModuleProjectAccessible
                                        .testProperty(new IModule[] { module }, cloudServer)) {
                            moduleName = cfAppName + " (" + moduleName + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                        } else {
                            moduleName = cfAppName;
                        }
                    }
                }
            }

            return moduleName;
        }

    });
    applicationsViewer.setInput(new CloudApplication[0]);
    applicationsViewer.setSorter(new CloudFoundryViewerSorter());

    applicationsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            IModule module = (IModule) selection.getFirstElement();

            if (currentModule != module) {
                currentModule = module;
                getManagedForm().fireSelectionChanged(ApplicationMasterPart.this, selection);
            }
        }
    });
    GridDataFactory.fillDefaults().grab(true, true).hint(250, SWT.DEFAULT)
            .applyTo(applicationsViewer.getControl());

    int ops = DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
    ApplicationViewersDropAdapter listener = new ApplicationViewersDropAdapter(applicationsViewer);
    applicationsViewer.addDropSupport(ops, transfers, listener);

    // create context menu
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillApplicationsContextMenu(manager);
        }
    });

    Menu menu = menuManager.createContextMenu(applicationsViewer.getControl());
    applicationsViewer.getControl().setMenu(menu);
    editorPage.getSite().registerContextMenu(menuManager, applicationsViewer);

    Action addRemoveApplicationAction = new Action(Messages.ApplicationMasterPart_TEXT_ADD_REMOVE,
            ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_MODIFY_MODULES)) {
        @Override
        public void run() {
            ModifyModulesWizard wizard = new ModifyModulesWizard(cloudServer.getServerOriginal());
            WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
            dialog.open();
        }
    };
    toolBarManager.add(addRemoveApplicationAction);

    // Fix for STS-2996. Moved from CloudFoundryApplicationsEditorPage
    toolBarManager.add(RefreshEditorAction.getRefreshAction(editorPage, null));
    toolBarManager.update(true);
    section.setTextClient(headerComposite);

    getManagedForm().getToolkit().paintBordersFor(client);
}

From source file:org.eclipse.datatools.connectivity.internal.ui.DriverListCombo.java

License:Open Source License

private void makeImages() {
    mDriverImage = DriverImages.DRIVER.createImage();

    PLUS = AbstractUIPlugin.imageDescriptorFromPlugin(
            ConnectivityUIPlugin.getDefault().getBundle().getSymbolicName(), "icons/add_obj2.gif"); //$NON-NLS-1$

    DecorationOverlayIcon icon = new DecorationOverlayIcon(mDriverImage, PLUS, IDecoration.TOP_RIGHT);
    mDriverWithPlusImage = icon.createImage();

    ARROW = AbstractUIPlugin.imageDescriptorFromPlugin(
            ConnectivityUIPlugin.getDefault().getBundle().getSymbolicName(), "icons/view_menu.gif"); //$NON-NLS-1$

    mArrowImage = ARROW.createImage();/*ww  w . j ava 2 s .c om*/

    CHANGE = AbstractUIPlugin.imageDescriptorFromPlugin(
            ConnectivityUIPlugin.getDefault().getBundle().getSymbolicName(), "icons/change_obj.gif"); //$NON-NLS-1$

    mChangeImage = CHANGE.createImage();
}

From source file:org.eclipse.dltk.tcl.internal.ui.editor.TclOutlineLabelDecorator.java

License:Open Source License

public Image decorateImage(Image image, Object obj) {
    try {//  w  w  w.  j a va 2s  .com
        if (obj instanceof IMember) {
            IMember member = (IMember) obj;
            ImageDescriptor decoration = getDecoration(member.getFlags());
            if (decoration != null) {
                return registry.get(new DecorationOverlayIcon(image, decoration, IDecoration.TOP_RIGHT));
            }
        }
    } catch (ModelException e) {
        if (DLTKCore.DEBUG) {
            e.printStackTrace();
        }
    }
    return image;
}

From source file:org.eclipse.egit.ui.internal.staging.StagingViewLabelProvider.java

License:Open Source License

private Image getDecoratedImage(Image base, ImageDescriptor decorator) {
    DecorationOverlayIcon decorated = new DecorationOverlayIcon(base, decorator, IDecoration.BOTTOM_RIGHT);
    return (Image) this.resourceManager.get(decorated);
}