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.eclipse.wst.jsdt.internal.ui.typehierarchy.MethodsLabelProvider.java

License:Open Source License

public Color getForeground(Object element) {
    if (fMethodsViewer.isShowInheritedMethods() && element instanceof IFunction) {
        IFunction curr = (IFunction) element;
        IMember declaringType = curr.getDeclaringType();

        if (declaringType == null || !declaringType.equals(fMethodsViewer.getInput())) {
            return JFaceResources.getColorRegistry().get(ColoredViewersManager.INHERITED_COLOR_NAME);
        }/*  w w  w .ja  v  a 2 s.c  om*/
    }
    return null;
}

From source file:org.eclipse.wst.jsdt.internal.ui.typehierarchy.MethodsLabelProvider.java

License:Open Source License

public void dispose() {
    JFaceResources.getColorRegistry().removeListener(fColorRegistryListener);
    fColorRegistryListener = null;
    super.dispose();
}

From source file:org.eclipse.wst.sse.ui.internal.util.EditorUtility.java

License:Open Source License

/**
 * Temporary method to help migrate from using StructuredTextColors to
 * using base ColorRegistry. Instead of using symbolic names in the color
 * registry, we are currently mapping the rgb.toString value to
 * corresponding color.//w w  w  . j a v a2s.  co m
 * 
 * @param rgb
 * @return Color
 */
public static Color getColor(RGB rgb) {
    if (rgb == null)
        return null;

    // get the color from the platform color registry
    Color color = JFaceResources.getColorRegistry().get(rgb.toString());

    // if the platform color registry does not have this color yet, add to
    // the registry
    if (color == null) {
        JFaceResources.getColorRegistry().put(rgb.toString(), rgb);
        color = JFaceResources.getColorRegistry().get(rgb.toString());
    }
    return color;
}

From source file:org.eclipse.wst.xml.vex.ui.internal.swt.ContentAssist.java

License:Open Source License

@Override
protected Color getBackground() {
    String colorId = JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR;
    return JFaceResources.getColorRegistry().get(colorId);
}

From source file:org.eclipse.xtext.graphview.lib.literals.ColorLiterals.java

License:Open Source License

public static Color color(ColorLiteral literal) {
    String symbolicName = literal.toString();
    if (!JFaceResources.getColorRegistry().hasValueFor(symbolicName)) {
        RGB rgb = new RGB(literal.getRed(), literal.getGreen(), literal.getBlue());
        JFaceResources.getColorRegistry().put(symbolicName, rgb);
    }//from   w  w  w  . java  2 s .c om
    return JFaceResources.getColorRegistry().getColorDescriptor(symbolicName).createColor(Display.getDefault());
}

From source file:org.eclipse.xtext.ui.codetemplates.ui.highlighting.TemplatesHighlightingConfiguration.java

License:Open Source License

public TextStyle counterStyle() {
    TextStyle textStyle = new TextStyle();
    RGB color = JFaceResources.getColorRegistry().getRGB(JFacePreferences.COUNTER_COLOR);
    textStyle.setColor(color);//from   w  w  w.j  av a 2  s .  c o  m
    return textStyle;
}

From source file:org.eclipse.xtext.ui.codetemplates.ui.highlighting.TemplatesHighlightingConfiguration.java

License:Open Source License

public TextStyle decorationsStyle() {
    TextStyle textStyle = new TextStyle();
    RGB color = JFaceResources.getColorRegistry().getRGB(JFacePreferences.DECORATIONS_COLOR);
    textStyle.setColor(color);/* w  w w.j  a  v  a 2  s  .c o m*/
    return textStyle;
}

From source file:org.eclipse.xtext.ui.editor.utils.EditorUtils.java

License:Open Source License

public static Color colorFromString(String rgbString) {
    if (rgbString != null && rgbString.trim().length() > 0) {
        Color col = JFaceResources.getColorRegistry().get(rgbString);
        try {/*from   w w  w .  j  av  a 2 s. com*/
            if (col == null) {
                RGB rgb = StringConverter.asRGB(rgbString);
                JFaceResources.getColorRegistry().put(rgbString, rgb);
                col = JFaceResources.getColorRegistry().get(rgbString);
            }
        } catch (DataFormatException e) {
            log.error("Corrupt color value: " + rgbString, e);
        }
        return col;
    }
    return null;
}

From source file:org.eclipse.xtext.xbase.ui.contentassist.ParameterContextInformation.java

License:Open Source License

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

    try {//from   ww w.j av a  2  s  .co  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.ganoro.phing.ui.editors.AntEditorSourceViewerConfiguration.java

License:Open Source License

public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    fContentAssistant = new ContentAssistant();
    AntEditorCompletionProcessor processor = new AntEditorCompletionProcessor(fEditor.getAntModel());
    fContentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    fContentAssistant.setContentAssistProcessor(processor, AntEditorPartitionScanner.XML_TAG);
    fContentAssistant.setDocumentPartitioning(AntDocumentSetupParticipant.ANT_PARTITIONING);

    String triggers = fPreferenceStore
            .getString(AntEditorPreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS);
    if (triggers != null) {
        processor.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
    }//from w  ww .  j  ava  2 s. co  m

    fContentAssistant
            .enableAutoInsert(fPreferenceStore.getBoolean(AntEditorPreferenceConstants.CODEASSIST_AUTOINSERT));
    fContentAssistant.enableAutoActivation(
            fPreferenceStore.getBoolean(AntEditorPreferenceConstants.CODEASSIST_AUTOACTIVATION));
    fContentAssistant.setAutoActivationDelay(
            fPreferenceStore.getInt(AntEditorPreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
    fContentAssistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
    fContentAssistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
    fContentAssistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

    Color background = JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
    fContentAssistant.setContextInformationPopupBackground(background);
    fContentAssistant.setContextSelectorBackground(background);

    Color foreground = JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
    fContentAssistant.setContextInformationPopupForeground(foreground);
    fContentAssistant.setContextSelectorForeground(foreground);

    IInformationControlCreator creator = getInformationControlCreator(sourceViewer);
    fContentAssistant.setInformationControlCreator(creator);

    fContentAssistant.setRepeatedInvocationMode(true);
    fContentAssistant.setStatusLineVisible(true);
    fContentAssistant.setShowEmptyList(true);
    fContentAssistant.addCompletionListener(processor);
    return fContentAssistant;
}