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.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   ww  w .  j av  a 2 s.  c  o m
    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));
}

From source file:org.rubypeople.rdt.debug.ui.launchConfigurations.RubyConnectTab.java

License:Open Source License

/**
 * Update the argument area to show the selected connector's arguments
 *///from ww  w  .jav  a 2 s  . c  o  m
private void handleConnectorComboModified() {
    int index = fConnectorCombo.getSelectionIndex();
    if ((index < 0) || (index >= fConnectors.length)) {
        return;
    }
    IVMConnector vm = fConnectors[index];
    if (vm.equals(fConnector)) {
        return; // selection did not change
    }
    fConnector = vm;
    try {
        fArgumentMap = vm.getDefaultArguments();
    } catch (CoreException e) {
        RdtDebugUiPlugin.statusDialog(LauncherMessages.RubyConnectTab_Unable_to_display_connection_arguments__2,
                e.getStatus());
        return;
    }

    // Dispose of any current child widgets in the tab holder area
    Control[] children = fArgumentComposite.getChildren();
    for (int i = 0; i < children.length; i++) {
        children[i].dispose();
    }
    fFieldEditorMap.clear();
    PreferenceStore store = new PreferenceStore();
    // create editors
    Iterator<String> keys = vm.getArgumentOrder().iterator();
    while (keys.hasNext()) {
        String key = keys.next();
        Object arg = fArgumentMap.get(key);
        FieldEditor field = null;
        if (arg instanceof Integer) {
            store.setDefault(key, ((Integer) arg).intValue());
            field = new IntegerFieldEditor(key, key, fArgumentComposite);
        } else if (arg instanceof String) {
            store.setDefault(key, (String) arg);
            field = new StringFieldEditor(key, key, fArgumentComposite);
        }
        //         if (arg instanceof Connector.IntegerArgument) {
        //            store.setDefault(arg.name(), ((Connector.IntegerArgument) arg)
        //                  .intValue());
        //            field = new IntegerFieldEditor(arg.name(), arg.label(),
        //                  fArgumentComposite);
        //         } else if (arg instanceof Connector.SelectedArgument) {
        //            List choices = ((Connector.SelectedArgument) arg).choices();
        //            String[][] namesAndValues = new String[choices.size()][2];
        //            Iterator iter = choices.iterator();
        //            int count = 0;
        //            while (iter.hasNext()) {
        //               String choice = (String) iter.next();
        //               namesAndValues[count][0] = choice;
        //               namesAndValues[count][1] = choice;
        //               count++;
        //            }
        //            store.setDefault(arg.name(), arg.value());
        //            field = new ComboFieldEditor(arg.name(), arg.label(),
        //                  namesAndValues, fArgumentComposite);
        //         } else if (arg instanceof Connector.StringArgument) {
        //            store.setDefault(arg.name(), arg.value());
        //            field = new StringFieldEditor(arg.name(), arg.label(),
        //                  fArgumentComposite);
        //         } else if (arg instanceof Connector.BooleanArgument) {
        //            store.setDefault(arg.name(), ((Connector.BooleanArgument) arg)
        //                  .booleanValue());
        //            field = new BooleanFieldEditor(arg.name(), arg.label(),
        //                  fArgumentComposite);
        //         }
        if (field != null) {
            field.setPreferenceStore(store);
            field.loadDefault();
            field.setPropertyChangeListener(this);
            fFieldEditorMap.put(key, field);
        }
    }
    fArgumentComposite.getParent().getParent().layout();
    fArgumentComposite.layout(true);
    updateLaunchConfigurationDialog();
}

From source file:org.s23m.cell.eclipse.preferences.ui.RepositoryPreferencePage.java

License:Mozilla Public License

@Override
public void createFieldEditors() {
    final String[][] array = new String[connectors.size()][2];
    for (int i = 0; i < connectors.size(); i++) {
        final String name = connectors.get(i).getName();
        array[i][0] = name;// w w w . ja v a 2 s  .c om
        array[i][1] = name;
    }

    final Composite parent = getFieldEditorParent();

    databaseTypeEditor = new RadioGroupFieldEditorWithSelection(RepositoryPreferences.DATABASE_TYPE,
            "Database &type", 1, array, parent);
    databaseTypeEditor.getSelectedValue();
    addField(databaseTypeEditor);

    hostNameEditor = new StringFieldEditor(RepositoryPreferences.HOSTNAME, "&Hostname", parent);
    addField(hostNameEditor);

    portEditor = new IntegerFieldEditor(RepositoryPreferences.PORT, "P&ort", parent);
    portEditor.setStringValue("3306");
    portEditor.setValidRange(1025, 65536);
    // TODO use default port supplied by connector
    addField(portEditor);

    databaseNameEditor = new StringFieldEditor(RepositoryPreferences.DATABASE_NAME, "Database &name", parent);
    addField(databaseNameEditor);

    usernameEditor = new StringFieldEditor(RepositoryPreferences.USERNAME, "&Username", parent);
    addField(usernameEditor);

    passwordEditor = new PasswordFieldEditor(RepositoryPreferences.PASSWORD, "&Password", parent);
    addField(passwordEditor);

    final Composite buttonGroup = new Composite(parent, SWT.NONE);
    buttonGroup.setLayoutData(new GridData());
    final GridLayout buttonLayout = new GridLayout();
    buttonLayout.marginHeight = 0;
    buttonLayout.marginWidth = 0;
    buttonGroup.setLayout(buttonLayout);

    testConnectionButton = new Button(buttonGroup, SWT.NONE);
    testConnectionButton.setText("&Test connection");
    testConnectionButton.setEnabled(true);
    testConnectionButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {

            final Display display = Display.getCurrent();
            final Runnable connectionTest = new Runnable() {
                public void run() {
                    final String hostname = hostNameEditor.getStringValue();
                    final int port = portEditor.getIntValue();
                    final String databaseName = databaseNameEditor.getStringValue();
                    final String username = usernameEditor.getStringValue();
                    final String password = passwordEditor.getStringValue();
                    final String connectorName = databaseTypeEditor.getSelectedValue();

                    final DatabaseConnector connector = findConnectorByName(connectorName);

                    final String validConnection = DatabaseConnectorSupport.testConnection(connector, hostname,
                            port, databaseName, username, password);

                    final String message;
                    if (validConnection == null) {
                        message = "The connection details are valid";
                    } else {
                        message = "The connection details are invalid:\n" + validConnection;
                    }
                    MessageDialog.openInformation(display.getActiveShell(), "Test connection", message);
                }
            };

            BusyIndicator.showWhile(display, connectionTest);
        }
    });
    final GridData testConnectionButtonData = new GridData(GridData.FILL_HORIZONTAL);
    testConnectionButtonData.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    //removeTagData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    testConnectionButton.setLayoutData(testConnectionButtonData);

    readOnlyEditor = new BooleanFieldEditor(RepositoryPreferences.READ_ONLY, "&Read Only Access", parent);
    addField(readOnlyEditor);

}

From source file:org.search.niem.uml.papyrus.preferences.ModelPreferencePage.java

License:Open Source License

