|
From: John W. <jo...@wa...> - 2004-05-02 18:19:09
|
Slava Pestov wrote:
>On Wed, Apr 28, 2004 at 06:42:44PM +0000, Michael Wexler wrote:
>
>
>>2) replace this box with a windows native file open which does do all of these
>>things?
>>
>>
>You can write a macro that calls the Swing file chooser API, and bind it
>to C+o. It is still not the native file chooser -- but in Java 1.4.2 and
>up Swing emulates the Windows chooser pretty closely.
>
>
>
I did this a while back. Here are the macros, if you're interested.
Set the Swing Look & Feel in the Appearance panel of global options to
get a file chooser that looks like the Windows file chooser. I found
that it is enough NOT like the native chooser to be annoying
(particularly in the behavior of entering partial filenames on the
filename input box and pressing enter) and stopped using it quickly. It
also doesn't do the sorting you want, but there you go. ;-)
Open_file.bsh:
==============
// store path in this property variable
String PROP = "macro.jdw.open_file.path";
// get last path used
String path = jEdit.getProperty(PROP);
JFileChooser jfc = new JFileChooser(path);
int returnVal = jfc.showOpenDialog(view);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = jfc.getSelectedFile();
if(file.getPath() != null) {
// store last path used
jEdit.setProperty(PROP, file.getPath());
jEdit.openFile(view, file.getPath());
}
}
Save_file.bsh:
==============
// store path in this property variable
String PROP = "macro.jdw.open_file.path";
// get last path used
String path = jEdit.getProperty(PROP);
if (buffer.isNewFile()) {
JFileChooser jfc = new JFileChooser(path);
int returnVal = jfc.showSaveDialog(view);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = jfc.getSelectedFile();
if (file.getPath() != null) {
// store last path used
//jEdit.setProperty(PROP, file.getPath());
buffer.save(view, file.getPath());
}
}
} else {
buffer.save(view, buffer.getPath());
}
|