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

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

Introduction

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

Prototype

public PreferenceNode(String id, String label, ImageDescriptor image, String className) 

Source Link

Document

Creates a preference node with the given id, label, and image, and lazily-loaded preference page.

Usage

From source file:com.gigaspaces.azure.propertypage.SubscriptionPropertyPage.java

License:Open Source License

protected int openPropertyDialog(PublishData pd) {
    int retVal = Window.CANCEL;
    try {//from   ww w  . j a  v a2 s  . co  m
        // Create the nodes
        IPreferenceNode subscriptionGeneral = new PreferenceNode(Messages.credentialsPageId,
                Messages.credentialsNodeText, null, CredentialsPropertyPage.class.toString());

        CredentialsPropertyPage.setPublishData(null);

        if (pd != null) {
            CredentialsPropertyPage.setPublishData(pd);
        }

        SelectionProvider selProvider = new SelectionProvider();

        PropertyDialogAction action = new PropertyDialogAction(new IShellProvider() {

            @Override
            public Shell getShell() {
                return new Shell();
            }
        }, selProvider);

        StructuredSelection selection = new StructuredSelection(subscriptionGeneral);

        selProvider.setSelection(selection);

        PreferenceDialog dlg = action.createDialog();

        String dlgTitle = String.format(Messages.credentialsDlgTitle);

        dlg.getShell().setText(dlgTitle);

        retVal = dlg.open();

    } catch (Exception ex) {
    }
    return retVal;
}

From source file:com.microsoft.azuretools.core.utils.PluginUtil.java

License:Open Source License

/**
 * Method opens property dialog with only desired property page.
 *
 * @param nodeId// www.j av  a  2  s. c o  m
 *            : Node ID of property page
 * @param nodeLbl
 *            : Property page name
 * @param classObj
 *            : Class object of property page
 * @return
 */
public static int openPropertyPageDialog(String nodeId, String nodeLbl, Object classObj) {
    int retVal = Window.CANCEL; // value corresponding to cancel
    // Node creation
    try {
        PreferenceNode nodePropPg = new PreferenceNode(nodeId, nodeLbl, null, classObj.getClass().toString());
        nodePropPg.setPage((IPreferencePage) classObj);
        nodePropPg.getPage().setTitle(nodeLbl);

        PreferenceManager mgr = new PreferenceManager();
        mgr.addToRoot(nodePropPg);
        // Dialog creation
        PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                mgr);
        // make desired property page active.
        dialog.setSelectedNode(nodeLbl);
        dialog.create();
        /*
         * If showing storage accounts preference page, don't show
         * properties for title as its common repository.
         */
        String dlgTitle = "";
        if (nodeLbl.equals(Messages.cmhLblStrgAcc) || nodeLbl.equals(Messages.aiTxt)) {
            dlgTitle = nodeLbl;
        } else {
            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(PluginUtil.getParentShell(), Messages.rolsDlgErr,
                Messages.projDlgErrMsg, e);
    }
    return retVal;
}

From source file:com.microsoftopentechnologies.wacommon.utils.PluginUtil.java

License:Open Source License

/**
 * Method opens property dialog with only desired property page.
 * //from  w w  w .ja  v  a2s. c  o m
 * @param nodeId
 *            : Node ID of property page
 * @param nodeLbl
 *            : Property page name
 * @param classObj
 *            : Class object of property page
 * @return
 */
