Here is another editing fix. 2005-11-25 Lillian Angel <[EMAIL PROTECTED]>
* javax/swing/plaf/metal/MetalFileChooserUI.java (mouseClicked): Fixed to keep track of last object clicked, instead of index. Problems arise when lists change for different directories and using the index. (editFile): Fixed size and location for text field. Painting is still a little messed up when typing because there is no action listener yet. On Fri, 2005-11-25 at 16:59 -0500, Lillian Angel wrote: > I am starting to implement the editing for the MetalFileChooser. It does > not completely work, but its a start. > > 2005-11-25 Lillian Angel <[EMAIL PROTECTED]> > > * javax/swing/JFileChooser.java: > selectedFiles field should not be initialized. > (getSelectedFiles): Should return empty array, not null. > * javax/swing/plaf/metal/MetalFileChooserUI.java > (MetalFileChooserSelectionListener): Added comment. > (valueChanged): Fixed API documentation. > (SingleClickListener): Likewise. > (SingleClickListener.init): Added field initializations. > (mouseClicked): Implemented. > (editFile): Partially implemented. > (completeEditing): Implemented. > (installUI): Added call to create the action map. > (uninstallUI): Set actionMap to null. > (getActionMap): Implemented. > (createList): Uncommented code. > (removeControlButtons): Implemented. > > _______________________________________________ > Classpath-patches mailing list > Classpath-patches@gnu.org > http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/plaf/metal/MetalFileChooserUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java,v retrieving revision 1.6 diff -u -r1.6 MetalFileChooserUI.java --- javax/swing/plaf/metal/MetalFileChooserUI.java 25 Nov 2005 21:58:39 -0000 1.6 +++ javax/swing/plaf/metal/MetalFileChooserUI.java 25 Nov 2005 22:54:03 -0000 @@ -45,7 +45,7 @@ import java.awt.GridLayout; import java.awt.Insets; import java.awt.LayoutManager; -import java.awt.Point; +import java.awt.Rectangle; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; @@ -63,6 +63,7 @@ import javax.swing.ButtonGroup; import javax.swing.ComboBoxModel; import javax.swing.DefaultListCellRenderer; +import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; @@ -647,8 +648,8 @@ /** The current file chooser. */ JFileChooser fc; - /** The index of the last file selected. */ - int lastSelected; + /** The last file selected. */ + Object lastSelected; /** The textfield used for editing. */ JTextField editField; @@ -663,7 +664,7 @@ this.list = list; editFile = null; fc = getFileChooser(); - lastSelected = -1; + lastSelected = null; } /** @@ -680,15 +681,16 @@ if ((!fc.isMultiSelectionEnabled() || (sf != null && sf.length <= 1)) && index >= 0 && editFile == null && list.isSelectedIndex(index)) { - if (lastSelected == index) + Object tmp = list.getModel().getElementAt(index); + if (lastSelected != null && lastSelected.equals(tmp)) editFile(index); - lastSelected = index; + lastSelected = tmp; } else if (editFile != null) { completeEditing(); editFile = null; - lastSelected = -1; + lastSelected = null; } } } @@ -705,20 +707,24 @@ editFile = (File) list.getModel().getElementAt(index); if (editFile.canWrite()) { - Point p = list.indexToLocation(index); + Rectangle bounds = list.getCellBounds(index, index); + Icon icon = getFileView(fc).getIcon(editFile); editField = new JTextField(editFile.getName()); - // FIXME: add action listener + // FIXME: add action listener for typing + // FIXME: painting for textfield is messed up when typing list.add(editField); editField.requestFocus(); - editField.selectAll(); - list.revalidate(); - list.repaint(); + editField.selectAll(); + + if (icon != null) + bounds.x += icon.getIconWidth() + 4; + editField.setBounds(bounds); } else { editField = null; editFile = null; - lastSelected = -1; + lastSelected = null; } }
_______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches