DefaultPreferenceForm { PropertyEditorFieldInfo createFieldInfo(final String propertyName, final PropertyEditorType propertyType, final Object propertyValue) { final PropertyEditorFieldInfo fieldInfo = new PropertyEditorFieldInfo(translationService.format(hierarchyElement.getBundleKeyByProperty().get(propertyName)), propertyValue != null ? propertyValue.toString() : "", propertyType); setupFieldValidators(propertyName, fieldInfo); setupFieldHelpText(propertyName, fieldInfo); setupFieldOptions(propertyName, fieldInfo); setupFieldKey(propertyName, fieldInfo); if (propertyType == PropertyEditorType.COMBO) { fillEnumValues(propertyValue, fieldInfo); } return fieldInfo; } @Inject  DefaultPreferenceForm(final View view,
                                 final TranslationService translationService); @OnStartup void onStartup(final PlaceRequest placeRequest); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsElement getView(); void hierarchyItemFormInitializationEvent(@Observes HierarchyItemFormInitializationEvent event); PropertyEditorEvent generatePropertyEditorEvent(); void propertyChanged(@Observes PropertyEditorChangeEvent event); void saveEvent(@Observes PreferencesCentralSaveEvent event); void undoEvent(@Observes PreferencesCentralUndoChangesEvent event); BasePreferencePortable<?> getPreference(); PropertyEditorType getPropertyEditorType(PropertyFormType propertyFormType); static final String IDENTIFIER; }
@Test public void testCreateFieldInfo() { fireInitializationEvent("preference-id"); final PropertyEditorFieldInfo fieldInfo = formPresenter.createFieldInfo("property", PropertyEditorType.TEXT, "some-text"); assertEquals("property", fieldInfo.getKey()); assertEquals(1, fieldInfo.getValidators().size()); assertEquals("propertyBundleKey", fieldInfo.getLabel()); assertEquals("propertyHelpBundleKey", fieldInfo.getHelpText()); assertEquals(1, fieldInfo.getOptions().size()); assertEquals(PropertyEditorFieldOption.DISABLED, fieldInfo.getOptions().get(0)); }
@Test public void testCreateFieldInfoCombo() { fireInitializationEvent("preference-id"); final PropertyEditorFieldInfo fieldInfo = formPresenter.createFieldInfo("property", PropertyEditorType.COMBO, EnumForComboTest.val1); assertEquals("property", fieldInfo.getKey()); assertEquals(1, fieldInfo.getValidators().size()); assertEquals("propertyBundleKey", fieldInfo.getLabel()); assertEquals("propertyHelpBundleKey", fieldInfo.getHelpText()); assertEquals(1, fieldInfo.getOptions().size()); assertEquals(PropertyEditorFieldOption.DISABLED, fieldInfo.getOptions().get(0)); assertEquals(EnumForComboTest.val1.name(), fieldInfo.getCurrentStringValue()); assertEquals(EnumForComboTest.values().length, fieldInfo.getComboValues().size()); assertTrue(fieldInfo.getComboValues() .contains(EnumForComboTest.val1.name())); assertTrue(fieldInfo.getComboValues() .contains(EnumForComboTest.val2.name())); }