Add the possibility to create a new group directly from the "Add contact" dialog.

cusax-fix
Yana Stamcheva 16 years ago
parent dfa8aff8ca
commit 5b353e6815

@ -123,7 +123,7 @@ service.gui.CREATE_CHAT_ROOM_ERROR=Failed to create {0} chat room.
service.gui.CREATE_CHAT_ROOM_WIZARD=Create chat room wizard
service.gui.CREATE_CONFERENCE_CALL=&Create a conference call...
service.gui.CREATE_CONFERENCE_CHAT=&Create a conference chat...
service.gui.CREATE_GROUP=&Create group
service.gui.CREATE_GROUP=&Create group...
service.gui.CREATE_GROUP_NAME=In the field below enter the name of the group you would like to create.
service.gui.CREATE_FIRST_GROUP_WIZARD=Your contact list doesn't contain any groups. Please create a group first (File/Create group).
service.gui.CONTACT_INFO_NOT_SUPPORTED=This contact doesn't support web contact info

@ -648,11 +648,13 @@ public MetaContactGroup findParentMetaContactGroup(MetaContact child)
* @param contactID
* a protocol specific string identifier indicating the contact
* the protocol provider should create.
* @return the newly created <tt>MetaContact</tt>
*
* @throws MetaContactListException
* with an appropriate code if the operation fails for some
* reason.
*/
public void createMetaContact( ProtocolProviderService provider,
public MetaContact createMetaContact( ProtocolProviderService provider,
MetaContactGroup metaContactGroup,
String contactID)
throws MetaContactListException
@ -665,13 +667,16 @@ public void createMetaContact( ProtocolProviderService provider,
MetaContactImpl newMetaContact = new MetaContactImpl();
this.addNewContactToMetaContact(provider, metaContactGroup, newMetaContact,
contactID, false); //don't fire a PROTO_CONT_ADDED event we'll
//fire our own event here.
this.addNewContactToMetaContact(provider, metaContactGroup,
newMetaContact, contactID, false);
//don't fire a PROTO_CONT_ADDED event we'll
//fire our own event here.
fireMetaContactEvent( newMetaContact,
findParentMetaContactGroup(newMetaContact),
MetaContactEvent.META_CONTACT_ADDED);
return newMetaContact;
}
/**
@ -681,18 +686,19 @@ public void createMetaContact( ProtocolProviderService provider,
* creation of the first protocol specific child contact in the respective
* group.
*
* * @param parentGroup the <tt>MetaContactGroup</tt> that should be the
* @param parentGroup the <tt>MetaContactGroup</tt> that should be the
* parent of the newly created group.
* @param parent
* the meta contact group inside which the new child group must
* be created.
* @param groupName
* the name of the <tt>MetaContactGroup</tt> to create.
* @param groupName the name of the <tt>MetaContactGroup</tt> to create.
* @return the newly created <tt>MetaContactGroup</tt>
*
* @throws MetaContactListException
* with an appropriate code if the operation fails for some
* reason.
*/
public void createMetaContactGroup(MetaContactGroup parent,
public MetaContactGroup createMetaContactGroup(MetaContactGroup parent,
String groupName)
throws MetaContactListException
{
@ -731,6 +737,8 @@ public void createMetaContactGroup(MetaContactGroup parent,
//fire the event
fireMetaContactGroupEvent(newMetaGroup
, null, null, MetaContactGroupEvent. META_CONTACT_GROUP_ADDED);
return newMetaGroup;
}
/**

@ -16,6 +16,7 @@
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.contactlist.addgroup.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
@ -246,6 +247,34 @@ private void initGroupCombo()
{
groupCombo.addItem(groupList.next());
}
final String newGroupString = GuiActivator.getResources()
.getI18NString("service.gui.CREATE_GROUP");
groupCombo.addItem(newGroupString);
groupCombo.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (groupCombo.getSelectedItem().equals(newGroupString))
{
CreateGroupDialog dialog
= new CreateGroupDialog(AddContactDialog.this, false);
dialog.setModal(true);
dialog.setVisible(true);
MetaContactGroup newGroup = dialog.getNewMetaGroup();
if (newGroup != null)
{
groupCombo.insertItemAt(newGroup,
groupCombo.getItemCount() - 2);
groupCombo.setSelectedItem(newGroup);
}
}
}
});
}
/**
@ -403,13 +432,25 @@ public Component getListCellRendererComponent( JList list,
boolean isSelected,
boolean cellHasFocus)
{
MetaContactGroup group = (MetaContactGroup) value;
if (group.equals(GuiActivator.getContactListService().getRoot()))
this.setText(GuiActivator.getResources()
.getI18NString("service.gui.SELECT_NO_GROUP"));
if (value instanceof String)
{
this.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(1, 0, 0, 0, Color.LIGHT_GRAY),
BorderFactory.createEmptyBorder(5, 0, 0, 0)));
this.setText((String) value);
}
else
this.setText(group.getGroupName());
{
this.setBorder(null);
MetaContactGroup group = (MetaContactGroup) value;
if (group.equals(GuiActivator
.getContactListService().getRoot()))
this.setText(GuiActivator.getResources()
.getI18NString("service.gui.SELECT_NO_GROUP"));
else
this.setText(group.getGroupName());
}
if (isSelected)
{

@ -11,9 +11,10 @@
import javax.swing.*;
import sun.font.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
@ -46,15 +47,33 @@ public class CreateGroupDialog
private MetaContactListService clist;
/**
* The newly created <tt>MetaContactGroup</tt>.
*/
private MetaContactGroup newMetaGroup;
/**
* Creates an instance of <tt>CreateGroupDialog</tt> that represents a dialog
* that creates a new contact group.
*
* @param mainFrame The MainFrame window.
* @param parentWindow the parent window
*/
public CreateGroupDialog(Window parentWindow)
{
this(parentWindow, true);
}
/**
* Creates an instance of <tt>CreateGroupDialog</tt> that represents a dialog
* that creates a new contact group.
*
* @param parentWindow the parent window
* @param isSaveSizeAndLocation indicates if this dialog should remember its
* size and location
*/
public CreateGroupDialog(MainFrame mainFrame)
public CreateGroupDialog(Window parentWindow, boolean isSaveSizeAndLocation)
{
super(mainFrame);
super(parentWindow, isSaveSizeAndLocation);
this.clist = GuiActivator.getContactListService();
@ -93,6 +112,10 @@ private void init()
this.addWindowFocusListener(this);
}
/**
* Performs needed actions when one of the buttons is pressed.
* @param e the <tt>ActionEvent</tt> that notified us
*/
public void actionPerformed(ActionEvent e)
{
JButton button = (JButton)e.getSource();
@ -108,12 +131,17 @@ else if(name.equals("cancel"))
}
}
/**
* Indicates that the window has gained the focus. Requests the focus in
* the text field.
* @param e the <tt>WindowEvent</tt> that notified us
*/
public void windowGainedFocus(WindowEvent e)
{
this.groupPanel.requestFocusInField();
}
public void windowLostFocus(WindowEvent e) {;}
public void windowLostFocus(WindowEvent e) {}
/**
* Creates a new meta contact group in a separate thread.
@ -136,7 +164,7 @@ public void run()
{
try
{
mcl.createMetaContactGroup(
newMetaGroup = mcl.createMetaContactGroup(
mcl.getRoot(), groupName);
dispose();
@ -192,6 +220,21 @@ else if (errorCode
}
}
/**
* Returns the newly created <tt>MetaContactGroup</tt> if everything is
* gone well, otherwise returns null.
* @return the newly created <tt>MetaContactGroup</tt>
*/
public MetaContactGroup getNewMetaGroup()
{
return newMetaGroup;
}
/**
* Cancels the application if the window is closed.
* @param isEscaped indicates if the window has been closed by pressing the
* Esc button.
*/
protected void close(boolean isEscaped)
{
this.cancelButton.doClick();

@ -272,12 +272,13 @@ public void addNewContactToMetaContact(ProtocolProviderService provider,
* @param contactGroup the MetaContactGroup where the newly created meta
* contact should be stored.
* @param contactID a protocol specific string identifier indicating the
* contact the prtocol provider should create.
* contact the protocol provider should create.
* @return the newly created <tt>MetaContact</tt>
*
* @throws MetaContactListException with an appropriate code if the
* operation fails for some reason.
*/
public void createMetaContact(ProtocolProviderService provider,
public MetaContact createMetaContact(ProtocolProviderService provider,
MetaContactGroup contactGroup,
String contactID)
throws MetaContactListException;
@ -331,11 +332,12 @@ public void removeMetaContact(MetaContact metaContact)
* @param parentGroup the <tt>MetaContactGroup</tt> that should be the
* parent of the newly created group.
* @param groupName the name of the <tt>MetaContactGroup</tt> to create.
* @return the newly created <tt>MetaContactGroup</tt>
*
* @throws MetaContactListException with an appropriate code if the
* operation fails for some reason.
*/
public void createMetaContactGroup(MetaContactGroup parentGroup,
public MetaContactGroup createMetaContactGroup(MetaContactGroup parentGroup,
String groupName)
throws MetaContactListException;

@ -78,6 +78,18 @@ public SIPCommDialog(Frame owner)
this.init();
}
/**
* Creates an instance of <tt>SIPCommDialog</tt> by specifying the
* <tt>Frame</tt> owner.
* @param owner the owner of this dialog
*/
public SIPCommDialog(Window owner)
{
super(owner);
this.init();
}
/**
* Creates an instance of <tt>SIPCommDialog</tt> by specifying explicitly
* if the size and location properties are saved. By default size and
@ -122,6 +134,21 @@ public SIPCommDialog(Frame owner, boolean isSaveSizeAndLocation)
this.isSaveSizeAndLocation = isSaveSizeAndLocation;
}
/**
* Creates an instance of <tt>SIPCommDialog</tt> by specifying the owner
* of this dialog and indicating whether to save the size and location
* properties.
* @param owner the owner of this dialog
* @param isSaveSizeAndLocation indicates whether to save the size and
* location of this dialog
*/
public SIPCommDialog(Window owner, boolean isSaveSizeAndLocation)
{
this(owner);
this.isSaveSizeAndLocation = isSaveSizeAndLocation;
}
/**
* Initializes this dialog.
*/

Loading…
Cancel
Save