org.eclipse.core.runtime.preferences.IEclipsePreferences Java Examples

The following examples show how to use org.eclipse.core.runtime.preferences.IEclipsePreferences. 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: DefaultValuesInitializer.java    From e4Preferences with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void initializeDefaultPreferences()
{
	IEclipsePreferences node = DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(getClass()).getSymbolicName());

	if (node != null)
	{
		node.put("rootPageValue", "DEFAULT ROOT PAGE VALUE");
		node.put("page1", "DEFAULT PAGE 1 VALUE");
		node.put("page2", "DEFAULT PAGE 2 VALUE");
	
		node.put("prefCombo", "value2");
		node.put("prefColor", StringConverter.asString(new RGB(0,255,0)));
		node.putBoolean("prefBoolean",true);
		node.put("prefString","Default string value");
		
		try { node.flush();  }  catch (BackingStoreException e) { }
	}		
	
	
	
}
 
Example #2
Source File: JavaProject.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void close() throws JavaModelException {
	if (JavaProject.hasJavaNature(this.project)) {
		// Get cached preferences if exist
		JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(this.project, false);
		if (perProjectInfo != null && perProjectInfo.preferences != null) {
			IEclipsePreferences eclipseParentPreferences = (IEclipsePreferences) perProjectInfo.preferences.parent();
			if (this.preferencesNodeListener != null) {
				eclipseParentPreferences.removeNodeChangeListener(this.preferencesNodeListener);
				this.preferencesNodeListener = null;
			}
			if (this.preferencesChangeListener != null) {
				perProjectInfo.preferences.removePreferenceChangeListener(this.preferencesChangeListener);
				this.preferencesChangeListener = null;
			}
		}
	}
	super.close();
}
 
Example #3
Source File: ScopedPreferenceStore.java    From e4Preferences with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
	}
}
 
Example #4
Source File: ExecutableEntry.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This operation loads the ExecutableEntry from Eclipse Preferences. 
 * @param prefId
 */
public void loadFromPreferences(String prefId) {
	// Get the Application preferences
	IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(prefId);
	try {
		for (String key : prefs.keys()) {
			String pref = prefs.get(key, "");
			if (!pref.isEmpty()) {
				allowedValues.add(pref);
				allowedValueToURI.put(pref, URI.create(key));
			}
		}
	} catch (BackingStoreException e) {
		logger.error(getClass().getName() + " Exception!", e);
	}

	if (!allowedValues.isEmpty()) {
		allowedValues.add(0, "Select Application");
		setDefaultValue(allowedValues.get(0));
	} else {
		allowedValues.add("Import Application");
		setDefaultValue(allowedValues.get(0));
	}
}
 
Example #5
Source File: PreferenceInitializer.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void initializeDefaultPreferences()
{
	IEclipsePreferences prefs = EclipseUtil.defaultScope().getNode(CSSPlugin.PLUGIN_ID);

	// prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.LINK_OUTLINE_WITH_EDITOR, true);
	prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_AUTO_INDENT, true);
	prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_ENABLE_FOLDING, 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$
	prefs.put(com.aptana.editor.common.contentassist.IPreferenceConstants.PROPOSAL_TRIGGER_CHARACTERS,
			StringUtil.EMPTY);

	// mark occurrences
	// prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
}
 
Example #6
Source File: FilterViewerTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Initialization, creates a temp trace
 *
 * @throws IOException
 *             should not happen
 */
@BeforeClass
public static void init() throws IOException {
    IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    defaultPreferences.put(ITmfTimePreferencesConstants.TIME_ZONE, "GMT-05:00");
    TmfTimestampFormat.updateDefaultFormats();

    SWTBotUtils.initialize();
    Thread.currentThread().setName("SWTBot Thread"); // for the debugger
    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
    fBot = new SWTWorkbenchBot();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
    fFileLocation = File.createTempFile("sample", ".xml");
    try (BufferedRandomAccessFile braf = new BufferedRandomAccessFile(fFileLocation, "rw")) {
        braf.writeBytes(TRACE_START);
        for (int i = 0; i < 100; i++) {
            braf.writeBytes(makeEvent(i * 100, i % 4));
        }
        braf.writeBytes(TRACE_END);
    }
}
 
