List of usage examples for com.vaadin.ui Button addStyleName
@Override public void addStyleName(String style)
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * construye el menu//from w w w. j a v a 2s . c om * * @param request * @return */ CssLayout buildMenu(VaadinRequest request) { HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName(ValoTheme.MENU_TITLE); menu.addComponent(top); //menu.addComponent(createThemeSelect()); Button showMenu = new Button("Menu", new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (menu.getStyleName().contains("valo-menu-visible")) { menu.removeStyleName("valo-menu-visible"); } else { menu.addStyleName("valo-menu-visible"); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName("valo-menu-toggle"); showMenu.setIcon(FontAwesome.LIST); menu.addComponent(showMenu); //Label title = new Label("<h3><strong>" + getApp().getName() + "</strong></h3>", ContentMode.HTML); Button title = new Button(getApp().getName(), new ClickListener() { @Override public void buttonClick(ClickEvent event) { Page.getCurrent().open("#!", (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName()); } }); title.addStyleName(ValoTheme.BUTTON_LINK); title.addStyleName("tituloapp"); title.setSizeUndefined(); top.addComponent(title); top.setExpandRatio(title, 1); settings = new MenuBar(); settings.addStyleName("user-menu"); settings.addStyleName("mi-user-menu"); menu.addComponent(settings); HorizontalLayout navlinks = new HorizontalLayout(); navlinks.setSpacing(true); { Button nav = new Button(VaadinIcons.ARROWS_CROSS, new ClickListener() { @Override public void buttonClick(ClickEvent event) { Page.getCurrent().open("#!nav", (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName()); } }); nav.addStyleName(ValoTheme.BUTTON_LINK); nav.setDescription("Search inside menu"); nav.addStyleName("navlink"); navlinks.addComponent(nav); } if (MateuUI.getApp().isFavouritesAvailable()) { Button nav = new Button(VaadinIcons.USER_STAR, new ClickListener() { @Override public void buttonClick(ClickEvent event) { Page.getCurrent().open("#!favourites", (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName()); } }); nav.addStyleName(ValoTheme.BUTTON_LINK); nav.addStyleName("navlink"); nav.setDescription("My favourites"); nav.setVisible(MateuUI.getApp().getUserData() != null); linkFavoritos = nav; navlinks.addComponent(nav); } if (MateuUI.getApp().isLastEditedAvailable()) { Button nav = new Button(VaadinIcons.RECORDS, new ClickListener() { @Override public void buttonClick(ClickEvent event) { Page.getCurrent().open("#!lastedited", (event.isAltKey() || event.isCtrlKey()) ? "_blank" : Page.getCurrent().getWindowName()); } }); nav.addStyleName(ValoTheme.BUTTON_LINK); nav.addStyleName("navlink"); nav.setDescription("Last edited records"); nav.setVisible(MateuUI.getApp().getUserData() != null); linkUltimosRegistros = nav; navlinks.addComponent(nav); } HorizontalLayout aux = new HorizontalLayout(navlinks); aux.setSpacing(false); aux.addStyleName("contenedoriconosnav"); menu.addComponent(aux); if (MateuUI.getApp().isFavouritesAvailable()) { aux = new HorizontalLayout(); { Button nav = new Button(VaadinIcons.STAR, new ClickListener() { @Override public void buttonClick(ClickEvent event) { System.out.println(Page.getCurrent().getUriFragment()); System.out.println(Page.getCurrent().getLocation()); } }); nav.addStyleName(ValoTheme.BUTTON_LINK); nav.addStyleName("navlink"); nav.setDescription("Add current page to my favourites"); nav.setVisible(MateuUI.getApp().getUserData() != null); linkNuevoFavorito = nav; aux.addComponent(nav); } aux.setSpacing(false); aux.addStyleName("contenedoriconosnav"); menu.addComponent(aux); } menuItemsLayout.setPrimaryStyleName("valo-menuitems"); menu.addComponent(menuItemsLayout); refreshMenu(null, null); return menu; }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * construye el men/*from w ww .j av a 2 s .c o m*/ */ public void refreshMenu(AbstractArea area, MenuEntry menu) { if (area != null && area.equals(getAreaActual())) { // no cambia el area. Solo puede cambiar el menu if ((menu == null && getMenuActual() == null) || (menu != null && menu.equals(getMenuActual()))) { // no cambia nada. no hacemos nada } else { setMenuActual(menu); } } else { // cambia el area. debemos reconstruir el menu setAreaActual(area); VaadinSession s = VaadinSession.getCurrent(); boolean autentico = s.getAttribute("usuario") != null; List<AbstractArea> areas = new ArrayList<>(); for (AbstractArea a : getApp().getAreas()) { if (autentico) { if (!a.isPublicAccess()) { if (area == null) area = a; areas.add(a); } } else { if (!getApp().isAuthenticationNeeded() || a.isPublicAccess()) { if (area == null) area = a; areas.add(a); } } } menuItemsLayout.removeAllComponents(); /** * area no puede ser null */ if (area != null) { divIndicadorAreaActual = new VerticalLayout(); divIndicadorAreaActual.setSpacing(false); divIndicadorAreaActual.addStyleName("divIndicadorAreaActual"); if (areas.size() > 1) { Button b; AbstractArea finalArea = area; divIndicadorAreaActual .addComponent(b = new Button("You are at " + ((area != null) ? area.getName() : "--"), new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { navigator.navigateTo(getApp().getAreaId(finalArea) + "/changearea"); } })); b.addStyleName(ValoTheme.BUTTON_LINK); b.addStyleName("linkotrasareas"); menuItemsLayout.addComponent(divIndicadorAreaActual); } buildMenuOptions(area); } setMenuActual(menu); } }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * are el dilogo para autenticarse//from w w w . j av a2 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 * */// w ww.j a va2s. 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 w w . j a va 2s . co 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 av a 2 s. c om*/ * * */ 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.wizard.ConfigurationStep.java
public ConfigurationStep(final Accumulo accumulo, final Hadoop hadoop, final Zookeeper zookeeper, final EnvironmentManager environmentManager, final Wizard wizard) { this.environmentManager = environmentManager; this.wizard = wizard; this.hadoop = hadoop; this.zookeeper = zookeeper; this.accumulo = accumulo; if (wizard.getConfig().getSetupType() == SetupType.OVER_HADOOP_N_ZK) { //hadoop combo final ComboBox hadoopClustersCombo = getCombo("Hadoop cluster"); hadoopClustersCombo.setId("hadoopClusterscb"); //zookeeper combo final ComboBox zkClustersCombo = getCombo("Zookeeper cluster"); zkClustersCombo.setId("zkClustersCombo"); //master nodes final ComboBox masterNodeCombo = getCombo("Master node"); masterNodeCombo.setId("masterNodeCombo"); final ComboBox gcNodeCombo = getCombo("GC node"); gcNodeCombo.setId("gcNodeCombo"); final ComboBox monitorNodeCombo = getCombo("Monitor node"); monitorNodeCombo.setId("monitorNodeCombo"); //accumulo init controls TextField clusterNameTxtFld = getTextField("Cluster name", "Cluster name", 20); clusterNameTxtFld.setId("clusterNameTxtFld"); TextField instanceNameTxtFld = getTextField("Instance name", "Instance name", 20); instanceNameTxtFld.setId("instanceNameTxtFld"); TextField passwordTxtFld = getTextField("Password", "Password", 20); passwordTxtFld.setId("passwordTxtFld"); //tracers final TwinColSelect tracersSelect = getTwinSelect("Tracers", "hostname", "Available Nodes", "Selected Nodes", 4); tracersSelect.setId("TracersSelect"); //slave nodes final TwinColSelect slavesSelect = getTwinSelect("Slaves", "hostname", "Available Nodes", "Selected Nodes", 4); slavesSelect.setId("SlavesSelect"); //get existing hadoop clusters List<HadoopClusterConfig> hadoopClusters = hadoop.getClusters(); //fill hadoopClustersCombo with hadoop cluster infos for (HadoopClusterConfig hadoopClusterInfo : hadoopClusters) { hadoopClustersCombo.addItem(hadoopClusterInfo); hadoopClustersCombo.setItemCaption(hadoopClusterInfo, hadoopClusterInfo.getClusterName()); }// ww w . j a va2s .co m //try to find hadoop cluster info based on one saved in the configuration if (wizard.getConfig().getHadoopClusterName() != null) { hadoop.getCluster(wizard.getConfig().getHadoopClusterName()); } //select if saved found if (!hadoopClusters.isEmpty()) { //select first one if saved not found hadoopClustersCombo.setValue(hadoopClusters.iterator().next()); fillZookeeperComboBox(zkClustersCombo, zookeeper, hadoopClusters.iterator().next().getEnvironmentId()); } // fill selection controls with hadoop nodes if (hadoopClustersCombo.getValue() != null) { HadoopClusterConfig hadoopInfo = (HadoopClusterConfig) hadoopClustersCombo.getValue(); wizard.getConfig().setHadoopClusterName(hadoopInfo.getClusterName()); setComboDS(masterNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setComboDS(gcNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setComboDS(monitorNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setTwinSelectDS(tracersSelect, getSlaveContainerHosts(Sets.newHashSet(hadoopInfo.getAllNodes()))); setTwinSelectDS(slavesSelect, getSlaveContainerHosts(Sets.newHashSet(hadoopInfo.getAllNodes()))); } //on hadoop cluster change reset all controls and config hadoopClustersCombo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { HadoopClusterConfig hadoopInfo = (HadoopClusterConfig) event.getProperty().getValue(); //reset relevant controls setComboDS(masterNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setComboDS(gcNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setComboDS(monitorNodeCombo, hadoopInfo.getAllNodes(), new HashSet<String>()); setTwinSelectDS(tracersSelect, getSlaveContainerHosts(Sets.newHashSet(hadoopInfo.getAllNodes()))); setTwinSelectDS(slavesSelect, getSlaveContainerHosts(Sets.newHashSet(hadoopInfo.getAllNodes()))); //reset relevant properties wizard.getConfig().setMasterNode(null); wizard.getConfig().setGcNode(null); wizard.getConfig().setMonitor(null); wizard.getConfig().setTracers(null); wizard.getConfig().setSlaves(null); wizard.getConfig().setHadoopClusterName(hadoopInfo.getClusterName()); fillZookeeperComboBox(zkClustersCombo, zookeeper, hadoopInfo.getEnvironmentId()); } } }); //restore master node if back button is pressed if (wizard.getConfig().getMasterNode() != null) { masterNodeCombo.setValue(wizard.getConfig().getMasterNode()); } //restore gc node if back button is pressed if (wizard.getConfig().getGcNode() != null) { gcNodeCombo.setValue(wizard.getConfig().getGcNode()); } //restore monitor node if back button is pressed if (wizard.getConfig().getMonitor() != null) { monitorNodeCombo.setValue(wizard.getConfig().getMonitor()); } //add value change handler masterNodeCombo.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { String masterNode = (String) event.getProperty().getValue(); wizard.getConfig().setMasterNode(masterNode); } } }); //add value change handler gcNodeCombo.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { String gcNode = (String) event.getProperty().getValue(); wizard.getConfig().setGcNode(gcNode); } } }); //add value change handler monitorNodeCombo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { String monitor = (String) event.getProperty().getValue(); wizard.getConfig().setMonitor(monitor); } } }); //restore tracers if back button is pressed if (!CollectionUtil.isCollectionEmpty(wizard.getConfig().getTracers())) { tracersSelect.setValue(wizard.getConfig().getTracers()); } //restore slaves if back button is pressed if (!CollectionUtil.isCollectionEmpty(wizard.getConfig().getSlaves())) { slavesSelect.setValue(wizard.getConfig().getSlaves()); } clusterNameTxtFld.setValue(wizard.getConfig().getInstanceName()); clusterNameTxtFld.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { wizard.getConfig().setClusterName(event.getProperty().getValue().toString().trim()); } }); instanceNameTxtFld.setValue(wizard.getConfig().getInstanceName()); instanceNameTxtFld.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { wizard.getConfig().setInstanceName(event.getProperty().getValue().toString().trim()); } }); passwordTxtFld.setValue(wizard.getConfig().getPassword()); passwordTxtFld.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { wizard.getConfig().setPassword(event.getProperty().getValue().toString().trim()); } }); //add value change handler tracersSelect.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { Set<String> nodes = new HashSet<>(); Set<EnvironmentContainerHost> nodeList = (Set<EnvironmentContainerHost>) event.getProperty() .getValue(); for (EnvironmentContainerHost host : nodeList) { nodes.add(host.getId()); } wizard.getConfig().setTracers(nodes); } } }); //add value change handler slavesSelect.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { Set<String> nodes = new HashSet<>(); Set<EnvironmentContainerHost> nodeList = (Set<EnvironmentContainerHost>) event.getProperty() .getValue(); for (EnvironmentContainerHost host : nodeList) { nodes.add(host.getId()); } wizard.getConfig().setSlaves(nodes); } } }); Button next = new Button("Next"); next.setId("confNext2"); next.addStyleName("default"); //check valid configuration next.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (Strings.isNullOrEmpty(wizard.getConfig().getClusterName())) { show("Please, enter cluster name"); } else if (Strings.isNullOrEmpty(wizard.getConfig().getZookeeperClusterName())) { show("Please, select Zookeeper cluster"); } else if (Strings.isNullOrEmpty(wizard.getConfig().getHadoopClusterName())) { show("Please, select Hadoop cluster"); } else if (wizard.getConfig().getMasterNode() == null) { show("Please, select master node"); } else if (Strings.isNullOrEmpty(wizard.getConfig().getInstanceName())) { show("Please, specify instance name"); } else if (Strings.isNullOrEmpty(wizard.getConfig().getPassword())) { show("Please, specify password"); } else if (wizard.getConfig().getGcNode() == null) { show("Please, select gc node"); } else if (wizard.getConfig().getMonitor() == null) { show("Please, select monitor"); } else if (CollectionUtil.isCollectionEmpty(wizard.getConfig().getTracers())) { show("Please, select tracer(s)"); } else if (CollectionUtil.isCollectionEmpty(wizard.getConfig().getSlaves())) { show("Please, select slave(s)"); } else { wizard.next(); } } }); Button back = new Button("Back"); back.setId("confBack2"); back.addStyleName("default"); back.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { wizard.back(); } }); setSizeFull(); VerticalLayout content = new VerticalLayout(); content.setSizeFull(); content.setSpacing(true); content.setMargin(true); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.addComponent(new Label("Please, specify installation settings")); layout.addComponent(content); HorizontalLayout masters = new HorizontalLayout(); masters.setMargin(new MarginInfo(true, false, false, false)); masters.setSpacing(true); masters.addComponent(hadoopClustersCombo); masters.addComponent(zkClustersCombo); masters.addComponent(masterNodeCombo); masters.addComponent(gcNodeCombo); masters.addComponent(monitorNodeCombo); HorizontalLayout credentials = new HorizontalLayout(); credentials.setMargin(new MarginInfo(true, false, false, false)); credentials.setSpacing(true); credentials.addComponent(clusterNameTxtFld); credentials.addComponent(instanceNameTxtFld); credentials.addComponent(passwordTxtFld); HorizontalLayout buttons = new HorizontalLayout(); buttons.setMargin(new MarginInfo(true, false, false, false)); buttons.setSpacing(true); buttons.addComponent(back); buttons.addComponent(next); content.addComponent(masters); content.addComponent(credentials); content.addComponent(tracersSelect); content.addComponent(slavesSelect); content.addComponent(buttons); setContent(layout); } }
From source file:io.subutai.plugin.accumulo.ui.wizard.VerificationStep.java
public VerificationStep(final Accumulo accumulo, final Hadoop hadoop, final ExecutorService executorService, final Tracker tracker, EnvironmentManager environmentManager, final Wizard wizard) { setSizeFull();/* w w w. j a v a2 s. com*/ GridLayout grid = new GridLayout(1, 5); grid.setSpacing(true); grid.setMargin(true); grid.setSizeFull(); Label confirmationLbl = new Label("<strong>Please verify the installation settings " + "(you may change them by clicking on Back button)</strong><br/>"); confirmationLbl.setContentMode(ContentMode.HTML); ConfigView cfgView = new ConfigView("Installation configuration"); cfgView.addStringCfg("Cluster Name", wizard.getConfig().getClusterName()); cfgView.addStringCfg("Instance name", wizard.getConfig().getInstanceName()); cfgView.addStringCfg("Password", wizard.getConfig().getPassword()); cfgView.addStringCfg("Hadoop cluster", wizard.getConfig().getHadoopClusterName()); cfgView.addStringCfg("Zookeeper cluster", wizard.getConfig().getZookeeperClusterName()); if (wizard.getConfig().getSetupType() == SetupType.OVER_HADOOP_N_ZK) { try { Environment hadoopEnvironment = environmentManager.loadEnvironment( hadoop.getCluster(wizard.getConfig().getHadoopClusterName()).getEnvironmentId()); EnvironmentContainerHost master = hadoopEnvironment .getContainerHostById(wizard.getConfig().getMasterNode()); EnvironmentContainerHost gc = hadoopEnvironment .getContainerHostById(wizard.getConfig().getGcNode()); EnvironmentContainerHost monitor = hadoopEnvironment .getContainerHostById(wizard.getConfig().getMonitor()); Set<EnvironmentContainerHost> tracers = hadoopEnvironment .getContainerHostsByIds(wizard.getConfig().getTracers()); Set<EnvironmentContainerHost> slaves = hadoopEnvironment .getContainerHostsByIds(wizard.getConfig().getSlaves()); cfgView.addStringCfg("Master node", master.getHostname()); cfgView.addStringCfg("GC node", gc.getHostname()); cfgView.addStringCfg("Monitor node", monitor.getHostname()); for (EnvironmentContainerHost containerHost : tracers) { cfgView.addStringCfg("Tracers", containerHost.getHostname()); } for (EnvironmentContainerHost containerHost : slaves) { cfgView.addStringCfg("Slaves", containerHost.getHostname()); } } catch (EnvironmentNotFoundException | ContainerHostNotFoundException e) { LOGGER.error("Error applying operations on environment/container", e); } } else { cfgView.addStringCfg("Number of Hadoop slaves", wizard.getHadoopClusterConfig().getCountOfSlaveNodes() + ""); cfgView.addStringCfg("Hadoop replication factor", wizard.getHadoopClusterConfig().getReplicationFactor() + ""); cfgView.addStringCfg("Hadoop domain name", wizard.getHadoopClusterConfig().getDomainName() + ""); cfgView.addStringCfg("Number of tracers", wizard.getConfig().getNumberOfTracers() + ""); cfgView.addStringCfg("Number of slaves", wizard.getConfig().getNumberOfSlaves() + ""); } Button install = new Button("Install"); install.setId("installBtn"); install.addStyleName("default"); install.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UUID trackID; if (wizard.getConfig().getSetupType() == SetupType.OVER_HADOOP_N_ZK) { trackID = accumulo.installCluster(wizard.getConfig()); } else { trackID = accumulo.installCluster(wizard.getConfig()); } ProgressWindow window = new ProgressWindow(executorService, tracker, trackID, AccumuloClusterConfig.PRODUCT_KEY); window.getWindow().addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent closeEvent) { wizard.init(); } }); getUI().addWindow(window.getWindow()); } }); Button back = new Button("Back"); back.setId("verBack"); back.addStyleName("default"); back.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { wizard.back(); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.addComponent(back); buttons.addComponent(install); grid.addComponent(confirmationLbl, 0, 0); grid.addComponent(cfgView.getCfgTable(), 0, 1, 0, 3); grid.addComponent(buttons, 0, 4); setContent(grid); }
From source file:io.subutai.plugin.accumulo.ui.wizard.WelcomeStep.java
public WelcomeStep(final Wizard wizard) { setSizeFull();/*from w ww .j a va 2 s.c o m*/ GridLayout grid = new GridLayout(10, 6); grid.setSpacing(true); grid.setMargin(true); grid.setSizeFull(); Label welcomeMsg = new Label("<center><h2>Welcome to Accumulo Installation Wizard!</h2>"); welcomeMsg.setContentMode(ContentMode.HTML); grid.addComponent(welcomeMsg, 3, 1, 6, 2); Label logoImg = new Label(); // Image as a file resource logoImg.setIcon(new FileResource(FileUtil.getFile(AccumuloPortalModule.MODULE_IMAGE, this))); logoImg.setContentMode(ContentMode.HTML); logoImg.setHeight(56, Unit.PIXELS); logoImg.setWidth(220, Unit.PIXELS); grid.addComponent(logoImg, 1, 3, 2, 5); Button startOverHadoopNZK = new Button("Start over Hadoop & ZK installation"); startOverHadoopNZK.setId("startOverHadoopNZK"); startOverHadoopNZK.addStyleName("default"); grid.addComponent(startOverHadoopNZK, 4, 4, 4, 4); grid.setComponentAlignment(startOverHadoopNZK, Alignment.BOTTOM_RIGHT); startOverHadoopNZK.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { wizard.init(); wizard.getConfig().setSetupType(SetupType.OVER_HADOOP_N_ZK); wizard.next(); } }); setContent(grid); }
From source file:it.vige.greenarea.bpm.custom.ui.form.GreenareaAbstractFormPropertyRenderer.java
License:Apache License
protected void addButton(String operation, HorizontalLayout buttons, final String item, final Table table) { final String finalOperation = operation; final Button button = new Button(); if (operation.equals(MODIFICA.name())) button.setIcon(new ThemeResource("img/edit.png")); else if (operation.equals(CANCELLAZIONE.name())) button.setIcon(new ThemeResource("img/delete.png")); else// w w w . j a va 2 s . c o m button.setIcon(new ThemeResource("img/task-16.png")); button.addStyleName(BUTTON_LINK); I18nManager i18nManager = get().getI18nManager(); button.setDescription(i18nManager.getMessage(operation)); buttons.addComponent(button); buttons.setComponentAlignment(button, BOTTOM_RIGHT); button.addListener(new ClickListener() { private static final long serialVersionUID = -6091586145870618870L; public void buttonClick(ClickEvent event) { // Extract the submitted values from the form. Throws // exception // when validation fails. try { table.select(item); Map<String, String> formProperties = greenareaFormPropertiesForm .getGreenareaFormPropertiesComponent().getFormPropertyValues(); setOperation(formProperties, finalOperation); greenareaFormPropertiesForm.getMainTitle() .setPropertyDataSource(new ObjectProperty<String>( greenareaFormPropertiesForm.getMainTitle().getValue() + " > " + finalOperation, String.class)); FormPropertiesEvent formPropertiesEvent = greenareaFormPropertiesForm.new FormPropertiesEvent( greenareaFormPropertiesForm, TYPE_SUBMIT, formProperties); greenareaFormPropertiesForm.fireEvent(formPropertiesEvent); button.setComponentError(null); } catch (InvalidValueException ive) { // Error is presented to user by the form component } } }); }