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

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

Introduction

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

Prototype

int TOP_RIGHT

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

Click Source Link

Document

Constant for the top right quadrant.

Usage

From source file:org.eclipse.jpt.common.ui.internal.jface.OverlayImageDescriptor.java

License:Open Source License

/**
 * Draw the underlay image first, followed by either the base image or the
 * replacement image, followed by the overlay images in the order indicated
 * by the overlay constants defined on {@link IDecoration}.
 *///from  www .j av a 2  s . com
@Override
protected void drawCompositeImage(int width, int height) {
    if (this.overlays.length > IDecoration.UNDERLAY) {
        ImageDescriptor underlay = this.overlays[IDecoration.UNDERLAY];
        if (underlay != null) {
            this.drawImage(underlay.getImageData(), 0, 0);
        }
    }

    ImageDescriptor temp = this.base;
    if (this.overlays.length > IDecoration.REPLACE) {
        ImageDescriptor replace = this.overlays[IDecoration.REPLACE];
        if (replace != null) {
            temp = replace;
        }
    }
    this.drawImage(this.convertToImageData(temp), 0, 0);

    for (int i = 0; i < this.overlays.length; i++) {
        ImageDescriptor overlay = this.overlays[i];
        if (overlay == null) {
            continue;
        }
        ImageData overlayData = this.convertToImageData(overlay);
        switch (i) {
        case IDecoration.TOP_LEFT:
            this.drawImage(overlayData, 0, 0);
            break;
        case IDecoration.TOP_RIGHT:
            this.drawImage(overlayData, (this.size.x - overlayData.width), 0);
            break;
        case IDecoration.BOTTOM_LEFT:
            this.drawImage(overlayData, 0, (this.size.y - overlayData.height));
            break;
        case IDecoration.BOTTOM_RIGHT:
            this.drawImage(overlayData, (this.size.x - overlayData.width), (this.size.y - overlayData.height));
            break;
        default:
            // NOP
        }
    }
}

From source file:org.eclipse.mylyn.internal.tasks.ui.TaskLabelDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {

    ImageDescriptor priorityOverlay = getPriorityImageDescriptor(element);
    if (priorityOverlay != null) {
        decoration.addOverlay(priorityOverlay, IDecoration.BOTTOM_LEFT);
    }/*from   w ww  .ja v a2  s. c o m*/

    if (element instanceof ITask) {
        ITask task = (ITask) element;
        if (!task.isCompleted() && (TasksUiPlugin.getTaskActivityManager().isDueToday(task)
                || TasksUiPlugin.getTaskActivityManager().isOverdue(task))) {
            decoration.addOverlay(CommonImages.OVERLAY_DATE_OVERDUE, IDecoration.TOP_RIGHT);
        } else if (!task.isCompleted() && task.getDueDate() != null) {
            decoration.addOverlay(CommonImages.OVERLAY_DATE_DUE, IDecoration.TOP_RIGHT);
        }
        if (hasNotes(task)) {
            decoration.addOverlay(TasksUiImages.NOTES, IDecoration.BOTTOM_RIGHT);
        }
    } else if (element instanceof ITaskRepositoryElement) {
        ITaskRepositoryElement repositoryElement = (ITaskRepositoryElement) element;
        String repositoryUrl = repositoryElement.getRepositoryUrl();
        TaskRepository taskRepository = TasksUi.getRepositoryManager()
                .getRepository(repositoryElement.getConnectorKind(), repositoryUrl);
        if (taskRepository != null) {
            decoration.addSuffix("   [" + taskRepository.getRepositoryLabel() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
        }
    } else if (element instanceof TaskRepository) {
        ImageDescriptor overlay = TasksUiPlugin.getDefault()
                .getOverlayIcon(((TaskRepository) element).getConnectorKind());
        if (overlay != null) {
            decoration.addOverlay(overlay, IDecoration.BOTTOM_RIGHT);
        }
    }
}

From source file:org.eclipse.n4js.ui.N4JSEditor.java

License:Open Source License

/**
 * This method is expected to add all applicable overlays for the title image to the given image descriptor. If no
 * overlays are to be added, then the given image descriptor should be returned (this method should never return
 * <code>null</code>).//from w w w . j  a va  2  s  . c o m
 * <p>
 * This method should never add overlays to indicate errors/warnings, as this is taken care of by the default
 * implementation of {@link XtextEditorErrorTickUpdater}.
 */
public ImageDescriptor applyTitleImageOverlays(ImageDescriptor titleImageDesc) {
    if (isReconciling()) {
        final Image image = imageHelper.getImage(titleImageDesc);
        titleImageDesc = new DecorationOverlayIcon(image, ImageRef.TINY_CLOCK.asImageDescriptor().get(),
                IDecoration.TOP_RIGHT);
    }
    return titleImageDesc;
}

From source file:org.eclipse.ocl.examples.modelregistry.ui.icons.DecorationOverlayIcon.java

License:Open Source License

/**
  * Draw the overlays for the receiver./*ww  w  .ja  v  a2 s  .co  m*/
  * @param overlaysArray 
  */
private void drawOverlays(ImageDescriptor[] overlaysArray) {

    for (int i = 0; i < overlays.length; i++) {
        ImageDescriptor overlay = overlaysArray[i];
        if (overlay == null) {
            continue;
        }
        ImageData overlayData = overlay.getImageData();
        //Use the missing descriptor if it is not there.
        if (overlayData == null) {
            overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData();
        }
        switch (i) {
        case IDecoration.TOP_LEFT:
            drawImage(overlayData, 0, 0);
            break;
        case IDecoration.TOP_RIGHT:
            drawImage(overlayData, size.x - overlayData.width, 0);
            break;
        case IDecoration.BOTTOM_LEFT:
            drawImage(overlayData, 0, size.y - overlayData.height);
            break;
        case IDecoration.BOTTOM_RIGHT:
            drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height);
            break;
        }
    }
}

