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

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

Introduction

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

Prototype

@Override
public Shell getShell() 

Source Link

Document

Returns this window's shell.

Usage

From source file:org.eclipse.pde.internal.runtime.spy.sections.ActiveHelpSection.java

License:Open Source License

public void build(ScrolledForm form, SpyFormToolkit toolkit, ExecutionEvent event) {
    this.toolkit = toolkit;
    final Shell shell = HandlerUtil.getActiveShell(event);
    Object object = shell.getData();
    if (object == null)
        return;/*  w ww.j a  va  2 s  .  com*/

    StringBuffer helpBuffer = new StringBuffer();
    // process help
    // TODO we need to make this cleaner... help processing is complicated atm
    if (object instanceof PreferenceDialog) {
        PreferenceDialog dialog = (PreferenceDialog) object;
        IPreferencePage page = (IPreferencePage) dialog.getSelectedPage();
        processHelp(page.getControl().getShell(), helpBuffer);
        processChildren(page.getControl(), helpBuffer);
    } else if (object instanceof Dialog) {
        Dialog dialog = (Dialog) object;
        processChildren(dialog.getShell(), helpBuffer);
    } else {
        helpBuffer.append(processControlHelp(event, toolkit));
    }

    if (helpBuffer != null && helpBuffer.length() > 0) {
        Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR);
        section.setText(PDERuntimeMessages.SpyDialog_activeHelpSection_title);
        section.clientVerticalSpacing = 9;

        FormText text = toolkit.createFormText(section, true);
        section.setClient(text);
        TableWrapData td = new TableWrapData();
        td.align = TableWrapData.FILL;
        td.grabHorizontal = true;
        section.setLayoutData(td);

        Image image = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_CONTEXTID_OBJ);
        text.setImage("contextid", image); //$NON-NLS-1$

        StringBuffer buffer = new StringBuffer();
        buffer.append("<form>"); //$NON-NLS-1$
        buffer.append("<p>"); //$NON-NLS-1$
        buffer.append(PDERuntimeMessages.SpyDialog_activeHelpSection_desc);
        buffer.append("</p>"); //$NON-NLS-1$
        buffer.append(helpBuffer.toString());
        buffer.append("</form>"); //$NON-NLS-1$
        String content = buffer.toString().replaceAll("&", "&amp;"); //$NON-NLS-1$ //$NON-NLS-2$
        text.setText(content, true, false);
    }

}

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;//from  www.  j  ava2 s. c o m
    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.project.examples.model.ProjectFix.java

License:Open Source License

public void fix() {
    if (SEAM_RUNTIME.equals(type)) {
        Shell shell = getShell();//  w  w w . j  a v  a  2 s.  c om
        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, SEAM_PREFERENCES_ID, null,
                null);
        if (dialog != null) {
            dialog.open();
        }
    }
    if (WTP_RUNTIME.equals(type)) {
        Shell shell = getShell();
        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, WTP_PREFERENCES_ID, null,
                null);
        if (dialog != null) {
            dialog.open();
        }
    }
    if (PLUGIN_TYPE.equals(type)) {

        ProvisioningUI ui = ProvisioningUI.getDefaultUI();
        InstallWizard wizard = new InstallWizard(ui, null, null, null);
        WizardDialog dialog = new ProvisioningWizardDialog(getShell(), wizard);
        dialog.create();
        PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(),
                IProvHelpContextIds.INSTALL_WIZARD);
        dialog.open();

    }
}

From source file:org.jboss.tools.vpe.editor.preferences.VpeEditorPreferencesPage.java

License:Open Source License

