Search in sources :

Example 46 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project translationstudio8 by heartsome.

the class FileFormatUtils method checkAutomaticOO.

/**
	 * 检查是否启用 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));
    }
}
Also used : ConverterBean(net.heartsome.cat.converter.util.ConverterBean) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 47 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project tesb-studio-se by Talend.

the class AnsiConsoleUtils method getDebugConsoleFgColor.

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

Example 48 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project knime-core by knime.

the class ImportPreferencesAction 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;
    }
    FileDialog fileDialog = new FileDialog(workbenchWindow.getShell(), SWT.OPEN);
    fileDialog.setFilterExtensions(new String[] { "*.epf", "*.*" });
    fileDialog.setText("Specify the preferences file to import.");
    String filePath = fileDialog.open();
    if (filePath == null || filePath.trim().length() == 0) {
        return;
    }
    File inFile = new File(filePath);
    if (!inFile.isFile() || !inFile.canRead()) {
        MessageDialog.openError(workbenchWindow.getShell(), "File Selection Error", "Unable to read from specified location.");
        return;
    }
    InputStream in = null;
    try {
        in = new BufferedInputStream(new FileInputStream(inFile));
        IPreferencesService prefService = Platform.getPreferencesService();
        LOGGER.info("Importing preferences from file " + inFile.getAbsolutePath() + " now ...");
        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 });
        LOGGER.info("Import of preferences successfully finished.");
    } catch (Throwable t) {
        String msg = "Unable to read preferences from selected file";
        if (t.getMessage() != null && !t.getMessage().isEmpty()) {
            msg = t.getMessage();
        }
        MessageDialog.openError(workbenchWindow.getShell(), "Error Importing Preferences", msg);
        return;
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
            // ignore
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IExportedPreferences(org.eclipse.core.runtime.preferences.IExportedPreferences) IPreferenceFilter(org.eclipse.core.runtime.preferences.IPreferenceFilter) IOException(java.io.IOException) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) FileInputStream(java.io.FileInputStream) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 49 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project yamcs-studio by yamcs.

the class PreferencesHelper method getConsolePopupLevel.

public static ConsolePopupLevel getConsolePopupLevel() {
    final IPreferencesService service = Platform.getPreferencesService();
    String popupLevelString = service.getString(OPIBuilderPlugin.PLUGIN_ID, POPUP_CONSOLE, ConsolePopupLevel.ALL.toString(), null);
    return ConsolePopupLevel.valueOf(popupLevelString);
}
Also used : IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 50 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project erlide_eclipse by erlang.

the class ErlangCoreLogger method getLogFile.

public static String getLogFile() {
    final IPreferencesService service = Platform.getPreferencesService();
    final String pluginId = ErlangCore.PLUGIN_ID;
    String file = System.getProperty("erlide.log_file");
    if (file == null) {
        file = service.getString(pluginId, "log_file", "erlide.log", null);
    }
    final IPath path = new Path(file);
    String location;
    if (!path.isAbsolute()) {
        final IPath wroot = ResourcesPlugin.getWorkspace().getRoot().getLocation();
        location = wroot.append(file).toPortableString();
    } else {
        location = file;
    }
    new File(location).getParentFile().mkdirs();
    return location;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) File(java.io.File) 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