aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/demo/CustomLayoutDemo.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/demo/CustomLayoutDemo.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/demo/CustomLayoutDemo.java')
-rw-r--r--src/com/itmill/toolkit/demo/CustomLayoutDemo.java220
1 files changed, 114 insertions, 106 deletions
diff --git a/src/com/itmill/toolkit/demo/CustomLayoutDemo.java b/src/com/itmill/toolkit/demo/CustomLayoutDemo.java
index 6035fdc0cc..0bf256b409 100644
--- a/src/com/itmill/toolkit/demo/CustomLayoutDemo.java
+++ b/src/com/itmill/toolkit/demo/CustomLayoutDemo.java
@@ -1,6 +1,13 @@
package com.itmill.toolkit.demo;
-import com.itmill.toolkit.ui.*;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.CustomLayout;
+import com.itmill.toolkit.ui.Field;
+import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Panel;
+import com.itmill.toolkit.ui.TextField;
+import com.itmill.toolkit.ui.Tree;
+import com.itmill.toolkit.ui.Window;
import com.itmill.toolkit.ui.Component.Event;
import com.itmill.toolkit.ui.Component.Listener;
@@ -18,110 +25,111 @@ import com.itmill.toolkit.ui.Component.Listener;
*
*/
public class CustomLayoutDemo extends com.itmill.toolkit.Application implements
- Listener {
-
- private CustomLayout mainLayout = null;
-
- private Panel bodyPanel = new Panel();
-
- private TextField username = new TextField("Username");
-
- private TextField loginPwd = new TextField("Password");
-
- private Button loginButton = new Button("Login", this, "loginClicked");
-
- private Tree menu = new Tree();
-
- /**
- * Initialize Application. Demo components are added to main window.
- */
- public void init() {
- Window mainWindow = new Window("CustomLayout demo");
- setMainWindow(mainWindow);
-
- // set the application to use example -theme
- setTheme("example");
-
- // Create custom layout, themes/example/layout/mainLayout.html
- mainLayout = new CustomLayout("mainLayout");
- // wrap custom layout inside a panel
- Panel customLayoutPanel = new Panel(
- "Panel containing custom layout (mainLayout.html)");
- customLayoutPanel.addComponent(mainLayout);
-
- // Login components
- loginPwd.setSecret(true);
- mainLayout.addComponent(username, "loginUser");
- mainLayout.addComponent(loginPwd, "loginPassword");
- mainLayout.addComponent(loginButton, "loginButton");
-
- // Menu component, when clicked bodyPanel is updated
- menu.addItem("Welcome");
- menu.addItem("Products");
- menu.addItem("Support");
- menu.addItem("News");
- menu.addItem("Developers");
- menu.addItem("Contact");
- // "this" handles all menu events, e.g. node clicked event
- menu.addListener((Listener) this);
- // Value changes are immediate
- menu.setImmediate(true);
- menu.setNullSelectionAllowed(false);
- mainLayout.addComponent(menu, "menu");
-
- // Body component
- mainLayout.addComponent(bodyPanel, "body");
-
- // Initial body are comes from Welcome.html
- setBody("Welcome");
-
- // Add heading label and custom layout panel to main window
- mainWindow.addComponent(new Label("<h3>Custom layout demo</h3>",
- Label.CONTENT_XHTML));
- mainWindow.addComponent(customLayoutPanel);
- }
-
- /**
- * Login button clicked. Hide login components and replace username
- * component with "Welcome user Username" message.
- *
- */
- public void loginClicked() {
- username.setVisible(false);
- loginPwd.setVisible(false);
- if (username.getValue().toString().length() < 1)
- username.setValue("Anonymous");
- mainLayout.replaceComponent(loginButton, new Label("Welcome user <em>"
- + username.getValue() + "</em>", Label.CONTENT_XHTML));
- }
-
- /**
- * Set body panel caption, remove all existing components and add given
- * custom layout in it.
- *
- */
- public void setBody(String customLayout) {
- bodyPanel.setCaption(customLayout + ".html");
- bodyPanel.removeAllComponents();
- bodyPanel.addComponent(new CustomLayout(customLayout));
- }
-
- /**
- * Handle all menu events. Updates body panel contents if menu item is
- * clicked.
- */
- public void componentEvent(Event event) {
- // Check if event occured at fsTree component
- if (event.getSource() == menu) {
- // Check if event is about changing value
- if (event.getClass() == Field.ValueChangeEvent.class) {
- // Update body area with selected item
- setBody(menu.getValue().toString());
- }
- // here we could check for other type of events for tree
- // component
- }
- // here we could check for other component's events
- }
+ Listener {
+
+ private CustomLayout mainLayout = null;
+
+ private Panel bodyPanel = new Panel();
+
+ private TextField username = new TextField("Username");
+
+ private TextField loginPwd = new TextField("Password");
+
+ private Button loginButton = new Button("Login", this, "loginClicked");
+
+ private Tree menu = new Tree();
+
+ /**
+ * Initialize Application. Demo components are added to main window.
+ */
+ public void init() {
+ Window mainWindow = new Window("CustomLayout demo");
+ setMainWindow(mainWindow);
+
+ // set the application to use example -theme
+ setTheme("example");
+
+ // Create custom layout, themes/example/layout/mainLayout.html
+ mainLayout = new CustomLayout("mainLayout");
+ // wrap custom layout inside a panel
+ Panel customLayoutPanel = new Panel(
+ "Panel containing custom layout (mainLayout.html)");
+ customLayoutPanel.addComponent(mainLayout);
+
+ // Login components
+ loginPwd.setSecret(true);
+ mainLayout.addComponent(username, "loginUser");
+ mainLayout.addComponent(loginPwd, "loginPassword");
+ mainLayout.addComponent(loginButton, "loginButton");
+
+ // Menu component, when clicked bodyPanel is updated
+ menu.addItem("Welcome");
+ menu.addItem("Products");
+ menu.addItem("Support");
+ menu.addItem("News");
+ menu.addItem("Developers");
+ menu.addItem("Contact");
+ // "this" handles all menu events, e.g. node clicked event
+ menu.addListener(this);
+ // Value changes are immediate
+ menu.setImmediate(true);
+ menu.setNullSelectionAllowed(false);
+ mainLayout.addComponent(menu, "menu");
+
+ // Body component
+ mainLayout.addComponent(bodyPanel, "body");
+
+ // Initial body are comes from Welcome.html
+ setBody("Welcome");
+
+ // Add heading label and custom layout panel to main window
+ mainWindow.addComponent(new Label("<h3>Custom layout demo</h3>",
+ Label.CONTENT_XHTML));
+ mainWindow.addComponent(customLayoutPanel);
+ }
+
+ /**
+ * Login button clicked. Hide login components and replace username
+ * component with "Welcome user Username" message.
+ *
+ */
+ public void loginClicked() {
+ username.setVisible(false);
+ loginPwd.setVisible(false);
+ if (username.getValue().toString().length() < 1) {
+ username.setValue("Anonymous");
+ }
+ mainLayout.replaceComponent(loginButton, new Label("Welcome user <em>"
+ + username.getValue() + "</em>", Label.CONTENT_XHTML));
+ }
+
+ /**
+ * Set body panel caption, remove all existing components and add given
+ * custom layout in it.
+ *
+ */
+ public void setBody(String customLayout) {
+ bodyPanel.setCaption(customLayout + ".html");
+ bodyPanel.removeAllComponents();
+ bodyPanel.addComponent(new CustomLayout(customLayout));
+ }
+
+ /**
+ * Handle all menu events. Updates body panel contents if menu item is
+ * clicked.
+ */
+ public void componentEvent(Event event) {
+ // Check if event occured at fsTree component
+ if (event.getSource() == menu) {
+ // Check if event is about changing value
+ if (event.getClass() == Field.ValueChangeEvent.class) {
+ // Update body area with selected item
+ setBody(menu.getValue().toString());
+ }
+ // here we could check for other type of events for tree
+ // component
+ }
+ // here we could check for other component's events
+ }
}