Show directly the add contact dialog when we have only one contact detail available (instead of opening a popup menu).

cusax-fix
Yana Stamcheva 16 years ago
parent bf8603d408
commit e13dc394f1

@ -1189,45 +1189,46 @@ else if (deviceNumber > 1)
*/
private void addContact(SourceUIContact contact)
{
JMenuItem addContactMenu = TreeContactList.createAddContactMenu(
(SourceContact) contact.getDescriptor());
SourceContact sourceContact = (SourceContact) contact.getDescriptor();
JPopupMenu popupMenu;
List<ContactDetail> details = sourceContact.getContactDetails();
int detailsCount = details.size();
if (addContactMenu instanceof JMenu)
if (detailsCount > 1)
{
JMenu menu = ((JMenu) addContactMenu);
popupMenu = menu.getPopupMenu();
}
else
{
popupMenu = new JPopupMenu();
popupMenu.add(addContactMenu);
}
JMenuItem addContactMenu = TreeContactList.createAddContactMenu(
(SourceContact) contact.getDescriptor());
// Add a title label.
JLabel infoLabel = new JLabel();
infoLabel.setText("<html><b>"
+ GuiActivator.getResources()
.getI18NString("service.gui.ADD_CONTACT")
+ "</b></html>");
JPopupMenu popupMenu = ((JMenu) addContactMenu).getPopupMenu();
popupMenu.insert(infoLabel, 0);
popupMenu.insert(new Separator(), 1);
// Add a title label.
JLabel infoLabel = new JLabel();
infoLabel.setText("<html><b>"
+ GuiActivator.getResources()
.getI18NString("service.gui.ADD_CONTACT")
+ "</b></html>");
popupMenu.setFocusable(true);
popupMenu.setInvoker(tree);
popupMenu.insert(infoLabel, 0);
popupMenu.insert(new Separator(), 1);
Point location = new Point(addContactButton.getX(),
addContactButton.getY() + addContactButton.getHeight());
popupMenu.setFocusable(true);
popupMenu.setInvoker(tree);
SwingUtilities.convertPointToScreen(location, tree);
Point location = new Point(addContactButton.getX(),
addContactButton.getY() + addContactButton.getHeight());
location.y = location.y
+ tree.getPathBounds(tree.getSelectionPath()).y;
SwingUtilities.convertPointToScreen(location, tree);
popupMenu.setLocation(location.x + 8, location.y - 8);
popupMenu.setVisible(true);
location.y = location.y
+ tree.getPathBounds(tree.getSelectionPath()).y;
popupMenu.setLocation(location.x + 8, location.y - 8);
popupMenu.setVisible(true);
}
else if (details.size() == 1)
{
TreeContactList.showAddContactDialog(details.get(0));
}
}
/**

@ -2031,7 +2031,7 @@ public void actionPerformed(ActionEvent e)
* <tt>contactAddress</tt> and <tt>protocolProvider</tt>.
* @param contactDetail the contact detail to be added
*/
private static void showAddContactDialog(ContactDetail contactDetail)
public static void showAddContactDialog(ContactDetail contactDetail)
{
AddContactDialog dialog = new AddContactDialog(
GuiActivator.getUIService().getMainFrame());

Loading…
Cancel
Save