Java Code Examples for org.eclipse.core.runtime.Platform#getPreferencesService()

The following examples show how to use org.eclipse.core.runtime.Platform#getPreferencesService() . 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: LineSeparators.java    From eclipse-encoding-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static String ofWorkspace() {
	IPreferencesService prefs = Platform.getPreferencesService();
	IScopeContext[] scopeContext = new IScopeContext[] { InstanceScope.INSTANCE };
	String lineSeparator = prefs.getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
	if (lineSeparator == null) {
		lineSeparator = System.getProperty("line.separator");
	}
	return toLabel(lineSeparator);
}
 
Example 2
Source File: ImageServiceMock.java    From dawnsci with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ImageServiceBean createBeanFromPreferences() {
	
	ImageServiceBean imageServiceBean = new ImageServiceBean();
	
	if (Platform.getPreferencesService() != null) { // Normally
		IPreferenceStore store            = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.dawnsci.plotting");
		imageServiceBean.setOrigin(ImageOrigin.forLabel(store.getString(BasePlottingConstants.ORIGIN_PREF)));
		imageServiceBean.setHistogramType(HistoType.forLabel(store.getString(BasePlottingConstants.HISTO_PREF)));
		imageServiceBean.setMinimumCutBound(HistogramBound.fromString(store.getString(BasePlottingConstants.MIN_CUT)));
		imageServiceBean.setMaximumCutBound(HistogramBound.fromString(store.getString(BasePlottingConstants.MAX_CUT)));
		imageServiceBean.setNanBound(HistogramBound.fromString(store.getString(BasePlottingConstants.NAN_CUT)));
		imageServiceBean.setLo(store.getDouble(BasePlottingConstants.HISTO_LO));
		imageServiceBean.setHi(store.getDouble(BasePlottingConstants.HISTO_HI));		
		
		try {
			
			imageServiceBean.setPalette(makeJetPalette());

		} catch (Exception e) {
			// Ignored
		}
		
	} else { // Hard code something
		
		imageServiceBean.setOrigin(ImageOrigin.TOP_LEFT);
		imageServiceBean.setHistogramType(HistoType.OUTLIER_VALUES);
		imageServiceBean.setMinimumCutBound(HistogramBound.DEFAULT_MINIMUM);
		imageServiceBean.setMaximumCutBound(HistogramBound.DEFAULT_MAXIMUM);
		imageServiceBean.setNanBound(HistogramBound.DEFAULT_NAN);
		imageServiceBean.setLo(00.01);
		imageServiceBean.setHi(99.99);		
		imageServiceBean.setPalette(makeJetPalette());
	}

	return imageServiceBean;
}
 
Example 3
Source File: FileFormatUtils.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 检查是否启用 Open Office
 */
private static void checkAutomaticOO(List<ConverterBean> list) {
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = Activator.getDefault().getBundle().getSymbolicName();
	boolean automaticOO = service.getBoolean(qualifier, IPreferenceConstants.AUTOMATIC_OO, false, null);
	if (!automaticOO) {
		list.remove(new ConverterBean("MS Office Document to XLIFF Conveter", null));
	}
}
 
Example 4
Source File: FileFormatUtils.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 检查是否启用 Open Office
 */
private static void checkAutomaticOO(List<ConverterBean> list) {
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = Activator.getDefault().getBundle().getSymbolicName();
	boolean automaticOO = service.getBoolean(qualifier, IPreferenceConstants.AUTOMATIC_OO, false, null);
	if (!automaticOO) {
		list.remove(new ConverterBean("MS Office Document to XLIFF Conveter", null));
	}
}
 
Example 5
Source File: ApplicationWorkbenchAdvisor.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private void saveEclipsePreferences() {
	final IPreferencesService service = Platform.getPreferencesService();

	try (final FileOutputStream outputStream =
		new FileOutputStream(Platform.getInstanceLocation().getURL().getPath() + "/.gama.epf")) {
		service.exportPreferences(service.getRootNode(), WorkspacePreferences.getPreferenceFilters(), outputStream);
	} catch (final CoreException | IOException e1) {}

}
 
Example 6
Source File: TmfTimePreferences.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get the locale
 *
 * @return the locale
 */
public static Locale getLocale() {
    String defaultLanguageTag = Locale.getDefault().toLanguageTag();
    IPreferencesService preferencesService = Platform.getPreferencesService();
    if (preferencesService == null) {
        return Locale.forLanguageTag(defaultLanguageTag);
    }
    return Locale.forLanguageTag(preferencesService.getString(Activator.PLUGIN_ID, ITmfTimePreferencesConstants.LOCALE, defaultLanguageTag, null));
}
 
Example 7
Source File: TmfTimePreferences.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get the time zone
 *
 * @return the time zone
 */
public static TimeZone getTimeZone() {
    String defaultId = TimeZone.getDefault().getID();
    IPreferencesService preferencesService = Platform.getPreferencesService();
    if (preferencesService == null) {
        return TimeZone.getTimeZone(defaultId);
    }
    return TimeZone.getTimeZone(preferencesService.getString(Activator.PLUGIN_ID, ITmfTimePreferencesConstants.TIME_ZONE, defaultId, null));
}
 
