List of usage examples for org.eclipse.jface.resource ColorRegistry put
public void put(String symbolicName, RGB colorData)
From source file:asia.sejong.freedrawing.draw2d.figures.SquareButton.java
License:Apache License
protected Color getSavedColor(int r, int g, int b) { String colorString = "SB_DEFAULT:" + r + "-" + g + "-" + b; ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); if (!colorRegistry.hasValueFor(colorString)) { colorRegistry.put(colorString, new RGB(r, g, b)); }//www . ja v a2 s. c om return colorRegistry.get(colorString); }
From source file:ccw.CCWPlugin.java
License:Open Source License
/** * Not thread safe, but should only be called from the UI Thread, so it's * not really a problem.//from w ww.j a v a 2 s . co m * @param rgb * @return The <code>Color</code> instance cached for this rgb value, creating * it along the way if required. */ public static Color getColor(RGB rgb) { ColorRegistry r = getDefault().getColorCache(); String rgbString = StringConverter.asString(rgb); if (!r.hasValueFor(rgbString)) { r.put(rgbString, rgb); } return r.get(rgbString); }
From source file:ccw.CCWPlugin.java
License:Open Source License
public static void registerEditorColors(IPreferenceStore store, RGB foregroundColor) { final ColorRegistry colorCache = getDefault().getColorCache(); for (Keyword token : PreferenceConstants.colorizableTokens) { PreferenceConstants.ColorizableToken tokenStyle = PreferenceConstants.getColorizableToken(store, token, foregroundColor);/*from w ww .j a v a2 s . co m*/ colorCache.put(tokenStyle.rgb.toString(), tokenStyle.rgb); } }
From source file:com.agynamix.platform.frontend.gui.ApplicationStatusLineManager.java
License:Open Source License
public ApplicationStatusLineManager() { ColorRegistry cr = JFaceResources.getColorRegistry(); cr.put(JFacePreferences.ERROR_COLOR, new RGB(205, 2, 4)); // schoen rot }
From source file:com.aptana.ide.editor.css.contentassist.CSSContextInformationValidator.java
License:Open Source License
/** * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int, * org.eclipse.jface.text.TextPresentation) *//*from w w w. j a v a2 s . co m*/ public boolean updatePresentation(int offset, TextPresentation presentation) { try { String s = this.fContextInformation.getInformationDisplayString(); if (s.indexOf(COLON) == -1) { return false; } int colonPos = s.indexOf(COLON); RGB blackColor = new RGB(0, 0, 0); ColorRegistry cm = JFaceResources.getColorRegistry(); cm.put(BLACK_COLOR, blackColor); Color norm = cm.get(BLACK_COLOR); // make this settable StyleRange st = new StyleRange(0, colonPos, norm, null, SWT.BOLD); presentation.clear(); presentation.addStyleRange(st); return true; } catch (Exception e) { IdeLog.logError(UnifiedEditorsPlugin.getDefault(), Messages.CSSContextInformationValidator_ErrorUpdatingContextInformation, e); return true; } }
From source file:com.aptana.ide.editor.js.contentassist.JSContextInformationValidator.java
License:Open Source License
/** * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int, org.eclipse.jface.text.TextPresentation) */// w w w . j a va2s. c o m public boolean updatePresentation(int offset, TextPresentation presentation) { try { String s = this.fContextInformation.getInformationDisplayString(); int arg = fProcessor.getJSOffsetMapper().getArgIndexAndCalculateMode(); if (s.indexOf("(") == -1) //$NON-NLS-1$ { return false; } presentation.clear(); String[] lines = s.split(ScriptDocHelper.DEFAULT_DELIMITER); s = lines[0]; // only look at first line // If open/close parens, then no params if (s.indexOf("()") > 0) //$NON-NLS-1$ { return false; } // arg text always starts with brace int count = 0; int startPos = s.indexOf("("); //$NON-NLS-1$ int endPos = s.indexOf(","); //$NON-NLS-1$ // Single parameter case if (endPos == -1) { endPos = s.indexOf(")"); // arg text always ends with ")" //$NON-NLS-1$ } RGB blackColor = new RGB(0, 0, 0); ColorRegistry cm = JFaceResources.getColorRegistry(); cm.put("black", blackColor); //$NON-NLS-1$ Color norm = cm.get("black"); // make this settable //$NON-NLS-1$ StyleRange st = new StyleRange(0, startPos, norm, null, SWT.BOLD); presentation.addStyleRange(st); while (count < arg) { startPos = endPos; endPos = s.indexOf(",", startPos + 1); //$NON-NLS-1$ if (endPos == -1) { endPos = s.indexOf(")", startPos); //$NON-NLS-1$ } if (endPos == -1) { break; } count++; } // + 1 accounts for the leading "(" startPos += 1; st = new StyleRange(startPos, endPos - startPos, norm, null, SWT.BOLD); presentation.addStyleRange(st); int delimiterLength = ScriptDocHelper.DEFAULT_DELIMITER.length(); // bold the arg comment names if (lines.length > 1) { int totalLen = lines[0].length() + delimiterLength; // 1 crlf for (int i = 1; i < lines.length; i++) { String line = lines[i]; StyleRange argNameStyle = null; if (arg + 1 == i) { argNameStyle = new StyleRange(totalLen, line.length(), norm, null, SWT.BOLD); } else { argNameStyle = new StyleRange(totalLen, line.indexOf(":"), norm, null, SWT.NORMAL); //$NON-NLS-1$ } presentation.addStyleRange(argNameStyle); totalLen += line.length() + delimiterLength; // 1 crlf } } return true; } catch (Exception e) { IdeLog.logError(UnifiedEditorsPlugin.getDefault(), Messages.JSContextInformationValidator_ErrorUpdatingCOntext, e); return true; } }
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. * /* w w w .j a v a 2s .c om*/ * @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.archimatetool.editor.ui.ColorFactory.java
License:Open Source License
public static Color get(String rgbValue) { if (rgbValue == null) { return null; }//w ww . j a va 2 s. c om if (!ColorRegistry.hasValueFor(rgbValue)) { RGB rgb = convertStringToRGB(rgbValue); if (rgb != null) { ColorRegistry.put(rgbValue, rgb); } } return ColorRegistry.get(rgbValue); }
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;/*www. ja v a 2 s . c o 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)); } }
From source file:com.bdaum.zoom.rcp.internal.Application.java
License:Open Source License
public Object start(IApplicationContext context) throws Exception { Display display = PlatformUI.createDisplay(); ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); RGB white = new RGB(255, 255, 255); RGB silver = new RGB(144, 144, 144); RGB grey = new RGB(128, 128, 128); RGB dark = new RGB(64, 64, 64); RGB black = new RGB(0, 0, 0); // Regions//from w w w. jav a 2s .co m colorRegistry.put(Constants.APPCOLOR_REGION_FACE, new RGB(255, 160, 0)); // Background colorRegistry.put("b", black); //$NON-NLS-1$ colorRegistry.put("d", dark); //$NON-NLS-1$ colorRegistry.put("g", new RGB(240, 240, 248)); //$NON-NLS-1$ colorRegistry.put("w", white); //$NON-NLS-1$ colorRegistry.put("p", display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND).getRGB()); //$NON-NLS-1$ // Widget text colorRegistry.put("b_", white); //$NON-NLS-1$ colorRegistry.put("d_", white); //$NON-NLS-1$ colorRegistry.put("g_", black); //$NON-NLS-1$ colorRegistry.put("w_", black); //$NON-NLS-1$ colorRegistry.put("p_", display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND).getRGB()); //$NON-NLS-1$ // Gallery item text colorRegistry.put("b-", grey); //$NON-NLS-1$ colorRegistry.put("d-", silver); //$NON-NLS-1$ colorRegistry.put("g-", new RGB(32, 32, 32)); //$NON-NLS-1$ colorRegistry.put("w-", grey); //$NON-NLS-1$ colorRegistry.put("p-", display.getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB()); //$NON-NLS-1$ // Selected gallery item background colorRegistry.put("b#", grey); //$NON-NLS-1$ colorRegistry.put("d#", silver); //$NON-NLS-1$ colorRegistry.put("g#", dark); //$NON-NLS-1$ colorRegistry.put("w#", silver); //$NON-NLS-1$ colorRegistry.put("p#", display.getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB()); //$NON-NLS-1$ // Selected gallery item text colorRegistry.put("b!", black); //$NON-NLS-1$ colorRegistry.put("d!", dark); //$NON-NLS-1$ colorRegistry.put("g!", grey); //$NON-NLS-1$ colorRegistry.put("w!", white); //$NON-NLS-1$ colorRegistry.put("p!", display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT).getRGB()); //$NON-NLS-1$ // Fonts are created by the ApplicationWorkbenchAdvisor URL iniUrl = FileLocator.find(RcpActivator.getDefault().getBundle(), new Path(ZOOM_INI), null); if (iniUrl != null) try (InputStream in = iniUrl.openStream()) { System.getProperties().load(in); } try { return (PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()) == PlatformUI.RETURN_RESTART) ? IApplication.EXIT_RESTART : IApplication.EXIT_OK; } finally { try { display.dispose(); } catch (Exception e) { // catched only because of trayitem bug in osx implemention } } }