diff options
author | Marc Englund <marc.englund@itmill.com> | 2007-11-19 14:03:05 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2007-11-19 14:03:05 +0000 |
commit | f2e3722df9676436680afc0f1991e91e1696fb99 (patch) | |
tree | 6f255ff78abaf96f1e71a1f2c9ecd3b66647f4a2 /src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java | |
parent | 93291f532db9d545cf2a8dd98e2671f27cd197b0 (diff) | |
download | vaadin-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/tests/magi/DefaultButtonExample.java')
-rw-r--r-- | src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java | 149 |
1 files changed, 81 insertions, 68 deletions
diff --git a/src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java b/src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java index 991264d206..a91493eb79 100644 --- a/src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java +++ b/src/com/itmill/toolkit/tests/magi/DefaultButtonExample.java @@ -1,84 +1,97 @@ package com.itmill.toolkit.tests.magi; + import com.itmill.toolkit.event.Action; import com.itmill.toolkit.event.ShortcutAction; import com.itmill.toolkit.event.Action.Handler; -import com.itmill.toolkit.ui.*; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.CustomComponent; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.TextField; public class DefaultButtonExample extends CustomComponent implements Handler { - // Define and create user interface components - Panel panel = new Panel("Login"); - OrderedLayout formlayout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL); - TextField username = new TextField("Username"); - TextField password = new TextField("Password"); - OrderedLayout buttons = new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL); - - // Create buttons and define their listener methods. Here we use parameterless - // methods so that we can use same methods for both click events and keyboard - // actions. - Button ok = new Button("OK", this, "okHandler"); - Button cancel = new Button("Cancel", this, "cancelHandler"); + // Define and create user interface components + Panel panel = new Panel("Login"); + OrderedLayout formlayout = new OrderedLayout( + OrderedLayout.ORIENTATION_VERTICAL); + TextField username = new TextField("Username"); + TextField password = new TextField("Password"); + OrderedLayout buttons = new OrderedLayout( + OrderedLayout.ORIENTATION_HORIZONTAL); + + // Create buttons and define their listener methods. Here we use + // parameterless + // methods so that we can use same methods for both click events and + // keyboard + // actions. + Button ok = new Button("OK", this, "okHandler"); + Button cancel = new Button("Cancel", this, "cancelHandler"); + + public DefaultButtonExample() { + // Set up the user interface + setCompositionRoot(panel); + panel.addComponent(formlayout); + formlayout.addComponent(username); + formlayout.addComponent(password); + formlayout.setStyle("form"); + formlayout.addComponent(buttons); + buttons.addComponent(ok); + buttons.addComponent(cancel); + + // Set focus to username + username.focus(); - public DefaultButtonExample() { - // Set up the user interface - setCompositionRoot(panel); - panel.addComponent(formlayout); - formlayout.addComponent(username); - formlayout.addComponent(password); - formlayout.setStyle("form"); - formlayout.addComponent(buttons); - buttons.addComponent(ok); - buttons.addComponent(cancel); - - // Set focus to username - username.focus(); - - // Set this object as the action handler for actions related to the Ok - // and Cancel buttons. - // @TODO - //ok.addActionHandler(this); - //cancel.addActionHandler(this); - } + // Set this object as the action handler for actions related to the Ok + // and Cancel buttons. + // @TODO + // ok.addActionHandler(this); + // cancel.addActionHandler(this); + } - /** - * Retrieve actions for a specific component. This method will be called for each - * object that has a handler; in this example the Ok and Cancel buttons. - **/ - public Action[] getActions(Object target, Object sender) { - Action[] actions = new Action[1]; + /** + * Retrieve actions for a specific component. This method will be called for + * each object that has a handler; in this example the Ok and Cancel + * buttons. + */ + public Action[] getActions(Object target, Object sender) { + Action[] actions = new Action[1]; - // Set the action for the requested component + // Set the action for the requested component if (sender == ok) { - // Bind the unmodified Enter key to the Ok button. + // Bind the unmodified Enter key to the Ok button. actions[0] = new ShortcutAction("Default key", - ShortcutAction.KeyCode.ENTER, null); + ShortcutAction.KeyCode.ENTER, null); } else if (sender == cancel) { - // Bind "C" key modified with Alt to the Cancel button. - actions[0] = new ShortcutAction("Alt+C", - ShortcutAction.KeyCode.C, new int[] { - ShortcutAction.ModifierKey.ALT}); - } else - return null; - return actions; - } + // Bind "C" key modified with Alt to the Cancel button. + actions[0] = new ShortcutAction("Alt+C", ShortcutAction.KeyCode.C, + new int[] { ShortcutAction.ModifierKey.ALT }); + } else { + return null; + } + return actions; + } - /** - * Handle actions received from keyboard. This simply directs the actions to - * the same listener methods that are called with ButtonClick events. - **/ - public void handleAction(Action action, Object sender, Object target) { - if (target == ok) - this.okHandler(); - if (target == cancel) - this.cancelHandler(); - } + /** + * Handle actions received from keyboard. This simply directs the actions to + * the same listener methods that are called with ButtonClick events. + */ + public void handleAction(Action action, Object sender, Object target) { + if (target == ok) { + okHandler(); + } + if (target == cancel) { + cancelHandler(); + } + } - public void okHandler() { - // Do something: report the click - formlayout.addComponent(new Label("OK clicked")); - } + public void okHandler() { + // Do something: report the click + formlayout.addComponent(new Label("OK clicked")); + } - public void cancelHandler() { - // Do something: report the click - formlayout.addComponent(new Label("Cancel clicked")); - } + public void cancelHandler() { + // Do something: report the click + formlayout.addComponent(new Label("Cancel clicked")); + } } |