Example #1
0
 public void execute(Event<UIAddAttachment> event) throws Exception {
   UIAddAttachment component = event.getSource();
   EventUIComponent eventUIComponent = component.getTargetAttachEvent();
   UIPortletApplication portlet = component.getAncestorOfType(UIPortletApplication.class);
   UIComponent targerComponent = portlet.findComponentById(eventUIComponent.getId());
   Event<UIComponent> xEvent =
       targerComponent.createEvent(
           eventUIComponent.getEventName(), Event.Phase.PROCESS, event.getRequestContext());
   if (!StringUtils.isEmpty(getSelectedFile(event))) {
     processEvent(event);
   } else {
     event
         .getRequestContext()
         .getUIApplication()
         .addMessage(
             new ApplicationMessage(
                 "UIAddAttachment.msg.not-a-file", null, ApplicationMessage.WARNING));
     ((PortalRequestContext) event.getRequestContext().getParentAppRequestContext())
         .ignoreAJAXUpdateOnPortlets(true);
     return;
   }
   if (xEvent != null) {
     xEvent.broadcast();
   }
   UIPopupWindow uiPopupWindow = event.getSource().getParent();
   uiPopupWindow.setRendered(false);
   uiPopupWindow.setUIComponent(null);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupWindow.getParent());
 }
 public void initPopup(UIComponent uiComponent, String popupId) throws Exception {
   removeChildById(popupId);
   UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, popupId);
   uiPopup.setShowMask(true);
   uiPopup.setWindowSize(600, 300);
   uiPopup.setUIComponent(uiComponent);
   uiPopup.setShow(true);
   uiPopup.setResizable(true);
 }
Example #3
0
    @Override
    public void execute(Event<UIAvatarUploader> event) throws Exception {
      WebuiRequestContext ctx = event.getRequestContext();
      UIApplication uiApplication = ctx.getUIApplication();
      UIAvatarUploader uiAvatarUploader = event.getSource();
      UIFormUploadInput uiAvatarUploadInput = uiAvatarUploader.getChild(UIFormUploadInput.class);
      UIPopupWindow uiPopup = uiAvatarUploader.getParent();
      InputStream uploadedStream = uiAvatarUploadInput.getUploadDataAsStream();

      if (uploadedStream == null) {
        uiApplication.addMessage(
            new ApplicationMessage(MSG_IMG_NOT_UPLOADED, null, ApplicationMessage.ERROR));
        ctx.addUIComponentToUpdateByAjax(uiAvatarUploader);
        return;
      }
      UploadResource uploadResource = uiAvatarUploadInput.getUploadResource();

      String mimeType = uploadResource.getMimeType();
      String uploadId = uiAvatarUploadInput.getUploadId();
      if (!uiAvatarUploader.isAcceptedMimeType(mimeType)) {
        UploadService uploadService =
            (UploadService) PortalContainer.getComponent(UploadService.class);
        uploadService.removeUploadResource(uploadId);
        uiApplication.addMessage(
            new ApplicationMessage(MSG_MIMETYPE_NOT_ACCEPTED, null, ApplicationMessage.ERROR));
        ctx.addUIComponentToUpdateByAjax(uiAvatarUploader);
      } else {
        MimeTypeResolver mimeTypeResolver = new MimeTypeResolver();
        String fileName = uploadResource.getFileName();

        // @since 1.1.3
        String extension = mimeTypeResolver.getExtension(mimeType);
        if ("".equals(extension)) {
          mimeType = uiAvatarUploader.getStandardMimeType(mimeType);
        }

        // Resize avatar to fixed width if can't(avatarAttachment == null) keep
        // origin avatar
        AvatarAttachment avatarAttachment =
            ImageUtils.createResizedAvatarAttachment(
                uploadedStream, WIDTH, 0, null, fileName, mimeType, null);
        if (avatarAttachment == null) {
          avatarAttachment =
              new AvatarAttachment(
                  null, fileName, mimeType, uploadedStream, null, System.currentTimeMillis());
        }

        UploadService uploadService =
            (UploadService) PortalContainer.getComponent(UploadService.class);
        uploadService.removeUploadResource(uploadId);
        UIAvatarUploadContent uiAvatarUploadContent =
            uiAvatarUploader.createUIComponent(UIAvatarUploadContent.class, null, null);
        uiAvatarUploadContent.setAvatarAttachment(avatarAttachment);
        uiPopup.setUIComponent(uiAvatarUploadContent);
        ctx.addUIComponentToUpdateByAjax(uiPopup);
      }
    }
