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

The following examples show how to use org.eclipse.core.runtime.preferences.IEclipsePreferences#putInt() . 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: UIPlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void updateInitialPerspectiveVersion()
{
	// updates the initial stored version so that user won't get a prompt on a new workspace
	boolean hasStartedBefore = Platform.getPreferencesService().getBoolean(PLUGIN_ID,
			IPreferenceConstants.IDE_HAS_LAUNCHED_BEFORE, false, null);
	if (!hasStartedBefore)
	{
		IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(PLUGIN_ID);
		prefs.putInt(IPreferenceConstants.PERSPECTIVE_VERSION, WebPerspectiveFactory.VERSION);
		prefs.putBoolean(IPreferenceConstants.IDE_HAS_LAUNCHED_BEFORE, true);
		try
		{
			prefs.flush();
		}
		catch (BackingStoreException e)
		{
			IdeLog.logError(getDefault(), Messages.UIPlugin_ERR_FailToSetPref, e);
		}
	}
}
 
Example 2
Source File: PreferenceInitializerAddon.java    From saneclipse with Eclipse Public License 1.0 6 votes vote down vote up
private void configureJDTUi() {
	// JDT settings
	IEclipsePreferences prefs = Util.getNode("org.eclipse.jdt.ui"); // does all
	if(null == prefs) {
		return;
	}
	
	prefs.putInt("content_assist_autoactivation_delay", 0);
	// commented out until https://bugs.eclipse.org/bugs/show_bug.cgi?id=453125 is solved
	// prefs.put("content_assist_autoactivation_triggers_java",
	//		".abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_");
	prefs.put("content_assist_favorite_static_members", "org.hamcrest.Matchers.*;org.junit.Assert.*;org.mockito.Mockito.*");
	prefs.put("org.eclipse.jdt.ui.typefilter.enabled", "java.awt.*;javax.swing.*;");
	prefs.putBoolean("content_assist_insert_completion", false);
	prefs.putBoolean("enclosingBrackets", true);
	prefs.putBoolean("smart_semicolon", true);
	prefs.putBoolean("smart_opening_brace", true);
	prefs.putBoolean("escapeStrings", true);
	prefs.put("org.eclipse.jdt.ui.text.custom_code_templates", "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><templates><template autoinsert=\"false\" context=\"catchblock_context\" deleted=\"false\" description=\"Code in new catch blocks\" enabled=\"true\" id=\"org.eclipse.jdt.ui.text.codetemplates.catchblock\" name=\"catchblock\">${exception_var}.printStackTrace();</template><template autoinsert=\"false\" context=\"methodbody_context\" deleted=\"false\" description=\"Code in created method stubs\" enabled=\"true\" id=\"org.eclipse.jdt.ui.text.codetemplates.methodbody\" name=\"methodbody\">${body_statement}</template><template autoinsert=\"false\" context=\"constructorbody_context\" deleted=\"false\" description=\"Code in created constructor stubs\" enabled=\"true\" id=\"org.eclipse.jdt.ui.text.codetemplates.constructorbody\" name=\"constructorbody\">${body_statement}</template></templates>");
	
	configureSaveActions(prefs);
	Util.savePrefs(prefs);
}
 
Example 3
Source File: CheckstyleUIPluginPrefs.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initializeDefaultPreferences() {

  IEclipsePreferences prefs = DefaultScope.INSTANCE.getNode(CheckstyleUIPlugin.PLUGIN_ID);

  prefs.putBoolean(PREF_FILESET_WARNING, true);
  prefs.put(PREF_ASK_BEFORE_REBUILD, MessageDialogWithToggle.PROMPT);
  prefs.putBoolean(PREF_TRANSLATE_TOKENS, true);
  prefs.putBoolean(PREF_SORT_TOKENS, false);
  prefs.putBoolean(PREF_OPEN_MODULE_EDITOR, true);
  prefs.putInt(PREF_DUPLICATED_CODE_MIN_LINES, DUPLICATED_CODE_MIN_LINES);
  prefs.putBoolean(PREF_STATS_SHOW_ALL_CATEGORIES, false);

  try {
    prefs.flush();
  } catch (BackingStoreException e) {
    CheckstyleLog.log(e);
  }
}
 
