org.eclipse.jface.resource.StringConverter Java Examples

The following examples show how to use org.eclipse.jface.resource.StringConverter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected void setToken(IEclipsePreferences prefs, Theme theme, String ourTokenType, String jdtToken,
		boolean revertToDefaults)
{
	if (revertToDefaults)
	{
		prefs.remove(jdtToken);
		prefs.remove(jdtToken + "_bold"); //$NON-NLS-1$
		prefs.remove(jdtToken + "_italic"); //$NON-NLS-1$
		prefs.remove(jdtToken + "_underline"); //$NON-NLS-1$
		prefs.remove(jdtToken + "_strikethrough"); //$NON-NLS-1$
	}
	else
	{
		TextAttribute attr = theme.getTextAttribute(ourTokenType);
		prefs.put(jdtToken, StringConverter.asString(attr.getForeground().getRGB()));
		prefs.putBoolean(jdtToken + "_bold", (attr.getStyle() & SWT.BOLD) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + "_italic", (attr.getStyle() & SWT.ITALIC) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + "_underline", (attr.getStyle() & TextAttribute.UNDERLINE) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + "_strikethrough", (attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0); //$NON-NLS-1$
	}
}
 
Example #2
Source File: InputURLDialog.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets or clears the error message.
 * If not <code>null</code>, the OK button is disabled.
 * 
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
	this.errorMessage = errorMessage;
	if (errorMessageText != null && !errorMessageText.isDisposed()) {
		errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
		// Disable the error message text control if there is no error, or
		// no error text (empty or whitespace only).  Hide it also to avoid
		// color change.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
		boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
		errorMessageText.setEnabled(hasError);
		errorMessageText.setVisible(hasError);
		errorMessageText.getParent().update();
		// Access the ok button by id, in case clients have overridden button creation.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
		Control button = getButton(IDialogConstants.OK_ID);
		if (button != null) {
			button.setEnabled(errorMessage == null);
		}
	}
}
 
Example #3
Source File: SplashHandler.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void init(Shell splash) {
    super.init(splash);

    String progressString = null;

    // Try to get the progress bar and message updater.
    IProduct product = Platform.getProduct();
    if (product != null) {
        progressString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
    }
    Rectangle progressRect = StringConverter.asRectangle(progressString, PROCESS_BAR_RECTANGLE);
    setProgressRect(progressRect);

    // Set font color.
    setForeground(FOREGROUND_COLOR);

    // Set the software version.
    getContent().addPaintListener(e -> {
        e.gc.setForeground(getForeground());
        e.gc.drawText(
                NLS.bind(Messages.SplahScreen_VersionString,
                        TracingRcpPlugin.getDefault().getBundle().getVersion().toString()),
                VERSION_LOCATION.x, VERSION_LOCATION.y, true);
    });
}
 
Example #4
Source File: DialogComboSelection.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Sets or clears the error message. If not <code>null</code>, the OK button
 * is disabled.
 * 
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
    this.errorMessage = errorMessage;
    if (errorMessageText != null && !errorMessageText.isDisposed()) {
        errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
        // Disable the error message text control if there is no error, or
        // no error text (empty or whitespace only). Hide it also to avoid
        // color change. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
        boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
        errorMessageText.setEnabled(hasError);
        errorMessageText.setVisible(hasError);
        errorMessageText.getParent().update();
        // Access the ok button by id, in case clients have overridden
        // button creation. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
        Control button = getButton(IDialogConstants.OK_ID);
        if (button != null) {
            button.setEnabled(errorMessage == null);
        }
    }
}
 
Example #5
Source File: DialogComboDoubleSelection.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Sets or clears the error message. If not <code>null</code>, the OK button
 * is disabled.
 * 
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
    this.errorMessage = errorMessage;
    if (errorMessageText != null && !errorMessageText.isDisposed()) {
        errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
        // Disable the error message text control if there is no error, or
        // no error text (empty or whitespace only). Hide it also to avoid
        // color change. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
        boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
        errorMessageText.setEnabled(hasError);
        errorMessageText.setVisible(hasError);
        errorMessageText.getParent().update();
        // Access the ok button by id, in case clients have overridden
        // button creation. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
        Control button = getButton(IDialogConstants.OK_ID);
        if (button != null) {
            button.setEnabled(errorMessage == null);
        }
    }
}
 
