SPARK-1375 fix right click menu when privacy list is active and multiple users are selected

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12494 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Holger Bergunde
2011-06-16 12:08:28 +00:00
committed by holger.bergunde
parent c1c3e9793c
commit 6d8acb7bdf

View File

@ -127,50 +127,53 @@ public class PrivacyPlugin implements Plugin {
@Override @Override
public void poppingUp(Object object, JPopupMenu popup) { public void poppingUp(Object object, JPopupMenu popup) {
final PrivacyManager pManager = PrivacyManager.getInstance(); if (object instanceof ContactItem)
{
final PrivacyManager pManager = PrivacyManager.getInstance();
if (pManager.hasActiveList()) if (pManager.hasActiveList())
{ {
final SparkPrivacyList activeList = pManager.getActiveList(); final SparkPrivacyList activeList = pManager.getActiveList();
final ContactItem item = (ContactItem) object; final ContactItem item = (ContactItem) object;
JMenuItem blockMenu; JMenuItem blockMenu;
if ( activeList.isBlockedItem(item.getJID()) ) { if ( activeList.isBlockedItem(item.getJID()) ) {
blockMenu = new JMenuItem(Res.getString("menuitem.unblock.contact"), SparkRes.getImageIcon(SparkRes.UNBLOCK_CONTACT_16x16)); blockMenu = new JMenuItem(Res.getString("menuitem.unblock.contact"), SparkRes.getImageIcon(SparkRes.UNBLOCK_CONTACT_16x16));
blockMenu.addActionListener(new ActionListener() { //unblock contact blockMenu.addActionListener(new ActionListener() { //unblock contact
@Override @Override
public void actionPerformed(ActionEvent ae) { public void actionPerformed(ActionEvent ae) {
if ( item != null ) { if ( item != null ) {
activeList.removeItem(((ContactItem) item).getJID()); //Add to block list activeList.removeItem(((ContactItem) item).getJID()); //Add to block list
activeList.save(); activeList.save();
}
} }
} });
}); } else {
} else { blockMenu = new JMenuItem(Res.getString("menuitem.block.contact"), SparkRes.getImageIcon(SparkRes.BLOCK_CONTACT_16x16));
blockMenu = new JMenuItem(Res.getString("menuitem.block.contact"), SparkRes.getImageIcon(SparkRes.BLOCK_CONTACT_16x16)); blockMenu.addActionListener(new ActionListener() { //Block contact
blockMenu.addActionListener(new ActionListener() { //Block contact
@Override @Override
public void actionPerformed(ActionEvent ae) { public void actionPerformed(ActionEvent ae) {
if ( item != null ) { if ( item != null ) {
PrivacyItem pItem = new PrivacyItem(Type.jid.toString(), false, activeList.getNewItemOrder()); PrivacyItem pItem = new PrivacyItem(Type.jid.toString(), false, activeList.getNewItemOrder());
pItem.setFilterMessage(true); pItem.setFilterMessage(true);
pItem.setFilterPresence_out(true); pItem.setFilterPresence_out(true);
pItem.setValue(item.getJID()); pItem.setValue(item.getJID());
activeList.addItem(pItem); //Add to block list activeList.addItem(pItem); //Add to block list
activeList.save(); activeList.save();
}
} }
} });
}); }
}
popup.add(blockMenu); popup.add(blockMenu);
} }
}
} }
@Override @Override