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 List<ApplicationCategory> getAllCategories() {
   try {
     ApplicationRegistryService appRegService =
         getApplicationComponent(ApplicationRegistryService.class);
     List<ApplicationCategory> categories =
         appRegService.getApplicationCategories(new Util.CategoryComparator());
     categories = categories != null ? categories : new ArrayList<ApplicationCategory>();
     return categories;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
 @Override
 public void execute(Event<UICategorySelector> event) throws Exception {
   UICategorySelector selector = event.getSource();
   ApplicationRegistryService appRegService =
       selector.getApplicationComponent(ApplicationRegistryService.class);
   List<ApplicationCategory> categories = appRegService.getApplicationCategories();
   UICheckBoxInput chkInput;
   for (ApplicationCategory category : categories) {
     chkInput = selector.getUIInput("category_" + category.getName());
     if (chkInput != null && chkInput.isChecked()) {
       selector.addSelectedCategory("category_" + category.getName());
     }
   }
 }
Esempio n. 4
0
 /**
  * Gets the gadget categories.
  *
  * @return the gadget categories
  * @throws Exception the exception
  */
 private List<ApplicationCategory> getGadgetCategories() throws Exception {
   List<ApplicationCategory> gadgetCategories = new ArrayList<ApplicationCategory>();
   PortalContainer container = PortalContainer.getInstance();
   RequestLifeCycle.begin(container);
   try {
     List<ApplicationCategory> applicationCategories =
         applicationRegistryService.getApplicationCategories();
     for (ApplicationCategory applicationCategory : applicationCategories) {
       if (!applicationRegistryService
           .getApplications(applicationCategory, ApplicationType.GADGET)
           .isEmpty()) {
         gadgetCategories.add(applicationCategory);
       }
     }
   } finally {
     RequestLifeCycle.end();
   }
   return gadgetCategories;
 }
Esempio n. 5
0
  private void initApplicationCategories() throws Exception {
    ApplicationRegistryService prService =
        getApplicationComponent(ApplicationRegistryService.class);
    String remoteUser = WebuiRequestContext.getCurrentInstance().getRemoteUser();
    if (remoteUser == null || remoteUser.equals("")) return;

    List<ApplicationCategory> appCategories =
        prService.getApplicationCategories(new ApplicationCategoryComparator());

    Iterator<ApplicationCategory> cateItr = appCategories.iterator();
    while (cateItr.hasNext()) {
      ApplicationCategory cate = cateItr.next();

      if (!hasPermission(cate.getAccessPermissions()) || filterApps(cate).size() < 1) {
        cateItr.remove();
      } else {
        Collections.sort(cate.getApplications(), new ApplicationComparator());
      }
    }

    listAppCategories = appCategories;
  }