public static void openPreferenceDialog() {

    PreferenceDialog prefsdlg = PreferencesUtil.createPreferenceDialogOn(
            PlatformUI.getWorkbench().getDisplay().getActiveShell(), ID, new String[] { ID }, null);
    /*//www .  j a v a2s.co  m
     * https://jira.jboss.org/jira/browse/JBIDE-4975 
     * Setting up the correct preference page size. 
     * Without specifying any preferred size 
     * the default constrained Shell bounds are used, 
     * which are not always optimal.
     */
    prefsdlg.getShell().setSize(prefsdlg.getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
    prefsdlg.open();
}

From source file:org.swtchart.ext.InteractiveChart.java

License:Apache License

/**
 * Opens the properties dialog.//from  w  w w.  j ava  2  s.  com
 */
private void openPropertiesDialog() {
    PreferenceManager manager = new PreferenceManager();

    final String chartTitle = "Chart";
    PreferenceNode chartNode = new PreferenceNode(chartTitle);
    chartNode.setPage(new ChartPage(this, resources, chartTitle));
    manager.addToRoot(chartNode);

    final String legendTitle = "Legend";
    PreferenceNode legendNode = new PreferenceNode(legendTitle);
    legendNode.setPage(new LegendPage(this, resources, legendTitle));
    manager.addTo(chartTitle, legendNode);

    final String xAxisTitle = "X Axis";
    PreferenceNode xAxisNode = new PreferenceNode(xAxisTitle);
    xAxisNode.setPage(new AxisPage(this, resources, Direction.X, xAxisTitle));
    manager.addTo(chartTitle, xAxisNode);

    final String gridTitle = "Grid";
    PreferenceNode xGridNode = new PreferenceNode(gridTitle);
    xGridNode.setPage(new GridPage(this, resources, Direction.X, gridTitle));
    manager.addTo(chartTitle + "." + xAxisTitle, xGridNode);

    final String tickTitle = "Tick";
    PreferenceNode xTickNode = new PreferenceNode(tickTitle);
    xTickNode.setPage(new AxisTickPage(this, resources, Direction.X, tickTitle));
    manager.addTo(chartTitle + "." + xAxisTitle, xTickNode);

    final String yAxisTitle = "Y Axis";
    PreferenceNode yAxisNode = new PreferenceNode(yAxisTitle);
    yAxisNode.setPage(new AxisPage(this, resources, Direction.Y, yAxisTitle));
    manager.addTo(chartTitle, yAxisNode);

    PreferenceNode yGridNode = new PreferenceNode(gridTitle);
    yGridNode.setPage(new GridPage(this, resources, Direction.Y, gridTitle));
    manager.addTo(chartTitle + "." + yAxisTitle, yGridNode);

    PreferenceNode yTickNode = new PreferenceNode(tickTitle);
    yTickNode.setPage(new AxisTickPage(this, resources, Direction.Y, tickTitle));
    manager.addTo(chartTitle + "." + yAxisTitle, yTickNode);

    final String seriesTitle = "Series";
    PreferenceNode plotNode = new PreferenceNode(seriesTitle);
    plotNode.setPage(new SeriesPage(this, resources, seriesTitle));
    manager.addTo(chartTitle, plotNode);

    final String labelTitle = "Label";
    PreferenceNode labelNode = new PreferenceNode(labelTitle);
    labelNode.setPage(new SeriesLabelPage(this, resources, labelTitle));
    manager.addTo(chartTitle + "." + seriesTitle, labelNode);

    PreferenceDialog dialog = new PreferenceDialog(getShell(), manager);
    dialog.create();
    dialog.getShell().setText("Properties");
    dialog.getTreeViewer().expandAll();
    dialog.open();
}

From source file:org.talend.repository.ui.dialog.ProjectSettingDialog.java

License:Open Source License

public void open(final String pageId) {
    PreferenceManager manager = getNodeManager();
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    final PreferenceDialog dialog = new ProjectSettingsPreferenceDialog(shell, manager);
    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

        @Override/*w ww  .  ja va 2s . c o  m*/
        public void run() {
            if (StringUtils.isNotEmpty(pageId)) {
                dialog.setSelectedNode(pageId);
            }
            dialog.create();
            dialog.getShell().setText(TITLE);
            dialog.getShell().setSize(DEFAULT_SIZE);
            dialog.open();
        }
    });
}