Search in sources :

Example 1 with EmoticonManager

use of org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager in project Spark by igniterealtime.

the class ThemePanel method showSelectedEmoticon.

/**
 * Displays the active emoticon pack.
 */
protected void showSelectedEmoticon() {
    EmoticonManager emoticonManager = EmoticonManager.getInstance();
    int i = emoticonManager.getActiveEmoticonSet().size();
    if (i == 0) {
        emoticonspanel = new EmoticonPanel(1);
        JLabel label = new JLabel(SparkRes.getImageIcon(SparkRes.SMALL_DELETE));
        emoticonspanel.add(label);
    } else if (i < 25) {
        emoticonspanel = new EmoticonPanel(i);
    } else {
        emoticonspanel = new EmoticonPanel(10);
    }
    for (Emoticon emoticon : emoticonManager.getActiveEmoticonSet()) {
        ImageIcon ico = new ImageIcon(emoticonManager.getEmoticonURL(emoticon));
        JLabel label = new JLabel(ico);
        emoticonspanel.add(label);
    }
    int rows = Math.min(((EmoticonPanel) emoticonspanel).getNumRows() * 45, 300);
    emoticonscrollpane.setPreferredSize(new Dimension(300, rows));
    emoticonscrollpane.setViewportView(emoticonspanel);
    this.revalidate();
}
Also used : Emoticon(org.jivesoftware.sparkimpl.plugin.emoticons.Emoticon) EmoticonManager(org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager)

Example 2 with EmoticonManager

use of org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager in project Spark by igniterealtime.

the class ButtonFactory method createEmoticonButton.

public RolloverButton createEmoticonButton() {
    final EmoticonManager emoticonManager = EmoticonManager.getInstance();
    final String activeEmoticonSetName = emoticonManager.getActiveEmoticonSetName();
    final Emoticon smileEmoticon = emoticonManager.getEmoticon(activeEmoticonSetName, ":)");
    Emoticon firstEmoticon = (smileEmoticon == null) ? emoticonManager.getFirstEmotion(activeEmoticonSetName) : smileEmoticon;
    URL emotionURL = emoticonManager.getEmoticonURL(firstEmoticon);
    ImageIcon icon = new ImageIcon(emotionURL);
    return new RolloverButton(icon);
}
Also used : Emoticon(org.jivesoftware.sparkimpl.plugin.emoticons.Emoticon) ImageIcon(javax.swing.ImageIcon) EmoticonManager(org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager) RolloverButton(org.jivesoftware.spark.component.RolloverButton) URL(java.net.URL)

Example 3 with EmoticonManager

use of org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager in project Spark by igniterealtime.

the class ThemePanel method buildUI.

/**
 * Builds the UI.
 */
