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.dawb.workbench.ui.editors.preference.EditorPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {

    // Choice between diamond and light weight plotting
    final String[][] namesAndValues = getPlottingPreferenceChoices();
    ComboFieldEditor plotChoice = new ComboFieldEditor(EditorConstants.PLOTTING_SYSTEM_CHOICE,
            "Plotting Technology*", namesAndValues, getFieldEditorParent());
    addField(plotChoice);//from  w  ww.j a  va 2s .c  o m
    new LabelFieldEditor("(* Please close and reopen the part after changing plotting preference.)\n\n",
            getFieldEditorParent());

    IConfigurationElement[] config = Platform.getExtensionRegistry()
            .getConfigurationElementsFor("uk.ac.diamond.scisoft.analysis.data.set.filter");

    if (config != null && config.length > 0) {
        final Label sep = new Label(getFieldEditorParent(), SWT.NONE);
        sep.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 5));
        BooleanFieldEditor showAll = new BooleanFieldEditor(EditorConstants.IGNORE_DATASET_FILTERS,
                "Show all possible data sets", getFieldEditorParent());
        addField(showAll);

        final StringBuilder buf = new StringBuilder("Current data set filters:\n");

        for (IConfigurationElement e : config) {
            buf.append("\t-    ");
            final String pattern = e.getAttribute("regularExpression");
            buf.append(pattern);
            buf.append("\n");
        }
        buf.append(
                "\nData set filters reduce the content available to plot and\ncompare for simplicity but can be turned off.\nAll data is shown in the nexus tree, filters are not applied.");
        final Label label = new Label(getFieldEditorParent(), SWT.WRAP);
        label.setText(buf.toString());
        label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    }

    BooleanFieldEditor showXY = new BooleanFieldEditor(EditorConstants.SHOW_XY_COLUMN, "Show XY column.",
            getFieldEditorParent());
    addField(showXY);

    BooleanFieldEditor showSize = new BooleanFieldEditor(EditorConstants.SHOW_DATA_SIZE, "Show size column.",
            getFieldEditorParent());
    addField(showSize);

    BooleanFieldEditor showDims = new BooleanFieldEditor(EditorConstants.SHOW_DIMS, "Show dimensions column.",
            getFieldEditorParent());
    addField(showDims);

    BooleanFieldEditor showShape = new BooleanFieldEditor(EditorConstants.SHOW_SHAPE, "Show shape column.",
            getFieldEditorParent());
    addField(showShape);

    BooleanFieldEditor showVarName = new BooleanFieldEditor(EditorConstants.SHOW_VARNAME,
            "Show expression variable name.", getFieldEditorParent());
    addField(showVarName);

    BooleanFieldEditor showLocalName = new BooleanFieldEditor(EditorConstants.SHOW_LOCALNAME,
            "Use local name attribute.", getFieldEditorParent());
    addField(showLocalName);

    new LabelFieldEditor(
            "\nEditors with a 'Data' tab, show the data of the current plot.\nThis option sets the number format for the table and the csv file, if the data is exported.",
            getFieldEditorParent());

    formatFieldEditor = new StringFieldEditor(EditorConstants.DATA_FORMAT, "Number format:",
            getFieldEditorParent());
    addField(formatFieldEditor);

    new LabelFieldEditor("Examples: #0.0000, 0.###E0, ##0.#####E0, 00.###E0", getFieldEditorParent());

    new LabelFieldEditor("\n", getFieldEditorParent());

    IntegerFieldEditor playSpeed = new IntegerFieldEditor(EditorConstants.PLAY_SPEED,
            "Speed of slice play for n-Dimensional data sets (ms):", getFieldEditorParent()) {
        @Override
        protected boolean checkState() {
            if (!super.checkState())
                return false;
            if (getIntValue() < 10 || getIntValue() > 10000)
                return false;
            return true;
        }
    };
    addField(playSpeed);

    new LabelFieldEditor("\n", getFieldEditorParent());
    new LabelFieldEditor("\n", getFieldEditorParent());

    PlotDataSelection[] pds = PlotDataSelection.values();
    int nTypes = pds.length;
    String[][] pdsTypes = new String[nTypes][1];
    for (int i = 0; i < nTypes; i++) {
        String label = pds[i].getLabel();
        String name = pds[i].toString();
        pdsTypes[i] = new String[] { label, name };
    }

    OpenComboFieldEditor saveDataChoice = new OpenComboFieldEditor(EditorConstants.SAVE_SEL_DATA,
            "Automatically open dataset(s)", pdsTypes, getFieldEditorParent());
    addField(saveDataChoice);

    final StringFieldEditor datasetNameEditor = new StringFieldEditor(EditorConstants.DATA_SEL, "Data name(s)",
            getFieldEditorParent());
    addField(datasetNameEditor);
    datasetNameEditor.setEnabled(
            PlotDataSelection.isFixed(getPreferenceStore().getString(EditorConstants.SAVE_SEL_DATA)),
            getFieldEditorParent());

    BooleanFieldEditor saveLogFormat = new BooleanFieldEditor(EditorConstants.SAVE_LOG_FORMAT,
            "Save the last axis log format by file extension.", getFieldEditorParent());
    addField(saveLogFormat);
    BooleanFieldEditor saveTimeFormat = new BooleanFieldEditor(EditorConstants.SAVE_TIME_FORMAT,
            "Save the last axis time format by file extension.", getFieldEditorParent());
    addField(saveTimeFormat);
    BooleanFieldEditor saveFormatString = new BooleanFieldEditor(EditorConstants.SAVE_FORMAT_STRING,
            "Save the last axis format string by file extension.", getFieldEditorParent());
    addField(saveFormatString);

    dataModeListener = new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {

            final String propValue = getPreferenceStore().getString(EditorConstants.SAVE_SEL_DATA);
            updateMode(datasetNameEditor, PlotDataSelection.valueOf(propValue));
        }
    };
    getPreferenceStore().addPropertyChangeListener(dataModeListener);

    final Combo combo = saveDataChoice.getCombo(getFieldEditorParent());
    if (combo != null) {
        combo.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                PlotDataSelection sel = PlotDataSelection.values()[combo.getSelectionIndex()];
                updateMode(datasetNameEditor, sel);
            }
        });
    }
}

