Java 类org.eclipse.core.runtime.preferences.IEclipsePreferences 实例源码

项目:n4js    文件:OsgiBinariesPreferenceStore.java   
@Override
public IStatus save() {
    try {
        final IEclipsePreferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
        for (final Entry<Binary, URI> entry : getOrCreateState().entrySet()) {
            final URI path = entry.getValue();
            if (null != path) {
                final File file = new File(path);
                if (file.isDirectory()) {
                    node.put(entry.getKey().getId(), file.getAbsolutePath());
                }
            } else {
                // Set to default.
                node.put(entry.getKey().getId(), "");
            }
        }
        node.flush();
        return OK_STATUS;
    } catch (final BackingStoreException e) {
        final String message = "Unexpected error when trying to persist binary preferences.";
        LOGGER.error(message, e);
        return statusHelper.createError(message, e);
    }
}
项目:AgentWorkbench    文件:BundleProperties.java   
/**
 * return the listener for preferences changes.
 * @return the change listener
 */
private IEclipsePreferences.IPreferenceChangeListener getChangeListener() {
    if (changeListener==null) {
        changeListener = new IEclipsePreferences.IPreferenceChangeListener() {
            @Override
            public void preferenceChange(PreferenceChangeEvent pce) {

                if (debug==true) System.out.println("Property '" + pce.getKey() + "' changed from " + pce.getOldValue() + " to "+ pce.getNewValue());

                switch(pce.getKey()) {
                case DEF_RUNAS:
                    boolean changedExecutionMode = (pce.getOldValue()!=null && pce.getNewValue()!=pce.getOldValue());
                    if (changedExecutionMode==true) {
                        if (debug==true) System.out.println("Changed Execution Mode: changed from " + pce.getOldValue() + " to "+ pce.getNewValue());
                        //TODO if the preference dialog was set to SWT!
                    }
                }
            }
        };
    }
    return changeListener;
}
项目:EclipseMinifyBuilder    文件:MinifyBuilder.java   
@Override
protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args,
        IProgressMonitor monitor) throws CoreException {
    ProjectScope projectScope = new ProjectScope(getProject());
    IEclipsePreferences prefs = projectScope.getNode(BUILDER_ID);
    if (kind == FULL_BUILD) {
        fullBuild(prefs, monitor);
    } else {
        IResourceDelta delta = getDelta(getProject());
        if (delta == null) {
            fullBuild(prefs, monitor);
        } else {
            incrementalBuild(delta, prefs, monitor);
        }
    }
    return null;
}
项目:EclipseMinifyBuilder    文件:GccMinifier.java   
public GccMinifier(MinifyBuilder builder, IFile srcFile, IFile destFile, 
        OutputStream out, IEclipsePreferences prefs)
    throws IOException, CoreException {
    super(builder);
    this.srcFile = srcFile;
    this.out = out;
    this.outCharset = destFile.exists() ? destFile.getCharset() : "ascii";
    console = builder.minifierConsole();

    String optLevel = prefs.get(PrefsAccess.preferenceKey(
            srcFile, MinifyBuilder.GCC_OPTIMIZATION),
            MinifyBuilder.GCC_OPT_WHITESPACE_ONLY);
    switch (optLevel) {
    case MinifyBuilder.GCC_OPT_ADVANCED:
        compilationLevel = CompilationLevel.ADVANCED_OPTIMIZATIONS;
        break;
    case MinifyBuilder.GCC_OPT_SIMPLE:
        compilationLevel = CompilationLevel.SIMPLE_OPTIMIZATIONS;
        break;
    default:
        compilationLevel = CompilationLevel.WHITESPACE_ONLY;
    }
}
项目:pgcodekeeper    文件:DbSource.java   
@Override
protected PgDatabase loadInternal(SubMonitor monitor)
        throws IOException, InterruptedException, CoreException {
    String charset = proj.getProjectCharset();
    monitor.subTask(Messages.dbSource_loading_tree);
    IProject project = proj.getProject();

    int filesCount = PgUIDumpLoader.countFiles(project);
    monitor.setWorkRemaining(filesCount);

    IEclipsePreferences pref = proj.getPrefs();
    return PgUIDumpLoader.loadDatabaseSchemaFromIProject(
            project.getProject(),
            getPgDiffArgs(charset, pref.getBoolean(PROJ_PREF.FORCE_UNIX_NEWLINES, true)),
            monitor, null, errors);
}
项目:pgcodekeeper    文件:SQLEditor.java   
public DbInfo getCurrentDb() {
    if (currentDB != null) {
        return currentDB;
    }

    IResource res = ResourceUtil.getResource(getEditorInput());
    if (res != null) {
        IEclipsePreferences prefs = PgDbProject.getPrefs(res.getProject());
        if (prefs != null) {
            List<DbInfo> lastStore = DbInfo.preferenceToStore(
                    prefs.get(PROJ_PREF.LAST_DB_STORE_EDITOR, "")); //$NON-NLS-1$
            if (!lastStore.isEmpty()) {
                return lastStore.get(0);
            }
        }
    }
    return null;
}
项目:Hydrograph    文件:DebugDataViewer.java   
/**
 * 
 * Get data viewer preferences from preference file
 * 
 * @return {@link ViewDataPreferencesVO}
 */
