Revision: 7433
Author: [email protected]
Date: Tue Jan 19 13:57:56 2010
Log: Merges tr...@7432 into releases/2.0
  IntPairAttributeParser now actually parses
svn merge --ignore-ancestry -c 7432 http://google-web-toolkit.googlecode.com/svn/trunk .


http://code.google.com/p/google-web-toolkit/source/detail?r=7433

Added:
/releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/IntPairAttributeParser.java /releases/2.0/user/test/com/google/gwt/uibinder/attributeparsers/IntPairAttributeParserTest.java
Deleted:
/releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/IntPairParser.java
Modified:
 /releases/2.0/branch-info.txt
/releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/AttributeParsers.java /releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/LengthAttributeParser.java
 /releases/2.0/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java
/releases/2.0/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java /releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java /releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml

=======================================
--- /dev/null
+++ /releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/IntPairAttributeParser.java Tue Jan 19 13:57:56 2010
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.uibinder.attributeparsers;
+
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.uibinder.rebind.MortalLogger;
+
+/**
+ * Parses a pair of integer values.
+ */
+class IntPairAttributeParser implements AttributeParser {
+
+  private final IntAttributeParser intParser;
+  private final MortalLogger logger;
+
+ IntPairAttributeParser(IntAttributeParser intParser, MortalLogger logger) {
+    this.intParser = intParser;
+    this.logger = logger;
+  }
+
+  public String parse(String value) throws UnableToCompleteException {
+    String[] values = value.split(",");
+    if (values.length != 2) {
+      die(value);
+    }
+
+    String left = intParser.parse(values[0].trim());
+    String right = intParser.parse(values[1].trim());
+    return String.format("%s, %s", left, right);
+  }
+
+  private void die(String value) throws UnableToCompleteException {
+    logger.die("Unable to parse \"%s\" as a pair of integers", value);
+  }
+}
=======================================
--- /dev/null
+++ /releases/2.0/user/test/com/google/gwt/uibinder/attributeparsers/IntPairAttributeParserTest.java Tue Jan 19 13:57:56 2010
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.uibinder.attributeparsers;
+
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.core.ext.typeinfo.TypeOracle;
+import com.google.gwt.dev.javac.CompilationState;
+import com.google.gwt.dev.javac.CompilationStateBuilder;
+import com.google.gwt.uibinder.rebind.MortalLogger;
+import com.google.gwt.uibinder.test.UiJavaResources;
+
+import junit.framework.TestCase;
+
+/**
+ * Eponymous test class.
+ */
+public class IntPairAttributeParserTest extends TestCase {
+  private IntPairAttributeParser parser;
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+
+    MortalLogger logger = MortalLogger.NULL;
+
+    CompilationState state = CompilationStateBuilder.buildFrom(
+        logger.getTreeLogger(), UiJavaResources.getUiResources());
+    TypeOracle types = state.getTypeOracle();
+
+    FieldReferenceConverter converter = new FieldReferenceConverter(null);
+    IntAttributeParser intParser = new IntAttributeParser(converter,
+        types.parse("int"), logger);
+
+    parser = new IntPairAttributeParser(intParser, logger);
+  }
+
+  public void testGood() throws UnableToCompleteException {
+    assertEquals("1, 1", parser.parse("1, 1"));
+    assertEquals("123, 456", parser.parse("123, 456"));
+    assertEquals("(int)able.baker(), (int)charlie.delta()",
+        parser.parse("{able.baker}, {charlie.delta}"));
+    assertEquals("0001, 0002", parser.parse("0001, 0002"));
+  }
+
+  public void testBad() {
+    try {
+      parser.parse("fnord");
+      fail("Expected UnableToCompleteException");
+    } catch (UnableToCompleteException e) {
+      /* pass */
+    }
+
+    try {
+      parser.parse("1, 2, 3");
+      fail("Expected UnableToCompleteException");
+    } catch (UnableToCompleteException e) {
+      /* pass */
+    }
+
+    try {
+      parser.parse("1");
+      fail("Expected UnableToCompleteException");
+    } catch (UnableToCompleteException e) {
+      /* pass */
+    }
+
+    try {
+      parser.parse("1.2, 3.4");
+      fail("Expected UnableToCompleteException");
+    } catch (UnableToCompleteException e) {
+      /* pass */
+    }
+  }
+}
=======================================
--- /releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/IntPairParser.java Wed Nov 11 22:32:37 2009
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * Licensed 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 com.google.gwt.uibinder.attributeparsers;
-
-
-/**
- * Parses a pair of integer values.
- */
-class IntPairParser implements AttributeParser {
-
-  public String parse(String value) {
-    // TODO(jgw): parse & validate
-    return value;
-  }
-}
=======================================
--- /releases/2.0/branch-info.txt       Tue Jan 19 07:30:50 2010
+++ /releases/2.0/branch-info.txt       Tue Jan 19 13:57:56 2010
@@ -1271,3 +1271,6 @@
Add @defs to interfaces created by the CssResource InterfaceGenerator utility class. svn merge -c 7402 --ignore-ancestry https://google-web-toolkit.googlecode.com/svn/trunk