Example #7
Source File: StandardPreferenceManager.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private void updateParallelBuild(int maxConcurrentBuilds) {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IWorkspaceDescription description = workspace.getDescription();
	if (description.getMaxConcurrentBuilds() == maxConcurrentBuilds) {
		return;
	}

	description.setMaxConcurrentBuilds(maxConcurrentBuilds);
	try {
		workspace.setDescription(description);
	} catch (CoreException e) {
		JavaLanguageServerPlugin.logException("Problems setting maxConcurrentBuilds from workspace.", e);
	}

	String stringValue = maxConcurrentBuilds != 1 ? Boolean.TRUE.toString() : Boolean.FALSE.toString();
	IEclipsePreferences pref = InstanceScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
	pref.put(MavenPreferenceConstants.P_BUILDER_USE_NULL_SCHEDULING_RULE, stringValue);
	pref = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);
}
 
Example #8
Source File: UserAgentManager.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void clearPreferences(IProject project)
{
	if (project != null)
	{
		// Save to the project scope
		IEclipsePreferences preferences = new ProjectScope(project).getNode(CommonEditorPlugin.PLUGIN_ID);
		preferences.remove(IPreferenceConstants.USER_AGENT_PREFERENCE);
		try
		{
			preferences.flush();
		}
		catch (BackingStoreException e)
		{
			// ignore
		}
	}
}
 
Example #9
Source File: ProfileManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param uiPrefs
 * @param allOptions
 */
private void addAll(IEclipsePreferences uiPrefs, Map<String, String> allOptions) {
	try {
		String[] keys= uiPrefs.keys();
		for (int i= 0; i < keys.length; i++) {
			String key= keys[i];
			String val= uiPrefs.get(key, null);
			if (val != null) {
				allOptions.put(key, val);
			}
		}
	} catch (BackingStoreException e) {
		// ignore
	}

}
 
Example #10
Source File: PreferenceInitializerAddon.java    From saneclipse with Eclipse Public License 1.0 6 votes vote down vote up
private void configureJDTCore() {
	// JDT settings
	IEclipsePreferences prefs = Util.getNode("org.eclipse.jdt.core"); // does all
	if(null == prefs) {
		return;
	}
	
	prefs.put("org.eclipse.jdt.core.compiler.problem.noEffectAssignment", "error");
	prefs.put("org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation", "warning");
	prefs.put("org.eclipse.jdt.core.compiler.problem.comparingIdentical", "error");
	prefs.put("org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod", "warning");
	prefs.put("org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable", "warning");
	prefs.put("org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments", "warning");
	
	configureSaveActions(prefs);
	Util.savePrefs(prefs);
}
 
Example #11
Source File: PyParserEditorIntegrationTest.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public void testIntegration() throws Exception {
    IEclipsePreferences preferences = new InMemoryEclipsePreferences();
    PyParserManager pyParserManager = PyParserManager.getPyParserManager(preferences);

    Document doc = new Document();
    PyEditStub pyEdit = new PyEditStub(doc, new PydevFileEditorInputStub());
    pyParserManager.attachParserTo(pyEdit);
    checkParserChanged(pyEdit, 1);

    doc.replace(0, 0, "\r\ntest");
    checkParserChanged(pyEdit, 2);

    pyParserManager.attachParserTo(pyEdit);
    checkParserChanged(pyEdit, 3);

    doc.replace(0, 0, "\r\ntest"); //after this change, only 1 reparse should be asked, as the editor and doc is the same
    checkParserChanged(pyEdit, 4);

    pyParserManager.notifyEditorDisposed(pyEdit);
    doc.replace(0, 0, "\r\ntest"); //after this change, only 1 reparse should be asked, as the editor and doc is the same
    waitABit();
    assertEquals(4, pyEdit.parserChanged);

    assertEquals(0, pyParserManager.getParsers().size());
}
 
