Package org.openbp.cockpit.plugins.finder.treemodel

Examples of org.openbp.cockpit.plugins.finder.treemodel.GenericNode


  public int compare(Object o1, Object o2)
  {
    if (o1 == o2)
      return 0;

    GenericNode n1 = (GenericNode) o1;
    GenericNode n2 = (GenericNode) o2;

    // Get the priority of the nodes, 1 stands for model node,
    // 2 for an simple node, 3 for a leaf node
    int prio1 = ((Integer) n1.getProperty(RefStrategy.PRIORITY_KEY)).intValue();
    int prio2 = ((Integer) n1.getProperty(RefStrategy.PRIORITY_KEY)).intValue();
    if (prio1 == prio2 && prio1 == 1)
    {
      return n1.toString().compareTo(n2.toString());
    }
    else if (prio1 == prio2 && prio1 == 2)
    {
      String type1 = (String) n1.getProperty(RefStrategy.ITEMTYPE_KEY);
      String type2 = (String) n2.getProperty(RefStrategy.ITEMTYPE_KEY);
      if (type1.equals(type2))
        return n1.toString().compareTo(n2.toString());

      // Sort by the item type
      int index1 = Arrays.binarySearch(ItemTypes.getValues(), type1);
      int index2 = Arrays.binarySearch(ItemTypes.getValues(), type2);
      return index2 - index1;
    }
    else if (prio1 == prio2 && prio1 == 3)
      return n1.toString().compareTo(n2.toString());
    else
      return prio1 - prio2;
  }
View Full Code Here

TOP

Related Classes of org.openbp.cockpit.plugins.finder.treemodel.GenericNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.