/**
  * User selected a leaf node and is interested in its data attributes
  *
  * @param event
  */
 public void processSelection(NodeSelectedEvent event) {
   HtmlTree tree = (HtmlTree) event.getComponent();
   TreeNode currentNode = tree.getTreeNode(tree.getRowKey());
   if (currentNode.isLeaf()) {
     this.setSelTreeNode(currentNode);
   }
 }
 /**
  * Takes the selected properties and returns their data
  *
  * @return
  */
 public List<OntologyProperty> getSelectedOntologyProperties() {
   List<OntologyProperty> ret = new ArrayList<OntologyProperty>();
   List<TreeNode> nodes = this.getSelNodes();
   for (TreeNode node : nodes) {
     ret.add((OntologyProperty) node.getData());
   }
   return ret;
 }
  private void processAddNodeActionEvent(UITreeNode srcNode) {
    UITree srcTree = srcNode != null ? srcNode.getUITree() : null;
    TreeRowKey dragNodeKey =
        (srcNode.getDragValue() instanceof TreeRowKey) ? (TreeRowKey) srcNode.getDragValue() : null;
    TreeNode draggedNode = dragNodeKey != null ? srcTree.getTreeNode(dragNodeKey) : null;

    log.debug("dropped key: " + dragNodeKey);

    // add to list of selected properties
    if (draggedNode != null)
      this.dndSelNodes.put(((OntologyProperty) draggedNode.getData()).getURI(), draggedNode);
  }
