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

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

Introduction

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

Prototype

@Override
public Object getSelectedPage() 

Source Link

Usage

From source file:com.archimatetool.editor.ui.components.ColorChooser.java

License:Open Source License

protected void addMenuActions(MenuManager menuManager) {
    if (fDoShowDefaultMenuItem) {
        IAction defaultColorAction = new Action(Messages.ColorChooser_1) {
            @Override/*from w ww. j  av a 2  s  .c om*/
            public void run() {
                boolean oldValue = fIsDefaultColor;
                fIsDefaultColor = !fIsDefaultColor;
                fireActionListenerEvent(PROP_COLORDEFAULT, oldValue, fIsDefaultColor);
            }
        };

        menuManager.add(defaultColorAction);
        defaultColorAction.setEnabled(!isDefaultColor());
    }

    for (IAction action : fExtraActionsList) {
        menuManager.add(action);
    }

    if (fDoShowPreferencesMenuItem) {
        menuManager.add(new Separator());

        IAction preferencesAction = new Action(Messages.ColorChooser_2) {
            @Override
            public void run() {
                PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getControl().getShell(),
                        ColoursFontsPreferencePage.ID, null, null);
                if (dialog != null) {
                    ColoursFontsPreferencePage page = (ColoursFontsPreferencePage) dialog.getSelectedPage();
                    page.selectColoursTab();
                    dialog.open();
                }
            }
        };
        menuManager.add(preferencesAction);
    }
}

From source file:com.archimatetool.editor.ui.components.FontChooser.java

License:Open Source License

protected void addMenuActions(MenuManager menuManager) {
    if (fDoShowDefaultMenuItem) {
        IAction defaultFontAction = new Action(Messages.FontChooser_1) {
            @Override/*www .ja  v  a  2 s.  c  o m*/
            public void run() {
                boolean oldValue = fIsDefaultFont;
                fIsDefaultFont = !fIsDefaultFont;
                fireActionListenerEvent(PROP_FONTDEFAULT, oldValue, fIsDefaultFont);
            }
        };

        menuManager.add(defaultFontAction);
        defaultFontAction.setEnabled(!isDefaultFont());
    }

    for (IAction action : fExtraActionsList) {
        menuManager.add(action);
    }

    if (fDoShowPreferencesMenuItem) {
        menuManager.add(new Separator());

        IAction preferencesAction = new Action(Messages.FontChooser_2) {
            @Override
            public void run() {
                PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getControl().getShell(),
                        ColoursFontsPreferencePage.ID, null, null);
                if (dialog != null) {
                    ColoursFontsPreferencePage page = (ColoursFontsPreferencePage) dialog.getSelectedPage();
                    page.selectFontsTab();
                    dialog.open();
                }
            }
        };
        menuManager.add(preferencesAction);
    }
}

From source file:com.nokia.s60tools.remotecontrol.actions.OpenPreferencePageAction.java

License:Open Source License

/**
 * Open Remote control preferences page//from w w w. j a v  a  2  s  . c  o  m
 */
private void openPreferencePage() {

    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
            RemoteControlActivator.getCurrentlyActiveWbWindowShell(), RCPreferencePage.PAGE_ID, null, null);

    Object object = dialog.getSelectedPage();
    if (object instanceof RCPreferencePage) {
        // Selecting correct tab.
        ((RCPreferencePage) object).openTab(selection);
    }

    dialog.open();
}

