projects
/
jSite2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Hide file manager window when no default file is set.
[jSite2.git]
/
src
/
net
/
pterodactylus
/
util
/
swing
/
SortableTreeNode.java
diff --git
a/src/net/pterodactylus/util/swing/SortableTreeNode.java
b/src/net/pterodactylus/util/swing/SortableTreeNode.java
index
dbdeb68
..
056b708
100644
(file)
--- a/
src/net/pterodactylus/util/swing/SortableTreeNode.java
+++ b/
src/net/pterodactylus/util/swing/SortableTreeNode.java
@@
-30,7
+30,7
@@
import javax.swing.tree.TreeNode;
/**
* {@link MutableTreeNode} subclass that allows to sort its children.
/**
* {@link MutableTreeNode} subclass that allows to sort its children.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class SortableTreeNode implements MutableTreeNode {
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class SortableTreeNode implements MutableTreeNode {
@@
-49,7
+49,7
@@
public class SortableTreeNode implements MutableTreeNode {
/**
* Creates a new sortable tree node.
/**
* Creates a new sortable tree node.
- *
+ *
* @param allowsChildren
* <code>true</code> if this node allows children,
* <code>false</code> otherwise
* @param allowsChildren
* <code>true</code> if this node allows children,
* <code>false</code> otherwise
@@
-61,7
+61,7
@@
public class SortableTreeNode implements MutableTreeNode {
/**
* Creates a new sortable tree node that contains the given user-defined
* object.
/**
* Creates a new sortable tree node that contains the given user-defined
* object.
- *
+ *
* @param userObject
* The user-defined object
*/
* @param userObject
* The user-defined object
*/
@@
-72,7
+72,7
@@
public class SortableTreeNode implements MutableTreeNode {
/**
* Creates a new sortable tree node that contains the given user-defined
* object.
/**
* Creates a new sortable tree node that contains the given user-defined
* object.
- *
+ *
* @param userObject
* The user-defined object
* @param allowsChildren
* @param userObject
* The user-defined object
* @param allowsChildren
@@
-125,7
+125,7
@@
public class SortableTreeNode implements MutableTreeNode {
/**
* Returns the user-defined object.
/**
* Returns the user-defined object.
- *
+ *
* @return The user-defined object
*/
public Object getUserObject() {
* @return The user-defined object
*/
public Object getUserObject() {
@@
-139,13
+139,20
@@
public class SortableTreeNode implements MutableTreeNode {
return children.isEmpty();
}
return children.isEmpty();
}
+ /**
+ * {@inheritDoc}
+ */
+ public Enumeration<?> children() {
+ return Collections.enumeration(children);
+ }
+
//
// ACTIONS
//
/**
* Adds the given node to this node as a child.
//
// ACTIONS
//
/**
* Adds the given node to this node as a child.
- *
+ *
* @param child
* The child node to add
*/
* @param child
* The child node to add
*/
@@
-159,13
+166,14
@@
public class SortableTreeNode implements MutableTreeNode {
*/
public void insert(MutableTreeNode child, int index) {
children.add(index, child);
*/
public void insert(MutableTreeNode child, int index) {
children.add(index, child);
+ child.setParent(this);
}
/**
* {@inheritDoc}
*/
public void remove(int index) {
}
/**
* {@inheritDoc}
*/
public void remove(int index) {
- children.remove(index);
+ children.remove(index)
.setParent(null)
;
}
/**
}
/**
@@
-173,6
+181,7
@@
public class SortableTreeNode implements MutableTreeNode {
*/
public void remove(MutableTreeNode node) {
children.remove(node);
*/
public void remove(MutableTreeNode node) {
children.remove(node);
+ node.setParent(null);
}
/**
}
/**
@@
-186,6
+195,16
@@
public class SortableTreeNode implements MutableTreeNode {
}
/**
}
/**
+ * Removes all children of this node.
+ */
+ public void removeAll() {
+ for (MutableTreeNode childNode : children) {
+ childNode.setParent(null);
+ }
+ children.clear();
+ }
+
+ /**
* {@inheritDoc}
*/
public void setParent(MutableTreeNode newParent) {
* {@inheritDoc}
*/
public void setParent(MutableTreeNode newParent) {
@@
-235,13
+254,6
@@
public class SortableTreeNode implements MutableTreeNode {
/**
* {@inheritDoc}
*/
/**
* {@inheritDoc}
*/
- public Enumeration<?> children() {
- return Collections.enumeration(children);
- }
-
- /**
- * {@inheritDoc}
- */
@Override
public String toString() {
return (userObject != null) ? userObject.toString() : null;
@Override
public String toString() {
return (userObject != null) ? userObject.toString() : null;