@Override
    public void execute(Event<UIWikiPermalinkForm> event) throws Exception {
      UIWikiPermalinkForm uiWikiPermalinkForm = event.getSource();
      if (uiWikiPermalinkForm.canPublicAndRetrictPage()) {
        Page currentPage = Utils.getCurrentWikiPage();
        HashMap<String, String[]> permissions = currentPage.getPermission();
        permissions.remove(IdentityConstants.ANY);
        currentPage.setPermission(permissions);

        UIWikiPortlet uiWikiPortlet = uiWikiPermalinkForm.getAncestorOfType(UIWikiPortlet.class);
        if (currentPage.hasPermission(PermissionType.VIEWPAGE)) {
          UIWikiPageInfoArea uiWikiPageInfoArea =
              uiWikiPortlet.findFirstComponentOfType(UIWikiPageInfoArea.class);
          UIWikiPageControlArea uiWikiPageControlArea =
              uiWikiPortlet.findFirstComponentOfType(UIWikiPageControlArea.class);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiWikiPermalinkForm);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiWikiPageInfoArea);
          event.getRequestContext().addUIComponentToUpdateByAjax(uiWikiPageControlArea);
        } else {
          uiWikiPortlet.changeMode(WikiMode.PAGE_NOT_FOUND);
          event
              .getRequestContext()
              .getJavascriptManager()
              .addCustomizedOnLoadScript("eXo.wiki.UIWikiPageNotFound.hidePopup();");
          Utils.ajaxRedirect(
              event, Utils.getCurrentWikiPageParams(), WikiMode.PAGE_NOT_FOUND, null);
        }
      }
    }
 public void execute(Event<UIPortal> event) throws Exception {
   UIPortal uiPortal = event.getSource();
   String portletId = event.getRequestContext().getRequestParameter("portletId");
   UIPortlet uiPortlet = uiPortal.findComponentById(portletId);
   WebuiRequestContext context = event.getRequestContext();
   uiPortlet.createEvent("ChangeWindowState", event.getExecutionPhase(), context).broadcast();
 }
    public void execute(Event<UIUserActivitiesDisplay> event) throws Exception {
      UIUserActivitiesDisplay uiUserActivities = event.getSource();
      uiUserActivities.init();
      event.getRequestContext().addUIComponentToUpdateByAjax(uiUserActivities);

      Utils.resizeHomePage();
    }
 public void execute(Event<UIModeratorManagementForm> event) throws Exception {
   UIModeratorManagementForm uiForm = event.getSource();
   uiForm.isEdit = false;
   UIPopupWindow popupWindow = uiForm.getAncestorOfType(UIPopupWindow.class);
   popupWindow.setWindowSize(760, 350);
   event.getRequestContext().addUIComponentToUpdateByAjax(popupWindow.getParent());
 }
Exemple #5
0
 public void execute(Event<UIVoteQuestion> event) throws Exception {
   UIVoteQuestion voteQuestion = event.getSource();
   double markVote = Double.parseDouble(event.getRequestContext().getRequestParameter(OBJECTID));
   FAQService faqService_ =
       (FAQService) PortalContainer.getInstance().getComponentInstanceOfType(FAQService.class);
   Answer answer = null;
   if (voteQuestion.language_ != null
       && voteQuestion.language_.trim().length() > 0
       && !voteQuestion.language_.equals(voteQuestion.question_.getLanguage())) {
     answer =
         faqService_.getAnswerById(
             voteQuestion.question_.getPath(), voteQuestion.answerId_, voteQuestion.language_);
     answer.setMarksVoteAnswer(markVote);
     faqService_.saveAnswer(voteQuestion.question_.getPath(), answer, voteQuestion.language_);
   } else {
     answer =
         faqService_.getAnswerById(voteQuestion.question_.getPath(), voteQuestion.answerId_);
     answer.setMarksVoteAnswer(markVote);
     faqService_.saveAnswer(voteQuestion.question_.getPath(), answer, false);
   }
   UIAnswersPortlet portlet = voteQuestion.getAncestorOfType(UIAnswersPortlet.class);
   UIPopupAction popupAction = portlet.getChild(UIPopupAction.class);
   UIQuestions questions =
       portlet.getChild(UIAnswersContainer.class).getChild(UIQuestions.class);
   // questions.setIsNotChangeLanguage() ;
   event.getRequestContext().addUIComponentToUpdateByAjax(questions);
   popupAction.deActivate();
   event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
 }
