List of usage examples for com.vaadin.ui GridLayout setSizeUndefined
@Override public void setSizeUndefined()
From source file:at.peppol.webgui.app.components.TabInvoiceTaxTotal.java
License:Mozilla Public License
@SuppressWarnings("serial") private void initElements() { taxTotalList = parent.getInvoice().getTaxTotal(); if (taxTotalList.size() == 0) { taxTotalItem = createTaxTotalItem(); taxTotalList.add(taxTotalItem);//from ww w .j ava 2 s .c o m } else { taxTotalItem = taxTotalList.get(0); } //taxSubtotalList = parent.getInvoice ().getTaxTotal ().get (0).getTaxSubtotal (); taxSubtotalList = taxTotalItem.getTaxSubtotal(); final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true); hiddenContent.setMargin(true); final Panel outerPanel = new Panel("Tax Total"); outerPanel.addComponent(grid); outerPanel.setScrollable(true); outerLayout.addComponent(outerPanel); table = new InvoiceTaxSubtotalTable(taxTotalList.get(0).getTaxSubtotal()); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setFooterVisible(true); table.addStyleName("striped strong"); final VerticalLayout tableContainer = new VerticalLayout(); tableContainer.addComponent(table); tableContainer.setMargin(false, true, false, false); Button addButton = new Button("Add new"); Button editButton = new Button("Edit selected"); Button deleteButton = new Button("Delete selected"); final VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addButton); buttonsContainer.addComponent(editButton); buttonsContainer.addComponent(deleteButton); InvoiceTaxSubtotalTableEditor editor = new InvoiceTaxSubtotalTableEditor(editMode); Label label = new Label("<h3>Adding new tax subtotal</h3>", Label.CONTENT_XHTML); addButton.addListener( editor.addButtonListener(editButton, deleteButton, hiddenContent, table, taxSubtotalList, label)); label = new Label("<h3>Edit tax subtotal</h3>", Label.CONTENT_XHTML); editButton.addListener( editor.editButtonListener(addButton, deleteButton, hiddenContent, table, taxSubtotalList, label)); deleteButton.addListener(editor.deleteButtonListener(table)); /* // buttons Add, Edit, Delete final Button addBtn = new Button ("Add New", new Button.ClickListener () { @Override public void buttonClick (final Button.ClickEvent event) { addMode = true; hiddenContent.removeAllComponents (); taxSubtotalItem = createTaxSubtotalItem (); final Label formLabel = new Label ("<h3>Adding new tax subtotal line</h3>", Label.CONTENT_XHTML); hiddenContent.addComponent (formLabel); hiddenContent.addComponent (createInvoiceTaxSubtotalForm ()); // Save new line button final HorizontalLayout buttonLayout = new HorizontalLayout (); buttonLayout.setSpacing (true); buttonLayout.addComponent (new Button ("Save tax subtotal line", new Button.ClickListener () { @Override public void buttonClick (final ClickEvent event) { // update table (and consequently add new item to taxSubtotalList // list) table.addTaxSubtotalLine (taxSubtotalItem); // hide form hiddenContent.setVisible (false); addMode = false; // update Total Tax Amount taxTotalItem.getTaxAmount ().setValue (SumTaxSubtotalAmount ()); // update form as well // invoiceTaxTotalTopForm.getField("Tax Total Amount").setRequired(true); invoiceTaxTotalTopForm.getField ("Tax Total Amount").setValue (taxTotalItem.getTaxAmount ().getValue ()); } })); buttonLayout.addComponent (new Button ("Cancel", new Button.ClickListener () { @Override public void buttonClick (final ClickEvent event) { hiddenContent.removeAllComponents (); // hide form hiddenContent.setVisible (false); addMode = false; } })); hiddenContent.addComponent (buttonLayout); // hiddenContent.setVisible(!hiddenContent.isVisible()); hiddenContent.setVisible (true); } }); final Button editBtn = new Button ("Edit Selected", new Button.ClickListener () { @Override public void buttonClick (final Button.ClickEvent event) { /* * Object rowId = table.getValue(); // get the selected rows id if(rowId * != null){ if(addMode || editMode){ parent.getWindow * ().showNotification("Info", "You cannot edit while in add/edit mode", * Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } final String * sid = * (String)table.getContainerProperty(rowId,"ID.value").getValue(); // * TODO: PUT THIS IN FUNCTION BEGINS editMode = true; * hiddenContent.removeAllComponents (); //get selected item * allowanceChargeItem = (InvoiceAllowanceChargeAdapter) * allowanceChargeList.get (table.getIndexFromID (sid)); //clone it to * original item originalItem = new InvoiceAllowanceChargeAdapter (); * cloneInvoiceAllowanceChargeItem(allowanceChargeItem, originalItem); * Label formLabel = new Label("<h3>Editing allowance charge line</h3>", * Label.CONTENT_XHTML); hiddenContent.addComponent (formLabel); * hiddenContent.addComponent(createInvoiceAllowanceChargeForm()); * //Save new line button HorizontalLayout buttonLayout = new * HorizontalLayout(); buttonLayout.setSpacing (true); * buttonLayout.addComponent(new Button("Save changes",new * Button.ClickListener(){ * @Override public void buttonClick (ClickEvent event) { //update table * (and consequently edit item to allowanceChargeList list) * table.setAllowanceChargeLine (sid, allowanceChargeItem); //hide form * hiddenContent.setVisible(false); editMode = false; } })); * buttonLayout.addComponent(new Button("Cancel editing",new * Button.ClickListener(){ * @Override public void buttonClick (ClickEvent event) { * hiddenContent.removeAllComponents (); table.setAllowanceChargeLine * (sid, originalItem); //hide form hiddenContent.setVisible(false); * editMode = false; } })); hiddenContent.addComponent(buttonLayout); * //hiddenContent.setVisible(!hiddenContent.isVisible()); * hiddenContent.setVisible(true); // TODO: PUT THIS IN FUNCTION ENDS } * else { parent.getWindow ().showNotification("Info", * "No table line is selected", * Window.Notification.TYPE_HUMANIZED_MESSAGE); } */ /* } }); editBtn.setEnabled (false); final Button deleteBtn = new Button ("Delete Selected", new Button.ClickListener () { @Override public void buttonClick (final Button.ClickEvent event) { final Object rowId = table.getValue (); // get the selected rows id if (rowId != null) { if (addMode || editMode) { parent.getWindow ().showNotification ("Info", "You cannot delete while in add/edit mode", Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } if (table.getContainerProperty (rowId, "TableLineID").getValue () != null) { final String sid = (String) table.getContainerProperty (rowId, "TableLineID").getValue (); table.removeTaxSubtotalLine (sid); // update Total Tax Amount taxTotalItem.getTaxAmount ().setValue (SumTaxSubtotalAmount ()); invoiceTaxTotalTopForm.getField ("Tax Total Amount").setValue (taxTotalItem.getTaxAmount ().getValue ()); } } else { parent.getWindow ().showNotification ("Info", "No table line is selected", Window.Notification.TYPE_HUMANIZED_MESSAGE); } } });*/ final Panel invoiceDetailsPanel = new Panel("Tax Total Details"); invoiceDetailsPanel.setStyleName("light"); invoiceDetailsPanel.setSizeFull(); invoiceDetailsPanel.addComponent(createInvoiceTaxTotalTopForm()); table.addListener(new ItemSetChangeListener() { @Override public void containerItemSetChange(ItemSetChangeEvent event) { Field f = invoiceTaxTotalTopForm.getField(taxTotalAmount); f.setValue(addTaxSubTotals()); } }); grid.setSpacing(true); grid.addComponent(invoiceDetailsPanel, 0, 0); grid.addComponent(tableContainer, 0, 1); grid.addComponent(buttonsContainer, 1, 1); grid.setSizeUndefined(); // ---- HIDDEN FORM BEGINS ----- final VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); outerLayout.addComponent(formLayout); // ---- HIDDEN FORM ENDS ----- setLayout(outerLayout); outerPanel.requestRepaintAll(); }
From source file:ch.bfh.ti.soed.hs16.srs.black.view.reservationView.ReservationView.java
License:Open Source License
public ReservationView() { reservationMakeView = new ReservationMakeView(); reservationTableView = new ReservationTableView(); VerticalLayout makeViewLayoutVL = reservationMakeView.getMakeViewLayout(); VerticalLayout listReservationsVL = reservationTableView.getListReservations(); GridLayout grid = new GridLayout(2, 1); grid.addComponent(makeViewLayoutVL, 0, 0); grid.addComponent(listReservationsVL, 1, 0); grid.setComponentAlignment(makeViewLayoutVL, Alignment.TOP_CENTER); grid.setComponentAlignment(listReservationsVL, Alignment.TOP_CENTER); grid.setSizeUndefined(); setSizeFull();//from ww w . j a v a 2s. com addComponent(grid); setComponentAlignment(grid, Alignment.TOP_CENTER); }
From source file:com.javalego.ui.vaadin.component.util.MessageBox.java
License:Apache License
/** * Similar to/*from w w w .j av a 2s .c o m*/ * {@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. * * @param messageComponent * a Vaadin component */ public MessageBox(String dialogCaption, Icon dialogIcon, Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) { super(); setResizable(false); setClosable(false); setCaption(dialogCaption); GridLayout mainLayout = new GridLayout(2, 2); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setSizeUndefined(); messageComponent.setSizeUndefined(); // Add Content 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); // Label icon = new Label(); // switch (dialogIcon) { // case QUESTION: // icon.setIcon(FontAwesome.QUESTION); // break; // case INFO: // icon.setIcon(FontAwesome.INFO); // break; // case WARN: // icon.setIcon(FontAwesome.WARNING); // break; // case ERROR: // icon.setIcon(FontAwesome.STOP); // break; // default: // break; // } // mainLayout.addComponent(icon, 0, 0); } // Add Buttons HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setMargin(true); mainLayout.addComponent(buttonLayout, 0, 1, 1, 1); mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment); for (ButtonConfig buttonConfig : buttonConfigs) { ButtonExt button = new ButtonExt(buttonConfig.getCaption()); // if (buttonConfig.buttonType == ButtonType.YES || buttonConfig.buttonType == ButtonType.OK) { // button.blue(); // } button.addClickListener(new ButtonClickListener(buttonConfig.getButtonType())); buttonLayout.addComponent(button); } setContent(mainLayout); }
From source file:com.klwork.explorer.ui.user.ProfilePanel.java
License:Apache License
protected void initContactSection() { Label header = createProfileHeader(i18nManager.getMessage(Messages.PROFILE_CONTACT)); header.addStyleName(ExplorerLayout.STYLE_H3); header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); infoPanelLayout.addComponent(header); GridLayout contactLayout = createInfoSectionLayout(2, 4); // Email//from ww w . ja va 2s .co m if (!editable && isDefined(user.getEmail())) { addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), user.getEmail()); } else if (editable) { emailField = new TextField(); addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), emailField, user.getEmail()); } // Phone if (!editable && isDefined(phone)) { addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phone); } else if (editable) { phoneField = new TextField(); addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phoneField, phone); } // Twitter if (!editable && isDefined(twitterName)) { Link twitterLink = new Link(twitterName, new ExternalResource("http://www.twitter.com/" + twitterName)); addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterLink); } else if (editable) { twitterField = new TextField(); addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterField, twitterName); } // Skype if (!editable && isDefined(skypeId)) { // The skype entry shows the name + skype icon, laid out in a small grid GridLayout skypeLayout = new GridLayout(2, 1); skypeLayout.setSpacing(true); skypeLayout.setSizeUndefined(); Label skypeIdLabel = new Label(skypeId); skypeIdLabel.setSizeUndefined(); skypeLayout.addComponent(skypeIdLabel); addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeLayout); } else if (editable) { skypeField = new TextField(); addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeField, skypeId); } }
From source file:com.purebred.core.view.field.FormFields.java
License:Open Source License
public GridLayout createGridLayout(String tabName) { GridLayout gridLayout; if (form instanceof EntityForm) { gridLayout = new LeftLabelGridLayout(getColumns(tabName), getRows(tabName)); } else {/*from ww w .j a v a2 s . co m*/ gridLayout = new TopLabelGridLayout(getColumns(tabName), getRows(tabName)); } gridLayout.setMargin(true, true, true, true); gridLayout.setSpacing(true); gridLayout.setSizeUndefined(); return gridLayout; }
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. * // ww w . ja va 2 s . c om * @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. * //from w w w . j av a2s. c om * @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.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the current info.// w w w .jav a 2s . c o m * * @param labels the labels * @param values the values * @return the component */ private Component createCurrentInfo(Label[] labels, String[] values) { GridLayout currentGrid = new GridLayout(2, labels.length); currentGrid.addStyleName("currentInfo"); currentGrid.setSpacing(true); currentGrid.setMargin(new MarginInfo(false, false, false, true)); currentGrid.setSizeUndefined(); for (int i = 0; i < labels.length; i++) { Label label = new Label(values[i]); label.setSizeUndefined(); currentGrid.addComponent(label, 0, i); labels[i] = new Label(""); labels[i].setSizeUndefined(); currentGrid.addComponent(labels[i], 1, i); } return (currentGrid); }
From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java
public VerticalLayout createTab(Group g) { User u = UserUtils.getCurrent();//from w w w .ja va 2 s .c om 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);/* w w w . ja v a 2s .c om*/ 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; }