You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/07/05 16:30:13 UTC
[1/4] syncope git commit: Ignoring deprecation warnings related to
WICKET-5877 - don't import DateFieldPanel / DateTimeFieldPanel into 2.0.0 but
replace with existing modern components
Repository: syncope
Updated Branches:
refs/heads/1_2_X bdb3257c8 -> e1c258763
refs/heads/master b13e9fe4d -> b96bb5a61
Ignoring deprecation warnings related to WICKET-5877 - don't import DateFieldPanel / DateTimeFieldPanel into 2.0.0 but replace with existing modern components
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/e1c25876
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/e1c25876
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/e1c25876
Branch: refs/heads/1_2_X
Commit: e1c2587634375dba6d58133a75aa0e61a2171263
Parents: bdb3257
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Sun Jul 5 16:28:14 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Sun Jul 5 16:28:14 2015 +0200
----------------------------------------------------------------------
.../markup/html/form/DateTimeFieldPanel.java | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/e1c25876/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
----------------------------------------------------------------------
diff --git a/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java b/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
index 0fc7436..2562461 100644
--- a/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
+++ b/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
@@ -37,7 +37,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -428975732068281726L;
- private Form form = null;
+ private Form<?> form = null;
public DateTimeFieldPanel(final String id, final String name, final IModel<Date> model, final String datePattern) {
super(id, name, model, datePattern);
@@ -50,6 +50,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -1107858522700306810L;
+ @SuppressWarnings("deprecation")
@Override
protected void onUpdate(final AjaxRequestTarget target) {
final Integer hours = ((DateTimeField) field).getHours();
@@ -64,6 +65,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -1107858522700306810L;
+ @SuppressWarnings("deprecation")
@Override
protected void onUpdate(final AjaxRequestTarget target) {
final Integer minutes = ((DateTimeField) field).getMinutes();
@@ -78,6 +80,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -1107858522700306810L;
+ @SuppressWarnings("deprecation")
@Override
protected void onUpdate(final AjaxRequestTarget target) {
final Date date = ((DateTimeField) field).getDate();
@@ -85,7 +88,8 @@ public class DateTimeFieldPanel extends DateFieldPanel {
field.setModelObject(null);
} else {
cal.setTime(date);
- cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm()) ? Calendar.PM
+ cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm())
+ ? Calendar.PM
: Calendar.AM);
field.setModelObject(cal.getTime());
}
@@ -96,6 +100,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -1107858522700306810L;
+ @SuppressWarnings("deprecation")
@Override
protected void onUpdate(final AjaxRequestTarget target) {
cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm()) ? Calendar.PM
@@ -114,18 +119,18 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = 6842264694946633582L;
- private FormComponent[] dateTimeComponents;
+ private FormComponent<?>[] dateTimeComponents;
public DateTimeFormValidator(final DateTimeField dateTimeComponent) {
if (dateTimeComponent == null) {
throw new IllegalArgumentException("argument dateTimeComponent cannot be null");
}
- dateTimeComponents = new FormComponent[] { dateTimeComponent };
+ dateTimeComponents = new FormComponent<?>[] { dateTimeComponent };
}
@Override
- public FormComponent[] getDependentFormComponents() {
+ public FormComponent<?>[] getDependentFormComponents() {
return dateTimeComponents;
}
@@ -134,8 +139,9 @@ public class DateTimeFieldPanel extends DateFieldPanel {
*
* @param form
*/
+ @SuppressWarnings("deprecation")
@Override
- public void validate(final Form form) {
+ public void validate(final Form<?> form) {
final DateTimeField dateTimeField = (DateTimeField) dateTimeComponents[0];
if (!(dateTimeField.getDate() != null && dateTimeField.getHours() != null
@@ -150,7 +156,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
}
@SuppressWarnings("rawtypes")
- public FieldPanel<Date> setFormValidator(final Form form) {
+ public FieldPanel<Date> setFormValidator(final Form<?> form) {
if (field == null) {
LOG.error("Error setting form validator");
} else {
[3/4] syncope git commit: Merge branch '1_2_X'
Posted by il...@apache.org.
Merge branch '1_2_X'
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/89f5ead3
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/89f5ead3
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/89f5ead3
Branch: refs/heads/master
Commit: 89f5ead3859fa29f75adbbea0901c0321107db09
Parents: b13e9fe e1c2587
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Sun Jul 5 16:29:20 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Sun Jul 5 16:29:20 2015 +0200
----------------------------------------------------------------------
.../markup/html/form/DateTimeFieldPanel.java | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/89f5ead3/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTimeFieldPanel.java
----------------------------------------------------------------------
diff --cc client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTimeFieldPanel.java
index d8014f6,0000000..67d72d1
mode 100644,000000..100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTimeFieldPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTimeFieldPanel.java
@@@ -1,195 -1,0 +1,201 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.wicket.markup.html.form;
+
+import java.util.Calendar;
+import java.util.Date;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.extensions.yui.calendar.DateTimeField;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.FormComponent;
+import org.apache.wicket.markup.html.form.validation.AbstractFormValidator;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.validation.IValidationError;
+import org.apache.wicket.validation.ValidationError;
+
+public class DateTimeFieldPanel extends DateFieldPanel {
+
+ private static final long serialVersionUID = -428975732068281726L;
+
- private Form form = null;
++ private Form<?> form = null;
+
+ public DateTimeFieldPanel(final String id, final String name, final IModel<Date> model, final String datePattern) {
+ super(id, name, model, datePattern);
+
+ field = new DateTimeField("field", model);
+
+ final Calendar cal = Calendar.getInstance();
+
+ field.get("hours").add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
++ @SuppressWarnings("deprecation")
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ final Integer hours = ((DateTimeField) field).getHours();
+ if (hours != null) {
+ cal.set(hours > 12 ? Calendar.HOUR_OF_DAY : Calendar.HOUR, hours);
+ field.setModelObject(cal.getTime());
+ }
+ }
+ });
+
+ field.get("minutes").add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
++ @SuppressWarnings("deprecation")
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ final Integer minutes = ((DateTimeField) field).getMinutes();
+ if (minutes != null) {
+ cal.set(Calendar.MINUTE, minutes);
+ field.setModelObject(cal.getTime());
+ }
+ }
+ });
+
+ field.get("date").add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
++ @SuppressWarnings("deprecation")
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ final Date date = ((DateTimeField) field).getDate();
+ if (date == null) {
+ field.setModelObject(null);
+ } else {
+ cal.setTime(date);
- cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm()) ? Calendar.PM
++ cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm())
++ ? Calendar.PM
+ : Calendar.AM);
+ field.setModelObject(cal.getTime());
+ }
+ }
+ });
+
+ field.get("amOrPmChoice").add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
++ @SuppressWarnings("deprecation")
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm()) ? Calendar.PM
+ : Calendar.AM);
+ field.setModelObject(cal.getTime());
+ }
+ });
+
+ add(field.setLabel(new Model<String>(name)).setOutputMarkupId(true));
+ }
+
+ /**
+ * Custom form validator for registering and handling DateTimeField components that are in it.
+ */
+ private class DateTimeFormValidator extends AbstractFormValidator {
+
+ private static final long serialVersionUID = 6842264694946633582L;
+
- private FormComponent[] dateTimeComponents;
++ private FormComponent<?>[] dateTimeComponents;
+
+ public DateTimeFormValidator(final DateTimeField dateTimeComponent) {
+ if (dateTimeComponent == null) {
+ throw new IllegalArgumentException("argument dateTimeComponent cannot be null");
+ }
+
- dateTimeComponents = new FormComponent[] { dateTimeComponent };
++ dateTimeComponents = new FormComponent<?>[] { dateTimeComponent };
+ }
+
+ @Override
- public FormComponent[] getDependentFormComponents() {
++ public FormComponent<?>[] getDependentFormComponents() {
+ return dateTimeComponents;
+ }
+
+ /**
+ * Validation rule : all 3 fields (date,hours,minutes) must be not-null.
+ *
+ * @param form
+ */
++ @SuppressWarnings("deprecation")
+ @Override
- public void validate(final Form form) {
++ public void validate(final Form<?> form) {
+ final DateTimeField dateTimeField = (DateTimeField) dateTimeComponents[0];
+
+ if (!(dateTimeField.getDate() != null && dateTimeField.getHours() != null
+ && dateTimeField.getMinutes() != null)) {
+
+ ValidationError ve = new ValidationError();
+ ve.setVariables(DateTimeFormValidator.this.variablesMap());
+ ve.addKey(resourceKey());
+ dateTimeComponents[0].error((IValidationError) ve);
+ }
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
- public FieldPanel<Date> setFormValidator(final Form form) {
++ public FieldPanel<Date> setFormValidator(final Form<?> form) {
+ if (field == null) {
+ LOG.error("Error setting form validator");
+ } else {
+ form.add(new DateTimeFormValidator(((DateTimeField) field)));
+ this.form = form;
+ }
+
+ return this;
+ }
+
+ @Override
+ public FieldPanel<Date> setStyleSheet(final String classes) {
+ field.get("date").add(AttributeModifier.replace("class", (classes == null ? "" : classes) + " date_size"));
+
+ field.get("hours").add(AttributeModifier.replace("class", classes == null ? "" : classes));
+
+ field.get("minutes").add(AttributeModifier.replace("class", classes == null ? "" : classes));
+
+ field.get("amOrPmChoice").add(AttributeModifier.replace("class", classes == null ? "" : classes));
+
+ return this;
+ }
+
+ @Override
+ public FieldPanel<Date> clone() {
+ final FieldPanel<Date> panel = new DateTimeFieldPanel(getId(), name, new Model<Date>(null), datePattern);
+
+ panel.setRequired(isRequired());
+ panel.setReadOnly(isReadOnly());
+ panel.setTitle(title);
+
+ if (isRequiredLabelAdded) {
+ panel.addRequiredLabel();
+ }
+
+ if (form != null && isRequired()) {
+ ((DateTimeFieldPanel) panel).setFormValidator(form);
+ }
+
+ return panel;
+ }
+}
[2/4] syncope git commit: Ignoring deprecation warnings related to
WICKET-5877 - don't import DateFieldPanel / DateTimeFieldPanel into 2.0.0 but
replace with existing modern components
Posted by il...@apache.org.
Ignoring deprecation warnings related to WICKET-5877 - don't import DateFieldPanel / DateTimeFieldPanel into 2.0.0 but replace with existing modern components
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/e1c25876
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/e1c25876
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/e1c25876
Branch: refs/heads/master
Commit: e1c2587634375dba6d58133a75aa0e61a2171263
Parents: bdb3257
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Sun Jul 5 16:28:14 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Sun Jul 5 16:28:14 2015 +0200
----------------------------------------------------------------------
.../markup/html/form/DateTimeFieldPanel.java | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/e1c25876/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
----------------------------------------------------------------------
diff --git a/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java b/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
index 0fc7436..2562461 100644
--- a/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
+++ b/console/src/main/java/org/apache/syncope/console/wicket/markup/html/form/DateTimeFieldPanel.java
@@ -37,7 +37,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -428975732068281726L;
- private Form form = null;
+ private Form<?> form = null;
public DateTimeFieldPanel(final String id, final String name, final IModel<Date> model, final String datePattern) {
super(id, name, model, datePattern);
@@ -50,6 +50,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -1107858522700306810L;
+ @SuppressWarnings("deprecation")
@Override
protected void onUpdate(final AjaxRequestTarget target) {
final Integer hours = ((DateTimeField) field).getHours();
@@ -64,6 +65,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -1107858522700306810L;
+ @SuppressWarnings("deprecation")
@Override
protected void onUpdate(final AjaxRequestTarget target) {
final Integer minutes = ((DateTimeField) field).getMinutes();
@@ -78,6 +80,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -1107858522700306810L;
+ @SuppressWarnings("deprecation")
@Override
protected void onUpdate(final AjaxRequestTarget target) {
final Date date = ((DateTimeField) field).getDate();
@@ -85,7 +88,8 @@ public class DateTimeFieldPanel extends DateFieldPanel {
field.setModelObject(null);
} else {
cal.setTime(date);
- cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm()) ? Calendar.PM
+ cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm())
+ ? Calendar.PM
: Calendar.AM);
field.setModelObject(cal.getTime());
}
@@ -96,6 +100,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = -1107858522700306810L;
+ @SuppressWarnings("deprecation")
@Override
protected void onUpdate(final AjaxRequestTarget target) {
cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm()) ? Calendar.PM
@@ -114,18 +119,18 @@ public class DateTimeFieldPanel extends DateFieldPanel {
private static final long serialVersionUID = 6842264694946633582L;
- private FormComponent[] dateTimeComponents;
+ private FormComponent<?>[] dateTimeComponents;
public DateTimeFormValidator(final DateTimeField dateTimeComponent) {
if (dateTimeComponent == null) {
throw new IllegalArgumentException("argument dateTimeComponent cannot be null");
}
- dateTimeComponents = new FormComponent[] { dateTimeComponent };
+ dateTimeComponents = new FormComponent<?>[] { dateTimeComponent };
}
@Override
- public FormComponent[] getDependentFormComponents() {
+ public FormComponent<?>[] getDependentFormComponents() {
return dateTimeComponents;
}
@@ -134,8 +139,9 @@ public class DateTimeFieldPanel extends DateFieldPanel {
*
* @param form
*/
+ @SuppressWarnings("deprecation")
@Override
- public void validate(final Form form) {
+ public void validate(final Form<?> form) {
final DateTimeField dateTimeField = (DateTimeField) dateTimeComponents[0];
if (!(dateTimeField.getDate() != null && dateTimeField.getHours() != null
@@ -150,7 +156,7 @@ public class DateTimeFieldPanel extends DateFieldPanel {
}
@SuppressWarnings("rawtypes")
- public FieldPanel<Date> setFormValidator(final Form form) {
+ public FieldPanel<Date> setFormValidator(final Form<?> form) {
if (field == null) {
LOG.error("Error setting form validator");
} else {
[4/4] syncope git commit: Removing Date-related panels to avoid usage
in 2.0.0
Posted by il...@apache.org.
Removing Date-related panels to avoid usage in 2.0.0
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/b96bb5a6
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/b96bb5a6
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/b96bb5a6
Branch: refs/heads/master
Commit: b96bb5a6172c52e46edb391236ae17eef95411c6
Parents: 89f5ead
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Sun Jul 5 16:30:03 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Sun Jul 5 16:30:03 2015 +0200
----------------------------------------------------------------------
.../wicket/markup/html/form/DateFieldPanel.java | 132 ------------
.../markup/html/form/DateTextFieldPanel.java | 88 --------
.../markup/html/form/DateTimeFieldPanel.java | 201 -------------------
3 files changed, 421 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/b96bb5a6/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateFieldPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateFieldPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateFieldPanel.java
deleted file mode 100644
index 1f5aaf6..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateFieldPanel.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.console.wicket.markup.html.form;
-
-import java.io.Serializable;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.springframework.util.StringUtils;
-
-public class DateFieldPanel extends FieldPanel<Date> {
-
- private static final long serialVersionUID = -428975732068281726L;
-
- protected final String name;
-
- protected final String datePattern;
-
- protected DateFieldPanel(final String id, final String name, final IModel<Date> model, final String datePattern) {
- super(id, model);
- this.name = name;
- this.datePattern = datePattern;
- }
-
- @Override
- public FieldPanel<Date> setNewModel(final List<Serializable> list) {
- final SimpleDateFormat formatter = datePattern == null
- ? new SimpleDateFormat(SyncopeConstants.DEFAULT_DATE_PATTERN, Locale.getDefault())
- : new SimpleDateFormat(datePattern, Locale.getDefault());
-
- setNewModel(new Model<Date>() {
-
- private static final long serialVersionUID = 527651414610325237L;
-
- @Override
- public Date getObject() {
- Date date = null;
-
- if (list != null && !list.isEmpty() && StringUtils.hasText(list.get(0).toString())) {
- try {
- // Parse string using datePattern
- date = formatter.parse(list.get(0).toString());
- } catch (ParseException e) {
- LOG.error("invalid parse exception", e);
- }
- }
-
- return date;
- }
-
- @Override
- public void setObject(final Date object) {
- list.clear();
- if (object != null) {
- list.add(formatter.format(object));
- }
- }
- });
-
- return this;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public FieldPanel<Date> setNewModel(final ListItem item) {
- final SimpleDateFormat formatter = datePattern == null
- ? new SimpleDateFormat(SyncopeConstants.DEFAULT_DATE_PATTERN, Locale.getDefault())
- : new SimpleDateFormat(datePattern, Locale.getDefault());
-
- IModel<Date> model = new Model<Date>() {
-
- private static final long serialVersionUID = 6799404673615637845L;
-
- @Override
- public Date getObject() {
- Date date = null;
-
- final Object obj = item.getModelObject();
-
- if (obj != null && !obj.toString().isEmpty()) {
- if (obj instanceof String) {
- // Parse string using datePattern
- try {
- date = formatter.parse(obj.toString());
- } catch (ParseException e) {
- LOG.error("While parsing date", e);
- }
- } else if (obj instanceof Date) {
- // Don't parse anything
- date = (Date) obj;
- } else {
- // consider Long
- date = new Date((Long) obj);
- }
- }
-
- return date;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void setObject(final Date object) {
- item.setModelObject(object != null ? formatter.format(object) : null);
- }
- };
-
- field.setModel(model);
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b96bb5a6/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTextFieldPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTextFieldPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTextFieldPanel.java
deleted file mode 100644
index add3de6..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTextFieldPanel.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.console.wicket.markup.html.form;
-
-import java.util.Date;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.datetime.markup.html.form.DateTextField;
-import org.apache.wicket.extensions.yui.calendar.DatePicker;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-
-public class DateTextFieldPanel extends DateFieldPanel {
-
- private static final long serialVersionUID = 1919852712185883648L;
-
- public DateTextFieldPanel(final String id, final String name, final IModel<Date> model, final String datePattern) {
- super(id, name, model, datePattern);
-
- field = DateTextField.forDatePattern("field", model, datePattern);
-
- if (!isReadOnly()) {
- field.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- // nothing to do
- }
- });
- }
-
- field.add(getDatePicker());
-
- add(field.setLabel(new Model<String>(name)).setOutputMarkupId(true));
- }
-
- /**
- * Setup a DatePicker component.
- */
- private DatePicker getDatePicker() {
- final DatePicker picker = new DatePicker() {
-
- private static final long serialVersionUID = 4166072895162221956L;
-
- @Override
- protected boolean enableMonthYearSelection() {
- return true;
- }
- };
-
- picker.setShowOnFieldClick(true);
-
- return picker;
- }
-
- @Override
- public FieldPanel<Date> clone() {
- final FieldPanel<Date> panel = new DateTextFieldPanel(getId(), name, new Model<Date>(), datePattern);
- panel.setRequired(isRequired());
- panel.setReadOnly(isReadOnly());
- panel.setTitle(title);
-
- if (isRequiredLabelAdded) {
- panel.addRequiredLabel();
- }
-
- return panel;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b96bb5a6/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTimeFieldPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTimeFieldPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTimeFieldPanel.java
deleted file mode 100644
index 67d72d1..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/DateTimeFieldPanel.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.console.wicket.markup.html.form;
-
-import java.util.Calendar;
-import java.util.Date;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.extensions.yui.calendar.DateTimeField;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.FormComponent;
-import org.apache.wicket.markup.html.form.validation.AbstractFormValidator;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.validation.IValidationError;
-import org.apache.wicket.validation.ValidationError;
-
-public class DateTimeFieldPanel extends DateFieldPanel {
-
- private static final long serialVersionUID = -428975732068281726L;
-
- private Form<?> form = null;
-
- public DateTimeFieldPanel(final String id, final String name, final IModel<Date> model, final String datePattern) {
- super(id, name, model, datePattern);
-
- field = new DateTimeField("field", model);
-
- final Calendar cal = Calendar.getInstance();
-
- field.get("hours").add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @SuppressWarnings("deprecation")
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- final Integer hours = ((DateTimeField) field).getHours();
- if (hours != null) {
- cal.set(hours > 12 ? Calendar.HOUR_OF_DAY : Calendar.HOUR, hours);
- field.setModelObject(cal.getTime());
- }
- }
- });
-
- field.get("minutes").add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @SuppressWarnings("deprecation")
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- final Integer minutes = ((DateTimeField) field).getMinutes();
- if (minutes != null) {
- cal.set(Calendar.MINUTE, minutes);
- field.setModelObject(cal.getTime());
- }
- }
- });
-
- field.get("date").add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @SuppressWarnings("deprecation")
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- final Date date = ((DateTimeField) field).getDate();
- if (date == null) {
- field.setModelObject(null);
- } else {
- cal.setTime(date);
- cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm())
- ? Calendar.PM
- : Calendar.AM);
- field.setModelObject(cal.getTime());
- }
- }
- });
-
- field.get("amOrPmChoice").add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
-
- private static final long serialVersionUID = -1107858522700306810L;
-
- @SuppressWarnings("deprecation")
- @Override
- protected void onUpdate(final AjaxRequestTarget target) {
- cal.set(Calendar.AM_PM, "PM".equals("" + ((DateTimeField) field).getAmOrPm()) ? Calendar.PM
- : Calendar.AM);
- field.setModelObject(cal.getTime());
- }
- });
-
- add(field.setLabel(new Model<String>(name)).setOutputMarkupId(true));
- }
-
- /**
- * Custom form validator for registering and handling DateTimeField components that are in it.
- */
- private class DateTimeFormValidator extends AbstractFormValidator {
-
- private static final long serialVersionUID = 6842264694946633582L;
-
- private FormComponent<?>[] dateTimeComponents;
-
- public DateTimeFormValidator(final DateTimeField dateTimeComponent) {
- if (dateTimeComponent == null) {
- throw new IllegalArgumentException("argument dateTimeComponent cannot be null");
- }
-
- dateTimeComponents = new FormComponent<?>[] { dateTimeComponent };
- }
-
- @Override
- public FormComponent<?>[] getDependentFormComponents() {
- return dateTimeComponents;
- }
-
- /**
- * Validation rule : all 3 fields (date,hours,minutes) must be not-null.
- *
- * @param form
- */
- @SuppressWarnings("deprecation")
- @Override
- public void validate(final Form<?> form) {
- final DateTimeField dateTimeField = (DateTimeField) dateTimeComponents[0];
-
- if (!(dateTimeField.getDate() != null && dateTimeField.getHours() != null
- && dateTimeField.getMinutes() != null)) {
-
- ValidationError ve = new ValidationError();
- ve.setVariables(DateTimeFormValidator.this.variablesMap());
- ve.addKey(resourceKey());
- dateTimeComponents[0].error((IValidationError) ve);
- }
- }
- }
-
- @SuppressWarnings("rawtypes")
- public FieldPanel<Date> setFormValidator(final Form<?> form) {
- if (field == null) {
- LOG.error("Error setting form validator");
- } else {
- form.add(new DateTimeFormValidator(((DateTimeField) field)));
- this.form = form;
- }
-
- return this;
- }
-
- @Override
- public FieldPanel<Date> setStyleSheet(final String classes) {
- field.get("date").add(AttributeModifier.replace("class", (classes == null ? "" : classes) + " date_size"));
-
- field.get("hours").add(AttributeModifier.replace("class", classes == null ? "" : classes));
-
- field.get("minutes").add(AttributeModifier.replace("class", classes == null ? "" : classes));
-
- field.get("amOrPmChoice").add(AttributeModifier.replace("class", classes == null ? "" : classes));
-
- return this;
- }
-
- @Override
- public FieldPanel<Date> clone() {
- final FieldPanel<Date> panel = new DateTimeFieldPanel(getId(), name, new Model<Date>(null), datePattern);
-
- panel.setRequired(isRequired());
- panel.setReadOnly(isReadOnly());
- panel.setTitle(title);
-
- if (isRequiredLabelAdded) {
- panel.addRequiredLabel();
- }
-
- if (form != null && isRequired()) {
- ((DateTimeFieldPanel) panel).setFormValidator(form);
- }
-
- return panel;
- }
-}