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;
}
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;
}
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();
}
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());
}
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();
}
Aggregations