Example 8
Source File: ImportPlatformWizard.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
protected boolean isAutoBuildEnabled()
{
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
	String key = "description.autobuilding";
	IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE};
	return service.getBoolean( qualifier, key, false, contexts );
}
 
Example 9
Source File: SynchronizePlatformWizard.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
protected boolean isAutoBuildEnabled()
{
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
	String key = "description.autobuilding";
	IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE};
	return service.getBoolean( qualifier, key, false, contexts );
}
 
Example 10
Source File: FileFormatUtils.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 检查是否启用 Open Office
 */
private static void checkAutomaticOO(List<ConverterBean> list) {
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = Activator.getDefault().getBundle().getSymbolicName();
	boolean automaticOO = service.getBoolean(qualifier, IPreferenceConstants.AUTOMATIC_OO, false, null);
	if (!automaticOO) {
		list.remove(new ConverterBean("MS Office Document to XLIFF Conveter", null));
	}
}
 
Example 11
Source File: BuildUtils.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
protected static boolean isAutoBuildEnabled() {
	IPreferencesService service = Platform.getPreferencesService();
	String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
	String key = "description.autobuilding";
	IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE };
	return service.getBoolean(qualifier, key, false, contexts);
}
 
Example 12
Source File: LineSeparators.java    From eclipse-encoding-plugin with Eclipse Public License 1.0 4 votes vote down vote up
public static String ofProject(IResource resource) {
	IPreferencesService prefs = Platform.getPreferencesService();
	IScopeContext[] scopeContext = new IScopeContext[] { new ProjectScope(resource.getProject()) };
	String lineSeparator = prefs.getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
	return toLabel(lineSeparator);
}
 
Example 13
Source File: PreferencesLookupHelper.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
protected static IPreferencesService preferences() {
	return Platform.getPreferencesService();
}
 
Example 14
Source File: AnsiConsoleUtils.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
public static Color getDebugConsoleBgColor() {
    IPreferencesService ps = Platform.getPreferencesService();
    String value = ps.getString(DEBUG_CONSOLE_PLUGIN_ID, "org.eclipse.debug.ui.consoleBackground",
            DEBUG_CONSOLE_FALLBACK_BKCOLOR, null);
    return colorFromStringRgb(value);
}
 
Example 15
Source File: AnsiConsoleUtils.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
public static Color getDebugConsoleFgColor() {
    IPreferencesService ps = Platform.getPreferencesService();
    String value = ps.getString(DEBUG_CONSOLE_PLUGIN_ID, "org.eclipse.debug.ui.outColor", DEBUG_CONSOLE_FALLBACK_FGCOLOR,
            null);
    return colorFromStringRgb(value);
}
 
Example 16
Source File: CheckstyleUIPluginPrefs.java    From eclipse-cs with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns a string preference for the given preference id.
 * 
 * @param prefId
 *          the preference id
 * @return the string result
 */
public static String getString(String prefId) {

  IPreferencesService prefs = Platform.getPreferencesService();
  return prefs.getString(CheckstyleUIPlugin.PLUGIN_ID, prefId, null, null);
}
 
Example 17
Source File: PreferencesLookupDelegate.java    From APICloud-Studio with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new delegate instance
 * <p>
 * A project may be specified to retrieve project specific value.
 * </p>
 * 
 * @param project
 *            project reference, may be <code>null</code>
 */
public PreferencesLookupDelegate(IProject project)
{
	this.service = Platform.getPreferencesService();
	this.contexts = getLookupScopes(project);
}
 
Example 18
Source File: CheckstylePluginPrefs.java    From eclipse-cs with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns a boolean preference for the given preference id.
 * 
 * @param prefId
 *          the preference id
 * @return the boolean result
 */
public static boolean getBoolean(String prefId) {

  IPreferencesService prefs = Platform.getPreferencesService();
  return prefs.getBoolean(CheckstylePlugin.PLUGIN_ID, prefId, false, null);
}
 
Example 19
Source File: CheckstyleUIPluginPrefs.java    From eclipse-cs with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns an integer preference for the given preference id.
 * 
 * @param prefId
 *          the preference id
 * @return the integer result
 */
public static int getInt(String prefId) {

  IPreferencesService prefs = Platform.getPreferencesService();
  return prefs.getInt(CheckstyleUIPlugin.PLUGIN_ID, prefId, 0, null);
}
 
Example 20
Source File: CheckstyleUIPluginPrefs.java    From eclipse-cs with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns a boolean preference for the given preference id.
 * 
 * @param prefId
 *          the preference id
 * @return the boolean result
 */
public static boolean getBoolean(String prefId) {

  IPreferencesService prefs = Platform.getPreferencesService();
  return prefs.getBoolean(CheckstyleUIPlugin.PLUGIN_ID, prefId, false, null);
}