Example #4
0
 @Override
 public void execute(Event<UISpaceSearch> event) throws Exception {
   UISpaceSearch uiSpaceSearch = event.getSource();
   UIPopupWindow uiPopup = uiSpaceSearch.getChild(UIPopupWindow.class);
   UISpaceAddForm uiAddSpaceForm =
       uiSpaceSearch.createUIComponent(UISpaceAddForm.class, null, null);
   uiPopup.setUIComponent(uiAddSpaceForm);
   uiPopup.setWindowSize(500, 0);
   uiPopup.setShow(true);
 }
 public void execute(Event<UIUserSelector> event) throws Exception {
   UIUserSelector uiForm = event.getSource();
   UIPermissionManagerBase uiParent = uiForm.getAncestorOfType(UIPermissionManagerBase.class);
   UIPermissionFormBase uiPermissionForm = uiParent.getChild(UIPermissionFormBase.class);
   uiPermissionForm.doSelect(UIPermissionInputSet.FIELD_USERORGROUP, uiForm.getSelectedUsers());
   UIPopupWindow uiPopup = uiParent.getChild(UIPopupWindow.class);
   uiPopup.setUIComponent(null);
   uiPopup.setShow(false);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiParent);
 }
 public void initPopupPermission(UIComponent uiSelector) throws Exception {
   removeChildById(UIPermissionForm.POPUP_SELECT);
   UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, UIPermissionForm.POPUP_SELECT);
   uiPopup.setShowMask(true);
   uiPopup.setWindowSize(560, 300);
   uiPopup.setRendered(true);
   uiPopup.setUIComponent(uiSelector);
   uiPopup.setShow(true);
   uiPopup.setResizable(true);
 }
Example #7
0
 private void initTaggingFormPopup(Node selectedTag) throws Exception {
   removeChildById("TagPopup");
   UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, "TagPopup");
   uiPopup.setShowMask(true);
   uiPopup.setWindowSize(600, 200);
   UITagForm uiForm = createUIComponent(UITagForm.class, null, null);
   uiForm.setTag(selectedTag);
   uiPopup.setUIComponent(uiForm);
   uiPopup.setRendered(true);
   uiPopup.setShow(true);
   uiPopup.setResizable(true);
 }
 public void initUserSelector() throws Exception {
   UIPopupWindow uiPopup = getChildById("PopupUserSelector");
   if (uiPopup == null) {
     uiPopup = addChild(UIPopupWindow.class, null, "PopupUserSelector");
   }
   uiPopup.setWindowSize(790, 400);
   UIUserContainer uiUserContainer = this.createUIComponent(UIUserContainer.class, null, null);
   uiPopup.setUIComponent(uiUserContainer);
   uiPopup.setShow(true);
   uiPopup.setShowMask(true);
   uiPopup.setResizable(true);
 }
 public void execute(Event<UIUserInGroup> event) throws Exception {
   UIUserInGroup uiUserInGroup = event.getSource();
   String id = event.getRequestContext().getRequestParameter(OBJECTID);
   OrganizationService service =
       uiUserInGroup.getApplicationComponent(OrganizationService.class);
   MembershipHandler handler = service.getMembershipHandler();
   UIPopupWindow uiPopup = uiUserInGroup.getChild(UIPopupWindow.class);
   UIGroupEditMembershipForm uiEditMemberShip =
       uiUserInGroup.createUIComponent(UIGroupEditMembershipForm.class, null, null);
   uiEditMemberShip.setValue(handler.findMembership(id), uiUserInGroup.getSelectedGroup());
   uiPopup.setUIComponent(uiEditMemberShip);
   uiPopup.setShow(true);
 }
 public void initPopupPermission(UIComponent uiSelector) throws Exception {
   UIPopupWindow uiPopup = getChildById(UIPermissionFormBase.POPUP_SELECT);
   if (uiPopup == null) {
     uiPopup = addChild(UIPopupWindow.class, null, UIPermissionFormBase.POPUP_SELECT);
     uiPopup.setWindowSize(560, 345);
     uiPopup.setShowMask(true);
   } else {
     uiPopup.setShowMask(true);
     uiPopup.setRendered(true);
   }
   uiPopup.setUIComponent(uiSelector);
   uiPopup.setShow(true);
   uiPopup.setResizable(true);
 }
Example #11
0
  public UIUserSelector() throws Exception {
    addUIFormInput(new UIFormStringInput(FIELD_KEYWORD, FIELD_KEYWORD, null));
    addUIFormInput(new UIFormSelectBox(FIELD_FILTER, FIELD_FILTER, getFilters()));
    addUIFormInput(new UIFormStringInput(FIELD_GROUP, FIELD_GROUP, null));
    isShowSearch_ = true;
    OrganizationService service = getApplicationComponent(OrganizationService.class);
    ObjectPageList objPageList =
        new ObjectPageList(service.getUserHandler().findUsers(new Query()).getAll(), 10);
    uiIterator_ = new UIPageIterator();
    uiIterator_.setPageList(objPageList);
    uiIterator_.setId("UISelectUserPage");

    // create group selector
    UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, "UIPopupGroupSelector");
    uiPopup.setWindowSize(540, 0);
    UIGroupSelector uiGroup = createUIComponent(UIGroupSelector.class, null, null);
    uiPopup.setUIComponent(uiGroup);
    uiGroup.setId("GroupSelector");
    uiGroup.getChild(UITree.class).setId("TreeGroupSelector");
    uiGroup.getChild(UIBreadcumbs.class).setId("BreadcumbsGroupSelector");
  }
Example #12
0
 public void execute(Event<UIAddAttachment> event) throws Exception {
   UIPopupWindow uiPopupWindow = event.getSource().getParent();
   uiPopupWindow.setUIComponent(null);
   uiPopupWindow.setRendered(false);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupWindow.getParent());
 }