Search in sources :

Example 1 with IPreferencesService

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);
}
Also used : IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 2 with IPreferencesService

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
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 3 with IPreferencesService

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 });
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) IExportedPreferences(org.eclipse.core.runtime.preferences.IExportedPreferences) IPreferenceFilter(org.eclipse.core.runtime.preferences.IPreferenceFilter) FileInputStream(java.io.FileInputStream) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 4 with IPreferencesService

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;
}
Also used : IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 5 with IPreferencesService

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;
}
Also used : IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Aggregations

IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)96 IFile (org.eclipse.core.resources.IFile)26 ArrayList (java.util.ArrayList)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)14 IProject (org.eclipse.core.resources.IProject)13 CoreException (org.eclipse.core.runtime.CoreException)13 Module (org.eclipse.titan.designer.AST.Module)11 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)11 List (java.util.List)10 File (java.io.File)8 TextSelection (org.eclipse.jface.text.TextSelection)8 Path (org.eclipse.core.runtime.Path)6 IContainer (org.eclipse.core.resources.IContainer)5 IMarker (org.eclipse.core.resources.IMarker)5 IPath (org.eclipse.core.runtime.IPath)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)5 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)5 IOException (java.io.IOException)4 IStatus (org.eclipse.core.runtime.IStatus)4