Search in sources :

Example 1 with PreferenceDialog

use of org.eclipse.jface.preference.PreferenceDialog in project gfm_viewer by satyagraha.

the class Preferences method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "code.satyagraha.gfm.viewer.preferences.PreferencePage", null, null);
    pref.open();
    return null;
}
Also used : PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog)

Example 2 with PreferenceDialog

use of org.eclipse.jface.preference.PreferenceDialog in project sling by apache.

the class SlingProjectPropertyPage method openPropertyDialog.

public static void openPropertyDialog(Shell shell, IProject project) {
    // find out if the override page is contributed, and show that instead of the default one
    // TODO - stop relying on internals
    PropertyPageManager pageManager = new PropertyPageManager();
    PropertyPageContributorManager.getManager().contribute(pageManager, project);
    List<?> nodes = pageManager.getElements(PreferenceManager.PRE_ORDER);
    boolean overridePresent = false;
    for (Object node : nodes) {
        if (((IPreferenceNode) node).getId().equals(PAGE_ID_OVERRIDE)) {
            overridePresent = true;
            break;
        }
    }
    String pageId = overridePresent ? PAGE_ID_OVERRIDE : PAGE_ID;
    PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(shell, project, pageId, new String[] { pageId }, null);
    dialog.open();
}
Also used : PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) PropertyPageManager(org.eclipse.ui.internal.dialogs.PropertyPageManager)

Example 3 with PreferenceDialog

use of org.eclipse.jface.preference.PreferenceDialog in project bndtools by bndtools.

the class JPMBrowserView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    StackLayout stack = new StackLayout();
    parent.setLayout(stack);
    JpmPreferences prefs = new JpmPreferences();
    if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_EXTERNAL) {
        external = true;
        Composite composite = new Composite(parent, SWT.NONE);
        composite.setLayout(new GridLayout(2, false));
        new Label(composite, SWT.NONE).setText("JPM is configured to open in an external browser.");
        Hyperlink linkToPrefs = new Hyperlink(composite, SWT.NONE);
        linkToPrefs.setText("Open Preference Page");
        linkToPrefs.setUnderlined(true);
        linkToPrefs.addHyperlinkListener(new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
                PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getViewSite().getShell(), "bndtools.prefPages.jpm", new String[] { "bndtools.prefPages.jpm" }, null);
                dialog.open();
            }
        });
        //            linkToPrefs.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
        stack.topControl = composite;
    } else {
        if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_PLATFORM_DEFAULT) {
            browser = new Browser(parent, SWT.NONE);
            stack.topControl = browser;
        } else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_WEBKIT) {
            browser = new Browser(parent, SWT.WEBKIT);
            stack.topControl = browser;
        } else if (prefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_MOZILLA) {
            browser = new Browser(parent, SWT.MOZILLA);
            stack.topControl = browser;
        }
        createActions();
        // Prevent navigation away from JPM4J.org, and redirect from HTTP back to HTTPS
        browser.addLocationListener(new LocationAdapter() {

            @Override
            public void changing(LocationEvent event) {
                setContentDescription(event.location);
            /*
                     *
                    if (event.location.startsWith(HTTPS_URL))
                        return;
                    if (event.location.startsWith(HTTP_URL))
                        event.location = event.location.replaceFirst(HTTP_URL, HTTP_URL);
                    else
                        event.doit = false;
                     */
            }
        });
    }
    selectionService = getViewSite().getWorkbenchWindow().getSelectionService();
    selectionService.addSelectionListener(this);
    handleWorkbenchSelection(selectionService.getSelection());
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) JpmPreferences(bndtools.preferences.JpmPreferences) LocationAdapter(org.eclipse.swt.browser.LocationAdapter) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) StackLayout(org.eclipse.swt.custom.StackLayout) LocationEvent(org.eclipse.swt.browser.LocationEvent) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) Browser(org.eclipse.swt.browser.Browser)

Example 4 with PreferenceDialog

use of org.eclipse.jface.preference.PreferenceDialog in project dbeaver by serge-rider.

the class StreamConsumerPageSettings method createControl.

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    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[] { //$NON-NLS-1$
            "Base64", //$NON-NLS-1$
            "Hex", //$NON-NLS-1$
            "Binary" });
            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);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) PropertyTreeViewer(org.jkiss.dbeaver.ui.properties.PropertyTreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 5 with PreferenceDialog

use of org.eclipse.jface.preference.PreferenceDialog in project azure-tools-for-java by Microsoft.

the class PluginUtil method openPropertyPageDialog.

/**
	 * Method opens property dialog with only desired property page.
	 *
	 * @param nodeId
	 *            : Node ID of property page
	 * @param nodeLbl
	 *            : Property page name
	 * @param classObj
	 *            : Class object of property page
	 * @return
	 */
public static int openPropertyPageDialog(String nodeId, String nodeLbl, Object classObj) {
    // value corresponding to cancel
    int retVal = Window.CANCEL;
    // Node creation
    try {
        PreferenceNode nodePropPg = new PreferenceNode(nodeId, nodeLbl, null, classObj.getClass().toString());
        nodePropPg.setPage((IPreferencePage) classObj);
        nodePropPg.getPage().setTitle(nodeLbl);
        PreferenceManager mgr = new PreferenceManager();
        mgr.addToRoot(nodePropPg);
        // Dialog creation
        PreferenceDialog dialog = new PreferenceDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), mgr);
        // make desired property page active.
        dialog.setSelectedNode(nodeLbl);
        dialog.create();
        /*
			 * If showing storage accounts preference page, don't show
			 * properties for title as its common repository.
			 */
        String dlgTitle = "";
        if (nodeLbl.equals(Messages.cmhLblStrgAcc) || nodeLbl.equals(Messages.aiTxt)) {
            dlgTitle = nodeLbl;
        } else {
            dlgTitle = String.format(Messages.cmhPropFor, getSelectedProject().getName());
        }
        dialog.getShell().setText(dlgTitle);
        dialog.open();
        // return whether user has pressed OK or Cancel button
        retVal = dialog.getReturnCode();
    } catch (Exception e) {
        PluginUtil.displayErrorDialogAndLog(PluginUtil.getParentShell(), Messages.rolsDlgErr, Messages.projDlgErrMsg, e);
    }
    return retVal;
}
Also used : PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) PreferenceNode(org.eclipse.jface.preference.PreferenceNode) PreferenceManager(org.eclipse.jface.preference.PreferenceManager) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Aggregations

PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)9 GridLayout (org.eclipse.swt.layout.GridLayout)3 CoreException (org.eclipse.core.runtime.CoreException)2 PreferenceManager (org.eclipse.jface.preference.PreferenceManager)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 Workspace (aQute.bnd.build.Workspace)1 JpmPreferences (bndtools.preferences.JpmPreferences)1 WorkspaceSetupWizard (bndtools.wizards.workspace.WorkspaceSetupWizard)1 IOException (java.io.IOException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 PreferenceNode (org.eclipse.jface.preference.PreferenceNode)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Browser (org.eclipse.swt.browser.Browser)1 LocationAdapter (org.eclipse.swt.browser.LocationAdapter)1