public ViewDataPreferencesVO getViewDataPreferencesFromPreferenceFile() {
    boolean includeHeaderValue = false;
    IEclipsePreferences eclipsePreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    String delimiter = eclipsePreferences.get(DELIMITER, DEFAULT);
    String quoteCharactor = eclipsePreferences.get(QUOTE_CHARACTOR, DEFAULT);
    String includeHeader = eclipsePreferences.get(INCLUDE_HEADERS, DEFAULT);
    String fileSize = eclipsePreferences.get(FILE_SIZE, DEFAULT);
    String pageSize = eclipsePreferences.get(PAGE_SIZE, DEFAULT);
    delimiter = delimiter.equalsIgnoreCase(DEFAULT) ? DEFAULT_DELIMITER : delimiter;
    quoteCharactor = quoteCharactor.equalsIgnoreCase(DEFAULT) ? DEFAULT_QUOTE_CHARACTOR : quoteCharactor;
    includeHeaderValue = includeHeader.equalsIgnoreCase(DEFAULT) ? true : false;
    fileSize = fileSize.equalsIgnoreCase(DEFAULT) ? DEFAULT_FILE_SIZE : fileSize;
    pageSize = pageSize.equalsIgnoreCase(DEFAULT) ? DEFAULT_PAGE_SIZE : pageSize;
    ViewDataPreferencesVO viewDataPreferencesVO = new ViewDataPreferencesVO(delimiter, quoteCharactor,
            includeHeaderValue, Integer.parseInt(fileSize), Integer.parseInt(pageSize));
    return viewDataPreferencesVO;
}
项目:tm4e    文件:ThemeManager.java   
/**
 * Load TextMate Themes from preferences.
 */
private void loadThemesFromPreferences() {
    // Load Theme definitions from the
    // "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
    IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
    String json = prefs.get(PreferenceConstants.THEMES, null);
    if (json != null) {
        ITheme[] themes = PreferenceHelper.loadThemes(json);
        for (ITheme theme : themes) {
            super.registerTheme(theme);
        }
    }

    json = prefs.get(PreferenceConstants.THEME_ASSOCIATIONS, null);
    if (json != null) {
        IThemeAssociation[] themeAssociations = PreferenceHelper.loadThemeAssociations(json);
        for (IThemeAssociation association : themeAssociations) {
            super.registerThemeAssociation(association);
        }
    }
}
项目:tm4e    文件:ThemeManager.java   
@Override
public void save() throws BackingStoreException {
    // Save Themes in the
    // "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
    String json = PreferenceHelper.toJsonThemes(
            Arrays.stream(getThemes()).filter(t -> t.getPluginId() == null).collect(Collectors.toList()));
    IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
    prefs.put(PreferenceConstants.THEMES, json);

    // Save Theme associations in the
    // "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
    json = PreferenceHelper.toJsonThemeAssociations(Arrays.stream(getAllThemeAssociations())
            .filter(t -> t.getPluginId() == null).collect(Collectors.toList()));
    prefs.put(PreferenceConstants.THEME_ASSOCIATIONS, json);

    // Save preferences
    prefs.flush();
}
项目:eclipse-asciidoctools    文件:AsciidocConfiguration.java   
private static boolean updateConfigurationFromSettings(AsciidocConfiguration configuration, IProject project) {
    final IScopeContext projectScope = new ProjectScope(project);
    IEclipsePreferences preferences = projectScope.getNode(Activator.PLUGIN_ID);
    try {
        createSettings(project, BACKEND_DEFAULT, RESOURCESPATH_DEFAULT, SOURCESPATH_DEFAULT, STYLESHEETPATH_DEFAULT, TARGETPATH_DEFAULT);
        configuration.setBackend(preferences.get(BACKEND_PROPERTY, BACKEND_DEFAULT));
        configuration.setResourcesPath(preferences.get(RESOURCESPATH_PROPERTY, RESOURCESPATH_DEFAULT));
        configuration.setSourcesPath(preferences.get(SOURCESPATH_PROPERTY, SOURCESPATH_DEFAULT));
        configuration.setStylesheetPath(preferences.get(STYLESHEETPATH_PROPERTY, STYLESHEETPATH_DEFAULT));
        configuration.setTargetPath(preferences.get(TARGETPATH_PROPERTY, TARGETPATH_DEFAULT));
    } catch (BackingStoreException e) {
        Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e));
        return false;
    }
    configuration.source = AsciidocConfigurationSource.SETTINGS;
    return true;
}
项目:workspacemechanic    文件:PreferenceRecorder.java   
public void added(NodeChangeEvent event) {
  synchronized (lock) {
    // It's possible that we've stopped recording, but the listeners have
    // not yet been removed.
    // Ensure that we're still recording before writing new data
    if (currState != State.RECORDING) {
      return;
    }

    IEclipsePreferences childPrefs = (IEclipsePreferences) event.getChild();
    addListener(childPrefs);

    changeLog.add(new NodeChanged(true, new Path(event.getParent().absolutePath()), 
        event.getChild().name()));
  }
}
项目:workspacemechanic    文件:PreferenceReconcilerTaskTest.java   
public void testCompositeReconcilerReconciles() throws Exception {

    IEclipsePreferences root = mock(IEclipsePreferences.class);
    IEclipsePreferences wee = mock(IEclipsePreferences.class);

    when(root.node(WEE.getPath()))
        .thenReturn(wee);

    // should return an incorrect value
    when(wee.get(WEE.getKey(), null))
        .thenReturn(HAA.getValue());

    // It's a weird idiom, but we have to call this method before the
    // replay so that easy-mock will be aware of the fact that we will
    // be calling it after the replay. Else we get an exception.
    wee.put(WEE.getKey(), WEE.getValue());

    // needs reconciliation
    Reconciler reconciler = new CompositeReconciler(root, HAA,
        new EqualsMatcher(WEE), new SimpleResolver(WEE));

    assertFalse(reconciler.isReconciled());
    reconciler.reconcile(); // causes wee.put to be called.

    verify(wee).flush();
  }
