Example usage for org.eclipse.jface.preference StringFieldEditor setStringValue

List of usage examples for org.eclipse.jface.preference StringFieldEditor setStringValue

Introduction

In this page you can find the example usage for org.eclipse.jface.preference StringFieldEditor setStringValue.

Prototype

public void setStringValue(String value) 

Source Link

Document

Sets this field editor's value.

Usage

From source file:org.eclipse.cdt.llvm.dsf.lldb.ui.internal.LLDBDebugPreferencePage.java

License:Open Source License

private void handleBrowseButtonSelected(final String dialogTitle, final StringFieldEditor stringFieldEditor) {
    FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
    dialog.setText(dialogTitle);//from   w  ww. j a  v  a 2 s  .  com
    String lldbCommand = stringFieldEditor.getStringValue().trim();
    int lastSeparatorIndex = lldbCommand.lastIndexOf(File.separator);
    if (lastSeparatorIndex != -1) {
        dialog.setFilterPath(lldbCommand.substring(0, lastSeparatorIndex));
    }
    String res = dialog.open();
    if (res == null) {
        return;
    }
    stringFieldEditor.setStringValue(res);
}

From source file:org.eclipse.stem.ui.populationmodels.preferences.PopulationPreferencePage.java

License:Open Source License

/**
 * Creates the field editors. Field editors are abstractions of the common
 * GUI blocks needed to manipulate various types of preferences. Each field
 * editor knows how to save and restore itself.
 *//*from   w  w  w.  j  a  v  a 2 s . c o  m*/
@Override
public void createFieldEditors() {

    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    long refPop = store.getLong(PreferenceConstants.REFERENCE_POPULATION);
    long refDens = store.getLong(PreferenceConstants.REFERENCE_DENSITY);

    final StringFieldEditor referencePopulationThreadsFieldEditor = new StringFieldEditor(
            PreferenceConstants.REFERENCE_POPULATION,
            PopulationModelWizardMessages.getString("ReferencePopulation"), getFieldEditorParent()); //$NON-NLS-1$

    referencePopulationThreadsFieldEditor.setStringValue("" + refPop);
    addField(referencePopulationThreadsFieldEditor);

    final StringFieldEditor referenceDensityThreadsFieldEditor = new StringFieldEditor(
            PreferenceConstants.REFERENCE_DENSITY, PopulationModelWizardMessages.getString("ReferenceDensity"), //$NON-NLS-1$
            getFieldEditorParent());
    referencePopulationThreadsFieldEditor.setStringValue("" + refDens);
    addField(referenceDensityThreadsFieldEditor);

}

From source file:org.mwc.debrief.core.wizards.FlatFilenameWizardPage.java

License:Open Source License

/**
 * @see IDialogPage#createControl(Composite)
 *///  w w w  .  j  a v  a2  s  . c  o m
