List of usage examples for com.vaadin.ui Label setValue
public void setValue(String value)
From source file:edu.kit.dama.ui.admin.administration.user.MembershipRoleEditorWindow.java
License:Apache License
/** * Get the memberships table.// w w w.ja v a 2 s .c o m * * @return The memberships table. */ private Table getMembershipsTable() { if (membershipsTable == null) { String id = "membershipsTable"; LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ..."); membershipsTable = new Table(); membershipsTable.setId(DEBUG_ID_PREFIX + id); membershipsTable.setSizeFull(); membershipsTable.setSelectable(true); membershipsTable.setMultiSelect(true); IndexedContainer c = new IndexedContainer(); c.addContainerProperty(NAME_COLUMN_ID, String.class, null); c.addContainerProperty(ROLE_COLUMN_ID, Role.class, null); c.addContainerProperty(INFO_COLUMN_ID, String.class, null); membershipsTable.setContainerDataSource(c); membershipsTable.setColumnHeader(NAME_COLUMN_ID, "Group Name"); membershipsTable.setColumnHeader(ROLE_COLUMN_ID, "Role"); membershipsTable.setColumnHeader(INFO_COLUMN_ID, "Info"); membershipsTable.addGeneratedColumn(ROLE_COLUMN_ID, (Table source, Object itemId, Object columnId) -> { Role role = (Role) source.getContainerDataSource().getContainerProperty(itemId, columnId) .getValue(); Label cellContent = new Label(); if (role != null && role.moreThan(Role.NO_ACCESS)) { cellContent.addStyleName(CSSTokenContainer.GREEN_BOLD_CENTERED_LABEL); cellContent.setValue(role.toString()); } else if (role != null && !role.moreThan(Role.NO_ACCESS)) { cellContent.addStyleName(CSSTokenContainer.RED_BOLD_CENTERED_LABEL); cellContent.setValue(role.toString()); } else { cellContent.addStyleName(CSSTokenContainer.ORANGE_BOLD_CENTERED_LABEL); cellContent.setValue("NO MEMBER"); } return cellContent; }); membershipsTable.addGeneratedColumn(INFO_COLUMN_ID, (Table source, Object itemId, Object columnId) -> { String value = (String) source.getContainerDataSource().getContainerProperty(itemId, columnId) .getValue(); Label cellContent = new Label(); cellContent.addStyleName(CSSTokenContainer.RED_BOLD_CENTERED_LABEL); if (value != null) { cellContent.setValue("!"); cellContent.setDescription(value); } else { cellContent.setValue(""); cellContent.setDescription(null); } return cellContent; }); } return membershipsTable; }
From source file:edu.kit.dama.ui.admin.administration.user.UserDataTablePanel.java
License:Apache License
protected final Table getUserDataTable() { if (userDataTable == null) { String id = "userDataTable"; LOGGER.debug("Building " + DEBUG_ID_PREFIX + " ..."); userDataTable = new Table(); userDataTable.setId(DEBUG_ID_PREFIX + id); userDataTable.setSizeFull();/*w w w . ja va 2 s . c om*/ userDataTable.setSelectable(true); userDataTable.setNullSelectionAllowed(true); IndexedContainer c = new IndexedContainer(); c.addContainerProperty(ID_COLUMN_ID, Long.class, null); c.addContainerProperty(USERID_COLUMN_ID, String.class, null); c.addContainerProperty(FIRST_NAME_COLUMN_ID, String.class, null); c.addContainerProperty(LAST_NAME_COLUMN_ID, String.class, null); c.addContainerProperty(EMAIL_COLUMN_ID, String.class, null); c.addContainerProperty(VALID_FROM_COLUMN_ID, Date.class, null); c.addContainerProperty(VALID_UNTIL_COLUMN_ID, Date.class, null); userDataTable.setContainerDataSource(c); userDataTable.setColumnHeader(ID_COLUMN_ID, "ID"); userDataTable.setColumnHeader(USERID_COLUMN_ID, "DISTINGUISHED NAME"); userDataTable.setColumnHeader(FIRST_NAME_COLUMN_ID, "FIRST NAME"); userDataTable.setColumnHeader(LAST_NAME_COLUMN_ID, "LAST NAME"); userDataTable.setColumnHeader(EMAIL_COLUMN_ID, "EMAIL"); userDataTable.setColumnHeader(VALID_FROM_COLUMN_ID, "VALID FROM"); userDataTable.setColumnHeader(VALID_UNTIL_COLUMN_ID, "VALID UNTIL"); Table.ColumnGenerator dateGenerator = (Table source, Object itemId, Object columnId) -> { Date date = (Date) source.getContainerDataSource().getContainerProperty(itemId, columnId) .getValue(); Label cellContent = new Label(); if (date != null) { cellContent.setValue(new SimpleDateFormat("dd.MM.yyyy").format(date)); } else { cellContent.setValue("-"); } return cellContent; }; userDataTable.addGeneratedColumn(VALID_FROM_COLUMN_ID, dateGenerator); userDataTable.addGeneratedColumn(VALID_UNTIL_COLUMN_ID, dateGenerator); userDataTable.addValueChangeListener((Property.ValueChangeEvent event) -> { userDataAdministrationTab.getUserDataForm().update(UIHelper.getSessionUserRole()); }); userDataTable.addItemSetChangeListener((Container.ItemSetChangeEvent event) -> { userDataTable.refreshRowCache(); }); userDataTable.addHeaderClickListener((Table.HeaderClickEvent event) -> { if (!event.isDoubleClick()) { return; } if (userDataTable.getColumnIcon(event.getPropertyId()) == null) { return; } removeTableFilter((String) event.getPropertyId()); }); reloadUserDataTable(); } return userDataTable; }
From source file:edu.kit.dama.ui.admin.administration.usergroup.GroupMembershipEditorWindow.java
License:Apache License
private Table getMembersTable() { if (membersTable == null) { String id = "membersTable"; LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ..."); membersTable = new Table(); membersTable.setId(DEBUG_ID_PREFIX + id); membersTable.setSizeFull();//from ww w. j a v a2 s . c om membersTable.setSelectable(true); membersTable.setMultiSelect(true); IndexedContainer c = new IndexedContainer(); c.addContainerProperty(NAME_COLUMN_ID, String.class, null); c.addContainerProperty(ROLE_COLUMN_ID, Role.class, null); c.addContainerProperty(INFO_COLUMN_ID, String.class, null); membersTable.setContainerDataSource(c); membersTable.setColumnHeader(NAME_COLUMN_ID, "User Name"); membersTable.setColumnHeader(ROLE_COLUMN_ID, "Role"); membersTable.setColumnHeader(INFO_COLUMN_ID, "Info"); membersTable.addGeneratedColumn(ROLE_COLUMN_ID, (Table source, Object itemId, Object columnId) -> { Role role = (Role) source.getContainerDataSource().getContainerProperty(itemId, columnId) .getValue(); Label cellContent = new Label(); if (role != null && role.moreThan(Role.NO_ACCESS)) { cellContent.addStyleName(CSSTokenContainer.GREEN_BOLD_CENTERED_LABEL); cellContent.setValue(role.toString()); } else if (role != null && !role.moreThan(Role.NO_ACCESS)) { cellContent.addStyleName(CSSTokenContainer.RED_BOLD_CENTERED_LABEL); cellContent.setValue(role.toString()); } else { cellContent.addStyleName(CSSTokenContainer.ORANGE_BOLD_CENTERED_LABEL); cellContent.setValue("NO MEMBER"); } return cellContent; }); membersTable.addGeneratedColumn(INFO_COLUMN_ID, (Table source, Object itemId, Object columnId) -> { String value = (String) source.getContainerDataSource().getContainerProperty(itemId, columnId) .getValue(); Label cellContent = new Label(); cellContent.addStyleName(CSSTokenContainer.RED_BOLD_CENTERED_LABEL); if (value != null) { cellContent.setValue("!"); cellContent.setDescription(value); } else { cellContent.setValue(""); cellContent.setDescription(null); } return cellContent; }); } return membersTable; }
From source file:edu.kit.dama.ui.simon.panel.SimonMainPanel.java
License:Apache License
/** * Assign the current "simon says" comment to the label including the * correct format./* w ww .j ava2s . c o m*/ * * @param pLabel The label to assign the comment to. * @param pMessage The comment. */ private void setSimonSaysContent(Label pLabel, String pMessage) { pLabel.setValue("<p style=\"font-size:30px;line-height:30px;vertical-align:middle;\">Simon says: " + pMessage + "</p>"); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
void handleShowActiveUsersPerServer(MenuBar mbar) { Object[][] oa = Mmowgli2UI.getGlobals().getSessionCountByServer(); Window svrCountWin = new Window("Display Active Users Per Server"); svrCountWin.setModal(true);// w w w . j a v a 2s .com VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); svrCountWin.setContent(layout); GridLayout gl = new GridLayout(2, Math.max(1, oa.length)); gl.setSpacing(true); gl.addStyleName("m-greyborder"); for (Object[] row : oa) { Label lab = new Label(); lab.setSizeUndefined(); lab.setValue(row[0].toString()); gl.addComponent(lab); gl.setComponentAlignment(lab, Alignment.MIDDLE_RIGHT); gl.addComponent(new Label(row[1].toString())); } layout.addComponent(gl); layout.setComponentAlignment(gl, Alignment.MIDDLE_CENTER); svrCountWin.setWidth("250px"); UI.getCurrent().addWindow(svrCountWin); svrCountWin.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
void handleShowActiveUsersActionTL(MenuBar menubar) { Session session = HSess.get();/*from www .ja v a2 s. c o m*/ Criteria criteria = session.createCriteria(User.class); criteria.setProjection(Projections.rowCount()); criteria.add(Restrictions.eq("accountDisabled", false)); int totcount = ((Long) criteria.list().get(0)).intValue(); // new and improved int count = Mmowgli2UI.getGlobals().getSessionCount(); Window countWin = new Window("Display Active User Count"); countWin.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); countWin.setContent(layout); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Label lab; hl.addComponent(lab = new HtmlLabel("Number of users* (including yourself)<br/>currently playing:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label countTf = new HtmlLabel(); countTf.setWidth("50px"); countTf.setValue(" " + count); countTf.addStyleName("m-greyborder"); hl.addComponent(countTf); hl.setComponentAlignment(countTf, Alignment.MIDDLE_LEFT); layout.addComponent(hl); layout.addComponent(new Label("* Count incremented on login, decremented on timeout or logout.")); hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(lab = new HtmlLabel("Total registered users:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label totalLab = new HtmlLabel(); totalLab.setWidth("50px"); totalLab.setValue(" " + totcount); totalLab.addStyleName("m-greyborder"); hl.addComponent(totalLab); hl.setComponentAlignment(totalLab, Alignment.MIDDLE_LEFT); layout.addComponent(hl); countWin.setWidth("325px"); UI.getCurrent().addWindow(countWin); countWin.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleShowNumberCardsActionTL(MenuBar mbar) { Session session = HSess.get();// w ww . j a va2 s.co m Criteria criteria = session.createCriteria(Card.class); criteria.setProjection(Projections.rowCount()); int count = ((Long) criteria.list().get(0)).intValue(); // Create the window... Window countWin = new Window("Display Card Count"); countWin.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); countWin.setContent(layout); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Label lab; hl.addComponent(lab = new HtmlLabel("Number of cards played:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label countTf = new HtmlLabel(); countTf.setWidth("50px"); countTf.setValue(" " + count); countTf.addStyleName("m-greyborder"); hl.addComponent(countTf); hl.setComponentAlignment(countTf, Alignment.MIDDLE_LEFT); layout.addComponent(hl); countWin.setWidth("255px"); UI.getCurrent().addWindow(countWin); countWin.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
private Component makeHL(String s, int num) { HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true);/*from w w w . j a v a 2 s. c o m*/ Label lab; hl.addComponent(lab = new HtmlLabel(s)); hl.setExpandRatio(lab, 1.0f); Label countTf = new HtmlLabel(); countTf.setWidth("50px"); countTf.setValue(" " + num); countTf.addStyleName("m-greyborder"); countTf.addStyleName("m-textalignright"); hl.addComponent(countTf); hl.setComponentAlignment(countTf, Alignment.TOP_RIGHT); hl.setWidth("100%"); return hl; }
From source file:edu.nps.moves.security.PasswordResetUI.java
License:Open Source License
private void handleChangeTL(User user) { this.user = user; Game g = Game.getTL();/*from w ww . j av a 2 s. com*/ String brand = g.getCurrentMove().getTitle(); Page.getCurrent().setTitle("Password reset for " + brand + " mmowgli"); HorizontalLayout hLay = new HorizontalLayout(); hLay.setMargin(true); hLay.setWidth("100%"); setContent(hLay); GameLinks gl = GameLinks.getTL(); String blog = gl.getBlogLink(); Label lab; hLay.addComponent(lab = new Label()); hLay.setExpandRatio(lab, 0.5f); VerticalLayout vl = new VerticalLayout(); hLay.addComponent(vl); vl.setWidth(bannerWidthPx); hLay.addComponent(lab = new Label()); hLay.setExpandRatio(lab, 0.5f); vl.addStyleName("m-greyborder"); vl.setMargin(true); vl.setSpacing(true); vl.addComponent(lab = new HtmlLabel("")); lab.addStyleName("m-font-21-bold"); lab.setSizeUndefined(); vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); StringBuilder sb = new StringBuilder(); sb.append(thanksHdr1); sb.append(blog); sb.append(thanksHdr2); sb.append(brand); sb.append(thanksHdr3); lab.setValue(sb.toString()); vl.addComponent(lab = new HtmlLabel("")); lab.setHeight("15px"); vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); FormLayout fLay = new FormLayout(); fLay.setSizeUndefined(); fLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield) vl.addComponent(fLay); vl.setComponentAlignment(fLay, Alignment.MIDDLE_CENTER); newPw = new PasswordField("New Password"); newPw.setWidth("99%"); fLay.addComponent(newPw); newPw2 = new PasswordField("Again, please"); newPw2.setWidth("99%"); fLay.addComponent(newPw2); HorizontalLayout buttLay = new HorizontalLayout(); buttLay.setSpacing(true); vl.addComponent(buttLay); vl.setComponentAlignment(buttLay, Alignment.TOP_CENTER); NativeButton cancelButt = new NativeButton(); cancelButt.setStyleName("m-cancelButton"); buttLay.addComponent(cancelButt); buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT); saveButt = new NativeButton(); saveButt.setClickShortcut(ShortcutAction.KeyCode.ENTER); saveButt.setStyleName("m-continueButton"); //m-saveChangesButton"); buttLay.addComponent(saveButt); buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT); cancelButt.addClickListener(this); saveButt.addClickListener(this); }
From source file:eu.lod2.OnlineToolsTab.java
License:Apache License
public OnlineToolsTab(String g, LOD2DemoState st) { // The internal state and state = st;/* ww w . j a va2 s . co m*/ storeInGraph = g; //************************************************************************ // OnlineToolsTab VerticalLayout onlineToolsTab = new VerticalLayout(); TextField sid = new TextField("search sameAs id's for:"); sid.setDebugId(this.getClass().getSimpleName() + "_sid"); final Label sidenc = new Label(""); // configure & add to layout sid.setImmediate(true); sid.setColumns(30); sid.addListener(new TextChangeListener() { public void textChange(TextChangeEvent event) { sameasid = event.getText(); } }); Button sidbutton = new Button("convert", new ClickListener() { public void buttonClick(ClickEvent event) { try { URI encoded = new URI(sameasid); sidenc.setValue("http://sameAs.org/rdf?uri=" + encoded.toASCIIString()); } catch (Exception e) { e.printStackTrace(); } ; try { // java.net.URL sameAsData = new java.net.URL("http://sameAs.org/rdf?uri=http%3A%2F%2Fdbpedia.org%2Fresource%2FGermany"); URI sidencoded = new URI(sameasid); java.net.URL sameAsData = new java.net.URL( "http://sameAs.org/rdf?uri=" + sidencoded.toASCIIString()); String baseURI = "http://sameAs.org#"; RepositoryConnection con = state.getRdfStore().getConnection(); Resource contextURI = con.getValueFactory().createURI(storeInGraph); Resource[] contexts = new Resource[] { contextURI }; con.add(sameAsData, baseURI, RDFFormat.RDFXML, contexts); } catch (RepositoryException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (RDFParseException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } ; }; }); onlineToolsTab.addComponent(sid); onlineToolsTab.addComponent(sidenc); onlineToolsTab.addComponent(sidbutton); /* Sigma EE is temporarily deprecated try { URL url2 = new URL(state.getHostName() + "/lod2.sigma.html"); Embedded browser2 = new Embedded("", new ExternalResource(url2)); browser2.setType(Embedded.TYPE_BROWSER); browser2.setWidth("100%"); browser2.setHeight(500); onlineToolsTab.addComponent(browser2); } catch (MalformedURLException e) { e.printStackTrace(); }; */ /* The online resources link page */ final Panel panel = new Panel("LOD2 online components"); VerticalLayout panelContent = new VerticalLayout(); Link l = new Link("SameAs Inference", new ExternalResource("http://sameAs.org/")); l.setTargetName("_blank"); l.setTargetBorder(Link.TARGET_BORDER_NONE); panelContent.addComponent(l); Link l2 = new Link("Sig.ma", new ExternalResource("http://sig.ma/")); l2.setTargetName("_blank"); l2.setTargetBorder(Link.TARGET_BORDER_NONE); //panelContent.addComponent(l2); Link l3 = new Link("LOD cloud", new ExternalResource("http://lod.openlinksw.com/")); l3.setTargetName("_blank"); l3.setTargetBorder(Link.TARGET_BORDER_NONE); panelContent.addComponent(l3); panel.setContent(panelContent); onlineToolsTab.addComponent(panel); // The composition root MUST be set setCompositionRoot(onlineToolsTab); }