private int searchSelectItem(PropertyEditorFieldInfo property, int index, int selected, String value) { if (value.equalsIgnoreCase(property.getCurrentStringValue())) { selected = index; } return selected; }
private Enum<?> getEnumValue(PropertyEditorChangeEvent event, Object currentValue) { String selectedValue = event.getProperty().getCurrentStringValue(); Object[] enumConstants = ((Enum<?>) currentValue).getDeclaringClass().getEnumConstants(); Enum<?> enumValue = Arrays.stream(enumConstants) .filter(e -> e.toString().equals(selectedValue)) .map(e -> (Enum<?>) e) .findFirst().orElseThrow(RuntimeException::new); return enumValue; }
private Enum<?> getEnumValue(PropertyEditorChangeEvent event, Object currentValue) { String selectedValue = event.getProperty().getCurrentStringValue(); Object[] enumConstants = ((Enum<?>) currentValue).getDeclaringClass().getEnumConstants(); Enum<?> enumValue = Arrays.stream(enumConstants) .filter(e -> e.toString().equals(selectedValue)) .map(e -> (Enum<?>) e) .findFirst().orElseThrow(RuntimeException::new); return enumValue; }
public void observeEditComponentEventFromPropertyEditor(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(EditTargetDiv.PROPERTY_EDITOR_KEY)) { configContext.setComponentProperty(ID_PARAMETER, property.getCurrentStringValue()); } } }
public void observeEditComponentEventFromPropertyEditor(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(EditTargetDiv.PROPERTY_EDITOR_KEY)) { configContext.setComponentProperty(ID_PARAMETER, property.getCurrentStringValue()); } } }
@Override public Widget widget(final PropertyEditorFieldInfo property) { final PropertyEditorTextBox textBox = GWT.create(PropertyEditorTextBox.class); textBox.setText(property.getCurrentStringValue()); textBox.setId(String.valueOf(property.hashCode())); addEnterKeyHandler(property, textBox); addLostFocusHandler(property, textBox); return textBox; }
@Override public Widget widget(final PropertyEditorFieldInfo property) { final PropertyEditorCheckBox checkBox = GWT.create(PropertyEditorCheckBox.class); checkBox.setValue(Boolean.parseBoolean(property.getCurrentStringValue())); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (validate(property, checkBox.getValue().toString())) { checkBox.clearOldValidationErrors(); property.setCurrentStringValue(checkBox.getValue().toString()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, checkBox.getValue().toString())); } else { checkBox.setValidationError(getValidatorErrorMessage(property, checkBox.getValue().toString())); checkBox.setValue(Boolean.valueOf(property.getCurrentStringValue())); } } }); return checkBox; } }
@Override public Widget widget(final PropertyEditorFieldInfo property) { final PropertyEditorPasswordTextBox passwordTextBox = GWT.create(PropertyEditorPasswordTextBox.class); passwordTextBox.setText(property.getCurrentStringValue()); addLostFocusHandler(property, passwordTextBox); addKeyDownHandler(property, passwordTextBox); return passwordTextBox; }
public void observeEditComponentEventFromPropertyEditor(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(EditScreen.PROPERTY_EDITOR_KEY)) { configContext.setComponentProperty(property.getLabel(), property.getCurrentStringValue()); } }
public void observeEditComponentEventFromPropertyEditor(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(EditScreen.PROPERTY_EDITOR_KEY)) { configContext.setComponentProperty(property.getLabel(), property.getCurrentStringValue()); } }
public void edit(LayoutEditorElement element) { this.layoutElement = element; view.clear(); layoutElement.getPropertyCategories().forEach(category -> { view.addCategory(category); category.getFields().forEach(field -> { String prop = field.getKey(); String val = field.getCurrentStringValue(); if (val != null && !val.isEmpty()) { currentValues.put(prop, val); } }); }); view.show(); }
public void edit(LayoutEditorElement element) { this.layoutElement = element; view.clear(); layoutElement.getPropertyCategories().forEach(category -> { view.addCategory(category); category.getFields().forEach(field -> { String prop = field.getKey(); String val = field.getCurrentStringValue(); if (val != null && !val.isEmpty()) { currentValues.put(prop, val); } }); }); view.show(); }
@Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (validate(property, checkBox.getValue().toString())) { checkBox.clearOldValidationErrors(); property.setCurrentStringValue(checkBox.getValue().toString()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, checkBox.getValue().toString())); } else { checkBox.setValidationError(getValidatorErrorMessage(property, checkBox.getValue().toString())); checkBox.setValue(Boolean.valueOf(property.getCurrentStringValue())); } } });
@Override public Widget widget(final PropertyEditorFieldInfo property) { final PropertyEditorColorPicker colorPicker = GWT.create(PropertyEditorColorPicker.class); String colorCode = property.getCurrentStringValue(); colorPicker.setValue(colorCode.startsWith("#") ? colorCode.substring(1) : colorCode); colorPicker.addChangeHandler(event -> { String color = colorPicker.getValue(); if (color.isEmpty() || validate(property, color)) { colorPicker.clearOldValidationErrors(); property.setCurrentStringValue(color); propertyEditorChangeEvent.fire(new PropertyEditorChangeEvent(property, "#" + color)); } else { colorPicker.setValidationError(getValidatorErrorMessage(property, color)); colorPicker.setValue(property.getCurrentStringValue()); } }); return colorPicker; } }
private void assertProperty(PropertyEditorFieldInfo fieldInfo, String label, PropertyEditorType type, String expectedValue) { assertProperty(fieldInfo, label, type); assertEquals(expectedValue, fieldInfo.getCurrentStringValue()); }
@Override public void onBlur(BlurEvent event) { if (validate(property, textBox.getText())) { textBox.clearOldValidationErrors(); property.setCurrentStringValue(textBox.getText()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, textBox.getText())); } else { textBox.setValidationError(getValidatorErrorMessage(property, textBox.getText())); textBox.setText(property.getCurrentStringValue()); } } });
@Override public void onBlur(BlurEvent event) { if (validate(property, passwordTextBox.getText())) { passwordTextBox.clearOldValidationErrors(); property.setCurrentStringValue(passwordTextBox.getText()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, passwordTextBox.getText())); } else { passwordTextBox.setValidationError(getValidatorErrorMessage(property, passwordTextBox.getText())); passwordTextBox.setText(property.getCurrentStringValue()); } } });
@Override public void onChange(ChangeEvent event) { int selectedIndex = listBox.getSelectedIndex(); if (validate(property, listBox.getItemText(selectedIndex))) { listBox.clearOldValidationErrors(); property.setCurrentStringValue(listBox.getItemText(selectedIndex)); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, listBox.getItemText(selectedIndex))); } else { listBox.setValidationError(getValidatorErrorMessage(property, listBox.getItemText(selectedIndex))); listBox.setSelectItemByText(property.getCurrentStringValue()); } } }
@Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { if (validate(property, passwordTextBox.getText())) { passwordTextBox.clearOldValidationErrors(); property.setCurrentStringValue(passwordTextBox.getText()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, passwordTextBox.getText())); } else { passwordTextBox.setValidationError(getValidatorErrorMessage(property, passwordTextBox.getText())); passwordTextBox.setText(property.getCurrentStringValue()); } } } });
@Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { if (validate(property, textBox.getText())) { textBox.clearOldValidationErrors(); property.setCurrentStringValue(textBox.getText()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, textBox.getText())); } else { textBox.setValidationError(getValidatorErrorMessage(property, textBox.getText())); textBox.setText(property.getCurrentStringValue()); } } } });