From source file:org.dawnsci.commandserver.ui.preference.ActiveMQPage.java

License:Open Source License

@Override
protected void createFieldEditors() {

    final StringFieldEditor uri = new StringFieldEditor(CommandConstants.JMS_URI, "Comamnd Server",
            getFieldEditorParent());/*from w ww.j  ava2 s . c o m*/
    addField(uri);

}

From source file:org.ebayopensource.turmeric.eclipse.errorlibrary.properties.preferences.ErrorIdServicePreferencePage.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  v  a  2s .co m*/
@Override
public void createFieldEditors() {
    hostSelectionField = new RadioGroupFieldEditor(ErrorIdServicePreferenceConstants.HOSTSELECTION,
            SOAMessages.SELECT_HOST, 1, radioGroup, getFieldEditorParent(), true);
    addField(hostSelectionField);

    localFileField = new DirectoryFieldEditor(ErrorIdServicePreferenceConstants.LOCALFILEPATH,
            SOAMessages.LOCAL_CONF_FOLDER, getFieldEditorParent());
    addField(localFileField);

    asEndpointField = new StringFieldEditor(ErrorIdServicePreferenceConstants.REMOTEENDPOINTURL,
            SOAMessages.REMOTE_ENDPOINT, getFieldEditorParent());
    addField(asEndpointField);

}

From source file:org.ebayopensource.turmeric.eclipse.maven.ui.preferences.TurmericSOAConfigPrefPage.java

License:Open Source License

