Java Code Examples for org.eclipse.core.runtime.preferences.IEclipsePreferences#getInt()

The following examples show how to use org.eclipse.core.runtime.preferences.IEclipsePreferences#getInt() . 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: AbstractProfileManager.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Update all formatter settings with the settings of the specified profile.
 * 
 * @param profile
 *            The profile to write to the preference store
 */
private void writeToPreferenceStore(Profile profile, IScopeContext context) {
	final Map profileOptions = profile.getSettings();

	for (int i = 0; i < fKeySets.length; i++) {
		updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions);
	}

	final IEclipsePreferences uiPrefs = context.getNode(getNodeId());
	if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
		uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
	}

	if (context.getName() == InstanceScope.SCOPE) {
		uiPrefs.put(fProfileKey, profile.getID());
	} else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
		uiPrefs.put(fProfileKey, profile.getID());
	}
}
 
Example 2
Source File: InlinedCssFormattingStrategy.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private String computeOneXmlIndentString() {
  char indentChar = ' ';
  IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(XMLCorePlugin.DEFAULT_CATALOG_ID);
  String indentCharPref = prefs.get(XMLCorePreferenceNames.INDENTATION_CHAR, null);

  if (XMLCorePreferenceNames.TAB.equals(indentCharPref)) {
    indentChar = '\t';
  }
  int indentationWidth = prefs.getInt(XMLCorePreferenceNames.INDENTATION_SIZE, 0);

  StringBuilder indent = new StringBuilder();
  for (int i = 0; i < indentationWidth; i++) {
    indent.append(indentChar);
  }
  return indent.toString();
}
 
Example 3
Source File: ProfileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Update all formatter settings with the settings of the specified profile.
 * @param profile The profile to write to the preference store
 */
private void writeToPreferenceStore(Profile profile, IScopeContext context) {
	final Map<String, String> profileOptions= profile.getSettings();

	for (int i= 0; i < fKeySets.length; i++) {
        updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions);
       }

	final IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN);
	if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
		uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
	}

	if (context.getName() == InstanceScope.SCOPE) {
		uiPrefs.put(fProfileKey, profile.getID());
	} else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
		uiPrefs.put(fProfileKey, profile.getID());
	}
}
 
Example 4
Source File: LaunchUtilities.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
   * Set the debug request timeout of a vm in ms, if supported by the vm implementation.
   */
  public static void setDebugTimeout(VirtualMachine vm) {
      IEclipsePreferences node = InstanceScope.INSTANCE.getNode(JDIDebugPlugin.getUniqueIdentifier());
      int timeOut = node.getInt(JDIDebugModel.PREF_REQUEST_TIMEOUT, 0);
      if (timeOut <= 0) {
	return;
}
      if (vm instanceof org.eclipse.jdi.VirtualMachine) {
          org.eclipse.jdi.VirtualMachine vm2 = (org.eclipse.jdi.VirtualMachine) vm;
          vm2.setRequestTimeout(timeOut);
      }
  }
 
Example 5
Source File: AbstractProfileManager.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Only to read project specific settings to find out to what profile it matches.
 * 
 * @param context
 *            The project context
 */
private Map readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
	final Map profileOptions = new HashMap();
	IEclipsePreferences uiPrefs = context.getNode(getNodeId());

	int version = uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
	if (version != fProfileVersioner.getCurrentVersion()) {
		Map allOptions = new HashMap();
		for (int i = 0; i < fKeySets.length; i++) {
			addAll(context.getNode(fKeySets[i].getNodeName()), allOptions);
		}
		CustomProfile profile = new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$
		fProfileVersioner.update(profile);
		return profile.getSettings();
	}

	boolean hasValues = false;
	for (int i = 0; i < fKeySets.length; i++) {
		KeySet keySet = fKeySets[i];
		IEclipsePreferences preferences = context.getNode(keySet.getNodeName());
		for (final Iterator keyIter = keySet.getKeys().iterator(); keyIter.hasNext();) {
			final String key = (String) keyIter.next();
			Object val = preferences.get(key, null);
			if (val != null) {
				hasValues = true;
			} else {
				val = workspaceProfile.getSettings().get(key);
			}
			profileOptions.put(key, val);
		}
	}

	if (!hasValues) {
		return null;
	}

	setLatestCompliance(profileOptions);
	return profileOptions;
}
 
Example 6
Source File: CleanUpPreferenceUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static Map<String, String> loadFromProject(IScopeContext context) {
final Map<String, String> profileOptions= new HashMap<String, String>();
IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN);

  	CleanUpProfileVersioner versioner= new CleanUpProfileVersioner();

  	CleanUpOptions defaultOptions= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS);
  	KeySet[] keySets= CleanUpProfileManager.KEY_SETS;

  	boolean hasValues= false;
