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.astra.ses.spell.dev.startup.SetPythonInterpreterCommand.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    /*//  w w  w .  j a  va2 s  .  co m
     * Step 1. Resolve if Python interpreter has been set previously
     */
    String nodeQualifier = PydevPlugin.DEFAULT_PYDEV_SCOPE;
    String prefName = PythonInterpreterManager.PYTHON_INTERPRETER_PATH;
    String prefPage = SpellPythonInterpreterPage.PAGE_ID;

    IEclipsePreferences confScope = new InstanceScope().getNode(nodeQualifier);
    String interpreter = confScope.get(prefName, "");
    if (interpreter.isEmpty()) {
        IEclipsePreferences defScope = new DefaultScope().getNode(nodeQualifier);
        interpreter = defScope.get(prefName, "");
    }
    if (!interpreter.isEmpty()) {
        //Python interpretar has been set 
        return null;
    }
    /*
     * Step 2. Open python interpretar wizard
     */
    String title = "Python intrepreter has not beeen set";
    String message = "Python interpreter has not been configured yet. "
            + "It is required for procedures development.\n" + "Would you like to configure it now?\n"
            + "It can also be configured later through the Window > Preferences menu.";
    Shell shell = new Shell();
    boolean open = MessageDialog.openQuestion(shell, title, message);
    if (open) {
        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, prefPage, null, null,
                SWT.NONE);
        dialog.open();
    }
    return null;
}

From source file:com.astra.ses.spell.dev.wizards.pages.ProjectInfoWizardPage.java

License:Open Source License

/***************************************************************************
 * Create interpreter info dialog if it has not been set
 * @param parent//from   w  ww.  j  a  v  a  2 s . c o  m
 **************************************************************************/
private void createInterpreterInfoGroup(Composite parent) {
    // Python interpreter group
    Group interpreterGroup = new Group(parent, SWT.BORDER);
    interpreterGroup.setText("Python interpreter information");

    StackLayout layout = new StackLayout();
    GridData interpreterData = new GridData(SWT.FILL, SWT.TOP, true, false);
    interpreterGroup.setLayout(layout);
    interpreterGroup.setLayoutData(interpreterData);

    /*
     * Link composite
     */
    m_linkComposite = new Composite(interpreterGroup, SWT.NONE);
    m_linkComposite.setLayout(new GridLayout());

    m_preferencesLink = new Link(m_linkComposite, SWT.NONE);
    m_preferencesLink.setData("PAGE", SpellPythonInterpreterPage.PAGE_ID);
    m_preferencesLink.setText("<a>Click here to set a Python interpreter</a>");
    m_preferencesLink.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            String page = (String) e.widget.getData("PAGE");
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, page, null, null);
            if (dialog.open() == PreferenceDialog.OK) {
                fillInterpreterInfoWidget();
                validatePage();
            }
        }
    });

    /*
     * Python interpreter composite
     */
    m_interpreterComposite = new Composite(interpreterGroup, SWT.NONE);
    m_interpreterComposite.setLayout(new GridLayout(2, false));

    Label pathLabel = new Label(m_interpreterComposite, SWT.NONE);
    pathLabel.setText("Interpreter path");
    m_interpreterLabel = new Label(m_interpreterComposite, SWT.NONE);

    Label versionLabel = new Label(m_interpreterComposite, SWT.NONE);
    versionLabel.setText("Version");
    m_interpreterVersion = new Label(m_interpreterComposite, SWT.NONE);

    Link explanation = new Link(m_interpreterComposite, SWT.WRAP);
    explanation
            .setText("Interpreter to use will be the first in the list at <a>Interpreters preference page</a>");
    explanation.setData("PAGE", SpellPythonInterpreterPage.PAGE_ID);
    explanation.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            String page = (String) e.widget.getData("PAGE");
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, page, null, null);
            if (dialog.open() == PreferenceDialog.OK) {
                fillInterpreterInfoWidget();
                validatePage();
            }
        }
    });
    GridData explData = new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1);
    explanation.setLayoutData(explData);

    fillInterpreterInfoWidget();
}

From source file:com.bdaum.overlayPages.FieldEditorOverlayPage.java

License:Open Source License

/**
 * Show a single preference pages/*from w  ww . jav  a 2s  .  c o m*/
 * 
 * @param id
 *            - the preference page identification
 * @param page
 *            - the preference page
 */
protected void showPreferencePage(final String id, final IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    final PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        @Override
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:com.bdaum.zoom.ai.internal.services.AiService.java

License:Open Source License

@Override
public boolean configure(Shell shell) {
    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, AiPreferencePage.ID, null, null);
    return dialog.open() == PreferenceDialog.OK;
}

From source file:com.bdaum.zoom.gps.internal.actions.GeonameAction.java

License:Open Source License

public void run(final File[] files, IAdaptable info) {
    if (info == null)
        return;//  w  ww .j a  v a 2  s  .c o m
    final Shell shell = info.getAdapter(Shell.class);
    AssetSelection assetSelection = info.getAdapter(AssetSelection.class);
    String[] assetIds = assetSelection == null ? null : assetSelection.getLocalAssetIds();
    if ((assetIds == null || assetIds.length == 0)
            && !AcousticMessageDialog.openConfirm(shell, Messages.getString("GeoNamingAction.Geonaming"), //$NON-NLS-1$
                    Messages.getString("GeoNamingAction.Nothing_selected"))) //$NON-NLS-1$
        return;
    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, GpsPreferencePage.ID, EMPTY,
            "onAction"); //$NON-NLS-1$
    if (dialog.open() != PreferenceDialog.OK)
        return;
    Trackpoint[] pnts = new Trackpoint[0];
    final GpsConfiguration gpsConfiguration = GpsActivator.getDefault().createGpsConfiguration();
    if (files != null) {
        gpsConfiguration.excludeNoGoAreas = true;
        BusyIndicator.showWhile(shell.getDisplay(), () -> {
            for (int i = 0; i < files.length; i++) {
                if (gpsConfiguration.useWaypoints)
                    try {
                        IWaypointCollector collector = Ui.getUi().getWaypointCollector(files[i]);
                        if (collector != null) {
                            if (waypoints == null)
                                waypoints = new HashMap<RasterCoordinate, Waypoint>(201);
                            try (InputStream in1 = new BufferedInputStream(new FileInputStream(files[i]))) {
                                collector.collect(in1, waypoints);
                            }
                        }
                    } catch (FileNotFoundException e1) {
                        showError(shell, NLS.bind(Messages.getString("GeotagAction.parsing_error"), //$NON-NLS-1$
                                files[i]), e1);
                    } catch (IOException e2) {
                        showError(shell, NLS.bind(Messages.getString("GeotagAction.io_error_waypoints"), //$NON-NLS-1$
                                files[i]), e2);
                    } catch (ParseException e3) {
                        showError(shell, NLS.bind(Messages.getString("GeotagAction.parsing_error"), //$NON-NLS-1$
                                files[i]), e3);
                    }
                try {
                    IGpsParser parser = Ui.getUi().getGpsParser(files[i]);
                    if (parser == null) {
                        GpsActivator.getDefault()
                                .logError(NLS.bind(Messages.getString("GeotagAction.no_parser"), //$NON-NLS-1$
                                        files[i]), null);
                        continue;
                    }
                    try (InputStream in2 = new BufferedInputStream(new FileInputStream(files[i]))) {
                        parser.parse(in2, trackpoints);
                    }
                } catch (FileNotFoundException e4) {
                    // should never happen
                } catch (ParseException e5) {
                    showError(shell, NLS.bind(Messages.getString("GeotagAction.parsing_error"), //$NON-NLS-1$
                            files[i]), e5);
                } catch (IOException e6) {
                    showError(shell, NLS.bind(Messages.getString("GeotagAction.io_error"), //$NON-NLS-1$
                            files[i]), e6);
                }
            }
        });
        pnts = trackpoints.toArray(new Trackpoint[trackpoints.size()]);
        Arrays.sort(pnts);
        if (!trackpoints.isEmpty() && info != null && gpsConfiguration.edit) {
            TrackpointDialog tdialog = new TrackpointDialog(shell, pnts,
                    gpsConfiguration.tolerance * ONEMINUTE);
            if (tdialog.open() != TrackpointDialog.OK)
                return;
            pnts = tdialog.getResult();
        }
    }
    OperationJob.executeOperation(new GeotagOperation(pnts, assetIds, gpsConfiguration), info);
}