Example 4
Source File: GWTPreferences.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the port number to use for the SourceViewerServer.
 *
 * @param port the port number to save
 */
public static void setSourceViewerServerPort(int port) {
  IEclipsePreferences workspacePreferences = getEclipsePreferences();
  workspacePreferences.putInt(SOURCE_VIEWER_SERVER_PORT, port);
  try {
    workspacePreferences.flush();
  } catch (BackingStoreException e) {
    CorePluginLog.logError(e);
  }
}
 
Example 5
Source File: HTMLFormatterPreferenceInitializer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initializeDefaultPreferences()
{
	IEclipsePreferences store = EclipseUtil.defaultScope().getNode(HTMLFormatterPlugin.PLUGIN_ID);
	store.put(HTMLFormatterConstants.FORMATTER_TAB_CHAR, CodeFormatterConstants.EDITOR);
	store.put(HTMLFormatterConstants.FORMATTER_TAB_SIZE,
			Integer.toString(EditorUtil.getSpaceIndentSize(HTMLPlugin.getDefault().getBundle().getSymbolicName())));
	store.put(HTMLFormatterConstants.FORMATTER_INDENTATION_SIZE, "4"); //$NON-NLS-1$
	store.putBoolean(HTMLFormatterConstants.WRAP_COMMENTS, false);
	store.putBoolean(HTMLFormatterConstants.PLACE_COMMENTS_IN_SEPARATE_LINES, false);
	store.putInt(HTMLFormatterConstants.WRAP_COMMENTS_LENGTH, 80);
	// We add all the 'Void' html tags here as well. They should not trigger an indent increase.
	store.put(
			HTMLFormatterConstants.INDENT_EXCLUDED_TAGS,
			"br,a,i,b,em,strong,h1,h2,h3,h4,h5,h6,area,base,col,command,embed,hr,img,input,keygen,link,param,source,track,wbr,td,th" //$NON-NLS-1$
			.replaceAll(",", IPreferenceDelegate.PREFERECE_DELIMITER)); //$NON-NLS-1$
	store.put(
			HTMLFormatterConstants.NEW_LINES_EXCLUDED_TAGS,
			"a,abbr,acronym,bdo,big,cite,del,dfn,font,img,ins,kbd,label,q,s,samp,small,strike,sub,sup,tt,u,var,span,i,b,em,strong,h1,h2,h3,h4,h5,h6,title,option,td,th" //$NON-NLS-1$
			.replaceAll(",", IPreferenceDelegate.PREFERECE_DELIMITER)); //$NON-NLS-1$
	store.putBoolean(HTMLFormatterConstants.NEW_LINES_EXCLUSION_IN_EMPTY_TAGS, true);
	store.putBoolean(HTMLFormatterConstants.TRIM_SPACES, true);
	store.putInt(HTMLFormatterConstants.LINES_AFTER_ELEMENTS, 0);
	store.putInt(HTMLFormatterConstants.LINES_AFTER_NON_HTML_ELEMENTS, 1);
	store.putInt(HTMLFormatterConstants.LINES_BEFORE_NON_HTML_ELEMENTS, 1);
	store.putInt(HTMLFormatterConstants.PRESERVED_LINES, 0);

	store.putBoolean(HTMLFormatterConstants.FORMATTER_OFF_ON_ENABLED, false);
	store.put(HTMLFormatterConstants.FORMATTER_ON, HTMLFormatterConstants.DEFAULT_FORMATTER_ON);
	store.put(HTMLFormatterConstants.FORMATTER_OFF, HTMLFormatterConstants.DEFAULT_FORMATTER_OFF);

	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(HTMLFormatterPlugin.getDefault(), e, IDebugScopes.DEBUG);
	}
}
 
