List of usage examples for org.eclipse.jface.preference IPersistentPreferenceStore save
public void save() throws IOException;
From source file:com.amazonaws.eclipse.core.ui.setupwizard.InitialSetupWizard.java
License:Apache License
@Override public boolean performFinish() { String internalAccountId = UUID.randomUUID().toString(); saveToCredentialsFile(internalAccountId); preferenceStore.setValue(PreferenceConstants.P_CURRENT_ACCOUNT, internalAccountId); preferenceStore.setValue(PreferenceConstants.P_GLOBAL_CURRENT_DEFAULT_ACCOUNT, internalAccountId); if (preferenceStore instanceof IPersistentPreferenceStore) { IPersistentPreferenceStore persistentPreferenceStore = (IPersistentPreferenceStore) preferenceStore; try {//w w w . j ava 2s . c o m persistentPreferenceStore.save(); } catch (IOException e) { String errorMessage = "Unable to write the account information to disk: " + e.getMessage(); Status status = new Status(Status.ERROR, AwsToolkitCore.PLUGIN_ID, errorMessage, e); StatusManager.getManager().handle(status, StatusManager.LOG); } } AwsToolkitCore.getDefault().getAccountManager().reloadAccountInfo(); if (dataModel.isOpenExplorer()) { openAwsExplorer(); } return true; }
From source file:com.liferay.ide.ui.util.UIUtil.java
License:Open Source License
public static void postInfoWithToggle(final String title, final String msg, final String toggleMessage, final boolean toggleState, final IPersistentPreferenceStore store, final String key) { if (store == null || key == null || store.getString(key).equals(MessageDialogWithToggle.NEVER)) { return;/* w ww. j a v a2 s .com*/ } Display.getDefault().asyncExec(new Runnable() { public void run() { MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation( Display.getDefault().getActiveShell(), title, msg, toggleMessage, toggleState, store, key); try { if (dialog.getToggleState()) { store.setValue(key, MessageDialogWithToggle.NEVER); store.save(); } } catch (IOException e) { } } }); }
From source file:com.siemens.ct.mp3m.Activator.java
License:Open Source License
/** * This method is called when the plug-in is stopped *//*ww w . j a v a2s. c o m*/ @Override public void stop(BundleContext context) throws Exception { // Saving preferences IPersistentPreferenceStore store = (IPersistentPreferenceStore) getPreferenceStore(); store.setValue(PREF_MUSIC_FOLDERS, MusicFolders.getMusicFoldersString()); store.save(); super.stop(context); plugin = null; }
From source file:de.tobject.findbugs.FindbugsPlugin.java
License:Open Source License
/** * Save current UserPreferences for given project or workspace. * * @param project/* ww w . j ava 2 s.c o m*/ * the project or null for workspace * @throws CoreException */ public static void saveUserPreferences(IProject project, final UserPreferences userPrefs) throws CoreException { FileOutput userPrefsOutput = new FileOutput() { @Override public void writeFile(OutputStream os) throws IOException { userPrefs.write(os); } @Override public String getTaskDescription() { return "writing user preferences"; } }; if (project != null) { // Make the new user preferences current for the project project.setSessionProperty(SESSION_PROPERTY_USERPREFS, userPrefs); IFile userPrefsFile = getUserPreferencesFile(project); ensureReadWrite(userPrefsFile); IO.writeFile(userPrefsFile, userPrefsOutput, null); if (project.getFile(DEPRECATED_PREFS_PATH).equals(userPrefsFile)) { String message = "Found old style FindBugs preferences for project '" + project.getName() + "'. This preferences are not at the default location: '" + DEFAULT_PREFS_PATH + "'." + " Please move '" + DEPRECATED_PREFS_PATH + "' to '" + DEFAULT_PREFS_PATH + "'."; getDefault().logWarning(message); } } else { // write the workspace preferences to the eclipse preference store ByteArrayOutputStream bos = new ByteArrayOutputStream(10000); try { userPrefs.write(bos); } catch (IOException e) { getDefault().logException(e, "Failed to write user preferences"); return; } Properties props = new Properties(); try { props.load(new ByteArrayInputStream(bos.toByteArray())); } catch (IOException e) { getDefault().logException(e, "Failed to save user preferences"); return; } IPreferenceStore store = getDefault().getPreferenceStore(); // Reset any existing custom group entries resetStore(store, UserPreferences.KEY_PLUGIN); resetStore(store, UserPreferences.KEY_EXCLUDE_BUGS); resetStore(store, UserPreferences.KEY_EXCLUDE_FILTER); resetStore(store, UserPreferences.KEY_INCLUDE_FILTER); for (Entry<Object, Object> entry : props.entrySet()) { store.putValue((String) entry.getKey(), (String) entry.getValue()); } if (store instanceof IPersistentPreferenceStore) { IPersistentPreferenceStore store2 = (IPersistentPreferenceStore) store; try { store2.save(); } catch (IOException e) { getDefault().logException(e, "Failed to save user preferences"); } } } }
From source file:org.absmodels.abs.plugin.util.UtilityFunctions.java
License:Open Source License
public static void syncPreferenceStore(IPersistentPreferenceStore prefstore) { try {// w ww . j av a2 s . c om prefstore.save(); } catch (IOException e) { standardExceptionHandling(e); } }
From source file:org.brainwy.liclipsetext.editor.languages.LanguagesManager.java
License:Open Source License
private boolean changeTrackedDir(File file, boolean add) { boolean changed = false; synchronized (lock) { IPreferenceStore preferenceStore = LiClipseTextEditorPlugin.getDefault().getPreferenceStore(); String string = preferenceStore.getString(ADDITIONAL_TRACKED_DIRS); Set<String> split = new OrderedSet<>(StringUtils.split(string, '|')); if (add) { changed = split.add(file.getAbsolutePath()); } else {// ww w .j av a 2 s . c om //remove changed = split.remove(file.getAbsolutePath()); } if (changed) { preferenceStore.setValue(ADDITIONAL_TRACKED_DIRS, StringUtils.join("|", split.toArray(new String[split.size()]))); if (preferenceStore instanceof IPersistentPreferenceStore) { IPersistentPreferenceStore iPersistentPreferenceStore = (IPersistentPreferenceStore) preferenceStore; try { iPersistentPreferenceStore.save(); } catch (Exception e) { Log.log(e); } } updateTrackedDirs(); } } if (changed) { reloadJob.schedule(JOB_TIMEOUT); } return changed; }
From source file:org.eclim.plugin.pdt.preference.OptionHandler.java
License:Open Source License
/** * {@inheritDoc}/* www . java 2 s. co m*/ */ public void setOption(String name, String value) throws Exception { /*Map<String,String> options = DLTKCore.getOptions(); if(name.equals(PHPCoreConstants.PHP_OPTIONS_PHP_VERSION)){ // not supported accross projects? }else{ options.put(name, value); DLTKCore.setOptions((Hashtable)options); }*/ if (VERSION.equals(name)) { getValues().put(VERSION, value); IPersistentPreferenceStore store = getPreferences(); store.setValue(name.substring(PREFIX.length()), value); store.save(); } }
From source file:org.nightlabs.editor2d.viewer.ui.preferences.ViewerPreferencePage.java
License:Open Source License
@Override public boolean performOk() { boolean ok = super.performOk(); BufferManager.sharedInstance().setBufferScaleFactor(bufferScale.getDoubleValue()); setRenderSelection(getPreferenceStore().getString(Preferences.PREFERENCE_RENDERING)); IPersistentPreferenceStore store = (IPersistentPreferenceStore) getPreferenceStore(); try {//w ww. jav a 2 s. c o m store.save(); } catch (IOException e) { throw new RuntimeException(e); } return ok; }
From source file:org.objectstyle.wolips.preferences.Preferences.java
License:Open Source License
/** * //from w ww . ja va 2 s .c o m */ public static void save() { IPreferenceStore store = getPreferenceStore(); if (store instanceof IPersistentPreferenceStore) { IPersistentPreferenceStore pstore = (IPersistentPreferenceStore) store; if (pstore.needsSaving()) { try { pstore.save(); } catch (IOException up) { // hmm, what should we do? } } } }
From source file:org.python.pydev.editor.codecompletion.revisited.SynchSystemModulesManager.java
License:Open Source License
/** * When the user selects changes in selectElementsInDialog, it's possible that he doesn't check some of the * proposed changes, thus, in this case, we should save the unselected items in the preferences and the next * time such a change is proposed, it should appear unchecked (and if all changes are unchecked, we shouldn't * present the user with a dialog)./*from w ww . ja v a2 s . c o m*/ * * @param root this is the initial structure, containing all the proposed changes. * @param selectedElements this is a structure which will hold only the selected changes. * @param iPreferenceStore this is the store where we'll keep the selected changes. */ public void saveUnselected(DataAndImageTreeNode root, List<TreeNode> selectedElements, IPreferenceStore iPreferenceStore) { //root has null data, level 1 has IInterpreterInfo and level 2 has PythonpathChange. HashSet<TreeNode> selectionSet = new HashSet<>(); if (selectedElements != null && selectedElements.size() > 0) { selectionSet.addAll(selectedElements); } boolean changed = false; for (DataAndImageTreeNode<IInterpreterInfo> interpreterNode : (List<DataAndImageTreeNode<IInterpreterInfo>>) root .getChildren()) { Set<TreeNode> addToIgnore = new HashSet<>(); if (!selectionSet.contains(interpreterNode)) { //ignore all the entries below this interpreter. addToIgnore.addAll(interpreterNode.getChildren()); } else { //check each entry and only add the ones not selected. for (TreeNode<PythonpathChange> pathNode : interpreterNode.getChildren()) { if (!selectionSet.contains(pathNode)) { addToIgnore.add(pathNode); } } } if (addToIgnore.size() > 0) { IInterpreterInfo info = interpreterNode.getData(); String key = createKeyForInfo(info); ArrayList<String> addToIgnorePaths = new ArrayList<String>(addToIgnore.size()); for (TreeNode<PythonpathChange> node : addToIgnore) { PythonpathChange data = node.getData(); addToIgnorePaths.add(data.path); } if (DEBUG) { System.out.println("Setting key: " + key); System.out.println("Paths ignored: " + addToIgnorePaths); } changed = true; iPreferenceStore.setValue(key, StringUtils.join("|||", addToIgnorePaths)); } } if (changed) { if (iPreferenceStore instanceof IPersistentPreferenceStore) { IPersistentPreferenceStore iPersistentPreferenceStore = (IPersistentPreferenceStore) iPreferenceStore; try { iPersistentPreferenceStore.save(); } catch (IOException e) { Log.log(e); } } } }