List of usage examples for com.vaadin.ui HorizontalLayout addComponent
@Override public void addComponent(Component c)
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();// w w w .ja va 2 s .c o m if (this.getAttributeModel() != null) { this.setCaption(getAttributeModel().getDisplayName()); } // 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();//from w w w. j a v a 2s . c om 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.dialog.EntityPopupDialog.java
License:Apache License
@Override protected void doBuildButtonBar(HorizontalLayout buttonBar) { // in read-only mode, display only an "OK" button that closes the dialog buttonBar.setVisible(formOptions.isReadOnly()); if (formOptions.isReadOnly()) { Button okButton = new Button(messageService.getMessage("ocs.ok")); okButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1889018073135108348L; @Override// ww w . j a va2 s . co m public void buttonClick(ClickEvent event) { close(); } }); buttonBar.addComponent(okButton); } }
From source file:com.ocs.dynamo.ui.composite.dialog.SimpleModalDialog.java
License:Apache License
@Override protected void doBuildButtonBar(HorizontalLayout buttonBar) { okButton = new Button(com.ocs.dynamo.ui.ServiceLocator.getMessageService().getMessage("ocs.ok")); okButton.addClickListener(new Button.ClickListener() { @Override//www . ja v a 2s . c o m public void buttonClick(ClickEvent event) { boolean result = doClose(); if (result) { SimpleModalDialog.this.close(); } } }); buttonBar.addComponent(okButton); cancelButton = new Button(com.ocs.dynamo.ui.ServiceLocator.getMessageService().getMessage("ocs.cancel")); cancelButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { SimpleModalDialog.this.close(); } }); cancelButton.setVisible(showCancelButton); buttonBar.addComponent(cancelButton); }
From source file:com.ocs.dynamo.ui.composite.form.ModelBasedEditForm.java
License:Apache License
private HorizontalLayout constructButtonBar() { HorizontalLayout buttonBar = new DefaultHorizontalLayout(); // button to go back to the main screen when in view mode if (isViewMode() && getFormOptions().isShowBackButton()) { Button backButton = new Button(message("ocs.back")); backButton.addClickListener(new Button.ClickListener() { @Override/*w ww . j a v a2 s .c o m*/ public void buttonClick(ClickEvent event) { back(); } }); buttonBar.addComponent(backButton); } // in edit mode, display a cancel button if (!isViewMode() && !getFormOptions().isHideCancelButton()) { Button cancelButton = new Button(message("ocs.cancel")); cancelButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (entity.getId() != null) { entity = service.fetchById(entity.getId()); } afterEditDone(true, entity.getId() == null, entity); } }); buttonBar.addComponent(cancelButton); } // create the save button if (!isViewMode()) { Button saveButton = constructSaveButton(); buttonBar.addComponent(saveButton); saveButtons.add(saveButton); } // create the edit button if (isViewMode() && getFormOptions().isShowEditButton() && isEditAllowed()) { Button editButton = new Button(message("ocs.edit")); editButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { setViewMode(false); } }); buttonBar.addComponent(editButton); } postProcessButtonBar(buttonBar, isViewMode()); return buttonBar; }
From source file:com.ocs.dynamo.ui.composite.form.ModelBasedSearchForm.java
License:Apache License
/** * Constructs a filter group for searching on a single attribute * /* w ww . ja va 2 s . c o 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.ocs.dynamo.ui.composite.layout.HorizontalDisplayLayout.java
License:Apache License
@Override public void build() { HorizontalLayout layout = new DefaultHorizontalLayout(false, true, true); for (AttributeModel attributeModel : getEntityModel().getAttributeModels()) { if (attributeModel.isVisible() && AttributeType.BASIC.equals(attributeModel.getAttributeType())) { layout.addComponent(constructLabel(entity, attributeModel)); }//ww w .j a v a 2 s.co m } setCompositionRoot(layout); }
From source file:com.oodrive.nuage.webui.component.VvrOperationComponent.java
License:Apache License
@Override public final AbstractComponent createComponent(final VvrModel model, final ModelCreator handler) { final HorizontalLayout operationLayout = new HorizontalLayout(); operationLayout.setMargin(true);//from ww w .j a v a2s .c o m operationLayout.setSpacing(true); operationLayout.setWidth("100%"); // Start and description buttons // START/STOP final Button startStop = new Button(); startStop.setWidth(BUTTON_WIDTH); startStop.addStyleName(Runo.BUTTON_BIG); final Resource iconStartStop; final String description; if (!model.isVvrStarted()) { iconStartStop = WebUiResources.getStartIcon(); description = "Start"; } else { iconStartStop = WebUiResources.getStopIcon(); description = "Stop"; } startStop.setIcon(iconStartStop); startStop.setDescription(description); operationLayout.addComponent(startStop); operationLayout.setExpandRatio(startStop, 1f); operationLayout.setComponentAlignment(startStop, Alignment.MIDDLE_LEFT); final UUID vvrUuid = model.getItemUuid(); startStop.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { final boolean started = model.isVvrStarted(); // Start/Stop are done in background if (!started) { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.startVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStopIcon()); startStop.setDescription("Stop"); Notification.show("VVR started ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } else { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.stopVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStartIcon()); startStop.setDescription("Start"); Notification.show("VVR stopped ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } } }); // ATTRIBUTES final Button attributes = new Button(); attributes.addStyleName(Runo.BUTTON_BIG); attributes.setWidth(BUTTON_WIDTH); operationLayout.addComponent(attributes); operationLayout.setExpandRatio(attributes, 1f); operationLayout.setComponentAlignment(attributes, Alignment.MIDDLE_LEFT); attributes.setIcon(WebUiResources.getSettingsIcon()); attributes.setDescription("Settings"); attributes.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrAttributesWindow attributesWindow = new VvrAttributesWindow(vvrUuid); attributesWindow.add(model); } catch (final Exception e) { LOGGER.error("Can not get VVR attributes: ", e); final ErrorWindow err = new ErrorWindow("Can not display VVR Attributes: " + e.getMessage()); err.add(model); } } }); // DELETE final Button delete = new Button(); delete.addStyleName(Runo.BUTTON_BIG); delete.setWidth(BUTTON_WIDTH); delete.setIcon(WebUiResources.getTrashIcon()); delete.setDescription("Delete"); operationLayout.addComponent(delete); operationLayout.setExpandRatio(delete, 12f); operationLayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT); delete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrDeleteWindow deleteWindow = new VvrDeleteWindow(vvrUuid); deleteWindow.add(vvrManagerModel); } catch (final Exception e) { LOGGER.error("Can not delete VVR: ", e); final ErrorWindow err = new ErrorWindow("Can not delete VVR: " + e.getMessage()); err.add(model); } } }); return operationLayout; }
From source file:com.oodrive.nuage.webui.component.window.AbstractConfirmationWindow.java
License:Apache License
@SuppressWarnings("serial") @Override/*from w w w.j a v a 2 s .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 w w w . j av a2s . c o 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; }