List of usage examples for com.vaadin.ui Label setValue
public void setValue(String value)
From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java
License:Open Source License
/** * Add File Name.<br>// ww w . j a va 2 s . c o m * If editFileName is true, display an Input Text Field. <br> * Else display a simple label. */ protected Component getFileDetailFileName() { // Build the file name without the extension final boolean hasExtension = StringUtils.isNotBlank(getValue().getExtension()); final String extension = hasExtension ? "." + getValue().getExtension() : ""; String fileName = StringUtils.removeEnd(getValue().getFileName(), extension); if (this.editFileName && !isReadOnly()) { TextField textField = new TextField(i18n.translate(fileDetailNameCaption), fileName); textField.setNullRepresentation(""); textField.setCaption(i18n.translate(fileDetailNameCaption)); textField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { Object newFileNameObject = event.getProperty().getValue(); String newFileName = (newFileNameObject != null && StringUtils.isNotBlank(newFileNameObject.toString())) ? newFileNameObject.toString() : UploadReceiver.INVALID_FILE_NAME; getValue().setFileName(newFileName + extension); getPropertyDataSource().setValue(getValue()); } }); return textField; } else { Label label = new Label("", ContentMode.HTML); label.setCaption(i18n.translate(fileDetailNameCaption)); label.setValue(fileName); return label; } }
From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java
License:Open Source License
/** * Add File Info.//w ww . jav a 2s . c om */ protected Component getFileDetailSize() { Label label = new Label("", ContentMode.HTML); label.setCaption(i18n.translate(fileDetailSizeCaption)); label.setValue(FileUtils.byteCountToDisplaySize(getValue().getFileSize())); return label; }
From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadField.java
License:Open Source License
/** * Add File Format.<br>//from w ww. j av a2s.co m * If editFileFormat is true, display an Input Text Field. <br> * Else display a simple label. */ protected Component getFileDetailFileFormat() { if (this.editFileFormat && !isReadOnly()) { TextField textField = new TextField(i18n.translate(fileDetailFormatCaption), getValue().getExtension()); textField.setNullRepresentation(""); textField.setCaption(i18n.translate(fileDetailFormatCaption)); return textField; } else { Label label = new Label("", ContentMode.HTML); label.setValue(getValue().getExtension()); label.setCaption(i18n.translate(fileDetailFormatCaption)); return label; } }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * are el dilogo para autenticarse// w w w . ja v a2 s .c o m */ 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 * *///from www.j av a 2s .c o m 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 ww .j av a2s .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 w w w.ja v a 2 s.c o m*/ * * */ 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:io.subutai.plugin.accumulo.ui.manager.Manager.java
private void populateMastersTable(final Table table, Set<EnvironmentContainerHost> containerHosts, final boolean masters) { table.removeAllItems();//from w ww .jav a 2s.c o m for (final EnvironmentContainerHost containerHost : containerHosts) { List<NodeType> rolesOfNode = accumuloClusterConfig.getMasterNodeRoles(containerHost.getId()); for (final NodeType role : rolesOfNode) { final Button checkBtn = new Button(CHECK_BUTTON_CAPTION); checkBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloCheck"); final Button destroyBtn = new Button(DESTROY_BUTTON_CAPTION); destroyBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloDestroy"); final Label resultHolder = new Label(); resultHolder.setId(containerHost.getIpByInterfaceName("eth0") + "accumuloResult"); HorizontalLayout availableOperations = new HorizontalLayout(); availableOperations.setSpacing(true); addGivenComponents(availableOperations, checkBtn); addStyleName(checkBtn, destroyBtn, availableOperations); table.addItem( new Object[] { containerHost.getHostname(), containerHost.getIpByInterfaceName("eth0"), filterNodeRole(role.name()), resultHolder, availableOperations }, null); checkBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { PROGRESS_ICON.setVisible(true); disableButtons(checkBtn, destroyBtn); executorService .execute(new CheckTask(accumulo, tracker, accumuloClusterConfig.getClusterName(), containerHost.getHostname(), new CompleteEvent() { public void onComplete(String result) { synchronized (PROGRESS_ICON) { resultHolder.setValue(parseStatus(result, role)); enableButtons(destroyBtn, checkBtn); PROGRESS_ICON.setVisible(false); } } })); } }); } } }
From source file:io.subutai.plugin.accumulo.ui.manager.Manager.java
private void populateTracersTable(final Table table, Set<EnvironmentContainerHost> containerHosts, final boolean masters) { table.removeAllItems();/*from w w w . ja v a2s . c om*/ for (final EnvironmentContainerHost containerHost : containerHosts) { final Button checkBtn = new Button(CHECK_BUTTON_CAPTION); checkBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloCheck"); final Button destroyBtn = new Button(DESTROY_BUTTON_CAPTION); destroyBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloDestroy"); final Label resultHolder = new Label(); resultHolder.setId(containerHost.getIpByInterfaceName("eth0") + "accumuloResult"); HorizontalLayout availableOperations = new HorizontalLayout(); availableOperations.setSpacing(true); addGivenComponents(availableOperations, checkBtn, destroyBtn); addStyleName(checkBtn, destroyBtn, availableOperations); table.addItem( new Object[] { containerHost.getHostname(), containerHost.getIpByInterfaceName("eth0"), filterNodeRole(NodeType.ACCUMULO_TRACER.name()), resultHolder, availableOperations }, null); checkBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { PROGRESS_ICON.setVisible(true); disableButtons(checkBtn, destroyBtn); executorService.execute(new CheckTask(accumulo, tracker, accumuloClusterConfig.getClusterName(), containerHost.getHostname(), new CompleteEvent() { public void onComplete(String result) { synchronized (PROGRESS_ICON) { resultHolder.setValue(parseStatus(result, NodeType.ACCUMULO_TRACER)); enableButtons(checkBtn, destroyBtn); PROGRESS_ICON.setVisible(false); } } })); } }); destroyBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (accumuloClusterConfig.getTracers().size() == 1) { show("This is last tracer node in cluster, please destroy whole cluster"); return; } ConfirmationDialog alert = new ConfirmationDialog( String.format("Do you want to destroy the %s node?", containerHost.getHostname()), "Yes", "No"); alert.getOk().addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { UUID trackID = accumulo.destroyNode(accumuloClusterConfig.getClusterName(), containerHost.getHostname(), NodeType.ACCUMULO_TRACER); ProgressWindow window = new ProgressWindow(executorService, tracker, trackID, AccumuloClusterConfig.PRODUCT_KEY); window.getWindow().addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent closeEvent) { refreshClustersInfo(); } }); contentRoot.getUI().addWindow(window.getWindow()); } }); contentRoot.getUI().addWindow(alert.getAlert()); } }); } }
From source file:io.subutai.plugin.accumulo.ui.manager.Manager.java
private void populateTabletServersTable(final Table table, Set<EnvironmentContainerHost> containerHosts, final boolean masters) { table.removeAllItems();//w w w . j a v a2s .c o m for (final EnvironmentContainerHost containerHost : containerHosts) { final Button checkBtn = new Button(CHECK_BUTTON_CAPTION); checkBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloCheck"); final Button destroyBtn = new Button(DESTROY_BUTTON_CAPTION); destroyBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloDestroy"); final Label resultHolder = new Label(); resultHolder.setId(containerHost.getIpByInterfaceName("eth0") + "accumuloResult"); HorizontalLayout availableOperations = new HorizontalLayout(); availableOperations.setSpacing(true); addGivenComponents(availableOperations, checkBtn, destroyBtn); addStyleName(checkBtn, destroyBtn, availableOperations); table.addItem(new Object[] { containerHost.getHostname(), containerHost.getIpByInterfaceName("eth0"), filterNodeRole(NodeType.ACCUMULO_TABLET_SERVER.name()), resultHolder, availableOperations }, null); checkBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { PROGRESS_ICON.setVisible(true); disableButtons(checkBtn, destroyBtn); executorService.execute(new CheckTask(accumulo, tracker, accumuloClusterConfig.getClusterName(), containerHost.getHostname(), new CompleteEvent() { public void onComplete(String result) { synchronized (PROGRESS_ICON) { resultHolder.setValue(parseStatus(result, NodeType.ACCUMULO_TABLET_SERVER)); enableButtons(checkBtn, destroyBtn); PROGRESS_ICON.setVisible(false); } } })); } }); destroyBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (accumuloClusterConfig.getSlaves().size() == 1) { show("This is last tablet server in cluster, please destroy whole cluster"); return; } ConfirmationDialog alert = new ConfirmationDialog( String.format("Do you want to destroy the %s node?", containerHost.getHostname()), "Yes", "No"); alert.getOk().addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { UUID trackID = accumulo.destroyNode(accumuloClusterConfig.getClusterName(), containerHost.getHostname(), NodeType.ACCUMULO_TABLET_SERVER); ProgressWindow window = new ProgressWindow(executorService, tracker, trackID, AccumuloClusterConfig.PRODUCT_KEY); window.getWindow().addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent closeEvent) { refreshClustersInfo(); } }); contentRoot.getUI().addWindow(window.getWindow()); } }); contentRoot.getUI().addWindow(alert.getAlert()); } }); } }