Example usage for org.eclipse.jface.preference PreferenceManager PreferenceManager

List of usage examples for org.eclipse.jface.preference PreferenceManager PreferenceManager

Introduction

In this page you can find the example usage for org.eclipse.jface.preference PreferenceManager PreferenceManager.

Prototype

public PreferenceManager() 

Source Link

Document

Creates a new preference manager.

Usage

From source file:com.persistent.util.WAEclipseHelper.java

License:Open Source License

/**
 * Method creates tree structure of azure deployment project property pages.
 * and opens property dialog with desired property page selected & active.
 * /*from w ww.j a v  a  2  s  .c om*/
 * @param pageToDisplay
 *            : property page Id which should be active after opening dialog
 * @return integer
 */
public static int openWAProjectPropertyDialog(String pageToDisplay) {
    int retVal = Window.CANCEL; // value corresponding to cancel
    // Node creation
    try {
        PreferenceNode nodeWindowsAzure = new PreferenceNode(Messages.cmhIdWinAz, Messages.cmhLblWinAz, null,
                WAWinAzurePropertyPage.class.toString());
        nodeWindowsAzure.setPage(new WAWinAzurePropertyPage());
        nodeWindowsAzure.getPage().setTitle(Messages.cmhLblWinAz);

        PreferenceNode nodeRemoteAcess = new PreferenceNode(Messages.cmhIdRmtAces, Messages.cmhLblRmtAces, null,
                WARemoteAccessPropertyPage.class.toString());
        nodeRemoteAcess.setPage(new WARemoteAccessPropertyPage());
        nodeRemoteAcess.getPage().setTitle(Messages.cmhLblRmtAces);

        PreferenceNode nodeRoles = new PreferenceNode(Messages.cmhIdRoles, Messages.cmhLblRoles, null,
                WARolesPropertyPage.class.toString());
        nodeRoles.setPage(new WARolesPropertyPage());
        nodeRoles.getPage().setTitle(Messages.cmhLblRoles);

        PreferenceNode nodeSubscriptions = new PreferenceNode(Messages.cmhIdCrdntls, Messages.cmhLblSubscrpt,
                null, SubscriptionPropertyPage.class.toString());
        nodeSubscriptions.setPage(new SubscriptionPropertyPage());
        nodeSubscriptions.getPage().setTitle(Messages.cmhLblSubscrpt);

        /*
         * Tree structure creation. Don't change order while adding nodes.
         * Its the default alphabetical order given by eclipse.
         */
        nodeWindowsAzure.add(nodeRemoteAcess);
        nodeWindowsAzure.add(nodeRoles);
        nodeWindowsAzure.add(nodeSubscriptions);

        PreferenceManager mgr = new PreferenceManager();
        mgr.addToRoot(nodeWindowsAzure);
        // Dialog creation
        PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                mgr);
        // make desired property page active.
        dialog.setSelectedNode(pageToDisplay);
        dialog.create();
        String dlgTitle = String.format(Messages.cmhPropFor, getSelectedProject().getName());
        dialog.getShell().setText(dlgTitle);
        dialog.open();
        // return whether user has pressed OK or Cancel button
        retVal = dialog.getReturnCode();
    } catch (Exception e) {
        PluginUtil.displayErrorDialogAndLog(new Shell(), Messages.rolsDlgErr, Messages.projDlgErrMsg, e);
    }
    return retVal;
}

From source file:com.programmablefun.ide.App.java

License:Open Source License

private void showPreferences() {
    PreferencePage pages[] = new PreferencePage[] { new RepositoryPrefPage(codeRepository),
            new ColorSchemePrefPage(stylesheetRepository, wellKnownWords), };
    PreferenceManager mgr = new PreferenceManager();
    for (PreferencePage p : pages) {
        mgr.addToRoot(new PreferenceNode(p.getTitle(), p));
    }/*from w  ww .j  a  va  2  s  .co m*/
    PreferenceDialog dlg = new PreferenceDialog(Display.getCurrent().getActiveShell(), mgr);
    if (dlg.open() == Window.OK) {
        sourceCodeComposite.setStylesheet(stylesheetRepository.get(settings.getSelectedStylesheet()));
        settings.save();
    }
}

From source file:com.siteview.mde.internal.ui.samples.ShowTargetPlatformAction.java

License:Open Source License

