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

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

Introduction

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

Prototype

public StringFieldEditor(String name, String labelText, Composite parent) 

Source Link

Document

Creates a string field editor of unlimited width.

Usage

From source file:org.limy.eclipse.code.LimyCodePropertyPage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {

    IAdaptable resource = getElement();/*  w  w  w.  ja v a 2 s. c  o m*/
    IProject project = (IProject) resource.getAdapter(IProject.class);
    ScopedPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project),
            LimyCodePlugin.getDefault().getBundle().getSymbolicName());
    setPreferenceStore(store);

    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new FormLayout());

    initField(new StringFieldEditor(LimyCodeConstants.PREF_PROJECT_NAME, "Project Name : ", comp));

    return comp;
}

From source file:org.limy.eclipse.code.preference.LimyCodePreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    System.out.println(parent.getLayout());
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());

    FileFieldEditor gnuHeaderFile = new FileFieldEditor(LimyCodeConstants.PREF_JAVA_HEADER,
            "Java Header Text File : ", comp);
    gnuHeaderFile.setFileExtensions(new String[] { "*.txt" });

    FileFieldEditor javadocProp = new FileFieldEditor(LimyCodeConstants.PREF_PROP_PATH,
            "Javadoc Comment File : ", comp);

    initField(gnuHeaderFile);/* w w  w.  ja  v a 2 s . c o m*/
    initField(javadocProp);

    Button button = new Button(comp, SWT.NONE);
    button.setText("&Edit...");
    button.setLayoutData(GridDataCreator.createHorizontalSpan(3, SWT.RIGHT));
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            String path = LimyCodePlugin.getDefault().getPreferenceStore()
                    .getString(LimyCodeConstants.PREF_PROP_PATH);
            if (path != null && path.length() > 0) {
                JavadocPropDialog dialog = new JavadocPropDialog(getShell(), new File(path));
                dialog.open();
            } else {
                LimySwtUtils.showAlertDialog(LimyCodePlugin.getResourceString("not.specified.javadoc.file"));
            }
        }
    });

    Composite comp2 = new Composite(parent, SWT.NONE);
    comp2.setLayout(new GridLayout());
    comp2.setLayoutData(GridDataCreator.createFillGrab());

    StringFieldEditor getter = new StringFieldEditor(LimyCodeConstants.PREF_GETTER_DESC,
            "Getter-method Description : ", comp2);

    StringFieldEditor setter = new StringFieldEditor(LimyCodeConstants.PREF_SETTER_DESC,
            "Setter-method Description : ", comp2);

    initField(getter);
    initField(setter);

    return comp;
}

From source file:org.lyllo.kickassplugin.ui.PreferencesCompiler.java

License:Open Source License

/**
 * {@inheritDoc}//from  w ww . j a va2s  .  c  o m
 */
protected void createFieldEditors() {
    Composite parent = getFieldEditorParent();

    // Field for Compiler-Executable
    FileFieldEditor compiler = new FileFieldEditor(Constants.PREFERENCES_COMPILER_NAME,
            Messages.COMPILER_NAME + ": ", true, parent);
    compiler.setEmptyStringAllowed(false);
    compiler.setFileExtensions(new String[] { "*.jar" });

    addField(compiler);

    BooleanFieldEditor symbols = new BooleanFieldEditor(Constants.PREFERENCES_COMPILER_SYMBOLS,
            Messages.COMPILER_SYMBOLS, parent);
    addField(symbols);

    BooleanFieldEditor vicesymbols = new BooleanFieldEditor(Constants.PREFERENCES_COMPILER_VICESYMBOLS,
            Messages.COMPILER_VICESYMBOLS, parent);
    addField(vicesymbols);

    BooleanFieldEditor afo = new BooleanFieldEditor(Constants.PREFERENCES_COMPILER_AFO, Messages.COMPILER_AFO,
            parent);
    addField(afo);

    StringFieldEditor kickasscfg = new StringFieldEditor(Constants.PREFERENCES_LOCAL_CONFIG,
            Messages.COMPILER_LOCAL_CFG, parent);
    kickasscfg.setEmptyStringAllowed(true);
    addField(kickasscfg);

    PathEditor pathEditor = new PathEditor(Constants.PREFERENCES_COMPILER_LIBDIRS, Messages.COMPILER_LIBDIRS,
            Messages.COMPILER_LIBDIRS_CHOOSETEXT, parent);
    addField(pathEditor);

    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;

    Label label = new Label(parent, SWT.LEFT);
    label.setText(Messages.PARAMS_TEMPLATE_COMPILER);
    label.setLayoutData(gd);

    // Field for parameters to use Compiler-Executable
    MultiLineStringFieldEditor params = new MultiLineStringFieldEditor(Constants.PREFERENCES_COMPILER_PARAMS,
            Messages.PARAMS_NAME, parent);
    params.setErrorMessage("Invalid parameter. Must be in 'key=value' format.");

    addField(params);

}

