Search in sources :

Example 11 with RolloverButton

use of org.jivesoftware.spark.component.RolloverButton in project Spark by igniterealtime.

the class BroadcastPlugin method initialize.

@Override
public void initialize() {
    // See if we should disable all "Broadcast" menu items
    if (Default.getBoolean(Default.DISABLE_BROADCAST_MENU_ITEM) || !Enterprise.containsFeature(Enterprise.BROADCAST_FEATURE)) {
        return;
    }
    // Add as ContainerDecoratr
    SparkManager.getChatManager().addSparkTabHandler(this);
    StanzaFilter serverFilter = new StanzaTypeFilter(Message.class);
    SparkManager.getConnection().addAsyncStanzaListener(this, serverFilter);
    // Register with action menu
    final JMenu actionsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions"));
    JMenuItem broadcastHistoryMenu = new JMenuItem(Res.getString("title.broadcast.history"), SparkRes.getImageIcon(SparkRes.HISTORY_16x16));
    JMenuItem broadcastMenu = new JMenuItem(Res.getString("title.broadcast.message"), SparkRes.getImageIcon(SparkRes.MEGAPHONE_16x16));
    ResourceUtils.resButton(broadcastMenu, Res.getString("title.broadcast.message"));
    actionsMenu.add(broadcastHistoryMenu);
    actionsMenu.add(broadcastMenu);
    broadcastMenu.addActionListener(e -> broadcastToRoster());
    broadcastHistoryMenu.addActionListener(e -> new BroadcastHistoryFrame().run());
    // Register with action menu
    JMenuItem startConversationtMenu = new JMenuItem("", SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE));
    ResourceUtils.resButton(startConversationtMenu, Res.getString("menuitem.start.a.chat"));
    if (!Default.getBoolean(Default.HIDE_START_A_CHAT) && Enterprise.containsFeature(Enterprise.START_A_CHAT_FEATURE)) {
        actionsMenu.add(startConversationtMenu, 0);
    }
    startConversationtMenu.addActionListener(e -> {
        ContactList contactList = SparkManager.getWorkspace().getContactList();
        Collection<ContactItem> selectedUsers = contactList.getSelectedUsers();
        String selectedUser = "";
        Iterator<ContactItem> selectedUsersIterator = selectedUsers.iterator();
        if (selectedUsersIterator.hasNext()) {
            ContactItem contactItem = selectedUsersIterator.next();
            selectedUser = contactItem.getJid().toString();
        }
        UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
        UIManager.put("OptionPane.cancelButtonText", Res.getString("cancel"));
        String jid = (String) JOptionPane.showInputDialog(SparkManager.getMainWindow(), Res.getString("label.enter.address"), Res.getString("title.start.chat"), JOptionPane.QUESTION_MESSAGE, null, null, selectedUser);
        if (ModelUtil.hasLength(jid) && ModelUtil.hasLength(XmppStringUtils.parseDomain(jid))) {
            if (ModelUtil.hasLength(jid) && jid.indexOf('@') == -1) {
                // Append server address
                jid = jid + "@" + SparkManager.getConnection().getXMPPServiceDomain();
            }
            EntityBareJid entityBareJid = JidCreate.entityBareFromUnescapedOrThrowUnchecked(jid);
            String nickname = SparkManager.getUserManager().getUserNicknameFromJID(entityBareJid);
            ChatRoom chatRoom = SparkManager.getChatManager().createChatRoom(entityBareJid, nickname, nickname);
            SparkManager.getChatManager().getChatContainer().activateChatRoom(chatRoom);
        }
    });
    // Add send to selected users.
    final ContactList contactList = SparkManager.getWorkspace().getContactList();
    contactList.addContextMenuListener(new ContextMenuListener() {

        @Override
        public void poppingUp(Object component, JPopupMenu popup) {
            if (component instanceof ContactGroup) {
                final ContactGroup group = (ContactGroup) component;
                Action broadcastMessageAction = new AbstractAction() {

                    private static final long serialVersionUID = -6411248110270296726L;

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        broadcastToGroup(group);
                    }
                };
                broadcastMessageAction.putValue(Action.NAME, Res.getString("menuitem.broadcast.to.group"));
                broadcastMessageAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.MEGAPHONE_16x16));
                popup.add(broadcastMessageAction);
            }
        }

        @Override
        public void poppingDown(JPopupMenu popup) {
        }

        @Override
        public boolean handleDefaultAction(MouseEvent e) {
            return false;
        }
    });
    // Add Broadcast to roster
    StatusBar statusBar = SparkManager.getWorkspace().getStatusBar();
    RolloverButton broadcastToRosterButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.MEGAPHONE_16x16));
    broadcastToRosterButton.setToolTipText(Res.getString("message.send.a.broadcast"));
    statusBar.invalidate();
    statusBar.validate();
    statusBar.repaint();
    broadcastToRosterButton.addActionListener(e -> broadcastToRoster());
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) StanzaFilter(org.jivesoftware.smack.filter.StanzaFilter) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) ContactItem(org.jivesoftware.spark.ui.ContactItem) ContextMenuListener(org.jivesoftware.spark.plugin.ContextMenuListener) ContactList(org.jivesoftware.spark.ui.ContactList) StatusBar(org.jivesoftware.spark.ui.status.StatusBar) RolloverButton(org.jivesoftware.spark.component.RolloverButton) JPopupMenu(javax.swing.JPopupMenu) StanzaTypeFilter(org.jivesoftware.smack.filter.StanzaTypeFilter) ChatRoom(org.jivesoftware.spark.ui.ChatRoom) JMenuItem(javax.swing.JMenuItem) BroadcastHistoryFrame(org.jivesoftware.spark.ui.BroadcastHistoryFrame) ContactGroup(org.jivesoftware.spark.ui.ContactGroup) EntityBareJid(org.jxmpp.jid.EntityBareJid) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu)

Example 12 with RolloverButton

use of org.jivesoftware.spark.component.RolloverButton in project Spark by igniterealtime.

the class EmoticonPlugin method chatRoomOpened.

@Override
public void chatRoomOpened(final ChatRoom room) {
    // Check to see if emoticons are enabled.
    if (!SettingsManager.getLocalPreferences().areEmoticonsEnabled()) {
        return;
    }
    // final String activeEmoticonSetName =
    // emoticonManager.getActiveEmoticonSetName();
    emoticonManager = EmoticonManager.getInstance();
    Collection<String> emoticonPacks;
    emoticonPacks = emoticonManager.getEmoticonPacks();
    if (emoticonPacks != null) {
        // Add Emoticon button
        final RolloverButton emoticonPicker = UIComponentRegistry.getButtonFactory().createEmoticonButton();
        room.addEditorComponent(emoticonPicker);
        emoticonPicker.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                // Show popup
                final JPopupMenu popup = new JPopupMenu();
                EmoticonUI emoticonUI = new EmoticonUI();
                emoticonUI.setEmoticonPickListener(emoticon -> {
                    try {
                        popup.setVisible(false);
                        final ChatInputEditor editor = room.getChatInputEditor();
                        String currentText = editor.getText();
                        if (currentText.length() == 0 || currentText.endsWith(" ")) {
                            room.getChatInputEditor().insertText(emoticon + " ");
                        } else {
                            room.getChatInputEditor().insertText(" " + emoticon + " ");
                        }
                        room.getChatInputEditor().requestFocus();
                    } catch (BadLocationException e1) {
                        Log.error(e1);
                    }
                });
                popup.add(emoticonUI);
                popup.show(emoticonPicker, e.getX(), e.getY());
            }
        });
        room.addClosingListener(() -> room.removeEditorComponent(emoticonPicker));
    }
}
Also used : ChatManager(org.jivesoftware.spark.ChatManager) Collection(java.util.Collection) JPopupMenu(javax.swing.JPopupMenu) SettingsManager(org.jivesoftware.sparkimpl.settings.local.SettingsManager) ChatRoom(org.jivesoftware.spark.ui.ChatRoom) UIComponentRegistry(org.jivesoftware.spark.util.UIComponentRegistry) BadLocationException(javax.swing.text.BadLocationException) Log(org.jivesoftware.spark.util.log.Log) Plugin(org.jivesoftware.spark.plugin.Plugin) MouseEvent(java.awt.event.MouseEvent) ThemePreference(org.jivesoftware.spark.ui.themes.ThemePreference) SparkManager(org.jivesoftware.spark.SparkManager) MouseAdapter(java.awt.event.MouseAdapter) ChatInputEditor(org.jivesoftware.spark.ui.ChatInputEditor) RolloverButton(org.jivesoftware.spark.component.RolloverButton) ChatRoomListener(org.jivesoftware.spark.ui.ChatRoomListener) ChatInputEditor(org.jivesoftware.spark.ui.ChatInputEditor) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) RolloverButton(org.jivesoftware.spark.component.RolloverButton) JPopupMenu(javax.swing.JPopupMenu) BadLocationException(javax.swing.text.BadLocationException)

