Search in sources :

Example 1 with WindowsFileSystemView

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());
    }
}
Also used : WindowsFileSystemView(org.jivesoftware.spark.util.WindowsFileSystemView) File(java.io.File)

Example 2 with WindowsFileSystemView

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;
}
Also used : JFileChooser(javax.swing.JFileChooser) WindowsFileSystemView(org.jivesoftware.spark.util.WindowsFileSystemView) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) File(java.io.File)

Example 3 with WindowsFileSystemView

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);
        }
    }
}
Also used : EmoticonManager(org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager) WindowsFileSystemView(org.jivesoftware.spark.util.WindowsFileSystemView) File(java.io.File)

Aggregations

File (java.io.File)3 WindowsFileSystemView (org.jivesoftware.spark.util.WindowsFileSystemView)3 JFileChooser (javax.swing.JFileChooser)1 EmoticonManager (org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager)1 LocalPreferences (org.jivesoftware.sparkimpl.settings.local.LocalPreferences)1