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:com.aptana.ide.editors.unified.contentassist.CompletionProposalPopup.java

License:Open Source License

/**
 * Returns the background color to use.//from  w  w  w  . ja v  a 2s. c  o m
 *
 * @param control the control to get the display from
 * @return the background color
 * @since 3.2
 */
private Color getBackgroundColor(Control control) {
    Color c = fContentAssistant.getProposalSelectorBackground();
    if (c == null) {
        c = JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
    }
    return c;
}

From source file:com.aptana.ide.editors.unified.contentassist.CompletionProposalPopup.java

License:Open Source License

/**
 * Returns the foreground color to use.//from w w  w. j  a  va 2 s . com
 * 
 * @param control
 *            the control to get the display from
 * @return the foreground color
 * @since 3.2
 */
private Color getForegroundColor(Control control) {
    Color c = fContentAssistant.getProposalSelectorForeground();
    if (c == null) {
        c = JFaceResources.getColorRegistry().get(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
    }
    return c;
}

From source file:com.aptana.ide.editors.unified.utils.HTML2TextReader.java

License:Open Source License

/**
 * Transforms the HTML text from the reader to formatted text.
 * //from  www .  j  ava 2  s .  co m
 * @param reader the reader
 * @param presentation If not <code>null</code>, formattings will be applied to
 * the presentation.
 * @param display 
*/
public HTML2TextReader(Reader reader, TextPresentation presentation, Display display) {
    super(new PushbackReader(reader));
    fTextPresentation = presentation;

    RGB blackColor = new RGB(0, 0, 0);
    RGB linkColor = new RGB(93, 117, 215);
    RGB preColor = new RGB(204, 153, 51);

    ColorRegistry cm = JFaceResources.getColorRegistry();
    cm.put("black", blackColor); //$NON-NLS-1$
    cm.put("link", linkColor); //$NON-NLS-1$
    cm.put("pre", preColor); //$NON-NLS-1$

    fLinkColor = cm.get("link"); //$NON-NLS-1$
    fPreColor = cm.get("pre"); //$NON-NLS-1$
}

From source file:com.aptana.theme.internal.InvasiveThemeHijacker.java

License:Open Source License

protected void setHyperlinkValues(Theme theme, IEclipsePreferences prefs, boolean revertToDefaults) {
    if (prefs == null || theme == null) {
        return;/*from  w w w. j  a  v  a 2 s.c om*/
    }
    if (revertToDefaults) {
        // Console preferences
        prefs.remove(JFacePreferences.HYPERLINK_COLOR);
        prefs.remove(JFacePreferences.ACTIVE_HYPERLINK_COLOR);

        // Editor preferences
        prefs.remove(DefaultHyperlinkPresenter.HYPERLINK_COLOR_SYSTEM_DEFAULT);
        prefs.remove(DefaultHyperlinkPresenter.HYPERLINK_COLOR);

    } else {
        TextAttribute editorHyperlink = theme.getTextAttribute("hyperlink"); //$NON-NLS-1$

        prefs.put(JFacePreferences.HYPERLINK_COLOR,
                StringConverter.asString(editorHyperlink.getForeground().getRGB()));
        JFaceResources.getColorRegistry().put(JFacePreferences.HYPERLINK_COLOR,
                editorHyperlink.getForeground().getRGB());
        prefs.put(JFacePreferences.ACTIVE_HYPERLINK_COLOR,
                StringConverter.asString(editorHyperlink.getForeground().getRGB()));
        JFaceResources.getColorRegistry().put(JFacePreferences.ACTIVE_HYPERLINK_COLOR,
                editorHyperlink.getForeground().getRGB());
        prefs.putBoolean(DefaultHyperlinkPresenter.HYPERLINK_COLOR_SYSTEM_DEFAULT, false);
        prefs.put(DefaultHyperlinkPresenter.HYPERLINK_COLOR,
                StringConverter.asString(editorHyperlink.getForeground().getRGB()));

    }

}

From source file:com.aptana.theme.internal.ThemeManager.java

License:Open Source License

private void setCompareColors(String nodeName, boolean override) {
    IEclipsePreferences instancePrefs = EclipseUtil.instanceScope().getNode(nodeName);

    if (override) {
        RGB bg = getCurrentTheme().getBackground();
        RGB inverted = new RGB(255 - bg.red, 255 - bg.green, 255 - bg.blue);

        JFaceResources.getColorRegistry().put("INCOMING_COLOR", inverted); //$NON-NLS-1$
        JFaceResources.getColorRegistry().put("OUTGOING_COLOR", inverted); //$NON-NLS-1$
        instancePrefs.put("INCOMING_COLOR", StringConverter.asString(inverted)); //$NON-NLS-1$
        instancePrefs.put("OUTGOING_COLOR", StringConverter.asString(inverted)); //$NON-NLS-1$
    } else {/*from  w  w  w . j  a v a 2s .co  m*/
        // Revert to defaults if we have them
        IEclipsePreferences defPrefs = EclipseUtil.defaultScope().getNode(nodeName);
        String value = defPrefs.get("OUTGOING_COLOR", null); //$NON-NLS-1$
        if (value != null) {
            try {
                RGB rgb = StringConverter.asRGB(value);
                if (rgb != null) {
                    JFaceResources.getColorRegistry().put("OUTGOING_COLOR", rgb); //$NON-NLS-1$
                }
            } catch (DataFormatException e) {
                // ignore
            }
        }
        value = defPrefs.get("INCOMING_COLOR", null); //$NON-NLS-1$
        if (value != null) {
            try {
                RGB rgb = StringConverter.asRGB(value);
                if (rgb != null) {
                    JFaceResources.getColorRegistry().put("INCOMING_COLOR", rgb); //$NON-NLS-1$
                }
            } catch (DataFormatException e) {
                // ignore
            }
        }

        // Now remove the instance prefs
        instancePrefs.remove("INCOMING_COLOR"); //$NON-NLS-1$
        instancePrefs.remove("OUTGOING_COLOR"); //$NON-NLS-1$
    }

    try {
        instancePrefs.flush();
    } catch (BackingStoreException e) {
        IdeLog.logError(ThemePlugin.getDefault(), e);
    }
}

From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java

License:Open Source License

/**
 * Return preference colors for MetaWare debugger displays.
 * @return the seecode display color./*from ww  w . j a v  a 2s  .  c o  m*/
 */
public static IColorPreferences getColorPreferences() {
    if (COLOR_PREFERENCES == null) {
        COLOR_PREFERENCES = new IColorPreferences() {
            private IColor getColor(String prefID) {
                RGB rgb = JFaceResources.getColorRegistry().getRGB(prefID);
                return rgb != null ? getWidgetFactory().makeColor(rgb.red, rgb.green, rgb.blue) : null;
            }

            @Override
            public IColor getForegroundColor() {
                return getColor(SEECODE_FOREGROUND);
            }

            @Override
            public IColor getBackgroundColor() {
                return getColor(SEECODE_BACKGROUND);
            }

            @Override
            public IColor getOverlayBackgroundColor() {
                return getColor(SEECODE_OVERLAY_BACKGROUND);
            }

            @Override
            public IColor getReadonlyBackgroundColor() {
                return getColor(SEECODE_READONLY_BACKGROUND);
            }

            @Override
            public IColor getMisalignedBackgroundColor() {
                return getColor(SEECODE_MISALIGNED_BACKGROUND);
            }

            @Override
            public IColor getErrorLogBackgroundColor() {
                return getColor(SEECODE_ERRORLOG_BACKGROUND);
            }

            @Override
            public IColor getErrorLogForegroundColor() {
                return getColor(SEECODE_ERRORLOG_FOREGROUND);

            }
        };
    }
    return COLOR_PREFERENCES;
}

From source file:com.arc.cdt.debug.seecode.ui.views.AbstractEngineBasedView.java

License:Open Source License

@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
    super.init(site);
    if (memento != null) {
        String title = memento.getString(TITLE);
        String tip = memento.getString(TIP);
        if (title != null)
            setPartName(title);/*from  w  w  w.j ava2 s  .co  m*/
        if (tip != null)
            setContentDescription(tip);
    }

    mDebugEventListener = new IDebugEventSetListener() {

        @Override
        public void handleDebugEvents(DebugEvent[] events) {
            for (int j = 0; j < events.length; j++) {
                DebugEvent event = events[j];
                switch (event.getKind()) {
                case DebugEvent.TERMINATE:
                    handleTerminateEvent(event);
                    break;
                default:
                    break;
                }
            }

        }

    };
    DebugPlugin.getDefault().addDebugEventListener(mDebugEventListener);

    setFont();
    setColor();
    JFaceResources.getFontRegistry().addListener(this);
    JFaceResources.getColorRegistry().addListener(this);
}

