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

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

Introduction

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

Prototype

void addOverlay(ImageDescriptor overlay, int quadrant);

Source Link

Document

Adds an overlay to the element's image.

Usage

From source file:org.polymap.core.mapeditor.tooling.edit.LayerEditableDecorator.java

License:Open Source License

public void decorate(Object elm, IDecoration decoration) {
    if (elm instanceof ILayer) {
        ILayer layer = (ILayer) elm;//ww w.ja  v  a 2 s.  com

        // layer removed?
        try {
            layer.id();
        } catch (NoSuchEntityException e) {
            return;
        }

        if (editableLayerIds.contains(layer.id())) {
            ImageDescriptor ovr = MapEditorPlugin.imageDescriptor(imageEdit);
            decoration.addOverlay(ovr, QUADRANT);
        }
        if (digitizableLayerIds.contains(layer.id())) {
            ImageDescriptor ovr = MapEditorPlugin.imageDescriptor(imageDigitize);
            decoration.addOverlay(ovr, QUADRANT);
        }
    }
}

From source file:org.polymap.core.mapeditor.tooling.select.LayerSelectableDecorator.java

License:Open Source License

public void decorate(Object elm, IDecoration decoration) {
    if (elm instanceof ILayer) {
        ILayer layer = (ILayer) elm;/*from   ww w.j  a  v a2 s .  c o  m*/

        // layer removed?
        try {
            layer.id();
        } catch (NoSuchEntityException e) {
            return;
        }

        if (selectableLayerIds.contains(layer.id())) {
            ImageDescriptor ovr = MapEditorPlugin.imageDescriptor(image);
            decoration.addOverlay(ovr, QUADRANT);
        }
    }
}

From source file:org.polymap.core.project.ui.EntityModificationDecorator.java

License:Open Source License

public void decorate(Object elm, IDecoration decoration) {
    try {/*from ww w.jav  a2s.co  m*/
        ModelChangeSupport entity = (ModelChangeSupport) elm;
        EntityChangeStatus entityState = EntityChangeStatus.forEntity(entity);

        boolean dirty = entityState.isDirty();
        boolean pendingConflict = entityState.isConcurrentlyDirty();
        boolean conflicting = entityState.isConflicting();

        if (dirty && conflicting) {
            ImageDescriptor ovr = ProjectPlugin.getDefault().imageDescriptor(conflictImage);
            decoration.addOverlay(ovr, IDecoration.BOTTOM_RIGHT);
            //decoration.addPrefix( "# " );
        } else if (!dirty && conflicting) {
            //ImageDescriptor ovr = ProjectPlugin.imageDescriptorFromPlugin( ProjectPlugin.PLUGIN_ID, warningImage );
            //decoration.addOverlay( ovr, IDecoration.BOTTOM_RIGHT );
            //decoration.addPrefix( "< " );
        } else if (dirty) {
            ImageDescriptor ovr = ProjectPlugin.getDefault().imageDescriptor(dirtyImage);
            decoration.addOverlay(ovr, IDecoration.BOTTOM_RIGHT);
            //decoration.addSuffix( "*" );
        }

        // register
        decorated.put(entity.id(), entity);
    } catch (NoSuchEntityException e) {
        decoration.addSuffix(" (removed)");
    }
}

From source file:org.polymap.core.project.ui.layer.LayerStatusDecorator.java

License:Open Source License

public void decorate(Object elm, IDecoration decoration) {
    if (elm instanceof ILayer) {
        ILayer layer = (ILayer) elm;/*from w w w  .j  av a  2  s .  com*/

        try {
            layer.id();
        } catch (NoSuchEntityException e) {
            // handled by EntityModificationDecorator
            return;
        }

        // visible
        if (layer.isVisible()) {
            ImageDescriptor image = ProjectPlugin.getDefault().imageDescriptor(visible);
            decoration.setFont(bold);

            DecorationContext context = (DecorationContext) decoration.getDecorationContext();
            context.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);
            decoration.addOverlay(image, IDecoration.REPLACE);

            ImageDescriptor ovr = ProjectPlugin.getDefault().imageDescriptor(visible_ovr);
            decoration.addOverlay(ovr, TOP_LEFT);
        }

        // inactive == not visible
        if (!layer.isVisible()) {
            decoration.setForegroundColor(INACTIVE_COLOR);
        }

        LayerStatus layerStatus = layer.getLayerStatus();
        if (layerStatus.getCode() == LayerStatus.MISSING) {
            decoration.setForegroundColor(MISSING_COLOR);
            decoration.addSuffix(Messages.get("LayerStatusDecorator_missing"));
        } else if (layerStatus.getCode() == LayerStatus.WAITING) {
            ImageDescriptor ovr = ProjectPlugin.getDefault().imageDescriptor(waiting);
            decoration.setFont(italic);
            decoration.addOverlay(ovr, TOP_RIGHT);
            decoration.addSuffix(Messages.get("LayerStatusDecorator_checking"));
        } else if (layerStatus.getSeverity() == LayerStatus.OK) {
            //
        }

        // register listener
        decorated.put(layer.id(), layer);
    }
}

From source file:org.polymap.core.project.ui.project.MapStatusDecorator.java

License:Open Source License

public void decorate(Object elm, IDecoration decoration) {
    if (elm instanceof IMap) {
        IMap map = (IMap) elm;//from  ww w.j  a  va 2s . co  m
        // visible
        if (map.isVisible() /*activeMaps.containsKey( map.id() )*/) {
            DecorationContext context = (DecorationContext) decoration.getDecorationContext();
            context.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);
            decoration.addOverlay(visible, IDecoration.REPLACE);
            decoration.addOverlay(visibleOvr, IDecoration.TOP_LEFT);
        }
        // empty
        if (map.getLayers().isEmpty()) {
            DecorationContext context = (DecorationContext) decoration.getDecorationContext();
            context.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);
            decoration.addOverlay(empty, IDecoration.REPLACE);
        }
        decorated.put(map.id(), map);
    }
}

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  www  .jav a  2 s. c om
}

From source file:org.reuseware.sokan.resource.ui.GenDecorator.java

License:Open Source License

/**
 * Calculates decorations based on element. 
 * //from   w  w  w  .  ja va2  s .co  m
 * @param element the element to decorate
 * @param decoration the decoration to set
 */
public void decorate(Object element, IDecoration decoration) {
    IFile file = null;
    if (element instanceof IFile) {
        file = (IFile) element;
    } else if (element instanceof IAdaptable) {
        file = (IFile) ((IAdaptable) element).getAdapter(IFile.class);
    }

    if (file == null) {
        return;
    }
    if (isGenerated(file)) {
        ImageDescriptor descriptor = SokanResourcePlugin.getImageDescriptor(iconPath);
        if (descriptor == null) {
            return;
        }
        decoration.addOverlay(descriptor, QUADRANT);
    }
}

From source file:org.reuseware.sokan.resource.ui.StoreDecorator.java

License:Open Source License

/**
 * Calculates decorations based on element. 
 * /*from w w  w. j a  va 2 s . c  om*/
 * @param element the element to decorate
 * @param decoration the decoration to set
 */
public void decorate(Object element, IDecoration decoration) {
    IResource res = null;
    if (element instanceof IResource) {
        res = (IResource) element;
    } else if (element instanceof IAdaptable) {
        res = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
    }

    if (res == null) {
        return;
    }
    if (StoreUtil.INSTANCE.isStore(res)) {
        descriptor = SokanResourcePlugin.getImageDescriptor(iconPath);
        if (descriptor == null) {
            return;
        }
        quadrant = IDecoration.BOTTOM_RIGHT;
        decoration.addOverlay(descriptor, quadrant);
    }
}

From source file:org.seasar.dblauncher.decorator.DBRunningDecorator.java

License:Apache License

public void decorate(Object element, IDecoration decoration) {
    try {/*w  w w .j  a v a  2  s  .  c om*/
        if (element instanceof IAdaptable) {
            IAdaptable adaptable = (IAdaptable) element;
            IProject project = (IProject) adaptable.getAdapter(IProject.class);
            Object o = project.getSessionProperty(Constants.KEY_SERVER_STATE);
            H2Preferences pref = DbLauncherPlugin.getPreferences(project);
            if (o instanceof ITerminate) {
                ITerminate t = (ITerminate) o;
                if (t.isTerminated()) {
                    project.setSessionProperty(Constants.KEY_SERVER_STATE, null);
                } else {
                    decoration.addSuffix(" [H2:" + pref.getDbPortNo() + "]");
                    decoration.addOverlay(Images.RUNNING, IDecoration.BOTTOM_RIGHT);
                }
            }
        }
    } catch (CoreException e) {
    }

}

From source file:org.seasar.weblauncher.decorator.WebRunningDecorator.java

License:Apache License

public void decorate(Object element, IDecoration decoration) {
    try {/*from  w w w .j a va2 s  . co  m*/
        if (element instanceof IAdaptable) {
            IAdaptable adaptable = (IAdaptable) element;
            IProject project = (IProject) adaptable.getAdapter(IProject.class);
            Object o = project.getSessionProperty(Constants.KEY_SERVER_STATE);
            WebPreferences pref = Activator.getPreferences(project);
            if (o instanceof ITerminate) {
                ITerminate t = (ITerminate) o;
                if (t.isTerminated()) {
                    project.setSessionProperty(Constants.KEY_SERVER_STATE, null);
                } else {
                    decoration.addSuffix(" [Web:" + pref.getWebPortNo() + "]");
                    decoration.addOverlay(Images.RUNNING, IDecoration.BOTTOM_RIGHT);
                }
            }
        }
    } catch (CoreException e) {
    }
}