protected void addMethod(UserRequest ureq, AccessMethod method) { Offer offer = acService.createOffer(resource, displayName); OfferAccess link = acService.createOfferAccess(offer, method); removeAsListenerAndDispose(newMethodCtrl); AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType()); if (handler != null) { newMethodCtrl = handler.createConfigurationController(ureq, getWindowControl(), link); } if (newMethodCtrl != null) { listenTo(newMethodCtrl); String title = handler.getMethodName(getLocale()); cmc = new CloseableModalController( getWindowControl(), translate("close"), newMethodCtrl.getInitialComponent(), true, title); cmc.activate(); listenTo(cmc); } else { OfferAccess newLink = acService.saveOfferAccess(link); addConfiguration(newLink); } }
protected void addConfiguration(OfferAccess link) { AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType()); AccessInfo infos = new AccessInfo(handler.getMethodName(getLocale()), handler.isPaymentMethod(), null, link); confControllers.add(infos); if (editable) { FormLink editLink = uifactory.addFormLink( "edit_" + link.getKey(), "edit", "edit", null, confControllerContainer, Link.BUTTON_SMALL); editLink.setUserObject(infos); editLink.setIconLeftCSS("o_icon o_icon-fw o_icon_edit"); confControllerContainer.add(editLink.getName(), editLink); FormLink delLink = uifactory.addFormLink( "del_" + link.getKey(), "delete", "delete", null, confControllerContainer, Link.BUTTON_SMALL); delLink.setUserObject(infos); delLink.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item"); confControllerContainer.add(delLink.getName(), delLink); } }
@Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { if (editable) { List<AccessMethod> methods = acService.getAvailableMethods(getIdentity(), ureq.getUserSession().getRoles()); for (AccessMethod method : methods) { AccessMethodHandler handler = acModule.getAccessMethodHandler(method.getType()); if (handler.isPaymentMethod() && !allowPaymentMethod) { continue; } String title = handler.getMethodName(getLocale()); FormLink add = uifactory.addFormLink( "create." + handler.getType(), title, null, formLayout, Link.LINK | Link.NONTRANSLATED); add.setUserObject(method); add.setIconLeftCSS(("o_icon " + method.getMethodCssClass() + "_icon o_icon-lg").intern()); addMethods.add(add); formLayout.add(add.getName(), add); } ((FormLayoutContainer) formLayout).contextPut("methods", addMethods); } String confPage = velocity_root + "/configuration_list.html"; confControllerContainer = FormLayoutContainer.createCustomFormLayout("conf-controllers", getTranslator(), confPage); confControllerContainer.setRootForm(mainForm); formLayout.add(confControllerContainer); loadConfigurations(); confControllerContainer.contextPut("confControllers", confControllers); if (!embbed) { setFormTitle("accesscontrol.title"); setFormContextHelp( AccessConfigurationController.class.getPackage().getName(), "accesscontrol.html", "chelp.accesscontrol.hover"); if (editable) { final FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator()); buttonGroupLayout.setRootForm(mainForm); formLayout.add(buttonGroupLayout); formLayout.add("buttonLayout", buttonGroupLayout); uifactory.addFormSubmitButton("save", buttonGroupLayout); } } confControllerContainer.contextPut( "emptyConfigGrantsFullAccess", Boolean.valueOf(emptyConfigGrantsFullAccess)); }
private void editMethod(UserRequest ureq, AccessInfo infos) { OfferAccess link = infos.getLink(); removeAsListenerAndDispose(editMethodCtrl); AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType()); if (handler != null) { editMethodCtrl = handler.editConfigurationController(ureq, getWindowControl(), link); } if (editMethodCtrl != null) { listenTo(editMethodCtrl); String title = handler.getMethodName(getLocale()); cmc = new CloseableModalController( getWindowControl(), translate("close"), editMethodCtrl.getInitialComponent(), true, title); cmc.activate(); listenTo(cmc); } }