Example usage for org.eclipse.jface.preference PreferenceDialog open

List of usage examples for org.eclipse.jface.preference PreferenceDialog open

Introduction

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

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:com.liferay.ide.ui.util.SWTUtil.java

License:Open Source License

public static boolean showPreferencePage(String id, Shell shell) {
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode node = manager.find("org.eclipse.jdt.ui.preferences.JavaBasePreferencePage") //$NON-NLS-1$
            .findSubNode(id);/* www . jav a  2 s. c  o m*/
    PreferenceManager manager2 = new PreferenceManager();
    manager2.addToRoot(node);
    PreferenceDialog dialog = new PreferenceDialog(shell, manager2);
    dialog.create();
    return (dialog.open() == Window.OK);
}

From source file:com.mentor.nucleus.bp.core.ui.SetBPProjectPreferencesAction.java

License:Open Source License

public void run(IAction action) {
    IStructuredSelection structuredSelection = Selection.getInstance().getStructuredSelection();
    if (structuredSelection != null) {
        Object selection = structuredSelection.getFirstElement();
        if (selection instanceof SystemModel_c) {
            IProject selectedProject = (IProject) ((SystemModel_c) selection).getAdapter(IProject.class);
            if (selectedProject != null) {
                IScopeContext projectScope = new ProjectScope(selectedProject);
                Preferences projectNode = projectScope
                        .getNode(BridgePointProjectPreferences.BP_PROJECT_PREFERENCES_ID);
                PreferenceDialog pd = new PreferenceDialog(
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        CorePlugin.getProjectPreferenceManager(projectNode));

                pd.open();
            }/*from   w ww  . jav a2  s .  c  om*/

        }
    }

}

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/*from w w w  .j ava2s.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.
 * // w ww.j  a v a 2  s.com
 * @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.mobilesorcery.sdk.profiles.ui.internal.ProfilesView.java

License:Open Source License

private void createErrorPane(Composite parent) {
    errorPane = new Composite(parent, SWT.NONE);
    errorPane.setLayout(new GridLayout(1, false));
    errorMessage = new Link(errorPane, SWT.WRAP);
    errorMessage.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, true, true));
    errorMessage.addSelectionListener(new SelectionAdapter() {
        @Override/* w  w  w  . j a  v a  2s .  c o m*/
        public void widgetSelected(SelectionEvent event) {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
                    ProfilesView.this.getSite().getShell(), "com.mobilesorcery.sdk.preferences.main", //$NON-NLS-1$
                    new String[] { "com.mobilesorcery.sdk.preferences.main" }, null); //$NON-NLS-1$
            dialog.open();
        }
    });
    updateErrorMessage();
}

From source file:com.mobilesorcery.sdk.ui.internal.actions.ManageBuildConfigsAction.java

License:Open Source License

public void run(IAction action) {
    PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(
            targetPart.getSite().getWorkbenchWindow().getShell(), project.getWrappedProject(),
            BUILD_CONFIG_SETTINGS_ID, new String[] { BUILD_CONFIG_SETTINGS_ID, BUILD_SETTINGS_ID }, null,
            PreferencesUtil.OPTION_FILTER_LOCKED);

    dialog.open();
}

From source file:com.motorola.studio.android.common.utilities.EclipseUtils.java

License:Apache License

/**
 * Open the preference page with the specified ID
 * @param nodeID the id of preference page to show
 *//*ww w  .  ja v  a  2s .com*/
@SuppressWarnings("unchecked")
public static void openPreference(Shell shell, String nodeID) {
    // Makes the network preferences dialog manager
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode networkNode = null;
    for (IPreferenceNode node : (List<IPreferenceNode>) manager.getElements(PreferenceManager.PRE_ORDER)) {
        if (node.getId().equals(nodeID)) {
            networkNode = node;
            break;
        }
    }
    PreferenceManager prefMan = new PreferenceManager();
    if (networkNode != null) {
        prefMan.addToRoot(networkNode);
    }
    PreferenceDialog preferencesDialog = new WorkbenchPreferenceDialog(shell, prefMan);
    preferencesDialog.create();
    preferencesDialog.open();
}

From source file:com.motorola.studio.android.common.utilities.ui.WidgetsUtil.java

License:Apache License

/**
 * Opens the Eclipse preferences dialog and selects the page of the given
 * id.//from   ww w  . jav a 2 s.c o m
 * 
 * @param shell The shell.
 * @param selectedNode The preferences page to selec.
 * @return <code>true</code> if the Wizard dialog has constant OK,
 *         <code>false</code> otherwise .
 */
public static boolean runPreferencePage(Shell shell, String selectedNode) {
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    PreferenceDialog dialog = new PreferenceDialog(shell, manager);
    dialog.setSelectedNode(selectedNode);
    WidgetsUtil.centerDialog(shell);
    return dialog.open() == PreferenceDialog.OK;
}

From source file:com.motorola.studio.android.emulator.device.ui.PropertiesMainComposite.java

License:Apache License

@SuppressWarnings("unchecked")
protected void openNetworkPreferences() {
    // Makes the network preferences dialog manager
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode networkNode = null;/*from   w ww  .j  ava 2s  .  c om*/
    for (IPreferenceNode node : (List<IPreferenceNode>) manager.getElements(PreferenceManager.PRE_ORDER)) {
        if (node.getId().equals(ORG_ECLIPSE_UI_NET_NET_PREFERENCES)) {
            networkNode = node;
            break;
        }
    }
    PreferenceManager prefMan = new PreferenceManager();
    if (networkNode != null) {
        prefMan.addToRoot(networkNode);
    }
    PreferenceDialog networkPreferencesDialog = new WorkbenchPreferenceDialog(getShell(), prefMan);
    networkPreferencesDialog.create();
    networkPreferencesDialog.open();
}

From source file:com.motorolamobility.preflighting.ui.utilities.EclipseUtils.java

License:Apache License

@SuppressWarnings("unchecked")
public static void openPreference(Shell shell, String nodeID) {
    // Makes the network preferences dialog manager
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode networkNode = null;/*w  ww  .  jav a2s. c om*/
    for (IPreferenceNode node : (List<IPreferenceNode>) manager.getElements(PreferenceManager.PRE_ORDER)) {
        if (node.getId().equals(nodeID)) {
            networkNode = node;
            break;
        }
    }
    PreferenceManager prefMan = new PreferenceManager();
    if (networkNode != null) {
        prefMan.addToRoot(networkNode);
    }
    PreferenceDialog preferencesDialog = new WorkbenchPreferenceDialog(shell, prefMan);
    preferencesDialog.create();
    preferencesDialog.open();
}