diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties
index f769639f2..776391949 100644
--- a/resources/languages/resources.properties
+++ b/resources/languages/resources.properties
@@ -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
diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java
index c55910c54..3a59a0ecd 100644
--- a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java
@@ -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 MetaContact
+ *
* @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 MetaContactGroup that should be the
+ * @param parentGroup the MetaContactGroup 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 MetaContactGroup to create.
+ * @param groupName the name of the MetaContactGroup to create.
+ * @return the newly created MetaContactGroup
+ *
* @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;
}
/**
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java
index 148900a72..d0526d40d 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java
@@ -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)
{
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addgroup/CreateGroupDialog.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addgroup/CreateGroupDialog.java
index ee2427907..199cb6c43 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addgroup/CreateGroupDialog.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addgroup/CreateGroupDialog.java
@@ -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 MetaContactGroup.
+ */
+ private MetaContactGroup newMetaGroup;
+
/**
* Creates an instance of CreateGroupDialog 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 CreateGroupDialog 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 ActionEvent 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 WindowEvent 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 MetaContactGroup if everything is
+ * gone well, otherwise returns null.
+ * @return the newly created MetaContactGroup
+ */
+ 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();
diff --git a/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java b/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java
index 81a4331a1..463ece188 100644
--- a/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java
+++ b/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java
@@ -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 MetaContact
*
* @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 MetaContactGroup that should be the
* parent of the newly created group.
* @param groupName the name of the MetaContactGroup to create.
+ * @return the newly created MetaContactGroup
*
* @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;
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommDialog.java b/src/net/java/sip/communicator/util/swing/SIPCommDialog.java
index 94de67f8e..b97a89aa8 100644
--- a/src/net/java/sip/communicator/util/swing/SIPCommDialog.java
+++ b/src/net/java/sip/communicator/util/swing/SIPCommDialog.java
@@ -78,6 +78,18 @@ public SIPCommDialog(Frame owner)
this.init();
}
+ /**
+ * Creates an instance of SIPCommDialog by specifying the
+ * Frame owner.
+ * @param owner the owner of this dialog
+ */
+ public SIPCommDialog(Window owner)
+ {
+ super(owner);
+
+ this.init();
+ }
+
/**
* Creates an instance of SIPCommDialog 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 SIPCommDialog 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.
*/