From source file:com.arc.cdt.debug.seecode.ui.views.AbstractEngineBasedView.java

License:Open Source License

@Override
public void dispose() {
    getSite().getPage().removePartListener(fPartListener);
    super.dispose();
    if (!mUnwired) {
        mUnwired = true;/*from w  w w. j  av  a 2  s. co m*/
        IWorkbenchWindow w = this.getViewSite().getWorkbenchWindow();
        DebugUITools.getDebugContextManager().getContextService(w)
                .removeDebugContextListener(mDebugContextListener);
        mEngine = null;
        mControlMap.clear();
        DebugPlugin.getDefault().removeDebugEventListener(mDebugEventListener);
        JFaceResources.getFontRegistry().removeListener(this);
        JFaceResources.getColorRegistry().removeListener(this);
    }
}

From source file:com.arc.cdt.debug.seecode.ui.views.SeeCodeErrorLogView.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    mCards = new Composite(parent, 0);
    mCardLayout = new StackLayout();
    mCards.setLayout(mCardLayout);// ww  w.j  av a  2s  .c om
    mBlank = new Composite(mCards, 0);
    mCardLayout.topControl = mBlank;
    // listen to selection in debug view
    IWorkbenchWindow w = this.getViewSite().getWorkbenchWindow();
    DebugUITools.getDebugContextManager().getContextService(w).addDebugContextListener(mDebugContextListener);
    getSite().getPage().addPartListener(fPartListener);

    setFont();
    setColor();
    JFaceResources.getFontRegistry().addListener(this);
    JFaceResources.getColorRegistry().addListener(this);
    fIsVisible = true;
    resetSelection();

    if (fLaunchListener == null) {
        // Remove engine's error log cache when reference is removed from Launch View.
        fLaunchListener = new ILaunchesListener() {

            @Override
            public void launchesRemoved(ILaunch[] launches) {
                for (ILaunch launch : launches) {
                    IDebugTarget targets[] = launch.getDebugTargets();
                    for (IDebugTarget target : targets) {
                        ICDISession session = (ICDISession) target.getAdapter(ICDISession.class);
                        for (ICDITarget cdiTarget : session.getTargets()) {
                            if (cdiTarget instanceof IAdaptable) {
                                EngineInterface engine = (EngineInterface) ((IAdaptable) cdiTarget)
                                        .getAdapter(EngineInterface.class);
                                if (engine != null) {
                                    fContent.remove(engine);
                                }
                            }
                        }
                    }
                }
            }

            @Override
            public void launchesAdded(ILaunch[] launches) {
            }

            @Override
            public void launchesChanged(ILaunch[] launches) {

            }
        };
        DebugPlugin.getDefault().getLaunchManager().addLaunchListener(fLaunchListener);
    }
}