项目:google-cloud-eclipse    文件:AppEngineDeployPreferencesPanelTest.java   
@Test
public void testProjectSavedInPreferencesSelected()
    throws ProjectRepositoryException, InterruptedException, BackingStoreException {
  IEclipsePreferences node =
      new ProjectScope(project).getNode(DeployPreferences.PREFERENCE_STORE_QUALIFIER);
  try {
    node.put("project.id", "projectId1");
    node.put("account.email", EMAIL_1);
    model = new DeployPreferences(project);

    initializeProjectRepository();
    when(loginService.getAccounts()).thenReturn(twoAccountSet);
    deployPanel = createPanel(true /* requireValues */);
    deployPanel.latestGcpProjectQueryJob.join();

    ProjectSelector projectSelector = getProjectSelector();
    IStructuredSelection selection = projectSelector.getViewer().getStructuredSelection();
    assertThat(selection.size(), is(1));
    assertThat(((GcpProject) selection.getFirstElement()).getId(), is("projectId1"));
  } finally {
    node.clear();
  }
}
项目:CodeCheckerEclipsePlugin    文件:CcConfiguration.java   
private  Map<ConfigTypes, String> getConfigEclipse(IEclipsePreferences pref ) {
    Map<ConfigTypes, String> ret = new HashMap<ConfigTypes, String>();
    for (ConfigTypes k:ConfigTypes.values()){
        if (defaults.containsKey(k))
            ret.put(k,defaults.get(k));
        else
            ret.put(k,"");
    }

    try {
        for (String configKey : pref.keys()) {
            for (ConfigTypes c : configKeys.keySet()) {
                if (configKey.equals(configKeys.get(c))){
                    ret.put(c, pref.get(configKey, ""));
                }
            }
        }
    } catch (BackingStoreException e) {
    }


    return ret;
}
项目:dsl-devkit    文件:ValidPreferenceStore.java   
/**
 * Does its best at determining the default value for the given key. Checks
 * the given object's type and then looks in the list of defaults to see if
 * a value exists. If not or if there is a problem converting the value, the
 * default default value for that type is returned.
 *
 * @param key
 *          the key to search
 * @param object
 *          the object who default we are looking for
 * @return Object or <code>null</code>
 */
