List of usage examples for org.apache.wicket.markup.html.list ListView ListView
public ListView(final String id)
From source file:de.elatexam.editor.components.panels.tasks.mc.McPreviewPanel.java
License:Open Source License
@Override protected void onInitialize() { super.onInitialize(); add(new ListView<McSubTaskDefAnswerDefinitionsItem>("answerDefinitionsItems") { @Override//from w ww . j av a2 s. c om protected void populateItem(ListItem<McSubTaskDefAnswerDefinitionsItem> item) { McAnswersCorrectnessModel answerCorrectnessModel = new McAnswersCorrectnessModel(item.getModel()); item.add(new CheckBox("correct", answerCorrectnessModel).setEnabled(false)); item.add(new Label("value", new McAnswersModel(item.getModel()))); } }); }
From source file:de.tudarmstadt.ukp.csniper.webapp.evaluation.page.EvaluationPage.java
License:Apache License
/** * Constructor that is invoked when page is invoked without a session. *//*from w w w .j ava 2 s . c om*/ @SuppressWarnings({ "serial" }) public EvaluationPage() { contextViewsContainer = new WebMarkupContainer("contextViewsContainer") { { contextViews = new ListView<ContextView>("contextViews") { @Override protected void populateItem(ListItem aItem) { aItem.add((Component) aItem.getModelObject()); } }; add(contextViews); } }; contextViewsContainer.setOutputMarkupId(true); add(contextViewsContainer); columns = new ArrayList<IColumn<EvaluationResult, String>>(); columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("")) { @Override public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem, String aComponentId, final IModel<EvaluationResult> model) { EmbeddableImage iconContext = new EmbeddableImage(aComponentId, new ContextRelativeResource("images/context.png")); iconContext.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget aTarget) { try { contextViews .setList(asList(new ContextView(contextProvider, model.getObject().getItem()))); aTarget.add(contextViewsContainer); } catch (IOException e) { aTarget.add(getFeedbackPanel()); error("Unable to load context: " + e.getMessage()); } } }); iconContext.add(new AttributeModifier("class", new Model<String>("clickableElement"))); aCellItem.add(iconContext); } }); columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("")) { @Override public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem, final String aComponentId, final IModel<EvaluationResult> model) { // PopupLink pl = new PopupLink(aComponentId, new AnalysisPage(model.getObject() // .getItem()), "analysis", "Analyse", 800, 600); // pl.add(new AttributeModifier("class", new Model<String>("clickableElement"))); // aCellItem.add(pl); EmbeddableImage iconAnalysis = new EmbeddableImage(aComponentId, new ContextRelativeResource("images/analysis.png")); iconAnalysis.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget aTarget) { EvaluationItem item = model.getObject().getItem(); CachedParse cachedTree = repository.getCachedParse(item); ParseTreeResource ptr; if (cachedTree != null) { ptr = new ParseTreeResource(cachedTree.getPennTree()); } else { if (pp == null) { pp = new ParsingPipeline(); } CasHolder ch = new CasHolder(pp.parseInput("stanfordParser", corpusService.getCorpus(item.getCollectionId()).getLanguage(), item.getCoveredText())); ptr = new ParseTreeResource(ch); } analysisModal.setContent(new AnalysisPanel(analysisModal.getContentId(), ptr)); analysisModal.show(aTarget); } }); iconAnalysis.add(new AttributeModifier("class", new Model<String>("clickableElement"))); aCellItem.add(iconAnalysis); } }); // columns.add(new PropertyColumn(new Model<String>("ID"), "id", "id")); // columns.add(new PropertyColumn(new Model<String>("Collection"), "item.collectionId", // "item.collectionId")); columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Doc"), "item.documentId", "item.documentId")); // columns.add(new PropertyColumn(new Model<String>("Begin"), "item.beginOffset", // "item.beginOffset")); // columns.add(new PropertyColumn(new Model<String>("End"), "item.endOffset", // "item.endOffset")); columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Left"), "item.leftContext", "item.leftContext") { @Override public String getCssClass() { return contextAvailable ? "leftContext" : " hideCol"; } }); columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Match"), "item.match", "item.match") { @Override public String getCssClass() { return contextAvailable ? "match nowrap" : null; } }); columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Right"), "item.rightContext", "item.rightContext") { @Override public String getCssClass() { return contextAvailable ? "rightContext" : " hideCol"; } }); columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("Label"), "result") { @Override public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem, String aComponentId, final IModel<EvaluationResult> model) { final Label resultLabel = new Label(aComponentId, new PropertyModel(model, "result")); resultLabel.setOutputMarkupId(true); aCellItem.add(resultLabel); if (showResultColumns) { aCellItem.add(AttributeModifier.replace("class", new Model<String>("editable " + model.getObject().getResult().toLowerCase()))); } aCellItem.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget aTarget) { EvaluationResult result = model.getObject(); // cycle to next result Mark newResult = Mark.fromString(result.getResult()).next(); // update database result.setResult(newResult.getTitle()); repository.updateEvaluationResult(result); // update DataTable aCellItem.add(AttributeModifier.replace("class", new Model<String>("editable " + newResult.getTitle().toLowerCase()))); aTarget.add(resultLabel, aCellItem); } }); } @Override public String getCssClass() { return (showResultColumns ? "" : " hideCol"); } }); columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("Comment"), "comment") { @Override public void populateItem(Item<ICellPopulator<EvaluationResult>> cellItem, String componentId, final IModel<EvaluationResult> model) { cellItem.add( new AjaxEditableLabel<String>(componentId, new PropertyModel<String>(model, "comment")) { @Override public void onSubmit(final AjaxRequestTarget aTarget) { super.onSubmit(aTarget); EvaluationResult result = model.getObject(); // get new comment String newComment = getEditor().getInput(); // update database result.setComment(newComment); repository.updateEvaluationResult(result); } @Override public void onError(AjaxRequestTarget aTarget) { super.onError(aTarget); aTarget.add(getFeedbackPanel()); } }.add(new DbFieldMaxLengthValidator(projectRepository, "EvaluationResult", "comment"))); } @Override public String getCssClass() { return "editable" + (showResultColumns ? "" : " hideCol"); } }); // collection and type add(parentOptionsForm = new ParentOptionsForm("parentOptions")); tabs = new Tabs("tabs"); tabs.setVisible(false); // query tab tabs.add(queryForm = new QueryForm("queryForm")); // revision tab tabs.add(reviewForm = new ReviewForm("reviewForm")); // completion tab tabs.add(new Form("completeForm") { { add(new ExtendedIndicatingAjaxButton("completeButton", new Model<String>("Complete"), new Model<String>("Running query ...")) { { setDefaultFormProcessing(false); } @Override public void onSubmit(AjaxRequestTarget aTarget, Form<?> aForm) { AnnotationType type = parentOptionsForm.typeInput.getModelObject(); if (type == null) { error(LocalizerUtil.getString(parentOptionsForm.typeInput, "Required")); aTarget.add(getFeedbackPanel()); return; } ParentOptionsFormModel pModel = parentOptionsForm.getModelObject(); String user = SecurityContextHolder.getContext().getAuthentication().getName(); List<String> otherUsers = new ArrayList<String>(repository.listUsers()); otherUsers.remove(user); // get items, create/persist results List<EvaluationItem> items = repository.listEvaluationResultsMissing(pModel.collectionId, pModel.type.getName(), user, otherUsers); List<EvaluationResult> results = createEvaluationResults(items); repository.writeEvaluationResults(results); // persis. results: hide saveButton, show result columns and filter options limitForm.setVisible(false); filterForm.setChoices(ResultFilter.values()); showColumnsForm.setVisible(true && !pModel.type.getAdditionalColumns().isEmpty()); showResultColumns(true); saveButton.setVisible(false); predictButton.setVisible(true); samplesetButton.setVisible(true); // update dataprovider dataProvider = new SortableEvaluationResultDataProvider(results); dataProvider.setSort("item.documentId", SortOrder.ASCENDING); dataProvider.setFilter(ResultFilter.ALL); // then update the table resultTable = resultTable.replaceWith(new CustomDataTable<EvaluationResult>("resultTable", getAllColumns(pModel.type), dataProvider, ROWS_PER_PAGE)); contextAvailable = false; updateComponents(aTarget); } @Override public void onError(AjaxRequestTarget aTarget, Form<?> aForm) { super.onError(aTarget, aForm); // Make sure the feedback messages are rendered aTarget.add(getFeedbackPanel()); } }); } }); // sampleset tab tabs.add(samplesetForm = new SamplesetForm("samplesetForm")); // sampleset tab tabs.add(findForm = new FindForm("findForm")); add(tabs); add(new Label("description", new LoadableDetachableModel<String>() { @Override protected String load() { Object value = PropertyResolver.getValue("type.description", parentOptionsForm.getModelObject()); if (value != null) { RenderContext context = new BaseRenderContext(); RenderEngine engine = new BaseRenderEngine(); return engine.render(String.valueOf(value), context); } else { return getString("page.selectTypeHint"); } } }).setEscapeModelStrings(false)); add(filterForm = (FilterForm) new FilterForm("filterForm").setOutputMarkupPlaceholderTag(true)); add(showColumnsForm = (ShowColumnsForm) new ShowColumnsForm("showColumnsForm") .setOutputMarkupPlaceholderTag(true)); add(resultTable = new Label("resultTable").setOutputMarkupId(true)); add(predictionModal = new ModalWindow("predictionModal")); final PredictionPanel predictionPanel = new PredictionPanel(predictionModal.getContentId()); predictionModal.setContent(predictionPanel); predictionModal.setTitle("Predict results"); predictionModal.setAutoSize(false); predictionModal.setInitialWidth(550); predictionModal.setInitialHeight(350); predictionModal.setCloseButtonCallback(new CloseButtonCallback() { @Override public boolean onCloseButtonClicked(AjaxRequestTarget aTarget) { predictionPanel.cancel(aTarget); return true; } }); add(samplesetModal = new ModalWindow("samplesetModal")); samplesetModal.setContent(new SamplesetPanel(samplesetModal.getContentId())); samplesetModal.setTitle("Create / Extend sampleset"); samplesetModal.setAutoSize(true); add(analysisModal = new ModalWindow("analysisModal")); analysisModal.setTitle("Parse tree"); analysisModal.setInitialWidth(65 * 16); analysisModal.setInitialHeight(65 * 9); // autosize does not work... // analysisModal.setAutoSize(true); add(new Form("saveForm") { { add(saveButton = (ExtendedIndicatingAjaxButton) new ExtendedIndicatingAjaxButton("saveButton", new Model<String>("Start annotating"), new Model<String>("Preparing ...")) { @Override protected void onSubmit(AjaxRequestTarget aTarget, Form<?> aForm) { // persist items and results List<EvaluationItem> items = dataProvider.getItems(); items = repository.writeEvaluationItems(items); List<EvaluationResult> results = createEvaluationResults(items); dataProvider.setResults(results); repository.writeEvaluationResults(results); // save results, query ParentOptionsFormModel pModel = parentOptionsForm.getModelObject(); String user = SecurityContextHolder.getContext().getAuthentication().getName(); QueryFormModel model = queryForm.getModelObject(); if (model.engine != null && !StringUtils.isBlank(model.query)) { repository.recordQuery(model.engine.getName(), model.query, pModel.collectionId, pModel.type.getName(), model.comment, user); } // hide saveButton, show result columns and filter options limitForm.setVisible(false); filterForm.setChoices(ResultFilter.values()); showColumnsForm.setVisible(true && !pModel.type.getAdditionalColumns().isEmpty()); showResultColumns(true); saveButton.setVisible(false); predictButton.setVisible(true); samplesetButton.setVisible(true); updateComponents(aTarget); } }.setOutputMarkupPlaceholderTag(true)); add(predictButton = (ExtendedIndicatingAjaxButton) new ExtendedIndicatingAjaxButton("predictButton", new Model<String>("Predict results"), new Model<String>("Predicting ...")) { @Override protected void onSubmit(AjaxRequestTarget aTarget, Form<?> aForm) { aTarget.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); predictionModal.show(aTarget); } }.setOutputMarkupPlaceholderTag(true)); add(samplesetButton = (ExtendedIndicatingAjaxButton) new ExtendedIndicatingAjaxButton( "samplesetButton", new Model<String>("Save results as sampleset"), new Model<String>("Saving...")) { @Override public void onSubmit(AjaxRequestTarget aTarget, Form<?> aForm) { samplesetModal.show(aTarget); } }.setOutputMarkupPlaceholderTag(true)); } }); add(limitForm = (LimitForm) new LimitForm("limit").setOutputMarkupPlaceholderTag(true)); // at start, don't show: save button, results columns, filter limitForm.setVisible(false); filterForm.setChoices(); showColumnsForm.setVisible(false); showResultColumns(false); saveButton.setVisible(false); predictButton.setVisible(false); samplesetButton.setVisible(false); }
From source file:de.tudarmstadt.ukp.csniper.webapp.search.page.SearchPage.java
License:Apache License
/** * Constructor that is invoked when page is invoked without a session. */// ww w . ja va 2 s . c o m @SuppressWarnings({ "serial" }) public SearchPage() { contextViewsContainer = new WebMarkupContainer("contextViewsContainer") { { contextViews = new ListView<ContextView>("contextViews") { @Override protected void populateItem(ListItem aItem) { aItem.add((Component) aItem.getModelObject()); } }; add(contextViews); } }; contextViewsContainer.setOutputMarkupId(true); add(contextViewsContainer); columns = new ArrayList<IColumn<EvaluationResult, String>>(); columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("")) { @Override public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem, String aComponentId, final IModel<EvaluationResult> model) { EmbeddableImage iconContext = new EmbeddableImage(aComponentId, new ContextRelativeResource("images/context.png")); iconContext.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget aTarget) { try { contextViews .setList(asList(new ContextView(contextProvider, model.getObject().getItem()))); aTarget.add(contextViewsContainer); } catch (IOException e) { error("Unable to load context: " + e.getMessage()); aTarget.add(getFeedbackPanel()); } } }); iconContext.add(new AttributeModifier("class", new Model<String>("clickableElement"))); aCellItem.add(iconContext); } }); columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("")) { @Override public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem, String aComponentId, final IModel<EvaluationResult> model) { EmbeddableImage iconAnalysis = new EmbeddableImage(aComponentId, new ContextRelativeResource("images/analysis.png")); iconAnalysis.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget aTarget) { EvaluationItem item = model.getObject().getItem(); CachedParse cachedTree = repository.getCachedParse(item); ParseTreeResource ptr; if (cachedTree != null) { ptr = new ParseTreeResource(cachedTree.getPennTree()); } else { if (pp == null) { pp = new ParsingPipeline(); } CasHolder ch = new CasHolder(pp.parseInput("stanfordParser", corpusService.getCorpus(item.getCollectionId()).getLanguage(), item.getCoveredText())); ptr = new ParseTreeResource(ch); } analysisModal.setContent(new AnalysisPanel(analysisModal.getContentId(), ptr)); analysisModal.show(aTarget); } }); iconAnalysis.add(new AttributeModifier("class", new Model<String>("clickableElement"))); aCellItem.add(iconAnalysis); } }); columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Doc"), "item.documentId", "item.documentId")); columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Left"), "item.leftContext", "item.leftContext") { @Override public String getCssClass() { return contextAvailable ? "leftContext" : " hideCol"; } }); columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Match"), "item.match", "item.match") { @Override public String getCssClass() { return contextAvailable ? "match nowrap" : null; } }); columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Right"), "item.rightContext", "item.rightContext") { @Override public String getCssClass() { return contextAvailable ? "rightContext" : " hideCol"; } }); add(queryForm = new QueryForm("queryForm")); add(limitForm = (LimitForm) new LimitForm("limit").setOutputMarkupPlaceholderTag(true)); add(resultTable = new Label("resultTable").setOutputMarkupId(true)); add(analysisModal = new ModalWindow("analysisModal")); analysisModal.setTitle("Parse tree"); analysisModal.setInitialWidth(65 * 16); analysisModal.setInitialHeight(65 * 9); // autosize does not work... // analysisModal.setAutoSize(true); // at start, don't show: save button, results columns, filter limitForm.setVisible(false); }
From source file:de.tudarmstadt.ukp.csniper.webapp.statistics.page.StatisticsPage.java
License:Apache License
/** * Constructor that is invoked when page is invoked without a session. *//*from ww w .ja va 2 s . com*/ public StatisticsPage() { super(); contextViewsContainer = new WebMarkupContainer("contextViewsContainer") { { contextViews = new ListView<ContextView>("contextViews") { @Override protected void populateItem(ListItem aItem) { aItem.add((Component) aItem.getModelObject()); } }; add(contextViews); } }; contextViewsContainer.setOutputMarkupId(true); add(contextViewsContainer); columns.add(new AbstractColumn<AggregatedEvaluationResult, String>(new Model<String>("")) { @Override public void populateItem(final Item<ICellPopulator<AggregatedEvaluationResult>> aCellItem, String aComponentId, final IModel<AggregatedEvaluationResult> model) { EmbeddableImage iconContext = new EmbeddableImage(aComponentId, new ContextRelativeResource("images/context.png")); iconContext.add(new AjaxEventBehavior("onclick") { @Override protected void onEvent(AjaxRequestTarget aTarget) { try { contextViews .setList(asList(new ContextView(contextProvider, model.getObject().getItem()))); aTarget.add(contextViewsContainer); } catch (IOException e) { error("Unable to load context: " + e.getMessage()); } } }); iconContext.add(new AttributeModifier("class", new Model<String>("clickableElement"))); aCellItem.add(iconContext); } }); columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Type"), "item.type", "item.type") { private static final long serialVersionUID = 1L; @Override public String getCssClass() { return super.getCssClass() + " nowrap"; } }); columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Collection"), "item.collectionId", "item.collectionId") { private static final long serialVersionUID = 1L; @Override public String getCssClass() { return super.getCssClass() + " nowrap"; } }); columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Document"), "item.documentId", "item.documentId") { private static final long serialVersionUID = 1L; @Override public String getCssClass() { return super.getCssClass() + " nowrap"; } }); columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Item"), "item.coveredText", "item.coveredText")); columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("#Correct"), "correct", "correct")); columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("#Wrong"), "wrong", "wrong")); columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("#Incomplete"), "incomplete", "incomplete")); columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Aggregated"), "classification", "classification")); // { // private static final long serialVersionUID = 1L; // // @Override // public void populateItem(Item<ICellPopulator<AggregatedEvaluationResult>> aCellItem, // String aComponentId, IModel<AggregatedEvaluationResult> aRowModel) // { // StatisticsFormModel sModel = statisticsForm.getModelObject(); // ResultFilter aggregated = aRowModel.getObject().getClassification(sModel.users, // sModel.userThreshold, sModel.confidenceThreshold); // aCellItem.add(new Label(aComponentId, aggregated.getLabel())); // } // }); columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Confidence"), "confidence", "confidence")); // { // private static final long serialVersionUID = 1L; // // @Override // public void populateItem(Item<ICellPopulator<AggregatedEvaluationResult>> aCellItem, // String aComponentId, IModel<AggregatedEvaluationResult> aRowModel) // { // StatisticsFormModel sModel = statisticsForm.getModelObject(); // double confidence = aRowModel.getObject().getConfidence(sModel.users, // sModel.userThreshold); // aCellItem.add(new Label(aComponentId, Double.toString(confidence))); // } // }); add(exportModal = new ModalWindow("exportModal")); final ExportPanel exportPanel = new ExportPanel(exportModal.getContentId()); exportModal.setContent(exportPanel); exportModal.setTitle("Export"); exportModal.setInitialWidth(550); exportModal.setInitialHeight(350); exportModal.setCloseButtonCallback(new CloseButtonCallback() { @Override public boolean onCloseButtonClicked(AjaxRequestTarget aTarget) { exportPanel.cancel(aTarget); return true; } }); add(exportDownload = new AjaxFileDownload()); add(statisticsForm = new StatisticsForm("statisticsForm")); add(displayOptions = (WebMarkupContainer) new WebMarkupContainer("displayOptions") { private static final long serialVersionUID = 1L; { add(new Label("filterLabel", new PropertyModel<List<ResultFilter>>(statisticsForm, "modelObject.filters"))); add(new Label("collectionIdLabel", new PropertyModel<Set<String>>(statisticsForm, "modelObject.collections"))); add(new Label("typeLabel", new PropertyModel<Set<AnnotationType>>(statisticsForm, "modelObject.types")) { private static final long serialVersionUID = 1L; @Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { Set<AnnotationType> types = (Set<AnnotationType>) getDefaultModelObject(); List<String> typeNames = new ArrayList<String>(); for (AnnotationType t : types) { typeNames.add(t.getName()); } Collections.sort(typeNames); replaceComponentTagBody(markupStream, openTag, typeNames.toString()); }; }); } }.setOutputMarkupPlaceholderTag(true).setVisible(false)); add(resultTable = new Label("resultTable").setOutputMarkupId(true)); }