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

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

Introduction

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

Prototype

@Override
    public void setEnabled(boolean enabled, Composite parent) 

Source Link

Usage

From source file:com.photon.phresco.ui.preferences.PhrescoPreferencePage.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 ww w . ja  v  a 2 s . c o m*/
 */
public void createFieldEditors() {
    Composite serviceComposite = new Composite(getFieldEditorParent(), NONE);
    GridLayout layout = new GridLayout(1, false);
    serviceComposite.setLayout(layout);
    StringFieldEditor serviceURL = new StringFieldEditor(PreferenceConstants.SERVICE_URL,
            Messages.PhrescoPreferencePage_service_url, serviceComposite);
    addField(serviceURL);
    serviceURL.setEnabled(false, serviceComposite);
    new Label(serviceComposite, SWT.None).setText(Messages.PhrescoPreferencePage_username_label);
    userTxt = new Text(serviceComposite, SWT.BORDER);
    userTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    userTxt.setText(username);
    new Label(serviceComposite, SWT.None).setText(Messages.PhrescoPreferencePage_password_label);
    pwdTxt = new Text(serviceComposite, SWT.BORDER | SWT.PASSWORD);
    pwdTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    pwdTxt.setText(password);
    new Label(serviceComposite, SWT.None).setText("");
    testBtn = new Button(serviceComposite, SWT.PUSH);
    testBtn.setText(Messages.PhrescoPreferencePage_testbutton_name);
    testBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    serviceComposite.setLayoutData(data);
    StringFieldEditor jenkinsURL = new StringFieldEditor(PreferenceConstants.JENKINS_URL,
            Messages.PhrescoPreferencePage_ci_url, getFieldEditorParent());
    addField(jenkinsURL);
}

From source file:com.siemens.ct.mp3m.ui.editors.id3.databinding.Id3TagPage.java

License:Open Source License

private void addKeyValuePair(String key, IMP3Info id3TagInfo, String value,
        final DataBindingContext bindingContext, boolean editable) {
    StringFieldEditor stringEditor = new StringFieldEditor(key, key + ":", section); //$NON-NLS-1$
    toolkit.adapt(stringEditor.getTextControl(section), true, true);
    stringEditor.setEnabled(editable, section);
    Label label = stringEditor.getLabelControl(section);
    label.setEnabled(true);//www  .ja  va2s.  c o m
    toolkit.adapt(label, false, false);
    ControlDecoration controlDecoration = createTextDecoration(stringEditor.getTextControl(section));

    // do the data binding
    bindingContext.bindValue(SWTObservables.observeText(stringEditor.getTextControl(section), SWT.Modify),
            PojoObservables.observeValue(id3TagInfo, value),
            new UpdateValueStrategy().setAfterConvertValidator(new RequiredValidator(controlDecoration, this)),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE));

    stringEditor.setPropertyChangeListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (AggregateValidationStatus
                    .getStatusMerged(bindingContext.getValidationStatusProviders()) == Status.OK_STATUS) {
                if (event.getProperty().equals("field_editor_value")) {
                    isDirty = true;
                }
                getEditor().editorDirtyStateChanged();
            }
        }
    });
    fieldEditors.add(stringEditor);
}

From source file:com.siemens.ct.mp3m.ui.editors.id3.Id3TagPage.java

License:Open Source License

private void addKeyValuePair(String key, String value, boolean editable) {
    StringFieldEditor stringEditor = new StringFieldEditor(key, key + ":", section); //$NON-NLS-1$
    toolkit.adapt(stringEditor.getTextControl(section), true, true);
    stringEditor.setStringValue(value);//  w w w .j  av a  2  s  .c o m
    stringEditor.setEnabled(editable, section);
    Label label = stringEditor.getLabelControl(section);
    label.setEnabled(true);
    toolkit.adapt(label, false, false);

    stringEditor.setPropertyChangeListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals("field_editor_value")) {
                isDirty = true;
            }
            getEditor().editorDirtyStateChanged();
        }
    });
    fieldEditors.add(stringEditor);
}

