Java Code Examples for org.eclipse.jface.resource.StringConverter

The following examples show how to use org.eclipse.jface.resource.StringConverter. These examples are extracted from open source projects. 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 Project: xtext-eclipse   Source File: EditorUtils.java    License: 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 2
Source Project: tracecompass   Source File: SplashHandler.java    License: 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 3
/**
 * 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 4
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 5
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 6
Source Project: APICloud-Studio   Source File: InputDialog.java    License: 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 7
/**
 * 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 8
@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 9
Source Project: birt   Source File: GroupRenameDialog.java    License: 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 10
Source Project: birt   Source File: LevelStaticAttributeDialog.java    License: 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 11
Source Project: birt   Source File: RenameInputDialog.java    License: 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 12
@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 13
Source Project: Pydev   Source File: InputDialogWithLongMessage.java    License: 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 14
Source Project: Pydev   Source File: PyCodeScannerTest.java    License: 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 15
Source Project: arx   Source File: DialogComboSelection.java    License: 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 16
Source Project: arx   Source File: DialogComboDoubleSelection.java    License: 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 17
Source Project: xds-ide   Source File: PersistentTokenDescriptor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void preferenciesFromIni(Ini ini) {
    String s = ini.get(Config.DEFAULT_GLOBAL_SECTION_NAME, styleId);
    if (s != null) {
        styleWhenEnabled = Integer.parseInt(s);
    } else {
        styleWhenEnabled = getDefaultStyle();
    }
    
    s = ini.get(Config.DEFAULT_GLOBAL_SECTION_NAME, disabledId);
    if (s != null) {
        isDisabled = (Integer.parseInt(s) != 0);
    } else {
        isDisabled = false;
    }
    
    s = ini.get(Config.DEFAULT_GLOBAL_SECTION_NAME, colorId);
    if (s != null) {
        rgbWhenEnabled = StringConverter.asRGB(s, getDefaultRgb());
    } else {
        rgbWhenEnabled = getDefaultRgb();
    }
    
    if (isDisabled && iTokens != null) {
        PersistentTokenDescriptor pt = iTokens.getDefaultColoring();
        TextAttributeDescriptor ta = pt.getTextAttribute();
        if (ta != null) {
            setTextAttribute(new TextAttributeDescriptor(ta.getForeground(), null, ta.getStyle()));
        }
    } else {
    	setTextAttribute(new TextAttributeDescriptor(rgbWhenEnabled, null, styleWhenEnabled));
    }
}
 
Example 18
Source Project: tracecompass   Source File: ParameterDialog.java    License: Eclipse Public License 2.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
 */
private void setErrorMessage(String errorMessage) {
    this.fErrorMessage = errorMessage;
    if (fErrorMessageText != null && !fErrorMessageText.isDisposed()) {
        fErrorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
        boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
        fErrorMessageText.setEnabled(hasError);
        fErrorMessageText.setVisible(hasError);
        fErrorMessageText.getParent().update();
        Control button = getButton(IDialogConstants.OK_ID);
        if (button != null) {
            button.setEnabled(errorMessage == null);
        }
    }
}
 
Example 19
Source Project: tracecompass   Source File: AddAnalysisDialog.java    License: 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 20
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 21
Source Project: depan   Source File: NodeDisplayTableControl.java    License: Apache License 2.0 5 votes vote down vote up
private String getColorName(GraphNode node) {
  NodeDisplayProperty prop = getDisplayProperty(node);
  if (null == prop) {
    return null;
  }
  Color color = prop.getColor();
  if (null == color) {
    return null;
  }
  String result = StringConverter.asString(Colors.rgbFromColor(color));
  return "(" + result + ")";
}
 
Example 22
Source Project: depan   Source File: EdgeDisplayTableControl.java    License: 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 23
Source Project: depan   Source File: RelationDisplayTableControl.java    License: 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 24
private void applyThemeToConsole(Theme currentTheme, boolean revertToDefaults, IProgressMonitor monitor)
{
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode("org.eclipse.debug.ui"); //$NON-NLS-1$
	if (revertToDefaults)
	{
		prefs.remove("org.eclipse.debug.ui.errorColor"); //$NON-NLS-1$
		prefs.remove("org.eclipse.debug.ui.outColor"); //$NON-NLS-1$
		prefs.remove("org.eclipse.debug.ui.inColor"); //$NON-NLS-1$
		prefs.remove("org.eclipse.debug.ui.consoleBackground"); //$NON-NLS-1$
		prefs.remove("org.eclipse.debug.ui.PREF_CHANGED_VALUE_BACKGROUND"); //$NON-NLS-1$
	}
	else
	{
		setColor(prefs, "org.eclipse.debug.ui.errorColor", currentTheme, ConsoleThemer.CONSOLE_ERROR, //$NON-NLS-1$
				currentTheme.getForegroundAsRGB("console.error")); //$NON-NLS-1$
		setColor(prefs, "org.eclipse.debug.ui.outColor", currentTheme, ConsoleThemer.CONSOLE_OUTPUT, //$NON-NLS-1$
				currentTheme.getForeground());
		setColor(prefs, "org.eclipse.debug.ui.inColor", currentTheme, ConsoleThemer.CONSOLE_INPUT, //$NON-NLS-1$
				currentTheme.getForegroundAsRGB("console.input")); //$NON-NLS-1$
		prefs.put("org.eclipse.debug.ui.consoleBackground", StringConverter.asString(currentTheme.getBackground())); //$NON-NLS-1$
		prefs.put("org.eclipse.debug.ui.PREF_CHANGED_VALUE_BACKGROUND", //$NON-NLS-1$
				StringConverter.asString(currentTheme.getBackgroundAsRGB("markup.changed.variable"))); //$NON-NLS-1$
	}
	if (monitor.isCanceled())
	{
		return;
	}
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(ThemePlugin.getDefault(), e);
	}
}
 
Example 25
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 26
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 27
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 28
/**
 * 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 29
/**
 * 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 Project: tmxeditor8   Source File: InputDialog.java    License: 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);
		}
	}
}