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

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

Introduction

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

Prototype

public void load() 

Source Link

Document

Initializes this field editor with the preference value from the preference store.

Usage

From source file:com.amazonaws.eclipse.core.ui.preferences.AwsAccountPreferencePage.java

License:Apache License

protected void setUpFieldEditor(String currentAccount, String preferenceKey, Composite parent,
        StringFieldEditor fieldEditor) {
    fieldEditor.setPage(this);
    fieldEditor.setPreferenceStore(this.getPreferenceStore());
    fieldEditor.load();

    // For backwards compatibility with single-account storage
    if (accountNamesByIdentifier.get(currentAccount) != null
            && accountNamesByIdentifier.get(currentAccount).equals(PreferenceConstants.DEFAULT_ACCOUNT_NAME)
            && (fieldEditor.getStringValue() == null || fieldEditor.getStringValue().length() == 0)) {
        String currentPrefValue = getPreferenceStore().getString(preferenceKey);
        if (ObfuscatingStringFieldEditor.isBase64(currentPrefValue)) {
            currentPrefValue = ObfuscatingStringFieldEditor.decodeString(currentPrefValue);
        }//from   w  ww.j av  a 2 s .  com
        fieldEditor.setStringValue(currentPrefValue);
    }

    fieldEditor.fillIntoGrid(parent, LAYOUT_COLUMN_WIDTH);
    fieldEditor.getTextControl(parent).addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            updatePageValidation();
        }
    });
}

From source file:com.blackducksoftware.integration.eclipseplugin.preferences.BlackDuckPreferences.java

License:Apache License

private StringFieldEditor createStringField(String preferenceName, String label, Composite composite,
        boolean integerValidation) {
    StringFieldEditor editor;
    if (integerValidation) {
        // String field editor w/ integer validation, we can make this a separate class if we need to.
        editor = new StringFieldEditor(preferenceName, label, composite) {
            @Override/*from w w  w .java 2  s  .  c  o m*/
            protected boolean checkState() {
                setErrorMessage(JFaceResources.getString(INTEGER_FIELD_EDITOR_ERROR_STRING));
                Text text = getTextControl();
                if (text == null) {
                    return false;
                }
                String intString = text.getText();
                if (intString.isEmpty()) {
                    clearErrorMessage();
                    return true;
                }
                try {
                    Integer.valueOf(intString).intValue();
                } catch (NumberFormatException nfe) {
                    showErrorMessage();
                }
                return false;
            }
        };
    } else {
        editor = new StringFieldEditor(preferenceName, label, composite);
    }
    editor.setPage(this);
    editor.setPreferenceStore(this.getPreferenceStore());
    editor.fillIntoGrid(composite, NUM_COLUMNS);
    editor.load();
    return editor;
}

From source file:net.mldonkey.g2gui.view.pref.G2GuiPref.java

License:Open Source License

protected void createFieldEditors() {

    Composite composite = getFieldEditorParent();
    StringFieldEditor hostNameField = new StringFieldEditor("hostname", "Hostname", composite);

    hostNameField.setPreferenceStore(this.getPreferenceStore());
    hostNameField.fillIntoGrid(composite, 2);
    addField(hostNameField);//from   w  w  w .  j  a va2 s .c om
    hostNameField.load();

    StringFieldEditor portField = new StringFieldEditor("port", "Port", composite);
    portField.setPreferenceStore(this.getPreferenceStore());
    portField.fillIntoGrid(composite, 2);
    addField(portField);
    portField.load();

    StringFieldEditor userNameField = new StringFieldEditor("username", "Username", composite);
    userNameField.setPreferenceStore(this.getPreferenceStore());
    userNameField.fillIntoGrid(composite, 2);
    addField(userNameField);
    userNameField.load();

    StringFieldEditor passwordField = new StringFieldEditor("password", "Password", composite);
    passwordField.getTextControl(composite).setEchoChar('*');
    passwordField.fillIntoGrid(composite, 2);
    passwordField.setPreferenceStore(this.getPreferenceStore());
    addField(passwordField);
    passwordField.load();

    GCJFileFieldEditor executableField = new GCJFileFieldEditor("coreExecutable",
            G2GuiResources.getString("PREF_CORE_EXEC"), true, composite);
    executableField.setPreferenceStore(this.getPreferenceStore());
    addField(executableField);
    executableField.load();

    if (VersionCheck.isWin32()) {
        executableField.setFileExtensions(new String[] { "*.exe;*.bat" });
    } else {
        executableField.setFileExtensions(new String[] { "*" });
    }

    FieldEditor mulitpleInstancesEditor = new BooleanFieldEditor("allowMultipleInstances",
            G2GuiResources.getString("PREF_ALLOW_MULIPLE"), composite);
    mulitpleInstancesEditor.setPreferenceStore(this.getPreferenceStore());
    mulitpleInstancesEditor.fillIntoGrid(composite, 2);
    addField(mulitpleInstancesEditor);
    mulitpleInstancesEditor.load();

    ExtendedBooleanFieldEditor advancedModeEditor = new ExtendedBooleanFieldEditor("advancedMode",
            "Advanced user mode (*)", composite);
    advancedModeEditor.setPreferenceStore(this.getPreferenceStore());
    advancedModeEditor.fillIntoGrid(composite, 2);

    addField(advancedModeEditor);
    advancedModeEditor.load();

    // Make this a little more obvious
    Button b = advancedModeEditor.getChangeControl(composite);
    b.setFont(JFaceResources.getBannerFont());
    b.setToolTipText(G2GuiResources.getString("PREF_ADVANCED_TOOLTIP"));
    b.setForeground(composite.getDisplay().getSystemColor(SWT.COLOR_BLUE));

    ((GridLayout) composite.getLayout()).numColumns = 2;
}

