List of usage examples for com.vaadin.ui GridLayout GridLayout
public GridLayout(int columns, int rows)
From source file:org.accelerators.activiti.admin.ui.UserEditForm.java
License:Open Source License
public UserEditForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false);/*from ww w.jav a 2 s. c om*/ // 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); // 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); 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 user. tf.setReadOnly(true); // 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; // 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; // 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; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } else if (propertyId.equals("lastName")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } field.setWidth("100%"); return field; } }); }
From source file:org.accelerators.activiti.admin.ui.UserTab.java
License:Open Source License
public UserTab(AdminApp application) { // Set application reference this.app = application; // Set tab name setCaption(app.getMessage(Messages.Users)); // Add main layout VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);// w w w . j a va 2 s.com 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.CreateUser)); 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 UserTable(app); table.setSizeFull(); layout.addComponent(table); // Set table to expand layout.setExpandRatio(table, 1.0f); // Root setCompositionRoot(layout); }
From source file:org.activiti.administrator.AdminApp.java
License:Apache License
/** * Switch view/*w w w .j a v a 2 s .c o m*/ * * @param name * the name of the view class * @param view * the view to switch to */ public void switchView(String name, Layout view) { // Add view to main layout mainLayout.addComponent(view, Consts.CONTENT); // Add logout button if user is authenticated if ((getUser() != null) && !getUser().toString().isEmpty()) { // Create logout grid with user icon, user id and logout button GridLayout logoutGrid = new GridLayout(3, 1); logoutGrid.setStyleName("logout"); // Add user icon Embedded userIcon = new Embedded(null, new ThemeResource("img/user-icon.png")); userIcon.setType(Embedded.TYPE_IMAGE); userIcon.addStyleName("icon"); // Add user id Label userLabel = new Label(getUser().toString()); userLabel.addStyleName("user"); // Add logout button logout.setStyleName(Reindeer.BUTTON_LINK); logout.addStyleName("logout"); logout.setIcon(new ThemeResource("img/divider-white.png")); // Add to logout grid logoutGrid.addComponent(userIcon, 0, 0); logoutGrid.addComponent(userLabel, 1, 0); logoutGrid.addComponent(logout, 2, 0); // Add logout grid to header mainLayout.addComponent(logoutGrid, Consts.LOGOUT); } else { // Remove logout button mainLayout.removeComponent(Consts.LOGOUT); } // Switch to new view viewManager.switchScreen(name, mainLayout); }
From source file:org.activiti.administrator.ui.UserEditForm.java
License:Apache License
public UserEditForm(AdminApp application) { // Set application reference this.app = application; // Enable buffering so that commit() must be called for the form. setWriteThrough(false);/*from www. j a v a2 s .c om*/ // 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); // 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); 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 user. tf.setReadOnly(true); // 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; // 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; // 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; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } else if (propertyId.equals("lastName")) { TextField tf = (TextField) field; // Do not display "null" to the user when the field is empty tf.setNullRepresentation(""); } field.setWidth("100%"); return field; } }); }
From source file:org.activiti.editor.ui.DeployModelPopupWindow.java
License:Apache License
public DeployModelPopupWindow(Model modelData) { setWidth(400, UNITS_PIXELS);/*from ww w. j a v a2 s . c o m*/ setModal(true); setResizable(false); addStyleName(Reindeer.PANEL_LIGHT); layout = new GridLayout(2, 2); layout.setSpacing(true); layout.setSizeFull(); layout.setMargin(false, false, true, false); addComponent(layout); I18nManager i18nManager = ExplorerApp.get().getI18nManager(); setCaption(i18nManager.getMessage(Messages.MODEL_DEPLOY_POPUP_CAPTION)); // Process name Label nameLabel = new Label(i18nManager.getMessage(Messages.MODEL_DEPLOY_NAME)); layout.addComponent(nameLabel, 0, 0); processNameTextField = new TextField(); if (modelData.getName() != null) { processNameTextField.setValue(modelData.getName()); } processNameTextField.focus(); layout.addComponent(processNameTextField, 1, 0); // Generate reports Label generateReportsLabel = new Label(i18nManager.getMessage(Messages.MODEL_DEPLOY_GENERATE_REPORTS)); layout.addComponent(generateReportsLabel, 0, 1); generateReportsCheckBox = new CheckBox(); generateReportsCheckBox.setValue(true); layout.addComponent(generateReportsCheckBox, 1, 1); // Buttons initButtons(i18nManager); }
From source file:org.activiti.editor.ui.EditorProcessDefinitionDetailPanel.java
License:Apache License
protected void initHeader() { GridLayout details = new GridLayout(2, 2); details.setWidth(100, UNITS_PERCENTAGE); details.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); details.setSpacing(true);//ww w . j a va 2s . c om details.setMargin(false, false, true, false); details.setColumnExpandRatio(1, 1.0f); detailPanelLayout.addComponent(details); // Image Embedded image = new Embedded(null, Images.PROCESS_50); details.addComponent(image, 0, 0, 0, 1); // Name Label nameLabel = new Label(modelData.getName()); nameLabel.addStyleName(Reindeer.LABEL_H2); details.addComponent(nameLabel, 1, 0); // Properties HorizontalLayout propertiesLayout = new HorizontalLayout(); propertiesLayout.setSpacing(true); details.addComponent(propertiesLayout); // Version String versionString = i18nManager.getMessage(Messages.PROCESS_VERSION, modelData.getVersion()); Label versionLabel = new Label(versionString); versionLabel.addStyleName(ExplorerLayout.STYLE_PROCESS_HEADER_VERSION); propertiesLayout.addComponent(versionLabel); }
From source file:org.activiti.editor.ui.NewModelPopupWindow.java
License:Apache License
protected void addFields() { formLayout = new GridLayout(2, 3); formLayout.setSpacing(true);//w w w .j av a2 s. co m formLayout.addComponent(new Label(i18nManager.getMessage(Messages.TASK_NAME))); nameTextField = new TextField(); nameTextField.setWidth(25, Sizeable.UNITS_EM); nameTextField.focus(); formLayout.addComponent(nameTextField); formLayout.addComponent(new Label(i18nManager.getMessage(Messages.TASK_DESCRIPTION))); descriptionTextArea = new TextArea(); descriptionTextArea.setRows(8); descriptionTextArea.setWidth(25, Sizeable.UNITS_EM); descriptionTextArea.addStyleName(ExplorerLayout.STYLE_TEXTAREA_NO_RESIZE); formLayout.addComponent(descriptionTextArea); Label editorLabel = new Label(i18nManager.getMessage(Messages.PROCESS_EDITOR_CHOICE)); formLayout.addComponent(editorLabel); formLayout.setComponentAlignment(editorLabel, Alignment.MIDDLE_LEFT); selectEditorComponent = new SelectEditorComponent(); formLayout.addComponent(selectEditorComponent); addComponent(formLayout); // Some empty space Label emptySpace = new Label(" ", Label.CONTENT_XHTML); addComponent(emptySpace); }
From source file:org.activiti.explorer.ui.AbstractOneViewPage.java
License:Apache License
protected void addMainLayout() { grid = new GridLayout(1, 2); grid.setSizeFull();//w ww. j a va 2s .co m // Height division grid.setRowExpandRatio(1, 1.0f); setCompositionRoot(grid); }
From source file:org.activiti.explorer.ui.AbstractPage.java
License:Apache License
protected void addMainLayout() { if (showEvents) { grid = new GridLayout(3, 3); grid.setColumnExpandRatio(0, .25f); grid.setColumnExpandRatio(1, .52f); grid.setColumnExpandRatio(2, .23f); } else {/* w w w . ja v a 2 s. co m*/ grid = new GridLayout(2, 3); grid.setColumnExpandRatio(0, .25f); grid.setColumnExpandRatio(1, .75f); } grid.addStyleName(Reindeer.SPLITPANEL_SMALL); grid.setSizeFull(); // Height division grid.setRowExpandRatio(2, 1.0f); setCompositionRoot(grid); }
From source file:org.activiti.explorer.ui.content.CreateAttachmentPopupWindow.java
License:Apache License
public CreateAttachmentPopupWindow() { this.i18nManager = ExplorerApp.get().getI18nManager(); this.attachmentRendererManager = ExplorerApp.get().getAttachmentRendererManager(); this.taskService = ProcessEngines.getDefaultProcessEngine().getTaskService(); setCaption(i18nManager.getMessage(Messages.RELATED_CONTENT_ADD)); setWidth(700, UNITS_PIXELS);//www . ja v a 2 s . co m setHeight(430, UNITS_PIXELS); center(); setModal(true); addStyleName(Reindeer.WINDOW_LIGHT); layout = new HorizontalLayout(); layout.setSpacing(false); layout.setMargin(true); layout.setSizeFull(); setContent(layout); initTable(); detailLayout = new GridLayout(1, 2); detailLayout.setSizeFull(); detailLayout.setMargin(true); detailLayout.setSpacing(true); detailLayout.addStyleName(ExplorerLayout.STYLE_RELATED_CONTENT_CREATE_DETAIL); layout.addComponent(detailLayout); layout.setExpandRatio(detailLayout, 1.0f); detailLayout.setRowExpandRatio(0, 1.0f); detailLayout.setColumnExpandRatio(0, 1.0f); initActions(); }