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

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

Introduction

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

Prototype

int REPLACE

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

Click Source Link

Document

Constant for replacing the original image.

Usage

From source file:com.google.gdt.eclipse.managedapis.ui.ManagedApiContainerDecorator.java

License:Open Source License

private void applyApiSpecificContainerIcon(Object element, IDecoration decoration)
        throws MalformedURLException {
    ImageDescriptor replacementIcon = null;

    ManagedApi managedApi = ManagedApiContainer
            .getManagedApiForClassPathContainer((ClassPathContainer) element);
    if (managedApi != null && managedApi.hasClasspathContainerIcon()) {
        replacementIcon = managedApi.getClasspathContainerIconImageDescriptor();
    }/*w w  w.  ja v a 2 s  .c  o m*/
    if (replacementIcon == null) {
        replacementIcon = resources.getGoogleAPIContainerIcon16ImageDescriptor();
    }
    decoration.addOverlay(replacementIcon, IDecoration.REPLACE);
}

From source file:com.rcpcompany.uibindings.internal.decorators.extenders.ViewerSpecificLabelDecoratorExtender.java

License:Open Source License

@Override
public void extend(final IUIBindingDecoratorExtenderContext context) {
    final ValidationLabelDecorator labelDecorator = getLabelDecorator(context.getBinding());

    if (labelDecorator == null)
        return;/*from   w  w  w  . j av a2 s  . c o m*/

    /*
     * We want to be notified next time the decorator changes...
     * 
     * Note that we expect the decorator to conform to the comment of #addListener(): "Adds a
     * listener to this label provider. Has no effect if an identical listener is already
     * registered.".
     * 
     * This is done this way to avoid any references from the extender to the decorator, as
     * these can be problematic when garbage collecting...
     */
    labelDecorator.addListener(this);

    final EObject element = context.getBinding().getModelObject();

    final IDecoration decoration = new IDecoration() {
        @Override
        public void addPrefix(String prefix) {
            // TODO
        }

        @Override
        public void addSuffix(String suffix) {
            // TODO
        }

        @Override
        public void addOverlay(ImageDescriptor overlay) {
            final DecorationPosition pos = IManager.Factory.getManager().getMessageDecorationPosition();
            switch (pos) {
            case TOP_LEFT:
            case CENTER_LEFT:
                addOverlay(overlay, IDecoration.TOP_LEFT);
                break;
            case BOTTOM_LEFT:
                addOverlay(overlay, IDecoration.BOTTOM_LEFT);
                break;
            case TOP_RIGHT:
            case CENTER_RIGHT:
                addOverlay(overlay, IDecoration.TOP_RIGHT);
                break;
            case BOTTOM_RIGHT:
                addOverlay(overlay, IDecoration.BOTTOM_RIGHT);
                break;
            default:
                LogUtils.error(this, "Unknown position: " + pos);
                addOverlay(overlay, IDecoration.TOP_LEFT);
                break;
            }
        }

        @Override
        public void addOverlay(ImageDescriptor overlay, int quadrant) {
            final Image image = getResourceManager().createImage(overlay);
            switch (quadrant) {
            case IDecoration.BOTTOM_LEFT:
                context.setDecoratingImage(DecorationPosition.BOTTOM_LEFT, false, image, null);
                break;
            case IDecoration.TOP_LEFT:
                context.setDecoratingImage(DecorationPosition.TOP_LEFT, false, image, null);
                break;
            case IDecoration.BOTTOM_RIGHT:
                context.setDecoratingImage(DecorationPosition.BOTTOM_RIGHT, false, image, null);
                break;
            case IDecoration.TOP_RIGHT:
                context.setDecoratingImage(DecorationPosition.TOP_RIGHT, false, image, null);
                break;
            case IDecoration.REPLACE:
                context.setImage(image);
                break;
            default:
                LogUtils.error(this, "Unknown quadrant: " + quadrant);
                break;
            }
        }

        @Override
        public void setForegroundColor(Color color) {
            context.setForegound(color);
        }

        @Override
        public void setBackgroundColor(Color color) {
            context.setBackgound(color);
        }

        @Override
        public void setFont(Font font) {
            context.setFont(font);
        }

        @Override
        public IDecorationContext getDecorationContext() {
            return DecorationContext.DEFAULT_CONTEXT;
        }
    };
    labelDecorator.decorate(element, decoration);
}

From source file:org.eclipse.egit.ui.internal.DecorationOverlayDescriptor.java

License:Open Source License

protected void drawCompositeImage(int width, int height) {
    if (overlays.length > IDecoration.UNDERLAY) {
        ImageDescriptor underlay = overlays[IDecoration.UNDERLAY];
        if (underlay != null)
            drawImage(underlay.getImageData(), 0, 0);
    }//from   w w  w .j a  v a 2  s  .com

    if (overlays.length > IDecoration.REPLACE && overlays[IDecoration.REPLACE] != null)
        drawImage(overlays[IDecoration.REPLACE].getImageData(), 0, 0);
    else
        drawImage(getBaseImageData(), 0, 0);

    drawOverlays(overlays);
}

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}.
 *//*ww  w .  j ava2s . c  o  m*/
@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.jubula.client.ui.provider.labelprovider.decorators.ResultDecorator.java

License:Open Source License

/** {@inheritDoc} */
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof TestResultNode) {
        TestResultNode resultNode = ((TestResultNode) element);
        if (resultNode.getNode() instanceof ICommentPO) {
            return;
        }/*  w  w  w .j  ava 2 s . c  o  m*/

        int status = resultNode.getStatus();
        ImageDescriptor image2use = null;
        IDecorationContext context = decoration.getDecorationContext();
        if (context instanceof DecorationContext) {
            ((DecorationContext) context).putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);
        }
        switch (status) {
        case TestResultNode.NOT_YET_TESTED:
            break;
        case TestResultNode.NO_VERIFY:
            image2use = IconConstants.STEP_OK_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.TESTING:
            image2use = IconConstants.STEP_TESTING_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.SUCCESS:
            image2use = IconConstants.STEP_OK_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.ERROR:
        case TestResultNode.CONDITION_FAILED:
        case TestResultNode.INFINITE_LOOP:
            image2use = IconConstants.STEP_NOT_OK_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.ERROR_IN_CHILD:
            image2use = IconConstants.STEP_NOT_OK_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.NOT_TESTED:
            image2use = IconConstants.STEP_FAILED_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.RETRYING:
            image2use = IconConstants.STEP_RETRY_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.SUCCESS_RETRY:
            image2use = IconConstants.STEP_RETRY_OK_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.ABORT:
            image2use = IconConstants.STEP_NOT_OK_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.SKIPPED:
            image2use = IconConstants.STEP_SKIPPED_IMAGE_DESCRIPTOR;
            break;
        case TestResultNode.SUCCESS_ONLY_SKIPPED:
            image2use = IconConstants.STEP_SUCCESS_SKIPPED_IMAGE_DESCRIPTOR;
            break;
        default:
            break;
        }
        decoration.addOverlay(image2use, IDecoration.REPLACE);
    }
}

From source file:org.eclipse.php.internal.ui.navigator.PHPNavigatorLabelDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IFolder) {
        IDecorationContext context = decoration.getDecorationContext();
        if (context instanceof DecorationContext) {
            ((DecorationContext) context).putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);
        }/*from  www.j  a  va  2s .c  om*/
        IFolder folder = (IFolder) element;
        IScriptProject project = DLTKCore.create(folder.getProject());
        try {
            if (PHPToolkitUtil.isPhpProject(folder.getProject()) && project.isOnBuildpath(folder)) {
                if (lfm.isInLibraryFolder(folder)) {
                    decoration.addOverlay(PHPPluginImages.DESC_OBJS_PHP_LIBFOLDER, IDecoration.REPLACE);
                } else {
                    decoration.addOverlay(DLTKPluginImages.DESC_OBJS_PACKFRAG_ROOT, IDecoration.REPLACE);
                }
            }
        } catch (CoreException e) {
            Logger.logException(e);
        }
    }
}

From source file:org.eclipse.ui.internal.decorators.DecorationBuilder.java

License:Open Source License

/**
 * Clear the current values and return a DecorationResult.
 * /*ww w .j  a  v  a 2  s.c  o  m*/
 * @return DecorationResult
 */
DecorationResult createResult() {
    // check whether the context says that replacement should happen
    boolean clearReplacementImage = true;
    if (context != null) {
        Object propertyValue = context.getProperty(IDecoration.ENABLE_REPLACE);
        if (propertyValue instanceof Boolean) {
            if (((Boolean) propertyValue).booleanValue()) {
                clearReplacementImage = false;
            }
        }
    }
    if (clearReplacementImage) {
        descriptors[IDecoration.REPLACE] = null;
    }
    DecorationResult newResult = new DecorationResult(new ArrayList(prefixes), new ArrayList(suffixes),
            descriptors, foregroundColor, backgroundColor, font);

    return newResult;
}

From source file:org.kalypso.model.wspm.tuhh.ui.internal.gml.WspmBuildingDecorator.java

License:Open Source License

private void decorateBuilding(final IProfileObject building, final IDecoration decoration) {
    final String typeLabel = building.getTypeLabel();

    /* suffix *///  w ww .  jav  a 2  s  .  c om
    if (building instanceof ICulvertBuilding)
        decoration.addSuffix(String.format(Messages.getString("WspmBuildingDecorator_0"), typeLabel)); //$NON-NLS-1$
    else if (building instanceof GenericProfileHorizon) {
        // FIXME: remove this label
        //      final String id = building.getType();
        //      decoration.addSuffix( String.format( " ('%s')", id ) );
    } else
        decoration.addSuffix(String.format(" (%s)", typeLabel)); //$NON-NLS-1$

    /* icon */
    final ImageDescriptor buildingImage = getBuildingImage(building);
    if (buildingImage != null)
        decoration.addOverlay(buildingImage, IDecoration.REPLACE);
}

From source file:org.marketcetera.photon.strategy.engine.ui.StrategyEngineStatusDecorator.java

private void replaceImage(final IDecoration decoration, ImageDescriptor imageDescriptor) {
    /*//  w w  w .  ja v a  2s  .co m
     * Without setting IDecoration.ENABLE_REPLACE, IDecoration.REPLACE will
     * not be respected
     */
    ((DecorationContext) decoration.getDecorationContext()).putProperty(IDecoration.ENABLE_REPLACE,
            Boolean.TRUE);
    decoration.addOverlay(imageDescriptor, IDecoration.REPLACE);
}

From source file:org.marketcetera.photon.strategy.engine.ui.StrategyEngineStatusDecoratorTest.java

@Test
public void testDisconnectedEngine() {
    StrategyEngine engine = createEngine("");
    mFixture.decorate(engine, mMockDecoration);
    verify(mMockDecorationContext).putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);
    verify(mMockDecoration).addOverlay(StrategyEngineImage.ENGINE_DISCONNECTED_OBJ.getImageDescriptor(),
            IDecoration.REPLACE);
    verify(mMockDecoration).setForegroundColor(StrategyEngineColor.ENGINE_DISCONNECTED.getColor());
}