Example #4
0
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public void loadTree() {
		try {
			rootNode = new TreeNodeImpl();

			Query query = getSession().getNamedQuery("core.org.records");
			Iterator it = query.list().iterator();
			int id;
			String name, desc;
			key = 1;
			while (it.hasNext()) {
				Object obj[] = (Object[]) it.next();
				id = 0;
				name = desc = "";
				if (obj[0] != null)
					id = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[6] != null)
					name = String.valueOf(obj[6]);
				if (obj[7] != null)
					desc = String.valueOf(obj[7]);
				TreeNodeImpl nodeImpl = new TreeNodeImpl();
				nodeImpl.setData(new Department(id, 0, 0, name, name, name, desc));
				rootNode.addChild(key, nodeImpl);
				key++;
				addNodes(nodeImpl, id, 0, name, name);

			}
			it = null;

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
Example #5
0
	/*
	 * * Tree Node
	 * 
	 * @param parentCode
	 * 
	 * @param node
	 */
	@SuppressWarnings("unchecked")
	public void addNodes(TreeNode<Department> node, int orgId, int parentId, String oName, String pName) {
		try {
			Query query = getSession().getNamedQuery("core.department.getchildren");
			query.setParameter("orgId", orgId);
			query.setParameter("parentId", parentId);
			Iterator<?> it = query.list().iterator();
			int id;
			String name, desc;
			while (it.hasNext()) {
				Object obj[] = (Object[]) it.next();
				id = 0;
				name = desc = "";
				if (obj[0] != null)
					id = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[1] != null)
					name = String.valueOf(obj[1]);
				if (obj[2] != null)
					desc = String.valueOf(obj[2]);
				@SuppressWarnings("rawtypes")
				TreeNodeImpl nodeImpl = new TreeNodeImpl();
				nodeImpl.setData(new Department(orgId, id, id, oName, pName, name, desc));
				node.addChild(key, nodeImpl);
				key++;
				if (hasChild(orgId, id))
					addNodes(nodeImpl, orgId, id, oName, name);
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
  @Override
  protected void proceedToNext() {
    Object key = childrenKeysIterator.next();
    TreeNode data = treeNode.getChild(key);

    setKeyAndData(key, data);
  }
  public void processDrop(DropEvent dropEvent) {
    // resolve drag source attributes
    UITreeNode srcNode =
        (dropEvent.getDraggableSource() instanceof UITreeNode)
            ? (UITreeNode) dropEvent.getDraggableSource()
            : null;
    UITree srcTree = srcNode != null ? srcNode.getUITree() : null;
    TreeRowKey dragNodeKey =
        (dropEvent.getDragValue() instanceof TreeRowKey)
            ? (TreeRowKey) dropEvent.getDragValue()
            : null;
    TreeNode draggedNode = dragNodeKey != null ? srcTree.getTreeNode(dragNodeKey) : null;

    log.debug("dropped key: " + dragNodeKey);

    // add to list of selected properties
    if (draggedNode != null)
      this.dndSelNodes.put(((OntologyProperty) draggedNode.getData()).getURI(), draggedNode);
  }
Example #8
0
  public TreeBean() {

    String[] components = {"< a4j:ajaxListener >", "< a4j:keepAlive >", "< a4j:actionparam >"};
    String[][] attributes = {
      {"type"},
      {"ajaxOnly", "beanName"},
      {"actionListener", "assignTo", "binding", "converter", "id", "name", "noEscape", "value"}
    };

    if (data == null) {
      data = new TreeNodeImpl<String>();

      for (int i = 0; i < components.length; i++) {
        TreeNode<String> child = new TreeNodeImpl<String>();
        child.setData(components[i]);
        data.addChild(components[i], child);

        for (int j = 0; j < attributes[i].length; j++) {
          TreeNode<String> grandChild = new TreeNodeImpl<String>();
          grandChild.setData(attributes[i][j]);
          child.addChild(attributes[i][j], grandChild);
        }
      }
    }
  }
Example #9
0
 public void addChild(Object identifier, TreeNode child) {
   getArtists().put(identifier, child);
   child.setParent(this);
 }
Example #10
0
    public void begin(String namespace, String name, Attributes attributes) throws Exception {
      super.begin(namespace, name, attributes);

      level++;

      XmlNodeData xmlNodeData = new XmlNodeData();
      xmlNodeData.setName(name);
      xmlNodeData.setNamespace(namespace);

      String id = null;

      if (attributes != null) {
        int length = attributes.getLength();
        for (int i = 0; i < length; i++) {
          xmlNodeData.setAttribute(attributes.getQName(i), attributes.getValue(i));
        }

        id = attributes.getValue("id");
      }

      if (exclusionSets.size() == level) {
        exclusionSets.add(null);
      }

      if (id == null || id.length() == 0) {
        int currentId = 0;

        if (idsList.size() <= level) {
          for (int i = idsList.size(); i <= level; i++) {
            idsList.add(null);
          }
        } else {
          Integer integer = (Integer) idsList.get(level);
          currentId = integer.intValue() + 1;
        }

        Set exclusions = (Set) exclusionSets.get(level);

        while (exclusions != null && exclusions.contains(Integer.toString(currentId))) {
          currentId++;
        }

        idsList.set(level, new Integer(currentId));

        id = Integer.toString(currentId);
      } else {
        Set exclusions = (Set) exclusionSets.get(level);
        if (exclusions == null) {
          exclusions = new HashSet();

          exclusionSets.set(level, exclusions);
        }

        exclusions.add(id);
      }

      TreeNode node = new TreeNodeImpl();
      node.setData(xmlNodeData);

      this.treeNode.addChild(id, node);
      this.treeNodesList.add(this.treeNode);
      this.treeNode = node;
    }
    public static TreeNode standardTraverseTree(
        OWLNamedClass cl, List stack, TreeNode node, boolean applyfilter) {
      Collection<RDFIndividual> instances = cl.getInstances(false);

      // adding a new category - isn't backed by any data, not even name??
      TreeNode childClass = new TreeNodeImpl();
      String instanceCountText = instances.size() > 0 ? " (" + instances.size() + ")" : "";
      childClass.setData(new DummyOntologyProperty(cl.getLocalName() + instanceCountText));
      // addChild(key, nodeImpl
      node.addChild(cl.getURI(), childClass);

      if (instances.size() > 0) {
        for (Iterator<RDFIndividual> jt = instances.iterator(); jt.hasNext(); ) {
          try {
            RDFIndividual individual = (RDFIndividual) jt.next();
            // OWLIndividual individual = (OWLIndividual) jt.next();
            TreeNode child = new TreeNodeImpl();
            OntologyProperty ontologyProperty = new OntologyPropertyImpl(individual);

            boolean bMatchesFilter = true;
            if (applyfilter) {
              boolean b1 =
                  ontologyProperty.getName().toLowerCase().contains(filterTreeString.toLowerCase());
              boolean b2 =
                  ontologyProperty
                      .getHumanReadableName()
                      .toLowerCase()
                      .contains(filterTreeString.toLowerCase());
              bMatchesFilter = b1 || b2;
            }
            if (bMatchesFilter) {
              child.setData(ontologyProperty);
              childClass.addChild(ontologyProperty.getURI(), child);
            }
          } catch (ClassCastException e) {
            log.debug("Shouldn't happen any more: Filtering out RDFIndividual");
          }
        }
      }
      if (!stack.contains(cl)) {
        for (java.util.Iterator<OWLNamedClass> it = cl.getSubclasses(false).iterator();
            it.hasNext(); ) {
          OWLNamedClass subClass = (OWLNamedClass) it.next();
          stack.add(cl);
          standardTraverseTree(subClass, stack, childClass, applyfilter);
          stack.remove(cl);
        }
      }

      // remove nodes that don't apply the given filter
      if (applyfilter) {
        Iterator it = childClass.getChildren();
        if (it.hasNext()) {
          // ok node still has other leaf elements - keep it
        } else {
          node.removeChild(cl.getURI());
        }
      }

      return node;
    }
 public void setSelTreeNode(TreeNode node) {
   this.selNode = new TreeNodeImpl();
   selNode.setData(node.getData());
 }
 public ClassicTreeNodeTuplesIterator(TreeNode treeNode, SequenceRowKey baseKey) {
   super(baseKey);
   this.treeNode = treeNode;
   this.childrenKeysIterator = treeNode.getChildrenKeysIterator();
 }