Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SWT Filedialog Open into home folder

I want to open a FileDialog window into the user home folder (i.e. /home/user or /Users/unsername)

I read the user home folder, using System.getProperty:

  String homefolder = System.getProperty(user.home);

And the variable containts the correct home folder. But when i set the filterpath in FileDialog, it opens (in linux) only the /home level not entering into the user home dir.

This is the source code:

  FileDialog dialog = new FileDialog(shell); 
  dialog.setText("Choose a certificate");
  String platform = SWT.getPlatform();
  String homefolder = System.getProperty("user.home");
  dialog.setFilterPath(homefolder);

Any idea? Here a screenshot: Swt FileDialog Problem

like image 561
Ivan Avatar asked Dec 02 '12 10:12

Ivan


1 Answers

Your code works perfectly with SWT 3.6.1. There is a bug report here stating that this was a problem in SWT versions <= 3.3 and was fixed in 3.4.

So, the solution would be to install a never version (ideally the current version).

Since you mentioned that you use a Maven repository, there is one for SWT 3.8 here:

maven project: SWT 3.5 dependency: any official public repo?

like image 53
Baz Avatar answered Oct 14 '22 23:10

Baz