List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink add
public MarkupContainer add(final Component... children)
From source file:ontopoly.components.ButtonFunctionBoxPanel.java
License:Apache License
protected Component getButton(String id) { AjaxLink<Object> button = new AjaxLink<Object>(id) { @Override//from w w w. ja va2s . co m protected void onComponentTag(ComponentTag tag) { tag.setName("input"); tag.put("type", "button"); tag.put("value", getButtonLabel().getObject().toString()); super.onComponentTag(tag); } @Override public void onClick(AjaxRequestTarget target) { ButtonFunctionBoxPanel.this.onClick(target); } }; List<IBehavior> behaviors = getButtonBehaviors(); if (behaviors != null) { Iterator<IBehavior> it = behaviors.iterator(); while (it.hasNext()) { button.add(it.next()); } } return button; }
From source file:ontopoly.components.FieldInstanceCreatePlayerPanel.java
License:Apache License
public FieldInstanceCreatePlayerPanel(String id, FieldInstanceModel _fieldInstanceModel, FieldsViewModel fieldsViewModel, RoleFieldModel _roleFieldModel, AbstractFieldInstancePanel fieldInstancePanel, int createAction) { super(id);/*from w w w .j a v a 2s. c om*/ this.fieldInstanceModel = _fieldInstanceModel; this.fieldsViewModel = fieldsViewModel; this.roleFieldModel = _roleFieldModel; this.fieldInstancePanel = fieldInstancePanel; this.createAction = createAction; RoleField associationField = roleFieldModel.getRoleField(); Collection<TopicType> allowedValueTypes = associationField .getAllowedPlayerTypes(_fieldInstanceModel.getFieldInstance().getInstance()); if (allowedValueTypes.isEmpty()) { setVisible(false); OntopolyImageLink button = new OntopolyImageLink("button", "create.gif", new ResourceModel("icon.create.player")) { @Override public void onClick(AjaxRequestTarget target) { } }; add(button); add(new Label("createMenu")); add(new Label("createModal")); } else if (allowedValueTypes.size() == 1) { this.topicTypeModel = new TopicTypeModel((TopicType) allowedValueTypes.iterator().next()); OntopolyImageLink button = new OntopolyImageLink("button", "create.gif", new ResourceModel("icon.create.player")) { @Override public void onClick(AjaxRequestTarget target) { FieldInstanceCreatePlayerPanel.this.onClick(target, topicTypeModel.getTopicType()); } }; add(button); add(new Label("createMenu").setVisible(false)); add(new Label("createModal").setVisible(false)); } else { final String menuId = id + "_" + associationField.getId() + "_" + _fieldInstanceModel.getFieldInstance().getInstance().getId(); Link<Object> button = new Link<Object>("button") { { add(new Image("image", new AbstractReadOnlyModel<ResourceReference>() { @Override public ResourceReference getObject() { return new ResourceReference(ImageResource.class, "create.gif"); } })); } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("onclick", "menuItemPopup(this)"); tag.put("id", "main" + menuId); tag.put("href", "#"); } @Override public void onClick() { } }; add(button); add(new ContextMenuPanel<TopicType>("createMenu", menuId) { @Override protected ListView<TopicType> createListView(final String menuId, final String menuItemId) { return new ListView<TopicType>(menuId, new PlayerTypesModel(fieldInstanceModel, roleFieldModel)) { @Override public void populateItem(final ListItem<TopicType> item) { AjaxLink<Object> createLink = new AjaxLink<Object>(menuItemId) { @Override public void onClick(AjaxRequestTarget target) { FieldInstanceCreatePlayerPanel.this.onClick(target, item.getModelObject()); } }; createLink.add(new Label("label", item.getModelObject().getName())); item.add(createLink); } }; } }); add(new Label("createModal").setVisible(false)); } }
From source file:org.apache.isis.viewer.wicket.ui.components.bookmarkedpages.BookmarkedPagesPanel.java
License:Apache License
private void buildGui() { final BookmarkedPagesModel bookmarkedPagesModel = getModel(); Component helpText = addHelpText(bookmarkedPagesModel); addOrReplace(helpText);//from w w w. j a va 2s.c o m final WebMarkupContainer container = new WebMarkupContainer(ID_BOOKMARK_LIST) { private static final long serialVersionUID = 1L; @Override public void renderHead(IHeaderResponse response) { response.render(CssHeaderItem.forReference( new CssResourceReference(BookmarkedPagesPanel.class, "BookmarkedPagesPanel.css"))); response.render(JavaScriptReferenceHeaderItem.forReference(SLIDE_PANEL_JS)); } }; // allow to be updated by AjaxLink container.setOutputMarkupId(true); add(container); final AjaxLink<Void> clearAllBookmarksLink = new AjaxLink<Void>(CLEAR_BOOKMARKS) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { BookmarkedPagesPanel.this.getModel().clear(); setEnabled(false); target.add(container, this); } }; clearAllBookmarksLink.setOutputMarkupId(true); add(clearAllBookmarksLink); clearAllBookmarksLink.setOutputMarkupId(true); if (getModel().isEmpty()) { clearAllBookmarksLink.setVisible(false); } final ListView<BookmarkTreeNode> listView = new ListView<BookmarkTreeNode>(ID_BOOKMARKED_PAGE_ITEM, bookmarkedPagesModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<BookmarkTreeNode> item) { final BookmarkTreeNode node = item.getModelObject(); try { final PageType pageType = node.getPageType(); final Class<? extends Page> pageClass = pageClassRegistry.getPageClass(pageType); final AjaxLink<Object> clearBookmarkLink = new AjaxLink<Object>(ID_CLEAR_BOOKMARK_LINK) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { bookmarkedPagesModel.remove(node); if (bookmarkedPagesModel.isEmpty()) { permanentlyHide(CLEAR_BOOKMARKS); } target.add(container, clearAllBookmarksLink); } }; if (node.getDepth() == 0) { clearBookmarkLink.add(new CssClassAppender("clearBookmark")); } else { clearBookmarkLink.setEnabled(true); } item.add(clearBookmarkLink); PageParameters pageParameters = node.getPageParameters(); final AbstractLink link = Links.newBookmarkablePageLink(ID_BOOKMARKED_PAGE_LINK, pageParameters, pageClass); ObjectSpecification objectSpec = null; RootOid oid = node.getOidNoVer(); if (oid != null) { ObjectSpecId objectSpecId = oid.getObjectSpecId(); objectSpec = getSpecificationLoader().lookupBySpecId(objectSpecId); } final ResourceReference imageResource = imageCache.resourceReferenceForSpec(objectSpec); final Image image = new Image(ID_BOOKMARKED_PAGE_ICON, imageResource) { private static final long serialVersionUID = 1L; @Override protected boolean shouldAddAntiCacheParameter() { return false; } }; link.addOrReplace(image); String title = node.getTitle(); final Label label = new Label(ID_BOOKMARKED_PAGE_TITLE, title); link.add(label); item.add(link); if (bookmarkedPagesModel.isCurrent(pageParameters)) { item.add(new CssClassAppender("disabled")); } item.add(new CssClassAppender("bookmarkDepth" + node.getDepth())); } catch (ObjectNotFoundException ex) { // ignore // this is a partial fix for an infinite redirect loop. // should be a bit smarter here, though; see ISIS-596. } } }; container.add(listView); }
From source file:org.apache.isis.viewer.wicket.ui.components.widgets.cssmenu.ActionLinkFactoryAbstract.java
License:Apache License
/** * Either creates a link for the action be rendered in a {@link ModalWindow}, or (if none can be * {@link ActionPromptProvider#getActionPrompt() provided}, or creates a link to * the {@link ActionPromptPage} (ie the {@link PageClassRegistry registered page} for * {@link PageType#ACTION_PROMPT action}s). * //w w w . ja v a 2s. c om * <p> * If the action's {@link ObjectAction#getSemantics() semantics} are {@link ActionSemantics.Of#SAFE safe}, then * concurrency checking is disabled; otherwise it is enforced. */ protected AbstractLink newLink(final String linkId, final ObjectAdapter objectAdapter, final ObjectAction action, final ActionPromptProvider actionPromptProvider) { final ActionPrompt actionPrompt = actionPromptProvider.getActionPrompt(); if (actionPrompt != null) { final ActionModel actionModel = ActionModel.create(objectAdapter, action); actionModel.setActionPrompt(actionPrompt); AjaxLink<Object> link = new AjaxLink<Object>(linkId) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { final ActionPanel actionPromptPanel = (ActionPanel) getComponentFactoryRegistry() .createComponent(ComponentType.ACTION_PROMPT, actionPrompt.getContentId(), actionModel); actionPrompt.setPanel(actionPromptPanel, target); actionPrompt.show(target); target.focusComponent(actionPromptPanel); } }; link.add(new CssClassAppender("noVeil")); return link; } else { // use the action semantics to determine whether invoking this action will require a concurrency check or not // if it's "safe", then we'll just continue without any checking. final ConcurrencyChecking concurrencyChecking = ConcurrencyChecking .concurrencyCheckingFor(action.getSemantics()); final PageParameters pageParameters = ActionModel.createPageParameters(objectAdapter, action, concurrencyChecking); final Class<? extends Page> pageClass = getPageClassRegistry().getPageClass(PageType.ACTION_PROMPT); AbstractLink link = Links.newBookmarkablePageLink(linkId, pageParameters, pageClass); // special case handling if this a no-arg action is returning a URL if (action.getParameterCount() == 0) { addTargetBlankIfActionReturnsUrl(link, action); } return link; } }
From source file:org.apache.syncope.client.console.pages.DerSchemaModalPage.java
License:Apache License
@Override public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window, DerSchemaTO schema, final boolean createFlag) { if (schema == null) { schema = new DerSchemaTO(); }//w w w . j av a 2 s . c om final Form<DerSchemaTO> schemaForm = new Form<>(FORM); schemaForm.setModel(new CompoundPropertyModel<>(schema)); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("key", getString("key"), new PropertyModel<String>(schema, "key")); name.addRequiredLabel(); final AjaxTextFieldPanel expression = new AjaxTextFieldPanel("expression", getString("expression"), new PropertyModel<String>(schema, "expression")); expression.addRequiredLabel(); final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); schemaForm.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); name.setEnabled(createFlag); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form form) { DerSchemaTO schemaTO = (DerSchemaTO) form.getDefaultModelObject(); try { if (createFlag) { schemaRestClient.createDerSchema(kind, schemaTO); } else { schemaRestClient.updateDerSchema(kind, schemaTO); } if (pageRef.getPage() instanceof BasePage) { ((BasePage) pageRef.getPage()).setModalResult(true); } window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); String allowedRoles = createFlag ? xmlRolesReader.getEntitlement("Schema", "create") : xmlRolesReader.getEntitlement("Schema", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); schemaForm.add(name); schemaForm.add(expression); schemaForm.add(submit); schemaForm.add(cancel); add(schemaForm); }
From source file:org.apache.syncope.client.console.pages.PlainSchemaModalPage.java
License:Apache License
@Override public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window, final PlainSchemaTO schemaTO, final boolean createFlag) { final PlainSchemaTO schema = schemaTO == null ? new PlainSchemaTO() : schemaTO; final Form<PlainSchemaTO> schemaForm = new Form<>(FORM); schemaForm.setModel(new CompoundPropertyModel<>(schema)); schemaForm.setOutputMarkupId(true);// w w w . j a v a 2 s.co m final AjaxTextFieldPanel name = new AjaxTextFieldPanel("key", getString("key"), new PropertyModel<String>(schema, "key")); name.addRequiredLabel(); name.setEnabled(createFlag); schemaForm.add(name); final AjaxDropDownChoicePanel<AttrSchemaType> type = new AjaxDropDownChoicePanel<>("type", getString("type"), new PropertyModel<AttrSchemaType>(schema, "type")); type.setChoices(Arrays.asList(AttrSchemaType.values())); type.addRequiredLabel(); schemaForm.add(type); // -- long, double, date final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern", getString("conversionPattern"), new PropertyModel<String>(schema, "conversionPattern")); schemaForm.add(conversionPattern); final WebMarkupContainer conversionParams = new WebMarkupContainer("conversionParams"); conversionParams.setOutputMarkupPlaceholderTag(true); conversionParams.add(conversionPattern); schemaForm.add(conversionParams); final WebMarkupContainer typeParams = new WebMarkupContainer("typeParams"); typeParams.setOutputMarkupPlaceholderTag(true); // -- enum final AjaxTextFieldPanel enumerationValuesPanel = new AjaxTextFieldPanel("panel", "enumerationValues", new Model<String>(null)); @SuppressWarnings({ "unchecked", "rawtypes" }) final MultiFieldPanel<String> enumerationValues = new MultiFieldPanel<>("enumerationValues", new Model(), enumerationValuesPanel); enumerationValues.setModelObject(getEnumValuesAsList(schema.getEnumerationValues())); @SuppressWarnings({ "unchecked", "rawtypes" }) final MultiFieldPanel<String> enumerationKeys = new MultiFieldPanel<>("enumerationKeys", new Model(), new AjaxTextFieldPanel("panel", "enumerationKeys", new Model<String>(null))); enumerationKeys.setModelObject(getEnumValuesAsList(schema.getEnumerationKeys())); final WebMarkupContainer enumParams = new WebMarkupContainer("enumParams"); enumParams.setOutputMarkupPlaceholderTag(true); enumParams.add(enumerationValues); enumParams.add(enumerationKeys); typeParams.add(enumParams); // -- encrypted final AjaxTextFieldPanel secretKey = new AjaxTextFieldPanel("secretKey", getString("secretKey"), new PropertyModel<String>(schema, "secretKey")); final AjaxDropDownChoicePanel<CipherAlgorithm> cipherAlgorithm = new AjaxDropDownChoicePanel<>( "cipherAlgorithm", getString("cipherAlgorithm"), new PropertyModel<CipherAlgorithm>(schema, "cipherAlgorithm")); cipherAlgorithm.setChoices(Arrays.asList(CipherAlgorithm.values())); final WebMarkupContainer encryptedParams = new WebMarkupContainer("encryptedParams"); encryptedParams.setOutputMarkupPlaceholderTag(true); encryptedParams.add(secretKey); encryptedParams.add(cipherAlgorithm); typeParams.add(encryptedParams); // -- binary final AjaxTextFieldPanel mimeType = new AjaxTextFieldPanel("mimeType", getString("mimeType"), new PropertyModel<String>(schema, "mimeType")); mimeType.setChoices(mimeTypesInitializer.getMimeTypes()); final WebMarkupContainer binaryParams = new WebMarkupContainer("binaryParams"); binaryParams.setOutputMarkupPlaceholderTag(true); binaryParams.add(mimeType); typeParams.add(binaryParams); schemaForm.add(typeParams); // -- show or hide showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { PlainSchemaModalPage.this.showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); target.add(typeParams); } }); final IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return schemaRestClient.getAllValidatorClasses(); } }; final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<>("validatorClass", getString("validatorClass"), new PropertyModel<String>(schema, "validatorClass")); ((DropDownChoice) validatorClass.getField()).setNullValid(true); validatorClass.setChoices(validatorsList.getObject()); schemaForm.add(validatorClass); final AutoCompleteTextField<String> mandatoryCondition = new AutoCompleteTextField<String>( "mandatoryCondition") { private static final long serialVersionUID = -2428903969518079100L; @Override protected Iterator<String> getChoices(final String input) { List<String> choices = new ArrayList<String>(); if (Strings.isEmpty(input)) { choices = Collections.emptyList(); } else if ("true".startsWith(input.toLowerCase())) { choices.add("true"); } else if ("false".startsWith(input.toLowerCase())) { choices.add("false"); } return choices.iterator(); } }; mandatoryCondition.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); schemaForm.add(mandatoryCondition); final WebMarkupContainer pwdJexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> pwdQuestionMarkJexlHelp = JexlHelpUtils.getAjaxLink(pwdJexlHelp, "questionMarkJexlHelp"); schemaForm.add(pwdQuestionMarkJexlHelp); pwdQuestionMarkJexlHelp.add(pwdJexlHelp); final AjaxCheckBoxPanel multivalue = new AjaxCheckBoxPanel("multivalue", getString("multivalue"), new PropertyModel<Boolean>(schema, "multivalue")); schemaForm.add(multivalue); final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"), new PropertyModel<Boolean>(schema, "readonly")); schemaForm.add(readonly); final AjaxCheckBoxPanel uniqueConstraint = new AjaxCheckBoxPanel("uniqueConstraint", getString("uniqueConstraint"), new PropertyModel<Boolean>(schema, "uniqueConstraint")); schemaForm.add(uniqueConstraint); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final PlainSchemaTO schemaTO = (PlainSchemaTO) form.getDefaultModelObject(); schemaTO.setEnumerationValues(getEnumValuesAsString(enumerationValues.getView().getModelObject())); schemaTO.setEnumerationKeys(getEnumValuesAsString(enumerationKeys.getView().getModelObject())); if (schemaTO.isMultivalue() && schemaTO.isUniqueConstraint()) { error(getString("multivalueAndUniqueConstr.validation")); feedbackPanel.refresh(target); return; } try { if (createFlag) { schemaRestClient.createPlainSchema(kind, schemaTO); } else { schemaRestClient.updatePlainSchema(kind, schemaTO); } if (pageRef.getPage() instanceof BasePage) { ((BasePage) pageRef.getPage()).setModalResult(true); } window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; schemaForm.add(submit); final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); schemaForm.add(cancel); String allowedRoles = createFlag ? xmlRolesReader.getEntitlement("Schema", "create") : xmlRolesReader.getEntitlement("Schema", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); add(schemaForm); }
From source file:org.apache.syncope.client.console.pages.Resources.java
License:Apache License
private void setupResources() { List<IColumn<ResourceTO, String>> columns = new ArrayList<>(); columns.add(/* ww w. j av a 2s . c om*/ new PropertyColumn<ResourceTO, String>(new StringResourceModel("key", this, null), "key", "key")); columns.add(new AbstractColumn<ResourceTO, String>( new StringResourceModel("connector", this, null, "connector")) { private static final long serialVersionUID = 8263694778917279290L; @Override public void populateItem(final Item<ICellPopulator<ResourceTO>> cellItem, final String componentId, final IModel<ResourceTO> rowModel) { final AjaxLink<String> editLink = new ClearIndicatingAjaxLink<String>("link", getPageReference()) { private static final long serialVersionUID = -7978723352517770644L; @Override protected void onClickInternal(final AjaxRequestTarget target) { editConnectorWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new ConnectorModalPage(Resources.this.getPageReference(), editConnectorWin, connectorRestClient.read(rowModel.getObject().getConnectorId())); } }); editConnectorWin.show(target); } }; editLink.add(new Label("linkTitle", rowModel.getObject().getConnectorDisplayName())); LinkPanel editConnPanel = new LinkPanel(componentId); editConnPanel.add(editLink); cellItem.add(editConnPanel); MetaDataRoleAuthorizationStrategy.authorize(editConnPanel, ENABLE, xmlRolesReader.getEntitlement("Connectors", "read")); } }); columns.add( new AbstractColumn<ResourceTO, String>(new StringResourceModel("propagationPrimary", this, null)) { private static final long serialVersionUID = -3503023501954863131L; @Override public void populateItem(final Item<ICellPopulator<ResourceTO>> item, final String componentId, final IModel<ResourceTO> model) { item.add(new Label(componentId, "")); item.add(new AttributeModifier("class", new Model<>(Boolean.toString(model.getObject().isPropagationPrimary())))); } @Override public String getCssClass() { return "narrowcolumn"; } }); columns.add( new PropertyColumn<ResourceTO, String>(new StringResourceModel("propagationPriority", this, null), "propagationPriority", "propagationPriority") { @Override public String getCssClass() { return "narrowcolumn"; } }); columns.add(new AbstractColumn<ResourceTO, String>(new StringResourceModel("actions", this, null, "")) { private static final long serialVersionUID = 2054811145491901166L; @Override public String getCssClass() { return "action"; } @Override public void populateItem(final Item<ICellPopulator<ResourceTO>> cellItem, final String componentId, final IModel<ResourceTO> model) { final ResourceTO resourceTO = model.getObject(); final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference()); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { statusmodal.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new ProvisioningModalPage<>(getPageReference(), statusmodal, model.getObject(), UserTO.class); } }); statusmodal.show(target); } }, ActionLink.ActionType.MANAGE_USERS, "Resources"); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { statusmodal.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new ProvisioningModalPage<>(getPageReference(), statusmodal, model.getObject(), GroupTO.class); } }); statusmodal.show(target); } }, ActionLink.ActionType.MANAGE_GROUPS, "Resources"); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { resourceTO.setUsyncToken(null); resourceTO.setRsyncToken(null); try { resourceRestClient.update(resourceTO); info(getString(Constants.OPERATION_SUCCEEDED)); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ":" + e.getMessage()); LOG.error("While resetting sync token from " + resourceTO.getKey(), e); } feedbackPanel.refresh(target); target.add(resourceContainer); } }, ActionLink.ActionType.RESET, "Resources"); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { editResourceWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new ResourceModalPage(Resources.this.getPageReference(), editResourceWin, resourceTO, false); } }); editResourceWin.show(target); } }, ActionLink.ActionType.EDIT, "Resources"); panel.add(new ActionLink() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target) { try { resourceRestClient.delete(resourceTO.getKey()); info(getString(Constants.OPERATION_SUCCEEDED)); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); LOG.error("While deleting resource " + resourceTO.getKey(), e); } feedbackPanel.refresh(target); target.add(resourceContainer); } }, ActionLink.ActionType.DELETE, "Resources"); cellItem.add(panel); } }); final AjaxDataTablePanel<ResourceTO, String> table = new AjaxDataTablePanel<>("resourceDatatable", columns, (ISortableDataProvider<ResourceTO, String>) new ResourcesProvider(), resourcePaginatorRows, Arrays.asList(new ActionLink.ActionType[] { ActionLink.ActionType.DELETE }), resourceRestClient, "key", "Resources", getPageReference()); resourceContainer = new WebMarkupContainer("resourceContainer"); resourceContainer.add(table); resourceContainer.setOutputMarkupId(true); add(resourceContainer); setWindowClosedCallback(createResourceWin, resourceContainer); setWindowClosedCallback(editResourceWin, resourceContainer); createResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); createResourceWin.setInitialHeight(WIN_HEIGHT); createResourceWin.setInitialWidth(WIN_WIDTH); createResourceWin.setCookieName("create-res-modal"); editResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); editResourceWin.setInitialHeight(WIN_HEIGHT); editResourceWin.setInitialWidth(WIN_WIDTH); editResourceWin.setCookieName("edit-res-modal"); AjaxLink<Void> createResourceLink = new ClearIndicatingAjaxLink<Void>("createResourceLink", getPageReference()) { private static final long serialVersionUID = -7978723352517770644L; @Override protected void onClickInternal(final AjaxRequestTarget target) { createResourceWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { final ResourceModalPage windows = new ResourceModalPage(Resources.this.getPageReference(), editResourceWin, new ResourceTO(), true); return windows; } }); createResourceWin.show(target); } }; MetaDataRoleAuthorizationStrategy.authorize(createResourceLink, ENABLE, xmlRolesReader.getEntitlement("Resources", "create")); add(createResourceLink); @SuppressWarnings("rawtypes") final Form paginatorForm = new Form("resourcePaginatorForm"); @SuppressWarnings({ "unchecked", "rawtypes" }) final DropDownChoice rowsChooser = new DropDownChoice("rowsChooser", new PropertyModel(this, "resourcePaginatorRows"), prefMan.getPaginatorChoices()); rowsChooser.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { prefMan.set(getRequest(), getResponse(), Constants.PREF_RESOURCES_PAGINATOR_ROWS, String.valueOf(resourcePaginatorRows)); table.setItemsPerPage(resourcePaginatorRows); target.add(resourceContainer); } }); paginatorForm.add(rowsChooser); add(paginatorForm); }
From source file:org.apache.syncope.client.console.pages.ResultStatusModalPage.java
License:Apache License
private ResultStatusModalPage(final Builder builder) { super();/*from w w w . j a v a 2 s.co m*/ this.subject = builder.subject; statusUtils = new StatusUtils(this.userRestClient); if (builder.mode == null) { this.mode = Mode.ADMIN; } else { this.mode = builder.mode; } final BaseModalPage page = this; final WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); add(container); final Fragment fragment = new Fragment("resultFrag", mode == Mode.SELF ? "userSelfResultFrag" : "propagationResultFrag", this); fragment.setOutputMarkupId(true); container.add(fragment); if (mode == Mode.ADMIN) { // add Syncope propagation status PropagationStatus syncope = new PropagationStatus(); syncope.setResource("Syncope"); syncope.setStatus(PropagationTaskExecStatus.SUCCESS); List<PropagationStatus> propagations = new ArrayList<PropagationStatus>(); propagations.add(syncope); propagations.addAll(subject.getPropagationStatusTOs()); fragment.add(new Label("info", ((subject instanceof UserTO) && ((UserTO) subject).getUsername() != null) ? ((UserTO) subject).getUsername() : ((subject instanceof GroupTO) && ((GroupTO) subject).getName() != null) ? ((GroupTO) subject).getName() : String.valueOf(subject.getKey()))); final ListView<PropagationStatus> propRes = new ListView<PropagationStatus>("resources", propagations) { private static final long serialVersionUID = -1020475259727720708L; @Override protected void populateItem(final ListItem<PropagationStatus> item) { final PropagationStatus propTO = (PropagationStatus) item.getDefaultModelObject(); final ListView attributes = getConnObjectView(propTO); final Fragment attrhead; if (attributes.getModelObject() == null || attributes.getModelObject().isEmpty()) { attrhead = new Fragment("attrhead", "emptyAttrHeadFrag", page); } else { attrhead = new Fragment("attrhead", "attrHeadFrag", page); } item.add(attrhead); item.add(attributes); attrhead.add(new Label("resource", propTO.getResource())); attrhead.add(new Label("propagation", propTO.getStatus() == null ? "UNDEFINED" : propTO.getStatus().toString())); final Image image; final String alt, title; final ModalWindow failureWindow = new ModalWindow("failureWindow"); final AjaxLink<?> failureWindowLink = new AjaxLink<Void>("showFailureWindow") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(AjaxRequestTarget target) { failureWindow.show(target); } }; switch (propTO.getStatus()) { case SUCCESS: case SUBMITTED: case CREATED: image = new Image("icon", new ContextRelativeResource( IMG_PREFIX + Status.ACTIVE.toString() + Constants.PNG_EXT)); alt = "success icon"; title = "success"; failureWindow.setVisible(false); failureWindowLink.setEnabled(false); break; default: image = new Image("icon", new ContextRelativeResource( IMG_PREFIX + Status.SUSPENDED.toString() + Constants.PNG_EXT)); alt = "failure icon"; title = "failure"; } image.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("alt", alt); tag.put("title", title); } }); final FailureMessageModalPage executionFailureMessagePage; if (propTO.getFailureReason() == null) { executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(), StringUtils.EMPTY); } else { executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(), propTO.getFailureReason()); } failureWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return executionFailureMessagePage; } }); failureWindow.setCookieName("failureWindow"); failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); failureWindowLink.add(image); attrhead.add(failureWindowLink); attrhead.add(failureWindow); } }; fragment.add(propRes); } final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { builder.window.close(target); } }; container.add(close); setOutputMarkupId(true); }
From source file:org.apache.syncope.client.console.panels.GroupDetailsPanel.java
License:Apache License
public GroupDetailsPanel(final String id, final GroupTO groupTO, final boolean templateMode) { super(id);//ww w.j av a2 s. co m ownerContainer = new WebMarkupContainer("ownerContainer"); ownerContainer.setOutputMarkupId(true); this.add(ownerContainer); final ModalWindow userOwnerSelectWin = new ModalWindow("userOwnerSelectWin"); userOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); userOwnerSelectWin.setCookieName("create-userOwnerSelect-modal"); this.add(userOwnerSelectWin); final ModalWindow groupOwnerSelectWin = new ModalWindow("groupOwnerSelectWin"); groupOwnerSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); groupOwnerSelectWin.setCookieName("create-groupOwnerSelect-modal"); this.add(groupOwnerSelectWin); final ModalWindow parentSelectWin = new ModalWindow("parentSelectWin"); parentSelectWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); parentSelectWin.setCookieName("create-parentSelect-modal"); this.add(parentSelectWin); if (templateMode) { parentFragment = new Fragment("parent", "parentFragment", this); parentModel = new ParentModel(groupTO); @SuppressWarnings("unchecked") final AjaxTextFieldPanel parent = new AjaxTextFieldPanel("parent", "parent", parentModel); parent.setReadOnly(true); parent.setOutputMarkupId(true); parentFragment.add(parent); final AjaxLink<Void> parentSelect = new IndicatingAjaxLink<Void>("parentSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new GroupSelectModalPage(getPage().getPageReference(), parentSelectWin, ParentSelectPayload.class); } }); parentSelectWin.show(target); } }; parentFragment.add(parentSelect); final IndicatingAjaxLink<Void> parentReset = new IndicatingAjaxLink<Void>("parentReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentModel.setObject(null); target.add(parent); } }; parentFragment.add(parentReset); } else { parentFragment = new Fragment("parent", "emptyFragment", this); } parentFragment.setOutputMarkupId(true); this.add(parentFragment); final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", "name", new PropertyModel<String>(groupTO, "key")); final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); this.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (!templateMode) { name.addRequiredLabel(); questionMarkJexlHelp.setVisible(false); } this.add(name); userOwnerModel = new OwnerModel(groupTO, AttributableType.USER); @SuppressWarnings("unchecked") final AjaxTextFieldPanel userOwner = new AjaxTextFieldPanel("userOwner", "userOwner", userOwnerModel); userOwner.setReadOnly(true); userOwner.setOutputMarkupId(true); ownerContainer.add(userOwner); final AjaxLink<Void> userOwnerSelect = new IndicatingAjaxLink<Void>("userOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new UserOwnerSelectModalPage(getPage().getPageReference(), userOwnerSelectWin); } }); userOwnerSelectWin.show(target); } }; ownerContainer.add(userOwnerSelect); final IndicatingAjaxLink<Void> userOwnerReset = new IndicatingAjaxLink<Void>("userOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { userOwnerModel.setObject(null); target.add(userOwner); } }; ownerContainer.add(userOwnerReset); groupOwnerModel = new OwnerModel(groupTO, AttributableType.GROUP); @SuppressWarnings("unchecked") final AjaxTextFieldPanel groupOwner = new AjaxTextFieldPanel("groupOwner", "groupOwner", groupOwnerModel); groupOwner.setReadOnly(true); groupOwner.setOutputMarkupId(true); ownerContainer.add(groupOwner); final AjaxLink<Void> groupOwnerSelect = new IndicatingAjaxLink<Void>("groupOwnerSelect") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { parentSelectWin.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return new GroupSelectModalPage(getPage().getPageReference(), parentSelectWin, GroupOwnerSelectPayload.class); } }); parentSelectWin.show(target); } }; ownerContainer.add(groupOwnerSelect); final IndicatingAjaxLink<Void> groupOwnerReset = new IndicatingAjaxLink<Void>("groupOwnerReset") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { groupOwnerModel.setObject(null); target.add(groupOwner); } }; ownerContainer.add(groupOwnerReset); final AjaxCheckBoxPanel inhOwner = new AjaxCheckBoxPanel("inheritOwner", "inheritOwner", new PropertyModel<Boolean>(groupTO, "inheritOwner")); this.add(inhOwner); final AjaxCheckBoxPanel inhTemplates = new AjaxCheckBoxPanel("inheritTemplates", "inheritTemplates", new PropertyModel<Boolean>(groupTO, "inheritTemplates")); inhTemplates.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(Type.gPlainAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(Type.gDerAttrTemplates, target)); send(getPage(), Broadcast.BREADTH, new GroupAttrTemplatesChange(Type.gVirAttrTemplates, target)); } }); this.add(inhTemplates); }
From source file:org.apache.syncope.client.console.panels.PlainAttrsPanel.java
License:Apache License
public <T extends AbstractAttributableTO> PlainAttrsPanel(final String id, final T entityTO, final Form<?> form, final Mode mode, final AttrTemplatesPanel attrTemplates) { super(id);//from ww w. j a va2 s. co m this.entityTO = entityTO; this.mode = mode; this.attrTemplates = attrTemplates; this.setOutputMarkupId(true); setSchemas(); setAttrs(); add(new AltListView<AttrTO>("schemas", new PropertyModel<List<? extends AttrTO>>(entityTO, "attrs")) { private static final long serialVersionUID = 9101744072914090143L; @Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void populateItem(final ListItem<AttrTO> item) { final AttrTO attributeTO = (AttrTO) item.getDefaultModelObject(); final WebMarkupContainer jexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> questionMarkJexlHelp = JexlHelpUtils.getAjaxLink(jexlHelp, "questionMarkJexlHelp"); item.add(questionMarkJexlHelp); questionMarkJexlHelp.add(jexlHelp); if (mode != Mode.TEMPLATE) { questionMarkJexlHelp.setVisible(false); } item.add(new Label("name", attributeTO.getSchema())); final FieldPanel panel = getFieldPanel(schemas.get(attributeTO.getSchema()), form, attributeTO); if (mode == Mode.TEMPLATE || !schemas.get(attributeTO.getSchema()).isMultivalue()) { item.add(panel); } else { item.add(new MultiFieldPanel<String>("panel", new PropertyModel<List<String>>(attributeTO, "values"), panel)); } } }); }