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.aerogear.hybrid.ui.internal.status.EngineStatusHandler.java

License:Open Source License

@Override
public Object handleStatus(IStatus status, Object source) throws CoreException {
    HybridMobileStatus hs = (HybridMobileStatus) status;

    boolean open = MessageDialog.openQuestion(AbstractStatusHandler.getShell(),
            "Missing or incomplete Hybrid Mobile Engine",
            NLS.bind("{0} \n\nWould you like to modify Hybrid Mobile Engine preferences to correct this issue?",
                    hs.getMessage()));//from  w  ww . j av  a2 s.  c  om

    if (open) {
        PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), hs.getProject(),
                EnginePropertyPage.PAGE_ID, new String[] { EnginePropertyPage.PAGE_ID }, null);
        return dialog.open() == Window.OK ? Boolean.TRUE : Boolean.FALSE;
    }
    return Boolean.FALSE;
}

From source file:org.jboss.tools.arquillian.ui.internal.refactoring.AddArquillianSupportWizardPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginWidth = 10;//www. j a  v  a2  s.  c  om
    gridLayout.marginHeight = 10;
    composite.setLayout(gridLayout);
    initializeDialogUnits(composite);
    Dialog.applyDialogFont(composite);

    Link link = new Link(composite, SWT.NONE);
    link.setText("<a>Arquillian Settings</a>");
    GridData gd = new GridData(SWT.FILL, GridData.FILL, true, false);
    gd.horizontalSpan = 2;
    link.setLayoutData(gd);
    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(getShell(),
                    ArquillianPreferencePage.ID, null, null);
            preferenceDialog.open();
        }

    });

    Label label = new Label(composite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    label.setLayoutData(gd);
    label.setText("Arquillian version:");
    versionCombo = new Combo(composite, SWT.READ_ONLY);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    versionCombo.setLayoutData(gd);
    versionCombo.setItems(ArquillianUtility.getVersions(defaultVersions));
    String value = ArquillianUtility.getPreference(ArquillianConstants.ARQUILLIAN_VERSION,
            ArquillianConstants.ARQUILLIAN_VERSION_DEFAULT);
    versionCombo.setText(value);
    refactoring.setVersion(value);
    versionCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    versionCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            refactoring.setVersion(versionCombo.getText());
            validate();
        }
    });

    updatePomButton = new Button(composite, SWT.CHECK);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    updatePomButton.setText("Update the pom.xml file");
    updatePomButton.setLayoutData(gd);

    dialogSettings = ArquillianUIActivator.getDefault().getDialogSettings();
    addArquillianSupportSection = dialogSettings.getSection(ADD_ARQUILLIAN_SUPPORT_SECTION);
    if (addArquillianSupportSection == null) {
        addArquillianSupportSection = dialogSettings.addNewSection(ADD_ARQUILLIAN_SUPPORT_SECTION);
    }
    value = addArquillianSupportSection.get(UPDATE_POM);
    boolean updatePom;
    if (value == null) {
        updatePom = true;
    } else {
        updatePom = addArquillianSupportSection.getBoolean(UPDATE_POM);
    }
    updatePomButton.setSelection(updatePom);

    updateDependenciesButton = new Button(composite, SWT.CHECK);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    updateDependenciesButton.setText("Update the dependencies section");
    updateDependenciesButton.setLayoutData(gd);

    value = addArquillianSupportSection.get(UPDATE_DEPENDENCIES);
    boolean updateDependencies;
    if (value == null) {
        updateDependencies = true;
    } else {
        updateDependencies = addArquillianSupportSection.getBoolean(UPDATE_DEPENDENCIES);
    }
    updateDependenciesButton.setSelection(updateDependencies);

    updateDependenciesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            refactoring.setUpdateDependencies(updateDependenciesButton.getSelection());
            validate();
        }

    });

    updateBuildButton = new Button(composite, SWT.CHECK);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    updateBuildButton.setText("Update the build section");
    updateBuildButton.setLayoutData(gd);

    value = addArquillianSupportSection.get(UPDATE_BUILD);
    boolean updateBuild;
    if (value == null) {
        updateBuild = true;
    } else {
        updateBuild = addArquillianSupportSection.getBoolean(UPDATE_BUILD);
    }
    updateBuildButton.setSelection(updateBuild);

    updateBuildButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            refactoring.setUpdateBuild(updateBuildButton.getSelection());
            validate();
        }

    });

    addProfilesButton = new Button(composite, SWT.CHECK);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    addProfilesButton.setText("Add Profiles");
    addProfilesButton.setLayoutData(gd);

    value = addArquillianSupportSection.get(ADD_PROFILES);
    boolean addProfiles;
    if (value == null) {
        addProfiles = true;
    } else {
        addProfiles = addArquillianSupportSection.getBoolean(ADD_PROFILES);
    }
    addProfilesButton.setSelection(addProfiles);

    addProfilesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            refactoring.setAddProfiles(addProfilesButton.getSelection());
            validate();
        }

    });

    updatePomButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updatePomChanged();
        }

    });
    String message = null;
    try {
        IProject project = refactoring.getProject();
        IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project,
                new NullProgressMonitor());
        if (facade != null) {
            MavenProject mavenProject = facade.getMavenProject(new NullProgressMonitor());
            String version = ArquillianUtility.getArquillianVersion(mavenProject);
            if (version != null) {
                updatePomButton.setSelection(false);
                updatePomButton.setEnabled(false);
                message = "The project already includes Arquillian settings";
            }
        } else {
            updatePomButton.setSelection(false);
            updatePomButton.setEnabled(false);
            message = "The project is not a valid maven project";
        }
    } catch (CoreException e1) {
        updatePomButton.setSelection(false);
        updatePomButton.setEnabled(false);
        message = "Some issues encountered.\nCaused by: " + e1.getLocalizedMessage();
    }
    if (message != null) {
        Composite warningComposite = new Composite(composite, SWT.NONE);
        gd = new GridData(SWT.FILL, SWT.FILL, true, false);
        gd.horizontalSpan = 2;
        warningComposite.setLayoutData(gd);
        warningComposite.setLayout(new GridLayout(2, false));
        Label emptyLabel = new Label(warningComposite, SWT.NONE);
        gd = new GridData(SWT.FILL, SWT.FILL, true, true);
        gd.horizontalSpan = 2;
        emptyLabel.setLayoutData(gd);
        Label warningImage = new Label(warningComposite, SWT.NONE);
        gd = new GridData(SWT.FILL, SWT.LEFT, false, false);
        warningImage.setLayoutData(gd);
        warningImage.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
        Label warningText = new Label(warningComposite, SWT.NONE);
        gd = new GridData(SWT.FILL, SWT.FILL, true, false);
        warningText.setLayoutData(gd);
        warningText.setText(message);
    }

    updatePomChanged();
    setControl(composite);
    validate();
}

From source file:org.jboss.tools.cdi.ui.internal.handlers.AddCDISupportHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    IProject project = null;//  w  ww.j  av a  2 s  .c  om
    Object element = ((IStructuredSelection) HandlerUtil.getCurrentSelection(event)).getFirstElement();
    if (element instanceof IProject) {
        project = (IProject) element;
    } else if (element instanceof IJavaProject) {
        project = ((IJavaProject) element).getProject();
    }
    if (project != null) {
        final PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), project,
                CDISettingsPreferencePage.ID, new String[] { CDISettingsPreferencePage.ID }, null);
        CDISettingsPreferencePage page = (CDISettingsPreferencePage) dialog.getSelectedPage();
        page.setEnabledCDISuport(shouldEnable());
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                if (dialog.getShell() != null && !dialog.getShell().isDisposed()) {
                    dialog.getTreeViewer().getControl().forceFocus();
                }
            }
        });
        dialog.open();
    }
    return null;
}

From source file:org.jboss.tools.cdi.ui.preferences.AddCDISupportAction.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,
            CDISettingsPreferencePage.ID, new String[] { CDISettingsPreferencePage.ID }, null);
    CDISettingsPreferencePage page = (CDISettingsPreferencePage) dialog.getSelectedPage();
    page.setEnabledCDISuport(shouldEnable());
    dialog.open();
}

From source file:org.jboss.tools.central.actions.AbstractPreferencesHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell, getPreferenceId(), null,
            null);/*from w ww  . ja  v  a2  s.c  o  m*/
    preferenceDialog.open();
    return null;
}

From source file:org.jboss.tools.common.jdt.debug.ui.launching.JBossConnectTab.java

License:Open Source License

public void createControl(Composite parent) {
    Font font = parent.getFont();
    Composite comp = SWTFactory.createComposite(parent, font, 1, 1, GridData.FILL_BOTH);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;/* www  .j ava  2 s.c o m*/
    comp.setLayout(layout);

    createVerticalSpacer(comp, 2);
    jbossConfigurationButton = createCheckButton(comp, "JBoss Remote Configuration");
    jbossConfigurationButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            setDirty(true);
            updateLaunchConfigurationDialog();
        }

    });
    createVerticalSpacer(comp, 2);
    messageGroup = new Group(comp, SWT.NONE);
    messageGroup.setText(Messages.JavaConnectTab_Warning);
    messageGroup.setLayout(new GridLayout(3, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    messageGroup.setLayoutData(gd);

    Label noteLabel = new Label(messageGroup, SWT.NONE);
    gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
    noteLabel.setLayoutData(gd);
    Image image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
    image.setBackground(noteLabel.getBackground());
    noteLabel.setImage(image);

    Text noteText = new Text(messageGroup, SWT.WRAP | SWT.READ_ONLY);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    GC gc = new GC(parent);
    gd.heightHint = Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), 3);
    gc.dispose();
    noteText.setLayoutData(gd);
    noteText.setText(Messages.JavaConnectTab_JDK_Required);

    messageGroup.setVisible(!RemoteDebugActivator.getDefault().isJdk());

    Button addJDK = new Button(messageGroup, SWT.PUSH);
    addJDK.setText(Messages.JavaConnectTab_Add_JDK);
    gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
    addJDK.setLayoutData(gd);
    addJDK.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String preferenceId = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; //$NON-NLS-1$
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), preferenceId, null,
                    null);
            dialog.open();
            updateLaunchConfigurationDialog();
            messageGroup.setVisible(!RemoteDebugActivator.getDefault().isJdk());
        }
    });

    setControl(comp);
}