From source file:org.mailster.gui.prefs.pages.POP3ConfigurationPage.java

License:Open Source License

/**
 * <p>/*from  w w  w  . j a  v a2 s.  co m*/
 * Creates and returns the SWT control for the customized body of this
 * preference page under the given parent composite.
 * </p>
 * 
 * @param parent the parent composite
 * @return the new control
 * 
 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
 */
protected Control createContents(Composite parent) {
    // Create content composite
    Composite content = new Composite(parent, SWT.NONE);
    content.setLayout(LayoutUtils.createGridLayout(1, false, 0, 0, 5, 5, 0, 0, 0, 0));

    // Create archive directory group
    Group pop3GeneralGroup = new Group(content, SWT.NONE);
    pop3GeneralGroup.setLayout(new GridLayout());
    pop3GeneralGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    pop3GeneralGroup.setText(Messages.getString("pop3GeneralGroupHeader"));

    Composite pop3GeneralOptions = new Composite(pop3GeneralGroup, SWT.NONE);
    pop3GeneralOptions.setLayout(LayoutUtils.createGridLayout(1, false, 5, 5, 5, 5, 0, 5, 0, 0));
    pop3GeneralOptions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    connectionTimeoutEditor = new SpinnerFieldEditor(ConfigurationManager.POP3_CONNECTION_TIMEOUT_KEY,
            Messages.getString("connectionTimeoutLabel"), pop3GeneralOptions);
    connectionTimeoutEditor.setMinimum(1);
    connectionTimeoutEditor.setMaximum(1000);
    connectionTimeoutEditor.setIncrement(1);
    connectionTimeoutEditor.setPageIncrement(10);
    setupEditor(connectionTimeoutEditor);

    // Separator
    Label sep = new Label(pop3GeneralOptions, SWT.NONE);
    sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, GridData.CENTER, false, false, 2, 1));

    pop3ServerEditor = new HostFieldEditor(ConfigurationManager.POP3_SERVER_KEY,
            Messages.getString("pop3ServerLabel"), pop3GeneralOptions);
    pop3ServerEditor.setEmptyStringAllowed(true);
    pop3ServerEditor.setOnlyLocalAddressAllowed(true);
    setupEditor(pop3ServerEditor);

    pop3PortEditor = new SpinnerFieldEditor(ConfigurationManager.POP3_PORT_KEY,
            Messages.getString("pop3PortLabel"), pop3GeneralOptions, 5);
    pop3PortEditor.setMinimum(0);
    pop3PortEditor.setMaximum(65535);
    pop3PortEditor.setIncrement(1);
    pop3PortEditor.setPageIncrement(100);
    setupEditor(pop3PortEditor);

    requireSecuredAuthMethodsEditor = new Button(pop3GeneralOptions, SWT.CHECK);
    requireSecuredAuthMethodsEditor.setText(Messages.getString("requireSecuredAuthMethodsLabel"));
    requireSecuredAuthMethodsEditor
            .setLayoutData(LayoutUtils.createGridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1));
    requireSecuredAuthMethodsEditor.setSelection(
            getPreferenceStore().getBoolean(ConfigurationManager.POP3_REQUIRE_SECURE_AUTH_METHOD_KEY));

    allowAPOPEditor = new Button(pop3GeneralOptions, SWT.CHECK);
    allowAPOPEditor.setText(Messages.getString("allowAPOPLabel"));
    allowAPOPEditor
            .setLayoutData(LayoutUtils.createGridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1));
    allowAPOPEditor.setSelection(
            getPreferenceStore().getBoolean(ConfigurationManager.POP3_ALLOW_APOP_AUTH_METHOD_KEY));

    // Separator
    new Label(content, SWT.NONE);

    // Create pop3 accounts group
    Group pop3AccountsGroup = new Group(content, SWT.NONE);
    pop3AccountsGroup.setLayout(new GridLayout());
    pop3AccountsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    pop3AccountsGroup.setText(Messages.getString("pop3AccountsGroupHeader"));

    Composite pop3AccountsOptions = new Composite(pop3AccountsGroup, SWT.NONE);
    pop3AccountsOptions.setLayout(LayoutUtils.createGridLayout(1, false, 5, 5, 5, 5, 0, 5, 0, 0));
    pop3AccountsOptions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    pop3SpecialAccountNameEditor = new StringFieldEditor(ConfigurationManager.POP3_SPECIAL_ACCOUNT_KEY,
            Messages.getString("pop3SpecialAccountLabel"), pop3AccountsOptions);
    pop3SpecialAccountNameEditor.setPage(this);
    pop3SpecialAccountNameEditor.setPreferenceStore(this.getPreferenceStore());
    setupEditor(pop3SpecialAccountNameEditor);

    pop3PasswordEditor = new StringFieldEditor(ConfigurationManager.POP3_PASSWORD_KEY,
            Messages.getString("pop3PasswordLabel"), pop3AccountsOptions);
    pop3PasswordEditor.getTextControl(pop3AccountsOptions).setEchoChar('*');
    setupEditor(pop3PasswordEditor);

    return content;
}

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  ww w. ja v a 2  s  . co  m
             * 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.melord.pde.explorer.preferences.ExplorerPreferencePage.java