Example #12
Source File: AbstractPreferencePage.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Saves the 'use project settings' as a preference in the store using the
 * {@link #useProjectSettingsPreferenceName()} as the key. If not project specific, all affected keys are removed
 * from the project preferences.
 */
private void saveUseProjectSettings(boolean isProjectSpecific) throws IOException {
	final FixedScopedPreferenceStore store = (FixedScopedPreferenceStore) getPreferenceStore();
	if (!isProjectSpecific) {
		// remove all the keys (written by various field editors)
		IEclipsePreferences storePreferences = store.getStorePreferences();
		for (FieldEditor field : editors) {
			storePreferences.remove(field.getPreferenceName());
		}
		// Also remove the master key (i.e. use default/default == false when later reading).
		storePreferences.remove(useProjectSettingsPreferenceName());
	} else {
		store.setValue(useProjectSettingsPreferenceName(), Boolean.toString(isProjectSpecific));
	}
	store.save();
}
 
Example #13
Source File: JavaCorePreferenceModifyListener.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public IEclipsePreferences preApply(IEclipsePreferences node) {
	// the node does not need to be the root of the hierarchy
	Preferences root = node.node("/"); //$NON-NLS-1$
	try {
		// we must not create empty preference nodes, so first check if the node exists
		if (root.nodeExists(InstanceScope.SCOPE)) {
			Preferences instance = root.node(InstanceScope.SCOPE);
			// we must not create empty preference nodes, so first check if the node exists
			if (instance.nodeExists(JavaCore.PLUGIN_ID)) {
				cleanJavaCore(instance.node(JavaCore.PLUGIN_ID));
			}
		}
	} catch (BackingStoreException e) {
		// do nothing
	}
	return super.preApply(node);
}
 
Example #14
Source File: FixedScopedPreferenceStore.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Dispose the preference store listener.
 */
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;
	}
}
 
Example #15
Source File: ValidPreferenceStore.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
  }
}
 
Example #16
Source File: JavaLanguageServerPlugin.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private void setPreferenceNodeId() {
	// a hack to ensure unit tests work in Eclipse and CLI builds on Mac
	Bundle bundle = Platform.getBundle(JDT_UI_PLUGIN);
	if (bundle != null && bundle.getState() != Bundle.ACTIVE) {
		// start the org.eclipse.jdt.ui plugin if it exists
		try {
			bundle.start();
		} catch (BundleException e) {
			JavaLanguageServerPlugin.logException(e.getMessage(), e);
		}
	}
	// if preferenceNodeId is already set, we have to nullify it
	// https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=4c731bc9cc7e1cfd2e67746171aede8d7719e9c1
	JavaManipulation.setPreferenceNodeId(null);
	// Set the ID to use for preference lookups
	JavaManipulation.setPreferenceNodeId(IConstants.PLUGIN_ID);

	IEclipsePreferences fDefaultPreferenceStore = DefaultScope.INSTANCE.getNode(JavaManipulation.getPreferenceNodeId());
	fDefaultPreferenceStore.put(MembersOrderPreferenceCacheCommon.APPEARANCE_MEMBER_SORT_ORDER, DEFAULT_MEMBER_SORT_ORDER);
	fDefaultPreferenceStore.put(CodeGenerationSettingsConstants.CODEGEN_USE_OVERRIDE_ANNOTATION, Boolean.TRUE.toString());

	// initialize MembersOrderPreferenceCacheCommon used by BodyDeclarationRewrite
	MembersOrderPreferenceCacheCommon preferenceCache = JavaManipulationPlugin.getDefault().getMembersOrderPreferenceCacheCommon();
	preferenceCache.install();
}
 
Example #17
Source File: JavaModelManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public Hashtable getDefaultOptions(){

		Hashtable defaultOptions = new Hashtable(10);

		// see JavaCorePreferenceInitializer#initializeDefaultPluginPreferences() for changing default settings
		// If modified, also modify the method getDefaultOptionsNoInitialization()
		IEclipsePreferences defaultPreferences = getDefaultPreferences();

		// initialize preferences to their default
		Iterator iterator = this.optionNames.iterator();
		while (iterator.hasNext()) {
		    String propertyName = (String) iterator.next();
		    String value = defaultPreferences.get(propertyName, null);
		    if (value != null) defaultOptions.put(propertyName, value);
		}
		// get encoding through resource plugin
		defaultOptions.put(JavaCore.CORE_ENCODING, JavaCore.getEncoding());
		// backward compatibility
		addDeprecatedOptions(defaultOptions);

		return defaultOptions;
	}
 
