Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » FileDialog Extension Filter does not work ?!
FileDialog Extension Filter does not work ?! [message #444574] Fri, 15 October 2004 10:13 Go to next message
Rene is currently offline ReneFriend
Messages: 80
Registered: July 2009
Member
Hello
I have tried to to set the filter extension in my SaveDialog to xml files.
But the FileDialog doesn't show any file in the Directory!??
Another question, is it possible to define a default extension. For example:
When the user write "myfile", I want to store this as "myfile.xml".

Here is the Codesnippet:

FileDialog dialog = new FileDialog(this.getSite().getShell(), SWT.SAVE);
dialog.setText("Save as...");
dialog.setFilterNames(new String[]{"xml"});
dialog.setFilterExtensions(new String[]{"xml"});
String path = dialog.open();


Thanks in advance!
-Rene-
Re: FileDialog Extension Filter does not work ?! [message #444577 is a reply to message #444574] Fri, 15 October 2004 13:26 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Rene,

Your filter extension string should be "*.xml", not just "xml". This should
explain why all of your files are being filtered out; if this change does
not make some or all of them reappear then please log a bug report with
Platform - SWT.

There is no way to set a default extension into a FileDialog, but since the
dialog just returns to you whatever the user entered, you can just detect
the case where no extension was specified and add it on yourself afterwards,
no?

Grant

"Teichgraf" <teichgraf@gmx.de> wrote in message
news:cko7hu$mgt$1@eclipse.org...
> Hello
> I have tried to to set the filter extension in my SaveDialog to xml files.
> But the FileDialog doesn't show any file in the Directory!??
> Another question, is it possible to define a default extension. For
example:
> When the user write "myfile", I want to store this as "myfile.xml".
>
> Here is the Codesnippet:
>
> FileDialog dialog = new FileDialog(this.getSite().getShell(), SWT.SAVE);
> dialog.setText("Save as...");
> dialog.setFilterNames(new String[]{"xml"});
> dialog.setFilterExtensions(new String[]{"xml"});
> String path = dialog.open();
>
>
> Thanks in advance!
> -Rene-
>
>
Re: FileDialog Extension Filter does not work ?! [message #444629 is a reply to message #444577] Mon, 18 October 2004 08:43 Go to previous message
Rene is currently offline ReneFriend
Messages: 80
Registered: July 2009
Member
Blame on me!! ;-)

It have to be *.xml!!! Thanks for your Tipp!
And if no extension is entered, the FileDialog uses xml. I don't have to set
the default manually.
I think I am a bit too much Microsoft (MFC, .Net WinForms) misguided. ;-)

"Grant Gayed" <grant_gayed@ca.ibm.com> schrieb im Newsbeitrag
news:ckois3$dsa$1@eclipse.org...
> Rene,
>
> Your filter extension string should be "*.xml", not just "xml". This
> should
> explain why all of your files are being filtered out; if this change does
> not make some or all of them reappear then please log a bug report with
> Platform - SWT.
>
> There is no way to set a default extension into a FileDialog, but since
> the
> dialog just returns to you whatever the user entered, you can just detect
> the case where no extension was specified and add it on yourself
> afterwards,
> no?
>
> Grant
>
> "Teichgraf" <teichgraf@gmx.de> wrote in message
> news:cko7hu$mgt$1@eclipse.org...
>> Hello
>> I have tried to to set the filter extension in my SaveDialog to xml
>> files.
>> But the FileDialog doesn't show any file in the Directory!??
>> Another question, is it possible to define a default extension. For
> example:
>> When the user write "myfile", I want to store this as "myfile.xml".
>>
>> Here is the Codesnippet:
>>
>> FileDialog dialog = new FileDialog(this.getSite().getShell(), SWT.SAVE);
>> dialog.setText("Save as...");
>> dialog.setFilterNames(new String[]{"xml"});
>> dialog.setFilterExtensions(new String[]{"xml"});
>> String path = dialog.open();
>>
>>
>> Thanks in advance!
>> -Rene-
>>
>>
>
>
Previous Topic:Re: Watermark
Next Topic:Editor closing/background
Goto Forum:
  


Current Time: Tue Apr 16 09:43:52 GMT 2024

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

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

Back to the top