List of usage examples for com.vaadin.ui Window setWidth
@Override public void setWidth(String width)
From source file:at.peppol.webgui.app.MainWindow.java
License:Mozilla Public License
public void showInvUploadWindow() { // this.showNotification("Warning", // "<br/>Uploading invoices is under construction", // Window.Notification.TYPE_HUMANIZED_MESSAGE); final Window popup = new InvoiceUploadWindow().getWindow(); popup.setResizable(false);/*from ww w . j a va 2s. c o m*/ popup.setHeight("150px"); popup.setWidth("430px"); getWindow().addWindow(popup); }
From source file:at.peppol.webgui.app.MainWindow.java
License:Mozilla Public License
public void showOrdUploadWindow() { // this.showNotification("Warning", // "<br/>Uploading orders is under construction", // Window.Notification.TYPE_HUMANIZED_MESSAGE); final Window popup = new OrderUploadWindow().getWindow(); popup.setResizable(false);//from ww w . j av a 2 s. com popup.setHeight("150px"); popup.setWidth("430px"); getWindow().addWindow(popup); }
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();/*from w w w . j ava2s . 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);//w w w. j a 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);//w w w. j av a2 s . co 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;//from w w w .j a v a 2 s. co 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);/* www .j ava 2 s.c o 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.bellkenz.modules.PersonalInformation.java
public Window transferEmployee(final String employeeId, final ComboBox div, final ComboBox dept, final TextField post) { VerticalLayout vlayout = new VerticalLayout(); vlayout.setMargin(true);// w w w. j av a2s . co m vlayout.setSpacing(true); final Window subWindow = new Window("Transfer Employee", vlayout); subWindow.setWidth("200px"); final ComboBox division = new ComboBox("Division: "); division.setWidth("100%"); dropDownBoxList.populateBranchComboBox(division); subWindow.addComponent(division); 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()); } } }); subWindow.addComponent(department); final TextField position = createTextField("Position: "); position.setWidth("100%"); subWindow.addComponent(position); final PopupDateField entryDate = (PopupDateField) createDateField("Date of Entry: "); subWindow.addComponent(entryDate); Button updateButton = new Button("UPDATE"); updateButton.setWidth("100%"); updateButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (division.getValue() == null) { getWindow().showNotification("Select Division!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (department.getValue() == null) { getWindow().showNotification("Select Department!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (position.getValue() == null || position.getValue().toString().trim().isEmpty()) { getWindow().showNotification("Enter Position!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (entryDate.getValue() == null) { getWindow().showNotification("Select Entry Date!", Window.Notification.TYPE_WARNING_MESSAGE); return; } List<EmployeePositionHistory> ephList = new ArrayList<EmployeePositionHistory>(); EmployeePositionHistory eph = new EmployeePositionHistory(); eph.setBranch(division.getValue().toString()); eph.setDepartment(department.getValue().toString()); eph.setPosition(position.getValue().toString().trim().toLowerCase()); eph.setEntryDate(conUtil.convertDateFormat(entryDate.getValue().toString())); ephList.add(eph); Integer deptId = departmentDAO.getDepartmentId(divisionId, department.getValue().toString()); Boolean result = employeeInformationDAO.transferEmployee(ephList, deptId); if (result) { Object divObjectId = div.addItem(); div.setItemCaption(divObjectId, division.getValue().toString()); div.setValue(divObjectId); Object deptObjectId = dept.addItem(); dept.setItemCaption(deptObjectId, department.getValue().toString()); dept.setValue(deptObjectId); post.setValue(position.getValue().toString().trim().toLowerCase()); (subWindow.getParent()).removeWindow(subWindow); } else { getWindow().showNotification("Cannot Transfer employee", Window.Notification.TYPE_ERROR_MESSAGE); } } }); subWindow.addComponent(updateButton); return subWindow; }
From source file:com.cavisson.gui.dashboard.components.calender.BeanItemContainerTestUI.java
License:Apache License
/** * Opens up a modal dialog window where an event can be modified * /*from w w w . j a v a 2s . c o m*/ * @param event * The event to modify */ private void editEvent(final BasicEvent event) { Window modal = new Window("Add event"); modal.setModal(true); modal.setResizable(false); modal.setDraggable(false); modal.setWidth("300px"); final FieldGroup fieldGroup = new FieldGroup(); FormLayout formLayout = new FormLayout(); TextField captionField = new TextField("Caption"); captionField.setImmediate(true); TextField descriptionField = new TextField("Description"); descriptionField.setImmediate(true); DateField startField = new DateField("Start"); startField.setResolution(Resolution.MINUTE); startField.setImmediate(true); DateField endField = new DateField("End"); endField.setImmediate(true); endField.setResolution(Resolution.MINUTE); formLayout.addComponent(captionField); formLayout.addComponent(descriptionField); formLayout.addComponent(startField); formLayout.addComponent(endField); fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY); fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY); fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY); fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY); fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event, Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY, ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY))); modal.setContent(formLayout); modal.addCloseListener(new Window.CloseListener() { @Override public void windowClose(CloseEvent e) { // Commit changes to bean try { fieldGroup.commit(); } catch (CommitException e1) { e1.printStackTrace(); } if (events.containsId(event)) { /* * BeanItemContainer does not notify container listeners * when the bean changes so we need to trigger a * ItemSetChange event */ BasicEvent dummy = new BasicEvent(); events.addBean(dummy); events.removeItem(dummy); } else { events.addBean(event); } } }); getUI().addWindow(modal); }
From source file:com.cavisson.gui.dashboard.components.charts.Impl.ResizeInsideVaadinComponent.java
@Override protected Component getChart() { VerticalSplitPanel verticalSplitPanel = new VerticalSplitPanel(); HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel(); horizontalSplitPanel.setSecondComponent(verticalSplitPanel); verticalSplitPanel.setFirstComponent(createChart()); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setMargin(true);//from w w w. j a v a2 s .c o m verticalLayout.setSpacing(true); verticalLayout.addComponent( new Label("Relatively sized components resize themselves automatically when in Vaadin component.")); Button button = new Button("Open in a window"); button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { Window window = new Window("Chart windodw"); window.setContent(createChart()); window.setWidth("50%"); window.setHeight("50%"); getUI().addWindow(window); } }); verticalLayout.addComponent(button); horizontalSplitPanel.setFirstComponent(verticalLayout); return horizontalSplitPanel; }