List of usage examples for org.apache.wicket.ajax AjaxEventBehavior AjaxEventBehavior
public AjaxEventBehavior(String event)
From source file:de.tudarmstadt.ukp.clarin.webanno.monitoring.page.AgreementTable.java
License:Apache License
private Behavior makeDownloadBehavior(final String aKey1, final String aKey2) { return new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 1L; @Override/*from ww w . j a v a 2 s. c o m*/ protected void onEvent(AjaxRequestTarget aTarget) { AJAXDownload download = new AJAXDownload() { private static final long serialVersionUID = 1L; @Override protected IResourceStream getResourceStream() { return new AbstractResourceStream() { private static final long serialVersionUID = 1L; @Override public InputStream getInputStream() throws ResourceStreamNotFoundException { try { AgreementResult result = AgreementTable.this.getModelObject().getStudy(aKey1, aKey2); switch (settings.getObject().exportFormat) { case CSV: return generateCsvReport(result); case DEBUG: return generateDebugReport(result); default: throw new IllegalStateException("Unknown export format [" + settings.getObject().exportFormat + "]"); } } catch (Exception e) { // FIXME Is there some better error handling here? LOG.error("Unable to generate agreement report", e); throw new ResourceStreamNotFoundException(e); } } @Override public void close() throws IOException { // Nothing to do } }; } }; getComponent().add(download); download.initiate(aTarget, "agreement" + settings.getObject().exportFormat.getExtension()); } }; }
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 av a 2s . co m*/ @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. *///from ww w .j a v a 2 s .co 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 www . jav a2 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)); }
From source file:dk.teachus.frontend.components.calendar.PeriodsCalendarPanel.java
License:Apache License
@Override protected final List<String> getTimeSlotContent(final DateMidnight date, final TimeSlot<PeriodBookingTimeSlotPayload> timeSlot, final ListItem<TimeSlot<PeriodBookingTimeSlotPayload>> timeSlotItem) { // Click action timeSlotItem.add(new AjaxEventBehavior("onclick") { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override// w w w . j av a2s .c om protected void onEvent(AjaxRequestTarget target) { onTimeSlotClicked(timeSlot, timeSlot.getStartTime().toDateTime(date), target); target.add(timeSlotItem); } @Override public boolean isEnabled(Component component) { return isTimeSlotBookable(timeSlot); } }); timeSlotItem.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override public String getObject() { return getTimeSlotClass(timeSlot); } })); List<String> contentLines = new ArrayList<String>(); Period period = timeSlot.getPayload().getPeriod(); // Time line DateTime startTime = timeSlot.getStartTime().toDateTime(date); DateTime endTime = timeSlot.getEndTime().toDateTime(date); org.joda.time.Period minutesDuration = new org.joda.time.Period(startTime, endTime, PeriodType.minutes()); String timePriceLine = TIME_FORMAT.print(startTime) + "-" + TIME_FORMAT.print(endTime) + " - " //$NON-NLS-1$//$NON-NLS-2$ + Math.round(minutesDuration.getMinutes()) + "m"; //$NON-NLS-1$ if (period.getPrice() > 0) { timePriceLine += " - " + Formatters.getFormatCurrency().format(period.getPrice()); //$NON-NLS-1$ } contentLines.add(timePriceLine); // Period if (Strings.isEmpty(period.getLocation()) == false) { contentLines.add(period.getLocation()); } appendToTimeSlotContent(contentLines, timeSlot); return contentLines; }
From source file:eu.uqasar.web.components.DropDownModal.java
License:Apache License
/** * Modal with a title and a DropDownChoice * @param id/*from w ww .j a v a 2s . c om*/ * @param headerModel header * @param types Options in DropDownChoice * @param showImmediately */ protected DropDownModal(final String id, final IModel<String> headerModel, List<Class> types, final boolean showImmediately) { super(id); show(showImmediately); header(headerModel); List<String> ls = new ArrayList<>(); for (Class type : types) { ls.add((type).getSimpleName()); } metaDataTypes = new DropDownChoice<>("metaDataTypes", new Model(), ls); metaDataTypes.add(new AjaxEventBehavior("onchange") { @Override protected void onEvent(AjaxRequestTarget target) { typeSelected = metaDataTypes.getChoices().get(Integer.valueOf(metaDataTypes.getInput())); } }); add(metaDataTypes).setEscapeModelStrings(false); setUseKeyboard(false); }
From source file:eu.uqasar.web.components.historical.SnapshotRecoverConfirmationModal.java
License:Apache License
public SnapshotRecoverConfirmationModal(String id, final Project project) { super(id);// ww w. j a v a2 s . com add(new Label("message", new StringResourceModel("snapshot.confirmation.modal.message", this, null))); header(new StringResourceModel("snapshot.confirmation.modal.header", this, null)); snapDropDown = new DropDownChoice<>("snapshotName", snapShotService.getProjectSnapshot(project)); snapDropDown.add(new AjaxEventBehavior("onchange") { private static final long serialVersionUID = -5413222633224844355L; @Override protected void onEvent(AjaxRequestTarget target) { snap = snapDropDown.getChoices().get(Integer.valueOf(snapDropDown.getInput())); } }); add(snapDropDown); addButton(submitButton = new ModalActionButton(this, Buttons.Type.Info, new StringResourceModel("button.snapshot.confirm", this, null), true) { private static final long serialVersionUID = 5342016192194431918L; @Override protected void onConfigure() { super.onConfigure(); if (snapShotService.getProjectSnapshot(project).size() == 0) { setEnabled(false); } else { setEnabled(true); } } @Override protected void onAfterClick(AjaxRequestTarget target) { onConfirmed(target); closeDeleteConfirmationModal(SnapshotRecoverConfirmationModal.this, target); } }); addButton(new ModalActionButton(this, Buttons.Type.Default, new StringResourceModel("button.snapshot.cancel", this, null), true) { private static final long serialVersionUID = 4299345298752864106L; @Override protected void onAfterClick(AjaxRequestTarget target) { closeDeleteConfirmationModal(SnapshotRecoverConfirmationModal.this, target); } }); }
From source file:eu.uqasar.web.components.navigation.notification.complexity.ComplexityNotificationLink.java
License:Apache License
public ComplexityNotificationLink(String id, PageParameters parameters, final IModel<ComplexityNotification> model) { super(id, ProjectViewPage.class, BaseTreePage.forProject(model.getObject().getProject()), model); add(new Label("metric.name", model.getObject().getName())); //set containers setIcon(new IconType("exclamation-sign")); get("notification.container").add(new AttributeModifier("style", "width:95%;")); get("notification.container").add(new AttributeModifier("class", "notification project red")); add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = -4295786924073241665L; @Override// w w w .j av a 2 s. c o m protected void onEvent(AjaxRequestTarget target) { setResponsePage(ProjectViewPage.class, getPageParameters().add("id", getModelObject().getProject().getId())); } }); final WebMarkupContainer deleteContainer = new WebMarkupContainer("delete"); final String deleteMessage = new StringResourceModel("delete.message", this, null).getString(); deleteContainer.add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 8973155682310698578L; @Override protected void onEvent(AjaxRequestTarget target) { UQasarUtil.getNotifications().remove(model.getObject()); setResponsePage(AboutPage.class, BasePage.appendSuccessMessage(getPageParameters(), deleteMessage)); } }); deleteContainer.setOutputMarkupId(true); add(deleteContainer); // tooltip TooltipConfig confConfig = new TooltipConfig().withPlacement(TooltipConfig.Placement.right); deleteContainer.add(new TooltipBehavior(new StringResourceModel("delete.title", this, null), confConfig)); }
From source file:eu.uqasar.web.components.navigation.notification.dashboard.DashboardSharedNotificationLink.java
License:Apache License
public DashboardSharedNotificationLink(String id, PageParameters parameters, IModel<DashboardSharedNotification> model) { super(id, DashboardViewPage.class, parameters.add("id", model.getObject().getDashboard().getId()), model); //get user who shared dashboard add(new Label("dashboard.user", model.getObject().getDashboard().getSharedBy())); //set containers setIcon(new IconType("dashboard")); get("notification.container").add(new AttributeModifier("style", "width:95%;")); get("notification.container").add(new AttributeModifier("class", "notification project green")); add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = -4295786924073241665L; @Override//www. ja va2 s . c o m protected void onEvent(AjaxRequestTarget target) { getModelObject().getDashboard().setSharedBy(null); setResponsePage(DashboardViewPage.class, getPageParameters().add("id", getModelObject().getDashboard().getId())); } }); }
From source file:eu.uqasar.web.components.navigation.notification.metric.MetricNotificationLink.java
License:Apache License
public MetricNotificationLink(String id, PageParameters parameters, final IModel<MetricNeedsToBeEdited> model) { super(id, MetricViewPage.class, BaseTreePage.forMetric(model.getObject().getMetric()), model); add(new Label("metric.name", getMetric().getName())); // Find ways to get Due date here and print it. if (model.getObject().getDueDays() == 0) { add(new Label("metric.due", new StringResourceModel("metric.needs.to.initialize", null, (0)))); } else {/*from w w w . j av a 2s . c om*/ add(new Label("metric.due", new StringResourceModel("metric.about.to.due", null, (model.getObject().getDueDays() + 7)))); } setIcon(new IconType("exclamation-sign")); get("notification.container") .add(new CssClassNameAppender("project", getMetric().getQualityStatus().getCssClassName())); final WebMarkupContainer deleteContainer = new WebMarkupContainer("delete"); final String deleteMessage = new StringResourceModel("delete.message", this, null).getString(); deleteContainer.add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 8973155682310698578L; @Override protected void onEvent(AjaxRequestTarget target) { UQasarUtil.getNotifications().remove(model.getObject()); setResponsePage(AboutPage.class, BasePage.appendSuccessMessage(getPageParameters(), deleteMessage)); } }); deleteContainer.setOutputMarkupId(true); add(deleteContainer); }