Call and Chat Conference Invite Dialog enhancements:

- Added the possibility to add contacts, which are not in the contact list.
- Filter contact list contacts already added in a conference.
cusax-fix
Yana Stamcheva 16 years ago
parent f660a5ed6c
commit 53fe8eefae

@ -261,8 +261,8 @@ service.gui.NO_GROUP_CHAT_ACCOUNT_AVAILABLE=No accounts, supporting multi user c
service.gui.NON_EMPTY_CHAT_WINDOW_CLOSE=You're trying to close a chat with a non-sent message. Are you sure you want to close this chat?
service.gui.NON_EXISTING_USER_ID=The {0} server does not recognize specified user id.
service.gui.NOTIFICATIONS=Notifications
service.gui.OK=&OK
service.gui.OFFLINE=Offline
service.gui.OK=&OK
service.gui.OLDER_CALLS=Older calls
service.gui.ONLINE=Online
service.gui.OPEN=Open
@ -271,6 +271,8 @@ service.gui.OPEN_FOLDER=Open folder
service.gui.OPEN_IN_BROWSER=Open in &browser
service.gui.OPEN_TOOLS=Open Tools Menu
service.gui.OPTIONS=Options
service.gui.OR=or
service.gui.OR_ENTER_PHONE_NUMBER=Or enter phone number here...
service.gui.PASSWORD=Password
service.gui.PASTE=&Paste
service.gui.PREVIOUS=Previous

@ -260,6 +260,17 @@ public Contact getContact(String contactAddress,
return null;
}
/**
* Returns <tt>true</tt> if the given <tt>protocolContact</tt> is contained
* in this <tt>MetaContact</tt>, otherwise - returns <tt>false</tt>.
* @param protocolContact the <tt>Contact</tt> we're looking for
* @return <tt>true</tt> if the given <tt>protocolContact</tt> is contained
* in this <tt>MetaContact</tt>, otherwise - returns <tt>false</tt>
*/
public boolean containsContact(Contact protocolContact)
{
return protoContacts.contains(protocolContact);
}
/**
* Returns a <tt>java.util.Iterator</tt> over all protocol specific

@ -15,6 +15,7 @@
import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.lookandfeel.*;
import net.java.sip.communicator.util.swing.plaf.*;
/**
* <tt>SIPCommSmartComboBox</tt> is an editable combo box which selects an item

@ -13,6 +13,7 @@
import javax.swing.plaf.metal.*;
import net.java.sip.communicator.util.swing.*;
import net.java.sip.communicator.util.swing.plaf.*;
/**
* The default editor for SIPCommunicator editable combo boxes.

@ -194,7 +194,7 @@ public void run()
= callHistory.findLast(MAX_HISTORY_SIZE);
FilterableComboBoxModel callComboModel
= (FilterableComboBoxModel)getModel();
= (FilterableComboBoxModel) getModel();
for (CallRecord call : historyCalls)
{

@ -113,7 +113,8 @@ public void actionPerformed(ActionEvent e)
{
public void actionPerformed(ActionEvent e)
{
if (getSelectedMetaContacts().hasMoreElements())
if (getSelectedMetaContacts() != null
|| getSelectedStrings() != null)
{
inviteContacts();
@ -216,7 +217,8 @@ private void initContactListData(ProtocolProviderService protocolProvider)
{
MetaContact metaContact = contactListIter.next();
this.addMetaContact(metaContact);
if (!containsContact(metaContact))
this.addMetaContact(metaContact);
}
}
@ -228,30 +230,45 @@ private void inviteContacts()
ProtocolProviderService selectedProvider
= (ProtocolProviderService) accountSelectorBox.getSelectedItem();
java.util.List<String> selectedContactAddresses =
new ArrayList<String>();
java.util.List<String> selectedContactAddresses
= new ArrayList<String>();
Enumeration<MetaContact> selectedContacts
= getSelectedMetaContacts();
// Obtain selected contacts.
Enumeration<MetaContact> selectedContacts = getSelectedMetaContacts();
while (selectedContacts.hasMoreElements())
if (selectedContacts != null)
{
MetaContact metaContact
= selectedContacts.nextElement();
while (selectedContacts.hasMoreElements())
{
MetaContact metaContact
= selectedContacts.nextElement();
Iterator<Contact> contactsIter = metaContact
.getContactsForProvider(selectedProvider);
Iterator<Contact> contactsIter = metaContact
.getContactsForProvider(selectedProvider);
// We invite the first protocol contact that corresponds to the
// invite provider.
if (contactsIter.hasNext())
{
Contact inviteContact = contactsIter.next();
// We invite the first protocol contact that corresponds to the
// invite provider.
if (contactsIter.hasNext())
{
Contact inviteContact = contactsIter.next();
selectedContactAddresses.add(inviteContact.getAddress());
selectedContactAddresses.add(inviteContact.getAddress());
}
}
}
// Obtain selected strings.
Enumeration<String> selectedStrings = getSelectedStrings();
if (selectedStrings != null)
{
while (selectedStrings.hasMoreElements())
{
selectedContactAddresses.add(selectedStrings.nextElement());
}
}
// Invite all selected.
String[] contactAddressStrings = null;
if (selectedContactAddresses.size() > 0)
{
@ -270,4 +287,30 @@ private void inviteContacts()
contactAddressStrings, selectedProvider);
}
}
/**
* Check if the given <tt>metaContact</tt> is already contained in the call.
*
* @param metaContact the <tt>Contact</tt> to check for
* @return <tt>true</tt> if the given <tt>metaContact</tt> is already
* contained in the call, otherwise - returns <tt>false</tt>
*/
private boolean containsContact(MetaContact metaContact)
{
// If the call is not yet created we just return false.
if (call == null)
return false;
Iterator<? extends CallPeer> callPeers = call.getCallPeers();
while(callPeers.hasNext())
{
CallPeer callPeer = callPeers.next();
if(metaContact.containsContact(callPeer.getContact()))
return true;
}
return false;
}
}

@ -92,30 +92,47 @@ private void inviteContacts()
java.util.List<String> selectedContactAddresses =
new ArrayList<String>();
Enumeration<MetaContact> selectedContacts
= getSelectedMetaContacts();
// Obtain selected contacts.
Enumeration<MetaContact> selectedContacts = getSelectedMetaContacts();
while (selectedContacts.hasMoreElements())
if (selectedContacts != null)
{
MetaContact metaContact
= selectedContacts.nextElement();
while (selectedContacts.hasMoreElements())
{
MetaContact metaContact
= selectedContacts.nextElement();
Iterator<Contact> contactsIter = metaContact
.getContactsForProvider(
inviteChatTransport.getProtocolProvider());
Iterator<Contact> contactsIter = metaContact
.getContactsForProvider(
inviteChatTransport.getProtocolProvider());
// We invite the first protocol contact that corresponds to the
// invite provider.
if (contactsIter.hasNext())
{
Contact inviteContact = contactsIter.next();
// We invite the first protocol contact that corresponds to the
// invite provider.
if (contactsIter.hasNext())
{
Contact inviteContact = contactsIter.next();
selectedContactAddresses.add(inviteContact.getAddress());
selectedContactAddresses.add(inviteContact.getAddress());
}
}
}
chatPanel.inviteContacts( inviteChatTransport,
selectedContactAddresses,
this.getReason());
// Obtain selected strings.
Enumeration<String> selectedStrings = getSelectedStrings();
if (selectedStrings != null)
{
while (selectedStrings.hasMoreElements())
{
selectedContactAddresses.add(selectedStrings.nextElement());
}
}
// Invite all selected.
if (selectedContactAddresses.size() > 0)
{
chatPanel.inviteContacts( inviteChatTransport,
selectedContactAddresses,
this.getReason());
}
}
}

@ -229,6 +229,12 @@ else if (value instanceof MetaContactGroup)
this.isLeaf = false;
}
else if (value instanceof String)
{
this.setPreferredSize(new Dimension(20, 30));
this.nameLabel.setText((String) value);
this.nameLabel.setFont(this.getFont().deriveFont(Font.PLAIN));
}
this.isSelected = isSelected;

@ -152,8 +152,7 @@ public void mouseClicked(MouseEvent e)
contactListScrollPane.getViewport().add(contactList);
contactListScrollPane.getViewport().setBorder(null);
contactListScrollPane.setViewportBorder(null);
contactListScrollPane.setBorder(
SIPCommBorders.getRoundBorder());
contactListScrollPane.setBorder(null);
JScrollPane selectedListScrollPane = new JScrollPane();
@ -165,10 +164,20 @@ public void mouseClicked(MouseEvent e)
selectedListScrollPane.setBorder(
SIPCommBorders.getRoundBorder());
// New contact text field panel.
final SIPCommTextField newContactField
= new SIPCommTextField(GuiActivator.getResources()
.getI18NString("service.gui.OR_ENTER_PHONE_NUMBER"));
TransparentPanel leftPanel = new TransparentPanel(new BorderLayout());
leftPanel.setBorder(SIPCommBorders.getRoundBorder());
leftPanel.add(contactListScrollPane);
leftPanel.add(newContactField, BorderLayout.SOUTH);
JPanel listPanel = new JPanel(new GridLayout(0, 2, 5, 5));
listPanel.setPreferredSize(new Dimension(400, 200));
listPanel.add(contactListScrollPane);
listPanel.add(leftPanel);
listPanel.add(selectedListScrollPane);
listPanel.setOpaque(false);
@ -193,6 +202,14 @@ public void actionPerformed(ActionEvent e)
if (metaContacts != null && metaContacts.length > 0)
moveContactsFromLeftToRight(metaContacts);
String newContactText = newContactField.getText();
if (newContactText != null && newContactText.length() > 0)
{
moveStringFromLeftToRight(newContactText);
newContactField.setText("");
}
}
});
@ -253,13 +270,45 @@ public void removeAllMetaContacts()
}
/**
* Returns an enumeration of the list of selected contacts.
* @return an enumeration of the list of selected contacts.
* Returns an enumeration of the list of selected <tt>MetaContact</tt>s.
* @return an enumeration of the list of selected <tt>MetaContact</tt>s
*/
@SuppressWarnings("unchecked") //We'd like to force the cast here.
public Enumeration<MetaContact> getSelectedMetaContacts()
{
return (Enumeration<MetaContact>) selectedContactListModel.elements();
if (selectedContactListModel.getSize() == 0)
return null;
Vector<MetaContact> selectedMetaContacts = new Vector<MetaContact>();
Enumeration<?> selectedContacts = selectedContactListModel.elements();
while(selectedContacts.hasMoreElements())
{
Object contact = selectedContacts.nextElement();
if (contact instanceof MetaContact)
selectedMetaContacts.add((MetaContact)contact);
}
return selectedMetaContacts.elements();
}
/**
* Returns an enumeration of the list of selected Strings.
* @return an enumeration of the list of selected Strings
*/
public Enumeration<String> getSelectedStrings()
{
if (selectedContactListModel.getSize() == 0)
return null;
Vector<String> selectedStrings = new Vector<String>();
Enumeration<?> selectedContacts = selectedContactListModel.elements();
while(selectedContacts.hasMoreElements())
{
Object contact = selectedContacts.nextElement();
if (contact instanceof String)
selectedStrings.add((String)contact);
}
return selectedStrings.elements();
}
/**
@ -314,18 +363,29 @@ private void moveContactsFromLeftToRight(Object[] metaContacts)
}
}
/**
* Moves a string from left to right.
* @param text the text to move from left to right
*/
private void moveStringFromLeftToRight(String text)
{
selectedContactListModel.addElement(text);
}
/**
* Moves a contact from the right list to the left.
*
* @param metaContacts the contact to move.
* @param contacts the contact to move.
*/
private void moveContactsFromRightToLeft(Object[] metaContacts)
private void moveContactsFromRightToLeft(Object[] contacts)
{
for (Object metaContact : metaContacts)
for (Object contact : contacts)
{
selectedContactListModel.removeElement(metaContact);
selectedContactListModel.removeElement(contact);
contactListModel.addElement(metaContact);
// If this is a MetaContact re-add it in the left list.
if (contact instanceof MetaContact)
contactListModel.addElement(contact);
}
}
}

@ -68,6 +68,15 @@ public interface MetaContact
public Contact getContact( String contactAddress,
ProtocolProviderService ownerProvider);
/**
* Returns <tt>true</tt> if the given <tt>protocolContact</tt> is contained
* in this <tt>MetaContact</tt>, otherwise - returns <tt>false</tt>.
* @param protocolContact the <tt>Contact</tt> we're looking for
* @return <tt>true</tt> if the given <tt>protocolContact</tt> is contained
* in this <tt>MetaContact</tt>, otherwise - returns <tt>false</tt>
*/
public boolean containsContact(Contact protocolContact);
/**
* Returns the number of protocol speciic <tt>Contact</tt>s that this
* <tt>MetaContact</tt> contains.

@ -0,0 +1,123 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.util.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* The <tt>SIPCommTextField</tt> is a <tt>JTextField</tt> that offers the
* possibility to specify a default (tip) text that explains what is the
* required data.
* @author Yana Stamcheva
*/
public class SIPCommTextField
extends JTextField
implements MouseListener,
FocusListener
{
private final String defaultText;
/**
* Creates an instance of <tt>SIPCommTextField</tt> by specifying the text
* we would like to show by default in it.
* @param text the text we would like to enter by default
*/
public SIPCommTextField(String text)
{
super(text);
this.defaultText = text;
this.setFont(getFont().deriveFont(11f));
this.setForeground(Color.GRAY);
this.addMouseListener(this);
this.addFocusListener(this);
}
/**
* Indicates that the mouse button was pressed on this component. Hides
* the default text when user clicks on the text field.
* @param e the <tt>MouseEvent</tt> that notified us
*/
public void mousePressed(MouseEvent e)
{
if (getText() == null)
{
// We call the super.setText() because we have modified ours to
// set the default text each time someone has set null text.
super.setText("");
this.setForeground(Color.BLACK);
}
}
public void mouseClicked(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
/**
* Selects the user text when this text field gains the focus.
* @param e the <tt>FocusEvent</tt> that notified us
*/
public void focusGained(FocusEvent e)
{
if (getText() != null)
select(0, super.getText().length());
}
/**
* Sets the default text when the field looses focus.
* @param e the <tt>FocusEvent</tt> that notified us
*/
public void focusLost(FocusEvent e)
{
if (getText() == null || getText().length() == 0)
{
setDefaultText();
}
}
/**
* Returns the text contained in this field.
* @return the text contained in this field
*/
public String getText()
{
if (!super.getText().equals(defaultText))
return super.getText();
return null;
}
/**
* Sets the text of this text field.
* @param text the text to show in this text field
*/
public void setText(String text)
{
if (text != null && text.length() > 0)
super.setText(text);
else
setDefaultText();
}
/**
* Sets the default text.
*/
private void setDefaultText()
{
super.setText(defaultText);
this.setForeground(Color.GRAY);
}
}

@ -3,7 +3,7 @@
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.lookandfeel;
package net.java.sip.communicator.util.swing.plaf;
import java.awt.*;
import java.awt.event.*;
@ -13,7 +13,7 @@
import javax.swing.plaf.metal.*;
import javax.swing.text.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
/**
@ -41,11 +41,12 @@ public class SIPCommTextFieldUI
*/
public SIPCommTextFieldUI()
{
deleteButtonImg
= ImageLoader.getImage(ImageLoader.DELETE_TEXT_ICON);
deleteButtonImg = UtilActivator.getResources()
.getImage("service.gui.lookandfeel.DELETE_TEXT_ICON").getImage();
deleteButtonRolloverImg
= ImageLoader.getImage(ImageLoader.DELETE_TEXT_ROLLOVER_ICON);
deleteButtonRolloverImg = UtilActivator.getResources()
.getImage("service.gui.lookandfeel.DELETE_TEXT_ROLLOVER_ICON")
.getImage();
deleteButton = new SIPCommButton( deleteButtonImg,
deleteButtonRolloverImg);
Loading…
Cancel
Save