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:org.jboss.tools.feedhenry.ui.internal.FHErrorHandler.java

License:Open Source License

private static boolean displayPreferences(String title, String message) {
    Shell shell = getActiveShell();//from   ww w . j a  v  a  2  s  .c o  m
    boolean define = MessageDialog.openQuestion(shell, title, message);
    if (define) {
        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell,
                FHPreferenceConstants.PREFERENCES_PAGE_ID, null, null);
        dialog.open();
        return true;
    }
    return false;

}

From source file:org.jboss.tools.internal.deltacloud.ui.wizards.NewInstancePage.java

License:Open Source License

private Composite createWidgets(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(container);

    Label nameLabel = new Label(container, SWT.NULL);
    nameLabel.setText(WizardMessages.getString(NAME_LABEL));
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
    this.nameText = new Text(container, SWT.BORDER | SWT.SINGLE);
    UIUtils.createPreferencesProposalAdapter(nameText,
            IDeltaCloudPreferenceConstants.INSTANCE_NAME_PROPOSAL_KEY);
    GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(nameText);

    Label imageLabel = new Label(container, SWT.NULL);
    imageLabel.setText(WizardMessages.getString(IMAGE_LABEL));
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(imageLabel);
    this.imageText = new Text(container, SWT.BORDER | SWT.SINGLE);
    UIUtils.createPreferencesProposalAdapter(imageText,
            IDeltaCloudPreferenceConstants.INSTANCE_IMAGE_PROPOSAL_KEY);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(imageText);
    Button findImageButton = new Button(container, SWT.NULL);
    findImageButton.setText(WizardMessages.getString(FIND_BUTTON_LABEL));
    findImageButton.addSelectionListener(findImageButtonListener);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(findImageButton);

    Label archLabel = new Label(container, SWT.NULL);
    archLabel.setText(WizardMessages.getString(ARCH_LABEL));
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(archLabel);
    arch = new Label(container, SWT.NULL);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(arch);

    Label realmLabel = new Label(container, SWT.NULL);
    realmLabel.setText(WizardMessages.getString(REALM_LABEL));
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(realmLabel);
    this.realmCombo = new Combo(container, SWT.BORDER | SWT.READ_ONLY);
    realmCombo.setItems(new String[] { WizardMessages.getString(LOADING_VALUE) });
    realmCombo.select(0);//  w w  w. j av  a2  s. com
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(realmCombo);

    Label keyLabel = new Label(container, SWT.NULL);
    keyLabel.setText(WizardMessages.getString(KEY_LABEL));
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(keyLabel);
    keyText = new Text(container, SWT.BORDER | SWT.SINGLE);
    UIUtils.createPreferencesProposalAdapter(keyText, IDeltaCloudPreferenceConstants.INSTANCE_KEY_PROPOSAL_KEY);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(keyText);
    Button keyManageButton = new Button(container, SWT.NULL);
    keyManageButton.setText(WizardMessages.getString(MANAGE_BUTTON_LABEL));
    keyManageButton.addSelectionListener(manageListener);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(keyManageButton);

    Label dummyLabel = new Label(container, SWT.NULL);
    dummyLabel.setVisible(false);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(dummyLabel);

    Link sshPrefsLink = new Link(container, SWT.NULL);
    sshPrefsLink.setText(WizardMessages.getString(SHOW_SSH2_PREFS));
    sshPrefsLink.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(event.display.getActiveShell(),
                    SSH_PREFERENCE_PAGE_ID, null, null);
            dialog.open();
        }
    });
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).applyTo(sshPrefsLink);

    Label hardwareLabel = new Label(container, SWT.NULL);
    hardwareLabel.setText(WizardMessages.getString(HARDWARE_LABEL));
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(hardwareLabel);
    this.hardwareCombo = new Combo(container, SWT.READ_ONLY);
    hardwareCombo.setItems(new String[] { WizardMessages.getString(LOADING_VALUE) });
    hardwareCombo.select(0);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(hardwareCombo);

    this.groupContainer = new Group(container, SWT.BORDER);
    groupContainer.setText(WizardMessages.getString(PROPERTIES_LABEL));
    GridDataFactory.fillDefaults().span(3, 5).hint(SWT.DEFAULT, 100).applyTo(groupContainer);
    groupContainer.setLayout(this.groupContainerStackLayout = new StackLayout());

    return container;
}

From source file:org.jboss.tools.jsf.ui.action.AddJSFNatureActionDelegate.java

License:Open Source License

/**
 * Convenience method that adds JBoss Tools JSF nature to the project.
 * These are the limitations for the use of the method.
 * 1) It should be run from UI thread./*from w w  w .ja  v  a2s.co  m*/
 * 2) It should be run on a faceted project.
 * 
 * @param project
 * @param showDialog
 */
public static void addJSFNature(IProject project, boolean showDialog) {
    try {
        IFacetedProject fp = ProjectFacetsManager.create(project);
        IFacetedProjectWorkingCopy wc = SharedWorkingCopyManager.getWorkingCopy(fp);

        Set<IProjectFacetVersion> vs = wc.getProjectFacets();
        IProjectFacetVersion web = null;
        IProjectFacetVersion jsf = null;
        for (IProjectFacetVersion v : vs) {
            String id = v.getProjectFacet().getId();
            if ("jst.web".equals(id)) { //$NON-NLS-1$
                web = v;
            } else if ("jst.jsf".equals(id)) { //$NON-NLS-1$
                jsf = v;
            }
        }

        if (web != null && jsf != null && wc.validate().isOK()) {
            WebModelPlugin.addNatureToProjectWithValidationSupport(project, KbBuilder.BUILDER_ID,
                    KbProject.NATURE_ID);
            EclipseResourceUtil.addNatureToProject(project, JSFNature.NATURE_ID);
            SharedWorkingCopyManager.releaseWorkingCopy(fp);
            return;
        }

        if (web == null) {
            web = ProjectFacetsManager.getProjectFacet("jst.web").getLatestVersion(); //$NON-NLS-1$
            wc.addProjectFacet(web);
        }
        String webVersion = web.getVersionString();
        if ("2.2".equals(webVersion)) { //$NON-NLS-1$
            web = ProjectFacetsManager.getProjectFacet("jst.web").getVersion("2.3"); //$NON-NLS-1$ //$NON-NLS-2$
            wc.changeProjectFacetVersion(web);
            webVersion = web.getVersionString();
        }
        if (jsf == null) {
            jsf = ProjectFacetsManager.getProjectFacet("jst.jsf").getLatestVersion(); //$NON-NLS-1$
            if ("2.3".equals(webVersion) || "2.4".equals(webVersion)) { //$NON-NLS-1$ //$NON-NLS-2$
                jsf = ProjectFacetsManager.getProjectFacet("jst.jsf").getVersion("1.1"); //$NON-NLS-1$ //$NON-NLS-2$
            }
            wc.addProjectFacet(jsf);
        }

        if (!showDialog) {
            wc.commitChanges(new NullProgressMonitor());
        } else {
            PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), project,
                    FacetsPropertyPage.ID, new String[] { FacetsPropertyPage.ID }, null);
            dialog.open();
        }

        SharedWorkingCopyManager.releaseWorkingCopy(fp);
    } catch (CoreException e) {
        JsfUiPlugin.getDefault().logError(e);
    }

}

From source file:org.jboss.tools.jsf.ui.internal.handlers.AddJSFNatureHandler.java

License:Open Source License

/**
 * Convenience method that adds JBoss Tools JSF nature to the project.
 * These are the limitations for the use of the method.
 * 1) It should be run from UI thread.// w ww  .  j  a v a2  s  .  com
 * 2) It should be run on a faceted project.
 * 
 * @param project
 * @param showDialog
 */
public static void addJSFNature(IProject project, boolean showDialog) {
    IFacetedProject fp = null;
    try {
        fp = ProjectFacetsManager.create(project);
        IFacetedProjectWorkingCopy wc = SharedWorkingCopyManager.getWorkingCopy(fp);
        Set<IProjectFacetVersion> vs = wc.getProjectFacets();

        IProjectFacetVersion web = null;
        IProjectFacetVersion jsf = null;

        for (IProjectFacetVersion v : vs) {
            String id = v.getProjectFacet().getId();
            if ("jst.web".equals(id)) { //$NON-NLS-1$
                web = v;
            } else if ("jst.jsf".equals(id)) { //$NON-NLS-1$
                jsf = v;
            }
        }

        if (web != null && jsf != null && wc.validate().isOK()) {
            WebModelPlugin.addNatureToProjectWithValidationSupport(project, KbBuilder.BUILDER_ID,
                    KbProject.NATURE_ID);
            EclipseResourceUtil.addNatureToProject(project, JSFNature.NATURE_ID);
            return;
        }

        if (web == null) {
            web = ProjectFacetsManager.getProjectFacet("jst.web").getLatestVersion(); //$NON-NLS-1$
            wc.addProjectFacet(web);
        }

        String webVersion = web.getVersionString();
        if ("2.2".equals(webVersion)) { //$NON-NLS-1$
            web = ProjectFacetsManager.getProjectFacet("jst.web").getVersion("2.3"); //$NON-NLS-1$ //$NON-NLS-2$
            wc.changeProjectFacetVersion(web);
            webVersion = web.getVersionString();
        }
        if (jsf == null) {
            jsf = ProjectFacetsManager.getProjectFacet("jst.jsf").getLatestVersion(); //$NON-NLS-1$
            if ("2.3".equals(webVersion) || "2.4".equals(webVersion)) { //$NON-NLS-1$ //$NON-NLS-2$
                jsf = ProjectFacetsManager.getProjectFacet("jst.jsf").getVersion("1.1"); //$NON-NLS-1$ //$NON-NLS-2$
            }
            wc.addProjectFacet(jsf);
        }

        if (!showDialog) {
            IProjectFacetVersion latestJava = ProjectFacetsManager.getProjectFacet("java").getLatestVersion(); //$NON-NLS-1$
            wc.changeProjectFacetVersion(latestJava);

            wc.commitChanges(new NullProgressMonitor());
        } else {
            PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), project,
                    FacetsPropertyPage.ID, new String[] { FacetsPropertyPage.ID }, null);
            dialog.open();
        }
    } catch (CoreException e) {
        JsfUiPlugin.getDefault().logError(e);
    } finally {
        if (fp != null) {
            SharedWorkingCopyManager.releaseWorkingCopy(fp);
        }
    }
}

