void confirmDelete() { // Create the window... subwindow = new Window("Xoa ??"); // ...and make it modal subwindow.setModal(true); // Configure the windws layout; by default a VerticalLayout VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); // Add some content; a label and a close-button Label message = new Label("Ban co chac chan muon xoa ?"); subwindow.addComponent(message); Button close = new Button( "Co", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.addComponent(close); layout.setComponentAlignment(close, Alignment.TOP_RIGHT); } // end of confirmDelete
public ConfirmDialog( String caption, String message, String okButtonText, String cancelButtonText) { super(caption); super.setModal(true); super.setClosable(false); super.setResizable(false); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setMargin(true); // confirmation message windowLayout.addComponent(new Label(message, ContentMode.HTML)); windowLayout.setSpacing(true); // buttons HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100.0f, Unit.PERCENTAGE); windowLayout.addComponent(buttonsLayout); okButton = new Button(okButtonText); buttonsLayout.addComponent(okButton); okButton.setTabIndex(1); okButton.addClickListener(this); buttonsLayout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER); cancelButton = new Button(cancelButtonText); buttonsLayout.addComponent(cancelButton); cancelButton.setTabIndex(0); cancelButton.setClickShortcut(KeyCode.ESCAPE, null); cancelButton.addClickListener(this); buttonsLayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_CENTER); super.setContent(windowLayout); }
public void showWindowForm() { itemDetilModel = new PerubahanHargaItemModel(); itemDetilView = new PerubahanHargaItemView(itemDetilModel); itemDetilPresenter = new PerubahanHargaItemPresenter(itemDetilModel, itemDetilView); itemDetilView.setSizeFull(); panelFormDetil.setContent(itemDetilView); windowForm = new Window(); windowForm.setModal(true); windowForm.center(); windowForm.setWidth("650px"); windowForm.setHeight("300px"); windowForm.setClosable(true); windowForm.setResizable(false); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSizeFull(); content.addComponent(panelFormDetil); windowForm.setContent(content); getUI().addWindow(windowForm); }
/** 增加 编辑 删除窗体初始化 * */ private void createWindow(Item item) { Window window = new Window(); window.setHeight(250, Unit.PIXELS); window.setWidth(300, Unit.PIXELS); window.setModal(true); window.setContent(createForm(item, window)); window.close(); getUI().addWindow(window); }
private void tambahUserYayasanbaru(UserOprYayasan i) { final Window win = new Window("Tambah User Baru"); Component c = new TambahUserYayasan(i, win); VerticalLayout vl = new VerticalLayout(); vl.setMargin(true); vl.addComponent(c); win.setContent(vl); win.setModal(true); win.setWidth("600px"); win.center(); UI.getCurrent().addWindow(win); }
@Override public Undoer execute(List<VertexRef> targets, OperationContext operationContext) { UI mainWindow = operationContext.getMainWindow(); CommandManager commandManager = m_commandManager; Window window = new Window(); window.setModal(true); VerticalLayout layout = new VerticalLayout(); for (Command command : commandManager.getHistoryList()) { layout.addComponent(new Label(command.toString())); } window.setContent(layout); mainWindow.addWindow(window); return null; }
public void showWindow() { subwindow = new Window("Change Category Type"); subwindow.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); final TextField txtField = new TextField("Change Category Type"); txtField.setValue(categoryType); subwindow.addComponent(txtField); Button close = new Button( "Close", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); Button save = new Button( "Save", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String newCatType = txtField.getValue().toString(); controller.updateComponentCategory(componentId, newCatType, itemId); (subwindow.getParent()).removeWindow(subwindow); } }); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(save); hl.addComponent(close); layout.addComponent(hl); subwindow.setWidth("350px"); subwindow.addComponent(layout); router.getMainWindow().addWindow(subwindow); }
private void cargarWindowRegistroPolicia() { pnlMantenPolicia = new PanelMantenPolicia(new ArrayList<Opcion>(), "400px"); pnlMantenPolicia.setParent(this.getParent()); Window window = new Window() { private static final long serialVersionUID = 1L; protected void close() { getApplication().getMainWindow().removeWindow(getWindow()); } }; window.setCaption("Registrar Policia"); window.addComponent(pnlMantenPolicia); window.setModal(true); window.setResizable(false); window.setWidth("1000px"); window.setHeight("-1px"); getWindow().addWindow(window); }
private void showNonMobileNotification() { try { URL appUrl = Page.getCurrent().getLocation().toURL(); String myIp = Inet4Address.getLocalHost().getHostAddress(); final String qrCodeUrl = appUrl.toString().replaceAll("localhost", myIp); Label info = new Label( "You appear to be running this demo on a non-portable device. " + "Parking is intended for touch devices primarily. " + "Please read the QR code on your touch device to access the demo."); info.setWidth("310px"); Image qrCode = new Image(); qrCode.addStyleName("qrcode-image"); StreamResource resource = new StreamResource( new StreamSource() { @Override public InputStream getStream() { InputStream result = null; try { final Map<EncodeHintType, ErrorCorrectionLevel> hintMap = Maps.newHashMap(); hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); final QRCodeWriter qrCodeWriter = new QRCodeWriter(); final BitMatrix byteMatrix = qrCodeWriter.encode(qrCodeUrl, BarcodeFormat.QR_CODE, 150, 150, hintMap); final int width = byteMatrix.getWidth(); final BufferedImage image = new BufferedImage(width, width, BufferedImage.TYPE_INT_RGB); image.createGraphics(); final Graphics2D graphics = (Graphics2D) image.getGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, width, width); graphics.setColor(Color.BLACK); for (int i = 0; i < width; i++) { for (int j = 0; j < width; j++) { if (byteMatrix.get(i, j)) { graphics.fillRect(i, j, 1, 1); } } } final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ImageIO.write(image, "png", baos); } catch (final IOException e) { e.printStackTrace(); } result = new ByteArrayInputStream(baos.toByteArray()); } catch (WriterException e) { e.printStackTrace(); } return result; } }, "qrcode-" + new Date().getTime() + ".png"); resource.setCacheTime(0); qrCode.setSource(resource); CssLayout qrCodeLayout = new CssLayout(qrCode, info); qrCodeLayout.setSizeFull(); Window window = new Window(null, qrCodeLayout); window.setWidth(500.0f, Unit.PIXELS); window.setHeight(200.0f, Unit.PIXELS); window.addStyleName("qr-code"); window.setModal(true); window.setResizable(false); window.setDraggable(false); addWindow(window); window.center(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (UnknownHostException e) { e.printStackTrace(); } }
@Override public Object createContainer() { dialog = new Window(); dialog.setModal(true); return dialog; }
void openLogoutWindow() { Window logout = new Window(getPbMessages("btnLogout")); logout.setModal(true); // logout.setStyleName(Reindeer.WINDOW_BLACK); logout.setWidth("260px"); logout.setResizable(false); logout.setClosable(false); logout.setDraggable(false); logout.setCloseShortcut(KeyCode.ESCAPE, null); Label helpText = new Label("Are you sure you want to log out?", Label.CONTENT_XHTML); logout.addComponent(helpText); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); Button yes = new Button( getPbMessages("btnLogout"), new Button.ClickListener() { public void buttonClick(ClickEvent event) { PbApplication app = (PbApplication) getApplication(); app.setUser(null); Cookie cookie = null; for (Cookie c : app.getHttpServletRequest().getCookies()) { if ("username".equals(c.getName())) { cookie = c; break; } } if (cookie != null) { Cookie del = new Cookie("username", ""); cookie.setMaxAge(0); // Delete app.getHttpServletResponse().addCookie(del); } WebApplicationContext applicationContext = (WebApplicationContext) getApplication().getContext(); getApplication().close(); applicationContext.getHttpSession().invalidate(); } }); yes.setStyleName(Reindeer.BUTTON_DEFAULT); yes.focus(); buttons.addComponent(yes); Button no = new Button( getPbMessages("btnCancel"), new Button.ClickListener() { public void buttonClick(ClickEvent event) { removeWindow(event.getButton().getWindow()); } }); buttons.addComponent(no); logout.addComponent(buttons); ((VerticalLayout) logout.getContent()).setComponentAlignment(buttons, Alignment.MIDDLE_CENTER); ((VerticalLayout) logout.getContent()).setSpacing(true); addWindow(logout); }
/* Initializes a modal window to edit schedule event. */ private void createCalendarEventPopup() { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); scheduleEventPopup = new Window(null, layout); scheduleEventPopup.setWidth("400px"); scheduleEventPopup.setModal(true); scheduleEventPopup.center(); layout.addComponent(scheduleEventFieldLayout); applyEventButton = new Button( "Apply", new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { try { commitCalendarEvent(); } catch (CommitException | ValidationException e) { e.printStackTrace(); } } }); Button cancel = new Button( "Cancel", new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { discardCalendarEvent(); } }); deleteEventButton = new Button( "Delete", new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { deleteCalendarEvent(); } }); scheduleEventPopup.addCloseListener( new Window.CloseListener() { private static final long serialVersionUID = 1L; @Override public void windowClose(Window.CloseEvent e) { discardCalendarEvent(); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(deleteEventButton); buttons.addComponent(applyEventButton); buttons.addComponent(cancel); layout.addComponent(buttons); layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT); }
protected void execute(TipiEvent event) throws TipiBreakException, TipiException { Operand value = getEvaluatedParameter("property", event); if (value == null) { throw new TipiException("TipiBrowseBinary: no value supplied"); } if (value.value == null) { throw new TipiException("TipiBrowseBinary: null value supplied"); } if (!(value.value instanceof Property)) { throw new TipiException( "TipiOpenBinary: Type of value is not Property, but: " + value.value.getClass()); } final Property pp = (Property) value.value; if (!pp.getType().equals(Property.BINARY_PROPERTY)) { throw new TipiException("TipiOpenBinary: Property is not type binary , but: " + pp.getType()); } final Window w = new Window("Upload binary"); w.setModal(true); w.setClosable(true); w.setWidth(320, Sizeable.UNITS_PIXELS); w.setHeight(70, Sizeable.UNITS_PIXELS); Upload u = new Upload( "", new Upload.Receiver() { private static final long serialVersionUID = 1L; @Override public OutputStream receiveUpload(String filename, String mimeType) { outputBinary = new Binary(); return outputBinary.getOutputStream(); } }); u.addListener( new Upload.SucceededListener() { private static final long serialVersionUID = 8118852698370774496L; @Override public void uploadSucceeded(SucceededEvent event) { try { pp.setAnyValue(outputBinary); getApplication().getMainWindow().removeWindow(w); continueAction(getEvent()); } catch (TipiBreakException e) { } catch (TipiSuspendException e) { } catch (TipiException e) { e.printStackTrace(); } } }); u.addListener( new Upload.FailedListener() { private static final long serialVersionUID = 4791549173755572186L; @Override public void uploadFailed(FailedEvent event) { System.err.println("Upload failed?"); throw new TipiBreakException(); } }); w.addComponent(u); getApplication().getMainWindow().addWindow(w); suspend(); }
@Override public void execute() { List<ChangeRecord> historyList = view.getUi().getStockService().findChanges(good); Window subWindow = new Window(); subWindow.setModal(true); subWindow.setHeight("650px"); subWindow.setWidth("700px"); subWindow.setClosable(true); view.getUi().addWindow(subWindow); final Button pdfButton = new Button(bundle.getString("pdf.export")); pdfButton.setIcon(new ThemeResource("img/pdf.png")); pdfButton.setWidth("150"); StreamResource pdfStream = getPDFStream(view.getUi().getStockService().findChanges(good)); pdfStream.setMIMEType("application/pdf"); FileDownloader pdfDownloader = new FileDownloader(pdfStream); pdfDownloader.extend(pdfButton); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.addComponent(pdfButton); for (ChangeRecord record : historyList) { for (ChangeRecord.PropertyChange p : record.getChangeList()) { p.setName(bundle.getString(p.getName())); } Panel panel = new Panel(); BeanItemContainer<ChangeRecord.PropertyChange> container = new BeanItemContainer<>(ChangeRecord.PropertyChange.class, record.getChangeList()); Table table = new Table(); table.setContainerDataSource(container); table.setVisibleColumns("name", "oldValue", "newValue"); table.setColumnHeaders( bundle.getString("history.property"), bundle.getString("history.old"), bundle.getString("history.new")); table.setColumnExpandRatio("name", 0.33f); table.setColumnExpandRatio("oldValue", 0.33f); table.setColumnExpandRatio("newValue", 0.33f); table.setPageLength(0); table.setWidth("100%"); VerticalLayout panelLayout = new VerticalLayout(); panelLayout.addComponent( new Label( "<b>" + new SimpleDateFormat("dd-MM-YYYY HH:mm").format(record.getDate()) + ": " + record.getUser().getName() + " " + record.getUser().getSurname() + "</b><br/>", ContentMode.HTML)); panelLayout.addComponent(table); panel.setContent(panelLayout); layout.addComponent(panel); } subWindow.setContent(layout); }