Object getDefault(final String key, final Object object) {
  final IEclipsePreferences defaults = getDefaultPreferences();
  if (object instanceof String) {
    return defaults.get(key, STRING_DEFAULT_DEFAULT);
  } else if (object instanceof Integer) {
    return Integer.valueOf(defaults.getInt(key, INT_DEFAULT_DEFAULT));
  } else if (object instanceof Double) {
    return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
  } else if (object instanceof Float) {
    return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
  } else if (object instanceof Long) {
    return Long.valueOf(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
  } else if (object instanceof Boolean) {
    return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE : Boolean.FALSE;
  } else {
    return null;
  }
}
项目:dsl-devkit    文件:ValidPreferenceStore.java   
/**
 * Return the preference path to search preferences on. This is the list of
 * preference nodes based on the scope contexts for this store. If there are
 * no search contexts set, then return this store's context.
 * <p>
 * Whether or not the default context should be included in the resulting list is specified by the <code>includeDefault</code> parameter.
 * </p>
 *
 * @param includeDefault
 *          <code>true</code> if the default context should be included
 *          and <code>false</code> otherwise
 * @return IEclipsePreferences[]
 * @since 3.4 public, was added in 3.1 as private method
 */
public IEclipsePreferences[] getPreferenceNodes(final boolean includeDefault) {
  // if the user didn't specify a search order, then return the scope that
  // this store was created on. (and optionally the default)
  if (searchContexts == null) {
    if (includeDefault) {
      return new IEclipsePreferences[] {getStorePreferences(), getDefaultPreferences()};
    }
    return new IEclipsePreferences[] {getStorePreferences()};
  }
  // otherwise the user specified a search order so return the appropriate
  // nodes based on it
  int length = searchContexts.length;
  if (includeDefault) {
    length++;
  }
  final IEclipsePreferences[] preferences = new IEclipsePreferences[length];
  for (int i = 0; i < searchContexts.length; i++) {
    preferences[i] = searchContexts[i].getNode(nodeQualifier);
  }
  if (includeDefault) {
    preferences[length - 1] = getDefaultPreferences();
  }
  return preferences;
}
项目:tlaplus    文件:PreferenceStoreHelper.java   
/**
    * Stores root file name in project preferences
    * @param project
    * @param rootFilename
    */
public static void storeRootFilename(IProject project, String rootFilename) {
    // If this condition does not hold, the subsequent code but also
    // AddModuleHandler will not work. The claim is that spec files are
    // always in the parent folder of the IProject.
    final IPath path = new Path(rootFilename);
    Assert.isTrue(ResourceHelper.isProjectParent(path.removeLastSegments(1), project),
            project.getLocation().toOSString() + " is *not* a subdirectory of " + rootFilename
                    + ". This is commonly caused by a symlink contained in the latter path.");
    // Store the filename *without* any path information, but prepend the
    // magical PARENT-1-PROJECT-LOC. It indicates that the file can be found
    // *one* level up (hence the "1") from the project location.
    // readProjectRootFile can later easily deduce the relative location of
    // the file.
    rootFilename = ResourceHelper.PARENT_ONE_PROJECT_LOC + path.lastSegment();
       IEclipsePreferences projectPrefs = getProjectPreferences(project);
       projectPrefs.put(IPreferenceConstants.P_PROJECT_ROOT_FILE, rootFilename);
       storePreferences(projectPrefs);        
   }
项目:tlaplus    文件:PreferenceStoreHelper.java   
/**
    * Retrieves project root file name
    * @param project
    * @return
    */
public static IFile readProjectRootFile(IProject project) {
    final IEclipsePreferences projectPrefs = getProjectPreferences(project);
    if (projectPrefs != null) {
        String rootFileName = projectPrefs.get(IPreferenceConstants.P_PROJECT_ROOT_FILE,
                IPreferenceConstants.DEFAULT_NOT_SET);
        if (!IPreferenceConstants.DEFAULT_NOT_SET.equals(rootFileName)) {
            final IPath path = new Path(rootFileName);
            if (path.isAbsolute()) {
                // Convert a legacy (absolute) path to the new relative one
                // with the magic PARENT_PROJECT_LOC prefix.
                rootFileName = ResourceHelper.PARENT_ONE_PROJECT_LOC + path.lastSegment(); 
                convertAbsoluteToRelative(projectPrefs, rootFileName);
            }
            final IFile linkedFile = ResourceHelper.getLinkedFile(project, rootFileName);
            Activator.getDefault().logDebug(
                    "footFileName = " + (linkedFile != null ? linkedFile.getLocation().toOSString() : null));
            return linkedFile;
        }
    } else {
        Activator.getDefault().logInfo("projectPrefs is null");
    }
    return null;
}
项目:gwt-eclipse-plugin    文件:GWTProjectProperties.java   
public static void setFileNamesCopiedToWebInfLib(IProject project,
    List<String> fileNamesCopiedToWebInfLib) throws BackingStoreException {
  IEclipsePreferences prefs = getProjectProperties(project);
  StringBuilder sb = new StringBuilder();
  boolean addPipe = false;
  for (String fileNameCopiedToWebInfLib : fileNamesCopiedToWebInfLib) {
    if (addPipe) {
      sb.append("|");
    } else {
      addPipe = true;
    }

    sb.append(fileNameCopiedToWebInfLib);
  }

  prefs.put(FILES_COPIED_TO_WEB_INF_LIB, sb.toString());
  prefs.flush();
}
项目:APICloud-Studio    文件:HTMLTidyValidator.java   
@Override
public void restoreDefaults()
{
    // Wipe the user prefs for the problem severities
    IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(getPreferenceNode());
    for (ProblemType type : ProblemType.values())
    {
        prefs.remove(type.getPrefKey());
    }
    try
    {
        prefs.flush();
    }
    catch (BackingStoreException e)
    {
        IdeLog.logError(BuildPathCorePlugin.getDefault(), e);
    }
    // Let super class handle cleaning up enablement and filters
    super.restoreDefaults();
}
项目:APICloud-Studio    文件:ShellExecutable.java   
public static void setPreferenceShellPath(IPath path)
{
    IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(CorePlugin.PLUGIN_ID);
    if (path != null)
    {
        prefs.put(ICorePreferenceConstants.PREF_SHELL_EXECUTABLE_PATH, path.toOSString());
    }
    else
    {
        prefs.remove(ICorePreferenceConstants.PREF_SHELL_EXECUTABLE_PATH);
    }
    try
    {
        prefs.flush();
    }
    catch (BackingStoreException e)
    {
        IdeLog.logError(CorePlugin.getDefault(), "Saving preferences failed.", e); //$NON-NLS-1$
    }
    shellPath = null;
    shellEnvironment = null;
}
项目:APICloud-Studio    文件:PreferenceUtils.java   
/**
 * Sets if the new files and folders should update their permissions to specific permissions after transferring.
 * 
 * @param shouldSpecific
 *            true if the permissions should be updated, false otherwise
 * @param direction
 *            indicates if this is for upload or download permissions
 */
public static void setSpecificPermissions(boolean shouldSpecific, PermissionDirection direction)
{
    IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(CoreIOPlugin.PLUGIN_ID);
    switch (direction)
    {
        case UPLOAD:
            prefs.putBoolean(IPreferenceConstants.UPLOAD_SPECIFIC_PERMISSIONS, shouldSpecific);
            break;
        case DOWNLOAD:
            prefs.putBoolean(IPreferenceConstants.DOWNLOAD_SPECIFIC_PERMISSIONS, shouldSpecific);
            break;
    }
    try
    {
        prefs.flush();
    }
    catch (BackingStoreException e)
    {
        IdeLog.logError(CoreIOPlugin.getDefault(), e);
    }
}
项目:cft    文件:ModuleCache.java   
private void setLocalModuleToCloudModuleMapping(Map<String, String> list) {
    String string = convertMapToString(list);
    IEclipsePreferences node = new InstanceScope().getNode(CloudFoundryPlugin.PLUGIN_ID);
    CloudFoundryPlugin.trace("Updated mapping: " + string); //$NON-NLS-1$
    node.put(KEY_MODULE_MAPPING_LIST + ":" + getServerId(), string); //$NON-NLS-1$
    try {
        node.flush();
    }
    catch (BackingStoreException e) {
        CloudFoundryPlugin
                .getDefault()
                .getLog()
                .log(new Status(IStatus.ERROR, CloudFoundryPlugin.PLUGIN_ID,
                        "Failed to update application mappings", e)); //$NON-NLS-1$
    }
}
项目:APICloud-Studio    文件:PreferenceInitializer.java   
@Override
public void initializeDefaultPreferences()
{
    IEclipsePreferences prefs = (EclipseUtil.defaultScope()).getNode(JSPlugin.PLUGIN_ID);

    prefs.putBoolean(IPreferenceConstants.COMMENT_INDENT_USE_STAR, DEFAULT_COMMENT_INDENT_USE_STAR);
    // prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.LINK_OUTLINE_WITH_EDITOR, true);
    prefs.put(
            com.aptana.editor.common.contentassist.IPreferenceConstants.COMPLETION_PROPOSAL_ACTIVATION_CHARACTERS,
            "."); //$NON-NLS-1$
    prefs.put(
            com.aptana.editor.common.contentassist.IPreferenceConstants.CONTEXT_INFORMATION_ACTIVATION_CHARACTERS,
            ".("); //$NON-NLS-1$
    // https://jira.appcelerator.org/browse/APSTUD-4665
    //      prefs.put(com.aptana.editor.common.contentassist.IPreferenceConstants.PROPOSAL_TRIGGER_CHARACTERS, "."); //$NON-NLS-1$
    prefs.put(com.aptana.editor.common.contentassist.IPreferenceConstants.PROPOSAL_TRIGGER_CHARACTERS, ""); //$NON-NLS-1$
    prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_AUTO_INDENT, true);
    prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_ENABLE_FOLDING, true);

    // mark occurrences
    // prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
}
项目:che    文件:ImportOrganizeTest.java   
protected void setOrganizeImportSettings(
    String[] order, int threshold, int staticThreshold, IJavaProject project) {
  IEclipsePreferences scope =
      new ProjectScope(project.getProject()).getNode("org.eclipse.jdt.ui");
  if (order == null) {
    scope.remove(PreferenceConstants.ORGIMPORTS_IMPORTORDER);
    scope.remove(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD);
  } else {
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < order.length; i++) {
      buf.append(order[i]);
      buf.append(';');
    }
    scope.put(PreferenceConstants.ORGIMPORTS_IMPORTORDER, buf.toString());
    scope.put(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, String.valueOf(threshold));
    scope.put(
        PreferenceConstants.ORGIMPORTS_STATIC_ONDEMANDTHRESHOLD, String.valueOf(staticThreshold));
  }
}
项目:APICloud-Studio    文件:PreferenceUtils.java   
/**
 * Sets the specific permissions used for new files created when transferring.
 * 
 * @param permissions
 *            permissions in decimal form
 * @param direction
 *            indicates if this is for upload or download permissions
 */
