Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » GTK: FileDialog to select multiple files from the "Recent" tab AND get their full paths?
GTK: FileDialog to select multiple files from the "Recent" tab AND get their full paths? [message #1861906] Sun, 12 November 2023 12:32 Go to next message
Jonathan Blacksmith is currently offline Jonathan BlacksmithFriend
Messages: 2
Registered: November 2023
Junior Member
I am trying to use FileDialog to select multiple files. I have noticed that the file names you retrieve with FileDialog::getFileNames() have no path. So I tried to combine them with FileDialog:getFilterPath, which returns a single string. However, in the "Recent" tab, each file has a different path! Is FileDialog not made with this in mind? How to proceed?

Here is code so that you can see it for yourself quickly:

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;

public class FileDialogRecentTest {

	public static void main (String [] args) {
		Display display = new Display ();
		Shell shell = new Shell (display);
		shell.setText("FileDialogRecentTest");
		shell.open ();

		// Trying to get full paths from GTK's "Recent" tab, in which all files have different directories
		FileDialog dialog = new FileDialog (shell, SWT.OPEN | SWT.MULTI);
		dialog.open();
		String[] fileNames = dialog.getFileNames();

		// But .getFilterPath() only returns the first selected file's path! It's the same for all files!
		String directory = dialog.getFilterPath();

		// Print full paths of all files
		for (String fileName : fileNames)
			System.out.println(directory + '/' + fileName);

		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}
}
Re: GTK: FileDialog to select multiple files from the "Recent" tab AND get their full path [message #1862086] Sun, 12 November 2023 21:10 Go to previous messageGo to next message
Eclipse UserFriend
555
Re: GTK: FileDialog to select multiple files from the "Recent" tab AND get their full path [message #1862473 is a reply to message #1861906] Wed, 06 December 2023 21:58 Go to previous message
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
Your code works as intended on Windows.
It's Linux problem. I gave up Linux SWT for all sort of problems.
Previous Topic:SWT table is not automatically adding "..." to columns in GTK
Next Topic:Make swt easier, welcome to join us
Goto Forum:
  


Current Time: Mon May 06 16:29:15 GMT 2024

Powered by FUDForum. Page generated in 0.02763 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top