Java Code Examples for org.apache.wicket.markup.repeater.Item#getModelObject()
The following examples show how to use
org.apache.wicket.markup.repeater.Item#getModelObject() .
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: QualifierFeatureEditor.java From inception with Apache License 2.0 | 5 votes |
private void setSelectedKBItem(KBHandle value, Item<LinkWithRoleModel> aItem, AnnotationFeature linkedAnnotationFeature) { if (aItem.getModelObject().targetAddr != -1) { try { CAS cas = actionHandler.getEditorCas(); FeatureStructure selectedFS = selectFsByAddr(cas, aItem.getModelObject().targetAddr); WebAnnoCasUtil.setFeature(selectedFS, linkedAnnotationFeature, value != null ? value.getIdentifier() : value); LOG.info("change the value"); qualifierModel.detach(); // Save the CAS. This must be done explicitly here since the KBItem dropdown // is not the focus-component of this editor. In fact, there could be multiple // KBItem dropdowns in this feature editor since we can have multilpe modifiers. // For focus-components, the AnnotationFeatureForm already handles adding the // saving behavior. actionHandler.actionCreateOrUpdate( RequestCycle.get().find(AjaxRequestTarget.class).get(), cas); } catch (Exception e) { LOG.error("Error: " + e.getMessage(), e); error("Error: " + e.getMessage()); } } }
Example 2
Source File: FeatureEditorListPanel.java From webanno with Apache License 2.0 | 4 votes |
@Override protected void populateItem(final Item<FeatureState> item) { LOG.trace("FeatureEditorPanelContent.populateItem(" + item.getModelObject().feature.getUiName() + ": " + item.getModelObject().value + ")"); // Feature editors that allow multiple values may want to update themselves, // e.g. to add another slot. item.setOutputMarkupId(true); final FeatureState featureState = item.getModelObject(); final FeatureEditor editor; // Look up a suitable editor and instantiate it FeatureSupport featureSupport = featureSupportRegistry .getFeatureSupport(featureState.feature); AnnotationDetailEditorPanel editorPanel = findParent(AnnotationDetailEditorPanel.class); editor = featureSupport.createEditor("editor", FeatureEditorListPanel.this, editorPanel, getModel(), item.getModel()); // We need to enable the markup ID here because we use it during the AJAX behavior // that automatically saves feature editors on change/blur. // Check addAnnotateActionBehavior. editor.setOutputMarkupId(true); editor.setOutputMarkupPlaceholderTag(true); // Ensure that markup IDs of feature editor focus components remain constant across // refreshes of the feature editor panel. This is required to restore the focus. editor.getFocusComponent().setOutputMarkupId(true); editor.getFocusComponent() .setMarkupId(ID_PREFIX + editor.getModelObject().feature.getId()); if (!featureState.feature.getLayer().isReadonly()) { AnnotatorState state = getModelObject(); // Whenever it is updating an annotation, it updates automatically when a // component for the feature lost focus - but updating is for every component // edited LinkFeatureEditors must be excluded because the auto-update will break // the ability to add slots. Adding a slot is NOT an annotation action. if ( state.getSelection().getAnnotation().isSet() && !(editor instanceof LinkFeatureEditor) ) { editor.addFeatureUpdateBehavior(); } else if (!(editor instanceof LinkFeatureEditor)) { editor.getFocusComponent().add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 5179816588460867471L; @Override protected void onUpdate(AjaxRequestTarget aTarget) { owner.refresh(aTarget); } }); } // Add tooltip on label StringBuilder tooltipTitle = new StringBuilder(); tooltipTitle.append(featureState.feature.getUiName()); if (featureState.feature.getTagset() != null) { tooltipTitle.append(" ("); tooltipTitle.append(featureState.feature.getTagset().getName()); tooltipTitle.append(')'); } Component labelComponent = editor.getLabelComponent(); // labelComponent.setMarkupId( // ID_PREFIX + editor.getModelObject().feature.getId() + "-w-lbl"); labelComponent.add(new AttributeAppender("style", "cursor: help", ";")); labelComponent.add(new DescriptionTooltipBehavior(tooltipTitle.toString(), featureState.feature.getDescription())); } else { editor.getFocusComponent().setEnabled(false); } item.add(editor); }
Example 3
Source File: SemesterPage.java From sakai with Educational Community License v2.0 | 4 votes |
private DataView<Semester>createDataView(IDataProvider<Semester> listDataProvider, final SemesterForm semesterEditor){ DataView<Semester> dataView = new DataView<Semester>("row", listDataProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item<Semester> item) { Semester sem = item.getModelObject(); RepeatingView repeatingView = new RepeatingView("dataRow"); CompoundPropertyModel<Semester> model = new CompoundPropertyModel<Semester>(sem); repeatingView.add(new Label(repeatingView.newChildId(), model.bind(PROP_EID))); repeatingView.add(new Label(repeatingView.newChildId(), model.bind(PROP_TITLE))); repeatingView.add(new Label(repeatingView.newChildId(),model.bind(PROP_START))); repeatingView.add(new Label(repeatingView.newChildId(),model.bind(PROP_END))); repeatingView.add(new Label(repeatingView.newChildId(), model.bind(PROP_DESC))); repeatingView.add(new Label(repeatingView.newChildId(), getString(sem.isCurrent()?"lbl_yes":"lbl_no"))); ActionLink<Semester> el = new ActionLink<Semester>(model) { private static final long serialVersionUID = 1L; @Override public void onClick() { IModel <Semester> m = getModel(); Semester selected = m.getObject(); semesterEditor.setModelObject(selected); semesterEditor.setUpdateEID(selected.getEid()); SemesterPage.this.clearFeedback(); } }; el.setBody(new ResourceModel(LABEL_EDIT)); repeatingView.add(new ActionPanel<Semester>(repeatingView.newChildId(), el)); item.add(repeatingView); } }; dataView.setItemsPerPage(DEFAULT_ITEMS_PER_PAGE); return dataView; }
Example 4
Source File: SemesterPage.java From sakai with Educational Community License v2.0 | 4 votes |
private DataView<Semester>createDataView(IDataProvider<Semester> listDataProvider, final SemesterForm semesterEditor){ DataView<Semester> dataView = new DataView<Semester>("row", listDataProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item<Semester> item) { Semester sem = item.getModelObject(); RepeatingView repeatingView = new RepeatingView("dataRow"); CompoundPropertyModel<Semester> model = new CompoundPropertyModel<Semester>(sem); repeatingView.add(new Label(repeatingView.newChildId(), model.bind(PROP_EID))); repeatingView.add(new Label(repeatingView.newChildId(), model.bind(PROP_TITLE))); repeatingView.add(new Label(repeatingView.newChildId(),model.bind(PROP_START))); repeatingView.add(new Label(repeatingView.newChildId(),model.bind(PROP_END))); repeatingView.add(new Label(repeatingView.newChildId(), model.bind(PROP_DESC))); repeatingView.add(new Label(repeatingView.newChildId(), getString(sem.isCurrent()?"lbl_yes":"lbl_no"))); ActionLink<Semester> el = new ActionLink<Semester>(model) { private static final long serialVersionUID = 1L; @Override public void onClick() { IModel <Semester> m = getModel(); Semester selected = m.getObject(); semesterEditor.setModelObject(selected); semesterEditor.setUpdateEID(selected.getEid()); SemesterPage.this.clearFeedback(); } }; el.setBody(new ResourceModel(LABEL_EDIT)); repeatingView.add(new ActionPanel<Semester>(repeatingView.newChildId(), el)); item.add(repeatingView); } }; dataView.setItemsPerPage(DEFAULT_ITEMS_PER_PAGE); return dataView; }
Example 5
Source File: RecommendedArtifactPortfolioPanel.java From artifact-listener with Apache License 2.0 | 4 votes |
@Override protected void addItemColumns(final Item<Artifact> item, IModel<? extends Artifact> itemModel) { item.setOutputMarkupId(true); Artifact artifact = item.getModelObject(); final IModel<Artifact> artifactModel = new ArtifactModel(Model.of(item.getModelObject().getArtifactKey())); final ArtifactLastVersionModel artifactLastVersionModel = new ArtifactLastVersionModel(artifactModel); item.add(new ClassAttributeAppender(new LoadableDetachableModel<String>() { private static final long serialVersionUID = 1L; @Override protected String load() { User user = MavenArtifactNotifierSession.get().getUser(); boolean isFollowed = user != null && userService.isFollowedArtifact(user, item.getModelObject()); boolean isDeprecated = artifactModel.getObject() != null && ArtifactDeprecationStatus.DEPRECATED.equals(artifactModel.getObject().getDeprecationStatus()); return isFollowed ? "success" : (isDeprecated ? "warning" : null); } })); // GroupId column item.add(new Label("groupId", BindingModel.of(artifactModel, Binding.artifact().group().groupId()))); item.add(new ExternalLink("groupLink", mavenCentralSearchUrlService.getGroupUrl(artifact.getGroup().getGroupId()))); // ArtifactId column Link<Void> localArtifactLink = ArtifactDescriptionPage.linkDescriptor(artifactModel).link("localArtifactLink"); localArtifactLink.add(new Label("artifactId", BindingModel.of(artifactModel, Binding.artifact().artifactId()))); item.add(localArtifactLink); item.add(new ExternalLink("artifactLink", mavenCentralSearchUrlService.getArtifactUrl(artifact.getGroup().getGroupId(), artifact.getArtifactId()))); // LastVersion, lastUpdateDate columns item.add(new Label("synchronizationPlannedPlaceholder", new ResourceModel("artifact.follow.synchronizationPlanned")) { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); setVisible(artifactModel.getObject() != null && !artifactLastVersionModel.isLastVersionAvailable()); } }); WebMarkupContainer localContainer = new WebMarkupContainer("followedArtifact") { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); setVisible(artifactLastVersionModel.isLastVersionAvailable()); } }; localContainer.add(new ArtifactVersionTagPanel("latestVersion", Model.of(artifactLastVersionModel.getLastVersion()))); String latestVersion = (artifact.getLatestVersion() != null ? artifact.getLatestVersion().getVersion() : ""); localContainer.add(new ExternalLink("versionLink", mavenCentralSearchUrlService.getVersionUrl(artifact.getGroup().getGroupId(), artifact.getArtifactId(), latestVersion))); localContainer.add(new DateLabelWithPlaceholder("lastUpdateDate", Model.of(artifactLastVersionModel.getLastVersionUpdateDate()), DatePattern.SHORT_DATE)); item.add(localContainer); // Followers count column Label followersCount = new CountLabel("followersCount", "artifact.follow.dataView.followers", BindingModel.of(artifactModel, Binding.artifact().followersCount())); followersCount.add(new AttributeModifier("class", new LoadableDetachableModel<String>() { private static final long serialVersionUID = 1L; @Override protected String load() { if (artifactModel.getObject() != null && artifactModel.getObject().getFollowersCount() > 0) { return "badge"; } return null; } })); item.add(followersCount); // Follow actions item.add(new ArtifactFollowActionsPanel("followActions", artifactModel)); }