use of org.jivesoftware.spark.util.WindowsFileSystemView in project Spark by igniterealtime.
the class FileTransferPreferencePanel method pickFile.
private void pickFile(String title, JTextField field) {
if (fc == null) {
fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (Spark.isWindows()) {
fc.setFileSystemView(new WindowsFileSystemView());
}
}
fc.setDialogTitle(title);
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
field.setText(file.getAbsolutePath());
}
}
use of org.jivesoftware.spark.util.WindowsFileSystemView in project Spark by igniterealtime.
the class Downloads method getFileChooser.
/**
* Returns a {@link JFileChooser} starting at the DownloadDirectory
*
* @return the filechooser
*/
public static JFileChooser getFileChooser() {
if (chooser == null) {
LocalPreferences _localPreferences = SettingsManager.getLocalPreferences();
downloadedDir = new File(_localPreferences.getDownloadDir());
chooser = new JFileChooser(downloadedDir);
if (Spark.isWindows()) {
chooser.setFileSystemView(new WindowsFileSystemView());
}
}
return chooser;
}
use of org.jivesoftware.spark.util.WindowsFileSystemView in project Spark by igniterealtime.
the class ThemePanel method addEmoticonPack.
/**
* Adds a new Emoticon pack to Spark.
*/
private void addEmoticonPack() {
if (fc == null) {
fc = new JFileChooser();
if (Spark.isWindows()) {
fc.setFileSystemView(new WindowsFileSystemView());
}
}
fc.setDialogTitle("Add Emoticon Pack");
fc.addChoosableFileFilter(new ZipFilter());
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File pack = fc.getSelectedFile();
try {
EmoticonManager emoticonManager = EmoticonManager.getInstance();
String name = emoticonManager.installPack(pack);
if (name == null) {
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
JOptionPane.showMessageDialog(this, "Not a valid emoticon pack.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
// If the name does not exists, add it to the message box.
for (int i = 0; i < emoticonBox.getItemCount(); i++) {
String n = emoticonBox.getItemAt(i);
if (name.equals(n)) {
return;
}
}
emoticonBox.addItem(name);
// Set Selected
emoticonBox.setSelectedItem(name);
} catch (Exception e) {
Log.error(e);
}
}
}
Aggregations