public void createControl(final Composite parent) {

    final Composite container = new Composite(parent, SWT.NULL);
    final GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;

    final String filenameKey = "3Debrief.FlatFileOutput";
    final String sensor1Key = "3Debrief.FlatFileSensorType1";
    final String sensor2Key = "3Debrief.FlatFileSensorType2";
    final String protMarkKey = "3Debrief.FlatFileProtMarking";
    final String serialKey = "3Debrief.FlatFileSerialName";
    final String sensor1fwdKey = "3Debrief.FlatFileSensor1fwd";
    final String sensor1aftKey = "3Debrief.FlatFileSensor1aft";
    final String sensor2fwdKey = "3Debrief.FlatFileSensor2fwd";
    final String sensor2aftKey = "3Debrief.FlatFileSensor2aft";
    final String speedOfSoundKey = "3Debrief.speedOfSoundKey";

    final String title = "Output directory:";
    _fileFieldEditor = new DirectoryFieldEditor(filenameKey, title, container) {
        @Override
        protected void doLoad() {
            super.doLoad();
            fireValueChanged(FieldEditor.VALUE, null, this.getStringValue());
        }

        protected void fireValueChanged(final String property, final Object oldValue, final Object newValue) {
            super.fireValueChanged(property, oldValue, newValue);

            // is this the value property?
            if (!property.equals(FieldEditor.VALUE))
                return;

            // tell the ui to update itself
            _filePath = (String) newValue;

            dialogChanged();
            this.store();

        }

        @Override
        protected boolean doCheckState() {
            return _filePath != null;
        }
    };
    _fileFieldEditor.fillIntoGrid(container, 3);
    _fileFieldEditor.setPreferenceStore(getPreferenceStore());
    _fileFieldEditor.setPage(this);
    _fileFieldEditor.setEmptyStringAllowed(false);
    _fileFieldEditor.load();

    // store the current editor value
    _filePath = _fileFieldEditor.getStringValue();

    // ok, we also need the sensor depth attribute
    if (_fileVersion.equals(FlatFileExporter.UPDATED_VERSION)) {
        // ok, get the sensor1 depth
        final StringFieldEditor speedOfSoundEditor = new StringFieldEditor(speedOfSoundKey,
                "Speed of Sound (m/sec):", container) {
            @Override
            protected void doLoad() {
                super.doLoad();
                fireValueChanged(FieldEditor.VALUE, null, this.getStringValue());
            }

            protected void fireValueChanged(final String property, final Object oldValue,
                    final Object newValue) {
                super.fireValueChanged(property, oldValue, newValue);

                // is this the value property?
                if (!property.equals(FieldEditor.VALUE))
                    return;

                // is this the value property?
                try {
                    _speedOfSound = MWCXMLReader.readThisDouble(newValue.toString());
                } catch (final ParseException e) {
                    // ignore
                }

                dialogChanged();
                // and remember the new value
                store();
            }

            @Override
            protected boolean doCheckState() {
                return _speedOfSound != null;
            }
        };
        speedOfSoundEditor.setEmptyStringAllowed(false);
        speedOfSoundEditor.setPreferenceStore(getPreferenceStore());
        speedOfSoundEditor.setPage(this);
        speedOfSoundEditor.setErrorMessage("A value for speed of sound must be supplied");
        speedOfSoundEditor.setStringValue("");
        speedOfSoundEditor.load();
        if (speedOfSoundEditor.getStringValue() != null) {
            try {
                _speedOfSound = MWCXMLReader.readThisDouble(speedOfSoundEditor.getStringValue());
            } catch (final ParseException pe) {
                // ignore
            }
        }

        @SuppressWarnings("unused")
        final Label lbl3 = new Label(container, SWT.None);

    }

    // sort out the correct selection lists
    String[][] sensorTypes;
    if (_fileVersion.equals(FlatFileExporter.INITIAL_VERSION)) {
        sensorTypes = sensor1Types;
    } else {
        sensorTypes = sensor2Types;
    }

    // sort out the first sensor
    _sensor1TypeEditor = new RadioGroupFieldEditor(sensor1Key, "Sensor 1 type:", 2, sensorTypes, container) {
        protected void fireValueChanged(final String property, final Object oldValue, final Object newValue) {
            super.fireValueChanged(property, oldValue, newValue);

            // is this the value property?
            if (!property.equals(FieldEditor.VALUE))
                return;

            _sensorType1 = (String) newValue;
            enableAftEditor(container, _sensor1AftEditor, _sensorType1);
            dialogChanged();

            // remember the value
            this.store();

        }

    };
    _sensor1TypeEditor.setPreferenceStore(getPreferenceStore());
    _sensor1TypeEditor.setPage(this);
    _sensor1TypeEditor.load();
    _sensorType1 = getPreferenceStore().getString(sensor1Key);

    @SuppressWarnings("unused")
    final Label lbl = new Label(container, SWT.None);

    // ok, we also need the sensor depth attribute
    if (_fileVersion.equals(FlatFileExporter.UPDATED_VERSION)) {

        // ok, get the sensor1 depth
        final StringFieldEditor sensor1FwdEditor = new StringFieldEditor(sensor1fwdKey,
                "Sensor 1 fwd depth (m):", container) {
            @Override
            protected void doLoad() {
                super.doLoad();
                fireValueChanged(FieldEditor.VALUE, null, this.getStringValue());
            }

            protected void fireValueChanged(final String property, final Object oldValue,
                    final Object newValue) {
                super.fireValueChanged(property, oldValue, newValue);

                // is this the value property?
                if (!property.equals(FieldEditor.VALUE))
                    return;

                try {
                    _sensor1Fwd = MWCXMLReader.readThisDouble(newValue.toString());
                } catch (final ParseException pe) {
                    _sensor1Fwd = null;
                }

                if (_sensor1AftEditor != null)
                    _sensor1AftEditor.setEnabled(!_sensorType1.startsWith("H"), container);

                // we may not have a second editor = get checking
                // if (_sensor2AftEditor != null)
                // _sensor2AftEditor.setEnabled(!_sensorType2.startsWith("H"),
                // container);

                dialogChanged();

                // remember the value
                this.store();
            }

            @Override
            protected boolean doCheckState() {
                return _sensor1Fwd != null;
            }
        };
        sensor1FwdEditor.setEmptyStringAllowed(false);
        sensor1FwdEditor.setPreferenceStore(getPreferenceStore());
        sensor1FwdEditor.setPage(this);
        sensor1FwdEditor.setErrorMessage("A value for Sensor 1 fwd depth must be supplied");
        sensor1FwdEditor.setStringValue("");
        sensor1FwdEditor.load();
        if (sensor1FwdEditor.getStringValue() != null) {
            try {
                _sensor1Fwd = MWCXMLReader.readThisDouble(sensor1FwdEditor.getStringValue());
            } catch (final ParseException pe) {
                // ignore
            }
        }

        @SuppressWarnings("unused")
        final Label lbl2 = new Label(container, SWT.None);

        // ok, get the sensor1 depth
        _sensor1AftEditor = new StringFieldEditor(sensor1aftKey, "Sensor 1 aft depth (m):", container) {
            @Override
            protected void doLoad() {
                super.doLoad();
                fireValueChanged(FieldEditor.VALUE, null, this.getStringValue());
            }

            protected void fireValueChanged(final String property, final Object oldValue,
                    final Object newValue) {
                super.fireValueChanged(property, oldValue, newValue);

                // is this the value property?
                if (!property.equals(FieldEditor.VALUE))
                    return;

                // is this the value property?
                try {
                    _sensor1Aft = MWCXMLReader.readThisDouble(newValue.toString());
                } catch (final ParseException pe) {
                    _sensor1Aft = null;
                }

                dialogChanged();

                // remember this value
                this.store();
            }

            @Override
            protected boolean doCheckState() {
                return _sensor1Aft != null;
            }
        };
        _sensor1AftEditor.setEmptyStringAllowed(false);
        _sensor1AftEditor.setPreferenceStore(getPreferenceStore());
        _sensor1AftEditor.setPage(this);
        _sensor1AftEditor.setErrorMessage("A value for Sensor 1 aft depth must be supplied");
        _sensor1AftEditor.setStringValue("");
        _sensor1AftEditor.load();
        enableAftEditor(container, _sensor1AftEditor, _sensorType1);
        if (_sensor1AftEditor.getStringValue() != null) {
            try {
                _sensor1Aft = MWCXMLReader.readThisDouble(_sensor1AftEditor.getStringValue());
            } catch (final ParseException pe) {
                // ignore
            }
        }

        @SuppressWarnings("unused")
        final Label lbl3b = new Label(container, SWT.None);

    }

    // and now the second sensor
    if (_numSensors > 1) {
        _sensor2TypeEditor = new RadioGroupFieldEditor(sensor2Key, "Sensor 2 type:", 2, sensorTypes,
                container) {
            protected void fireValueChanged(final String property, final Object oldValue,
                    final Object newValue) {
                super.fireValueChanged(property, oldValue, newValue);

                // is this the value property?
                if (!property.equals(FieldEditor.VALUE))
                    return;

                _sensorType2 = (String) newValue;

                enableAftEditor(container, _sensor2AftEditor, _sensorType2);
                dialogChanged();
                // remember this value
                this.store();

            }
        };
        _sensor2TypeEditor.setPreferenceStore(getPreferenceStore());
        _sensor2TypeEditor.setPage(this);
        _sensor2TypeEditor.load();
        _sensorType2 = getPreferenceStore().getString(sensor2Key);

        @SuppressWarnings("unused")
        final Label lbl2 = new Label(container, SWT.None);

        // ok, we also need the sensor depth attribute
        if (_fileVersion.equals(FlatFileExporter.UPDATED_VERSION)) {
            // ok, get the sensor1 depth
            final StringFieldEditor sensor2FwdEditor = new StringFieldEditor(sensor2fwdKey,
                    "Sensor 2 fwd depth (m):", container) {
                @Override
                protected void doLoad() {
                    super.doLoad();
                    fireValueChanged(FieldEditor.VALUE, null, this.getStringValue());
                }

                protected void fireValueChanged(final String property, final Object oldValue,
                        final Object newValue) {
                    super.fireValueChanged(property, oldValue, newValue);

                    // is this the value property?
                    if (!property.equals(FieldEditor.VALUE))
                        return;

                    // is this the value property?                  
                    try {
                        _sensor2Fwd = MWCXMLReader.readThisDouble(newValue.toString());
                        dialogChanged();
                        // remember this value
                        this.store();
                    } catch (final ParseException pe) {
                        _sensor2Fwd = null;
                    }
                }

                @Override
                protected boolean doCheckState() {
                    return _sensor2Fwd != null;
                }
            };
            sensor2FwdEditor.setEmptyStringAllowed(false);
            sensor2FwdEditor.setPreferenceStore(getPreferenceStore());
            sensor2FwdEditor.setPage(this);
            sensor2FwdEditor.setErrorMessage("A value for Sensor 2 fwd depth must be supplied");
            sensor2FwdEditor.load();
            if (sensor2FwdEditor.getStringValue() != null) {
                try {
                    _sensor2Fwd = MWCXMLReader.readThisDouble(sensor2FwdEditor.getStringValue());
                } catch (final ParseException pe) {
                    // ignore
                }
            }

            @SuppressWarnings("unused")
            final Label lbl3 = new Label(container, SWT.None);

            // ok, get the sensor1 depth
            _sensor2AftEditor = new StringFieldEditor(sensor2aftKey, "Sensor 2 aft depth (m):", container) {
                @Override
                protected void doLoad() {
                    super.doLoad();
                    fireValueChanged(FieldEditor.VALUE, null, this.getStringValue());
                }

                protected void fireValueChanged(final String property, final Object oldValue,
                        final Object newValue) {
                    super.fireValueChanged(property, oldValue, newValue);

                    // is this the value property?
                    if (!property.equals(FieldEditor.VALUE))
                        return;

                    // is this the value property?
                    try {
                        _sensor2Aft = MWCXMLReader.readThisDouble(newValue.toString());
                    } catch (final ParseException pe) {
                        _sensor2Aft = null;
                    }
                    // remember this value
                    this.store();

                    dialogChanged();
                }

                @Override
                protected boolean doCheckState() {
                    return _sensor2Aft != null;
                }
            };
            _sensor2AftEditor.setEmptyStringAllowed(false);
            _sensor2AftEditor.setPreferenceStore(getPreferenceStore());
            _sensor2AftEditor.setPage(this);

            _sensor2AftEditor.setErrorMessage("A value for Sensor 2 aft depth must be supplied");
            _sensor2AftEditor.load();
            enableAftEditor(container, _sensor2AftEditor, _sensorType2);

            if (_sensor2AftEditor.getStringValue() != null) {
                try {
                    _sensor2Aft = MWCXMLReader.readThisDouble(_sensor2AftEditor.getStringValue());
                } catch (final ParseException pe) {
                    // ignore
                }
            }

            @SuppressWarnings("unused")
            final Label lbl4 = new Label(container, SWT.None);

        }
    }

    if (_fileVersion.equals(FlatFileExporter.UPDATED_VERSION)) {

        // we also want to specify the prot marking editor
        _protMarkingEditor = new StringFieldEditor(protMarkKey, "Protective Marking:", container) {
            protected void fireValueChanged(final String property, final Object oldValue,
                    final Object newValue) {
                super.fireValueChanged(property, oldValue, newValue);

                // is this the value property?
                if (!property.equals(FieldEditor.VALUE))
                    return;

                _protMarking = (String) newValue;
                dialogChanged();

                // remember this value
                this.store();
            }

            @Override
            protected boolean doCheckState() {
                return _protMarking != null;
            }
        };
        _protMarkingEditor.setEmptyStringAllowed(false);
        _protMarkingEditor.setPreferenceStore(getPreferenceStore());
        _protMarkingEditor.setPage(this);
        _protMarkingEditor.setErrorMessage("A value for protective marking must be supplied");
        _protMarkingEditor.setStringValue("");
        _protMarkingEditor.load();
        _protMarking = _protMarkingEditor.getStringValue();

        @SuppressWarnings("unused")
        final Label lbl3 = new Label(container, SWT.None);

    }

    // we also want to specify the serial nane (for single or double sensors)
    _serialNameEditor = new StringFieldEditor(serialKey, "Serial name:", container) {
        protected void fireValueChanged(final String property, final Object oldValue, final Object newValue) {
            super.fireValueChanged(property, oldValue, newValue);

            // is this the value property?
            if (!property.equals(FieldEditor.VALUE))
                return;

            _serialName = (String) newValue;
            dialogChanged();

            // remember this value
            this.store();
        }

        @Override
        protected boolean doCheckState() {
            return _serialName != null;
        }

    };
    _serialNameEditor.setPreferenceStore(getPreferenceStore());
    _serialNameEditor.setPage(this);
    _serialNameEditor.setEmptyStringAllowed(false);
    _serialNameEditor.setErrorMessage("The serial name must be supplied");
    _serialNameEditor.load();
    _serialName = _serialNameEditor.getStringValue();

    final GridLayout urlLayout = (GridLayout) container.getLayout();
    urlLayout.numColumns = 3;

    container.layout();
    setControl(container);
}

From source file:org.polymap.core.data.image.cache304.ImageCacheProcessorConfig.java

License:Open Source License

protected void createFieldEditors() {
    noDefaultAndApplyButton();//from   w  w w.  j  a v  a  2 s  .  c om

    TypedProperties params = new TypedProperties(props);

    Integer value = null;

    timeToLiveField = new IntegerFieldEditor(Cache304.PROP_MAX_TILE_LIVETIME, "Max tile livetime (hours)",
            getFieldEditorParent());
    timeToLiveField.setValidRange(0, 100000);
    value = params.getInt(Cache304.PROP_MAX_TILE_LIVETIME, Cache304.DEFAULT_MAX_TILE_LIVETIME);
    timeToLiveField.setStringValue(String.valueOf(value));
    addField(timeToLiveField);

    maxTotalSizeField = new IntegerFieldEditor(Cache304.PREF_TOTAL_STORE_SIZE, "Max total size (MB)",
            getFieldEditorParent());
    maxTotalSizeField.setValidRange(1, 100000);
    maxTotalSizeField.setStringValue(mbFormat.format(cache.getMaxTotalSize() / 1024 / 1024));
    addField(maxTotalSizeField);

    // statistics
    //new SeparatorFieldEditor( "sep1", "", getFieldEditorParent() );

    CacheStatistics stats = Cache304.statistics();

    // hit count
    Composite fieldParent = getFieldEditorParent();
    StringFieldEditor hitsField = new StringFieldEditor("hits", "Cache hits", fieldParent);
    hitsField.setEnabled(false, fieldParent);
    hitsField.setStringValue(mbFormat.format(stats.layerHitCount((ILayer) holder)));

    // miss count
    fieldParent = getFieldEditorParent();
    StringFieldEditor missField = new StringFieldEditor("misses", "Cache misses", fieldParent);
    missField.setEnabled(false, fieldParent);
    missField.setStringValue(mbFormat.format(stats.layerMissCount((ILayer) holder)));

    // layer size
    fieldParent = getFieldEditorParent();
    StringFieldEditor layerSizeField = new StringFieldEditor("layerSize", "Layer cache size (MB)", fieldParent);
    layerSizeField.setEnabled(false, fieldParent);
    layerSizeField.setStringValue(
            mbFormat.format((double) stats.layerStoreSize(cache, (ILayer) holder) / 1024 / 1024));

    // layer tile count
    fieldParent = getFieldEditorParent();
    StringFieldEditor tileCountField = new StringFieldEditor("tileCount", "Tiles", fieldParent);
    tileCountField.setEnabled(false, fieldParent);
    tileCountField.setStringValue(mbFormat.format(stats.layerTileCount(cache, (ILayer) holder)));

    // store size
    fieldParent = getFieldEditorParent();
    StringFieldEditor totalSizeField = new StringFieldEditor("totalSize", "Total cache size (MB)", fieldParent);
    totalSizeField.setEnabled(false, fieldParent);
    totalSizeField.setStringValue(mbFormat.format((double) stats.totalStoreSize(cache) / 1024 / 1024));
}

From source file:org.polymap.service.ui.OwsPropertiesPage.java

License:Open Source License

protected void createFieldEditors() {
    IPreferenceStore store = new PreferenceStore() {
        public boolean needsSaving() {
            return false;
        }//  ww  w  . jav  a2  s. c om
    };
    setPreferenceStore(store);
    store.setDefault("WMS", providedService.isEnabled());
    store.setDefault("WFS", false);
    store.setDefault(IProvidedService.PROP_PATHSPEC, providedService.getPathSpec());
    store.setDefault(IProvidedService.PROP_SRS, StringUtils.join(providedService.getSRS(), ", "));

    Composite pathParent = getFieldEditorParent();
    Composite uriParent = getFieldEditorParent();

    // URI
    final StringFieldEditor uriField = new StringFieldEditor("URI", "URI*", uriParent);
    addField(uriField);
    uriField.setStringValue(ServicesPlugin.createServiceUrl(providedService.getPathSpec()));
    uriField.getTextControl(uriParent).setToolTipText("The complete URI of this service.");
    uriField.setEnabled(false, uriParent);

    // service path
    StringFieldEditor pathField = new StringFieldEditor(IProvidedService.PROP_PATHSPEC, "Service Name/Pfad",
            pathParent) {

        protected boolean doCheckState() {
            String value = getStringValue();
            uriField.setStringValue(ServicesPlugin.createServiceUrl(value));

            String validName = ServicesPlugin.validPathSpec(value);
            if (!value.equals(validName)) {
                setErrorMessage("Der Name darf nur Buchstaben, Zahlen oder '-', '_', '.' enthalten.");
                return false;
            }
            return true;
        }
    };
    addField(pathField);

    // WMS
    BooleanFieldEditor wmsField = new BooleanFieldEditor("WMS", "WMS aktivieren", getFieldEditorParent());
    addField(wmsField);

    // WFS
    BooleanFieldEditor wfsField = new BooleanFieldEditor("WFS", "WFS aktivieren", getFieldEditorParent());
    //        wfsField.setEnabled( false, getFieldEditorParent() );

    // SRS
    //        Composite parent = getFieldEditorParent();
    //        StringFieldEditor srsField = new StringFieldEditor(
    //                IProvidedService.PROP_SRS, "Koordinatensysteme*", parent );
    //        srsField.getLabelControl( parent )
    //                .setToolTipText( "Komma-separierte Liste mit EPSG-Codes: EPSG:31468, EPSG:4326, ..." );
    //        addField( srsField );

    // load default values
    performDefaults();
}

From source file:org.talend.designer.esb.runcontainer.preferences.RunContainerPreferencePage.java

License:Open Source License

/**
 * Create contents of the preference page.
 * //w w  w .java  2s.  co m
 * @param parent
 */
@Override
public Control createPageContents(Composite parent) {
    serverFieldEditors = new ArrayList<FieldEditor>();
    optionFieldEditors = new ArrayList<FieldEditor>();
    runtimeEnable = getPreferenceStore().getBoolean(RunContainerPreferenceInitializer.P_ESB_IN_OSGI);
    GridLayout gridLayoutDefault = new GridLayout(1, false);

    Composite body = new Composite(parent, SWT.NONE);
    body.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    body.setLayout(gridLayoutDefault);
    getPreferenceStore().getBoolean(RunContainerPreferenceInitializer.P_ESB_IN_OSGI);
    useOSGiEditor = new BooleanFieldEditor(RunContainerPreferenceInitializer.P_ESB_IN_OSGI,
            "ESB Studio Runtime - Use Local Talend Runtime (OSGi Container)", body);
    addField(useOSGiEditor);
    Label lblNote = new Label(body, SWT.WRAP);
    lblNote.setText("Note: It will be only taken into account for an ESB Artifact:\n"
            + "   A Route (Any Route)\n" + "   A DataService (SOAP/REST)\n"
            + "   A Job contains tRESTClient or tESBConsumer component");

    Group groupServer = new Group(body, SWT.NONE);
    groupServer.setText(RunContainerMessages.getString("RunContainerPreferencePage.Group1")); //$NON-NLS-1$
    groupServer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupServer.setLayout(new GridLayout(2, false));

    compositeServerBody = new Composite(groupServer, SWT.NONE);
    compositeServerBody.setLayout(gridLayoutDefault);
    compositeServerBody.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    StringFieldEditor locationEditor = new StringFieldEditor(
            RunContainerPreferenceInitializer.P_ESB_RUNTIME_LOCATION,
            RunContainerMessages.getString("RunContainerPreferencePage.Location"), compositeServerBody); //$NON-NLS-1$
    addField(locationEditor);
    serverFieldEditors.add(locationEditor);

    StringFieldEditor hostFieldEditor = new StringFieldEditor(
            RunContainerPreferenceInitializer.P_ESB_RUNTIME_HOST,
            RunContainerMessages.getString("RunContainerPreferencePage.Host"), compositeServerBody);
    addField(hostFieldEditor);
    // only support local runtime server, if need support remote server ,enable this editor
    hostFieldEditor.setEnabled(false, compositeServerBody);

    StringFieldEditor userFieldEditor = new StringFieldEditor(
            RunContainerPreferenceInitializer.P_ESB_RUNTIME_USERNAME,
            RunContainerMessages.getString("RunContainerPreferencePage.Username"), compositeServerBody); //$NON-NLS-1$
    addField(userFieldEditor);
    serverFieldEditors.add(userFieldEditor);
    StringFieldEditor passwordFieldEditor = new StringFieldEditor(
            RunContainerPreferenceInitializer.P_ESB_RUNTIME_PASSWORD,
            RunContainerMessages.getString("RunContainerPreferencePage.Password"), compositeServerBody); //$NON-NLS-1$
    addField(passwordFieldEditor);
    serverFieldEditors.add(passwordFieldEditor);
    StringFieldEditor instanceFieldEditor = new StringFieldEditor(
            RunContainerPreferenceInitializer.P_ESB_RUNTIME_INSTANCE,
            RunContainerMessages.getString("RunContainerPreferencePage.Instance"), compositeServerBody); //$NON-NLS-1$
    addField(instanceFieldEditor);
    serverFieldEditors.add(instanceFieldEditor);

    IntegerFieldEditor portFieldEditor = new IntegerFieldEditor(
            RunContainerPreferenceInitializer.P_ESB_RUNTIME_PORT,
            RunContainerMessages.getString("RunContainerPreferencePage.Port"), compositeServerBody); //$NON-NLS-1$
    addField(portFieldEditor);
    serverFieldEditors.add(portFieldEditor);

    StringFieldEditor jmxPortFieldEditor = new StringFieldEditor(
            RunContainerPreferenceInitializer.P_ESB_RUNTIME_JMX_PORT,
            RunContainerMessages.getString("RunContainerPreferencePage.JMXPort"), compositeServerBody); //$NON-NLS-1$
    addField(jmxPortFieldEditor);
    serverFieldEditors.add(jmxPortFieldEditor);

    Composite compBtn = new Composite(groupServer, SWT.NONE);
    GridData gridDataBtn = new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1);
    gridDataBtn.widthHint = 100;
    compBtn.setLayoutData(gridDataBtn);
    GridLayout layoutCompBtn = new GridLayout(1, false);
    layoutCompBtn.marginWidth = 0;
    layoutCompBtn.marginHeight = 0;

    compBtn.setLayout(layoutCompBtn);
    buttonAddServer = new Button(compBtn, SWT.NONE);
    buttonAddServer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    buttonAddServer.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            AddRuntimeWizard dirWizard = new AddRuntimeWizard(locationEditor.getStringValue());
            dirWizard.setNeedsProgressMonitor(true);
            WizardDialog wizardDialog = new WizardDialog(getShell(), dirWizard);
            if (wizardDialog.open() == Window.OK) {
                locationEditor.setStringValue(dirWizard.getTarget());
            }
        }
    });
    buttonAddServer.setText(RunContainerMessages.getString("RunContainerPreferencePage.ServerButton")); //$NON-NLS-1$

    // Button btnTestConnection = new Button(compBtn, SWT.NONE);
    // btnTestConnection.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    // btnTestConnection.setText("Server Info...");

    buttonInitalizeServer = new Button(compBtn, SWT.NONE);
    buttonInitalizeServer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    buttonInitalizeServer.setText(RunContainerMessages.getString("RunContainerPreferencePage.InitalizeButton")); //$NON-NLS-1$
    buttonInitalizeServer.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (initalizeRuntime(locationEditor.getStringValue(), hostFieldEditor.getStringValue())) {
                try {
                    new InitFinishMessageDialog(getShell(), JMXUtil.getBundlesName()).open();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    });

    Group groupOption = new Group(body, SWT.NONE);
    groupOption.setLayout(gridLayoutDefault);
    groupOption.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    groupOption.setText(RunContainerMessages.getString("RunContainerPreferencePage.Group2")); //$NON-NLS-1$

    compositeOptionBody = new Composite(groupOption, SWT.NONE);
    compositeOptionBody.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    BooleanFieldEditor filterLogEditor = new BooleanFieldEditor(
            RunContainerPreferenceInitializer.P_ESB_RUNTIME_SYS_LOG,
            RunContainerMessages.getString("RunContainerPreferencePage.FilterLogs"), compositeOptionBody); //$NON-NLS-1$
    addField(filterLogEditor);
    optionFieldEditors.add(filterLogEditor);

    manager = ProcessManager.getInstance();
    return body;
}

