/[classpath]/classpath/javax/swing/tree/DefaultTreeCellEditor.java
ViewVC logotype

Diff of /classpath/javax/swing/tree/DefaultTreeCellEditor.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by langel, Thu Sep 1 15:16:15 2005 UTC revision 1.15 by langel, Fri Sep 2 18:03:25 2005 UTC
# Line 340  public class DefaultTreeCellEditor Line 340  public class DefaultTreeCellEditor
340      if (editor == null)      if (editor == null)
341        editor = createTreeCellEditor();        editor = createTreeCellEditor();
342      realEditor = editor;      realEditor = editor;
343        
344        lastPath = tree.getLeadSelectionPath();
345      tree.addTreeSelectionListener(this);      tree.addTreeSelectionListener(this);
346      editingContainer = createContainer();      editingContainer = createContainer();
347      UIDefaults defaults = UIManager.getLookAndFeelDefaults();      UIDefaults defaults = UIManager.getLookAndFeelDefaults();
# Line 360  public class DefaultTreeCellEditor Line 361  public class DefaultTreeCellEditor
361    private void configureEditingComponent(JTree tree,    private void configureEditingComponent(JTree tree,
362                                           DefaultTreeCellRenderer renderer,                                           DefaultTreeCellRenderer renderer,
363                                           TreeCellEditor editor)                                           TreeCellEditor editor)
364    {    {    
365      if (tree != null && lastPath != null)      if (tree != null && lastPath != null)
366        {        {
367          Object val = lastPath.getLastPathComponent();          Object val = lastPath.getLastPathComponent();
# Line 499  public class DefaultTreeCellEditor Line 500  public class DefaultTreeCellEditor
500     * @return true if editing can be started     * @return true if editing can be started
501     */     */
502    public boolean isCellEditable(EventObject event)    public boolean isCellEditable(EventObject event)
503    {        {
504        if (editingComponent == null)
505            configureEditingComponent(tree, renderer, realEditor);
506        
507      if (editingComponent != null && realEditor.isCellEditable(event))      if (editingComponent != null && realEditor.isCellEditable(event))
508        {        {
509          prepareForEditing();          prepareForEditing();
# Line 509  public class DefaultTreeCellEditor Line 513  public class DefaultTreeCellEditor
513      // Cell may not be currently editable, but may need to start timer.      // Cell may not be currently editable, but may need to start timer.
514      if (shouldStartEditingTimer(event))      if (shouldStartEditingTimer(event))
515        startEditingTimer();        startEditingTimer();
         
516      return false;      return false;
517    }    }
518    
# Line 536  public class DefaultTreeCellEditor Line 539  public class DefaultTreeCellEditor
539      if (editingComponent != null && realEditor.stopCellEditing())      if (editingComponent != null && realEditor.stopCellEditing())
540        {        {
541          timer.stop();          timer.stop();
         tree.setCellEditor(null);  
542          return true;          return true;
543        }        }
544      return false;      return false;
# Line 547  public class DefaultTreeCellEditor Line 549  public class DefaultTreeCellEditor
549     * from this instance.     * from this instance.
550     */     */
551    public void cancelCellEditing()    public void cancelCellEditing()
552    {          {
553      if (editingComponent != null)      if (editingComponent != null)
554        {        {
555          timer.stop();          timer.stop();
556          realEditor.cancelCellEditing();          realEditor.cancelCellEditing();
         tree.setCellEditor(null);  
557        }        }
558    }    }
559    
# Line 595  public class DefaultTreeCellEditor Line 596  public class DefaultTreeCellEditor
596     */     */
597    public void valueChanged(TreeSelectionEvent e)    public void valueChanged(TreeSelectionEvent e)
598    {    {
599        tPath = lastPath;
600      lastPath = e.getNewLeadSelectionPath();      lastPath = e.getNewLeadSelectionPath();
601      lastRow = tree.getRowForPath(lastPath);      lastRow = tree.getRowForPath(lastPath);
       
602      configureEditingComponent(tree, renderer, realEditor);      configureEditingComponent(tree, renderer, realEditor);
603    }    }
604        
# Line 608  public class DefaultTreeCellEditor Line 609  public class DefaultTreeCellEditor
609     */     */
610    public void actionPerformed(ActionEvent e)    public void actionPerformed(ActionEvent e)
611    {    {
     lastPath = tree.getSelectionPath();  
   
612      if (lastPath != null && tPath != null && tPath.equals(lastPath))      if (lastPath != null && tPath != null && tPath.equals(lastPath))
613        {        {
614          tree.startEditingAtPath(lastPath);          tree.startEditingAtPath(lastPath);
615          tPath = null;          timer.stop();
616        }        }
     else if (tPath == null)  
       tPath = lastPath;  
     else  
       tPath = null;  
617    }    }
618    
619    /**    /**

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26