You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jb...@apache.org on 2007/06/25 17:27:42 UTC
svn commit: r550526 - in
/incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette:
Palette.java component/AbstractOptions.java
Author: jbq
Date: Mon Jun 25 08:27:40 2007
New Revision: 550526
URL: http://svn.apache.org/viewvc?view=rev&rev=550526
Log:
WICKET-636: use more generic Map instead of HashMap, and reindent
Modified:
incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java
incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java
Modified: incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java?view=diff&rev=550526&r1=550525&r2=550526
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/Palette.java Mon Jun 25 08:27:40 2007
@@ -17,8 +17,8 @@
package org.apache.wicket.extensions.markup.html.form.palette;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.apache.wicket.Component;
import org.apache.wicket.ResourceReference;
@@ -51,9 +51,9 @@
* Example:
*
* <pre>
- * Form form=new Form(...);
- * Palette palette=new Palette(...);
- * palette.getRecorderComponent().add(new AjaxFormComponentUpdatingBehavior("onchange") {...});
+ * Form form=new Form(...);
+ * Palette palette=new Palette(...);
+ * palette.getRecorderComponent().add(new AjaxFormComponentUpdatingBehavior("onchange") {...});
* </pre>
*
* @author Igor Vaynberg ( ivaynberg )
@@ -367,22 +367,25 @@
*/
protected Component newSelectionComponent()
{
- return new Selection("selection", this) {
+ return new Selection("selection", this)
+ {
private static final long serialVersionUID = 1L;
- protected HashMap getAdditionalAttributes(Object choice) {
- return Palette.this.getAdditionalAttributesForSelection(choice);
- }
- };
+ protected Map getAdditionalAttributes(Object choice)
+ {
+ return Palette.this.getAdditionalAttributesForSelection(choice);
+ }
+ };
+ }
+
+ /**
+ * @see wicket.extensions.markup.html.form.palette.component#getAdditionalAttributes()
+ */
+ protected Map getAdditionalAttributesForSelection(Object choice)
+ {
+ return null;
}
- /**
- * @see wicket.extensions.markup.html.form.palette.component#getAdditionalAttributes()
- */
- protected HashMap getAdditionalAttributesForSelection(Object choice) {
- return null;
- }
-
/**
* factory method for the available items component
*
@@ -390,22 +393,25 @@
*/
protected Component newChoicesComponent()
{
- return new Choices("choices", this) {
+ return new Choices("choices", this)
+ {
private static final long serialVersionUID = 1L;
- protected HashMap getAdditionalAttributes(Object choice) {
- return Palette.this.getAdditionalAttributesForChoices(choice);
- }
- };
+ protected Map getAdditionalAttributes(Object choice)
+ {
+ return Palette.this.getAdditionalAttributesForChoices(choice);
+ }
+ };
+ }
+
+ /**
+ * @see wicket.extensions.markup.html.form.palette.component#getAdditionalAttributes()
+ */
+ protected Map getAdditionalAttributesForChoices(Object choice)
+ {
+ return null;
}
- /**
- * @see wicket.extensions.markup.html.form.palette.component#getAdditionalAttributes()
- */
- protected HashMap getAdditionalAttributesForChoices(Object choice) {
- return null;
- }
-
private Component getChoicesComponent()
{
return choicesComponent;
Modified: incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java?view=diff&rev=550526&r1=550525&r2=550526
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java Mon Jun 25 08:27:40 2007
@@ -16,8 +16,8 @@
*/
package org.apache.wicket.extensions.markup.html.form.palette.component;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.apache.wicket.extensions.markup.html.form.palette.Palette;
import org.apache.wicket.markup.ComponentTag;
@@ -60,7 +60,7 @@
protected abstract Iterator getOptionsIterator();
-
+
protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
{
final AppendingStringBuffer buffer = new AppendingStringBuffer(128);
@@ -76,23 +76,28 @@
String value = getConverter(displayClass).convertToString(displayValue, getLocale());
value = getLocalizer().getString(id + "." + value, this, value);
- // A piece of javascript to avoid serializing this during AJAX serialization.
- buffer.append(JavascriptUtils.SCRIPT_OPEN_TAG +
- "if (typeof(Wicket) != \"undefined\" && typeof(Wicket.Form) != \"undefined\")" +
- " Wicket.Form.excludeFromAjaxSerialization." + this.getMarkupId() + "='true';" +
- JavascriptUtils.SCRIPT_CLOSE_TAG);
-
- buffer.append("\n<option value=\"").append(id).append("\"");
-
- HashMap additionalAttributesMap = getAdditionalAttributes(choice);
- if(additionalAttributesMap != null) {
- Iterator iter = additionalAttributesMap.keySet().iterator();
- while(iter.hasNext()) {
- String next = (String)iter.next();
- buffer.append(" " + next.toString() + "=\"" + additionalAttributesMap.get(next).toString() + "\"");
- }
- }
-
+ // A piece of javascript to avoid serializing this during AJAX
+ // serialization.
+ buffer
+ .append(JavascriptUtils.SCRIPT_OPEN_TAG
+ + "if (typeof(Wicket) != \"undefined\" && typeof(Wicket.Form) != \"undefined\")"
+ + " Wicket.Form.excludeFromAjaxSerialization." + this.getMarkupId()
+ + "='true';" + JavascriptUtils.SCRIPT_CLOSE_TAG);
+
+ buffer.append("\n<option value=\"").append(id).append("\"");
+
+ Map additionalAttributesMap = getAdditionalAttributes(choice);
+ if (additionalAttributesMap != null)
+ {
+ Iterator iter = additionalAttributesMap.keySet().iterator();
+ while (iter.hasNext())
+ {
+ String next = (String)iter.next();
+ buffer.append(" " + next.toString() + "=\""
+ + additionalAttributesMap.get(next).toString() + "\"");
+ }
+ }
+
buffer.append(">").append(value).append("</option>");
}
@@ -101,13 +106,14 @@
replaceComponentTagBody(markupStream, openTag, buffer);
}
- /**
- * @return map of attribute/value pairs (String/String)
- */
- protected HashMap getAdditionalAttributes(Object choice) {
- return null;
- }
-
+ /**
+ * @return map of attribute/value pairs (String/String)
+ */
+ protected Map getAdditionalAttributes(Object choice)
+ {
+ return null;
+ }
+
/**
*
* @param tag
@@ -122,8 +128,9 @@
attrs.put("multiple", null);
attrs.put("size", new Integer(getPalette().getRows()));
- if (!palette.isPaletteEnabled()) {
- attrs.put("disabled","disabled");
+ if (!palette.isPaletteEnabled())
+ {
+ attrs.put("disabled", "disabled");
}
}