public void run() {
    final IPreferenceNode targetNode = new TargetPlatformPreferenceNode();
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);//from  www.j  a  v a2 s  .c om
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    final PreferenceDialog dialog = new PreferenceDialog(shell, manager);
    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:com.siteview.mde.internal.ui.wizards.imports.PluginImportWizardFirstPage.java

License:Open Source License

private boolean showPreferencePage(final IPreferenceNode targetNode, Shell shell) {
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);//  ww  w .  ja v a  2s.co m
    final PreferenceDialog dialog = new PreferenceDialog(shell, manager);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            if (dialog.open() == Window.OK)
                result[0] = true;
        }
    });
    return result[0];
}

From source file:com.telink.tc32eclipse.ui.actions.TCDBPrefAction.java

License:Open Source License

/**
 * Start the TCDB UploadJob./*from  w w  w .  j a  va  2  s. c o m*/
 * 
 * @param buildcfg
 *            The build configuration for resolving macros.
 * @param props
 *            The AVR properties for the project / the current configuration
 */
private void runTCDBPref(IConfiguration buildcfg, TC32ProjectProperties props) {

    TCDBProperties TCDBprops = props.getTCDBProperties();

    // get the list of normal (non-action) arguments
    //      List<String> optionargs = TCDBprops.getArguments();

    // get a list of actions
    List<String> actionargs = TCDBprops.getActionArguments(buildcfg, true);

    // Get the ProgrammerConfig in case we need to display an error
    // message
    //      ProgrammerConfig programmer = TCDBprops.getProgrammer();

    actionargs.add(props.getBinaryTargetName()); // + " " + programmer.getArg2String());

    // Set the working directory to the CWD of the active build config, so that
    // relative paths are resolved correctly.
    //      IPath cwdunresolved = buildcfg.getBuildData().getBuilderCWD();
    //      IPath cwd = new Path(BuildMacro.resolveMacros(buildcfg, cwdunresolved.toString()));

    IPreferencePage page = new MainPreferencePage();
    PreferenceManager mgr = new PreferenceManager();
    IPreferenceNode node = new PreferenceNode("1", page);
    mgr.addToRoot(node);
    PreferenceDialog dialog = new PreferenceDialog(getShell(), mgr);
    dialog.create();
    dialog.setMessage(page.getTitle());
    dialog.open();
    /*
    //ISelection sel = ... obtain the current selection
       PropertyPage page = new PageTCDB(); //MyPropertyPage();
       PreferenceManager mgr = new PreferenceManager();
       IPreferenceNode node = new PreferenceNode("1", page);
       mgr.addToRoot(node);
       @SuppressWarnings("restriction")
       ISelection sel = (ISelection) fProject;
       PropertyDialog dialog = new PropertyDialog(getShell(), mgr, sel);
       dialog.create();
       dialog.setMessage(page.getTitle());
       //PropertyDialog dialog = PropertyDialog.createDialogOn(getShell(), null, (ISelection) fProject);  
       dialog.open();
       */

}

From source file:de.jcup.egradle.eclipse.ide.IDEUtil.java

License:Apache License

private static void showPreferencePage(IPreferencePage page) {
    EclipseUtil.safeAsyncExec(new Runnable() {

        @Override//from w w w .j a va  2  s .c o m
        public void run() {
            Shell shell = getSafeDisplay().getActiveShell();

            PreferenceManager mgr = new PreferenceManager();
            IPreferenceNode node = new PreferenceNode("1", page);
            mgr.addToRoot(node);
            PreferenceDialog dialog = new PreferenceDialog(shell, mgr);
            dialog.create();
            dialog.setMessage(page.getTitle());
            dialog.open();
        }

    });

}

From source file:de.uniluebeck.itm.spyglass.gui.configuration.PluginPreferenceDialog.java

License:Open Source License

public PluginPreferenceDialog(final Shell parentShell, final Spyglass spyglass) {

    this.spyglass = spyglass;

    preferenceManager = new PreferenceManager();
    preferenceDialog = new CustomPreferenceDialog(parentShell, preferenceManager);
    addPreferenceNodes();/*from w  ww. j a  v  a  2 s .  c o  m*/

}

