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.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);
    /*// w  ww . j a  v  a2 s  .  c  o  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.jboss.tools.ws.ui.test.preferences.JBossWSRuntimePreferencePageTest.java

License:Open Source License

private Object openPreferencepage(PreferenceDialog prefDialog) {
    prefDialog.setBlockOnOpen(false);
    prefDialog.open();
    return prefDialog.getSelectedPage();
}

From source file:org.jcryptool.crypto.xml.ui.dialogs.MissingPreferenceDialog.java

License:Open Source License

/**
 * Opens the preferences with the node selected given by the target parameter. If the preferences
 * are closed by clicking on the OK button this dialog will disappear and the needed preference
 * values will be verified again.//from  w  w  w .ja v a2 s  .co  m
 */
private void openPreferencePage() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    PreferenceManager pm = workbench.getPreferenceManager();
    if (pm != null) {
        PreferenceDialog d = new PreferenceDialog(workbench.getActiveWorkbenchWindow().getShell(), pm);
        d.setSelectedNode(target);
        d.create();

        if (d.open() == Window.OK) {
            close();
        }
    }
}

From source file:org.jkiss.dbeaver.data.office.export.StreamPOIConsumerPageSettings.java

License:Apache License

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);/*from w w w .  j a  v a 2  s  . c  o m*/
    final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    composite.setLayout(gl);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    {
        Group generalSettings = new Group(composite, SWT.NONE);
        generalSettings.setText(CoreMessages.data_transfer_wizard_settings_group_general);
        gl = new GridLayout(4, false);
        generalSettings.setLayout(gl);
        generalSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        {
            Composite formattingGroup = UIUtils.createPlaceholder(generalSettings, 3);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = 4;
            formattingGroup.setLayoutData(gd);

            UIUtils.createControlLabel(formattingGroup,
                    CoreMessages.data_transfer_wizard_settings_label_formatting);
            formatProfilesCombo = new Combo(formattingGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
            gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            gd.widthHint = 200;
            formatProfilesCombo.setLayoutData(gd);
            formatProfilesCombo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (formatProfilesCombo.getSelectionIndex() > 0) {
                        settings.setFormatterProfile(DataFormatterRegistry.getInstance()
                                .getCustomProfile(UIUtils.getComboSelection(formatProfilesCombo)));
                    } else {
                        settings.setFormatterProfile(null);
                    }
                }
            });

            Button profilesManageButton = new Button(formattingGroup, SWT.PUSH);
            profilesManageButton.setText(CoreMessages.data_transfer_wizard_settings_button_edit);
            profilesManageButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    PreferenceDialog propDialog = PreferencesUtil.createPropertyDialogOn(getShell(),
                            DataFormatterRegistry.getInstance(), PrefPageDataFormat.PAGE_ID, null,
                            getSelectedFormatterProfile(), PreferencesUtil.OPTION_NONE);
                    if (propDialog != null) {
                        propDialog.open();
                        reloadFormatProfiles();
                    }
                }
            });

            reloadFormatProfiles();
        }
    }

    Group exporterSettings = new Group(composite, SWT.NONE);
    exporterSettings.setText(CoreMessages.data_transfer_wizard_settings_group_exporter);
    exporterSettings.setLayoutData(new GridData(GridData.FILL_BOTH));
    exporterSettings.setLayout(new GridLayout(1, false));

    propsEditor = new PropertyTreeViewer(exporterSettings, SWT.BORDER);

    setControl(composite);
}