public static int openPropertyPageDialog(String nodeId, String nodeLbl, Object classObj) {
    int retVal = Window.CANCEL; // value corresponding to cancel
    // Node creation
    try {
        PreferenceNode nodePropPg = new PreferenceNode(nodeId, nodeLbl, null, classObj.getClass().toString());
        nodePropPg.setPage((IPreferencePage) classObj);
        nodePropPg.getPage().setTitle(nodeLbl);

        PreferenceManager mgr = new PreferenceManager();
        mgr.addToRoot(nodePropPg);
        // Dialog creation
        PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                mgr);
        // make desired property page active.
        dialog.setSelectedNode(nodeLbl);
        dialog.create();
        /*
         * If showing storage accounts preference page, don't show
         * properties for title as its common repository.
         */
        String dlgTitle = "";
        if (nodeLbl.equals(Messages.cmhLblStrgAcc) || nodeLbl.equals(Messages.aiTxt)) {
            dlgTitle = nodeLbl;
        } else {
            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.persistent.util.WAEclipseHelper.java

License:Open Source License

/**
 * Method creates tree structure of azure property pages. and opens property
 * dialog with desired property page selected & active.
 * /*from w  w  w .j ava  2s.  c  om*/
 * @param windowsAzureRole
 *            : worker role
 * @param pageToDisplay
 *            : property page Id which should be active after opening dialog
 * @param tabToSelect : In case pageToDisplay is Server Configuration page then
 *                   provide tab which should be selected.
 * @return integer
 */
public static int openRolePropertyDialog(WindowsAzureRole windowsAzureRole, String pageToDisplay,
        String tabToSelect) {
    int retVal = Window.CANCEL; // value corresponding to cancel
    try {
        // Node creation
        PreferenceNode nodeGeneral = new PreferenceNode(Messages.cmhIdGeneral, Messages.cmhLblGeneral, null,
                WARGeneral.class.toString());
        nodeGeneral.setPage(new WARGeneral());
        nodeGeneral.getPage().setTitle(Messages.cmhLblGeneral);

        PreferenceNode nodeCache = new PreferenceNode(Messages.cmhIdCach, Messages.cmhLblCach, null,
                WARCaching.class.toString());
        nodeCache.setPage(new WARCaching());
        nodeCache.getPage().setTitle(Messages.cmhLblCach);

        PreferenceNode nodeCert = new PreferenceNode(Messages.cmhIdCert, Messages.cmhLblCert, null,
                WARCertificates.class.toString());
        nodeCert.setPage(new WARCertificates());
        nodeCert.getPage().setTitle(Messages.cmhLblCert);

        PreferenceNode nodeCmpnts = new PreferenceNode(Messages.cmhIdCmpnts, Messages.cmhLblCmpnts, null,
                WARComponents.class.toString());
        nodeCmpnts.setPage(new WARComponents());
        nodeCmpnts.getPage().setTitle(Messages.cmhLblCmpnts);

        PreferenceNode nodeDebugging = new PreferenceNode(Messages.cmhIdDbg, Messages.cmhLblDbg, null,
                WARDebugging.class.toString());
        nodeDebugging.setPage(new WARDebugging());
        nodeDebugging.getPage().setTitle(Messages.cmhLblDbg);

        PreferenceNode nodeEndPts = new PreferenceNode(Messages.cmhIdEndPts, Messages.cmhLblEndPts, null,
                WAREndpoints.class.toString());
        nodeEndPts.setPage(new WAREndpoints());
        nodeEndPts.getPage().setTitle(Messages.cmhLblEndPts);

        PreferenceNode nodeEnvVars = new PreferenceNode(Messages.cmhIdEnvVars, Messages.cmhLblEnvVars, null,
                WAREnvVars.class.toString());
        nodeEnvVars.setPage(new WAREnvVars());
        nodeEnvVars.getPage().setTitle(Messages.cmhLblEnvVars);

        PreferenceNode nodeLdBlnc = new PreferenceNode(Messages.cmhIdLdBlnc, Messages.cmhLblLdBlnc, null,
                WARLoadBalance.class.toString());
        nodeLdBlnc.setPage(new WARLoadBalance());
        nodeLdBlnc.getPage().setTitle(Messages.cmhLblLdBlnc);

        PreferenceNode nodeLclStg = new PreferenceNode(Messages.cmhIdLclStg, Messages.cmhLblLclStg, null,
                WARLocalStorage.class.toString());
        nodeLclStg.setPage(new WARLocalStorage());
        nodeLclStg.getPage().setTitle(Messages.cmhLblLclStg);

        PreferenceNode nodeSrvCnfg = new PreferenceNode(Messages.cmhIdSrvCnfg, Messages.cmhLblSrvCnfg, null,
                WAServerConfiguration.class.toString());
        nodeSrvCnfg.setPage(new WAServerConfiguration(tabToSelect));
        nodeSrvCnfg.getPage().setTitle(Messages.cmhLblSrvCnfg);

        PreferenceNode nodeSslOff = new PreferenceNode(Messages.cmhIdSsl, Messages.cmhLblSsl, null,
                WASSLOffloading.class.toString());
        nodeSslOff.setPage(new WASSLOffloading());
        nodeSslOff.getPage().setTitle(Messages.cmhLblSsl);

        /*
         * Tree structure creation. Don't change order while adding nodes.
         * Its the default alphabetical order given by eclipse.
         */
        nodeGeneral.add(nodeCache);
        nodeGeneral.add(nodeCert);
        nodeGeneral.add(nodeCmpnts);
        nodeGeneral.add(nodeDebugging);
        nodeGeneral.add(nodeEndPts);
        nodeGeneral.add(nodeEnvVars);
        nodeGeneral.add(nodeLdBlnc);
        nodeGeneral.add(nodeLclStg);
        nodeGeneral.add(nodeSrvCnfg);
        nodeGeneral.add(nodeSslOff);

        PreferenceManager mgr = new PreferenceManager();
        mgr.addToRoot(nodeGeneral);
        // 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, windowsAzureRole.getName());
        dialog.getShell().setText(dlgTitle);
        dialog.open();
        // return whether user has pressed OK or Cancel button
        retVal = dialog.getReturnCode();
    } catch (Exception ex) {
        PluginUtil.displayErrorDialogAndLog(new Shell(), Messages.rolsDlgErr, Messages.rolsDlgErrMsg, ex);
    }
    return retVal;
}

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.
 * /* w  w w.ja v  a  2  s .  co m*/
 * @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:org.eclipse.ui.tests.preferences.PreferencesDialogTest.java

License:Open Source License

/**
 * Test preference dialog with a custom manager, custom nodes, this time
 * using an icon./*from  w  w  w .  j av  a2  s.co m*/
 */
public void testWithIcons() {
    PreferenceManager manager = new PreferenceManager();

    IPreferencePage page1 = new SamplePreferencePage("Zzz", "First Sample");
    PreferenceNode node1 = new PreferenceNode("one", "Zzz", descriptor, SamplePreferencePage.class.getName());
    node1.setPage(page1);
    manager.addToRoot(node1);

    IPreferencePage page2 = new SamplePreferencePage("Aaa", "Second Sample");
    PreferenceNode node2 = new PreferenceNode("two", "Aaa", descriptor, SamplePreferencePage.class.getName());
    node2.setPage(page2);
    manager.addToRoot(node2);

    PreferenceDialog dialog = null;
    try {
        dialog = new PreferenceDialog(shell, manager);
        dialog.setBlockOnOpen(false);

        // check that we can create a dialog with custom preference manager
        // with
        // pages with icons
        dialog.open();
    } finally {
        if (dialog != null)
            dialog.close();
    }
}

From source file:org.marketcetera.photon.internal.marketdata.ui.FeedPreferencePageInitializer.java

@Override
public void earlyStartup() {
    List<IMarketDataFeed> providers = new ArrayList<IMarketDataFeed>(
            Activator.getMarketDataManager().getProviders());
    Collections.sort(providers, new Comparator<IMarketDataFeed>() {
        @Override// w w  w .  j a  v a  2s  .com
        public int compare(IMarketDataFeed o1, IMarketDataFeed o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode rootNode = preferenceManager.find(ROOT_NODE);
    for (IMarketDataFeed provider : providers) {
        final ModuleURN urn = provider.getURN();
        try {
            MBeanAttributeInfo[] attributes = ModuleSupport.getMBeanServerConnection()
                    .getMBeanInfo(urn.toObjectName()).getAttributes();
            final List<MBeanAttributeInfo> writableAttributes = new ArrayList<MBeanAttributeInfo>();
            for (MBeanAttributeInfo attribute : attributes) {
                if (attribute.isWritable()) {
                    writableAttributes.add(attribute);
                }
            }
            if (writableAttributes.size() > 0) {
                final String label = provider.getName();
                rootNode.add(new PreferenceNode("org.marketcetera.photon.marketdata.ui." //$NON-NLS-1$
                        + provider.getId(), label, null, null) {
                    @Override
                    public void createPage() {
                        setPage(new GenericAttributePreferencePage(urn,
                                writableAttributes.toArray(new MBeanAttributeInfo[writableAttributes.size()]),
                                label));
                    }
                });
            }
        } catch (Exception e) {
            Messages.FEED_PREFERENCE_PAGE_INITIALIZER_MODULE_ERROR.error(this, e);
        }

    }
}

From source file:org.pwsafe.passwordsafeswt.action.OptionsAction.java

License:Open Source License

/**
 * @see org.eclipse.jface.action.Action#run()
 *//*from w w  w. j a  v a2s.  co m*/
@Override
public void run() {
    final PasswordSafeJFace app = PasswordSafeJFace.getApp();

    // Create the preference manager
    PreferenceManager mgr = new PreferenceManager();

    // Create the nodes
    PreferenceNode displayPrefs = new PreferenceNode("display", Messages.getString("OptionsAction.DisplayNode"), //$NON-NLS-1$//$NON-NLS-2$
            null, DisplayPreferences.class.getName());
    PreferenceNode securityPrefs = new PreferenceNode("security", //$NON-NLS-1$
            Messages.getString("OptionsAction.SecurityNode"), null, SecurityPreferences.class //$NON-NLS-1$
                    .getName());
    PreferenceNode passwordPolicyPrefs = new PreferenceNode("policy", //$NON-NLS-1$
            Messages.getString("OptionsAction.PolicyNode"), null, //$NON-NLS-1$
            PasswordPolicyPreferences.class.getName());
    PreferenceNode usernamePrefs = new PreferenceNode("username", //$NON-NLS-1$
            Messages.getString("OptionsAction.UserNameNode"), null, UsernamePreferences.class //$NON-NLS-1$
                    .getName());
    PreferenceNode miscPrefs = new PreferenceNode("misc", Messages.getString("OptionsAction.MiscNode"), null, //$NON-NLS-1$//$NON-NLS-2$
            MiscPreferences.class.getName());

    // Add the nodes
    mgr.addToRoot(displayPrefs);
    mgr.addToRoot(securityPrefs);
    mgr.addToRoot(passwordPolicyPrefs);
    mgr.addToRoot(usernamePrefs);
    mgr.addToRoot(miscPrefs);

    // Create the preferences dialog
    PreferenceDialog dlg = new PreferenceDialog(app.getShell(), mgr);
    Window.setDefaultImage(
            IOUtils.getImage(PasswordSafeJFace.class, "/org/pwsafe/passwordsafeswt/images/clogo.gif")); //$NON-NLS-1$

    // Set the preference store
    dlg.setPreferenceStore(JFacePreferences.getPreferenceStore());

    // Open the dialog
    dlg.open();

    try {
        if (JFacePreferences.getPreferenceStore().needsSaving()) {
            // Be Paranoid - Save the preferences now
            UserPreferences.getInstance().savePreferences();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}