Java Code Examples for org.apache.wicket.model.PropertyModel#of()
The following examples show how to use
org.apache.wicket.model.PropertyModel#of() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogDialogContent.java From inception with Apache License 2.0 | 6 votes |
private ListView<LogMessage> createMessagesView(IModel<LogMessageGroup> aModel) { return new ListView<LogMessage>("messages", PropertyModel.of(aModel, "messages")) { private static final long serialVersionUID = 5961113080333988246L; @Override protected void populateItem(ListItem<LogMessage> aItem) { IModel<LogMessage> msg = aItem.getModel(); aItem.add(new Label("level", PropertyModel.of(msg, "level"))); aItem.add(new Label("source", PropertyModel.of(msg, "source"))); aItem.add(new Label("message", PropertyModel.of(msg, "message"))); } }; }
Example 2
Source File: ProjectCasDoctorPanel.java From webanno with Apache License 2.0 | 6 votes |
public ProjectCasDoctorPanel(String id, IModel<Project> aProjectModel) { super(id, aProjectModel); setOutputMarkupId(true); Form<FormModel> form = new Form<>("casDoctorForm", PropertyModel.of(this, "formModel")); add(form); CheckBoxMultipleChoice<Class<? extends Repair>> repairs = new CheckBoxMultipleChoice<>( "repairs"); repairs.setModel(PropertyModel.of(this, "formModel.repairs")); repairs.setChoices(CasDoctor.scanRepairs()); repairs.setChoiceRenderer(new ChoiceRenderer<>("simpleName")); repairs.setPrefix("<div class=\"checkbox\">"); repairs.setSuffix("</div>"); repairs.setLabelPosition(LabelPosition.WRAP_AFTER); form.add(repairs); form.add(new LambdaAjaxButton<FormModel>("check", this::actionCheck)); form.add(new LambdaAjaxButton<FormModel>("repair", this::actionRepair)); add(createMessageSetsView()); }
Example 3
Source File: ProjectCasDoctorPanel.java From webanno with Apache License 2.0 | 6 votes |
private ListView<LogMessageSet> createMessageSetsView() { return new ListView<LogMessageSet>("messageSets", PropertyModel.of(this, "formModel.messageSets")) { private static final long serialVersionUID = 8957632000765128508L; @Override protected void populateItem(ListItem<LogMessageSet> aItem) { IModel<LogMessageSet> set = aItem.getModel(); aItem.add(new Label("name", PropertyModel.of(set, "name"))); aItem.add(createMessagesView(set)); } }; }
Example 4
Source File: ProjectCasDoctorPanel.java From webanno with Apache License 2.0 | 6 votes |
private ListView<LogMessage> createMessagesView(IModel<LogMessageSet> aModel) { return new ListView<LogMessage>("messages", PropertyModel.of(aModel, "messages")) { private static final long serialVersionUID = 8957632000765128508L; @Override protected void populateItem(ListItem<LogMessage> aItem) { IModel<LogMessage> msg = aItem.getModel(); aItem.add(new Label("level", PropertyModel.of(msg, "level"))); aItem.add(new Label("source", PropertyModel.of(msg, "source"))); aItem.add(new Label("message", PropertyModel.of(msg, "message"))); } }; }
Example 5
Source File: OrienteerBasePage.java From Orienteer with Apache License 2.0 | 6 votes |
@Override public void initialize() { super.initialize(); showChangedPerspectiveInfo(); IModel<ODocument> perspectiveModel = PropertyModel.of(this, "perspective"); IModel<List<ODocument>> perspectivesModel = new OQueryModel<>("select from " + PerspectivesModule.OPerspective.CLASS_NAME); add(createPerspectivesContainer("perspectivesContainer", perspectiveModel, perspectivesModel)); add(new RecursiveMenuPanel("perspectiveItems", perspectiveModel)); boolean signedIn = OrientDbWebSession.get().isSignedIn(); add(new BookmarkablePageLink<>("login", LoginPage.class).setVisible(!signedIn)); add(new BookmarkablePageLink<>("logout", LogoutPage.class).setVisible(signedIn)); add(feedbacks = new OrienteerFeedbackPanel("feedbacks")); add(new ODocumentPageLink("myProfile", new PropertyModel<>(this, "session.user.document"))); add(createUsernameLabel("username")); add(createSearchForm("searchForm", Model.of())); }
Example 6
Source File: CuratorWorkflowActionBarItemGroup.java From webanno with Apache License 2.0 | 5 votes |
public CuratorWorkflowActionBarItemGroup(String aId, AnnotationPageBase aPage) { super(aId); page = aPage; add(finishDocumentDialog = new ConfirmationDialog("finishDocumentDialog", new StringResourceModel("FinishDocumentDialog.title", this, null), new StringResourceModel("FinishDocumentDialog.text", this, null))); add(finishDocumentLink = new LambdaAjaxLink("showFinishDocumentDialog", this::actionFinishDocument)); finishDocumentLink.setOutputMarkupId(true); finishDocumentLink.add(enabledWhen(this::isEditable)); finishDocumentLink.add(new Label("state") .add(new CssClassNameModifier(LambdaModel.of(this::getStateClass)))); IModel<String> documentNameModel = PropertyModel.of(page.getModel(), "document.name"); add(resetDocumentDialog = new MergeDialog("resetDocumentDialog", new StringResourceModel("ResetDocumentDialog.title", this), new StringResourceModel("ResetDocumentDialog.text", this) .setModel(page.getModel()).setParameters(documentNameModel), documentNameModel)); resetDocumentDialog.setConfirmAction(this::actionResetDocument); add(resetDocumentLink = new LambdaAjaxLink("showResetDocumentDialog", resetDocumentDialog::show)); resetDocumentLink.add(enabledWhen(this::isEditable)); }
Example 7
Source File: AnnotatorWorkflowActionBarItemGroup.java From webanno with Apache License 2.0 | 5 votes |
public AnnotatorWorkflowActionBarItemGroup(String aId, AnnotationPageBase aPage) { super(aId); page = aPage; add(finishDocumentDialog = new ConfirmationDialog("finishDocumentDialog", new StringResourceModel("FinishDocumentDialog.title", this, null), new StringResourceModel("FinishDocumentDialog.text", this, null))); add(finishDocumentLink = new LambdaAjaxLink("showFinishDocumentDialog", this::actionFinishDocument)); finishDocumentLink.setOutputMarkupId(true); finishDocumentLink.add(enabledWhen(() -> page.isEditable())); finishDocumentLink.add(new Label("state") .add(new CssClassNameModifier(LambdaModel.of(this::getStateClass)))); IModel<String> documentNameModel = PropertyModel.of(page.getModel(), "document.name"); add(resetDocumentDialog = new ChallengeResponseDialog("resetDocumentDialog", new StringResourceModel("ResetDocumentDialog.title", this), new StringResourceModel("ResetDocumentDialog.text", this) .setModel(page.getModel()).setParameters(documentNameModel), documentNameModel)); resetDocumentDialog.setConfirmAction(this::actionResetDocument); add(resetDocumentLink = new LambdaAjaxLink("showResetDocumentDialog", resetDocumentDialog::show)); resetDocumentLink.add(enabledWhen(() -> page.isEditable())); }
Example 8
Source File: CurationSidebar.java From inception with Apache License 2.0 | 4 votes |
public CurationSidebar(String aId, IModel<AnnotatorState> aModel, AnnotationActionHandler aActionHandler, CasProvider aCasProvider, AnnotationPage aAnnotationPage) { super(aId, aModel, aActionHandler, aCasProvider, aAnnotationPage); annoPage = aAnnotationPage; mainContainer = new WebMarkupContainer("mainContainer"); mainContainer.setOutputMarkupId(true); add(mainContainer); // set up user-checklist usersForm = createUserSelection(); usersForm.setOutputMarkupId(true); mainContainer.add(usersForm); // set up settings form for curation target Form<Void> settingsForm = createSettingsForm("settingsForm"); settingsForm.setOutputMarkupId(true); settingsForm.setVisible(false); mainContainer.add(settingsForm); // confirmation dialog when using automatic merging (might change user's annos) IModel<String> documentNameModel = PropertyModel.of(annoPage.getModel(), "document.name"); add(mergeConfirm = new MergeDialog("mergeConfirmDialog", new StringResourceModel("mergeConfirmTitle", this), new StringResourceModel("mergeConfirmText", this) .setModel(annoPage.getModel()).setParameters(documentNameModel), documentNameModel)); mainContainer.add(mergeConfirm); // Add empty space message noDocsLabel = new Label("noDocumentsLabel", new ResourceModel("noDocuments")); mainContainer.add(noDocsLabel); // if curation user changed we have to reload the document AnnotatorState state = aModel.getObject(); String currentUser = userRepository.getCurrentUser().getUsername(); long projectid = state.getProject().getId(); User curationUser = curationService.retrieveCurationUser(currentUser, projectid); if (currentUser != null && !currentUser.equals(curationUser.getUsername())) { state.setUser(curationUser); Optional<AjaxRequestTarget> target = RequestCycle.get().find(AjaxRequestTarget.class); annoPage.actionLoadDocument(target.orElseGet(null)); } // user started curating, extension can show suggestions state.setMetaData(CurationMetadata.CURATION_USER_PROJECT, true); }
Example 9
Source File: KendoComboboxTextFeatureEditor.java From webanno with Apache License 2.0 | 4 votes |
@SuppressWarnings("rawtypes") @Override protected AbstractTextComponent createInputField() { return new ComboBox<Tag>("value", PropertyModel.of(getModel(), "tagset")) { private static final long serialVersionUID = -1735694425658462932L; @Override protected IJQueryTemplate newTemplate() { return KendoChoiceDescriptionScriptReference.templateReorderable(); } @Override public void onConfigure(JQueryBehavior aBehavior) { super.onConfigure(aBehavior); aBehavior.setOption("animation", false); aBehavior.setOption("delay", 0); } @Override protected void onConfigure() { super.onConfigure(); // Trigger a re-loading of the tagset from the server as constraints may have // changed the ordering RequestCycle.get().find(AjaxRequestTarget.class).ifPresent(target -> { LOG.trace("onInitialize() requesting datasource re-reading"); target.appendJavaScript(String.join("\n", "try {", " var $w = " + widget(this, ComboBoxBehavior.METHOD) + ";", " if ($w) {", " $w.dataSource.read();", " }", "}", "catch(error) {", " console.error(error);", "}")); }); } }; }
Example 10
Source File: ClassicKendoComboboxTextFeatureEditor.java From webanno with Apache License 2.0 | 4 votes |
@Override protected AbstractTextComponent createInputField() { return new StyledComboBox<Tag>("value", PropertyModel.of(getModel(), "tagset")) { private static final long serialVersionUID = -1735694425658462932L; @Override protected void onInitialize() { super.onInitialize(); // Ensure proper order of the initializing JS header items: first combo box // behavior (in super.onInitialize()), then tooltip. Options options = new Options(DescriptionTooltipBehavior.makeTooltipOptions()); options.set("content", FUNCTION_FOR_TOOLTIP); add(new TooltipBehavior("#" + getMarkupId() + "_listbox *[title]", options) { private static final long serialVersionUID = 1854141593969780149L; @Override protected String $() { // REC: It takes a moment for the KendoDatasource to load the data and // for the Combobox to render the hidden dropdown. I did not find // a way to hook into this process and to get notified when the // data is available in the dropdown, so trying to handle this // with a slight delay hoping that all is set up after 1 second. return "try {setTimeout(function () { " + super.$() + " }, 1000); } catch (err) {}; "; } }); } @Override protected void onConfigure() { super.onConfigure(); // Trigger a re-loading of the tagset from the server as constraints may have // changed the ordering Optional<AjaxRequestTarget> target = RequestCycle.get() .find(AjaxRequestTarget.class); if (target.isPresent()) { LOG.trace("onInitialize() requesting datasource re-reading"); target.get().appendJavaScript( String.format("var $w = %s; if ($w) { $w.dataSource.read(); }", KendoUIBehavior.widget(this, ComboBoxBehavior.METHOD))); } } }; }
Example 11
Source File: ProjectPage.java From webanno with Apache License 2.0 | 4 votes |
private void commonInit() { selectedProject = Model.of(); sidebar = new WebMarkupContainer("sidebar"); sidebar.setOutputMarkupId(true); add(sidebar); tabContainer = new WebMarkupContainer("tabContainer"); tabContainer.setOutputMarkupPlaceholderTag(true); tabContainer.add(visibleWhen(() -> selectedProject.getObject() != null)); add(tabContainer); tabContainer.add(new Label("projectName", PropertyModel.of(selectedProject, "name"))); tabContainer.add(new LambdaAjaxLink("cancel", this::actionCancel)); tabContainer.add(new LambdaAjaxLink("delete", this::actionDelete) .onConfigure((_this) -> _this.setEnabled(selectedProject.getObject() != null && selectedProject.getObject().getId() != null))); tabPanel = new BootstrapAjaxTabbedPanel<ITab>("tabPanel", makeTabs()) { private static final long serialVersionUID = -7356420977522213071L; @Override protected void onConfigure() { super.onConfigure(); setVisible(selectedProject.getObject() != null); } }; tabPanel.setOutputMarkupPlaceholderTag(true); tabContainer.add(tabPanel); projects = new ProjectSelectionPanel("projects", selectedProject); projects.setCreateAction(target -> { selectedProject.setObject(new Project()); // Make sure that default values are loaded tabPanel.visitChildren(new ModelChangedVisitor(selectedProject)); }); projects.setChangeAction(target -> { target.add(tabContainer); // Make sure that any invalid forms are cleared now that we load the new project. // If we do not do this, then e.g. input fields may just continue showing the values // they had when they were marked invalid. tabPanel.visitChildren(new ModelChangedVisitor(selectedProject)); }); sidebar.add(projects); IModel<String> projectNameModel = PropertyModel.of(selectedProject, "name"); add(deleteProjectDialog = new ChallengeResponseDialog("deleteProjectDialog", new StringResourceModel("DeleteProjectDialog.title", this), new StringResourceModel("DeleteProjectDialog.text", this) .setModel(selectedProject).setParameters(projectNameModel), projectNameModel)); deleteProjectDialog.setConfirmAction((target) -> { try { projectService.removeProject(selectedProject.getObject()); if (preSelectedModelMode) { setResponsePage(getApplication().getHomePage()); } else { selectedProject.setObject(null); target.add(getPage()); } } catch (IOException e) { LOG.error("Unable to remove project :" + ExceptionUtils.getRootCauseMessage(e)); error("Unable to remove project " + ":" + ExceptionUtils.getRootCauseMessage(e)); target.addChildren(getPage(), IFeedback.class); } }); }