List of usage examples for com.vaadin.ui GridLayout setSpacing
@Override public void setSpacing(boolean spacing)
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); 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)); }/*from w w w . java2 s . co m*/ } else { buildComponent(component, mapComponents, fieldIdList, extraObjects); } } } return layout; }
From source file:org.accelerators.activiti.admin.ui.GroupCreateForm.java
License:Open Source License
/** * /*from w ww .j ava 2 s. c om*/ * @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 w ww. ja v a 2 s .co m*/ * @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.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 ww . j a v a 2s . c o m 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);/*w ww .ja va 2s. c o 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; } }); }
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);//w ww. j ava 2s . c o 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 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.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 w w w . j a va 2s .c o 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 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.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); details.setMargin(false, false, true, false); details.setColumnExpandRatio(1, 1.0f); detailPanelLayout.addComponent(details); // Image//from w w w . java 2 s . c o m 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.explorer.ui.flow.ProcessDefinitionDetailPanel.java
License:Apache License
protected void initHeader() { GridLayout taskDetails = new GridLayout(4, 2); taskDetails.setWidth(100, UNITS_PERCENTAGE); taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); taskDetails.setSpacing(true); taskDetails.setMargin(false, false, true, false); // Add image/*from w w w . j a v a2 s .co m*/ Embedded image = new Embedded(null, Images.FLOW_50); taskDetails.addComponent(image, 0, 0, 0, 1); // Add task name Label nameLabel = new Label(processDefinition.getName()); nameLabel.addStyleName(Reindeer.LABEL_H2); taskDetails.addComponent(nameLabel, 1, 0, 3, 0); // Add version String versionString = i18nManager.getMessage(Messages.FLOW_VERSION, processDefinition.getVersion()); Label versionLabel = new Label(versionString); versionLabel.addStyleName(ExplorerLayout.STYLE_FLOW_HEADER_VERSION); taskDetails.addComponent(versionLabel, 1, 1); // Add deploy time PrettyTimeLabel deployTimeLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.FLOW_DEPLOY_TIME), deployment.getDeploymentTime(), null); deployTimeLabel.addStyleName(ExplorerLayout.STYLE_FLOW_HEADER_DEPLOY_TIME); taskDetails.addComponent(deployTimeLabel, 2, 1); taskDetails.setColumnExpandRatio(1, 1.0f); taskDetails.setColumnExpandRatio(2, 1.0f); taskDetails.setColumnExpandRatio(3, 1.0f); verticalLayout.addComponent(taskDetails); }
From source file:org.activiti.explorer.ui.flow.ProcessInstanceDetailPanel.java
License:Apache License
protected void addName() { GridLayout header = new GridLayout(3, 2); header.setWidth(100, UNITS_PERCENTAGE); header.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); header.setSpacing(true); header.setMargin(false, false, true, false); // Add image/*from w ww. ja v a 2 s. c om*/ Embedded image = new Embedded(null, Images.FLOW_50); header.addComponent(image, 0, 0, 0, 1); // Add task name Label nameLabel = new Label(processDefinition.getName() + " (" + processInstance.getId() + ")"); nameLabel.addStyleName(Reindeer.LABEL_H2); header.addComponent(nameLabel, 1, 0, 2, 0); // Add start time PrettyTimeLabel startTimeLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.FLOW_START_TIME), historicProcessInstance.getStartTime(), null); startTimeLabel.addStyleName(ExplorerLayout.STYLE_FLOW_HEADER_START_TIME); header.addComponent(startTimeLabel, 1, 1); header.setColumnExpandRatio(1, 1.0f); header.setColumnExpandRatio(2, 1.0f); verticalLayout.addComponent(header); }