Example usage for org.eclipse.jface.preference RadioGroupFieldEditor getRadioBoxControl

List of usage examples for org.eclipse.jface.preference RadioGroupFieldEditor getRadioBoxControl

Introduction

In this page you can find the example usage for org.eclipse.jface.preference RadioGroupFieldEditor getRadioBoxControl.

Prototype

public Composite getRadioBoxControl(Composite parent) 

Source Link

Document

Returns this field editor's radio group control.

Usage

From source file:eu.geclipse.ui.internal.preference.PerspectivePreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    ImageDescriptor userPerspectiveImage = null;
    ImageDescriptor operatorPerspectiveImage = null;
    ImageDescriptor developerPerspectiveImage = null;

    RadioGroupFieldEditor editor = new RadioGroupFieldEditor(KEY_REMEMBER_SWITCHING,
            "Open a g-Eclipse perspective after creating a Cloud/Grid Project", 3,
            new String[][] { { "Always", MessageDialogWithToggle.ALWAYS },
                    { "Never", MessageDialogWithToggle.NEVER }, { "Prompt", MessageDialogWithToggle.PROMPT }, },
            getFieldEditorParent(), true);
    addField(editor);//w  ww  .  j  ava2s . com
    IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry();

    String[][] labels = new String[][] { { "Grid User Perspective", Activator.ID_USER_PERSPECTIVE },
            { "Grid Operator Perspective", Activator.ID_OPERATOR_PERSPECTIVE },
            { "Grid Developer Perspective", Activator.ID_DEVELOPER_PERSPECTIVE } };

    IPerspectiveDescriptor p;
    p = reg.findPerspectiveWithId(Activator.ID_USER_PERSPECTIVE);
    if (p != null) {
        labels[0][0] = p.getLabel();
        userPerspectiveImage = p.getImageDescriptor();
    }
    p = reg.findPerspectiveWithId(Activator.ID_OPERATOR_PERSPECTIVE);
    if (p != null) {
        labels[1][0] = p.getLabel();
        operatorPerspectiveImage = p.getImageDescriptor();
    }
    p = reg.findPerspectiveWithId(Activator.ID_DEVELOPER_PERSPECTIVE);
    if (p != null) {
        labels[2][0] = p.getLabel();
        developerPerspectiveImage = p.getImageDescriptor();
    }

    editor = new RadioGroupFieldEditor(KEY_DEFAULT_PERSPECTIVE,
            "Choose perspective to open for new Cloud/Grid Projects", 1, labels, getFieldEditorParent(), true);
    addField(editor);

    //add perspective images
    Control[] children = editor.getRadioBoxControl(getFieldEditorParent()).getChildren();
    if (userPerspectiveImage != null && children[0] != null && children[0] instanceof Button) {
        ((Button) children[0]).setImage(userPerspectiveImage.createImage());
    }
    if (operatorPerspectiveImage != null && children[1] != null && children[1] instanceof Button) {
        ((Button) children[1]).setImage(operatorPerspectiveImage.createImage());
    }
    if (developerPerspectiveImage != null && children[2] != null && children[2] instanceof Button) {
        ((Button) children[2]).setImage(developerPerspectiveImage.createImage());
    }

    BooleanFieldEditor bfe = new BooleanFieldEditor(KEY_NOT_SWITCH_FROM_GECLIPSE_PERSPECTIVE,
            "Do not switch from other g-Eclipse perspectives (User, Operator or Developer)",
            getFieldEditorParent());
    addField(bfe);
}

From source file:org.eclipse.actf.ai.audio.description.preferences.ADPreferencePage.java

License:Open Source License

@Override
public void createFieldEditors() {
    RadioGroupFieldEditor rgfe;
    String[][] labelAndIds = TTSRegistry.getLabelAndIds();
    addField(rgfe = new RadioGroupFieldEditor(DescriptionPlugin.PREF_ENGINE,
            Messages.AudioDescription_voice_engine, 1, labelAndIds, getFieldEditorParent()));
    Composite c = rgfe.getRadioBoxControl(getFieldEditorParent());
    for (int i = 0; i < labelAndIds.length; i++) {
        if (labelAndIds[i][1].length() == 0) {
            c.getChildren()[i].setEnabled(false);
        }//from   w ww  . j  av a  2 s. c  o  m
    }
}