Exemple #6
0
 public void processEvent(Event<UIAddAttachment> event) throws Exception {
   UIAddAttachment component = event.getSource();
   event
       .getRequestContext()
       .setAttribute(SELECTEDFILE, component.getFileURL(getSelectedFile(event)));
   event.getRequestContext().setAttribute(ISATTACHFILE, false);
 }
Exemple #7
0
 @Override
 public void execute(Event<UISpaceInfo> event) throws Exception {
   UISpaceInfo uiSpaceInfo = event.getSource();
   PopupContainer popupContainer = uiSpaceInfo.getChild(PopupContainer.class);
   popupContainer.activate(UIAvatarUploader.class, 500, POPUP_AVATAR_UPLOADER);
   event.getRequestContext().addUIComponentToUpdateByAjax(popupContainer);
 }
Exemple #8
0
 public void execute(Event<UIVoteQuestion> event) throws Exception {
   UIVoteQuestion voteQuestion = event.getSource();
   UIAnswersPortlet portlet = voteQuestion.getAncestorOfType(UIAnswersPortlet.class);
   UIPopupAction popupAction = portlet.getChild(UIPopupAction.class);
   popupAction.deActivate();
   event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
 }
    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>();
      for (ApplicationCategory category : categories) {
        if (selector.getSelectedCategories().contains("category_" + category.getName())) {
          Application newApp = cloneApplication(selector.getApplication());
          UIApplicationRegistryPortlet.setPermissionToAdminGroup(newApp);
          appRegService.save(category, newApp);
        }
      }
      selector.clearSelectedCategories();

      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<UICategorySelector> event) throws Exception {
   UICategorySelector selector = event.getSource();
   selector.clearSelectedCategories();
   UIContainer appInfo = selector.getParent();
   appInfo.getChild(UICategorySelector.class).setRendered(false);
   event.getRequestContext().addUIComponentToUpdateByAjax(appInfo);
 }