Example #18
Source File: AbstractSaveParticipantPreferenceConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean isEnabled(IScopeContext context) {
	IEclipsePreferences node;
	if (hasSettingsInScope(context)) {
		node= context.getNode(JavaUI.ID_PLUGIN);
	} else {
		node= InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);
	}
	IEclipsePreferences defaultNode= DefaultScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);

	String key= getPreferenceKey();
	return node.getBoolean(key, defaultNode.getBoolean(key, false));
}
 
Example #19
Source File: CleanUpPreferenceUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static void saveSaveParticipantOptions(IScopeContext context, Map<String, String> settings) {
	IEclipsePreferences node= context.getNode(JavaUI.ID_PLUGIN);
	for (Iterator<String> iterator= settings.keySet().iterator(); iterator.hasNext();) {
     String key= iterator.next();
     node.put(SAVE_PARTICIPANT_KEY_PREFIX + key, settings.get(key));
    }
}
 
Example #20
Source File: CreateBonitaBPMProjectOperation.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createJavaProject(final IProgressMonitor monitor) {
    monitor.subTask(Messages.initializingJavaProject);
    final IJavaProject javaProject = asJavaProject();
    javaProject.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8);
    javaProject.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
    javaProject.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
    javaProject.setOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.IGNORE);
    IEclipsePreferences preferences = jdtLaunchingPrefNode();
    preferences.put(JavaRuntime.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE, JavaCore.IGNORE);
    monitor.worked(1);
}
 
Example #21
Source File: GdtPreferences.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Registers all of the {@link SdkRegistrant}s, and records as a workspace preference which ones those were.
 * Registrants will only be called once per workspace.
 *
 * Prior versions of the SDK registration mechanism required adding implementations of SdkBundleRegistratant that were
 * aware of GPE internals, and would handle registrations themselves. To decouple the build/release process of
 * sdkbundles from GPE, this approach has been abandoned.
 *
 * This implementation inspects bundles with a com.google.*.eclipse.sdkbundle bundle id and looks for a marker
 * property file for details about the SDK. If the information resolves as a known SDK type and a valid SDK path, the
 * SDK path is then registered against the proper registrant.
 *
 */
public static synchronized void registerSdks() {
  IEclipsePreferences instancePrefs = getInstancePreferences();

  final String sdkRegistrantsKeyV3 = computeSdkRegistrantsKeyV3();
  ensureUsingNewSdkRegistrantsKey(instancePrefs, sdkRegistrantsKeyV3);

  String sdkRegistrantsAsString = instancePrefs.get(sdkRegistrantsKeyV3, "");
  Set<String> sdkRegistrants = new LinkedHashSet<String>(decodeRegistrants(sdkRegistrantsAsString));

  BundleContext context = GdtPlugin.getDefault().getBundle().getBundleContext();

  for (Bundle bundle : context.getBundles()) {
    String bundleName = bundle.getSymbolicName();
    String bundleVersion = bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION);
    String sdkId = bundleName + '_' + bundleVersion;

    // The bundle name must match com.google.*.eclipse.sdkbundle
    if (bundleName.startsWith(SDK_BUNDLE_PREFIX) && bundleName.contains(SDK_BUNDLE_SUFFIX)
        && !sdkRegistrants.contains(sdkId)) {

      GdtPlugin.getLogger().logInfo("Registering: " + sdkId);
      try {
        registerBundleSdk(bundle);
      } catch (CoreException e) {
        // Log and continue.
        GdtPlugin.getLogger().logError(e);
      }

      // Add the sdk even if we get an exception while registering to prevent
      // logging an error on each restart.
      sdkRegistrants.add(sdkId);
    }
  }

  instancePrefs.put(sdkRegistrantsKeyV3, encodeRegistrants(sdkRegistrants));
  flushPreferences(instancePrefs);
}
 
