Example usage for org.eclipse.jface.preference ScaleFieldEditor getScaleControl

List of usage examples for org.eclipse.jface.preference ScaleFieldEditor getScaleControl

Introduction

In this page you can find the example usage for org.eclipse.jface.preference ScaleFieldEditor getScaleControl.

Prototype

public Scale getScaleControl() 

Source Link

Document

Returns this field editor's scale control.

Usage

From source file:com.litrik.eclipse.xps.preferences.XPSPreferencePage.java

License:Apache License

public void createFieldEditors() {
    addField(new BooleanFieldEditor(XPSPreferenceConstants.P_JUNIT_ENABLED, JUNIT_ENABLED,
            getFieldEditorParent()));//w  w  w  .  java2 s  .c o  m

    // A group for the color preferences
    Group colorGroup = new Group(getFieldEditorParent(), SWT.NONE);
    colorGroup.setText(JUNIT_COLOR);

    // The color when a test run starts
    final LEDColorFieldEditor startLEDColorFieldEditor = new LEDColorFieldEditor(
            XPSPreferenceConstants.P_JUNIT_COLOR_START, JUNIT_COLOR_START, colorGroup);
    addField(startLEDColorFieldEditor);
    // A preview button
    final Button previewStartButton = new Button(colorGroup, SWT.NONE);
    previewStartButton.setText("Preview");

    // The color when a test run was successful
    final LEDColorFieldEditor successLEDColorFieldEditor = new LEDColorFieldEditor(
            XPSPreferenceConstants.P_JUNIT_COLOR_SUCCESS, JUNIT_COLOR_SUCCESS, colorGroup);
    addField(successLEDColorFieldEditor);
    // A preview button
    final Button previewSuccessButton = new Button(colorGroup, SWT.NONE);
    previewSuccessButton.setText("Preview");

    // The color when a test failed
    final LEDColorFieldEditor failureLEDColorFieldEditor = new LEDColorFieldEditor(
            XPSPreferenceConstants.P_JUNIT_COLOR_FAILURE, JUNIT_COLOR_FAILURE, colorGroup);
    addField(failureLEDColorFieldEditor);
    // A preview button
    final Button previewFailureButton = new Button(colorGroup, SWT.NONE);
    previewFailureButton.setText("Preview");

    // The brightness
    final ScaleFieldEditor brightnessScaleFieldEditor = new ScaleFieldEditor(
            XPSPreferenceConstants.P_JUNIT_BRIGHTNESS, JUNIT_BRIGHTNESS, colorGroup, 1, 7, 1, 1);
    addField(brightnessScaleFieldEditor);

    // Pulsate
    addField(new BooleanFieldEditor(XPSPreferenceConstants.P_JUNIT_PULSATE, JUNIT_PULSE, colorGroup));

    // Layout the group
    GridLayout colorGroupLayout = new GridLayout();
    colorGroupLayout.numColumns = 3;
    colorGroup.setLayout(colorGroupLayout);
    GridData colorGroupGridData = new GridData(GridData.FILL_HORIZONTAL);
    colorGroupGridData.horizontalSpan = 2;
    colorGroup.setLayoutData(colorGroupGridData);

    // A group for the time-out preferences
    Group timeOutGroup = new Group(getFieldEditorParent(), SWT.NONE);
    timeOutGroup.setText(JUNIT_TIMEOUT);

    // The time-out after success
    addField(new IntegerFieldEditor(XPSPreferenceConstants.P_JUNIT_TIMEOUT_SUCCESS, JUNIT_TIMEOUT_SUCCESS,
            timeOutGroup, 3));
    final Label secondsSuccessLabel = new Label(timeOutGroup, SWT.NONE);
    secondsSuccessLabel.setText(JUNIT_TIMEOUT_SECONDS);

    // The time-out after failure
    addField(new IntegerFieldEditor(XPSPreferenceConstants.P_JUNIT_TIMEOUT_FAILURE, JUNIT_TIMEOUT_FAILURE,
            timeOutGroup, 3));
    final Label secondsFailureLabel = new Label(timeOutGroup, SWT.NONE);
    secondsFailureLabel.setText(JUNIT_TIMEOUT_SECONDS);

    // Layout the group
    GridLayout timeOutGroupLayout = new GridLayout();
    timeOutGroupLayout.numColumns = 3;
    timeOutGroup.setLayout(timeOutGroupLayout);
    GridData timeOutGroupGridData = new GridData(GridData.FILL_HORIZONTAL);
    timeOutGroupGridData.horizontalSpan = 2;
    timeOutGroup.setLayoutData(timeOutGroupGridData);

    // A group for the LED location preferences
    Group locationGroup = new Group(getFieldEditorParent(), SWT.NONE);
    locationGroup.setText(JUNIT_LOCATION);

    // Fan LEDs
    final BooleanFieldEditor fansBooleanFieldEditor = new BooleanFieldEditor(
            XPSPreferenceConstants.P_JUNIT_LOCATION_FANS, JUNIT_LOCATION_FANS, locationGroup);
    addField(fansBooleanFieldEditor);

    // Speaker LEDs
    final BooleanFieldEditor speakersBooleanFieldEditor = new BooleanFieldEditor(
            XPSPreferenceConstants.P_JUNIT_LOCATION_SPEAKERS, JUNIT_LOCATION_SPEAKERS, locationGroup);
    addField(speakersBooleanFieldEditor);

    // Panel back LEDs
    final BooleanFieldEditor panelBooleanFieldEditor = new BooleanFieldEditor(
            XPSPreferenceConstants.P_JUNIT_LOCATION_PANEL, JUNIT_LOCATION_PANEL, locationGroup);
    addField(panelBooleanFieldEditor);

    // Layout the group
    GridLayout locationGroupLayout = new GridLayout();
    locationGroup.setLayout(locationGroupLayout);
    GridData locationGroupGridData = new GridData(GridData.FILL_HORIZONTAL);
    locationGroupGridData.horizontalSpan = 2;
    locationGroup.setLayoutData(locationGroupGridData);

    // Let the "Preview" buttons do something
    previewStartButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent se) {
            try {
                LEDs.setLeds(startLEDColorFieldEditor.getCurrentValue(),
                        fansBooleanFieldEditor.getBooleanValue(), speakersBooleanFieldEditor.getBooleanValue(),
                        panelBooleanFieldEditor.getBooleanValue(),
                        brightnessScaleFieldEditor.getScaleControl().getSelection());
            } catch (LEDException e) {
                Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Status.OK,
                        "An unexpected error occurred when setting the XPS LEDs.", e));
            }
        }
    });
    previewSuccessButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent se) {
            try {
                LEDs.setLeds(successLEDColorFieldEditor.getCurrentValue(),
                        fansBooleanFieldEditor.getBooleanValue(), speakersBooleanFieldEditor.getBooleanValue(),
                        panelBooleanFieldEditor.getBooleanValue(),
                        brightnessScaleFieldEditor.getScaleControl().getSelection());
            } catch (LEDException e) {
                Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Status.OK,
                        "An unexpected error occurred when setting the XPS LEDs.", e));
            }
        }
    });
    previewFailureButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent se) {
            try {
                LEDs.setLeds(failureLEDColorFieldEditor.getCurrentValue(),
                        fansBooleanFieldEditor.getBooleanValue(), speakersBooleanFieldEditor.getBooleanValue(),
                        panelBooleanFieldEditor.getBooleanValue(),
                        brightnessScaleFieldEditor.getScaleControl().getSelection());
            } catch (LEDException e) {
                Activator.getDefault().getLog().log(
                        new Status(IStatus.ERROR, Activator.PLUGIN_ID, Status.OK, LEDException.MESSAGE, e));
            }
        }
    });

}