Exemple #11
0
    public void execute(Event<UIVoteQuestion> event) throws Exception {
      UIVoteQuestion voteQuestion = event.getSource();
      int number = Integer.parseInt(event.getRequestContext().getRequestParameter(OBJECTID));
      String currentUser = FAQUtils.getCurrentUser();
      List<String> listUsers = new ArrayList<String>();

      if (voteQuestion.question_.getUsersVote() != null) {
        listUsers.addAll(Arrays.asList(voteQuestion.question_.getUsersVote()));
      }
      long totalVote = listUsers.size();
      double markVote =
          (voteQuestion.question_.getMarkVote() * totalVote + number) / (totalVote + 1);

      listUsers.add(currentUser + "/" + number);
      voteQuestion.question_.setMarkVote(markVote);
      voteQuestion.question_.setUsersVote(listUsers.toArray(new String[] {}));
      FAQService faqService_ =
          (FAQService) PortalContainer.getInstance().getComponentInstanceOfType(FAQService.class);
      FAQUtils.getEmailSetting(voteQuestion.faqSetting_, false, false);
      faqService_.saveQuestion(voteQuestion.question_, false, voteQuestion.faqSetting_);
      UIAnswersPortlet portlet = voteQuestion.getAncestorOfType(UIAnswersPortlet.class);
      UIPopupAction popupAction = portlet.getChild(UIPopupAction.class);
      UIQuestions questions =
          portlet.getChild(UIAnswersContainer.class).getChild(UIQuestions.class);
      // questions.setIsNotChangeLanguage() ;
      event.getRequestContext().addUIComponentToUpdateByAjax(questions);
      popupAction.deActivate();
      event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
    }
 public void execute(Event<UISelectUserForm> event) throws Exception {
   UISelectUserForm uiAddressForm = event.getSource();
   UIPopupContainer uiContainer = uiAddressForm.getAncestorOfType(UIPopupContainer.class);
   UIPopupAction chilPopup = uiContainer.getChild(UIPopupAction.class);
   chilPopup.deActivate();
   event.getRequestContext().addUIComponentToUpdateByAjax(chilPopup);
 }
    @Override
    public void execute(Event<UITabContainer> event) throws Exception {
      UITabContainer container = event.getSource();
      PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
      if (container == null) {
        return;
      }

      List<UIComponent> children = container.getChildren();
      for (UIComponent child : children) {
        if (child.isRendered() && child instanceof UIContainer) {
          UIContainer newTabContainer = container.addChild(UIContainer.class, null, null);
          newTabContainer.setTemplate(child.getTemplate());
          child.setRendered(false);
          newTabContainer.setRendered(true);
          newTabContainer.setId(String.valueOf(newTabContainer.hashCode()));
          pcontext.addUIComponentToUpdateByAjax(container);
          pcontext
              .getJavascriptManager()
              .require("SHARED/portal", "portal")
              .addScripts("portal.PortalComposer.toggleSaveButton();");
          return;
        }
      }
    }
 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<UIFilterableTree> event) throws Exception {
   UISocialGroupSelector uiGroupSelector =
       event.getSource().getAncestorOfType(UISocialGroupSelector.class);
   String groupId = event.getRequestContext().getRequestParameter(OBJECTID);
   uiGroupSelector.changeGroup(groupId);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiGroupSelector);
 }
    public void execute(Event<UIPortlet> event) throws Exception {
      UIPortlet uiPortlet = event.getSource();

      String portletMode = null;

      Object changePortletModeAttribute =
          event.getRequestContext().getAttribute(CHANGE_PORTLET_MODE_EVENT);
      if (changePortletModeAttribute != null && changePortletModeAttribute instanceof String) {
        portletMode = (String) changePortletModeAttribute;
      }

      if (portletMode == null) {
        portletMode = event.getRequestContext().getRequestParameter(Constants.PORTAL_PORTLET_MODE);
      }
      if (portletMode == null) {
        portletMode = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
      }
      if (portletMode == null) {
        portletMode = uiPortlet.getCurrentPortletMode().toString();
      }

      log.trace(
          "Change portlet mode of " + uiPortlet.getPortletContext().getId() + " to " + portletMode);
      if (portletMode.equals(PortletMode.HELP.toString())) {
        uiPortlet.setCurrentPortletMode(PortletMode.HELP);
      } else if (portletMode.equals(PortletMode.EDIT.toString())) {
        uiPortlet.setCurrentPortletMode(PortletMode.EDIT);
      } else if (portletMode.equals(PortletMode.VIEW.toString())) {
        uiPortlet.setCurrentPortletMode(PortletMode.VIEW);
      } else {
        PortletMode customMode = new PortletMode(portletMode);
        uiPortlet.setCurrentPortletMode(customMode);
      }
      event.getRequestContext().addUIComponentToUpdateByAjax(uiPortlet);
    }
Exemple #17
0
 public void execute(Event<UIGroupMemberSelector> event) throws Exception {
   UIGroupMemberSelector uiGroupMemberSelector = event.getSource();
   if (uiGroupMemberSelector.getCurrentGroup() == null) return;
   String groupId = uiGroupMemberSelector.getCurrentGroup().getId();
   String permission = event.getRequestContext().getRequestParameter(OBJECTID);
   String value = "";
   if (uiGroupMemberSelector.isSelectedUser()) {
     value = permission;
   } else {
     value = permission + ":" + groupId;
   }
   String returnField = uiGroupMemberSelector.getReturnField();
   ((UISelectable) uiGroupMemberSelector.getSourceComponent()).doSelect(returnField, value);
   if (uiGroupMemberSelector.isUsePopup) {
     UIPopupWindow uiPopup = uiGroupMemberSelector.getParent();
     uiPopup.setShow(false);
     UIComponent uicomp = uiGroupMemberSelector.getSourceComponent().getParent();
     event.getRequestContext().addUIComponentToUpdateByAjax(uicomp);
     if (!uiPopup.getId().equals("PopupComponent"))
       event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup);
   } else {
     event
         .getRequestContext()
         .addUIComponentToUpdateByAjax(uiGroupMemberSelector.getSourceComponent());
   }
 }
    public void execute(Event<UIMembersPortlet> event) throws Exception {
      UIMembersPortlet uiAllPeople = event.getSource();
      String userId = event.getRequestContext().getRequestParameter(OBJECTID);
      Identity inviIdentityIdentity = Utils.getIdentityManager().getIdentity(userId, true);
      Identity invitingIdentity = Utils.getViewerIdentity();

      Relationship relationship =
          Utils.getRelationshipManager().get(invitingIdentity, inviIdentityIdentity);

      uiAllPeople.setLoadAtEnd(false);
      if (relationship != null && relationship.getStatus() == Relationship.Type.CONFIRMED) {
        Utils.getRelationshipManager().delete(relationship);
        return;
      }

      if (relationship == null) {
        UIApplication uiApplication = event.getRequestContext().getUIApplication();
        uiApplication.addMessage(
            new ApplicationMessage(INVITATION_REVOKED_INFO, null, ApplicationMessage.INFO));
        return;
      }

      Utils.clearCacheOnUserPopup();
      Utils.getRelationshipManager().deny(inviIdentityIdentity, invitingIdentity);
    }
 public void loadView(Event<? extends UIComponent> event) throws Exception {
   UISpaceNavigationNodeSelector uiNodeSelector = getChild(UISpaceNavigationNodeSelector.class);
   UITree uiTree = uiNodeSelector.getChild(UITree.class);
   uiTree
       .createEvent("ChangeNode", event.getExecutionPhase(), event.getRequestContext())
       .broadcast();
 }
 public void execute(Event<UIWikiAdvanceSearchForm> event) throws Exception {
   UIWikiAdvanceSearchForm uiSearch = event.getSource();
   uiSearch.processSearchAction();
   event
       .getRequestContext()
       .addUIComponentToUpdateByAjax(uiSearch.getAncestorOfType(UIWikiSearchSpaceArea.class));
 }
