Java Code Examples for org.apache.wicket.model.AbstractReadOnlyModel
The following examples show how to use
org.apache.wicket.model.AbstractReadOnlyModel. These examples are extracted from open source projects.
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 Project: onedev Source File: PolymorphicPropertyViewer.java License: MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); String displayName = EditableUtils.getDisplayName(propertyValue.getClass()); displayName = Application.get().getResourceSettings().getLocalizer().getString(displayName, this, displayName); add(new Label("type", displayName)); add(new Label("typeDescription", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return EditableUtils.getDescription(propertyValue.getClass()); } }) { @Override protected void onConfigure() { super.onConfigure(); setVisible(propertyValue != null && EditableUtils.getDescription(propertyValue.getClass()) != null); } }); add(BeanContext.view("beanViewer", propertyValue, excludedProperties, true)); }
Example 2
Source Project: onedev Source File: RequestStatusLabel.java License: MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { PullRequest request = getPullRequest(); CloseInfo closeInfo = request.getCloseInfo(); if (closeInfo == null) return "label label-warning request-status"; else if (closeInfo.getStatus() == CloseInfo.Status.MERGED) return "label label-success request-status"; else return "label label-danger request-status"; } })); }
Example 3
Source Project: onedev Source File: MyPasswordPage.java License: MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); if (getLoginUser().getPassword().equals(User.EXTERNAL_MANAGED)) { String message; if (getLoginUser().getSsoInfo().getConnector() != null) { message = "You are currently authenticated via SSO provider '" + getLoginUser().getSsoInfo().getConnector() + "', please change password there instead"; } else { message = "You are currently authenticated via external system, " + "please change password there instead"; } add(new Label("content", message).add(AttributeAppender.append("class", "alert alert-warning"))); } else { add(new PasswordEditPanel("content", new AbstractReadOnlyModel<User>() { @Override public User getObject() { return getLoginUser(); } })); } }
Example 4
Source Project: the-app Source File: ProductCatalogPage.java License: Apache License 2.0 | 6 votes |
private IModel<ProductType> productTypeModel() { return new AbstractReadOnlyModel<ProductType>() { private ProductType productType; @Override public ProductType getObject() { if (productType == null) { if (getPageParameters() == null || getPageParameters().get("type") == null) { productType = ProductType.HANDY; } else { productType = ProductType.fromUrlname(getPageParameters().get("type").toString()); } } return productType; } }; }
Example 5
Source Project: webanno Source File: MonitoringPage.java License: Apache License 2.0 | 6 votes |
public DocumentStatusColumnMetaData(final TableDataProvider prov, final int colNumber, Project aProject) { super(new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return prov.getColNames().get(colNumber); } }); columnNumber = colNumber; project = aProject; }
Example 6
Source Project: sakai Source File: EditablePanelDateText.java License: Educational Community License v2.0 | 6 votes |
public EditablePanelDateText(String id, IModel inputModel, final NodeModel nodeModel, final TreeNode node, final boolean startDate) { super(id); IModel<String> labelModel = new AbstractReadOnlyModel<String>() { @Override public String getObject() { Date date = null; if(startDate) date = nodeModel.getNodeShoppingPeriodStartDate(); else date = nodeModel.getNodeShoppingPeriodEndDate(); if(date == null){ return ""; }else{ return format.format(date); } } }; add(new Label("inherited", labelModel){ public boolean isVisible() { return !nodeModel.isDirectAccess() || !nodeModel.getNodeShoppingPeriodAdmin(); }; }); }
Example 7
Source Project: sakai Source File: SakaiInfinitePagingDataTableNavigationToolbar.java License: Educational Community License v2.0 | 6 votes |
@Override public void onInitialize() { super.onInitialize(); WebMarkupContainer span = new WebMarkupContainer("span"); add(span); span.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return String.valueOf(table.getColumns().size()); } })); final Form<?> form = new Form<>("navForm"); form.add(newPagingNavigator("navigator", table, form).setRenderBodyOnly(true)); form.add(newNavigatorLabel("navigatorLabel", table).setRenderBodyOnly(true)); span.add(form); }
Example 8
Source Project: sakai Source File: SakaiInfinitePagingNoRecordsToolbar.java License: Educational Community License v2.0 | 6 votes |
public SakaiInfinitePagingNoRecordsToolbar(final InfinitePagingDataTable<?, ?> table) { super(null, table); WebMarkupContainer td = new WebMarkupContainer("td"); add(td); td.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return String.valueOf(table.getColumns().size()); } })); td.add(new Label("msg", new ResourceModel("no_data"))); }
Example 9
Source Project: ontopia Source File: SignInPage.java License: Apache License 2.0 | 6 votes |
public SignInPage(PageParameters params) { super(params); add(new StartPageHeaderPanel("header")); add(new FooterPanel("footer")); add(new Label("title", new ResourceModel("page.title.signin"))); add(new Label("message", new AbstractReadOnlyModel<String>() { @Override public String getObject() { OntopolySession session = (OntopolySession)Session.findOrCreate(); return session.getSignInMessage(); } })); add(new SignInForm("form")); }
Example 10
Source Project: ontopia Source File: FieldInstanceImageField.java License: Apache License 2.0 | 6 votes |
public FieldInstanceImageField(String id, FieldValueModel _fieldValueModel, boolean readonly) { super(id); this.fieldValueModel = _fieldValueModel; image = new Image("image"); image.add(new AttributeModifier("src", true, new AbstractReadOnlyModel<String>() { @Override public final String getObject() { TopicMap topicMap = fieldValueModel.getFieldInstanceModel().getFieldInstance().getInstance().getTopicMap(); Object o = fieldValueModel.getFieldValue(); return getRequest().getRelativePathPrefixToContextRoot() + "occurrenceImages?topicMapId=" + topicMap.getId() + "&occurrenceId=" + ((o instanceof OccurrenceIF ? ((OccurrenceIF)o).getObjectId(): "unknown")); } })); upload = new UploadPanel("upload", this); add(image); add(upload); if (fieldValueModel.isExistingValue()) { upload.setVisible(false); } else { image.setVisible(false); if (readonly) upload.setVisible(false); } }
Example 11
Source Project: AppStash Source File: ProductCatalogPage.java License: Apache License 2.0 | 6 votes |
private IModel<ProductType> productTypeModel() { return new AbstractReadOnlyModel<ProductType>() { private ProductType productType; @Override public ProductType getObject() { if (productType == null) { if (getPageParameters() == null || getPageParameters().get("type") == null) { productType = ProductType.HANDY; } else { productType = ProductType.fromUrlname(getPageParameters().get("type").toString()); } } return productType; } }; }
Example 12
Source Project: sakai Source File: EditablePanelDateText.java License: Educational Community License v2.0 | 6 votes |
public EditablePanelDateText(String id, IModel inputModel, final NodeModel nodeModel, final TreeNode node, final boolean startDate) { super(id); IModel<String> labelModel = new AbstractReadOnlyModel<String>() { @Override public String getObject() { Date date = null; if(startDate) date = nodeModel.getNodeShoppingPeriodStartDate(); else date = nodeModel.getNodeShoppingPeriodEndDate(); if(date == null){ return ""; }else{ return format.format(date); } } }; add(new Label("inherited", labelModel){ public boolean isVisible() { return !nodeModel.isDirectAccess() || !nodeModel.getNodeShoppingPeriodAdmin(); }; }); }
Example 13
Source Project: sakai Source File: SakaiInfinitePagingDataTableNavigationToolbar.java License: Educational Community License v2.0 | 6 votes |
@Override public void onInitialize() { super.onInitialize(); WebMarkupContainer span = new WebMarkupContainer("span"); add(span); span.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return String.valueOf(table.getColumns().size()); } })); final Form<?> form = new Form<>("navForm"); form.add(newPagingNavigator("navigator", table, form).setRenderBodyOnly(true)); form.add(newNavigatorLabel("navigatorLabel", table).setRenderBodyOnly(true)); span.add(form); }
Example 14
Source Project: sakai Source File: SakaiInfinitePagingNoRecordsToolbar.java License: Educational Community License v2.0 | 6 votes |
public SakaiInfinitePagingNoRecordsToolbar(final InfinitePagingDataTable<?, ?> table) { super(null, table); WebMarkupContainer td = new WebMarkupContainer("td"); add(td); td.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return String.valueOf(table.getColumns().size()); } })); td.add(new Label("msg", new ResourceModel("no_data"))); }
Example 15
Source Project: onedev Source File: NavigationToolbar.java License: MIT License | 5 votes |
/** * Constructor * * @param table * data table this toolbar will be attached to */ public NavigationToolbar(final DataTable<?, ?> table) { super(table); WebMarkupContainer span = new WebMarkupContainer("span") { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { addOrReplace(newPagingNavigator("navigator", table)); addOrReplace(newNavigatorLabel("navigatorLabel", table)); super.onBeforeRender(); } }; add(span); span.add(AttributeModifier.replace("colspan", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return String.valueOf(table.getColumns().size()).intern(); } })); }
Example 16
Source Project: onedev Source File: MilestoneStatusLabel.java License: MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return "label label-" + (milestoneModel.getObject().isClosed()? "success": "warning"); } })); }
Example 17
Source Project: onedev Source File: AccessTokenPanel.java License: MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); IModel<String> valueModel = new AbstractReadOnlyModel<String>() { @Override public String getObject() { return getUser().getAccessToken(); } }; add(new TextField<String>("value", valueModel) { @Override protected String[] getInputTypes() { return new String[] {"password"}; } }); add(new CopyToClipboardLink("copy", valueModel)); add(new Link<Void>("regenerate") { @Override public void onClick() { getUser().setAccessToken(RandomStringUtils.randomAlphanumeric(User.ACCESS_TOKEN_LEN)); OneDev.getInstance(UserManager.class).save(getUser()); Session.get().success("Access token regenerated"); setResponsePage(getPage()); } }.add(new ConfirmClickModifier("This will invalidate current token and generate a new one, do you want to continue?"))); }
Example 18
Source Project: onedev Source File: NewPullRequestPage.java License: MIT License | 5 votes |
private Fragment newEffectiveFrag() { Fragment fragment = new Fragment("status", "effectiveFrag", this); fragment.add(new Label("description", new AbstractReadOnlyModel<String>() { @Override public String getObject() { if (requestModel.getObject().isOpen()) return "This change is already opened for merge by pull request"; else return "This change is squashed/rebased onto base branch via pull request"; } }).setEscapeModelStrings(false)); fragment.add(new Link<Void>("link") { @Override protected void onInitialize() { super.onInitialize(); add(new Label("label", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return "#" + getPullRequest().getNumber(); } })); } @Override public void onClick() { PageParameters params = PullRequestDetailPage.paramsOf(getPullRequest()); setResponsePage(PullRequestActivitiesPage.class, params); } }); return fragment; }
Example 19
Source Project: onedev Source File: PullRequestChangePanel.java License: MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); PullRequestChange change = getModelObject(); if (change.getUser() != null) add(new Label("user", change.getUser().getDisplayName())); else if (change.getUserName() != null) add(new Label("user", change.getUserName())); else add(new WebMarkupContainer("user").setVisible(false)); add(new Label("description", change.getData().getActivity(null))); add(new Label("age", DateUtils.formatAge(change.getDate()))); add(new SinceChangesLink("changes", new AbstractReadOnlyModel<PullRequest>() { @Override public PullRequest getObject() { return getChange().getRequest(); } }, getChange().getDate())); Component body = change.getData().render("body", change); if (body != null) { add(body); } else { add(new WebMarkupContainer("body").setVisible(false)); add(AttributeAppender.append("class", "no-body")); } }
Example 20
Source Project: onedev Source File: ProjectBlobPage.java License: MIT License | 5 votes |
private AdvancedSearchPanel newAdvancedSearchPanel(String id, ModalPanel modal) { /* * Re-use advanced search panel instance so that search options can be preserved in the page */ advancedSearchPanelModal = modal; if (advancedSearchPanel == null) { advancedSearchPanel = new AdvancedSearchPanel(id, projectModel, new AbstractReadOnlyModel<String>() { @Override public String getObject() { return state.blobIdent.revision; } }) { @Override protected void onSearchComplete(AjaxRequestTarget target, List<QueryHit> hits) { newSearchResult(target, hits); resizeWindow(target); advancedSearchPanelModal.close(); } @Override protected void onCancel(AjaxRequestTarget target) { advancedSearchPanelModal.close(); } @Override protected BlobIdent getCurrentBlob() { return state.blobIdent; } }; } return advancedSearchPanel; }
Example 21
Source Project: onedev Source File: CommitOptionPanel.java License: MIT License | 5 votes |
private void newChangedContainer(@Nullable AjaxRequestTarget target) { WebMarkupContainer changedContainer = new WebMarkupContainer("changed"); changedContainer.setVisible(change != null); if (change != null) { changedContainer.add(new BlobDiffPanel("changes", new AbstractReadOnlyModel<Project>() { @Override public Project getObject() { return context.getProject(); } }, new Model<PullRequest>(null), change, DiffViewMode.UNIFIED, null, null)); } else { changedContainer.add(new WebMarkupContainer("changes")); } if (target != null) { form.replace(changedContainer); target.add(form); if (change != null) { String script = String.format("$('#%s .commit-option input[type=submit]').val('Commit and overwrite');", getMarkupId()); target.appendJavaScript(script); } } else { form.add(changedContainer); } }
Example 22
Source Project: onedev Source File: MyProfilePage.java License: MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); add(new Label("externalManagedNote", "Your profile is managed from " + getLoginUser().getAuthSource()) .setVisible(getLoginUser().isExternalManaged())); if (getLoginUser().isExternalManaged()) { add(BeanContext.view("content", getLoginUser(), Sets.newHashSet("password"), true)); } else { add(new ProfileEditPanel("content", new AbstractReadOnlyModel<User>() { @Override public User getObject() { return getLoginUser(); } })); } add(new UserDeleteLink("delete") { @Override protected User getUser() { return getLoginUser(); } }.setVisible(getLoginUser().isExternalManaged())); }
Example 23
Source Project: onedev Source File: MyAvatarPage.java License: MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); add(new AvatarEditPanel("content", new AbstractReadOnlyModel<User>() { @Override public User getObject() { return getLoginUser(); } })); }
Example 24
Source Project: the-app Source File: LoginInfoPanel.java License: Apache License 2.0 | 5 votes |
private IModel<UserInfo> userInfoModel() { return new AbstractReadOnlyModel<UserInfo>() { private static final long serialVersionUID = -2206159169788096455L; @Override public UserInfo getObject() { return getAuthenticationService().getAuthenticatedUserInfo(); } }; }
Example 25
Source Project: the-app Source File: LoginInfoPanel.java License: Apache License 2.0 | 5 votes |
private IModel<Boolean> isAuthorizedModel() { return new AbstractReadOnlyModel<Boolean>() { private static final long serialVersionUID = -6807240140221845040L; @Override public Boolean getObject() { return isAuthorized(); } }; }
Example 26
Source Project: sakai Source File: SearchUsersPage.java License: Educational Community License v2.0 | 5 votes |
public IModel<SearchResult> model(final SearchResult object) { return new AbstractReadOnlyModel<SearchResult>() { private static final long serialVersionUID = 1L; @Override public SearchResult getObject() { return object; } }; }
Example 27
Source Project: sakai Source File: EditablePanelDropdownText.java License: Educational Community License v2.0 | 5 votes |
public EditablePanelDropdownText(String id, IModel inputModel, final NodeModel nodeModel, final TreeNode node, final Map<String, String> realmMap, final int type) { super(id); //show the inherited role if the user hasn't selected this node IModel<String> labelModel = new AbstractReadOnlyModel<String>() { @Override public String getObject() { String[] inheritedAccess = nodeModel.getNodeAccessRealmRole(); if("".equals(inheritedAccess[0])){ return ""; }else{ String realmRole = inheritedAccess[0] + ":" + inheritedAccess[1]; if(realmMap.containsKey(realmRole)){ return realmMap.get(realmRole); }else{ return realmRole; } } } }; Label label = new Label("realmRole", labelModel){ public boolean isVisible() { if(DelegatedAccessConstants.TYPE_ACCESS_SHOPPING_PERIOD_USER == type){ return !nodeModel.isDirectAccess() || !nodeModel.getNodeShoppingPeriodAdmin(); }else{ return !nodeModel.isDirectAccess(); } }; }; add(label); }
Example 28
Source Project: sakai Source File: SearchAccessPage.java License: Educational Community License v2.0 | 5 votes |
public IModel<AccessSearchResult> model(final AccessSearchResult object) { return new AbstractReadOnlyModel<AccessSearchResult>() { private static final long serialVersionUID = 1L; @Override public AccessSearchResult getObject() { return object; } }; }
Example 29
Source Project: sakai Source File: UserPageSiteSearch.java License: Educational Community License v2.0 | 5 votes |
public IModel<SiteSearchResult> model(final SiteSearchResult object) { return new AbstractReadOnlyModel<SiteSearchResult>() { private static final long serialVersionUID = 1L; @Override public SiteSearchResult getObject() { return object; } }; }
Example 30
Source Project: ontopia Source File: EmbeddedHierarchicalInstancePage.java License: Apache License 2.0 | 5 votes |
protected IModel<TreeModel> createTreeModel(final TopicModel<Topic> hierarchyTopicModel, final TopicModel<Topic> currentNodeModel) { final TreeModel treeModel; Topic hierarchyTopic = hierarchyTopicModel.getTopic(); Topic currentNode = currentNodeModel.getTopic(); // find hierarchy definition query for topic String query = (hierarchyTopic == null ? null : getDefinitionQuery(hierarchyTopic)); if (query != null) { Map<String,TopicIF> params = new HashMap<String,TopicIF>(2); params.put("hierarchyTopic", hierarchyTopic.getTopicIF()); params.put("currentNode", currentNode.getTopicIF()); treeModel = TreeModels.createQueryTreeModel(currentNode.getTopicMap(), query, params); } else if (currentNode.isTopicType()) { // if no definition query found, then show topic in instance hierarchy treeModel = TreeModels.createTopicTypesTreeModel(currentNode.getTopicMap(), isAnnotationEnabled(), isAdministrationEnabled()); } else { treeModel = TreeModels.createInstancesTreeModel(OntopolyUtils.getDefaultTopicType(currentNode), isAdministrationEnabled()); } return new AbstractReadOnlyModel<TreeModel>() { @Override public TreeModel getObject() { return treeModel; } }; }