Make it easy to override FileDescriptor in action handler

This commit is contained in:
Konstantin Bulenkov
2010-06-28 17:48:32 +04:00
parent d928d880fa
commit cc98c8f8b7
@@ -21,8 +21,6 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ui.AbstractTableCellEditor;
import com.intellij.util.ui.CellEditorComponentWithBrowseButton;
import javax.swing.*;
import java.awt.*;
@@ -45,12 +43,7 @@ public class LocalPathCellEditor extends AbstractTableCellEditor {
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, int column) {
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor d = new FileChooserDescriptor(false, true, false, true, false, false);
if (myTitle != null) {
d.setTitle(myTitle);
}
d.setShowFileSystemRoots(true);
final FileChooserDescriptor d = getFileChooserDescriptor();
VirtualFile initialFile = LocalFileSystem.getInstance().findFileByPath((String)getCellEditorValue());
VirtualFile[] files = FileChooser.chooseFiles(table, d, initialFile);
if (files.length == 1 && files[0] != null) {
@@ -66,4 +59,13 @@ public class LocalPathCellEditor extends AbstractTableCellEditor {
myComponent.getChildComponent().setText((String)value);
return myComponent;
}
public FileChooserDescriptor getFileChooserDescriptor() {
FileChooserDescriptor d = new FileChooserDescriptor(false, true, false, true, false, false);
if (myTitle != null) {
d.setTitle(myTitle);
}
d.setShowFileSystemRoots(true);
return d;
}
}