Exemple #21
0
    public void execute(Event<UIWCMCacheManagerForm> event) throws Exception {
      UIWCMCacheManagerForm uiCacheForm = event.getSource();
      UIWCMCacheManagerPanel uiCachePanel =
          uiCacheForm.getAncestorOfType(UIWCMCacheManagerPanel.class);
      // droplist option choice
      // String cacheOpt = uiCacheForm.getUIFormSelectBox(FIELD_MODIFY).getValue();

      // get current cache
      // cache = WCMCoreUtils.getService(CacheService.class).getCacheInstance(cacheOpt);

      // check whether its allowed to change
      Boolean isChecked = uiCacheForm.getUIFormCheckBoxInput(CHECKBOX_ENABLE_CACHE).isChecked();
      if (isChecked) {
        String livetime = uiCacheForm.getUIStringInput(FIELD_LIVE_TIME).getValue();
        String maxsize = uiCacheForm.getUIStringInput(FIELD_MAX_SIZE).getValue();
        // update changes
        uiCacheForm.cache.setLiveTime(Long.parseLong(livetime));
        uiCacheForm.cache.setMaxSize(Integer.parseInt(maxsize));
        // update cache info
        uiCacheForm.update(cache);
      } else {
        throw new Exception("cache enable is not set");
      }

      event.getRequestContext().addUIComponentToUpdateByAjax(uiCachePanel);
    }
    @Override
    public void execute(Event<UIMeetingDetail> event) throws Exception {
      UIMeetingDetail detail = event.getSource();
      UIApplication uiApp = event.getRequestContext().getUIApplication();
      if (detail.selectedOptions.isEmpty()) {
        uiApp.addMessage(
            new ApplicationMessage(
                "You need to select at least one option",
                new Object[0],
                AbstractApplicationMessage.ERROR));
        return;
      }

      Identity identity = ConversationState.getCurrent().getIdentity();
      if (!identity.getUserId().equals(detail.getMeeting().getOwner())) {
        uiApp.addMessage(
            new ApplicationMessage(
                "Only owner can make plan for this meeting",
                new Object[0],
                AbstractApplicationMessage.ERROR));
        return;
      }

      MeetingService service = detail.getApplicationComponent(MeetingService.class);
      Meeting m =
          service.finalMeeting(detail.meeting, new ArrayList<String>(detail.selectedOptions));
      detail.setMeeting(m);
    }
    @Override
    public void execute(Event<UISpaceSearch> event) throws Exception {
      WebuiRequestContext ctx = event.getRequestContext();
      UISpaceSearch uiSpaceSearch = event.getSource();
      String charSearch = ctx.getRequestParameter(OBJECTID);
      ResourceBundle resApp = ctx.getApplicationResourceBundle();
      String defaultSpaceNameAndDesc =
          resApp.getString(uiSpaceSearch.getId() + ".label.DefaultSpaceNameAndDesc");
      String searchCondition =
          (((UIFormStringInput) uiSpaceSearch.getChildById(SPACE_SEARCH)).getValue());
      if ((searchCondition == null || searchCondition.equals(defaultSpaceNameAndDesc))
          && charSearch == null) {
        uiSpaceSearch.setSelectedChar(null);
        uiSpaceSearch.setSpaceNameSearch(null);
        ctx.addUIComponentToUpdateByAjax(uiSpaceSearch);
      } else {
        if (searchCondition != null) {
          searchCondition = searchCondition.trim();
        }
        if (charSearch != null) {
          ((UIFormStringInput) uiSpaceSearch.getChildById(SPACE_SEARCH))
              .setValue(defaultSpaceNameAndDesc);
        }
        uiSpaceSearch.setSelectedChar(charSearch);
        uiSpaceSearch.setSpaceNameSearch(searchCondition);
        uiSpaceSearch.setNewSearch(true);

        Event<UIComponent> searchEvent =
            uiSpaceSearch.<UIComponent>getParent().createEvent(SEARCH, Event.Phase.DECODE, ctx);
        if (searchEvent != null) {
          searchEvent.broadcast();
        }
      }
    }
    public void execute(Event<UIUserSelector> event) throws Exception {
      UIUserSelector uiSelectUserForm = event.getSource();
      uiSelectUserForm.setSelectedItem();

      int page = Integer.parseInt(event.getRequestContext().getRequestParameter(OBJECTID));
      uiSelectUserForm.updateCurrentPage(page);
      event.getRequestContext().addUIComponentToUpdateByAjax(uiSelectUserForm);
    }
 public void execute(Event<UICategorySelector> event) throws Exception {
   UICategorySelector selector = event.getSource();
   int page = Integer.parseInt(event.getRequestContext().getRequestParameter(OBJECTID));
   UIFormTableIteratorInputSet inputSet = selector.getChild(UIFormTableIteratorInputSet.class);
   inputSet.getUIFormPageIterator().setCurrentPage(page);
   selector.init();
   event.getRequestContext().addUIComponentToUpdateByAjax(selector);
 }
 @Override
 public void execute(Event<UIMeetingDetail> event) throws Exception {
   UIMeetingDetail detail = event.getSource();
   UIMeetingSchedulePortlet portlet = detail.getAncestorOfType(UIMeetingSchedulePortlet.class);
   detail.setRendered(false);
   portlet.getChild(UIListMeetingSchedule.class).setRendered(true);
   event.getRequestContext().addUIComponentToUpdateByAjax(portlet);
 }
 @Override
 public void execute(Event<UISpaceNavigationManagement> event) throws Exception {
   UISpaceNavigationManagement uiManagement = event.getSource();
   UISpaceNavigationNodeSelector uiNodeSelector =
       uiManagement.getChild(UISpaceNavigationNodeSelector.class);
   UIRightClickPopupMenu menu = uiNodeSelector.getChild(UIRightClickPopupMenu.class);
   menu.createEvent("AddNode", Phase.PROCESS, event.getRequestContext()).broadcast();
 }
 public void execute(Event<UIForgetPassword> event) throws Exception {
   UILogin uilogin = event.getSource().getParent();
   uilogin.getChild(UILoginForm.class).setRendered(false);
   uilogin.getChild(UIForgetPasswordWizard.class).setRendered(true);
   uilogin.getChild(UIForgetPassword.class).setRendered(false);
   event.getSource().reset();
   event.getRequestContext().addUIComponentToUpdateByAjax(uilogin);
 }
 public void execute(Event<UIInvitations> event) throws Exception {
   UIInvitations uiInvitations = event.getSource();
   if (uiInvitations.currentLoadIndex < uiInvitations.peopleNum) {
     uiInvitations.increaseOffset();
   } else {
     uiInvitations.setEnableLoadNext(false);
   }
   event.getRequestContext().addUIComponentToUpdateByAjax(uiInvitations);
 }
 public void execute(Event<UICategorySelector> event) throws Exception {
   UICategorySelector selector = event.getSource();
   UICheckBoxInput chkInput;
   for (String category : selector.getSelectedCategories()) {
     chkInput = selector.getUIInput(category);
     chkInput.setChecked(true);
   }
   event.getRequestContext().addUIComponentToUpdateByAjax(selector);
 }