Java Code Examples for org.eclipse.jface.preference.PreferenceManager#addToRoot()

The following examples show how to use org.eclipse.jface.preference.PreferenceManager#addToRoot() . 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: SWTUtil.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method allows us to open the preference dialog on the specific page, in this case the perspective page
 * 
 * @param id
 *            the id of pref page to show
 * @param page
 *            the actual page to show Copied from org.eclipse.debug.internal.ui.SWTUtil
 */
public static void showPreferencePage(String id, IPreferencePage page)
{
	final IPreferenceNode targetNode = new PreferenceNode(id, page);
	PreferenceManager manager = new PreferenceManager();
	manager.addToRoot(targetNode);
	final PreferenceDialog dialog = new PreferenceDialog(UIUtils.getActiveShell(), manager);
	BusyIndicator.showWhile(getStandardDisplay(), new Runnable()
	{
		public void run()
		{
			dialog.create();
			dialog.setMessage(targetNode.getLabelText());
			dialog.open();
		}
	});
}
 
Example 2
Source File: FieldEditorOverlayPage.java    From cppcheclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Show a single preference pages
 * 
 * @param id
 *            - the preference page identification
 * @param page
 *            - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
	final IPreferenceNode targetNode = new PreferenceNode(id, page);
	PreferenceManager manager = new PreferenceManager();
	manager.addToRoot(targetNode);
	final PreferenceDialog dialog = new PreferenceDialog(getControl()
			.getShell(), manager);
	BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
		public void run() {
			dialog.create();
			dialog.setMessage(targetNode.getLabelText());
			dialog.open();
		}
	});
}
 
Example 3
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 4
Source File: CppStylePropertyPage.java    From CppStyle with MIT License 5 votes vote down vote up
/**
 * Show a single preference pages
 * 
 * @param id
 *            - the preference page identification
 * @param page
 *            - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
	final IPreferenceNode targetNode = new PreferenceNode(id, page);
	PreferenceManager manager = new PreferenceManager();
	manager.addToRoot(targetNode);
	final PreferenceDialog dialog = new PreferenceDialog(getControl()
			.getShell(), manager);
	BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
		public void run() {
			dialog.create();
			dialog.setMessage(targetNode.getLabelText());
			dialog.open();
		}
	});
}
 
Example 5
Source File: AnnotationStyleViewPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
        IStatusLineManager statusLineManager) {
  super.makeContributions(menuManager, toolBarManager, statusLineManager);
  
  // TODO: Figure out how to use open properties dialog action here correctly
  // see http://wiki.eclipse.org/FAQ_How_do_I_open_a_Property_dialog%3F
  
  IAction action = new Action() {
    @Override
    public void run() {
      super.run();
      
      ISelection sel = new StructuredSelection(new AnnotationTypeNode(editor, null));
      PropertyPage page = new EditorAnnotationPropertyPage();
      page.setElement(new AnnotationTypeNode(editor, null));
      page.setTitle("Styles");
      PreferenceManager mgr = new PreferenceManager();
      IPreferenceNode node = new PreferenceNode("1", page);
      mgr.addToRoot(node);
      PropertyDialog dialog = new PropertyDialog(getSite().getShell(), mgr, sel);
      dialog.create();
      dialog.setMessage(page.getTitle());
      dialog.open();
    }
  };
  
  action.setImageDescriptor(CasEditorPlugin
          .getTaeImageDescriptor(Images.MODEL_PROCESSOR_FOLDER));
  
  toolBarManager.add(action);
}
 
Example 6
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);
		}
}
 
Example 7
Source File: StyleBuilder.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private static PreferenceManager createPreferenceManager(
		ReportElementHandle handle, AbstractThemeHandle theme )
{
	PreferenceManager preferenceManager = new PreferenceManager( '/' );

	// Get the pages from the registry
	List<IPreferenceNode> pageContributions = new ArrayList<IPreferenceNode>( );

	// adds preference pages into page contributions.
	pageContributions.add( new StylePreferenceNode( "General", //$NON-NLS-1$
			new GeneralPreferencePage( handle, theme ) ) );
	pageContributions.add( new StylePreferenceNode( "Font", //$NON-NLS-1$
			new FontPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Size", //$NON-NLS-1$
			new SizePreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Background", //$NON-NLS-1$
			new BackgroundPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Block", //$NON-NLS-1$
			new BlockPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Box", //$NON-NLS-1$
			new BoxPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Border", //$NON-NLS-1$
			new BorderPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Number Format", //$NON-NLS-1$
			new FormatNumberPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "DateTime Format", //$NON-NLS-1$
			new FormatDateTimePreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "String Format", //$NON-NLS-1$
			new FormatStringPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "PageBreak", //$NON-NLS-1$
			new PageBreakPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Map", //$NON-NLS-1$
			new MapPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Highlights", //$NON-NLS-1$
			new HighlightsPreferencePage( handle ) ) );
	pageContributions.add( new StylePreferenceNode( "Comments", //$NON-NLS-1$
			new CommentsPreferencePage( handle ) ) );

	// Add the contributions to the manager
	Iterator<IPreferenceNode> it = pageContributions.iterator( );
	while ( it.hasNext( ) )
	{
		IPreferenceNode node = it.next( );
		preferenceManager.addToRoot( node );
	}
	return preferenceManager;
}