Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31012/src/net/sourceforge/bprocessor/gui/treeview
Modified Files:
GenericTreeView.java
Log Message:
added transforms to the space tree
Index: GenericTreeView.java
===================================================================
RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** GenericTreeView.java 28 Nov 2006 10:07:40 -0000 1.65
--- GenericTreeView.java 28 Nov 2006 15:39:35 -0000 1.66
***************
*** 22,25 ****
--- 22,26 ----
import java.util.Map;
import java.util.Set;
+ import java.util.Stack;
import java.awt.event.ActionEvent;
***************
*** 533,536 ****
--- 534,541 ----
ContainerNode cn = new ConstructorContainer("Constructors", space.getConstructors());
add(cn);
+ ContainerNode tc =
+ new TransformationContainer("Transformations", space.getTransformations().stack());
+ tc.update(space.getTransformations().stack());
+ add(tc);
}
if (space.getModellor() != null) {
***************
*** 555,571 ****
if (s.isContainer()) {
((GenericNode)getChildAt(3)).update(s.getConstructors());
! }
! if (s.getModellor() != null) {
! if (getChildCount() == 5) {
! ((GenericNode)getChildAt(4)).update(s.getModellor());
} else {
! add(new ModellorNode(s.getModellor()));
! model.nodesWereInserted(this, new int[]{4});
! }
! } else {
! if (getChildCount() == 5) {
! TreeNode node = getChildAt(4);
! remove(4);
! model.nodesWereRemoved(this, new int[]{4}, new Object[]{node});
}
}
--- 560,577 ----
if (s.isContainer()) {
((GenericNode)getChildAt(3)).update(s.getConstructors());
! ((GenericNode)getChildAt(4)).update(s.getTransformations().stack());
! if (s.getModellor() != null) {
! if (getChildCount() == 6) {
! ((GenericNode)getChildAt(5)).update(s.getModellor());
! } else {
! add(new ModellorNode(s.getModellor()));
! model.nodesWereInserted(this, new int[]{5});
! }
} else {
! if (getChildCount() == 6) {
! TreeNode node = getChildAt(5);
! remove(5);
! model.nodesWereRemoved(this, new int[]{5}, new Object[]{node});
! }
}
}
***************
*** 1239,1242 ****
--- 1245,1307 ----
/**
+ * ConstraintContainer
+ */
+ public class TransformationContainer extends ContainerNode {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor for ConstraintContainer
+ * @param name The name
+ * @param transforms The constraints
+ */
+ public TransformationContainer(String name, Stack transforms) {
+ super(name, transforms);
+ update(transforms);
+ }
+
+ /**
+ * Update the node with the given object
+ * @param o The object
+ */
+ public void update(Object o) {
+ if (o instanceof Stack) {
+ content = (Stack) o;
+ if (((Stack)o).size() != this.getChildCount()) {
+ this.removeAllChildren();
+ LinkedList elem = new LinkedList();
+ Iterator iter = ((Stack)o).iterator();
+ while (iter.hasNext()) {
+ elem.add(iter.next());
+ }
+ this.insertChildren(elem);
+ model.nodeStructureChanged(this);
+ }
+ } else {
+ log.warn(userObject + " were called with " + o + " and not a list");
+ }
+ }
+
+ /**
+ * Insert the given object into the node
+ * @param elem the elements
+ */
+ public void insertChildren(Collection elem) {
+ //insert
+ int[] ins = new int[elem.size()];
+ int i = 0;
+ Iterator iter = elem.iterator();
+ while (iter.hasNext()) {
+ this.add(new EntityNode(iter.next()));
+ ins[i] = this.getChildCount() - 1;
+ i++;
+ }
+ model.nodesWereInserted(this, ins);
+ }
+ }
+
+ /**
* Selection Listener
*/
|