From source file:org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerPageSettings.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);//from w w  w .jav  a2s .c om
    final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout gl = new GridLayout();
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    composite.setLayout(gl);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    {
        Group generalSettings = new Group(composite, SWT.NONE);
        generalSettings.setText(CoreMessages.data_transfer_wizard_settings_group_general);
        gl = new GridLayout(4, false);
        generalSettings.setLayout(gl);
        generalSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        {
            Composite formattingGroup = UIUtils.createPlaceholder(generalSettings, 3);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = 4;
            formattingGroup.setLayoutData(gd);

            UIUtils.createControlLabel(formattingGroup,
                    CoreMessages.data_transfer_wizard_settings_label_formatting);
            formatProfilesCombo = new Combo(formattingGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
            gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            gd.widthHint = 200;
            formatProfilesCombo.setLayoutData(gd);
            formatProfilesCombo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (formatProfilesCombo.getSelectionIndex() > 0) {
                        settings.setFormatterProfile(DataFormatterRegistry.getInstance()
                                .getCustomProfile(UIUtils.getComboSelection(formatProfilesCombo)));
                    } else {
                        settings.setFormatterProfile(null);
                    }
                }
            });

            Button profilesManageButton = new Button(formattingGroup, SWT.PUSH);
            profilesManageButton.setText(CoreMessages.data_transfer_wizard_settings_button_edit);
            profilesManageButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    //DataFormatProfilesEditDialog dialog = new DataFormatProfilesEditDialog(getShell());
                    //dialog.open();
                    PreferenceDialog propDialog = PreferencesUtil.createPropertyDialogOn(getShell(),
                            DataFormatterRegistry.getInstance(), PrefPageDataFormat.PAGE_ID, null,
                            getSelectedFormatterProfile(), PreferencesUtil.OPTION_NONE);
                    if (propDialog != null) {
                        propDialog.open();
                        reloadFormatProfiles();
                    }
                }
            });

            reloadFormatProfiles();
        }
        {
            UIUtils.createControlLabel(generalSettings,
                    CoreMessages.data_transfer_wizard_settings_label_binaries);
            lobExtractType = new Combo(generalSettings, SWT.DROP_DOWN | SWT.READ_ONLY);
            lobExtractType.setItems(
                    new String[] { CoreMessages.data_transfer_wizard_settings_binaries_item_set_to_null,
                            CoreMessages.data_transfer_wizard_settings_binaries_item_save_to_file,
                            CoreMessages.data_transfer_wizard_settings_binaries_item_inline });
            lobExtractType.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch (lobExtractType.getSelectionIndex()) {
                    case EXTRACT_LOB_SKIP:
                        settings.setLobExtractType(StreamConsumerSettings.LobExtractType.SKIP);
                        break;
                    case EXTRACT_LOB_FILES:
                        settings.setLobExtractType(StreamConsumerSettings.LobExtractType.FILES);
                        break;
                    case EXTRACT_LOB_INLINE:
                        settings.setLobExtractType(StreamConsumerSettings.LobExtractType.INLINE);
                        break;
                    }
                    updatePageCompletion();
                }
            });

            lobEncodingLabel = UIUtils.createControlLabel(generalSettings,
                    CoreMessages.data_transfer_wizard_settings_label_encoding);
            lobEncodingCombo = new Combo(generalSettings, SWT.DROP_DOWN | SWT.READ_ONLY);
            lobEncodingCombo.setItems(new String[] { "Base64", //$NON-NLS-1$
                    "Hex", //$NON-NLS-1$
                    "Binary" }); //$NON-NLS-1$
            lobEncodingCombo.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch (lobEncodingCombo.getSelectionIndex()) {
                    case LOB_ENCODING_BASE64:
                        settings.setLobEncoding(StreamConsumerSettings.LobEncoding.BASE64);
                        break;
                    case LOB_ENCODING_HEX:
                        settings.setLobEncoding(StreamConsumerSettings.LobEncoding.HEX);
                        break;
                    case LOB_ENCODING_BINARY:
                        settings.setLobEncoding(StreamConsumerSettings.LobEncoding.BINARY);
                        break;
                    }
                }
            });
        }
    }

    Group exporterSettings = new Group(composite, SWT.NONE);
    exporterSettings.setText(CoreMessages.data_transfer_wizard_settings_group_exporter);
    exporterSettings.setLayoutData(new GridData(GridData.FILL_BOTH));
    exporterSettings.setLayout(new GridLayout(1, false));

    propsEditor = new PropertyTreeViewer(exporterSettings, SWT.BORDER);

    setControl(composite);
}