for (int i= 0; i < keySets.length; i++) {
       KeySet keySet= keySets[i];
       IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
       for (final Iterator<String> keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
		final String key= keyIter.next();
		String val= preferences.get(key, null);
		if (val != null) {
			hasValues= true;
		} else {
			val= defaultOptions.getValue(key);
		}
		profileOptions.put(key, val);
	}
      }

if (!hasValues)
	return null;

int version= uiPrefs.getInt(CleanUpConstants.CLEANUP_SETTINGS_VERSION_KEY, versioner.getFirstVersion());
if (version == versioner.getCurrentVersion())
	return profileOptions;

CustomProfile profile= new CustomProfile("tmp", profileOptions, version, versioner.getProfileKind()); //$NON-NLS-1$
versioner.update(profile);
return profile.getSettings();
  }
 
Example 7
Source File: ProfileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Only to read project specific settings to find out to what profile it matches.
 * @param context The project context
 */
private Map<String, String> readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
	final Map<String, String> profileOptions= new HashMap<String, String>();
	IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN);

	int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
	if (version != fProfileVersioner.getCurrentVersion()) {
		Map<String, String> allOptions= new HashMap<String, String>();
		for (int i= 0; i < fKeySets.length; i++) {
            addAll(context.getNode(fKeySets[i].getNodeName()), allOptions);
           }
		CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$
		fProfileVersioner.update(profile);
		return profile.getSettings();
	}

	boolean hasValues= false;
	for (int i= 0; i < fKeySets.length; i++) {
        KeySet keySet= fKeySets[i];
        IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
        for (final Iterator<String> keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
			final String key= keyIter.next();
			String val= preferences.get(key, null);
			if (val != null) {
				hasValues= true;
			} else {
				val= workspaceProfile.getSettings().get(key);
			}
			profileOptions.put(key, val);
		}
       }

	if (!hasValues) {
		return null;
	}

	setLatestCompliance(profileOptions);
	return profileOptions;
}
 
Example 8
Source File: ScopedPreferences.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public int getInt(IEclipsePreferences instancePreferences, IEclipsePreferences defaultPreferences,
        String keyInPreferenceStore, IAdaptable adaptable) {
    Object object = getFromProjectOrUserSettings(keyInPreferenceStore, adaptable);
    if (object != null) {
        return toInt(object);
    }
    // Ok, not in project or user settings: get it from the workspace settings.
    return instancePreferences.getInt(keyInPreferenceStore, defaultPreferences.getInt(keyInPreferenceStore, 0));
}
 
Example 9
Source File: GdtPreferences.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
public static int getProjectMigratorVersion(IProject project) {
  IEclipsePreferences instancePrefs = getInstancePreferences();
  return instancePrefs.getInt(PROJECT_MIGRATOR_VERSION + project.getName(), 0);
}
 
Example 10
Source File: PyParserManager.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Constructor
 *
 * @param prefs the prefs to get to the parser
 */
private PyParserManager(IEclipsePreferences prefs) {
    super();
    Assert.isNotNull(prefs); //in this constructor the prefs may never be null!

    //Override the default to deal with pydev preferences.
    this.prefs = prefs;
    this.millisBeforeAnalysis = prefs.getInt(PYDEV_ELAPSE_BEFORE_ANALYSIS,
            PyDevBuilderPreferences.DEFAULT_PYDEV_ELAPSE_BEFORE_ANALYSIS);

    this.useOnlyOnSave = prefs.getBoolean(USE_PYDEV_ANALYSIS_ONLY_ON_DOC_SAVE,
            PyDevBuilderPreferences.DEFAULT_USE_PYDEV_ONLY_ON_DOC_SAVE);

    //singleton: private constructor
    IEclipsePreferences.IPreferenceChangeListener prefListener = new IEclipsePreferences.IPreferenceChangeListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent event) {
            String property = event.getKey();
            if (property.equals(USE_PYDEV_ANALYSIS_ONLY_ON_DOC_SAVE)
                    || property.equals(PYDEV_ELAPSE_BEFORE_ANALYSIS)) {
                //reset the caches
                millisBeforeAnalysis = PyParserManager.this.prefs.getInt(PYDEV_ELAPSE_BEFORE_ANALYSIS,
                        PyDevBuilderPreferences.DEFAULT_PYDEV_ELAPSE_BEFORE_ANALYSIS);

                useOnlyOnSave = PyParserManager.this.prefs.getBoolean(USE_PYDEV_ANALYSIS_ONLY_ON_DOC_SAVE,
                        PyDevBuilderPreferences.DEFAULT_USE_PYDEV_ONLY_ON_DOC_SAVE);

                //and set the needed parsers
                boolean useAnalysisOnlyOnDocSave = useAnalysisOnlyOnDocSave();

                synchronized (lock) {
                    for (IParser parser : parsers.keySet()) {
                        parser.resetTimeoutPreferences(useAnalysisOnlyOnDocSave);
                    }
                }
            }
        }
    };
    this.prefs.addPreferenceChangeListener(prefListener);
}