List of usage examples for com.vaadin.ui Window Window
public Window(String caption)
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * abre una vista. La colocar en el lado derecho * * @param ui//from ww w . j a va 2s . c o m * @param view */ public static void addView(MyUI ui, AbstractView view) { if (view == null) { System.out.println("abriendo vista null"); ui.getViewDisplay().removeAllComponents(); } else { System.out.println("abriendo vista " + view.getClass().getName() + "::" + view.getViewId()); ViewLayout v = new ViewLayout(view); if (view instanceof AbstractDialog) { AbstractDialog d = (AbstractDialog) view; // Create a sub-window and set the content Window subWindow = new Window(((AbstractDialog) view).getTitle()); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button ok; if (d instanceof AbstractAddRecordDialog) { ok = new Button("Add record", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { //if (d.isCloseOnOk()) subWindow.close(); ((AbstractAddRecordDialog) view).addAndClean(v.getView().getForm().getData()); } }); } else { ok = new Button(d.getOkText(), e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (d.isCloseOnOk()) subWindow.close(); ((AbstractDialog) view).onOk(v.getView().getForm().getData()); } }); } ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); footer.addComponents(footerText); for (AbstractAction a : d.getActions()) { Button b = new Button(a.getName(), e -> { a.run(); }); //b.addStyleName(ValoTheme.BUTTON_); //b.setClickShortcut(ShortcutAction.KeyCode.ENTER); if ("previous".equalsIgnoreCase(a.getName())) { b.setIcon(VaadinIcons.ANGLE_LEFT); } else if ("next".equalsIgnoreCase(a.getName())) { b.setIcon(VaadinIcons.ANGLE_RIGHT); } footer.addComponent(b); } if (d instanceof AbstractListEditorDialog) { AbstractListEditorDialog lv = (AbstractListEditorDialog) d; Property<Integer> pos = new SimpleObjectProperty<>(); pos.setValue(lv.getInitialPos()); Button prev = new Button("Previous", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (pos.getValue() > 0) { lv.setData(pos.getValue(), view.getForm().getData()); pos.setValue(pos.getValue() - 1); view.getForm().setData(lv.getData(pos.getValue())); } } }); prev.setIcon(VaadinIcons.ANGLE_LEFT); footer.addComponent(prev); Button next = new Button("Next", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (pos.getValue() < lv.getListSize() - 1) { lv.setData(pos.getValue(), view.getForm().getData()); pos.setValue(pos.getValue() + 1); view.getForm().setData(lv.getData(pos.getValue())); } } }); next.setIcon(VaadinIcons.ANGLE_RIGHT); footer.addComponent(next); pos.addListener(new ChangeListener<Integer>() { @Override public void changed(ObservableValue<? extends Integer> observable, Integer oldValue, Integer newValue) { if (newValue <= 0) { prev.setEnabled(false); } else { prev.setEnabled(true); } if (newValue < lv.getListSize() - 1) { next.setEnabled(true); } else { next.setEnabled(false); } } }); } footer.addComponents(ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI ui.addWindow(subWindow); } else { System.out.println("aadiendo vista al contenedor de vistas"); ui.getViewDisplay().removeAllComponents(); ui.getViewDisplay().addComponent(v); ui.refreshMenu(v.getArea(), v.getMenu()); } } }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * are el dilogo para autenticarse//from w w w. j a va2 s . com */ private void openLoginDialog(boolean gohome) { // Create a sub-window and set the content Window subWindow = new Window("Login"); subWindow.setWidth("375px"); FormLayout f = new FormLayout(); f.setMargin(true); TextField l; f.addComponent(l = new TextField("Username")); PasswordField p; f.addComponent(p = new PasswordField("Password")); Label e; f.addComponent(e = new Label()); VerticalLayout v = new VerticalLayout(); v.addComponent(f); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button forgot = new Button("Forgot password", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { e.setValue("Asking for email..."); io.mateu.ui.core.client.app.MateuUI.getBaseService().forgotPassword(l.getValue(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage()); } @Override public void onSuccess(Void result) { e.setValue("Email sent. Please check your inbox"); } }); } }); //forgot.addStyleName(ValoTheme.BUTTON_); Button ok = new Button("Login", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { e.setValue("Authenticating..."); io.mateu.ui.core.client.app.MateuUI.getBaseService().authenticate(l.getValue(), p.getValue(), new AsyncCallback<UserData>() { @Override public void onFailure(Throwable caught) { e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage()); } @Override public void onSuccess(UserData result) { e.setValue("OK!"); getApp().setUserData(result); VaadinSession.getCurrent().setAttribute("usuario", "admin"); subWindow.close(); if (MateuUI.getApp().isFavouritesAvailable()) linkFavoritos.setVisible(true); if (MateuUI.getApp().isLastEditedAvailable()) linkUltimosRegistros.setVisible(true); if (MateuUI.getApp().isFavouritesAvailable()) linkNuevoFavorito.setVisible(true); refreshSettings(); refreshMenu(null, null); System.out.println("STATE:" + navigator.getState()); System.out.println("URIFRAGMENT:" + Page.getCurrent().getUriFragment()); navigator.navigateTo((gohome) ? "" : navigator.getState()); } }); } }); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); Button cancel = new Button("Cancel"); footer.addComponents(footerText, forgot, ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI UI.getCurrent().addWindow(subWindow); l.focus(); }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * abre el dilogo para cambiar el password * *//* ww w .ja v a2 s . c om*/ private void changePassword() { // Create a sub-window and set the content Window subWindow = new Window("Change password"); subWindow.setWidth("375px"); FormLayout f = new FormLayout(); f.setMargin(true); PasswordField l; f.addComponent(l = new PasswordField("Current password")); PasswordField p; f.addComponent(p = new PasswordField("New password")); PasswordField p2; f.addComponent(p2 = new PasswordField("Repeat password")); Label e; f.addComponent(e = new Label()); VerticalLayout v = new VerticalLayout(); v.addComponent(f); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button ok = new Button("Change it!", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { if (l.getValue() == null || "".equals(l.getValue().trim())) e.setValue("Old password is required"); else if (p.getValue() == null || "".equals(p.getValue().trim())) e.setValue("New password is required"); else if (p2.getValue() == null || "".equals(p2.getValue().trim())) e.setValue("New password repeated is required"); else if (!p.getValue().equals(p2.getValue())) e.setValue("New password and new password repeated must be equal"); else { e.setValue("Changing password..."); io.mateu.ui.core.client.app.MateuUI.getBaseService().changePassword( getApp().getUserData().getLogin(), l.getValue(), p.getValue(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage()); } @Override public void onSuccess(Void result) { e.setValue("OK!"); subWindow.close(); } }); } } }); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI UI.getCurrent().addWindow(subWindow); l.focus(); }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * abre el dilogo para editar el perfil//from w w w . j a v a 2 s .c o m * */ private void editProfile() { // Create a sub-window and set the content Window subWindow = new Window("My profile"); subWindow.setWidth("375px"); FormLayout f = new FormLayout(); f.setMargin(true); TextField l; f.addComponent(l = new TextField("Name")); l.setValue(getApp().getUserData().getName()); TextField p; f.addComponent(p = new TextField("Email")); p.setValue(getApp().getUserData().getEmail()); Label e; f.addComponent(e = new Label()); VerticalLayout v = new VerticalLayout(); v.addComponent(f); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button ok = new Button("Update it!", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { e.setValue("Authenticating..."); io.mateu.ui.core.client.app.MateuUI.getBaseService().updateProfile( getApp().getUserData().getLogin(), l.getValue(), p.getValue(), null, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage()); } @Override public void onSuccess(Void result) { e.setValue("OK!"); getApp().getUserData().setName(l.getValue()); getApp().getUserData().setEmail(p.getValue()); subWindow.close(); refreshSettings(); } }); } }); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI UI.getCurrent().addWindow(subWindow); l.focus(); }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * abre el dilogo para cambiar la foto/*from ww w.j ava 2 s . com*/ * * */ private void uploadFoto() { // Create a sub-window and set the content Window subWindow = new Window("My photo"); subWindow.setWidth("475px"); FormLayout f = new FormLayout(); f.setMargin(true); Label e = new Label(); Image image = new Image(); class MyUploader implements Upload.Receiver, Upload.SucceededListener { File file; public File getFile() { return file; } public OutputStream receiveUpload(String fileName, String mimeType) { // Create and return a file output stream System.out.println("receiveUpload(" + fileName + "," + mimeType + ")"); FileOutputStream os = null; if (fileName != null && !"".equals(fileName)) { long id = fileId++; String extension = ".tmp"; if (fileName == null || "".equals(fileName.trim())) fileName = "" + id + extension; if (fileName.lastIndexOf(".") < fileName.length() - 1) { extension = fileName.substring(fileName.lastIndexOf(".")); fileName = fileName.substring(0, fileName.lastIndexOf(".")); } File temp = null; try { temp = File.createTempFile(fileName, extension); os = new FileOutputStream(file = temp); } catch (IOException e) { e.printStackTrace(); } } return os; } public void uploadSucceeded(Upload.SucceededEvent event) { // Show the uploaded file in the image viewer image.setSource(new FileResource(file)); System.out.println("uploadSucceeded(" + file.getAbsolutePath() + ")"); } public FileLocator getFileLocator() throws IOException { String extension = ".tmp"; String fileName = file.getName(); if (file.getName() == null || "".equals(file.getName().trim())) fileName = "" + getId(); if (fileName.lastIndexOf(".") < fileName.length() - 1) { extension = fileName.substring(fileName.lastIndexOf(".")); fileName = fileName.substring(0, fileName.lastIndexOf(".")).replaceAll(" ", "_"); } java.io.File temp = (System.getProperty("tmpdir") == null) ? java.io.File.createTempFile(fileName, extension) : new java.io.File(new java.io.File(System.getProperty("tmpdir")), fileName + extension); System.out.println("java.io.tmpdir=" + System.getProperty("java.io.tmpdir")); System.out.println("Temp file : " + temp.getAbsolutePath()); if (System.getProperty("tmpdir") == null || !temp.exists()) { System.out.println("writing temp file to " + temp.getAbsolutePath()); Files.copy(file, temp); } else { System.out.println("temp file already exists"); } String baseUrl = System.getProperty("tmpurl"); URL url = null; try { if (baseUrl == null) { url = file.toURI().toURL(); } else url = new URL(baseUrl + "/" + file.getName()); } catch (MalformedURLException e) { e.printStackTrace(); } return new FileLocator(0, file.getName(), url.toString(), file.getAbsolutePath()); } } ; MyUploader receiver = new MyUploader(); Upload upload = new Upload(null, receiver); //upload.setImmediateMode(false); upload.addSucceededListener(receiver); f.addComponent(image); f.addComponent(upload); f.addComponent(e); VerticalLayout v = new VerticalLayout(); v.addComponent(f); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button ok = new Button("Change it!", new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { e.setValue("Changing photo..."); try { FileLocator loc = receiver.getFileLocator(); io.mateu.ui.core.client.app.MateuUI.getBaseService() .updateFoto(getApp().getUserData().getLogin(), loc, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { e.setValue("" + caught.getClass().getName() + ": " + caught.getMessage()); } @Override public void onSuccess(Void result) { e.setValue("OK!"); getApp().getUserData().setPhoto(loc.getUrl()); foto = (getApp().getUserData().getPhoto() != null) ? new ExternalResource(getApp().getUserData().getPhoto()) : new ClassResource("profile-pic-300px.jpg"); subWindow.close(); refreshSettings(); } }); } catch (IOException e1) { e1.printStackTrace(); io.mateu.ui.core.client.app.MateuUI.alert("" + e1.getClass().getName() + ":" + e1.getMessage()); } } }); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); Button cancel = new Button("Cancel"); footer.addComponents(footerText, ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI UI.getCurrent().addWindow(subWindow); upload.focus(); }
From source file:it.vige.greenarea.bpm.custom.ui.dettaglio.KmlDocumentViewer.java
License:Apache License
public KmlDocumentViewer(String focusedFeature, Coordinate coordinate) { super();/* www. ja v a 2s .c o m*/ setImmediate(true); loadDocument(); setWidth(100, UNITS_PERCENTAGE); addComponent(ufu); addLayer(osm); addLayer(vectorLayer); extractStyles(doc); displayFeatures(focusedFeature); vectorLayer.setSelectionMode(SIMPLE); vectorLayer.setImmediate(true); vectorLayer.addListener(new VectorSelectedListener() { public void vectorSelected(VectorSelectedEvent event) { final Area component = (Area) event.getVector(); final String data = (String) component.getData(); final Window window = new Window("Details"); window.getContent().setSizeFull(); window.setHeight("50%"); window.setWidth("50%"); Button button = new Button("Focus this feature"); button.addListener(new ClickListener() { private static final long serialVersionUID = 3286851301965195290L; @Override public void buttonClick(ClickEvent event) { ufu.setFragment(data); displayFeatures(data); window.getParent().removeWindow(window); } }); window.addComponent(button); window.setClosable(true); window.center(); getWindow().addWindow(window); vectorLayer.setSelectedVector(null); } }); if (coordinate != null) { // Definig a Marker Layer MarkerLayer markerLayer = new MarkerLayer(); // Defining a new Marker final Marker marker = new Marker(coordinate.getLongitude(), coordinate.getLatitude()); // URL of marker Icon marker.setIcon(new ThemeResource("img/marker.png"), 60, 60); markerLayer.addComponent(marker); addLayer(markerLayer); setCenter(coordinate.getLongitude(), coordinate.getLatitude()); } }
From source file:jcaster_vaadin.Jcaster_vaadinApplication.java
License:Open Source License
@Override public void init() { Window mainWindow = new Window("Jcaster"); mainWindow.addComponent(new Gui2()); setMainWindow(mainWindow);/*from w w w. j a v a2 s . c o m*/ }
From source file:jp.primecloud.auto.ui.AutoApplication.java
License:Open Source License
private void initMainLayout() { main = new VerticalLayout(); main.setSizeFull();/* w w w. j a v a 2 s .c om*/ mainWindow = new Window(ViewProperties.getCaption("window.main")); setMainWindow(mainWindow); mainWindow.setContent(main); mainWindow.setWidth("960px"); mainWindow.setHeight("100%"); setTheme("classy"); //? top = new TopBar(); main.addComponent(top); // ? setErrorHandler(new ErrorHandler(mainWindow)); }
From source file:kg.cloud.acc.MyVaadinApplication.java
License:Apache License
@Override public void init() { setTheme("good_cham"); final ResourceBundle i18n = ResourceBundle.getBundle(UimsMessages.class.getName(), getLocale()); this.getContext().addTransactionListener(this); this.window = new Window(i18n.getString(UimsMessages.AppTitle)); this.setMainWindow(window); viewManager = new ViewManager(window); viewManager.switchScreen(LoginScreen.class.getName(), new LoginScreen(this)); }
From source file:kg.cloud.hospital.MyVaadinApplication.java
License:Apache License
@Override public void init() { this.getContext().addTransactionListener(this); this.window = new Window("DentalCare Hospital"); this.setMainWindow(window); window.setContent(new LoginScreen(this)); }