List of usage examples for org.apache.wicket.markup.html.list ListView ListView
public ListView(final String id, final List<T> list)
From source file:ch.tkuhn.nanobrowser.AgentPage.java
License:Open Source License
public AgentPage(final PageParameters parameters) { agent = new AgentElement(parameters.get("uri").toString()); boolean isBot = agent.isBot(); update();/*from w w w . j a v a 2s . c o m*/ add(new MenuBar("menubar")); WebMarkupContainer icon = new WebMarkupContainer("icon"); if (isBot) { icon.add(new AttributeModifier("src", new Model<String>("icons/bot.svg"))); } add(icon); add(new Label("title", agent.getName())); add(new ExternalLink("uri", agent.getURI(), agent.getTruncatedURI())); add(new HList("typelist", agent.getTypes(), "Types")); if (isBot) { add(new HList("commanderlist", agent.getCommanders(), "Commanders")); } else { add(new WebMarkupContainer("commanderlist")); } add(new VList("nanopublist", nanopubModel, "Nanopublications")); add(new Label("emptyopinions", opinionModel.getObject().isEmpty() ? "(nothing)" : "")); add(new ListView<Opinion>("opinions", opinionModel) { private static final long serialVersionUID = -4257147575068849793L; protected void populateItem(ListItem<Opinion> item) { item.add(new Label("opinion", Opinion.getVerbPhrase(item.getModelObject().getOpinionType(), true))); item.add(new SentenceItem("opinionsentence", item.getModelObject().getSentence())); item.add(new NanopubItem("opinionpub", item.getModelObject().getNanopub(), ThingElement.TINY_GUI_ITEM)); } }); WebMarkupContainer aa = new WebMarkupContainer("adminactions"); if (NanobrowserApplication.isInDevelopmentMode()) { Link<Object> thatsmeButton; aa.add(thatsmeButton = new Link<Object>("thatsme") { private static final long serialVersionUID = 8608371149183694875L; public void onClick() { NanobrowserSession.get().setUser(agent); update(); setResponsePage(AgentPage.class, getPageParameters()); } }); thatsmeButton.setVisible(!isBot); } else { aa.add(new AttributeModifier("class", new Model<String>("hidden"))); aa.add(new Label("thatsme", "")); } add(aa); }
From source file:ch.tkuhn.nanobrowser.HList.java
License:Open Source License
public HList(String id, List<? extends Object> items, String title) { super(id);//from w w w. j a v a 2s . c om add(new Label("title", title)); add(new Label("empty", items.size() == 0 ? "(unknown)" : "")); add(new ListView<Object>("items", items) { private static final long serialVersionUID = -6222434246491371652L; protected void populateItem(ListItem<Object> item) { Object obj = item.getModelObject(); if (obj instanceof ThingElement) { item.add(((ThingElement) obj).createGUIItem("item")); } else { item.add(ThingElement.getThing(obj.toString()).createGUIItem("item")); } } }); }
From source file:ch.tkuhn.nanobrowser.NanopubPage.java
License:Open Source License
public NanopubPage(final PageParameters parameters) { pub = new NanopubElement(parameters.get("uri").toString()); add(new MenuBar("menubar")); WebMarkupContainer icon = new WebMarkupContainer("icon"); if (pub.isValid()) { icon.add(new AttributeModifier("src", new Model<String>("icons/nanopubv.svg"))); }//www . j ava2 s . co m add(icon); add(new Label("title", pub.getShortName())); add(new Link<Object>("trig") { private static final long serialVersionUID = 4680516569316406945L; @SuppressWarnings("deprecation") public void onClick() { throw new RedirectToUrlException("./trig?uri=" + URLEncoder.encode(pub.getURI())); } }); add(new Link<Object>("xml") { private static final long serialVersionUID = 4680516569316406945L; @SuppressWarnings("deprecation") public void onClick() { throw new RedirectToUrlException("./xml?uri=" + URLEncoder.encode(pub.getURI())); } }); add(new Link<Object>("nq") { private static final long serialVersionUID = 4680516569316406945L; @SuppressWarnings("deprecation") public void onClick() { throw new RedirectToUrlException("./nq?uri=" + URLEncoder.encode(pub.getURI())); } }); add(new ExternalLink("uri", pub.getURI(), pub.getTruncatedURI())); add(new HList("typelist", pub.getTypes(), "Types")); String dateString = pub.getCreateDateString(); if (dateString == null) { add(new Label("dateempty", "(unknown)")); add(new Label("date", "")); } else { add(new Label("dateempty", "")); add(new Label("date", dateString)); } add(new HList("authorlist", pub.getAuthors(), "Authors")); add(new HList("creatorlist", pub.getCreators(), "Creator")); List<SentenceElement> sentass = pub.getSentenceAssertions(); if (sentass.size() > 0) { add(new VList("sentencelist", sentass, "Assertion as sentence")); } else { add(new Label("sentencelist", "")); } List<Triple<?, ?>> ass = pub.getAssertionTriples(); if (ass.size() > 0) { String assUri = pub.getNanopub().getAssertionUri().stringValue(); String note = null; if (!pub.hasCompleteFormalAssertionQuery()) note = "(incomplete)"; add(new VList("asslist", TripleStoreAccess.sortTriples(ass), "Assertion as formula", assUri, note)); } else { add(new Label("asslist", "")); } List<Triple<?, ?>> prov = pub.getProvenanceTriples(); if (prov.size() > 0) { add(new VList("provlist", TripleStoreAccess.sortTriples(prov), "Provenance", pub.getURI())); } else { add(new Label("provlist", "")); } List<Opinion> opinions = pub.getOpinions(true); add(new Label("emptyopinions", opinions.isEmpty() ? "(nothing)" : "")); add(new ListView<Opinion>("opinions", opinions) { private static final long serialVersionUID = 6804591967140101102L; protected void populateItem(ListItem<Opinion> item) { item.add(new AgentItem("opinionagent", item.getModelObject().getAgent())); item.add(new Label("opinion", Opinion.getVerbPhrase(item.getModelObject().getOpinionType(), false) + ".")); item.add(new NanopubItem("opinionpub", item.getModelObject().getNanopub(), ThingElement.TINY_GUI_ITEM)); } }); WebMarkupContainer aa = new WebMarkupContainer("adminactions"); if (NanobrowserApplication.isInDevelopmentMode()) { aa.add(new Link<Object>("delete") { private static final long serialVersionUID = 8608371149183694875L; public void onClick() { pub.delete(); MainPage.resetLists(); setResponsePage(MainPage.class); } }); } else { aa.add(new AttributeModifier("class", new Model<String>("hidden"))); aa.add(new Label("delete", "")); } add(aa); }
From source file:ch.tkuhn.nanobrowser.SentencePage.java
License:Open Source License
public SentencePage(final PageParameters parameters) { sentence = new SentenceElement(parameters.get("uri").toString()); update();/*from www .j av a 2 s .c om*/ add(new MenuBar("menubar")); add(new Label("title", sentence.getSentenceText())); add(new ExternalLink("uri", sentence.getURI(), sentence.getTruncatedURI())); add(new VList("nanopublist", sentence.getNanopubs(), "Nanopublications")); add(new Link<Object>("agree") { private static final long serialVersionUID = 8608371149183694875L; public void onClick() { (new Opinion(getUser(), Opinion.AGREEMENT_TYPE, sentence)).publish(); update(); } }); add(new Link<Object>("disagree") { private static final long serialVersionUID = 6155018832205809659L; public void onClick() { (new Opinion(getUser(), Opinion.DISAGREEMENT_TYPE, sentence)).publish(); update(); } }); add(new Link<Object>("noopinion") { private static final long serialVersionUID = -731806526201590205L; public void onClick() { (new Opinion(getUser(), Opinion.NULL_TYPE, sentence)).publish(); update(); } }); add(new Label("emptyopinions", opinionsEmptyModel)); add(new ListView<Opinion>("opinions", opinionModel) { private static final long serialVersionUID = 5235305068010085751L; protected void populateItem(ListItem<Opinion> item) { item.add(new AgentItem("agent", item.getModelObject().getAgent())); item.add(new Label("opinion", Opinion.getVerbPhrase(item.getModelObject().getOpinionType(), false) + ".")); item.add(new NanopubItem("opinionpub", item.getModelObject().getNanopub(), ThingElement.TINY_GUI_ITEM)); } }); add(new Label("emptyrelations", relationsEmptyModel)); add(new ListView<Triple<SentenceElement, SentenceElement>>("relations", relationModel) { private static final long serialVersionUID = -3149020273243388808L; protected void populateItem(ListItem<Triple<SentenceElement, SentenceElement>> item) { item.add(new TriplePanel("relation", item.getModelObject(), TriplePanel.PREDICATE_SUBJECT)); } }); otherSentenceField = new TextField<String>("othersentence", Model.of("")); sentenceRelChoice = new DropDownChoice<SentenceRelation>("reltype", new PropertyModel<SentenceRelation>(this, "selectedRelType"), sentenceRelOptions); Form<?> newSentRelForm = new Form<Void>("newrelform") { private static final long serialVersionUID = -6636881419461562970L; protected void onSubmit() { String s = otherSentenceField.getModelObject(); SentenceElement other = null; if (s != null && SentenceElement.isSentenceURI(s)) { other = new SentenceElement(s); } else { try { other = SentenceElement.withText(s); } catch (AidaException ex) { sentenceError.setObject("ERROR: " + ex.getMessage()); return; } } sentence.publishSentenceRelation(selectedRelType, other, getUser()); setResponsePage(SentencePage.class, getPageParameters()); } }; add(newSentRelForm); newSentRelForm.add(otherSentenceField); newSentRelForm.add(sentenceRelChoice); sentenceError = Model.of(""); newSentRelForm.add(new Label("sentenceerror", sentenceError)); }
From source file:ch.tkuhn.nanobrowser.VList.java
License:Open Source License
public VList(String id, List<? extends Object> items, String title, String thisUri, String note) { super(id);//ww w .j a va 2 s . c o m this.thisUri = thisUri; add(new Label("title", title)); add(new ListView<Object>("items", items) { private static final long serialVersionUID = 41253459622515487L; protected void populateItem(ListItem<Object> item) { VList.this.populateItem(item); } }); if (note != null) { add(new Label("note", note)); } else if (items.isEmpty()) { add(new Label("note", "(nothing)")); } else { add(new Label("note", "")); } }
From source file:ch.tkuhn.nanobrowser.VList.java
License:Open Source License
public VList(String id, IModel<? extends List<? extends Object>> items, String title, String thisUri, String note) {//from ww w . j av a 2 s . c o m super(id); this.thisUri = thisUri; add(new Label("title", title)); add(new ListView<Object>("items", items) { private static final long serialVersionUID = 41253459622515487L; protected void populateItem(ListItem<Object> item) { VList.this.populateItem(item); } }); if (note != null) { add(new Label("note", note)); } else if (items.getObject().isEmpty()) { add(new Label("note", "(nothing)")); } else { add(new Label("note", "")); } }
From source file:com.adamjan.pages.MainPage.java
License:Open Source License
public MainPage() { add(new Label("msg", "Hello")); LoadableDetachableModel<List<AccountDto>> model = new LoadableDetachableModel<List<AccountDto>>() { @Override/* w w w. j a va 2 s . co m*/ protected List<AccountDto> load() { return accountBusiness.getAllAccounts(); } }; ListView listView = new ListView<AccountDto>("repeater", model) { @Override protected void populateItem(ListItem item) { AccountDto dto = getModelObject().get(item.getIndex()); item.add(new Label("label", dto.getName())); } }; add(listView); Form form = new Form<String>("form") { @Override protected void onSubmit() { accountBusiness.addAccount(accName); accName = null; } }; add(form); form.add(new TextField<>("acc_name", new PropertyModel<>(this, "accName"))); add(new Box2dPanel("box2d")); }
From source file:com.alfredmuponda.lostandfound.pages.DetailedSearchResults.java
License:Apache License
public DetailedSearchResults(final PageParameters parameters) { search = new SearchItem(); contactDetails = new ContactInformation(); articles = search.search(parameters.get("uuid").toString()); search.getContactInfo(contactDetails, articles.get(0).getUniqueID()); detailedResultsModel = new LoadableDetachableModel() { @Override//from ww w .java2s. c o m protected Object load() { return articles; } }; //List of Lost/Found articles items = new ListView("items", detailedResultsModel) { @Override protected void populateItem(final ListItem item) { final Item theItem = (Item) item.getModelObject(); item.add(new Label("itemid", theItem.getUniqueID())); item.add(new Label("itemtype", theItem.getItemType())); item.add(new Label("description", theItem.getDescription())); item.add(new Label("itemnumber", theItem.getItemID())); item.add(new Link("delete") { @Override public void onClick() { Delete db = new Delete(); db.deleteRecord(theItem.getUniqueID()); articles.remove((Item) item.getModelObject()); detailedResultsModel.detach(); } //Only allow Adim ability to delete individual record @Override public boolean isVisible() { WiaSession session = WiaSession.get(); return session.isAuthenticated() && session.getUser().isAdmin(); } }); } }; add(new HeaderPanel("headerpanel")); add(items); final Label reportID = new Label("reportid", articles.get(0).getUuid()); add(reportID); add(new Label("location", articles.get(0).getLocation())); add(new Label("datelostfound", articles.get(0).getDateLorF())); add(new Label("surname", contactDetails.getSurname())); add(new Label("firstname", contactDetails.getFirstName())); add(new Label("address", contactDetails.getAddress())); add(new Label("phonenumber", contactDetails.getPhoneNumber())); add(new Link("deleterecord") { @Override public void onClick() { Delete db = new Delete(); db.delete(parameters.get("uuid").toString()); /*Implement this*/ articles.removeAll(articles); detailedResultsModel.detach(); reportID.setVisible(false); setVisible(false); } //Allow only the Admin user to delete the entire record @Override public boolean isVisible() { WiaSession session = WiaSession.get(); return session.isAuthenticated() && session.getUser().isAdmin(); } }); }
From source file:com.alfredmuponda.lostandfound.pages.Search.java
public Search() { itemTypes = Arrays.asList("Wallet", "National ID", "Driver's Licence", "Passport", "Report ID"); searchModel = new Model(); searchTypeModel = new Model(); Form form = new Form("searchform"); searchByField = new DropDownChoice("searchby", searchTypeModel, itemTypes); searchInputField = new TextField("searchinput", searchModel); resultsModel = new LoadableDetachableModel() { @Override/*from w w w . j a va2 s. c o m*/ protected Object load() { String searchBy = (String) searchTypeModel.getObject(); String searchInput = (String) searchModel.getObject(); search = new SearchItem(); return search.search(searchBy, searchInput); } }; Button button = new Button("submit") { @Override public void onSubmit() { } }; Link link = new Link("view") { @Override public void onClick() { } }; /*ListView shows search results*/ ListView items = new ListView("items", resultsModel) { @Override protected void populateItem(ListItem item) { final Item theItem = (Item) item.getModelObject(); item.add(new Label("itemtype", theItem.getItemType())); item.add(new Label("itemnumber", theItem.getItemID())); item.add(new Label("date", theItem.getDateLorF())); item.add(new Label("location", theItem.getLocation())); item.add(new Label("description", theItem.getDescription())); item.add(new Label("uniqueID", theItem.getUniqueIDAsString())); item.add(new Link("view") { @Override public void onClick() { //add the UUID of the article, it is used in DetailedSearchResults page PageParameters pageParameters = new PageParameters(); pageParameters.add("uuid", theItem.getUuid()); setResponsePage(DetailedSearchResults.class, pageParameters); } }); } }; /* *experimentation with a PageableListView *Shows 20 results per page PageableListView items = new PageableListView ("items", resultsModel) { @Override protected void populateItem(ListItem item) { Item theItem = (Item) item.getModelObject(); item.add(new Label("itemtype", theItem.getItemType())); item.add(new Label("itemnumber", theItem.getItemID())); item.add(new Label("date", theItem.getDate())); item.add(new Label("location", theItem.getLocation())); item.add(new Label("description", theItem.getDescription())); item.add(new Label("uniqueID", theItem.getUniqueIDAsString())); } }; add(items); add(new PagingNavigator("navigator", items)); */ add(new HeaderPanel("headerpanel")); add(form); form.add(searchByField); form.add(searchInputField); form.add(button); add(items); }
From source file:com.apachecon.memories.ScrapbookPage.java
License:Apache License
@SuppressWarnings({ "rawtypes", "unchecked" }) public ScrapbookPage() { add(new ExternalLink("apacheCon", "http://na11.apachecon.com/")); add(new BookmarkablePageLink("logo", Index.class)); List<Class<? extends Page>> links = new ArrayList<Class<? extends Page>>(); links.add(Index.class); links.add(Upload.class); Roles roles = AuthenticatedWebSession.get().getRoles(); if (roles != null && roles.hasRole("admin")) { links.add(Browse.class); links.add(Approve.class); links.add(Logout.class); } else {//from ww w . j a va 2 s.c o m links.add(Browse.class); links.add(SignIn.class); } add(new ListView<Class>("menu", links) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<Class> item) { BookmarkablePageLink link = new BookmarkablePageLink("link", item.getModelObject()); String simpleName = item.getModelObject().getSimpleName(); if (getPage().getClass().equals(item.getModelObject())) { item.add(AttributeModifier.append("class", "active")); } link.add(new Label("label", simpleName)); item.add(link); } }); }