+tr...@7432 was merged into this branch
+  IntPairAttributeParser now actually parses
+ svn merge --ignore-ancestry -c 7432 http://google-web-toolkit.googlecode.com/svn/trunk .
=======================================
--- /releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/AttributeParsers.java Thu Nov 19 13:02:01 2009 +++ /releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/AttributeParsers.java Tue Jan 19 13:57:56 2010
@@ -69,7 +69,7 @@
       addAttributeParser(DOUBLE, doubleParser);
       addAttributeParser(Double.class.getCanonicalName(), doubleParser);

-      addAttributeParser("int,int", new IntPairParser());
+ addAttributeParser("int,int", new IntPairAttributeParser(intParser, logger));

addAttributeParser(HORIZ_CONSTANT, new HorizontalAlignmentConstantParser(
           converter, types.parse(HORIZ_CONSTANT), logger));
=======================================
--- /releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/LengthAttributeParser.java Thu Nov 19 13:02:01 2009 +++ /releases/2.0/user/src/com/google/gwt/uibinder/attributeparsers/LengthAttributeParser.java Tue Jan 19 13:57:56 2010
@@ -39,7 +39,7 @@
   private final DoubleAttributeParser doubleParser;
   private final EnumAttributeParser enumParser;

-  public LengthAttributeParser(DoubleAttributeParser doubleParser,
+  LengthAttributeParser(DoubleAttributeParser doubleParser,
       EnumAttributeParser enumParser, MortalLogger logger) {
     this.doubleParser = doubleParser;
     this.enumParser = enumParser;
=======================================
--- /releases/2.0/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java Fri Jan 15 17:06:54 2010 +++ /releases/2.0/user/test/com/google/gwt/uibinder/UiBinderJreSuite.java Tue Jan 19 13:57:56 2010
@@ -18,6 +18,7 @@
 import com.google.gwt.uibinder.attributeparsers.CssNameConverterTest;
import com.google.gwt.uibinder.attributeparsers.FieldReferenceConverterTest;
 import com.google.gwt.uibinder.attributeparsers.IntAttributeParserTest;
+import com.google.gwt.uibinder.attributeparsers.IntPairAttributeParserTest;
 import com.google.gwt.uibinder.attributeparsers.LengthAttributeParserTest;
 import com.google.gwt.uibinder.attributeparsers.StrictAttributeParserTest;
 import com.google.gwt.uibinder.attributeparsers.StringAttributeParserTest;
@@ -63,6 +64,7 @@
     // attributeparsers
     suite.addTestSuite(CssNameConverterTest.class);
     suite.addTestSuite(IntAttributeParserTest.class);
+    suite.addTestSuite(IntPairAttributeParserTest.class);
     suite.addTestSuite(FieldReferenceConverterTest.class);
     suite.addTestSuite(StrictAttributeParserTest.class);
     suite.addTestSuite(StringAttributeParserTest.class);
=======================================
--- /releases/2.0/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java Fri Jan 15 17:06:54 2010 +++ /releases/2.0/user/test/com/google/gwt/uibinder/test/client/UiBinderTest.java Tue Jan 19 13:57:56 2010
@@ -444,6 +444,11 @@
     assertEquals("expected style name", widget.getStyleName());
   }

+  public void testIntPair() {
+    assertEquals(100, widgetUi.sideBarWidget.getOffsetWidth());
+    assertEquals(150, widgetUi.sideBarWidget.getOffsetHeight());
+  }
+
   public void testDataResource() {
     assertNotNull(widgetUi.heartCursorResource.getUrl());
   }
=======================================
--- /releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java Fri Jan 15 17:06:54 2010 +++ /releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.java Tue Jan 19 13:57:56 2010
@@ -100,6 +100,7 @@
   @UiField Tree myTree;
   @UiField Element nonStandardElement;
   @UiField DockPanel root;
+  @UiField Widget sideBarWidget;
   @UiField DivElement sideBar;
   @UiField SpanElement spanInMsg;
   @UiField Element tmElement;
=======================================
--- /releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml Fri Jan 15 17:06:54 2010 +++ /releases/2.0/user/test/com/google/gwt/uibinder/test/client/WidgetBasedUi.ui.xml Tue Jan 19 13:57:56 2010
@@ -152,7 +152,7 @@
     </gwt:HTML>
   </gwt:Dock>
   <gwt:Dock direction='WEST'>
-    <gwt:HTML>
+    <gwt:HTML ui:field='sideBarWidget' pixelSize="100, 150">
       <div ui:field="sideBar"
       style='border: 4px solid gray; padding: 4px; margin: 4px;'
       >This could<br/>
-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to