List of usage examples for com.vaadin.ui GridLayout GridLayout
public GridLayout(int columns, int rows)
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
private void initView() { setCompositionRoot(root);/*from ww w. ja va 2 s. c o m*/ root.setSizeFull(); root.setSplitPosition(15); root.setStyleName("small previews"); previewArea.setWidth("100%"); previewTabs = new VerticalLayout(); previewTabs.setSizeFull(); previewTabs.setHeight(null); compoundTabs = new VerticalLayout(); compoundTabs.setSizeFull(); compoundTabs.setHeight(null); bennuStylesTabs = new VerticalLayout(); bennuStylesTabs.setSizeFull(); bennuStylesTabs.setHeight(null); VerticalLayout menu = new VerticalLayout(); menu.setSizeFull(); menu.setStyleName("sidebar-menu"); Button syncThemes = new Button("Sync Themes", new ClickListener() { @Override public void buttonClick(ClickEvent event) { syncThemes(); } }); menu.addComponent(syncThemes); menu.addComponent(new Label("Single Components")); menu.addComponent(previewTabs); menu.addComponent(new Label("Compound Styles")); menu.addComponent(compoundTabs); menu.addComponent(new Label("Bennu Styles")); menu.addComponent(bennuStylesTabs); root.setFirstComponent(menu); CssLayout toolbar = new CssLayout(); toolbar.setWidth("100%"); toolbar.setStyleName("toolbar"); toolbar.addComponent(editorToggle); final Window downloadWindow = new Window("Download Theme"); GridLayout l = new GridLayout(3, 2); l.setSizeUndefined(); l.setMargin(true); l.setSpacing(true); downloadWindow.setContent(l); downloadWindow.setModal(true); downloadWindow.setResizable(false); downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null); downloadWindow.addStyleName("opaque"); Label caption = new Label("Theme Name"); l.addComponent(caption); l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER); final TextField name = new TextField(); name.setValue("my-chameleon"); name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed")); name.setRequired(true); name.setRequiredError("Please give a name for the theme"); downloadWindow.addComponent(name); Label info = new Label( "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.", Label.CONTENT_XHTML); info.addStyleName("tiny"); info.setWidth("200px"); l.addComponent(info, 1, 1, 2, 1); Button download = new Button(null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { getApplication().getMainWindow().addWindow(downloadWindow); name.focus(); } }); download.setDescription("Donwload the current theme"); download.setIcon(new ThemeResource("download.png")); download.setStyleName("icon-only"); toolbar.addComponent(download); menu.addComponent(toolbar); menu.setExpandRatio(toolbar, 1); menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER); }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
GridLayout getPreviewLayout(String caption) { GridLayout grid = new GridLayout(3, 1) { @Override/*w ww. j a v a 2s . c o m*/ public void addComponent(Component c) { super.addComponent(c); setComponentAlignment(c, "center middle"); if (c.getStyleName() != "") { ((AbstractComponent) c).setDescription( c.getClass().getSimpleName() + ".addStyleName(\"" + c.getStyleName() + "\")"); } else { ((AbstractComponent) c).setDescription("new " + c.getClass().getSimpleName() + "()"); } } }; grid.setWidth("100%"); grid.setSpacing(true); grid.setMargin(true); grid.setCaption(caption); grid.setStyleName("preview-grid"); return grid; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java
License:Apache License
private Component getMenu() { GridLayout gl = new GridLayout(3, 3); gl.addComponent(new Image("", LOGO), 0, 0); Label version = new Label(TRANSLATOR.translate("general.version") + ": " + getVersion()); gl.addComponent(version, 2, 2);//from www .java 2 s. c om if (getUser() != null) { getUser().update(); //Logout button Button logout = new Button(TRANSLATOR.translate("general.logout")); logout.addClickListener((Button.ClickEvent event) -> { try { user.update(); user.write2DB(); user = null; main = null; setLocale(Locale.ENGLISH); updateScreen(); // Close the session closeSession(); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } }); gl.addComponent(logout, 1, 0); //Notification Button if (getUser().getNotificationList().isEmpty() && DataBaseManager.isDemo()) { //For demo add a notification for users try { Lookup.getDefault().lookup(INotificationManager.class).addNotification( "Welcome to ValidationManager!", NotificationTypes.GENERAL, getUser().getEntity(), new VMUserServer(1).getEntity()); } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); } } Button notification = new Button(); if (getUser().getPendingNotifications().size() > 0) { notification.setCaption("" + getUser().getPendingNotifications().size()); //any number, count, etc } notification.setHtmlContentAllowed(true); notification.setIcon(VaadinIcons.BELL); notification.addClickListener((Button.ClickEvent event) -> { //TODO: Show notifications screen }); gl.addComponent(notification, 2, 0); } gl.setSizeFull(); return gl; }
From source file:org.abstractform.vaadin.VaadinFormToolkit.java
License:Apache License
private AbstractComponentContainer buildSubForm(SubForm subForm, Map<String, AbstractComponent> mapComponents, List<String> fieldIdList, Map<String, Object> extraObjects) { //panel.setCaption(formEditor.getName()); GridLayout layout = new GridLayout(subForm.getColumns(), subForm.getRows()); layout.setWidth("100%"); layout.setSpacing(true);//from w w w .ja v a 2 s .co m for (int row = 0; row < subForm.getRows(); row++) { for (int column = 0; column < subForm.getColumns(); column++) { Component component = subForm.getField(row, column); if (component == null) { layout.addComponent(new Label(" ", Label.CONTENT_XHTML)); } else if (component instanceof Field) { Field editor = (Field) component; if (editor != null) { layout.addComponent(buildField(editor, mapComponents, fieldIdList, extraObjects)); } } else { buildComponent(component, mapComponents, fieldIdList, extraObjects); } } } return layout; }
From source file:org.accelerators.activiti.admin.ui.GroupCreateForm.java
License:Open Source License
/** * /*w w w. ja va 2 s .com*/ * @param app */ public GroupCreateForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false); // Set the form to act immediately on user input. setImmediate(true); // Set form size setSizeFull(); // Setup footer layout HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.setWidth("100%"); footer.setVisible(true); // Add footer setFooter(footer); // Init buttons create = new Button(app.getMessage(Messages.Create), (ClickListener) this); close = new Button(app.getMessage(Messages.Close), (ClickListener) this); reset = new Button(app.getMessage(Messages.Reset), this, "discard"); // Set button grid GridLayout grid = new GridLayout(3, 1); grid.addComponent(create, 0, 0); grid.addComponent(reset, 1, 0); grid.addComponent(close, 2, 0); grid.setSpacing(true); // Add grid to footer footer.addComponent(grid); // Right align buttons in footer footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT); // Init group types types = new String[] { app.getMessage(Messages.Assignment), app.getMessage(Messages.Program), app.getMessage(Messages.Project), app.getMessage(Messages.Role), app.getMessage(Messages.Team), app.getMessage(Messages.Unit) }; // Create combo box for group types groupTypes = new ComboBox("type"); groupTypes.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH); for (int i = 0; i < types.length; i++) { groupTypes.addItem(types[i]); } // Propagate changes directly groupTypes.setImmediate(true); // Allow adding new group types groupTypes.setNewItemsAllowed(true); // Get available users members = new TwinColSelect(app.getMessage(Messages.Members), app.getAdminService().getUsers()); // Set column headers members.setLeftColumnCaption(app.getMessage(Messages.AvailableUsers)); members.setRightColumnCaption(app.getMessage(Messages.GroupMembers)); // Propagate changes directly members.setImmediate(true); // Set max width members.setWidth("100%"); // Field factory for over riding how fields are created setFormFieldFactory(new DefaultFieldFactory() { private static final long serialVersionUID = 1L; @Override public Field createField(Item item, Object propertyId, Component uiContext) { if (propertyId.equals("type")) { groupTypes.setWidth("100%"); groupTypes.setRequired(false); groupTypes.setCaption(app.getMessage(Messages.Types)); return groupTypes; } Field field = super.createField(item, propertyId, uiContext); if (propertyId.equals("id")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set error message tf.setRequiredError("Id is missing"); // Set read only tf.setReadOnly(false); } else if (propertyId.equals("name")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set error message tf.setRequiredError(app.getMessage(Messages.GroupNameIsMissing)); } field.setWidth("100%"); return field; } }); }
From source file:org.accelerators.activiti.admin.ui.GroupEditForm.java
License:Open Source License
/** * /*from www.j ava 2 s . c om*/ * @param app */ public GroupEditForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false); // Set the form to act immediately on user input. setImmediate(true); // Set form size setSizeFull(); // Setup footer layout HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.setWidth("100%"); footer.setVisible(true); // Add footer setFooter(footer); // Init buttons save = new Button(app.getMessage(Messages.Save), (ClickListener) this); close = new Button(app.getMessage(Messages.Close), (ClickListener) this); reset = new Button(app.getMessage(Messages.Reset), this, "discard"); // Set button grid GridLayout grid = new GridLayout(3, 1); grid.addComponent(save, 0, 0); grid.addComponent(reset, 1, 0); grid.addComponent(close, 2, 0); grid.setSpacing(true); // Add grid to footer footer.addComponent(grid); // Right align buttons in footer footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT); // Init group types types = new String[] { app.getMessage(Messages.Assignment), app.getMessage(Messages.Program), app.getMessage(Messages.Project), app.getMessage(Messages.Role), app.getMessage(Messages.Team), app.getMessage(Messages.Unit) }; // Create combo box for group types groupTypes = new ComboBox("type"); groupTypes.setFilteringMode(Filtering.FILTERINGMODE_STARTSWITH); for (int i = 0; i < types.length; i++) { groupTypes.addItem(types[i]); } // Propagate changes directly groupTypes.setImmediate(true); // Allow adding new group types groupTypes.setNewItemsAllowed(true); // Get available users members = new TwinColSelect(app.getMessage(Messages.Members), app.getAdminService().getUsers()); // Set column headers members.setLeftColumnCaption(app.getMessage(Messages.AvailableUsers)); members.setRightColumnCaption(app.getMessage(Messages.GroupMembers)); // Propagate changes directly members.setImmediate(true); // Set max width members.setWidth("100%"); // Field factory for over riding how fields are created setFormFieldFactory(new DefaultFieldFactory() { private static final long serialVersionUID = 1L; @Override public Field createField(Item item, Object propertyId, Component uiContext) { if (propertyId.equals("type")) { groupTypes.setWidth("100%"); groupTypes.setRequired(false); groupTypes.setCaption(app.getMessage(Messages.Types)); return groupTypes; } Field field = super.createField(item, propertyId, uiContext); if (propertyId.equals("id")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as read-only. Changing the id will create a new // group. tf.setReadOnly(true); // Set as required field // tf.setRequired(true); // Set error message tf.setRequiredError("Id is missing"); } else if (propertyId.equals("name")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set error message tf.setRequiredError(app.getMessage(Messages.GroupNameIsMissing)); } field.setWidth("100%"); return field; } }); }
From source file:org.accelerators.activiti.admin.ui.GroupTab.java
License:Open Source License
public GroupTab(AdminApp application) { // Set application reference this.app = application; // Set tab name setCaption(app.getMessage(Messages.Groups)); // Add main layout VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/*from w ww . j av a 2 s . c om*/ layout.setSpacing(true); layout.setSizeFull(); // Add toolbar layout GridLayout toolbar = new GridLayout(2, 1); toolbar.setWidth("100%"); layout.addComponent(toolbar); // Add create button create = new Button(app.getMessage(Messages.Create), (ClickListener) this); create.setDescription(app.getMessage(Messages.CreateGroup)); create.setIcon(new ThemeResource("../runo/icons/16/ok.png")); toolbar.addComponent(create, 0, 0); toolbar.setComponentAlignment(create, Alignment.TOP_LEFT); // Add refresh button refresh = new Button(app.getMessage(Messages.Refresh), (ClickListener) this); refresh.setDescription(app.getMessage(Messages.RefreshTable)); refresh.setIcon(new ThemeResource("../runo/icons/16/reload.png")); toolbar.addComponent(refresh, 1, 0); toolbar.setComponentAlignment(refresh, Alignment.TOP_RIGHT); // Add table table = new GroupTable(app); table.setSizeFull(); layout.addComponent(table); // Set table to expand layout.setExpandRatio(table, 1.0f); // Root setCompositionRoot(layout); }
From source file:org.accelerators.activiti.admin.ui.LoginView.java
License:Open Source License
@SuppressWarnings("serial") public LoginView(AdminApp application) { // Set application reference this.app = application; // Init window caption app.getMainWindow().setCaption(app.getMessage(Messages.Title)); // Set layout to full size setSizeFull();//from www. j a v a 2s. c o m // Set style this.setStyleName("login-background"); // Add header bar final HorizontalLayout header = new HorizontalLayout(); header.setHeight("50px"); header.setWidth("100%"); addComponent(header); setComponentAlignment(header, Alignment.MIDDLE_CENTER); // Setup grid GridLayout loginGrid = new GridLayout(1, 2); loginGrid.setWidth("250px"); addComponent(loginGrid); setComponentAlignment(loginGrid, Alignment.MIDDLE_CENTER); // Add title to header GridLayout logoGrid = new GridLayout(1, 1); loginGrid.addComponent(logoGrid, 0, 0); loginGrid.setComponentAlignment(logoGrid, Alignment.MIDDLE_CENTER); Embedded logoImage = new Embedded(null, new ThemeResource("img/login-logo.png")); logoImage.setType(Embedded.TYPE_IMAGE); logoImage.addStyleName("login-image"); logoGrid.addComponent(logoImage, 0, 0); logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER); // Add field and button layout VerticalLayout buttonLayout = new VerticalLayout(); buttonLayout.setSizeFull(); buttonLayout.setSpacing(true); buttonLayout.setMargin(false); buttonLayout.setStyleName("login-form"); loginGrid.addComponent(buttonLayout, 0, 1); loginGrid.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER); // Add username field username = new TextField(app.getMessage(Messages.Username)); username.setWidth("100%"); buttonLayout.addComponent(username); // Add password field password = new PasswordField(app.getMessage(Messages.Password)); password.setWidth("100%"); buttonLayout.addComponent(password); // Add Login button buttonLayout.addComponent(login); buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_RIGHT); // Set focus to this component username.focus(); // Add shortcut to login button login.setClickShortcut(KeyCode.ENTER); login.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { try { // Athenticate the user authenticate((String) username.getValue(), (String) password.getValue()); // Switch to the main view app.getViewManager().switchScreen(MainView.class.getName(), new MainView(app)); } catch (Exception e) { getWindow().showNotification(e.toString()); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setHeight("50px"); footer.setWidth("100%"); addComponent(footer); }
From source file:org.accelerators.activiti.admin.ui.MainView.java
License:Open Source License
public MainView(AdminApp application) { // Set application this.app = application; // Setup main layout setStyleName(Reindeer.LAYOUT_WHITE); setMargin(false);//from w w w . j a v a 2 s .com setSpacing(false); setSizeFull(); // Add header GridLayout header = new GridLayout(2, 1); header.setWidth("100%"); header.setHeight("34px"); addComponent(header); // Add header styles header.addStyleName(Consts.HEADER); header.addStyleName("header"); header.setSpacing(true); // Add title to header GridLayout logoGrid = new GridLayout(1, 1); header.addComponent(logoGrid, 0, 0); header.setComponentAlignment(logoGrid, Alignment.MIDDLE_LEFT); Embedded logoImage = new Embedded(null, new ThemeResource("img/header-logo.png")); logoImage.setType(Embedded.TYPE_IMAGE); logoImage.addStyleName("header-image"); logoGrid.addComponent(logoImage, 0, 0); logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER); // Add logout button to header GridLayout logoutGrid = new GridLayout(2, 1); Label userLabel = new Label("Signed in as: " + app.getUser().toString()); userLabel.addStyleName("user"); logout.setStyleName(Reindeer.BUTTON_LINK); logout.addStyleName("logout"); logoutGrid.addComponent(userLabel, 0, 0); logoutGrid.addComponent(logout, 1, 0); header.addComponent(logoutGrid, 1, 0); header.setComponentAlignment(logoutGrid, Alignment.TOP_RIGHT); // Create tab sheet TabSheet tabs = new TabSheet(); tabs.setSizeFull(); // Add tab styles tabs.addStyleName(Reindeer.TABSHEET_BORDERLESS); tabs.addStyleName(Reindeer.LAYOUT_WHITE); // Add task view tab tabs.addTab(new UserTab(app)); tabs.addTab(new GroupTab(app)); // Add tab sheet to layout addComponent(tabs); setExpandRatio(tabs, 1.0F); // Add footer text Label footerText = new Label(app.getMessage(Messages.Footer)); footerText.setSizeUndefined(); footerText.setStyleName(Reindeer.LABEL_SMALL); addComponent(footerText); setComponentAlignment(footerText, Alignment.BOTTOM_CENTER); }
From source file:org.accelerators.activiti.admin.ui.UserCreateForm.java
License:Open Source License
public UserCreateForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false);//from ww w .j a v a 2s . co m // Set the form to act immediately on user input. setImmediate(true); // Set form size setSizeFull(); // Setup footer layout HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.setWidth("100%"); footer.setVisible(true); // Add footer setFooter(footer); // Init buttons create = new Button(app.getMessage(Messages.Create), (ClickListener) this); close = new Button(app.getMessage(Messages.Close), (ClickListener) this); reset = new Button(app.getMessage(Messages.Reset), this, "discard"); // Set button grid GridLayout grid = new GridLayout(3, 1); grid.addComponent(create, 0, 0); grid.addComponent(reset, 1, 0); grid.addComponent(close, 2, 0); grid.setSpacing(true); // Add grid to footer footer.addComponent(grid); // Right align buttons in footer footer.setComponentAlignment(grid, Alignment.BOTTOM_RIGHT); // Get all available groups groups = new TwinColSelect(app.getMessage(Messages.Groups), app.getAdminService().getGroups()); // Set column headers groups.setLeftColumnCaption(app.getMessage(Messages.AvailableGroups)); groups.setRightColumnCaption(app.getMessage(Messages.MemberOfGroups)); // Propagate changes directly groups.setImmediate(true); // Max width groups.setWidth("100%"); // Field factory for over riding how fields are created setFormFieldFactory(new DefaultFieldFactory() { private static final long serialVersionUID = 1L; @Override public Field createField(Item item, Object propertyId, Component uiContext) { Field field = super.createField(item, propertyId, uiContext); field.setWidth("100%"); // field.setVisible(false); if (propertyId.equals("id")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set validator example, should not be restricted in the // admin ui // tf.addValidator(new // RegexpValidator("^[a-zA-Z0-9_-]{4,20}", // app.getMessage(Messages.InvalidUsername))); // Set error message tf.setRequiredError(app.getMessage(Messages.UsernameIsMissing)); } else if (propertyId.equals("password")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field tf.setRequired(true); // Set as secret (todo: use password field instead of text // field) tf.setSecret(true); // Set error message tf.setRequiredError(app.getMessage(Messages.PasswordIsMissing)); } else if (propertyId.equals("email")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); // Set as required field, should not be required by default // in the admin ui // tf.setRequired(true); // Set error message // tf.setRequiredError(application.getMessage(Messages.EmailIsMissing)); /* Add a validator for email and make it required */ field.addValidator(new EmailValidator(app.getMessage(Messages.EmailFormatError))); } else if (propertyId.equals("firstName")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } else if (propertyId.equals("lastName")) { TextField tf = (TextField) field; tf.setVisible(true); // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } return field; } }); }