From source file:org.wesnoth.preferences.WesnothInstallsPage.java

License:Open Source License

/**
 * Tests the list of paths and if any path exists it will
 * set it as the string value to the field editor
 * if the field editor value is empty/*from w  w  w .j  a v a  2s  . c o m*/
 * 
 * @param list
 *        The list to search in
 * @param field
 *        The field to put the path in
 */
private void testAndSetPaths(String[] list, StringFieldEditor field) {
    if (!(field.getStringValue().isEmpty())) {
        return;
    }

    for (String path : list) {
        if (new File(path).exists()) {
            field.setStringValue(path);
            return;
        }
    }
}

From source file:org.wesnoth.preferences.WesnothPreferencesPage.java

License:Open Source License

/**
 * Tests the list of paths and if any path exists will
 * set it as the string value to the field editor
 * @param list The list to search in//from  www.  j  av a  2  s .  c  om
 * @param field The field to put the path in
 */
private void testPaths(String[] list, StringFieldEditor field) {
    if (!(field.getStringValue().isEmpty()))
        return;

    for (String path : list) {
        if (new File(path).exists()) {
            field.setStringValue(path);
            return;
        }
    }
}

From source file:pl.poznan.put.cs.gui4pddl.preferences.ui.PlannerPreferencesPageTabItem.java

License:Open Source License

private StringFieldEditor createPlannerNameFieldEditor(Composite tabItemComposite) {
    StringFieldEditor plannerName = new StringFieldEditor("Planner Name", "Planner Name", tabItemComposite);
    plannerName.fillIntoGrid(tabItemComposite, 3);
    plannerName.setEmptyStringAllowed(false);
    plannerName.setStringValue(preferences.getPlannerName());

    return plannerName;
}