List of usage examples for com.vaadin.ui HorizontalLayout setSizeFull
@Override public void setSizeFull()
From source file:com.mycompany.project.views.ContactsView.java
public ContactsView() { VerticalLayout mainVLayout = new VerticalLayout(); mainVLayout.setMargin(true);//from w w w . j a v a2 s. com mainVLayout.setSpacing(true); setContent(mainVLayout); // view header Label header = new Label("<div align=\"center\" style=\"font-size:12pt;\">Contactos</div>"); header.setContentMode(ContentMode.HTML); mainVLayout.addComponent(header); // set window properties window.setWidth("400px"); window.setCaption("Nuevo Contacto"); window.setModal(true); window.setContent(newContactForm); // add new cotact button Button btnNew = new Button("Agregar Nuevo Contacto"); mainVLayout.addComponent(btnNew); // clicking the button should display the NewContactForm btnNew.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (window.getParent() == null) { getUI().addWindow(window); } } }); //add a horozontal layout - left has a table, right has a ContactDetail component HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSizeFull(); hLayout.setSpacing(true); mainVLayout.addComponent(hLayout); //add a table table.setWidth("600px"); table.setImmediate(true); hLayout.addComponent(table); // how does table get its data beanContainer.setBeanIdProperty("id"); table.setContainerDataSource(beanContainer); //set columns final Object[] NATURAL_COL_ORDER = new Object[] { "name", "phone", "email" }; final String[] COL_HEADERS_ENGLISH = new String[] { "Name", "Phone", "Email" }; table.setSelectable(true); table.setColumnCollapsingAllowed(true); table.setRowHeaderMode(RowHeaderMode.INDEX); table.setVisibleColumns(NATURAL_COL_ORDER); table.setColumnHeaders(COL_HEADERS_ENGLISH); // selecting a table row should enable/disale the ContactDetails component table.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { String contactId = (String) table.getValue(); contactDetails.setContactId(contactId); } }); //add a ContactDetails component // contactDetails.setWidth("500px"); hLayout.addComponent(contactDetails); // let the table fill the entire remaining width hLayout.setExpandRatio(contactDetails, 1); }
From source file:com.mycompany.project.views.GroupsView.java
public GroupsView() { VerticalLayout mainVLayout = new VerticalLayout(); mainVLayout.setMargin(true);/*ww w .ja v a 2 s. com*/ mainVLayout.setSpacing(true); setContent(mainVLayout); // view header Label header = new Label("<div align=\"center\" style=\"font-size:12pt;\">Grupos</div>"); header.setContentMode(ContentMode.HTML); mainVLayout.addComponent(header); // set window properties window.setWidth("400px"); window.setCaption("New Group"); window.setModal(true); window.setContent(newGroupForm); // add new cotact button Button btnNew = new Button("Add New Group"); mainVLayout.addComponent(btnNew); // clicking the button should display the NewContactForm btnNew.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (window.getParent() == null) { getUI().addWindow(window); } } }); //add a horozontal layout - left has a table, right has a ContactDetail component HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSizeFull(); hLayout.setSpacing(true); mainVLayout.addComponent(hLayout); //add a table table.setWidth("600px"); table.setImmediate(true); hLayout.addComponent(table); // how does table get its data beanContainer.setBeanIdProperty("id"); table.setContainerDataSource(beanContainer); //set columns final Object[] NATURAL_COL_ORDER = new Object[] { "name" }; final String[] COL_HEADERS_ENGLISH = new String[] { "Name" }; table.setSelectable(true); table.setColumnCollapsingAllowed(true); table.setRowHeaderMode(RowHeaderMode.INDEX); table.setVisibleColumns(NATURAL_COL_ORDER); table.setColumnHeaders(COL_HEADERS_ENGLISH); // selecting a table row should enable/disale the ContactDetails component table.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { String groupId = (String) table.getValue(); groupDetails.setGroupId(groupId); } }); //add a ContactDetails component // contactDetails.setWidth("500px"); hLayout.addComponent(groupDetails); // let the table fill the entire remaining width hLayout.setExpandRatio(groupDetails, 1); }
From source file:com.ocs.dynamo.ui.component.FancyListSelect.java
License:Apache License
@Override protected Component initContent() { VerticalLayout layout = new DefaultVerticalLayout(false, false); HorizontalLayout firstBar = new DefaultHorizontalLayout(false, false, true); firstBar.setSizeFull(); comboBox.setCaption(null);//from ww w.ja va 2 s. c om comboBox.setSizeFull(); firstBar.addComponent(comboBox); layout.addComponent(firstBar); HorizontalLayout secondBar = new DefaultHorizontalLayout(false, true, true); firstBar.addComponent(secondBar); // button for selecting an item selectButton = new Button(getMessageService().getMessage("ocs.select")); selectButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 2333147549550914035L; @Override @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { if (comboBox.getValue() != null) { if (!container.containsId(comboBox.getValue())) { container.addBean((T) comboBox.getValue()); copyValueFromContainer(); } } comboBox.setValue(null); } }); secondBar.addComponent(selectButton); // adds a button for removing the selected items from the list select removeButton = new Button(getMessageService().getMessage("ocs.remove")); removeButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -1761776309410298236L; @Override @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { Object value = listSelect.getValue(); if (value instanceof Collection) { Collection<T> col = (Collection<T>) value; for (T t : col) { container.removeItem(t); copyValueFromContainer(); } } } }); secondBar.addComponent(removeButton); // add a button for removing all items at once clearButton = new Button(getMessageService().getMessage("ocs.clear")); clearButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -1761776309410298236L; @Override public void buttonClick(ClickEvent event) { // clear the container setValue(new HashSet<>()); copyValueFromContainer(); } }); secondBar.addComponent(clearButton); if (addAllowed) { Button addButton = constructAddButton(); secondBar.addComponent(addButton); } listSelect.setSizeFull(); listSelect.setNullSelectionAllowed(false); listSelect.setItemCaptionMode(ItemCaptionMode.PROPERTY); listSelect.setItemCaptionPropertyId(getEntityModel().getDisplayProperty()); listSelect.setMultiSelect(true); layout.addComponent(listSelect); return layout; }
From source file:com.ocs.dynamo.ui.component.QuickAddEntityComboBox.java
License:Apache License
@Override protected Component initContent() { HorizontalLayout bar = new DefaultHorizontalLayout(false, true, true); bar.setSizeFull(); if (this.getAttributeModel() != null) { this.setCaption(getAttributeModel().getDisplayName()); }//from ww w . j a v a 2 s .com // no caption needed (the wrapping component has the caption) comboBox.setCaption(null); comboBox.setSizeFull(); comboBox.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 5114731461745867455L; @Override @SuppressWarnings("unchecked") public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { setValue((T) event.getProperty().getValue()); } }); bar.addComponent(comboBox); Button addButton = constructAddButton(); bar.addComponent(addButton); return bar; }
From source file:com.ocs.dynamo.ui.component.QuickAddListSelect.java
License:Apache License
@Override protected Component initContent() { HorizontalLayout bar = new DefaultHorizontalLayout(false, true, true); bar.setSizeFull(); if (this.getAttributeModel() != null) { this.setCaption(getAttributeModel().getDisplayName()); }//from w w w . ja v a2 s .c o m // no caption needed (the wrapping component has the caption) listSelect.setCaption(null); listSelect.setSizeFull(); listSelect.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 5114731461745867455L; @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { setValue(event.getProperty().getValue()); } }); bar.addComponent(listSelect); if (!viewMode) { addButton = constructAddButton(); bar.addComponent(addButton); } return bar; }
From source file:com.ocs.dynamo.ui.component.TokenFieldSelect.java
License:Apache License
@Override protected Component initContent() { HorizontalLayout layout = new DefaultHorizontalLayout(false, true, false); comboBox.setInputPrompt(getMessageService().getMessage("ocs.type.to.add")); comboBox.setFilteringMode(FilteringMode.CONTAINS); comboBox.setWidth(20, Unit.PERCENTAGE); comboBox.setHeightUndefined();/* www . j a v a 2 s .c o m*/ extTokenField.setInputField(comboBox); extTokenField.setEnableDefaultDeleteTokenAction(true); attachComboBoxValueChange(); attachTokenFieldValueChange(); setupContainerFieldSync(); layout.addComponent(extTokenField); if (addAllowed) { Button addButton = constructAddButton(); layout.addComponent(addButton); } // initial filling of the field addTokens(); layout.setSizeFull(); return layout; }
From source file:com.ocs.dynamo.ui.composite.form.ModelBasedSearchForm.java
License:Apache License
/** * Constructs a filter group for searching on a single attribute * /*from w w w .ja v a 2s .co m*/ * @param entityModel * the entity model * @param attributeModel * the attribute model * @return */ protected FilterGroup constructFilterGroup(EntityModel<T> entityModel, AttributeModel attributeModel) { Field<?> field = this.constructField(entityModel, attributeModel); if (field != null) { FilterType filterType = FilterType.BETWEEN; if (String.class.isAssignableFrom(attributeModel.getType())) { filterType = FilterType.LIKE; } else if (Boolean.class.isAssignableFrom(attributeModel.getType()) || Boolean.TYPE.isAssignableFrom(attributeModel.getType())) { filterType = FilterType.BOOLEAN; } else if (attributeModel.getType().isEnum()) { filterType = FilterType.ENUM; } else if (AbstractEntity.class.isAssignableFrom(attributeModel.getType()) || AttributeType.DETAIL.equals(attributeModel.getAttributeType())) { // search for an entity filterType = FilterType.ENTITY; } else if (attributeModel.isSearchForExactValue()) { filterType = FilterType.EQUAL; } Component comp = field; Field<?> auxField = null; if (FilterType.BETWEEN.equals(filterType)) { // in case of a between value, construct two fields for the // lower // and upper bounds String from = message("ocs.from"); field.setCaption(attributeModel.getDisplayName() + " " + from); auxField = constructField(entityModel, attributeModel); String to = message("ocs.to"); auxField.setCaption(attributeModel.getDisplayName() + " " + to); auxField.setVisible(true); HorizontalLayout layout = new DefaultHorizontalLayout(); layout.setSizeFull(); layout.addComponent(field); layout.addComponent(auxField); comp = layout; } return new FilterGroup(attributeModel, attributeModel.getPath(), filterType, comp, field, auxField); } return null; }
From source file:com.oodrive.nuage.webui.component.window.AbstractConfirmationWindow.java
License:Apache License
@SuppressWarnings("serial") @Override/*from www. j a va2s . c o m*/ public Window init(final AbstractItemModel model) { // Add new window final Window vvrConfirmationWindow = new Window("Confirmation"); vvrConfirmationWindow.center(); vvrConfirmationWindow.setResizable(false); final VerticalLayout vvrConfirmationLayout = new VerticalLayout(); vvrConfirmationLayout.setMargin(true); vvrConfirmationWindow.setContent(vvrConfirmationLayout); // Message to display before buttons final Label confirmationMessage = new Label(confirmation); vvrConfirmationLayout.addComponent(confirmationMessage); vvrConfirmationLayout.setComponentAlignment(confirmationMessage, Alignment.MIDDLE_CENTER); vvrConfirmationLayout.setSpacing(true); final HorizontalLayout buttonLayout = new HorizontalLayout(); vvrConfirmationLayout.addComponent(buttonLayout); // Button OK final Button okButton = new Button("OK"); buttonLayout.setSizeFull(); buttonLayout.addComponent(okButton); buttonLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER); okButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { action.execute(model); vvrConfirmationWindow.close(); } catch (final Exception e) { vvrConfirmationWindow.close(); } } }); // Button cancel final Button cancelButton = new Button("Cancel"); buttonLayout.addComponent(cancelButton); buttonLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER); cancelButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { // Just close the window vvrConfirmationWindow.close(); } }); return vvrConfirmationWindow; }
From source file:com.oodrive.nuage.webui.component.window.VvrAttributesWindow.java
License:Apache License
@SuppressWarnings("serial") @Override//from ww w . j a v a2 s. co m public final Window init(final AbstractItemModel model) { // Cast model in vvrModel final VvrModel vvrModel = (VvrModel) model; // Add new window final Window vvrAttributesWindow = new Window("VVR Attributes"); vvrAttributesWindow.center(); vvrAttributesWindow.setWidth("400px"); vvrAttributesWindow.setResizable(false); final VerticalLayout layout = new VerticalLayout(); vvrAttributesWindow.setContent(layout); layout.setMargin(true); final FormLayout vvrAttributesLayout = new FormLayout(); layout.addComponent(vvrAttributesLayout); vvrAttributesLayout.setMargin(true); // Enter NAME String value = vvrModel.getVvrName(); if (value == null) { value = ""; } final TextField name = new TextField("Name", value); name.setSizeFull(); vvrAttributesLayout.addComponent(name); // Enter description value = vvrModel.getVvrDescription(); if (value == null) { value = ""; } final TextField desc = new TextField("Description", value); desc.setSizeFull(); vvrAttributesLayout.addComponent(desc); // Enter name final TextField vvrUUID = new TextField("UUID"); vvrUUID.setValue(vvrUuid.toString()); vvrUUID.setReadOnly(true); vvrUUID.setSizeFull(); vvrAttributesLayout.addComponent(vvrUUID); // OK button final HorizontalLayout hzlayout = new HorizontalLayout(); layout.addComponent(hzlayout); hzlayout.setSizeFull(); final Button okButton = new Button("OK"); hzlayout.addComponent(okButton); hzlayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER); okButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { WaitingComponent.executeBackground(vvrModel, new Background() { @Override public void processing() { vvrModel.setVvrName(name.getValue()); vvrModel.setVvrDescription(desc.getValue()); } @Override public void postProcessing() { } }); vvrAttributesWindow.close(); } }); // Cancel button final Button cancelButton = new Button("Cancel"); hzlayout.addComponent(cancelButton); hzlayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER); cancelButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { // Just close the window vvrAttributesWindow.close(); } }); return vvrAttributesWindow; }
From source file:com.oodrive.nuage.webui.VvrManagerUi.java
License:Apache License
@Override protected void init(final VaadinRequest request) { // Listener to disconnect JMX connection on exit. addDetachListener(new DetachListener() { @Override//from w ww.j a v a 2 s.co m public void detach(final DetachEvent event) { jmxHandler.disconnect(); } }); setPollInterval(1000); final Label labelLeft = new Label(""); final Label labelRight = new Label(""); labelLeft.setHeight("100%"); labelRight.setHeight("100%"); final HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); rootLayout.setWidth(rootLayoutWidth); rootLayout.setImmediate(true); rootLayout.addComponent(vvrManagerLayout); vvrManagerLayout.setMargin(false); vvrManagerLayout.setSpacing(true); vvrManagerLayout.setWidth(rootLayoutWidth); content.addComponent(labelLeft); content.addComponent(rootLayout); content.addComponent(labelRight); content.setExpandRatio(labelLeft, 0.5f); content.setExpandRatio(labelRight, 0.5f); content.setComponentAlignment(rootLayout, Alignment.TOP_CENTER); setContent(content); // Init Jmx Handler try { jmxHandler.connect(); // Init ui initVvrManagerUi(jmxHandler); } catch (final Exception e) { LOGGER.error("Can not connect to JMX", e); } }