Example 13 with RolloverButton

use of org.jivesoftware.spark.component.RolloverButton in project Spark by igniterealtime.

the class CoBrowser method tabSelected.

public void tabSelected() {
    goButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.PUSH_URL_16x16));
    pushCurrentPageButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.DOWNLOAD_16x16));
    followMeButton = new JCheckBox(FpRes.getString("checkbox.allow.user.to.follow"), false);
    followMeButton.setToolTipText(GraphicUtils.createToolTip(PUBLIC_TOOLTIP));
    followMeButton.addActionListener(this);
    final JPanel mainPanel = new JPanel();
    browser = BrowserFactory.getBrowser();
    browser.addBrowserListener(this);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(browser, BorderLayout.CENTER);
    urlField = new JTextField();
    setLayout(new GridBagLayout());
    backButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.SMALL_PIN_BLUE));
    backButton.setText(FpRes.getString("back"));
    backButton.setToolTipText(GraphicUtils.createToolTip(FpRes.getString("tooltip.back.one.page")));
    goButton.setToolTipText(GraphicUtils.createToolTip(FpRes.getString("tooltip.push.url")));
    goButton.setText(FpRes.getString("go"));
    pushCurrentPageButton.setToolTipText(GraphicUtils.createToolTip(FpRes.getString("tooltip.push.current.page")));
    pushCurrentPageButton.setText(FpRes.getString("button.start.cobrowsing.session"));
    load(getStartLocation());
    buildUI();
    add(mainPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    urlField.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ENTER) {
                showSpecifiedPage();
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }
    });
    followMeButton.setOpaque(false);
}
Also used : JCheckBox(javax.swing.JCheckBox) KeyEvent(java.awt.event.KeyEvent) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) BorderLayout(java.awt.BorderLayout) GridBagLayout(java.awt.GridBagLayout) KeyListener(java.awt.event.KeyListener) JTextField(javax.swing.JTextField) RolloverButton(org.jivesoftware.spark.component.RolloverButton)

Example 14 with RolloverButton

use of org.jivesoftware.spark.component.RolloverButton in project Spark by igniterealtime.

the class ButtonFactory method createTemaButton.

public RolloverButton createTemaButton() {
    RolloverButton thema = new RolloverButton(SparkRes.getImageIcon(SparkRes.TYPING_TRAY));
    thema.setToolTipText(Res.getString("menuitem.change.subject"));
    return thema;
}
Also used : RolloverButton(org.jivesoftware.spark.component.RolloverButton)

Example 15 with RolloverButton

use of org.jivesoftware.spark.component.RolloverButton 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)

Aggregations

RolloverButton (org.jivesoftware.spark.component.RolloverButton)25 JPanel (javax.swing.JPanel)12 GridBagConstraints (java.awt.GridBagConstraints)11 GridBagLayout (java.awt.GridBagLayout)11 Insets (java.awt.Insets)11 Font (java.awt.Font)7 Color (java.awt.Color)6 JLabel (javax.swing.JLabel)6 BorderLayout (java.awt.BorderLayout)4 JScrollPane (javax.swing.JScrollPane)4 SmackException (org.jivesoftware.smack.SmackException)4 XMPPException (org.jivesoftware.smack.XMPPException)4 FlowLayout (java.awt.FlowLayout)3 ActionEvent (java.awt.event.ActionEvent)3 JTextField (javax.swing.JTextField)3 Dimension (java.awt.Dimension)2 ActionListener (java.awt.event.ActionListener)2 KeyEvent (java.awt.event.KeyEvent)2 MouseEvent (java.awt.event.MouseEvent)2 Collection (java.util.Collection)2