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:de.jetwick.ui.UrlTrendPanel.java
License:Apache License
public UrlTrendPanel(String id) { super(id);/*from w w w.j a v a 2 s .c o m*/ // to hide + show on ajax request setOutputMarkupPlaceholderTag(true); // TODO WICKET: update urlTitle even if we call only update(rsp) add(new ListView("urlTitle", filter) { @Override public void populateItem(final ListItem item) { boolean filteredUrl = (Boolean) item.getModelObject(); if (filteredUrl) { item.add(new LabeledLink("filterName", "< " + TITLE) { @Override public void onClick(AjaxRequestTarget target) { onUrlClick(target, null); } }.add(new AttributeAppender("title", new Model("Deselect all url filters"), " "))); } else item.add(new Label("filterName", TITLE)); } }); ListView urlListView = new ListView("urls", urls) { @Override public void populateItem(final ListItem item) { final Entry<String, Long> url = (Entry) item.getModelObject(); String title = url.getKey(); if (title.startsWith("_")) { int index2 = title.indexOf("_", 1); if (index2 > 1) title = title.substring(index2 + 1); } title = Helper.trimAll(title); title = Helper.htmlEntityDecode(title); Link contextLink = new AjaxFallbackLink("urlLink") { @Override public void onClick(AjaxRequestTarget target) { onUrlClick(target, url.getKey()); } }; contextLink.add(new AttributeAppender("title", new Model("View Url in Context of " + url.getValue() + " tweets"), " ")); item.add(contextLink); Link directLink = new AjaxFallbackLink("directLink") { @Override public void onClick(AjaxRequestTarget target) { onDirectUrlClick(target, url.getKey()); } }; item.add(directLink); directLink.add(new Label("urlLabel", title)); directLink.add(new AttributeAppender("title", new Model(title), " ")); } }; add(urlListView); HeaderContributor c = new HeaderContributor(new IHeaderContributor() { @Override public void renderHead(IHeaderResponse response) { response.renderString("<style type='text/css'>\n" + cssString + "</style>"); } }); add(c); }
From source file:de.jetwick.wikipedia.WikipediaPanel.java
License:Apache License
public WikipediaPanel(String id) { super(id);//from w ww . j a v a2 s .c o m urlListView = new ListView("urls", urls) { @Override public void populateItem(final ListItem item) { final WikiEntry url = (WikiEntry) item.getModelObject(); String str = url.getTitle(); if (str.length() > 40) str = str.substring(0, 37).trim() + ".."; ExternalLink link = new ExternalLink("urlLink", url.getUrl(), str); item.add(link); Label label = new Label("urlLabel", url.getText()); label.setEscapeModelStrings(false); //label.add(new AttributeAppender("title", new Model(url.getText()), " ")); item.add(label); } }; add(urlListView); }
From source file:de.lichtflut.glasnost.is.components.devops.items.DevOpsItemPanel.java
License:Apache License
private void addListView(final String id, final IModel<PerceptionItem> model, final WebMarkupContainer container) { ListView<PerceptionItem> view = new ListView<PerceptionItem>(id, getSubItems(model)) { @Override// w ww .j a v a 2 s.c o m protected void populateItem(final ListItem<PerceptionItem> item) { item.add(new DevOpsItemPanel("item", item.getModel())); } }; view.add(visibleIf(isTrue(expanded))); container.add(view); }
From source file:de.lichtflut.glasnost.is.components.devops.perceptions.CreatePerceptionsWizzardPanel.java
License:Apache License
private void addPerceptionsContainer(final String id, final Form<?> form) { ListView<List<Perception>> listView = new ListView<List<Perception>>(id, model) { @Override/*from w w w . j av a 2 s. co m*/ protected void populateItem(final ListItem<List<Perception>> item) { createPerceptionsList(item); } }; form.add(listView); }
From source file:de.lichtflut.glasnost.is.components.devops.perceptions.PerceptionManagementPanel.java
License:Apache License
private ListView<Perception> createListView(final IModel<List<Perception>> model) { ListView<Perception> view = new ListView<Perception>("perceptionView", model) { @Override/*w w w. j av a2 s. c o m*/ protected void populateItem(final ListItem<Perception> item) { Perception perception = item.getModelObject(); Label id = new Label("id", perception.getID()); id.add(new AttributeModifier("title", perception.getContext())); item.add(id); Label name = new Label("name", perception.getName()); item.add(name); Label owner = new Label("owner", new ResourceLabelModel(perception.getOwner())); item.add(owner); Label color = new Label("color", ""); color.add(CssModifier.appendStyle("background-color : #" + perception.getColor())); item.add(color); item.add(createViewLink(item.getModel())); item.add(createDeleteLink(item.getModel())); item.add(createUpLink(item.getModel(), model)); item.add(createDownLink(item.getModel(), model)); } }; view.add(ConditionalBehavior.visibleIf(ConditionalModel.isNotEmpty(model))); return view; }
From source file:de.lichtflut.glasnost.is.pages.DevOpsPage.java
License:Apache License
public DevOpsPage(final PageParameters parameters) { super(parameters); ListView<Perception> listView = new ListView<Perception>("stages", getStageListModel()) { @Override/*from w w w. jav a 2 s .c o m*/ protected void populateItem(final ListItem<Perception> item) { item.add(createStage(item.getModel())); } }; add(listView); }
From source file:de.lichtflut.glasnost.is.pages.DevOpsPage.java
License:Apache License
private Component createStage(final IModel<Perception> model) { WebMarkupContainer container = new WebMarkupContainer("stage"); container.add(new PanelTitle("name", new PropertyModel<String>(model, "name"))); ListView<PerceptionItem> listView = new ListView<PerceptionItem>("items", rootItemsModel(model)) { @Override//from w ww. java2 s . c om protected void populateItem(final ListItem<PerceptionItem> item) { item.add(new DevOpsItemPanel("item", item.getModel())); } }; container.add(listView); container.add(new Link<Void>("addRootItem") { @Override public void onClick() { PerceptionItem item = new PerceptionItem(); item.addAssociation(RDF.TYPE, GIS.DATA_CENTER); item.setID("DCX"); item.setName("DataCenter X"); perceptionService.addBaseItemToPerception(item, model.getObject().getQualifiedName()); } }); return container; }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.curation.component.CurationPanel.java
License:Apache License
public CurationPanel(String id, final IModel<CurationContainer> cCModel) { super(id, cCModel); // add container for list of sentences panel sentencesListView = new WebMarkupContainer("sentencesListView"); sentencesListView.setOutputMarkupId(true); add(sentencesListView);/* ww w. j av a 2s . c om*/ // add container for the list of sentences where annotations exists crossing multiple // sentences // outside of the current page corssSentAnnoView = new WebMarkupContainer("corssSentAnnoView"); corssSentAnnoView.setOutputMarkupId(true); add(corssSentAnnoView); bModel = getModelObject().getBratAnnotatorModel(); LinkedList<CurationUserSegmentForAnnotationDocument> sentences = new LinkedList<CurationUserSegmentForAnnotationDocument>(); CurationUserSegmentForAnnotationDocument curationUserSegmentForAnnotationDocument = new CurationUserSegmentForAnnotationDocument(); if (bModel != null) { curationUserSegmentForAnnotationDocument .setAnnotationSelectionByUsernameAndAddress(annotationSelectionByUsernameAndAddress); curationUserSegmentForAnnotationDocument.setBratAnnotatorModel(bModel); sentences.add(curationUserSegmentForAnnotationDocument); } // update source list model only first time. sourceListModel = sourceListModel == null ? getModelObject().getCurationViews() : sourceListModel; suggestionViewPanel = new SuggestionViewPanel("suggestionViewPanel", new Model<LinkedList<CurationUserSegmentForAnnotationDocument>>(sentences)) { private static final long serialVersionUID = 2583509126979792202L; CurationContainer curationContainer = cCModel.getObject(); @Override public void onChange(AjaxRequestTarget aTarget) { try { // update begin/end of the curationsegment based on bratAnnotatorModel changes // (like sentence change in auto-scroll mode,.... aTarget.addChildren(getPage(), FeedbackPanel.class); updatePanel(aTarget, curationContainer); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } } }; suggestionViewPanel.setOutputMarkupId(true); add(suggestionViewPanel); editor = new AnnotationDetailEditorPanel("annotationDetailEditorPanel", new Model<BratAnnotatorModel>(bModel)) { private static final long serialVersionUID = 2857345299480098279L; @Override protected void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel aBModel) { aTarget.addChildren(getPage(), FeedbackPanel.class); annotate = true; annotator.onChange(aTarget, aBModel); } @Override protected void onAutoForward(AjaxRequestTarget aTarget, BratAnnotatorModel aBModel) { try { annotator.autoForward(aTarget, getCas(aBModel)); } catch (UIMAException | ClassNotFoundException | IOException | BratAnnotationException e) { LOG.info("Error reading CAS " + e.getMessage()); error("Error reading CAS " + e.getMessage()); return; } } @Override protected void onConfigure() { super.onConfigure(); setEnabled(bModel.getDocument() != null && !repository .getSourceDocument(bModel.getDocument().getProject(), bModel.getDocument().getName()) .getState().equals(SourceDocumentState.CURATION_FINISHED)); } }; editor.setOutputMarkupId(true); add(editor); annotator = new BratAnnotator("mergeView", new Model<BratAnnotatorModel>(bModel), editor) { private static final long serialVersionUID = 7279648231521710155L; @Override public void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel bratAnnotatorModel) { aTarget.addChildren(getPage(), FeedbackPanel.class); try { updatePanel(aTarget, cCModel.getObject()); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } } }; // reset sentenceAddress and lastSentenceAddress to the orginal once annotator.setOutputMarkupId(true); add(annotator); LoadableDetachableModel sentenceDiffModel = new LoadableDetachableModel() { @Override protected Object load() { int fSN = bModel.getFSN(); int lSN = bModel.getLSN(); List<String> crossSentAnnos = new ArrayList<>(); if (SuggestionBuilder.crossSentenceLists != null) { for (int sn : SuggestionBuilder.crossSentenceLists.keySet()) { if (sn >= fSN && sn <= lSN) { List<Integer> cr = new ArrayList<>(); for (int c : SuggestionBuilder.crossSentenceLists.get(sn)) { if (c < fSN || c > lSN) { cr.add(c); } } if (!cr.isEmpty()) { crossSentAnnos.add(sn + "-->" + cr); } } } } return crossSentAnnos; } }; crossSentAnnoList = new ListView<String>("crossSentAnnoList", sentenceDiffModel) { private static final long serialVersionUID = 8539162089561432091L; @Override protected void populateItem(ListItem<String> item) { String crossSentAnno = item.getModelObject(); // ajax call when clicking on a sentence on the left side final AbstractDefaultAjaxBehavior click = new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 5803814168152098822L; @Override protected void respond(AjaxRequestTarget aTarget) { // Expand curation view } }; // add subcomponents to the component item.add(click); Label crossSentAnnoItem = new AjaxLabel("crossAnnoSent", crossSentAnno, click); item.add(crossSentAnnoItem); } }; crossSentAnnoList.setOutputMarkupId(true); corssSentAnnoView.add(crossSentAnnoList); LoadableDetachableModel sentencesListModel = new LoadableDetachableModel() { @Override protected Object load() { return getModelObject().getCurationViews(); } }; sentenceList = new ListView<SourceListView>("sentencesList", sentencesListModel) { private static final long serialVersionUID = 8539162089561432091L; @Override protected void populateItem(ListItem<SourceListView> item) { final SourceListView curationViewItem = item.getModelObject(); // ajax call when clicking on a sentence on the left side final AbstractDefaultAjaxBehavior click = new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 5803814168152098822L; @Override protected void respond(AjaxRequestTarget aTarget) { curationView = curationViewItem; fSn = 0; try { JCas jCas = repository.readCurationCas(bModel.getDocument()); updateCurationView(cCModel.getObject(), curationViewItem, aTarget, jCas); updatePanel(aTarget, cCModel.getObject()); bModel.setSentenceNumber(curationViewItem.getSentenceNumber()); } catch (UIMAException e) { error(ExceptionUtils.getRootCause(e)); } catch (ClassNotFoundException e) { error(e.getMessage()); } catch (IOException e) { error(e.getMessage()); } catch (BratAnnotationException e) { error(e.getMessage()); } } }; // add subcomponents to the component item.add(click); String cC = curationViewItem.getSentenceState().getValue(); // mark current sentence in orange if disagree if (curationViewItem.getSentenceNumber() == bModel.getSentenceNumber()) { if (cC != null) { item.add(AttributeModifier.append("class", "current-disagree")); } } else if (cC != null) { // disagree in range if (curationViewItem.getSentenceNumber() >= fSn && curationViewItem.getSentenceNumber() <= lSn) { item.add(AttributeModifier.append("class", "range-disagree")); } else { item.add(AttributeModifier.append("class", "disagree")); } } // agree and in range else if (curationViewItem.getSentenceNumber() >= fSn && curationViewItem.getSentenceNumber() <= lSn) { item.add(AttributeModifier.append("class", "range-agree")); } else { item.add(AttributeModifier.append("class", "agree")); } Label sentenceNumber = new AjaxLabel("sentenceNumber", curationViewItem.getSentenceNumber().toString(), click); item.add(sentenceNumber); } }; // add subcomponents to the component sentenceList.setOutputMarkupId(true); sentencesListView.add(sentenceList); }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.curation.component.SuggestionViewPanel.java
License:Apache License
public SuggestionViewPanel(String id, IModel<LinkedList<CurationUserSegmentForAnnotationDocument>> aModel) { super(id, aModel); // update list of brat embeddings sentenceListView = new ListView<CurationUserSegmentForAnnotationDocument>("sentenceListView", aModel) { private static final long serialVersionUID = -5389636445364196097L; @Override//from ww w . j a v a2 s.c o m protected void populateItem(ListItem<CurationUserSegmentForAnnotationDocument> item2) { final CurationUserSegmentForAnnotationDocument curationUserSegment = item2.getModelObject(); BratSuggestionVisualizer curationVisualizer = new BratSuggestionVisualizer("sentence", new Model<CurationUserSegmentForAnnotationDocument>(curationUserSegment)) { private static final long serialVersionUID = -1205541428144070566L; /** * Method is called, if user has clicked on a span or an arc in the sentence * panel. The span or arc respectively is identified and copied to the merge * cas. * @throws IOException * @throws ClassNotFoundException * @throws UIMAException * @throws BratAnnotationException */ @Override protected void onSelectAnnotationForMerge(AjaxRequestTarget aTarget) throws UIMAException, ClassNotFoundException, IOException, BratAnnotationException { // TODO: chain the error from this component up in the // CurationPage // or CorrectionPage if (BratAnnotatorUtility.isDocumentFinished(repository, curationUserSegment.getBratAnnotatorModel())) { aTarget.appendJavaScript( "alert('This document is already closed." + " Please ask admin to re-open')"); return; } final IRequestParameters request = getRequest().getPostParameters(); String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); SourceDocument sourceDocument = curationUserSegment.getBratAnnotatorModel().getDocument(); JCas annotationJCas = null; annotationJCas = (curationUserSegment.getBratAnnotatorModel().getMode() .equals(Mode.AUTOMATION) || curationUserSegment.getBratAnnotatorModel().getMode().equals(Mode.CORRECTION)) ? repository.readAnnotationCas( repository.getAnnotationDocument(sourceDocument, user)) : repository.readCurationCas(sourceDocument); StringValue action = request.getParameterValue("action"); // check if clicked on a span if (!action.isEmpty() && action.toString().equals("selectSpanForMerge")) { mergeSpan(request, curationUserSegment, annotationJCas, repository, annotationService); } // check if clicked on an arc else if (!action.isEmpty() && action.toString().equals("selectArcForMerge")) { // add span for merge // get information of the span clicked mergeArc(request, curationUserSegment, annotationJCas); } onChange(aTarget); } }; curationVisualizer.setOutputMarkupId(true); item2.add(curationVisualizer); } }; sentenceListView.setOutputMarkupId(true); add(sentenceListView); }
From source file:de.tudarmstadt.ukp.dkpro.uby.vis.webapp.tryUby.AllPanel.java
License:Apache License
public AllPanel(String id, IModel<?> model) { super(id, model); final Map<String, String> res_map = new HashMap<String, String>(); res_map.put("FN", "rgba(148,103,189,0.8)"); res_map.put("OW_deu", "rgba(255,152,150,0.8)"); res_map.put("OW_eng", "rgba(214,39,40,0.8)"); res_map.put("OntoWktDE", "rgba(255,187,120,0.8)"); res_map.put("OntoWktEN", "rgba(255,127,14,0.8)"); res_map.put("VN", "rgba(188,189,34,0.8)"); res_map.put("WikiDE", "rgba(174,199,232,0.8)"); res_map.put("WikiEN", "rgba(31,119,180,0.8)"); res_map.put("WktDE", "rgba(152,223,138,0.8)"); res_map.put("WktEN", "rgba(44,160,44,0.8)"); res_map.put("WN", "rgba(23,190,207,0.8)"); if (model.getObject() != null) { list = new ListView("listSenses", model) { private static final long serialVersionUID = 1L; @Override//from w w w . j av a 2s.co m protected void populateItem(ListItem item) { final Sense sense = (Sense) item.getModelObject(); int sIndex = item.getIndex(); if (sIndex == 0) { count = 0; } count++; String res_id = sense.toString(); String[] result_arr = res_id.split("_"); String res_color = result_arr[0]; if (res_id.contains("OW_eng") || res_id.contains("OW_deu")) { res_color = result_arr[0].concat("_").concat(result_arr[1]); } String border = " border : 1px solid " + res_map.get(res_color) + ";" + "border-left-width: 15px"; item.add(new AttributeAppender("style", border)); Label word = new Label("word", "(" + count + ") " + sense.getLexicalEntry().getLemmaForm()); String postag = (sense.getLexicalEntry().getPartOfSpeech() != null) ? "(" + sense.getLexicalEntry().getPartOfSpeech().name() + ")" : ""; Label pos = new Label("POSTAG", postag); String defString = sense.getDefinitionText(); if (defString == null) { if (sense.getSynset() != null) { defString = sense.getSynset().getDefinitionText(); } } if (defString == null || defString.trim().length() == 0) { defString = "No definition found!"; } Label definition = new Label("definition", new Model<String>(defString.trim())); item.add(word); item.add(pos); item.add(definition); } }; } add(list); setOutputMarkupId(true); }