From source file:com.siteview.mde.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  w w. ja v a  2 s  . c om

    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(MDERuntimeMessages.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(MDERuntimeMessages.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:gov.redhawk.ide.graphiti.sad.ui.tests.PortStatsPrefPageTest.java

License:Open Source License

private String getErrorMessage(final SWTBotShell shell) {
    Display.getDefault().syncExec(new Runnable() {

        @Override//from  w w  w .j a v a  2 s .c om
        public void run() {
            Shell w = shell.widget;
            PreferenceDialog data = (PreferenceDialog) w.getData();
            DialogPage page = (DialogPage) data.getSelectedPage();
            setErrorMessage(page.getErrorMessage());
        }
    });

    return this.errorMessage;
}

From source file:msi.gama.lang.gaml.ui.templates.TemplatesView.java

@Override
public void createPartControl(final Composite parent) {
    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(parent.getShell(),
            "msi.gama.lang.gaml.Gaml.templates", new String[] {}, null);
    PreferencePage selectedPage = (PreferencePage) dialog.getSelectedPage();
    selectedPage.createControl(parent);/* w w  w . ja va  2s .  c  o m*/
}

From source file:net.rim.ejde.internal.signing.CodeSignMarkerResolution.java

License:Open Source License

public void run(IMarker marker) {
    try {//from   w  ww  .j  a  v  a2 s. c  o m
        String msg = marker.getAttribute(IMarker.MESSAGE).toString();
        String keyLabel = VMUtils.convertCodeSignErrorMsgToPreferenceLabel(msg);
        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
                Display.getDefault().getActiveShell(), WarningsPrefsPage.ID, null, null);
        WarningsPrefsPage page = (WarningsPrefsPage) dialog.getSelectedPage();
        page.setSelection(keyLabel, true);
        dialog.open();
    } catch (CoreException e) {
        e.printStackTrace();
    }
}

From source file:org.eclipse.datatools.connectivity.ui.actions.ViewPropertyAction.java

License:Open Source License

public void run() {
    Object selected = getSelectedObject();
    PreferenceDialog propertyDialog = ProfileUIManager.createPreferenceDialog(mViewer.getControl().getShell(),
            selected);/*www  .  j a va 2 s.  c  o  m*/
    if (propertyDialog == null)
        return;

    // check for size settings
    IDialogSettings dset = ConnectivityUIPlugin.getDefault().getDialogSettings();
    boolean foundSettings = false;
    if (dset != null) {
        IDialogSettings dSection = dset.getSection(MEMENTO_ROOT);
        if (dSection != null) {
            if (dSection.get(MEMENTO_DIALOG_SIZE_HEIGHT) != null
                    && dSection.get(MEMENTO_DIALOG_SIZE_HEIGHT).trim().length() > 0) {
                mShellHeight = dSection.getInt(MEMENTO_DIALOG_SIZE_HEIGHT);
                mShellWidth = dSection.getInt(MEMENTO_DIALOG_SIZE_WIDTH);
                foundSettings = true;
            }
        }
    }
    // if we found them, set it to the old values
    if (foundSettings) {
        propertyDialog.getShell().setSize(mShellWidth, mShellHeight);
        propertyDialog.getShell().layout();
        // if not, initialize 'mShellWidth' and 'mShellHeigth'
    } else {
        mShellHeight = propertyDialog.getShell().getSize().y;
        mShellWidth = propertyDialog.getShell().getSize().x;
    }

    this.mShell = propertyDialog.getShell();
    String title = ConnectivityUIPlugin.getDefault().getResourceString("properties.dialog"); //$NON-NLS-1$
    if (selected instanceof IConnectionProfile) {
        IConnectionProfile profile = (IConnectionProfile) selected;
        title = ConnectivityUIPlugin.getDefault().getResourceString("ConnectAction.title", //$NON-NLS-1$
                new String[] { profile.getName() });
    }
    propertyDialog.getShell().setText(title);

    // add a listener to make sure we get any resizes of the dialog
    // to store for the next time
    this.mShell.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            if (e.getSource() instanceof Shell) {
                Shell shell = (Shell) e.getSource();
                ViewPropertyAction.this.mShellHeight = shell.getSize().y;
                ViewPropertyAction.this.mShellWidth = shell.getSize().x;
            }
        }
    });

    // check to see if the profile is in a read-only repository
    // and if so, disable the controls on each page selected
    boolean inReadOnlyRepository = false;
    if (getSelectedObject() instanceof IConnectionProfile) {
        IConnectionProfile profile = (IConnectionProfile) getSelectedObject();
        if (profile.getParentProfile() != null) {
            IManagedConnection imc = ((IConnectionProfile) profile.getParentProfile()).getManagedConnection(
                    IConnectionProfileRepositoryConstants.REPOSITORY_CONNECTION_FACTORY_ID);
            if (imc != null && imc.isConnected()) {
                IConnectionProfileRepository repo = (IConnectionProfileRepository) imc.getConnection()
                        .getRawConnection();
                inReadOnlyRepository = repo.isReadOnly();
            }
        }
    }

    // handle the initial page selected in the dialog for the
    // read only repository page disabling...
    propertyDialog.addPageChangedListener(new PropertyPageChangeListener(inReadOnlyRepository));
    if (inReadOnlyRepository && propertyDialog.getSelectedPage() != null) {
        PropertyPage page = (PropertyPage) propertyDialog.getSelectedPage();
        if (propertyDialog.getSelectedPage() instanceof ConnectionProfileDetailsPage
                || propertyDialog.getSelectedPage() instanceof ProfileDetailsPropertyPage) {
            if (page.getControl() instanceof Composite) {
                Composite composite = (Composite) page.getControl();
                if (inReadOnlyRepository)
                    disableControls(composite, !inReadOnlyRepository, true);
            }
        } else if (propertyDialog.getSelectedPage() instanceof PropertyPage) {
            if (page.getControl() instanceof Composite) {
                Composite composite = (Composite) page.getControl();
                disableControls(composite, !inReadOnlyRepository);
            }
        }
    }
    int rtn_val = propertyDialog.open();
    if (rtn_val == Dialog.OK)
        saveState();

    mViewer.setSelection(mViewer.getSelection());
}

