List of usage examples for com.vaadin.ui Window center
public void center()
From source file:at.jku.ce.adaptivetesting.vaadin.ui.VaadinResultView.java
License:LGPL
public VaadinResultView(ResultFiredArgs args, String title) { setSpacing(true);//from www. j av a 2 s. c o m addComponent(new HtmlLabel(title)); //addComponent(HtmlLabel.getCenteredLabel("h2", "Test abgeschlossen")); addComponent(HtmlLabel.getCenteredLabel( "Der Test wurde beendet, da " + (args.outOfQuestions ? "keine weiteren Fragen verfgbar sind." : "dein Kompetenzniveau bestimmt wurde."))); addComponent(HtmlLabel.getCenteredLabel( "Im Folgenden siehst du die Fragen und die gegebenen Antworten in zeitlich absteigender Reihenfolge.")); addComponent(HtmlLabel.getCenteredLabel( "Die Zahl in der ersten Spalte bezieht sich auf die Schwierigkeit der jeweiligen Frage. Negative Zahlen stehen fr leichtere Fragen, positive Zahlen kennzeichnen schwierigere Fragen.")); // Create HTML table of the history Table table = new Table(); final String solution = "Korrekte Antwort", userAnswer = "Ihre Antwort"; table.addContainerProperty("Schwierigkeitsgrad", Float.class, null); table.addContainerProperty("Resultat", String.class, null); table.addContainerProperty(userAnswer, Button.class, null); table.addContainerProperty(solution, Button.class, null); //List<HistoryEntry> entries = Lists.reverse(args.history); List<HistoryEntry> entries = new ArrayList<HistoryEntry>(args.history); Collections.reverse(entries); for (HistoryEntry entry : entries) { Button qAnswer = null, qSolution = null; if (entry.question instanceof Component && entry.question != null) { try { Class<? extends AnswerStorage> dataStorageClass = entry.question.getSolution().getClass(); Constructor<? extends IQuestion> constructor = entry.question.getClass() .getConstructor(dataStorageClass, dataStorageClass, float.class, String.class); // The following casts can not fail, because the question is // a component as well Component iQuestionSolution = (Component) constructor.newInstance(entry.question.getSolution(), entry.question.getSolution(), entry.question.getDifficulty(), entry.question.getQuestionText()); Component iQuestionUser = (Component) constructor.newInstance(entry.question.getSolution(), entry.question.getUserAnswer(), entry.question.getDifficulty(), entry.question.getQuestionText()); // Create the 2 needed click listeners ClickListener clickListenerSol = event -> { Window window = new Window(solution); event.getButton().setEnabled(false); window.addCloseListener(e -> event.getButton().setEnabled(true)); window.setContent(iQuestionSolution); window.center(); window.setWidth("90%"); window.setHeight("50%"); if (iQuestionSolution instanceof Sizeable) { Sizeable sizeable = iQuestionSolution; sizeable.setSizeFull(); } getUI().addWindow(window); }; ClickListener clickListenerUA = event -> { Window window = new Window(userAnswer); event.getButton().setEnabled(false); window.addCloseListener(e -> event.getButton().setEnabled(true)); window.setContent(iQuestionUser); window.center(); window.setWidth("90%"); window.setHeight("50%"); if (iQuestionUser instanceof Sizeable) { Sizeable sizeable = iQuestionUser; sizeable.setSizeFull(); } getUI().addWindow(window); }; // Create the two buttons qAnswer = new Button(userAnswer, clickListenerUA); qSolution = new Button(solution, clickListenerSol); } catch (Exception e) { // Ignore this line in the table LogHelper.logInfo("1 entry's solution/ user answer are missing on the final screen." + entry.question.getClass().getName() + " does not implement the constructors required by" + IQuestion.class.getName()); } } table.addItem(new Object[] { entry.question.getDifficulty(), isCorrect(entry.points, entry.question.getMaxPoints()), qAnswer, qSolution }, null); } int size = table.size(); if (size > 10) { size = 10; } table.setPageLength(size); addComponent(table); setComponentAlignment(table, Alignment.MIDDLE_CENTER); addComponent(HtmlLabel.getCenteredLabel("h3", "Dein Kompetenzniveau ist: <b>" + args.skillLevel + "</b>")); addComponent(HtmlLabel.getCenteredLabel("Delta: " + args.delta)); storeResults(args); }
From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.topic.accounting.AccountingQuestionManager.java
License:LGPL
public AccountingQuestionManager(String quizName) { super(quizName); Button openKontenplan = new Button("Open Kontenplan"); openKontenplan.addClickListener(e -> { openKontenplan.setEnabled(false); // Create Window with layout Window window = new Window("Kontenplan"); GridLayout layout = new GridLayout(1, 1); layout.addComponent(AccountingDataProvider.getInstance().toHtmlTable()); layout.setSizeFull();// www . j ava 2 s . c o m window.setContent(layout); window.center(); window.setWidth("60%"); window.setHeight("80%"); window.setResizable(false); window.addCloseListener(e1 -> openKontenplan.setEnabled(true)); getUI().addWindow(window); }); addHelpButton(openKontenplan); }
From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.VaadinResultView.java
License:LGPL
public VaadinResultView(ResultFiredArgs args, String title) { setSpacing(true);/*from w w w . ja v a 2 s . c o m*/ addComponent(new HtmlLabel(title)); addComponent(HtmlLabel.getCenteredLabel("h2", "Finished test")); addComponent(HtmlLabel.getCenteredLabel("The test ended, because we " + (args.outOfQuestions ? "did not have any more questions" : "determined your skill level"))); addComponent(HtmlLabel.getCenteredLabel( "This are the difficulties and your answers. On top are your last answers. The first column indicates the difficulty.")); addComponent(HtmlLabel.getCenteredLabel( "Closer to -INF means easy question, to +INF dificult questions. This also applies to your skill level!")); // Create HTML table of the history Table table = new Table(); final String solution = "Solution", userAnswewr = "Yourt answer"; table.addContainerProperty("Question difficulty", Float.class, null); table.addContainerProperty("Result", String.class, null); table.addContainerProperty(userAnswewr, Button.class, null); table.addContainerProperty(solution, Button.class, null); List<HistoryEntry> entries = Lists.reverse(args.history); for (HistoryEntry entry : entries) { Button qAnswer = null, qSolution = null; if (entry.question instanceof Component && entry.question != null) { try { Class<? extends AnswerStorage> dataStorageClass = entry.question.getSolution().getClass(); Constructor<? extends IQuestion> constructor = entry.question.getClass() .getConstructor(dataStorageClass, dataStorageClass, float.class, String.class); // The following casts can not fail, because the question is // a component as well Component iQuestionSolution = (Component) constructor.newInstance(entry.question.getSolution(), entry.question.getSolution(), entry.question.getDifficulty(), entry.question.getQuestionText()); Component iQuestionUser = (Component) constructor.newInstance(entry.question.getSolution(), entry.question.getUserAnswer(), entry.question.getDifficulty(), entry.question.getQuestionText()); // Create the 2 needed click listeners ClickListener clickListenerSol = event -> { Window window = new Window(solution); event.getButton().setEnabled(false); window.addCloseListener(e -> event.getButton().setEnabled(true)); window.setContent(iQuestionSolution); window.center(); window.setWidth("90%"); window.setHeight("50%"); if (iQuestionSolution instanceof Sizeable) { Sizeable sizeable = iQuestionSolution; sizeable.setSizeFull(); } getUI().addWindow(window); }; ClickListener clickListenerUA = event -> { Window window = new Window(userAnswewr); event.getButton().setEnabled(false); window.addCloseListener(e -> event.getButton().setEnabled(true)); window.setContent(iQuestionUser); window.center(); window.setWidth("90%"); window.setHeight("50%"); if (iQuestionUser instanceof Sizeable) { Sizeable sizeable = iQuestionUser; sizeable.setSizeFull(); } getUI().addWindow(window); }; // Create the two buttons qAnswer = new Button(userAnswewr, clickListenerUA); qSolution = new Button(solution, clickListenerSol); } catch (Exception e) { // Ignore this line in the table LogHelper.logInfo("1 entry's solution/ user answer are missing on the final screen." + entry.question.getClass().getName() + " does not implement the constructors required by" + IQuestion.class.getName()); } } table.addItem(new Object[] { entry.question.getDifficulty(), isCorrect(entry.points, entry.question.getMaxPoints()), qAnswer, qSolution }, null); } int size = table.size(); if (size > 10) { size = 10; } table.setPageLength(size); addComponent(table); setComponentAlignment(table, Alignment.MIDDLE_CENTER); addComponent(HtmlLabel.getCenteredLabel("h3", "Your skill level is: <b>" + args.skillLevel + "</b>")); addComponent(HtmlLabel.getCenteredLabel("Delta (Valus close to 0 are best): " + args.delta)); }
From source file:au.org.scoutmaster.views.ContactView.java
private void showMailForm(final TextField emailField) { final Window mailWindow = new Window("Send Email"); mailWindow.setWidth("80%"); mailWindow.setHeight("80%"); final User sender = (User) getSession().getAttribute("user"); mailWindow.setContent(new EmailForm(mailWindow, sender, getCurrent(), emailField.getValue())); mailWindow.setVisible(true);//from w ww. java2s . c o m mailWindow.center(); UI.getCurrent().addWindow(mailWindow); }
From source file:br.com.anteros.mobileserver.util.UserMessages.java
License:Apache License
public Window confirm(String title, String message, String okTitle, String cancelTitle, Button.ClickListener listener) { if (title == null) { title = CONFIRM_OK_TITLE;/*ww w . j a v a 2 s. c o m*/ } if (cancelTitle == null) { cancelTitle = CONFIRM_CANCEL_TITLE; } if (okTitle == null) { okTitle = CONFIRM_OK_TITLE; } final Window confirm = new Window(title); this.confirm = confirm; win.addWindow(confirm); confirm.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1971800928047045825L; public void windowClose(CloseEvent ce) { Object data = ce.getWindow().getData(); if (data != null) { try { } catch (Exception exception) { error("Unhandled Exception", exception); } } } }); int chrW = 5; int chrH = 15; int txtWidth = Math.max(250, Math.min(350, message.length() * chrW)); int btnHeight = 25; int vmargin = 100; int hmargin = 40; int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth; confirm.setWidth((txtWidth + hmargin) + "px"); confirm.setHeight((vmargin + txtHeight + btnHeight) + "px"); confirm.getContent().setSizeFull(); confirm.center(); confirm.setModal(true); Label text = new Label(message); text.setWidth("100%"); text.setHeight("100%"); HorizontalLayout buttons = new HorizontalLayout(); buttons.setHeight(btnHeight + 5 + "px"); buttons.setWidth("100%"); buttons.setSpacing(true); buttons.setMargin(false); Button cancel = new Button(cancelTitle, listener); cancel.setIcon(new ThemeResource("icons/16/no.png")); cancel.setData(USER_CONFIRM_CANCEL); cancel.setClickShortcut(KeyCode.ESCAPE); Button ok = new Button(okTitle, listener); ok.setIcon(new ThemeResource("icons/16/yes.png")); ok.setData(USER_CONFIRM_OK); ok.setClickShortcut(KeyCode.ENTER); buttons.addComponent(ok); buttons.setExpandRatio(ok, 1); buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT); buttons.addComponent(cancel); buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT); confirm.addComponent(text); confirm.addComponent(buttons); ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f); confirm.setResizable(false); return confirm; }
From source file:com.bellkenz.modules.PersonalInformation.java
public ComponentContainer personalInformation() { employeeInformationDAO = new EmployeeInformationDAO(getEmployeeId()); employeePersonalInformation = new EmployeePersonalInformation(); GridLayout glayout = new GridLayout(5, 9); glayout.setSpacing(true);//from w w w. j av a 2 s . co m glayout.setMargin(true); final Panel imagePanel = new Panel(); imagePanel.setStyleName("light"); AbstractLayout panelLayout = (AbstractLayout) imagePanel.getContent(); panelLayout.setMargin(false); imagePanel.setSizeFull(); employeeImage = new Embedded(null, new ThemeResource("../myTheme/images/ronnie.jpg")); employeeImage.setImmediate(true); employeeImage.setWidth(90, Sizeable.UNITS_PIXELS); employeeImage.setHeight(90, Sizeable.UNITS_PIXELS); employeeImage.setStyleName("logo-img"); imagePanel.addComponent(employeeImage); glayout.addComponent(employeeImage, 0, 0, 0, 1); glayout.setComponentAlignment(imagePanel, Alignment.MIDDLE_CENTER); firstname = createTextField("Firstname: "); glayout.addComponent(firstname, 1, 0, 2, 0); final TextField middlename = createTextField("Middlename: "); glayout.addComponent(middlename, 3, 0); final TextField lastname = createTextField("Lastname: "); glayout.addComponent(lastname, 4, 0); final TextField houseNo = createTextField("No: "); houseNo.setWidth("40px"); glayout.addComponent(houseNo, 1, 1); final TextField street = createTextField("Street: "); street.setWidth("118"); glayout.addComponent(street, 2, 1); final TextField city = createTextField("City: "); glayout.addComponent(city, 3, 1); final TextField zipCode = createTextField("Zip Code:"); glayout.addComponent(zipCode, 4, 1); final TextField nickname = createTextField("Nickname: "); nickname.setWidth("90px"); glayout.addComponent(nickname, 0, 2); final TextField permanentAddress = createTextField("Permanent/Provincial Address: "); permanentAddress.setWidth("533px"); glayout.addComponent(permanentAddress, 1, 2, 4, 2); Button uploadPicture = new Button("Upload..."); uploadPicture.setWidth("100%"); uploadPicture.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (employeeId == null) { getWindow().showNotification("You did not select and Employee!", Window.Notification.TYPE_WARNING_MESSAGE); return; } Window uploadImage = new UploadImage(imagePanel, employeeImage, employeeId); uploadImage.setWidth("450px"); if (uploadImage.getParent() == null) { getWindow().addWindow(uploadImage); } uploadImage.setModal(true); uploadImage.center(); } }); glayout.addComponent(uploadPicture, 0, 3); final TextField landline = createTextField("Landline #: "); glayout.addComponent(landline, 1, 3, 2, 3); final TextField mobileNo = createTextField("Mobile #: "); glayout.addComponent(mobileNo, 3, 3); final TextField age = createTextField("Age: "); glayout.addComponent(age, 4, 3); final TextField emailAddress = createTextField("Email Address: "); glayout.addComponent(emailAddress, 1, 4, 2, 4); final PopupDateField dob = (PopupDateField) createDateField("Date of Birth: "); glayout.addComponent(dob, 3, 4); final TextField height = createTextField("Height: "); glayout.addComponent(height, 4, 4); final ComboBox civilStatus = new ComboBox("Civil Status: "); civilStatus.setWidth("100%"); dropDownBoxList.populateCivilStatusList(civilStatus); glayout.addComponent(civilStatus, 1, 5, 2, 5); final ComboBox gender = new ComboBox("Gender: "); gender.setWidth("100%"); dropDownBoxList.populateGenderList(gender); glayout.addComponent(gender, 3, 5); final TextField weight = createTextField("Weigth: "); glayout.addComponent(weight, 4, 5); final TextField driversLicenseNo = createTextField("Drivers License: "); glayout.addComponent(driversLicenseNo, 1, 6, 2, 6); final TextField restrictionCode = createTextField("Restriction Code: "); glayout.addComponent(restrictionCode, 3, 6); final TextField religion = createTextField("Religion: "); glayout.addComponent(religion, 4, 6); final ComboBox division = new ComboBox("Division: "); division.setWidth("100%"); dropDownBoxList.populateBranchComboBox(division); glayout.addComponent(division, 1, 7, 2, 7); final ComboBox department = dropDownBoxList.populateDepartment(new ComboBox()); department.setWidth("100%"); division.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (division.getValue() == null) { } else { divisionId = branchDAO.getBranchId(division.getValue().toString()); } } }); glayout.addComponent(department, 3, 7); final TextField position = createTextField("Position: "); glayout.addComponent(position, 4, 7); //glayout.setComponentAlignment(position, Alignment.BOTTOM_LEFT); Button transferButton = new Button("Transfer Employee"); transferButton.setWidth("100%"); transferButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (getEmployeeId() == null) { getWindow().showNotification("You did not select an Employee!", Window.Notification.TYPE_WARNING_MESSAGE); return; } Window subWindow = transferEmployee(getEmployeeId(), division, department, position); if (subWindow.getParent() == null) { getWindow().addWindow(subWindow); } subWindow.setModal(true); subWindow.center(); } }); glayout.addComponent(transferButton, 1, 8, 2, 8); glayout.setComponentAlignment(transferButton, Alignment.BOTTOM_CENTER); if (employeeId != null) { epiList = employeeInformationDAO.employeePersonalInformation(); for (EmployeePersonalInformation epi : epiList) { final byte[] image = epi.getImage(); if (image != null) { StreamResource.StreamSource imageSource = new StreamResource.StreamSource() { @Override public InputStream getStream() { return new ByteArrayInputStream(image); } }; StreamResource imageResource = new StreamResource(imageSource, epi.getFirstname() + ".jpg", getApplication()); imageResource.setCacheTime(0); employeeImage.setSource(imageResource); } firstname.setValue(epi.getFirstname()); middlename.setValue(epi.getMiddlename()); lastname.setValue(epi.getLastname()); houseNo.setValue(epi.getHouseNumber()); street.setValue(epi.getStreet()); city.setValue(epi.getStreet()); zipCode.setValue(epi.getZipCode()); nickname.setValue(epi.getNickname()); permanentAddress.setValue(epi.getPermanentAddress()); landline.setValue(epi.getLandlineNumber()); mobileNo.setValue(epi.getMobileNumber()); age.setValue(epi.getAge()); emailAddress.setValue(epi.getEmailAddress()); if (epi.getDob() != null) { dob.setValue(conUtil.parsingDate(epi.getDob())); } else { dob.setValue(null); } height.setValue(epi.getHeight()); if (epi.getCivilStatus() != null) { Object civilStatusId = civilStatus.addItem(); civilStatus.setItemCaption(civilStatusId, epi.getCivilStatus()); civilStatus.setValue(civilStatusId); } if (epi.getGender() != null) { Object genderId = gender.addItem(); gender.setItemCaption(genderId, epi.getGender()); gender.setValue(genderId); } weight.setValue(epi.getWeight()); driversLicenseNo.setValue(epi.getDriversLicense()); restrictionCode.setValue(epi.getRestrictionCode()); religion.setValue(epi.getReligion()); position.setValue(epi.getPosition()); Object divisionObjectId = division.addItem(); division.setItemCaption(divisionObjectId, epi.getDivision()); division.setValue(divisionObjectId); Object departmentObjectId = department.addItem(); department.setItemCaption(departmentObjectId, epi.getDepartment()); department.setValue(departmentObjectId); } } firstname.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { employeePersonalInformation.setFirstname(event.getProperty().getValue().toString()); } }); firstname.setImmediate(true); setInformation(employeePersonalInformation); return glayout; }
From source file:com.cbnserver.gwtp4vaadin.core.PopupViewImpl.java
License:Apache License
/** * This method centers the popup panel, temporarily making it visible if * needed./*from w ww .jav a2s. c o m*/ */ private void doCenter() { // We can't use Element.center() method as it will show the popup // by default and not only centering it. This is resulting in onAttach() // being called twice when using setInSlot() or addToPopupSlot() in PresenterWidget // If left/top are set from a previous doCenter() call, and our content // has changed, we may get a bogus getOffsetWidth because our new content // is wrapping (giving a lower offset width) then it would without the // previous left. Clearing left/top to avoids this. Window popup = asPopupPanel(); popup.center(); }
From source file:com.coatl.vaadin.abc.ixABCDialogos.java
public void abrirCrear() { cerrarDialogos();//from ww w.j a v a 2s. c o m defFormaCrear = getFormaCrear(); Window subWindow = new Window("Crear"); subWindow.setContent(defFormaCrear.getComponente()); getIxUI().addWindow(subWindow); subWindow.center(); this.defFormaCrear.setVentana(subWindow); }
From source file:com.coatl.vaadin.abc.ixABCDialogos.java
public void abrirEditar() { cerrarDialogos();/*ww w . j a v a 2 s .co m*/ defFormaEditar = getFormaEditar(); Window subWindow = new Window("Editar"); subWindow.setContent(defFormaEditar.getComponente()); getIxUI().addWindow(subWindow); subWindow.center(); this.defFormaEditar.setVentana(subWindow); }
From source file:com.coatl.vaadin.abc.ixABCDialogos.java
public void abrirBorrar() { if (defFormaEditar == null) { return;/*from w ww . j ava2s. co m*/ } Map m = defFormaEditar.getMapa(); cerrarDialogos(); defFormaBorrar = getFormaBorrar(); defFormaBorrar.vaciarMapa(m); Window subWindow = new Window("Borrar"); subWindow.setContent(defFormaBorrar.getComponente()); getIxUI().addWindow(subWindow); subWindow.center(); this.defFormaBorrar.setVentana(subWindow); }