SPARK-1235

CTRL-F gets popupmenu support

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12168 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Wolf Posdorfer
2011-03-23 16:41:15 +00:00
committed by wolf.posdorfer
parent 6c3dcf6552
commit 5763ca9cb2
4 changed files with 54 additions and 7 deletions

View File

@ -422,6 +422,22 @@ public class UserManager {
contactField.getList().addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if(e.getButton() == MouseEvent.BUTTON3)
{
contactField.setSelectetIndex(e);
ContactItem item = contactField.getSelectedContactItem();
// get a new width, sometimes the popup appears under the
// current panel, that suxx, so get a different location
int w1 = item.getNicknameLabel().getWidth();
int w2=5;
if(item.getIcon()!=null)
w2 = item.getIcon().getIconWidth();
int newWidthforStuff = w1+w2 +5;
MouseEvent exx = new MouseEvent((Component)e.getSource(),e.getID(), e.getWhen(),e.getModifiers(),newWidthforStuff, e.getY(), e.getClickCount(), false);
SparkManager.getContactList().showPopup(contactField,exx,item);
}
if (e.getClickCount() == 2) {
if (ModelUtil.hasLength(contactField.getText())) {
ContactItem item = contactMap.get(contactField.getText());

View File

@ -304,5 +304,15 @@ public class JContactItemField extends JPanel {
return !textField.hasFocus();
}
/**
* sets the selected Index using the Point of a given {@link MouseEvent}
* @param mouseevent - {@link MouseEvent} to get The {@link Point} from
*/
public void setSelectetIndex(MouseEvent mouseevent)
{
Point p = mouseevent.getPoint();
list.setSelectedIndex(list.locationToIndex(p));
}
}

View File

@ -73,6 +73,7 @@ import org.jivesoftware.spark.component.tabbedPane.SparkTabbedPaneListener;
import org.jivesoftware.spark.ui.rooms.ChatRoomImpl;
import org.jivesoftware.spark.ui.rooms.GroupChatRoom;
import org.jivesoftware.spark.util.SwingTimerTask;
import org.jivesoftware.spark.util.SwingWorker;
import org.jivesoftware.spark.util.TaskEngine;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.plugin.alerts.SparkToaster;
@ -247,7 +248,18 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
private static final long serialVersionUID = -6904085783599775675L;
public void actionPerformed(ActionEvent evt) {
SparkManager.getUserManager().searchContacts("", SparkManager.getChatManager().getChatContainer().getChatFrame());
SwingWorker worker = new SwingWorker() {
@Override
public Object construct() {
return 42;
}
@Override
public void finished() {
SparkManager.getUserManager().searchContacts("", SparkManager.getMainWindow());
}
};
worker.start();
}
});
}

View File

@ -32,7 +32,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -1517,13 +1516,18 @@ public final class ContactList extends JPanel implements ActionListener,
activeGroup = group;
}
public void showPopup(MouseEvent e, final ContactItem item)
{
showPopup(null,e,item);
}
/**
* Shows popup for right-clicking of ContactItem.
*
* @param e the MouseEvent
* @param item the ContactItem
*/
public void showPopup(MouseEvent e, final ContactItem item) {
public void showPopup(Component component, MouseEvent e, final ContactItem item) {
if (item.getJID() == null) {
return;
}
@ -1674,7 +1678,12 @@ public final class ContactList extends JPanel implements ActionListener,
fireContextMenuListenerPopup(popup, item);
ContactGroup group = getContactGroup(item.getGroupName());
if (component == null) {
popup.show(group.getList(), e.getX(), e.getY());
} else {
popup.show(component, e.getX(), e.getY());
popup.requestFocus();
}
}
public void showPopup(MouseEvent e, final Collection<ContactItem> items) {