From source file:org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.EnvironmentVariablesPreferencePage.java

License:Open Source License

/**
 * Creates and returns a StringFieldEditor object with preferences set to it.
 *
 * @param name Name of the field.//www .j a va2 s  .c o  m
 * @param lblText Label text of the field.
 * @param parent Composite object parent of the object.
 *
 * @return The created and configued StringFieldEditor ojbect.
 */
private StringFieldEditor createStringFieldEditor(String name, String lblText, Composite parent) {
    StringFieldEditor sfe = new StringFieldEditor(name, lblText, parent);
    sfe.setPage(this);
    sfe.setPreferenceStore(getPreferenceStore());
    sfe.load();

    return sfe;
}

From source file:org.eclipse.linuxtools.systemtap.ui.systemtapgui.preferences.EnvironmentVariablesPreferencePage.java

License:Open Source License

/**
 * Creates and returns a StringFieldEditor object with preferences set to it.
 *
 * @param name Name of the field./* w ww .  j  ava 2s.c o m*/
 * @param lblText Label text of the field.
 * @param parent Composite object parent of the object.
 * 
 * @return The created and configued StringFieldEditor ojbect.
 */
private StringFieldEditor createStringFieldEditor(String name, String lblText, Composite parent) {
    LogManager.logDebug(
            "Start createStringFieldEditor: name-" + name + ", lblText-" + lblText + ", parent-" + parent,
            this);
    StringFieldEditor sfe = new StringFieldEditor(name, lblText, parent);
    sfe.setPage(this);
    sfe.setPreferenceStore(getPreferenceStore());
    sfe.load();

    LogManager.logDebug("End createStringFieldEditor: returnVal-" + sfe, this);
    return sfe;
}

From source file:org.jboss.tools.feedhenry.ui.cordova.internal.preferences.FeedHenryPreferencesPage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    final Composite parent = getFieldEditorParent();
    parent.setFont(getControl().getFont());

    // FH target URL
    final URLFieldEditor targetUrlField = new URLFieldEditor(PREF_TARGET_URL, LABEL_TARGET_URL, parent);
    targetUrlField.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST);
    targetUrlField.setPreferenceStore(getPreferenceStore());
    targetUrlField.setPage(this);
    targetUrlField.load();//from   ww  w .  j a v a  2  s .  co  m
    targetUrlField.setPropertyChangeListener(this);
    targetUrlField.getTextControl(parent).setMessage(MESSAGE_TARGET_URL);
    addField(targetUrlField);

    // API key
    final StringFieldEditor apikeyField = new StringFieldEditor(PREF_API_KEY, LABEL_API_KEY, parent);
    apikeyField.setPreferenceStore(getPreferenceStore());
    apikeyField.setPage(this);
    apikeyField.load();
    addField(apikeyField);
}

From source file:org.maven.ide.eclipse.preferences.Maven2PreferencePage.java