@Override
public void createFieldEditors() {
    addField(new StringFieldEditor(P_DEFAULT_MODEL_NAME,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_defaultModelNamePreference"),
            getFieldEditorParent()));//from   w  w  w.j  a v a2 s  . c o  m
    addField(new StringFieldEditor(P_EXCHANGE_MODEL_TARGET_NAMESPACE,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_exchangeModelTargetNamespace"),
            getFieldEditorParent()));
    addField(new StringFieldEditor(P_EXTENSION_MODEL_TARGET_NAMESPACE,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_extensionModelTargetNamespace"),
            getFieldEditorParent()));
    addField(new StringFieldEditor(P_MPD_BASE_URI,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_mpdBaseURI"), getFieldEditorParent()));
    addField(new StringFieldEditor(P_MPD_VERSION_NUMBER,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_mpdVersionNumber"), getFieldEditorParent()));
    addField(new StringFieldEditor(P_MPD_DESCRIPTION,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_mpdDescription"), getFieldEditorParent()));
    addField(new StringFieldEditor(P_MPD_PURPOSE,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_mpdPurpose"), getFieldEditorParent()));
    addField(new StringFieldEditor(P_MPD_SECURITY_MARKING,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_mpdSecurityMarking"),
            getFieldEditorParent()));
    addField(new MultiStringEditor(P_DOMAINS, Activator.INSTANCE.getString("_UI_ModelPreferencePage_domain"),
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_domains"), getFieldEditorParent()));
    addField(new MultiStringEditor(P_KEYWORDS, Activator.INSTANCE.getString("_UI_ModelPreferencePage_keyword"),
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_keywords"), getFieldEditorParent()));
    addField(new StringFieldEditor(P_AUTHORITATIVE_SOURCE_NAME,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_authoritativeSourceName"),
            getFieldEditorParent()));
    addField(new MultiLineStringFieldEditor(P_AUTHORITATIVE_SOURCE_ADDRESS,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_authoritativeSourceAddress"),
            getFieldEditorParent()));
    addField(new StringFieldEditor(P_AUTHORITATIVE_SOURCE_WEBSITE,
            Activator.INSTANCE.getString("_UI_ModelPreferencePage_authoritativeSourceWebsite"),
            getFieldEditorParent()));
    addField(new PointsOfContactEditor(getFieldEditorParent()));
}

From source file:org.search.niem.uml.qvt.ui.preferences.MPDOutputPreferencePage.java

License:Open Source License

@Override
public void createFieldEditors() {
    addField(new StringFieldEditor(P_MPD_CATALOG_FILE_NAME,
            Activator.INSTANCE.getString("_UI_MPDOutputPreferencePage_mpdCatalogFileName"),
            getFieldEditorParent()));//w  w w  .j  ava 2s .  c  o  m
    addField(new StringFieldEditor(P_XML_SCHEMAS_FOLDER,
            Activator.INSTANCE.getString("_UI_MPDOutputPreferencePage_xmlSchemasFolder"),
            getFieldEditorParent()));
    addField(new StringFieldEditor(P_XML_SAMPLES_FOLDER,
            Activator.INSTANCE.getString("_UI_MPDOutputPreferencePage_xmlSamplesFolder"),
            getFieldEditorParent()));
    addField(new StringFieldEditor(P_SAMPLE_XML_SUFFIX,
            Activator.INSTANCE.getString("_UI_MPDOutputPreferencePage_sampleXmlSuffix"),
            getFieldEditorParent()));
    addField(new StringFieldEditor(P_CHANGELOG_FILE_NAME,
            Activator.INSTANCE.getString("_UI_MPDOutputPreferencePage_changelogFileName"),
            getFieldEditorParent()));
}

From source file:org.sonar.ide.eclipse.ui.internal.preferences.SonarPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {

    addField(new ComboFieldEditor(SonarUiPlugin.PREF_MARKER_SEVERITY,
            Messages.SonarPreferencePage_label_marker_severity,
            new String[][] { { "Info", String.valueOf(IMarker.SEVERITY_INFO) },
                    { "Warning", String.valueOf(IMarker.SEVERITY_WARNING) },
                    { "Error", String.valueOf(IMarker.SEVERITY_ERROR) } },
            getFieldEditorParent()));/*www . j  av  a2 s  .  c o  m*/
    addField(new ComboFieldEditor(SonarUiPlugin.PREF_NEW_ISSUE_MARKER_SEVERITY,
            Messages.SonarPreferencePage_label_new_issues_marker_severity,
            new String[][] { { "Info", String.valueOf(IMarker.SEVERITY_INFO) },
                    { "Warning", String.valueOf(IMarker.SEVERITY_WARNING) },
                    { "Error", String.valueOf(IMarker.SEVERITY_ERROR) } },
            getFieldEditorParent()));
    addField(new StringFieldEditor(SonarUiPlugin.PREF_JVM_ARGS, Messages.SonarPreferencePage_label_jvm_args,
            getFieldEditorParent()));
    addField(new BooleanFieldEditor(SonarUiPlugin.PREF_FORCE_FULL_PREVIEW,
            Messages.SonarPreferencePage_label_force_full_preview, BooleanFieldEditor.SEPARATE_LABEL,
            getFieldEditorParent()));
}

From source file:org.sonarlint.eclipse.ui.internal.preferences.SonarLintPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {

    addField(new ComboFieldEditor(PreferencesUtils.PREF_MARKER_SEVERITY,
            Messages.SonarPreferencePage_label_marker_severity,
            new String[][] { { "Info", String.valueOf(IMarker.SEVERITY_INFO) },
                    { "Warning", String.valueOf(IMarker.SEVERITY_WARNING) },
                    { "Error", String.valueOf(IMarker.SEVERITY_ERROR) } },
            getFieldEditorParent()));//from w w w.j a v  a  2s  .com
    addField(new StringFieldEditor(PreferencesUtils.PREF_TEST_FILE_REGEXPS,
            Messages.SonarPreferencePage_label_test_file_regexps, getFieldEditorParent()));
}

From source file:org.spdx.spdxeclipse.preferences.SpdxFilePreferencePage.java

License:Apache License

public void createFieldEditors() {
    addField(new LicenseFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_FILE_LICENSE,
            "Default SPDX File License: ", getFieldEditorParent()));
    addField(new StringFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_FILE_COPYRIGHT,
            "Default SPDX File Copyright: ", getFieldEditorParent()));
    addField(new StringFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_FILE_NOTICE,
            "Default SPDX File Notice: ", getFieldEditorParent()));
    addField(new StringListFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_FILE_CONTRIBUTORS,
            "Default SPDX File Contributors: ", getFieldEditorParent()));
}

From source file:org.spdx.spdxeclipse.preferences.SpdxPreferencePage.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./*  w w w. j a  v a2s  .  c  o  m*/
 */
public void createFieldEditors() {
    addField(new StringFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_FILE_NAME, "Default SPDX &File Name:",
            getFieldEditorParent()));
    addField(new StringFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_URL, "Default SPDX Document &URL:",
            getFieldEditorParent()));
    addField(new StringFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_PROJECT_NAME,
            "Default SPDX Project &Name:", getFieldEditorParent()));
    addField(new StringFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_PROJECT_VERSION,
            "Default SPDX Project &Version:", getFieldEditorParent()));
    addField(new StringFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_PACKAGE_COPYRIGHT,
            "Default SPDX Project &Copyright: ", getFieldEditorParent()));
    addField(new StringFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_PACKAGE_DOWNLOAD_URL,
            "Default SPDX Project &Download URL: ", getFieldEditorParent()));
    addField(new CreatorFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_CREATOR, "Default SPDX Creator: ",
            getFieldEditorParent()));
    addField(new LicenseFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_DECLARED_LICENSE,
            "Default SPDX Declared License: ", getFieldEditorParent()));
    addField(new LicenseFieldEditor(PreferenceConstants.PREF_DEFAULT_SPDX_CONCLUDED_LICENSE,
            "Default SPDX Concluded License: ", getFieldEditorParent()));
}

From source file:org.springframework.ide.eclipse.boot.ui.preferences.InitializrPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    Composite parent = getFieldEditorParent();

    StringFieldEditor initializrUrl = new StringFieldEditor(PREF_INITIALIZR_URL, LABEL_INITIALIZR_URL, parent) {

        @Override// w w  w  .j  av a 2s  .  c om
        protected boolean checkState() {
            // Checks if string has a correct URL format 
            Text text = getTextControl();
            if (text == null) {
                return false;
            }
            try {
                new URL(text.getText());
                clearErrorMessage();
                return true;
            } catch (MalformedURLException e) {
                setErrorMessage(MSG_INVALID_URL_FORMAT);
                showErrorMessage();
                return false;
            }
        }

    };

    initializrUrl.getLabelControl(parent).setToolTipText(TOOLTIP_INITIALIZR_URL);
    initializrUrl.getTextControl(parent).setToolTipText(TOOLTIP_INITIALIZR_URL);
    addField(initializrUrl);

}