public void execute(Event<UISelectUserForm> event) throws Exception { UISelectUserForm uiForm = event.getSource(); UIPopupContainer uiContainer = uiForm.getAncestorOfType(UIPopupContainer.class); UIEventForm uiEventForm = uiContainer.findFirstComponentOfType(UIEventForm.class); if (uiEventForm != null) { StringBuilder sb = new StringBuilder(); for (Object o : uiForm.uiIterator_.getCurrentPageData()) { User u = (User) o; UIFormCheckBoxInput input = uiForm.getUIFormCheckBoxInput(u.getUserName()); if (input != null && input.isChecked()) { if (sb != null && sb.length() > 0) sb.append(CalendarUtils.COMMA); sb.append(u.getUserName()); } } if (CalendarUtils.isEmpty(sb.toString())) { event .getRequestContext() .getUIApplication() .addMessage(new ApplicationMessage("UISelectUserForm.msg.user-required", null)); return; } uiEventForm.setSelectedTab(uiForm.tabId_); event.getRequestContext().addUIComponentToUpdateByAjax(uiEventForm.getParent()); } UIPopupAction chilPopup = uiContainer.getChild(UIPopupAction.class); chilPopup.deActivate(); event.getRequestContext().addUIComponentToUpdateByAjax(chilPopup); }
public void execute(Event<UICategorySelector> event) throws Exception { UICategorySelector selector = event.getSource(); ApplicationRegistryService appRegService = selector.getApplicationComponent(ApplicationRegistryService.class); List<ApplicationCategory> categories = appRegService.getApplicationCategories(); categories = categories != null ? categories : new ArrayList<ApplicationCategory>(); UIFormCheckBoxInput<Boolean> chkInput; for (ApplicationCategory category : categories) { chkInput = selector.getUIInput("category_" + category.getName()); if (chkInput != null && chkInput.isChecked()) { Application newApp = cloneApplication(selector.getApplication()); UIApplicationRegistryPortlet.setPermissionToEveryone(newApp); appRegService.save(category, newApp); } } UIContainer appInfo = selector.getParent(); appInfo.getChild(UICategorySelector.class).setRendered(false); UIApplicationRegistryPortlet uiPortlet = appInfo.getAncestorOfType(UIApplicationRegistryPortlet.class); UIApplicationOrganizer uiOrganizer = uiPortlet.getChild(UIApplicationOrganizer.class); UIGadgetManagement uiGadgetManagement = uiPortlet.getChild(UIGadgetManagement.class); uiOrganizer.reload(); if (uiGadgetManagement != null) { uiGadgetManagement.setSelectedGadget(selector.getApplication().getApplicationName()); } event.getRequestContext().addUIComponentToUpdateByAjax(appInfo); }
public void execute(Event<UISyntaxSettingForm> event) throws Exception { UIWikiPortlet wikiPortlet = event.getSource().getAncestorOfType(UIWikiPortlet.class); UIWikiSyntaxPreferences uiSyntaxPreferences = wikiPortlet.findComponentById(PREFERENCES_SYNTAX); UIFormSelectBox defaultSyntaxSelect = uiSyntaxPreferences.getChildById(UIWikiSyntaxPreferences.FIELD_SYNTAX); UIFormCheckBoxInput<Boolean> allowCheckBox = uiSyntaxPreferences.getChildById(UIWikiSyntaxPreferences.FIELD_ALLOW); WikiPreferences preferences = Utils.getCurrentPreferences(); WikiPreferencesSyntax preferencesSyntax = preferences.getWikiPreferencesSyntax(); preferencesSyntax.setAllowMultipleSyntaxes(allowCheckBox.isChecked()); preferencesSyntax.setDefaultSyntax(defaultSyntaxSelect.getValue()); event .getRequestContext() .getUIApplication() .addMessage( new ApplicationMessage( "UISyntaxSettingForm.msg.Save-syntax-setting-success", null, ApplicationMessage.INFO)); }