[sip-comm-dev] Using AWT's FileDialog instead of Swing's JFileChooser


#1

Hi Emil, Lubomir, all,

I bring back this thread to the light :slight_smile:

Archive: https://sip-communicator.dev.java.net/servlets/ReadMsg?list=dev&msgNo=7312

Therefore a patch that uses the AWT one on Mac only would be welcome.

Committed.
I've begun to use it in some places and I'm still working on it, but the main part is done.

We should probably think of a global SC chooser that others could also
use and that would hide the selection logic.

I've made a SipCommFileChooser (interface), which can be used with SipCommFileFilter-s.

Here is an example:
  
  SipCommFileChooser scfc = GenericFileDialog.create(null, "Send file...");
  File selectedFile = scfc.getFileFromDialog();
  
  if(selectedFile != null)
  {
          ConfigurationManager.setSendFileLastDir(selectedFile.getParent());
          messageWindow.getCurrentChatPanel().sendFile(selectedFile);
        }

In the call GenericFileDialog.create, I use OSUtils to determine if the user is running on Mac; if yes, an AWT
FileDialog insance is given back (JFileChooser for Windows & Linux else).
In this way, I try to hide the selection logic.

It's the same for filters. When creating a new file filter, you just will have to extend from SipCommFileFilter (abstract class),
and override 'public boolean accept(File f)', to determine if a file should be accepted by the filter.

I tested on Windows and Mac, eveything seems to be ok (even filters) for now. Every remark is welcome!
AIS, I'm still working on it, since JFileChooser and FileDialog work quite differently each other.

Regards,
Valentin