License:Apache 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 . ja v a  2s.  com
public void createFieldEditors() {
    addField(new StringFieldEditor(PreferenceConstants.EXPLORER_CMD, Messages.ExplorerPreferencePage_cmd,
            getFieldEditorParent()));

}

From source file:org.modelio.mda.infra.catalog.update.CatalogUpdatePreferencesPage.java

License:Open Source License

@objid("d86fcd83-8195-4b5d-bb51-eaf5a3b1d8c6")
@Override/*from w w w. j  a  va 2  s.com*/
public void createFieldEditors() {
    this.updateSiteField = new StringFieldEditor(CATALOG_UPDATE_SITE,
            MdaInfra.I18N.getString("ModuleCatalog.Preference.UpdateSite"), getFieldEditorParent());
    addField(this.updateSiteField);

    this.showLatestField = new BooleanFieldEditor(CATALOG_SHOW_LATEST,
            MdaInfra.I18N.getString("ModuleCatalog.Preference.ShowOnlyLatest"), getFieldEditorParent());
    addField(this.showLatestField);

    this.showCompatibleField = new BooleanFieldEditor(CATALOG_SHOW_COMPATIBLE,
            MdaInfra.I18N.getString("ModuleCatalog.Preference.ShowOnlyCompatible"), getFieldEditorParent());
    addField(this.showCompatibleField);

    final Composite composite = getFieldEditorParent();

    this.localCatalogPathFieldEditor = new DirectoryFieldEditor(ModelioEnv.MODULE_PATH_PREFERENCE,
            MdaInfra.I18N.getString("ModuleCatalog.Preference.MoveCatalog.label"), composite);
    this.localCatalogPathFieldEditor
            .setChangeButtonText(MdaInfra.I18N.getString("ModuleCatalog.Preference.MoveCatalog.button"));
    final Text localCatalogPathText = this.localCatalogPathFieldEditor.getTextControl(composite);
    localCatalogPathText.setEditable(false);

    Label label = new Label(composite, SWT.NONE);
    label.setText(MdaInfra.I18N.getString("ModuleCatalog.Preference.MoveCatalog.description"));
    final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
    label.setLayoutData(gd);

    // Add a modify listener to move the old catalog's contents to the new one
    localCatalogPathText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            Path newPath = Paths.get(localCatalogPathText.getText());
            if (Files.exists(CatalogUpdatePreferencesPage.this.currentModulePath)
                    && !CatalogUpdatePreferencesPage.this.currentModulePath.equals(newPath)) {
                try {
                    FileUtils.copyDirectoryTo(CatalogUpdatePreferencesPage.this.currentModulePath, newPath);

                    // Delete the old catalog
                    try {
                        FileUtils.delete(CatalogUpdatePreferencesPage.this.currentModulePath);
                    } catch (IOException e1) {
                        MdaInfra.LOG.error(e1.getMessage());
                    }

                    MessageDialog.openInformation(localCatalogPathText.getShell(),
                            MdaInfra.I18N.getString("ModuleCatalog.Preference.MoveCatalog.SuccessTitle"),
                            MdaInfra.I18N.getString("ModuleCatalog.Preference.MoveCatalog.SuccessMessage"));
                } catch (IOException e1) {
                    // Error occured during copy, reset the Text's value
                    localCatalogPathText
                            .setText(CatalogUpdatePreferencesPage.this.currentModulePath.toString());
                    MdaInfra.LOG.error(e1.getMessage());
                    MessageDialog.openError(localCatalogPathText.getShell(),
                            MdaInfra.I18N.getString("ModuleCatalog.Preference.MoveCatalog.FailTitle"),
                            MdaInfra.I18N.getMessage("ModuleCatalog.Preference.MoveCatalog.FailMessage",
                                    e1.getMessage()));
                    return;
                }

                CatalogUpdatePreferencesPage.this.currentModulePath = newPath;
            }
        }
    });
    addField(this.localCatalogPathFieldEditor);
}

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