From source file:org.eclipse.actf.ai.voice.preferences.VoicePreferencePage.java

License:Open Source License

public void createFieldEditors() {

    final RadioGroupFieldEditor rgfe;
    String[][] labelAndIds = TTSRegistry.getLabelAndIds();
    addField(rgfe = new RadioGroupFieldEditor(IVoice.PREF_ENGINE, Messages.voice_engine, 1, labelAndIds,
            getFieldEditorParent()));//from   w w  w  .j  a va2s.co  m
    Composite c = rgfe.getRadioBoxControl(getFieldEditorParent());
    for (int i = 0; i < labelAndIds.length; i++) {
        if (labelAndIds[i][1].length() == 0) {
            c.getChildren()[i].setEnabled(false);
        }
    }

    final ScaleFieldEditor speedEditor;
    addField(speedEditor = new ScaleFieldEditor(IVoice.PREF_SPEED, Messages.voice_speed, getFieldEditorParent(),
            IVoice.SPEED_MIN, IVoice.SPEED_MAX, 5, 25));

    Composite comp = new Composite(getFieldEditorParent(), SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = layout.marginWidth = 0;
    comp.setLayout(layout);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gd.horizontalSpan = speedEditor.getNumberOfControls();
    comp.setLayoutData(gd);

    Button testButton = new Button(comp, SWT.NONE);
    testButton.setText(Messages.voice_test);
    testButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {

            voice.setSpeed(speedEditor.getScaleControl().getSelection());
            voice.speak(SAMPLE_TEXT, false);
        }
    });
}

From source file:org.eclipse.linuxtools.internal.profiling.launch.provider.AbstractProviderPreferencesPage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    String providerId = ProviderFramework.getHighestProviderId(type);

    if (providerId != null) {
        getPreferenceStore().setDefault(ProviderProfileConstants.PREFS_KEY + type, providerId);
    }/*from  w ww . j ava2s. c o  m*/

    HashMap<String, String> map = ProviderFramework.getProviderNamesForType(type);
    // 2d array containing launch provider names on the first column and
    // corresponding id's on the second.
    String[][] providerList = new String[map.size()][2];
    int i = 0;
    for (Entry<String, String> entry : map.entrySet()) {
        String toolId = entry.getValue();
        String toolDescription = ProviderFramework.getToolInformationFromId(toolId, PROVIDER_ATT_DESC);
        String toolName = entry.getKey();

        // Append tool description to tool name if available.
        if (toolDescription != null && !toolDescription.equals("")) { //$NON-NLS-1$
            toolName = toolName + " " + "[" + toolDescription + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }

        providerList[i][0] = toolName;
        providerList[i][1] = toolId;
        i++;
    }

    // Create basic field editor.
    RadioGroupFieldEditor editor = new RadioGroupFieldEditor(ProviderProfileConstants.PREFS_KEY + type,
            Messages.ProviderPreferencesPage_1, 1, providerList, getFieldEditorParent(), true);
    editor.setPreferenceStore(getPreferenceStore());
    addField(editor);

    Composite radioBoxControl = editor.getRadioBoxControl(getFieldEditorParent());
    Control[] providerOptions = radioBoxControl.getChildren();

    // Set tool tip text on field editors.
    for (Control control : providerOptions) {
        // Get tool specific information from provider id.
        String curProviderId = (String) control.getData();
        // Set tool tip description text.
        String toolDescription = ProviderFramework.getToolInformationFromId(curProviderId, PROVIDER_ATT_INFO);
        if (toolDescription != null && !toolDescription.equals("")) { //$NON-NLS-1$
            control.setToolTipText(toolDescription);
        }
    }
}