Search in sources :

Example 6 with ContactList

use of org.jivesoftware.spark.ui.ContactList in project Spark by igniterealtime.

the class UserManager method searchContacts.

public void searchContacts(String contact, final JFrame parent) {
    if (parents.get(parent) == null && parent.getGlassPane() != null) {
        parents.put(parent, parent.getGlassPane());
    }
    // Make sure we are using the default glass pane
    final Component glassPane = parents.get(parent);
    parent.setGlassPane(glassPane);
    final Map<String, ContactItem> contactMap = new HashMap<>();
    final List<ContactItem> contacts = new ArrayList<>();
    final ContactList contactList = SparkManager.getWorkspace().getContactList();
    for (ContactGroup contactGroup : contactList.getContactGroups()) {
        contactGroup.clearSelection();
        for (ContactItem contactItem : contactGroup.getContactItems()) {
            if (!contactMap.containsKey(contactItem.getJID())) {
                contacts.add(contactItem);
                contactMap.put(contactItem.getJID(), contactItem);
            }
        }
    }
    // Sort
    Collections.sort(contacts, itemComparator);
    final JContactItemField contactField = new JContactItemField(new ArrayList<>(contacts));
    JPanel layoutPanel = new JPanel();
    layoutPanel.setLayout(new GridBagLayout());
    JLabel enterLabel = new JLabel(Res.getString("label.contact.to.find"));
    enterLabel.setFont(new Font("dialog", Font.BOLD, 10));
    layoutPanel.add(enterLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
    layoutPanel.add(contactField, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
    layoutPanel.setBorder(BorderFactory.createBevelBorder(0));
    contactField.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent keyEvent) {
            if (keyEvent.getKeyChar() == KeyEvent.VK_ENTER) {
                if (ModelUtil.hasLength(contactField.getText())) {
                    ContactItem item = contactMap.get(contactField.getText());
                    if (item == null) {
                        item = contactField.getSelectedContactItem();
                    }
                    if (item != null) {
                        parent.setGlassPane(glassPane);
                        parent.getGlassPane().setVisible(false);
                        contactField.dispose();
                        SparkManager.getChatManager().activateChat(item.getJID(), item.getDisplayName());
                    }
                }
            } else if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) {
                parent.setGlassPane(glassPane);
                parent.getGlassPane().setVisible(false);
                contactField.dispose();
            }
        }
    });
    contactField.getList().addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                contactField.setSelectetIndex(e);
                ContactItem item = contactField.getSelectedContactItem();
                MouseEvent exx = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), e.getX() + 20, e.getY(), e.getClickCount(), false);
                SparkManager.getContactList().setSelectedUser(item.getJID());
                SparkManager.getContactList().showPopup(contactField.getPopup(), exx, item);
            }
            if (e.getClickCount() == 2) {
                if (ModelUtil.hasLength(contactField.getText())) {
                    ContactItem item = contactMap.get(contactField.getText());
                    if (item == null) {
                        item = contactField.getSelectedContactItem();
                    }
                    if (item != null) {
                        parent.setGlassPane(glassPane);
                        parent.getGlassPane().setVisible(false);
                        contactField.dispose();
                        SparkManager.getChatManager().activateChat(item.getJID(), item.getDisplayName());
                    }
                }
            }
        }
    });
    final JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setLayout(new GridBagLayout());
    mainPanel.add(layoutPanel, new GridBagConstraints(0, 0, 1, 1, 0.5, 0.5, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(SparkManager.getMainWindow().getTopToolBar().getHeight() + SparkManager.getWorkspace().getStatusBar().getHeight() + 47, 1, 5, 1), 200, 0));
    mainPanel.setOpaque(false);
    contactField.setText(contact);
    parent.setGlassPane(mainPanel);
    parent.getGlassPane().setVisible(true);
    contactField.focus();
    mainPanel.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent mouseEvent) {
            parent.setGlassPane(glassPane);
            parent.getGlassPane().setVisible(false);
            contactField.dispose();
        }
    });
    parent.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent windowEvent) {
            parent.setGlassPane(glassPane);
            parent.getGlassPane().setVisible(false);
            contactField.dispose();
            parent.removeWindowListener(this);
        }

        public void windowDeactivated(final WindowEvent windowEvent) {
            TimerTask task = new SwingTimerTask() {

                public void doRun() {
                    if (contactField.canClose()) {
                        windowClosing(windowEvent);
                    }
                }
            };
            TaskEngine.getInstance().schedule(task, 250);
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) HashMap(java.util.HashMap) KeyAdapter(java.awt.event.KeyAdapter) ArrayList(java.util.ArrayList) WindowAdapter(java.awt.event.WindowAdapter) Font(java.awt.Font) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) TimerTask(java.util.TimerTask) SwingTimerTask(org.jivesoftware.spark.util.SwingTimerTask) JContactItemField(org.jivesoftware.spark.component.JContactItemField) Component(java.awt.Component) MouseEvent(java.awt.event.MouseEvent) ContactItem(org.jivesoftware.spark.ui.ContactItem) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) ContactList(org.jivesoftware.spark.ui.ContactList) SwingTimerTask(org.jivesoftware.spark.util.SwingTimerTask) WindowEvent(java.awt.event.WindowEvent) ContactGroup(org.jivesoftware.spark.ui.ContactGroup)

Example 7 with ContactList

use of org.jivesoftware.spark.ui.ContactList in project Spark by igniterealtime.

the class ReceiveFileTransfer method acceptRequest.

private void acceptRequest(final FileTransferRequest request) {
    String requestor = request.getRequestor();
    String bareJID = XmppStringUtils.parseBareJid(requestor);
    ContactList contactList = SparkManager.getWorkspace().getContactList();
    final ContactItem contactItem = contactList.getContactItemByJID(bareJID);
    setBackground(new Color(239, 245, 250));
    acceptButton.setVisible(false);
    declineButton.setVisible(false);
    titleLabel.setText(Res.getString("message.negotiate.file.transfer"));
    titleLabel.setForeground(new Color(65, 139, 179));
    add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0));
    add(progressLabel, new GridBagConstraints(1, 3, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0));
    add(cancelButton, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
    cancelButton.setVisible(true);
    transfer = request.accept();
    final File downloadedFile = new File(Downloads.getDownloadDirectory(), request.getFileName());
    try {
        _starttime = System.currentTimeMillis();
        transfer.recieveFile(downloadedFile);
    } catch (SmackException | IOException e) {
        Log.error(e);
    }
    // setting it to percent
    progressBar.setMaximum(100);
    progressBar.setStringPainted(true);
    final Timer timer = new Timer();
    TimerTask updateProgessBar = new TimerTask() {

        @Override
        public void run() {
            if (transfer.getAmountWritten() >= request.getFileSize() || transfer.getStatus() == FileTransfer.Status.error || transfer.getStatus() == FileTransfer.Status.refused || transfer.getStatus() == FileTransfer.Status.cancelled || transfer.getStatus() == FileTransfer.Status.complete) {
                this.cancel();
                timer.cancel();
                _endtime = System.currentTimeMillis();
                updateonFinished(request, downloadedFile);
            } else {
                // 100 % = Filesize
                // x %   = Currentsize
                long p = (transfer.getAmountWritten() * 100 / transfer.getFileSize());
                progressBar.setValue(Math.round(p));
            }
        }
    };
    final Timer timer2 = new Timer();
    TimerTask updatePrograssBarText = new TimerTask() {

        long timenow;

        long timeearlier;

        long bytesnow;

        long bytesearlier;

        @Override
        public void run() {
            if (transfer.getAmountWritten() >= request.getFileSize() || transfer.getStatus() == FileTransfer.Status.error || transfer.getStatus() == FileTransfer.Status.refused || transfer.getStatus() == FileTransfer.Status.cancelled || transfer.getStatus() == FileTransfer.Status.complete) {
                this.cancel();
                timer2.cancel();
            } else {
                timenow = System.currentTimeMillis();
                bytesnow = transfer.getAmountWritten();
                bytesRead = transfer.getAmountWritten();
                if (bytesRead == -1) {
                    bytesRead = 0;
                }
                ByteFormat format = new ByteFormat();
                String text = format.format(bytesRead);
                FileTransfer.Status status = transfer.getStatus();
                if (status == FileTransfer.Status.in_progress) {
                    titleLabel.setText(Res.getString("message.receiving.file", contactItem.getDisplayName()));
                    String speed = TransferUtils.calculateSpeed(bytesnow - bytesearlier, timenow - timeearlier);
                    String est = TransferUtils.calculateEstimate(bytesnow, transfer.getFileSize(), _starttime, System.currentTimeMillis());
                    progressLabel.setText(Res.getString("message.transfer.progressbar.text.received", text, speed, est));
                } else if (status == FileTransfer.Status.negotiating_stream) {
                    titleLabel.setText(Res.getString("message.negotiate.stream"));
                }
                bytesearlier = bytesnow;
                timeearlier = timenow;
            }
        }
    };
    timer.scheduleAtFixedRate(updateProgessBar, 10, 10);
    timer2.scheduleAtFixedRate(updatePrograssBarText, 10, 500);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) ContactItem(org.jivesoftware.spark.ui.ContactItem) Color(java.awt.Color) SmackException(org.jivesoftware.smack.SmackException) FileTransfer(org.jivesoftware.smackx.filetransfer.FileTransfer) IncomingFileTransfer(org.jivesoftware.smackx.filetransfer.IncomingFileTransfer) ContactList(org.jivesoftware.spark.ui.ContactList) IOException(java.io.IOException) Timer(java.util.Timer) TimerTask(java.util.TimerTask) ByteFormat(org.jivesoftware.spark.util.ByteFormat) File(java.io.File)