From source file:org.eclipse.jubula.rc.rcp.swt.aut.RcpSwtComponentNamer.java

License:Open Source License

/**
 * Adds name information to the given widget, if necessary.
 *
 * @param widget//from  ww w . j  a  v  a2s.  c  o  m
 *            The widget to name.
 */
private void addNameData(Widget widget) {
    // Assign name
    if (hasWidgetToBeNamed(widget)) {
        Object data = getWidgetData(widget);

        if (data instanceof IContributionItem) {
            // Name buttons and toolitems according to the action that
            // they represent, if possible.
            String actionId = ((IContributionItem) data).getId();
            if (actionId != null && actionId.trim().length() > 0) {
                setComponentName(widget, actionId);
                ComponentHandler.getAutHierarchy().refreshComponentName(widget);

            }
        } else if (data instanceof PreferenceDialog) {
            PreferenceDialog prefDialog = (PreferenceDialog) data;

            // Add a listener to add name data as pages are
            // selected/created.
            prefDialog.addPageChangedListener(new IPageChangedListener() {

                public void pageChanged(PageChangedEvent event) {
                    addNameDataToPrefPage(event.getSelectedPage());
                }

            });

            // The listener won't notice the initally selected page,
            // so we have to add that name data here.
            addNameDataToPrefPage(prefDialog.getSelectedPage());
        }
        if (generateNames && data instanceof Dialog) {
            Dialog dialog = (Dialog) data;
            setNameForDialogButtonBarButtons(dialog);
        }
    }
}

From source file:org.eclipse.mylyn.reviews.r4e.ui.tests.proxy.R4EUITestPreferences.java

License:Open Source License

/**
 * Method getUser./*  w  w  w  .  j  a  v a  2  s  . c  o  m*/
 * 
 * @return String
 */
public String getUser() {
    //Inner class that runs the command on the UI thread
    class RunGetUser implements Runnable {
        private String user;

        public String getUser() {
            return user;
        }

        public void setUser(String aUser) {
            user = aUser;
        }

        public void run() {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, PREFERENCES_PAGE_ID, null,
                    null);
            R4EPreferencePage preferences = (R4EPreferencePage) dialog.getSelectedPage();
            setUser(preferences.getAuthor());
            preferences.performOk();
            dialog.close();
        }
    }
    ;

    //Run the UI job and wait until the command is completely executed before continuing
    RunGetUser getUserJob = new RunGetUser();
    Display.getDefault().syncExec(getUserJob);
    TestUtils.waitForJobs();
    return getUserJob.getUser();
}