List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:org.jdal.vaadin.ui.form.SimpleBoxFormBuilder.java
License:Apache License
public void add(Component c, String label, int width, Alignment alignment) { if (rows == 0 && rowsHeight.isEmpty()) { log.warn("You must call row() before adding components. I will add a row with default height for you"); row();// w w w . ja va 2 s . c om } if (label != null) c.setCaption(label); VerticalLayout column = getColumn(); column.addComponent(c); index++; setWidth(width); if (alignment != null) { column.setComponentAlignment(c, alignment); } if (rowCellSpand) { c.setWidth(100, Unit.PERCENTAGE); } if (useTabIndex && c instanceof Field) { ((Field<?>) c).setTabIndex(tabIndex++); } }
From source file:org.jdal.vaadin.ui.FormUtils.java
License:Apache License
/** * Show a YES/NO confirm dialog/* w w w . ja v a 2s . co m*/ * @param window Window to attach the dialog * @param msg the msg */ public static void showConfirmDialog(UI ui, final Command command, String msg) { final Window dlg = new Window("Please Confirm"); VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); vl.setSpacing(true); vl.setMargin(true); Label label = new Label(msg, Label.CONTENT_XHTML); vl.addComponent(label); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Button ok = new Button(StaticMessageSource.getMessage("yes")); ok.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { command.execute(null); closeWindow(dlg); } }); Button cancel = new Button(StaticMessageSource.getMessage("no")); cancel.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { closeWindow(dlg); } }); hl.setSpacing(true); hl.addComponent(ok); hl.addComponent(cancel); hl.setSizeFull(); vl.addComponent(hl); vl.setComponentAlignment(hl, Alignment.TOP_CENTER); dlg.setContent(vl); dlg.setModal(true); vl.setSizeUndefined(); ui.addWindow(dlg); }
From source file:org.jdal.vaadin.ui.table.PageableTable.java
License:Apache License
@SuppressWarnings("unchecked") @PostConstruct// w w w .ja v a2 s . c om public void init() { // build Component VerticalLayout verticalLayout = getVerticalLayout(); verticalLayout.setSizeUndefined(); verticalLayout.setSpacing(true); // filter if (filterEditor != null && filterForm == null) { filterForm = (VaadinView<Filter>) getGuiFactory().getView(filterEditor); } if (filterForm != null) { if (beanFilter != null) { filterForm.setModel(beanFilter); } else { beanFilter = filterForm.getModel(); } verticalLayout.addComponent((Component) filterForm.getPanel()); } // action group if (getActions().size() > 0) { verticalLayout.addComponent(createButtonBox()); } // table verticalLayout.addComponent(getTable()); verticalLayout.setExpandRatio(getTable(), 1.0f); // paginator if (paginator != null) { paginator.setModel(page); paginator.addPaginatorListener(this); paginator.setNativeButtons(isNativeButtons()); page.setPageableDataSource(getService()); // set external sorting, ie don't call Container.sort() getTable().setSorter(new PageSorter()); Component p = paginator.getPanel(); verticalLayout.addComponent(p); verticalLayout.setComponentAlignment(p, Alignment.MIDDLE_CENTER); getTable().setPageLength(page.getPageSize()); if (beanFilter != null) page.setFilter(beanFilter); // get initial page and wrap data in container paginator.firstPage(); } getTable().addItemClickListener(this); this.setSizeUndefined(); }
From source file:org.jpos.qi.QIEntityView.java
License:Open Source License
public Layout createForm(final Object entity, String[] params, boolean isNew) { VerticalLayout profileLayout = new VerticalLayout(); profileLayout.setMargin(true);//www . j av a 2s . c om profileLayout.setSpacing(true); //Add Back Button if (params.length <= 1 || !"profile".equals(params[1])) { Button back = new Button(getApp().getMessage("back")); back.addStyleName("borderless-colored"); back.setIcon(VaadinIcons.ARROW_LEFT); back.addClickListener(event -> app.getNavigator().navigateTo(getGeneralRoute())); profileLayout.addComponent(back); profileLayout.setComponentAlignment(back, Alignment.MIDDLE_LEFT); } binder = new Binder<T>(clazz) { @Override public void setReadOnly(boolean readOnly) { super.setReadOnly(readOnly); if (readOnlyFields != null) { for (String fieldId : readOnlyFields) { if (binder.getBinding(fieldId).isPresent()) { HasValue field = binder.getBinding(fieldId).get().getField(); if ((field != null && !field.isEmpty()) || !field.isRequiredIndicatorVisible()) { field.setReadOnly(true); binder.bind(field, fieldId); } } } } } }; bean = (T) entity; final Layout formLayout = createLayout(); getHelper().setOriginalEntity(bean); binder.readBean((T) entity); binder.setReadOnly(true); profileLayout.addComponent(formLayout); HorizontalLayout footer = new HorizontalLayout(); footer.addStyleName("footer"); footer.setMargin(new MarginInfo(true, false, false, false)); footer.setSpacing(true); formLayout.addComponent(footer); //Add Save, Remove & Cancel Buttons editBtn = new Button(app.getMessage("edit")); removeBtn = new Button(app.getMessage("remove")); saveBtn = new Button(app.getMessage("save")); cancelBtn = new Button(app.getMessage("cancel")); editBtn.addClickListener(event -> editClick(event, formLayout)); editBtn.addStyleName("icon-edit"); saveBtn.addClickListener(event -> saveClick(event, formLayout)); saveBtn.setVisible(false); saveBtn.setStyleName("icon-ok"); saveBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER); removeBtn.addClickListener(event -> app.addWindow(new ConfirmDialog(app.getMessage("confirmTitle"), app.getMessage("removeConfirmationMessage"), confirm -> { if (confirm) { removeEntity(); } }))); removeBtn.addStyleName("icon-trash"); cancelBtn.addClickListener(event -> { if (isNew) { app.getNavigator().navigateTo(getGeneralRoute()); } else { cancelClick(event, formLayout); } }); cancelBtn.setClickShortcut(ShortcutAction.KeyCode.ESCAPE); cancelBtn.setVisible(false); cancelBtn.addStyleName("icon-cancel"); if (canEdit()) { footer.addComponent(editBtn); footer.addComponent(saveBtn); footer.addComponent(cancelBtn); footer.setComponentAlignment(editBtn, Alignment.MIDDLE_RIGHT); footer.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT); footer.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT); } if (canRemove()) { footer.addComponent(removeBtn); footer.setComponentAlignment(removeBtn, Alignment.MIDDLE_RIGHT); } if (isNew) { editBtn.click(); } errorLabel = new Label(); errorLabel.setVisible(false); errorLabel.setStyleName(ValoTheme.LABEL_FAILURE); profileLayout.addComponent(errorLabel); return profileLayout; }
From source file:org.jumpmind.metl.ui.views.design.EditFlowPalette.java
License:Open Source License
protected void addItemToFlowPanelSection(String labelName, String componentType, VerticalLayout componentLayout, ClassResource icon, String componentId) { FlowPaletteItem paletteItem = new FlowPaletteItem(labelName); if (componentId != null) { paletteItem.setShared(true);/* w w w.j a v a 2s. co m*/ paletteItem.setComponentId(componentId); } else { paletteItem.setComponentType(componentType); paletteItem.setShared(false); } paletteItem.setIcon(icon); paletteItem.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); paletteItem.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); paletteItem.addStyleName("leftAligned"); paletteItem.setWidth(100, Unit.PERCENTAGE); DragAndDropWrapper wrapper = new DragAndDropWrapper(paletteItem); wrapper.setSizeUndefined(); wrapper.setDragStartMode(DragStartMode.WRAPPER); componentLayout.addComponent(wrapper); componentLayout.setComponentAlignment(wrapper, Alignment.TOP_CENTER); }
From source file:org.kani.Application.java
License:Apache License
private Window getAboutDialog() { if (aboutWindow == null) { aboutWindow = new Window("About..."); aboutWindow.setModal(true);/*w ww . j av a2 s. c o m*/ aboutWindow.setWidth("400px"); VerticalLayout layout = (VerticalLayout) aboutWindow.getContent(); layout.setMargin(true); layout.setSpacing(true); layout.setStyleName("blue"); CssLayout titleLayout = new CssLayout(); H2 title = new H2("Dynamic Vaadin OSGi Demo"); titleLayout.addComponent(title); SmallText description = new SmallText("<br>Copyright ?? and others.<br>" + "The icons are from the Silk icon set by Mark James<br>" + "<a href=\"http://www.famfamfam.com/lab/icons/silk/\">http://www.famfamfam.com/lab/icons/silk/</a>"); description.setSizeUndefined(); description.setContentMode(Label.CONTENT_XHTML); titleLayout.addComponent(description); aboutWindow.addComponent(titleLayout); Button close = new Button("Close", new Button.ClickListener() { public void buttonClick(ClickEvent event) { (aboutWindow.getParent()).removeWindow(aboutWindow); } }); layout.addComponent(close); layout.setComponentAlignment(close, Alignment.MIDDLE_RIGHT); } return aboutWindow; }
From source file:org.lucidj.vaadinui.Login.java
License:Apache License
@Override // LoginForm protected Component createContent(TextField userNameField, PasswordField passwordField, Button loginButton) { // Save the predefined components this.userNameField = userNameField; this.passwordField = passwordField; this.loginButton = loginButton; // Make LoginForm container full-screen setSizeFull();//from w ww . j a v a 2 s. c o m VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.addStyleName("login-wallpaper"); final VerticalLayout loginPanel = new VerticalLayout(); loginPanel.setSizeUndefined(); loginPanel.setMargin(true); loginPanel.setSpacing(true); Responsive.makeResponsive(loginPanel); loginPanel.addStyleName("card"); //-------- // HEADER //-------- final HorizontalLayout labels = new HorizontalLayout(); labels.setWidth("100%"); final Label title = new Label("<h3><strong>LucidJ</strong> Console</h3>", ContentMode.HTML); labels.addComponent(title); labels.setExpandRatio(title, 1); loginPanel.addComponent(labels); //-------- // FIELDS //-------- HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); userNameField.setImmediate(true); userNameField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER); final ShortcutListener username_enter_listener = new ShortcutListener("Next field (Tab)", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object o, Object o1) { passwordField.setValue(""); passwordField.focus(); } }; userNameField.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent textChangeEvent) { show_default_message(); int new_username_length = textChangeEvent.getText().length(); // Check for autofill if (userNameField.isEmpty() && new_username_length > 1 && !userNameField_filling) { // This is autofill userNameField.removeShortcutListener(username_enter_listener); userNameField.setCursorPosition(new_username_length); userNameField.setSelectionRange(0, new_username_length); } else { userNameField_filling = true; passwordField.setValue(""); userNameField.addShortcutListener(username_enter_listener); } } }); userNameField.addFocusListener(new FieldEvents.FocusListener() { @Override public void focus(FieldEvents.FocusEvent focusEvent) { // Cursor on username, Enter jump to password loginButton.removeClickShortcut(); userNameField.addShortcutListener(username_enter_listener); } }); userNameField.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent blurEvent) { // Cursor on password or elsewhere, enter submits userNameField.removeShortcutListener(username_enter_listener); loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); } }); passwordField.setImmediate(true); passwordField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER); passwordField.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent textChangeEvent) { show_default_message(); } }); loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY); loginButton.setDisableOnClick(true); fields.addComponents(userNameField, passwordField, loginButton); fields.setComponentAlignment(loginButton, Alignment.BOTTOM_LEFT); loginPanel.addComponent(fields); //-------- // FOOTER //-------- loginPanel.addComponent(new CheckBox("Remember me", true)); loginPanel.addComponent(message_label); show_default_message(); layout.addComponent(loginPanel); layout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); return (layout); }
From source file:org.lunifera.examples.vaaclipse.demo1.e4.editors.ImageView.java
License:Open Source License
@Inject public ImageView(VerticalLayout container, MInputPart inputPart) { super(inputPart.getInputURI()); embedded = new Embedded(); container.addComponent(embedded);/*from w w w. j a va2s . c o m*/ container.setComponentAlignment(embedded, Alignment.MIDDLE_CENTER); container.setSizeFull(); embedded.setSource(new FileResource(getFile())); }
From source file:org.lunifera.examples.vaaclipse.demo1.e4.views.ProcessView.java
License:Open Source License
@Inject public ProcessView(VerticalLayout parent, IEclipseContext context, MApplication app) { this.parent = parent; parent.setSizeFull();/*from w ww . ja va2s . c o m*/ parent.setMargin(true); embedded = new Embedded(); parent.addComponent(embedded); parent.setComponentAlignment(embedded, Alignment.MIDDLE_CENTER); }
From source file:org.metawidget.example.vaadin.addressbook.ContactDialog.java
License:BSD License
public ContactDialog(AddressBook addressBook, final Contact contact) { mAddressBook = addressBook;/*from ww w. j a va 2 s . c o m*/ setHeight("600px"); setWidth("800px"); ((Layout) getContent()).setMargin(false); CustomLayout body = new CustomLayout("contact"); addComponent(body); // Bundle ResourceBundle bundle = ResourceBundle .getBundle("org.metawidget.example.shared.addressbook.resource.Resources"); // Title StringBuilder builder = new StringBuilder(contact.getFullname()); if (builder.length() > 0) { builder.append(" - "); } // Personal/business icon if (contact instanceof PersonalContact) { builder.append(bundle.getString("personalContact")); body.addComponent(new Embedded(null, new ThemeResource("../addressbook/img/personal.gif")), "icon"); } else { builder.append(bundle.getString("businessContact")); body.addComponent(new Embedded(null, new ThemeResource("../addressbook/img/business.gif")), "icon"); } setCaption(builder.toString()); // Metawidget mContactMetawidget = new VaadinMetawidget(); mContactMetawidget.setWidth("100%"); mContactMetawidget.setConfig("org/metawidget/example/vaadin/addressbook/metawidget.xml"); mContactMetawidget.setReadOnly(contact.getId() != 0); mContactMetawidget.setToInspect(contact); // Communications override final TableDataSource<Communication> tableDataSource = new TableDataSource<Communication>( Communication.class, contact.getCommunications(), "type", "value"); mCommunicationsTable = new Table(); mCommunicationsTable.setWidth("100%"); mCommunicationsTable.setHeight("170px"); final Button deleteButton = new Button("Delete"); deleteButton.setEnabled(false); deleteButton.addListener(new ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { Communication communication = tableDataSource.getDataRow(mCommunicationsTable.getValue()); contact.removeCommunication(communication); ((TableDataSource<Communication>) mCommunicationsTable.getContainerDataSource()) .importCollection(contact.getCommunications()); } }); Button addNewButton = new Button("Add"); addNewButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { mCommunicationsTable.setValue(null); deleteButton.setEnabled(false); CommunicationDialog communicationDialog = new CommunicationDialog(ContactDialog.this, new Communication()); communicationDialog.setModal(true); getParent().addWindow(communicationDialog); } }); mCommunicationsTable.setSelectable(false); mCommunicationsTable.addListener(new ItemClickListener() { public void itemClick(ItemClickEvent event) { if (!mCommunicationsTable.isSelectable()) { return; } if (!event.isDoubleClick()) { deleteButton.setEnabled(true); return; } deleteButton.setEnabled(false); Communication communication = tableDataSource.getDataRow(event.getItemId()); CommunicationDialog communicationDialog = new CommunicationDialog(ContactDialog.this, communication); communicationDialog.setModal(true); getParent().addWindow(communicationDialog); } }); mCommunicationsButtons = new com.vaadin.ui.HorizontalLayout(); mCommunicationsButtons.setVisible(!mContactMetawidget.isReadOnly()); mCommunicationsButtons.setMargin(false); mCommunicationsButtons.setSpacing(true); mCommunicationsButtons.addComponent(addNewButton); mCommunicationsButtons.addComponent(deleteButton); VerticalLayout wrapper = new VerticalLayout(); wrapper.setData("communications"); wrapper.addComponent(mCommunicationsTable); wrapper.addComponent(mCommunicationsButtons); wrapper.setComponentAlignment(mCommunicationsButtons, Alignment.MIDDLE_CENTER); mContactMetawidget.addComponent(wrapper); mCommunicationsTable.setContainerDataSource(tableDataSource); body.addComponent(mContactMetawidget, "pagebody"); // Embedded buttons Facet facetButtons = new Facet(); facetButtons.setData("buttons"); facetButtons.setWidth("100%"); mContactMetawidget.addComponent(facetButtons); mButtonsMetawidget = new VaadinMetawidget(); mButtonsMetawidget.setWidth(null); mButtonsMetawidget.setConfig("org/metawidget/example/vaadin/addressbook/metawidget.xml"); mButtonsMetawidget.setLayout(new HorizontalLayout()); mButtonsMetawidget.setToInspect(this); facetButtons.addComponent(mButtonsMetawidget); ((com.vaadin.ui.VerticalLayout) facetButtons.getContent()).setComponentAlignment(mButtonsMetawidget, Alignment.MIDDLE_CENTER); }