License:Open Source License

/**
 * @see IDialogPage#createControl(Composite)
 *//* ww  w .ja  v  a  2  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.mwc.debrief.gndmanager.preferences.CloudStoragePrefsPage.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  ww  .j  a va 2  s . com
public void createFieldEditors() {
    addField(new StringFieldEditor(TrackStoreWrapper.COUCHDB_LOCATION, "&CouchDb Database URL:",
            getFieldEditorParent()));
    addField(new StringFieldEditor(TrackStoreWrapper.ES_LOCATION, "&ElasticSearch index URL:",
            getFieldEditorParent()));
}

From source file:org.mxupdate.eclipse.MXPreferencePage.java

License:Apache License

/**
 *
 * @see FieldEditorPreferencePage#createFieldEditors()
 *//*from  www.  ja v  a  2 s .  co m*/
@Override()
protected void createFieldEditors() {
    final Composite parent = this.getFieldEditorParent();

    this.host = new StringFieldEditor(MXAdapter.PREF_URL, Messages.getString("MXPreferencePage.Host"), //$NON-NLS-1$
            parent);
    this.addField(this.host);

    this.userName = new StringFieldEditor(MXAdapter.PREF_NAME, Messages.getString("MXPreferencePage.UserName"), //$NON-NLS-1$
            parent);
    this.addField(this.userName);

    this.password = new PasswordFieldEditor(MXAdapter.PREF_PASSWORD,
            Messages.getString("MXPreferencePage.Password"), //$NON-NLS-1$
            parent);
    this.addField(this.password);

    this.storePassword = new BooleanFieldEditor(MXAdapter.PREF_STORE_PASSWORD,
            Messages.getString("MXPreferencePage.StorePassword"), //$NON-NLS-1$
            parent);
    this.addField(this.storePassword);

    this.updateByFileContent = new BooleanFieldEditor(MXAdapter.PREF_UPDATE_FILE_CONTENT,
            Messages.getString("MXPreferencePage.UpdateByFileContent"), //$NON-NLS-1$
            parent);
    this.addField(this.updateByFileContent);

    final BooleanFieldEditor externalConfigured = new BooleanFieldEditor(MXAdapter.PREF_EXTERNAL_CONFIGURED,
            Messages.getString("MXPreferencePage.ExternalConfigured"), //$NON-NLS-1$
            parent) {
        /**
         * Called if the preference page is called the first time.
         */
        @Override()
        protected void doLoad() {
            super.doLoad();
            MXPreferencePage.this.updateDependencies(this.getBooleanValue());
        }

        /**
         * Called if the user (de-) selects the external configuration
         * flag.
         *
         * @param _oldValue     old value
         * @param _newValue     new value
         */
        @Override()
        protected void valueChanged(final boolean _oldValue, final boolean _newValue) {
            super.valueChanged(_oldValue, _newValue);
            MXPreferencePage.this.updateDependencies(_newValue);
        }

    };
    this.addField(externalConfigured);

    this.fileEditor = new FileFieldEditor(MXAdapter.PREF_PROP_FILE,
            Messages.getString("MXPreferencePage.PropertyFile"), //$NON-NLS-1$
            parent);
    this.fileEditor.setFileExtensions(new String[] { "properties", "*" });
    this.addField(this.fileEditor);

    this.propKeyHost = new StringFieldEditor(MXAdapter.PREF_PROP_KEY_URL,
            Messages.getString("MXPreferencePage.PropKeyHost"), //$NON-NLS-1$
            parent);
    this.addField(this.propKeyHost);

    this.propKeyUserName = new StringFieldEditor(MXAdapter.PREF_PROP_KEY_NAME,
            Messages.getString("MXPreferencePage.PropKeyUserName"), //$NON-NLS-1$
            parent);
    this.addField(this.propKeyUserName);

    this.propKeyPassword = new StringFieldEditor(MXAdapter.PREF_PROP_KEY_PASSWORD,
            Messages.getString("MXPreferencePage.PropKeyPassword"), //$NON-NLS-1$
            parent);
    this.addField(this.propKeyPassword);
}