Example 6
Source File: BuildParticipantWorkingCopy.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void setPreferences(IEclipsePreferences prefs, Map<String, ? extends Object> preferences)
{
	if (CollectionsUtil.isEmpty(preferences))
	{
		return;
	}

	for (Map.Entry<String, ? extends Object> entry : preferences.entrySet())
	{
		Object value = entry.getValue();
		if (value instanceof Boolean)
		{
			prefs.putBoolean(entry.getKey(), (Boolean) value);
		}
		else if (value instanceof Long)
		{
			prefs.putLong(entry.getKey(), (Long) value);
		}
		else if (value instanceof Integer)
		{
			prefs.putInt(entry.getKey(), (Integer) value);
		}
		else if (value instanceof Double)
		{
			prefs.putDouble(entry.getKey(), (Double) value);
		}
		else if (value != null)
		{
			prefs.put(entry.getKey(), value.toString());
		}
	}
}
 
Example 7
Source File: CSSFormatterPreferenceInitializer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initializeDefaultPreferences()
{
	IEclipsePreferences pref = EclipseUtil.defaultScope().getNode(CSSFormatterPlugin.PLUGIN_ID);

	pref.put(CSSFormatterConstants.FORMATTER_TAB_CHAR, CodeFormatterConstants.EDITOR);
	pref.put(CSSFormatterConstants.FORMATTER_TAB_SIZE,
			Integer.toString(EditorUtil.getSpaceIndentSize(CSSPlugin.getDefault().getBundle().getSymbolicName())));
	pref.put(CSSFormatterConstants.FORMATTER_INDENTATION_SIZE, "4"); //$NON-NLS-1$
	pref.putBoolean(CSSFormatterConstants.WRAP_COMMENTS, false);
	pref.putInt(CSSFormatterConstants.WRAP_COMMENTS_LENGTH, 80);
	pref.put(CSSFormatterConstants.NEW_LINES_BEFORE_BLOCKS, CodeFormatterConstants.SAME_LINE);
	pref.putInt(CSSFormatterConstants.LINES_AFTER_ELEMENTS, 0);
	pref.putInt(CSSFormatterConstants.LINES_AFTER_DECLARATION, 0);
	pref.putInt(CSSFormatterConstants.PRESERVED_LINES, 1);

	pref.putInt(CSSFormatterConstants.SPACES_BEFORE_COMMAS, 0);
	pref.putInt(CSSFormatterConstants.SPACES_AFTER_COMMAS, 1);
	pref.putInt(CSSFormatterConstants.SPACES_BEFORE_SEMICOLON, 0);
	pref.putInt(CSSFormatterConstants.SPACES_AFTER_SEMICOLON, 0);
	pref.putInt(CSSFormatterConstants.SPACES_BEFORE_PARENTHESES, 1);
	pref.putInt(CSSFormatterConstants.SPACES_AFTER_PARENTHESES, 1);
	pref.putInt(CSSFormatterConstants.SPACES_BEFORE_COLON, 0);
	pref.putInt(CSSFormatterConstants.SPACES_AFTER_COLON, 1);
	pref.putInt(CSSFormatterConstants.SPACES_BEFORE_CHILD_COMBINATOR, 1);
	pref.putInt(CSSFormatterConstants.SPACES_AFTER_CHILD_COMBINATOR, 1);

	pref.putBoolean(CSSFormatterConstants.FORMATTER_OFF_ON_ENABLED, false);
	pref.put(CSSFormatterConstants.FORMATTER_ON, CSSFormatterConstants.DEFAULT_FORMATTER_ON);
	pref.put(CSSFormatterConstants.FORMATTER_OFF, CSSFormatterConstants.DEFAULT_FORMATTER_OFF);

	try
	{
		pref.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CSSFormatterPlugin.getDefault(), e, IDebugScopes.DEBUG);
	}
}
 