private void buildUI() {
    // Add Viewer
    // add(new JScrollPane(transcript), new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    add(emoticonscrollpane, new GridBagConstraints(0, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    add(emoticonBox, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    add(addEmoticonButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(emoticonCheckBox, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    // todo : k33ptoo: not necessary until dark LAF is completed
    // add( _lookandfeelLabel, new GridBagConstraints( 0, 4, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets( 5, 5, 5, 5 ), 50, 0 ) );
    // add( _lookandfeel, new GridBagConstraints( 1, 4, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( 5, 5, 5, 5 ), 50, 0 ) );
    // add( _lookandfeelpreview, new GridBagConstraints( 2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets( 5, 5, 5, 5 ), 0, 0 ) );
    add(chatRoomFontLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(chatRoomFontField, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    add(contactListFontLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(contactListFontField, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    add(maxCurrentHistorySizeLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(maxCurrentHistorySizeField, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    add(showAvatarsBox, new GridBagConstraints(0, 8, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(avatarSizeLabel, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(avatarSizeField, new GridBagConstraints(1, 9, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    add(showVCards, new GridBagConstraints(0, 10, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    add(disableGrayingIdleContacts, new GridBagConstraints(0, 11, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    add(_useTabsForTransports, new GridBagConstraints(0, 12, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    add(_useTabsForConference, new GridBagConstraints(0, 13, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    JLabel reconnectionlabel = new JLabel(Res.getString("checkbox.reconnect.info"));
    add(reconnectionlabel, new GridBagConstraints(0, 14, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
    add(_showReconnectBox, new GridBagConstraints(1, 14, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 50, 0));
    // Activate live one.
    _useTabsForTransports.setSelected(pref.getShowTransportTab());
    _useTabsForTransports.addActionListener(e -> SettingsManager.getLocalPreferences().setShowTransportTab(_useTabsForTransports.isSelected()));
    _useTabsForConference.setSelected(pref.isShowConferenceTab());
    _useTabsForConference.addActionListener(e -> SettingsManager.getLocalPreferences().setShowConferenceTab(_useTabsForConference.isSelected()));
    _useTabsForConference.setSelected(pref.isShowConferenceTab());
    _useTabsForConference.addActionListener(e -> SettingsManager.getLocalPreferences().setShowConferenceTab(_useTabsForConference.isSelected()));
    final EmoticonManager emoticonManager = EmoticonManager.getInstance();
    if (emoticonManager.getEmoticonPacks() != null) {
        for (String pack : emoticonManager.getEmoticonPacks()) {
            emoticonBox.addItem(pack);
        }
    }
    final String activePack = pref.getEmoticonPack();
    emoticonBox.setSelectedItem(activePack);
    emoticonBox.addActionListener(e -> {
        emoticonManager.addEmoticonPack((String) emoticonBox.getSelectedItem());
        emoticonManager.setActivePack((String) emoticonBox.getSelectedItem());
        showSelectedEmoticon();
    });
    addEmoticonButton.addActionListener(e -> addEmoticonPack());
    showSelectedEmoticon();
    emoticonCheckBox.setSelected(pref.areEmoticonsEnabled());
    final String className = pref.getLookAndFeel();
    final String name = LookAndFeelManager.getName(className);
    _lookandfeel.setSelectedItem("SparkLighLaf");
    showVCards.setSelected(pref.areVCardsVisible());
    showAvatarsBox.setSelected(pref.areAvatarsVisible());
    disableGrayingIdleContacts.setSelected(pref.isGrayingOutEnabled());
    if (pref.getContactListIconSize() == 16) {
        avatarSizeField.setSelectedIndex(0);
    } else if (pref.getContactListIconSize() == 24) {
        avatarSizeField.setSelectedIndex(1);
    } else if (pref.getContactListIconSize() == 32) {
        avatarSizeField.setSelectedIndex(2);
    } else {
        avatarSizeField.setSelectedIndex(1);
    }
    try {
        int chatRoomFontSize = pref.getChatRoomFontSize();
        int contactListFontSize = pref.getContactListFontSize();
        int maxCurrentHistorySize = pref.getMaxCurrentHistorySize();
        chatRoomFontField.setText(Integer.toString(chatRoomFontSize));
        contactListFontField.setText(Integer.toString(contactListFontSize));
        maxCurrentHistorySizeField.setText(Integer.toString(maxCurrentHistorySize));
    } catch (Exception e) {
        Log.error(e);
    }
}
Also used : EmoticonManager(org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager)

Example 4 with EmoticonManager

use of org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager 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

EmoticonManager (org.jivesoftware.sparkimpl.plugin.emoticons.EmoticonManager)4 Emoticon (org.jivesoftware.sparkimpl.plugin.emoticons.Emoticon)2 File (java.io.File)1 URL (java.net.URL)1 ImageIcon (javax.swing.ImageIcon)1 RolloverButton (org.jivesoftware.spark.component.RolloverButton)1 WindowsFileSystemView (org.jivesoftware.spark.util.WindowsFileSystemView)1