Example #22
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 5 votes vote down vote up
private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) {
	IEclipsePreferences node = context.getNode(fQualifier);
	if (manager != null) {
		return manager.getWorkingCopy(node);
	}
	return node;
}
 
Example #23
Source File: CheckDefaultPreferencesDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void apply() {
    IEclipsePreferences node = InstanceScope.INSTANCE.getNode(this.plugin);
    node.put(this.pref, this.value);
    try {
        node.flush();
    } catch (BackingStoreException e) {
        Log.log(e);
    }
}
 
Example #24
Source File: TextTraceTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@AfterClass
public static void tearDown() {
    fTrace.dispose();
    fTrace = null;
    IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    defaultPreferences.put(ITmfTimePreferencesConstants.DATIME, ITmfTimePreferencesConstants.TIME_HOUR_FMT);
    defaultPreferences.put(ITmfTimePreferencesConstants.SUBSEC, ITmfTimePreferencesConstants.SUBSEC_NANO_FMT);
    defaultPreferences.put(ITmfTimePreferencesConstants.LOCALE, Locale.getDefault().toLanguageTag());
    TmfTimestampFormat.updateDefaultFormats();
}
 
Example #25
Source File: DefaultResourceBlacklist.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected String getPersistentValues(IProject project) {
	IScopeContext projectScope = getPreferenceScope(project);
	IEclipsePreferences node = projectScope.getNode(SCT_RESOURCE_NODE);

	String string = node.get(SCT_BLACKLIST_KEY, SCT_BLACKLIST_DEFAULT);
	return string;
}
 
Example #26
Source File: TextStylingPreference.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static void setToStore(IEclipsePreferences store, String key, TextStyling textStyle) {
	store.putBoolean(getEnabledKey(key), textStyle.isEnabled);
	store.put(getColorKey(key), StringConverter.asString(textStyle.rgb));
	store.putBoolean(getBoldKey(key), textStyle.isBold);
	store.putBoolean(getItalicKey(key), textStyle.isItalic);
	store.putBoolean(getStrikethroughKey(key), textStyle.isStrikethrough);
	store.putBoolean(getUnderlineKey(key), textStyle.isUnderline);
}
 
Example #27
Source File: AbstractProfileManager.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public static boolean hasProjectSpecificSettings(IScopeContext context, KeySet[] keySets) {
	for (int i = 0; i < keySets.length; i++) {
		KeySet keySet = keySets[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) {
				return true;
			}
		}
	}
	return false;
}
 
Example #28
Source File: DialogUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static void setShouldShowDialog(String dialogKey, boolean shouldShow)
{
	final IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(UIEplPlugin.PLUGIN_ID);
	String[] keys = prefs.get(IEplPreferenceConstants.HIDDEN_MESSAGES, StringUtil.EMPTY).split(","); //$NON-NLS-1$
	Set<String> keysSet = CollectionsUtil.newSet(keys);

	if (shouldShow)
	{
		if (!keysSet.contains(dialogKey))
		{
			// Do nothing
			return;
		}
		keysSet.remove(dialogKey);
	}
	else
	{
		if (keysSet.contains(dialogKey))
		{
			// Do nothing
			return;
		}
		keysSet.add(dialogKey);
	}

	prefs.put(IEplPreferenceConstants.HIDDEN_MESSAGES, StringUtil.join(",", keysSet)); //$NON-NLS-1$
	try
	{
		prefs.flush();
	}
	catch (Exception e)
	{
		IdeLog.logError(UIPlugin.getDefault(), e);
	}
}
 
Example #29
Source File: PreferenceRecorder.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Ends the recording process. No other changes to the preference tree are
 * recorded after this method is called.
 * 
 * @throws IllegalStateException if {@code startRecording()} had not been
 *         previously called, or if recording has already completed on this
 *         object.
 */
public void endRecording() {
  synchronized (lock) {
    Preconditions.checkState(currState == State.RECORDING, "Recorder object is not currently recording");

    currState = State.COMPLETE;

    for (IEclipsePreferences node : recordedNodes) {
      node.removeNodeChangeListener(listener);
      node.removePreferenceChangeListener(listener);
    }

    recordedNodes.clear();
  }
}
 
Example #30
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);
  
}