Example usage for org.eclipse.jface.resource StringConverter asString

List of usage examples for org.eclipse.jface.resource StringConverter asString

Introduction

In this page you can find the example usage for org.eclipse.jface.resource StringConverter asString.

Prototype

public static String asString(boolean value) 

Source Link

Document

Converts the given boolean value to a string.

Usage

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.//  ww w.  j  ava2s  . c o  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.editors.clojure.scanners.ClojureTokenScanner.java

License:Open Source License

protected void initClojureTokenTypeToJFaceTokenMap(TokenScannerUtils u) {
    u.addTokenType(Keyword.intern("unexpected"), ClojureTokenScanner.errorToken);
    u.addTokenType(Keyword.intern("eof"), Token.EOF);
    u.addTokenType(Keyword.intern("whitespace"), Token.WHITESPACE);

    for (Keyword token : PreferenceConstants.colorizableTokens) {
        PreferenceConstants.ColorizableToken tokenStyle = PreferenceConstants
                .getColorizableToken(preferenceStore, token);
        u.addTokenType(token, StringConverter.asString(tokenStyle.rgb), tokenStyle.isBold, tokenStyle.isItalic);
    }//from   w  ww .  j a v a  2 s  .  c o m
}

From source file:ccw.editors.clojure.scanners.TokenScannerUtils.java

License:Open Source License

/**
  * Creates the data to feed an IToken.//from w ww . j a v a  2 s .  c om
  * @param rgb A color (RGB).
  * @param isBold If it is in bold style.
  * @param isItalic If it is in italic style.
  * @return An Object (tipically a TextAttribute)
  */
public static TextAttribute createTokenData(RGB rgb, Boolean isBold, Boolean isItalic) {
    return createTokenData(StringConverter.asString(rgb), isBold, isItalic);
}

From source file:ccw.preferences.PreferenceInitializer.java

License:Open Source License

@Override
public void initializeDefaultPreferences() {
    IPreferenceStore store = CCWPlugin.getDefault().getPreferenceStore();

    store.setDefault(PreferenceConstants.CCW_GENERAL_AUTOMATIC_NATURE_ADDITION, true);
    store.setDefault(PreferenceConstants.CCW_GENERAL_AUTO_RELOAD_ON_STARTUP_SAVE, false);
    store.setDefault(PreferenceConstants.CCW_GENERAL_LAUNCH_REPLS_IN_DEBUG_MODE, true);
    store.setDefault(PreferenceConstants.CCW_GENERAL_USE_LEININGEN_LAUNCHER, true);

    store.setDefault(org.eclipse.jdt.ui.PreferenceConstants.EDITOR_MATCHING_BRACKETS, true);
    store.setDefault(org.eclipse.jdt.ui.PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR,
            StringConverter.asString(new RGB(150, 150, 150)));
    store.setDefault(PreferenceConstants.EDITOR_ESCAPE_ON_PASTE, false);
    store.setDefault(PreferenceConstants.EDITOR_CODE_COMPLETION_AUTO_ACTIVATE, true);
    store.setDefault(PreferenceConstants.EDITOR_DISPLAY_NAMESPACE_IN_TABS, true);
    store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 2);
    store.setDefault(PreferenceConstants.SWITCH_TO_NS_ON_REPL_STARTUP, true);
    store.setDefault(USE_STRICT_STRUCTURAL_EDITING_MODE_BY_DEFAULT, false);
    store.setDefault(PreferenceConstants.SHOW_RAINBOW_PARENS_BY_DEFAULT, true);
    store.setDefault(PreferenceConstants.USE_TAB_FOR_REINDENTING_LINE, true);
    store.setDefault(PreferenceConstants.FORCE_TWO_SPACES_INDENT, false);

    store.setDefault(PreferenceConstants.REPL_VIEW_AUTO_EVAL_ON_ENTER_ACTIVE, true);
    store.setDefault(PreferenceConstants.REPL_VIEW_DISPLAY_HINTS, true);

    store.setDefault(PreferenceConstants.REPL_HISTORY_MAX_SIZE, 1000);
    store.setDefault(PreferenceConstants.REPL_HISTORY_PERSIST_SCHEDULE, 30000);

    for (SyntaxColoringDefault d : coloringDefaults) {
        store.setDefault(d.getPreferenceConstant(), StringConverter.asString(d.getDefaultColor()));
        store.setDefault(SyntaxColoringHelper.getEnabledPreferenceKey(d.getPreferenceConstant()),
                d.isDefaultEnabled());//from   w  w w  .j av a  2s . c  o  m
        store.setDefault(SyntaxColoringHelper.getBoldPreferenceKey(d.getPreferenceConstant()), d.isBold());
        store.setDefault(SyntaxColoringHelper.getItalicPreferenceKey(d.getPreferenceConstant()), d.isItalic());
    }

    // Experimental Features
    store.setDefault(PreferenceConstants.EXPERIMENTAL_AUTOSHIFT_ENABLED, true);
}

From source file:cn.edu.pku.ogeditor.properties.ColorSection.java

License:Open Source License