Example #6
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected void setSemanticToken(IEclipsePreferences prefs, Theme theme, String ourTokenType, String jdtToken,
		boolean revertToDefaults)
{
	String prefix = "semanticHighlighting."; //$NON-NLS-1$
	jdtToken = prefix + jdtToken;
	if (revertToDefaults)
	{
		prefs.remove(jdtToken + ".color"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".bold"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".italic"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".underline"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".strikethrough"); //$NON-NLS-1$
		prefs.remove(jdtToken + ".enabled"); //$NON-NLS-1$
	}
	else
	{
		TextAttribute attr = theme.getTextAttribute(ourTokenType);
		prefs.put(jdtToken + ".color", StringConverter.asString(attr.getForeground().getRGB())); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".bold", (attr.getStyle() & SWT.BOLD) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".italic", (attr.getStyle() & SWT.ITALIC) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".underline", (attr.getStyle() & TextAttribute.UNDERLINE) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".strikethrough", (attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0); //$NON-NLS-1$
		prefs.putBoolean(jdtToken + ".enabled", true); //$NON-NLS-1$
	}
}
 
Example #7
Source File: InputDialog.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets or clears the error message.
 * If not <code>null</code>, the OK button is disabled.
 * 
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
	this.errorMessage = errorMessage;
	if (errorMessageText != null && !errorMessageText.isDisposed()) {
		errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
		// Disable the error message text control if there is no error, or
		// no error text (empty or whitespace only).  Hide it also to avoid
		// color change.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
		boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
		errorMessageText.setEnabled(hasError);
		errorMessageText.setVisible(hasError);
		errorMessageText.getParent().update();
		// Access the ok button by id, in case clients have overridden button creation.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
		Control button = getButton(IDialogConstants.OK_ID);
		if (button != null) {
			button.setEnabled(errorMessage == null);
		}
	}
}
 
