public boolean getEngineEnabled(EngineDescriptor desc) { IPreferenceStore store = getPreferenceStore(); String key = getMasterKey(desc.getId()); if (store.contains(key)) return store.getBoolean(key); store.setValue(key, desc.isEnabled()); return desc.isEnabled(); }
/** * Save the values specified in the pages. * * <p>The default implementation of this framework method saves all pages of type <code> * PreferencePage</code> (if their store needs saving and is a <code>PreferenceStore</code>). * * <p>Subclasses may override. */ protected void handleSave() { Iterator<IPreferenceNode> nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator(); while (nodes.hasNext()) { IPreferenceNode node = nodes.next(); IPreferencePage page = node.getPage(); if (page instanceof PreferencePage) { // Save now in case tbe workbench does not shutdown cleanly IPreferenceStore store = ((PreferencePage) page).getPreferenceStore(); if (store != null && store.needsSaving() && store instanceof IPersistentPreferenceStore) { try { ((IPersistentPreferenceStore) store).save(); } catch (IOException e) { String message = JFaceResources.format( "PreferenceDialog.saveErrorMessage", page.getTitle(), // $NON-NLS-1$ e.getMessage()); Policy.getStatusHandler() .show( new Status(IStatus.ERROR, Policy.JFACE, message, e), JFaceResources.getString("PreferenceDialog.saveErrorTitle")); // $NON-NLS-1$ } } } } }
/* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ public void init(IWorkbench workbench) { try { PROSActions actions = Activator.getPROSActions(); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); store.setValue( PreferenceConstants.P_LOCAL_REPOSITORY, actions.getLocalRepositoryPath().toString()); store.setValue(PreferenceConstants.P_UPDATE_SITE, actions.getUpdateSite().toExternalForm()); } catch (IOException e) { e.printStackTrace(); } }
/** Stores this field editor's value back into the preference store. */ public void store() { if (preferenceStore == null) { return; } if (isDefaultPresented) { preferenceStore.setToDefault(preferenceName); } else { doStore(); } }
/** * Create a new instance of the receiver. * * @param title The displayable name of the action. * @param preferenceStore The preference store to propogate changes to * @param property The property that is being updated * @throws IllegalArgumentException Thrown if preferenceStore or property are <code>null</code>. */ public BooleanPropertyAction(String title, IPreferenceStore preferenceStore, String property) throws IllegalArgumentException { super(title, AS_CHECK_BOX); if (preferenceStore == null || property == null) { throw new IllegalArgumentException(); } this.preferenceStore = preferenceStore; this.property = property; final String finalProprety = property; preferenceStore.addPropertyChangeListener( new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (finalProprety.equals(event.getProperty())) { setChecked(Boolean.TRUE.equals(event.getNewValue())); } } }); setChecked(preferenceStore.getBoolean(property)); }
@Override protected void performApply() { super.performApply(); PROSActions actions; try { actions = Activator.getPROSActions(); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); try { actions.setLocalKernelRepository( Paths.get(store.getString(PreferenceConstants.P_LOCAL_REPOSITORY))); } catch (IOException e) { showErrorDialog( "Error saving settings", "There was an error saving the settings. Try again later.", IStatus.ERROR, e); } try { actions.setUpdateSite(new URL(store.getString(PreferenceConstants.P_UPDATE_SITE))); } catch (MalformedURLException e) { showErrorDialog("Bad URL input", "The provided URL is invalid.", IStatus.ERROR, e); } catch (IOException e) { showErrorDialog( "Error saving settings", "There was an error saving the settings. Try again later.", IStatus.ERROR, e); } kernelListEditor.doLoad(); } catch (IOException e) { showErrorDialog( "PROS Error", "There was an error creating the PROS Updater interface.", IStatus.ERROR, e); } }
public void setEngineEnabled(EngineDescriptor desc, boolean value) { IPreferenceStore store = getPreferenceStore(); String key = getMasterKey(desc.getId()); store.setValue(key, value); }
/* * (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ @Override public void run() { preferenceStore.setValue(property, isChecked()); }
protected void storeValues() { IPreferenceStore store = getPreferenceStore(); store.setValue(SURROUND_WITH_BEGIN, mSurroundWithBegin); store.setValue(SAVE_BEFORE_LOAD, mSaveBeforeLoad); }
protected void initializeValues() { IPreferenceStore store = getPreferenceStore(); mSaveBeforeLoad = store.getBoolean(SAVE_BEFORE_LOAD); mSurroundWithBegin = store.getBoolean(SURROUND_WITH_BEGIN); }
public static void initializeDefaults(IPreferenceStore store) { store.setDefault(SURROUND_WITH_BEGIN, DEFAULT_SURROUND_WITH_BEGIN); store.setDefault(SAVE_BEFORE_LOAD, DEFAULT_SAVE_BEFORE_LOAD); }