aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/ui/CustomLayout.java
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2007-11-19 14:03:05 +0000
committerMarc Englund <marc.englund@itmill.com>2007-11-19 14:03:05 +0000
commitf2e3722df9676436680afc0f1991e91e1696fb99 (patch)
tree6f255ff78abaf96f1e71a1f2c9ecd3b66647f4a2 /src/com/itmill/toolkit/ui/CustomLayout.java
parent93291f532db9d545cf2a8dd98e2671f27cd197b0 (diff)
downloadvaadin-framework-f2e3722df9676436680afc0f1991e91e1696fb99.tar.gz
vaadin-framework-f2e3722df9676436680afc0f1991e91e1696fb99.zip
MASS REFORMAT.
According to http://toolkit.intra.itmill.com/trac/itmilltoolkit/wiki/CodingConventions svn changeset:2864/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/ui/CustomLayout.java')
-rw-r--r--src/com/itmill/toolkit/ui/CustomLayout.java383
1 files changed, 193 insertions, 190 deletions
diff --git a/src/com/itmill/toolkit/ui/CustomLayout.java b/src/com/itmill/toolkit/ui/CustomLayout.java
index 6eb165cb4c..283c1edf19 100644
--- a/src/com/itmill/toolkit/ui/CustomLayout.java
+++ b/src/com/itmill/toolkit/ui/CustomLayout.java
@@ -63,214 +63,217 @@ import com.itmill.toolkit.terminal.PaintTarget;
*/
public class CustomLayout extends AbstractLayout {
- /**
- * Custom layout slots containing the components.
- */
- private HashMap slots = new HashMap();
+ /**
+ * Custom layout slots containing the components.
+ */
+ private HashMap slots = new HashMap();
- private String templateName;
+ private String templateName;
- /**
- * Constructor for custom layout with given template name.
- */
- public CustomLayout(String template) {
- templateName = template;
- }
+ /**
+ * Constructor for custom layout with given template name.
+ */
+ public CustomLayout(String template) {
+ templateName = template;
+ }
- /**
- * Gets the component UIDL tag.
- *
- * @return the Component UIDL tag as string.
- */
- public String getTag() {
- return "customlayout";
- }
+ /**
+ * Gets the component UIDL tag.
+ *
+ * @return the Component UIDL tag as string.
+ */
+ public String getTag() {
+ return "customlayout";
+ }
- /**
- * Adds the component into this container to given location.
- *
- * @param c
- * the component to be added.
- * @param location
- * the location of the component.
- */
- public void addComponent(Component c, String location) {
- Component old = (Component) slots.get(location);
- if (old != null) {
- removeComponent(old);
- }
- slots.put(location, c);
- c.setParent(this);
- fireComponentAttachEvent(c);
- requestRepaint();
- }
+ /**
+ * Adds the component into this container to given location.
+ *
+ * @param c
+ * the component to be added.
+ * @param location
+ * the location of the component.
+ */
+ public void addComponent(Component c, String location) {
+ Component old = (Component) slots.get(location);
+ if (old != null) {
+ removeComponent(old);
+ }
+ slots.put(location, c);
+ c.setParent(this);
+ fireComponentAttachEvent(c);
+ requestRepaint();
+ }
- /**
- * Adds the component into this container. The component is added without
- * specifying the location (empty string is then used as location). Only one
- * component can be added to the default "" location and adding more
- * components into that location overwrites the old components.
- *
- * @param c
- * the component to be added.
- */
- public void addComponent(Component c) {
- this.addComponent(c, "");
- }
+ /**
+ * Adds the component into this container. The component is added without
+ * specifying the location (empty string is then used as location). Only one
+ * component can be added to the default "" location and adding more
+ * components into that location overwrites the old components.
+ *
+ * @param c
+ * the component to be added.
+ */
+ public void addComponent(Component c) {
+ this.addComponent(c, "");
+ }
- /**
- * Removes the component from this container.
- *
- * @param c
- * the component to be removed.
- */
- public void removeComponent(Component c) {
- if (c == null)
- return;
- slots.values().remove(c);
- c.setParent(null);
- fireComponentDetachEvent(c);
- requestRepaint();
- }
+ /**
+ * Removes the component from this container.
+ *
+ * @param c
+ * the component to be removed.
+ */
+ public void removeComponent(Component c) {
+ if (c == null) {
+ return;
+ }
+ slots.values().remove(c);
+ c.setParent(null);
+ fireComponentDetachEvent(c);
+ requestRepaint();
+ }
- /**
- * Removes the component from this container from given location.
- *
- * @param location
- * the Location identifier of the component.
- */
- public void removeComponent(String location) {
- this.removeComponent((Component) slots.get(location));
- }
+ /**
+ * Removes the component from this container from given location.
+ *
+ * @param location
+ * the Location identifier of the component.
+ */
+ public void removeComponent(String location) {
+ this.removeComponent((Component) slots.get(location));
+ }
- /**
- * Gets the component container iterator for going trough all the components
- * in the container.
- *
- * @return the Iterator of the components inside the container.
- */
- public Iterator getComponentIterator() {
- return slots.values().iterator();
- }
+ /**
+ * Gets the component container iterator for going trough all the components
+ * in the container.
+ *
+ * @return the Iterator of the components inside the container.
+ */
+ public Iterator getComponentIterator() {
+ return slots.values().iterator();
+ }
- /**
- * Gets the child-component by its location.
- *
- * @param location
- * the name of the location where the requested component
- * resides.
- * @return the Component in the given location or null if not found.
- */
- public Component getComponent(String location) {
- return (Component) slots.get(location);
- }
+ /**
+ * Gets the child-component by its location.
+ *
+ * @param location
+ * the name of the location where the requested component
+ * resides.
+ * @return the Component in the given location or null if not found.
+ */
+ public Component getComponent(String location) {
+ return (Component) slots.get(location);
+ }
- /**
- * Paints the content of this component.
- *
- * @param target
- * @throws PaintException
- * if the paint operation failed.
- */
- public void paintContent(PaintTarget target) throws PaintException {
- super.paintContent(target);
+ /**
+ * Paints the content of this component.
+ *
+ * @param target
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
- target.addAttribute("template", templateName);
- // Adds all items in all the locations
- for (Iterator i = slots.keySet().iterator(); i.hasNext();) {
- // Gets the (location,component)
- String location = (String) i.next();
- Component c = (Component) slots.get(location);
- if (c != null) {
- // Writes the item
- target.startTag("location");
- target.addAttribute("name", location);
- c.paint(target);
- target.endTag("location");
- }
- }
- }
+ target.addAttribute("template", templateName);
+ // Adds all items in all the locations
+ for (Iterator i = slots.keySet().iterator(); i.hasNext();) {
+ // Gets the (location,component)
+ String location = (String) i.next();
+ Component c = (Component) slots.get(location);
+ if (c != null) {
+ // Writes the item
+ target.startTag("location");
+ target.addAttribute("name", location);
+ c.paint(target);
+ target.endTag("location");
+ }
+ }
+ }
- /* Documented in superclass */
- public void replaceComponent(Component oldComponent, Component newComponent) {
+ /* Documented in superclass */
+ public void replaceComponent(Component oldComponent, Component newComponent) {
- // Gets the locations
- String oldLocation = null;
- String newLocation = null;
- for (Iterator i = slots.keySet().iterator(); i.hasNext();) {
- String location = (String) i.next();
- Component component = (Component) slots.get(location);
- if (component == oldComponent)
- oldLocation = location;
- if (component == newComponent)
- newLocation = location;
- }
+ // Gets the locations
+ String oldLocation = null;
+ String newLocation = null;
+ for (Iterator i = slots.keySet().iterator(); i.hasNext();) {
+ String location = (String) i.next();
+ Component component = (Component) slots.get(location);
+ if (component == oldComponent) {
+ oldLocation = location;
+ }
+ if (component == newComponent) {
+ newLocation = location;
+ }
+ }
- if (oldLocation == null)
- addComponent(newComponent);
- else if (newLocation == null) {
- removeComponent(oldLocation);
- addComponent(newComponent, oldLocation);
- } else {
- slots.put(newLocation, oldComponent);
- slots.put(oldLocation, newComponent);
- requestRepaint();
- }
- }
+ if (oldLocation == null) {
+ addComponent(newComponent);
+ } else if (newLocation == null) {
+ removeComponent(oldLocation);
+ addComponent(newComponent, oldLocation);
+ } else {
+ slots.put(newLocation, oldComponent);
+ slots.put(oldLocation, newComponent);
+ requestRepaint();
+ }
+ }
- /**
- * CustomLayout's template selecting was previously implemented with
- * setStyle. Overriding to improve backwards compatibility.
- *
- * @param name
- * template name
- */
- public void setStyle(String name) {
- setTemplateName(name);
- }
+ /**
+ * CustomLayout's template selecting was previously implemented with
+ * setStyle. Overriding to improve backwards compatibility.
+ *
+ * @param name
+ * template name
+ */
+ public void setStyle(String name) {
+ setTemplateName(name);
+ }
- /** Get the name of the template */
- public String getTemplateName() {
- return templateName;
- }
+ /** Get the name of the template */
+ public String getTemplateName() {
+ return templateName;
+ }
- /**
- * Set the name of the template used to draw custom layout.
- *
- * With GWT-adapter, the template with name 'templatename' is loaded from
- * ITMILL/themes/themename/layouts/templatename.html. If the theme has not
- * been set (with Application.setTheme()), themename is 'default'.
- *
- * @param templateName
- */
- public void setTemplateName(String templateName) {
- this.templateName = templateName;
- requestRepaint();
- }
+ /**
+ * Set the name of the template used to draw custom layout.
+ *
+ * With GWT-adapter, the template with name 'templatename' is loaded from
+ * ITMILL/themes/themename/layouts/templatename.html. If the theme has not
+ * been set (with Application.setTheme()), themename is 'default'.
+ *
+ * @param templateName
+ */
+ public void setTemplateName(String templateName) {
+ this.templateName = templateName;
+ requestRepaint();
+ }
- /**
- * Although most layouts support margins, CustomLayout does not. The
- * behaviour of this layout is determined almost completely by the actual
- * template.
- *
- * @throws UnsupportedOperationException
- */
- public void setMargin(boolean enabled) {
- throw new UnsupportedOperationException(
- "CustomLayout does not support margins.");
- }
+ /**
+ * Although most layouts support margins, CustomLayout does not. The
+ * behaviour of this layout is determined almost completely by the actual
+ * template.
+ *
+ * @throws UnsupportedOperationException
+ */
+ public void setMargin(boolean enabled) {
+ throw new UnsupportedOperationException(
+ "CustomLayout does not support margins.");
+ }
- /**
- * Although most layouts support margins, CustomLayout does not. The
- * behaviour of this layout is determined almost completely by the actual
- * template.
- *
- * @throws UnsupportedOperationException
- */
- public void setMargin(boolean topEnabled, boolean rightEnabled,
- boolean bottomEnabled, boolean leftEnabled) {
- throw new UnsupportedOperationException(
- "CustomLayout does not support margins.");
- }
+ /**
+ * Although most layouts support margins, CustomLayout does not. The
+ * behaviour of this layout is determined almost completely by the actual
+ * template.
+ *
+ * @throws UnsupportedOperationException
+ */
+ public void setMargin(boolean topEnabled, boolean rightEnabled,
+ boolean bottomEnabled, boolean leftEnabled) {
+ throw new UnsupportedOperationException(
+ "CustomLayout does not support margins.");
+ }
}