Ejemplo n.º 1
0
  private SimpleTreeNode getTreeNode(ResourceCategory resourceCategory) {
    SimpleTreeNode treeNode = null;
    if (resourceCategory.getSubCategoryList() == null
        || resourceCategory.getSubCategoryList().size() <= 0) {
      TreeItem categoryResourceTreeItem =
          new TreeItem(resourceCategory.getCategoryName(), false, resourceCategory.getId());
      List<SimpleTreeNode> resourceTreeNodeList = new ArrayList<SimpleTreeNode>();
      TreeItem resourceTreeItem;
      if (resourceCategory.getResourceList() != null
          && resourceCategory.getResourceList().size() > 0) {
        categoryResourceTreeItem.setHasResourceList(true);
        for (Resource resource : resourceCategory.getResourceList()) {
          resourceTreeItem = new TreeItem(resource.getResourceName(), true);
          resourceTreeNodeList.add(new SimpleTreeNode(resourceTreeItem, new ArrayList()));
        }
      }
      treeNode = new SimpleTreeNode(categoryResourceTreeItem, resourceTreeNodeList);

    } else {
      List<SimpleTreeNode> treeNodeList = new ArrayList<SimpleTreeNode>();
      for (ResourceCategory category : resourceCategory.getSubCategoryList()) {
        treeNodeList.add(getTreeNode(category));
      }
      TreeItem categoryResourceTreeItem =
          new TreeItem(resourceCategory.getCategoryName(), false, resourceCategory.getId());
      treeNode = new SimpleTreeNode(categoryResourceTreeItem, treeNodeList);
    }
    return treeNode;
  }
Ejemplo n.º 2
0
  public void createResourceForm(Long categoryId) {
    resourceCategorySelected = this.projectMgmtService.getResourceCategoryById(categoryId);
    this.clearResourceForm();
    SelectedResource selectedResource;
    ResourceRow resourceRow;
    ProjectResource projectResourceFound = getProjectResource(categoryId);
    for (Resource resource : resourceCategorySelected.getResourceList()) {
      resourceRow = new ResourceRow(resource);
      rowsResourceList.getChildren().add(resourceRow);
      // Sets selected recources
      if (projectResourceFound == null) {
        continue;
      } else {
        for (int j = 0; j < projectResourceFound.getSelectedResourceList().size(); j++) {
          selectedResource = projectResourceFound.getSelectedResourceList().get(j);
          if (selectedResource.getResource().getId().compareTo(resource.getId()) == 0) {
            resourceRow.selectedResource();
            resourceRow.setSelectedValue(selectedResource.getSelectedValue());
          }
        }
      }
    }
    // Sets selected recources

    grdEditResource.setVisible(true);
    btnSaveResource.setVisible(true);
  }