From source file:org.cs3.pdt.connector.internal.preferences.ConfigurationPreferencePage.java

License:Open Source License

@Override
public void createFieldEditors() {
    Group executableGroup = new Group(getFieldEditorParent(), SWT.SHADOW_ETCHED_OUT);
    executableGroup.setText("Executable");

    invocation = new MyStringFieldEditor(Connector.PREF_INVOCATION, "OS invocation", executableGroup);
    addField(invocation);//  ww  w  .j a  va2  s.  com

    // eg. xpce or /usr/bin/xpce
    executable = new MyFileFieldEditor(Connector.PREF_EXECUTABLE, "Prolog executable", executableGroup);
    executable.getLabelControl(executableGroup)
            .setToolTipText("Don't enter quotes, they will be added automatically.");
    addField(executable);

    commandLineArguments = new MyStringFieldEditor(Connector.PREF_COMMAND_LINE_ARGUMENTS,
            "Command line arguments", executableGroup);
    commandLineArguments.getLabelControl(executableGroup)
            .setToolTipText("See SWI-Prolog manual for a list of possible command line arguments.");
    addField(commandLineArguments);

    startupFiles = new MyStringFieldEditor(Connector.PREF_ADDITIONAL_STARTUP, "Additional startup files",
            executableGroup) {
        @Override
        protected boolean doCheckState() {
            String value = getStringValue();
            String[] files = value.split(",");
            for (String file : files) {
                if (file.contains(" ")) {
                    if (!(file.startsWith("\"") && file.endsWith("\""))
                            && !(file.startsWith("'") && file.endsWith("'"))) {
                        return false;
                    }
                }
            }
            return true;
        }
    };
    startupFiles.setErrorMessage(
            "File paths containing white spaces must be enclosed in double quotes. To enter multiple files, separate them by a comma.");
    startupFiles.getLabelControl(executableGroup).setToolTipText(
            "Can be multiple files, seperated by commas.\nAdd quotes if needed!\n\nExample: \"c:/my files/dummy.pl\" dummy2.pl");

    addField(startupFiles);

    executeablePreviewLabel = new MyLabelFieldEditor(executableGroup, "Executable preview");
    addField(executeablePreviewLabel);

    extraEnvironmentVariables = new MyStringFieldEditor(Connector.PREF_ENVIRONMENT,
            "Extra environment variables", getFieldEditorParent());
    addField(extraEnvironmentVariables);

    serverLogDir = new MyDirectoryFieldEditor(Connector.PREF_SERVER_LOGDIR, "Server-Log file location",
            getFieldEditorParent());
    addField(serverLogDir);

    timeoutFieldEditor = new MyIntegerFieldEditor(Connector.PREF_TIMEOUT, "Connect Timeout",
            getFieldEditorParent());
    timeoutFieldEditor.getTextControl(getFieldEditorParent())
            .setToolTipText("Milliseconds to wait until connection to a new Prolog Process is established");
    timeoutFieldEditor.getLabelControl(getFieldEditorParent())
            .setToolTipText("Milliseconds to wait until connection to a new Prolog Process is established");
    addField(timeoutFieldEditor);

    // The host the process server is listening on
    StringFieldEditor host = new MyStringFieldEditor(Connector.PREF_HOST, "Server host",
            getFieldEditorParent());
    host.setEnabled(false, getFieldEditorParent());
    addField(host);

    // The port the process server is listening on
    IntegerFieldEditor port = new MyIntegerFieldEditor(Connector.PREF_PORT, "Server port",
            getFieldEditorParent());
    port.setEnabled(false, getFieldEditorParent());
    addField(port);

    hidePrologWindow = new MyBooleanFieldEditor(Connector.PREF_HIDE_PLWIN,
            "Hide prolog process window (Windows only)", getFieldEditorParent());
    addField(hidePrologWindow);

    adjustLayoutForElement(executableGroup);
}

From source file:org.cs3.prolog.connector.internal.preferences.PreferencePage.java

License:Open Source License

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

    Group executableGroup = new Group(getFieldEditorParent(), SWT.SHADOW_ETCHED_OUT);
    executableGroup.setText("Executable");

    invocation = new MyStringFieldEditor(PrologRuntime.PREF_INVOCATION, "OS invocation", executableGroup);
    addField(invocation);

    // eg. xpce or /usr/bin/xpce
    executable = new MyFileFieldEditor(PrologRuntime.PREF_EXECUTABLE, "Prolog executable", executableGroup);
    executable.getLabelControl(executableGroup)
            .setToolTipText("Don't enter quotes, they will be added automatically.");
    addField(executable);

    commandLineArguments = new MyStringFieldEditor(PrologRuntime.PREF_COMMAND_LINE_ARGUMENTS,
            "Command line arguments", executableGroup);
    commandLineArguments.getLabelControl(executableGroup)
            .setToolTipText("See SWI-Prolog manual for a list of possible command line arguments.");
    addField(commandLineArguments);

    startupFiles = new MyStringFieldEditor(PrologRuntime.PREF_ADDITIONAL_STARTUP, "Additional startup files",
            executableGroup) {
        @Override
        protected boolean doCheckState() {
            String value = getStringValue();
            String[] files = value.split(",");
            for (String file : files) {
                if (file.contains(" ")) {
                    if (!(file.startsWith("\"") && file.endsWith("\""))
                            && !(file.startsWith("'") && file.endsWith("'"))) {
                        return false;
                    }
                }
            }
            return true;
        }
    };
    startupFiles.setErrorMessage(
            "File paths containing white spaces must be enclosed in double quotes. To enter multiple files, separate them by a comma.");
    startupFiles.getLabelControl(executableGroup).setToolTipText(
            "Can be multiple files, seperated by commas.\nAdd quotes if needed!\n\nExample: \"c:/my files/dummy.pl\" dummy2.pl");

    addField(startupFiles);

    executeablePreviewLabel = new MyLabelFieldEditor(executableGroup, "Executable preview");
    addField(executeablePreviewLabel);

    extraEnvironmentVariables = new MyStringFieldEditor(PrologRuntime.PREF_ENVIRONMENT,
            "Extra environment variables", getFieldEditorParent());
    addField(extraEnvironmentVariables);

    serverLogDir = new MyDirectoryFieldEditor(PrologRuntime.PREF_SERVER_LOGDIR, "Server-Log file location",
            getFieldEditorParent());
    addField(serverLogDir);

    timeoutFieldEditor = new MyIntegerFieldEditor(PrologRuntime.PREF_TIMEOUT, "Connect Timeout",
            getFieldEditorParent());
    timeoutFieldEditor.getTextControl(getFieldEditorParent())
            .setToolTipText("Milliseconds to wait until connection to a new Prolog Process is established");
    timeoutFieldEditor.getLabelControl(getFieldEditorParent())
            .setToolTipText("Milliseconds to wait until connection to a new Prolog Process is established");
    addField(timeoutFieldEditor);

    // The host the PIF server is listening on
    StringFieldEditor host = new MyStringFieldEditor(PrologRuntime.PREF_HOST, "Server host",
            getFieldEditorParent());
    host.setEnabled(false, getFieldEditorParent());
    addField(host);

    // The port the PIF server is listening on
    IntegerFieldEditor port = new MyIntegerFieldEditor(PrologRuntime.PREF_PORT, "Server port",
            getFieldEditorParent());
    port.setEnabled(false, getFieldEditorParent());
    addField(port);

    hidePrologWindow = new MyBooleanFieldEditor(PrologRuntime.PREF_HIDE_PLWIN,
            "Hide prolog process window (Windows only)", getFieldEditorParent());
    addField(hidePrologWindow);

    adjustLayoutForElement(configurationSelector);
    adjustLayoutForElement(executableGroup);
}

From source file:org.csstudio.desy.logging.ui.LoggingPreferencePage.java

License:Open Source License

private void makeFileInfoArea() {
    StringFieldEditor fileNameEditor = new StringFieldEditor("FileName", "&File", getFieldEditorParent());
    fileNameEditor.setEnabled(false, getFieldEditorParent());
    fileNameEditor.setStringValue(getFilePath());
    addField(fileNameEditor);/*  w  w w.  j  a va  2s. c  o  m*/
}

