@Override public boolean performOk() { IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer(); if (!processChanges(container)) { return false; } boolean retVal = super.performOk(); if (retVal && isProjectPreferencePage()) { try { IPreferenceStore preferenceStore = preferenceStoreAccessImpl.getWritablePreferenceStore(getProject()); if (preferenceStore instanceof IPersistentPreferenceStore) { ((IPersistentPreferenceStore) preferenceStore).save(); } } catch (Exception e) { System.err.println(e); retVal = false; } } return retVal; }
/** * @see PreferencePage#performOk */ @Override public boolean performOk() { if( !modified ) { return true; } IPath path = Path.EMPTY; Object[] checked = listViewer.getCheckedElements(); for( Object elements : checked ) { path = path.append(((IProject) elements).getName()); } IPreferenceStore prefs = getPreferenceStore(); prefs.setValue(JPFClasspathPlugin.PREF_PARENT_REGISTRIES, path.toString()); try { ((IPersistentPreferenceStore) prefs).save(); } catch( IOException e ) { JPFClasspathLog.logError(e); } return true; }
/** * @see PreferencePage#performOk */ @Override public boolean performOk() { if( !modified ) { return true; } StructuredSelection selection = (StructuredSelection) listViewer.getSelection(); IProject project = (IProject) selection.getFirstElement(); if( project != null ) { IPreferenceStore prefs = getPreferenceStore(); prefs.setValue(JPFClasspathPlugin.PREF_REGISTRY_NAME, project.getName()); try { ((IPersistentPreferenceStore) prefs).save(); } catch( IOException e ) { JPFClasspathLog.logError(e); } } return true; }
@Override public boolean performOk() { boolean retVal = super.performOk(); if (retVal && isPropertyPage()) { try { currentProject().setPersistentProperty(new QualifiedName(qualifiedName(), USE_PROJECT_SETTINGS), String.valueOf(useProjectSettingsButton.getSelection())); ((IPersistentPreferenceStore) getPreferenceStore()).save(); } catch (Exception e) { log.error("Error", e); //$NON-NLS-1$ retVal = false; } } return retVal; }
public static Date getLastUpdateCheckDate() { IPersistentPreferenceStore configuration = CppcheclipsePlugin .getConfigurationPreferenceStore(); String dateString = configuration .getString(IPreferenceConstants.P_LAST_UPDATE_CHECK); if (dateString.length() == 0) { return null; } DateFormat format = new SimpleDateFormat(DATE_PATTERN); Date lastUpdateDate = null; try { lastUpdateDate = format.parse(dateString); } catch (ParseException e) { CppcheclipsePlugin.logError("Could not parse date from last update check", e); } return lastUpdateDate; }
private static boolean needUpdateCheck() { IPersistentPreferenceStore configuration = CppcheclipsePlugin .getConfigurationPreferenceStore(); if (!configuration .getBoolean(IPreferenceConstants.P_USE_AUTOMATIC_UPDATE_CHECK)) { return false; } Date lastUpdateDate = getLastUpdateCheckDate(); if (lastUpdateDate == null) { return true; } Date today = new Date(); long timeDifferenceMS = today.getTime() - lastUpdateDate.getTime(); String updateInterval = configuration .getString(IPreferenceConstants.P_AUTOMATIC_UPDATE_CHECK_INTERVAL); for (int i = 0; i < INTERVALS.length; i++) { if (updateInterval.equals(INTERVALS[i][1])) { return timeDifferenceMS >= INTERVALS_IN_MS[i]; } } return false; }
@Override protected void handleSave() { final Iterator<IPreferenceNode> nodes = getPreferenceManager().getElements(PreferenceManager.PRE_ORDER).iterator(); while (nodes.hasNext()) { final IPreferenceNode node = nodes.next(); final IPreferencePage page = node.getPage(); if (page instanceof PreferencePage) { final IPreferenceStore store = ((PreferencePage) page).getPreferenceStore(); if (store != null && store.needsSaving() && store instanceof IPersistentPreferenceStore) { try { ((IPersistentPreferenceStore) store).save(); } catch (final IOException ioe) { final String message = JFaceMessages.get("err.preferences.save"); logger.log(Level.SEVERE, message, ioe); EnhancedErrorDialog.openError(getShell(), title, message, IStatus.ERROR, ioe, new Image[] { Display.getCurrent().getSystemImage(SWT.ICON_ERROR) }); } } } } }
public void checkAllNow() { //Add all to be tracked Map<IInterpreterManager, Map<String, IInterpreterInfo>> addedToTrack = job.addAllToTrack(); //remove from the preferences any ignore the user had set previously Set<Entry<IInterpreterManager, Map<String, IInterpreterInfo>>> entrySet = addedToTrack.entrySet(); IPreferenceStore preferences = PydevPrefs.getPreferences(); for (Entry<IInterpreterManager, Map<String, IInterpreterInfo>> entry : entrySet) { Set<Entry<String, IInterpreterInfo>> entrySet2 = entry.getValue().entrySet(); for (Entry<String, IInterpreterInfo> entry2 : entrySet2) { String key = SynchSystemModulesManager.createKeyForInfo(entry2.getValue()); preferences.setValue(key, ""); } } if (preferences instanceof IPersistentPreferenceStore) { IPersistentPreferenceStore iPersistentPreferenceStore = (IPersistentPreferenceStore) preferences; try { iPersistentPreferenceStore.save(); } catch (IOException e) { Log.log(e); } } //schedule changes to be executed. job.scheduleLater(0); }
@Override public void run() { PromptOverlay overlay = promptOverlay.get(); if (overlay == null || preferences == null) { return; } Integer newSize = DialogHelpers.openAskInt("Percentual size for console prompt.", "Please enter the relative size for the console prompt (0-100)", preferences.getInt(PydevDebugPreferencesInitializer.RELATIVE_CONSOLE_HEIGHT)); if (newSize != null) { if (newSize < 0) { newSize = 0; } if (newSize > 100) { newSize = 100; } } preferences.setValue(PydevDebugPreferencesInitializer.RELATIVE_CONSOLE_HEIGHT, newSize); if (preferences instanceof IPersistentPreferenceStore) { try { ((IPersistentPreferenceStore) preferences).save(); } catch (IOException e) { Log.log(e); } } }
/** * Saves the templates to the preferences. * * @throws IOException if the templates cannot be written */ public void save() throws IOException { ArrayList custom= new ArrayList(); List<TemplatePersistenceData> fTemplates=Arrays.asList(this.getTemplateData(true)); for (Iterator it= fTemplates.iterator(); it.hasNext();) { TemplatePersistenceData data= (TemplatePersistenceData) it.next(); if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates custom.add(data); } StringWriter output= new StringWriter(); TemplateReaderWriter writer= new SilverStripeTemplateReaderWriter(); writer.save((TemplatePersistenceData[]) custom.toArray(new TemplatePersistenceData[custom.size()]), output); this.stopListeningForPreferenceChanges(); try { fPreferenceStore.setValue(fKey, output.toString()); if (fPreferenceStore instanceof IPersistentPreferenceStore) ((IPersistentPreferenceStore)fPreferenceStore).save(); } finally { this.startListeningForPreferenceChanges(); } }
/** * If the preference store is persistable, it will serialized here. * * This method has been copied and adapted from org.eclipse.xtext.ui.preferences.OptionsConfigurationBlock. */ protected void savePreferences() { try { if (getPreferenceStore() instanceof IPersistentPreferenceStore) { ((IPersistentPreferenceStore) getPreferenceStore()).save(); } } catch (IOException e) { IStatus status = new Status(IStatus.ERROR, N4JSActivator.getInstance().getBundle().getSymbolicName(), "Unexpected internal error: ", e); //$NON-NLS-1$ N4JSActivator.getInstance().getLog().log(status); } }
@Override public boolean performOk() { for (PreferenceArea area : areas) { area.performApply(); if (area.getPreferenceStore() instanceof IPersistentPreferenceStore) { try { ((IPersistentPreferenceStore) area.getPreferenceStore()).save(); } catch (IOException ex) { logger.log(Level.SEVERE, "Unable to persist preferences for " + area, ex); return false; } } } return true; }
protected void savePreferences() { try { if (preferenceStore instanceof IPersistentPreferenceStore) { ((IPersistentPreferenceStore) preferenceStore).save(); } } catch (IOException e) { IStatus status = new Status(IStatus.ERROR, uiPlugin.getBundle().getSymbolicName(), "Unexpected internal error: ", e); //$NON-NLS-1$ uiPlugin.getLog().log(status); } }
protected void toggle() { boolean newState = !isPropertySet(); IPreferenceStore store = preferenceStoreAccess.getWritablePreferenceStore(); store.setValue(getPreferenceKey(), newState); if (store instanceof IPersistentPreferenceStore) try { ((IPersistentPreferenceStore) store).save(); } catch (IOException e) { // log and ignore logger.debug(e.getMessage(), e); } stateChanged(newState); }
public static IPersistentPreferenceStore getProjectPreferenceStore(IProject project) { // Create an overlay preference store and fill it with properties ProjectScope ps = new ProjectScope(project); ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps, getId()); PreferenceInitializer.initializePropertiesDefault(scoped); return scoped; }
public void save() throws IOException { StringBuffer suppressions = new StringBuffer(); for (Suppression suppression : suppressionList) { suppressions.append(suppression.serialize()).append(DELIMITER); } projectPreferences.setValue(IPreferenceConstants.P_SUPPRESSIONS, suppressions.toString()); if (projectPreferences instanceof IPersistentPreferenceStore) { ((IPersistentPreferenceStore) projectPreferences).save(); } }
public void save() throws IOException { StringBuffer symbolsSerialization = new StringBuffer(); for (Symbol symbol : symbols) { // only serialize user-defined symbols if (!symbol.isCDTDefined()) symbolsSerialization.append(symbol.serialize()).append(DELIMITER); } projectPreferences.setValue(IPreferenceConstants.P_SYMBOLS, symbolsSerialization.toString()); if (projectPreferences instanceof IPersistentPreferenceStore) { ((IPersistentPreferenceStore) projectPreferences).save(); } }
@Override protected IStatus run(IProgressMonitor monitor) { monitor.beginTask(getName(), 1); if (monitor.isCanceled()) return Status.CANCEL_STATUS; UpdateCheckCommand updateCheck = new UpdateCheckCommand(); Version newVersion; try { newVersion = updateCheck.run(monitor, Console.getInstance(), binaryPath); DateFormat format = new SimpleDateFormat(DATE_PATTERN); IPersistentPreferenceStore configuration = CppcheclipsePlugin .getConfigurationPreferenceStore(); configuration.setValue( IPreferenceConstants.P_LAST_UPDATE_CHECK, format .format(new Date())); configuration.save(); Display display = Display.getDefault(); display.syncExec(new UpdateCheckNotifier(newVersion)); } catch (Exception e) { if (!isSilent) { CppcheclipsePlugin .showError("Error checking for update", e); //$NON-NLS-1$ } else { CppcheclipsePlugin.logError("Error checking for update", e); } } return Status.OK_STATUS; }
public void finish() { replacementStrings.put(KEY_PACKAGE_NAME, String.valueOf(getValue(KEY_PLUGIN_ID))); for (Entry<TemplateOption, ParameterDescriptor> entry : options.entrySet()) { TemplateOption templateOption = entry.getKey(); ParameterDescriptor descriptor = entry.getValue(); if (descriptor == null) { continue; } Object value = templateOption.getValue(); if (!(value instanceof String)) { continue; } String valueString = (String) value; replacementStrings.put(templateOption.getName() + UNMAPPED_VALUE_SUFFIX, valueString); ParameterMapping valueMapping = descriptor.getValueMapping(); String newValue = valueString.replaceAll(valueMapping.getPattern(), valueMapping.getReplacement()); templateOption.setValue(newValue); addStringMappings(templateOption.getName(), valueString); ParameterPreference preference = descriptor.getPreference(); if (preference != null) { IPersistentPreferenceStore preferences = new ScopedPreferenceStore(InstanceScope.INSTANCE, preference.getPluginId()); preferences.setValue(preference.getPreferenceName(), valueString); try { preferences.save(); } catch (IOException e) { ProjectTemplateActivator.logError("Failed to save preference", e); } } } }
public void save() { if (store.needsSaving() && store instanceof IPersistentPreferenceStore) { try { ((IPersistentPreferenceStore)store).save(); } catch (IOException e) { Activator.logError(Activator.getResourceString("easyshell.message.error.store.save"), e); } } }
private static IPersistentPreferenceStore createStore(IProject project) { IScopeContext projectScope = new ProjectScope(project); IPersistentPreferenceStore store = new ScopedPreferenceStore(projectScope, CooperateProjectNature.NATURE_ID); CDO_HOST.init(store); CDO_PORT.init(store); CDO_REPO.init(store); MSG_PORT.init(store); return store; }
public void save( ) throws IOException { if ( this.preferenceType == SPECIAL_TYPE && project != null ) prefs.saveReportPreference( project ); else if ( prefsStore instanceof IPersistentPreferenceStore ) ( (IPersistentPreferenceStore) prefsStore ).save( ); }
@Override public boolean performOk() { boolean ret = super.performOk(); IPreferenceStore preferenceStore2 = getPreferenceStore(); // When the user presses apply, make sure we try to persist now, not when the IDE is closed. if (preferenceStore2 instanceof IPersistentPreferenceStore) { IPersistentPreferenceStore iPersistentPreferenceStore = (IPersistentPreferenceStore) preferenceStore2; try { iPersistentPreferenceStore.save(); } catch (IOException e) { Log.log(e); } } return ret; }
@Override public void run(IAction action) { preferences.setValue(PydevDebugPreferencesInitializer.SHOW_CONSOLE_PROMPT_ON_DEBUG, !preferences.getBoolean(PydevDebugPreferencesInitializer.SHOW_CONSOLE_PROMPT_ON_DEBUG)); if (preferences instanceof IPersistentPreferenceStore) { try { ((IPersistentPreferenceStore) preferences).save(); } catch (IOException e) { Log.log(e); } } }
@Override public void run() { PromptOverlay overlay = promptOverlay.get(); if (overlay == null || preferences == null) { return; } int relativeConsoleHeight = overlay.getRelativeConsoleHeight(); int newSize; if (relativeConsoleHeight < 100) { previousConsoleHeight = relativeConsoleHeight; newSize = 100; preferences.setValue(PydevDebugPreferencesInitializer.CONSOLE_PROMPT_OUTPUT_MODE, PydevDebugPreferencesInitializer.MODE_NOT_ASYNC_SAME_CONSOLE); } else { newSize = previousConsoleHeight; preferences.setValue(PydevDebugPreferencesInitializer.CONSOLE_PROMPT_OUTPUT_MODE, PydevDebugPreferencesInitializer.MODE_ASYNC_SEPARATE_CONSOLE); } preferences.setValue(PydevDebugPreferencesInitializer.RELATIVE_CONSOLE_HEIGHT, newSize); if (preferences instanceof IPersistentPreferenceStore) { try { ((IPersistentPreferenceStore) preferences).save(); } catch (IOException e) { Log.log(e); } } updateText(); }
private void savePrefs() { if (preferences instanceof IPersistentPreferenceStore) { try { ((IPersistentPreferenceStore) preferences).save(); } catch (IOException e) { Log.log(e); } } }
public TestPrefArea(String preferenceName, String preferenceValue, IPersistentPreferenceStore preferences) { this.preferenceName = preferenceName; this.preferenceValue = preferenceValue; setPreferenceStore(preferences); }
public static IPersistentPreferenceStore getWorkspacePreferenceStore() { return getDefault().getInternalWorkspacePreferenceStore(); }
public static IPersistentPreferenceStore getConfigurationPreferenceStore() { return getDefault().getInternalConfigurationPreferenceStore(); }
public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(); // if no new version found, just display a dialog if not in silent mode if (newVersion == null) { if (!isSilent) { MessageDialog.openInformation(shell, Messages.UpdateCheck_NoUpdateTitle, Messages.UpdateCheck_NoUpdateMessage); } } else { boolean downloadUpdate = false; // only have toggle switch for update check if silent (not // started from preferences) if (isSilent) { MessageDialogWithToggle msgDialog = MessageDialogWithToggle .openYesNoQuestion(shell, Messages.UpdateCheck_UpdateTitle, Messages.bind( Messages.UpdateCheck_UpdateMessage, newVersion), Messages.UpdateCheck_NeverCheckAgain, false, null, null); IPersistentPreferenceStore configuration = CppcheclipsePlugin .getConfigurationPreferenceStore(); configuration.setValue( IPreferenceConstants.P_USE_AUTOMATIC_UPDATE_CHECK, !msgDialog.getToggleState()); if (msgDialog.getReturnCode() == IDialogConstants.YES_ID) { downloadUpdate = true; } try { configuration.save(); } catch (IOException e1) { CppcheclipsePlugin.logError("Could not save changes for update checks", e1); } } else { downloadUpdate = MessageDialog.openQuestion(shell, Messages.UpdateCheck_UpdateTitle, Messages.bind( Messages.UpdateCheck_UpdateMessage, newVersion)); } if (downloadUpdate) { try { Utils.openUrl(DOWNLOAD_URL); } catch (Exception e) { CppcheclipsePlugin.logError("Could not open cppcheck download page", e); } } } }
/** * 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). * * @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); } } } }
public SilverStripeTemplateStore(ContextTypeRegistry registry, IPreferenceStore store, String key) { super(registry, store, key); fPreferenceStore=(IPersistentPreferenceStore) store; fKey=key; }