Vojtech Szocs has uploaded a new change for review. Change subject: webadmin,userportal: Improve UiCommon Editor integration ......................................................................
webadmin,userportal: Improve UiCommon Editor integration This patch makes UiCommonEditorVisitor work with new interface (UiCommonEditor) instead of using WidgetWithLabelEditor class directly. UiCommonEditor interface can now be implemented by any specific editor class, i.e. we're no longer limited by using only WidgetWithLabelEditor bound to specific widget type (AbstractValidatedWidgetWithLabel). Change-Id: Ifd5a5456966b99e9d2eef8b5a0199f04793b315e Signed-off-by: Vojtech Szocs <vsz...@redhat.com> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/binding/UiCommonEditorDriverGenerator.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/AbstractUiCommonModelEditorDriver.java A frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/UiCommonEditor.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/UiCommonEditorVisitor.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/WidgetWithLabelEditor.java 5 files changed, 54 insertions(+), 27 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/23246/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/binding/UiCommonEditorDriverGenerator.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/binding/UiCommonEditorDriverGenerator.java index 93990b6..9148f53 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/binding/UiCommonEditorDriverGenerator.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/binding/UiCommonEditorDriverGenerator.java @@ -17,8 +17,7 @@ import com.google.gwt.editor.rebind.model.EditorModel; import com.google.gwt.user.rebind.SourceWriter; -public class UiCommonEditorDriverGenerator extends - AbstractEditorDriverGenerator { +public class UiCommonEditorDriverGenerator extends AbstractEditorDriverGenerator { private JClassType entityModelType; private JClassType listModelType; @@ -64,7 +63,7 @@ this.model = model; this.sw = sw; - logger.log(Type.DEBUG, "Strating to write additional Driver code"); //$NON-NLS-1$ + logger.log(Type.DEBUG, "Starting to write additional Driver code"); //$NON-NLS-1$ writeListenerMap(); writeEventMap(); writeOwnerModels(); @@ -75,7 +74,7 @@ * Writes the UiCommonListenerMap for the edited model */ private void writeListenerMap() { - logger.log(Type.DEBUG, "Strating to write ListenerMap"); //$NON-NLS-1$ + logger.log(Type.DEBUG, "Starting to write ListenerMap"); //$NON-NLS-1$ sw.println(); sw.println("@Override"); //$NON-NLS-1$ sw.println("protected " + UiCommonListenerMap.class.getName() + " getListenerMap() {"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -127,7 +126,7 @@ * Writes the UiCommonEventMap for the edited model */ private void writeEventMap() { - logger.log(Type.DEBUG, "Strating to write EventMap"); //$NON-NLS-1$ + logger.log(Type.DEBUG, "Starting to write EventMap"); //$NON-NLS-1$ sw.println(); sw.println("@Override"); //$NON-NLS-1$ @@ -177,7 +176,7 @@ * Writes the map of the owner Models */ private void writeOwnerModels() { - logger.log(Type.DEBUG, "Strating to write OwnerModels"); //$NON-NLS-1$ + logger.log(Type.DEBUG, "Starting to write OwnerModels"); //$NON-NLS-1$ sw.println(); sw.println("@Override"); //$NON-NLS-1$ sw.println("protected java.util.Map<String, org.ovirt.engine.ui.uicommonweb.models.EntityModel> getOwnerModels() {"); //$NON-NLS-1$ diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/AbstractUiCommonModelEditorDriver.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/AbstractUiCommonModelEditorDriver.java index 3abdbdf..a215f3b1 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/AbstractUiCommonModelEditorDriver.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/AbstractUiCommonModelEditorDriver.java @@ -25,8 +25,8 @@ public abstract class AbstractUiCommonModelEditorDriver<T extends Model, E extends Editor<T>> extends BaseEditorDriver<T, E> implements SimpleBeanEditorDriver<T, E> { - private IEventListener propertyChangeListener = null; - private EditorVisitor visitor = null; + private IEventListener propertyChangeListener; + private EditorVisitor visitor; /** * {@inheritDoc} <BR> @@ -97,7 +97,6 @@ /** * Returns a Map of the parent ListModel for all the ListModelBoxes being edited. * - * @param absolutePath * @return */ protected abstract Map<String, EntityModel> getOwnerModels(); diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/UiCommonEditor.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/UiCommonEditor.java new file mode 100644 index 0000000..b6a0da8 --- /dev/null +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/UiCommonEditor.java @@ -0,0 +1,28 @@ +package org.ovirt.engine.ui.common.editor; + +import org.ovirt.engine.ui.common.widget.HasAccess; +import org.ovirt.engine.ui.common.widget.HasEnabledWithHints; +import org.ovirt.engine.ui.common.widget.HasValidation; + +import com.google.gwt.editor.client.Editor; +import com.google.gwt.editor.client.LeafValueEditor; +import com.google.gwt.event.dom.client.HasAllKeyHandlers; +import com.google.gwt.user.client.ui.Focusable; + +/** + * Classes acting as Editors of UiCommon model properties can implement this interface to expose additional + * functionality to {@link UiCommonEditorVisitor}. + * + * @param <T> + * The type being edited. + */ +public interface UiCommonEditor<T> extends Editor<T>, + HasValidation, HasEnabledWithHints, HasAccess, HasAllKeyHandlers, Focusable { + + /** + * In case of leaf Editor, returns {@code this}. In case of composite Editor, returns the actual leaf Editor for + * editing the given property. + */ + LeafValueEditor<T> getActualEditor(); + +} diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/UiCommonEditorVisitor.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/UiCommonEditorVisitor.java index 07291c4..01c67b5 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/UiCommonEditorVisitor.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/editor/UiCommonEditorVisitor.java @@ -7,7 +7,6 @@ import org.ovirt.engine.ui.common.widget.HasEnabledWithHints; import org.ovirt.engine.ui.common.widget.HasValidation; import org.ovirt.engine.ui.common.widget.editor.TakesConstrainedValueEditor; -import org.ovirt.engine.ui.common.widget.editor.WidgetWithLabelEditor; import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.ListModel; import org.ovirt.engine.ui.uicommonweb.models.Model; @@ -26,6 +25,11 @@ import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; +/** + * Editor visitor that implements integration with UiCommon models. + * + * @see UiCommonEditor + */ public class UiCommonEditorVisitor<M extends Model> extends EditorVisitor { private final UiCommonEventMap eventMap; @@ -66,8 +70,7 @@ }); } - final WidgetWithLabelEditor<T, ?> functionalEditor = - getFunctionalEditor(currentLeafEditor); + final UiCommonEditor<T> functionalEditor = getFunctionalEditor(currentLeafEditor); if (functionalEditor != null) { // Set tab index @@ -160,17 +163,17 @@ @SuppressWarnings("unchecked") <T> LeafValueEditor<T> getActualEditor(LeafValueEditor<T> editor) { - if (editor instanceof WidgetWithLabelEditor) { - return ((WidgetWithLabelEditor<T, ?>) editor).getSubEditor(); + if (editor instanceof UiCommonEditor) { + return ((UiCommonEditor<T>) editor).getActualEditor(); } else { return editor; } } @SuppressWarnings("unchecked") - <T> WidgetWithLabelEditor<T, ?> getFunctionalEditor(LeafValueEditor<T> editor) { - if (editor instanceof WidgetWithLabelEditor) { - return (WidgetWithLabelEditor<T, ?>) editor; + <T> UiCommonEditor<T> getFunctionalEditor(LeafValueEditor<T> editor) { + if (editor instanceof UiCommonEditor) { + return (UiCommonEditor<T>) editor; } else { return null; } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/WidgetWithLabelEditor.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/WidgetWithLabelEditor.java index 7d1c09d..fcc7756 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/WidgetWithLabelEditor.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/WidgetWithLabelEditor.java @@ -2,36 +2,29 @@ import java.util.List; +import org.ovirt.engine.ui.common.editor.UiCommonEditor; import org.ovirt.engine.ui.common.widget.AbstractValidatedWidgetWithLabel; -import org.ovirt.engine.ui.common.widget.HasAccess; -import org.ovirt.engine.ui.common.widget.HasEnabledWithHints; -import org.ovirt.engine.ui.common.widget.HasValidation; import com.google.gwt.editor.client.LeafValueEditor; import com.google.gwt.editor.client.adapters.OptionalFieldEditor; -import com.google.gwt.event.dom.client.HasAllKeyHandlers; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.ui.Focusable; /** - * Composite editor that exposes {@link AbstractValidatedWidgetWithLabel} functionality for the given sub-Editor. + * A {@link UiCommonEditor} adapted to work with {@link AbstractValidatedWidgetWithLabel} widget. * * @param <T> * The type being edited. - * @param <E> - * Editor type. * @param <W> * Type that exposes validated widget functionality. * * @see OptionalFieldEditor - * */ public class WidgetWithLabelEditor<T, W extends AbstractValidatedWidgetWithLabel<T, ?>> - extends OptionalFieldEditor<T, LeafValueEditor<T>> implements HasValidation, HasEnabledWithHints, HasAccess, HasAllKeyHandlers, Focusable { + extends OptionalFieldEditor<T, LeafValueEditor<T>> implements UiCommonEditor<T> { public static <T, W extends AbstractValidatedWidgetWithLabel<T, ?>> WidgetWithLabelEditor<T, W> of( LeafValueEditor<T> subEditor, W widgetWithLabel) { @@ -52,6 +45,11 @@ } @Override + public LeafValueEditor<T> getActualEditor() { + return getSubEditor(); + } + + @Override public void markAsValid() { widgetWithLabel.markAsValid(); } -- To view, visit http://gerrit.ovirt.org/23246 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifd5a5456966b99e9d2eef8b5a0199f04793b315e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Vojtech Szocs <vsz...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches