Ejemplo n.º 1
0
 /**
  * Creates the root element.
  *
  * @param currentFolder the current folder
  * @param applicationCategories the application categories
  * @param language the language
  * @return the element
  * @throws Exception the exception
  */
 private Element createRootElement(
     String currentFolder,
     List<ApplicationCategory> applicationCategories,
     String language,
     String host)
     throws Exception {
   Document document = null;
   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   DocumentBuilder builder = factory.newDocumentBuilder();
   document = builder.newDocument();
   if (applicationCategories.isEmpty()) {
     Locale locale = null;
     if (language == null) {
       locale = Locale.ENGLISH;
     } else {
       locale = new Locale(language);
     }
     ResourceBundle resourceBundle = ResourceBundle.getBundle(FCK_RESOURCE_BUNDLE_FILE, locale);
     String message = "";
     try {
       message = resourceBundle.getString("fckeditor.no-gadget");
     } catch (MissingResourceException e) {
       message = "fckeditor.no-gadget";
     }
     Element rootElement = document.createElement("Message");
     document.appendChild(rootElement);
     rootElement.setAttribute("number", "555");
     rootElement.setAttribute("text", message);
     rootElement.setAttribute("type", "Error");
     return rootElement;
   }
   Element rootElement = document.createElement("Connector");
   document.appendChild(rootElement);
   rootElement.setAttribute("resourceType", "Gadget");
   Element currentFolderElement = document.createElement("CurrentFolder");
   if (currentFolder == null || currentFolder.equals("/")) {
     currentFolderElement.setAttribute("name", applicationCategories.get(0).getName());
     Element foldersElement = createFolderElement(document, applicationCategories);
     rootElement.appendChild(foldersElement);
   } else {
     PortalContainer container = PortalContainer.getInstance();
     RequestLifeCycle.begin(container);
     try {
       ApplicationCategory applicationCategory =
           applicationRegistryService.getApplicationCategory(
               currentFolder.substring(1, currentFolder.length() - 1));
       currentFolderElement.setAttribute("name", applicationCategory.getDisplayName());
       Element filesElement = createFileElement(document, applicationCategory, host);
       rootElement.appendChild(filesElement);
     } finally {
       RequestLifeCycle.end();
     }
   }
   rootElement.appendChild(currentFolderElement);
   return rootElement;
 }
Ejemplo n.º 2
0
 /**
  * Creates the folder element.
  *
  * @param document the document
  * @param applicationCategories the application categories
  * @return the element
  * @throws Exception the exception
  */
 private Element createFolderElement(
     Document document, List<ApplicationCategory> applicationCategories) throws Exception {
   Element folders = document.createElement("Folders");
   for (ApplicationCategory applicationCategory : applicationCategories) {
     Element folder = document.createElement("Folder");
     folder.setAttribute("name", applicationCategory.getDisplayName());
     folders.appendChild(folder);
   }
   return folders;
 }
Ejemplo n.º 3
0
  public void init() throws Exception {
    UIFormTableIteratorInputSet uiTableInputSet =
        createUIComponent(UIFormTableIteratorInputSet.class, null, null);
    uiTableInputSet.setName(getClass().getSimpleName());
    uiTableInputSet.setId(getClass().getSimpleName());
    uiTableInputSet.setColumns(TABLE_COLUMNS);
    addChild(uiTableInputSet);

    UIFormInputSet uiInputSet;
    UICheckBoxInput checkBoxInput;
    UIFormInputInfo uiInfo;

    HTMLEntityEncoder encoder = HTMLEntityEncoder.getInstance();

    //
    ApplicationRegistryService appRegService =
        getApplicationComponent(ApplicationRegistryService.class);
    List<ApplicationCategory> categories = getAllCategories();
    List<UIFormInputSet> uiInputSetList = new ArrayList<UIFormInputSet>();
    for (ApplicationCategory category : categories) {
      uiInputSet = new UIFormInputSet(category.getName());
      boolean defaultValue = false;
      if (application != null) {
        String definitionName = application.getDisplayName().replace(' ', '_');
        defaultValue = appRegService.getApplication(category.getName(), definitionName) != null;
      }
      checkBoxInput = new UICheckBoxInput("category_" + category.getName(), null, defaultValue);
      checkBoxInput.setOnChange("SelectBox");
      uiInfo =
          new UIFormInputInfo("categoryName", null, encoder.encode(category.getDisplayName(true)));
      uiInputSet.addChild(checkBoxInput);
      uiInputSet.addChild(uiInfo);
      uiTableInputSet.addChild(uiInputSet);
      uiInputSetList.add(uiInputSet);
    }

    UIFormPageIterator uiIterator = uiTableInputSet.getChild(UIFormPageIterator.class);
    SerializablePageList<UIFormInputSet> pageList =
        new SerializablePageList<UIFormInputSet>(UIFormInputSet.class, uiInputSetList, 5);
    uiIterator.setPageList(pageList);
  }
Ejemplo n.º 4
0
 public int compare(ApplicationCategory cat1, ApplicationCategory cat2) {
   return cat1.getDisplayName().compareToIgnoreCase(cat2.getDisplayName());
 }