Example usage for org.eclipse.jface.resource JFaceResources getColorRegistry

List of usage examples for org.eclipse.jface.resource JFaceResources getColorRegistry

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getColorRegistry.

Prototype

public static ColorRegistry getColorRegistry() 

Source Link

Document

Returns the color registry for JFace itself.

Usage

From source file:org.overture.ide.ui.internal.viewsupport.VdmColoredViewersManager.java

License:Open Source License

public void installColoredLabels(VdmColoringLabelProvider labelProvider) {
    if (fManagedLabelProviders.contains(labelProvider))
        return;/* www  .ja v  a 2 s. com*/

    if (fManagedLabelProviders.isEmpty()) {
        // first lp installed
        PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
        JFaceResources.getColorRegistry().addListener(this);
    }
    fManagedLabelProviders.add(labelProvider);
}

From source file:org.overture.ide.ui.internal.viewsupport.VdmColoredViewersManager.java

License:Open Source License

public void uninstallColoredLabels(VdmColoringLabelProvider labelProvider) {
    if (!fManagedLabelProviders.remove(labelProvider))
        return; // not installed

    if (fManagedLabelProviders.isEmpty()) {
        PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
        JFaceResources.getColorRegistry().removeListener(this);
        // last viewer uninstalled
    }/*from   ww  w. j a va  2s  .  co  m*/
}

From source file:org.phpmaven.eclipse.ui.prj.ProjWizArchetypePage.java

License:Open Source License

/** initializes the colors. */
private void initializeColors() {
    if (this.colorWhite == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_WHITE)) {
            colorRegistry.put(COLOR_WHITE, new RGB(255, 255, 255));
        }//from  ww  w  .  j  a  v  a2 s.  c om
        this.colorWhite = colorRegistry.get(COLOR_WHITE);
    }
    if (this.colorDisabled == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_DARK_GRAY)) {
            colorRegistry.put(COLOR_DARK_GRAY, new RGB(0x69, 0x69, 0x69));
        }
        this.colorDisabled = colorRegistry.get(COLOR_DARK_GRAY);
    }

    if (this.colorCategoryGradientStart == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_CATEGORY_GRADIENT_START)) {
            colorRegistry.put(COLOR_CATEGORY_GRADIENT_START, new RGB(240, 240, 240));
        }
        this.colorCategoryGradientStart = colorRegistry.get(COLOR_CATEGORY_GRADIENT_START);
    }

    if (this.colorCategoryGradientEnd == null) {
        ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
        if (!colorRegistry.hasValueFor(COLOR_CATEGORY_GRADIENT_END)) {
            colorRegistry.put(COLOR_CATEGORY_GRADIENT_END, new RGB(220, 220, 220));
        }
        this.colorCategoryGradientEnd = colorRegistry.get(COLOR_CATEGORY_GRADIENT_END);
    }
}

From source file:org.polarsys.reqcycle.styling.model.Activator.java

License:Open Source License

public static Color getColor(RGB rgb) {
    ColorRegistry registry = JFaceResources.getColorRegistry();
    String rgbStringValue = StringConverter.asString(rgb);
    Color color = registry.get(rgbStringValue);
    if (color == null) {
        registry.put(rgbStringValue, rgb);
        color = registry.get(rgbStringValue);
    }/*from  w  ww  .j a v a2  s  .c  o m*/
    return color;

}

From source file:org.polarsys.reqcycle.traceability.types.configuration.preferences.dialogs.DecorationDialog.java

License:Open Source License

/**
 * Create contents of the dialog.// w  w w . java2s  .com
 * 
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    setMessage("Please choose the style applied to relations matching the chosen predicate");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(4, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label lblStyle = new Label(container, SWT.NONE);
    lblStyle.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblStyle.setText("style :");

    textStyle = new Text(container, SWT.BORDER);
    textStyle.setText("a quick brown fox jumps over the lazy dog");
    textStyle.setEditable(false);
    textStyle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Button button_1 = new Button(container, SWT.NONE);
    button_1.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FontDialog font = new FontDialog(getShell());
            FontData result = font.open();
            if (result != null) {
                FontData[] list = font.getFontList();
                currentStyle = StringConverter.asString(list);
                JFaceResources.getFontRegistry().put(currentStyle, list);
                textStyle.setFont(JFaceResources.getFontRegistry().get(currentStyle));
                RGB rgb = font.getRGB();
                if (rgb != null) {
                    currentColor = StringConverter.asString(rgb);
                    JFaceResources.getColorRegistry().put(currentColor, rgb);
                    textStyle.setForeground(JFaceResources.getColorRegistry().get(currentColor));
                }
            }
        }
    });
    button_1.setText("...");

    Label lblPredicate = new Label(container, SWT.NONE);
    lblPredicate.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblPredicate.setText("predicate : ");

    comboViewer = new ComboViewer(container, SWT.READ_ONLY);
    predicateCombo = comboViewer.getCombo();
    predicateCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    comboViewer.setContentProvider(ArrayContentProvider.getInstance());
    comboViewer.setLabelProvider(new AdapterFactoryLabelProvider(
            new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)));
    comboViewer.setInput(predicateManager.getPredicates(true));
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (comboViewer.getSelection() instanceof IStructuredSelection) {
                IStructuredSelection structured = (IStructuredSelection) comboViewer.getSelection();
                if (structured.getFirstElement() instanceof IPredicate) {
                    IPredicate p = (IPredicate) structured.getFirstElement();
                    currentPredicate = p;
                    return;
                }
            }
            currentPredicate = null;
        }
    });
    return area;
}

From source file:org.polarsys.reqcycle.traceability.types.configuration.preferences.TTypeDecorationPreferencePage.java

License:Open Source License

private void initProviders() {
    AdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    listOfRelationsViewer.setLabelProvider(new AdapterFactoryLabelProvider(factory));
    listOfRelationsViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableOfMappingViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableOfMappingViewer.setLabelProvider(
            new AdapterFactoryLabelProvider.FontAndColorProvider(factory, tableOfMappingViewer) {

                @Override//  w  w  w . j a  v a2 s  .c om
                public Font getFont(Object object, int columnIndex) {
                    if (object instanceof DecorationPredicate) {
                        DecorationPredicate d = (DecorationPredicate) object;
                        Font font = JFaceResources.getFontRegistry().get(d.getStyle());
                        if (font == null) {
                            JFaceResources.getFontRegistry().put(d.getStyle(),
                                    StringConverter.asFontDataArray(d.getStyle()));
                            font = JFaceResources.getFontRegistry().get(d.getStyle());
                        }
                        return font;
                    }
                    return super.getFont(object, columnIndex);
                }

                @Override
                public Color getForeground(Object object, int columnIndex) {
                    if (object instanceof DecorationPredicate) {
                        DecorationPredicate d = (DecorationPredicate) object;
                        Color color = JFaceResources.getColorRegistry().get(d.getColor());
                        if (color == null) {
                            JFaceResources.getColorRegistry().put(d.getColor(),
                                    StringConverter.asRGB(d.getColor()));
                            color = JFaceResources.getColorRegistry().get(d.getColor());
                        }
                        return color;
                    }
                    return super.getForeground(object, columnIndex);
                }

            });
}

From source file:org.polarsys.reqcycle.traceability.types.ui.impl.StylePredicateProvider.java

License:Open Source License

public Color getColorForRelation(Link link) {
    return getResourcetForRelation(link, new IBehavior<Color>() {

        @Override/*w  w w  . j  a  v  a 2  s. co  m*/
        public Color handleRegistry(DecorationPredicate t) {
            Color result = JFaceResources.getColorRegistry().get(t.getColor());
            if (result == null) {
                JFaceResources.getColorRegistry().put(t.getColor(), StringConverter.asRGB(t.getColor()));
                result = JFaceResources.getColorRegistry().get(t.getColor());
            }
            return result;
        }
    });
}

From source file:org.rubypeople.rdt.internal.ui.infoviews.AbstractInfoView.java

License:Open Source License

final public void dispose() {
    // cancel possible running computation
    fComputeCount++;//from  ww w .  j  a v  a 2 s .  com

    getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener);

    //      ISelectionProvider provider= getSelectionProvider();
    //      if (provider != null)
    //         provider.removeSelectionChangedListener(fCopyToClipboardAction);

    JFaceResources.getColorRegistry().removeListener(this);
    fBackgroundColorRGB = null;
    if (fBackgroundColor != null) {
        fBackgroundColor.dispose();
        fBackgroundColor = null;
    }

    internalDispose();

}

From source file:org.summer.dsl.xbase.ui.contentassist.ParameterContextInformation.java

License:Open Source License

public boolean updatePresentation(ITextViewer viewer, int position, TextPresentation presentation) {
    int currentParameter = -1;

    try {//from  w  w  w  .  java2  s .c o m
        currentParameter = getCharCount(viewer.getDocument(), this.parameterListOffset, position, ",", "", //$NON-NLS-1$//$NON-NLS-2$
                true);
    } catch (BadLocationException x) {
        return false;
    }

    if (currentParameter != -1) {
        if (currentParameter == this.currentParameter)
            return false;
    }

    presentation.clear();
    this.currentParameter = currentParameter;

    List<String> rawStrings = internalGetInformationDisplayString();
    List<int[]> commaArrays = Lists.newArrayList();
    for (String s : rawStrings) {
        commaArrays.add(computeCommaPositions(s));
    }

    int offset = 0;
    for (int i = 0; i < rawStrings.size(); i++) {
        String raw = rawStrings.get(i);
        int[] commas = commaArrays.get(i);
        if (commas.length - 2 < this.currentParameter && !data.isVarArgs(i)) {
            presentation.addStyleRange(new StyleRange(offset, raw.length(),
                    JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR), null, SWT.NORMAL));
        } else {
            int actualParameter = this.currentParameter;
            if (actualParameter + 1 >= commas.length)
                actualParameter = commas.length - 2;
            int start = commas[actualParameter] + 1;
            int end = commas[actualParameter + 1];
            if (start > 0)
                presentation.addStyleRange(new StyleRange(offset, start, null, null, SWT.NORMAL));

            if (end > start)
                presentation.addStyleRange(new StyleRange(offset + start, end - start, null, null, SWT.BOLD));

            if (end < raw.length())
                presentation.addStyleRange(
                        new StyleRange(offset + end, raw.length() - end, null, null, SWT.NORMAL));
        }
        offset += raw.length() + 1;
    }

    return true;
}

From source file:org.summer.sdt.ui.PreferenceConstants.java

License:Open Source License

/**
 * Initializes deprecated color constants.
 * //  w  ww.  j a v a 2  s. c  o  m
 * @param store the preference store
 * @since 3.6
 */
private static void initializeDeprecatedColorConstants(IPreferenceStore store) {
    RGB bgRGB = null;
    RGB fgRGB = null;

    // Don't fail in headless mode
    if (PlatformUI.isWorkbenchRunning()) {
        bgRGB = JFaceResources.getColorRegistry().getRGB(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
        fgRGB = JFaceResources.getColorRegistry().getRGB(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
    }

    // Workaround for https://bugs.eclipse.org/306736
    if (bgRGB == null)
        bgRGB = new RGB(255, 255, 255);
    if (fgRGB == null)
        fgRGB = new RGB(0, 0, 0);

    setRGBValue(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, bgRGB);
    setRGBValue(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, fgRGB);

}