List of usage examples for com.vaadin.ui VerticalLayout addComponent
@Override public void addComponent(Component c)
From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java
License:Open Source License
private void createView() { LspsUI ui = (LspsUI) getUI();/* w w w .j av a 2 s .c o m*/ Person user = ui.getUser().getPerson(); userRights = user.getRights(); setTitle(ui.getMessage(TITLE)); Panel panel = new Panel(); panel.addStyleName("l-border-none"); setContent(panel); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); panel.setContent(layout); //user data and settings will be laid out next to each other HorizontalLayout topSection = new HorizontalLayout(); topSection.setSpacing(true); topSection.setWidth("100%"); layout.addComponent(topSection); VerticalLayout userData = createUserDataSection(ui, user); topSection.addComponent(userData); topSection.setExpandRatio(userData, 1); Label spacer = new Label(); spacer.setWidth("20px"); topSection.addComponent(spacer); VerticalLayout settings = createSettingsSection(ui); topSection.addComponent(settings); topSection.setExpandRatio(settings, 1); //substitution section VerticalLayout substitution = createSubstitutionSection(ui, user); layout.addComponent(substitution); Label spacer2 = new Label(); spacer2.setHeight("10px"); layout.addComponent(spacer2); //buttons HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); Button saveButton = new Button(ui.getMessage("action.save"), new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (save()) { if (requestReload) { JavaScript.getCurrent().execute("window.location.reload()"); } else { close(); } } } }); saveButton.setData(BUTTON_TYPE_SAVE); buttons.addComponent(saveButton); Button cancelButton = new Button(ui.getMessage("action.cancel"), new ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); buttons.addComponent(cancelButton); layout.addComponent(buttons); }
From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java
License:Open Source License
private VerticalLayout createUserDataSection(LspsUI ui, Person user) { VerticalLayout userData = new VerticalLayout(); Label userDataHeader = new Label("<h2>" + ui.getMessage("settings.userSection") + "</h2>", ContentMode.HTML);//from w ww. j a va2s.c o m userData.addComponent(userDataHeader); FormLayout userDataContent = new FormLayout(); if ((userRights.contains(OsRights.CHANGE_OWN_PASSWORD)) || (userRights.contains(OsRights.MANAGE_PERSON))) { this.passwordField = new PasswordField(ui.getMessage("settings.password")); passwordField.setWidth("100%"); userDataContent.addComponent(passwordField); this.confirmation = new PasswordField(ui.getMessage("settings.passwordVerification")); confirmation.setWidth("100%"); userDataContent.addComponent(confirmation); } this.email = new TextField(ui.getMessage("settings.email")); email.setWidth("100%"); email.setValue(user.getEmail()); email.setNullRepresentation(""); userDataContent.addComponent(email); this.telephone = new TextField(ui.getMessage("settings.phoneNumber")); telephone.setWidth("100%"); telephone.setValue(user.getPhone()); telephone.setNullRepresentation(""); userDataContent.addComponent(telephone); userData.addComponent(userDataContent); return userData; }
From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java
License:Open Source License
private VerticalLayout createSettingsSection(LspsUI ui) { VerticalLayout settings = new VerticalLayout(); settings.setSpacing(true);//from ww w. j av a 2 s. c o m Label settingsHeader = new Label("<h2>" + ui.getMessage("settings.applicationSection") + "</h2>", ContentMode.HTML); settings.addComponent(settingsHeader); this.languages = new OptionGroup(ui.getMessage("settings.language")); languages.addStyleName("ui-spacing"); languages.addItem("en_US"); languages.setItemCaption("en_US", "English"); languages.addItem("de_DE"); languages.setItemCaption("de_DE", "Deutsch"); languages.addItem("sk_SK"); languages.setItemCaption("sk_SK", "Slovensky"); languages.setValue(ui.getLocale().toString()); settings.addComponent(languages); this.themes = new OptionGroup(ui.getMessage("settings.theme")); themes.addStyleName("ui-spacing"); for (String s : Constants.THEMES) { themes.addItem(s); } String userTheme = ui.getUser().getSettingString("theme", Constants.DEFAULT_THEME); themes.setValue(userTheme); themes.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { if (Constants.CUSTOMISABLE_THEMES.contains(themes.getValue().toString())) { layoutSettings.setVisible(true); fontSettings.setVisible(true); } else { layoutSettings.setVisible(false); fontSettings.setVisible(false); } } }); settings.addComponent(themes); layoutSettings = new OptionGroup(ui.getMessage("settings.layout")); layoutSettings.addStyleName("ui-spacing"); layoutSettings.addItem("compact"); layoutSettings.setItemCaption("compact", ui.getMessage("settings.layout.compact")); layoutSettings.addItem("standard"); layoutSettings.setItemCaption("standard", ui.getMessage("settings.layout.standard")); layoutSettings.addItem("generous"); layoutSettings.setItemCaption("generous", ui.getMessage("settings.layout.generous")); layoutSettings.setValue(ui.getUser().getSettingString("layoutSetting", "compact")); settings.addComponent(layoutSettings); fontSettings = new OptionGroup(ui.getMessage("settings.font")); fontSettings.addStyleName("ui-spacing"); fontSettings.addItem("small"); fontSettings.setItemCaption("small", ui.getMessage("settings.font.small")); fontSettings.addItem("standard"); fontSettings.setItemCaption("standard", ui.getMessage("settings.font.standard")); fontSettings.addItem("large"); fontSettings.setItemCaption("large", ui.getMessage("settings.font.large")); fontSettings.addItem("huge"); fontSettings.setItemCaption("huge", ui.getMessage("settings.font.huge")); fontSettings.setValue(ui.getUser().getSettingString("fontSetting", "standard")); settings.addComponent(fontSettings); if (!Constants.CUSTOMISABLE_THEMES.contains(userTheme)) { layoutSettings.setVisible(false); fontSettings.setVisible(false); } return settings; }
From source file:com.lst.deploymentautomation.vaadin.page.SettingsView.java
License:Open Source License
private VerticalLayout createSubstitutionSection(LspsUI ui, Person user) { VerticalLayout substitution = new VerticalLayout(); substitution.setSpacing(true);/*w w w . ja va2 s.com*/ Label substitutionHeader = new Label("<h2>" + ui.getMessage("settings.substitutionSection") + "</h2>", ContentMode.HTML); substitution.addComponent(substitutionHeader); Label substitutionHelp = new Label(ui.getMessage("settings.substitutionHelp")); substitutionHelp.setStyleName("form-help"); substitution.addComponent(substitutionHelp); this.substitutionActive = new CheckBox(ui.getMessage("settings.substitutionActive")); substitutionActive.addStyleName("ui-spacing"); substitutionActive.setValue(user.isSubstitutionActive()); substitution.addComponent(substitutionActive); //substitutes Set<Person> selectedPersons = user.getDirectSubstitutes(); //all persons except the user himself Collection<Person> persons = new ArrayList<Person>( personService.findPersons(new PersonCriteria()).getData()); this.substitutes = new OptionGroup(ui.getMessage("settings.substitutes")); substitutes.setMultiSelect(true); substitutes.addStyleName("ui-spacing"); for (Person substitute : persons) { if (!substitute.equals(user)) { substitutes.addItem(substitute); substitutes.setItemCaption(substitute, substitute.getFullName()); } } substitutes.setValue(selectedPersons); substitution.addComponent(substitutes); return substitution; }
From source file:com.lst.deploymentautomation.vaadin.page.TodoListView.java
License:Open Source License
@SuppressWarnings("serial") private void createView() { final LspsUI ui = (LspsUI) getUI(); setTitle(ui.getMessage(TITLE));/*ww w .ja va 2 s. c o m*/ VerticalLayout layout = new VerticalLayout(); setContent(layout); table = new Table(); table.setSizeFull(); table.setSelectable(true); table.setMultiSelectMode(MultiSelectMode.SIMPLE); table.setSortEnabled(false); table.setColumnReorderingAllowed(true); table.setColumnCollapsingAllowed(true); table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { final Object sel = event.getProperty().getValue(); if (sel instanceof Set) { selection = (Set<Long>) sel; } else if (sel instanceof Long) { selection = Collections.singleton((Long) sel); } else { selection = Collections.emptySet(); } //enable todo actions only if the sel is non-empty actionBtn.setEnabled(selection.size() > 0); } }); table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (table.isMultiSelect()) { return; //don't do anything if in selection mode } if (event.getButton() != MouseButton.LEFT || event.isDoubleClick()) { return; //ignore right-clicks } final Item item = event.getItem(); final Long todoId = (Long) item.getItemProperty("id").getValue(); try { ((LspsUI) getUI()).openTodo(todoId); } catch (Exception e) { Utils.log(e, "could not open to-do " + todoId, log); final LspsUI ui = (LspsUI) getUI(); ui.showErrorMessage("app.unknownErrorOccurred", e); //todo.openFailed? } } }); table.setContainerDataSource(container); Object[] defaultColumns = new Object[] { "title", "notes", "priority", "authorization", "modelInstanceId", "issuedDate" }; //load table settings String settings = ui.getUser().getSettingString(SETTINGS_KEY, null); if (settings == null) { table.setVisibleColumns(defaultColumns); originalSettings = getColumnSettings(); } else { originalSettings = settings; try { applyTableSettings(settings); } catch (Exception e) { table.setVisibleColumns(defaultColumns); Utils.log(e, "could not load todo list settings", log); } } table.setColumnHeader("title", ui.getMessage("todo.title")); table.setColumnHeader("notes", ui.getMessage("todo.notes")); table.setColumnHeader("priority", ui.getMessage("todo.priority")); table.setColumnHeader("authorization", ui.getMessage("todo.authorizationShort")); table.setColumnHeader("modelInstanceId", ui.getMessage("todo.process")); table.setColumnHeader("issuedDate", ui.getMessage("todo.issued")); table.setColumnAlignment("modelInstanceId", Table.Align.CENTER); table.setColumnExpandRatio("title", 2); table.setColumnExpandRatio("notes", 1); //localize todo titles table.addGeneratedColumn("title", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { @SuppressWarnings("unchecked") BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId); return ui.localizeEngineText(item.getBean().getTitle()); } }); //show icons for authorization table.addGeneratedColumn("authorization", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { @SuppressWarnings("unchecked") BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId); String icon; String text; switch (item.getBean().getAuthorization()) { case INITIAL_PERFORMER: icon = "auth_performer.gif"; text = ui.getMessage("todo.authorizationPerformer"); break; case DELEGATE: icon = "auth_delegate.gif"; text = ui.getMessage("todo.authorizationDelegate"); break; case SUBSTITUTE: icon = "auth_substitute.gif"; text = ui.getMessage("todo.authorizationSubstitute"); break; case NOT_PERMITTED: default: icon = "auth_unknown.gif"; text = ui.getMessage("todo.authorizationUnknown"); break; } Embedded authIcon = new Embedded(null, new ThemeResource("../icons/" + icon)); authIcon.setDescription(text); if (item.getBean().getAllocatedTo() != null) { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); layout.addComponent(authIcon); Embedded lockedIcon = new Embedded(null, new ThemeResource("../icons/lock.gif")); lockedIcon.setDescription( ui.getMessage("todo.lockedBy", item.getBean().getAllocatedToFullName())); layout.addComponent(lockedIcon); return layout; } else { return authIcon; } } }); //format date final SimpleDateFormat df = new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")); table.addGeneratedColumn("issuedDate", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { @SuppressWarnings("unchecked") BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId); return df.format(item.getBean().getIssuedDate()); } }); layout.addComponent(table); layout.setExpandRatio(table, 1); }
From source file:com.lst.deploymentautomation.vaadin.page.TodoView.java
License:Open Source License
@Override protected void setContent(Component content) { VerticalLayout layout = new VerticalLayout(); layout.setSizeFull();//from ww w .j a va 2s.com layout.addComponent(annotations); layout.addComponent(content); layout.setExpandRatio(content, 1); super.setContent(layout); }
From source file:com.lst.deploymentautomation.vaadin.popup.TodoAnnotation.java
License:Open Source License
@Override public void attach() { super.attach(); LspsUI ui = (LspsUI) getUI();//from w w w . j a va 2s . co m setCaption(ui.getMessage("todo.annotationTitle")); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); setContent(layout); Label help = new Label(ui.getMessage("todo.annotationHelp")); help.setStyleName("form-help"); layout.addComponent(help); priorityField = new TextField(ui.getMessage("todo.priority"), priority); //TODO forbid negative priorities priorityField.setConverter(Integer.class); priorityField.setConversionError(ui.getMessage("app.invalidValueMessage")); priorityField.setNullRepresentation(""); priorityField.setNullSettingAllowed(true); layout.addComponent(priorityField); TextArea notesField = new TextArea(ui.getMessage("todo.notes"), notes); notesField.setMaxLength(1024); notesField.setNullRepresentation(""); priorityField.setNullSettingAllowed(true); notesField.setSizeFull(); layout.addComponent(notesField); layout.setExpandRatio(notesField, 1); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); layout.addComponent(buttons); @SuppressWarnings("serial") Button submitButton = new Button(ui.getMessage("action.annotate"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { annotate(); } }); buttons.addComponent(submitButton); @SuppressWarnings("serial") Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); buttons.addComponent(cancelButton); }
From source file:com.lst.deploymentautomation.vaadin.popup.TodoDelegation.java
License:Open Source License
@Override public void attach() { super.attach(); LspsUI ui = (LspsUI) getUI();//w ww. j a va 2 s.c om setCaption(ui.getMessage("todo.delegationTitle")); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); setContent(layout); Label help = new Label(ui.getMessage("todo.delegationHelp")); help.setStyleName("form-help"); layout.addComponent(help); Collection<Person> allUsers = new ArrayList<Person>( personService.findPersons(new PersonCriteria()).getData()); Set<Person> substitutes = ui.getUser().getPerson().getDirectSubstitutes(); Set<String> substitutesIds = new HashSet<String>(); for (Person p : substitutes) { substitutesIds.add(p.getId()); } delegates = new OptionGroup(ui.getMessage("todo.delegates")); delegates.setMultiSelect(true); delegates.addStyleName("ui-spacing"); delegates.setRequired(true); delegates.setSizeFull(); for (Person p : allUsers) { delegates.addItem(p.getId()); delegates.setItemCaption(p.getId(), p.getFullName()); } delegates.setValue(substitutesIds); layout.addComponent(delegates); layout.setExpandRatio(delegates, 1); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); layout.addComponent(buttons); @SuppressWarnings("serial") Button delegateButton = new Button(ui.getMessage("action.delegate"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { delegate(); } }); buttons.addComponent(delegateButton); @SuppressWarnings("serial") Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); buttons.addComponent(cancelButton); }
From source file:com.lst.deploymentautomation.vaadin.popup.TodoEscalation.java
License:Open Source License
@Override public void attach() { super.attach(); LspsUI ui = (LspsUI) getUI();// w w w . ja v a 2 s .com setCaption(ui.getMessage("todo.escalationTitle")); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); setContent(layout); Label help = new Label(ui.getMessage("todo.escalationHelp")); help.setStyleName("form-help"); layout.addComponent(help); reason = new TextArea(ui.getMessage("todo.escalationReason")); reason.setMaxLength(1024); reason.setRequired(true); reason.setSizeFull(); layout.addComponent(reason); layout.setExpandRatio(reason, 1); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); layout.addComponent(buttons); @SuppressWarnings("serial") Button submitButton = new Button(ui.getMessage("action.escalate"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { escalate(); } }); buttons.addComponent(submitButton); @SuppressWarnings("serial") Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); buttons.addComponent(cancelButton); }
From source file:com.lst.deploymentautomation.vaadin.popup.TodoRejection.java
License:Open Source License
@Override public void attach() { super.attach(); LspsUI ui = (LspsUI) getUI();//ww w . j a v a 2 s. co m setCaption(ui.getMessage("todo.rejectionTitle")); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); setContent(layout); Label help = new Label(ui.getMessage("todo.rejectionHelp")); help.setStyleName("form-help"); layout.addComponent(help); reason = new TextArea(ui.getMessage("todo.rejectionReason")); reason.setMaxLength(1024); reason.setRequired(true); reason.setSizeFull(); layout.addComponent(reason); layout.setExpandRatio(reason, 1); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); layout.addComponent(buttons); @SuppressWarnings("serial") Button rejectButton = new Button(ui.getMessage("action.reject"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { reject(); } }); buttons.addComponent(rejectButton); @SuppressWarnings("serial") Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); } }); buttons.addComponent(cancelButton); }