summaryrefslogtreecommitdiff
path: root/src/antidote
diff options
context:
space:
mode:
authornickdavis <dev-null@apache.org>2001-04-16 01:52:06 +0000
committernickdavis <dev-null@apache.org>2001-04-16 01:52:06 +0000
commit28ca8667ace3c4a587a19338482ef9c732d877c4 (patch)
tree43388f2cf66249521a53fb321856e4946f54f154 /src/antidote
parent31dfcee6062cd37d7af28fe80f88fd841951ee47 (diff)
downloadant-28ca8667ace3c4a587a19338482ef9c732d877c4.tar.gz
changed the JTree to DragTree and added DragTreeListener
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268946 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/antidote')
-rw-r--r--src/antidote/org/apache/tools/ant/gui/modules/edit/ElementNavigator.java54
1 files changed, 52 insertions, 2 deletions
diff --git a/src/antidote/org/apache/tools/ant/gui/modules/edit/ElementNavigator.java b/src/antidote/org/apache/tools/ant/gui/modules/edit/ElementNavigator.java
index 2505453e7..7dceeeb0a 100644
--- a/src/antidote/org/apache/tools/ant/gui/modules/edit/ElementNavigator.java
+++ b/src/antidote/org/apache/tools/ant/gui/modules/edit/ElementNavigator.java
@@ -64,6 +64,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.EventObject;
import java.beans.PropertyChangeEvent;
+import org.w3c.dom.Node;
/**
* Module for navigating build file elemenets.
@@ -74,7 +75,7 @@ import java.beans.PropertyChangeEvent;
public class ElementNavigator extends AntModule {
/** Navigation via a tree widget. */
- private JTree _tree = null;
+ private DragTree _tree = null;
/** The selection model being used. */
private ElementTreeSelectionModel _selections = null;
@@ -96,7 +97,8 @@ public class ElementNavigator extends AntModule {
setLayout(new GridLayout(1,1));
- _tree = new JTree();
+ _tree = new DragTree();
+ _tree.addDragTreeListener(new DragHandler());
_tree.setModel(null);
_tree.setCellRenderer(new ElementTreeCellRenderer());
_tree.addMouseListener(new PopupHandler());
@@ -280,4 +282,52 @@ public class ElementNavigator extends AntModule {
handle(e);
}
}
+
+ /** Class for handling drag operation. */
+ private static class DragHandler implements DragTreeListener {
+
+ /**
+ * Append the object to the end of the parent's child list.
+ */
+ public Object appendChild(Object parent, Object newChild) {
+
+ ACSTreeNodeElement parentNode =
+ (ACSTreeNodeElement) parent;
+ ACSTreeNodeElement newChildNode =
+ (ACSTreeNodeElement) newChild;
+ ACSTreeNodeElement clone =
+ (ACSTreeNodeElement) newChildNode.cloneNode(true);
+ parentNode.appendChild(clone);
+ return clone;
+ }
+
+ /**
+ * Append the object to the end of the parent's child list.
+ */
+ public Object insertBefore(Object parent, Object index, Object newChild) {
+
+ ACSTreeNodeElement parentNode =
+ (ACSTreeNodeElement) parent;
+ ACSTreeNodeElement indexNode =
+ (ACSTreeNodeElement) index;
+ ACSTreeNodeElement newChildNode =
+ (ACSTreeNodeElement) newChild;
+ ACSTreeNodeElement clone =
+ (ACSTreeNodeElement) newChildNode.cloneNode(true);
+ parentNode.insertBefore(clone, indexNode);
+ return clone;
+ }
+
+ /**
+ * Append the object to the end of the parent's child list.
+ */
+ public void removeChild(Object child) {
+
+ ACSTreeNodeElement childNode =
+ (ACSTreeNodeElement) child;
+ ACSTreeNodeElement parentNode =
+ (ACSTreeNodeElement) childNode.getParentNode();
+ parentNode.removeChild(childNode);
+ }
+ }
}