You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/01/25 15:33:48 UTC

[2/5] git commit: ISIS-658: new java.sql.Timestamp panel for wicket viewer

ISIS-658: new java.sql.Timestamp panel for wicket viewer

Also:
- provide the ability to fine-tune adjustments in table view for date/time
based fields.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/0ebc55a9
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/0ebc55a9
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/0ebc55a9

Branch: refs/heads/master
Commit: 0ebc55a9e7108dbd4d4a9cc4b0d802180631f6d1
Parents: 8542acd
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sat Jan 25 14:17:22 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Sat Jan 25 14:17:22 2014 +0000

----------------------------------------------------------------------
 .../ComponentFactoryRegistrarDefault.java       |  2 +
 .../ScalarPanelTextFieldDatePickerAbstract.java | 13 +++++-
 .../scalars/jdkdates/JavaSqlTimestampPanel.css  | 18 ++++++++
 .../scalars/jdkdates/JavaSqlTimestampPanel.html | 41 ++++++++++++++++++
 .../scalars/jdkdates/JavaSqlTimestampPanel.java | 44 ++++++++++++++++++++
 .../jdkdates/JavaSqlTimestampPanelFactory.java  | 44 ++++++++++++++++++++
 6 files changed, 161 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/0ebc55a9/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
index bd41e66..07d53d7 100644
--- a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
+++ b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/components/ComponentFactoryRegistrarDefault.java
@@ -56,6 +56,7 @@ import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisTimePa
 import org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisTimeStampPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.jdkdates.JavaSqlDatePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.jdkdates.JavaSqlTimePanelFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.jdkdates.JavaSqlTimestampPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.jdkdates.JavaUtilDatePanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.jdkmath.JavaMathBigDecimalPanelFactory;
 import org.apache.isis.viewer.wicket.ui.components.scalars.jdkmath.JavaMathBigIntegerPanelFactory;
@@ -200,6 +201,7 @@ public class ComponentFactoryRegistrarDefault implements ComponentFactoryRegistr
         // work-in-progress
         // componentFactories.add(new JavaAwtImagePanelFactory()); 
         componentFactories.add(new JavaUtilDatePanelFactory());
+        componentFactories.add(new JavaSqlTimestampPanelFactory());
         componentFactories.add(new JavaSqlDatePanelFactory());
         componentFactories.add(new JavaSqlTimePanelFactory());
 

http://git-wip-us.apache.org/repos/asf/isis/blob/0ebc55a9/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldDatePickerAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldDatePickerAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldDatePickerAbstract.java
index 704ee81..1aecb38 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldDatePickerAbstract.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldDatePickerAbstract.java
@@ -86,13 +86,24 @@ public abstract class ScalarPanelTextFieldDatePickerAbstract<T extends Serializa
         
         textField.setEnabled(false);
         
+        
+        // adding an amount because seemed to truncate in tables in certain circumstances
+        final int lengthAdjust = 
+                getLengthAdjustHint() != null ? getLengthAdjustHint() : 1; 
         final String dateTimePattern = converter.getDateTimePattern(getLocale());
-        final int length = dateTimePattern.length() + 1; // adding 1 because seemed to truncate in tables in certain circumstances
+        final int length = dateTimePattern.length() + lengthAdjust; 
         textField.add(new AttributeModifier("size", Model.of("" + length)));
         
         addOrReplace(textField);
         return textField;
     }
+    
+    /**
+     * Optional override for subclasses to explicitly indicate desired amount to adjust compact form of textField
+     */
+    protected Integer getLengthAdjustHint() {
+        return null;
+    }
 
     private void addObjectAdapterValidator() {
         final AbstractTextComponent<T> textField = getTextField();

http://git-wip-us.apache.org/repos/asf/isis/blob/0ebc55a9/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.css
new file mode 100644
index 0000000..eaeea17
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.css
@@ -0,0 +1,18 @@
+/*
+ *  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.
+ */

http://git-wip-us.apache.org/repos/asf/isis/blob/0ebc55a9/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.html
new file mode 100644
index 0000000..3ac45cd
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.html
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"  
+      xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"  
+      xml:lang="en"  
+      lang="en">
+	<head></head>
+	<body>
+		<wicket:panel>
+			<div class="javaSqlTimestampPanel scalarNameAndValueComponentType">
+				<label for="scalarValue" wicket:id="scalarIfRegular">
+	      			<span wicket:id="scalarName" class="scalarName">[Label text]</span>
+	      			<span class="scalarValue">
+		      			<input type="text" name="scalarValue" wicket:id="scalarValue" />
+		      			<span wicket:id="feedback"></span>
+                        <span wicket:id="additionalLinks"/>
+	      			</span>
+				</label>
+				<input type="text" wicket:id="scalarIfCompact"></input>
+			</div>
+		</wicket:panel>
+	</body>
+</html>

http://git-wip-us.apache.org/repos/asf/isis/blob/0ebc55a9/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.java
new file mode 100644
index 0000000..acd25b3
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanel.java
@@ -0,0 +1,44 @@
+/*
+ *  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.isis.viewer.wicket.ui.components.scalars.jdkdates;
+
+
+
+import org.apache.isis.viewer.wicket.model.models.ScalarModel;
+import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelTextFieldDatePickerAbstract;
+
+/**
+ * Panel for rendering scalars of type {@link java.util.Date}.
+ */
+public class JavaSqlTimestampPanel extends ScalarPanelTextFieldDatePickerAbstract<java.util.Date> {
+
+    private static final long serialVersionUID = 1L;
+
+    public JavaSqlTimestampPanel(final String id, final ScalarModel scalarModel) {
+        super(id, scalarModel, java.util.Date.class);
+        init(new DateConverterForJavaUtilDate(getSettings(), getAdjustBy()));
+    }
+
+    @Override
+    protected Integer getLengthAdjustHint() {
+        return +5;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/0ebc55a9/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanelFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanelFactory.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanelFactory.java
new file mode 100644
index 0000000..20e19a8
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkdates/JavaSqlTimestampPanelFactory.java
@@ -0,0 +1,44 @@
+/*
+ *  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.isis.viewer.wicket.ui.components.scalars.jdkdates;
+
+import org.apache.wicket.Component;
+
+import org.apache.isis.viewer.wicket.model.models.ScalarModel;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.components.scalars.ComponentFactoryScalarAbstract;
+
+/**
+ * {@link ComponentFactory} for {@link JavaUtilDatePanel}.
+ */
+public class JavaSqlTimestampPanelFactory extends ComponentFactoryScalarAbstract {
+
+    private static final long serialVersionUID = 1L;
+
+    public JavaSqlTimestampPanelFactory() {
+        super(JavaSqlTimestampPanel.class, java.sql.Timestamp.class);
+    }
+
+    @Override
+    public Component createComponent(final String id, final ScalarModel scalarModel) {
+        return new JavaSqlTimestampPanel(id, scalarModel);
+    }
+
+}