use of org.freeplane.plugin.script.proxy.Proxy.Node in project freeplane by freeplane.
the class ControllerProxy method select.
public void select(final Collection<Node> toSelect) {
final Iterator<Node> it = toSelect.iterator();
if (!it.hasNext()) {
return;
}
final Node firstNode = it.next();
select(firstNode);
while (it.hasNext()) {
final Node nextNode = it.next();
final NodeModel nodeModel = ((NodeProxy) nextNode).getDelegate();
Controller.getCurrentModeController().getMapController().displayNode(nodeModel);
Controller.getCurrentController().getSelection().toggleSelected(nodeModel);
}
}
use of org.freeplane.plugin.script.proxy.Proxy.Node in project freeplane by freeplane.
the class ScriptApiTest method test_NodeRO_getNodeID.
@SuppressWarnings("deprecation")
public void test_NodeRO_getNodeID() {
map = c.newMap();
final Node root = map.getRoot();
assertTrue("unknown node id pattern in '" + root.getNodeID() + "'", root.getNodeID().matches("ID_[1-9]\\d+"));
}
use of org.freeplane.plugin.script.proxy.Proxy.Node in project freeplane by freeplane.
the class ScriptApiTest method test_Node_createChild_int_position.
public void test_Node_createChild_int_position() {
map = c.newMap();
final Node root = map.getRoot();
final Node child1 = root.createChild("child 1");
final Node child2 = root.createChild("child 2");
assertEquals("wrong position", 0, root.getChildPosition(child1));
assertEquals("wrong position", 1, root.getChildPosition(child2));
final Node child3 = root.createChild(0);
assertEquals("wrong insert position", 0, root.getChildPosition(child3));
assertEquals("node should be shifted", 1, root.getChildPosition(child1));
assertEquals("node should be shifted", 2, root.getChildPosition(child2));
final Node child4 = root.createChild(3);
assertEquals("wrong insert position", 3, root.getChildPosition(child4));
assertEquals("node should be shifted", 0, root.getChildPosition(child3));
assertEquals("node should be shifted", 1, root.getChildPosition(child1));
try {
root.createChild(-1);
fail("a negative position should lead to an exception");
} catch (Throwable e) {
}
try {
root.createChild(5);
fail("too large positions should lead to an exception");
} catch (Throwable e) {
}
}
use of org.freeplane.plugin.script.proxy.Proxy.Node in project freeplane by freeplane.
the class ScriptApiTest method test_NodeRO_getLastModifiedAt.
// public void test_NodeRO_find_Closure_closure() {
//
// }
public void test_NodeRO_getLastModifiedAt() {
map = c.newMap();
final Node child = map.getRoot().createChild("a node");
final Date initialLastModifiedAt = child.getLastModifiedAt();
long diff = System.currentTimeMillis() - initialLastModifiedAt.getTime();
// one second should be enough
assertTrue(//
"lastModifiedAt seems to be set incorrectly. It says it's " + diff + " ms ago", diff >= 0 && diff < 1000L);
// createChild() initially set both timestamps to the same value and changes modifiedAt directly
// afterwards in setText()
diff = initialLastModifiedAt.getTime() - child.getCreatedAt().getTime();
assertTrue("modifiedAt and createdAt should be set nearly to the same timestamp initially but modifiedAt = " + initialLastModifiedAt.getTime() + ", createdAt = " + //
child.getCreatedAt().getTime(), diff >= 0 && diff < 50);
final Date epoch = new Date(0);
child.setLastModifiedAt(epoch);
child.setText("changed");
assertTrue(//
"lastModifiedAt should be changed after changing the node text", child.getLastModifiedAt().after(epoch));
}
use of org.freeplane.plugin.script.proxy.Proxy.Node in project freeplane by freeplane.
the class ScriptApiTest method test_NodeRO_getText.
public void test_NodeRO_getText() {
map = c.newMap();
final Node root = map.getRoot();
root.setText(" xxx ");
assertEquals("", " xxx ", root.getText());
root.setText(" x\nxx ");
assertEquals("", " x\nxx ", root.getText());
}
Aggregations