public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
    super.createControls(parent, tabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;//from   w  w w .j av  a 2 s  . c om

    Shell shell = new Shell();
    GC gc = new GC(shell);
    gc.setFont(shell.getFont());
    Point point = gc.textExtent("");//$NON-NLS-1$
    int buttonHeight = point.y + 5;
    gc.dispose();
    shell.dispose();

    CLabel colorLabel = getWidgetFactory().createCLabel(composite, "Color:"); //$NON-NLS-1$
    colorText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
    colorText.setEditable(false);
    Button colorButton = getWidgetFactory().createButton(composite, "Change...", SWT.PUSH); //$NON-NLS-1$
    colorButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            ColorDialog clDialog = new ColorDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());

            RGB clData = clDialog.open();

            if (clData != null) {
                //value = clData.toString();
                Color newColor = new Color(null, clData);
                sep.getCastedModel().setColor(newColor.getRGB());
                colorText.setText(StringConverter.asString(clData));
                ShapesEditor.myselfShapesEditor.setDirty(true);
            }
        }
    });

    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(colorText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(0, 0);
    colorLabel.setLayoutData(data);

    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(colorButton, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(0, 0);
    colorText.setLayoutData(data);

    data = new FormData();
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.height = buttonHeight;
    colorButton.setLayoutData(data);
}

From source file:cn.edu.pku.ogeditor.properties.ColorSection.java

License:Open Source License

public void refresh() {
    RGB colorData = ((ShapeFigure) sep.getFigure()).getEllipseFigure().getBackgroundColor().getRGB();
    String value = colorData.toString();

    if ((value != null) && (value.length() > 0)) {
        colorText.setText(StringConverter.asString(colorData));
    }//from w  w w  .ja v  a 2  s. c o  m
}

From source file:cn.edu.pku.ogeditor.properties.FontSection.java

License:Open Source License

public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
    super.createControls(parent, tabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;//from w ww.  j  a v  a2s  .com

    Shell shell = new Shell();
    GC gc = new GC(shell);
    gc.setFont(shell.getFont());
    Point point = gc.textExtent("");//$NON-NLS-1$
    int buttonHeight = point.y + 5;
    gc.dispose();
    shell.dispose();

    CLabel fontLabel = getWidgetFactory().createCLabel(composite, "Font:"); //$NON-NLS-1$
    fontText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
    fontText.setEditable(false);
    Button fontButton = getWidgetFactory().createButton(composite, "Change...", SWT.PUSH); //$NON-NLS-1$
    fontButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            FontDialog ftDialog = new FontDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());

            FontData fontdata = ((ShapeFigure) sep.getFigure()).getFont().getFontData()[0];
            String value = fontdata.toString();

            if ((value != null) && (value.length() > 0)) {
                ftDialog.setFontList(new FontData[] { new FontData(value) });
            }
            FontData fData = ftDialog.open();

            if (fData != null) {
                value = fData.toString();
                Font newFont = new Font(null, fData);
                ((ShapeFigure) sep.getFigure()).setFont(newFont);
                fontText.setText(StringConverter.asString(fData));
            }
        }
    });

    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(fontText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(0, 0);
    fontLabel.setLayoutData(data);

    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(fontButton, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(0, 0);
    fontText.setLayoutData(data);

    data = new FormData();
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.height = buttonHeight;
    fontButton.setLayoutData(data);
}

From source file:cn.edu.pku.ogeditor.properties.FontSection.java

License:Open Source License

public void refresh() {
    if (((ShapeFigure) sep.getFigure()).getFont() != null) {
        FontData fontData = ((ShapeFigure) sep.getFigure()).getFont().getFontData()[0];
        String value = fontData.toString();

        if ((value != null) && (value.length() > 0)) {
            fontText.setText(StringConverter.asString(fontData));
        }/* w w  w .j a v a2  s  .co m*/
    }
}

From source file:com.amalto.workbench.dialogs.AnnotationOrderedListsDialog.java

License:Open Source License

public void initializeDefaultPreferences() {
    IPreferenceStore store = MDMWorbenchPlugin.getDefault().getPreferenceStore();

    store.setDefault(PREF_COLOR_DEFAULT, StringConverter.asString(new RGB(0, 128, 0)));
    store.setDefault(PREF_COLOR_STRING, StringConverter.asString(new RGB(0, 0, 255)));
    store.setDefault(PREF_COLOR_KEYWORD, StringConverter.asString(new RGB(0, 0, 128)));
}

From source file:com.aptana.editor.common.CommonEditorPlugin.java

License:Open Source License

/**
 * Hook up a listener for theme changes, and change the PHP occurrence colors!
 *//*  w  w w.  ja va2 s  .  c  o  m*/
private void listenForThemeChanges() {
    Job job = new UIJob("Set occurrence colors to theme") //$NON-NLS-1$
    {
        private void setOccurrenceColors() {
            IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode("org.eclipse.ui.editors"); //$NON-NLS-1$
            Theme theme = ThemePlugin.getDefault().getThemeManager().getCurrentTheme();

            prefs.put("OccurrenceIndicationColor", StringConverter.asString(theme.getSearchResultColor())); //$NON-NLS-1$

            try {
                prefs.flush();
            } catch (BackingStoreException e) {
                // ignore
            }
        }

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            fThemeChangeListener = new IPreferenceChangeListener() {
                public void preferenceChange(PreferenceChangeEvent event) {
                    if (event.getKey().equals(IThemeManager.THEME_CHANGED)) {
                        setOccurrenceColors();
                    }
                }
            };

            setOccurrenceColors();

            EclipseUtil.instanceScope().getNode(ThemePlugin.PLUGIN_ID)
                    .addPreferenceChangeListener(fThemeChangeListener);

            return Status.OK_STATUS;
        }
    };

    EclipseUtil.setSystemForJob(job);
    job.schedule(2000);
}