
org.yaoqiang.collaboration.panels.RosterGroupPane Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yaoqiang-bpmn-editor Show documentation
Show all versions of yaoqiang-bpmn-editor Show documentation
an Open Source BPMN 2.0 Modeler
package org.yaoqiang.collaboration.panels;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import org.jivesoftware.smack.RosterEntry;
import org.yaoqiang.collaboration.MainPanel;
public class RosterGroupPane extends JPanel {
private static final long serialVersionUID = -3689803530164704648L;
protected MainPanel mainPanel;
private RosterGroupTitlePane titlePane;
private JPanel contactListPanel;
private DefaultListModel model;
private JList contactItemList;
public RosterGroupPane(final MainPanel mainPanel) {
setLayout(new BorderLayout());
this.mainPanel = mainPanel;
titlePane = new RosterGroupTitlePane();
contactListPanel = new JPanel();
contactListPanel.setLayout(new BorderLayout());
model = new DefaultListModel();
contactItemList = new JList(model);
contactItemList.setCellRenderer(new ContractListCellRenderer());
setContentPane(contactItemList);
add(titlePane, BorderLayout.NORTH);
add(contactListPanel, BorderLayout.CENTER);
titlePane.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.isPopupTrigger()) {
return;
}
boolean isCollapsed = titlePane.isCollapsed();
setCollapsed(!isCollapsed);
}
});
contactItemList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
RosterEntry entry = (RosterEntry) contactItemList.getSelectedValue();
mainPanel.setSelectedContact(RosterGroupPane.this, entry);
if (e.getClickCount() > 1 && !SwingUtilities.isRightMouseButton(e)) {
mainPanel.showChatRoom(entry);
}
}
});
}
public void addContactItem(RosterEntry item) {
if (!model.contains(item)) {
model.addElement(item);
}
}
public void removeContactItem(RosterEntry item) {
if (model.contains(item)) {
model.removeElement(item);
}
}
public RosterGroupPane(MainPanel mainPanel, String title) {
this(mainPanel);
setTitle(title);
}
public void setTitle(String title) {
titlePane.setTitle(title);
}
public void setIcon(Icon icon) {
titlePane.setIcon(icon);
}
public void setCollapsed(boolean collapsed) {
titlePane.setCollapsed(collapsed);
contactListPanel.setVisible(!collapsed);
}
public void setContentPane(Component comp) {
contactListPanel.add(comp);
}
public RosterGroupTitlePane getTitlePane() {
return titlePane;
}
protected void setTitlePane(RosterGroupTitlePane titlePane) {
this.titlePane = titlePane;
}
public boolean isCollapsed() {
return titlePane.isCollapsed();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy