incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1384216 - in /incubator/isis/trunk/framework: core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/ core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/biginteger/ viewer/wicket/wicket-ui...
Date Thu, 13 Sep 2012 06:35:48 GMT
Author: danhaywood
Date: Thu Sep 13 06:35:48 2012
New Revision: 1384216

URL: http://svn.apache.org/viewvc?rev=1384216&view=rev
Log:
ISIS-232: bigdecimal and biginteger text field

- typical length = 8
- right-align
- parse commas

Added:
    incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/TextFieldValueModel.java
Modified:
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java
    incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/biginteger/BigIntegerValueSemanticsProvider.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigDecimalPanel.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigIntegerPanel.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css
    incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java

Modified: incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java?rev=1384216&r1=1384215&r2=1384216&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java
(original)
+++ incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java
Thu Sep 13 06:35:48 2012
@@ -41,7 +41,7 @@ public class BigDecimalValueSemanticsPro
         return BigDecimalValueFacet.class;
     }
 
-    private static final int TYPICAL_LENGTH = 19;
+    private static final int TYPICAL_LENGTH = 8;
     private static final BigDecimal DEFAULT_VALUE = new BigDecimal(0);
 
     private final NumberFormat format;

Modified: incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/biginteger/BigIntegerValueSemanticsProvider.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/biginteger/BigIntegerValueSemanticsProvider.java?rev=1384216&r1=1384215&r2=1384216&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/biginteger/BigIntegerValueSemanticsProvider.java
(original)
+++ incubator/isis/trunk/framework/core/progmodel/src/main/java/org/apache/isis/core/progmodel/facets/value/biginteger/BigIntegerValueSemanticsProvider.java
Thu Sep 13 06:35:48 2012
@@ -35,7 +35,7 @@ import org.apache.isis.core.progmodel.fa
 
 public class BigIntegerValueSemanticsProvider extends ValueSemanticsProviderAndFacetAbstract<BigInteger>
implements BigIntegerValueFacet {
 
-    private static final int TYPICAL_LENGTH = 19;
+    private static final int TYPICAL_LENGTH = 8;
 
     private static Class<? extends Facet> type() {
         return BigIntegerValueFacet.class;

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java?rev=1384216&r1=1384215&r2=1384216&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
Thu Sep 13 06:35:48 2012
@@ -29,6 +29,7 @@ import org.apache.isis.applib.annotation
 import org.apache.isis.viewer.wicket.model.models.EntityModel.RenderingHint;
 import org.apache.isis.viewer.wicket.model.models.ScalarModel;
 import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelAbstract.Rendering;
+import org.apache.isis.viewer.wicket.ui.components.scalars.TextFieldValueModel.ScalarModelProvider;
 import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
 
 /**
@@ -39,7 +40,7 @@ import org.apache.isis.viewer.wicket.ui.
  * Supports the concept of being {@link Rendering#COMPACT} (eg within a table) or
  * {@link Rendering#REGULAR regular} (eg within a form).
  */
-public abstract class ScalarPanelAbstract extends PanelAbstract<ScalarModel> {
+public abstract class ScalarPanelAbstract extends PanelAbstract<ScalarModel> implements
ScalarModelProvider {
 
     private static final long serialVersionUID = 1L;
 

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java?rev=1384216&r1=1384215&r2=1384216&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
Thu Sep 13 06:35:48 2012
@@ -21,7 +21,6 @@ package org.apache.isis.viewer.wicket.ui
 
 import org.apache.wicket.AttributeModifier;
 import org.apache.wicket.Component;
-import org.apache.wicket.behavior.IBehavior;
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.form.AbstractTextComponent;
 import org.apache.wicket.markup.html.form.FormComponentLabel;
@@ -29,12 +28,9 @@ import org.apache.wicket.markup.html.for
 import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
 import org.apache.wicket.model.Model;
 
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facetapi.FacetProvider;
 import org.apache.isis.core.metamodel.facets.SingleIntValueFacet;
 import org.apache.isis.core.metamodel.facets.maxlen.MaxLengthFacet;
 import org.apache.isis.core.metamodel.facets.typicallen.TypicalLengthFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.viewer.wicket.model.models.ScalarModel;
 import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
 

Added: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/TextFieldValueModel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/TextFieldValueModel.java?rev=1384216&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/TextFieldValueModel.java
(added)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/TextFieldValueModel.java
Thu Sep 13 06:35:48 2012
@@ -0,0 +1,52 @@
+package org.apache.isis.viewer.wicket.ui.components.scalars;
+
+import java.io.Serializable;
+
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.Model;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.viewer.wicket.model.models.ScalarModel;
+
+/**
+ * For custom {@link ScalarPanelTextFieldAbstract}s to use as the {@link Model}
+ * of their {@link TextField} (as constructed in {@link ScalarPanelTextFieldAbstract#createTextField()}).
+ */
+public class TextFieldValueModel<T extends Serializable> extends Model<T> {
+    
+    private static final long serialVersionUID = 1L;
+    
+    public interface ScalarModelProvider {
+        ScalarModel getModel();
+        AdapterManager getAdapterManager();
+    }
+    
+    private final ScalarModelProvider scalarModelProvider;
+    
+    public TextFieldValueModel(ScalarModelProvider scalarModelProvider) {
+        this.scalarModelProvider = scalarModelProvider;
+    }
+
+    @Override
+    public T getObject() {
+        final ScalarModel model = scalarModelProvider.getModel();
+        final ObjectAdapter objectAdapter = model.getObject();
+        return asT(objectAdapter);
+    }
+
+    @SuppressWarnings("unchecked")
+    private T asT(final ObjectAdapter objectAdapter) {
+        return (T) (objectAdapter != null? objectAdapter.getObject(): null);
+    }
+
+    @Override
+    public void setObject(final T object) {
+        if (object == null) {
+            scalarModelProvider.getModel().setObject(null);
+        } else {
+            final ObjectAdapter objectAdapter = scalarModelProvider.getAdapterManager().adapterFor(object);
+            scalarModelProvider.getModel().setObject(objectAdapter);
+        }
+    }
+}
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigDecimalPanel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigDecimalPanel.java?rev=1384216&r1=1384215&r2=1384216&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigDecimalPanel.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigDecimalPanel.java
Thu Sep 13 06:35:48 2012
@@ -21,24 +21,33 @@ package org.apache.isis.viewer.wicket.ui
 
 import java.math.BigDecimal;
 
+import org.apache.wicket.markup.html.form.AbstractTextComponent;
+import org.apache.wicket.markup.html.form.TextField;
+
 import org.apache.isis.viewer.wicket.model.models.ScalarModel;
-import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelTextFieldParseableAbstract;
+import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelTextFieldAbstract;
+import org.apache.isis.viewer.wicket.ui.components.scalars.TextFieldValueModel;
 
 /**
  * Panel for rendering scalars of type {@link BigDecimal}.
  */
-public class JavaMathBigDecimalPanel extends ScalarPanelTextFieldParseableAbstract {
+public class JavaMathBigDecimalPanel extends ScalarPanelTextFieldAbstract<BigDecimal>
{
 
     private static final long serialVersionUID = 1L;
     private static final String ID_SCALAR_VALUE = "scalarValue";
 
     public JavaMathBigDecimalPanel(final String id, final ScalarModel scalarModel) {
-        super(id, ID_SCALAR_VALUE, scalarModel);
+        super(id, scalarModel);
     }
 
     @Override
     protected void addSemantics() {
         super.addSemantics();
+        
     }
 
+    @Override
+    protected AbstractTextComponent<BigDecimal> createTextField() {
+        return new TextField<BigDecimal>(ID_SCALAR_VALUE, new TextFieldValueModel<BigDecimal>(this),
BigDecimal.class);
+    }
 }

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigIntegerPanel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigIntegerPanel.java?rev=1384216&r1=1384215&r2=1384216&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigIntegerPanel.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/jdkmath/JavaMathBigIntegerPanel.java
Thu Sep 13 06:35:48 2012
@@ -20,20 +20,39 @@
 package org.apache.isis.viewer.wicket.ui.components.scalars.jdkmath;
 
 import java.math.BigInteger;
+import java.util.Locale;
+
+import org.apache.wicket.markup.html.form.AbstractTextComponent;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.util.convert.IConverter;
+import org.apache.wicket.util.convert.converters.AbstractIntegerConverter;
 
 import org.apache.isis.viewer.wicket.model.models.ScalarModel;
-import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelTextFieldParseableAbstract;
+import org.apache.isis.viewer.wicket.ui.components.scalars.ScalarPanelTextFieldAbstract;
+import org.apache.isis.viewer.wicket.ui.components.scalars.TextFieldValueModel;
 
 /**
  * Panel for rendering scalars of type {@link BigInteger}.
  */
-public class JavaMathBigIntegerPanel extends ScalarPanelTextFieldParseableAbstract {
+public class JavaMathBigIntegerPanel extends ScalarPanelTextFieldAbstract<BigInteger>
{
 
     private static final long serialVersionUID = 1L;
     private static final String ID_SCALAR_VALUE = "scalarValue";
+    
+    private static final IConverter CONVERTER = new AbstractIntegerConverter() {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public Object convertToObject(String value, Locale locale) {
+            return new BigInteger(value);
+        }
+        @Override
+        protected Class<?> getTargetType() {
+            return BigInteger.class;
+        }
+    };
 
     public JavaMathBigIntegerPanel(final String id, final ScalarModel scalarModel) {
-        super(id, ID_SCALAR_VALUE, scalarModel);
+        super(id, scalarModel);
     }
 
     @Override
@@ -41,4 +60,16 @@ public class JavaMathBigIntegerPanel ext
         super.addSemantics();
     }
 
+    @Override
+    protected AbstractTextComponent<BigInteger> createTextField() {
+        return new TextField<BigInteger>(ID_SCALAR_VALUE, new TextFieldValueModel<BigInteger>(this),
BigInteger.class) {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public IConverter getConverter(Class<?> type) {
+                return type == BigInteger.class? CONVERTER: super.getConverter(type);
+            }
+        };
+    }
+
 }

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css?rev=1384216&r1=1384215&r2=1384216&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css
Thu Sep 13 06:35:48 2012
@@ -249,16 +249,9 @@ fieldset.propertiesAndOrCollections {
 .even, .odd {
 	margin-left: 1em;
 	margin-right: 1em;
-}
-
-.even {
 	background-color: #ffffff; 
 }
 
-.odd {
-	/*background-color: #eeeeee;*/ 
-}
-
 
 .propertyOrCollection, .parameter {
 	clear: both;
@@ -315,4 +308,8 @@ div.scalarPanel {
 
 .mandatory {
 	font-weight: bold;
+}
+
+.number input {
+ 	text-align: right;
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java?rev=1384216&r1=1384215&r2=1384216&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/panels/PanelAbstract.java
Thu Sep 13 06:35:48 2012
@@ -84,7 +84,7 @@ public abstract class PanelAbstract<T ex
     }
 
     @SuppressWarnings("unchecked")
-    protected T getModel() {
+    public T getModel() {
         return (T) getDefaultModel();
     }
 
@@ -161,7 +161,7 @@ public abstract class PanelAbstract<T ex
         return IsisContext.getPersistenceSession();
     }
 
-    protected AdapterManager getAdapterManager() {
+    public AdapterManager getAdapterManager() {
         return IsisContext.getPersistenceSession().getAdapterManager();
     }
 



Mime
View raw message