Example usage for org.eclipse.jface.viewers DecorationContext DEFAULT_CONTEXT

List of usage examples for org.eclipse.jface.viewers DecorationContext DEFAULT_CONTEXT

Introduction

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

Prototype

IDecorationContext DEFAULT_CONTEXT

To view the source code for org.eclipse.jface.viewers DecorationContext DEFAULT_CONTEXT.

Click Source Link

Document

Constant that defines a default decoration context that has no context ids associated with it.

Usage

From source file:com.google.dart.tools.ui.internal.viewsupport.DecoratingDartLabelProvider.java

License:Open Source License

/**
 * Tells the label decorator if the view presents packages flat or hierarchical.
 * /*ww  w. j a va  2 s.com*/
 * @param enable If set, packages are presented in flat mode.
 */
public void setFlatPackageMode(boolean enable) {
    //TODO (pquitslund): dart has no packages so package representation logic should go away
    //    if (enable) {
    setDecorationContext(DecorationContext.DEFAULT_CONTEXT);
    //    } else {
    //      setDecorationContext(HierarchicalDecorationContext.CONTEXT);
    //    }
}

From source file:com.rcpcompany.uibindings.extests.bindingMessages.LabelDecoratorTest.java

License:Open Source License

/**
 * Tests whether the element - if it is an {@link EObject} - has the specified message type and
 * whether the specified decorator has the specified decoration.
 * /*from w w  w.  ja  v a2 s  .c o  m*/
 * @param labelDecorator the decorator
 * @param element the element in question
 * @param messageType the expected message for the element
 * @param decorationType the expected decoration for the element
 */
private void testLD(ValidationLabelDecorator labelDecorator, Object element, int messageType,
        int decorationType) {
    if (element instanceof EObject) {
        assertEquals(messageType, myValidatorManager.getObjectSeverity((EObject) element));
    }
    if (decorationType == -1) {
        decorationType = messageType;
    }

    myCurrentOverlay = null;
    final IDecoration decoration = new IDecoration() {

        @Override
        public void setForegroundColor(Color color) {
            fail();
        }

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

        @Override
        public void setBackgroundColor(Color color) {
            fail();
        }

        @Override
        public IDecorationContext getDecorationContext() {
            return DecorationContext.DEFAULT_CONTEXT;
        }

        @Override
        public void addSuffix(String suffix) {
            fail();
        }

        @Override
        public void addPrefix(String prefix) {
            fail();
        }

        @Override
        public void addOverlay(ImageDescriptor overlay, int quadrant) {
            fail();
        }

        @Override
        public void addOverlay(ImageDescriptor overlay) {
            assertEquals(null, myCurrentOverlay);
            assertNotNull(overlay);
            myCurrentOverlay = overlay;
        }
    };
    labelDecorator.decorate(element, decoration);
    assertEquals(decorationType, labelDecorator.getElementSeverity(element));
    switch (decorationType) {
    case IMessageProvider.NONE:
        // No overlay expected
        assertEquals(null, myCurrentOverlay);
        break;
    case IMessageProvider.INFORMATION:
        // No overlay expected
        assertEquals(null, myCurrentOverlay);
        break;
    case IMessageProvider.WARNING:
        assertEquals(ValidationLabelDecorator.WARNING_IMAGE, myCurrentOverlay);
        break;
    case IMessageProvider.ERROR:
        assertEquals(ValidationLabelDecorator.ERROR_IMAGE, myCurrentOverlay);
        break;
    }
}

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 ww  . ja v  a2s .  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:com.redhat.ceylon.eclipse.code.explorer.DecoratingJavaLabelProvider.java

License:Open Source License

/**
 * Decorating label provider for Java. Combines a JavaUILabelProvider
 * (if enabled with problem indicator) with the workbench
 * decorator (label decorator extension point).
 *    @param labelProvider the label provider to decorate
 * @param errorTick show error ticks/*  ww  w  .  ja v  a  2  s.c o  m*/
 * @param flatPackageMode configure flat package mode
 */
public DecoratingJavaLabelProvider(JavaUILabelProvider labelProvider, boolean errorTick,
        boolean flatPackageMode) {
    super(labelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(),
            DecorationContext.DEFAULT_CONTEXT);
    if (errorTick) {
        labelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
    }
    setFlatPackageMode(flatPackageMode);
}

From source file:com.redhat.ceylon.eclipse.code.explorer.DecoratingJavaLabelProvider.java

License:Open Source License

/**
 * Tells the label decorator if the view presents packages flat or hierarchical.
 * @param enable If set, packages are presented in flat mode.
 *///from  w  ww .  j ava  2s. c  o m
public void setFlatPackageMode(boolean enable) {
    if (enable) {
        setDecorationContext(DecorationContext.DEFAULT_CONTEXT);
    } else {
        setDecorationContext(HierarchicalDecorationContext.getContext());
    }
}

From source file:de.walware.ecommons.ui.viewers.DecoratingStyledCellLabelProvider.java

License:Open Source License

/**
 * Creates a {@link DecoratingStyledCellLabelProvider} that delegates the
 * requests for styled labels and for images to a
 * {@link DelegatingStyledCellLabelProvider.IStyledLabelProvider}.
 * /*from  w w  w . jav a2  s. c  om*/
 * @param labelProvider the styled label provider
 * @param decorator a label decorator or <code>null</code> to not decorate the
 *         label
 * @param decorationContext a decoration context or <code>null</code> if the no
 *          decorator is configured or the default decorator should be used
 */
public DecoratingStyledCellLabelProvider(final IStyledLabelProvider labelProvider,
        final ILabelDecorator decorator, final IDecorationContext decorationContext) {
    super(labelProvider);

    this.decorator = decorator;
    this.decorationContext = (decorationContext != null) ? decorationContext
            : DecorationContext.DEFAULT_CONTEXT;

    this.labelProviderListener = new ILabelProviderListener() {
        @Override
        public void labelProviderChanged(final LabelProviderChangedEvent event) {
            fireLabelProviderChanged(event);
        }
    };
    labelProvider.addListener(this.labelProviderListener);
    if (decorator != null) {
        decorator.addListener(this.labelProviderListener);
    }
}

From source file:descent.internal.ui.viewsupport.DecoratingJavaLabelProvider.java

License:Open Source License

/**
 * Tells the label decorator if the view presents packages flat or hierarchical.
 * @param enable If set, packages are presented in flat mode.
 *///from  w w w  .  j  av a2 s  .c  om
public void setFlatPackageMode(boolean enable) {
    if (enable) {
        setDecorationContext(DecorationContext.DEFAULT_CONTEXT);
    }
    /* TODO JDT UI hierarchical view
    else {
       setDecorationContext(HierarchicalDecorationContext.CONTEXT);
    }
    */
}

From source file:org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider.java

License:Open Source License

/**
 * Decorating label provider for C/C++. Combines a CUILabelProvider
 * (if enabled with problem indicator) with the workbench
 * decorator (label decorator extension point).
 * @param labelProvider the label provider to decorate
 * @param errorTick show error ticks/*from   w w  w . ja  va2s.  c o m*/
 */
public DecoratingCLabelProvider(CUILabelProvider labelProvider, boolean errorTick) {
    super(labelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(),
            DecorationContext.DEFAULT_CONTEXT);
    if (errorTick) {
        labelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
    }
}

From source file:org.eclipse.dltk.mod.ui.viewsupport.DecoratingModelLabelProvider.java

License:Open Source License

/**
 * Tells the label decorator if the view presents packages flat or hierarchical.
 * @param enable If set, packages are presented in flat mode.
 *///w ww.j a v  a  2  s  .  co  m
public void setFlatPackageMode(boolean enable) {
    if (enable) {
        setDecorationContext(DecorationContext.DEFAULT_CONTEXT);
    }
    if (DLTKCore.DEBUG) {
        System.err.println("TODO: DecoratingModelLabelProvider: Add HierarchicalDecorationContext"); //$NON-NLS-1$
    }
    //      else {
    //         setDecorationContext(HierarchicalDecorationContext.CONTEXT);
    //      }
}

From source file:org.eclipse.dltk.ui.viewsupport.DecoratingModelLabelProvider.java

License:Open Source License

/**
 * Tells the label decorator if the view presents packages flat or
 * hierarchical./*from  w ww . j  a  v  a  2s .  co m*/
 * 
 * @param enable
 *            If set, packages are presented in flat mode.
 */
public void setFlatPackageMode(boolean enable) {
    if (enable) {
        setDecorationContext(DecorationContext.DEFAULT_CONTEXT);
    } else {
        setDecorationContext(DecorationContext.DEFAULT_CONTEXT);
        // TODO setDecorationContext(HierarchicalDecorationContext.CONTEXT);
    }
}