1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.desktoputil;
import java.awt.*;
import javax.swing.*;
import org.jitsi.util.*;
/**
* This class is the entry point for creating a file dialog regarding to the OS.
*
* If the current operating system is Apple Mac OS X, we create an AWT
* FileDialog (user interface is more practical under Mac OS than a
* JFileChooser), else, a Swing JFileChooser.
*
* @author Valentin Martinet
*/
public class GenericFileDialog
{
/**
* Creates a file dialog (AWT's FileDialog or Swing's JFileChooser)
* regarding to user's operating system.
*
* @param parent the parent Frame/JFrame of this dialog
* @param title dialog's title
* @param fileOperation
* @return a SipCommFileChooser instance
*/
public static SipCommFileChooser create(
Frame parent,
String title,
int fileOperation)
{
int operation;
if(OSUtils.IS_MAC)
{
switch (fileOperation)
{
case SipCommFileChooser.LOAD_FILE_OPERATION:
operation = FileDialog.LOAD;
break;
case SipCommFileChooser.SAVE_FILE_OPERATION:
operation = FileDialog.SAVE;
break;
default:
throw new IllegalArgumentException("fileOperation");
}
if (parent == null)
parent = new Frame();
return new SipCommFileDialogImpl(parent, title, operation);
}
else
{
switch (fileOperation)
{
case SipCommFileChooser.LOAD_FILE_OPERATION:
operation = JFileChooser.OPEN_DIALOG;
break;
case SipCommFileChooser.SAVE_FILE_OPERATION:
operation = JFileChooser.SAVE_DIALOG;
break;
default:
throw new IllegalArgumentException("fileOperation");
}
return new SipCommFileChooserImpl(title, operation);
}
}
/**
* Creates a file dialog (AWT FileDialog or Swing JFileChooser) regarding to
* user's operating system.
*
* @param parent the parent Frame/JFrame of this dialog
* @param title dialog's title
* @param fileOperation
* @param path start path of this dialog
* @return SipCommFileChooser an implementation of SipCommFileChooser
*/
public static SipCommFileChooser create(
Frame parent, String title, int fileOperation, String path)
{
SipCommFileChooser scfc
= GenericFileDialog.create(parent, title, fileOperation);
if(path != null)
scfc.setStartPath(path);
return scfc;
}
}
|