From source file:org.dawb.tango.extensions.editors.preferences.CalibrationPreferences.java

License:Open Source License

private void updateEnabled(boolean enabled) {
    for (StringFieldEditor ed : editors) {
        ed.setEnabled(enabled, getFieldEditorParent());
    }//from  w ww  . j a  v a 2  s  . c o  m

    final Control[] controls = getFieldEditorParent().getChildren();
    for (int i = 0; i < controls.length; i++) {
        if (controls[i] instanceof Text) {
            controls[i].setEnabled(enabled);
        }
    }
    getFieldEditorParent().layout(true, true);
}

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  w  w  .  jav a 2 s. co 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.dawb.workbench.ui.editors.preference.EditorPreferencePage.java

License:Open Source License

protected void updateMode(StringFieldEditor datasetNameEditor, PlotDataSelection pds) {

    datasetNameEditor.setEnabled(pds.isFixed(), getFieldEditorParent());
    if (!pds.isActive()) {
        datasetNameEditor.setStringValue("");
    } else {/*from ww  w  . j a va  2 s .  c  om*/
        datasetNameEditor.setStringValue(getPreferenceStore().getString(EditorConstants.DATA_SEL));
    }

}

From source file:org.eclipse.linuxtools.internal.lttng2.control.ui.views.preferences.ControlPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {

    StringFieldEditor tracingGroup = new StringFieldEditor(ControlPreferences.TRACE_CONTROL_TRACING_GROUP_PREF,
            Messages.TraceControl_TracingGroupPreference, getFieldEditorParent());
    addField(tracingGroup);/*from  w  ww  .j ava2s  . c o  m*/

    BooleanFieldEditor logCommand = new BooleanFieldEditor(ControlPreferences.TRACE_CONTROL_LOG_COMMANDS_PREF,
            Messages.TraceControl_LoggingPreference, getFieldEditorParent());
    addField(logCommand);

    StringFieldEditor logfile = new StringFieldEditor(ControlPreferences.TRACE_CONTROL_LOG_FILE_PATH_PREF,
            Messages.TraceControl_LogfilePath, getFieldEditorParent());
    addField(logfile);

    fIsAppend = new BooleanFieldEditor(ControlPreferences.TRACE_CONTROL_LOG_APPEND_PREF,
            Messages.TraceControl_AppendLogfilePreference, getFieldEditorParent());
    addField(fIsAppend);

    fVerboseLevel = new RadioGroupFieldEditor(ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_PREF,
            Messages.TraceControl_VerboseLevelsPreference, 4,
            new String[][] {
                    { Messages.TraceControl_VerboseLevelNonePreference,
                            ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_NONE, },
                    { Messages.TraceControl_VerboseLevelVerbosePreference,
                            ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_VERBOSE },
                    { Messages.TraceControl_VerboseLevelVeryVerbosePreference,
                            ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_V_VERBOSE },
                    { Messages.TraceControl_VerboseLevelVeryVeryVerbosePreference,
                            ControlPreferences.TRACE_CONTROL_VERBOSE_LEVEL_V_V_VERBOSE } },
            getFieldEditorParent(), true);

    addField(fVerboseLevel);

    Boolean enabled = ControlPreferences.getInstance().isLoggingEnabled();
    fVerboseLevel.setEnabled(enabled, getFieldEditorParent());
    fIsAppend.setEnabled(enabled, getFieldEditorParent());
    logfile.setEnabled(false, getFieldEditorParent());

    IntegerFieldEditor commandTimeout = new IntegerFieldEditor(
            ControlPreferences.TRACE_CONTROL_COMMAND_TIMEOUT_PREF, Messages.TraceControl_CommandTimeout,
            getFieldEditorParent());
    commandTimeout.setValidRange(ControlPreferences.TRACE_CONTROL_MIN_TIMEOUT_VALUE,
            ControlPreferences.TRACE_CONTROL_MAX_TIMEOUT_VALUE);
    addField(commandTimeout);
}