From source file:com.blackducksoftware.integration.eclipseplugin.popupmenu.handlers.OpenPreferences.java

License:Apache License

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final Shell activeShell = HandlerUtil.getActiveShell(event);
    final String[] pageIds = new String[] { PreferencePageIds.BLACK_DUCK,
            PreferencePageIds.ACTIVE_JAVA_PROJECTS, PreferencePageIds.DEFAULT_CONFIG,
            PreferencePageIds.HUB_AUTHORIZATION };
    final PreferenceDialog prefPage = PreferencesUtil.createPreferenceDialogOn(activeShell,
            PreferencePageIds.BLACK_DUCK, pageIds, null);
    prefPage.open();
    return null;/*  ww w  .j  a  va2  s  .c om*/
}

From source file:com.blackducksoftware.integration.eclipseplugin.popupmenu.handlers.OpenProjectPreferences.java

License:Apache License

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final Shell activeShell = HandlerUtil.getActiveShell(event);
    final PreferenceManager mgr = new PreferenceManager(preferencePathSeparatorCharacter);

    final DependencyInformationService depService = new DependencyInformationService();
    final FilePathGavExtractor extractor = new FilePathGavExtractor();
    final ProjectInformationService projService = new ProjectInformationService(depService, extractor);
    final WorkspaceInformationService workspaceService = new WorkspaceInformationService(projService);

    final String projectPrefId = workspaceService.getSelectedProject();
    final IndividualProjectPreferences prefPage = new IndividualProjectPreferences(projectPrefId,
            projectPrefId);// www  .j a va 2 s.c om
    final PreferenceNode prefNode = new PreferenceNode(projectPrefId, prefPage);
    mgr.addToRoot(prefNode);
    final PreferenceDialog prefDialog = new PreferenceDialog(activeShell, mgr);
    prefDialog.open();
    return null;
}

From source file:com.centurylink.mdw.plugin.actions.ConvertProjectAction.java

License:Apache License

@SuppressWarnings("restriction")
public void run(IAction action) {
    if (selection != null) {
        Object element = selection.getFirstElement();
        try {//  w  w w.j av a 2 s .  c  om
            IProject project = (element instanceof IJavaProject) ? ((IJavaProject) element).getProject()
                    : (IProject) element;
            IFacetedProject facetedProject = ProjectFacetsManager.create(project);
            if (facetedProject == null) {
                org.eclipse.wst.common.project.facet.ui.internal.ConvertProjectToFacetedFormRunnable
                        .runInProgressDialog(shell, project);
                facetedProject = ProjectFacetsManager.create(project);
            }
            IFacetedProjectWorkingCopy workingCopy = org.eclipse.wst.common.project.facet.ui.internal.SharedWorkingCopyManager
                    .getWorkingCopy(facetedProject);
            workingCopy
                    .addProjectFacet(ProjectFacetsManager.getProjectFacet("mdw.workflow").getDefaultVersion());
            if (!facetedProject.hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.ear"))
                    && !facetedProject.hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.web"))
                    && !facetedProject.hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.utility"))) {
                workingCopy.addProjectFacet(
                        ProjectFacetsManager.getProjectFacet("jst.utility").getDefaultVersion());
            }

            PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(shell, element,
                    FACETS_PROP_PAGE_ID, null, null, PreferencesUtil.OPTION_NONE);
            if (dialog != null) {
                dialog.open();
            }
        } catch (Exception ex) {
            PluginMessages.uiError(shell, ex, "Convert Workflow Project");
        }
    }
}

From source file:com.centurylink.mdw.plugin.designer.wizards.ImportPackagePage.java

License:Apache License