public static void setFilePermissions(long permissions, PermissionDirection direction)
{
    IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(CoreIOPlugin.PLUGIN_ID);
    switch (direction)
    {
        case UPLOAD:
            prefs.putLong(IPreferenceConstants.UPLOAD_FILE_PERMISSION, permissions);
            break;
        case DOWNLOAD:
            prefs.putLong(IPreferenceConstants.DOWNLOAD_FILE_PERMISSION, permissions);
            break;
    }
    try
    {
        prefs.flush();
    }
    catch (BackingStoreException e)
    {
        IdeLog.logError(CoreIOPlugin.getDefault(), e);
    }
}
项目:gwt-eclipse-plugin    文件:GdtPreferences.java   
private static void ensureUsingNewSdkRegistrantsKey(IEclipsePreferences instancePrefs, String newKey) {
  try {
    List<String> keys = Arrays.asList(instancePrefs.keys());
    if (!keys.contains(newKey)) {
      String oldKey2;
      // are we using the original "SdkRegistrants" key?
      if (keys.contains(SDK_REGISTRANTS_KEY_PREFIX)) {
        updateSdkRegistrantsKey(instancePrefs, SDK_REGISTRANTS_KEY_PREFIX, newKey);
      } else if (keys.contains((oldKey2 = computeSdkRegistrantsKeyV2()))) {
        // or are we using the 2nd version "SdkRegistrants_installationpath"
        // key?
        updateSdkRegistrantsKey(instancePrefs, oldKey2, newKey);
      }
    }
  } catch (BackingStoreException e) {
    CorePluginLog.logError(e, "Could not check if migration to new SdkRegistrants key format is needed.");
  }
}
项目:bts    文件:ScopedPreferenceStore.java   
/**
 * Does its best at determining the default value for the given key. Checks
 * the given object's type and then looks in the list of defaults to see if
 * a value exists. If not or if there is a problem converting the value, the
 * default default value for that type is returned.
 * 
 * @param key
 *            the key to search
 * @param obj
 *            the object who default we are looking for
 * @return Object or <code>null</code>
 */
