当前位置: 首页>>代码示例>>Java>>正文


Java StringConverter类代码示例

本文整理汇总了Java中org.eclipse.jface.resource.StringConverter的典型用法代码示例。如果您正苦于以下问题:Java StringConverter类的具体用法?Java StringConverter怎么用?Java StringConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringConverter类属于org.eclipse.jface.resource包,在下文中一共展示了StringConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setErrorMessage

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
/**
 * 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);
		}
	}
}
 
开发者ID:32kda,项目名称:com.onpositive.prefeditor,代码行数:29,代码来源:FolderSelectionDialog.java

示例2: get

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
public List<SyntaxStyle> get() {
	ArrayList<SyntaxStyle> result = new ArrayList<SyntaxStyle>();
	setDefaults(store);
	for (SyntaxStyle s : defaultStyles) {
		boolean enable = store.getBoolean(getStyleKey(StyleAspect.enable, s.displayName));
		RGB color = StringConverter.asRGB(store.getString(getStyleKey(StyleAspect.color, s.displayName)));
		boolean bold = store.getBoolean(getStyleKey(StyleAspect.bold, s.displayName));
		;
		boolean italic = store.getBoolean(getStyleKey(StyleAspect.italic, s.displayName));
		;
		boolean strikethrough = store.getBoolean(getStyleKey(StyleAspect.strikethrough, s.displayName));
		;
		boolean underline = store.getBoolean(getStyleKey(StyleAspect.underline, s.displayName));
		;
		result.add(new SyntaxStyle(s.displayName, s.type, enable, color, bold, italic, strikethrough, underline));
	}
	return result;
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:19,代码来源:SyntaxStyleSettings.java

示例3: adaptToColorChange

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
private void adaptToColorChange(Token token, PropertyChangeEvent event) {
	RGB rgb = null;

	Object value = event.getNewValue();
	if (value instanceof RGB) {
		rgb = (RGB) value;
	} else if (value instanceof String) {
		rgb = StringConverter.asRGB((String) value);
	}

	if (rgb != null) {

		String property = event.getProperty();
		Color color = colorMgr.getColor(property);
		if (!rgb.equals(color.getRGB())) {
			colorMgr.setValue(property, rgb);
			color = colorMgr.getColor(property);
		}

		Object data = token.getData();
		if (data instanceof TextAttribute) {
			TextAttribute oldAttr = (TextAttribute) data;
			token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
		}
	}
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:27,代码来源:AbstractBufferedRuleBasedScanner.java

示例4: setErrorMessage

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
public void setErrorMessage(String 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);
		}
	}
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:20,代码来源:FontCustomDialog.java

示例5: colorFromString

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
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;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:EditorUtils.java

示例6: getColorForKeyWithoutDefault

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
protected Color getColorForKeyWithoutDefault(String key) {
	Color result = null;
	try {
		if (!Raptor.getInstance().getColorRegistry().hasValueFor(key)) {
			// We don't want the default color if not found we want to
			// return null, so use
			// StringConverter instead of PreferenceConverter.
			String value = getString(key);
			if (StringUtils.isNotBlank(value)) {
				RGB rgb = StringConverter.asRGB(value, null);
				if (rgb != null) {
					Raptor.getInstance().getColorRegistry().put(key, rgb);
				} else {
					return null;
				}
			} else {
				return null;
			}
		}
		result = Raptor.getInstance().getColorRegistry().get(key);
	} catch (Throwable t) {
		result = null;
	}
	return result;
}
 
开发者ID:evilwan,项目名称:raptor-chess-interface,代码行数:26,代码来源:RaptorPreferenceStore.java

示例7: getColor

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
private Color getColor(final String configurationKey, final String defaultColorKey) {
	String colorKey = configuration.getString(configurationKey, defaultColorKey);
	RGB rgbColorData;
	try {
		rgbColorData = StringConverter.asRGB(colorKey);
	}
	catch (final RuntimeException e) {
		logger.log(Level.FINER, e.toString(), e);
		logger.log(Level.INFO, Messages.get("err.invalid.color"), colorKey);
		colorKey = defaultColorKey;
		rgbColorData = StringConverter.asRGB(colorKey);
	}
	final ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
	if (!colorRegistry.hasValueFor(colorKey)) {
		colorRegistry.put(colorKey, rgbColorData);
	}
	return colorRegistry.get(colorKey);
}
 
开发者ID:Albertus82,项目名称:RouterLogger,代码行数:19,代码来源:DataTable.java

示例8: setErrorMessage

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
public void setErrorMessage(final String errorMessage) {
	this.errorMessage = errorMessage;

	if (errorMessageText != null && !errorMessageText.isDisposed()) {
		errorMessageText.setText(errorMessage == null ? " \n " : errorMessage);

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

		final Control button = getButton(IDialogConstants.OK_ID);
		if (button != null)
			button.setEnabled(errorMessage == null);
	}
}
 
开发者ID:boalang,项目名称:xtext-ide,代码行数:17,代码来源:InputSelectionDialog.java

示例9: createColorProperty

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
public void createColorProperty(Composite cmp, final String prop, String name, final IPreferenceStore store) {
	new Label(cmp, SWT.NONE).setText(name);

	final ColorSelector colorSelector = new ColorSelector(cmp);
	colorSelector.addListener(new IPropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent event) {
			properties.put(prop, StringConverter.asString(colorSelector.getColorValue()));
			save(store);
		}
	});
	try {
		colorSelector.setColorValue(StringConverter.asRGB(properties.get(prop)));
	} catch (DataFormatException e) {
		e.printStackTrace();
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:17,代码来源:UITheme.java

示例10: refreshGridLayer

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
/**
 * Updates the {@link GridLayer grid} based on properties set on the {@link #getViewer() graphical viewer}:
 * {@link SnapToGrid#PROPERTY_GRID_VISIBLE}, {@link SnapToGrid#PROPERTY_GRID_SPACING}, and
 * {@link SnapToGrid#PROPERTY_GRID_ORIGIN}.
 * <p>
 * This method is invoked initially when the GridLayer is created, and when any of the above-mentioned properties are
 * changed on the viewer.
 */