From source file:fr.obeo.dsl.arduino.commands.PreferencesHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IPreferencePage page = new ArduinoPreferencesPage();
    PreferenceManager manager = new PreferenceManager();
    IPreferenceNode node = new PreferenceNode("0", page);
    manager.addToRoot(node);/*w  w  w . j  av  a2 s  .c  om*/
    Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
    PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(shell, page.getDescription(), null, null);
    if (pref != null)
        pref.open();
    return null;
}

From source file:gov.redhawk.internal.ui.port.nxmplot.view.PlotSettingsAction.java

License:Open Source License

@Override
public void run() {
    PreferenceManager manager = new PreferenceManager();

    if (pageBook.getSources().size() > 1) {
        PlotPreferencePage plotPage = new PlotPreferencePage("Plot", false);
        plotPage.setPreferenceStore(pageBook.getActivePlotWidget().getPreferenceStore());

        PlotPreferenceNode plotNode = new PlotPreferenceNode("plotSettings", plotPage);
        manager.addToRoot(plotNode);/*from   w w  w .j a va2 s  .c o m*/
        for (PlotSource source : pageBook.getSources()) {
            List<INxmBlock> blockChain = pageBook.getBlockChain(source);
            String name = source.getInput().getName();
            SourcePreferencePage sourcePrefPage = new SourcePreferencePage(name, pageBook, blockChain);
            PreferenceNode sourceNode = new PreferenceNode(source.toString(), sourcePrefPage);

            for (INxmBlock block : blockChain) {
                IPreferencePage page = block.createPreferencePage();
                if (page != null) {
                    PreferenceNode blockNode = new PreferenceNode(block.toString(), page);
                    sourceNode.add(blockNode);
                }
            }
            manager.addToRoot(sourceNode);
        }
    } else if (pageBook.getSources().size() == 1) {
        PlotSource source = pageBook.getSources().get(0);
        List<INxmBlock> blockChain = pageBook.getBlockChain(source);

        PlotNxmBlock plotBlock = null;
        for (INxmBlock block : blockChain) {
            if (block instanceof PlotNxmBlock) {
                plotBlock = (PlotNxmBlock) block;
            }
        }
        PlotPreferencePage plotPage = new PlotPreferencePage("Plot");
        plotPage.setPreferenceStore(pageBook.getActivePlotWidget().getPreferenceStore());
        plotPage.setBlockPreferenceStore(pageBook.getSharedPlotBlockPreferences());
        PlotPreferenceNode plotNode = new PlotPreferenceNode("plotSettings", plotPage);
        manager.addToRoot(plotNode);

        //                  String name = entry.getKey().getInput().getName();
        //                  SourcePreferencePage sourcePrefPage = new SourcePreferencePage(name, PlotPageBook2.this);
        //                  PreferenceNode sourceNode = new PreferenceNode(entry.getKey().toString(), sourcePrefPage);
        //                  manager.addToRoot(sourceNode);

        for (INxmBlock block : blockChain) {
            if (plotBlock == block) {
                continue;
            }
            IPreferencePage page = block.createPreferencePage();
            if (page != null) {
                PreferenceNode blockNode = new PreferenceNode(block.toString(), page);
                manager.addToRoot(blockNode);
            }
        }
    } else {
        PlotPreferencePage plotPage = new PlotPreferencePage("Plot");
        plotPage.setPreferenceStore(pageBook.getActivePlotWidget().getPreferenceStore());
        plotPage.setBlockPreferenceStore(pageBook.getSharedPlotBlockPreferences());
        PlotPreferenceNode plotNode = new PlotPreferenceNode("plotSettings", plotPage);
        manager.addToRoot(plotNode);
    }

    PlotPreferenceDialog dialog = new PlotPreferenceDialog(pageBook.getShell(), manager);
    dialog.open();
}

From source file:joachimeichborn.geotag.ui.preferences.PreferencesDialog.java

License:Open Source License

public PreferencesDialog(final IEclipsePreferences aPreferences) {
    final PreferenceManager manager = new PreferenceManager();

    final PreferenceNode general = new PreferenceNode("general", new GeneralPreferences(aPreferences));
    final PreferenceNode map = new PreferenceNode("map", new MapPreferences(aPreferences));
    final PreferenceNode geocoding = new PreferenceNode("geocoding", new GeocodingPreferences(aPreferences));

    manager.addToRoot(general);/*  w  ww.j  a v a 2  s  . c o  m*/
    manager.addToRoot(map);
    manager.addToRoot(geocoding);
    dialog = new PreferenceDialog(null, manager);
}