List of usage examples for com.vaadin.ui Button Button
public Button(Resource icon)
From source file:ch.bfh.ti.soed.hs16.srs.black.view.reservationView.ReservationController.java
License:Open Source License
public void createList(String customer) throws Exception { reservationView.getReservationList().removeAllItems(); List<Reservation> reservationList = dataModel.getReservations(dataModel.getCustomer(customer)); for (Reservation reservation : reservationList) { Button button = new Button("X"); Object newItemId = reservationView.getReservationList().addItem(); button.addClickListener(new Button.ClickListener() { @Override/* ww w . j a v a2s. c o m*/ public void buttonClick(Button.ClickEvent clickEvent) { dataModel.cancelReservation(reservation); reservationView.getReservationList().removeItem(newItemId); } }); Item row1 = reservationView.getReservationList().getItem(newItemId); row1.getItemProperty("Room").setValue(reservation.getRoom().getRoomNr()); row1.getItemProperty("Start Time").setValue(reservation.getBegin()); row1.getItemProperty("End Time").setValue(reservation.getEnd()); row1.getItemProperty("Cancel").setValue(button); } }
From source file:ch.bfh.ti.soed.hs16.srs.black.view.signUpView.SignUpView.java
License:Open Source License
public SignUpView() { usernameField = new TextField("Username"); usernameField.setIcon(FontAwesome.USER); usernameField.setWidth(12, Unit.EM); passwordField = new PasswordField("Password"); passwordField.setIcon(FontAwesome.KEY); passwordField.setWidth(12, Unit.EM); passwordFieldRepeat = new PasswordField("Repeat Password"); passwordFieldRepeat.setIcon(FontAwesome.KEY); passwordFieldRepeat.setWidth(12, Unit.EM); addUserButton = new Button("Add New User"); addUserButton.setWidth(12, Unit.EM); goBackButton = new Button("Back"); VerticalLayout layout = new VerticalLayout(); Panel panel = new Panel("Sign Up - Smart ReservationEntity System"); panel.setSizeUndefined();/* w ww. ja v a 2s .c om*/ layout.addComponent(panel); FormLayout content = new FormLayout(); content.addComponents(usernameField, passwordField, passwordFieldRepeat, addUserButton); content.setSizeUndefined(); content.setMargin(true); VerticalLayout formAndBack = new VerticalLayout(content, goBackButton); formAndBack.setMargin(true); panel.setContent(formAndBack); setCompositionRoot(layout); layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); layout.setMargin(new MarginInfo(true, false, false, false)); }
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 w w w.j av a 2s . co 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.kandr3.view.MyUI.java
License:Open Source License
@Override protected void init(VaadinRequest vaadinRequest) { final VerticalLayout layout = new VerticalLayout(); final TextField name = new TextField(); name.setCaption("Type your name here:"); Button button = new Button("Click Me"); button.addClickListener(e -> {/*from w w w . j a v a 2s. c o m*/ layout.addComponent(new Label("Thanks " + name.getValue() + ", it works!")); }); layout.addComponents(name, button); layout.setMargin(true); layout.setSpacing(true); 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!) *///w ww . j a va2 s . c om @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.helper.Menu.java
License:Open Source License
public Menu(Navigator nav) { /*--------------------------------- initalize Objects//from w w w . ja v a 2 s . co m ---------------------------------*/ this.navigator = nav; this.menu = new HorizontalLayout(); this.myReservationButton = new Button("my reservation"); /*------------------------------- add to css -------------------------------*/ menu.setPrimaryStyleName(CLASSNAME); myReservationButton.setPrimaryStyleName(CLASSNAME + "-button"); /*------------------------------- add Buttons to Layout --------------------------------*/ menu.addComponent(myReservationButton); /*------------------------------ Event Handling Buttons ------------------------------*/ myReservationButton .addClickListener((Button.ClickListener) event -> navigator.navigateTo("my Reservation")); }
From source file:ch.bfh.ti.soed.hs16.srs.red.ui.helper.SubWindowReservation.java
License:Open Source License
public SubWindowReservation() { this.layout = new VerticalLayout(); this.id = new Label("id"); this.name = new Label("name"); this.roomTitle = new Label("select room"); this.startTime = new Label("start time"); this.endTime = new Label("end time"); this.textFieldId = new TextField(); this.textFieldName = new TextField(); this.rooms = new ComboBox(); this.dateFieldStart = new DateField(); this.dateFieldEnd = new DateField(); this.buttonSave = new Button("save"); this.buttonDelete = new Button("delete"); dateFieldStart.setResolution(Resolution.MINUTE); dateFieldEnd.setResolution(Resolution.MINUTE); /*--------------------------------- add objects to horizontal container/* w ww . j a v a 2s . c o m*/ ---------------------------------*/ HorizontalLayout idContainer = new HorizontalLayout(id, textFieldId); HorizontalLayout nameContainer = new HorizontalLayout(name, textFieldName); HorizontalLayout roomContainer = new HorizontalLayout(roomTitle, rooms); HorizontalLayout startContainer = new HorizontalLayout(startTime, dateFieldStart); HorizontalLayout endContainer = new HorizontalLayout(endTime, dateFieldEnd); HorizontalLayout buttons = new HorizontalLayout(buttonSave, buttonDelete); /*--------------------------------- add style names ---------------------------------*/ layout.setPrimaryStyleName(CSS_NAME); idContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); nameContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); roomContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); startContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); endContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); buttons.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); /*--------------------------------- add to root layout ---------------------------------*/ this.layout.addComponents(idContainer, nameContainer, roomContainer, startContainer, endContainer, buttons); }
From source file:ch.bfh.ti.soed.hs16.srs.view.views.helpers.Menu.java
License:Open Source License
public Menu(Navigator nav) { /* init objects */ this.navigator = nav; this.layout = new HorizontalLayout(); this.bookerBtn = new Button("booker"); this.roomBtn = new Button("room"); /* add to css */ this.layout.setPrimaryStyleName(CLASSNAME); this.bookerBtn.setPrimaryStyleName(CLASSNAME + "-button"); this.roomBtn.setPrimaryStyleName(CLASSNAME + "-button"); /* add components to layout */ this.layout.addComponent(roomBtn); this.layout.addComponent(bookerBtn); /* event handling */ this.bookerBtn.addClickListener((Button.ClickListener) e -> navigator.navigateTo("BookerView")); this.roomBtn.addClickListener((Button.ClickListener) e -> navigator.navigateTo("RoomView")); }
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 ww . j a v a 2s.com*/ /* 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();// ww w.j a va 2 s. c om }