Search in sources :

Example 1 with GPNode

use of cern.gp.nodes.GPNode in project ACS by ACS-Community.

the class GPListExplorerPanel method getListNodes.

/**
   * accessor method, returns the nodes set with the {@link #setListNodes(GPNode[])} method.
   * Attention: this implementation returns the order the nodes had when they were set
   * with the setListNodes() method, it not reflect the order of the nodes as they are displayed
   * in the Explorer
   * @return the nodes displayed in this explorer
   */
public GPNode[] getListNodes() {
    // TODO implement some method like NodeCollection.toArray() instead of casting here.
    // TODO also make sure we have the same ordering of nodes, which is not guaranteed in the current implemenation
    NodeCollection coll = rootNode.getNodeCollection();
    GPNode[] ret = new GPNode[coll.getNodesCount()];
    if (coll instanceof NodeList) {
        Iterator it = ((NodeList) coll).iterator();
        for (int ix = 0; ix < ret.length && it.hasNext(); ix++) {
            ret[ix] = (GPNode) it.next();
        }
    } else if (coll instanceof NodeMap) {
        NodeMap map = (NodeMap) coll;
        Iterator it = map.keySet().iterator();
        for (int ix = 0; ix < ret.length && it.hasNext(); ix++) {
            ret[ix] = map.getNode(it.next());
        }
    } else {
        throw new RuntimeException("internal error: unknown NodeCollection class: " + coll.getClass());
    }
    return ret;
}
Also used : NodeList(cern.gp.nodes.children.NodeList) Iterator(java.util.Iterator) NodeCollection(cern.gp.nodes.children.NodeCollection) NodeMap(cern.gp.nodes.children.NodeMap) GPNode(cern.gp.nodes.GPNode)

Example 2 with GPNode

use of cern.gp.nodes.GPNode in project ACS by ACS-Community.

the class TestColoredListTableExplorer method createListTableExplorer.

/**
   * method that creates and returns a ListTableExplorer
   */
public static ListTableExplorer createListTableExplorer() {
    ListTableExplorer expl = null;
    try {
        expl = new ListTableExplorer();
        GPNode root = NodeFactory.createNode(new Object(), new RecursiveChildrenListManager(ColoredBean.class, 1, 10));
        expl.setRootNode(root);
        expl.setTableColumns(new ColoredBean(), null);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return expl;
}
Also used : ListTableExplorer(cern.gp.explorer.ListTableExplorer) ColoredBean(cern.gp.explorer.test.helpers.ColoredBean) RecursiveChildrenListManager(cern.gp.explorer.test.helpers.RecursiveChildrenListManager) GPNode(cern.gp.nodes.GPNode)

Example 3 with GPNode

use of cern.gp.nodes.GPNode in project ACS by ACS-Community.

the class TestListExplorer method main.

public static void main(String[] args) throws Exception {
    int numberOfBeans = 6;
    // create the beans you want to display
    SimpleDemoBean[] beans = new SimpleDemoBean[numberOfBeans];
    for (int ix = 0; ix < numberOfBeans; ix++) {
        beans[ix] = new SimpleDemoBean("bean_" + ix);
    }
    // create nodes associated with the beans
    GPNode[] nodes = NodeFactory.createNode(beans);
    // create the explorer and set the columns it shall display
    ListExplorer expl = new ListExplorer(nodes);
    //  open the explorer in a NetBeans "Mode"
    WindowUtils.openInMode(expl, "TestListExplorer");
    expl.requestFocus();
}
Also used : SimpleDemoBean(cern.gp.explorer.test.helpers.SimpleDemoBean) ListExplorer(cern.gp.explorer.ListExplorer) GPNode(cern.gp.nodes.GPNode)

Example 4 with GPNode

use of cern.gp.nodes.GPNode in project ACS by ACS-Community.

the class BeanComparatorAdapter method compare.

//
// -- PUBLIC METHODS -----------------------------------------------
//
//
// -- implements Comparator interface ------------------------------
//
public final int compare(Object o1, Object o2) {
    GPNode b1 = (GPNode) o1;
    GPNode b2 = (GPNode) o2;
    return beanComparator.compare(b1.getBean(), b2.getBean());
}
Also used : GPNode(cern.gp.nodes.GPNode)

Example 5 with GPNode

use of cern.gp.nodes.GPNode in project ACS by ACS-Community.

the class TestListTableExplorer method main.

public static void main(String[] args) throws Exception {
    int numberOfBeans = 6;
    // create the beans you want to display
    SimpleDemoBean[] beans = new SimpleDemoBean[numberOfBeans];
    for (int ix = 0; ix < numberOfBeans; ix++) {
        beans[ix] = new SimpleDemoBean("bean_" + ix);
    }
    // create nodes associated with the beans
    GPNode[] nodes = NodeFactory.createNode(beans);
    // create the explorer and set the columns it shall display
    ListTableExplorer expl = new ListTableExplorer(nodes);
    expl.setTableColumns(new String[] { "name", "value" });
    //  open the explorer in a NetBeans "Mode"
    WindowUtils.openInMode(expl, "TestListTableExplorer");
    expl.requestFocus();
}
Also used : SimpleDemoBean(cern.gp.explorer.test.helpers.SimpleDemoBean) ListTableExplorer(cern.gp.explorer.ListTableExplorer) GPNode(cern.gp.nodes.GPNode)

Aggregations

GPNode (cern.gp.nodes.GPNode)11 SimpleDemoBean (cern.gp.explorer.test.helpers.SimpleDemoBean)7 RecursiveChildrenListManager (cern.gp.explorer.test.helpers.RecursiveChildrenListManager)6 IntrospectionException (java.beans.IntrospectionException)3 ListTableExplorer (cern.gp.explorer.ListTableExplorer)2 TreeExplorer (cern.gp.explorer.TreeExplorer)2 TreeTableExplorer (cern.gp.explorer.TreeTableExplorer)2 ListExplorer (cern.gp.explorer.ListExplorer)1 MultiListExplorer (cern.gp.explorer.MultiListExplorer)1 ColoredBean (cern.gp.explorer.test.helpers.ColoredBean)1 NodeCollection (cern.gp.nodes.children.NodeCollection)1 NodeList (cern.gp.nodes.children.NodeList)1 NodeMap (cern.gp.nodes.children.NodeMap)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Node (org.openide.nodes.Node)1 Property (org.openide.nodes.Node.Property)1 PropertySet (org.openide.nodes.Node.PropertySet)1