Example 8
Source File: XMLFormatterPreferenceInitializer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initializeDefaultPreferences()
{
	IEclipsePreferences store = EclipseUtil.defaultScope().getNode(XMLFormatterPlugin.PLUGIN_ID);
	store.put(XMLFormatterConstants.FORMATTER_TAB_CHAR, CodeFormatterConstants.EDITOR);
	store.put(XMLFormatterConstants.FORMATTER_TAB_SIZE,
			Integer.toString(EditorUtil.getSpaceIndentSize(XMLPlugin.getDefault().getBundle().getSymbolicName())));
	store.put(XMLFormatterConstants.FORMATTER_INDENTATION_SIZE, "4"); //$NON-NLS-1$
	store.putBoolean(XMLFormatterConstants.WRAP_COMMENTS, false);
	store.putInt(XMLFormatterConstants.WRAP_COMMENTS_LENGTH, 80);
	// No excluded tags by default
	store.put(XMLFormatterConstants.INDENT_EXCLUDED_TAGS, StringUtil.EMPTY);
	store.put(XMLFormatterConstants.NEW_LINES_EXCLUDED_TAGS, StringUtil.EMPTY);
	store.putBoolean(XMLFormatterConstants.NEW_LINES_EXCLUDED_ON_TEXT_NODES, true);
	store.putInt(XMLFormatterConstants.LINES_AFTER_ELEMENTS, 0);
	store.putInt(XMLFormatterConstants.LINES_AFTER_NON_XML_ELEMENTS, 1);
	store.putInt(XMLFormatterConstants.LINES_BEFORE_NON_XML_ELEMENTS, 1);
	store.putInt(XMLFormatterConstants.PRESERVED_LINES, 1);

	store.putBoolean(XMLFormatterConstants.FORMATTER_OFF_ON_ENABLED, false);
	store.put(XMLFormatterConstants.FORMATTER_ON, XMLFormatterConstants.DEFAULT_FORMATTER_ON);
	store.put(XMLFormatterConstants.FORMATTER_OFF, XMLFormatterConstants.DEFAULT_FORMATTER_OFF);

	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(XMLFormatterPlugin.getDefault(), e, IDebugScopes.DEBUG);
	}
}
 
Example 9
Source File: TypeScriptCorePreferenceInitializer.java    From typescript.java with MIT License 5 votes vote down vote up
private void initializeEditorFormatOptions(IEclipsePreferences node) {
	node.putBoolean(TypeScriptCorePreferenceConstants.EDITOR_OPTIONS_CONVERT_TABS_TO_SPACES,
			TypeScriptCorePreferenceConstants.EDITOR_OPTIONS_CONVERT_TABS_TO_SPACES_DEFAULT);
	node.putInt(TypeScriptCorePreferenceConstants.EDITOR_OPTIONS_INDENT_SIZE,
			TypeScriptCorePreferenceConstants.EDITOR_OPTIONS_INDENT_SIZE_DEFAULT);
	node.putInt(TypeScriptCorePreferenceConstants.EDITOR_OPTIONS_TAB_SIZE,
			TypeScriptCorePreferenceConstants.EDITOR_OPTIONS_TAB_SIZE_DEFAULT);
	node.putBoolean(TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_COMMA_DELIMITER,
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_COMMA_DELIMITER_DEFAULT);
	node.putBoolean(TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR_STATEMENTS,
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR_STATEMENTS_DEFAULT);
	node.putBoolean(TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_BEFORE_AND_AFTER_BINARY_OPERATORS,
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_BEFORE_AND_AFTER_BINARY_OPERATORS_DEFAULT);
	node.putBoolean(
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_KEYWORDS_IN_CONTROL_FLOW_STATEMENTS,
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_KEYWORDS_IN_CONTROL_FLOW_STATEMENTS_DEFAULT);
	node.putBoolean(
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_FUNCTION_KEYWORD_FOR_ANONYMOUS_FUNCTIONS,
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_FUNCTION_KEYWORD_FOR_ANONYMOUS_FUNCTIONS_DEFAULT);
	node.putBoolean(
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_OPENING_AND_BEFORE_CLOSING_NONEMPTY_PARENTHESIS,
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_OPENING_AND_BEFORE_CLOSING_NONEMPTY_PARENTHESIS_DEFAULT);
	node.putBoolean(
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_OPENING_AND_BEFORE_CLOSING_NONEMPTY_BRACKETS,
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_INSERT_SPACE_AFTER_OPENING_AND_BEFORE_CLOSING_NONEMPTY_BRACKETS_DEFAULT);
	node.putBoolean(TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_PLACE_OPEN_BRACE_ON_NEW_LINE_FOR_FUNCTIONS,
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_PLACE_OPEN_BRACE_ON_NEW_LINE_FOR_FUNCTIONS_DEFAULT);
	node.putBoolean(
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_PLACE_OPEN_BRACE_ON_NEW_LINE_FOR_CONTROL_BLOCKS,
			TypeScriptCorePreferenceConstants.FORMAT_OPTIONS_PLACE_OPEN_BRACE_ON_NEW_LINE_FOR_CONTROL_BLOCKS_DEFAULT);
}
 
Example 10
Source File: PreferenceInitializerAddon.java    From saneclipse with Eclipse Public License 1.0 5 votes vote down vote up
private void configureXMLEditor() {
	IEclipsePreferences prefs = Util.getNode("org.eclipse.wst.xml.core");
	if(null == prefs) {
		return;
	}
	
	prefs.putInt("lineWidth", 120);
	Util.savePrefs(prefs);
}
 
Example 11
Source File: LibraryChecksPreferenceInitializer.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
private void initializeSeverities(final IEclipsePreferences preferences) {
  preferences.putInt("COM.AVALOQ.TOOLS.DDK.SAMPLE.HELLOWORLD.VALIDATION.LIBRARYCHECKSISSUECODES.CHECK.CATALOG.IS.ACTIVE$SEVERITY", 1);
  preferences.putInt("COM.AVALOQ.TOOLS.DDK.SAMPLE.HELLOWORLD.VALIDATION.LIBRARYCHECKSISSUECODES.CACHE.INJECTION.FAILED$SEVERITY", 0);
  preferences.putInt("COM.AVALOQ.TOOLS.DDK.SAMPLE.HELLOWORLD.VALIDATION.LIBRARYCHECKSISSUECODES.CACHE.DOESNT.WORK$SEVERITY", 0);
  preferences.putInt("COM.AVALOQ.TOOLS.DDK.SAMPLE.HELLOWORLD.VALIDATION.LIBRARYCHECKSISSUECODES.FORMAL.PARAMETERS$SEVERITY", 0);
  
}
 
Example 12
Source File: LibraryChecksPreferenceInitializer.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
private void initializeSeverities(final IEclipsePreferences preferences) {
  preferences.putInt("COM.AVALOQ.TOOLS.DDK.CHECK.VALIDATION.LIBRARYCHECKSISSUECODES.CHECK.CATALOG.IS.ACTIVE$SEVERITY", 1);
  preferences.putInt("COM.AVALOQ.TOOLS.DDK.CHECK.VALIDATION.LIBRARYCHECKSISSUECODES.CACHE.INJECTION.FAILED$SEVERITY", 0);
  preferences.putInt("COM.AVALOQ.TOOLS.DDK.CHECK.VALIDATION.LIBRARYCHECKSISSUECODES.CACHE.DOESNT.WORK$SEVERITY", 0);
  preferences.putInt("COM.AVALOQ.TOOLS.DDK.CHECK.VALIDATION.LIBRARYCHECKSISSUECODES.FORMAL.PARAMETERS$SEVERITY", 0);
  
}
 
Example 13
Source File: BonitaStudioWorkbenchAdvisor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void initXMLandHTMLValidationPreferences() {
    IEclipsePreferences xmlNode = DefaultScope.INSTANCE
            .getNode(XMLCorePlugin.getDefault().getBundle().getSymbolicName());
    xmlNode.putInt(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR, -1);

    IEclipsePreferences htmlNode = DefaultScope.INSTANCE
            .getNode(HTMLCorePlugin.getDefault().getBundle().getSymbolicName());
    htmlNode.putInt(HTMLCorePreferenceNames.ATTRIBUTE_INVALID_NAME, -1);
    htmlNode.putInt(HTMLCorePreferenceNames.ATTRIBUTE_INVALID_VALUE, -1);
    htmlNode.putInt(HTMLCorePreferenceNames.ATTRIBUTE_UNDEFINED_NAME, -1);
    htmlNode.putInt(HTMLCorePreferenceNames.ATTRIBUTE_UNDEFINED_VALUE, -1);
    htmlNode.putInt(HTMLCorePreferenceNames.ATTRIBUTE_VALUE_EQUALS_MISSING, -1);
    htmlNode.putInt(HTMLCorePreferenceNames.ELEM_UNKNOWN_NAME, -1);
}
 
