You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2015/10/16 15:09:54 UTC
svn commit: r1708984 - in /myfaces/tobago/branches/tobago-3.0.x:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/
tobago-core/src/main/java/o...
Author: lofwyr
Date: Fri Oct 16 13:09:54 2015
New Revision: 1708984
URL: http://svn.apache.org/viewvc?rev=1708984&view=rev
Log:
TOBAGO-1489: Refactoring: using enums (also for attributes in taglib)
Added:
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/ShowPosition.java
Modified:
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasSanitize.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Selectable.java
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/SheetConfig.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.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/SheetTagDeclaration.java?rev=1708984&r1=1708983&r2=1708984&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SheetTagDeclaration.java Fri Oct 16 13:09:54 2015
@@ -34,6 +34,7 @@ import org.apache.myfaces.tobago.interna
import org.apache.myfaces.tobago.internal.taglib.declaration.IsShowRoot;
import org.apache.myfaces.tobago.internal.taglib.declaration.IsShowRootJunction;
import org.apache.myfaces.tobago.internal.taglib.declaration.IsVisual;
+import org.apache.myfaces.tobago.layout.ShowPosition;
import org.apache.myfaces.tobago.model.Selectable;
import javax.faces.component.UIData;
@@ -146,8 +147,13 @@ public interface SheetTagDeclaration
* rendered in the sheet's footer.
*/
@TagAttribute
- @UIComponentTagAttribute(defaultValue = "center",
- allowedValues = {"left", "center", "right", "none"})
+ @UIComponentTagAttribute(
+ type = "org.apache.myfaces.tobago.layout.ShowPosition",
+ defaultValue = ShowPosition.STRING_CENTER,
+ allowedValues = {
+ ShowPosition.STRING_LEFT, ShowPosition.STRING_CENTER, ShowPosition.STRING_RIGHT, ShowPosition.STRING_NONE
+ },
+ defaultCode = "org.apache.myfaces.tobago.layout.ShowPosition.center")
void setShowDirectLinks(String showDirectLinks);
/**
@@ -156,8 +162,13 @@ public interface SheetTagDeclaration
* capability to enter the index displayed page directly.
*/
@TagAttribute
- @UIComponentTagAttribute(defaultValue = "right",
- allowedValues = {"left", "center", "right", "none"})
+ @UIComponentTagAttribute(
+ type = "org.apache.myfaces.tobago.layout.ShowPosition",
+ defaultValue = ShowPosition.STRING_RIGHT,
+ allowedValues = {
+ ShowPosition.STRING_LEFT, ShowPosition.STRING_CENTER, ShowPosition.STRING_RIGHT, ShowPosition.STRING_NONE
+ },
+ defaultCode = "org.apache.myfaces.tobago.layout.ShowPosition.right")
void setShowPageRange(String showPageRange);
/**
@@ -166,8 +177,13 @@ public interface SheetTagDeclaration
* capability to enter the index of the start row directly.
*/
@TagAttribute
- @UIComponentTagAttribute(defaultValue = "left",
- allowedValues = {"left", "center", "right", "none"})
+ @UIComponentTagAttribute(
+ type = "org.apache.myfaces.tobago.layout.ShowPosition",
+ defaultValue = ShowPosition.STRING_LEFT,
+ allowedValues = {
+ ShowPosition.STRING_LEFT, ShowPosition.STRING_CENTER, ShowPosition.STRING_RIGHT, ShowPosition.STRING_NONE
+ },
+ defaultCode = "org.apache.myfaces.tobago.layout.ShowPosition.left")
void setShowRowRange(String showRowRange);
/**
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasSanitize.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/declaration/HasSanitize.java?rev=1708984&r1=1708983&r2=1708984&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasSanitize.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/HasSanitize.java Fri Oct 16 13:09:54 2015
@@ -35,7 +35,10 @@ public interface HasSanitize {
* because that are the critical parts.
*/
@TagAttribute
- @UIComponentTagAttribute(defaultValue = SanitizeMode.STRING_AUTO,
- allowedValues = {SanitizeMode.STRING_AUTO, SanitizeMode.STRING_NEVER})
+ @UIComponentTagAttribute(
+ type = "org.apache.myfaces.tobago.sanitizer.SanitizeMode",
+ defaultValue = SanitizeMode.STRING_AUTO,
+ allowedValues = {SanitizeMode.STRING_AUTO, SanitizeMode.STRING_NEVER},
+ defaultCode = "org.apache.myfaces.tobago.sanitizer.SanitizeMode.auto")
void setSanitize(String sanitize);
}
Added: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/ShowPosition.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/ShowPosition.java?rev=1708984&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/ShowPosition.java (added)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/ShowPosition.java Fri Oct 16 13:09:54 2015
@@ -0,0 +1,33 @@
+/*
+ * 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 ShowPosition {
+
+ left,
+ center,
+ right,
+ none;
+
+ public static final String STRING_LEFT = "left";
+ public static final String STRING_CENTER = "center";
+ public static final String STRING_RIGHT = "right";
+ public static final String STRING_NONE = "none";
+}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Selectable.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Selectable.java?rev=1708984&r1=1708983&r2=1708984&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Selectable.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/model/Selectable.java Fri Oct 16 13:09:54 2015
@@ -126,13 +126,13 @@ public enum Selectable {
public static final String STRING_MULTI_CASCADE = "multiCascade";
- private static final Set<Selectable> SHEET_VALUES = EnumSet.of(
+ public static final Set<Selectable> SHEET_VALUES = EnumSet.of(
none,
multi,
single,
singleOrNone);
- private static final Set<Selectable> TREE_VALUES = EnumSet.of(
+ public static final Set<Selectable> TREE_VALUES = EnumSet.of(
none,
multi,
single,
@@ -140,7 +140,7 @@ public enum Selectable {
singleLeafOnly,
multiCascade);
- private static final Set<Selectable> TREE_LISTBOX_VALUES = EnumSet.of(
+ public static final Set<Selectable> TREE_LISTBOX_VALUES = EnumSet.of(
single,
singleLeafOnly,
multiLeafOnly);
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/SheetConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/SheetConfig.java?rev=1708984&r1=1708983&r2=1708984&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/SheetConfig.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/SheetConfig.java Fri Oct 16 13:09:54 2015
@@ -19,36 +19,25 @@
package org.apache.myfaces.tobago.example.demo.overview;
+import org.apache.myfaces.tobago.layout.ShowPosition;
+import org.apache.myfaces.tobago.model.Selectable;
+
import javax.faces.model.SelectItem;
public class SheetConfig {
- private static final String[] SHEET_PAGER_POSITION_KEYS = {
- "none",
- "left",
- "center",
- "right"
- };
-
- private static final String[] SHEET_SELECTABLE_KEYS = {
- "none",
- "single",
- "singleOrNone",
- "multi"
- };
-
private boolean sheetShowHeader;
private boolean showPagingAlways;
private int sheetFirst;
private int sheetRows;
private int sheetDirectLinkCount;
- private String sheetRowPagingPosition;
- private String sheetDirectPagingPosition;
- private String sheetPagePagingPosition;
+ private ShowPosition sheetRowPagingPosition;
+ private ShowPosition sheetDirectPagingPosition;
+ private ShowPosition sheetPagePagingPosition;
private SelectItem[] sheetDirectLinkCountItems;
private SelectItem[] sheetPagingPositionItems;
private SelectItem[] sheetSelectableItems;
- private String selectable;
+ private Selectable selectable;
private boolean showDirectLinksArrows;
private boolean showPageRangeArrows;
private boolean sheetConfigPopup;
@@ -60,12 +49,12 @@ public class SheetConfig {
sheetDirectLinkCountItems = createSheetItems(new Integer[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15});
sheetShowHeader = true;
showPagingAlways = false;
- sheetRowPagingPosition = SHEET_PAGER_POSITION_KEYS[1];
- sheetDirectPagingPosition = SHEET_PAGER_POSITION_KEYS[2];
- sheetPagePagingPosition = SHEET_PAGER_POSITION_KEYS[3];
- sheetPagingPositionItems = createSheetItems(SHEET_PAGER_POSITION_KEYS);
- sheetSelectableItems = createSheetItems(SHEET_SELECTABLE_KEYS);
- selectable = SHEET_SELECTABLE_KEYS[2];
+ sheetRowPagingPosition = ShowPosition.left;
+ sheetDirectPagingPosition = ShowPosition.center;
+ sheetPagePagingPosition = ShowPosition.right;
+ sheetPagingPositionItems = createSheetItems(ShowPosition.values());
+ sheetSelectableItems = createSheetItems(Selectable.SHEET_VALUES.toArray());
+ selectable = Selectable.singleOrNone;
showDirectLinksArrows = false;
showPageRangeArrows = true;
}
@@ -142,27 +131,27 @@ public class SheetConfig {
return sheetDirectLinkCountItems;
}
- public String getSheetRowPagingPosition() {
+ public ShowPosition getSheetRowPagingPosition() {
return sheetRowPagingPosition;
}
- public void setSheetRowPagingPosition(final String sheetRowPagingPosition) {
+ public void setSheetRowPagingPosition(final ShowPosition sheetRowPagingPosition) {
this.sheetRowPagingPosition = sheetRowPagingPosition;
}
- public String getSheetDirectPagingPosition() {
+ public ShowPosition getSheetDirectPagingPosition() {
return sheetDirectPagingPosition;
}
- public void setSheetDirectPagingPosition(final String sheetDirectPagingPosition) {
+ public void setSheetDirectPagingPosition(final ShowPosition sheetDirectPagingPosition) {
this.sheetDirectPagingPosition = sheetDirectPagingPosition;
}
- public String getSheetPagePagingPosition() {
+ public ShowPosition getSheetPagePagingPosition() {
return sheetPagePagingPosition;
}
- public void setSheetPagePagingPosition(final String sheetPagePagingPosition) {
+ public void setSheetPagePagingPosition(final ShowPosition sheetPagePagingPosition) {
this.sheetPagePagingPosition = sheetPagePagingPosition;
}
@@ -178,11 +167,11 @@ public class SheetConfig {
this.sheetSelectableItems = sheetSelectableItems;
}
- public String getSelectable() {
+ public Selectable getSelectable() {
return selectable;
}
- public void setSelectable(final String selectable) {
+ public void setSelectable(final Selectable selectable) {
this.selectable = selectable;
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java?rev=1708984&r1=1708983&r2=1708984&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java Fri Oct 16 13:09:54 2015
@@ -48,6 +48,7 @@ import org.apache.myfaces.tobago.interna
import org.apache.myfaces.tobago.internal.util.StringUtils;
import org.apache.myfaces.tobago.layout.Display;
import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.layout.ShowPosition;
import org.apache.myfaces.tobago.layout.TextAlign;
import org.apache.myfaces.tobago.model.ExpandedState;
import org.apache.myfaces.tobago.model.Selectable;
@@ -677,17 +678,17 @@ public class SheetRenderer extends Rende
RenderUtils.decodedStateOfTreeData(facesContext, sheet);
}
- private Markup markupForLeftCenterRight(final String name) {
- if ("left".equals(name)) {
- return Markup.LEFT;
+ private Markup markupForLeftCenterRight(final ShowPosition position) {
+ switch (position) {
+ case left:
+ return Markup.LEFT;
+ case center:
+ return Markup.CENTER;
+ case right:
+ return Markup.RIGHT;
+ default:
+ return Markup.NULL;
}
- if ("center".equals(name)) {
- return Markup.CENTER;
- }
- if ("right".equals(name)) {
- return Markup.RIGHT;
- }
- return Markup.NULL;
}
private String checkPagingAttribute(final String name) {
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg?rev=1708984&r1=1708983&r2=1708984&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg Fri Oct 16 13:09:54 2015
@@ -326,6 +326,14 @@ OverflowProperty(property) ::= <<
<NormalProperty(property)>
>>
+SanitizeModeProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
+ShowPositionProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
StyleProperty(property) ::= <<
<NormalProperty(property)>
>>