Example 8 with ContactList

use of org.jivesoftware.spark.ui.ContactList in project Spark by igniterealtime.

the class ReceiveFileTransfer method transferDone.

private void transferDone(final FileTransferRequest request, FileTransfer transfer) {
    cancelButton.setVisible(false);
    showAlert(true);
    String bareJID = XmppStringUtils.parseBareJid(request.getRequestor());
    ContactList contactList = SparkManager.getWorkspace().getContactList();
    ContactItem contactItem = contactList.getContactItemByJID(bareJID);
    titleLabel.setText(Res.getString("message.received.file", contactItem.getDisplayName()));
    fileLabel.setText(request.getFileName());
    remove(acceptButton);
    remove(declineButton);
    remove(progressBar);
    remove(pathButton);
    final TransferButton openFileButton = new TransferButton();
    final TransferButton openFolderButton = new TransferButton();
    add(openFileButton, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
    add(openFolderButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
    final File downloadedFile = new File(Downloads.getDownloadDirectory(), request.getFileName());
    openFileButton.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent e) {
            openFileButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
        }

        public void mouseExited(MouseEvent e) {
            openFileButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }

        public void mousePressed(MouseEvent e) {
            launchFile(Downloads.getDownloadDirectory() + File.separator + request.getFileName());
        }
    });
    openFolderButton.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent e) {
            openFolderButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
        }

        public void mouseExited(MouseEvent e) {
            openFolderButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }

        public void mousePressed(MouseEvent event) {
            launchFile(Downloads.getDownloadDirectory());
        }
    });
    add(fileLabel, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
    ResourceUtils.resButton(openFileButton, Res.getString("open"));
    ResourceUtils.resButton(openFolderButton, Res.getString("open.folder"));
    openFileButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196)));
    openFileButton.setForeground(new Color(73, 113, 196));
    openFileButton.setFont(new Font("Dialog", Font.BOLD, 11));
    openFolderButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(73, 113, 196)));
    openFolderButton.setForeground(new Color(73, 113, 196));
    openFolderButton.setFont(new Font("Dialog", Font.BOLD, 11));
    imageLabel.setIcon(GraphicUtils.getIcon(downloadedFile));
    imageLabel.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            showPopup(e, downloadedFile);
        }

        public void mouseReleased(MouseEvent e) {
            showPopup(e, downloadedFile);
        }
    });
    if (isImage(downloadedFile.getName())) {
        try {
            URL imageURL = downloadedFile.toURI().toURL();
            ImageIcon image = new ImageIcon(imageURL);
            image = GraphicUtils.scaleImageIcon(image, 64, 64);
            imageLabel.setIcon(image);
        } catch (MalformedURLException e) {
            Log.error("Could not locate image.", e);
            imageLabel.setIcon(SparkRes.getImageIcon(SparkRes.DOCUMENT_INFO_32x32));
        }
    }
    invalidate();
    validate();
    repaint();
}
Also used : ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) MalformedURLException(java.net.MalformedURLException) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) ContactItem(org.jivesoftware.spark.ui.ContactItem) Color(java.awt.Color) MouseAdapter(java.awt.event.MouseAdapter) ContactList(org.jivesoftware.spark.ui.ContactList) Cursor(java.awt.Cursor) Font(java.awt.Font) URL(java.net.URL) File(java.io.File)

Example 9 with ContactList

use of org.jivesoftware.spark.ui.ContactList in project Spark by igniterealtime.

the class SendFileTransfer method sendFile.

public void sendFile(final OutgoingFileTransfer transfer, FileTransferManager transferManager, final String jid, final String nickname) {
    this.transferManager = transferManager;
    // SPARK-1869
    FileTransferNegotiator.getInstanceFor(SparkManager.getConnection());
    FileTransferNegotiator.IBB_ONLY = SettingsManager.getLocalPreferences().isFileTransferIbbOnly();
    cancelButton.setVisible(true);
    retryButton.setVisible(false);
    this.fullJID = jid;
    this.nickname = nickname;
    this.transfer = transfer;
    String fileName = transfer.getFileName();
    long fileSize = transfer.getFileSize();
    ByteFormat format = new ByteFormat();
    String text = format.format(fileSize);
    fileToSend = new File(transfer.getFilePath());
    imageLabel.setFile(fileToSend);
    fileLabel.setText(fileName + " (" + text + ")");
    ContactList contactList = SparkManager.getWorkspace().getContactList();
    ContactItem contactItem = contactList.getContactItemByJID(jid);
    titleLabel.setText(Res.getString("message.transfer.waiting.on.user", contactItem.getDisplayName()));
    if (isImage(fileName)) {
        try {
            URL imageURL = new File(transfer.getFilePath()).toURI().toURL();
            ImageIcon image = new ImageIcon(imageURL);
            image = GraphicUtils.scaleImageIcon(image, 64, 64);
            imageLabel.setIcon(image);
        } catch (MalformedURLException e) {
            Log.error("Could not locate image.", e);
            imageLabel.setIcon(SparkRes.getImageIcon(SparkRes.DOCUMENT_INFO_32x32));
        }
    } else {
        File file = new File(transfer.getFilePath());
        Icon icon = GraphicUtils.getIcon(file);
        imageLabel.setIcon(icon);
    }
    cancelButton.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent mouseEvent) {
            transfer.cancel();
        }
    });
    cancelButton.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent e) {
            cancelButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
        }

        public void mouseExited(MouseEvent e) {
            cancelButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    });
    progressBar.setMaximum(100);
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    add(progressBar, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0));
    add(progressLabel, new GridBagConstraints(1, 3, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 150, 0));
    SwingWorker worker = new SwingWorker() {

        public Object construct() {
            while (true) {
                try {
                    if (transfer.getBytesSent() > 0 && _starttime == 0) {
                        _starttime = System.currentTimeMillis();
                    }
                    long starttime = System.currentTimeMillis();
                    long startbyte = transfer.getBytesSent();
                    Thread.sleep(500);
                    FileTransfer.Status status = transfer.getStatus();
                    if (status == Status.error || status == Status.complete || status == Status.cancelled || status == Status.refused) {
                        break;
                    }
                    long endtime = System.currentTimeMillis();
                    long endbyte = transfer.getBytesSent();
                    long timediff = endtime - starttime;
                    long bytediff = endbyte - startbyte;
                    updateBar(transfer, nickname, TransferUtils.calculateSpeed(bytediff, timediff));
                } catch (InterruptedException e) {
                    Log.error("Unable to sleep thread.", e);
                }
            }
            return "";
        }

        public void finished() {
            updateBar(transfer, nickname, "??MB/s");
        }
    };
    worker.start();
    makeClickable(imageLabel);
    makeClickable(titleLabel);
}
Also used : ImageIcon(javax.swing.ImageIcon) MalformedURLException(java.net.MalformedURLException) GridBagConstraints(java.awt.GridBagConstraints) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) ContactItem(org.jivesoftware.spark.ui.ContactItem) MouseAdapter(java.awt.event.MouseAdapter) OutgoingFileTransfer(org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer) FileTransfer(org.jivesoftware.smackx.filetransfer.FileTransfer) ContactList(org.jivesoftware.spark.ui.ContactList) Cursor(java.awt.Cursor) URL(java.net.URL) Status(org.jivesoftware.smackx.filetransfer.FileTransfer.Status) ByteFormat(org.jivesoftware.spark.util.ByteFormat) SwingWorker(org.jivesoftware.spark.util.SwingWorker) ImageIcon(javax.swing.ImageIcon) Icon(javax.swing.Icon) File(java.io.File)

Example 10 with ContactList

use of org.jivesoftware.spark.ui.ContactList in project Spark by igniterealtime.

the class ContactListAssistantPlugin method initialize.

@Override
public void initialize() {
    moveToMenu = new JMenu(Res.getString("menuitem.move.to"));
    copyToMenu = new JMenu(Res.getString("menuitem.copy.to"));
    localPreferences = new LocalPreferences();
    final ContactList contactList = SparkManager.getContactList();
    contactList.addContextMenuListener(new ContextMenuListener() {

        @Override
        public void poppingUp(Object object, final JPopupMenu popup) {
            final Collection<ContactItem> contactItems = Collections.unmodifiableCollection(contactList.getSelectedUsers());
            if (!contactItems.isEmpty()) {
                final List<ContactGroup> contactGroups = contactList.getContactGroups();
                Collections.sort(contactGroups, ContactList.GROUP_COMPARATOR);
                for (final ContactGroup group : contactGroups) {
                    if (group.isUnfiledGroup() || group.isOfflineGroup()) {
                        continue;
                    }
                    if (isContactItemInGroup(contactItems, group)) {
                        continue;
                    }
                    final Action moveAction = new AbstractAction() {

                        private static final long serialVersionUID = 6542011870221162331L;

                        @Override
                        public void actionPerformed(ActionEvent actionEvent) {
                            moveItems(contactItems, group.getGroupName());
                        }
                    };
                    final Action copyAction = new AbstractAction() {

                        private static final long serialVersionUID = 2232885525630977329L;

                        @Override
                        public void actionPerformed(ActionEvent actionEvent) {
                            copyItems(contactItems, group.getGroupName());
                        }
                    };
                    moveAction.putValue(Action.NAME, group.getGroupName());
                    moveToMenu.add(moveAction);
                    copyAction.putValue(Action.NAME, group.getGroupName());
                    copyToMenu.add(copyAction);
                }
                popup.addPopupMenuListener(new PopupMenuListener() {

                    @Override
                    public void popupMenuWillBecomeVisible(PopupMenuEvent popupMenuEvent) {
                    }

                    @Override
                    public void popupMenuWillBecomeInvisible(PopupMenuEvent popupMenuEvent) {
                        moveToMenu.removeAll();
                        copyToMenu.removeAll();
                        popup.removePopupMenuListener(this);
                    }

                    @Override
                    public void popupMenuCanceled(PopupMenuEvent popupMenuEvent) {
                        moveToMenu.removeAll();
                        copyToMenu.removeAll();
                        popup.removePopupMenuListener(this);
                    }
                });
                int index = -1;
                if (!Default.getBoolean("DISABLE_RENAMES") && Enterprise.containsFeature(Enterprise.RENAMES_FEATURE)) {
                    for (int i = 0; i < popup.getComponentCount(); i++) {
                        Object o = popup.getComponent(i);
                        if (o instanceof JMenuItem && ((JMenuItem) o).getText().equals(Res.getString("menuitem.rename"))) {
                            index = i;
                            break;
                        }
                    }
                } else
                    index = 3;
                if (contactItems.size() == 1) {
                    // Add MOVE/COPY options right after the RENAME option or in it's place if it doesn't exist.
                    if (index != -1) {
                        // See if we should disable the "Move to" and "Copy to" menu options
                        if (!Default.getBoolean("DISABLE_MOVE_AND_COPY") && Enterprise.containsFeature(Enterprise.MOVE_COPY_FEATURE)) {
                            popup.add(moveToMenu, index + 1);
                            popup.add(copyToMenu, index + 2);
                        }
                    }
                } else if (contactItems.size() > 1) {
                    // See if we should disable the "Move to" and "Copy to" menu options
                    if (!Default.getBoolean("DISABLE_MOVE_AND_COPY") && Enterprise.containsFeature(Enterprise.MOVE_COPY_FEATURE)) {
                        popup.addSeparator();
                        popup.add(moveToMenu);
                        popup.add(copyToMenu);
                    }
                    // Clean up the extra separator if "Broadcast" menu items are disabled
                    if (!Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM") && Enterprise.containsFeature(Enterprise.BROADCAST_FEATURE))
                        popup.addSeparator();
                }
            }
        }

        @Override
        public void poppingDown(JPopupMenu popup) {
        }

        @Override
        public boolean handleDefaultAction(MouseEvent e) {
            return false;
        }
    });
    updateAvatarsInContactList();
    SettingsManager.addPreferenceListener(preference -> updateAvatarsInContactList());
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) PopupMenuListener(javax.swing.event.PopupMenuListener) ContextMenuListener(org.jivesoftware.spark.plugin.ContextMenuListener) ContactList(org.jivesoftware.spark.ui.ContactList) PopupMenuEvent(javax.swing.event.PopupMenuEvent) JPopupMenu(javax.swing.JPopupMenu) Collection(java.util.Collection) List(java.util.List) ContactList(org.jivesoftware.spark.ui.ContactList) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) ContactGroup(org.jivesoftware.spark.ui.ContactGroup) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu)

Aggregations

ContactList (org.jivesoftware.spark.ui.ContactList)20 ContactItem (org.jivesoftware.spark.ui.ContactItem)16 MouseEvent (java.awt.event.MouseEvent)10 MouseAdapter (java.awt.event.MouseAdapter)6 File (java.io.File)5 StanzaTypeFilter (org.jivesoftware.smack.filter.StanzaTypeFilter)5 Color (java.awt.Color)4 Cursor (java.awt.Cursor)4 GridBagConstraints (java.awt.GridBagConstraints)4 Insets (java.awt.Insets)4 ActionEvent (java.awt.event.ActionEvent)4 MalformedURLException (java.net.MalformedURLException)4 AbstractAction (javax.swing.AbstractAction)4 Action (javax.swing.Action)4 JPopupMenu (javax.swing.JPopupMenu)4 Presence (org.jivesoftware.smack.packet.Presence)4 ContextMenuListener (org.jivesoftware.spark.plugin.ContextMenuListener)4 ContactGroup (org.jivesoftware.spark.ui.ContactGroup)4 IOException (java.io.IOException)3 URL (java.net.URL)3