diff options
-rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/MainLayout.java | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/vaadin-app/src/ch/asynk/helloworld/MainLayout.java b/vaadin-app/src/ch/asynk/helloworld/MainLayout.java index 48fb7f1..0ab997a 100644 --- a/vaadin-app/src/ch/asynk/helloworld/MainLayout.java +++ b/vaadin-app/src/ch/asynk/helloworld/MainLayout.java @@ -4,7 +4,10 @@ package ch.asynk.helloworld; import java.util.Date; import com.vaadin.terminal.UserError; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Panel; import com.vaadin.ui.Label; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -19,22 +22,37 @@ public class MainLayout extends VerticalLayout { public MainLayout(Context context) { ctx = context; // + final AbstractComponent ctrlPanel = buildListsPanel(); + ctrlPanel.setWidth(500,UNITS_PIXELS); + ctrlPanel.setHeight(400,UNITS_PIXELS); + addComponent(ctrlPanel); + setComponentAlignment(ctrlPanel, Alignment.MIDDLE_CENTER); + // + } - public MainLayout() { + private AbstractComponent buildListsPanel() { + Panel panel = new Panel("Main Layout"); + VerticalLayout layout = (VerticalLayout) panel.getContent(); + layout.setMargin(true); + layout.setSpacing(true); + layout.setHeight(100,UNITS_PERCENTAGE); + // Label label = new Label("Hello world"); - addComponent(label); + layout.addComponent(label); // - addComponent( new Button("What is the time?", new Button.ClickListener() { + layout.addComponent( new Button("What is the time?", new Button.ClickListener() { + private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { - getApplication().getMainWindow().showNotification("The time is " + new Date(), "<i>italic</i> <b>bold</b> description",Notification.TYPE_WARNING_MESSAGE); + ctx.getApp().notifyError("The time is " + new Date(), "<i>italic</i> <b>bold</b> description"); event.getButton().setComponentError( new UserError("Stop pressing this button !!") ); } })); /// Button exceptionButton = new Button("throw an exception"); - addComponent(exceptionButton ); + layout.addComponent(exceptionButton ); exceptionButton.addListener( new Button.ClickListener() { + private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { throw new RuntimeException("Wahou !! : exception"); @@ -43,13 +61,15 @@ public class MainLayout extends VerticalLayout { // Button nextButton = new Button("next layout"); nextButton.setDescription("Go to next layout"); - addComponent(nextButton ); + layout.addComponent(nextButton ); nextButton.addListener( new Button.ClickListener() { + private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { - getApplication().getMainWindow().setContent( new DataMappingLayout(ctx) ); + ctx.getApp().getMainWindow().setContent( new DataMappingLayout(ctx) ); } }); + // + return panel; } - } |