List of usage examples for com.vaadin.ui Button addListener
@Override
public Registration addListener(Component.Listener listener)
From source file:v7cr.ProjectEditor.java
License:Open Source License
public void buttonClick(ClickEvent event) { rightSide.removeAllComponents();/*from w w w .j av a2 s . c om*/ final DBObject b = new BasicDBObject(); Project p = new Project(new BSONBackedObject()); final Form form = new Form(); form.setWidth("100%"); rightSide.addComponent(form); form.setFormFieldFactory(new BSONFormFieldFactory(p.getSchemaDefinition())); form.setItemDataSource(new BSONItem(b, p.getSchemaDefinition())); form.setVisibleItemProperties(new String[] { "_id", "name", "repo", "viewChanges" }); V7CR v7 = V7CR.getInstance(); Button submit = new Button(v7.getMessage("button.create")); rightSide.addComponent(submit); submit.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { form.commit(); V7CR v7 = V7CR.getInstance(); v7.insert("projects", b); // also create the member role DBObject r = new BasicDBObjectBuilder().add("_id", "project:" + b.get("_id")) .add("name", "Reviewers of project '" + b.get("_id") + "'").get(); v7.insert("roles", r); rightSide.removeAllComponents(); reload(v7); } }); }
From source file:v7cr.ReviewTab.java
License:Open Source License
private void reload() { final V7CR v7 = V7CR.getInstance(); r = new Review(v7.load("reviews", reviewId)); Project p = new Project(v7.load("projects", r.getProjectName())); SVNLogEntry svn = r.getSVNLogEntry(); String url;//from w w w.j ava2 s. c om if (svn != null) { url = r.getProjectName() + "-" + svn.getRevision(); setCaption(url); } else { url = reviewId.toString(); setCaption(StringUtils.abbreviate(r.getTitle(), 20)); } VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); vl.addComponent(getBasicInfo(v7, r, p, url)); Panel s = getSVNPanel(v7, r.getSchemaDefinition(), svn, p); if (s != null) vl.addComponent(s); final BSONBackedObject[] notes = r.getObjectFieldAsArray("notes"); if (notes != null) { for (BSONBackedObject note : notes) { vl.addComponent(getNotesPanel(note)); } } final BSONBackedObject[] votes = r.getObjectFieldAsArray("v"); if (votes != null) { for (BSONBackedObject vote : votes) { vl.addComponent(new CommentPanel(vote)); } } { HorizontalLayout commentGrid = new HorizontalLayout(); newComment = new TextArea(); newComment.setColumns(50); newComment.setRows(10); commentGrid.addComponent(newComment); voteOptions = new OptionGroup(); voteOptions.addItem("+"); voteOptions.addItem("0"); voteOptions.addItem("-"); voteOptions.setValue("0"); commentGrid.addComponent(voteOptions); vl.addComponent(commentGrid); fileArea = new VerticalLayout(); vl.addComponent(fileArea); MultiFileUpload uploader = new MultiFileUpload() { @Override protected void handleFile(File file, String fileName, String mimeType, long length) { try { BSONBackedObject gf = v7.storeFile(file, fileName, mimeType); TemporaryFile tf = new TemporaryFile(v7, gf); fileArea.addComponent(tf); } catch (IOException e) { throw new RuntimeException(e); } } }; vl.addComponent(uploader); Button submitButton = new Button(v7.getMessage("button.submit")); submitButton.addListener(this); vl.addComponent(submitButton); } setCompositionRoot(vl); Component parent = getParent(); if (parent instanceof TabSheet) { TabSheet t = (TabSheet) parent; Iterator<Component> i = t.getComponentIterator(); while (i.hasNext()) { Component c = i.next(); if (c instanceof ReviewList && r.getProjectName().equals(c.getCaption())) { ((ReviewList) c).reload(); break; } } } }
From source file:v7cr.RoleEditor.java
License:Open Source License
RoleEditor(V7CR v7) { setCaption(v7.getMessage("roleEditor.name")); setIcon(new ThemeResource("../runo/icons/16/users.png")); this.roles.setBeanIdProperty("id"); for (BSONBackedObject b : v7.find("roles")) { roles.addBean(new Role(b)); }/*from w ww. j av a 2s . c om*/ SchemaDefinition sd = Role.getRoleSchemaDefinition(); Locale l = v7.getLocale(); rolesTab.setContainerDataSource(this.roles); rolesTab.addGeneratedColumn("name", new LocalizedStringColumnGenerator(l)); rolesTab.setVisibleColumns(new Object[] { "id", "name" }); rolesTab.setColumnHeaders(new String[] { sd.getFieldCaption("_id", l), sd.getFieldCaption("name", l) }); rolesTab.setSelectable(true); rolesTab.setImmediate(true); rolesTab.addListener(this); Panel rightSide = new Panel(); memberSelect.setRightColumnCaption(sd.getFieldCaption("member", l)); memberSelect.setLeftColumnCaption(v7.getMessage("roleEditor.nonMembers")); rightSide.addComponent(memberSelect); Button commitButton = new Button(v7.getMessage("button.submit")); commitButton.addListener(this); rightSide.addComponent(commitButton); rightSide.setWidth("500"); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(rolesTab); hl.addComponent(rightSide); setCompositionRoot(hl); }
From source file:v7cr.TopPageWindow.java
License:Open Source License
private HorizontalLayout createToolbar(V7CR app) { Label logo = new Label(getCaption()); Label username = new Label(app.getSessionUser().getName() + " " + app.getSessionUser().getId()); Button logout = new Button(app.getMessage("button.logout")); logout.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { Application a = V7CR.getInstance(); a.close();/*from www . ja v a 2 s .co m*/ ((WebApplicationContext) a.getContext()).getHttpSession().invalidate(); } }); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(logo); hl.addComponent(logout); hl.addComponent(username); hl.setSpacing(true); return hl; }