use of org.eclipse.core.runtime.preferences.IPreferencesService in project tesb-studio-se by Talend.
the class AnsiConsoleUtils method getDebugConsoleBgColor.
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);
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project knime-core by knime.
the class ExportPreferencesAction method run.
/**
* Invoke the Import wizards selection Wizard.
*/
@Override
public void run() {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workbenchWindow == null) {
// action has been disposed
return;
}
ExportPreferencesDialog dlg = new ExportPreferencesDialog(workbenchWindow.getShell());
dlg.setBlockOnOpen(true);
int dlgResult = dlg.open();
if (dlgResult != IDialogConstants.OK_ID) {
return;
}
File outFile = new File(dlg.fileName());
if (!outFile.exists()) {
File p = outFile.getParentFile();
if (!p.exists() && !outFile.getParentFile().mkdirs()) {
MessageDialog.openError(workbenchWindow.getShell(), "File Creation Error", "Unable to create parent directory for output file");
return;
}
}
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(outFile));
IPreferencesService prefService = Platform.getPreferencesService();
NodeLogger.getLogger(ExportPreferencesAction.class).info("Exporting preferences to file " + outFile.getAbsolutePath());
/* Do not export the default values and the profile (contains only update site URLs). */
prefService.exportPreferences(prefService.getRootNode(), out, new String[] { "bundle_defaults", "profile", "instance/org.knime.product//us_info-" });
} catch (Throwable t) {
String msg = "Unable to write preferences to output file";
if (t.getMessage() != null && !t.getMessage().isEmpty()) {
msg = t.getMessage();
}
MessageDialog.openError(workbenchWindow.getShell(), "Error Writing File", msg);
return;
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
// ignore
}
}
}
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project knime-core by knime.
the class BatchExecutor method setPreferences.
/**
* Sets the workspace preferences using the given file.
*
* @param preferenceFile the preferences file
* @throws FileNotFoundException if the given file is not a file or does not exist
* @throws CoreException if applying the preferences fails
* @since 2.8
*/
public static void setPreferences(final File preferenceFile) throws FileNotFoundException, CoreException {
if (!preferenceFile.isFile()) {
throw new FileNotFoundException("Preference file '" + preferenceFile.getAbsolutePath() + "' does not exist");
}
InputStream in = new BufferedInputStream(new FileInputStream(preferenceFile));
IPreferencesService prefService = Platform.getPreferencesService();
IExportedPreferences prefs = prefService.readPreferences(in);
IPreferenceFilter filter = new IPreferenceFilter() {
@Override
public String[] getScopes() {
return new String[] { InstanceScope.SCOPE, ConfigurationScope.SCOPE, "profile" };
}
@Override
@SuppressWarnings("rawtypes")
public Map getMapping(final String scope) {
// this filter is applicable for all nodes
return null;
}
};
/*
* Calling this method with filters and not the applyPreferences without
* filters is very important! The other method does not merge the
* preferences but deletes all default values.
*/
prefService.applyPreferences(prefs, new IPreferenceFilter[] { filter });
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project org.csstudio.display.builder by kasemir.
the class Preferences method getUpdateAccumulationMillisec.
public static int getUpdateAccumulationMillisec() {
int milli = 20;
final IPreferencesService prefs = Platform.getPreferencesService();
if (prefs != null)
milli = prefs.getInt(ID, "update_accumulation_time", milli, null);
return milli;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project org.csstudio.display.builder by kasemir.
the class Preferences method getMaxReparse.
/**
* @return Maximum number of re-parse operations
*/
public static int getMaxReparse() {
int max_reparse = 5000;
final IPreferencesService prefs = Platform.getPreferencesService();
if (prefs != null)
max_reparse = prefs.getInt(ModelPlugin.ID, MAX_REPARSE_ITERATIONS, max_reparse, null);
return max_reparse;
}
Aggregations