/[classpath]/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/metal/MetalFileChooserUI.java

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

revision 1.6 by langel, Fri Nov 25 21:58:39 2005 UTC revision 1.7 by langel, Fri Nov 25 22:57:15 2005 UTC
# Line 45  import java.awt.Dimension; Line 45  import java.awt.Dimension;
45  import java.awt.GridLayout;  import java.awt.GridLayout;
46  import java.awt.Insets;  import java.awt.Insets;
47  import java.awt.LayoutManager;  import java.awt.LayoutManager;
48  import java.awt.Point;  import java.awt.Rectangle;
49  import java.awt.Window;  import java.awt.Window;
50  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
51  import java.awt.event.MouseAdapter;  import java.awt.event.MouseAdapter;
# Line 63  import javax.swing.BorderFactory; Line 63  import javax.swing.BorderFactory;
63  import javax.swing.ButtonGroup;  import javax.swing.ButtonGroup;
64  import javax.swing.ComboBoxModel;  import javax.swing.ComboBoxModel;
65  import javax.swing.DefaultListCellRenderer;  import javax.swing.DefaultListCellRenderer;
66    import javax.swing.Icon;
67  import javax.swing.JButton;  import javax.swing.JButton;
68  import javax.swing.JComboBox;  import javax.swing.JComboBox;
69  import javax.swing.JComponent;  import javax.swing.JComponent;
# Line 647  public class MetalFileChooserUI Line 648  public class MetalFileChooserUI
648      /** The current file chooser. */      /** The current file chooser. */
649      JFileChooser fc;      JFileChooser fc;
650            
651      /** The index of the last file selected. */      /** The last file selected. */
652      int lastSelected;      Object lastSelected;
653            
654      /** The textfield used for editing. */      /** The textfield used for editing. */
655      JTextField editField;      JTextField editField;
# Line 663  public class MetalFileChooserUI Line 664  public class MetalFileChooserUI
664        this.list = list;        this.list = list;
665        editFile = null;        editFile = null;
666        fc = getFileChooser();        fc = getFileChooser();
667        lastSelected = -1;        lastSelected = null;
668      }      }
669            
670      /**      /**
# Line 680  public class MetalFileChooserUI Line 681  public class MetalFileChooserUI
681            if ((!fc.isMultiSelectionEnabled() || (sf != null && sf.length <= 1))            if ((!fc.isMultiSelectionEnabled() || (sf != null && sf.length <= 1))
682                && index >= 0 && editFile == null && list.isSelectedIndex(index))                && index >= 0 && editFile == null && list.isSelectedIndex(index))
683              {              {
684                if (lastSelected == index)                Object tmp = list.getModel().getElementAt(index);
685                  if (lastSelected != null && lastSelected.equals(tmp))
686                  editFile(index);                  editFile(index);
687                lastSelected = index;                lastSelected = tmp;
688              }              }
689            else if (editFile != null)            else if (editFile != null)
690              {              {
691                completeEditing();                completeEditing();
692                editFile = null;                editFile = null;
693                lastSelected = -1;                lastSelected = null;
694              }              }
695          }          }
696      }      }
# Line 705  public class MetalFileChooserUI Line 707  public class MetalFileChooserUI
707        editFile = (File) list.getModel().getElementAt(index);        editFile = (File) list.getModel().getElementAt(index);
708        if (editFile.canWrite())        if (editFile.canWrite())
709          {          {
710            Point p = list.indexToLocation(index);            Rectangle bounds = list.getCellBounds(index, index);
711              Icon icon = getFileView(fc).getIcon(editFile);
712            editField = new JTextField(editFile.getName());            editField = new JTextField(editFile.getName());
713            // FIXME: add action listener            // FIXME: add action listener for typing
714              // FIXME: painting for textfield is messed up when typing    
715            list.add(editField);            list.add(editField);
716            editField.requestFocus();            editField.requestFocus();
717            editField.selectAll();                      editField.selectAll();
718            list.revalidate();            
719            list.repaint();            if (icon != null)
720                bounds.x += icon.getIconWidth() + 4;
721              editField.setBounds(bounds);
722          }          }
723        else        else
724          {          {
725            editField = null;            editField = null;
726            editFile = null;            editFile = null;
727            lastSelected = -1;            lastSelected = null;
728          }          }
729      }      }
730            

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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