From source file:com.bdaum.zoom.css.internal.CssActivator.java

License:Open Source License

private void readJfaceColors(File file) {
    try (FileReader fileReader = new FileReader(file)) {
        char[] buf = new char[1024];
        int len = fileReader.read(buf);
        StringTokenizer st = new StringTokenizer(new String(buf, 0, len), "\n\r"); //$NON-NLS-1$
        while (st.hasMoreTokens()) {
            String line = st.nextToken();
            if (line.startsWith("/*")) //$NON-NLS-1$
                continue;
            if (line.startsWith(JFACE)) {
                ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
                int p = JFACE.length();
                int q = line.length();
                if (line.length() > p && line.charAt(p) == '{')
                    ++p;/* w w  w  .j  av  a  2  s.co m*/
                if (line.charAt(q - 1) == '}')
                    --q;
                StringTokenizer st2 = new StringTokenizer(line.substring(p, q), ";"); //$NON-NLS-1$
                while (st2.hasMoreTokens()) {
                    String token = st2.nextToken();
                    p = token.indexOf(':');
                    if (p > 0)
                        colorRegistry.put(token.substring(0, p), convertToRGB(token.substring(p + 1)));
                }
                break;
            }
        }
    } catch (IOException e) {
        getLog().log(new Status(IStatus.ERROR, PLUGIN_ID,
                NLS.bind(Messages.CssActivator_error_when_parsing, file.getName()), e));
    }

}