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

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

Introduction

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

Prototype

@Override
    public void create() 

Source Link

Usage

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//ww w. ja va  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. jav  a  2 s . 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.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  . j  a  va2s .  c  o m
@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.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 av a  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;/*from   w ww .  j  a v a  2  s. 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();
}

From source file:com.nokia.carbide.internal.bugdatacollector.ui.preferences.BugDataCollectorPreferencePage.java

License:Open Source License

/**
 * Shows the preference dialog with only this preference page 
 * available in the tree/*from  w  w  w .  j  a v a2 s .c  om*/
 * @param shell 
 */
public static void showYourself(Shell shell) {
    IPreferencePage page = new BugDataCollectorPreferencePage();
    PreferenceManager mgr = new PreferenceManager();
    IPreferenceNode node = new PreferenceNode("1", page); //$NON-NLS-1$
    mgr.addToRoot(node);
    PreferenceDialog dialog = new PreferenceDialog(shell, mgr);
    dialog.create();
    dialog.setMessage(page.getTitle());
    dialog.open();
}

From source file:com.nokia.s60tools.hticonnection.actions.OpenPreferencePageAction.java

License:Open Source License

/**
 * Open HTI API preferences page preference page
 */// w  ww  .  ja  v a  2s. c o m
private void openPreferencePage() {
    IPreferencePage page = new HtiApiPreferencePage();
    PreferenceManager mgr = new PreferenceManager();
    IPreferenceNode node = new PreferenceNode("1", page);//$NON-NLS-1$
    mgr.addToRoot(node);
    PreferenceDialog dialog = new PreferenceDialog(HtiApiActivator.getCurrentlyActiveWbWindowShell(), mgr);
    dialog.create();
    dialog.setMessage(page.getTitle());
    dialog.open();
}

From source file:com.nokia.traceviewer.engine.ConnectionHelper.java

License:Open Source License

/**
 * Creates Client UI//  ww w.  j  a  va2 s.  c o m
 */
private static void createClientUI() {
    PreferenceManager mgr = new PreferenceManager();

    // Create connection preference page
    IPreferencePage connectionPage = new TraceViewerConnectionPreferencesPage();
    IPreferenceNode connectionNode = new PreferenceNode("1", connectionPage); //$NON-NLS-1$
    mgr.addToRoot(connectionNode);

    // Create the dialog
    PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
            mgr);
    dialog.create();
}

From source file:com.nokia.traceviewer.view.TraceViewerView.java

License:Open Source License

public boolean openPreferencePage(TVPreferencePage TVpage) {
    boolean ret = false;
    PreferenceManager mgr = new PreferenceManager();

    // Create general preference page
    IPreferencePage generalPage = new TraceViewerPreferencesPage();
    generalPage.setTitle(TRACE_VIEWER_TITLE);
    IPreferenceNode generalNode = new PreferenceNode("1", generalPage); //$NON-NLS-1$
    mgr.addToRoot(generalNode);/*from   w  w  w . j  ava2  s  .  c o  m*/

    // Create advanced preference page
    IPreferencePage advancedPage = new TraceViewerAdvancedPreferencesPage();
    advancedPage.setTitle(Messages.getString("TraceViewerView.AdvancedPageTitle")); //$NON-NLS-1$
    IPreferenceNode advancedNode = new PreferenceNode("2", advancedPage); //$NON-NLS-1$
    mgr.addTo("1", advancedNode); //$NON-NLS-1$

    // Create connection preference page
    IPreferencePage connectionPage = new TraceViewerConnectionPreferencesPage();
    connectionPage.setTitle(Messages.getString("TraceViewerView.ConnectionPageTitle")); //$NON-NLS-1$
    IPreferenceNode connectionNode = new PreferenceNode("3", connectionPage); //$NON-NLS-1$
    mgr.addTo("1", connectionNode); //$NON-NLS-1$

    PreferenceDialog dialog = new PreferenceDialog(getShell(), mgr);
    dialog.create();
    dialog.getTreeViewer().expandAll();

    // Switch the page
    switch (TVpage) {
    case GENERAL:
        dialog.getTreeViewer().setSelection(new StructuredSelection(generalNode));
        break;
    case ADVANCED:
        dialog.getTreeViewer().setSelection(new StructuredSelection(advancedNode));
        break;
    case CONNECTION:
        dialog.getTreeViewer().setSelection(new StructuredSelection(connectionNode));
        break;
    default:
        break;
    }

    // Open dialog and get return value
    int ok = dialog.open();
    if (ok == Window.OK) {
        ret = true;
    }

    return ret;
}

From source file:com.nsn.squirrel.preferences.handlers.E4PreferencesHandler.java

License:Open Source License

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, E4PreferenceRegistry prefReg) {

    PreferenceManager pm = prefReg.getPreferenceManager();
    PreferenceDialog dialog = new PreferenceDialog(shell, pm);
    dialog.create();
    dialog.getTreeViewer().setComparator(new ViewerComparator());
    dialog.getTreeViewer().expandAll();//from w  w w.  j  a  v a  2 s  .c  om
    dialog.open();
}