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

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

Introduction

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

Prototype

public void setEnabled(boolean enabled, Composite parent) 

Source Link

Document

Set whether or not the controls in the field editor are enabled.

Usage

From source file:org.eclipse.titan.executor.properties.FieldEditorPropertyPage.java

License:Open Source License

/**
 * Enables or disables the field editors and buttons of this page
*///from ww  w .  j a v  a2 s .co m
protected void updateFieldEditors() {
    if (!isPropertyPage()) {
        return;
    }

    boolean projectSettings = useProjectSettingsButton.getSelection();
    Composite parent = getFieldEditorParent();
    for (FieldEditor editor : editors) {
        editor.setEnabled(projectSettings, parent);
    }
}

From source file:org.eclipse.titan.log.viewer.preferences.pages.LogViewerPreferenceRootPage.java

License:Open Source License

/**
 * Enables or disables the field editors and buttons of this page
 * Subclasses may override.//from   w  w w . jav  a2  s. c  o  m
 * @param enabled true if enabled
 */
protected void updateFieldEditors(final boolean enabled) {
    Composite parent = getFieldEditorParent();
    for (FieldEditor editor : this.editors) {
        editor.setEnabled(enabled, parent);
    }
}

From source file:org.eclipse.ui.internal.monitoring.preferences.MonitoringPreferencePage.java

License:Open Source License

private void enableDependentFields(boolean enable) {
    for (Map.Entry<FieldEditor, Composite> entry : editors.entrySet()) {
        FieldEditor editor = entry.getKey();
        if (!editor.getPreferenceName().equals(PreferenceConstants.MONITORING_ENABLED)) {
            editor.setEnabled(enable, entry.getValue());
        }//from   w w  w.jav a  2s  .  co m
    }
}

From source file:org.entirej.framework.plugin.preferences.FieldEditorOverlayPage.java

License:Apache License

/**
 * Enables or disables the field editors and buttons of this page Subclasses
 * may override./*from  w w  w .  ja v  a  2s . c  om*/
 * 
 * @param enabled
 *            - true if enabled
 */
protected void updateFieldEditors(boolean enabled) {
    Composite parent = getFieldEditorParent();
    Iterator<FieldEditor> it = editors.iterator();
    while (it.hasNext()) {
        FieldEditor editor = it.next();
        editor.setEnabled(enabled, parent);
    }
}

From source file:org.fastcode.preferences.CreateSimilarPreferencePage.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.
 *//*  w  w  w.  j  a v  a 2s.  co  m*/
