@Override public ComponentContainer constructBody() { MHorizontalLayout layout = new MHorizontalLayout().withMargin(true); nameField = ShortcutExtension.installShortcutAction( new TextField(), new ShortcutListener("OpportunitySearchRequest", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object o, Object o1) { callSearchAction(); } }); nameField.setInputPrompt("Query by opportunity name"); nameField.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH); layout.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER); this.myItemCheckbox = new CheckBox(AppContext.getMessage(GenericI18Enum.SEARCH_MYITEMS_CHECKBOX)); layout.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER); Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH)); searchBtn.setStyleName(UIConstants.BUTTON_ACTION); searchBtn.setIcon(FontAwesome.SEARCH); searchBtn.addClickListener( new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { OpportunityBasicSearchLayout.this.callSearchAction(); } }); layout.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLEAR)); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); cancelBtn.addClickListener( new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { OpportunityBasicSearchLayout.this.nameField.setValue(""); } }); layout.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER); Button advancedSearchBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { OpportunitySearchPanel.this.moveToAdvancedSearchLayout(); } }); advancedSearchBtn.setStyleName(UIConstants.BUTTON_LINK); layout.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER); return layout; }
@SuppressWarnings("serial") private void initButtonLinkCcBcc() { btnLinkCc = new Button("Add Cc"); btnLinkCc.setStyleName(UIConstants.BUTTON_LINK); inputLayout.addComponent(btnLinkCc, 1, 0); inputLayout.setComponentAlignment(btnLinkCc, Alignment.MIDDLE_CENTER); btnLinkBcc = new Button("Add Bcc"); btnLinkBcc.setStyleName(UIConstants.BUTTON_LINK); inputLayout.addComponent(btnLinkBcc, 2, 0); inputLayout.setComponentAlignment(btnLinkBcc, Alignment.MIDDLE_CENTER); btnLinkCc.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { buttonLinkCcClick(event); } }); btnLinkBcc.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { butonLinkBccClick(event); } }); }
private com.vaadin.ui.Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); final TextField username = new TextField("Username"); username.setIcon(FontAwesome.USER); username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final PasswordField password = new PasswordField("Password"); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(ShortcutAction.KeyCode.ENTER); signin.focus(); fields.addComponents(username, password, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); signin.addClickListener( new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { DashboardEventBus.post( new UserLoginRequestedEvent(username.getValue(), password.getValue())); } }); return fields; }
private void initComponents() { setSpacing(true); HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); layout.setWidth("100%"); cardNuberField = new TextField(); cardNuberField.setWidth("100%"); cardNuberField.setInputPrompt("Ноомер социальной карты, либо e-mail"); layout.addComponent(cardNuberField); layout.setComponentAlignment(cardNuberField, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(cardNuberField, 1.0f); addComponent(layout); layout = new HorizontalLayout(); layout.setSpacing(true); layout.setWidth("100%"); checkwordField = new TextField(); checkwordField.setWidth("100%"); checkwordField.setInputPrompt("Проверочное слово"); layout.addComponent(checkwordField); layout.setComponentAlignment(checkwordField, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(checkwordField, 1.0f); addComponent(layout); Button btnSearch = new Button("Найти"); btnSearch.addClickListener(getSearchClickListener()); addComponent(btnSearch); }
private Button genBut(String name) { Button b = new Button(name); b.addStyleName("user-select"); b.setIcon(userIcon); b.addClickListener( e -> { if (loginBox.isVisible()) { hidePass(); return; } loginField.setValue(""); String t = e.getButton().getCaption(); if (Globals.control.hasPassword(t)) { selected = Globals.control.getUser(t); showPassField(); } else { User s = Globals.control.getUser(t); if (s == null) { return; } Globals.user = s; Globals.root.changeScreen(Globals.user); } }); return b; }
private Component buildFooter() { HorizontalLayout footer = new HorizontalLayout(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Unit.PERCENTAGE); Button ok = new Button("OK"); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.addClickListener( event -> { try { fieldGroup.commit(); // Updated user should also be persisted to database. But // not in this demo. Notification success = new Notification("Profile updated successfully"); success.setDelayMsec(2000); success.setStyleName("bar success small"); success.setPosition(Position.BOTTOM_CENTER); success.show(Page.getCurrent()); // DashboardEventBus.post(new ProfileUpdatedEvent()); close(); } catch (CommitException e) { Notification.show("Error while updating profile", Type.ERROR_MESSAGE); } }); ok.focus(); footer.addComponent(ok); footer.setComponentAlignment(ok, Alignment.TOP_RIGHT); return footer; }
@Test public void click_ClickkListener_NestedWidget() { // Given clicked = false; FlexTable t = new FlexTable(); Button b = new Button("Wide Button"); b.addClickListener( new ClickListener() { public void onClick(Widget sender) { clicked = !clicked; } }); // add the button t.setWidget(0, 0, b); // Preconditions assertThat(clicked).isEqualTo(false); // When Browser.click(t.getWidget(0, 0)); // Then assertThat(clicked).isEqualTo(true); }
private void initLayout() { FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined(); loginForm.addComponent(userName = new TextField("Username")); loginForm.addComponent(passwordField = new PasswordField("Password")); loginForm.addComponent(login = new Button("Login")); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { login(); } }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSizeUndefined(); loginLayout.addComponent(loginFailedLabel = new Label()); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(rootLayout); setSizeFull(); }
protected void addSubmitButton() { Button button = UIUtil.addButton(this, "Submit", "left: 420px; top: 80px;", "100px"); button.addClickListener( new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { loadChart(); } }); }
public UserSelect() { loginInfo = new Label(""); loginInfo.addStyleName("error-font"); loginInfo.addStyleName("margin15"); loginInfo.addStyleName("margin-top40"); loginInfo.setVisible(false); selected = null; loginField = new PasswordField(""); loginField.setWidth("200px"); loginField.addStyleName("margin15"); loginField.addStyleName("margin-bot40"); loginBut = new Button("login"); loginBut.addStyleName("margin15"); loginBut.addClickListener( e -> { if (loginField.getValue().equals(selected.getPassword())) { hidePass(); Globals.user = selected; Globals.root.changeScreen(Globals.user); } else { loginInfo.setVisible(true); loginInfo.setValue("Wrong password"); loginField.setValue(""); } }); loginBox = new HorizontalLayout(); loginBox.addStyleName("popup-box"); loginBox.addComponents(loginField, loginBut, loginInfo); loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_LEFT); loginBox.setComponentAlignment(loginBut, Alignment.MIDDLE_CENTER); loginBox.setComponentAlignment(loginField, Alignment.MIDDLE_RIGHT); loginBox.setVisible(false); userIcon = new ThemeResource("icons/user.png"); users = Globals.control.usersData(); vbox = new VerticalLayout(); // vbox.setSizeUndefined(); vbox.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); Panel p = new Panel(); p.setSizeFull(); p.setContent(vbox); // vbox.addStyleName("border-l-r"); this.addComponent(p, "left: 25%; right: 25%; top: 15px"); this.addComponent(loginBox, "left: 25%; right: 25%; top: 40%"); this.addLayoutClickListener( e -> { if (!loginBox.isVisible()) return; System.out.println(e.getClickedComponent()); if (e.getClickedComponent() == null || e.getClickedComponent().equals(vbox)) hidePass(); }); }
protected void addNextChartButton() { nextChartButton = UIUtil.addButton(this, "", "left: 750px; top: 120px;", "250px"); nextChartButton.setStyleName(Reindeer.BUTTON_LINK); nextChartButton.addClickListener( new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { config.getLayoutContext().show(config.getNextLayout(), getParams()); } }); }
private HorizontalLayout createButtonBar() { final HorizontalLayout buttonBar = new HorizontalLayout(); Button drawBadge = new Button( "Draw badge", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { extension.addBadge(); } }); final Button enableZoomTracking = new Button("Enable zoom tracking"); enableZoomTracking.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { extension.enableZoomTracking(); buttonBar.replaceComponent(enableZoomTracking, goBackInZooming); } }); goBackInZooming = new Button( "Go back in zoom state", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (list.size() > 1) { ZoomCoordinates zoom = list.get(list.size() - 2); zoomTo(zoom); list.remove(list.size() - 1); } else { list.clear(); XAxis xAxis = chart.getConfiguration().getxAxis(); YAxis yAxis = chart.getConfiguration().getyAxis(); xAxis.setExtremes(148, 182); yAxis.setExtremes(0, 125); goBackInZooming.setEnabled(false); } writeOutZoomInfo(); } }); goBackInZooming.setEnabled(false); buttonBar.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); buttonBar.addComponents(drawBadge, enableZoomTracking, zoominfo); buttonBar.setSpacing(true); return buttonBar; }
private void addKeyRemoveButton(final String keyName, int top) { String position = String.format("left: 0px; top: %spx;", top); Button button = UIUtil.addButton(this, "[X]", position, "25px"); button.setStyleName(Reindeer.BUTTON_LINK); button.addClickListener( new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { removeKey(keyName); } }); keyRemoveButtons.add(button); }
@Override protected void init(VaadinRequest vaadinRequest) { // DI.addNewClassLoaderAndMerge(Service.class.getClassLoader()); // inject DI.getInstance().activateDI(this); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); Button button = new Button("Click Me"); button.addClickListener( event -> layout.addComponent(new Label("Thank you for clicking " + service.doWork()))); layout.addComponent(button); }
@Override protected void init(VaadinRequest request) { System.out.println("request = " + request); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); layout.addComponent(chart); try { empf = new MqttClient("tcp://192.168.0.106:1883", "MyfirstMQTTEmpf", new MemoryPersistence()); empf.setCallback( new MqttCallback() { @Override public void connectionLost(Throwable throwable) {} @Override public void messageArrived(String str, MqttMessage mqttMessage) throws Exception { byte[] payload = mqttMessage.getPayload(); lastMessage = new String(payload); System.out.println("s = " + str + " msg " + lastMessage); } @Override public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {} }); Button button = new Button("refresh"); button.addClickListener( event -> access( () -> chart .getConfiguration() .getSeries() .forEach( s -> ((ListSeries) s) .updatePoint(0, Double.valueOf(lastMessage.split(":")[3]))))); layout.addComponent(button); empf.connect(); empf.subscribe(TOPIC, 1); mqqtThread.start(); } catch (MqttException e) { e.printStackTrace(); } }
public TableEditorWindow(final Table table, final Object value, Object... dates) { for (Object o : dates) dates2.add(o); VerticalLayout content = new VerticalLayout(); Object[] columns = table.getVisibleColumns(); String[] headers = table.getColumnHeaders(); int n = columns.length; for (int i = 0; i < n; ++i) { HorizontalLayout lay = new HorizontalLayout(); Label l = new Label(headers[i]); lay.addComponent(l); Component field = dates2.contains(columns[i]) ? new DateField() : new TextField(); lay.addComponent(field); map.put(columns[i], field); content.addComponent(lay); lay.setComponentAlignment(l, Alignment.MIDDLE_LEFT); lay.setComponentAlignment(field, Alignment.MIDDLE_RIGHT); } if (value != null) { Item item = table.getItem(value); for (Object o : columns) { Object val = item.getItemProperty(o).getValue(); if (dates2.contains(o)) { ((DateField) map.get(o)).setValue((Date) val); } else { ((TextField) map.get(o)).setValue(val.toString()); } } } save = new Button("Записать"); content.addComponent(save); save.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (actionPerformed()) close(); } }); setContent(content); }
public MainScreen() { Label loginLabel = new Label("Welcome " + VaadinSession.getCurrent().getAttribute(String.class)); HorizontalLayout menuBar = new HorizontalLayout(loginLabel); MessageTable table = new MessageTable(); TextArea messageArea = new TextArea(); messageArea.setWidth(100, PERCENTAGE); Button sendButton = new Button("Send"); sendButton.addClickListener(new SendMessageClickListener(table, messageArea)); HorizontalLayout lowerBar = new HorizontalLayout(messageArea, sendButton); lowerBar.setWidth(100, PERCENTAGE); lowerBar.setSpacing(true); VerticalLayout mainLayout = new VerticalLayout(menuBar, table, lowerBar); mainLayout.setSpacing(true); mainLayout.setMargin(true); mainLayout.setSizeFull(); setCompositionRoot(mainLayout); }
private void initLayout() { layout.setMargin(true); setContent(layout); form.setCaption("Employee Details "); PropertysetItem item = new PropertysetItem(); item.addItemProperty("Name", new ObjectProperty<String>("")); item.addItemProperty("Address", new ObjectProperty<String>("")); ComboBox combobox = new ComboBox("Sex"); combobox.setInvalidAllowed(true); combobox.setNullSelectionAllowed(false); combobox.addItem("Male"); combobox.addItem("Female"); item.addItemProperty("Age", new ObjectProperty<String>("")); item.addItemProperty("Email", new ObjectProperty<String>("")); item.addItemProperty("Mobile No", new ObjectProperty<String>("")); Form form = new Form(); final Form reader = new Form(); form.setCaption("Fill Your Details"); form.setItemDataSource(item); reader.setItemDataSource(item); reader.setCaption("Your registation details"); reader.setReadOnly(true); button.addClickListener( new Button.ClickListener() { public void buttonClick(ClickEvent event) { Label message = new Label("You are Registered"); layout.addComponent(message); layout.addComponent(reader); } }); layout.addComponent(form); final RichTextArea area = new RichTextArea(); area.setValue("Add more details here"); layout.addComponent(area); layout.addComponent(button); }
@SuppressWarnings("serial") public NotAllowedPopover() { setWidth("75%"); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); setHeight("150px"); Label lbl; layout.addComponent( lbl = new Label( "This mmowgli game does not allow guest access. Thank you for your interest.")); layout.setExpandRatio(lbl, 1.0f); Button closeButt; layout.addComponent(closeButt = new Button("Close")); NavigationView nv = new NavigationView(layout); nv.setCaption("Access Not Allowed"); setContent(nv); this.center(); closeButt.addClickListener( new ClickListener() { @Override public void buttonClick(ClickEvent event) { HSess.init(); GameLinks links = GameLinks.getTL(); HSess.close(); UI.getCurrent().getPage().setLocation(links.getThanksForInterestLink()); getSession().close(); } }); }
@Override public Component generateRow(final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, true, false)) .withWidth("100%") .withStyleName("message"); UserBlock memberBlock = new UserBlock( comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock); CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, false, true)) .withWidth("100%") .withStyleName("message-header"); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel timePostLbl = new ELabel( AppContext.getMessage( GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())), ContentMode.HTML) .withDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); messageHeader.with(timePostLbl).expand(timePostLbl); // Message delete button Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); if (hasDeletePermission(comment)) { msgDeleteBtn.setVisible(true); msgDeleteBtn.addClickListener( new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { ConfirmDialogExt.show( UI.getCurrent(), AppContext.getMessage( GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { CommentService commentService = ApplicationContextUtil.getSpringBean(CommentService.class); commentService.removeWithSession( comment, AppContext.getUsername(), AppContext.getAccountId()); owner.removeRow(layout); } } }); } }); } else { msgDeleteBtn.setVisible(false); } rowLayout.addComponent(messageHeader); Label messageContent = new SafeHtmlLabel(comment.getComment()); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout() .withSpacing(false) .withWidth("100%") .withStyleName("message-footer"); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.with(rowLayout).expand(rowLayout); return layout; }
public EditVehicleWindow(final VehicleView parent, final long vehID) { super("Edycja pojazdu"); FormLayout newVehicleLayout = new FormLayout(); final FieldGroup fields = new FieldGroup(); Table vehiclesList = parent.getVehiclesList(); fields.setBuffered(true); String fieldName = ""; fieldName = VehicleView.BRAND; TextField fieldBRAND = new TextField(fieldName); fieldBRAND.setValue( (String) vehiclesList .getContainerProperty(vehiclesList.getValue(), VehicleView.BRAND) .getValue()); fieldBRAND.addValidator( new StringLengthValidator("Niepoprawna długość pola marka", 3, 64, false)); fieldBRAND.addValidator( new RegexpValidator("^[\\p{L}0-9- ]*$", "Model zawiera nie właściwe znaki")); fieldBRAND.setWidth("20em"); fieldBRAND.setRequired(true); fieldBRAND.setRequiredError("Pole Model jest wymagane"); fieldBRAND.setImmediate(true); newVehicleLayout.addComponent(fieldBRAND); fields.bind(fieldBRAND, fieldName); fieldName = VehicleView.COLOUR; TextField fieldCOLOUR = new TextField(fieldName); fieldCOLOUR.setValue( (String) vehiclesList .getContainerProperty(vehiclesList.getValue(), VehicleView.COLOUR) .getValue()); fieldCOLOUR.addValidator( new StringLengthValidator("Niepoprawna długość pola Kolor nadwozia", 3, 64, false)); fieldCOLOUR.addValidator( new RegexpValidator("^[\\p{L}]*$", "pole Kolor nadwozia zawiera niewłaściwe znaki")); fieldCOLOUR.setWidth("20em"); fieldCOLOUR.setRequired(true); fieldCOLOUR.setRequiredError("Pole Kolor nadwozia jest wymagane"); fieldCOLOUR.setImmediate(true); newVehicleLayout.addComponent(fieldCOLOUR); fields.bind(fieldCOLOUR, fieldName); fieldName = VehicleView.MAX_LOAD; TextField fieldMAX_LOAD = new TextField(fieldName); fieldMAX_LOAD.setValue( vehiclesList .getContainerProperty(vehiclesList.getValue(), VehicleView.MAX_LOAD) .getValue() .toString()); fieldMAX_LOAD.setConverter(Integer.class); fieldMAX_LOAD.setConversionError("Wprowadzona wartość nie jest liczbą"); fieldMAX_LOAD.addValidator( new IntegerRangeValidator("Niewłaściwa wartość ładowności", 0, Integer.MAX_VALUE)); fieldMAX_LOAD.setWidth("20em"); fieldMAX_LOAD.setRequired(true); fieldMAX_LOAD.setRequiredError("Pole Ładowność jest wymagane"); fieldMAX_LOAD.setImmediate(true); newVehicleLayout.addComponent(fieldMAX_LOAD); fields.bind(fieldMAX_LOAD, fieldName); fieldName = VehicleView.REGISTRATION_NR; TextField fieldREGISTRATION_NR = new TextField(fieldName); fieldREGISTRATION_NR.setValue( (String) vehiclesList .getContainerProperty(vehiclesList.getValue(), VehicleView.REGISTRATION_NR) .getValue()); fieldREGISTRATION_NR.addValidator( new StringLengthValidator("Niepoprawna długość pola Nr rejestracyjny", 4, 12, false)); fieldREGISTRATION_NR.addValidator( new RegexpValidator("^[A-Z0-9-]+$", "pole Kolor zawiera nie właściwe znaki")); fieldREGISTRATION_NR.setWidth("20em"); fieldREGISTRATION_NR.setRequired(true); fieldREGISTRATION_NR.setRequiredError("Pole Nr rejestracyjny jest wymagane"); fieldREGISTRATION_NR.setImmediate(true); newVehicleLayout.addComponent(fieldREGISTRATION_NR); fields.bind(fieldREGISTRATION_NR, fieldName); Button changeDriver = new Button("Zatwierdź"); Button cancel = new Button("Anuluj"); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(changeDriver); hl.addComponent(cancel); newVehicleLayout.addComponent(hl); cancel.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); changeDriver.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Vehicle veh = new Vehicle(); veh.setId(vehID); veh.setBrand((String) fields.getField(VehicleView.BRAND).getValue()); veh.setColour((String) fields.getField(VehicleView.COLOUR).getValue()); Integer truckLoad = null; try { truckLoad = Integer.parseInt(fields.getField(VehicleView.MAX_LOAD).getValue().toString()); } catch (NumberFormatException e) { Notification delayNot = new Notification("Proszę wypełnić pola poprawnie"); delayNot.setDelayMsec(1000); delayNot.show(Page.getCurrent()); return; } veh.setTruckload(truckLoad); veh.setRegistrationNumber( (String) fields.getField(VehicleView.REGISTRATION_NR).getValue()); Boolean valOk = true; Collection colFields = fields.getFields(); for (Object o : colFields) { Field fi = (Field) o; try { fi.validate(); } catch (Validator.InvalidValueException e) { Notification delayNot = new Notification("Proszę wypełnić pola poprawnie"); delayNot.setDelayMsec(1000); delayNot.show(Page.getCurrent()); valOk = false; break; } } if (valOk) { veh = ReceiveVehicle.changeVehicle(veh); if (veh == null) { Notification.show("Nie wprowadzono zmian"); close(); return; } Notification.show("Wprowadzono zmiany"); parent.refreshDataSource(); close(); } } }); addCloseListener( new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { parent.setEnabled(true); } }); parent.setEnabled(false); setContent(newVehicleLayout); setResizable(false); setDraggable(false); center(); }
@Override protected void init(VaadinRequest request) { setSizeFull(); VerticalLayout layout = new VerticalLayout(); List<Aircraft> message = aircraftService.list(); Label label = new Label(message.toString()); final TextField field = new TextField(); Button button = new Button(); button.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { aircraftService.create(field.getValue()); } }); HorizontalLayout fieldPanel = new HorizontalLayout(); fieldPanel.addComponent(field); fieldPanel.addComponent(button); fieldPanel.addComponent(label); Table table = new Table(); table.setRowHeaderMode(Table.RowHeaderMode.ID); table.setSizeFull(); final BeanItemContainer<Booking> container = new BeanItemContainer<Booking>(Booking.class); container.addAll(bookingService.list()); container.addNestedContainerProperty("flight.flightNumber"); container.removeContainerProperty("flight"); table.setContainerDataSource(container); HorizontalLayout toolbar = new HorizontalLayout(); Button addButton = new Button("Add"); addButton.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { FormLayout formLayout = new FormLayout(); // Form for editing the bean final BeanFieldGroup<Booking> binder = new BeanFieldGroup<Booking>(Booking.class); binder.setBuffered(true); final Booking bean = new Booking(); bean.setFlight(new Flight()); binder.setItemDataSource(bean); formLayout.addComponent(binder.buildAndBind("Ticket", "ticket")); formLayout.addComponent(binder.buildAndBind("Flight Nr.", "flight.flightNumber")); Button save = new Button("Save"); save.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { binder.commit(); container.addBean(bean); } catch (FieldGroup.CommitException e) { throw new RuntimeException(e.getMessage()); } } }); formLayout.addComponent(save); UI.getCurrent().addWindow(new Window("Edit Booking", formLayout)); } }); toolbar.addComponent(addButton); layout.addComponent(fieldPanel); layout.addComponent(toolbar); layout.addComponent(table); UI.getCurrent() .setErrorHandler( new ErrorHandler() { @Override public void error(com.vaadin.server.ErrorEvent event) { Notification.show( event.getThrowable().getLocalizedMessage(), Notification.Type.ERROR_MESSAGE); } }); setContent(layout); }
public TaskDashboardViewImpl() { this.withMargin(new MarginInfo(false, true, true, true)); taskSearchPanel = new TaskSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); groupWrapLayout.addComponent(new Label("Filter:")); final TaskSavedFilterComboBox savedFilterComboBox = new TaskSavedFilterComboBox(); savedFilterComboBox.addQuerySelectListener( new SavedFilterComboBox.QuerySelectListener() { @Override public void querySelect(SavedFilterComboBox.QuerySelectEvent querySelectEvent) { List<SearchFieldInfo> fieldInfos = querySelectEvent.getSearchFieldInfos(); TaskSearchCriteria criteria = SearchFieldInfo.buildSearchCriteria(TaskSearchCriteria.class, fieldInfos); criteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance() .post(new TaskEvent.SearchRequest(TaskDashboardViewImpl.this, criteria)); } }); groupWrapLayout.addComponent(savedFilterComboBox); groupWrapLayout.addComponent(new Label("Sort:")); final ComboBox sortCombo = new ValueComboBox(false, DESCENDING, ASCENDING); sortCombo.setWidth("100px"); sortCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String sortValue = (String) sortCombo.getValue(); if (ASCENDING.equals(sortValue)) { sortDirection = SearchCriteria.ASC; } else { sortDirection = SearchCriteria.DESC; } queryAndDisplayTasks(); } }); sortDirection = SearchCriteria.DESC; groupWrapLayout.addComponent(sortCombo); groupWrapLayout.addComponent(new Label("Group by:")); final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, PLAIN_LIST); groupCombo.setWidth("100px"); groupCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { groupByState = (String) groupCombo.getValue(); queryAndDisplayTasks(); } }); groupByState = GROUP_DUE_DATE; groupWrapLayout.addComponent(groupCombo); taskSearchPanel.addHeaderRight(groupWrapLayout); Button exportBtn = new Button("Export"); final SplitButton exportSplitBtn = new SplitButton(exportBtn); exportBtn.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { exportSplitBtn.setPopupVisible(true); } }); exportSplitBtn.addStyleName(UIConstants.THEME_GREEN_LINK); OptionPopupContent popupButtonsControl = new OptionPopupContent(); Button exportPdfBtn = new Button("PDF"); exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O); FileDownloader pdfFileDownloder = new FileDownloader(buildStreamSource(ReportExportType.PDF)); pdfFileDownloder.extend(exportPdfBtn); popupButtonsControl.addOption(exportPdfBtn); Button exportExcelBtn = new Button("Excel"); exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O); FileDownloader excelFileDownloader = new FileDownloader(buildStreamSource(ReportExportType.EXCEL)); excelFileDownloader.extend(exportExcelBtn); popupButtonsControl.addOption(exportExcelBtn); exportSplitBtn.setContent(popupButtonsControl); groupWrapLayout.with(exportSplitBtn); Button newTaskBtn = new Button( AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { SimpleTask newTask = new SimpleTask(); newTask.setProjectid(CurrentProjectVariables.getProjectId()); UI.getCurrent().addWindow(new TaskAddWindow(newTask)); } }); newTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); newTaskBtn.setIcon(FontAwesome.PLUS); newTaskBtn.setDescription(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASKGROUP)); newTaskBtn.setStyleName(UIConstants.THEME_GREEN_LINK); groupWrapLayout.addComponent(newTaskBtn); Button advanceDisplayBtn = new Button(); advanceDisplayBtn.setWidth("50px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription( AppContext.getMessage(TaskGroupI18nEnum.ADVANCED_VIEW_TOOLTIP)); Button calendarBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new TaskEvent.GotoCalendarView(TaskDashboardViewImpl.this)); } }); calendarBtn.setWidth("50px"); calendarBtn.setDescription("Calendar View"); calendarBtn.setIcon(FontAwesome.CALENDAR); Button chartDisplayBtn = new Button( null, new Button.ClickListener() { private static final long serialVersionUID = -5707546605789537298L; @Override public void buttonClick(ClickEvent event) { displayGanttChartView(); } }); chartDisplayBtn.setWidth("50px"); chartDisplayBtn.setDescription("Display Gantt chart"); chartDisplayBtn.setIcon(FontAwesome.BAR_CHART_O); Button kanbanBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { displayKanbanView(); } }); kanbanBtn.setWidth("50px"); kanbanBtn.setDescription("Kanban View"); kanbanBtn.setIcon(FontAwesome.TH); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(calendarBtn); viewButtons.addButton(kanbanBtn); viewButtons.addButton(chartDisplayBtn); viewButtons.setDefaultButton(advanceDisplayBtn); groupWrapLayout.addComponent(viewButtons); mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth(); wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false)); rightColumn = new MVerticalLayout() .withWidth("350px") .withMargin(new MarginInfo(true, false, false, false)); mainLayout.with(wrapBody, rightColumn).expand(wrapBody); }
@SuppressWarnings("serial") @HibernateRead private void adminSwitchAuthorsTL(Button butt, final CardPlayHandler coroutine) { ArrayList<User> meLis = new ArrayList<User>(1); meLis.add(coroutine.author); User me = User.getTL(Mmowgli2UI.getGlobals().getUserID()); final AddAuthorDialog dial = new AddAuthorDialog(meLis, true); StringBuilder sb = new StringBuilder("As adminstrator, <b>"); sb.append(me.getUserName()); sb.append("</b>, you may choose another player to be card author."); dial.infoLabel.setValue(sb.toString()); dial.setCaption("Select Proxy Author"); dial.setMultiSelect(false); dial.cancelButt.setCaption("Use myself"); dial.addButt.setCaption("Use selected"); // Rearrange buttons, add real cancel butt. // ------------------- HorizontalLayout buttonHL = dial.getButtonHorizontalLayout(); Iterator<Component> itr = buttonHL.iterator(); Vector<Component> v = new Vector<Component>(); while (itr.hasNext()) { Component component = itr.next(); if (component instanceof Button) v.add(component); } buttonHL.removeAllComponents(); itr = v.iterator(); while (itr.hasNext()) { buttonHL.addComponent(itr.next()); } Label sp = null; buttonHL.addComponent(sp = new Label()); sp.setWidth("1px"); buttonHL.setExpandRatio(sp, 1.0f); Button cancelButt = null; buttonHL.addComponent(cancelButt = new Button("Cancel")); cancelButt.addClickListener( new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(dial); // dial.getParent().removeWindow(dial); coroutine.resetCoroutine(); } }); // ------------------- dial.selectItemAt(0); dial.addListener( new CloseListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed @HibernateUserRead public void windowClose(CloseEvent e) { HSess.init(); if (dial.addClicked) { Object o = dial.getSelected(); if (o instanceof User) { coroutine.author = (User) o; } else if (o instanceof QuickUser) { QuickUser qu = (QuickUser) o; coroutine.author = User.getTL(qu.id); } } coroutine.run(); // finish up HSess.close(); } }); UI.getCurrent().addWindow(dial); dial.center(); }