Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » FileChooser with default filename
FileChooser with default filename [message #870903] Thu, 10 May 2012 04:29 Go to next message
Alex Schroeder is currently offline Alex Schroeder
Messages: 38
Registered: February 2010
Location: Zürich, Switzerland
Member

This is what I want:

String filename = getExportPath() + sapFaufNr;
File[] file = new FileChooser(new File(filename), new String[]{"prd", "ddd"}, false).startChooser();


But FileChooser doesn't allow me to specify a default filename. In fact, if the File provided is not a directory, it is ignored. Right now I am forced to do the following:

String filename = getExportPath() + sapFaufNr; // ignore
File[] file = new FileChooser(new File(getExportPath()), new String[]{"prd", "ddd"}, false).startChooser();


Can this be added or is there some fundamental UI thought that went into this?
Re: FileChooser with default filename [message #870907 is a reply to message #870903] Thu, 10 May 2012 04:47 Go to previous messageGo to next message
Ivan Motsch is currently offline Ivan Motsch
Messages: 99
Registered: March 2010
Member
Did you try setting the filename?
The directory is the directory it starts browsing.
so do the following:

String folder = FileChooser.getCurrentDirectory();
String filename = "foo.prd";
FileChooser chooser=new FileChooser(folder, new String[]{"prd", "ddd"},false);
chooser.setFileName(filename);
File[] files = chooser.startChooser();
if(files.length>0){
  //convenience, remember the directory the user used for future accesses
  FileChooser.setCurrentDirectory(files[0].getParent());
  //use files[0]...
}
Re: FileChooser with default filename [message #870909 is a reply to message #870903] Thu, 10 May 2012 04:49 Go to previous messageGo to next message
Stephan Merkli is currently offline Stephan Merkli
Messages: 10
Registered: April 2012
Junior Member
Hi Alex

The way I use it:
FileChooser chooser = new FileChooser(null, new String[]{}, false);
chooser.setTypeLoad(false);
chooser.setFileName(getFileColumn().getSelectedValue());


The file chooser pops up and the filename is prefilled.
Re: FileChooser with default filename [message #870913 is a reply to message #870903] Thu, 10 May 2012 04:55 Go to previous message
Alex Schroeder is currently offline Alex Schroeder
Messages: 38
Registered: February 2010
Location: Zürich, Switzerland
Member

Thanks, all! That solved my problem. Smile
Previous Topic:Saving Form State to XML and Templates
Next Topic:Scout Client minimized to taskbar disappears when trying to reopen
Goto Forum:
  


Current Time: Wed Apr 16 03:28:15 EDT 2014

Powered by FUDForum. Page generated in 0.01844 seconds