org.apache.wicket.model.IModel Java Examples
The following examples show how to use
org.apache.wicket.model.IModel.
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: TestFilters.java From wicket-orientdb with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void testCollectionFilterCriteria() { List<Integer> models = Lists.newArrayList(); models.add(NUM_VALUE_1); models.add(NUM_VALUE_2); IModel<Collection<Integer>> collectionModel = new CollectionModel<>(models); IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD)); manager.addFilterCriteria(manager.createCollectionFilterCriteria(collectionModel, Model.of(true))); String field = wicket.getProperty(NUMBER_FIELD).getObject().getName(); queryModel.addFilterCriteriaManager(field, manager); queryModel.setSort(NUMBER_FIELD, SortOrder.ASCENDING); assertTrue(queryModel.getObject().size() == 2); assertTrue(queryModel.getObject().get(0).field(NUMBER_FIELD).equals(NUM_VALUE_1)); assertTrue(queryModel.getObject().get(1).field(NUMBER_FIELD).equals(NUM_VALUE_2)); }
Example #2
Source File: JiraIssuesPanel.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
public JiraIssuesPanel(final String id, final IModel<String> model) { super(id); setRenderBodyOnly(true); if (WicketUtils.isJIRAConfigured() == false) { final WebMarkupContainer dummy = new WebMarkupContainer("issues"); setVisible(false); dummy.add(new ExternalLink("jiraLink", "dummy")); add(dummy); return; } final RepeatingView jiraIssuesRepeater = new RepeatingView("issues"); add(jiraIssuesRepeater); final String[] jiraIssues = JiraUtils.checkForJiraIssues(model.getObject()); if (jiraIssues == null) { jiraIssuesRepeater.setVisible(false); } else { for (final String issue : jiraIssues) { final WebMarkupContainer item = new WebMarkupContainer(jiraIssuesRepeater.newChildId()); item.setRenderBodyOnly(true); jiraIssuesRepeater.add(item); item.add(new ExternalLink("jiraLink", JiraUtils.buildJiraIssueBrowseLinkUrl(issue), issue)); } } }
Example #3
Source File: WebappNotificationPanelRendererServiceImpl.java From artifact-listener with Apache License 2.0 | 6 votes |
@Override public IWicketNotificationDescriptor renderNewVersionNotificationPanel(final List<ArtifactVersionNotification> notifications, final User user) { return new AbstractSimpleWicketNotificationDescriptor("notification.panel.newVersion") { @Override public Object getSubjectParameter() { return user; } @Override public Iterable<?> getSubjectPositionalParameters() { return ImmutableList.of(user.getDisplayName()); } @Override public Component createComponent(String wicketId) { IModel<List<ArtifactVersionNotification>> notificationsModel = new ListModel<ArtifactVersionNotification>(notifications); return new NewVersionsHtmlNotificationPanel(wicketId, notificationsModel); } }; }
Example #4
Source File: TagSetSelectionPanel.java From webanno with Apache License 2.0 | 6 votes |
public TagSetSelectionPanel(String id, IModel<Project> aProject, IModel<TagSet> aTagset) { super(id, aProject); setOutputMarkupId(true); setOutputMarkupPlaceholderTag(true); selectedProject = aProject; overviewList = new OverviewListChoice<>("tagset"); overviewList.setChoiceRenderer(new ChoiceRenderer<>("name")); overviewList.setModel(aTagset); overviewList.setChoices(LambdaModel.of(this::listTagSets)); overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange)); add(overviewList); add(new LambdaAjaxLink("create", this::actionCreate)); tagSetImportPanel = new TagSetImportPanel("importPanel", selectedProject); tagSetImportPanel.setImportCompleteAction(target -> { target.add(findParent(ProjectTagSetsPanel.class)); }); add(tagSetImportPanel); }
Example #5
Source File: MaxLengthTextField.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
/** * The field length (if defined by Hibernate). The entity is the target class of the PropertyModel and the field name is the expression of * the given PropertyModel. * @param model If not from type PropertyModel then null is returned. * @return */ public static Integer getMaxLength(final IModel<String> model) { Integer length = null; if (ClassUtils.isAssignable(model.getClass(), PropertyModel.class)) { final PropertyModel< ? > propertyModel = (PropertyModel< ? >) model; final Object entity = BeanHelper.getFieldValue(propertyModel, ChainingModel.class, "target"); if (entity == null) { log.warn("Oups, can't get private field 'target' of PropertyModel!."); } else { final Field field = propertyModel.getPropertyField(); if (field != null) { length = HibernateUtils.getPropertyLength(entity.getClass().getName(), field.getName()); } else { log.info("Can't get field '" + propertyModel.getPropertyExpression() + "'."); } } } return length; }
Example #6
Source File: CollectionLinkFilterPanel.java From Orienteer with Apache License 2.0 | 6 votes |
private Select2MultiChoice<String> createClassChooseComponent(String id, IModel<Collection<String>> classNamesModel) { Select2MultiChoice<String> choice = new Select2MultiChoice<String>(id, classNamesModel, OClassCollectionTextChoiceProvider.INSTANCE) { @Override protected void onInitialize() { super.onInitialize(); OProperty property = CollectionLinkFilterPanel.this.getEntityModel().getObject(); if (property != null && property.getLinkedClass() != null) { setModelObject(Arrays.asList(property.getLinkedClass().getName())); setEnabled(false); } } }; choice.getSettings() .setWidth("100%") .setCloseOnSelect(true) .setTheme(BOOTSTRAP_SELECT2_THEME) .setContainerCssClass("link-filter-class-choice"); choice.add(new AjaxFormSubmitBehavior("change") {}); return choice; }
Example #7
Source File: QuerySettingsPanel.java From inception with Apache License 2.0 | 6 votes |
private CheckBox maxQueryLimitCheckbox(String id, IModel<Boolean> aModel) { return new AjaxCheckBox(id, aModel) { private static final long serialVersionUID = -8390353018496338400L; @Override public void onUpdate(AjaxRequestTarget aTarget) { if (getModelObject()) { queryLimitField.setModelObject(kbProperties.getHardMaxResults()); queryLimitField.setEnabled(false); } else { queryLimitField.setEnabled(true); } aTarget.add(queryLimitField); } }; }
Example #8
Source File: GuidelinesListPanel.java From webanno with Apache License 2.0 | 6 votes |
public GuidelinesListPanel(String aId, IModel<Project> aProject) { super(aId); setOutputMarkupId(true); project = aProject; guideline = Model.of(); Form<Void> form = new Form<>("form"); add(form); overviewList = new OverviewListChoice<>("guidelines"); overviewList.setModel(guideline); overviewList.setChoices(LambdaModel.of(this::listGuidelines)); form.add(overviewList); ConfirmationDialog confirmationDialog = new ConfirmationDialog("confirmationDialog"); confirmationDialog.setConfirmAction(this::actionDelete); add(confirmationDialog); LambdaAjaxButton<Void> delete = new LambdaAjaxButton<>("delete", (t, f) -> confirmationDialog.show(t)); form.add(delete); }
Example #9
Source File: AnnotationEditorBase.java From webanno with Apache License 2.0 | 6 votes |
public AnnotationEditorBase(final String aId, final IModel<AnnotatorState> aModel, final AnnotationActionHandler aActionHandler, final CasProvider aCasProvider) { super(aId, aModel); Validate.notNull(aActionHandler, "Annotation action handle must be provided"); Validate.notNull(aCasProvider, "CAS provider must be provided"); actionHandler = aActionHandler; casProvider = aCasProvider; // Allow AJAX updates. setOutputMarkupId(true); // The annotator is invisible when no document has been selected. Make sure that we can // make it visible via AJAX once the document has been selected. setOutputMarkupPlaceholderTag(true); }
Example #10
Source File: ExternalRecommenderTraitsEditor.java From inception with Apache License 2.0 | 5 votes |
public ExternalRecommenderTraitsEditor(String aId, IModel<Recommender> aRecommender) { super(aId, aRecommender); traits = toolFactory.readTraits(aRecommender.getObject()); Form<ExternalRecommenderTraits> form = new Form<ExternalRecommenderTraits>(MID_FORM, CompoundPropertyModel.of(Model.of(traits))) { private static final long serialVersionUID = -3109239605742291123L; @Override protected void onSubmit() { super.onSubmit(); toolFactory.writeTraits(aRecommender.getObject(), traits); } }; TextField<String> remoteUrl = new TextField<>("remoteUrl"); remoteUrl.setRequired(true); remoteUrl.add(new UrlValidator()); form.add(remoteUrl); CheckBox trainable = new CheckBox("trainable"); trainable.setOutputMarkupId(true); trainable.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> _target.add(getTrainingStatesChoice()))); form.add(trainable); getTrainingStatesChoice().add(visibleWhen(() -> trainable.getModelObject() == true)); add(form); }
Example #11
Source File: ProjectDocumentsPanel.java From webanno with Apache License 2.0 | 5 votes |
public ProjectDocumentsPanel(String id, IModel<Project> aProject) { super(id, aProject); add(new ImportDocumentsPanel("import", aProject)); add(new DocumentListPanel("documents", aProject)); }
Example #12
Source File: ExtendedPalette.java From nextreports-server with Apache License 2.0 | 5 votes |
/** * @param id Component id * @param model Model representing collection of user's selections * @param choicesModel Model representing collection of all available choices * @param choiceRenderer Render used to render choices. This must use unique IDs for the objects, not the * index. * @param rows Number of choices to be visible on the screen with out scrolling * @param allowOrder Allow user to move selections up and down * @param allowMoveAll Allow user to add or remove all items at once */ public ExtendedPalette(String id, IModel<List<T>> model, IModel<? extends Collection<? extends T>> choicesModel, IChoiceRenderer<T> choiceRenderer, int rows, boolean allowOrder, boolean allowMoveAll) { super(id, model, choicesModel, choiceRenderer, rows, allowOrder, allowMoveAll); this.choicesModel = choicesModel; this.choiceRenderer = choiceRenderer; this.rows = rows; this.allowOrder = allowOrder; this.allowMoveAll = allowMoveAll; }
Example #13
Source File: ProjectTab.java From onedev with MIT License | 5 votes |
public ProjectTab(IModel<String> titleModel, String iconClass, int count, Class<? extends ProjectPage> mainPageClass, Class<? extends ProjectPage> additionalPageClass1, Class<? extends ProjectPage> additionalPageClass2) { super(titleModel, mainPageClass, additionalPageClass1, additionalPageClass2); this.iconClass = iconClass; this.count = count; }
Example #14
Source File: GeneralSettingsPanel.java From inception with Apache License 2.0 | 5 votes |
public GeneralSettingsPanel(String id, IModel<Project> aProjectModel, CompoundPropertyModel<KnowledgeBaseWrapper> aModel) { super(id); setOutputMarkupId(true); projectModel = aProjectModel; kbModel = aModel; add(nameField("name", "kb.name")); add(languageComboBox("language", kbModel.bind("kb.defaultLanguage"))); add(basePrefixField("basePrefix", "kb.basePrefix")); add(createCheckbox("enabled", "kb.enabled")); }
Example #15
Source File: OClassSecurityWidget.java From Orienteer with Apache License 2.0 | 5 votes |
public OClassSecurityWidget(String id, IModel<OClass> model, IModel<ODocument> widgetDocumentModel) { super(id, model, widgetDocumentModel); List<IColumn<ORole, String>> sColumns = new ArrayList<IColumn<ORole,String>>(); OClass oRoleClass = OrientDbWebSession.get().getDatabase().getMetadata().getSchema().getClass("ORole"); sColumns.add(new AbstractColumn<ORole, String>(new OClassNamingModel(oRoleClass), "name") { @Override public void populateItem(Item<ICellPopulator<ORole>> cellItem, String componentId, IModel<ORole> rowModel) { cellItem.add(new LinkViewPanel(componentId, new PropertyModel<ODocument>(rowModel, "document"))); } }); sColumns.add(new SecurityRightsColumn(OrientPermission.EXECUTE)); sColumns.add(new SecurityRightsColumn(OrientPermission.CREATE)); sColumns.add(new SecurityRightsColumn(OrientPermission.READ)); sColumns.add(new SecurityRightsColumn(OrientPermission.UPDATE)); sColumns.add(new SecurityRightsColumn(OrientPermission.DELETE)); OQueryDataProvider<ORole> sProvider = new OQueryDataProvider<ORole>("select from ORole", ORole.class); sProvider.setSort("name", SortOrder.ASCENDING); GenericTablePanel<ORole> tablePanel = new GenericTablePanel<ORole>("tablePanel", sColumns, sProvider ,20); OSecurityHelper.secureComponent(tablePanel, OSecurityHelper.requireOClass("ORole", Component.ENABLE, OrientPermission.UPDATE)); OrienteerDataTable<ORole, String> sTable = tablePanel.getDataTable(); Command<ORole> saveCommand = new AbstractSaveCommand<ORole>(sTable, null); sTable.addCommand(saveCommand); sTable.setCaptionModel(new ResourceModel("class.security")); add(tablePanel); add(DisableIfPrototypeBehavior.INSTANCE, UpdateOnActionPerformedEventBehavior.INSTANCE_ALL_CONTINUE); }
Example #16
Source File: OrienteerCloudOModulesConfigurationsPanel.java From Orienteer with Apache License 2.0 | 5 votes |
public OrienteerCloudOModulesConfigurationsPanel(String id, final OArtifactsModalWindowPage windowPage, ISortableDataProvider<OArtifact, String> provider) { super(id); setOutputMarkupPlaceholderTag(true); Form orienteerModulesForm = new Form("orienteerCloudOModulesConfigsForm"); Label feedback = new Label("feedback"); feedback.setVisible(false); feedback.setOutputMarkupPlaceholderTag(true); IModel<DisplayMode> modeModel = DisplayMode.VIEW.asModel(); List<IColumn<OArtifact, String>> columns = getColumns(modeModel); OrienteerDataTable<OArtifact, String> table = new OrienteerDataTable<>("availableModules", columns, provider, 10); table.addCommand(new AjaxCommand<OArtifact>(new ResourceModel(BACK_BUT), table) { @Override public void onClick(Optional<AjaxRequestTarget> targetOptional) { windowPage.showOrienteerModulesPanel(false); targetOptional.ifPresent(target->target.add(windowPage)); } @Override protected void onInstantiation() { super.onInstantiation(); setIcon(FAIconType.angle_left); setBootstrapType(BootstrapType.PRIMARY); setAutoNotify(false); } }); table.addCommand(new InstallOModuleCommand(table, windowPage, false, feedback)); table.addCommand(new InstallOModuleCommand(table, windowPage,true, feedback)); orienteerModulesForm.add(table); orienteerModulesForm.add(feedback); add(orienteerModulesForm); }
Example #17
Source File: ConnObjectDetails.java From syncope with Apache License 2.0 | 5 votes |
public ConnObjectDetails(final ConnObjectTO connObjectTO) { super(); MultilevelPanel mlp = new MultilevelPanel("details"); mlp.setFirstLevel(new ConnObjectPanel( MultilevelPanel.FIRST_LEVEL_ID, Pair.<IModel<?>, IModel<?>>of(Model.of(), Model.of()), Pair.of((ConnObjectTO) null, connObjectTO), true)); add(mlp); }
Example #18
Source File: ListboxVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { if(DisplayMode.EDIT.equals(mode)) { OProperty property = propertyModel.getObject(); OClass oClass = property.getLinkedClass(); if(oClass!=null) { IModel<List<ODocument>> choicesModel = new OQueryModel<ODocument>("select from "+oClass.getName()+" LIMIT 100"); if(property.getType().isMultiValue()) { return new ListMultipleChoice<ODocument>(id, (IModel<Collection<ODocument>>) valueModel, choicesModel, new ODocumentChoiceRenderer()); } else { return new DropDownChoice<ODocument>(id, (IModel<ODocument>)valueModel, choicesModel, new ODocumentChoiceRenderer()) .setNullValid(!property.isNotNull()); } } else { OrienteerWebSession.get() .warn(OrienteerWebApplication.get().getResourceSettings() .getLocalizer().getString("errors.listbox.linkedclassnotdefined", null, new OPropertyNamingModel(propertyModel))); return new Label(id, ""); } } else { return null; } }
Example #19
Source File: AdvancedSearchPanel.java From onedev with MIT License | 5 votes |
public AdvancedSearchPanel(String id, IModel<Project> projectModel, IModel<String> revisionModel) { super(id); this.projectModel = projectModel; this.revisionModel = revisionModel; Class<? extends SearchOption> activeTab = WebSession.get().getMetaData(ACTIVE_TAB); if (activeTab != null) { try { option = activeTab.newInstance(); } catch (Exception e) { throw ExceptionUtils.unchecked(e); } } }
Example #20
Source File: FieldListEditPanel.java From onedev with MIT License | 5 votes |
public FieldListEditPanel(String id, PropertyDescriptor propertyDescriptor, IModel<List<Serializable>> model) { super(id, propertyDescriptor, model); FieldNamesProvider fieldNamesProvider = Preconditions.checkNotNull( propertyDescriptor.getPropertyGetter().getAnnotation(FieldNamesProvider.class)); fieldNamesProviderMethodName = fieldNamesProvider.value(); for (Serializable each: model.getObject()) { FieldSupply param = (FieldSupply) each; fields.put(param.getName(), param); } }
Example #21
Source File: WidgetTabTemplate.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Gets an optional message that will be displayed at the bottom of the tab. * @return a model containing the message string */ protected Optional<IModel<String>> getFooterMsg() { String localSakaiName = Locator.getFacade().getStatsManager().getLocalSakaiName(); StringResourceModel model = new StringResourceModel("widget_server_time_msg", getPage(), null, new Object[] {localSakaiName}); return Optional.of(model); }
Example #22
Source File: ArtifactDataProvider.java From artifact-listener with Apache License 2.0 | 5 votes |
public ArtifactDataProvider(IModel<String> searchTerm, IModel<ArtifactDeprecationStatus> deprecationModel) { super(); this.searchTermModel = searchTerm; this.deprecationModel = deprecationModel; Injector.get().inject(this); }
Example #23
Source File: LocatorListEditPanel.java From onedev with MIT License | 5 votes |
public LocatorListEditPanel(String id, PropertyDescriptor propertyDescriptor, IModel<List<Serializable>> model) { super(id, propertyDescriptor, model); locators = new ArrayList<>(); for (Serializable each: model.getObject()) { locators.add((ServiceLocator) each); } }
Example #24
Source File: StylableSelectOptions.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @param id * @param model * @param text */ public StylableSelectOption(String id, IModel model, String text, String style) { super(id, model); this.text = text; this.style = style; setIgnoreAttributeModifier(false); }
Example #25
Source File: AssignmentStatisticsPanel.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Get the grade data for the assignment and wrap it * * @param assignment assignment to get data for * @return */ private IModel<Map<String, Object>> getData(final Assignment assignment) { final Map<String, Object> data = new HashMap<>(); data.put("gradeInfo", this.businessService.buildGradeMatrix(Arrays.asList(assignment))); data.put("assignmentId", assignment.getId()); return Model.ofMap(data); }
Example #26
Source File: ActivePropertyColumn.java From nextreports-server with Apache License 2.0 | 5 votes |
public void populateItem(Item<ICellPopulator<Entity>> item, String componentId, final IModel<Entity> rowModel) { SchedulerJob job = (SchedulerJob) rowModel.getObject(); final boolean active; Date now = new Date(); if (ScheduleConstants.ONCE_TYPE.equals(job.getTime().getType())) { active = job.getTime().getRunDate().compareTo(now) >= 0; } else { active = (job.getTime().getStartActivationDate().compareTo(now) <= 0) && (job.getTime().getEndActivationDate().compareTo(now) >= 0); } item.add(new AbstractImagePanel(componentId) { private static final long serialVersionUID = 1L; @Override public String getImageName() { if (active) { String theme = settings.getSettings().getColorTheme(); return "images/" + ThemesManager.getTickImage(theme, (NextServerApplication)getApplication()); } else { return "images/delete.gif"; } } }); }
Example #27
Source File: ConnectionsGrid.java From sakai with Educational Community License v2.0 | 5 votes |
public ConnectionsGrid(final String id, final IModel<List<? extends WidgetPage.GridPerson>> iModel, int cols, boolean isCourse) { super(id, iModel); this.cols = cols; if(isCourse) { prefix = "course.heading."; } else { prefix = "other.heading."; } }
Example #28
Source File: AdministrationUserPortfolioPage.java From artifact-listener with Apache License 2.0 | 5 votes |
public AdministrationUserPortfolioPage(PageParameters parameters) { super(parameters); addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("navigation.administration.user"), AdministrationUserPortfolioPage.linkDescriptor())); IModel<String> searchTermModel = Model.of(""); UserPortfolioPanel portfolioPanel = new UserPortfolioPanel("portfolio", new UserDataProvider(searchTermModel), configurer.getPortfolioItemsPerPage()); add(portfolioPanel); add(new AdministrationUserSearchPanel("searchPanel", portfolioPanel.getPageable(), searchTermModel)); // User create popup UserFormPopupPanel userCreatePanel = new UserFormPopupPanel("userCreatePopupPanel"); add(userCreatePanel); Button createUser = new Button("createUser"); createUser.add(new AjaxModalOpenBehavior(userCreatePanel, MouseEvent.CLICK) { private static final long serialVersionUID = 5414159291353181776L; @Override protected void onShow(AjaxRequestTarget target) { } }); add(createUser); }
Example #29
Source File: RecommenderProjectSettingsPanelFactory.java From inception with Apache License 2.0 | 4 votes |
@Override public Panel createSettingsPanel(String aID, final IModel<Project> aProjectModel) { return new ProjectRecommendersPanel(aID, aProjectModel); }
Example #30
Source File: SakaiResponsivePropertyColumn.java From sakai with Educational Community License v2.0 | 4 votes |
@Override public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel) { super.populateItem(item, componentId, rowModel); item.add(AttributeAppender.append(DATA_LABEL_ATTR, getDisplayModel())); }