Hello anmolbabu,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/39356
to review the following change.
Change subject: webadmin : CheckBoxGroup and DaysOfMonthSelector Widgets
......................................................................
webadmin : CheckBoxGroup and DaysOfMonthSelector Widgets
CheckBoxGroup Widget and DaysOfMonthSelector Widgets
Change-Id: I38daa0d2c151eb0e34603488496a8a1ea4719c87
Signed-off-by: Anmol Babu <[email protected]>
---
A
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java
A
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroupCss.java
A
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/DaysOfMonthSelector.java
A
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/DaysOfMonthSelectorCss.java
A
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroup.java
A
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroupEditor.java
A
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelDaysOfMonthSelector.java
A
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelDaysOfMonthSelectorEditor.java
A
frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/CheckBoxGroup.css
A
frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/DaysOfMonthSelector.css
M
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
11 files changed, 628 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/56/39356/1
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java
new file mode 100644
index 0000000..2366442
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java
@@ -0,0 +1,182 @@
+package org.ovirt.engine.ui.common.widget.editor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.KeyDownEvent;
+import com.google.gwt.event.dom.client.KeyDownHandler;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
+import com.google.gwt.text.shared.Renderer;
+import com.google.gwt.user.client.TakesValue;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HasConstrainedValue;
+
+/**
+ * The CheckboxGroup Widget is used to group together a set of Checkbox
buttons. By default first checkbox is checked
+ * due to default behaviour of UiCommonEditorVisitor. Use clearAllSelections
to deselect all checkboxes. Any number of
+ * checkboxes can be checked/set at any point in time. Pushing/Clicking any
checkbox in the group toggles its state.
+ */
+
+public class CheckBoxGroup<T> extends Composite implements
TakesValue<List<T>>, HasConstrainedValue<List<T>> {
+
+ private final Map<T, CheckBox> checkBoxes = new LinkedHashMap<>();
+
+ private static Resources RESOURCES = GWT.create(Resources.class);
+ private final FlowPanel wrapperPanel = new FlowPanel();
+
+ private CheckBoxGroupCss style;
+
+ private boolean enabled = true;
+
+ Renderer<T> renderer;
+
+ int tabIndex;
+
+ public interface Resources extends ClientBundle {
+ @Source("org/ovirt/engine/ui/common/css/CheckBoxGroup.css")
+ CheckBoxGroupCss checkBoxGroupCss();
+ }
+
+ public CheckBoxGroup(Renderer<T> renderer) {
+ this.renderer = renderer;
+ style = RESOURCES.checkBoxGroupCss();
+ style.ensureInjected();
+ initWidget(wrapperPanel);
+ }
+
+ private void addCheckBox(T checkBoxValue) {
+ String checkBoxLabel = renderer.render(checkBoxValue);
+ if (checkBoxLabel == null) {
+ throw new IllegalArgumentException("null value is not permited");
//$NON-NLS-1$
+ }
+ final CheckBox newCheckBox = buildCheckbox(checkBoxValue);
+ checkBoxes.put(checkBoxValue, newCheckBox);
+ }
+
+ private CheckBox buildCheckbox(final T checkBoxValue) {
+ final CheckBox newCheckBox = new
CheckBox(SafeHtmlUtils.fromString(renderer.render(checkBoxValue)));
+ newCheckBox.setValue(false);
+ newCheckBox.setStyleName(style.checkBox());
+ newCheckBox.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ ValueChangeEvent.fire(CheckBoxGroup.this, getValue());
+ }
+ });
+ return newCheckBox;
+ }
+
+ /**
+ * Clear All checkBoxes' selection in the group
+ */
+ public void clearAllSelections() {
+ for (Entry<T, CheckBox> currentcheckBoxValue : checkBoxes.entrySet()) {
+ currentcheckBoxValue.getValue().setValue(false);
+ }
+ }
+
+ public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
+ return addDomHandler(handler, KeyUpEvent.getType());
+ }
+
+ public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
+ return addDomHandler(handler, KeyDownEvent.getType());
+ }
+
+ public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
+ return addDomHandler(handler, KeyPressEvent.getType());
+ }
+
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * Enable/disable all checkboxes
+ */
+ public void setEnabled(boolean enabled) {
+ for(Entry<T, CheckBox> currentValue : checkBoxes.entrySet()) {
+ currentValue.getValue().setEnabled(enabled);
+ }
+ }
+
+ public int getTabIndex() {
+ return tabIndex;
+ }
+
+ public void setTabIndex(int index) {
+ tabIndex = index;
+ }
+
+ @Override
+ public void setValue(List<T> value, boolean fireEvents) {
+ for (T currentvalue : value) {
+ if (checkBoxes.containsKey(currentvalue)) {
+ checkBoxes.get(currentvalue).setValue(true);
+ }
+ }
+ if (fireEvents) {
+ ValueChangeEvent.fire(this, value);
+ }
+ }
+
+ @Override
+ public HandlerRegistration
addValueChangeHandler(ValueChangeHandler<List<T>> handler) {
+ return addHandler(handler, ValueChangeEvent.getType());
+ }
+
+ @Override
+ public void setAcceptableValues(Collection<List<T>> values) {
+ if (values.isEmpty()) {
+ throw new IllegalArgumentException("Widget has nothing to
do");//$NON-NLS-1$
+ }
+ List<T> acceptableValues = (List<T>) values.toArray()[0];
+ for(T currentValue : acceptableValues) {
+ if(!checkBoxes.containsKey(currentValue)) {
+ addCheckBox(currentValue);
+ }
+ }
+ showCheckBoxes();
+ }
+
+ private void showCheckBoxes() {
+ for (Entry<T, CheckBox> currentEntry : checkBoxes.entrySet()) {
+ wrapperPanel.add(currentEntry.getValue());
+ }
+ }
+
+ @Override
+ public void setValue(List<T> value) {
+ setValue(value, false);
+ }
+
+ @Override
+ public List<T> getValue() {
+ List<T> selectedItems = new ArrayList<>();
+ for (Entry<T, CheckBox> currentEntry : checkBoxes.entrySet()) {
+ if (currentEntry.getValue().getValue()) {
+ selectedItems.add(currentEntry.getKey());
+ }
+ }
+ return selectedItems;
+ }
+
+}
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroupCss.java
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroupCss.java
new file mode 100644
index 0000000..1c2ce1b
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroupCss.java
@@ -0,0 +1,8 @@
+package org.ovirt.engine.ui.common.widget.editor;
+
+import com.google.gwt.resources.client.CssResource;
+
+public interface CheckBoxGroupCss extends CssResource {
+ @ClassName("checkBox")
+ String checkBox();
+}
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/DaysOfMonthSelector.java
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/DaysOfMonthSelector.java
new file mode 100644
index 0000000..128a2a7
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/DaysOfMonthSelector.java
@@ -0,0 +1,182 @@
+package org.ovirt.engine.ui.common.widget.editor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.ovirt.engine.ui.uicompat.ConstantsManager;
+import org.ovirt.engine.ui.uicompat.UIConstants;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.user.client.TakesValue;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HTMLTable.Cell;
+import com.google.gwt.user.client.ui.HasValue;
+import com.google.gwt.user.client.ui.Label;
+
+public class DaysOfMonthSelector extends Composite implements
TakesValue<String>, HasValue<String> {
+
+ private static final int DAYS_IN_WEEK = 7;
+ private static final int LAST_DAY_OF_MONTH_INDEX = 31;
+ private static final UIConstants constants =
ConstantsManager.getInstance().getConstants();
+
+ private static Resources RESOURCES = GWT.create(Resources.class);
+ private DaysOfMonthSelectorCss style;
+
+ private final FlowPanel wrapperPanel = new FlowPanel();
+ private final FlexTable daysOfMonth = new FlexTable();
+
+ // Starts from index 0 and goes upto 31(Assumed to be last day of
month(recurrence))
+ List<Boolean> clickedList = new ArrayList<>();
+
+ public interface Resources extends ClientBundle {
+ @Source("org/ovirt/engine/ui/common/css/DaysOfMonthSelector.css")
+ DaysOfMonthSelectorCss daysOfMonthSelectorCSS();
+ }
+
+ public DaysOfMonthSelector() {
+ initWidget(wrapperPanel);
+ style = RESOURCES.daysOfMonthSelectorCSS();
+ style.ensureInjected();
+ daysOfMonth.setStyleName(style.daysOfMonthWidget());
+ showDaysOfMonth();
+ daysOfMonth.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ Cell cellClicked = daysOfMonth.getCellForEvent(event);
+ int cellColumn = cellClicked.getCellIndex();
+ int cellRow = cellClicked.getRowIndex();
+ int actualCellIndex = (cellRow - 1) * DAYS_IN_WEEK +
cellColumn;
+ if (!clickedList.get(actualCellIndex)) {
+ ValueChangeEvent.fire(DaysOfMonthSelector.this,
+ addSelectedDate(getValue(),
getDateFromIndex(actualCellIndex)));
+ } else {
+ ValueChangeEvent.fire(DaysOfMonthSelector.this,
+ removeSelectedDate(getValue(),
getDateFromIndex(actualCellIndex)));
+ }
+ }
+ });
+ }
+
+ private void onSelectedItemsChange(int date, boolean clicked) {
+ String className = style.normalFlexTableCell();
+ if (clicked) {
+ className = style.selectedFlexTableCell();
+ }
+ daysOfMonth.getCellFormatter()
+ .getElement(getRowForTheDay(date), getColumnForTheDay(date))
+ .setClassName(className);
+ }
+
+ private void showDaysOfMonth() {
+ int row = 0;
+ int column = 0;
+ for (int i = 0; i < LAST_DAY_OF_MONTH_INDEX; i++) {
+ if ((i + 1) % DAYS_IN_WEEK == 1 && i != 1) {
+ row++;
+ column = 0;
+ }
+ daysOfMonth.setWidget(row, column, new Label(Integer.toString(i +
1)));
+ daysOfMonth.getCellFormatter().getElement(row,
column).addClassName(style.normalFlexTableCell());
+ clickedList.add(i, false);
+ column++;
+ }
+ Label widget = new Label(constants.lastDay());
+ clickedList.add(LAST_DAY_OF_MONTH_INDEX, false);
+ daysOfMonth.setWidget(row, column, widget);
+ daysOfMonth.getFlexCellFormatter().setColSpan(row, column, 4);
+ wrapperPanel.add(daysOfMonth);
+ }
+
+ @Override
+ public void setValue(String value, boolean fireEvents) {
+ clearSelections();
+ if (value != null && !value.isEmpty()) {
+ for (String valueInProcess : Arrays.asList(value.split(",")))
{//$NON-NLS-1$
+ int selectedIndex = getIndexFromDate(valueInProcess);
+ if (clickedList.get(selectedIndex) != null) {
+ clickedList.set(selectedIndex, true);
+ onSelectedItemsChange(selectedIndex + 1, true);
+ }
+ }
+ if (fireEvents) {
+ ValueChangeEvent.fire(this, value);
+ }
+ }
+ }
+
+ @Override
+ public void setValue(String value) {
+ setValue(value, false);
+ }
+
+ private void clearSelections() {
+ for (int index = 0; index <= LAST_DAY_OF_MONTH_INDEX; index++) {
+ clickedList.set(index, false);
+ onSelectedItemsChange(index + 1, false);
+ }
+ }
+
+ @Override
+ public String getValue() {
+ String selectedValues = null;
+ for (int dayInProcess = 0; dayInProcess <= LAST_DAY_OF_MONTH_INDEX;
dayInProcess++) {
+ if (clickedList.get(dayInProcess)) {
+ selectedValues = addSelectedDate(selectedValues,
getDateFromIndex(dayInProcess));
+ }
+ }
+ return selectedValues;
+ }
+
+ private String addSelectedDate(String selectedValues, String dateString) {
+ if (selectedValues == null) {
+ selectedValues = dateString;
+ } else {
+ selectedValues = selectedValues.concat(",");//$NON-NLS-1$
+ selectedValues = selectedValues.concat(dateString);
+ }
+ return selectedValues;
+ }
+
+ private String removeSelectedDate(String selectedValues, String
dayInProcess) {
+ List<String> selectedDatesList = new
ArrayList<>(Arrays.asList(selectedValues.split(",")));//$NON-NLS-1$
+ selectedDatesList.remove(dayInProcess);
+ String selectedDatesString = null;
+ for (String currentSelectedDate : selectedDatesList) {
+ selectedDatesString = addSelectedDate(selectedDatesString,
currentSelectedDate);
+ }
+ return selectedDatesString;
+ }
+
+ private String getDateFromIndex(int dayInProcess) {
+ return dayInProcess == LAST_DAY_OF_MONTH_INDEX ? "L" :
Integer.toString(dayInProcess + 1);//$NON-NLS-1$
+ }
+
+ private int getIndexFromDate(String value) {
+ return value.equals("L") ? LAST_DAY_OF_MONTH_INDEX :
Integer.parseInt(value) - 1;//$NON-NLS-1$
+ }
+
+ private int getRowForTheDay(int date) {
+ int row = date / DAYS_IN_WEEK;
+ return date % DAYS_IN_WEEK == 0 ? row : row + 1;
+ }
+
+ private int getColumnForTheDay(int date) {
+ int probableColumn = date % DAYS_IN_WEEK;
+ int cellColumn = probableColumn == 0 ? 6 : probableColumn - 1;
+ return cellColumn;
+ }
+
+ @Override
+ public HandlerRegistration
addValueChangeHandler(ValueChangeHandler<String> handler) {
+ return addHandler(handler, ValueChangeEvent.getType());
+ }
+}
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/DaysOfMonthSelectorCss.java
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/DaysOfMonthSelectorCss.java
new file mode 100644
index 0000000..76a6f29
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/DaysOfMonthSelectorCss.java
@@ -0,0 +1,14 @@
+package org.ovirt.engine.ui.common.widget.editor;
+
+import com.google.gwt.resources.client.CssResource;
+
+public interface DaysOfMonthSelectorCss extends CssResource {
+ @ClassName("normalFlexTableCell")
+ String normalFlexTableCell();
+
+ @ClassName("selectedFlexTableCell")
+ String selectedFlexTableCell();
+
+ @ClassName("daysOfMonthWidget")
+ String daysOfMonthWidget();
+}
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroup.java
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroup.java
new file mode 100644
index 0000000..d1757bc
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroup.java
@@ -0,0 +1,42 @@
+package org.ovirt.engine.ui.common.widget.editor;
+
+import java.util.List;
+
+import com.google.gwt.editor.client.adapters.TakesValueEditor;
+import com.google.gwt.text.shared.Renderer;
+import com.google.gwt.user.client.ui.HasConstrainedValue;
+
+/**
+ * ListModel bound CheckBoxGroup that uses {@link CheckBoxGroup}.
+ */
+public class ListModelCheckBoxGroup<T> extends CheckBoxGroup<T> implements
EditorWidget<List<T>, TakesValueEditor<List<T>>>, HasConstrainedValue<List<T>> {
+
+ private TakesConstrainedValueEditor<List<T>> editor;
+
+ private char accessKey;
+
+ public ListModelCheckBoxGroup(Renderer<T> renderer) {
+ super(renderer);
+ }
+
+ @Override
+ public TakesValueEditor<List<T>> asEditor() {
+ if (editor == null) {
+ editor = TakesConstrainedValueEditor.of(this, this, this);
+ }
+ return editor;
+ }
+
+ public char getAccessKey() {
+ return accessKey;
+ }
+
+ @Override
+ public void setAccessKey(char key) {
+ this.accessKey = key;
+ }
+
+ @Override
+ public void setFocus(boolean focused) {
+ }
+}
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroupEditor.java
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroupEditor.java
new file mode 100644
index 0000000..68b1908
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelCheckBoxGroupEditor.java
@@ -0,0 +1,49 @@
+package org.ovirt.engine.ui.common.widget.editor;
+
+import java.util.List;
+
+import org.ovirt.engine.ui.common.widget.AbstractValidatedWidgetWithLabel;
+import org.ovirt.engine.ui.common.widget.VisibilityRenderer;
+import org.ovirt.engine.ui.common.widget.renderer.StringRenderer;
+
+import com.google.gwt.dom.client.Style.BorderStyle;
+import com.google.gwt.editor.client.IsEditor;
+import com.google.gwt.text.shared.Renderer;
+
+/**
+ * ListModel bound CheckBoxGroup Editor that uses {@link
ListModelCheckBoxGroup}.
+ */
+
+public class ListModelCheckBoxGroupEditor<T> extends
AbstractValidatedWidgetWithLabel<List<T>, ListModelCheckBoxGroup<T>> implements
IsEditor<WidgetWithLabelEditor<List<T>, ListModelCheckBoxGroupEditor<T>>>{
+
+ private final WidgetWithLabelEditor<List<T>,
ListModelCheckBoxGroupEditor<T>> editor;
+
+ public ListModelCheckBoxGroupEditor() {
+ this(new StringRenderer<T>());
+ }
+
+ public ListModelCheckBoxGroupEditor(Renderer<T> renderer) {
+ super(new ListModelCheckBoxGroup<>(renderer), new
VisibilityRenderer.SimpleVisibilityRenderer());
+ editor = WidgetWithLabelEditor.of(getContentWidget().asEditor(), this);
+ }
+
+ @Override
+ public void markAsValid() {
+ super.markAsValid();
+ getValidatedWidgetStyle().setBorderStyle(BorderStyle.NONE);
+ }
+
+ @Override
+ public void markAsInvalid(List<String> validationHints) {
+ super.markAsInvalid(validationHints);
+ }
+
+ @Override
+ public WidgetWithLabelEditor<List<T>, ListModelCheckBoxGroupEditor<T>>
asEditor() {
+ return editor;
+ }
+
+ public CheckBoxGroup<T> asCheckBoxGroup() {
+ return getContentWidget();
+ }
+}
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelDaysOfMonthSelector.java
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelDaysOfMonthSelector.java
new file mode 100644
index 0000000..f264e46
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelDaysOfMonthSelector.java
@@ -0,0 +1,84 @@
+package org.ovirt.engine.ui.common.widget.editor;
+
+import java.util.Collection;
+
+import com.google.gwt.editor.client.adapters.TakesValueEditor;
+import com.google.gwt.event.dom.client.KeyDownEvent;
+import com.google.gwt.event.dom.client.KeyDownHandler;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.ui.HasConstrainedValue;
+
+/**
+ * ListModel bound DaysOfMonthSelector that uses {@link DaysOfMonthSelector}.
+ */
+public class ListModelDaysOfMonthSelector extends DaysOfMonthSelector
implements EditorWidget<String, TakesValueEditor<String>>,
HasConstrainedValue<String> {
+
+ private TakesConstrainedValueEditor<String> editor;
+
+ private int tabIndex;
+
+ @Override
+ public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
+ return addDomHandler(handler, KeyUpEvent.getType());
+ }
+
+ @Override
+ public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
+ return addDomHandler(handler, KeyDownEvent.getType());
+ }
+
+ @Override
+ public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
+ return addDomHandler(handler, KeyPressEvent.getType());
+ }
+
+ @Override
+ public int getTabIndex() {
+ return tabIndex;
+ }
+
+ @Override
+ public void setAccessKey(char key) {
+
+ }
+
+ @Override
+ public void setFocus(boolean focused) {
+
+ }
+
+ @Override
+ public void setTabIndex(int index) {
+ this.tabIndex = index;
+ }
+
+ @Override
+ public TakesValueEditor<String> asEditor() {
+ if (editor == null) {
+ editor = TakesConstrainedValueEditor.of(this, this, this);
+ }
+ return editor;
+ }
+
+ @Override
+ public void setAcceptableValues(Collection<String> values) {
+ // Keeping this mute as of now because the values set from the bound
ListModel's setItems don't have any
+ // significance here and hence shouldn't be done.
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ // Keeping this mute as no use of this can thought as of now.
+
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+}
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelDaysOfMonthSelectorEditor.java
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelDaysOfMonthSelectorEditor.java
new file mode 100644
index 0000000..eb9a919
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelDaysOfMonthSelectorEditor.java
@@ -0,0 +1,44 @@
+package org.ovirt.engine.ui.common.widget.editor;
+
+import java.util.List;
+
+import org.ovirt.engine.ui.common.widget.AbstractValidatedWidgetWithLabel;
+import org.ovirt.engine.ui.common.widget.VisibilityRenderer;
+
+import com.google.gwt.dom.client.Style.BorderStyle;
+import com.google.gwt.editor.client.IsEditor;
+
+public class ListModelDaysOfMonthSelectorEditor extends
AbstractValidatedWidgetWithLabel<String, ListModelDaysOfMonthSelector>
implements IsEditor<WidgetWithLabelEditor<String,
ListModelDaysOfMonthSelectorEditor>> {
+
+ /**
+ * ListModel bound DaysOfMonthSelector editor that uses {@link
ListModelDaysOfMonthSelector}.
+ */
+
+ private final WidgetWithLabelEditor<String,
ListModelDaysOfMonthSelectorEditor> editor;
+
+ public ListModelDaysOfMonthSelectorEditor() {
+ super(new ListModelDaysOfMonthSelector(), new
VisibilityRenderer.SimpleVisibilityRenderer());
+ editor = WidgetWithLabelEditor.of(getContentWidget().asEditor(), this);
+ }
+
+ public DaysOfMonthSelector asDaysOfMonthSelector() {
+ return getContentWidget();
+ }
+
+ @Override
+ public WidgetWithLabelEditor<String, ListModelDaysOfMonthSelectorEditor>
asEditor() {
+ return editor;
+ }
+
+ @Override
+ public void markAsValid() {
+ super.markAsValid();
+ getValidatedWidgetStyle().setBorderStyle(BorderStyle.NONE);
+ }
+
+ @Override
+ public void markAsInvalid(List<String> validationHints) {
+ super.markAsInvalid(validationHints);
+ }
+
+}
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/CheckBoxGroup.css
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/CheckBoxGroup.css
new file mode 100644
index 0000000..de8cbee
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/CheckBoxGroup.css
@@ -0,0 +1,5 @@
+.checkBox {
+ width: auto;
+ margin-right: 10px;
+ float: left;
+}
diff --git
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/DaysOfMonthSelector.css
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/DaysOfMonthSelector.css
new file mode 100644
index 0000000..ae5c660
--- /dev/null
+++
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/ui/common/css/DaysOfMonthSelector.css
@@ -0,0 +1,15 @@
+.selectedFlexTableCell {
+ background-color : #E6E6FA;
+ width: 25px;
+ border: 1px solid black;
+}
+
+.normalFlexTableCell {
+ background-color: white;
+ width: 25px;
+ border: 1px solid black;
+}
+
+.daysOfMonthWidget {
+ border: 2px solid black;
+}
\ No newline at end of file
diff --git
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
index b7905cf..c70346a 100644
---
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
+++
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java
@@ -2464,5 +2464,8 @@
@DefaultStringValue("The selected snapshot will be deactivated.\n Do you
want to continue?")
String confirmVolumeSnapshotDeactivateMessage();
+
+ @DefaultStringValue("Last Day")
+ String lastDay();
}
--
To view, visit https://gerrit.ovirt.org/39356
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I38daa0d2c151eb0e34603488496a8a1ea4719c87
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5-gluster
Gerrit-Owner: Shubhendu Tripathi <[email protected]>
Gerrit-Reviewer: anmolbabu <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches