You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2004/09/06 04:51:06 UTC
cvs commit: jakarta-commons/jelly/jelly-tags/swing project.xml
dion 2004/09/05 19:51:06
Modified: jelly/jelly-tags/swing/src/java/org/apache/commons/jelly/tags/swing/impl
GridBagConstraintBean.java
jelly/jelly-tags/swing/src/java/org/apache/commons/jelly/tags/swing
GbcTag.java
jelly/jelly-tags/swing project.xml
Log:
Apply Jelly-130, make GbcTag jdk 1.3 compliant
Revision Changes Path
1.7 +72 -12 jakarta-commons/jelly/jelly-tags/swing/src/java/org/apache/commons/jelly/tags/swing/impl/GridBagConstraintBean.java
Index: GridBagConstraintBean.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/swing/src/java/org/apache/commons/jelly/tags/swing/impl/GridBagConstraintBean.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GridBagConstraintBean.java 6 Sep 2004 00:41:07 -0000 1.6
+++ GridBagConstraintBean.java 6 Sep 2004 02:51:06 -0000 1.7
@@ -17,6 +17,10 @@
import java.awt.GridBagConstraints;
import java.awt.Insets;
+import java.lang.reflect.Field;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This class is a simple "bean-wrapper" for the {@link GridBagConstraints} class
@@ -28,16 +32,19 @@
*/
public class GridBagConstraintBean extends GridBagConstraints {
- private boolean gridxSet = false,
- gridySet = false,
- gridwidthSet = false,
- gridheightSet = false,
- weightxSet = false,
- weightySet = false,
- ipadxSet = false,
- ipadySet = false,
- anchorSet = false,
- fillSet = false;
+ private boolean gridxSet = false;
+ private boolean gridySet = false;
+ private boolean gridwidthSet = false;
+ private boolean gridheightSet = false;
+ private boolean weightxSet = false;
+ private boolean weightySet = false;
+ private boolean ipadxSet = false;
+ private boolean ipadySet = false;
+ private boolean anchorSet = false;
+ private boolean fillSet = false;
+
+ /** Logging output */
+ private static final Log LOG = LogFactory.getLog(GridBagConstraintBean.class);
public GridBagConstraintBean() {
}
@@ -139,9 +146,26 @@
return "west";
case NORTHWEST :
return "northwest";
- default :
- throw new IllegalArgumentException("Anchor must be one of the GridBagLayout constants: CENTER, NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, or NORTHWEST.");
}
+
+ if (this.anchor == getByReflection("LINE_START"))
+ return "line_start";
+ else if (this.anchor == getByReflection("LINE_END"))
+ return "line_end";
+ else if (this.anchor == getByReflection("PAGE_START"))
+ return "page_start";
+ else if (this.anchor == getByReflection("PAGE_END"))
+ return "page_end";
+ else if (this.anchor == getByReflection("FIRST_LINE_START"))
+ return "first_line_start";
+ else if (this.anchor == getByReflection("FIRST_LINE_END"))
+ return "first_line_end";
+ else if (this.anchor == getByReflection("LAST_LINE_START"))
+ return "last_line_start";
+ else if (this.anchor == getByReflection("LAST_LINE_END"))
+ return "last_line_end";
+
+ throw new IllegalArgumentException("Anchor must be one of the GridBagLayout constants: CENTER, NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, or NORTHWEST.");
}
/** Accepts one of the strings with the same name as the constants
@@ -170,6 +194,22 @@
this.anchor = WEST;
else if (lcAnchorString.equals("northwest"))
this.anchor = NORTHWEST;
+ else if (lcAnchorString.equals("page_start"))
+ this.anchor = getByReflection("PAGE_START");
+ else if (lcAnchorString.equals("page_end"))
+ this.anchor = getByReflection("PAGE_END");
+ else if (lcAnchorString.equals("line_start"))
+ this.anchor = getByReflection("LINE_START");
+ else if (lcAnchorString.equals("line_end"))
+ this.anchor = getByReflection("LINE_END");
+ else if (lcAnchorString.equals("first_line_start"))
+ this.anchor = getByReflection("FIRST_LINE_START");
+ else if (lcAnchorString.equals("first_line_end"))
+ this.anchor = getByReflection("FIRST_LINE_END");
+ else if (lcAnchorString.equals("last_line_end"))
+ this.anchor = getByReflection("LAST_LINE_END");
+ else if (lcAnchorString.equals("last_line_start"))
+ this.anchor = getByReflection("LAST_LINE_START");
else
throw new IllegalArgumentException("Anchor must be the name of one of the GridBagLayoutConstants (case doesn't matter): center, north, northeast, east, southeast, south, southwest, west, or northwest.");
this.anchorSet = true;
@@ -286,6 +326,26 @@
+ ", insets="
+ insets
+ "]";
+ }
+
+ private int getByReflection(String field) {
+ try {
+ Field f = getClass().getField(field);
+ Integer rv = (Integer) f.get(this);
+ return rv.intValue();
+ } catch (SecurityException e) {
+ LOG.debug(e);
+ throw new IllegalArgumentException("Anchor must be one of the GridBagLayout constants for the current Java version.");
+ } catch (NoSuchFieldException e) {
+ LOG.debug(e);
+ throw new IllegalArgumentException("Anchor must be one of the GridBagLayout constants for the current Java version.");
+ } catch (IllegalArgumentException e) {
+ LOG.debug(e);
+ throw new IllegalArgumentException("Anchor must be one of the GridBagLayout constants for the current Java version.");
+ } catch (IllegalAccessException e) {
+ LOG.debug(e);
+ throw new IllegalArgumentException("Anchor must be one of the GridBagLayout constants for the current Java version.");
+ }
}
} // class GridBagConstraintsBean
1.12 +3 -1 jakarta-commons/jelly/jelly-tags/swing/src/java/org/apache/commons/jelly/tags/swing/GbcTag.java
Index: GbcTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/swing/src/java/org/apache/commons/jelly/tags/swing/GbcTag.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- GbcTag.java 25 Feb 2004 01:31:56 -0000 1.11
+++ GbcTag.java 6 Sep 2004 02:51:06 -0000 1.12
@@ -26,6 +26,7 @@
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.tags.core.UseBeanTag;
import org.apache.commons.jelly.tags.swing.impl.GridBagConstraintBean;
+import org.apache.commons.lang.StringUtils;
/**
* This class represents a {@link GridBagConstraints} constraints as passed in
@@ -117,7 +118,8 @@
if (insetString instanceof String) {
attributes.remove("insets");
- String[] parts = ((String) insetString).split(",");
+
+ String[] parts = StringUtils.split((String) insetString, ",");
if (parts.length != 4) {
throw new JellyTagException(
1.14 +6 -0 jakarta-commons/jelly/jelly-tags/swing/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/swing/project.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- project.xml 11 Aug 2004 02:27:20 -0000 1.13
+++ project.xml 6 Sep 2004 02:51:06 -0000 1.14
@@ -45,6 +45,12 @@
<version>SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.0</version>
+ </dependency>
+
<!-- START for test -->
<dependency>
<groupId>commons-jelly</groupId>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org