List of usage examples for com.vaadin.ui Button addClickListener
public Registration addClickListener(ClickListener listener)
From source file:com.haulmont.cuba.web.AppUI.java
License:Apache License
protected void showCriticalExceptionMessage(Exception exception) { String initErrorCaption = messages.getMainMessage("app.initErrorCaption"); String initErrorMessage = messages.getMainMessage("app.initErrorMessage"); VerticalLayout content = new VerticalLayout(); content.setStyleName("c-init-error-view"); content.setSizeFull();/*from w w w . j a v a 2s . c om*/ VerticalLayout errorPanel = new VerticalLayout(); errorPanel.setStyleName("c-init-error-panel"); errorPanel.setWidthUndefined(); errorPanel.setSpacing(true); Label captionLabel = new Label(initErrorCaption); captionLabel.setWidthUndefined(); captionLabel.setStyleName("c-init-error-caption"); captionLabel.addStyleName("h2"); captionLabel.setValue(initErrorCaption); errorPanel.addComponent(captionLabel); Label messageLabel = new Label(initErrorCaption); messageLabel.setWidthUndefined(); messageLabel.setStyleName("c-init-error-message"); messageLabel.setValue(initErrorMessage); errorPanel.addComponent(messageLabel); Button retryButton = new Button(messages.getMainMessage("app.initRetry")); retryButton.setStyleName("c-init-error-retry"); retryButton.addClickListener(event -> { // always restart UI String url = ControllerUtils.getLocationWithoutParams() + "?restartApp"; getPage().open(url, "_self"); }); errorPanel.addComponent(retryButton); errorPanel.setComponentAlignment(retryButton, Alignment.MIDDLE_CENTER); content.addComponent(errorPanel); content.setComponentAlignment(errorPanel, Alignment.MIDDLE_CENTER); setContent(content); }
From source file:com.haulmont.cuba.web.exception.ExceptionDialog.java
License:Apache License
public ExceptionDialog(Throwable throwable, @Nullable String caption, @Nullable String message) { final AppUI ui = AppUI.getCurrent(); String closeShortcut = clientConfig.getCloseShortcut(); KeyCombination closeCombination = KeyCombination.create(closeShortcut); com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction( "closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers())); addActionHandler(new com.vaadin.event.Action.Handler() { @Override/*from w ww .j a v a 2s .co m*/ public com.vaadin.event.Action[] getActions(Object target, Object sender) { return new com.vaadin.event.Action[] { closeShortcutAction }; } @Override public void handleAction(com.vaadin.event.Action action, Object sender, Object target) { if (Objects.equals(action, closeShortcutAction)) { close(); } } }); setCaption(caption != null ? caption : messages.getMainMessage("exceptionDialog.caption")); ThemeConstants theme = ui.getApp().getThemeConstants(); setWidth(theme.get("cuba.web.ExceptionDialog.width")); center(); final String text = message != null ? message : getText(throwable); Throwable exception = removeRemoteException(throwable); final String stackTrace = getStackTrace(exception); mainLayout = new VerticalLayout(); mainLayout.setSpacing(true); TextArea textArea = new TextArea(); textArea.setHeight(theme.get("cuba.web.ExceptionDialog.textArea.height")); textArea.setWidth(100, Unit.PERCENTAGE); boolean showExceptionDetails = userSessionSource.getUserSession() != null && security.isSpecificPermitted("cuba.gui.showExceptionDetails"); if (showExceptionDetails) { textArea.setValue(text); } else { textArea.setValue(messages.getMainMessage("exceptionDialog.contactAdmin")); } textArea.setReadOnly(true); mainLayout.addComponent(textArea); HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); buttonsLayout.setWidth("100%"); mainLayout.addComponent(buttonsLayout); Button closeButton = new CubaButton(messages.getMainMessage("exceptionDialog.closeBtn")); closeButton.addClickListener((Button.ClickListener) event -> this.close()); buttonsLayout.addComponent(closeButton); showStackTraceButton = new CubaButton(messages.getMainMessage("exceptionDialog.showStackTrace")); showStackTraceButton .addClickListener((Button.ClickListener) event -> setStackTraceVisible(!isStackTraceVisible)); buttonsLayout.addComponent(showStackTraceButton); showStackTraceButton.setVisible(showExceptionDetails); Label spacer = new Label(); buttonsLayout.addComponent(spacer); buttonsLayout.setExpandRatio(spacer, 1); String cubaLogContentClass = "c-exception-dialog-log-content"; String cubaCopyLogContentClass = cubaLogContentClass + "-" + UUID.randomUUID(); if (browserSupportCopy()) { copyButton = new CubaButton(messages.getMainMessage("exceptionDialog.copyStackTrace")); copyButton.setVisible(false); CubaCopyButtonExtension copyExtension = CubaCopyButtonExtension.copyWith(copyButton, cubaCopyLogContentClass); copyExtension .addCopyListener( event -> Notification.show( messages.getMainMessage(event.isSuccess() ? "exceptionDialog.copingSuccessful" : "exceptionDialog.copingFailed"), Notification.Type.TRAY_NOTIFICATION)); buttonsLayout.addComponent(copyButton); } if (userSessionSource.getUserSession() != null) { if (!StringUtils.isBlank(clientConfig.getSupportEmail())) { Button reportButton = new CubaButton(messages.getMainMessage("exceptionDialog.reportBtn")); reportButton.addClickListener((Button.ClickListener) event -> { sendSupportEmail(text, stackTrace); reportButton.setEnabled(false); }); buttonsLayout.addComponent(reportButton); if (ui.isTestMode()) { reportButton.setCubaId("errorReportButton"); } } } Button logoutButton = new CubaButton(messages.getMainMessage("exceptionDialog.logout")); logoutButton.addClickListener((Button.ClickListener) event -> logoutPrompt()); buttonsLayout.addComponent(logoutButton); stackTraceTextArea = new TextArea(); stackTraceTextArea.setSizeFull(); stackTraceTextArea.setWordwrap(false); stackTraceTextArea.setValue(stackTrace); stackTraceTextArea.setStyleName(cubaLogContentClass); stackTraceTextArea.addStyleName(cubaCopyLogContentClass); stackTraceTextArea.setReadOnly(true); setContent(mainLayout); setResizable(false); if (ui.isTestMode()) { setId(ui.getTestIdManager().getTestId("exceptionDialog")); setCubaId("exceptionDialog"); closeButton.setCubaId("closeButton"); if (copyButton != null) { copyButton.setCubaId("copyStackTraceButton"); } showStackTraceButton.setCubaId("showStackTraceButton"); stackTraceTextArea.setCubaId("stackTraceTextArea"); logoutButton.setCubaId("logoutButton"); } }
From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java
License:Apache License
protected void showNoUserSessionDialog(App app) { Messages messages = AppBeans.get(Messages.NAME); Window dialog = new NoUserSessionExceptionDialog(); dialog.setStyleName("c-nousersession-dialog"); dialog.setCaption(messages.getMainMessage("dialogs.Information", locale)); dialog.setClosable(false);/*from w w w . j a va 2s .com*/ dialog.setResizable(false); dialog.setModal(true); AppUI ui = app.getAppUI(); if (ui.isTestMode()) { dialog.setCubaId("optionDialog"); dialog.setId(ui.getTestIdManager().getTestId("optionDialog")); } Label messageLab = new CubaLabel(); messageLab.setWidthUndefined(); messageLab.setValue(messages.getMainMessage("noUserSession.message", locale)); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setWidthUndefined(); layout.setStyleName("c-nousersession-dialog-layout"); layout.setSpacing(true); dialog.setContent(layout); Button reloginBtn = new Button(); if (ui.isTestMode()) { reloginBtn.setCubaId("reloginBtn"); reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn")); } reloginBtn.addStyleName(WebButton.ICON_STYLE); reloginBtn.addStyleName("c-primary-action"); reloginBtn.addClickListener(event -> relogin()); reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey())); String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey()); reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName)); ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class); setClickShortcut(reloginBtn, clientConfig.getCommitShortcut()); reloginBtn.focus(); layout.addComponent(messageLab); layout.addComponent(reloginBtn); layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT); ui.addWindow(dialog); dialog.center(); }
From source file:com.haulmont.cuba.web.gui.components.presentations.PresentationEditor.java
License:Apache License
protected void initLayout() { ThemeConstants theme = App.getInstance().getThemeConstants(); VerticalLayout root = new VerticalLayout(); root.setWidthUndefined();//from w w w. j a va 2 s .c om root.setSpacing(true); setContent(root); messages = AppBeans.get(Messages.class); nameField = new TextField(messages.getMainMessage("PresentationsEditor.name")); nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width")); nameField.setValue(getPresentationCaption()); root.addComponent(nameField); autoSaveField = new CheckBox(); autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave")); autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave())); root.addComponent(autoSaveField); defaultField = new CheckBox(); defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default")); defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId())); root.addComponent(defaultField); if (allowGlobalPresentations) { globalField = new CheckBox(); globalField.setCaption(messages.getMainMessage("PresentationsEditor.global")); globalField.setValue(!isNew && presentation.getUser() == null); root.addComponent(globalField); } HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setWidthUndefined(); root.addComponent(buttons); root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT); Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save")); commitButton.addClickListener(event -> { if (validate()) { commit(); close(); } }); buttons.addComponent(commitButton); Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close")); closeButton.addClickListener(event -> { close(); }); buttons.addComponent(closeButton); nameField.focus(); }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override public void showMessageDialog(String title, String message, MessageType messageType) { backgroundWorker.checkUIAccess();//from www . ja v a2 s . c o m final com.vaadin.ui.Window vWindow = new CubaWindow(title); if (ui.isTestMode()) { vWindow.setCubaId("messageDialog"); vWindow.setId(ui.getTestIdManager().getTestId("messageDialog")); } String closeShortcut = clientConfig.getCloseShortcut(); KeyCombination closeCombination = KeyCombination.create(closeShortcut); vWindow.addAction(new ShortcutListener("Esc", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers())) { @Override public void handleAction(Object sender, Object target) { vWindow.close(); } }); vWindow.addAction(new ShortcutListener("Enter", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { vWindow.close(); } }); VerticalLayout layout = new VerticalLayout(); layout.setStyleName("c-app-message-dialog"); layout.setSpacing(true); if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { layout.setWidthUndefined(); } vWindow.setContent(layout); Label messageLab = new CubaLabel(); messageLab.setValue(message); if (MessageType.isHTML(messageType)) { messageLab.setContentMode(ContentMode.HTML); } else { messageLab.setContentMode(ContentMode.TEXT); } if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { messageLab.setWidthUndefined(); } layout.addComponent(messageLab); DialogAction action = new DialogAction(Type.OK); Button button = WebComponentsHelper.createButton(); button.setCaption(action.getCaption()); button.setIcon(WebComponentsHelper.getIcon(action.getIcon())); button.addStyleName(WebButton.ICON_STYLE); button.addClickListener(event -> vWindow.close()); button.focus(); layout.addComponent(button); layout.setComponentAlignment(button, Alignment.BOTTOM_RIGHT); float width; SizeUnit unit; DialogParams dialogParams = getDialogParams(); if (messageType.getWidth() != null) { width = messageType.getWidth(); unit = messageType.getWidthUnit(); } else if (dialogParams.getWidth() != null) { width = dialogParams.getWidth(); unit = dialogParams.getWidthUnit(); } else { SizeWithUnit size = SizeWithUnit .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.messageDialog.width")); width = size.getSize(); unit = size.getUnit(); } vWindow.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS); vWindow.setResizable(false); boolean modal = true; if (!hasModalWindow()) { if (messageType.getModal() != null) { modal = messageType.getModal(); } else if (dialogParams.getModal() != null) { modal = dialogParams.getModal(); } } vWindow.setModal(modal); boolean closeOnClickOutside = false; if (vWindow.isModal()) { if (messageType.getCloseOnClickOutside() != null) { closeOnClickOutside = messageType.getCloseOnClickOutside(); } } ((CubaWindow) vWindow).setCloseOnClickOutside(closeOnClickOutside); if (messageType.getMaximized() != null) { if (messageType.getMaximized()) { vWindow.setWindowMode(WindowMode.MAXIMIZED); } else { vWindow.setWindowMode(WindowMode.NORMAL); } } dialogParams.reset(); ui.addWindow(vWindow); vWindow.center(); vWindow.focus(); }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override public void showOptionDialog(String title, String message, MessageType messageType, Action[] actions) { backgroundWorker.checkUIAccess();/*from ww w .j a va 2 s . c o m*/ final com.vaadin.ui.Window window = new CubaWindow(title); if (ui.isTestMode()) { window.setCubaId("optionDialog"); window.setId(ui.getTestIdManager().getTestId("optionDialog")); } window.setClosable(false); Label messageLab = new CubaLabel(); messageLab.setValue(message); if (MessageType.isHTML(messageType)) { messageLab.setContentMode(ContentMode.HTML); } else { messageLab.setContentMode(ContentMode.TEXT); } if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { messageLab.setWidthUndefined(); } float width; SizeUnit unit; if (messageType.getWidth() != null) { width = messageType.getWidth(); unit = messageType.getWidthUnit(); } else if (getDialogParams().getWidth() != null) { width = getDialogParams().getWidth(); unit = getDialogParams().getWidthUnit(); } else { SizeWithUnit size = SizeWithUnit .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.optionDialog.width")); width = size.getSize(); unit = size.getUnit(); } if (messageType.getModal() != null) { log.warn("MessageType.modal is not supported for showOptionDialog"); } getDialogParams().reset(); window.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS); window.setResizable(false); window.setModal(true); boolean closeOnClickOutside = false; if (window.isModal()) { if (messageType.getCloseOnClickOutside() != null) { closeOnClickOutside = messageType.getCloseOnClickOutside(); } } ((CubaWindow) window).setCloseOnClickOutside(closeOnClickOutside); if (messageType.getMaximized() != null) { if (messageType.getMaximized()) { window.setWindowMode(WindowMode.MAXIMIZED); } else { window.setWindowMode(WindowMode.NORMAL); } } VerticalLayout layout = new VerticalLayout(); layout.setStyleName("c-app-option-dialog"); layout.setSpacing(true); if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { layout.setWidthUndefined(); } window.setContent(layout); HorizontalLayout buttonsContainer = new HorizontalLayout(); buttonsContainer.setSpacing(true); boolean hasPrimaryAction = false; Map<Action, Button> buttonMap = new HashMap<>(); for (Action action : actions) { Button button = WebComponentsHelper.createButton(); button.setCaption(action.getCaption()); button.addClickListener(event -> { try { action.actionPerform(null); } finally { ui.removeWindow(window); } }); if (StringUtils.isNotEmpty(action.getIcon())) { button.setIcon(WebComponentsHelper.getIcon(action.getIcon())); button.addStyleName(WebButton.ICON_STYLE); } if (action instanceof AbstractAction && ((AbstractAction) action).isPrimary()) { button.addStyleName("c-primary-action"); button.focus(); hasPrimaryAction = true; } if (ui.isTestMode()) { button.setCubaId("optionDialog_" + action.getId()); button.setId(ui.getTestIdManager().getTestId("optionDialog_" + action.getId())); } buttonsContainer.addComponent(button); buttonMap.put(action, button); } assignDialogShortcuts(buttonMap); if (!hasPrimaryAction && actions.length > 0) { ((Button) buttonsContainer.getComponent(0)).focus(); } layout.addComponent(messageLab); layout.addComponent(buttonsContainer); layout.setExpandRatio(messageLab, 1); layout.setComponentAlignment(buttonsContainer, Alignment.BOTTOM_RIGHT); ui.addWindow(window); window.center(); }
From source file:com.hivesys.dashboard.view.search.TextualView.java
public void UpdateSearchPane(String searchString) { css.removeAllComponents();//from w w w . j a v a2 s. c om SearchResponse response = ElasticSearchContext.getInstance().searchSimpleQuery(searchString); logResponse(response); SearchHits results = response.getHits(); Label labelResultSummary = new Label("About " + results.getHits().length + " results found <br><br>", ContentMode.HTML); css.addComponent(labelResultSummary); for (SearchHit hit : results) { CssLayout cssResult = new CssLayout(); cssResult.setStyleName("search-result"); try { String filename = DocumentDB.getInstance().getDocumentNameFromHash(hit.getId()); String boxviewID = DocumentDB.getInstance().getBoxViewIDFromHash(hit.getId()); String highlight = ""; HighlightField objhighlight = hit.highlightFields().get("file"); if (objhighlight != null) { for (Text fgmt : objhighlight.getFragments()) { highlight += fgmt.string() + "<br>"; } } Button lblfileName = new Button(filename); lblfileName.addClickListener((Button.ClickEvent event) -> { if (boxviewID != null) { String url = BoxViewDocuments.getInstance().getViewURL(boxviewID); if (url != null || !url.equals("")) { url = BoxViewDocuments.getInstance().getViewURL(boxviewID); BrowserFrame bframe = new BrowserFrame(filename, new ExternalResource(url)); VerticalLayout vlayout = new VerticalLayout(bframe); final Window w = new Window(); w.setSizeFull(); w.setModal(true); w.setWindowMode(WindowMode.MAXIMIZED); w.setContent(vlayout); vlayout.setSizeFull(); vlayout.setMargin(true); w.setResizable(false); w.setDraggable(false); UI.getCurrent().addWindow(w); bframe.setSizeFull(); return; } Notification.show("Preview not available for this document!"); } }); lblfileName.setPrimaryStyleName("filename"); Label lblHighlight = new Label(highlight, ContentMode.HTML); lblHighlight.setStyleName("highlight"); cssResult.addComponent(lblfileName); cssResult.addComponent(lblHighlight); css.addComponent(cssResult); css.addComponent(new Label("<br>", ContentMode.HTML)); } catch (SQLException ex) { } } }
From source file:com.hris.payroll.thirteenthmonth.ThirteenthMonth.java
private Button generate13thMonth() { Button button = new Button("13th MONTH"); button.setWidth("200px"); button.setIcon(FontAwesome.SPINNER); button.addStyleName(ValoTheme.BUTTON_PRIMARY); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener((Button.ClickEvent event) -> { status.setValue(" Loading..."); current = 1.0;/*from www .jav a 2s .c o m*/ dataSize = es.findEmployeeByBranch(getBranchId(), employmentStatus.getValue().toString(), CommonUtil.convertStringToInteger(year.getValue().toString())).size(); populateDataGrid(); }); return button; }
From source file:com.hybridbpm.ui.component.adaptive.AdaptiveTaskEditor.java
License:Apache License
@Override public void buttonClick(Button.ClickEvent event) { if (event.getButton().equals(btnSend)) { } else if (event.getButton().equals(btnProcess)) { adaptiveLayout.setVisible(false); templateLayout.removeAllComponents(); templateLayout.setVisible(true); for (StartProcess startProcess : HybridbpmUI.getBpmAPI().getMyProcessToStart()) { String startTaskTitle = startProcess.getProcessModel() .getTaskModelByName(startProcess.getTaskName()).getTitle(); String processTitle = startProcess.getProcessModel().getTitle() .getValue(HybridbpmUI.getCurrent().getLocale()); Button button = new Button(processTitle + " (" + startTaskTitle + ")"); button.setData(startProcess); button.addClickListener(this); button.setStyleName(ValoTheme.BUTTON_LINK); button.addStyleName(ValoTheme.BUTTON_SMALL); button.setIcon(FontAwesome.valueOf(startProcess.getIcon())); templateLayout.addComponent(button); }//from ww w . j a v a 2 s . c o m templateLayout.addComponent(btnBack); templateLayout.setComponentAlignment(btnBack, Alignment.BOTTOM_RIGHT); } else if (event.getButton().getData() instanceof StartProcess) { StartProcess spd = (StartProcess) event.getButton().getData(); if (taskLayout != null && card.getComponentIndex(taskLayout) > -1) { card.removeComponent(taskLayout); } taskLayout = new TaskLayout(null, spd.getProcessModel().getName(), spd.getTaskName(), true); card.addComponents(taskLayout); card.setExpandRatio(taskLayout, 1f); card.setSizeFull(); topLayout.setVisible(false); // panelView.toggleMaximized(this, true); } else if (event.getButton().equals(btnBack)) { adaptiveLayout.setVisible(true); templateLayout.setVisible(false); } }
From source file:com.hybridbpm.ui.component.chart.color.GaugeBandLayout.java
License:Apache License
public GaugeBandLayout(final BeanFieldGroup<DiagrammePreference> preferences) { super(preferences); setCaption("Gauge Band Colors"); setSizeFull();/*from ww w.j av a 2s .com*/ setSpacing(true); setMargin(false); addBandButton.setIcon(FontAwesome.PLUS); addBandButton.setStyleName(ValoTheme.BUTTON_BORDERLESS); addBandButton.addStyleName(ValoTheme.BUTTON_SMALL); bandAdditionButtonFrame.setSpacing(true); bandAdditionButtonFrame.addComponent(addBandButton); bandAdditionButtonFrame.setComponentAlignment(addBandButton, Alignment.MIDDLE_RIGHT); addComponent(bandAdditionButtonFrame); addBandButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addBand(); } }); colorTable.setHeight("100%"); colorTable.setWidth("100%"); colorTable.addStyleName(ValoTheme.TABLE_COMPACT); colorTable.addStyleName(ValoTheme.TABLE_SMALL); colorTable.addStyleName("color-table"); colorTable.addContainerProperty(Translate.getMessage("colour"), ColorPicker.class, null); colorTable.addContainerProperty(Translate.getMessage("start"), TextField.class, null); colorTable.addContainerProperty(Translate.getMessage("end"), TextField.class, null); colorTable.addContainerProperty("remove", Button.class, null); // COLOR COLUMN colorTable.addGeneratedColumn(Translate.getMessage("colour"), new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { final Property<String> colorProp = tableContainer.getItem(itemId).getItemProperty("color"); int[] col = ColourUtil.decode(colorProp.getValue()); ColorPicker picker = new ColorPicker(); picker.addStyleName("diagramme"); picker.setPosition(Page.getCurrent().getBrowserWindowWidth() / 2 - 246 / 2, Page.getCurrent().getBrowserWindowHeight() / 2 - 507 / 2); picker.setColor(new com.vaadin.shared.ui.colorpicker.Color(col[0], col[1], col[2])); picker.addColorChangeListener(new ColorChangeListener() { @Override public void colorChanged(ColorChangeEvent event) { colorProp.setValue(event.getColor().getCSS()); updateDiagramme(); } }); picker.setWidth("25px"); return picker; } }); // BAND START COLUMN colorTable.addGeneratedColumn(Translate.getMessage("start"), new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { final Property<Double> startProp = tableContainer.getContainerProperty(itemId, "startValue"); final ObjectProperty<Double> startValue = new ObjectProperty<Double>(0.0); TextField startField = new TextField(startValue); //startField.setWidth("60px"); startField.setSizeFull(); startField.setNullRepresentation("0"); startField.addStyleName("tfwb"); startField.setConvertedValue(startProp.getValue()); startField.setImmediate(true); startValue.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { startProp.setValue((Double) event.getProperty().getValue()); updateDiagramme(); } }); return startField; } }); // BAND END COLUMN colorTable.addGeneratedColumn(Translate.getMessage("end"), new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { final Property<Double> endProp = tableContainer.getContainerProperty(itemId, "endValue"); final ObjectProperty<Double> endValue = new ObjectProperty<Double>(0.0); TextField endField = new TextField(endValue); //endField.setWidth("60px"); endField.setSizeFull(); endField.setNullRepresentation("0"); endField.addStyleName("tfwb"); endField.setConvertedValue(endProp.getValue()); endField.setImmediate(true); endValue.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { endProp.setValue((Double) valueChangeEvent.getProperty().getValue()); updateDiagramme(); } }); return endField; } }); // DELETE BAND COLUMN colorTable.addGeneratedColumn("remove", new Table.ColumnGenerator() { @Override public Object generateCell(Table source, final Object itemId, Object columnId) { Button delete = new Button(FontAwesome.TIMES); delete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { removeBand(itemId); } }); delete.setWidth("43px"); return delete; } }); colorTable.setColumnWidth(Translate.getMessage("colour"), 33); colorTable.setColumnWidth("remove", 48); colorTable.setColumnExpandRatio(Translate.getMessage("start"), 0.5f); colorTable.setColumnExpandRatio(Translate.getMessage("end"), 0.5f); colorTable.setSortEnabled(false); colorTable.setPageLength(0); colorTable.setEditable(true); colorTable.setImmediate(true); addComponent(colorTable); setExpandRatio(colorTable, 1f); setComponentAlignment(colorTable, Alignment.TOP_LEFT); }