@Override
protected void createFieldEditors() {
    final IPreferenceStore prefStore = TurmericSOAConfigPrefInitializer.getPreferenceStore();
    final Composite composite = getFieldEditorParent();

    try {//  w  w w .  jav a2s .c  o m
        final Group group = new Group(composite, SWT.SHADOW_ETCHED_IN);
        group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        GridLayout layout = new GridLayout(2, false);
        group.setLayout(layout);
        group.setText("Framework Version Configurations");
        final ISOAOrganizationProvider orgProvider = GlobalRepositorySystem.instanceOf()
                .getActiveRepositorySystem().getActiveOrganizationProvider();
        String soatoolsId = orgProvider.getSOAFrameworkLibraryIdentifier(SOAFrameworkLibrary.SOATOOLS);
        final ArtifactMetadata metadata = MavenEclipseUtil.artifactMetadata(soatoolsId);

        BooleanFieldEditor overwriteEditor = new BooleanFieldEditor(
                TurmericSOAConfigPrefInitializer.PREF_KEY_OVERWRITE_PREFERRED_VERSOIN,
                "Overwrite Preferred Version", group) {

            @Override
            protected void valueChanged(boolean oldValue, boolean newValue) {
                enableVersionEditor(newValue);
                super.valueChanged(oldValue, newValue);
            }

            private void enableVersionEditor(boolean newValue) {
                if (preferredVerEditor != null) {
                    preferredVerEditor.setEnabled(newValue, group);
                    if (newValue == true && StringUtils.isBlank(preferredVerEditor.getStringValue())) {
                        TurmericSOAConfigPrefPage.this.setErrorMessage("preferred version must not be empty");
                        preferredVerEditor.setErrorMessage("preferred version must not be empty");
                    }
                }
            }

            @Override
            protected void doLoadDefault() {

                super.doLoadDefault();
                enableVersionEditor(getBooleanValue());
            }
        };
        addField(overwriteEditor);
        final Collection<String> versions = new TreeSet<String>();
        if (metadata != null) {
            for (Artifact artifact : MavenCoreUtils.mavenEclipseAPI()
                    .findArtifactByNameAndGroup(metadata.getArtifactId(), metadata.getGroupId())) {
                versions.add(artifact.getVersion());
            }
        }

        final String minVersion = orgProvider.getMinimumRequiredTurmericFrameworkVersion();
        this.preferredVerEditor = new StringFieldEditor(
                TurmericSOAConfigPrefInitializer.PREF_KEY_TURMERIC_PREFERRED_VERSOIN,
                "Preferred Turmeric Version:", group) {

            @Override
            protected boolean doCheckState() {
                if (VersionUtil.compare(getStringValue(), minVersion) < 0) {
                    this.setErrorMessage("Preferred version must be equal to or greater than " + minVersion);
                    return false;
                }
                return super.doCheckState();
            }

        };
        this.preferredVerEditor.setEmptyStringAllowed(false);
        this.preferredVerEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);

        addField(preferredVerEditor);

        if (versions.isEmpty() == false) {
            Text verText = this.preferredVerEditor.getTextControl(group);
            new AutoCompleteField(verText, new TextContentAdapter(), versions.toArray(new String[0]));
        }

        this.preferredVerEditor.setEnabled(
                prefStore.getBoolean(TurmericSOAConfigPrefInitializer.PREF_KEY_OVERWRITE_PREFERRED_VERSOIN),
                group);

        prefStore.setValue(TurmericSOAConfigPrefInitializer.PREF_KEY_MINIMUM_REQUIRED_VERSOIN, minVersion);
        prefStore.setDefault(TurmericSOAConfigPrefInitializer.PREF_KEY_MINIMUM_REQUIRED_VERSOIN, minVersion);
        StringFieldEditor text = new StringFieldEditor(
                TurmericSOAConfigPrefInitializer.PREF_KEY_MINIMUM_REQUIRED_VERSOIN, "Minimum Required Version:",
                group);
        text.getTextControl(group).setEditable(false);
        text.setStringValue(orgProvider.getMinimumRequiredTurmericFrameworkVersion());
        addField(text);
    } catch (Exception e) {
        logger.error(e);
        UIUtil.showErrorDialog(e);
    }
}

From source file:org.ebayopensource.turmeric.eclipse.registry.consumer.preferences.AssertionServicePreferencePage.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./*www . ja v a2 s . co m*/
 */