Example 14
Source File: PreferenceInitializerAddon.java    From saneclipse with Eclipse Public License 1.0 5 votes vote down vote up
private void configureIde() {
	IEclipsePreferences prefs = Util.getNode("org.eclipse.ui.ide");
	if(null == prefs) {
		return;
	}
	
	prefs.putBoolean("EXIT_PROMPT_ON_CLOSE_LAST_WINDOW", false);
	prefs.putInt("MAX_RECENT_WORKSPACES", 10);
	Util.savePrefs(prefs);
}
 
Example 15
Source File: GdtPreferences.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
public static void setProjectMigratorVersion(IProject project, int version) {
  IEclipsePreferences configurationPreferences = getConfigurationPreferences();
  configurationPreferences.putInt(PROJECT_MIGRATOR_VERSION + project.getName(), version);
  flushPreferences(configurationPreferences);
}
 
Example 16
Source File: ScopedPreferencesTest.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public void testProjectSettingsScopedPreferences() throws Exception {
    IScopedPreferences iScopedPreferences = ScopedPreferences.get("my.test2");
    File eclipsePrefs = new File(baseDir, ".eclipse");
    File projectDir = new File(baseDir, "project");
    File projectDirSettings = new File(projectDir, ".settings");
    File projectDirYAMLFile = new File(projectDirSettings, "my.test2.yaml");
    eclipsePrefs.mkdirs();
    projectDir.mkdirs();
    projectDirSettings.mkdirs();
    FileUtils.writeStrToFile("", projectDirYAMLFile);
    assertTrue(eclipsePrefs.exists());
    File userSettingsYamlFile = new File(eclipsePrefs, "my.test2.yaml");
    assertTrue(!userSettingsYamlFile.exists());
    final IProject project = new ProjectStub(projectDir, null);
    Map<String, Object> saveData = new HashMap<String, Object>();
    saveData.put("foo", 1);
    iScopedPreferences.saveToProjectSettings(saveData, project);
    assertTrue(!userSettingsYamlFile.exists());
    assertEquals("foo: 1\n", FileUtils.getFileContents(projectDirYAMLFile));

    IAdaptable adaptable = new IAdaptable() {

        @Override
        public <T> T getAdapter(Class<T> adapter) {
            if (IProject.class == adapter) {
                return (T) project;
            }
            return null;
        }
    };
    IEclipsePreferences pluginPreferenceStore = new InMemoryEclipsePreferences();
    IEclipsePreferences defaultPreferenceStore = new InMemoryEclipsePreferences();

    assertEquals(1, iScopedPreferences.getInt(pluginPreferenceStore, defaultPreferenceStore, "foo", adaptable));
    saveData = new HashMap<String, Object>();
    saveData.put("bar", 2);
    waitABit();
    iScopedPreferences.saveToProjectSettings(saveData, project);
    waitABit();
    assertEquals("bar: 2\nfoo: 1\n", FileUtils.getFileContents(projectDirYAMLFile));
    assertEquals(2, iScopedPreferences.getInt(pluginPreferenceStore, defaultPreferenceStore, "bar", adaptable));
    FileUtils.writeStrToFile("bar: 1\nfoo: 1\n", projectDirYAMLFile);
    assertEquals(1, iScopedPreferences.getInt(pluginPreferenceStore, defaultPreferenceStore, "bar", adaptable));
    waitABit();
    FileUtils.writeStrToFile("foo: 1\n", projectDirYAMLFile);
    waitABit();
    assertEquals(0, iScopedPreferences.getInt(pluginPreferenceStore, defaultPreferenceStore, "bar", adaptable)); // default in NullPrefsStore
    pluginPreferenceStore.putInt("bar", 2);
    assertEquals(2, iScopedPreferences.getInt(pluginPreferenceStore, defaultPreferenceStore, "bar", adaptable)); // default in NullPrefsStore
}
 