From source file:org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview.ModelExplorerDecorationAdapter.java

License:Open Source License

/**
 * Sets the decorated image./*from w  w w.  ja  v a  2 s.  c o  m*/
 *
 * @param baseImage the base image
 * @param decoration the decoration
 * @param decorationPosition the decoration position
 */
public void setDecoratedImage(Image baseImage, ImageDescriptor decoration, int decorationPosition) {

    if (decoration == null || baseImage == null) {
        return;
    }

    DecorationOverlayIcon decoratedImage = null;

    // Construct a new image identifier
    String decoratedImageId = baseImage.toString().concat(decoration.toString() + decorationPosition);

    // Return the stored image if we have one
    if (Activator.getDefault().getImageRegistry().get(decoratedImageId) == null) {
        // Otherwise create a new image and store it
        switch (decorationPosition) {

        case IDecoration.TOP_LEFT:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { decoration, null, null, null, null }, size16);
            break;
        case IDecoration.TOP_RIGHT:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, decoration, null, null, null }, size16);
            break;
        case IDecoration.BOTTOM_LEFT:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, null, decoration, null, null }, size16);
            break;
        case IDecoration.BOTTOM_RIGHT:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, null, null, decoration, null }, size16);
            break;
        case IDecoration.UNDERLAY:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, null, null, null, decoration }, size16);
            break;
        default:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, null, decoration, null, null }, size16);
            break;
        }
        Activator.getDefault().getImageRegistry().put(decoratedImageId, decoratedImage);
    }

}

From source file:org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview.ModelExplorerDecorationAdapter.java

License:Open Source License

/**
 * Sets the decoration.//w  w  w.j  a  v a 2s  . co m
 *
 * @param decoration the decoration
 * @param position the position
 */
public void setDecoration(ImageDescriptor decoration, PreferedPosition position) {
    switch (position) {

    case NORTH_WEST:
        setDecoration(decoration, IDecoration.TOP_LEFT);
        break;
    case NORTH:
        setDecoration(decoration, IDecoration.TOP_RIGHT);
        break;
    case NORTH_EAST:
        setDecoration(decoration, IDecoration.TOP_RIGHT);
        break;
    case EAST:
        setDecoration(decoration, IDecoration.BOTTOM_RIGHT);
        break;
    case SOUTH_EAST:
        setDecoration(decoration, IDecoration.BOTTOM_RIGHT);
        break;
    case SOUTH:
        setDecoration(decoration, IDecoration.BOTTOM_LEFT);
        break;
    case SOUTH_WEST:
        setDecoration(decoration, IDecoration.BOTTOM_LEFT);
        break;
    case WEST:
        setDecoration(decoration, IDecoration.TOP_LEFT);
        break;
    case CENTER:
        setDecoration(decoration, IDecoration.UNDERLAY);
        break;
    default:
        setDecoration(decoration, IDecoration.BOTTOM_LEFT);
        break;

    }
}

From source file:org.eclipse.pde.internal.ds.ui.SharedImages.java

License:Open Source License

public static Image getImage(String key, int flags) {
    // TODO crufty code
    Image image = Activator.getDefault().getImageRegistry().get(key);
    if ((flags & F_DYNAMIC) != 0) {
        Image o = Activator.getDefault().getImageRegistry().get(key + OVR_DYNAMIC);
        if (o != null)
            return o;
        Image i = new DecorationOverlayIcon(image, SharedImages.getImageDescriptor(OVR_DYNAMIC),
                IDecoration.TOP_RIGHT).createImage();
        Activator.getDefault().getImageRegistry().put(key + OVR_DYNAMIC, i);
        return i;
    }//from  w  ww  .j a va  2  s  .co  m
    return image;
}

From source file:org.eclipse.sirius.diagram.ui.tools.internal.views.providers.outline.OutlineLabelProvider.java

License:Open Source License

private Image computeFoldDecorator(final Image baseImage, final DEdge edge) {
    if (new DDiagramElementQuery(edge).isFolded()) {
        return getDecoratedImage(baseImage, DiagramImagesPath.FOLD_DECORATOR, IDecoration.TOP_RIGHT);
    }//from   ww  w.j a  va  2  s.  c  o m
    return baseImage;
}

