aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/gui/main
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2007-10-02 16:21:47 +0000
committerYana Stamcheva <yana@jitsi.org>2007-10-02 16:21:47 +0000
commit9485d82f4a589e32b314be3e3fa5bcd89aaad4b9 (patch)
treea0b64fde99b7f1a2cd09f38e2c65bca0a8e06ef0 /src/net/java/sip/communicator/impl/gui/main
parentb95fb1d2d9cfb2bda8a5a33167ccb19a98c075bd (diff)
downloadjitsi-9485d82f4a589e32b314be3e3fa5bcd89aaad4b9.zip
jitsi-9485d82f4a589e32b314be3e3fa5bcd89aaad4b9.tar.gz
jitsi-9485d82f4a589e32b314be3e3fa5bcd89aaad4b9.tar.bz2
General "Join chat room" wizard opened from the main file menu
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui/main')
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/ChatRoomNamePanel.java (renamed from src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomPanel.java)30
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomDialog.java104
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SearchChatRoomPanel.java196
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java8
4 files changed, 215 insertions, 123 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomPanel.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/ChatRoomNamePanel.java
index e0a74a9..ae12082 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/ChatRoomNamePanel.java
@@ -10,6 +10,7 @@ package net.java.sip.communicator.impl.gui.main.chatroomslist.joinforms;
import java.awt.*;
import javax.swing.*;
+import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
@@ -21,7 +22,7 @@ import net.java.sip.communicator.impl.gui.utils.*;
*
* @author Yana Stamcheva
*/
-public class JoinChatRoomPanel
+public class ChatRoomNamePanel
extends JPanel
{
private JLabel chatRoomLabel = new JLabel(
@@ -46,25 +47,25 @@ public class JoinChatRoomPanel
/**
* Creates and initializes the <tt>ChatRoomNamePanel</tt>.
*/
- public JoinChatRoomPanel()
+ public ChatRoomNamePanel()
{
super(new BorderLayout());
-
+
this.infoLabel.setEditable(false);
-
+
this.dataPanel.add(chatRoomLabel, BorderLayout.WEST);
-
+
this.dataPanel.add(textField, BorderLayout.CENTER);
-
+
this.infoTitleLabel.setHorizontalAlignment(JLabel.CENTER);
this.infoTitleLabel.setFont(Constants.FONT.deriveFont(Font.BOLD, 18));
-
+
this.labelsPanel.add(infoTitleLabel);
this.labelsPanel.add(infoLabel);
this.labelsPanel.add(dataPanel);
-
+
this.rightPanel.add(labelsPanel, BorderLayout.NORTH);
-
+
this.add(rightPanel, BorderLayout.CENTER);
}
@@ -94,4 +95,15 @@ public class JoinChatRoomPanel
{
this.textField.requestFocus();
}
+
+ /**
+ * Adds a <tt>DocumentListener</tt> to the text field containing the chosen
+ * chat room.
+ *
+ * @param l the <tt>DocumentListener</tt> to add
+ */
+ public void addChatRoomNameListener(DocumentListener l)
+ {
+ this.textField.getDocument().addDocumentListener(l);
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomDialog.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomDialog.java
index 15eea4e..7ff6cc7 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomDialog.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomDialog.java
@@ -8,16 +8,12 @@ package net.java.sip.communicator.impl.gui.main.chatroomslist.joinforms;
import java.awt.*;
import java.awt.event.*;
-import java.util.*;
-import java.util.List;
import javax.swing.*;
-import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
-import net.java.sip.communicator.impl.gui.main.chat.conference.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
@@ -34,8 +30,6 @@ public class JoinChatRoomDialog
{
private Logger logger = Logger.getLogger(JoinChatRoomDialog.class.getName());
- private JoinChatRoomPanel namePanel = new JoinChatRoomPanel();
-
private SearchChatRoomPanel searchPanel;
private I18NString joinString = Messages.getI18NString("join");
@@ -51,18 +45,12 @@ public class JoinChatRoomDialog
private JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- private JPanel mainPanel = new JPanel(new BorderLayout());
-
- private JList chatRoomsList = new JList();
-
private OperationSetMultiUserChat multiUserChatOpSet;
private MainFrame mainFrame;
private ProtocolProviderService protocolProvider;
- private JScrollPane chatRoomsScrollPane = new JScrollPane();
-
/**
* Creates an instance of <tt>JoinChatRoomDialog</tt>.
*
@@ -81,13 +69,10 @@ public class JoinChatRoomDialog
= (OperationSetMultiUserChat) protocolProvider
.getOperationSet(OperationSetMultiUserChat.class);
- this.searchPanel = new SearchChatRoomPanel(this);
+ this.searchPanel = new SearchChatRoomPanel(this, protocolProvider);
this.setTitle(Messages.getI18NString("joinChatRoom").getText());
- this.namePanel.setPreferredSize(new Dimension(520, 100));
- this.searchPanel.setPreferredSize(new Dimension(520, 110));
-
this.getRootPane().setDefaultButton(joinButton);
this.joinButton.setName("join");
this.cancelButton.setName("cancel");
@@ -104,21 +89,9 @@ public class JoinChatRoomDialog
this.buttonsPanel.add(joinButton);
this.buttonsPanel.add(cancelButton);
- this.mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
- this.mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10));
-
- this.mainPanel.add(namePanel);
- this.mainPanel.add(searchPanel);
-
- this.chatRoomsScrollPane.setBorder(BorderFactory
- .createTitledBorder(Messages.getI18NString("chatRooms").getText()));
-
this.getContentPane().add(iconLabel, BorderLayout.WEST);
- this.getContentPane().add(mainPanel, BorderLayout.CENTER);
+ this.getContentPane().add(searchPanel, BorderLayout.CENTER);
this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
-
- this.chatRoomsList.addListSelectionListener(
- new ChatRoomListSelectionListener());
}
/**
@@ -140,7 +113,7 @@ public class JoinChatRoomDialog
{
ChatRoom chatRoom = null;
- String chatRoomName = namePanel.getChatRoomName();
+ String chatRoomName = searchPanel.getChatRoomName();
try
{
@@ -187,74 +160,7 @@ public class JoinChatRoomDialog
this.cancelButton.doClick();
}
- /**
- * Loads the list of existing server chat rooms.
- */
- public void loadChatRoomsList()
- {
- OperationSetMultiUserChat multiUserChat
- = (OperationSetMultiUserChat) protocolProvider
- .getOperationSet(OperationSetMultiUserChat.class);
-
- List list = null;
-
- try
- {
- list = multiUserChat.getExistingChatRooms();
- }
- catch (OperationFailedException e)
- {
- logger.error("Failed to obtain existing chat rooms for server: "
- + protocolProvider.getAccountID().getService(), e);
- }
- catch (OperationNotSupportedException e)
- {
- logger.error("Failed to obtain existing chat rooms for server: "
- + protocolProvider.getAccountID().getService(), e);
- }
-
- if(list != null)
- {
- if(list.size() == 0)
- list.add(Messages.getI18NString("noAvailableRooms").getText());
-
- chatRoomsList.setListData(new Vector(list));
- chatRoomsScrollPane.setPreferredSize(new Dimension(500, 120));
-
- chatRoomsScrollPane.getViewport().add(chatRoomsList);
-
- this.mainPanel.add(chatRoomsScrollPane);
-
- this.pack();
-
- // When we're finished we replace the "wait cursor"
- // by the default cursor.
- this.setCursor(Cursor.getDefaultCursor());
- }
- }
-
- /**
- * The <tt>ListSelectionListener</tt> of the chat rooms list. When a chat
- * room is selected in the list, we update the text field containing the
- * name of the chat room to join.
- */
- private class ChatRoomListSelectionListener
- implements ListSelectionListener
- {
- /**
- * When a chat room is selected in the list, we update the text field
- * containing the name of the chat room to join.
- */
- public void valueChanged(ListSelectionEvent e)
- {
- if(e.getValueIsAdjusting())
- return;
-
- namePanel.setChatRoomName(
- chatRoomsList.getSelectedValue().toString());
- }
- }
-
+
/**
* Shows this dialog. And requests the current focus in the chat room name
* field.
@@ -263,6 +169,6 @@ public class JoinChatRoomDialog
{
this.setVisible(true);
- namePanel.requestFocusInField();
+ searchPanel.requestFocusInField();
}
} \ No newline at end of file
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SearchChatRoomPanel.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SearchChatRoomPanel.java
index 95703eb..be401c8 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SearchChatRoomPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SearchChatRoomPanel.java
@@ -8,10 +8,15 @@ package net.java.sip.communicator.impl.gui.main.chatroomslist.joinforms;
import java.awt.*;
import java.awt.event.*;
+import java.util.*;
+import java.util.List;
import javax.swing.*;
+import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.i18n.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
public class SearchChatRoomPanel
@@ -20,6 +25,10 @@ public class SearchChatRoomPanel
{
private Logger logger = Logger.getLogger(SearchChatRoomPanel.class);
+ private ChatRoomNamePanel namePanel = new ChatRoomNamePanel();
+
+ private JPanel mainPanel = new JPanel();
+
private JPanel searchPanel = new JPanel(new GridLayout(0, 1));
private JTextArea searchTextArea = new JTextArea(
@@ -31,20 +40,44 @@ public class SearchChatRoomPanel
private JPanel buttonPanel = new JPanel(
new FlowLayout(FlowLayout.CENTER));
- private JoinChatRoomDialog joinChatRoomDialog;
+ private JList chatRoomsList = new JList();
+ private JScrollPane chatRoomsScrollPane = new JScrollPane();
+
+ private Window parentWindow;
+
+ private WizardContainer wizardContainer;
+
+ private ProtocolProviderService protocolProvider;
+
+ /**
+ * Creates a <tt>SearchChatRoomPanel</tt> instance without specifying
+ * neither the parent window, nor the protocol provider.
+ */
+ public SearchChatRoomPanel(WizardContainer wizardContainer)
+ {
+ this(null, null);
+
+ this.wizardContainer = wizardContainer;
+ }
+
/**
+ * Creates an instance of <tt>SearchChatRoomPanel</tt>.
*
- * @param joinChatRoomDialog
+ * @param parentWindow the window containing this panel
+ * @param protocolProvider the protocol provider corresponding to the
+ * account for which the search panel is created
*/
- public SearchChatRoomPanel(JoinChatRoomDialog joinChatRoomDialog)
- {
+ public SearchChatRoomPanel( Window parentWindow,
+ ProtocolProviderService protocolProvider)
+ {
super(new BorderLayout());
-
- this.joinChatRoomDialog = joinChatRoomDialog;
-
+
+ this.parentWindow = parentWindow;
+ this.protocolProvider = protocolProvider;
+
this.buttonPanel.add(searchButton);
-
+
this.searchTextArea.setOpaque(false);
this.searchTextArea.setEditable(false);
this.searchTextArea.setLineWrap(true);
@@ -53,12 +86,27 @@ public class SearchChatRoomPanel
this.searchPanel.add(searchTextArea);
this.searchPanel.add(buttonPanel);
+ this.namePanel.setPreferredSize(new Dimension(520, 100));
+ this.searchPanel.setPreferredSize(new Dimension(520, 150));
+
+ this.mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
+ this.mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10));
+
+ this.mainPanel.add(namePanel);
+ this.mainPanel.add(searchPanel);
+
this.searchPanel.setBorder(BorderFactory
.createTitledBorder(Messages.getI18NString("search").getText()));
this.searchButton.addActionListener(this);
-
- this.add(searchPanel);
+
+ this.add(mainPanel, BorderLayout.NORTH);
+
+ this.chatRoomsScrollPane.setBorder(BorderFactory
+ .createTitledBorder(Messages.getI18NString("chatRooms").getText()));
+
+ this.chatRoomsList.addListSelectionListener(
+ new ChatRoomListSelectionListener());
}
/**
@@ -74,13 +122,135 @@ public class SearchChatRoomPanel
{
public void run()
{
- joinChatRoomDialog.loadChatRoomsList();
+ loadChatRoomsList();
}
});
}
}.start();
- joinChatRoomDialog.setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ if (parentWindow != null)
+ parentWindow.setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ }
+
+ /**
+ * Loads the list of existing server chat rooms.
+ */
+ public void loadChatRoomsList()
+ {
+ OperationSetMultiUserChat multiUserChat
+ = (OperationSetMultiUserChat) protocolProvider
+ .getOperationSet(OperationSetMultiUserChat.class);
+
+ List list = null;
+
+ try
+ {
+ list = multiUserChat.getExistingChatRooms();
+ }
+ catch (OperationFailedException e)
+ {
+ logger.error("Failed to obtain existing chat rooms for server: "
+ + protocolProvider.getAccountID().getService(), e);
+ }
+ catch (OperationNotSupportedException e)
+ {
+ logger.error("Failed to obtain existing chat rooms for server: "
+ + protocolProvider.getAccountID().getService(), e);
+ }
+
+ if(list != null)
+ {
+ if(list.size() == 0)
+ list.add(Messages.getI18NString("noAvailableRooms").getText());
+
+ chatRoomsList.setListData(new Vector(list));
+ chatRoomsScrollPane.setPreferredSize(new Dimension(500, 120));
+
+ chatRoomsScrollPane.getViewport().add(chatRoomsList);
+
+ this.mainPanel.add(chatRoomsScrollPane);
+
+ if (parentWindow != null)
+ parentWindow.pack();
+ else
+ wizardContainer.refresh();
+
+ // When we're finished we replace the "wait cursor"
+ // by the default cursor.
+ this.setCursor(Cursor.getDefaultCursor());
+ }
+ }
+
+ /**
+ * The <tt>ListSelectionListener</tt> of the chat rooms list. When a chat
+ * room is selected in the list, we update the text field containing the
+ * name of the chat room to join.
+ */
+ private class ChatRoomListSelectionListener
+ implements ListSelectionListener
+ {
+ /**
+ * When a chat room is selected in the list, we update the text field
+ * containing the name of the chat room to join.
+ */
+ public void valueChanged(ListSelectionEvent e)
+ {
+ if(e.getValueIsAdjusting())
+ return;
+
+ namePanel.setChatRoomName(
+ chatRoomsList.getSelectedValue().toString());
+ }
+ }
+
+ /**
+ * Returns the chat room name entered by user.
+ * @return the chat room name entered by user
+ */
+ public String getChatRoomName()
+ {
+ return namePanel.getChatRoomName();
+ }
+
+ /**
+ * Sets the given chat room name to the text field, contained in this panel.
+ *
+ * @param chatRoomName the chat room name to set to the text field
+ */
+ public void setChatRoomName(String chatRoomName)
+ {
+ namePanel.setChatRoomName(chatRoomName);
+ }
+
+ /**
+ * Requests the focus in the name text field.
+ */
+ public void requestFocusInField()
+ {
+ namePanel.requestFocusInField();
+ }
+
+ /**
+ * Sets the protocol provider that have been chosen by user on the first
+ * page of the join chat room wizard.
+ *
+ * @param protocolProvider the protocol provider for which we'd search a
+ * chat room
+ */
+ public void setProtocolProvider(ProtocolProviderService protocolProvider)
+ {
+ this.protocolProvider = protocolProvider;
+ }
+
+ /**
+ * Adds a <tt>DocumentListener</tt> to the text field containing the chosen
+ * chat room.
+ *
+ * @param l the <tt>DocumentListener</tt> to add
+ */
+ public void addChatRoomNameListener(DocumentListener l)
+ {
+ namePanel.addChatRoomNameListener(l);
}
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java
index 95ea998..ce7cbbe 100644
--- a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java
@@ -17,6 +17,7 @@ import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.account.*;
import net.java.sip.communicator.impl.gui.main.chatroomslist.createforms.*;
+import net.java.sip.communicator.impl.gui.main.chatroomslist.joinforms.*;
import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*;
import net.java.sip.communicator.impl.gui.main.contactlist.addgroup.*;
import net.java.sip.communicator.impl.gui.utils.*;
@@ -181,12 +182,15 @@ public class FileMenu
{
CreateChatRoomWizard createChatRoomWizard
= new CreateChatRoomWizard(parentWindow);
-
+
createChatRoomWizard.showDialog(false);
}
else if (itemName.equals("searchForChatRooms"))
{
-
+ JoinChatRoomWizard joinChatRoomWizard
+ = new JoinChatRoomWizard(parentWindow);
+
+ joinChatRoomWizard.showDialog(false);
}
}
}