summaryrefslogtreecommitdiff
path: root/javax/swing/tree
diff options
context:
space:
mode:
authorLillian Angel <langel@redhat.com>2005-09-02 18:03:24 +0000
committerLillian Angel <langel@redhat.com>2005-09-02 18:03:24 +0000
commitb9f1c1a5891dbb61ad52057132d00e73cdf9fb39 (patch)
tree3c4a7a230767595ae48b1af7c5c87beecd0b193c /javax/swing/tree
parent3790d9b4e1c52b79e4381290d4af7766fb0ee12d (diff)
downloadclasspath-b9f1c1a5891dbb61ad52057132d00e73cdf9fb39.tar.gz
JTree editing and key handling is now completed.
2005-09-02 Lillian Angel <langel@redhat.com> * javax/swing/JTree.java (installUI): TreeSelectionListener removed because added too many times. * javax/swing/plaf/basic/BasicLookAndFeel.java: Fixed names for some tree defaults. * javax/swing/plaf/basic/BasicTreeUI.java: Added new fields for editing and keyboard actions. (setCellEditor): Took out unneeded if statement. (isEditing): Returned boolean instead. (updateCellEditor): Used set method. (installDefaults): Set focus to tree. (installKeyBoardActions): Implemented. (convertModifiers): New function implemented. (installUI): Used set method and initialized isEditing. (startEditing): set isEditing. (TreeAction): New class implemented to perform keyboard actions. (ActionListenerProxy): New private class used to distribute the key board actions to the true receiver. (editingStopped): Added code to prevent NPEs. set isEditing and focus to tree. Also, removed TreeSelectionListeners for cellEditor. (editingCanceled): Likewise. (keyPressed): Removed code, not needed anymore. (actionPerformed): Implemented for up/down keyboard actions. (actionPerformed): Implemented for left/right keyboard actions. * javax/swing/tree/DefaultTreeCellEditor.java (DefaultTreeCellEditor): Set lastPath. (isCellEditable): editingComponent should be configured if has not been. (stopCellEditing): No need to set cell editor to null here. (cancelCellEditing): Likewise. (valueChanged): Set tPath to the path that was last selected. Used for the click-pause-click implementation. (actionPerformed): Re-implemented in a simplier fashion. * javax/swing/tree/DefaultTreeCellRenderer.java (getTreeCellRendererComponent): Only set border color if val is lead selection path.
Diffstat (limited to 'javax/swing/tree')
-rw-r--r--javax/swing/tree/DefaultTreeCellEditor.java25
-rw-r--r--javax/swing/tree/DefaultTreeCellRenderer.java9
2 files changed, 17 insertions, 17 deletions
diff --git a/javax/swing/tree/DefaultTreeCellEditor.java b/javax/swing/tree/DefaultTreeCellEditor.java
index 2de593e39..7a44e7383 100644
--- a/javax/swing/tree/DefaultTreeCellEditor.java
+++ b/javax/swing/tree/DefaultTreeCellEditor.java
@@ -340,7 +340,8 @@ public class DefaultTreeCellEditor
if (editor == null)
editor = createTreeCellEditor();
realEditor = editor;
-
+
+ lastPath = tree.getLeadSelectionPath();
tree.addTreeSelectionListener(this);
editingContainer = createContainer();
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
@@ -360,7 +361,7 @@ public class DefaultTreeCellEditor
private void configureEditingComponent(JTree tree,
DefaultTreeCellRenderer renderer,
TreeCellEditor editor)
- {
+ {
if (tree != null && lastPath != null)
{
Object val = lastPath.getLastPathComponent();
@@ -499,7 +500,10 @@ public class DefaultTreeCellEditor
* @return true if editing can be started
*/
public boolean isCellEditable(EventObject event)
- {
+ {
+ if (editingComponent == null)
+ configureEditingComponent(tree, renderer, realEditor);
+
if (editingComponent != null && realEditor.isCellEditable(event))
{
prepareForEditing();
@@ -509,7 +513,6 @@ public class DefaultTreeCellEditor
// Cell may not be currently editable, but may need to start timer.
if (shouldStartEditingTimer(event))
startEditingTimer();
-
return false;
}
@@ -536,7 +539,6 @@ public class DefaultTreeCellEditor
if (editingComponent != null && realEditor.stopCellEditing())
{
timer.stop();
- tree.setCellEditor(null);
return true;
}
return false;
@@ -547,12 +549,11 @@ public class DefaultTreeCellEditor
* from this instance.
*/
public void cancelCellEditing()
- {
+ {
if (editingComponent != null)
{
timer.stop();
realEditor.cancelCellEditing();
- tree.setCellEditor(null);
}
}
@@ -595,9 +596,9 @@ public class DefaultTreeCellEditor
*/
public void valueChanged(TreeSelectionEvent e)
{
+ tPath = lastPath;
lastPath = e.getNewLeadSelectionPath();
lastRow = tree.getRowForPath(lastPath);
-
configureEditingComponent(tree, renderer, realEditor);
}
@@ -608,17 +609,11 @@ public class DefaultTreeCellEditor
*/
public void actionPerformed(ActionEvent e)
{
- lastPath = tree.getSelectionPath();
-
if (lastPath != null && tPath != null && tPath.equals(lastPath))
{
tree.startEditingAtPath(lastPath);
- tPath = null;
+ timer.stop();
}
- else if (tPath == null)
- tPath = lastPath;
- else
- tPath = null;
}
/**
diff --git a/javax/swing/tree/DefaultTreeCellRenderer.java b/javax/swing/tree/DefaultTreeCellRenderer.java
index fe415bbaf..4a353b301 100644
--- a/javax/swing/tree/DefaultTreeCellRenderer.java
+++ b/javax/swing/tree/DefaultTreeCellRenderer.java
@@ -418,8 +418,13 @@ public class DefaultTreeCellRenderer
{
super.setBackground(getBackgroundSelectionColor());
setForeground(getTextSelectionColor());
- setBorderSelectionColor(UIManager.getLookAndFeelDefaults().getColor(
- "Tree.selectionBorderColor"));
+
+ if (tree.getLeadSelectionPath() == null ||
+ (tree.getLeadSelectionPath().getLastPathComponent()).equals(val))
+ setBorderSelectionColor(UIManager.getLookAndFeelDefaults().
+ getColor("Tree.selectionBorderColor"));
+ else
+ setBorderSelectionColor(null);
}
else
{