From source file:net.refractions.udig.catalog.internal.wmt.ui.preferences.WMTTilePreferencesPage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    getFieldEditorParent().setLayout(new RowLayout(SWT.VERTICAL));

    //region Scale-Factor
    Group grpScaleFactor = new Group(getFieldEditorParent(), SWT.NONE);
    grpScaleFactor.setText(Messages.Preferences_ScaleFactor_Title);

    grpScaleFactor.setLayout(new RowLayout(SWT.VERTICAL));
    grpScaleFactor.setLayoutData(new RowData(300, 20));

    //region Scale-Component Description
    Composite cScaleFactorDescription = new Composite(grpScaleFactor, SWT.NONE);
    cScaleFactorDescription.setLayoutData(new RowData(400, 25));

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;//from w w w.  ja v a 2s.  c  o m
    gridLayout.makeColumnsEqualWidth = false;

    cScaleFactorDescription.setLayout(gridLayout);

    Label lblFast = new Label(cScaleFactorDescription, SWT.HORIZONTAL);
    lblFast.setText(Messages.Preferences_ScaleFactor_FastRendering);
    lblFast.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL));

    lblValue = new Label(cScaleFactorDescription, SWT.HORIZONTAL);
    lblValue.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.FILL_HORIZONTAL));

    Label lblQuality = new Label(cScaleFactorDescription, SWT.HORIZONTAL | GridData.FILL_HORIZONTAL);
    lblQuality.setText(Messages.Preferences_ScaleFactor_HighestQuality);
    lblQuality.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END));
    //endregion

    //region Scale-Component
    ScaleFieldEditor scaleFactorFieldEditor = new ScaleFieldEditor(WMTPreferenceConstants.P_WMT_SCALEFACTOR, "", //$NON-NLS-1$
            grpScaleFactor, 1, 100, 1, 5);
    scaleFactorFieldEditor.getLabelControl(grpScaleFactor).setLayoutData(new RowData());
    addField(scaleFactorFieldEditor);

    sclScaleFactor = scaleFactorFieldEditor.getScaleControl();
    sclScaleFactor.setSize(400, 30);
    sclScaleFactor.setMinimum(0);
    sclScaleFactor.setMaximum(100);
    sclScaleFactor.setIncrement(1);
    sclScaleFactor.setPageIncrement(10);
    sclScaleFactor.setSelection(50);
    sclScaleFactor.setLayoutData(new RowData(400, 30));
    sclScaleFactor.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }

        public void widgetSelected(SelectionEvent event) {
            updateScaleFactorValue();
        }
    });

    sclScaleFactor.addListener(SWT.Paint, new Listener() {
        /**
         * When the scale-component is painted for the first time,
         * also update the display of the scale-factor.
         */
        public void handleEvent(Event arg0) {
            updateScaleFactorValue();
            sclScaleFactor.removeListener(SWT.Paint, this);
        }

    });
    //endregion

    //region Scale-Component Label
    Composite cScaleFactorDescriptionValues = new Composite(grpScaleFactor, SWT.NONE);
    cScaleFactorDescriptionValues.setLayoutData(new RowData(400, 30));

    GridLayout gridLayoutTwo = new GridLayout();
    gridLayoutTwo.numColumns = 2;
    gridLayoutTwo.makeColumnsEqualWidth = false;

    cScaleFactorDescriptionValues.setLayout(gridLayoutTwo);

    Label lblValue0 = new Label(cScaleFactorDescriptionValues, SWT.HORIZONTAL);
    lblValue0.setText("0"); //$NON-NLS-1$
    lblValue0.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL));

    Label lblValue100 = new Label(cScaleFactorDescriptionValues, SWT.HORIZONTAL | GridData.FILL_HORIZONTAL);
    lblValue100.setText("100"); //$NON-NLS-1$
    lblValue100.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END));

    Label lblScaleFactorExpl = new Label(grpScaleFactor, SWT.HORIZONTAL | SWT.WRAP);
    lblScaleFactorExpl.setText(Messages.Preferences_ScaleFactor_Description);
    lblScaleFactorExpl.setLayoutData(new RowData(400, 50));
    //endregion
    //endregion

    //region Tile-Limit
    Group grpTileLimit = new Group(getFieldEditorParent(), SWT.NONE);
    grpTileLimit.setLayout(new RowLayout(SWT.VERTICAL));
    grpTileLimit.setText(Messages.Preferences_TileLimit_Title);

    Composite limitFields = new Composite(grpTileLimit, SWT.NONE);

    IntegerFieldEditor warningFieldEditor = new IntegerFieldEditor(
            WMTPreferenceConstants.P_WMT_TILELIMIT_WARNING, Messages.Preferences_TileLimit_Warning,
            limitFields);
    addField(warningFieldEditor);

    IntegerFieldEditor errorFieldEditor = new IntegerFieldEditor(WMTPreferenceConstants.P_WMT_TILELIMIT_ERROR,
            Messages.Preferences_TileLimit_Error, limitFields);
    addField(errorFieldEditor);

    Label lblTileLimitExpl = new Label(grpTileLimit, SWT.HORIZONTAL | SWT.WRAP);
    lblTileLimitExpl.setText(Messages.Preferences_TileLimit_Description);
    lblTileLimitExpl.setLayoutData(new RowData(400, 90));
    //endregion

    //region Reset LayoutManagers (they are set to GridLayout when the field is added)
    grpScaleFactor.setLayout(new RowLayout(SWT.VERTICAL));
    cScaleFactorDescription.setLayout(gridLayout);
    cScaleFactorDescriptionValues.setLayout(gridLayoutTwo);
    grpScaleFactor.pack();
    grpTileLimit.pack();
    //endregion
}

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 ww  . ja v  a 2 s.com
    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.titan.designer.preferences.pages.DebugPreferencePage.java

