Java Code Examples for org.apache.wicket.markup.html.panel.Fragment#add()
The following examples show how to use
org.apache.wicket.markup.html.panel.Fragment#add() .
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: NewPullRequestPage.java From onedev with MIT License | 6 votes |
private Fragment newAcceptedFrag() { Fragment fragment = new Fragment("status", "mergedFrag", this); fragment.add(new BranchLink("sourceBranch", getPullRequest().getSource())); fragment.add(new BranchLink("targetBranch", getPullRequest().getTarget())); fragment.add(new Link<Void>("swapBranches") { @Override public void onClick() { setResponsePage( NewPullRequestPage.class, paramsOf(getProject(), getPullRequest().getSource(), getPullRequest().getTarget())); } }); return fragment; }
Example 2
Source File: MergeLinkedAccountsSearchPanel.java From syncope with Apache License 2.0 | 6 votes |
public MergeLinkedAccountsSearchPanel(final MergeLinkedAccountsWizardModel model, final PageReference pageRef) { super(); setOutputMarkupId(true); this.wizardModel = model; setTitleModel(new StringResourceModel("mergeLinkedAccounts.searchUser", Model.of(model.getBaseUser()))); ownerContainer = new WebMarkupContainer("ownerContainer"); ownerContainer.setOutputMarkupId(true); add(ownerContainer); userSearchFragment = new Fragment("search", "userSearchFragment", this); userSearchPanel = UserSearchPanel.class.cast(new UserSearchPanel.Builder( new ListModel<>(new ArrayList<>())).required(false).enableSearch(MergeLinkedAccountsSearchPanel.this). build("usersearch")); userSearchFragment.add(userSearchPanel); AnyTypeTO anyTypeTO = anyTypeRestClient.read(AnyTypeKind.USER.name()); userDirectoryPanel = UserSelectionDirectoryPanel.class.cast(new UserSelectionDirectoryPanel.Builder( anyTypeClassRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef). build("searchResult")); userSearchFragment.add(userDirectoryPanel); ownerContainer.add(userSearchFragment); }
Example 3
Source File: StudentVisitsWidget.java From sakai with Educational Community License v2.0 | 6 votes |
private Fragment getLazyLoadedMiniStats(String markupId) { Fragment ministatFragment = new Fragment(markupId, "ministatFragment", this); int miniStatsCount = widgetMiniStats != null ? widgetMiniStats.size() : 0; Loop miniStatsLoop = new Loop("widgetRow", miniStatsCount) { private static final long serialVersionUID = 1L; @Override protected void populateItem(LoopItem item) { int index = item.getIndex(); WidgetMiniStat ms = widgetMiniStats.get(index); Label widgetValue = new Label("widgetValue", Model.of(ms.getValue())); Label widgetLabel = new Label("widgetLabel", Model.of(ms.getLabel())); WebMarkupContainer widgetIcon = new WebMarkupContainer("widgetIcon"); widgetIcon.add(new AttributeAppender("class", " " + ms.getSecondValue())); item.add(widgetValue); item.add(widgetLabel); item.add(widgetIcon); } }; ministatFragment.add(miniStatsLoop); return ministatFragment; }
Example 4
Source File: StudentVisitsWidget.java From sakai with Educational Community License v2.0 | 6 votes |
private Fragment getLazyLoadedMiniStats(String markupId) { Fragment ministatFragment = new Fragment(markupId, "ministatFragment", this); int miniStatsCount = widgetMiniStats != null ? widgetMiniStats.size() : 0; Loop miniStatsLoop = new Loop("widgetRow", miniStatsCount) { private static final long serialVersionUID = 1L; @Override protected void populateItem(LoopItem item) { int index = item.getIndex(); WidgetMiniStat ms = widgetMiniStats.get(index); Label widgetValue = new Label("widgetValue", Model.of(ms.getValue())); Label widgetLabel = new Label("widgetLabel", Model.of(ms.getLabel())); WebMarkupContainer widgetIcon = new WebMarkupContainer("widgetIcon"); widgetIcon.add(new AttributeAppender("class", " " + ms.getSecondValue())); item.add(widgetValue); item.add(widgetLabel); item.add(widgetIcon); } }; ministatFragment.add(miniStatsLoop); return ministatFragment; }
Example 5
Source File: NewPullRequestPage.java From onedev with 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 6
Source File: TopologyTogglePanel.java From syncope with Apache License 2.0 | 5 votes |
private Fragment getLocationFragment(final TopologyNode node, final PageReference pageRef) { Fragment fragment = new Fragment("actions", "locationActions", this); AjaxLink<String> create = new IndicatingAjaxLink<String>("create") { private static final long serialVersionUID = 3776750333491622263L; @Override public void onClick(final AjaxRequestTarget target) { final ConnInstanceTO modelObject = new ConnInstanceTO(); modelObject.setLocation(node.getKey()); final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject); modal.setFormModel(model); target.add(modal.setContent(new ConnectorWizardBuilder(modelObject, pageRef). build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE))); modal.header(new Model<>(MessageFormat.format(getString("connector.new"), node.getKey()))); modal.show(true); } @Override public String getAjaxIndicatorMarkupId() { return Constants.VEIL_INDICATOR_MARKUP_ID; } }; fragment.add(create); MetaDataRoleAuthorizationStrategy.authorize(create, RENDER, IdMEntitlement.CONNECTOR_CREATE); return fragment; }
Example 7
Source File: AbstractFieldPanel.java From syncope with Apache License 2.0 | 5 votes |
public AbstractFieldPanel<T> addRequiredLabel() { if (!isRequired()) { setRequired(true); } final Fragment fragment = new Fragment("required", "requiredFragment", this); fragment.add(new Label("requiredLabel", "*")); replace(fragment); this.isRequiredLabelAdded = true; return this; }
Example 8
Source File: AppointmentTemplate.java From openmeetings with Apache License 2.0 | 5 votes |
@Override Fragment getSubjectFragment() { Fragment f = new Fragment(COMP_ID, "subject", this); f.add(new OmTextLabel("prefix", getPrefix()) , new OmTextLabel("title", a.getTitle()) , new OmTextLabel("start", format(a.getStart(), SHORT)) , new DashOmTextLabel("dash") , new OmTextLabel("end", format(a.getEnd(), SHORT)) ); return f; }
Example 9
Source File: AbstractFieldPanel.java From syncope with Apache License 2.0 | 4 votes |
public AbstractFieldPanel<T> showExternAction(final Component component) { final Fragment fragment = new Fragment("externalAction", "externalActionFragment", AbstractFieldPanel.this); addOrReplace(fragment); fragment.add(component.setRenderBodyOnly(false)); return this; }
Example 10
Source File: ParamListViewPanel.java From onedev with MIT License | 4 votes |
@Override protected void onInitialize() { super.onInitialize(); RepeatingView paramsView = new RepeatingView("params"); for (ParamSupply param: params) { WebMarkupContainer paramItem = new WebMarkupContainer(paramsView.newChildId()); paramItem.add(new Label("name", param.getName())); if (param.getValuesProvider() instanceof SpecifiedValues) { if (param.isSecret()) paramItem.add(new Label("valuesProvider", SpecifiedValues.SECRET_DISPLAY_NAME)); else paramItem.add(new Label("valuesProvider", SpecifiedValues.DISPLAY_NAME)); Fragment fragment = new Fragment("values", "specifiedValuesFrag", this); RepeatingView valuesView = new RepeatingView("values"); SpecifiedValues specifiedValues = (SpecifiedValues) param.getValuesProvider(); for (List<String> value: specifiedValues.getValues()) { WebMarkupContainer valueItem = new WebMarkupContainer(valuesView.newChildId()); if (value.size() == 0) valueItem.add(new Label("value", "<i>Empty</i>").setEscapeModelStrings(false)); else if (value.size() == 1) valueItem.add(new Label("value", value.iterator().next())); else valueItem.add(new Label("value", value.toString())); valuesView.add(valueItem); } fragment.add(valuesView); paramItem.add(fragment); } else if (param.getValuesProvider() instanceof ScriptingValues) { if (param.isSecret()) paramItem.add(new Label("valuesProvider", ScriptingValues.SECRET_DISPLAY_NAME)); else paramItem.add(new Label("valuesProvider", ScriptingValues.DISPLAY_NAME)); paramItem.add(PropertyContext.view("values", param.getValuesProvider(), "scriptName")); } else { paramItem.add(new Label("valuesProvider", Ignore.DISPLAY_NAME)); paramItem.add(new WebMarkupContainer("values")); } paramsView.add(paramItem); } add(paramsView); }
Example 11
Source File: AbstractMultiPanel.java From syncope with Apache License 2.0 | 4 votes |
private Fragment getDataFragment() { final Fragment contentFragment = new Fragment("content", "dataFragment", AbstractMultiPanel.this); contentFragment.add(view.setOutputMarkupId(true)); return contentFragment; }
Example 12
Source File: AbstractMultiPanel.java From syncope with Apache License 2.0 | 4 votes |
private Fragment getNoDataFragment(final IModel<List<INNER>> model, final String label) { final Fragment fragment = new Fragment("content", "noDataFragment", AbstractMultiPanel.this); fragment.add(new Label("field-label", new ResourceModel(label, label))); fragment.add(getPlusFragment(model, label)); return fragment; }
Example 13
Source File: BinaryFieldPanel.java From syncope with Apache License 2.0 | 4 votes |
private void changePreviewer(final Component panelPreview) { final Fragment fragment = new Fragment("panelPreview", "previewFragment", container); fragment.add(panelPreview); container.addOrReplace(fragment); uploadForm.addOrReplace(container); }
Example 14
Source File: TwitterPrefsPane.java From sakai with Educational Community License v2.0 | 4 votes |
/** * Fragment which returns the components for the linked view * @return */ private Fragment linkedFragment() { Fragment frag = new Fragment("fragmentContainer", "linked", this); //label frag.add(new Label("twitterAuthLabel", new ResourceModel("twitter.auth.linked"))); //screen name String twitterName = externalIntegrationLogic.getTwitterName(externalIntegrationInfo); Label twitterAuthName = new Label("twitterAuthName", new Model<String>(twitterName)); if(StringUtils.isBlank(twitterName)){ twitterAuthName.setDefaultModel(new ResourceModel("error.twitter.details.invalid")); } frag.add(twitterAuthName); //remove link IndicatingAjaxLink<String> twitterAuthRemoveLink = new IndicatingAjaxLink<String>("twitterAuthRemoveLink") { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { externalIntegrationInfo.setTwitterToken(null); externalIntegrationInfo.setTwitterSecret(null); //remove details if(externalIntegrationLogic.updateExternalIntegrationInfo(externalIntegrationInfo)) { switchContentFragments(unlinkedFragment(), target); } else { target.appendJavaScript("alert('Couldn't remove info');"); return; } } }; ContextImage twitterAuthRemoveIcon = new ContextImage("twitterAuthRemoveIcon",new Model<String>(ProfileConstants.CROSS_IMG)); twitterAuthRemoveLink.add(twitterAuthRemoveIcon); twitterAuthRemoveLink.add(new AttributeModifier("title", true,new ResourceModel("link.title.unlinktwitter"))); frag.add(twitterAuthRemoveLink); frag.setOutputMarkupId(true); return frag; }
Example 15
Source File: RoleDetailPage.java From onedev with MIT License | 4 votes |
@Override protected void onInitialize() { super.onInitialize(); if (getRole().isOwner()) { add(new Fragment("content", "ownerFrag", this)); } else { Fragment fragment = new Fragment("content", "nonOwnerFrag", this); editor = BeanContext.editModel("editor", new IModel<Serializable>() { @Override public void detach() { } @Override public Serializable getObject() { return getRole(); } @Override public void setObject(Serializable object) { oldName = getRole().getName(); editor.getDescriptor().copyProperties(object, getRole()); } }); Form<?> form = new Form<Void>("form") { @Override protected void onSubmit() { super.onSubmit(); Role role = getRole(); RoleManager roleManager = OneDev.getInstance(RoleManager.class); Role roleWithSameName = roleManager.find(role.getName()); if (roleWithSameName != null && !roleWithSameName.equals(role)) { editor.error(new Path(new PathNode.Named("name")), "This name has already been used by another role."); } if (editor.isValid()) { roleManager.save(role, oldName); setResponsePage(RoleDetailPage.class, RoleDetailPage.paramsOf(role)); Session.get().success("Role updated"); } } }; form.add(editor); form.add(new FencedFeedbackPanel("feedback", form).setEscapeModelStrings(false)); form.add(new Link<Void>("delete") { @Override public void onClick() { OneDev.getInstance(RoleManager.class).delete(getRole()); Session.get().success("Role '" + getRole().getName() + "' deleted"); String redirectUrlAfterDelete = WebSession.get().getRedirectUrlAfterDelete(Role.class); if (redirectUrlAfterDelete != null) throw new RedirectToUrlException(redirectUrlAfterDelete); else setResponsePage(RoleListPage.class); } @Override protected void onConfigure() { super.onConfigure(); setVisible(!getRole().isOwner()); } }.add(new ConfirmClickModifier("Do you really want to delete role '" + getRole().getName() + "'?"))); fragment.add(form); add(fragment); } }
Example 16
Source File: BuildSpecBlobViewPanel.java From onedev with MIT License | 4 votes |
@Override protected void onInitialize() { super.onInitialize(); try { Blob blob = context.getProject().getBlob(context.getBlobIdent(), true); BuildSpec buildSpec = BuildSpec.parse(blob.getBytes()); if (buildSpec != null) { Fragment validFrag = new Fragment("content", "validFrag", this); if (!buildSpec.getJobs().isEmpty()) { Fragment hasJobsFrag = new Fragment("jobs", "hasJobsFrag", this); RepeatingView navsView = new RepeatingView("navs"); RepeatingView jobsView = new RepeatingView("contents"); for (Job job: buildSpec.getJobs()) { WebMarkupContainer nav = new WebMarkupContainer(navsView.newChildId()); nav.add(new Label("jobName", job.getName())); nav.add(AttributeAppender.append("data-name", job.getName())); nav.add(new RunJobLink("run", context.getCommit().copy(), job.getName()) { @Override protected Project getProject() { return context.getProject(); } }); navsView.add(nav); jobsView.add(BeanContext.view(jobsView.newChildId(), job)); } hasJobsFrag.add(navsView); hasJobsFrag.add(jobsView); validFrag.add(hasJobsFrag); } else { validFrag.add(new Label("jobs", "No jobs defined").add(AttributeAppender.append("class", "not-defined"))); } if (!buildSpec.getProperties().isEmpty()) validFrag.add(PropertyContext.view("properties", buildSpec, "properties")); else validFrag.add(new Label("properties", "No properties defined").add(AttributeAppender.append("class", "not-defined"))); add(validFrag); } else { add(new Label("content", "Build spec not defined").add(AttributeAppender.append("class", "not-defined"))); } } catch (Exception e) { Fragment invalidFrag = new Fragment("content", "invalidFrag", this); invalidFrag.add(new MultilineLabel("errorMessage", Throwables.getStackTraceAsString(e))); add(invalidFrag); } add(selectBehavior = new AbstractPostAjaxBehavior() { @Override protected void respond(AjaxRequestTarget target) { IRequestParameters params = RequestCycle.get().getRequest().getPostParameters(); String selection = params.getParameterValue("selection").toString(); String position = BuildSpecRendererProvider.getPosition(selection); context.pushState(target, context.getBlobIdent(), position); } }); }
Example 17
Source File: SourceViewPanel.java From onedev with MIT License | 4 votes |
private NestedTree<Symbol> newOutlineSearchSymbolTree(ModalPanel modal, List<Symbol> symbols, @Nullable String searchInput) { IModel<HashSet<Symbol>> state; if (StringUtils.isNotBlank(searchInput)) { state = new Model<HashSet<Symbol>>(new HashSet<>(symbols)); } else { state = new Model<HashSet<Symbol>>(new HashSet<>(getChildSymbols(symbols, null))); } NestedTree<Symbol> tree = new NestedTree<Symbol>("result", newSymbolTreeProvider(symbols), state) { @Override protected void onInitialize() { super.onInitialize(); add(new HumanTheme()); } @Override protected Component newContentComponent(String id, IModel<Symbol> nodeModel) { Symbol symbol = nodeModel.getObject(); Fragment fragment = new Fragment(id, "outlineSearchNodeFrag", SourceViewPanel.this); fragment.setOutputMarkupId(true); AjaxLink<Void> link = new ViewStateAwareAjaxLink<Void>("link") { @Override public void onClick(AjaxRequestTarget target) { modal.close(); context.onSelect(target, context.getBlobIdent(), SourceRendererProvider.getPosition(symbol.getPosition())); } }; link.add(symbol.renderIcon("icon")); link.add(symbol.render("label", null)); link.add(AttributeAppender.append("data-symbolindex", symbols.indexOf(symbol))); fragment.add(link); for (Symbol each: symbols) { if (each.isDisplayInOutline()) { if (symbol == each) link.add(AttributeAppender.append("class", "active")); break; } } return fragment; } }; tree.setOutputMarkupId(true); return tree; }
Example 18
Source File: PullRequestDetailPage.java From onedev with MIT License | 4 votes |
@Override public Component render(String componentId) { if (getMainPageClass() == PullRequestCodeCommentsPage.class) { Fragment fragment = new Fragment(componentId, "codeCommentsTabLinkFrag", PullRequestDetailPage.this); Link<Void> link = new ViewStateAwarePageLink<Void>("link", PullRequestCodeCommentsPage.class, paramsOf(getPullRequest())); link.add(AttributeAppender.append("class", new LoadableDetachableModel<String>() { @Override protected String load() { PullRequest request = getPullRequest(); if (request.getLastCodeCommentActivityDate() != null && !request.isCodeCommentsVisitedAfter(request.getLastCodeCommentActivityDate())) { return "new"; } else { return ""; } } })); link.add(new WebSocketObserver() { @Override public Collection<String> getObservables() { return Sets.newHashSet(PullRequest.getWebSocketObservable(getPullRequest().getId())); } @Override public void onObservableChanged(IPartialPageRequestHandler handler) { handler.add(component); } }); link.setOutputMarkupId(true); fragment.add(link); return fragment; } else { return new PageTabLink(componentId, this) { @Override protected Link<?> newLink(String linkId, Class<? extends Page> pageClass) { return new ViewStateAwarePageLink<Void>(linkId, pageClass, paramsOf(getPullRequest())); } }; } }
Example 19
Source File: RealmDetails.java From syncope with Apache License 2.0 | 4 votes |
public RealmDetails( final String id, final RealmTO realmTO, final ActionsPanel<?> actionsPanel, final boolean unwrapped) { super(id); container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); container.setRenderBodyOnly(unwrapped); add(container); final WebMarkupContainer generics = new WebMarkupContainer("generics"); container.add(generics.setVisible(unwrapped)); FieldPanel<String> name = new AjaxTextFieldPanel( "name", "name", new PropertyModel<>(realmTO, "name"), false); name.addRequiredLabel(); generics.add(name); FieldPanel<String> fullPath = new AjaxTextFieldPanel( "fullPath", "fullPath", new PropertyModel<>(realmTO, "fullPath"), false); fullPath.setEnabled(false); generics.add(fullPath); AjaxDropDownChoicePanel<String> accountPolicy = new AjaxDropDownChoicePanel<>( "accountPolicy", new ResourceModel("accountPolicy", "accountPolicy").getObject(), new PropertyModel<>(realmTO, "accountPolicy"), false); accountPolicy.setChoiceRenderer(new PolicyRenderer(accountPolicies)); accountPolicy.setChoices(new ArrayList<>(accountPolicies.getObject().keySet())); ((DropDownChoice<?>) accountPolicy.getField()).setNullValid(true); container.add(accountPolicy); AjaxDropDownChoicePanel<String> passwordPolicy = new AjaxDropDownChoicePanel<>( "passwordPolicy", new ResourceModel("passwordPolicy", "passwordPolicy").getObject(), new PropertyModel<>(realmTO, "passwordPolicy"), false); passwordPolicy.setChoiceRenderer(new PolicyRenderer(passwordPolicies)); passwordPolicy.setChoices(new ArrayList<>(passwordPolicies.getObject().keySet())); ((DropDownChoice<?>) passwordPolicy.getField()).setNullValid(true); container.add(passwordPolicy); AjaxPalettePanel<String> actions = new AjaxPalettePanel.Builder<String>(). setAllowMoveAll(true).setAllowOrder(true). build("actions", new PropertyModel<>(realmTO, "actions"), new ListModel<>(logicActions.getObject())); actions.setOutputMarkupId(true); container.add(actions); container.add(new AjaxPalettePanel.Builder<String>().build("resources", new PropertyModel<>(realmTO, "resources"), new ListModel<>(resources.getObject())). setOutputMarkupId(true). setEnabled(!SyncopeConstants.ROOT_REALM.equals(realmTO.getName())). setVisible(!SyncopeConstants.ROOT_REALM.equals(realmTO.getName()))); if (actionsPanel == null) { add(new Fragment("actions", "emptyFragment", this).setRenderBodyOnly(true)); } else { Fragment fragment = new Fragment("actions", "actionsFragment", this); fragment.add(actionsPanel); add(fragment.setRenderBodyOnly(true)); } }
Example 20
Source File: BinaryFieldPanel.java From syncope with Apache License 2.0 | 4 votes |
private void changePreviewer(final Component panelPreview) { final Fragment fragment = new Fragment("panelPreview", "previewFragment", container); fragment.add(panelPreview); container.addOrReplace(fragment); uploadForm.addOrReplace(container); }