From source file:org.eclipse.sirius.ui.tools.internal.views.common.navigator.SiriusCommonLabelProvider.java

License:Open Source License

/**
 * {@inheritDoc}/*from   www .  j  a  va2s. c o  m*/
 */
public Image getImage(Object element) {
    Image img = null;
    if (!(element instanceof IResource) && sessionLabelProvider != null) {
        try {

            // Let eclipse look for file and project icons + nature
            // decoration
            img = sessionLabelProvider.getImage(element);

            // If the current element is a dangling representation, its icon
            // is grayed. The grayed image is computed only once for each
            // type of representation.
            if (img != null && isDanglingRepresentation(element)) {
                DSemanticDecorator dSemanticDecorator = getDSemanticDecorator(element);
                String key = dSemanticDecorator.eClass().getName() + "_disabled";
                Image disabledImage = SiriusEditPlugin.getPlugin().getImageRegistry().get(key);
                if (disabledImage == null) {
                    ImageDescriptor desc = ImageDescriptor.createFromImage(img);
                    ImageDescriptor disabledDesc = ImageDescriptor.createWithFlags(desc, SWT.IMAGE_DISABLE);
                    SiriusEditPlugin.getPlugin().getImageRegistry().put(key, disabledDesc);
                    disabledImage = SiriusEditPlugin.getPlugin().getImageRegistry().get(key);
                }
                img = disabledImage;
            }
        } catch (IllegalStateException e) {
            // This can happen when trying to get the label of a CDOObject
            // which
            // Transaction has just been closed
            // Nothing to do, null will returned
        } catch (NullPointerException e) {
            // This can happen when trying to get the label of a CDOObject
            // which transaction has just been closed
            // Nothing to do, null will returned
        }
    } else if (element instanceof IFile) {
        // This file is not in a ModelingProject (check in
        // <possibleChildren> and <triggerPoints> of
        // "org.eclipse.ui.navigator.navigatorContent" of plugin.xml)
        IFile file = (IFile) element;

        if (new IFileQuery(file).isResourceHandledByOpenedSession()) {
            // Add "Sirius Modeling" overlay on this semantic file.
            String fileExtension = file.getFileExtension();
            // Create a key to store/restore the image in image registry of
            // SiriusEditPlugin
            String imgKey = fileExtension + "Decorated";
            // Get the existing image (if any)
            img = SiriusEditPlugin.getPlugin().getImageRegistry().get(imgKey);
            // If the image has already been computed, use it.
            if (img == null) {
                // Get the base image to overlay
                ImageDescriptor imageDescriptor = null;
                IWorkbenchAdapter wbAdapter = (IWorkbenchAdapter) file.getAdapter(IWorkbenchAdapter.class);
                if (wbAdapter != null) {
                    imageDescriptor = wbAdapter.getImageDescriptor(file);
                }
                if (imageDescriptor != null) {
                    // Add an overlay with the "Sirius Modeling" overlay
                    ImageDescriptor[] imageDescriptors = new ImageDescriptor[5];
                    imageDescriptors[IDecoration.TOP_RIGHT] = SIRIUS_MODELING_OVERLAY_DESC;
                    img = new DecorationOverlayIcon(imageDescriptor.createImage(), imageDescriptors)
                            .createImage();
                    SiriusEditPlugin.getPlugin().getImageRegistry().put(imgKey, img);
                }
            }
        }
    }
    return img;
}

From source file:org.eclipse.tycho.targeteditor.Activator.java

License:Open Source License

@Override
protected void initializeImageRegistry(final ImageRegistry reg) {
    reg.put(NEXUS_IMG, imageDescriptorFromPlugin(PLUGIN_ID, "icons/nexusRepo.png"));
    reg.put(VERSION_ACTION_DISABLED_IMG,
            imageDescriptorFromPlugin(PLUGIN_ID, "icons/versionUpdateAction_disabled.png"));
    reg.put(VERSION_ACTION_IMG, imageDescriptorFromPlugin(PLUGIN_ID, "icons/versionUpdateAction.png"));

    final Image nexusLogo = getImageFromRegistry(NEXUS_IMG);
    final DecorationOverlayIcon errorOverlay = new DecorationOverlayIcon(nexusLogo,
            PDEPluginImages.DESC_INTERNAL_CO, IDecoration.TOP_RIGHT);
    reg.put(ERROR_OVERLAY, errorOverlay.createImage());

    final DecorationOverlayIcon updateableOverlay = new DecorationOverlayIcon(nexusLogo,
            PDEPluginImages.DESC_FRIEND_CO, IDecoration.TOP_RIGHT);
    reg.put(UPDATEABLE_OVERLAY, updateableOverlay.createImage());

    final DecorationOverlayIcon loadingOverlay = new DecorationOverlayIcon(nexusLogo,
            PDEPluginImages.DESC_OPTIONAL_CO, IDecoration.TOP_RIGHT);
    reg.put(LOADING_OVERLAY, loadingOverlay.createImage());

}