Java Code Examples for org.eclipse.jface.preference.PreferenceDialog#setPreferenceStore()

The following examples show how to use org.eclipse.jface.preference.PreferenceDialog#setPreferenceStore() . 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: Preferences.java    From Rel with Apache License 2.0 5 votes vote down vote up
public Preferences(Shell parent) {
PreferenceManager preferenceManager = new PreferenceManager();

PreferenceNode general = new PreferenceNode("General", new PreferencePageGeneral());
preferenceManager.addToRoot(general);

PreferenceNode cmd = new PreferenceNode("Command line", new PreferencePageCmd());
preferenceManager.addToRoot(cmd);

PreferenceNode display = new PreferenceNode("Display", new PreferencePageDisplay());
preferenceManager.addToRoot(display);

preferenceDialog = new PreferenceDialog(parent, preferenceManager);
preferenceDialog.setPreferenceStore(preferences);
}
 
Example 2
Source File: Config.java    From pmTrans with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void showConfigurationDialog(Shell parent) throws PmTransException {
	// Create the preference manager
	PreferenceManager mgr = new PreferenceManager();

	// Create the nodes
	PreferenceNode playbackNode = new PreferenceNode("playbackPreferences");
	PreferencePage playbackPage = new FieldEditorPreferencePage() {
		@Override
		protected void createFieldEditors() {
			addField(new IntegerFieldEditor(SHORT_REWIND,
					"Short rewind duration (in sec)",
					getFieldEditorParent()));
			addField(new IntegerFieldEditor(LONG_REWIND,
					"Long rewind duration (in sec)", getFieldEditorParent()));
			addField(new IntegerFieldEditor(REWIND_AND_PLAY,
					"Rewind-and-resume duartion duration (in sec)",
					getFieldEditorParent()));
			addField(new IntegerFieldEditor(LOOP_FRECUENCY,
					"Loops frecuency (in seconds)", getFieldEditorParent()));
			addField(new IntegerFieldEditor(LOOP_LENGHT,
					"Loop rewind lenght (in seconds)",
					getFieldEditorParent()));
		}
	};
	playbackPage.setTitle("Playback preferences");
	playbackNode.setPage(playbackPage);

	PreferenceNode shortcutsNode = new PreferenceNode(
			"shortcutsPreferences");
	PreferencePage shortcutsPage = new FieldEditorPreferencePage() {
		@Override
		protected void createFieldEditors() {
			addField(new ShortcutFieldEditor(SHORT_REWIND_KEY,
					"Short rewind", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(LONG_REWIND_KEY,
					"Long rewind", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(PAUSE_KEY, "Pause and resume",
					getFieldEditorParent()));
			addField(new ShortcutFieldEditor(AUDIO_LOOPS_KEY,
					"Enable audio loops", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(SLOW_DOWN_KEY,
					"Slow down audio playback", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(SPEED_UP_KEY,
					"Speed up audio playback", getFieldEditorParent()));
			addField(new ShortcutFieldEditor(TIMESTAMP_KEY,
					"Insert timestamp", getFieldEditorParent()));
		}
	};
	shortcutsPage.setTitle("Shortcuts preferences");
	shortcutsNode.setPage(shortcutsPage);

	PreferenceNode generalNode = new PreferenceNode("generalPreferences");
	PreferencePage generalPage = new FieldEditorPreferencePage() {
		@Override
		protected void createFieldEditors() {
			addField(new IntegerFieldEditor(AUDIO_FILE_CACHE_LENGHT,
					"Max size of the \"recent audio files\" list",
					getFieldEditorParent()));
			addField(new IntegerFieldEditor(TEXT_FILE_CACHE_LENGHT,
					"Max size of the \"recent text files\" list",
					getFieldEditorParent()));
			// TODO add a separator here
			addField(new BooleanFieldEditor(AUTO_SAVE, "Auto save",
					getFieldEditorParent()));
			addField(new IntegerFieldEditor(AUTO_SAVE_TIME,
					"Auto save frecuency (in minutes)",
					getFieldEditorParent()));
		}
	};
	generalPage.setTitle("General preferences");
	generalNode.setPage(generalPage);

	mgr.addToRoot(playbackNode);
	mgr.addToRoot(shortcutsNode);
	mgr.addToRoot(generalNode);
	PreferenceDialog dlg = new PreferenceDialog(parent, mgr);
	dlg.setPreferenceStore(this);

	if (dlg.open() == PreferenceDialog.OK)
		try {
			save();
		} catch (IOException e) {
			throw new PmTransException("Unable to save preferences", e);
		}
}