License:Apache License

    public void createFieldEditors() {
            //    addField(new DirectoryFieldEditor(Maven2PreferenceConstants.P_LOCAL_REPOSITORY_DIR, 
            //        Messages.getString("preferences.localRepositoryFolder"), //$NON-NLS-1$
            //        getFieldEditorParent()));

            // addField( new BooleanFieldEditor( Maven2PreferenceConstants.P_CHECK_LATEST_PLUGIN_VERSION, 
            //     Messages.getString( "preferences.checkLastPluginVersions" ), //$NON-NLS-1$
            //     getFieldEditorParent() ) );

            addField(new BooleanFieldEditor(Maven2PreferenceConstants.P_OFFLINE,
                    Messages.getString("preferences.offline"), //$NON-NLS-1$
                    getFieldEditorParent()));

            // addField( new BooleanFieldEditor( Maven2PreferenceConstants.P_UPDATE_SNAPSHOTS, 
            //     Messages.getString( "preferences.updateSnapshots" ), //$NON-NLS-1$
            //     getFieldEditorParent() ) );

            addField(new BooleanFieldEditor(Maven2PreferenceConstants.P_DOWNLOAD_SOURCES,
                    Messages.getString("preferences.downloadSources"), //$NON-NLS-1$
                    getFieldEditorParent()));

            addField(new BooleanFieldEditor(Maven2PreferenceConstants.P_DOWNLOAD_JAVADOC,
                    Messages.getString("preferences.downloadJavadoc"), //$NON-NLS-1$
                    getFieldEditorParent()));

            /*//from w ww.j  a va 2 s . c  om
             * public static final String CHECKSUM_POLICY_FAIL = "fail"; 
             * public static final String CHECKSUM_POLICY_WARN = "warn"; 
             * public static final String CHECKSUM_POLICY_IGNORE = "ignore";
             */
            //    addField(new RadioGroupFieldEditor(Maven2PreferenceConstants.P_GLOBAL_CHECKSUM_POLICY, 
            //        Messages.getString("preferences.globalChecksumPolicy"), 1, //$NON-NLS-1$
            //        new String[][] {
            //            {Messages.getString("preferences.checksumPolicyFail"), ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL}, //$NON-NLS-1$
            //            {Messages.getString("preferences.checksumPolicyIgnore"), ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE}, //$NON-NLS-1$
            //            {Messages.getString("preferences.checksumPolicyWarn"), ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN}}, //$NON-NLS-1$  // DEFAULT
            //        getFieldEditorParent(), true));
            // addField( new StringFieldEditor( Maven2PreferenceConstants.P_OFFLINE,
            // "A &text preference:",
            // getFieldEditorParent()));
            addField(new BooleanFieldEditor(Maven2PreferenceConstants.P_DEBUG_OUTPUT, //
                    Messages.getString("preferences.debugOutput"), //$NON-NLS-1$
                    getFieldEditorParent()));

            globalSettingsEditor = new FileFieldEditor(Maven2PreferenceConstants.P_GLOBAL_SETTINGS_FILE, //
                    Messages.getString("preferences.globalSettingsFile"), getFieldEditorParent()) {
//$NON-NLS-0$
                {
                    setValidateStrategy(VALIDATE_ON_KEY_STROKE);
                }

                protected boolean doCheckState() {
                    return checkSettings(getStringValue());
                }
            };

            addField(new StringFieldEditor("", Messages.getString("preferences.userSettingsFile"), //$NON-NLS-1$
                    getFieldEditorParent()) {
                protected void doLoad() {
                    getTextControl().setEditable(false);
                    getTextControl().setText(MavenEmbedder.DEFAULT_USER_SETTINGS_FILE.getAbsolutePath());
                }

                protected void doLoadDefault() {
                    getTextControl().setEditable(false);
                    getTextControl().setText(MavenEmbedder.DEFAULT_USER_SETTINGS_FILE.getAbsolutePath());
                }

                protected void doStore() {
                }

                protected boolean doCheckState() {
                    return true;
                }
            });

            final StringFieldEditor localRepositoryEditor = new StringFieldEditor("", //$NON-NLS-1$
                    Messages.getString("preferences.localRepository"), getFieldEditorParent()) {
                protected void doLoad() {
                    getTextControl().setEditable(false);
                    getTextControl().setText(Maven2Plugin.getDefault().getMavenEmbedderManager().getLocalRepositoryDir()
                            .getAbsolutePath());
                }

                protected void doLoadDefault() {
                    getTextControl().setEditable(false);
                    getTextControl().setText(Maven2Plugin.getDefault().getMavenEmbedderManager().getLocalRepositoryDir()
                            .getAbsolutePath());
                }

                protected void doStore() {
                }

                protected boolean doCheckState() {
                    return true;
                }
            };
            addField(localRepositoryEditor);

            addField(globalSettingsEditor);

            GridData buttonsCompositeGridData = new GridData();
            buttonsCompositeGridData.verticalIndent = 15;
            buttonsCompositeGridData.horizontalSpan = 2;

            Composite buttonsComposite = new Composite(getFieldEditorParent(), SWT.NONE);
            buttonsComposite.setLayout(new RowLayout());
            buttonsComposite.setLayoutData(buttonsCompositeGridData);

            Button reindexButton = new Button(buttonsComposite, SWT.NONE);
            reindexButton.setText(Messages.getString("preferences.reindexButton"));
            reindexButton.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    plugin.getMavenEmbedderManager().invalidateMavenSettings();
                    plugin.getMavenRepositoryIndexManager().reindexLocal(0L);
                }
            });

            Button refreshButton = new Button(buttonsComposite, SWT.NONE);
            refreshButton.setText(Messages.getString("preferences.refreshButton"));
            refreshButton.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    plugin.getMavenEmbedderManager().invalidateMavenSettings();
                    localRepositoryEditor.load();
                }
            });
        }

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