From source file:org.jboss.tools.jst.web.kb.preferences.AddKBSupportAction.java

License:Open Source License

public void run(IAction action) {
    IProject project = (IProject) ((IStructuredSelection) currentSelection).getFirstElement();
    PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), project,
            KBSettingsPreferencePage.ID, new String[] { KBSettingsPreferencePage.ID }, null);
    KBSettingsPreferencePage page = (KBSettingsPreferencePage) dialog.getSelectedPage();
    page.setEnabledKBSuport(shouldEnable());
    dialog.open();
}

From source file:org.jboss.tools.jst.web.ui.palette.html.jquery.wizard.JQueryVersionPage.java

License:Open Source License

private void createReference(Composite parent) {
    StyledText text = new StyledText(parent, 0);
    text.setBackground(parent.getBackground());
    text.setText(WizardMessages.configureJSCSSLabel);
    text.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND));
    GridData d = new GridData();
    d.horizontalSpan = 3;//from ww  w  .ja  v a2s . c om
    text.setLayoutData(d);

    StyleRange range = new StyleRange();
    range.start = 0;
    range.length = text.getText().length();
    range.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
    range.background = parent.getBackground();
    range.underline = true;
    text.setStyleRanges(new StyleRange[] { range });
    text.addMouseListener(new MouseAdapter() {
        public void mouseUp(MouseEvent e) {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
                    Display.getDefault().getActiveShell(), JSCSSPreferencePage.ID,
                    new String[] { JSCSSPreferencePage.ID }, null);
            int result = dialog.open();
            if (result == Window.OK) {
                reloadFields();
            }
        }
    });
}

From source file:org.jboss.tools.jst.web.ui.palette.html.wizard.VersionPage.java

License:Open Source License

protected void createReference(Composite parent) {
    StyledText text = new StyledText(parent, 0);
    text.setBackground(parent.getBackground());
    text.setText(WizardMessages.configureJSCSSLabel);
    text.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND));
    GridData d = new GridData();
    d.horizontalSpan = 3;/*from  w  w  w .  java  2  s  .co m*/
    text.setLayoutData(d);

    StyleRange range = new StyleRange();
    range.start = 0;
    range.length = text.getText().length();
    range.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
    range.background = parent.getBackground();
    range.underline = true;
    text.setStyleRanges(new StyleRange[] { range });
    text.addMouseListener(new MouseAdapter() {
        public void mouseUp(MouseEvent e) {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
                    Display.getDefault().getActiveShell(), JSCSSPreferencePage.ID,
                    new String[] { JSCSSPreferencePage.ID }, null);
            int result = dialog.open();
            if (result == Window.OK) {
                reloadFields();
            }
        }
    });
}

From source file:org.jboss.tools.jst.web.ui.test.ConfigurationBlockTest.java

License:Open Source License

public void testFilter() {
    String preferencePageId = WebXMLValidatorPreferencePage.PREF_ID;
    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(WebUiPlugin.getShell(), preferencePageId,
            new String[] { preferencePageId }, WebXMLPreferences.INVALID_ROLE_REF);
    Object selectedPage = dialog.getSelectedPage();
    assertTrue(selectedPage instanceof SeverityPreferencePage);
    SeverityPreferencePage page = (SeverityPreferencePage) selectedPage;
    assertEquals(WebXMLPreferencesMessages.WebXMLValidatorConfigurationBlock_pb_invalidRoleRef_label,
            page.getFilterText());//from   www  . j a  va 2  s . c  om

    dialog.setBlockOnOpen(false);
    dialog.open();
    dialog.close();
}

From source file:org.jboss.tools.openshift.express.internal.ui.utils.SSHUtils.java

License:Open Source License

public static int openPreferencesPage(Shell shell) {
    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, SSH_PREFERENCE_PAGE_ID, null,
            null);/*from  w  w w. ja  va  2s.c  o m*/
    return dialog.open();
}

From source file:org.jboss.tools.project.examples.cheatsheet.actions.OpenPreferencePage.java

License:Open Source License

/**
 * Execution of the action//from  w  w w .  ja  v  a2 s  .  co  m
 * 
 * @param params
 *            Array of parameters
 *            index 0: preferences page id
 * @param manager
 *            Cheatsheet Manager
 */
public void run(String[] params, ICheatSheetManager manager) {
    if (params == null || params[0] == null) {
        return;
    }
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    PreferenceDialog dialog = WorkbenchPreferenceDialog.createDialogOn(shell, params[0]);
    dialog.open();
}