@Override
public void createFieldEditors() {
    final Composite fieldParent = getFieldEditorParent();
    enableASField = new BooleanFieldEditor(AssertionServicePreferenceConstants.ENABLE_ASSERTION_SERVICE,
            "&Enable Assertion Service Integration", fieldParent);
    addField(enableASField);
    overwriteASField = new BooleanFieldEditor(AssertionServicePreferenceConstants.OVERWRITE_AS_ENDPOINT,
            "&Overwrite Assertion Service Properties", fieldParent) {

        @Override
        protected void valueChanged(boolean oldValue, boolean newValue) {
            setFieldEnabled(newValue, fieldParent);
            if (newValue == false) {
                //user want to use the default value
                asEndpointField.loadDefault();
            }
            super.valueChanged(oldValue, newValue);
        }

    };
    addField(overwriteASField);
    boolean overwrite = Activator.getDefault().getPreferenceStore()
            .getBoolean(AssertionServicePreferenceConstants.OVERWRITE_AS_ENDPOINT);

    asEndpointField = new StringFieldEditor(AssertionServicePreferenceConstants.URL_AS_ENDPOINT, "&Endpoint:",
            fieldParent);
    addField(asEndpointField);

    setFieldEnabled(overwrite, fieldParent);
}

From source file:org.ebayopensource.turmeric.eclipse.services.ui.properties.SOAServiceDependenciesPage.java

License:Open Source License

private void addServiceLocation(Group group) {
    serviceLocationEditor = new StringFieldEditor("", "Service Location: ", group);
    // serviceLocationEditor.getTextControl(group).setEnabled(false);
    editorParentMap.put(serviceLocationEditor, group);
    addField(serviceLocationEditor);//from   w ww. jav  a 2s.  c om
}

From source file:org.ebix.umm.uml2text.preferences.UmmStereotypeProjectPropertiesPage.java

License:Open Source License

@Override
public Control createContents(final Composite parent) {
    IAdaptable _element = this.getElement();
    final IProject project = ((IProject) _element);
    InputOutput.<String>println(("in create contents of " + project));
    final ProjectScope projectScope = new ProjectScope(project);
    final IEclipsePreferences projectNode = projectScope.getNode("org.ebix.umm.uml2text");
    boolean _notEquals = (!Objects.equal(projectNode, null));
    if (_notEquals) {
        final UmmStereotypes ummStereotypes = new UmmStereotypes();
        for (final UmmStereotype st : ummStereotypes.allStereotypes) {
            {//from   w w  w  .j av a2s. c  o  m
                final StringFieldEditor st_editor = new StringFieldEditor(st.shortName, st.shortName, parent);
                final String value = projectNode.get(st.shortName, st.defaultName);
                st_editor.setStringValue(value);
                this.editors.put(st, st_editor);
            }
        }
    }
    return parent;
}

From source file:org.eclipse.ajdt.internal.ui.AspectJProjectPropertiesPage.java

License:Open Source License

private Composite outputTab(Composite composite) {
    Composite pageComposite = createPageComposite(composite, 3);

    // This will cover the top row of the panel.
    Composite row0Composite = createRowComposite(pageComposite, 1);
    //createText(row0Composite, UIMessages.compilerPropsPage_description);
    Label title = new Label(row0Composite, SWT.LEFT | SWT.WRAP);
    title.setText(UIMessages.compilerPropsPage_description);

    Composite row3Comp = createRowComposite(pageComposite, 2);

    outputJarEditor = new StringFieldEditor("", //$NON-NLS-1$
            UIMessages.compilerPropsPage_outputJar, row3Comp);

    return pageComposite;

}

