Java Code Examples for org.apache.wicket.model.Model#of()
The following examples show how to use
org.apache.wicket.model.Model#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: KnowledgeBasePanel.java From inception with Apache License 2.0 | 6 votes |
@OnEvent public void actionNewConcept(AjaxNewConceptEvent event) { // cancel selections for concepts and properties selectedConceptHandle.setObject(null); selectedPropertyHandle.setObject(null); // show panel for new, empty property KBConcept newConcept = new KBConcept(); newConcept.setLanguage(kbModel.getObject().getDefaultLanguage()); Component replacement = new ConceptInstancePanel(DETAILS_MARKUP_ID, kbModel, selectedConceptHandle, Model.of(newConcept)); details = details.replaceWith(replacement); event.getTarget().add(KnowledgeBasePanel.this); }
Example 2
Source File: PollResultsDialog.java From openmeetings with Apache License 2.0 | 6 votes |
@Override protected void onInitialize() { add(chartDiv.setOutputMarkupId(true)); chartSimple = getString("1414"); chartPie = getString("1415"); add(name, question, count); chartType = new DropDownChoice<>("chartType", Model.of(chartSimple), List.of(chartSimple, chartPie)); add(chartType.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { redraw(target, false); } })); super.onInitialize(); }
Example 3
Source File: BootstrapPaginatorTest.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testLastButton(){ WicketTester tester = createTester(); final Boxed<Integer> pageBox = new Boxed<Integer>(); BootstrapPaginator paginator = new BootstrapPaginator("paginator", Model.of(100)) { private static final long serialVersionUID = -4486050808642574868L; @Override public void onPageChange(AjaxRequestTarget target, IModel<Integer> page) { pageBox.value=page.getObject(); } }; paginator.setTotalResults(Model.of(100)); paginator.setNumberResultsPerPage(10); tester.startComponentInPage(paginator); tester.clickLink("paginator:last:link"); assertEquals(9, (int) pageBox.value); tester.assertDisabled("paginator:last:link"); tester.assertDisabled("paginator:next:link"); tester.assertEnabled("paginator:previous:link"); tester.assertEnabled("paginator:first:link"); }
Example 4
Source File: TagSetImportPanel.java From webanno with Apache License 2.0 | 5 votes |
public TagSetImportPanel(String aId, IModel<Project> aModel) { super(aId); setOutputMarkupId(true); setOutputMarkupPlaceholderTag(true); preferences = Model.of(new Preferences()); selectedProject = aModel; Form<Preferences> form = new Form<>("form", CompoundPropertyModel.of(preferences)); BootstrapSelect<String> format = new BootstrapSelect<>("format", asList(JSON_FORMAT, TAB_FORMAT)); form.add(format); format.setModelObject(JSON_FORMAT); // Set after adding to form to have access to for model format.setRequired(true); form.add(new CheckBox("overwrite")); form.add(fileUpload = new BootstrapFileInputField("content", new ListModel<>())); fileUpload.getConfig().showPreview(false); fileUpload.getConfig().showUpload(false); fileUpload.getConfig().showRemove(false); fileUpload.setRequired(true); form.add(new LambdaAjaxButton<>("import", this::actionImport)); add(form); }
Example 5
Source File: SelectDialogPanel.java From Orienteer with Apache License 2.0 | 5 votes |
public SelectDialogPanel(String id, final ModalWindow modal, IModel<OClass> initialClass, boolean isMultiValue) { super(id, Model.of("")); this.modal = modal; this.modal.setMinimalHeight(400); this.modal.setMinimalWidth(800); add(createSearchPanel("searchPanel", initialClass, isMultiValue)); }
Example 6
Source File: BranchSingleChoiceEditor.java From onedev with MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); Map<String, String> choices = new LinkedHashMap<>(); if (Project.get() != null) { for (RefInfo ref: Project.get().getBranchRefInfos()) { String branch = GitUtils.ref2branch(ref.getRef().getName()); choices.put(branch, branch); } } String selection = getModelObject(); if (!choices.containsKey(selection)) selection = null; input = new BranchSingleChoice("input", Model.of(selection), Model.ofMap(choices)) { @Override protected void onInitialize() { super.onInitialize(); getSettings().configurePlaceholder(descriptor); } }; // add this to control allowClear flag of select2 input.setRequired(descriptor.isPropertyRequired()); input.setLabel(Model.of(getDescriptor().getDisplayName())); input.add(new AjaxFormComponentUpdatingBehavior("change"){ @Override protected void onUpdate(AjaxRequestTarget target) { onPropertyUpdating(target); } }); add(input); }
Example 7
Source File: RoomMenuPanel.java From openmeetings with Apache License 2.0 | 5 votes |
@Override protected void onInitialize() { exitMenuItem = new RoomMenuItem(getString("308"), getString("309"), FontAwesome5IconType.sign_out_alt_s) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { chatDao.closeMessages(getUserId()); exit(target); } }; filesMenu = new RoomMenuItem(getString("245"), null, false); actionsSubMenu.init(); pollsSubMenu.init(); add((menuPanel = new MenuPanel("menu", getMenu())).setVisible(isVisible())); add(askBtn.add(AttributeModifier.replace(ATTR_TITLE, getString("84")))); Label demo = new Label("demo", Model.of("")); Room r = room.getRoom(); add(demo.setVisible(r.isDemoRoom() && r.getDemoTime() != null && room.getRoom().getDemoTime().intValue() > 0)); if (demo.isVisible()) { demo.add(new OmTimerBehavior(room.getRoom().getDemoTime().intValue(), "637") { private static final long serialVersionUID = 1L; @Override protected void onTimer(int remain) { getComponent().add(AttributeModifier.replace(ATTR_TITLE, getText(getString("637"), remain))); } @Override protected void onFinish(AjaxRequestTarget target) { exit(target); } }); } super.onInitialize(); }
Example 8
Source File: KnowledgeBasePanel.java From inception with Apache License 2.0 | 5 votes |
@OnEvent public void actionNewProperty(AjaxNewPropertyEvent event) { // cancel selections for concepts and properties selectedConceptHandle.setObject(null); selectedPropertyHandle.setObject(null); // show panel for new, empty property KBProperty newProperty = new KBProperty(); newProperty.setLanguage(kbModel.getObject().getDefaultLanguage()); Component replacement = new PropertyPanel(DETAILS_MARKUP_ID, kbModel, selectedPropertyHandle, Model.of(newProperty)); details = details.replaceWith(replacement); event.getTarget().add(KnowledgeBasePanel.this); }
Example 9
Source File: ProjectTagSetsPanel.java From webanno with Apache License 2.0 | 5 votes |
public ProjectTagSetsPanel(String id, final IModel<Project> aProjectModel) { super(id, aProjectModel); selectedProject = aProjectModel; selectedTagSet = Model.of(); selectedTag = Model.of(); tagSetSelectionPanel = new TagSetSelectionPanel("tagSetSelector", selectedProject, selectedTagSet); tagSetSelectionPanel .onConfigure(_this -> _this.setVisible(selectedProject.getObject() != null)); tagSetSelectionPanel.setCreateAction(target -> selectedTagSet.setObject(new TagSet())); tagSetSelectionPanel.setChangeAction(target -> { selectedTag.setObject(null); target.add(tagSetEditorPanel); target.add(tagSelectionPanel); target.add(tagEditorPanel); }); add(tagSetSelectionPanel); tagSelectionPanel = new TagSelectionPanel("tagSelector", selectedTagSet, selectedTag); tagSelectionPanel.onConfigure(_this -> _this.setVisible( selectedTagSet.getObject() != null && selectedTagSet.getObject().getId() != null)); tagSelectionPanel.setCreateAction(target -> selectedTag.setObject(new Tag())); tagSelectionPanel.setChangeAction(target -> { target.add(tagEditorPanel); }); add(tagSelectionPanel); tagEditorPanel = new TagEditorPanel("tagEditor", selectedTagSet, selectedTag); tagEditorPanel.onConfigure(_this -> _this.setVisible(selectedTag.getObject() != null)); add(tagEditorPanel); tagSetEditorPanel = new TagSetEditorPanel("tagSetEditor", selectedProject, selectedTagSet, selectedTag); tagSetEditorPanel .onConfigure(_this -> _this.setVisible(selectedTagSet.getObject() != null)); add(tagSetEditorPanel); }
Example 10
Source File: BarChartPanelTest.java From wicket-chartjs with Apache License 2.0 | 5 votes |
@Test public void testBarChartPanelStringIModelOfQextendsBar() { IModel<? extends Bar> model = Model.of(new Bar()); BarChartPanel panel = new BarChartPanel("foo", model); tester.startComponentInPage(panel); tester.assertComponent("foo:chart", WebMarkupContainer.class); }
Example 11
Source File: BranchLink.java From onedev with MIT License | 5 votes |
@Override public IModel<?> getBody() { String label; if (getPage() instanceof ProjectPage) { ProjectPage page = (ProjectPage) getPage(); if (page.getProject().equals(projectAndBranch.getProject())) label = projectAndBranch.getBranch(); else label = projectAndBranch.getFQN(); } else { label = projectAndBranch.getFQN(); } return Model.of(label); }
Example 12
Source File: DoughnutChartPanelTest.java From wicket-chartjs with Apache License 2.0 | 5 votes |
@Test public void testDoughnutChartPanelStringIModelOfQextendsDoughnut() { IModel<? extends Doughnut> model = Model.of(new Doughnut()); DoughnutChartPanel panel = new DoughnutChartPanel("foo", model); tester.startComponentInPage(panel); tester.assertComponent("foo:chart", WebMarkupContainer.class); }
Example 13
Source File: TagSetEditorPanel.java From webanno with Apache License 2.0 | 4 votes |
public TagSetEditorPanel(String aId, IModel<Project> aProject, IModel<TagSet> aTagSet, IModel<Tag> aSelectedTag) { super(aId, aTagSet); setOutputMarkupId(true); setOutputMarkupPlaceholderTag(true); selectedProject = aProject; selectedTagSet = aTagSet; selectedTag = aSelectedTag; exportFormat = Model.of(supportedFormats().get(0)); Form<TagSet> form = new Form<>("form", CompoundPropertyModel.of(aTagSet)); add(form); form.add(new TextField<String>("name") .add(new TagSetExistsValidator()) .setRequired(true)); form.add(new TextField<String>("language")); form.add(new TextArea<String>("description")); form.add(new CheckBox("createTag")); form.add(new LambdaAjaxButton<>("save", this::actionSave)); form.add(new LambdaAjaxLink("delete", this::actionDelete) .onConfigure(_this -> _this.setVisible(form.getModelObject().getId() != null))); form.add(new LambdaAjaxLink("cancel", this::actionCancel)); BootstrapRadioChoice<String> format = new BootstrapRadioChoice<>("format", exportFormat, LoadableDetachableModel.of(this::supportedFormats)); // The AjaxDownloadLink does not submit the form, so the format radio-buttons need to // submit themselves so their value is available when the export button is pressed format.add(onUpdateChoice(_target -> { /*NO-OP*/ })); form.add(format); form.add(new AjaxDownloadLink("export", LoadableDetachableModel.of(this::export))); confirmationDialog = new ConfirmationDialog("confirmationDialog"); confirmationDialog.setTitleModel(new StringResourceModel("DeleteDialog.title", this)); add(confirmationDialog); }
Example 14
Source File: ProjectIssuesPage.java From onedev with MIT License | 4 votes |
public IssuesTab(String title, Class<? extends Page> pageClass, Class<? extends Page> additionalPageClass1, Class<? extends Page> additionalPageClass2, Class<? extends Page> additionalPageClass3) { super(Model.of(title), pageClass, additionalPageClass1, additionalPageClass2, additionalPageClass3); }
Example 15
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); } }); }
Example 16
Source File: StopRestartNodeLink.java From JPPF with Apache License 2.0 | 4 votes |
/** * @param actionType the type of stop/restart action. */ public StopRestartNodeLink(final ActionType actionType) { super(actionType.getId(), Model.of(actionType.getModel()), actionType.getImageName()); this.actionType = actionType; setEnabled(false); }
Example 17
Source File: DescriptionTooltipBehavior.java From webanno with Apache License 2.0 | 4 votes |
@Override protected WebMarkupContainer newContent(String markupId) { return new DescriptionTooltipPanel(markupId, Model.of(this)); }
Example 18
Source File: UserSingleChoiceEditor.java From onedev with MIT License | 4 votes |
@SuppressWarnings("unchecked") @Override protected void onInitialize() { super.onInitialize(); List<User> choices = new ArrayList<>(); ComponentContext componentContext = new ComponentContext(this); ComponentContext.push(componentContext); try { UserChoice userChoice = descriptor.getPropertyGetter().getAnnotation(UserChoice.class); Preconditions.checkNotNull(userChoice); if (userChoice.value().length() != 0) { choices.addAll((List<User>)ReflectionUtils .invokeStaticMethod(descriptor.getBeanClass(), userChoice.value())); } else { choices.addAll(OneDev.getInstance(UserManager.class).query()); choices.sort(Comparator.comparing(User::getName)); } } finally { ComponentContext.pop(); } User selection; if (getModelObject() != null) selection = OneDev.getInstance(UserManager.class).findByName(getModelObject()); else selection = null; if (selection != null && !choices.contains(selection)) selection = null; input = new UserSingleChoice("input", Model.of(selection), Model.of(choices)) { @Override protected void onInitialize() { super.onInitialize(); getSettings().configurePlaceholder(descriptor); } }; // add this to control allowClear flag of select2 input.setRequired(descriptor.isPropertyRequired()); input.setLabel(Model.of(getDescriptor().getDisplayName())); input.add(new AjaxFormComponentUpdatingBehavior("change"){ @Override protected void onUpdate(AjaxRequestTarget target) { onPropertyUpdating(target); } }); add(input); }
Example 19
Source File: SqlCodeVisualizer.java From Orienteer with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { return new SqlEditorPanel(id, (IModel<String>) valueModel, Model.of(mode)); }
Example 20
Source File: RegistrationPage.java From AppStash with Apache License 2.0 | 3 votes |
private PasswordTextField passwordRepeatField() { PasswordTextField repeatPassword = new PasswordTextField("repeatPassword", Model.of("")); repeatPassword.setRequired(true); return repeatPassword; }