From source file:org.jkiss.dbeaver.ui.preferences.TargetPrefPage.java

License:Open Source License

private void doLinkActivated(Link link) {
    PreferenceDialog prefDialog = null;
    if (isDataSourcePreferencePage()) {
        // Show global settings
        prefDialog = PreferencesUtil.createPreferenceDialogOn(getShell(), getPropertyPageID(), null, //new String[]{getPropertyPageID()},
                null);//ww  w  . j  a  v a2  s .c  o m
    } else if (supportsDataSourceSpecificOptions()) {
        // Select datasource
        DBPDataSourceContainer dataSource = SelectDataSourceDialog.selectDataSource(getShell());
        if (dataSource != null) {
            DBNNode dsNode = DBeaverCore.getInstance().getNavigatorModel().getNodeByObject(dataSource);
            if (dsNode instanceof DBNDataSource) {
                prefDialog = PreferencesUtil.createPropertyDialogOn(getShell(), (DBNDataSource) dsNode,
                        getPropertyPageID(), null, //new String[]{getPropertyPageID()},
                        null);
            }
        }
    }
    if (prefDialog != null) {

        prefDialog.open();
    }
}

From source file:org.jkiss.dbeaver.ui.UIUtils.java

License:Open Source License

public static void showPreferencesFor(Shell shell, Object element, String defPageID) {
    PreferenceDialog propDialog;
    if (element == null) {
        propDialog = PreferencesUtil.createPreferenceDialogOn(shell, defPageID, new String[] { defPageID },
                null, PreferencesUtil.OPTION_NONE);
    } else {/*w w  w . j  av  a  2s.  c  o  m*/
        propDialog = PreferencesUtil.createPropertyDialogOn(shell, element, defPageID, null, null,
                PreferencesUtil.OPTION_NONE);
    }
    if (propDialog != null) {
        propDialog.open();
    }
}

From source file:org.jlibrary.client.preferences.actions.PreferencesAction.java

License:Open Source License

public void run() {

    logger.info("Showing preferences dialog");

    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();

    final PreferenceDialog dialog = new PreferenceDialog(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), manager);

    BusyIndicator.showWhile(PlatformUI.getWorkbench().getDisplay(), new Runnable() {
        public void run() {

            dialog.create();/*from  w w w .  j  a  v a2s .c om*/
            dialog.open();
        }
    });

}

From source file:org.jsweet.plugin.preferences.FieldEditorProjectPreferencePage.java

License:Apache License

private void configureWorkspaceSettings() {
    String preferenceNodeId = this.getPreferenceNodeId();
    IPreferencePage preferencePage = newPreferencePage();
    final IPreferenceNode preferenceNode = new PreferenceNode(preferenceNodeId, preferencePage);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(preferenceNode);//from   w w  w .ja  v a 2s.  c o  m
    final PreferenceDialog dialog = new PreferenceDialog(this.getControl().getShell(), manager);
    BusyIndicator.showWhile(this.getControl().getDisplay(), new Runnable() {
        @Override
        public void run() {
            dialog.create();
            dialog.setMessage(preferenceNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:org.kalypso.ogc.gml.outline.handler.NodePropertiesHandler.java

License:Open Source License

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IEvaluationContext context = (IEvaluationContext) event.getApplicationContext();
    final Shell shell = (Shell) context.getVariable(ISources.ACTIVE_SHELL_NAME);
    final ISelection selection = (ISelection) context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
    final IThemeNode[] selectedNodes = MapHandlerUtils.getSelectedNodes(selection);

    if (selectedNodes.length != 1)
        throw new ExecutionException("Empty selection"); //$NON-NLS-1$

    final PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(shell, selectedNodes[0], null, null,
            null);//w  ww  .  j av a 2 s .co m
    if (dialog == null)
        return null;

    dialog.open();

    return null;
}