protected void refreshGridLayer() {
	if (jConfig != null) {
		boolean visible = jConfig.getPropertyBoolean(RulersGridPreferencePage.P_PAGE_RULERGRID_SHOWGRID, true);
		GridLayer grid = ((APageFigure) getFigure()).getGrid();
		grid.setOrigin((Point) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ORIGIN));

		int x = jConfig.getPropertyInteger(RulersGridPreferencePage.P_PAGE_RULERGRID_GRIDSPACEX, 10);
		int y = jConfig.getPropertyInteger(RulersGridPreferencePage.P_PAGE_RULERGRID_GRIDSPACEY, 10);

		grid.setSpacing(new Dimension(x, y));
		grid.setVisible(visible);
		getViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(x, y));

		String mcolor = jConfig.getProperty(RulersGridPreferencePage.P_PAGE_GRID_COLOR,
				RulersGridPreferencePage.DEFAULT_GRIDCOLOR);
		Color fg = SWTResourceManager.getColor(StringConverter.asRGB(mcolor));
		grid.setForegroundColor(fg);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:28,代码来源:PageEditPart.java

示例11: setToken

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
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$
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:22,代码来源:InvasiveThemeHijacker.java

示例12: setSemanticToken

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
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$
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:26,代码来源:InvasiveThemeHijacker.java

示例13: setErrorMessage

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
/**
 * 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);
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:35,代码来源:RebootConfirmDialog.java

示例14: updateFont

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
/**
 * Updates the change font button and the previewer to reflect the newly selected font.
 * 
 * @param font
 *            The FontData[] to update with.
 */
private void updateFont(final FontData font[]) {

	FontData[] bestFont = JFaceResources.getFontRegistry().filterData(font, _lblSelectedFont.getDisplay());

	//if we have nothing valid do as best we can
	if (bestFont == null) {
		bestFont = getDefaultFontData();
	}

	//Now cache this value in the receiver
	this.chosenFont = bestFont;

	if (_lblSelectedFont != null) {
		_lblSelectedFont.setText(StringConverter.asString(chosenFont[0]));
	}
	if (_fontPreviewer != null) {
		_fontPreviewer.setFont(bestFont);
	}

	// update font size widget
	final int fontHeight = bestFont[0].getHeight();
	_spinFontSize.setSelection(fontHeight);
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:30,代码来源:FontFieldEditorExtended.java

示例15: parseRGB

import org.eclipse.jface.resource.StringConverter; //导入依赖的package包/类
/**
 * Converts a String to RGB, could be of several formats
 * * @see {@link StringUtils}
 */
public static RGB parseRGB(String valueString) {
	try {
		if (valueString != null && valueString.startsWith("#")) {
			valueString = valueString.substring(1);
		}
		Integer hexcode = Integer.parseInt(valueString, 16);
		if (hexcode != null) {
			return new RGB((hexcode/256/256)%256, (hexcode/256)%256, hexcode%256);
		}
	} catch (NumberFormatException e) {
		try {
			return StringConverter.asRGB(valueString);
		} catch (Exception x) {
			// ignore it
		}
	}
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:23,代码来源:ColorUtils.java


注:本文中的org.eclipse.jface.resource.StringConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。