List of usage examples for com.vaadin.ui GridLayout setColumnExpandRatio
public void setColumnExpandRatio(int columnIndex, float ratio)
From source file:com.lst.deploymentautomation.vaadin.popup.TodoDetails.java
License:Open Source License
private Component createTodoInfo(LspsUI ui) { GridLayout grid = new GridLayout(2, 10); grid.setMargin(true);/* ww w. j a va2 s .co m*/ grid.setSpacing(true); grid.setWidth("100%"); grid.setColumnExpandRatio(0, 1); grid.setColumnExpandRatio(1, 2); grid.addComponent(new Label(ui.getMessage("todo.id"))); grid.addComponent(new Label(String.valueOf(todo.getId()))); // grid.addComponent(new Label(ui.getMessage("todo.process"))); // grid.addComponent(new Label(String.valueOf(todo.getModelInstanceId()))); // grid.addComponent(new Label(ui.getMessage("todo.title"))); // grid.addComponent(new Label(ui.localizeEngineText(todo.getTitle()))); grid.addComponent(new Label(ui.getMessage("todo.task"))); grid.addComponent(new Label(todo.getTaskNamespace())); grid.addComponent(new Label(ui.getMessage("todo.issued"))); grid.addComponent( new Label(new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")).format(todo.getIssuedDate()))); String status = "???"; switch (todo.getStatus()) { case ALIVE: status = ui.getMessage("todo.statusAlive"); break; case ACCOMPLISHED: status = ui.getMessage("todo.statusAccomplished", todo.getSubmittedDate()); break; case INTERRUPTED: status = ui.getMessage("todo.statusInterrupted", todo.getSubmittedDate(), todo.getInterruptionReason()); break; case SUSPENDED: status = ui.getMessage("todo.statusSuspended"); break; } grid.addComponent(new Label(ui.getMessage("todo.status"))); grid.addComponent(new Label(status)); try { TodoAuthorization authorization = todoService.getAuthorization(todo.getId(), ui.getUser().getPerson().getId()); String authMsg; switch (authorization) { case INITIAL_PERFORMER: authMsg = ui.getMessage("todo.authorizationPerformer"); break; case DELEGATE: authMsg = ui.getMessage("todo.authorizationDelegate"); break; case SUBSTITUTE: authMsg = ui.getMessage("todo.authorizationSubstitute"); break; case NOT_PERMITTED: default: authMsg = ui.getMessage("todo.authorizationUnknown"); break; } grid.addComponent(new Label(ui.getMessage("todo.authorization"))); grid.addComponent(new Label(authMsg)); } catch (Exception e) { Utils.rethrow(e, "could not get authorization for " + todo.getId(), log); } //currently it's always the current user; no need to show him // grid.addComponent(new Label(ui.getMessage("todo.responsible"))); // grid.addComponent(new Label(todo.getAllocatedToFullName())); return grid; }
From source file:com.mycollab.module.crm.ui.components.PeopleInfoComp.java
License:Open Source License
public void displayEntryPeople(ValuedBean bean) { this.removeAllComponents(); this.withMargin(false); Label peopleInfoHeader = new Label( FontAwesome.USER.getHtml() + " " + UserUIContext.getMessage(CrmCommonI18nEnum.SUB_INFO_PEOPLE), ContentMode.HTML);//w w w .ja v a 2s. c om peopleInfoHeader.setStyleName("info-hdr"); this.addComponent(peopleInfoHeader); GridLayout layout = new GridLayout(2, 2); layout.setSpacing(true); layout.setWidth("100%"); layout.setMargin(new MarginInfo(false, false, false, true)); try { Label createdLbl = new Label(UserUIContext.getMessage(CrmCommonI18nEnum.ITEM_CREATED_PEOPLE)); createdLbl.setSizeUndefined(); layout.addComponent(createdLbl, 0, 0); String createdUserName = (String) PropertyUtils.getProperty(bean, "createduser"); String createdUserAvatarId = (String) PropertyUtils.getProperty(bean, "createdUserAvatarId"); String createdUserDisplayName = (String) PropertyUtils.getProperty(bean, "createdUserFullName"); UserLink createdUserLink = new UserLink(createdUserName, createdUserAvatarId, createdUserDisplayName); layout.addComponent(createdUserLink, 1, 0); layout.setColumnExpandRatio(1, 1.0f); Label assigneeLbl = new Label(UserUIContext.getMessage(CrmCommonI18nEnum.ITEM_ASSIGN_PEOPLE)); assigneeLbl.setSizeUndefined(); layout.addComponent(assigneeLbl, 0, 1); String assignUserName = (String) PropertyUtils.getProperty(bean, "assignuser"); String assignUserAvatarId = (String) PropertyUtils.getProperty(bean, "assignUserAvatarId"); String assignUserDisplayName = (String) PropertyUtils.getProperty(bean, "assignUserFullName"); UserLink assignUserLink = new UserLink(assignUserName, assignUserAvatarId, assignUserDisplayName); layout.addComponent(assignUserLink, 1, 1); } catch (Exception e) { LOG.error("Can not build user link {} ", BeanUtility.printBeanObj(bean)); } this.addComponent(layout); }
From source file:com.mymita.vaadlets.VaadletsBuilder.java
License:Apache License
private static void setLayoutAttributes(final com.vaadin.ui.Component vaadinComponent, final com.mymita.vaadlets.core.Component vaadletsComponent) { if (vaadletsComponent instanceof com.mymita.vaadlets.layout.AbstractLayout) { final Boolean margin = ((com.mymita.vaadlets.layout.AbstractLayout) vaadletsComponent).isMargin(); if (margin != null) { ((com.vaadin.ui.AbstractLayout) vaadinComponent).setMargin(margin); }//from w w w. j a v a 2 s . c o m final Boolean marginTop = ((com.mymita.vaadlets.layout.AbstractLayout) vaadletsComponent).isMarginTop(); final Boolean marginRight = ((com.mymita.vaadlets.layout.AbstractLayout) vaadletsComponent) .isMarginRight(); final Boolean marginBottom = ((com.mymita.vaadlets.layout.AbstractLayout) vaadletsComponent) .isMarginBottom(); final Boolean marginLeft = ((com.mymita.vaadlets.layout.AbstractLayout) vaadletsComponent) .isMarginLeft(); if (marginTop != null || marginRight != null || marginBottom != null || marginLeft != null) { ((com.vaadin.ui.AbstractLayout) vaadinComponent).setMargin( firstNonNull(marginTop, firstNonNull(margin, FALSE)), firstNonNull(marginRight, firstNonNull(margin, FALSE)), firstNonNull(marginBottom, firstNonNull(margin, FALSE)), firstNonNull(marginLeft, firstNonNull(margin, FALSE))); } } if (vaadletsComponent instanceof com.mymita.vaadlets.layout.OrderedLayout) { final Boolean spacing = ((com.mymita.vaadlets.layout.OrderedLayout) vaadletsComponent).isSpacing(); if (spacing != null) { ((com.vaadin.ui.AbstractOrderedLayout) vaadinComponent).setSpacing(spacing); } } if (vaadletsComponent instanceof com.mymita.vaadlets.layout.GridLayout) { final com.vaadin.ui.GridLayout vaadinGridLayout = (com.vaadin.ui.GridLayout) vaadinComponent; final com.mymita.vaadlets.layout.GridLayout vaadletsGridLayout = (com.mymita.vaadlets.layout.GridLayout) vaadletsComponent; vaadinGridLayout.setColumns(vaadletsGridLayout.getColumns()); vaadinGridLayout.setRows(vaadletsGridLayout.getRows()); for (final Object object : vaadletsGridLayout.getColumnExpandRatioOrRowExpandRatio()) { if (object instanceof GridLayoutColumExpandRatio) { final GridLayoutColumExpandRatio cr = (GridLayoutColumExpandRatio) object; vaadinGridLayout.setColumnExpandRatio(cr.getColumnIndex(), cr.getRatio()); } if (object instanceof GridLayoutRowExpandRatio) { final GridLayoutRowExpandRatio rr = (GridLayoutRowExpandRatio) object; vaadinGridLayout.setRowExpandRatio(rr.getRowIndex(), rr.getRatio()); } } final Boolean spacing = ((com.mymita.vaadlets.layout.GridLayout) vaadletsComponent).isSpacing(); if (spacing != null) { ((com.vaadin.ui.GridLayout) vaadinComponent).setSpacing(spacing); } } }
From source file:com.openhris.employee.salary.EmployeeSalaryInformation.java
public ComponentContainer layout() { GridLayout glayout = new GridLayout(2, 8); glayout.setSpacing(true);/*from ww w . j av a2 s .c o m*/ glayout.setWidth("600px"); glayout.setHeight("100%"); employmentStatus = dropDown.populateEmploymentStatus("Employment Status: "); employmentStatus.setWidth("200px"); glayout.addComponent(employmentStatus, 0, 0); Button esBtn = new Button("UPDATE EMPLOYMENT STATUS"); esBtn.setWidth("100%"); glayout.addComponent(esBtn, 1, 0); esBtn.addListener(buttonClickListener); glayout.setColumnExpandRatio(1, 1); glayout.setComponentAlignment(esBtn, Alignment.BOTTOM_LEFT); if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) { esBtn.setEnabled(true); } else { esBtn.setEnabled(false); } glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 2, 1, 2); employmentWageStatus = dropDown.populateEmploymentWageStatus("Employment Wage Status: "); employmentWageStatus.setWidth("200px"); glayout.addComponent(employmentWageStatus, 0, 3); Button ewsBtn = new Button("UPDATE EMPLOYMENT WAGE STATUS"); ewsBtn.setWidth("100%"); ewsBtn.addListener(buttonClickListener); glayout.addComponent(ewsBtn, 1, 3); glayout.setComponentAlignment(ewsBtn, Alignment.BOTTOM_LEFT); if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) { ewsBtn.setEnabled(true); } else { ewsBtn.setEnabled(false); } glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 4, 1, 4); employmentWageEntry = dropDown.populateEmploymentWageEntry("Employment Wage Entry: "); employmentWageEntry.setWidth("200px"); glayout.addComponent(employmentWageEntry, 0, 5); Button eweBtn = new Button("UPDATE EMPLOYMENT WAGE ENTRY"); eweBtn.setWidth("100%"); glayout.addComponent(eweBtn, 1, 5); eweBtn.addListener(buttonClickListener); glayout.setComponentAlignment(eweBtn, Alignment.BOTTOM_LEFT); if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) { eweBtn.setEnabled(true); } else { eweBtn.setEnabled(false); } glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 6, 1, 6); employmentWage = new TextField("Employment Wage"); employmentWage.setWidth("200px"); employmentWage.addStyleName("numerical"); glayout.addComponent(employmentWage, 0, 7); Button ewBtn = new Button("UPDATE EMPLOYMENT WAGE"); ewBtn.setWidth("100%"); glayout.addComponent(ewBtn, 1, 7); ewBtn.addListener(buttonClickListener); glayout.setComponentAlignment(ewBtn, Alignment.BOTTOM_LEFT); if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) { ewBtn.setEnabled(true); } else { ewBtn.setEnabled(false); } if (getEmployeeId() != null) { EmploymentInformation ei = si.getEmployeeSalaryInformation(getEmployeeId()); employmentStatus.setValue( Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_STATUS, ei.getEmploymentStatus())); employmentWageStatus.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_WAGE_STATUS, ei.getEmploymentWageStatus())); employmentWageEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_WAGE_ENTRY, ei.getEmploymentWageEntry())); employmentWage.setValue(ei.getEmploymentWage()); } return glayout; }
From source file:com.openhris.employee.salary.EmployeeSalaryInformation.java
public ComponentContainer layout2() { GridLayout glayout = new GridLayout(2, 1); glayout.setSpacing(true);//from www.jav a 2 s .co m glayout.setWidth("600px"); TextField employmentStatusField = new HRISTextField("Employment Status: "); employmentStatusField.setWidth("200px"); glayout.addComponent(employmentStatusField, 0, 0); Button setContributionBtn = new Button("SET EMPLOYEE'S CONTRIBUTIONS MAIN BRANCH"); setContributionBtn.setWidth("100%"); setContributionBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Window subWindow = setContributionMainBranch(); if (subWindow.getParent() == null) { getWindow().addWindow(subWindow); } subWindow.setModal(true); subWindow.center(); } }); glayout.addComponent(setContributionBtn, 1, 0); glayout.setColumnExpandRatio(1, 1); glayout.setComponentAlignment(setContributionBtn, Alignment.BOTTOM_CENTER); if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) { setContributionBtn.setEnabled(true); } else { setContributionBtn.setEnabled(false); } if (getEmployeeId() != null) { EmploymentInformation employmentInformation = si.getEmployeeSalaryInformation(getEmployeeId()); employmentStatusField.setValue(employmentInformation.getCurrentStatus().toUpperCase()); } employmentStatusField.setReadOnly(true); return glayout; }
From source file:com.scsb.crpro.MessageBox.java
License:Apache License
/** * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)}, * but the message component is defined explicitly. The component can be even a composite * of a layout manager and manager further Vaadin components. * /* www. j a v a2 s . c o m*/ * @param messageComponent a Vaadin component */ public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon, Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) { super(); setResizable(false); setClosable(false); setSizeUndefined(); setWidth(dialogWidth); //setHeight(dialogHeight); setCaption(dialogCaption); GridLayout mainLayout = new GridLayout(2, 2); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setSizeUndefined(); mainLayout.setWidth(GRID_DEFAULT_WIDTH1); // Add Content messageComponent.setSizeUndefined(); messageComponent.setWidth(GRID_DEFAULT_WIDTH2); if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) { mainLayout.addComponent(messageComponent, 0, 0, 1, 0); mainLayout.setRowExpandRatio(0, 1.0f); mainLayout.setColumnExpandRatio(0, 1.0f); } else { mainLayout.addComponent(messageComponent, 1, 0); mainLayout.setRowExpandRatio(0, 1.0f); mainLayout.setColumnExpandRatio(1, 1.0f); Embedded icon = null; switch (dialogIcon) { case QUESTION: icon = new Embedded(null, new ThemeResource("images/question.png")); break; case INFO: icon = new Embedded(null, new ThemeResource("images/info.png")); break; case WARN: icon = new Embedded(null, new ThemeResource("images/warn.png")); break; case ERROR: icon = new Embedded(null, new ThemeResource("images/error.png")); break; } mainLayout.addComponent(icon, 0, 0); icon.setWidth(ICON_DEFAULT_SIZE); icon.setHeight(ICON_DEFAULT_SIZE); } // Add Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); mainLayout.addComponent(buttonLayout, 0, 1, 1, 1); mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment); for (ButtonConfig buttonConfig : buttonConfigs) { Button button = new Button(buttonConfig.getCaption(), new ButtonClickListener(buttonConfig.getButtonType())); if (buttonConfig.getWidth() != null) { button.setWidth(buttonConfig.getWidth()); } if (buttonConfig.getOptionalResource() != null) { button.setIcon(buttonConfig.getOptionalResource()); } else { Resource icon = null; switch (buttonConfig.getButtonType()) { case ABORT: icon = new ThemeResource("images/famfamfam/cross.png"); break; case CANCEL: icon = new ThemeResource("images/famfamfam/cross.png"); break; case CLOSE: icon = new ThemeResource("images/famfamfam/door.png"); break; case HELP: icon = new ThemeResource("images/famfamfam/lightbulb.png"); break; case OK: icon = new ThemeResource("images/famfamfam/tick.png"); break; case YES: icon = new ThemeResource("images/famfamfam/tick.png"); break; case NO: icon = new ThemeResource("images/famfamfam/cross.png"); break; case SAVE: icon = new ThemeResource("images/famfamfam/disk.png"); break; case RETRY: icon = new ThemeResource("images/famfamfam/arrow_refresh.png"); break; case IGNORE: icon = new ThemeResource("images/famfamfam/lightning_go.png"); break; } button.setIcon(icon); } buttonLayout.addComponent(button); } setContent(mainLayout); }
From source file:com.scsb.vaadin.composite.MessageBox.java
License:Apache License
/** * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)}, * but the message component is defined explicitly. The component can be even a composite * of a layout manager and manager further Vaadin components. * // w w w .j a va 2 s. c o m * @param messageComponent a Vaadin component */ public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon, Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) { super(); setResizable(false); setClosable(false); setSizeUndefined(); setWidth(dialogWidth); //setHeight(dialogHeight); setCaption(dialogCaption); GridLayout mainLayout = new GridLayout(2, 2); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setSizeUndefined(); mainLayout.setWidth(GRID_DEFAULT_WIDTH1); // Add Content messageComponent.setSizeUndefined(); messageComponent.setWidth(GRID_DEFAULT_WIDTH2); if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) { mainLayout.addComponent(messageComponent, 0, 0, 1, 0); mainLayout.setRowExpandRatio(0, 1.0f); mainLayout.setColumnExpandRatio(0, 1.0f); } else { mainLayout.addComponent(messageComponent, 1, 0); mainLayout.setRowExpandRatio(0, 1.0f); mainLayout.setColumnExpandRatio(1, 1.0f); Embedded icon = null; switch (dialogIcon) { case QUESTION: icon = new Embedded(null, new ThemeResource("./images/question.png")); break; case INFO: icon = new Embedded(null, new ThemeResource("./images/info.png")); break; case WARN: icon = new Embedded(null, new ThemeResource("./images/warn.png")); break; case ERROR: icon = new Embedded(null, new ThemeResource("./images/error.png")); break; } mainLayout.addComponent(icon, 0, 0); icon.setWidth(ICON_DEFAULT_SIZE); icon.setHeight(ICON_DEFAULT_SIZE); } // Add Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); mainLayout.addComponent(buttonLayout, 0, 1, 1, 1); mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment); for (ButtonConfig buttonConfig : buttonConfigs) { Button button = new Button(buttonConfig.getCaption(), new ButtonClickListener(buttonConfig.getButtonType())); if (buttonConfig.getWidth() != null) { button.setWidth(buttonConfig.getWidth()); } if (buttonConfig.getOptionalResource() != null) { button.setIcon(buttonConfig.getOptionalResource()); } else { Resource icon = null; switch (buttonConfig.getButtonType()) { case ABORT: icon = new ThemeResource("images/famfamfam/cross.png"); break; case CANCEL: icon = new ThemeResource("images/famfamfam/cross.png"); break; case CLOSE: icon = new ThemeResource("images/famfamfam/door.png"); break; case HELP: icon = new ThemeResource("images/famfamfam/lightbulb.png"); break; case OK: icon = new ThemeResource("images/famfamfam/tick.png"); break; case YES: icon = new ThemeResource("images/famfamfam/tick.png"); break; case NO: icon = new ThemeResource("images/famfamfam/cross.png"); break; case SAVE: icon = new ThemeResource("images/famfamfam/disk.png"); break; case RETRY: icon = new ThemeResource("images/famfamfam/arrow_refresh.png"); break; case IGNORE: icon = new ThemeResource("images/famfamfam/lightning_go.png"); break; } button.setIcon(icon); } buttonLayout.addComponent(button); } setContent(mainLayout); }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
public VerticalLayout createTab(Group g) { User u = UserUtils.getCurrent();/*from w w w .ja v a2 s . c o m*/ VerticalLayout groupSettingsLayout = new VerticalLayout(); groupSettingsLayouts.put(g, groupSettingsLayout); GridLayout tabContent; TextField textFieldName = new TextField(); if (GroupUtils.isAdmin(g, u)) { tabContent = new GridLayout(3, 2); Language.set(Word.NAME, textFieldName); textFieldName.setWidth("100%"); textFieldName.setValue(g.getName()); textFieldName.setMaxLength(255); tabContent.addComponent(textFieldName); tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT); } else { tabContent = new GridLayout(3, 1); } buttonLeave = new Button(); Language.set(Word.LEAVE, buttonLeave); buttonLeave.setIcon(VaadinIcons.MINUS); buttonLeave.addStyleName(ValoTheme.BUTTON_DANGER); buttonLeave.addClickListener(ce -> { ConfirmationDialog.show(Language.get(Word.REALLY_LEAVE_GROUP).replace("[GROUP]", g.getName()), () -> { long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count(); if (amountAdmins > 1 || !GroupUtils.isAdmin(g, u)) { GroupUtils.removeUser(g, u); refreshAll(g); } else { VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP)); } }); }); buttonDelete = new Button(); Language.set(Word.DELETE, buttonDelete); buttonDelete.setIcon(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.addClickListener(ce -> { ConfirmationDialog.show(Language.get(Word.REALLY_DELETE_GROUP).replace("[GROUP]", g.getName()), () -> { GroupUtils.removeGroup(g); refreshAll(g); }); }); Button buttonSave = new Button(); Language.set(Word.SAVE, buttonSave); buttonSave.setIcon(VaadinIcons.CHECK); buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSave.addClickListener(ce -> { if (GroupUtils.isAdmin(g, u)) { GroupUtils.changeName(g, textFieldName.getValue()); accordion.getTab(groupSettingsLayout).setCaption(textFieldName.getValue()); } VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED)); }); buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); Label placeholder = new Label(); Label placeholder2 = new Label(); placeholder2.setWidth("100%"); Label placeholder3 = new Label(); GridLayout footer = new GridLayout(4, 1); footer.setSpacing(true); footer.setMargin(new MarginInfo(false, true)); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth("100%"); footer.addStyleName("menubar"); if (GroupUtils.isAdmin(g, u)) { footer.addComponents(placeholder, buttonDelete, buttonLeave, buttonSave); footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER); } else { footer.addComponents(placeholder, placeholder3, buttonLeave, buttonSave); } footer.setColumnExpandRatio(0, 5); footer.setComponentAlignment(buttonLeave, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER); if (GroupUtils.isAdmin(g, u)) { tabContent.addComponent(getProfiles(g), 0, 1, 1, 1); tabContent.addComponent(getMembers(g), 2, 1); } else { tabContent.addComponent(getProfiles(g), 0, 0, 1, 0); tabContent.addComponent(getMembers(g), 2, 0); } tabContent.setWidth("100%"); tabContent.setSpacing(true); tabContent.setMargin(true); tabContent.addStyleName("profiles"); groupSettingsLayout.addComponents(tabContent, footer); groupSettingsLayout.setMargin(false); groupSettingsLayout.setSpacing(false); groupSettingsLayout.setWidth("100%"); return groupSettingsLayout; }
From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java
public VerticalLayout createTab(InterestProfile profile) { VerticalLayout profileSettingsLayout = new VerticalLayout(); GridLayout tabContent = new GridLayout(3, 3); TextField textFieldName = new TextField(); Language.set(Word.NAME, textFieldName); textFieldName.setWidth("100%"); textFieldName.setValue(profile.getName()); textFieldName.setMaxLength(255);//from w w w . j a v a2 s .c o m CheckBox checkBoxEnabled = new CheckBox(); checkBoxEnabled.setValue(profile.isEnabled()); Language.setCustom(Word.ENABLED, s -> checkBoxEnabled.setCaption(s)); Button buttonDelete = new Button(); Language.set(Word.DELETE, buttonDelete); buttonDelete.setIcon(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.addClickListener(ce -> { InterestProfileUtils.delete(profile); accordion.removeTab(accordion.getTab(profileSettingsLayout)); }); Button buttonSave = new Button(); Language.set(Word.SAVE, buttonSave); buttonSave.setIcon(VaadinIcons.CHECK); buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonSave.addClickListener(ce -> { InterestProfileUtils.changeName(profile, textFieldName.getValue()); accordion.getTab(profileSettingsLayout).setCaption(textFieldName.getValue()); InterestProfileUtils.changeEnabled(profile, checkBoxEnabled.getValue()); InterestProfileUtils.changeSources(profile, profile.getSources()); InterestProfileUtils.changeCategories(profile, profile.getCategories()); InterestProfileUtils.changeAllTags(profile, profile.getTags()); VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED)); }); buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); Label placeholder = new Label(); Label placeholder2 = new Label(); placeholder2.setWidth("100%"); Label labelHelp = new Label(Language.get(Word.HELP_TEXT), ContentMode.HTML); Language.setCustom(Word.HELP_TEXT, s -> labelHelp.setValue(s)); labelHelp.setWidth("500px"); PopupView popupHelp = new PopupView(null, labelHelp); Button buttonHelp = new Button(Language.get(Word.HELP), VaadinIcons.QUESTION); buttonHelp.addClickListener(ce -> { popupHelp.setPopupVisible(true); }); GridLayout footer = new GridLayout(5, 1); footer.setSpacing(true); footer.setSizeUndefined(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth("100%"); footer.addStyleName("menubar"); footer.addComponents(buttonHelp, popupHelp, placeholder, buttonDelete, buttonSave); footer.setColumnExpandRatio(2, 5); footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER); tabContent.addComponents(textFieldName, checkBoxEnabled, placeholder2); tabContent.addComponent(getSources(profile), 0, 1, 1, 1); tabContent.addComponent(getCategories(profile), 2, 1); tabContent.addComponent(getTags(profile), 0, 2, 2, 2); tabContent.setWidth("100%"); tabContent.setSpacing(true); tabContent.setMargin(true); tabContent.addStyleName("profiles"); tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT); tabContent.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER); profileSettingsLayout.addComponents(tabContent, footer); profileSettingsLayout.setMargin(false); profileSettingsLayout.setSpacing(false); profileSettingsLayout.setWidth("100%"); return profileSettingsLayout; }
From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java
public Component getSources(InterestProfile profile) { VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setWidth("100%"); VerticalLayout sourcesLayout = new VerticalLayout(); sourcesLayout.setWidth("100%"); Panel sourcesPanel = new Panel(sourcesLayout); List<CheckBox> checkBoxes = new ArrayList<>(); HashMap<String, GridLayout> sourceLayouts = new HashMap<>(); profile.getSources().entrySet().stream() .sorted((e1, e2) -> e1.getKey().getName().compareToIgnoreCase(e2.getKey().getName())).forEach(e -> { Source source = e.getKey(); boolean enabled = e.getValue(); GridLayout sourceLayout = new GridLayout(5, 1); sourceLayout.setSizeFull(); CheckBox sourceSelected = new CheckBox(); sourceSelected.setValue(enabled); sourceSelected.addStyleName(ValoTheme.CHECKBOX_LARGE); sourceSelected.addValueChangeListener(v -> profile.getSources().replace(source, v.getValue())); checkBoxes.add(sourceSelected); Image sourceLogo = new Image(); sourceLogo.addStyleName("logosmall"); sourceLogo.setSource(new ExternalResource(source.getLogo())); sourceLogo.addClickListener(c -> { sourceSelected.setValue(!sourceSelected.getValue()); profile.getSources().replace(source, sourceSelected.getValue()); });//w w w . j a v a 2s .c o m VerticalLayout layoutLogo = new VerticalLayout(sourceLogo); layoutLogo.setWidth("150px"); layoutLogo.setHeight("50px"); layoutLogo.setMargin(false); layoutLogo.setSpacing(false); layoutLogo.setComponentAlignment(sourceLogo, Alignment.MIDDLE_LEFT); Label labelHeadLine = new Label( source.getCategory().getIcon().getHtml() + " " + source.getName(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H3); Label labelDescription = new Label(source.getDescription(), ContentMode.HTML); labelDescription.setWidth("300px"); PopupView popup = new PopupView(null, labelDescription); Button buttonDescription = new Button(VaadinIcons.INFO_CIRCLE_O); buttonDescription.addClickListener(ce -> { popup.setPopupVisible(true); }); sourceLayout.addComponents(sourceSelected, layoutLogo, labelHeadLine, popup, buttonDescription); sourceLayout.setComponentAlignment(sourceSelected, Alignment.MIDDLE_CENTER); sourceLayout.setComponentAlignment(layoutLogo, Alignment.MIDDLE_CENTER); sourceLayout.setColumnExpandRatio(2, 5); sourceLayout.setSpacing(true); sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "") .replaceAll("_", ""), sourceLayout); sourcesLayout.addComponent(sourceLayout); }); sourcesPanel.setContent(sourcesLayout); sourcesPanel.setHeight("100%"); sourcesPanel.setCaption(Language.get(Word.SOURCES)); Language.setCustom(Word.SOURCES, s -> sourcesPanel.setCaption(s)); windowLayout.addComponent(sourcesPanel); windowLayout.setExpandRatio(sourcesPanel, 1); windowLayout.setSpacing(false); windowLayout.setMargin(false); CheckBox checkBoxSelectAll = new CheckBox(); Language.setCustom(Word.SELECT_ALL, s -> checkBoxSelectAll.setCaption(s)); checkBoxSelectAll.setWidth("100%"); checkBoxSelectAll.addValueChangeListener(e -> { profile.getSources().replaceAll((c, enabled) -> checkBoxSelectAll.getValue()); checkBoxes.forEach(c -> c.setValue(checkBoxSelectAll.getValue())); }); TextField textFieldSearch = new TextField(); Language.setCustom(Word.SEARCH, s -> textFieldSearch.setPlaceholder(s)); textFieldSearch.setWidth("100%"); textFieldSearch.setMaxLength(255); textFieldSearch.setPlaceholder(Language.get(Word.SEARCH)); textFieldSearch.addValueChangeListener(searchValue -> { sourceLayouts.forEach((sourceName, sourceLayout) -> { if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "") .replaceAll("-", "").replaceAll("_", ""))) { sourcesLayout.removeComponent(sourceLayout); } else { sourcesLayout.addComponent(sourceLayout); } }); }); Label placeholder = new Label(); placeholder.setWidth("100%"); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.setMargin(new MarginInfo(true, false, false, false)); footer.addStyleName("menubar"); footer.setWidth("100%"); footer.addComponents(checkBoxSelectAll, textFieldSearch, placeholder); footer.setComponentAlignment(checkBoxSelectAll, Alignment.MIDDLE_LEFT); footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER); windowLayout.addComponent(footer); windowLayout.setHeight("350px"); return windowLayout; }