private void createImportControls(Composite parent, int ncol) {
    Group radioGroup = new Group(parent, SWT.NONE);
    radioGroup.setText("Import Type");
    GridLayout gl = new GridLayout();
    gl.numColumns = 3;//from   w w  w . ja v a 2  s. c  o m
    radioGroup.setLayout(gl);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.horizontalSpan = ncol;
    radioGroup.setLayoutData(gd);

    importFileRadio = new Button(radioGroup, SWT.RADIO | SWT.LEFT);
    gd = new GridData(GridData.BEGINNING);
    gd.horizontalSpan = 3;
    importFileRadio.setLayoutData(gd);
    importFileRadio.setSelection(true);
    importFileRadio.setText("From File");
    importFileRadio.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean selected = importFileRadio.getSelection();
            discoverRadio.setSelection(!selected);
            enableDiscoveryControls(!selected);
            enableFileControls(selected);
            handleFieldChanged();
        }
    });

    Label label = new Label(radioGroup, SWT.NONE);
    label.setText("Package File:");
    gd = new GridData(GridData.BEGINNING);
    gd.horizontalIndent = 25;
    label.setLayoutData(gd);

    filePathText = new Text(radioGroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 350;
    filePathText.setLayoutData(gd);
    filePathText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            handleFieldChanged();
        }
    });

    browseImportFileButton = new Button(radioGroup, SWT.PUSH);
    browseImportFileButton.setText("Browse...");
    browseImportFileButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            FileDialog dlg = new FileDialog(getShell());
            dlg.setFilterExtensions(new String[] { "*.json", "*.xml" });
            String res = dlg.open();
            if (res != null)
                filePathText.setText(res);
        }
    });

    discoverRadio = new Button(radioGroup, SWT.RADIO | SWT.LEFT);
    gd = new GridData(GridData.BEGINNING);
    gd.horizontalSpan = 3;
    discoverRadio.setLayoutData(gd);
    discoverRadio.setSelection(false);
    discoverRadio.setText("Discover");
    discoverRadio.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean selected = discoverRadio.getSelection();
            importFileRadio.setSelection(!selected);
            enableFileControls(!selected);
            enableDiscoveryControls(selected);
            handleFieldChanged();
        }
    });

    label = new Label(radioGroup, SWT.NONE);
    label.setText("Asset Discovery URL:");
    gd = new GridData(GridData.BEGINNING);
    gd.horizontalIndent = 25;
    label.setLayoutData(gd);

    discoveryUrlText = new Text(radioGroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 350;
    gd.horizontalSpan = 2;
    discoveryUrlText.setLayoutData(gd);
    String discUrl = MdwPlugin.getSettings().getDiscoveryUrl();
    discoveryUrlText.setText(discUrl.endsWith("/") ? discUrl + "Assets" : discUrl + "/assets");
    discoveryUrlText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            handleFieldChanged();
        }
    });

    createSpacer(radioGroup, 3);

    createSpacer(radioGroup, 1);
    latestVersionsCheckbox = new Button(radioGroup, SWT.CHECK | SWT.LEFT);
    gd = new GridData(GridData.BEGINNING);
    gd.horizontalSpan = 2;
    latestVersionsCheckbox.setLayoutData(gd);
    latestVersionsCheckbox.setText("Show only latest released versions");
    latestVersionsCheckbox.setSelection(true);

    new Label(radioGroup, SWT.NONE);
    Link link = new Link(radioGroup, SWT.SINGLE);
    link.setText(" Configure <A>Default Discovery base URL</A>");
    link.setLayoutData(new GridData(GridData.END));
    link.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(getShell(),
                    UrlsPreferencePage.PREF_PAGE_ID, null, null);
            if (pref != null) {
                pref.open();
                String discUrl = MdwPlugin.getSettings().getDiscoveryUrl();
                discoveryUrlText.setText(discUrl.endsWith("/") ? discUrl + "Assets" : discUrl + "/assets");
            }
        }
    });
}

From source file:com.cloudbees.eclipse.dev.ui.actions.ConfigureJenkinsInstancesAction.java

License:Open Source License

@Override
public void run() {
    PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(null,
            "com.cloudbees.eclipse.ui.preferences.JenkinsInstancesPreferencePage",
            new String[] { "com.cloudbees.eclipse.ui.preferences.JenkinsInstancesPreferencePage",
                    "com.cloudbees.eclipse.ui.internal.preferences.GeneralPreferencePage" },
            null);/*from w  ww.  j  a v  a 2s  .  c o  m*/
    if (pref != null) {
        pref.open();
    }
}