Example 17
Source File: AbstractScriptFormatterFactory.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Handle Tab-Size setting here. This settings will immediately effect all the editors of the kind we are
 * formatting. Since this method is also called when we load the preferences, we make sure we don't set anything
 * ahead of time.
 * <ul>
 * <li>In case the formatter settings indicate to use tabs - set the editor's prefs to tabs.</li>
 * <li>In case the settings indicate spaces, or mixed - set the editor's prefs to spaces.</li>
 * <li>When the workspace defaults settings match the formatter's settings, the editor preferences will indicate it.
 * </li>
 * </ul>
 * 
 * @param preferences
 * @param isInitializing
 */
/*
 * (non-Javadoc)
 * @see com.aptana.formatter.AbstractScriptFormatterFactory#updateEditorTabSize(java.util.Map, boolean)
 */
protected void updateEditorTabSize(Map<String, String> preferences, boolean isInitializing)
{
	IEclipsePreferences prefs = getEclipsePreferences();
	int editorTabSize = getEditorTabSize();
	if (CodeFormatterConstants.EDITOR.equals(getFormatterTabPolicy(preferences)))
	{
		// In case the formatter defines to follow the Editor's Tab-Policy, just update the preferences Map with the
		// editor-tab-size.
		preferences.put(getFormatterTabSizeKey(), String.valueOf(editorTabSize));
	}
	else
	{
		String prefTabSize = preferences.get(getFormatterTabSizeKey());
		int selectedTabValue = (prefTabSize != null) ? Integer.parseInt(prefTabSize) : 0;
		if (selectedTabValue == editorTabSize)
		{
			if (selectedTabValue == getDefaultEditorTabSize())
			{
				// Set the editor's settings to the default one.
				prefs.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
				prefs.putBoolean(USE_GLOBAL_DEFAULTS_KEY, true);
			}
		}
		else
		{
			if (isInitializing)
			{
				// fix the preferences value
				selectedTabValue = editorTabSize;
				preferences.put(getFormatterTabSizeKey(), String.valueOf(selectedTabValue));
			}
			prefs.putInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, selectedTabValue);
			prefs.putBoolean(USE_GLOBAL_DEFAULTS_KEY, selectedTabValue == getDefaultEditorTabSize());
		}
		try
		{
			prefs.flush();
		}
		catch (Exception e)
		{
			IdeLog.logError(FormatterPlugin.getDefault(), e);
		}
	}
}
 
Example 18
Source File: CheckstylePluginPrefs.java    From eclipse-cs with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Set a int preference for the given preference id.
 * 
 * @param prefId
 *          the preference id
 * @param value
 *          the boolean value
 * @throws BackingStoreException
 *           if this operation cannot be completed due to a failure in the backing store, or
 *           inability to communicate with it.
 */
public static void setInt(String prefId, int value) throws BackingStoreException {

  IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(CheckstylePlugin.PLUGIN_ID);
  prefs.putInt(prefId, value);
  prefs.flush();
}
 
Example 19
Source File: CheckstyleUIPluginPrefs.java    From eclipse-cs with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Set a int preference for the given preference id.
 * 
 * @param prefId
 *          the preference id
 * @param value
 *          the boolean value
 * @throws BackingStoreException
 *           if this operation cannot be completed due to a failure in the
 *           backing store, or inability to communicate with it.
 */
public static void setInt(String prefId, int value) throws BackingStoreException {

  IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(CheckstyleUIPlugin.PLUGIN_ID);
  prefs.putInt(prefId, value);
  prefs.flush();
}
 
Example 20
Source File: ExecutionEnvironmentPreferenceInitializer.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
private void initializeSeverities(final IEclipsePreferences preferences) {
  preferences.putInt("COM.AVALOQ.TOOLS.DDK.CHECK.VALIDATION.EXECUTIONENVIRONMENTISSUECODES.GREETING.NAME.LENGTH$SEVERITY", 0);
  
}