@Override
public void createFieldEditors() {
    this.project = getPreferenceStore().getString(getPreferenceLabel(P_PROJECT, this.preferenceId));
    String configItems = null;
    final GlobalSettings globalSettings = getInstance();

    final String classType = getPreferenceStoreValueString(P_CLASS_TYPE, this.preferenceId);
    final boolean isClass = CLASS_TYPE.getClassType(classType) == CLASS_TYPE.CLASS;

    if (getPreferenceStore().contains(getPreferenceLabel(P_CONFIG_ITEMS, this.preferenceId))) {
        configItems = getPreferenceStore().getString(getPreferenceLabel(P_CONFIG_ITEMS, this.preferenceId));
    }

    String[] configItemArr = null;
    if (!isEmpty(configItems)) {
        configItemArr = configItems.split(COLON);
    }

    this.numConfigs = configItemArr == null ? this.numMaxConfigs : configItemArr.length;

    if (!isCreateNew()) {
        this.fromPattern = new StringFieldEditor(getPreferenceLabel(P_FROM_PATTERN, this.preferenceId),
                "From Clasees :", 60, getFieldEditorParent());
        this.fromPattern.setEmptyStringAllowed(false);
        addField(this.fromPattern);
    }

    if (!isClass) {
        new Separator(SWT.SEPARATOR | SWT.HORIZONTAL).doFillIntoGrid(getFieldEditorParent(), 10,
                convertHeightInCharsToPixels(2));
    }

    this.toPattern = new StringFieldEditor(getPreferenceLabel(P_TO_PATTERN, this.preferenceId), "To classes :",
            40, getFieldEditorParent());
    this.toPattern.setEmptyStringAllowed(false);
    addField(this.toPattern);

    this.classTypeRadio = new RadioGroupFieldEditor(getPreferenceLabel(P_CLASS_TYPE, this.preferenceId),
            "This is a : ", CLASS_CHOICE_TYPES.length, CLASS_CHOICE_TYPES, getFieldEditorParent(), true);
    addField(this.classTypeRadio);
    this.classTypeRadio.setEnabled(false, getFieldEditorParent());

    final String[][] projects = getAllProjects();
    this.projectComboList = new ComboFieldEditor(getPreferenceLabel(P_PROJECT, this.preferenceId), "Project:",
            projects, getFieldEditorParent());
    addField(this.projectComboList);

    if (!globalSettings.isUseDefaultForPath()) {
        // String[][] sourcePaths =
        // getSourcePathsForProject(getPreferenceStore().getString(getPreferenceLabel(P_PROJECT,
        // preferenceId)));
        final String[][] sourcePaths = getAllSourcePathsInWorkspace();
        this.sourceComboList = new ComboFieldEditor(getPreferenceLabel(P_SOURCE_PATH, this.preferenceId),
                "Source Paths:", sourcePaths, getFieldEditorParent());
        addField(this.sourceComboList);
    }

    if (isCreateNew()) {
        this.packageFieldEditor = new StringButtonFieldEditor(getPreferenceLabel(P_PACKAGE, this.preferenceId),
                "Package :", getFieldEditorParent()) {
            @Override
            protected String changePressed() {
                try {
                    final IJavaProject javaProject = getJavaProject(CreateSimilarPreferencePage.this.project);
                    final SelectionDialog selectionDialog = JavaUI.createPackageDialog(getShell(), javaProject,
                            0, EMPTY_STR);
                    final int ret = selectionDialog.open();
                    if (ret == Window.CANCEL) {
                        return null;
                    }
                    final IPackageFragment packageFragment = (IPackageFragment) selectionDialog.getResult()[0];
                    return packageFragment.getElementName();
                } catch (final JavaModelException e) {
                    e.printStackTrace();
                }
                return null;
            }
        };
        // final IJavaProject javaProject =
        // getJavaProject(CreateSimilarPreferencePage.this.project);
        // this.packageFieldEditor = new
        // FastCodeListEditor(getPreferenceLabel(P_PACKAGE,
        // this.preferenceId), "Package", getFieldEditorParent(),
        // IJavaElement.PACKAGE_FRAGMENT, javaProject);

        addField(this.packageFieldEditor);
        this.packageFieldEditor.setEnabled(!isEmpty(CreateSimilarPreferencePage.this.project),
                getFieldEditorParent());
    }

    // classBodyPattern = new
    // MultiStringFieldEditor(getPreferenceLabel(P_CLASS_BODY_PATTERN,
    // preferenceId), "To Class Pattern :", getFieldEditorParent());
    // addField(classBodyPattern);

    // new
    // AutoCompleteField(classBodyPattern.getTextControl(getFieldEditorParent()),
    // new TextContentAdapter(), keyWords);

    if (!isForValueBeans()) {
        if (!isClass) {
            this.createImplCheckBox = new BooleanFieldEditor(
                    getPreferenceLabel(P_IMPLEMENT_INT, this.preferenceId),
                    "Create an &Implementation of above interface :", getFieldEditorParent());
            addField(this.createImplCheckBox);

            this.implSubPkg = new StringFieldEditor(getPreferenceLabel(P_IMPL_SUB_PACKAGE, this.preferenceId),
                    "Implementation &Sub Package :", 10, getFieldEditorParent());
            addField(this.implSubPkg);
            this.implSubPkg.setEnabled(
                    getPreferenceStore().getBoolean(getPreferenceLabel(P_IMPLEMENT_INT, this.preferenceId)),
                    getFieldEditorParent());
        }

        this.finalCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_FINAL_CLASS, this.preferenceId),
                "Make this Class final :", getFieldEditorParent());
        addField(this.finalCheckBox);
        if (this.preferenceId.equals(CREATE_NEW_PREFERENCE_SERVICE_ID)) {
            this.finalCheckBox.setEnabled(false, getFieldEditorParent());
        }

        // this.classHeader = new
        // MultiStringFieldEditor(getPreferenceLabel(P_CLASS_HEADER,
        // preferenceId), "Code Before Class (Header) :",
        // getFieldEditorParent());
        // addField(this.classHeader);

        this.classInsideBody = new MultiStringFieldEditor(
                getPreferenceLabel(P_CLASS_INSIDE_BODY, this.preferenceId), "Code In the Class (&Body) :",
                getFieldEditorParent());
        addField(this.classInsideBody);

        this.implSuperClass = new FastCodeListEditor(getPreferenceLabel(P_SUPER_CLASS, this.preferenceId),
                "Implementation &Super Class :", getFieldEditorParent(),
                IJavaElementSearchConstants.CONSIDER_CLASSES, null);
        addField(this.implSuperClass);
        // this.implSuperClass.setEnabled(getPreferenceStore().getBoolean(getPreferenceLabel(P_IMPLEMENT_INTERFACES,
        // preferenceId)), getFieldEditorParent());
        //this.implSuperClass.setChangeButtonText(BUTTON_TEXT_BROWSE);

        this.interfaces = new FastCodeListEditor(getPreferenceLabel(P_IMPLEMENT_INTERFACES, this.preferenceId),
                "Interfaces To &Implement:", getFieldEditorParent(), CONSIDER_INTERFACES, null);
        addField(this.interfaces);

        this.classImports = new FastCodeListEditor(getPreferenceLabel(P_CLASS_IMPORTS, this.preferenceId),
                "Clases To I&mport:", getFieldEditorParent(), CONSIDER_ALL_TYPES, null);
        addField(this.classImports);

        this.inclInstanceCheckBox = new BooleanFieldEditor(
                getPreferenceLabel(P_INCLUDE_INSTACE_FROM, this.preferenceId),
                "Include an in&stance of the from class :", getFieldEditorParent());
        addField(this.inclInstanceCheckBox);
        this.inclInstanceCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.createDefaultConstructor = new BooleanFieldEditor(
                getPreferenceLabel(P_CREATE_DEFAULT_CONSTRUCTOR, this.preferenceId),
                "Create Default Co&nstructor :", getFieldEditorParent());
        addField(this.createDefaultConstructor);

        this.createInstanceConstructor = new BooleanFieldEditor(
                getPreferenceLabel(P_CREATE_INSTANCE_CONSTRUCTOR, this.preferenceId),
                "Create Instance Co&nstructor :", getFieldEditorParent());
        addField(this.createInstanceConstructor);

        this.inclGetterSetterCheckBox = new BooleanFieldEditor(
                getPreferenceLabel(P_INCLUDE_GETTER_SETTER_INSTACE_FROM, this.preferenceId),
                "Generate &getter/setters for private fields :", getFieldEditorParent());
        addField(this.inclGetterSetterCheckBox);

        this.copyMethodCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_COPY_METHODS, this.preferenceId),
                "Copy &methods from the from Class", getFieldEditorParent());
        addField(this.copyMethodCheckBox);
        this.copyMethodCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.createMethodBody = new BooleanFieldEditor(
                getPreferenceLabel(P_CREATE_METHOD_BODY, this.preferenceId), "Create &method Body",
                getFieldEditorParent());
        addField(this.createMethodBody);
        this.createMethodBody.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.addionalFieldsCheckBox = new BooleanFieldEditor(
                getPreferenceLabel(P_CREATE_FIELDS, this.preferenceId), "Create &Additional Fields",
                getFieldEditorParent());
        addField(this.addionalFieldsCheckBox);

        this.addionalFieldsNameField = new StringFieldEditor(
                getPreferenceLabel(P_CREATE_FIELDS_NAME, this.preferenceId),
                "Name/Pattern for &Additional Fields", getFieldEditorParent());
        addField(this.addionalFieldsNameField);

        this.includePattern = new StringFieldEditor(getPreferenceLabel(P_INCLUDE_PATTERN, this.preferenceId),
                "Include Methods/Fields:", 20, getFieldEditorParent());
        addField(this.includePattern);
        this.includePattern.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.excludePattern = new StringFieldEditor(getPreferenceLabel(P_EXCLUDE_PATTERN, this.preferenceId),
                "Exclude Methods/Fields:", 20, getFieldEditorParent());
        addField(this.excludePattern);
        this.excludePattern.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.classAnnotations = new FastCodeListEditor(
                getPreferenceLabel(P_CLASS_ANNOTATIONS, this.preferenceId), "Class &Annotations:",
                getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null);
        addField(this.classAnnotations);

        this.fieldAnnotations = new FastCodeListEditor(
                getPreferenceLabel(P_FIELD_ANNOTATIONS, this.preferenceId), "Field &Annotations:",
                getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null);
        addField(this.fieldAnnotations);

        this.methodAnnotations = new FastCodeListEditor(
                getPreferenceLabel(P_METHOD_ANNOTATIONS, this.preferenceId), "Method &Annotations:",
                getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null);
        addField(this.methodAnnotations);
        /*
          this.assignReturnCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_RETURN_VARIABLE, this.preferenceId), "Assign &return type to a variable :",
                getFieldEditorParent());
          addField(this.assignReturnCheckBox);
          this.assignReturnCheckBox.setEnabled(!isCreateNew(),getFieldEditorParent());
                
          this.returnVariableName = new StringFieldEditor(getPreferenceLabel(P_RETURN_VARIABLE_NAME, this.preferenceId), "&Return variable name :", 20,
                getFieldEditorParent());
          this.returnVariableName.setEmptyStringAllowed(!this.assignReturnCheckBox.getBooleanValue());
          addField(this.returnVariableName);
          this.returnVariableName.setEnabled(!isCreateNew(),getFieldEditorParent());*/

        this.convertMethodParamCheckBox = new BooleanFieldEditor(
                getPreferenceLabel(P_CONVERT_METHOD_PARAM, this.preferenceId), "Convert Method &Parameter:",
                getFieldEditorParent());
        addField(this.convertMethodParamCheckBox);
        this.convertMethodParamCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.convertMethodParamFromField = new StringFieldEditor(
                getPreferenceLabel(P_CONVERT_METHOD_PARAM_FROM, this.preferenceId),
                "Convert Method &Parameter From :", 50, getFieldEditorParent());
        addField(this.convertMethodParamFromField);
        this.convertMethodParamFromField.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.convertMethodParamToField = new StringFieldEditor(
                getPreferenceLabel(P_CONVERT_METHOD_PARAM_TO, this.preferenceId),
                "Convert Method &Parameter To :", 50, getFieldEditorParent());
        addField(this.convertMethodParamToField);
        this.convertMethodParamToField.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.createUnitTestCheckBox = new BooleanFieldEditor(
                getPreferenceLabel(P_CREATE_UNIT_TEST, this.preferenceId),
                "Create &Unit Test of the Target Class:", getFieldEditorParent());
        addField(this.createUnitTestCheckBox);
        this.createUnitTestCheckBox.setEnabled(false, getFieldEditorParent());
    } else {
        // classHeader = new
        // MultiStringFieldEditor(getPreferenceLabel(P_CLASS_HEADER,
        // preferenceId), "Code Before Class (Header) :",
        // getFieldEditorParent());
        // addField(classHeader);
        this.finalCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_FINAL_CLASS, this.preferenceId),
                "Make this Class final :", getFieldEditorParent());
        addField(this.finalCheckBox);

        this.classInsideBody = new MultiStringFieldEditor(
                getPreferenceLabel(P_CLASS_INSIDE_BODY, this.preferenceId), "Code In the Class (&Body) :",
                getFieldEditorParent());
        addField(this.classInsideBody);

        this.implSuperClass = new FastCodeListEditor(getPreferenceLabel(P_SUPER_CLASS, this.preferenceId),
                "Implementation &Super Class :", getFieldEditorParent(),
                IJavaElementSearchConstants.CONSIDER_CLASSES, null);
        addField(this.implSuperClass);

        this.interfaces = new FastCodeListEditor(getPreferenceLabel(P_IMPLEMENT_INTERFACES, this.preferenceId),
                "Interfaces To &Implement:", getFieldEditorParent(), CONSIDER_INTERFACES, null);
        addField(this.interfaces);

        this.classImports = new FastCodeListEditor(getPreferenceLabel(P_CLASS_IMPORTS, this.preferenceId),
                "Clases To I&mport:", getFieldEditorParent(), CONSIDER_ALL_TYPES, null);
        addField(this.classImports);

        this.createDefaultConstructor = new BooleanFieldEditor(
                getPreferenceLabel(P_CREATE_DEFAULT_CONSTRUCTOR, this.preferenceId),
                "Create Default &Constructor :", getFieldEditorParent());
        addField(this.createDefaultConstructor);

        this.createInstanceConstructor = new BooleanFieldEditor(
                getPreferenceLabel(P_CREATE_INSTANCE_CONSTRUCTOR, this.preferenceId),
                "Create Instance &Constructor :", getFieldEditorParent());
        addField(this.createInstanceConstructor);

        this.copyFieldsCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_COPY_FIELDS, this.preferenceId),
                "Copy &Fields from the from Class :", getFieldEditorParent());
        addField(this.copyFieldsCheckBox);
        this.copyFieldsCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.breakDateFieldsCheckBox = new BooleanFieldEditor(
                getPreferenceLabel(P_BREAK_DATE_FIELDS, this.preferenceId), "Break &Date Fields :",
                getFieldEditorParent());
        addField(this.breakDateFieldsCheckBox);
        this.breakDateFieldsCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent());

        this.classAnnotations = new FastCodeListEditor(
                getPreferenceLabel(P_CLASS_ANNOTATIONS, this.preferenceId), "Class &Annotations:",
                getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null);
        addField(this.classAnnotations);

        this.fieldAnnotations = new FastCodeListEditor(
                getPreferenceLabel(P_FIELD_ANNOTATIONS, this.preferenceId), "Field &Annotations:",
                getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null);
        addField(this.fieldAnnotations);

        this.includePattern = new StringFieldEditor(getPreferenceLabel(P_INCLUDE_PATTERN, this.preferenceId),
                "Include Methods/Fields:", getFieldEditorParent());
        addField(this.includePattern);

        this.excludePattern = new StringFieldEditor(getPreferenceLabel(P_EXCLUDE_PATTERN, this.preferenceId),
                "Exclude Methods/Fields:", getFieldEditorParent());
        addField(this.excludePattern);
    }

    this.createWorkingSetCheckBox = new BooleanFieldEditor(
            getPreferenceLabel(P_CREATE_WORKING_SET, this.preferenceId), "Automatically Create a Working Set :",
            30, getFieldEditorParent());
    addField(this.createWorkingSetCheckBox);

    this.workingSetName = new StringFieldEditor(getPreferenceLabel(P_WORKING_SET_NAME, this.preferenceId),
            "Working Set Name :", 30, getFieldEditorParent());
    addField(this.workingSetName);

    final String[][] configTypes = new String[this.configPattern.getConfigs().length][2];
    for (int k = 0; k < configTypes.length; k++) {
        configTypes[k][0] = configTypes[k][1] = this.configPattern.getConfigs()[k].getConfigType();
    }

    final String[][] configFileConvTypes = new String[4][2];
    configFileConvTypes[0][0] = configFileConvTypes[0][1] = CONVERSION_NONE;
    configFileConvTypes[1][0] = configFileConvTypes[1][1] = CONVERSION_LOWER_CASE;
    configFileConvTypes[2][0] = configFileConvTypes[2][1] = CONVERSION_CAMEL_CASE;
    configFileConvTypes[3][0] = configFileConvTypes[3][1] = CONVERSION_CAMEL_CASE_HYPHEN;

    // Create the configuration file items.

    for (int configCount = 0; configCount < this.numMaxConfigs; configCount++) {
        final String configType = this.configPattern.getConfigs()[configCount].getConfigType();
        if (!(isStringInArray(configType, configItemArr)
                || isStringInArray(configType, this.configPattern.getConfigTypes().get(this.preferenceId)))) {
            continue;
        }

        new Separator(SWT.SEPARATOR | SWT.HORIZONTAL).doFillIntoGrid(getFieldEditorParent(), 100,
                convertHeightInCharsToPixels(2));

        this.createConfigCheckBox[configCount] = new BooleanFieldEditor(
                getPreferenceLabel(P_CREATE_CONFIG, this.preferenceId) + configCount,
                "Create configuration file :", getFieldEditorParent());

        addField(this.createConfigCheckBox[configCount]);

        final boolean enableConfigParts = getPreferenceStore()
                .getBoolean(getPreferenceLabel(P_CREATE_CONFIG, this.preferenceId) + configCount);

        FieldEditor fieldEditor;

        fieldEditor = createRadioGroupFieldEditor(
                getPreferenceLabel(P_CONFIG_TYPE, this.preferenceId) + configCount, "Configuration Type",
                this.configPattern.getConfigs().length, configTypes, getFieldEditorParent(), true);
        this.createSimilarConfigurationPart.setConfigTypeRadio(configCount,
                (RadioGroupFieldEditor) fieldEditor);
        addField(fieldEditor);
        fieldEditor.setEnabled(false, getFieldEditorParent());

        fieldEditor = createStringFieldEditor(
                getPreferenceLabel(P_CONFIG_LOCATION, this.preferenceId) + configCount,
                "Configuration Location :", getFieldEditorParent());
        this.createSimilarConfigurationPart.setConfigLocation(configCount, (StringFieldEditor) fieldEditor);
        addField(fieldEditor);

        fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent());
        // ((StringFieldEditor)fieldEditor).setEmptyStringAllowed(enableConfigParts
        // ? false : true);

        fieldEditor = createStringFieldEditor(
                getPreferenceLabel(P_CONFIG_FILE_NAME, this.preferenceId) + configCount,
                "Configuration File Name :", getFieldEditorParent());
        this.createSimilarConfigurationPart.setConfigFile(configCount, (StringFieldEditor) fieldEditor);

        // configFile[configCount] = new
        // StringFieldEditor(getPreferenceLabel(P_CONFIG_FILE_NAME,
        // preferenceId)+configCount, "Configuration File Name :",
        // getFieldEditorParent());
        addField(fieldEditor);
        fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent());
        ((StringFieldEditor) fieldEditor).setEmptyStringAllowed(enableConfigParts ? false : true);

        fieldEditor = new RadioGroupFieldEditor(
                getPreferenceLabel(P_CONFIG_FILE_CONV_TYPES, this.preferenceId) + configCount,
                "Convert the File Name :", configFileConvTypes.length, configFileConvTypes,
                getFieldEditorParent(), true);
        this.createSimilarConfigurationPart.setConfigFileNameConversion(configCount,
                (RadioGroupFieldEditor) fieldEditor);
        addField(fieldEditor);
        fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent());

        if (!isEmpty(this.configPattern.getConfigs()[configCount].getConfigLocale())) {
            fieldEditor = new StringFieldEditor(
                    getPreferenceLabel(P_CONFIG_LOCALE, this.preferenceId) + configCount,
                    "Configuration Locale :", getFieldEditorParent());
            this.createSimilarConfigurationPart.setConfigLocale(configCount, (StringFieldEditor) fieldEditor);
            addField(fieldEditor);
            fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent());
        }

        fieldEditor = createMultiStringFieldEditor(
                getPreferenceLabel(P_CONFIG_HEADER_PATTERN, this.preferenceId) + configCount,
                "Configuration Header :", getFieldEditorParent());
        this.createSimilarConfigurationPart.setConfigHeaderPattern(configCount,
                (MultiStringFieldEditor) fieldEditor);
        addField(fieldEditor);
        fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent());

        fieldEditor = createMultiStringFieldEditor(
                getPreferenceLabel(P_CONFIG_START_PATTERN, this.preferenceId) + configCount,
                "Configuration Start :", getFieldEditorParent());
        this.createSimilarConfigurationPart.setConfigStartPattern(configCount,
                (MultiStringFieldEditor) fieldEditor);
        addField(fieldEditor);
        fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent());

        fieldEditor = createStringFieldEditor(
                getPreferenceLabel(P_CONFIG_END_PATTERN, this.preferenceId) + configCount,
                "Configuration End :", getFieldEditorParent());
        this.createSimilarConfigurationPart.setConfigEndPattern(configCount, (StringFieldEditor) fieldEditor);
        addField(fieldEditor);
        fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent());

        fieldEditor = createMultiStringFieldEditor(
                getPreferenceLabel(P_CONFIG_PATTERN, this.preferenceId) + configCount,
                "Configuration Pattern :", getFieldEditorParent());
        this.createSimilarConfigurationPart.setConfigBodyPattern(configCount,
                (MultiStringFieldEditor) fieldEditor);
        addField(fieldEditor);
        fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent());
        ((MultiStringFieldEditor) fieldEditor).setEmptyStringAllowed(enableConfigParts ? false : true);
    }

    this.removeConfigCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_REMOVE_CONFIG, this.preferenceId),
            "Remove unused configurations :", BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent());
    if (this.numConfigs > 1) {
        // removeConfig should be always off.
        addField(this.removeConfigCheckBox);
        getPreferenceStore().setValue(getPreferenceLabel(P_REMOVE_CONFIG, this.preferenceId), false);
        this.removeConfigCheckBox.load();
    }
    final Button restoreConfigButton = new Button(getFieldEditorParent(), SWT.PUSH);
    restoreConfigButton.setText("Restore configurations");
    if (this.numConfigs == this.numMaxConfigs) {
        restoreConfigButton.setEnabled(false);
    }

    restoreConfigButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {

            final MessageDialogWithToggle dialogWithToggle = MessageDialogWithToggle.openYesNoQuestion(
                    CreateSimilarPreferencePage.this.getShell(), "Restore configurations",
                    "Restore configurations, this will close the preference dialog, You have reopen it.",
                    "Remember Decision", false, CreateSimilarPreferencePage.this.getPreferenceStore(),
                    getPreferenceLabel(P_RESTORE_CONFIG_ITEMS, CreateSimilarPreferencePage.this.preferenceId));
            if (dialogWithToggle.getReturnCode() != MESSAGE_DIALOG_RETURN_YES) {
                return;
            }
            CreateSimilarPreferencePage.this.getPreferenceStore().setValue(
                    getPreferenceLabel(P_CONFIG_ITEMS, CreateSimilarPreferencePage.this.preferenceId), "");
            CreateSimilarPreferencePage.this.getShell().close();
            // getShell().open();
        }
    });

}