License:Open Source License

/**
 * @see IDialogPage#createControl(Composite)
 *///from   ww  w.  j a  va 2 s  .co 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.robotframework.ide.eclipse.main.plugin.preferences.DefaultLaunchConfigurationPreferencePage.java

License:Apache License

private void createRobotLaunchConfigurationPreferences(final Composite parent) {
    final Group group = new Group(parent, SWT.NONE);
    group.setText("Robot tab");
    GridLayoutFactory.fillDefaults().applyTo(group);
    GridDataFactory.fillDefaults().grab(true, false).indent(0, 10).span(2, 1).applyTo(group);

    final StringFieldEditor additionalRobotArguments = new StringFieldEditor(
            RedPreferences.LAUNCH_ADDITIONAL_ROBOT_ARGUMENTS, "Additional Robot Framework arguments:", group);
    additionalRobotArguments.load();
    addField(additionalRobotArguments);//w w  w  .  j a  v  a2  s  . co m

    GridDataFactory.fillDefaults().grab(true, false).applyTo(additionalRobotArguments.getLabelControl(group));
}

From source file:org.robotframework.ide.eclipse.main.plugin.preferences.DefaultLaunchConfigurationPreferencePage.java

License:Apache License

private void createExecutorLaunchConfigurationPreferences(final Composite parent) {
    final Group group = new Group(parent, SWT.NONE);
    group.setText("Executor tab");
    GridLayoutFactory.fillDefaults().applyTo(group);
    GridDataFactory.fillDefaults().grab(true, false).indent(0, 10).span(2, 1).applyTo(group);

    final StringFieldEditor additionalInterpreterArguments = new StringFieldEditor(
            RedPreferences.LAUNCH_ADDITIONAL_INTERPRETER_ARGUMENTS, "Additional interpreter arguments:", group);
    additionalInterpreterArguments.load();
    addField(additionalInterpreterArguments);

    final FileFieldEditor scriptPathEditor = new FileFieldEditor(RedPreferences.LAUNCH_EXECUTABLE_FILE_PATH,
            "Executable file:", true, StringFieldEditor.VALIDATE_ON_KEY_STROKE, group);
    scriptPathEditor.setFileExtensions(RobotLaunchConfiguration.getSystemDependentExecutableFileExtensions());
    scriptPathEditor.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile());
    scriptPathEditor.load();//from w  w w .jav a  2s  .c  om
    addField(scriptPathEditor);

    final StringFieldEditor additionalScriptArguments = new StringFieldEditor(
            RedPreferences.LAUNCH_ADDITIONAL_EXECUTABLE_FILE_ARGUMENTS, "Additional executable file arguments:",
            group);
    additionalScriptArguments.load();
    addField(additionalScriptArguments);

    GridDataFactory.fillDefaults().span(2, 1).applyTo(scriptPathEditor.getLabelControl(group));
}