From source file:org.eclipse.andmore.ddms.preferences.PreferencePage.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  a 2 s  . c o m*/
@Override
public void createFieldEditors() {
    IntegerFieldEditor ife;

    ife = new IntegerFieldEditor(PreferenceInitializer.ATTR_DEBUG_PORT_BASE,
            Messages.PreferencePage_Base_Local_Debugger_Port, getFieldEditorParent());
    ife.setValidRange(1024, 32767);
    addField(ife);

    ife = new IntegerFieldEditor(PreferenceInitializer.ATTR_SELECTED_DEBUG_PORT,
            Messages.PreferencePage_Selected_Debugger_Port, getFieldEditorParent());
    ife.setValidRange(1024, 32767);
    addField(ife);

    BooleanFieldEditor bfe;

    bfe = new BooleanFieldEditor(PreferenceInitializer.ATTR_DEFAULT_THREAD_UPDATE,
            Messages.PreferencePage_Thread_Updates_Enabled_By_Default, getFieldEditorParent());
    addField(bfe);

    bfe = new BooleanFieldEditor(PreferenceInitializer.ATTR_DEFAULT_HEAP_UPDATE,
            Messages.PreferencePage_Heap_Updates_Enabled_Default, getFieldEditorParent());
    addField(bfe);

    ife = new IntegerFieldEditor(PreferenceInitializer.ATTR_THREAD_INTERVAL,
            Messages.PreferencePage_Thread_Status_Refresh_Interval, getFieldEditorParent());
    ife.setValidRange(1, 60);
    addField(ife);

    if (InstallDetails.isAdtInstalled()) {
        ComboFieldEditor cfe = new ComboFieldEditor(PreferenceInitializer.ATTR_HPROF_ACTION,
                Messages.PreferencePage_HPROF_Action,
                new String[][] { { Messages.PreferencePage_Save_Disk, HProfHandler.ACTION_SAVE },
                        { Messages.PreferencePage_Open_Eclipse, HProfHandler.ACTION_OPEN }, },
                getFieldEditorParent());
        addField(cfe);
    }

    mProfilerBufsize = new IntegerFieldEditor(PreferenceInitializer.ATTR_PROFILER_BUFSIZE_MB,
            "Method Profiler buffer size (MB):", getFieldEditorParent());
    addField(mProfilerBufsize);

    ife = new IntegerFieldEditor(PreferenceInitializer.ATTR_TIME_OUT,
            Messages.PreferencePage_ADB_Connection_Time_Out, getFieldEditorParent());
    addField(ife);

    RadioGroupFieldEditor rgfe = new RadioGroupFieldEditor(PreferenceInitializer.ATTR_LOG_LEVEL,
            Messages.PreferencePage_Logging_Level, 1,
            new String[][] { { Messages.PreferencePage_Verbose, LogLevel.VERBOSE.getStringValue() },
                    { Messages.PreferencePage_Debug, LogLevel.DEBUG.getStringValue() },
                    { Messages.PreferencePage_Info, LogLevel.INFO.getStringValue() },
                    { Messages.PreferencePage_Warning, LogLevel.WARN.getStringValue() },
                    { Messages.PreferencePage_Error, LogLevel.ERROR.getStringValue() },
                    { Messages.PreferencePage_Assert, LogLevel.ASSERT.getStringValue() } },
            getFieldEditorParent(), true);
    addField(rgfe);
    mUseAdbHost = new BooleanFieldEditor(PreferenceInitializer.ATTR_USE_ADBHOST,
            Messages.PreferencePage_Use_Adbhost, getFieldEditorParent());
    addField(mUseAdbHost);
    mAdbHostValue = new StringFieldEditor(PreferenceInitializer.ATTR_ADBHOST_VALUE,
            Messages.PreferencePage_Adbhost_value, getFieldEditorParent());
    mAdbHostValue.setEnabled(getPreferenceStore().getBoolean(PreferenceInitializer.ATTR_USE_ADBHOST),
            getFieldEditorParent());
    addField(mAdbHostValue);
}

From source file:org.eclipse.angularjs.internal.ui.properties.ExpressionPropertyPage.java

License:Open Source License

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

    // start symbol
    StringFieldEditor startSymbolField = new StringFieldEditor(AngularCoreConstants.EXPRESSION_START_SYMBOL,
            AngularUIMessages.ExpressionPropertyPage_startSybol_label, parent);
    addField(startSymbolField);/*www .jav a  2  s . c  om*/

    // end symbol
    StringFieldEditor endSymbolField = new StringFieldEditor(AngularCoreConstants.EXPRESSION_END_SYMBOL,
            AngularUIMessages.ExpressionPropertyPage_endSybol_label, parent);
    addField(endSymbolField);
}