From source file:org.jboss.tools.common.jdt.debug.ui.launching.LaunchRemoteApplicationDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.YES_ID) {
        //new LaunchDialogAction().run();
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        PreferenceDialog dialog = WorkbenchPreferenceDialog.createDialogOn(shell,
                RemoteDebugUIActivator.REMOTE_DEBUG_PREFERENCE_PAGE_ID);
        dialog.open();
        configureCombo();//w  w w.  j a v a 2s .  c  o m
    } else {
        super.buttonPressed(buttonId);
    }
}

From source file:org.jboss.tools.common.jdt.debug.ui.launching.xpl.JavaConnectTab.java

License:Open Source License

public void createControl(Composite parent) {
    Font font = parent.getFont();
    Composite comp = SWTFactory.createComposite(parent, font, 1, 1, GridData.FILL_BOTH);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;/*w w w . jav  a2s.  c o m*/
    comp.setLayout(layout);
    createProjectEditor(comp);
    createVerticalSpacer(comp, 1);

    //connection properties
    Group group = SWTFactory.createGroup(comp, Messages.JavaConnectTab_Connection_Properties_1, 2, 1,
            GridData.FILL_HORIZONTAL);
    Composite cgroup = SWTFactory.createComposite(group, font, 2, 1, GridData.FILL_HORIZONTAL);
    fArgumentComposite = cgroup;
    updateConnector();

    createVerticalSpacer(comp, 2);
    fAllowTerminateButton = createCheckButton(comp, Messages.JavaConnectTab__Allow_termination_of_remote_VM_6);
    fAllowTerminateButton.addSelectionListener(getDefaultListener());

    createVerticalSpacer(comp, 2);
    defaultButton = createCheckButton(comp, Messages.JavaConnectTab_SetAsDefault);
    defaultButton.addSelectionListener(getDefaultListener());

    createVerticalSpacer(comp, 2);
    messageGroup = new Group(comp, SWT.NONE);
    messageGroup.setText(Messages.JavaConnectTab_Warning);
    messageGroup.setLayout(new GridLayout(3, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    messageGroup.setLayoutData(gd);

    Label noteLabel = new Label(messageGroup, SWT.NONE);
    gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
    noteLabel.setLayoutData(gd);
    Image image = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
    image.setBackground(noteLabel.getBackground());
    noteLabel.setImage(image);

    Text noteText = new Text(messageGroup, SWT.WRAP | SWT.READ_ONLY);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    GC gc = new GC(parent);
    gd.heightHint = Dialog.convertHeightInCharsToPixels(gc.getFontMetrics(), 3);
    gc.dispose();
    noteText.setLayoutData(gd);
    noteText.setText(Messages.JavaConnectTab_JDK_Required);

    messageGroup.setVisible(!RemoteDebugActivator.getDefault().isJdk());

    Button addJDK = new Button(messageGroup, SWT.PUSH);
    addJDK.setText(Messages.JavaConnectTab_Add_JDK);
    gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
    addJDK.setLayoutData(gd);
    addJDK.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String preferenceId = "org.eclipse.jdt.debug.ui.preferences.VMPreferencePage"; //$NON-NLS-1$
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), preferenceId, null,
                    null);
            dialog.open();
            refresh(hostCombo.getText(), false);
            updateLaunchConfigurationDialog();
            messageGroup.setVisible(!RemoteDebugActivator.getDefault().isJdk());
        }
    });

    setControl(comp);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
            IJavaDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_CONNECT_TAB);
}

From source file:org.jboss.tools.common.ui.ssh.SshPrivateKeysPreferences.java

License:Open Source License

public static void openPreferencesPage(Shell shell) {
    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, SSH_PREFERENCE_PAGE_ID,
            new String[] {}, null);
    dialog.open();
}

From source file:org.jboss.tools.common.verification.ui.vrules.preferences.test.VerificationPreferencePageTest.java

License:Open Source License

@Ignore
@Test/*from   w  ww .  j  a va 2s  . com*/
public void _testShowVerificationPreferencePage() {

    doDefaultTest(ID, VerificationPreferencePage.class);

    PreferenceDialog dialog = null;
    try {
        dialog = WorkbenchUtils.createPreferenceDialog(ID);
        dialog.open();
        VerificationPreferencePage page = (VerificationPreferencePage) dialog.getSelectedPage();
        TabFolder tabs = (TabFolder) SwtUtils.findControlByClass((Composite) page.getControl(),
                TabFolder.class);
        tabs.setSelection(0);
        tabs.setSelection(1);
    } finally {
        dialog.close();
    }
}