Example #8
Source File: RebootConfirmDialog.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Validates the input.
 * 
 * /** Sets or clears the error message. If not <code>null</code>, the OK
 * button is disabled.
 * 
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
	this.errorMessage = errorMessage;
	if (errorMessageText != null && !errorMessageText.isDisposed()) {
		errorMessageText
				.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
		// Disable the error message text control if there is no error, or
		// no error text (empty or whitespace only). Hide it also to avoid
		// color change.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
		boolean hasError = errorMessage != null
				&& (StringConverter.removeWhiteSpaces(errorMessage))
						.length() > 0;
		errorMessageText.setEnabled(hasError);
		errorMessageText.setVisible(hasError);
		errorMessageText.getParent().update();
		// Access the ok button by id, in case clients have overridden
		// button creation.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
		Control button = getButton(IDialogConstants.OK_ID);
		if (button != null) {
			button.setEnabled(errorMessage == null);
		}
	}
}
 
Example #9
Source File: PyCodeScannerTest.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private PyCodeScanner createCodeScanner() {
    PreferenceStore store = new PreferenceStore();
    store.putValue(PyDevEditorPreferences.KEYWORD_COLOR, StringConverter.asString(new RGB(1, 0, 0)));
    store.putValue(PyDevEditorPreferences.SELF_COLOR, StringConverter.asString(new RGB(2, 0, 0)));
    store.putValue(PyDevEditorPreferences.CODE_COLOR, StringConverter.asString(new RGB(3, 0, 0)));
    store.putValue(PyDevEditorPreferences.DECORATOR_COLOR, StringConverter.asString(new RGB(4, 0, 0)));
    store.putValue(PyDevEditorPreferences.NUMBER_COLOR, StringConverter.asString(new RGB(5, 0, 0)));
    store.putValue(PyDevEditorPreferences.FUNC_NAME_COLOR, StringConverter.asString(new RGB(6, 0, 0)));
    store.putValue(PyDevEditorPreferences.CLASS_NAME_COLOR, StringConverter.asString(new RGB(7, 0, 0)));
    store.putValue(PyDevEditorPreferences.OPERATORS_COLOR, StringConverter.asString(new RGB(8, 0, 0)));
    store.putValue(PyDevEditorPreferences.PARENS_COLOR, StringConverter.asString(new RGB(9, 0, 0)));

    this.colorCache = new ColorAndStyleCache(store);
    PyCodeScanner scanner = new PyCodeScanner(colorCache);
    return scanner;
}
 
Example #10
Source File: SourceActionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean close() {
	if (fAllowedVisibilities != null && fAllowedVisibilities.size() > 0 && fAllowedVisibilities.contains(new Integer(fVisibilityModifier)))
		fSettings.put(SETTINGS_VISIBILITY_MODIFIER, StringConverter.asString(fVisibilityModifier));
	fSettings.put(SETTINGS_FINAL_MODIFIER, StringConverter.asString(fFinal));
	fSettings.put(SETTINGS_SYNCHRONIZED_MODIFIER, StringConverter.asString(fSynchronized));
	fSettings.put(SETTINGS_COMMENTS, fGenerateComment);

	if (fHasUserChangedPositionIndex) {
		if (fCurrentPositionIndex == INSERT_FIRST_INDEX || fCurrentPositionIndex == INSERT_LAST_INDEX)
			fSettings.put(SETTINGS_INSERT_POSITION, StringConverter.asString(fCurrentPositionIndex));
		else if (fEditor != null)
			fSettings.put(SETTINGS_INSERT_POSITION, StringConverter.asString(INSERT_POSITION_FROM_EDITOR));
	}

	return super.close();
}
 
Example #11
Source File: EditorUtils.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static Color colorFromString(String rgbString) {
	if (rgbString != null && rgbString.trim().length() > 0) {
		Color col = JFaceResources.getColorRegistry().get(rgbString);
		try {
			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;
}
 
Example #12
Source File: InputDialogWithLongMessage.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sets or clears the error message.
 * If not <code>null</code>, the OK button is disabled.
 *
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
    this.errorMessage = errorMessage;
    if (errorMessageText != null && !errorMessageText.isDisposed()) {
        errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
        // Disable the error message text control if there is no error, or
        // no error text (empty or whitespace only).  Hide it also to avoid
        // color change.
        // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
        boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
        errorMessageText.setEnabled(hasError);
        errorMessageText.setVisible(hasError);
        errorMessageText.getParent().update();
        // Access the ok button by id, in case clients have overridden button creation.
        // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
        Control button = getButton(IDialogConstants.OK_ID);
        if (button != null) {
            button.setEnabled(errorMessage == null);
        }
    }
}
 
Example #13
Source File: DefaultValuesInitializer.java    From e4Preferences with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void initializeDefaultPreferences()
{
	IEclipsePreferences node = DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(getClass()).getSymbolicName());

	if (node != null)
	{
		node.put("rootPageValue", "DEFAULT ROOT PAGE VALUE");
		node.put("page1", "DEFAULT PAGE 1 VALUE");
		node.put("page2", "DEFAULT PAGE 2 VALUE");
	
		node.put("prefCombo", "value2");
		node.put("prefColor", StringConverter.asString(new RGB(0,255,0)));
		node.putBoolean("prefBoolean",true);
		node.put("prefString","Default string value");
		
		try { node.flush();  }  catch (BackingStoreException e) { }
	}		
	
	
	
}
 
Example #14
Source File: RenameInputDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setErrorMessage( String errorMessage )
{
	this.errorMessage = errorMessage;
	if ( errorMessageText != null && !errorMessageText.isDisposed( ) )
	{
		errorMessageText.setText( errorMessage == null ? " \n " : errorMessage ); //$NON-NLS-1$

		boolean hasError = errorMessage != null
				&& ( StringConverter.removeWhiteSpaces( errorMessage ) ).length( ) > 0;
		errorMessageText.setEnabled( hasError );
		errorMessageText.setVisible( hasError );
		errorMessageText.getParent( ).update( );

		Control button = getButton( IDialogConstants.OK_ID );
		if ( button != null )
		{
			button.setEnabled( errorMessage == null );
		}
	}
}
 
Example #15
Source File: GroupRenameDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setErrorMessage( String errorMessage )
{
	this.errorMessage = errorMessage;
	if ( errorMessageText != null && !errorMessageText.isDisposed( ) )
	{
		errorMessageText.setText( errorMessage == null ? " \n " : errorMessage ); //$NON-NLS-1$
		// Disable the error message text control if there is no error, or
		// no error text (empty or whitespace only). Hide it also to avoid
		// color change.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
		boolean hasError = errorMessage != null
				&& ( StringConverter.removeWhiteSpaces( errorMessage ) ).length( ) > 0;
		errorMessageText.setEnabled( hasError );
		errorMessageText.setVisible( hasError );
		errorMessageText.getParent( ).update( );
		// Access the ok button by id, in case clients have overridden
		// button creation.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
		Control button = getButton( IDialogConstants.OK_ID );
		if ( button != null )
		{
			button.setEnabled( errorMessage == null );
		}
	}
}
 
Example #16
Source File: LevelStaticAttributeDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void setErrorMessage( String errorMessage )
{
	if ( errorMessageText != null && !errorMessageText.isDisposed( ) )
	{
		errorMessageText.setText( errorMessage == null ? " \n " : errorMessage ); //$NON-NLS-1$

		boolean hasError = errorMessage != null
				&& ( StringConverter.removeWhiteSpaces( errorMessage ) ).length( ) > 0;
		errorMessageText.setEnabled( hasError );
		errorMessageText.setVisible( hasError );
		errorMessageText.getParent( ).update( );

		Control button = getButton( IDialogConstants.OK_ID );
		if ( button != null )
		{
			button.setEnabled( errorMessage == null );
		}
	}
}
 
Example #17
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void setColor(IEclipsePreferences prefs, String prefKey, Theme currentTheme, String tokenName,
		RGB defaultColor)
{
	RGB rgb = defaultColor;
	if (currentTheme.hasEntry(tokenName))
	{
		rgb = currentTheme.getForegroundAsRGB(tokenName);
	}
	prefs.put(prefKey, StringConverter.asString(rgb));
}
 
Example #18
Source File: EdgeDisplayTableControl.java    From depan with Apache License 2.0 5 votes vote down vote up
private String getColorName(EdgeDisplayProperty prop) {
  if (null == prop) {
    return null;
  }
  Color color = prop.getColor();
  if (null == color) {
    return null;
  }
  String result = StringConverter.asString(Colors.rgbFromColor(color));
  return "(" + result + ")";
}
 
Example #19
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void setHyperlinkValues(Theme theme, IEclipsePreferences prefs, boolean revertToDefaults)
{
	if (prefs == null || theme == null)
	{
		return;
	}
	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()));

	}

}
 
Example #20
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void setGeneralEditorValues(Theme theme, IEclipsePreferences prefs, boolean revertToDefaults)
{
	if (prefs == null)
		return;
	if (revertToDefaults)
	{
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND);
		prefs.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
	}
	else
	{
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND,
				StringConverter.asString(theme.getSelectionAgainstBG()));
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND,
				StringConverter.asString(theme.getForeground()));
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, StringConverter.asString(theme.getBackground()));
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, StringConverter.asString(theme.getForeground()));
		prefs.put(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR,
				StringConverter.asString(theme.getLineHighlightAgainstBG()));
	}

	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, revertToDefaults);
	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, revertToDefaults);
	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, revertToDefaults);

	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(ThemePlugin.getDefault(), e);
	}
}
 
Example #21
Source File: EditorAppearanceColorsComponent.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public void setValues(String colorPrefValue, boolean useSystemDefaultPrefValue) {
	color = StringConverter.asRGB(colorPrefValue, PreferenceConverter.COLOR_DEFAULT_DEFAULT);
	useSystemDefault = false;
	if(useSystemDefaultKey != null) {
		useSystemDefault = useSystemDefaultPrefValue;
	}
}
 
Example #22
Source File: TextStylingPreference.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static void setToStore(IEclipsePreferences store, String key, TextStyling textStyle) {
	store.putBoolean(getEnabledKey(key), textStyle.isEnabled);
	store.put(getColorKey(key), StringConverter.asString(textStyle.rgb));
	store.putBoolean(getBoldKey(key), textStyle.isBold);
	store.putBoolean(getItalicKey(key), textStyle.isItalic);
	store.putBoolean(getStrikethroughKey(key), textStyle.isStrikethrough);
	store.putBoolean(getUnderlineKey(key), textStyle.isUnderline);
}
 
Example #23
Source File: SamplePart.java    From e4Preferences with Eclipse Public License 1.0 5 votes vote down vote up
private Color getColorFromPref(String colorKey)
{
	Color c = creg.get(colorKey);
	if (c == null)
	{
		creg.put(colorKey, StringConverter.asRGB(colorKey));
		c = creg.get(colorKey);
	}
	return c;
}
 
Example #24
Source File: InputDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets or clears the error message. If not <code>null</code>, the OK button is disabled.
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
	this.errorMessage = errorMessage;
	if (errorMessageText != null && !errorMessageText.isDisposed()) {
		String msg = errorMessageText.getText();
		msg = msg == null ? "" : msg;
		errorMessageText.setText(errorMessage == null ? "" : errorMessage); //$NON-NLS-1$
		// Disable the error message text control if there is no error, or
		// no error text (empty or whitespace only). Hide it also to avoid
		// color change.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
		boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
		errorMessageText.setEnabled(hasError);
		errorMessageText.setVisible(hasError);
		errorMessageText.getParent().update();
		String msg2 = errorMessageText.getText();
		if (!msg.equals(msg2) && initLocation != null && initSize != null) {
			Point p = getShell().computeSize(initSize.x, SWT.DEFAULT);
			getShell().setBounds(
					getConstrainedShellBounds(new Rectangle(initLocation.x, initLocation.y, initSize.x, p.y)));
		}
		// Access the ok button by id, in case clients have overridden button creation.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
		Control button = getButton(IDialogConstants.OK_ID);
		if (button != null) {
			button.setEnabled(errorMessage == null);
		}
	}
}
 
Example #25
Source File: ConsoleColorCache.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private Color getDebugColor(String key) {
    IEclipsePreferences node = new InstanceScope().getNode("org.eclipse.debug.ui");
    String color = node.get(key, null);
    if (color != null) {
        try {
            return getDefault().getColor(StringConverter.asRGB(color));
        } catch (Exception e) {
            Log.log(e);
        }
    }
    return null;
}
 
Example #26
Source File: PreferenceValueConverter.java    From LogViewer with Eclipse Public License 2.0 5 votes vote down vote up
public static final String asString(RulePreferenceData data) {
      String position = Base64.encode(Integer.toString(data.getPosition()));
      String checked = Base64.encode(Boolean.toString(data.isEnabled()));
      String rule = Base64.encode(data.getRuleName());
      String background = Base64.encode(StringConverter.asString(data.getBackgroundColor()));
      String foreground = Base64.encode(StringConverter.asString(data.getForegroundColor()));
      String value = Base64.encode(data.getRuleValue());
String matchMode = Base64.encode(data.getMatchMode());
String caseInsensitive = Base64.encode(Boolean.toString(data.isCaseInsensitive()));
      return position + VALUE_DELIMITER + checked + VALUE_DELIMITER + rule + VALUE_DELIMITER + background + VALUE_DELIMITER + foreground + VALUE_DELIMITER + value + VALUE_DELIMITER + matchMode + VALUE_DELIMITER + caseInsensitive;
  }
 
Example #27
Source File: InputDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets or clears the error message. If not <code>null</code>, the OK button is disabled.
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
	this.errorMessage = errorMessage;
	if (errorMessageText != null && !errorMessageText.isDisposed()) {
		String msg = errorMessageText.getText();
		msg = msg == null ? "" : msg;
		errorMessageText.setText(errorMessage == null ? "" : errorMessage); //$NON-NLS-1$
		// Disable the error message text control if there is no error, or
		// no error text (empty or whitespace only). Hide it also to avoid
		// color change.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
		boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
		errorMessageText.setEnabled(hasError);
		errorMessageText.setVisible(hasError);
		errorMessageText.getParent().update();
		String msg2 = errorMessageText.getText();
		if (!msg.equals(msg2) && initLocation != null && initSize != null) {
			Point p = getShell().computeSize(initSize.x, SWT.DEFAULT);
			getShell().setBounds(
					getConstrainedShellBounds(new Rectangle(initLocation.x, initLocation.y, initSize.x, p.y)));
		}
		// Access the ok button by id, in case clients have overridden button creation.
		// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
		Control button = getButton(IDialogConstants.OK_ID);
		if (button != null) {
			button.setEnabled(errorMessage == null);
		}
	}
}
 
Example #28
Source File: AddAnalysisDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
protected void setErrorLabel(Label label, String errorMessage) {
    if (label != null && !label.isDisposed()) {
        label.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
        final boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
        label.setEnabled(hasError);
        label.setVisible(hasError);
        label.getParent().update();
        Control button = getButton(IDialogConstants.OK_ID);

        if (button != null) {
            button.setEnabled(errorMessage == null);
        }
    }
}
 
Example #29
Source File: ColorPersistor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a Color instance using the String created by {@link ColorPersistor#asColor(String)}
 */
public static Color asColor(String colorAsString) {
	try {
		return GUIHelper.getColor(StringConverter.asRGB(colorAsString));
	} catch (DataFormatException e) {
		return DEFAULT_COLOR;
	}
}
 
Example #30
Source File: MinimapPreferenceInitializer.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void initializeDefaultPreferences() {
    Preferences node = DefaultScope.INSTANCE.getNode(SharedUiPlugin.PLUGIN_ID);

    node.putBoolean(MinimapOverviewRulerPreferencesPage.USE_MINIMAP, true);
    node.putBoolean(MinimapOverviewRulerPreferencesPage.SHOW_VERTICAL_SCROLLBAR, false);
    node.putBoolean(MinimapOverviewRulerPreferencesPage.SHOW_HORIZONTAL_SCROLLBAR, true);
    node.putBoolean(MinimapOverviewRulerPreferencesPage.SHOW_MINIMAP_CONTENTS, false);
    node.putInt(MinimapOverviewRulerPreferencesPage.MINIMAP_WIDTH, 25); // Change default from 70 -> 25
    node.put(MinimapOverviewRulerPreferencesPage.MINIMAP_SELECTION_COLOR,
            StringConverter.asString(new RGB(51, 153, 255)));

}