From source file:org.genivi.commonapi.core.ui.preferences.FieldEditorOverlayPage.java

License:Mozilla Public License

/**
 * Enables the field editors and buttons of this page 
 *///from   w  ww  .j  a  v a 2  s. c o  m
protected void enableControls(boolean state) {
    Composite parent = getFieldEditorParent();
    Iterator<FieldEditor> it = editors.iterator();
    while (it.hasNext()) {
        FieldEditor editor = it.next();
        editor.setEnabled(state, parent);
    }
    for (Button button : buttons) {
        button.setEnabled(state);
    }
}

From source file:org.gradle.eclipse.preferences.FieldEditorOverlayPage.java

License:Apache License

protected void updateFieldEditors(boolean enabled) {
    Composite parent = getFieldEditorParent();
    Iterator<FieldEditor> it = editors.iterator();
    while (it.hasNext()) {
        FieldEditor editor = it.next();
        editor.setEnabled(enabled, parent);
    }// ww w.j ava 2s  .c o m
}

From source file:org.jboss.tools.common.model.ui.wizards.special.SpecialWizardStep.java

License:Open Source License

public void updateFieldEnablement() {
    if (stepControl == null || stepControl.isDisposed())
        return;/* w ww  .  ja va  2  s .c o  m*/
    Properties p = attributes.getValues();
    XAttributeData[] ad = support.getEntityData()[id].getAttributeData();
    for (int i = 0; i < ad.length; i++) {
        String n = ad[i].getAttribute().getName();
        boolean b = support.isFieldEditorEnabled(id, n, p);
        FieldEditor f = attributes.getFieldEditorByName(n);
        if (f != null)
            f.setEnabled(b, stepControl);
    }
}

From source file:org.jboss.tools.jsf.ui.wizard.project.ImportProjectFoldersPage.java

License:Open Source License

protected void setDependencies() {
    boolean b = "true".equals(addLibAdapter.getStringValue(true)); //$NON-NLS-1$
    FieldEditor f = support.getFieldEditorByName("version"); //$NON-NLS-1$
    f.setEnabled(b, supportControl);
}

From source file:org.jsweet.plugin.preferences.FieldEditorProjectPreferencePage.java

License:Apache License

protected void updateFieldEditors() {
    boolean pageEnabled = this.isPageEnabled();
    Composite parent = this.getFieldEditorParent();
    for (FieldEditor field : this.fields) {
        field.setEnabled(pageEnabled, parent);
    }//from w w w .  j  a v  a  2  s.  c o  m
}