List of usage examples for com.vaadin.ui TextField TextField
public TextField(ValueChangeListener<String> valueChangeListener)
From source file:ch.bfh.ti.soed.hs16.srs.green.view.MyUI.java
License:Open Source License
/** * Method which actually creates the whole UI. *//*from ww w.ja v a2 s.c o m*/ @Override protected void init(VaadinRequest vaadinRequest) { VerticalLayout layout = new VerticalLayout(); Panel panel = new Panel("Login"); panel.setSizeUndefined(); FormLayout content = new FormLayout(); userName = new TextField("Username"); content.addComponent(userName); PasswordField password = new PasswordField("Password"); content.addComponent(password); Button login = new Button("Login"); register = new Button("Register"); CheckBox askBox = new CheckBox("Are you a Roommanager?"); login.setStyleName(Reindeer.BUTTON_SMALL); login.setWidth("86px"); register.setStyleName(Reindeer.BUTTON_SMALL); register.setWidth("86px"); askBox.setStyleName(Reindeer.BUTTON_SMALL); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(login); hl.addComponent(register); hl.addComponent(askBox); content.addComponent(hl); content.setSizeUndefined(); content.setMargin(true); panel.setContent(content); login.addClickListener(e -> { System.out.println(userName.getValue()); System.out.println(password.getValue()); try { if (controller.login(userName.getValue(), password.getValue()) || userName.equals(userName.getValue()) && password.equals(password.getValue())) { setContent(new ReservationUI()); } } catch (Throwable e1) { e1.printStackTrace(); } }); register.addClickListener(e -> { try { Role x = askBox.getValue() ? Role.ROOMMANAGER : Role.CUSTOMER; controller.register(userName.getValue(), password.getValue(), x); } catch (Throwable e1) { e1.printStackTrace(); } }); layout.setMargin(true); layout.setSpacing(true); layout.addComponent(panel); setContent(layout); }
From source file:ch.bfh.ti.soed.hs16.srs.purple.view.ReservationView.java
License:Open Source License
/** * Shows the popup window where a reservation can be modified, deleted or inserted * @param res The Reservation Object (for a new reservation, fill the startDate with the current Timestamp!) *//* ww w. j a v a2s . c o m*/ @SuppressWarnings("serial") private void showPopup(Reservation res) { this.res = res; //Update the member boolean newRes = res.getReservationID() > 0 ? false : true; boolean isHost = isHost(actualUser, res.getHostList()); boolean isParticipant = isHost(actualUser, res.getParticipantList()); final GridLayout gridLayout = new GridLayout(3, 5); ValueChangeListener vcl = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { List<Room> roomList = resCont.getAllFreeRooms(new Timestamp(startDate.getValue().getTime()), new Timestamp(endDate.getValue().getTime())); if (ReservationView.this.res.getReservationID() > 0) { System.out.println("Aktuellen Raum"); rooms.addItem(ReservationView.this.res.getRoom().getRoomID()); rooms.setItemCaption(ReservationView.this.res.getRoom().getRoomID(), ReservationView.this.res.getRoom().getName() + " (" + ReservationView.this.res.getRoom().getNumberOfSeats() + " Pltze)"); rooms.select(ReservationView.this.res.getRoom().getRoomID()); } for (int i = 0; i < roomList.size(); i++) { rooms.addItem(roomList.get(i).getRoomID()); String caption = roomList.get(i).getName() + " (" + roomList.get(i).getNumberOfSeats() + " Pltze)"; rooms.setItemCaption(roomList.get(i).getRoomID(), caption); } if (ReservationView.this.res.getReservationID() <= 0 && actualRoom != null) rooms.select(actualRoom.getRoomID()); } }; popUpWindow = new Window(); popUpWindow.center(); popUpWindow.setModal(true); startDate = new DateField("Startzeit"); startDate.setLocale(VaadinSession.getCurrent().getLocale()); startDate.setValue(res.getStart()); startDate.addValueChangeListener(vcl); startDate.setDateFormat("dd.MM.yyyy HH:mm"); startDate.setResolution(Resolution.HOUR); endDate = new DateField("Endzeit"); endDate.setValue(res.getEnd()); endDate.addValueChangeListener(vcl); endDate.setDateFormat("dd.MM.yyyy HH:mm"); endDate.setLocale(VaadinSession.getCurrent().getLocale()); endDate.setResolution(Resolution.HOUR); title = new TextField("Titel"); title.setValue(res.getTitle()); title.setWidth(100, Unit.PERCENTAGE); description = new TextArea("Beschreibung"); description.setValue(res.getDescription()); description.setRows(3); description.setWidth(100, Unit.PERCENTAGE); hosts = new ListSelect("Reservierender"); hosts.setMultiSelect(true); hosts.clear(); for (int i = 0; i < hostList.size(); i++) { hosts.addItem(hostList.get(i).getUserID()); hosts.setItemCaption(hostList.get(i).getUserID(), hostList.get(i).getUsername()); } //select the hosts in list if (!newRes) { List<User> resHosts = res.getHostList(); for (int i = 0; i < resHosts.size(); i++) for (int y = 0; y < hostList.size(); y++) if (hostList.get(y).getUserID() == resHosts.get(i).getUserID()) hosts.select(resHosts.get(i).getUserID()); } else hosts.select(actualUser.getUserID()); hosts.select(0); hosts.setRows(hostList.size() > 5 ? 5 : hostList.size()); participantList = new ListSelect("Teilnehmer"); participantList.setMultiSelect(true); participantList.clear(); for (int i = 0; i < participant.size(); i++) { participantList.addItem(participant.get(i).getUserID()); participantList.setItemCaption(participant.get(i).getUserID(), participant.get(i).getUsername()); } //select the participants in list if (!newRes) { List<User> resPart = res.getParticipantList(); for (int i = 0; i < resPart.size(); i++) for (int y = 0; y < participant.size(); y++) if (participant.get(y).getUserID() == resPart.get(i).getUserID()) participantList.select(resPart.get(i).getUserID()); } participantList.setRows(participant.size() > 5 ? 5 : participant.size()); rooms = new NativeSelect("Raum"); rooms.setNullSelectionAllowed(false); rooms.removeAllItems(); List<Room> roomList = resCont.getAllFreeRooms(new Timestamp(startDate.getValue().getTime()), new Timestamp(endDate.getValue().getTime())); if (!newRes) { rooms.addItem(res.getRoom().getRoomID()); rooms.setItemCaption(res.getRoom().getRoomID(), res.getRoom().getName() + " (" + res.getRoom().getNumberOfSeats() + " Pltze)"); rooms.select(res.getRoom().getRoomID()); } for (int i = 0; i < roomList.size(); i++) { rooms.addItem(roomList.get(i).getRoomID()); String caption = roomList.get(i).getName() + " (" + roomList.get(i).getNumberOfSeats() + " Pltze)"; rooms.setItemCaption(roomList.get(i).getRoomID(), caption); } if (newRes && actualRoom != null) rooms.select(actualRoom.getRoomID()); saveButton = new Button("Speichern"); saveButton.addClickListener(clButton); deleteButton = new Button("Lschen"); deleteButton.addClickListener(clButton); deleteButton.setVisible(res.getReservationID() > 0 ? true : false); if (!newRes) setEditable(false); gridLayout.addComponent(startDate, 0, 0); gridLayout.addComponent(endDate, 0, 1); gridLayout.addComponent(hosts, 1, 0, 1, 1); gridLayout.addComponent(participantList, 2, 0, 2, 1); gridLayout.addComponent(title, 0, 2); gridLayout.addComponent(rooms, 1, 2, 2, 2); gridLayout.addComponent(description, 0, 3, 1, 3); if (roomList.size() == 0) saveButton.setEnabled(false); if (isHost || newRes) //show buttons for edit and delete only if the user is host or its a new reservation { gridLayout.addComponent(saveButton, 0, 4); gridLayout.addComponent(deleteButton, 1, 4); } if (isParticipant) //show buttons for accept oder decline a reservation { acceptButton = new Button("Zusagen"); rejectButton = new Button("Absagen"); acceptButton.addClickListener(clButton); rejectButton.addClickListener(clButton); if (isHost(actualUser, res.getAcceptedParticipantsList())) { acceptButton.setEnabled(false); rejectButton.setEnabled(true); } else { rejectButton.setEnabled(false); acceptButton.setEnabled(true); } gridLayout.addComponent(acceptButton, 0, 4); gridLayout.addComponent(rejectButton, 1, 4); } gridLayout.setSpacing(true); gridLayout.setMargin(new MarginInfo(false, false, false, true)); gridLayout.setWidth(100, Unit.PERCENTAGE); popUpWindow.setContent(gridLayout); popUpWindow.setWidth("600px"); popUpWindow.setHeight("450px"); popUpWindow.setCaption(res.getReservationID() > 0 ? "Reservierungsdetails" : "Neue Reservierung"); UI.getCurrent().addWindow(popUpWindow); }
From source file:ch.bfh.ti.soed.hs16.srs.red.ui.views.LoginView.java
License:Open Source License
public LoginView(Navigator nav) { try {/*from ww w . j av a 2 s . c o m*/ // @TODO remove before release DevDemo devdemo = new DevDemo(); } catch (Exception ex) { Notification.show("Demo Entries failed to initialize.", ex.getMessage(), Notification.Type.ERROR_MESSAGE); } /*--------------------------------- initialize Objects ---------------------------------*/ this.nav = nav; this.vertical = new VerticalLayout(); this.loginName = new TextField("username"); this.passwordField = new PasswordField("password"); this.loginButton = new Button("Login", this); /*------------------------------- add to css -------------------------------*/ vertical.setPrimaryStyleName("rootLogin"); loginButton.setStyleName("buttonLogin"); /*------------------------------- add Components to Layout --------------------------------*/ vertical.addComponents(loginName, passwordField, loginButton); setCompositionRoot(vertical); }
From source file:ch.bfh.ti.soed.hs16.srs.view.views.LoginView.java
License:Open Source License
public LoginView(Navigator nav) { /* init objects */ this.layout = new VerticalLayout(); this.btn = new Button("Login"); this.loginFld = new TextField("username"); this.pwFld = new PasswordField("password"); this.header = new Header(); this.footer = new Footer("BFH", "Biel-Bienne", "Schweiz"); /* add to css */ this.layout.setPrimaryStyleName("rootLogin"); this.btn.setStyleName("buttonLogin"); /* add components to layout */ this.layout.addComponent(this.header.getHeaderLayout()); this.layout.addComponents(this.loginFld, this.pwFld, this.btn); this.layout.addComponent(this.footer.getFooterLayout()); setCompositionRoot(layout);/* w w w. j a va2 s. co m*/ /* event handling */ this.btn.addClickListener((Button.ClickListener) clickEvent -> { // handle userlogin nav.navigateTo("RoomView"); }); }
From source file:ch.bfh.ti.soed.hs16.srs.white.view.RegistrationView.java
License:Open Source License
public RegistrationView(AbstractView lastView) { super(lastView); fieldFirstName = new TextField("First Name"); fieldLastName = new TextField("Last Name"); fieldEmail = new TextField("E-Mail Address"); fieldConfirmEmail = new TextField("Repeat E-Mail Address"); fieldPassword = new PasswordField("Password"); fieldConfirmPassword = new PasswordField("Repeat Password"); btnSubmit = new Button("Submit"); btnCancel = new Button("Cancel"); labelMessage = new Label(); loadController();//from w w w . j a v a2s .c o m }
From source file:cirad.cgh.vcf2fasta.view.Vcf2fastaForm.java
License:Open Source License
private TextField getTextField(String caption, String bindName, String defaultValue, int columns) { TextField textField = new TextField(caption); textField.setImmediate(true);//w ww . j av a 2 s .c o m fieldGroup.bind(textField, bindName); textField.setValidationVisible(false); textField.setNullRepresentation(""); textField.setNullSettingAllowed(true); textField.setColumns(columns); textField.setValue(defaultValue); return textField; }
From source file:com.abien.vaadin.helloapp.HelloApp.java
License:Apache License
@Override public void init() { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/* w w w . j a v a2 s . com*/ Label header = new Label("Vaadin on Java EE"); header.setStyleName("h1"); layout.addComponent(header); final TextField nameField = new TextField("Input something:"); final Label greetingLbl = new Label(); layout.addComponent(nameField); layout.addComponent( new Button("Say slow Hello, clicking this shouldn't stall other users", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { Thread.sleep(20 * 1000); } catch (InterruptedException ex) { Logger.getLogger(HelloApp.class.getName()).log(Level.SEVERE, null, ex); } getMainWindow().showNotification("Hello!"); } })); layout.addComponent(new Button("Say Hello", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { greetingLbl.setCaption(greetingService.sayHello(nameField.getValue().toString())); buttonEvents.fire(event); } })); layout.addComponent(greetingLbl); Window mainWindow = new Window("Vaadin 6.8 - Java EE Integration", layout); setMainWindow(mainWindow); }
From source file:com.ahmed.vaadinone.ui.PersonForm.java
public PersonForm() { addField("First Name", new TextField("First Name")); addField("Last Name", new TextField("Last Name")); HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true);/*from w w w . j a va 2s .c o m*/ footer.addComponent(save); footer.addComponent(cancel); setFooter(footer); }
From source file:com.arcusys.liferay.vaadinplugin.ui.AdditionalDependenciesWindow.java
License:Apache License
private TextField createFilterTextField() { TextField filterTextField = new TextField("Filter"); filterTextField.setImmediate(true);/*from w ww.j a v a 2 s . c o m*/ filterTextField.addTextChangeListener(new FieldEvents.TextChangeListener() { public void textChange(FieldEvents.TextChangeEvent event) { filterDependencies(event.getText()); } }); filterTextField.setWidth("100%"); filterTextField.focus(); return filterTextField; }
From source file:com.bellkenz.modules.PersonalInformation.java
private TextField createTextField(String caption) { TextField f = new TextField(caption); f.setWidth("170px"); f.setNullRepresentation(""); return f;/*from w w w . j a v a2 s .co m*/ }