Object getDefault(String key, Object obj) {
    IEclipsePreferences defaults = getDefaultPreferences();
    if (obj instanceof String) {
        return defaults.get(key, STRING_DEFAULT_DEFAULT);
    } else if (obj instanceof Integer) {
        return new Integer(defaults.getInt(key, INT_DEFAULT_DEFAULT));
    } else if (obj instanceof Double) {
        return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
    } else if (obj instanceof Float) {
        return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
    } else if (obj instanceof Long) {
        return new Long(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
    } else if (obj instanceof Boolean) {
        return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE
                : Boolean.FALSE;
    } else {
        return null;
    }
}
项目:e4-cookbook-migration-guide    文件:ScopedPreferenceStore.java   
/**
 * Dispose the receiver.
 */
private void disposePreferenceStoreListener() {

    IEclipsePreferences root = (IEclipsePreferences) Platform
            .getPreferencesService().getRootNode().node(
                    Plugin.PLUGIN_PREFERENCE_SCOPE);
    try {
        if (!(root.nodeExists(nodeQualifier))) {
            return;
        }
    } catch (BackingStoreException e) {
        return;// No need to report here as the node won't have the
        // listener
    }

    IEclipsePreferences preferences = getStorePreferences();
    if (preferences == null) {
        return;
    }
    if (preferencesListener != null) {
        preferences.removePreferenceChangeListener(preferencesListener);
        preferencesListener = null;
    }
}
项目:bts    文件:ScopedPreferenceStore.java   
/**
 * Dispose the receiver.
 */
private void disposePreferenceStoreListener() {

    IEclipsePreferences root = (IEclipsePreferences) Platform
            .getPreferencesService().getRootNode().node(
                    Plugin.PLUGIN_PREFERENCE_SCOPE);
    try {
        if (!(root.nodeExists(nodeQualifier))) {
            return;
        }
    } catch (BackingStoreException e) {
        return;// No need to report here as the node won't have the
        // listener
    }

    IEclipsePreferences preferences = getStorePreferences();
    if (preferences == null) {
        return;
    }
    if (preferencesListener != null) {
        preferences.removePreferenceChangeListener(preferencesListener);
        preferencesListener = null;
    }
}
项目:PDFReporter-Studio    文件:GeneralPrefPage.java   
/**
   * @see org.eclipse.jface.preference.IPreferencePage#performOk()
   */
  public boolean performOk() {
      IEclipsePreferences prefs = MsgEditorPreferences.getEclipsePreferenceStore();
      prefs.put(MsgEditorPreferences.GROUP__LEVEL_SEPARATOR, keyGroupSeparator.getText());
      prefs.put(MsgEditorPreferences.FILTER_LOCALES_STRING_MATCHERS,filterLocales.getText());
      prefs.putBoolean(MsgEditorPreferences.UNICODE_UNESCAPE_ENABLED, convertEncodedToUnicode.getSelection());
      prefs.putBoolean(MsgEditorPreferences.NL_SUPPORT_ENABLED,supportNL.getSelection());
      prefs.putBoolean(MsgEditorPreferences.ADD_MSG_EDITOR_BUILDER_TO_JAVA_PROJECTS, setupRbeNatureAutomatically.getSelection());
      prefs.putBoolean(MsgEditorPreferences.KEY_TREE_HIERARCHICAL, keyTreeHierarchical.getSelection());
      prefs.putBoolean(MsgEditorPreferences.KEY_TREE_EXPANDED,  keyTreeExpanded.getSelection());
      prefs.putBoolean(MsgEditorPreferences.FIELD_TAB_INSERTS, fieldTabInserts.getSelection());
      try {
    prefs.flush();
} catch (BackingStoreException e) {
    e.printStackTrace();
}
      refreshEnabledStatuses();
      return super.performOk();
  }
项目:bts    文件:BTSEObjectHover.java   
public IInformationControlCreatorProvider getHoverInfo(final EObject object, final ITextViewer viewer, final IRegion region)
{
    boolean showHover = true;
    try {
        IEclipsePreferences defaultNode = DefaultScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus.egy");
        IEclipsePreferences instanceNode = InstanceScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus.egy");
        showHover = instanceNode.getBoolean(BTSEGYUIConstants.PREF_TRANSLITERATION_EDITOR_ACTIVATE_HOVER_INFO, 
            defaultNode.getBoolean(BTSEGYUIConstants.PREF_TRANSLITERATION_EDITOR_ACTIVATE_HOVER_INFO, true));
    } catch (Exception e) {
    }
    if (showHover)
    {
        return super.getHoverInfo(object, viewer, region);
    }
    return null;

}
项目:bts    文件:FixedScopedPreferenceStore.java   
/**
 * Does its best at determining the default value for the given key. Checks
 * the given object's type and then looks in the list of defaults to see if
 * a value exists. If not or if there is a problem converting the value, the
 * default default value for that type is returned.
 * 
 * @param key
 *            the key to search
 * @param obj
 *            the object who default we are looking for
 * @return Object or <code>null</code>
 */
Object getDefault(String key, Object obj) {
    IEclipsePreferences defaults = getDefaultPreferences();
    if (obj instanceof String) {
        return defaults.get(key, STRING_DEFAULT_DEFAULT);
    } else if (obj instanceof Integer) {
        return Integer.valueOf(defaults.getInt(key, INT_DEFAULT_DEFAULT));
    } else if (obj instanceof Double) {
        return Double.valueOf(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
    } else if (obj instanceof Float) {
        return Float.valueOf(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
    } else if (obj instanceof Long) {
        return Long.valueOf(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
    } else if (obj instanceof Boolean) {
        return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE : Boolean.FALSE;
    } else {
        return null;
    }
}
项目:APICloud-Studio    文件:Theme.java   
protected void storeDefaults()
{
    // Don't store builtin themes default copy in prefs!
    if (getThemeManager().isBuiltinTheme(getName()))
    {
        return;
    }
    // Only save to defaults if it has never been saved there. Basically take a snapshot of first version and
    // use that as the "default"
    IEclipsePreferences prefs = EclipseUtil.defaultScope().getNode(ThemePlugin.PLUGIN_ID);
    if (prefs == null)
    {
        return; // TODO Log something?
    }
    Preferences preferences = prefs.node(ThemeManager.THEMES_NODE);
    if (preferences == null)
    {
        return;
    }
    String value = preferences.get(getName(), null);
    if (value == null)
    {
        save(EclipseUtil.defaultScope());
    }
}
项目:filesync4eclipse    文件:ProjectSyncPropertyPage.java   
public boolean hasChangesInDialog() {
    String currSettings = getEncodedSettings();
    boolean b = !currSettings.equals(oldMappings);

    if(b){
        return true;
    }

    IEclipsePreferences preferences = getPreferences(false);
    boolean useCurrentDate = preferences.getBoolean(
            ProjectProperties.KEY_USE_CURRENT_DATE, false);
    boolean useCurrentDateNew = useCurrentDateField.isSelected();

    if (useCurrentDateNew != useCurrentDate){
        return true;
    }

    boolean includeTeamFiles = preferences.getBoolean(
            ProjectProperties.KEY_INCLUDE_TEAM_PRIVATE, false);
    boolean includeTeamFilesNew = includeTeamFilesField.isSelected();
    if (includeTeamFiles != includeTeamFilesNew){
        return true;
    }
    return false;
}
项目:jsweet-eclipse-plugin    文件:ProjectPreferenceStore.java   
private synchronized void insertValue(String name) {
    // check if an insertion is already in-progress
    if (this.inserting) {
        return;
    }
    if (this.projectSpecificSettings && super.contains(name)) {
        return;
    }
    this.inserting = true;
    try {
        IEclipsePreferences projectPreferences = this.getProjectPreferences();
        String value = projectPreferences.get(name, null);
        if (value == null) {
            value = this.preferenceStore.getString(name);
        }
        if (value != null) {
            this.setValue(name, value);
        }
    } finally {
        this.inserting = false;
    }
}
项目:dockerfoundry    文件:ModuleCache.java   
private void setLocalModuleToCloudModuleMapping(Map<String, String> list) {
    String string = convertMapToString(list);
    IEclipsePreferences node = new InstanceScope().getNode(DockerFoundryPlugin.PLUGIN_ID);
    DockerFoundryPlugin.trace("Updated mapping: " + string); //$NON-NLS-1$
    node.put(KEY_MODULE_MAPPING_LIST + ":" + getServerId(), string); //$NON-NLS-1$
    try {
        node.flush();
    }
    catch (BackingStoreException e) {
        DockerFoundryPlugin
                .getDefault()
                .getLog()
                .log(new Status(IStatus.ERROR, DockerFoundryPlugin.PLUGIN_ID,
                        "Failed to update application mappings", e)); //$NON-NLS-1$
    }
}
项目:eclox    文件:Doxygen.java   
/**
 * Retrieves the default doxygen instance to use.
 */
public static Doxygen getDefault() {
    Doxygen doxygen = null;
    // get the actual default preference store
    //final String identifier  = Plugin.getDefault().getPluginPreferences().getString( IPreferences.DEFAULT_DOXYGEN );
    IPreferencesService service = Platform.getPreferencesService();
    final String PLUGIN_ID = Plugin.getDefault().getBundle().getSymbolicName();
    IEclipsePreferences defaultNode = DefaultScope.INSTANCE.getNode(PLUGIN_ID);
    IEclipsePreferences instanceNode = InstanceScope.INSTANCE.getNode(PLUGIN_ID);
    IEclipsePreferences[] nodes = new IEclipsePreferences[] { instanceNode, defaultNode };
    final String identifier = service.get(IPreferences.DEFAULT_DOXYGEN, "", nodes);

    List<Class<? extends Doxygen>> doxygenClassList = new ArrayList<Class<? extends Doxygen>>();
    doxygenClassList.add(DefaultDoxygen.class);
    doxygenClassList.add(CustomDoxygen.class);
    doxygenClassList.add(BundledDoxygen.class);
    for (Class<? extends Doxygen> doxygenClass : doxygenClassList) {
        doxygen = getFromClassAndIdentifier(doxygenClass, identifier);
        if (doxygen != null)
            break;
    }
    return doxygen;
}
项目:APICloud-Studio    文件:UserAgentManager.java   
/**
 * Given a project, return the list of active user agent IDs. The current implementation processes only the first
 * (primary) nature ID of the given project. Secondary natures may be taken into consideration at a later point in
 * time
 * 
 * @param project
 *            An {@link IProject}.
 * @return Returns an array of user agent IDs for the main mature of the given project. In case the given project is
 *         null, an empty string array is returned.
 */
public String[] getActiveUserAgentIDs(IProject project)
{
    if (project == null)
    {
        return ArrayUtil.NO_STRINGS;
    }
    // Extract the natures from the given project
    String[] natureIDs = getProjectNatures(project);

    // Look at the project-scope preferences for the active agents.
    ProjectScope scope = new ProjectScope(project);
    IEclipsePreferences node = scope.getNode(CommonEditorPlugin.PLUGIN_ID);
    if (node != null)
    {
        String agents = node.get(IPreferenceConstants.USER_AGENT_PREFERENCE, null);
        if (agents != null)
        {
            Map<String, String[]> userAgents = extractUserAgents(agents);
            return getActiveUserAgentIDs(userAgents, natureIDs);
        }
    }
    // In case we did not find any project-specific settings, use the project's nature IDs to grab the agents that
    // were set in the workspace settings.
    return getActiveUserAgentIDs(natureIDs);
}
项目:n4js    文件:OsgiExternalLibraryPreferenceStore.java   
@Override
protected IStatus doSave(final ExternalLibraryPreferenceModel modelToSave) {
    final IEclipsePreferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
    node.put(CONFIGURATION_KEY, modelToSave.toJsonString());
    try {
        node.flush();
        return OK_STATUS;
    } catch (final BackingStoreException e) {
        final String message = "Unexpected error when trying to persist external library preferences.";
        LOGGER.error(message, e);
        return statusHelper.createError(message, e);
    }
}