License:Open Source License

private void createLoadBalancingSection(final Composite parent) {
    ExpandableComposite expandable = createExtendableComposite(parent, "Load balancing");
    Composite comp = new Composite(expandable, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    expandable.setClient(comp);/*  w  w  w.  j a  v a 2 s .co  m*/
    expandable.setExpanded(false);
    IntegerFieldEditor tokens = new IntegerFieldEditor(
            PreferenceConstants.DEBUG_LOAD_TOKENS_TO_PROCESS_IN_A_ROW,
            "Tokens to process between thread switches", comp);
    tokens.setValidRange(0, Integer.MAX_VALUE);
    addField(tokens);

    ScaleFieldEditor threadPriority = new ScaleFieldEditor(PreferenceConstants.DEBUG_LOAD_THREAD_PRIORITY,
            "Thread priority", comp);
    threadPriority.setMinimum(Thread.MIN_PRIORITY);
    threadPriority.setMaximum(Thread.MAX_PRIORITY);
    threadPriority.setIncrement(1);
    threadPriority.getScaleControl()
            .setToolTipText("Sets the priority of the threads created by the syntax analyzer.");
    addField(threadPriority);

    IntegerFieldEditor sleepBetweenFiles = new IntegerFieldEditor(
            PreferenceConstants.DEBUG_LOAD_SLEEP_BETWEEN_FILES,
            "Sleep the syntax analyzer thread after processing a single file(-1 to do not sleep at all)", comp);
    sleepBetweenFiles.setValidRange(-1, Integer.MAX_VALUE);
    addField(sleepBetweenFiles);

    BooleanFieldEditor yieldBetweenChecks = new BooleanFieldEditor(
            PreferenceConstants.DEBUG_LOAD_YIELD_BETWEEN_CHECKS,
            "Switch thread after semantically checking modules or definitions.", comp);
    addField(yieldBetweenChecks);
}