Java Code Examples for org.eclipse.jface.preference.IPersistentPreferenceStore#save()

The following examples show how to use org.eclipse.jface.preference.IPersistentPreferenceStore#save() . 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: UpdateCheck.java    From cppcheclipse with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 2
Source File: ScopedFieldEditorPreferencePage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example 3
Source File: UpdateCheck.java    From cppcheclipse with Apache License 2.0 4 votes vote down vote up
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);
			}
		}
	}
}