List of usage examples for org.eclipse.jface.preference StringFieldEditor StringFieldEditor
public StringFieldEditor(String name, String labelText, int width, Composite parent)
From source file:net.sourceforge.eclipseccase.ui.preferences.DecoratorPreferencePage.java
License:Open Source License
/** * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() *///from w w w .j a v a 2s .co m @Override protected void createFieldEditors() { /* * // general dirtyFolders = new * MasterBooleanFieldEditor(ClearCaseUIPreferences * .DECORATE_FOLDERS_DIRTY, * PreferenceMessages.getString("DecoratorPreferencePage.folders.dirty" * ), //$NON-NLS-1$ getFieldEditorParent(CAT_GENERAL)); * addField(dirtyFolders); * * dirtyFoldersWithViewPrivate = new * BooleanFieldEditor(ClearCaseUIPreferences * .DECORATE_FOLDERS_CONTAINING_VIEW_PRIVATE_DIRTY, * PreferenceMessages.getString * ("DecoratorPreferencePage.folders.dirty.withViewPrivate"), * getFieldEditorParent(CAT_GENERAL));//$NON-NLS-1$ * addField(dirtyFoldersWithViewPrivate); * dirtyFolders.addSlave(dirtyFoldersWithViewPrivate); */ // image decoration decorateClearCaseElements = new MasterBooleanFieldEditor(ClearCaseUIPreferences.DECORATE_CLEARCASE_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.clearCaseElements"), //$NON-NLS-1$ getFieldEditorParent(CAT_IMAGES)); addField(decorateClearCaseElements); // customClearCaseElementsBackground = new MasterBooleanFieldEditor(ClearCaseUIPreferences.IMAGE_CLEARCASE_ELEMENTS_BACKGROUND_CUSTOM, PreferenceMessages.getString("DecoratorPreferencePage.customClearCaseElementsBackground"), getFieldEditorParent(CAT_IMAGES)); //$NON-NLS-1$ // decorateClearCaseElements.addSlave(customClearCaseElementsBackground); // addField(customClearCaseElementsBackground); // imageClearCaseElementsBackground = new FileFieldEditor(ClearCaseUIPreferences.IMAGE_CLEARCASE_ELEMENTS_BACKGROUND, PreferenceMessages.getString("DecoratorPreferencePage.imageClearCaseElementsBackground"), getFieldEditorParent(CAT_IMAGES)); //$NON-NLS-1$ // imageClearCaseElementsBackground.setFileExtensions(new String[] { "*.gif;*.jpg;*.png" }); //$NON-NLS-1$ // imageClearCaseElementsBackground.setEmptyStringAllowed(true); // customClearCaseElementsBackground.addSlave(imageClearCaseElementsBackground); // addField(imageClearCaseElementsBackground); decorateCheckedIn = new BooleanFieldEditor(ClearCaseUIPreferences.DECORATE_CHECKED_IN_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.checkedIn"), //$NON-NLS-1$ getFieldEditorParent(CAT_IMAGES)); addField(decorateCheckedIn); // decorateEdited = new BooleanFieldEditor(ClearCaseUIPreferences.DECORATE_EDITED_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.edited"), getFieldEditorParent(CAT_IMAGES)); //$NON-NLS-1$ // addField(decorateEdited); decorateHijacked = new BooleanFieldEditor(ClearCaseUIPreferences.DECORATE_HIJACKED_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.hijacked"), //$NON-NLS-1$ getFieldEditorParent(CAT_IMAGES)); addField(decorateHijacked); decorateViewPrivate = new BooleanFieldEditor(ClearCaseUIPreferences.DECORATE_VIEW_PRIVATE_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.viewPrivate"), //$NON-NLS-1$ getFieldEditorParent(CAT_IMAGES)); addField(decorateViewPrivate); decorateDerivedObjects = new BooleanFieldEditor(ClearCaseUIPreferences.DECORATE_DERIVED_OBJECTS, PreferenceMessages.getString("DecoratorPreferencePage.derivedObjects"), //$NON-NLS-1$ getFieldEditorParent(CAT_IMAGES)); addField(decorateDerivedObjects); decorateUnknown = new BooleanFieldEditor(ClearCaseUIPreferences.DECORATE_UNKNOWN_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.unknown"), //$NON-NLS-1$ getFieldEditorParent(CAT_IMAGES)); addField(decorateUnknown); // text decorations addViewInfoToProjects = new BooleanFieldEditor(ClearCaseUIPreferences.DECORATE_PROJECTS_WITH_VIEW_INFO, PreferenceMessages.getString("DecoratorPreferencePage.addViewInfoToProjects"), //$NON-NLS-1$ getFieldEditorParent(CAT_TEXT)); addField(addViewInfoToProjects); addVersionInfo = new BooleanFieldEditor(ClearCaseUIPreferences.DECORATE_ELEMENTS_WITH_VERSION_INFO, PreferenceMessages.getString("DecoratorPreferencePage.appendVersionInfoToResources"), //$NON-NLS-1$ getFieldEditorParent(CAT_TEXT)); addField(addVersionInfo); decorateElementStatesWithTextPrefix = new MasterBooleanFieldEditor( ClearCaseUIPreferences.DECORATE_ELEMENT_STATES_WITH_TEXT_PREFIX, PreferenceMessages.getString("DecoratorPreferencePage.prependResourceNamesWithStateInfoFor"), //$NON-NLS-1$ getFieldEditorParent(CAT_TEXT)); addField(decorateElementStatesWithTextPrefix); prefixCheckedInResources = new StringFieldEditor(ClearCaseUIPreferences.TEXT_PREFIX_CHECKED_IN_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.checkedInResources"), 4, //$NON-NLS-1$ getFieldEditorParent(CAT_TEXT)); addField(prefixCheckedInResources); decorateElementStatesWithTextPrefix.addSlave(prefixCheckedInResources); prefixDirtyResources = new StringFieldEditor(ClearCaseUIPreferences.TEXT_PREFIX_DIRTY_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.dirtyResources"), 4, //$NON-NLS-1$ getFieldEditorParent(CAT_TEXT)); addField(prefixDirtyResources); decorateElementStatesWithTextPrefix.addSlave(prefixDirtyResources); prefixHijackedResources = new StringFieldEditor(ClearCaseUIPreferences.TEXT_PREFIX_HIJACKED_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.hijackedResources"), 4, //$NON-NLS-1$ getFieldEditorParent(CAT_TEXT)); addField(prefixHijackedResources); decorateElementStatesWithTextPrefix.addSlave(prefixHijackedResources); prefixViewPrivateResources = new StringFieldEditor(ClearCaseUIPreferences.TEXT_PREFIX_VIEW_PRIVATE_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.viewPrivateResources"), 4, //$NON-NLS-1$ getFieldEditorParent(CAT_TEXT)); addField(prefixViewPrivateResources); decorateElementStatesWithTextPrefix.addSlave(prefixViewPrivateResources); // prefixResourcesEditedBySomeoneElse = new StringFieldEditor(ClearCaseUIPreferences.TEXT_PREFIX_EDITED_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.resourcesEditedBySomeoneElse"), 4, //$NON-NLS-1$ // getFieldEditorParent(CAT_TEXT)); // addField(prefixResourcesEditedBySomeoneElse); // decorateElementStatesWithTextPrefix.addSlave(prefixResourcesEditedBySomeoneElse); prefixResourcesWithUnknownState = new StringFieldEditor(ClearCaseUIPreferences.TEXT_PREFIX_UNKNOWN_ELEMENTS, PreferenceMessages.getString("DecoratorPreferencePage.resourcesWithUnknownState"), 4, //$NON-NLS-1$ getFieldEditorParent(CAT_TEXT)); addField(prefixResourcesWithUnknownState); decorateElementStatesWithTextPrefix.addSlave(prefixResourcesWithUnknownState); }
From source file:org.eclipse.ajdt.internal.ui.preferences.AJCompilerPreferencePage.java
License:Open Source License
private Composite createCompilerPreferencesContent(Composite parent) { String[] errorWarningIgnore = new String[] { AspectJPreferences.VALUE_ERROR, AspectJPreferences.VALUE_WARNING, AspectJPreferences.VALUE_IGNORE }; String[] errorWarningIgnoreLabels = new String[] { UIMessages.CompilerConfigurationBlock_error, UIMessages.CompilerConfigurationBlock_warning, UIMessages.CompilerConfigurationBlock_ignore }; String[] enableDisableValues = new String[] { AspectJPreferences.VALUE_ENABLED, AspectJPreferences.VALUE_DISABLED }; int nColumns = 3; final ScrolledPageContent pageContent = new ScrolledPageContent(parent); GridLayout layout = new GridLayout(); layout.numColumns = nColumns;/*w ww . java 2s . com*/ Composite composite = pageContent.getBody(); composite.setLayout(layout); Composite othersComposite; ExpandableComposite excomposite; String label; if (!isProjectPreferencePage()) { label = UIMessages.CompilerConfigurationBlock_aj_builder_settings; excomposite = createStyleSection(composite, label, nColumns); othersComposite = new Composite(excomposite, SWT.NONE); excomposite.setClient(othersComposite); othersComposite.setLayout(new GridLayout(nColumns, false)); Preferences prefs = getAspectJCorePLuginPreferences(); // incremental compiler optimizations label = UIMessages.CompilerConfigurationBlock_aj_incrementalCompilerOptimizations; Button b = addCheckBox(othersComposite, label, AspectJCorePreferences.OPTION_IncrementalCompilationOptimizations, enableDisableValues, 0, false); useAspectJCorePreferences(b); // a little kludgy, but here we re-set the selection to be what is stored in AJ core preferences. // ignoring the original value. b.setSelection(prefs.getBoolean(AspectJCorePreferences.OPTION_IncrementalCompilationOptimizations)); // default is true } label = UIMessages.CompilerConfigurationBlock_aj_messages_matching; excomposite = createStyleSection(composite, label, nColumns); othersComposite = new Composite(excomposite, SWT.NONE); excomposite.setClient(othersComposite); othersComposite.setLayout(new GridLayout(nColumns, false)); label = UIMessages.CompilerConfigurationBlock_aj_invalid_absolute_type_name_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportInvalidAbsoluteTypeName, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_invalid_wildcard_type_name_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportInvalidWildcardTypeName, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_type_not_exposed_to_weaver_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportTypeNotExposedToWeaver, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_unmatched_super_type_in_call_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportUnmatchedSuperTypeInCall, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_no_interface_ctor_joinpoint_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportNoInterfaceCtorJoinpoint, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_cant_find_type; addComboBox(othersComposite, label, AspectJPreferences.OPTION_cantFindType, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_cant_find_type_affecting_jp_match; addComboBox(othersComposite, label, AspectJPreferences.OPTION_cantFindTypeAffectingJPMatch, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aspect_excluded_by_configuration; addComboBox(othersComposite, label, AspectJPreferences.OPTION_aspectExcludedByConfiguration, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_messages_optimization; excomposite = createStyleSection(composite, label, nColumns); othersComposite = new Composite(excomposite, SWT.NONE); excomposite.setClient(othersComposite); othersComposite.setLayout(new GridLayout(nColumns, false)); label = UIMessages.CompilerConfigurationBlock_aj_cannot_implement_lazy_tjp_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportCannotImplementLazyTJP, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_multiple_advice_stopping_lazy_tjp; addComboBox(othersComposite, label, AspectJPreferences.OPTION_multipleAdviceStoppingLazyTJP, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_no_guard_for_lazy_tjp; addComboBox(othersComposite, label, AspectJPreferences.OPTION_noGuardForLazyTjp, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_x_no_inline_label; addCheckBox(othersComposite, label, AspectJPreferences.OPTION_XNoInline, enableDisableValues, 0, true); label = UIMessages.CompilerConfigurationBlock_aj_messages_java5; excomposite = createStyleSection(composite, label, nColumns); othersComposite = new Composite(excomposite, SWT.NONE); excomposite.setClient(othersComposite); othersComposite.setLayout(new GridLayout(nColumns, false)); Text description = new Text(othersComposite, SWT.WRAP | SWT.READ_ONLY); description.setText(UIMessages.CompilerConfigurationBlock_aj_messages_java5_label); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gd.horizontalSpan = nColumns; description.setLayoutData(gd); label = UIMessages.CompilerConfigurationBlock_adviceDidNotMatch; addComboBox(othersComposite, label, AspectJPreferences.OPTION_adviceDidNotMatch, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_unmatchedTargetKind; addComboBox(othersComposite, label, AspectJPreferences.OPTION_unmatchedTargetKind, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_noJoinpointsForBridgeMethods; addComboBox(othersComposite, label, AspectJPreferences.OPTION_noJoinpointsForBridgeMethods, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_enumAsTargetForDecpIgnored; addComboBox(othersComposite, label, AspectJPreferences.OPTION_enumAsTargetForDecpIgnored, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_annotationAsTargetForDecpIgnored; addComboBox(othersComposite, label, AspectJPreferences.OPTION_annotationAsTargetForDecpIgnored, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_cantMatchArrayTypeOnVarargs; addComboBox(othersComposite, label, AspectJPreferences.OPTION_cantMatchArrayTypeOnVarargs, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_invalidTargetForAnnotation; addComboBox(othersComposite, label, AspectJPreferences.OPTION_invalidTargetForAnnotation, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_elementAlreadyAnnotated; addComboBox(othersComposite, label, AspectJPreferences.OPTION_elementAlreadyAnnotated, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_uncheckedArgument; addComboBox(othersComposite, label, AspectJPreferences.OPTION_uncheckedArgument, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_uncheckedAdviceConversion; addComboBox(othersComposite, label, AspectJPreferences.OPTION_uncheckedAdviceConversion, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_messages_programming; excomposite = createStyleSection(composite, label, nColumns); othersComposite = new Composite(excomposite, SWT.NONE); excomposite.setClient(othersComposite); othersComposite.setLayout(new GridLayout(nColumns, false)); label = UIMessages.CompilerConfigurationBlock_aj_need_serial_version_uid_field_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportNeedSerialVersionUIDField, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_incompatible_serial_version_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportIncompatibleSerialVersion, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_no_explicit_constructor_call; addComboBox(othersComposite, label, AspectJPreferences.OPTION_noExplicitConstructorCall, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_runtimeExceptionNotSoftened; addComboBox(othersComposite, label, AspectJPreferences.OPTION_runtimeExceptionNotSoftened, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_unordered_advice_at_shadow; addComboBox(othersComposite, label, AspectJPreferences.OPTION_unorderedAdviceAtShadow, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_swallowed_exception_in_catch_block; addComboBox(othersComposite, label, AspectJPreferences.OPTION_swallowedExceptionInCatchBlock, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_messages_information; excomposite = createStyleSection(composite, label, nColumns); othersComposite = new Composite(excomposite, SWT.NONE); excomposite.setClient(othersComposite); othersComposite.setLayout(new GridLayout(nColumns, false)); label = UIMessages.CompilerConfigurationBlock_aj_unresolvable_member_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportUnresolvableMember, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_shadow_not_in_structure_label; addComboBox(othersComposite, label, AspectJPreferences.OPTION_ReportShadowNotInStructure, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_calculating_serial_version_UID; addComboBox(othersComposite, label, AspectJPreferences.OPTION_calculatingSerialVersionUID, errorWarningIgnore, errorWarningIgnoreLabels, 0); label = UIMessages.CompilerConfigurationBlock_aj_enable_weave_messages_label; addCheckBox(othersComposite, label, AspectJPreferences.OPTION_WeaveMessages, enableDisableValues, 0, true); label = UIMessages.CompilerConfigurationBlock_aj_other_tabtitle; excomposite = createStyleSection(composite, label, nColumns); othersComposite = new Composite(excomposite, SWT.NONE); excomposite.setClient(othersComposite); othersComposite.setLayout(new GridLayout(nColumns, false)); label = UIMessages.CompilerConfigurationBlock_aj_x_serializable_aspects_label; addCheckBox(othersComposite, label, AspectJPreferences.OPTION_XSerializableAspects, enableDisableValues, 0, true); label = UIMessages.CompilerConfigurationBlock_aj_x_not_reweavable_label; addCheckBox(othersComposite, label, AspectJPreferences.OPTION_XNotReweavable, enableDisableValues, 0, true); label = UIMessages.CompilerConfigurationBlock_aj_x_has_member_label; addCheckBox(othersComposite, label, AspectJPreferences.OPTION_XHasMember, enableDisableValues, 0, true); label = UIMessages.CompilerConfigurationBlock_aj_out_xml; addCheckBox(othersComposite, label, AspectJPreferences.OPTION_Outxml, enableDisableValues, 0, true); label = "Verbose-Send extra information to the AJDT Event Trace view.\nMust use with 'Compiler / Task List Messages'\nfilter enabled."; addCheckBox(othersComposite, label, AspectJPreferences.OPTION_verbose, enableDisableValues, 0, true); label = "Pointcut matching timers-Show timing information to the AJDT Event Trace view \n(use with the 'Verbose' option)"; addCheckBox(othersComposite, label, AspectJPreferences.OPTION_timers, enableDisableValues, 0, true); Composite row3Comp = createRowComposite(othersComposite, 2); //fills the editor with the stored preference if there is one. String currValue = ""; //$NON-NLS-1$ if (isProjectPreferencePage()) { if (hasProjectSpecificOptions(getProject())) { currValue = AspectJPreferences.getStringPrefValue(getProject(), AspectJPreferences.COMPILER_OPTIONS); } else { currValue = getPreferenceStore().getString(AspectJPreferences.COMPILER_OPTIONS); } } else { currValue = getPreferenceStore().getString(AspectJPreferences.COMPILER_OPTIONS); } nonStandardOptionsEditor = new StringFieldEditor(currValue, UIMessages.compilerPropsPage_nonStandardOptions, StringFieldEditor.UNLIMITED, row3Comp); nonStandardOptionsEditor.setStringValue(currValue); IDialogSettings section = JavaPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME); restoreSectionExpansionStates(section); return pageContent; }
From source file:org.eclipse.buckminster.ui.prefs.DynamicPreferencePage.java
License:Open Source License
protected void addDynamicFieldEditors(Composite parent, String nodeName, IPreferenceDescriptor[] descriptors) { final IPreferenceStore nodePrefs = UiPlugin.getDefault().getBuckminsterPreferenceStore(nodeName); for (final IPreferenceDescriptor descriptor : descriptors) { String name = descriptor.getName(); String label = descriptor.getLabel(); IPreferenceValidator descValidator = descriptor.getValidator(); if (descValidator == null) descValidator = nullValidator; final IPreferenceValidator validator = descValidator; FieldEditor editor;/* ww w . ja va 2 s. c o m*/ switch (descriptor.getType()) { case Boolean: editor = new BooleanFieldEditor(name, label, parent) { @Override public IPreferenceStore getPreferenceStore() { return nodePrefs; } }; break; case Directory: editor = new DirectoryFieldEditor(name, label, parent) { @Override public IPreferenceStore getPreferenceStore() { return nodePrefs; } @Override protected boolean checkState() { return super.checkState() && validator.validate(UiUtils.trimmedValue(getTextControl())); } }; break; case Enum: Enum<?>[] enums = descriptor.getEnums(); int idx = enums.length; String[][] labelsAndValues = new String[idx][2]; while (--idx >= 0) { labelsAndValues[idx][0] = enums[idx].toString(); labelsAndValues[idx][1] = enums[idx].name(); } editor = new RadioGroupFieldEditor(name, label, 1, labelsAndValues, parent) { @Override public IPreferenceStore getPreferenceStore() { return nodePrefs; } }; break; case File: editor = new FileFieldEditor(name, label, parent) { @Override public IPreferenceStore getPreferenceStore() { return nodePrefs; } @Override protected boolean checkState() { return super.checkState() && validator.validate(UiUtils.trimmedValue(getTextControl())); } }; break; case Integer: editor = new IntegerFieldEditor(name, label, parent, descriptor.getTextWidth()) { @Override public IPreferenceStore getPreferenceStore() { return nodePrefs; } @Override protected boolean checkState() { return super.checkState() && validator.validate(UiUtils.trimmedValue(getTextControl())); } }; int[] range = descriptor.getIntegerRange(); if (range != null) ((IntegerFieldEditor) editor).setValidRange(range[0], range[1]); break; case Path: editor = new PathEditor(name, label, label, parent) { @Override public IPreferenceStore getPreferenceStore() { return nodePrefs; } }; break; case Password: editor = new PasswordFieldEditor(name, label, descriptor.getTextWidth(), parent, nodeName) { @Override public IPreferenceStore getPreferenceStore() { return nodePrefs; } @Override protected boolean checkState() { return validator.validate(UiUtils.trimmedValue(getTextControl())); } }; break; default: editor = new StringFieldEditor(name, label, descriptor.getTextWidth(), parent) { @Override public IPreferenceStore getPreferenceStore() { return nodePrefs; } @Override protected boolean checkState() { return validator.validate(UiUtils.trimmedValue(getTextControl())); } }; } addField(editor); } }
From source file:org.eclipse.cdt.internal.autotools.ui.properties.AutotoolsCategoryPropertyOptionPage.java
License:Open Source License
protected void createFieldEditors() { super.createFieldEditors(); Composite parent = getFieldEditorParent(); // FontMetrics fm = AbstractCPropertyTab.getFontMetrics(parent); AutotoolsConfiguration.Option[] options = AutotoolsConfiguration.getChildOptions(catName); for (int i = 0; i < options.length; ++i) { AutotoolsConfiguration.Option option = options[i]; switch (option.getType()) { case IConfigureOption.STRING: case IConfigureOption.INTERNAL: case IConfigureOption.MULTIARG: parent = getFieldEditorParent(); StringFieldEditor f = new StringFieldEditor(option.getName(), option.getDescription(), 20, parent); f.getLabelControl(parent).setToolTipText(option.getToolTip()); addField(f);/*from w w w.ja v a 2 s.co m*/ fieldEditors.add(f); break; case IConfigureOption.BIN: case IConfigureOption.FLAGVALUE: parent = getFieldEditorParent(); BooleanFieldEditor b = new BooleanFieldEditor(option.getName(), option.getDescription(), parent); b.getDescriptionControl(parent).setToolTipText(option.getToolTip()); addField(b); fieldEditors.add(b); break; case IConfigureOption.FLAG: parent = getFieldEditorParent(); FieldEditor l = createLabelEditor(parent, option.getName()); addField(l); fieldEditors.add(l); break; } } }
From source file:org.eclipse.linuxtools.internal.cdt.autotools.ui.properties.AutotoolsCategoryPropertyOptionPage.java
License:Open Source License
protected void createFieldEditors() { super.createFieldEditors(); Composite parent = getFieldEditorParent(); // FontMetrics fm = AbstractCPropertyTab.getFontMetrics(parent); AutotoolsConfiguration.Option[] options = AutotoolsConfiguration.getChildOptions(catName); for (int i = 0; i < options.length; ++i) { AutotoolsConfiguration.Option option = options[i]; switch (option.getType()) { case IConfigureOption.STRING: case IConfigureOption.INTERNAL: case IConfigureOption.MULTIARG: parent = getFieldEditorParent(); StringFieldEditor f = new StringFieldEditor(option.getName(), option.getDescription(), 20, parent); f.getLabelControl(parent).setToolTipText(option.getToolTip()); addField(f);//www .jav a 2s . c om fieldEditors.add(f); break; case IConfigureOption.BIN: parent = getFieldEditorParent(); BooleanFieldEditor b = new BooleanFieldEditor(option.getName(), option.getDescription(), parent); b.getDescriptionControl(parent).setToolTipText(option.getToolTip()); addField(b); fieldEditors.add(b); break; } } }
From source file:org.eclipse.mylyn.reviews.ldap.internal.preferences.R4ELdapPreferencePage.java
License:Open Source License
/** * Create the Server information GUI/*from w w w . j a va2s . c o m*/ * * @param Composite * aPrefsContainer */ private void createServerInformation(Composite aPrefsContainer) { // Create a Group to hold LDAP user preferences final Group r4ELdapHoostPrefsGroup = new Group(aPrefsContainer, SWT.BORDER_SOLID); final GridData r4eLdapHostPrefsGroupData = new GridData(GridData.FILL, GridData.FILL, true, false); r4eLdapHostPrefsGroupData.horizontalSpan = R4E_GROUP_PREFS_SERVER_DATA_SPAN; r4ELdapHoostPrefsGroup.setText(PreferenceConstants.FP_SERVER_GROUP); r4ELdapHoostPrefsGroup.setLayoutData(r4eLdapHostPrefsGroupData); r4ELdapHoostPrefsGroup.setLayout(new GridLayout(R4E_GROUP_PREFS_SERVER_DATA_SPAN, false)); // dummy spacer label final Label r4ELdapPrefsSpacer = new Label(r4ELdapHoostPrefsGroup, SWT.FILL); final GridData r4EUserPrefsSpacerData = new GridData(GridData.FILL, GridData.FILL, true, false); r4EUserPrefsSpacerData.horizontalSpan = R4E_GROUP_PREFS_SERVER_DATA_SPAN; r4ELdapPrefsSpacer.setLayoutData(r4EUserPrefsSpacerData); // Create Radio buttons to define the type of Server int numberRadio = 2; fLdapSelectBtn = new RadioGroupFieldEditor(PreferenceConstants.FP_SERVER_TYPE_ID, PreferenceConstants.FP_SERVER_TYPE_LABEL, numberRadio, PreferenceConstants.FP_SERVER_TYPE_VALUES, r4ELdapHoostPrefsGroup, false); fLdapSelectBtn.setPreferenceStore(getPreferenceStore()); fLdapSelectBtn.load(); // Test fields definitions fHostFieldEditor = new StringFieldEditor(PreferenceConstants.FP_HOST_ID, PreferenceConstants.FP_HOST_LABEL, StringFieldEditor.UNLIMITED, r4ELdapHoostPrefsGroup); fHostFieldEditor.getTextControl(r4ELdapHoostPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", R4EString.getString("fhostTooltip"))); addField(fHostFieldEditor); fPortFieldEditor = new StringFieldEditor(PreferenceConstants.FP_PORT_ID, PreferenceConstants.FP_PORT_LABEL, StringFieldEditor.UNLIMITED, r4ELdapHoostPrefsGroup); fPortFieldEditor.getTextControl(r4ELdapHoostPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", R4EString.getString("fPortTooltip"))); addField(fPortFieldEditor); fBaseFieldEditor = new StringFieldEditor(PreferenceConstants.FP_BASE_ID, PreferenceConstants.FP_BASE_LABEL, StringFieldEditor.UNLIMITED, r4ELdapHoostPrefsGroup); fBaseFieldEditor.getTextControl(r4ELdapHoostPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", R4EString.getString("fBaseTooltip"))); addField(fBaseFieldEditor); }
From source file:org.eclipse.mylyn.reviews.ldap.internal.preferences.R4ELdapPreferencePage.java
License:Open Source License
/** * Create the Security information GUI/* w ww.ja v a2 s . c om*/ * * @param Composite * aPrefsContainer */ private void createSecurityInformation(Composite aPrefsContainer) { // Create a Group to hold R4E Security preferences final Group r4ESecurityPrefsGroup = new Group(aPrefsContainer, SWT.BORDER_SOLID); final GridData r4EGroupPrefsGroupData = new GridData(GridData.FILL, GridData.FILL, true, false); r4EGroupPrefsGroupData.horizontalSpan = R4E_GROUP_PREFS_SECURITY_DATA_SPAN; r4ESecurityPrefsGroup.setText(PreferenceConstants.FP_SECURITY_GROUP); r4ESecurityPrefsGroup.setLayoutData(r4EGroupPrefsGroupData); r4ESecurityPrefsGroup.setLayout(new GridLayout(R4E_GROUP_PREFS_SECURITY_DATA_SPAN, false)); // dummy spacer label Label r4ESecurityGroupPrefsSpacer = new Label(r4ESecurityPrefsGroup, SWT.FILL); // Create Radio buttons to define the type of AUTHENTICATION int numberRadio = 3; fAuthenficationBtn = new RadioGroupFieldEditor(PreferenceConstants.FP_SECURITY_AUTHENTICATION_ID, PreferenceConstants.FP_SECURITY_AUTHENTICATION_LABEL, numberRadio, PreferenceConstants.FP_AUTHENTICATION_RADIO_VALUES, r4ESecurityPrefsGroup, false); fAuthenficationBtn.setPreferenceStore(getPreferenceStore()); fAuthenficationBtn.load(); // dummy spacer label Label r4EFieldPrefsSpacer = new Label(r4ESecurityPrefsGroup, SWT.FILL); final GridData r4EFieldPrefsSpacerData = new GridData(GridData.FILL, GridData.FILL, true, false); r4EFieldPrefsSpacerData.horizontalSpan = R4E_GROUP_PREFS_SECURITY_DATA_SPAN; r4EFieldPrefsSpacer.setLayoutData(r4EFieldPrefsSpacerData); final GridData r4EGroupPrefsSpacerData = new GridData(GridData.FILL, GridData.FILL, true, false); r4EGroupPrefsSpacerData.horizontalSpan = R4E_GROUP_PREFS_SECURITY_DATA_SPAN; r4ESecurityGroupPrefsSpacer.setLayoutData(r4EGroupPrefsSpacerData); // Test fields definitions fUserNamedEditor = new StringFieldEditor(PreferenceConstants.FP_SECURITY_USER_NAME_ID, PreferenceConstants.FP_SECURITY_USER_NAME_LABEL, StringFieldEditor.UNLIMITED, r4ESecurityPrefsGroup); fUserNamedEditor.getTextControl(r4ESecurityPrefsGroup) .setToolTipText(R4EString.getString("fUserNameTooltip")); addField(fUserNamedEditor); fPasswordEditor = new StringFieldEditor(PreferenceConstants.FP_SECURITY_PASSWORD_ID, PreferenceConstants.FP_SECURITY_PASSWORD_LABEL, StringFieldEditor.UNLIMITED, r4ESecurityPrefsGroup); addField(fPasswordEditor); fPasswordEditor.getTextControl(r4ESecurityPrefsGroup).addModifyListener(new ModifyListener() { // Echo * when typing a new password public void modifyText(ModifyEvent e) { fPasswordEditor.getTextControl(r4ESecurityPrefsGroup).setEchoChar('*'); } }); }
From source file:org.eclipse.mylyn.reviews.ldap.internal.preferences.R4ELdapPreferencePage.java
License:Open Source License
/** * Create the LDAP fields description information GUI * /* w w w.java 2s.c om*/ * @param Composite * aPrefsContainer */ private void createFieldDefinitionInformation(Composite aPrefsContainer) { // Create a Group to hold R4E LDAP Field preferences final Group r4EFieldPrefsGroup = new Group(aPrefsContainer, SWT.BORDER_SOLID); final GridData r4EFieldPrefsGroupData = new GridData(GridData.FILL, GridData.FILL, true, false); r4EFieldPrefsGroupData.horizontalSpan = R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS; r4EFieldPrefsGroup.setText(PreferenceConstants.FP_FIELD_GROUP); r4EFieldPrefsGroup.setLayoutData(r4EFieldPrefsGroupData); r4EFieldPrefsGroup.setLayout(new GridLayout(R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS, false)); // dummy spacer label Label r4EFieldPrefsSpacer = new Label(r4EFieldPrefsGroup, SWT.FILL); final GridData r4EFieldPrefsSpacerData = new GridData(GridData.FILL, GridData.FILL, true, false); r4EFieldPrefsSpacerData.horizontalSpan = R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS; r4EFieldPrefsSpacer.setLayoutData(r4EFieldPrefsSpacerData); // Create a Group to hold R4E LDAP Mandatory Field preferences final Group r4EFieldMandatoryPrefsGroup = new Group(r4EFieldPrefsGroup, SWT.BORDER_SOLID); final GridData r4EFieldMandatoryPrefsGroupData = new GridData(GridData.FILL, GridData.FILL, true, false); r4EFieldMandatoryPrefsGroupData.horizontalSpan = R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS; r4EFieldMandatoryPrefsGroup.setText(PreferenceConstants.FP_FIELD_MANDATORY_GROUP); r4EFieldMandatoryPrefsGroup.setLayoutData(r4EFieldMandatoryPrefsGroupData); r4EFieldMandatoryPrefsGroup .setLayout(new GridLayout(R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS, false)); fUserIdEditor = new StringFieldEditor(PreferenceConstants.FP_UID_ID, PreferenceConstants.FP_UID_LABEL, StringFieldEditor.UNLIMITED, r4EFieldMandatoryPrefsGroup); fUserIdEditor.setEmptyStringAllowed(false); fUserIdEditor.getTextControl(r4EFieldMandatoryPrefsGroup) .setToolTipText(R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_UID_ID)); addField(fUserIdEditor); fUserNameEditor = new StringFieldEditor(PreferenceConstants.FP_NAME_ID, PreferenceConstants.FP_NAME_LABEL, StringFieldEditor.UNLIMITED, r4EFieldMandatoryPrefsGroup); fUserNameEditor.setEmptyStringAllowed(false); fUserNameEditor.getTextControl(r4EFieldMandatoryPrefsGroup) .setToolTipText(R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_NAME_ID)); addField(fUserNameEditor); fEmailEditor = new StringFieldEditor(PreferenceConstants.FP_EMAIL_ID, PreferenceConstants.FP_EMAIL_LABEL, StringFieldEditor.UNLIMITED, r4EFieldMandatoryPrefsGroup); fEmailEditor.setEmptyStringAllowed(false); fEmailEditor.getTextControl(r4EFieldMandatoryPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_EMAIL_ID)); addField(fEmailEditor); // dummy spacer label Label r4EFieldPrefsSpacer2 = new Label(r4EFieldPrefsGroup, SWT.FILL); final GridData r4EFieldPrefsSpacer2Data = new GridData(GridData.FILL, GridData.FILL, true, false); r4EFieldPrefsSpacer2Data.horizontalSpan = R4E_GROUP_MANDATORY_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS; r4EFieldPrefsSpacer2.setLayoutData(r4EFieldPrefsSpacer2Data); // Create a Group to hold R4E LDAP Optional Field preferences final Group r4EFieldOptionalPrefsGroup = new Group(r4EFieldPrefsGroup, SWT.BORDER_SOLID); final GridData r4EFieldOptionalPrefsGroupData = new GridData(SWT.FILL, SWT.FILL, true, false); r4EFieldOptionalPrefsGroupData.horizontalSpan = R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS; r4EFieldOptionalPrefsGroup.setText(PreferenceConstants.FP_FIELD_OPTIONAL_GROUP); r4EFieldOptionalPrefsGroup.setLayoutData(r4EFieldOptionalPrefsGroupData); r4EFieldOptionalPrefsGroup .setLayout(new GridLayout(R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS, false)); fTelephoneEditor = new StringFieldEditor(PreferenceConstants.FP_TELEPHONE_ID, PreferenceConstants.FP_TELEPHONE_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup); fTelephoneEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_TELEPHONE_ID)); addField(fTelephoneEditor); fMobileEditor = new StringFieldEditor(PreferenceConstants.FP_MOBILE_ID, PreferenceConstants.FP_MOBILE_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup); fMobileEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_MOBILE_ID)); addField(fMobileEditor); fEcnEditor = new StringFieldEditor(PreferenceConstants.FP_ECN_ID, PreferenceConstants.FP_ECN_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup); fEcnEditor.getTextControl(r4EFieldOptionalPrefsGroup) .setToolTipText(R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_ECN_ID)); addField(fEcnEditor); fCieEditor = new StringFieldEditor(PreferenceConstants.FP_COMPANY_ID, PreferenceConstants.FP_COMPANY_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup); fCieEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_COMPANY_ID)); addField(fCieEditor); fDeptEditor = new StringFieldEditor(PreferenceConstants.FP_DEPARTMENT_ID, PreferenceConstants.FP_DEPARTMENT_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup); fDeptEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_DEPARTMENT_ID)); addField(fDeptEditor); fDomainEditor = new StringFieldEditor(PreferenceConstants.FP_DOMAIN_ID, PreferenceConstants.FP_DOMAIN_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup); fDomainEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_DOMAIN_ID)); addField(fDomainEditor); fTitleEditor = new StringFieldEditor(PreferenceConstants.FP_TITLE_ID, PreferenceConstants.FP_TITLE_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup); fTitleEditor.getTextControl(r4EFieldOptionalPrefsGroup).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_TITLE_ID)); addField(fTitleEditor); // Create a second optional group to maintain the remaining LDAP fields definition final Group r4EFieldOptionalPrefsGroup2 = new Group(r4EFieldPrefsGroup, SWT.BORDER_SOLID); final GridData r4EFieldOptionalPrefsGroupRightData2 = new GridData(GridData.FILL, GridData.FILL, true, false); r4EFieldOptionalPrefsGroupRightData2.horizontalSpan = R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS; r4EFieldOptionalPrefsGroup2.setText(PreferenceConstants.FP_FIELD_OPTIONAL_GROUP); r4EFieldOptionalPrefsGroup2.setLayoutData(r4EFieldOptionalPrefsGroupRightData2); r4EFieldOptionalPrefsGroup2 .setLayout(new GridLayout(R4E_GROUP_OPTIONAL_PREFS_FIELDS_DEF_DATA_NUM_COLUMNS, false)); // Fields editor fOfficeEditor = new StringFieldEditor(PreferenceConstants.FP_OFFICE_NAME_ID, PreferenceConstants.FP_OFFICE_ROOM_Label, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2); fOfficeEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_OFFICE_NAME_ID)); addField(fOfficeEditor); fRoomEditor = new StringFieldEditor(PreferenceConstants.FP_ROOM_NUMBER_ID, PreferenceConstants.FP_ROOM_NUMBER_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2); fRoomEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_ROOM_NUMBER_ID)); addField(fRoomEditor); fStreetAddrEditor = new StringFieldEditor(PreferenceConstants.FP_STREET_ADDRESS_ID, PreferenceConstants.FP_STREET_ADDRESS_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2); fStreetAddrEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_STREET_ADDRESS_ID)); addField(fStreetAddrEditor); fCityEditor = new StringFieldEditor(PreferenceConstants.FP_CITY_ID, PreferenceConstants.FP_CITY_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2); fCityEditor.getTextControl(r4EFieldOptionalPrefsGroup2) .setToolTipText(R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_CITY_ID)); addField(fCityEditor); fCountryEditor = new StringFieldEditor(PreferenceConstants.FP_COUNTRY_ID, PreferenceConstants.FP_COUNTRY_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2); fCountryEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_COUNTRY_ID)); addField(fCountryEditor); fPostalCodeEditor = new StringFieldEditor(PreferenceConstants.FP_POSTAL_CODE_ID, PreferenceConstants.FP_POSTAL_CODE_LABEL, StringFieldEditor.UNLIMITED, r4EFieldOptionalPrefsGroup2); fPostalCodeEditor.getTextControl(r4EFieldOptionalPrefsGroup2).setToolTipText( R4EString.getFormattedString("defaultDescription", PreferenceConstants.FP_POSTAL_CODE_ID)); addField(fPostalCodeEditor); }
From source file:org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage.java
License:Open Source License
/** * @since 2.0/*from w ww. j av a 2s.c o m*/ */ @Override protected void createSettingControls(Composite parent) { compositeContainer = parent; initializeOldValues(); Label serverLabel = new Label(compositeContainer, SWT.NONE); serverLabel.setText(LABEL_SERVER); serverUrlCombo = new Combo(compositeContainer, SWT.DROP_DOWN); serverUrlCombo.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } }); serverUrlCombo.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { updateHyperlinks(); } }); serverUrlCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } }); GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).grab(true, false).span(2, SWT.DEFAULT) .applyTo(serverUrlCombo); repositoryLabelEditor = new StringFieldEditor("", LABEL_REPOSITORY_LABEL, StringFieldEditor.UNLIMITED, //$NON-NLS-1$ compositeContainer) { @Override protected boolean doCheckState() { return true; // return isValidUrl(getStringValue()); } @Override protected void valueChanged() { super.valueChanged(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } @Override public int getNumberOfControls() { return 2; } }; disconnectedButton = new Button(compositeContainer, SWT.CHECK); disconnectedButton.setText(Messages.AbstractRepositorySettingsPage_Disconnected); disconnectedButton.setSelection(repository != null ? repository.isOffline() : false); disconnectedButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); isPageComplete(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } }); if (needsRepositoryCredentials()) { createRepositoryCredentialsSection(); } if (needsAdvanced() || needsEncoding()) { createAdvancedSection(); } if (needsCertAuth()) { createCertAuthSection(); } if (needsHttpAuth()) { createHttpAuthSection(); } if (needsProxy()) { createProxySection(); } createContributionControls(innerComposite); Composite managementComposite = new Composite(compositeContainer, SWT.NULL); GridLayout managementLayout = new GridLayout(4, false); managementLayout.marginHeight = 0; managementLayout.marginWidth = 0; managementLayout.horizontalSpacing = 10; managementComposite.setLayout(managementLayout); managementComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 2, 1)); createAccountHyperlink = toolkit.createHyperlink(managementComposite, Messages.AbstractRepositorySettingsPage_Create_new_account, SWT.NONE); createAccountHyperlink.setBackground(managementComposite.getBackground()); createAccountHyperlink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { // TaskRepository repository = getRepository(); TaskRepository repository = createTaskRepository(); // if (repository == null && getServerUrl() != null && getServerUrl().length() > 0) { // repository = createTaskRepository(); // } if (repository != null) { String accountCreationUrl = connectorUi.getAccountCreationUrl(repository); if (accountCreationUrl != null) { BrowserUtil.openUrl(accountCreationUrl, IWorkbenchBrowserSupport.AS_EXTERNAL); } } } }); manageAccountHyperlink = toolkit.createHyperlink(managementComposite, Messages.AbstractRepositorySettingsPage_Change_account_settings, SWT.NONE); manageAccountHyperlink.setBackground(managementComposite.getBackground()); manageAccountHyperlink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { TaskRepository repository = getRepository(); if (repository == null && getRepositoryUrl() != null && getRepositoryUrl().length() > 0) { repository = createTaskRepository(); } if (repository != null) { String accountManagementUrl = connectorUi.getAccountManagementUrl(repository); if (accountManagementUrl != null) { BrowserUtil.openUrl(accountManagementUrl, IWorkbenchBrowserSupport.AS_EXTERNAL); } } } }); if (needsRepositoryCredentials()) { // bug 131656: must set echo char after setting value on Mac ((RepositoryStringFieldEditor) repositoryPasswordEditor).getTextControl().setEchoChar('*'); if (needsAnonymousLogin()) { // do this after username and password widgets have been intialized if (repository != null) { setAnonymous(isAnonymousAccess()); } } } updateHyperlinks(); if (repository != null) { saveToValidatedProperties(createTaskRepository()); } GridLayout layout = new GridLayout(3, false); compositeContainer.setLayout(layout); }
From source file:org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage.java
License:Open Source License
private void createRepositoryCredentialsSection() { repositoryUserNameEditor = new StringFieldEditor("", LABEL_USER, StringFieldEditor.UNLIMITED, //$NON-NLS-1$ compositeContainer) {/*from ww w .ja va2 s . c om*/ @Override protected boolean doCheckState() { return true; } @Override protected void valueChanged() { super.valueChanged(); isPageComplete(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } @Override public int getNumberOfControls() { // always 2 columns -- if no anonymous checkbox, just leave 3rd column empty return 2; } }; if (needsAnonymousLogin()) { // need to increase column number here, because above string editor will use them if declared beforehand //((GridLayout) (compositeContainer.getLayout())).numColumns++; anonymousButton = new Button(compositeContainer, SWT.CHECK); anonymousButton.setText(Messages.AbstractRepositorySettingsPage_Anonymous_Access); anonymousButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setAnonymous(anonymousButton.getSelection()); isPageComplete(); } }); } else { Label dummyLabel = new Label(compositeContainer, SWT.NONE); // dummy control to fill 3rd column when no anonymous login GridDataFactory.fillDefaults().applyTo(dummyLabel); // not really necessary, but to be on the safe side } repositoryPasswordEditor = new RepositoryStringFieldEditor("", LABEL_PASSWORD, StringFieldEditor.UNLIMITED, //$NON-NLS-1$ compositeContainer) { @Override protected boolean doCheckState() { return true; } @Override protected void valueChanged() { super.valueChanged(); isPageComplete(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } @Override public int getNumberOfControls() { return 2; } }; savePasswordButton = new Button(compositeContainer, SWT.CHECK); savePasswordButton.setText(Messages.AbstractRepositorySettingsPage_Save_Password); savePasswordButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); isPageComplete(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } }); if (repository != null) { try { String repositoryLabel = repository.getProperty(IRepositoryConstants.PROPERTY_LABEL); if (repositoryLabel != null && repositoryLabel.length() > 0) { // repositoryLabelCombo.add(repositoryLabel); // repositoryLabelCombo.select(0); repositoryLabelEditor.setStringValue(repositoryLabel); } serverUrlCombo.setText(repository.getRepositoryUrl()); AuthenticationCredentials credentials = repository.getCredentials(AuthenticationType.REPOSITORY); if (credentials != null) { repositoryUserNameEditor.setStringValue(credentials.getUserName()); repositoryPasswordEditor.setStringValue(credentials.getPassword()); } else { repositoryUserNameEditor.setStringValue(""); //$NON-NLS-1$ repositoryPasswordEditor.setStringValue(""); //$NON-NLS-1$ } } catch (Throwable t) { StatusHandler .log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not set field value", t)); //$NON-NLS-1$ } } if (needsAnonymousLogin()) { if (repository != null) { setAnonymous(repository.getCredentials(AuthenticationType.REPOSITORY) == null); } else { setAnonymous(true); } } if (repository != null) { savePasswordButton.setSelection(repository.getSavePassword(AuthenticationType.REPOSITORY)); } else { savePasswordButton.setSelection(false); } RepositoryUiUtil.testCredentialsStore(getRepositoryUrl(), this); }