List of usage examples for com.vaadin.ui Window addListener
@Override
public Registration addListener(Component.Listener listener)
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 www. ja va 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.openhris.calendar.SchedulerMainUI.java
@SuppressWarnings("serial") private void addCalendarEventListeners() { // Register week clicks by changing the schedules start and end dates. cal.setHandler(new BasicWeekClickHandler() { @Override//from www . j a v a 2s.c om public void weekClick(CalendarComponentEvents.WeekClick event) { // let BasicWeekClickHandler handle calendar dates, and update // only the other parts of UI here super.weekClick(event); updateCaptionLabel(); switchToWeekView(); } }); cal.setHandler(new CalendarComponentEvents.EventClickHandler() { @Override public void eventClick(CalendarComponentEvents.EventClick event) { nextButton.setVisible(true); prevButton.setVisible(true); Window subWindow; if (event.getCalendarEvent() == null) { subWindow = new CalendarScheduleWindow(0, useSecondResolution, cal); if (subWindow.getParent() == null) { getWindow().addWindow(subWindow); } subWindow.addListener(scheduleWindowCloseListener); } else { CalendarService calendarService = new CalendarServiceImpl(); BasicEvent basicEvent = calendarService.getEvent(event); subWindow = new CalendarScheduleWindow(event, basicEvent, cal); if (subWindow.getParent() == null) { getWindow().addWindow(subWindow); } } } }); cal.setHandler(new BasicDateClickHandler() { @Override public void dateClick(CalendarComponentEvents.DateClickEvent event) { // let BasicDateClickHandler handle calendar dates, and update // only the other parts of UI here super.dateClick(event); switchToDayView(); } }); cal.setHandler(new CalendarComponentEvents.RangeSelectHandler() { @Override public void rangeSelect(CalendarComponentEvents.RangeSelectEvent event) { handleRangeSelect(event); } }); }
From source file:com.openhris.calendar.SchedulerMainUI.java
private void handleRangeSelect(CalendarComponentEvents.RangeSelectEvent event) { dateStart = event.getStart();/*from w w w . j av a 2 s. c om*/ dateEnd = event.getEnd(); /* * If a range of dates is selected in monthly mode, we want it to end at * the end of the last day. */ if (event.isMonthlyMode()) { dateEnd = Calendar.getEndOfDay(calendar, dateEnd); } Window subWindow = new CalendarScheduleWindow(0, useSecondResolution, cal); if (subWindow.getParent() == null) { getWindow().addWindow(subWindow); } subWindow.addListener(scheduleWindowCloseListener); }
From source file:com.openhris.employee.PostEmploymentInfomation.java
public Table positionHistoryTable() { positionHistoryTbl.removeAllItems(); List<PostEmploymentInformationBean> positionList = positionHistoryService .getPositionHistory(getEmployeeId()); int i = 0;/*from w w w. j a va2 s . c om*/ for (PostEmploymentInformationBean p : positionList) { positionHistoryTbl .addItem(new Object[] { p.getPositionId(), p.getPosition().toLowerCase(), p.getCompany(), p.getTrade(), p.getBranch(), p.getDepartment(), utilities.convertDateFormatForTableData( utilities.convertDateFormat(p.getEntryDate().toString())) }, i); i++; } positionHistoryTbl.setPageLength(7); for (Object listener : positionHistoryTbl.getListeners(ItemClickEvent.class)) { positionHistoryTbl.removeListener(ItemClickEvent.class, listener); } positionHistoryTbl.addListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { Object itemId = event.getItemId(); Item item = positionHistoryTbl.getItem(itemId); newPositionBtn.setValue(false); updateBtn.setCaption(BTN_CAPTION_2); positionId = utilities.convertStringToInteger(item.getItemProperty("id").getValue().toString()); setPositionId(positionId); if (event.getPropertyId().equals("id")) { Window window = new RemovePositionWindow(getPositionId()); if (window.getParent() == null) { getWindow().addWindow(window); } window.center(); window.addListener(subWindowCloseListener); } else { List<PostEmploymentInformationBean> positionListById = positionHistoryService .getPositionHistoryById(utilities .convertStringToInteger(item.getItemProperty("id").getValue().toString())); for (PostEmploymentInformationBean history : positionListById) { Object corporateObjectId = corporate.addItem(); corporate.setItemCaption(corporateObjectId, history.getCompany()); corporate.setValue(corporateObjectId); Object tradeObjectId = trade.addItem(); trade.setItemCaption(tradeObjectId, history.getTrade()); trade.setValue(tradeObjectId); Object branchObjectId = branch.addItem(); branch.setItemCaption(branchObjectId, history.getBranch()); branch.setValue(branchObjectId); department.setValue(history.getDepartment()); position.setValue(history.getPosition()); entryDate.setValue(history.getEntryDate()); } } } }); return positionHistoryTbl; }
From source file:com.ribas.andrei.vaadin.OpenWindowApplication.java
License:Open Source License
private void createSubWindow(String subWindowMessage, boolean modal, Embedded iframe) { final Window tempSubWindow = new Window(subWindowMessage); tempSubWindow.setWidth("80%"); tempSubWindow.setHeight("80%"); tempSubWindow.center();/*from w w w . j av a 2 s. com*/ tempSubWindow.setModal(modal); tempSubWindow.addListener(new Window.CloseListener() { public void windowClose(CloseEvent e) { closeWindow(); } }); tempSubWindow.addComponent(iframe); OpenWindowApplication.this.subWindow = tempSubWindow; OpenWindowApplication.this.mainWindow.addWindow(OpenWindowApplication.this.subWindow); }
From source file:jp.primecloud.auto.ui.LoadBalancerButtonsBottom.java
License:Open Source License
private void editButtonClick(ClickEvent event) { LoadBalancerDto loadBalancer = (LoadBalancerDto) sender.loadBalancerPanel.loadBalancerTable.getValue(); Window winLoadBalancerEdit; if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(loadBalancer.getLoadBalancer().getType())) { winLoadBalancerEdit = new WinCloudStackLoadBalancerEdit( loadBalancer.getLoadBalancer().getLoadBalancerNo()); } else {// w w w .j a v a 2 s .c o m winLoadBalancerEdit = new WinLoadBalancerEdit(loadBalancer.getLoadBalancer().getLoadBalancerNo()); } winLoadBalancerEdit.addListener(new Window.CloseListener() { @Override public void windowClose(CloseEvent e) { refreshTable(); } }); getWindow().addWindow(winLoadBalancerEdit); }
From source file:org.aksw.autosparql.tbsl.gui.vaadin.TBSLApplication.java
License:Apache License
private void onShowLearnedQuery() { String learnedSPARQLQuery = UserSession.getManager().getLearnedSPARQLQuery(); VerticalLayout layout = new VerticalLayout(); final Window w = new Window("Learned SPARQL Query", layout); w.setWidth("300px"); w.setSizeUndefined();//from ww w .j a va 2 s. c om w.setPositionX(200); w.setPositionY(100); getMainWindow().addWindow(w); w.addListener(new Window.CloseListener() { @Override public void windowClose(CloseEvent e) { getMainWindow().removeWindow(w); } }); Label queryLabel = new Label(learnedSPARQLQuery, Label.CONTENT_PREFORMATTED); queryLabel.setWidth(null); layout.addComponent(queryLabel); Label nlLabel = new Label(UserSession.getManager().getNLRepresentation(learnedSPARQLQuery)); layout.addComponent(nlLabel); }
From source file:org.casbah.ui.IssuedCertificateList.java
License:Open Source License
private void collectKeyCertificateInfo() throws CAProviderException { final Window principalWindow = new Window("Specify Certificate Details"); principalWindow.setPositionX(200);// ww w . jav a2 s . co m principalWindow.setPositionY(100); principalWindow.setWidth("600px"); principalWindow.setHeight("500px"); principalWindow.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1L; public void windowClose(CloseEvent e) { parentApplication.getMainWindow().removeWindow(principalWindow); } }); VerticalLayout vl = new VerticalLayout(); final PrincipalComponent pc = new PrincipalComponent(); Principal parentPrincipal = new Principal(provider.getCACertificate().getSubjectX500Principal()); pc.init(new Principal(parentPrincipal, provider.getRuleMap())); vl.addComponent(pc); HorizontalLayout passLayout = new HorizontalLayout(); vl.addComponent(passLayout); final TextField pass1 = new TextField("Private key/keystore passphrase"); pass1.setSecret(true); final TextField pass2 = new TextField(); pass2.setSecret(true); passLayout.addComponent(pass1); passLayout.addComponent(pass2); passLayout.setComponentAlignment(pass1, Alignment.BOTTOM_CENTER); passLayout.setComponentAlignment(pass2, Alignment.BOTTOM_CENTER); final OptionGroup type = new OptionGroup("Bundle Type"); type.addItem(BundleType.OPENSSL); type.addItem(BundleType.PKCS12); type.addItem(BundleType.JKS); type.setValue(BundleType.OPENSSL); vl.addComponent(type); HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.addComponent(new Button("Create", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (pass1.getValue().equals(pass2.getValue())) { try { createKeyCertificatePair(pc.toPrincipal(), (String) pass1.getValue(), (BundleType) type.getValue()); parentApplication.getMainWindow().removeWindow(principalWindow); } catch (Exception e) { logger.severe(e.getMessage()); parentApplication.getMainWindow().showNotification( "An error prevented the correct creation of the key/certificate pair", Notification.TYPE_ERROR_MESSAGE); } } else { parentApplication.getMainWindow().showNotification("Passphrases do not match", Notification.TYPE_ERROR_MESSAGE); } } })); buttonsLayout.addComponent(new Button("Cancel", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { parentApplication.getMainWindow().removeWindow(principalWindow); } })); vl.addComponent(buttonsLayout); principalWindow.setContent(vl); parentApplication.getMainWindow().addWindow(principalWindow); }
From source file:org.casbah.ui.MainCAView.java
License:Open Source License
private void uploadAndSignCsr() throws CAProviderException { final Window csrWindow = new Window("Upload CSR"); csrWindow.setPositionX(200);/* ww w. j a v a 2 s . co m*/ csrWindow.setPositionY(100); csrWindow.setWidth("800px"); csrWindow.setHeight("300px"); csrWindow.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1L; public void windowClose(CloseEvent e) { application.getMainWindow().removeWindow(csrWindow); } }); final TextField csrData = new TextField("DER Encoded CSR"); csrData.setColumns(80); csrData.setRows(20); csrData.setWordwrap(false); csrWindow.addComponent(csrData); HorizontalLayout hl = new HorizontalLayout(); csrWindow.addComponent(hl); hl.addComponent(new Button("Cancel", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(csrWindow); } })); hl.addComponent(new Button("Upload", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { String csr = (String) csrData.getValue(); try { X509Certificate result = provider.sign(csr); showEncodedCertificate(result, result.getSerialNumber().toString(16)); } catch (CAProviderException cpe) { cpe.printStackTrace(); } } })); csrWindow.setModal(true); application.getMainWindow().addWindow(csrWindow); }
From source file:org.casbah.ui.MainCAView.java
License:Open Source License
private void showEncodedCertificate(X509Certificate cert, String serialNumber) throws CAProviderException { final Window certWindow = new Window(serialNumber); certWindow.setPositionX(200);/*from ww w .ja v a 2 s .co m*/ certWindow.setPositionY(100); certWindow.setWidth("800px"); certWindow.setHeight("300px"); certWindow.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1L; public void windowClose(CloseEvent e) { application.getMainWindow().removeWindow(certWindow); } }); String certData = CertificateHelper.encodeCertificate(cert, true); TextField encodedCert = new TextField("Encoded Certificate", certData); encodedCert.setReadOnly(true); encodedCert.setColumns(80); encodedCert.setRows(certData.split("\n").length); encodedCert.setWordwrap(false); certWindow.addComponent(encodedCert); certWindow.addComponent(new Button("Close", new Button.ClickListener() { /** * */ private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(certWindow); } })); certWindow.setModal(true); application.getMainWindow().addWindow(certWindow); }