List of usage examples for com.vaadin.ui Button setDescription
public void setDescription(String description)
From source file:com.purebred.core.view.SearchForm.java
License:Open Source License
@Override protected void createFooterButtons(HorizontalLayout footerLayout) { footerLayout.setSpacing(true);/*from w w w . j a va2 s . c o m*/ footerLayout.setMargin(true); Button clearButton = new Button(uiMessageSource.getMessage("entitySearchForm.clear"), this, "clear"); clearButton.setDescription(uiMessageSource.getMessage("entitySearchForm.clear.description")); clearButton.setIcon(new ThemeResource("icons/16/clear.png")); clearButton.addStyleName("small default"); footerLayout.addComponent(clearButton); // alignment doesn't work // footerLayout.setComponentAlignment(clearButton, Alignment.MIDDLE_RIGHT); Button searchButton = new Button(uiMessageSource.getMessage("entitySearchForm.search"), this, "search"); searchButton.setDescription(uiMessageSource.getMessage("entitySearchForm.search.description")); searchButton.setIcon(new ThemeResource("icons/16/search.png")); searchButton.addStyleName("small default"); footerLayout.addComponent(searchButton); // footerLayout.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT); }
From source file:com.skysql.manager.ui.OverviewPanel.java
License:Open Source License
/** * Instantiates a new overview panel.//from ww w. j a v a 2 s . co m */ public OverviewPanel() { HorizontalLayout overviewContainer = new HorizontalLayout(); overviewContainer.addStyleName("overviewPanel"); overviewContainer.setWidth("100%"); setContent(overviewContainer); systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); systemRecord = systemInfo.getCurrentSystem(); systemLayout = new SystemLayout(systemRecord); overviewContainer.addComponent(systemLayout); VerticalLayout nodesSlot = new VerticalLayout(); nodesSlot.addStyleName("nodesSlot"); nodesSlot.setMargin(new MarginInfo(false, false, false, false)); overviewContainer.addComponent(nodesSlot); overviewContainer.setExpandRatio(nodesSlot, 1.0f); final HorizontalLayout nodesHeader = new HorizontalLayout(); nodesHeader.setStyleName("panelHeaderLayout"); nodesHeader.setWidth("100%"); nodesSlot.addComponent(nodesHeader); nodesLabel = new Label(" "); nodesLabel.setSizeUndefined(); nodesHeader.addComponent(nodesLabel); nodesHeader.setComponentAlignment(nodesLabel, Alignment.MIDDLE_CENTER); nodesHeader.setExpandRatio(nodesLabel, 1.0f); final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(new MarginInfo(false, true, false, false)); nodesHeader.addComponent(buttonsLayout); nodesHeader.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT); addSystemButton = new Button("Add System..."); addSystemButton.setDescription("Add System"); addSystemButton.setVisible(false); buttonsLayout.addComponent(addSystemButton); addSystemButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new SystemDialog(null, null); } }); addNodeButton = new Button("Add Node..."); addNodeButton.setDescription("Add Node to the current System"); addNodeButton.setVisible(false); buttonsLayout.addComponent(addNodeButton); addNodeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new NodeDialog(null, null); } }); final Button editButton = new Button("Edit"); editButton.setDescription("Enter Editing mode"); final Button saveButton = new Button("Done"); saveButton.setDescription("Exit Editing mode"); buttonsLayout.addComponent(editButton); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(editButton, saveButton); isEditable = true; systemLayout.setEditable(true); nodesLayout.setEditable(true); nodesHeader.setStyleName("panelHeaderLayout-editable"); if (systemRecord != null && !SystemInfo.SYSTEM_ROOT.equals(systemRecord.getID())) { addNodeButton.setVisible(true); } else { addSystemButton.setVisible(true); } if (systemRecord == null || (systemRecord != null && systemRecord.getNodes().length == 0)) { nodesLayout.placeholderLayout(null); } } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(saveButton, editButton); isEditable = false; systemLayout.setEditable(false); nodesLayout.setEditable(false); nodesHeader.setStyleName("panelHeaderLayout"); if (systemRecord != null && systemRecord.getNodes().length == 0) { nodesLayout.placeholderLayout(null); } addNodeButton.setVisible(false); addSystemButton.setVisible(false); } }); Panel panel = new Panel(); panel.setHeight(PANEL_HEIGHT, Unit.PIXELS); panel.addStyleName(Runo.PANEL_LIGHT); nodesSlot.addComponent(panel); nodesLayout = new NodesLayout(systemRecord); nodesLayout.addStyleName("nodesLayout"); nodesLayout.setWidth("100%"); panel.setContent(nodesLayout); }
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the charts layout.//from w ww . j av a 2s. c om */ private void createChartsLayout() { chartsLayout = new VerticalLayout(); chartsLayout.addStyleName("chartsLayout"); chartsLayout.setHeight("100%"); chartsLayout.setSpacing(true); addComponent(chartsLayout); final HorizontalLayout chartsHeaderLayout = new HorizontalLayout(); chartsHeaderLayout.setStyleName("panelHeaderLayout"); chartsHeaderLayout.setWidth("100%"); chartsHeaderLayout.setSpacing(true); chartsHeaderLayout.setMargin(new MarginInfo(false, true, false, true)); chartsLayout.addComponent(chartsHeaderLayout); chartControls = new ChartControls(); chartControls.addIntervalSelectionListener(chartIntervalListener); chartControls.addThemeSelectionListener(chartThemeListener); chartsHeaderLayout.addComponent(chartControls); chartsHeaderLayout.setComponentAlignment(chartControls, Alignment.MIDDLE_LEFT); final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); chartsHeaderLayout.addComponent(buttonsLayout); chartsHeaderLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT); SettingsDialog settingsDialog = new SettingsDialog("Edit Monitors...", "Monitors"); final Button editMonitorsButton = settingsDialog.getButton(); editMonitorsButton.setVisible(false); buttonsLayout.addComponent(editMonitorsButton); final Button addChartButton = new Button("Add Chart..."); addChartButton.setVisible(false); buttonsLayout.addComponent(addChartButton); addChartButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new ChartsDialog(chartsArrayLayout, null); } }); final Button editButton = new Button("Edit"); editButton.setDescription("Enter Editing mode"); final Button saveButton = new Button("Done"); saveButton.setDescription("Exit Editing mode"); buttonsLayout.addComponent(editButton); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(editButton, saveButton); chartsArrayLayout.setDragMode(LayoutDragMode.CLONE); chartsArrayLayout.setEditable(true); chartsHeaderLayout.setStyleName("panelHeaderLayout-editable"); editMonitorsButton.setVisible(true); addChartButton.setVisible(true); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(false); } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(saveButton, editButton); chartsArrayLayout.setDragMode(LayoutDragMode.NONE); chartsArrayLayout.setEditable(false); chartsHeaderLayout.setStyleName("panelHeaderLayout"); editMonitorsButton.setVisible(false); addChartButton.setVisible(false); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(true); refresh(); } }); final Button expandButton = new NativeButton(); expandButton.setStyleName("expandButton"); expandButton.setDescription("Expand/Reduce viewing area"); buttonsLayout.addComponent(expandButton); buttonsLayout.setComponentAlignment(expandButton, Alignment.MIDDLE_CENTER); expandButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { isExpanded = !isExpanded; AnimatorProxy proxy = getSession().getAttribute(AnimatorProxy.class); proxy.addListener(new AnimationListener() { public void onAnimation(AnimationEvent event) { Component component = event.getComponent(); component.setVisible(isExpanded ? false : true); } }); // OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); // if (!isExpanded) { // overviewPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(overviewPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); // // TopPanel topPanel = getSession().getAttribute(TopPanel.class); // if (!isExpanded) { // topPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(topPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); VerticalLayout topMid = getSession().getAttribute(VerticalLayout.class); if (!isExpanded) { topMid.setVisible(isExpanded ? false : true); } proxy.animate(topMid, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN) .setDuration(500).setDelay(100); expandButton.setStyleName(isExpanded ? "contractButton" : "expandButton"); } }); chartsPanel = new Panel(); chartsPanel.setSizeFull(); chartsPanel.addStyleName(Runo.PANEL_LIGHT); chartsLayout.addComponent(chartsPanel); chartsLayout.setExpandRatio(chartsPanel, 1.0f); }
From source file:com.snowy.Login.java
@PostConstruct void init() {/*from w w w.j av a 2 s.c o m*/ d = ((MyVaadinUI) UI.getCurrent()).getDataObject(); //Logger.getLogger(Login.class.getName()).info(d); this.setSizeFull(); this.setSpacing(false); this.setMargin(true); Label MainL = new Label("<h1>Connect 4</h1?>", ContentMode.HTML); //layout.addComponent(MainL); MainL.setSizeUndefined(); VerticalLayout lay = new VerticalLayout(); lay.setMargin(false); lay.addComponent(MainL); lay.setComponentAlignment(MainL, Alignment.TOP_CENTER); HorizontalLayout hz = new HorizontalLayout(); hz.setMargin(false); hz.setSpacing(false); LoginForm lf = new LoginForm(); lf.addLoginListener((e) -> { String token = d.genToken(e.getLoginParameter("username"), e.getLoginParameter("password")); //String token="true"; if (!token.equals("false")) { Cookie c = new Cookie("token", token); VaadinService.getCurrentResponse().addCookie(c); //https://vaadin.com/wiki/-/wiki/Main/Setting+and+reading+Cookies //Notification.show(VaadinService.getCurrentRequest().getCookies()[1].getValue(),Notification.Type.ERROR_MESSAGE); //this.getNavigator().navigateTo("main"); //this.getUI().get this.getUI().getNavigator().navigateTo("main"); } else { Label l = new Label("<h4 style=\"color:red\">Invalid Username or Password</h4>", ContentMode.HTML); l.setId("created"); if (lay.getComponent(lay.getComponentIndex(lf) + 1).getId() == null) { //lay.addComponent(new Label(String.valueOf(lay.getComponentIndex(l)))); lay.addComponent(l, lay.getComponentIndex(lf) + 1); l.setSizeUndefined(); lay.setComponentAlignment(l, Alignment.TOP_CENTER); } } }); lay.addComponent(lf); Button newUser = new Button("New User"); newUser.addClickListener((e) -> { this.getUI().addWindow(new NewUserSubWindow(d)); }); //newUser.setWidth((float)5.5, Unit.EM); Button forgotPass = new Button("Forgot Password"); //temp forgotPass.addClickListener((e) -> { //Notification.show(, Notification.Type.ERROR_MESSAGE); }); forgotPass.setEnabled(false); forgotPass.setDescription("Feature Disabled, Contact Administrator for Assistance"); //forgotPass.setWidth((float) 8.5,Unit.EM); forgotPass.setStyleName(ValoTheme.BUTTON_LINK); newUser.setStyleName(ValoTheme.BUTTON_LINK); hz.addComponent(newUser); hz.addComponent(forgotPass); lay.addComponent(hz); lay.setComponentAlignment(lf, Alignment.TOP_CENTER); lay.setComponentAlignment(hz, Alignment.MIDDLE_CENTER); this.addComponent(lay); this.setComponentAlignment(lay, Alignment.MIDDLE_CENTER); }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
@SuppressWarnings("unchecked") private void addLinksTable() { container.addContainerProperty("S/N", Integer.class, 0); container.addContainerProperty("Username", String.class, null); container.addContainerProperty("MSISDN", String.class, null); container.addContainerProperty("Email", String.class, null); container.addContainerProperty("Action", Button.class, null); StringBuilder sb = new StringBuilder(); sb.append(/*from w w w.ja v a 2 s.c o m*/ " SELECT concat(ahd.firstname,' ',ahd.lastname) as Name, ah.username as 'username', ah.msisdn as msisdn, ah.email as email "); sb.append(" FROM linkaccountrelations pl, accountholders ah, accountholderdetails ahd "); sb.append(" where linkstatus = 'LINKED' "); sb.append(" and ah.accountholderdetailid = ahd.accountdetailsid "); sb.append(" and pl.childuserresourceid = ah.accountholderid "); sb.append(" and parentuserresourceid in (select accountholderid from accountholders "); sb.append(" where (username = '" + curUser + "'))"); String drivers = "com.mysql.jdbc.Driver"; try { Class<?> driver_class = Class.forName(drivers); Driver driver = (Driver) driver_class.newInstance(); DriverManager.registerDriver(driver); Connection conn = DriverManager.getConnection(MatsWebPortalUI.conf.DB, MatsWebPortalUI.conf.UN, MatsWebPortalUI.conf.PW); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sb.toString()); int x = 0; Property<String> pUn; Property<String> pMsisdn; Property<String> pEmail; Property<Integer> pSn; Property<Button> pBtn; String un; String msisdn; String email; Object rid; Button btnLink; Item r; while (rs.next()) { x++; un = rs.getString("username"); msisdn = rs.getString("msisdn"); email = rs.getString("email"); rid = container.addItem(); r = container.getItem(rid); pSn = r.getItemProperty("S/N"); pUn = r.getItemProperty("Username"); pMsisdn = r.getItemProperty("MSISDN"); pEmail = r.getItemProperty("Email"); pBtn = r.getItemProperty("Action"); btnLink = new Button(); btnLink.setIcon(FontAwesome.UNLINK); btnLink.setStyleName("btn_link"); btnLink.setDescription("Unlink this account."); btnLink.addClickListener(new UNLinkClickHandler()); btnLink.setId(un); btnLink.setData(rid); pSn.setValue(x); pUn.setValue(un); pMsisdn.setValue(msisdn); pEmail.setValue(email); pBtn.setValue(btnLink); } tb.setContainerDataSource(container); if (x > 30) x = 30; tb.setPageLength(x); } catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException e) { errorHandler(e); } }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private void addLinkUserContainer() { VerticalLayout cDeletePrompt = new VerticalLayout(); cPlaceholder.addComponent(cDeletePrompt); cPlaceholder.setComponentAlignment(cDeletePrompt, Alignment.MIDDLE_CENTER); // cDeletePrompt.setWidth("100%"); cDeletePrompt.setStyleName("c_link"); cDeletePrompt.setSpacing(true);// ww w . j a v a 2 s. co m String username = curUser; Label lbActivationPrompt = new Label( "<span style='text-align: center;'>Please enter Child Username to link to " + username + "'s Account</span>"); lbActivationPrompt.setContentMode(ContentMode.HTML); lbActivationPrompt.setWidth("300px"); lbActivationPrompt.setStyleName("lb_link_user"); cDeletePrompt.addComponent(lbActivationPrompt); cDeletePrompt.setComponentAlignment(lbActivationPrompt, Alignment.TOP_LEFT); VerticalLayout frmDeleteReason = new VerticalLayout(); frmDeleteReason.setSizeUndefined(); frmDeleteReason.setSpacing(true); frmDeleteReason.setMargin(true); cDeletePrompt.addComponent(frmDeleteReason); cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.TOP_CENTER); tFU = new TextField("Child Username"); tFU.setRequired(true); final ComboBox comboUProf = new ComboBox("Select Profile"); comboUProf.setNullSelectionAllowed(false); comboUProf.setRequired(true); comboUProf.addItem(8); comboUProf.setItemCaption(8, "DEPOSIT_ONLY"); comboUProf.addItem(9); comboUProf.setItemCaption(9, "DEPOSIT_AND_WITHDRAWAL"); comboUProf.select(8); final TextField tFP = new TextField("Parent Account ID"); tFP.setValue(username); tFP.setEnabled(false); final TextField tFInitUser = new TextField("Initiating User"); tFInitUser.setValue(UI.getCurrent().getSession().getAttribute("user").toString()); tFInitUser.focus(); tFInitUser.setEnabled(false); frmDeleteReason.addComponent(tFU); frmDeleteReason.addComponent(comboUProf); frmDeleteReason.addComponent(tFP); frmDeleteReason.addComponent(tFInitUser); HorizontalLayout cPopupBtns = new HorizontalLayout(); cPopupBtns.setSizeUndefined(); cPopupBtns.setSpacing(true); final Button btnCancel = new Button(); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName("btn_link"); btnCancel.setDescription("Cancel"); final Button btnSet = new Button("Link"); btnSet.setDescription("Link specified account."); btnSet.setIcon(FontAwesome.LINK); cPopupBtns.addComponent(btnSet); cPopupBtns.addComponent(btnCancel); frmDeleteReason.addComponent(cPopupBtns); cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.MIDDLE_CENTER); btnSet.setClickShortcut(KeyCode.ENTER, null); btnSet.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -6318666715385643538L; @Override public void buttonClick(ClickEvent event) { tFU.validate(); btnSet.setEnabled(false); btnCancel.setEnabled(false); Button btn = event.getButton(); if (ums == null) ums = new UserManagementService(); btn.setEnabled(false); String strResponse = null; try { strResponse = UserManagementService.linkUser(tFP.getValue(), new Integer(comboUProf.getValue().toString()), tFInitUser.getValue(), tFU.getValue()); if (strResponse.equals("The operation was successful and completed")) { updateLinksTable(tFU.getValue()); cPlaceholder.setVisible(false); tFU.setValue(""); btnLink.setVisible(true); NotifCustom.show("Link", strResponse); } else { NotifCustom.show("Link", strResponse); } } catch (RemoteException e) { e.printStackTrace(); } btnSet.setEnabled(true); btnCancel.setEnabled(true); } }); btnCancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 7161821652386306043L; @Override public void buttonClick(ClickEvent event) { btnLink.setVisible(true); cPlaceholder.setVisible(false); } }); }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
@SuppressWarnings("unchecked") private void updateLinksTable(String un) { StringBuilder sb = new StringBuilder(); sb.append(//www . ja v a 2 s .c om " SELECT concat(ahd.firstname,' ',ahd.lastname) as Name, ah.username as 'username', ah.msisdn as msisdn, ah.email as email "); sb.append(" FROM linkaccountrelations pl, accountholders ah, accountholderdetails ahd "); sb.append(" where linkstatus = 'LINKED' and username = '" + un + "'"); sb.append(" and ah.accountholderdetailid = ahd.accountdetailsid "); sb.append(" and pl.childuserresourceid = ah.accountholderid"); String drivers = "com.mysql.jdbc.Driver"; try { Class<?> driver_class = Class.forName(drivers); Driver driver = (Driver) driver_class.newInstance(); DriverManager.registerDriver(driver); Connection conn = DriverManager.getConnection(MatsWebPortalUI.conf.DB, MatsWebPortalUI.conf.UN, MatsWebPortalUI.conf.PW); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sb.toString()); Property<String> pUn; Property<String> pMsisdn; Property<String> pEmail; Property<Integer> pSn; Property<Button> pBtn; String msisdn; String email; Object rid; Button btnLink; Item r; while (rs.next()) { int x = container.size() + 1; un = rs.getString("username"); msisdn = rs.getString("msisdn"); email = rs.getString("email"); rid = container.addItem(); r = container.getItem(rid); pSn = r.getItemProperty("S/N"); pUn = r.getItemProperty("Username"); pMsisdn = r.getItemProperty("MSISDN"); pEmail = r.getItemProperty("Email"); pBtn = r.getItemProperty("Action"); btnLink = new Button(); btnLink.setIcon(FontAwesome.UNLINK); btnLink.setStyleName("btn_link"); btnLink.setDescription("Unlink this account."); btnLink.addClickListener(new UNLinkClickHandler()); btnLink.setId(un); btnLink.setData(rid); pSn.setValue(x); pUn.setValue(un); pMsisdn.setValue(msisdn); pEmail.setValue(email); pBtn.setValue(btnLink); } tb.setContainerDataSource(container); int t = container.size(); if (t > 30) t = 30; tb.setPageLength(t); } catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException e) { errorHandler(e); } }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private HorizontalLayout getPC() { VerticalLayout cAgentInfo = new VerticalLayout(); final HorizontalLayout cPlaceholder = new HorizontalLayout(); cAgentInfo.setMargin(new MarginInfo(true, true, true, true)); cAgentInfo.setStyleName("c_details_test"); final VerticalLayout cLBody = new VerticalLayout(); cLBody.setStyleName("c_body_visible"); tb = new Table("Linked child accounts"); // addLinksTable(); final VerticalLayout cAllProf = new VerticalLayout(); HorizontalLayout cProfActions = new HorizontalLayout(); final FormLayout cProfName = new FormLayout(); cProfName.setStyleName("frm_profile_name"); cProfName.setSizeUndefined();// ww w. j a va2 s . co m final Label lbProf = new Label(); final TextField tFProf = new TextField(); lbProf.setCaption("Profile Name: "); lbProf.setValue("Certified Authorized User."); tFProf.setCaption(lbProf.getCaption()); cProfName.addComponent(lbProf); final Button btnEdit = new Button(); btnEdit.setIcon(FontAwesome.EDIT); btnEdit.setStyleName("btn_link"); btnEdit.setDescription("Edit profile name"); final Button btnCancel = new Button(); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName("btn_link"); btnCancel.setDescription("Cancel Profile name editting."); Button btnAdd = new Button("+"); // btnAdd.setIcon(FontAwesome.EDIT); btnAdd.setStyleName("btn_link"); btnAdd.setDescription("Set new profile"); Button btnRemove = new Button("-"); // btnRemove.setIcon(FontAwesome.EDIT); btnRemove.setStyleName("btn_link"); btnRemove.setDescription("Remove current profile"); // cProf.addComponent(cProfName); cProfActions.addComponent(btnEdit); cProfActions.addComponent(btnCancel); cProfActions.addComponent(btnAdd); cProfActions.addComponent(btnRemove); btnCancel.setVisible(false); cAllProf.addComponent(cProfName); cAllProf.addComponent(cProfActions); cAllProf.setComponentAlignment(cProfActions, Alignment.TOP_CENTER); cLBody.addComponent(cAllProf); // cLBody.addComponent(tb); tb.setSelectable(true); cAgentInfo.addComponent(cLBody); btnLink = new Button("Add New Link"); btnLink.setIcon(FontAwesome.LINK); btnLink.setDescription("Link new account."); // cLBody.addComponent(btnLink); // cLBody.setComponentAlignment(btnLink, Alignment.TOP_LEFT); btnLink.addClickListener(new LinkClickHandler()); cPlaceholder.setVisible(false); addLinkUserContainer(); cPlaceholder.setWidth("100%"); cLBody.addComponent(cPlaceholder); cLBody.setComponentAlignment(cPlaceholder, Alignment.TOP_CENTER); HorizontalLayout c = new HorizontalLayout(); c.addComponent(cAgentInfo); btnEdit.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -8427226211153164650L; @Override public void buttonClick(ClickEvent event) { if (btnEdit.getIcon().equals(FontAwesome.EDIT)) { tFProf.setValue(lbProf.getValue()); tFProf.selectAll(); cProfName.replaceComponent(lbProf, tFProf); btnEdit.setIcon(FontAwesome.SAVE); btnCancel.setVisible(true); return; } else if (btnEdit.getIcon().equals(FontAwesome.SAVE)) { lbProf.setValue(tFProf.getValue()); cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); return; } lbProf.setValue(tFProf.getValue()); cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); } }); btnCancel.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -2870045546205986347L; @Override public void buttonClick(ClickEvent event) { cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); } }); btnAdd.addClickListener(new AddProfileHandler(cAllProf, cPlaceholder)); btnRemove.addClickListener(new RemoveProfileHandler(pop)); return c; }
From source file:com.trivago.mail.pigeon.web.components.groups.ActionButtonColumnGenerator.java
License:Apache License
@Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout hl = new HorizontalLayout(); final Button showMembersButton = new Button(); showMembersButton.setIcon(new ThemeResource("../runo/icons/16/users.png")); showMembersButton.setDescription("Show recipients in this group"); showMembersButton.setImmediate(true); final Button deleteButton = new Button(); deleteButton.setIcon(new ThemeResource("../runo/icons/16/trash.png")); deleteButton.setDescription("Delete group and all users in it."); deleteButton.setImmediate(true);// w w w . j ava2 s. c om final Button csvImportButton = new Button(); csvImportButton.setIcon(new ThemeResource("../runo/icons/16/folder.png")); csvImportButton.setDescription("Import CSV file of users into this group"); csvImportButton.setImmediate(true); final Button refreshButton = new Button(); refreshButton.setIcon(new ThemeResource("../runo/icons/16/reload.png")); refreshButton.setDescription("Refresh the recipient count in this group (e.g. after an import)"); refreshButton.setImmediate(true); showMembersButton.setData(itemId); deleteButton.setData(itemId); csvImportButton.setData(itemId); refreshButton.setData(itemId); csvImportButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ModalRecipientImportCsv modalNewWindow = new ModalRecipientImportCsv( (Long) event.getButton().getData()); event.getButton().getWindow().addWindow(modalNewWindow); modalNewWindow.setVisible(true); } }); refreshButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { source.removeGeneratedColumn("memberNumber"); source.addGeneratedColumn("memberNumber", new GroupColumnGenerator()); source.removeGeneratedColumn("Actions"); source.addGeneratedColumn("Actions", new ActionButtonColumnGenerator()); } }); showMembersButton.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { long itemId = (Long) event.getButton().getData(); ModalRecipientList rlist = new ModalRecipientList(itemId); source.getWindow().addWindow(rlist); rlist.setVisible(true); } }); deleteButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Transaction tx = ConnectionFactory.getDatabase().beginTx(); try { RecipientGroup r = new RecipientGroup((Long) itemId); ConnectionFactory.getGroupIndex().remove(r.getDataNode()); for (Relationship rs : r.getDataNode().getRelationships()) { rs.delete(); } r.getDataNode().delete(); source.removeItem(itemId); source.getWindow().showNotification("Successfully deleted."); tx.success(); } catch (Exception e) { source.getWindow().showNotification("Error while deleting entry: " + e.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); log.error(e); tx.failure(); } finally { tx.finish(); } } }); hl.addComponent(showMembersButton); hl.addComponent(csvImportButton); hl.addComponent(refreshButton); hl.addComponent(deleteButton); hl.setSpacing(true); return hl; }
From source file:com.trivago.mail.pigeon.web.components.mail.ActionButtonColumnGenerator.java
License:Apache License
@Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout hl = new HorizontalLayout(); Button showNlConentButton = new Button(); showNlConentButton.setDescription("View"); showNlConentButton.setImmediate(true); showNlConentButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png")); showNlConentButton.addListener(new Button.ClickListener() { @Override/* w w w. ja va 2 s . co m*/ public void buttonClick(Button.ClickEvent event) { Mail m = new Mail((Long) itemId); Window nlConentView = new Window("Newsletter Contents of ID " + itemId); // Create an empty tab sheet. TabSheet tabsheet = new TabSheet(); Panel pText = new Panel("Text Content"); Panel pHtml = new Panel("Text Content"); RichTextArea textArea = new RichTextArea(); textArea.setValue(m.getText()); textArea.setReadOnly(true); RichTextArea richTextArea = new RichTextArea(); richTextArea.setValue(m.getHtml()); richTextArea.setReadOnly(true); pText.addComponent(textArea); pHtml.addComponent(richTextArea); richTextArea.setHeight("50%"); richTextArea.setWidth("100%"); textArea.setHeight("50%"); textArea.setWidth("100%"); nlConentView.setResizable(true); nlConentView.setWidth("800px"); nlConentView.setHeight("600px"); tabsheet.addTab(pText); tabsheet.getTab(pText).setCaption("Text Version"); tabsheet.addTab(pHtml); tabsheet.getTab(pHtml).setCaption("Html Version"); nlConentView.addComponent(tabsheet); source.getWindow().addWindow(nlConentView); nlConentView.setVisible(true); } }); final Button showOpenendMails = new Button(); showOpenendMails.setDescription("Show recipients of this mailling"); showOpenendMails.setIcon(new ThemeResource("../runo/icons/16/users.png")); showOpenendMails.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Mail m = new Mail((Long) itemId); ModalRecipientListByMail modalRecipientListByMail = new ModalRecipientListByMail(m); source.getWindow().addWindow(modalRecipientListByMail); modalRecipientListByMail.setVisible(true); } }); hl.addComponent(showNlConentButton); hl.addComponent(showOpenendMails); return hl; }