myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1702519 - in /myfaces/tobago/branches/tobago-3.0.x: tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ tobago-core/src/main/java/org/apache...
Date Fri, 11 Sep 2015 17:27:25 GMT
Author: lofwyr
Date: Fri Sep 11 17:27:24 2015
New Revision: 1702519

URL: http://svn.apache.org/r1702519
Log:
TOBAGO-1489: Optimize enums used for attributes in taglib.
* OrderBy

Added:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/OrderBy.java
Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIMessages.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/MessagesTagDeclaration.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIMessages.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIMessages.java?rev=1702519&r1=1702518&r2=1702519&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIMessages.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIMessages.java
Fri Sep 11 17:27:24 2015
@@ -21,6 +21,7 @@ package org.apache.myfaces.tobago.intern
 
 import org.apache.commons.collections.iterators.SingletonIterator;
 import org.apache.myfaces.tobago.layout.LayoutComponent;
+import org.apache.myfaces.tobago.layout.OrderBy;
 
 import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
@@ -47,7 +48,7 @@ public abstract class AbstractUIMessages
     final List<Item> messages = collectMessageList(facesContext, clientIds);
 
     // todo
-    if (OrderBy.SEVERITY.equals(getOrderBy())) {
+    if (OrderBy.severity == getOrderBy()) {
       // sort
       Collections.sort(messages, new ItemComparator());
     }
@@ -121,16 +122,4 @@ public abstract class AbstractUIMessages
   public abstract String getFor();
 */
 
-  public static enum OrderBy {
-
-    OCCURRENCE,
-    SEVERITY;
-
-    public static final String OCCURRENCE_STRING = "occurrence";
-    public static final String SEVERITY_STRING = "severity";
-
-    public static OrderBy parse(final String key) {
-      return valueOf(key.toUpperCase());
-    }
-  }
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/MessagesTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/MessagesTagDeclaration.java?rev=1702519&r1=1702518&r2=1702519&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/MessagesTagDeclaration.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/MessagesTagDeclaration.java
Fri Sep 11 17:27:24 2015
@@ -24,12 +24,12 @@ import org.apache.myfaces.tobago.apt.ann
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
 import org.apache.myfaces.tobago.component.RendererTypes;
-import org.apache.myfaces.tobago.internal.component.AbstractUIMessages;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasCurrentMarkup;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasFor;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasMarkup;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsGridLayoutComponent;
+import org.apache.myfaces.tobago.layout.OrderBy;
 
 import javax.faces.component.UIMessages;
 
@@ -99,10 +99,10 @@ public interface MessagesTagDeclaration
    * Sets the order of the messages.
    */
   @TagAttribute
-  @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.component.UIMessages$OrderBy",
-      allowedValues = {AbstractUIMessages.OrderBy.OCCURRENCE_STRING, AbstractUIMessages.OrderBy.SEVERITY_STRING},
-      defaultValue = AbstractUIMessages.OrderBy.OCCURRENCE_STRING, 
-      defaultCode = "org.apache.myfaces.tobago.internal.component.AbstractUIMessages.OrderBy.OCCURRENCE")
+  @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.OrderBy",
+      allowedValues = {OrderBy.STRING_OCCURRENCE, OrderBy.STRING_SEVERITY},
+      defaultValue = OrderBy.STRING_OCCURRENCE,
+      defaultCode = "org.apache.myfaces.tobago.layout.OrderBy.occurrence")
   void setOrderBy(String orderBy);
 
   /**

Added: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/OrderBy.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/OrderBy.java?rev=1702519&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/OrderBy.java
(added)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/OrderBy.java
Fri Sep 11 17:27:24 2015
@@ -0,0 +1,31 @@
+/*
+ * 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.myfaces.tobago.layout;
+
+public enum OrderBy {
+
+  occurrence,
+  severity;
+
+  public static final String STRING_OCCURRENCE = "occurrence";
+
+  public static final String STRING_SEVERITY = "severity";
+
+}

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java?rev=1702519&r1=1702518&r2=1702519&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/component/UIMessagesUnitTest.java
Fri Sep 11 17:27:24 2015
@@ -20,6 +20,7 @@
 package org.apache.myfaces.tobago.component;
 
 import org.apache.myfaces.tobago.internal.config.AbstractTobagoTestBase;
+import org.apache.myfaces.tobago.layout.OrderBy;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -119,7 +120,7 @@ public class UIMessagesUnitTest extends
   public void testCreateMessageListOrderBySeverity() {
 
     final UIMessages component = new UIMessages();
-    component.setOrderBy(UIMessages.OrderBy.SEVERITY);
+    component.setOrderBy(OrderBy.severity);
     final List<UIMessages.Item> messages = component.createMessageList(getFacesContext());
 
     int mustShrink = FacesMessage.SEVERITY_FATAL.getOrdinal();
@@ -129,12 +130,4 @@ public class UIMessagesUnitTest extends
       mustShrink = newValue;
     }
   }
-
-  @Test
-  public void testOrderByEnum() {
-    Assert.assertEquals(2, UIMessages.OrderBy.values().length);
-    Assert.assertEquals(UIMessages.OrderBy.OCCURRENCE, UIMessages.OrderBy.parse(UIMessages.OrderBy.OCCURRENCE_STRING));
-    Assert.assertEquals(UIMessages.OrderBy.SEVERITY, UIMessages.OrderBy.parse(UIMessages.OrderBy.SEVERITY_STRING));
-  }
-
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml?rev=1702519&r1=1702518&r2=1702519&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml
Fri Sep 11 17:27:24 2015
@@ -45,7 +45,7 @@
 
         <tc:flexLayout rows="auto;*;auto">
 
-          <tc:messages orderBy="SEVERITY"/>
+          <tc:messages orderBy="severity"/>
 
           <tc:box label="#{title}" id="content">
             <ui:insert/>



Mime
View raw message