Thread: [Zerofile-svn] SF.net SVN: zerofile: [46] trunk
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
From: <kar...@us...> - 2007-11-10 12:45:37
|
Revision: 46
http://zerofile.svn.sourceforge.net/zerofile/?rev=46&view=rev
Author: karl-bengtsson
Date: 2007-11-10 04:45:32 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
A lot of changes in this update. Essentially now we can launch a chat window by doubleclicking on a person, and text messages can be passed along to an empty stub method (which prints them to the console), paving the way for real network messaging with some more work.
*) removed appProperties from SVN synchronisation in eclipse project properties - this means that your testing settings won't be overwritten when doing an update from the SVN repo.
*) renamed the XMPPLinkLocalSession class to XMPPLinkLocalChatSession - it's a bit longer and a bit more unwieldy to type, but it clarifies what it is that this class represents.
*) Made some previously static classes (ZeroFileChatWindow, XMPPLinkLocalChatSession) into normal instantiable classes.
*) Added a few stub methods to XMPPLinkLocalChatSession, so that we have some sort of API for sending messages over the network. This will need to be expanded upon.
*) Made an instance of XMPPLinkLocalChatSession a private attribute of ZeroFileChatWindow - this means that each instantiated chat window will be tied to exactly one chat session. The constructor for the chat window now requires an XMPPLinkLocalHost type argument which gets passed along to this session in its constructor, so that the session in turn is tied to a particular host, just the way it should be. The name of this host also gets displayed in the chat window title bar.
*) Added mouse listeners for the contact list in the main window so that a new chat window is launched when a user doubleclicks a person in their contact list. I'm uncertain as to the stability of this piece of code, so it may need further review.
Modified Paths:
--------------
trunk/src/ZeroFile.java
trunk/src/ZeroFileChatWindow.java
trunk/src/ZeroFileMainWindow.java
Added Paths:
-----------
trunk/src/XMPPLinkLocalChatSession.java
Removed Paths:
-------------
trunk/src/XMPPLinkLocalSession.java
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Name: svn:ignore
+ appProperties
Copied: trunk/src/XMPPLinkLocalChatSession.java (from rev 45, trunk/src/XMPPLinkLocalSession.java)
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java (rev 0)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-11-10 12:45:32 UTC (rev 46)
@@ -0,0 +1,27 @@
+/*
+ * Class for handling chat sessions.
+ */
+
+public class XMPPLinkLocalChatSession {
+ private XMPPLinkLocalHost _remoteHost;
+ public XMPPLinkLocalChatSession(XMPPLinkLocalHost hostToChatWith)
+ {
+ _remoteHost = hostToChatWith;
+ connect();
+ }
+ public void sendMessage(String m)
+ {
+ int port = _remoteHost.getPort();
+ String hostName = _remoteHost.getHost();
+ System.out.println("The text \"" + m + "\" should now be sent to:");
+ System.out.println(hostName + ":" + port);
+ }
+ public void connect()
+ {
+ // TODO - establish connection to host
+ }
+ public void disconnect()
+ {
+ // TODO - disconnect from host
+ }
+}
Deleted: trunk/src/XMPPLinkLocalSession.java
===================================================================
--- trunk/src/XMPPLinkLocalSession.java 2007-11-09 12:43:02 UTC (rev 45)
+++ trunk/src/XMPPLinkLocalSession.java 2007-11-10 12:45:32 UTC (rev 46)
@@ -1,8 +0,0 @@
-/* Stub class, to be the base for our actual chat sessions
-* Should perhaps be renamed to indicate that this is actually a
-* chat session?
-*/
-
-public class XMPPLinkLocalSession {
-
-}
Modified: trunk/src/ZeroFile.java
===================================================================
--- trunk/src/ZeroFile.java 2007-11-09 12:43:02 UTC (rev 45)
+++ trunk/src/ZeroFile.java 2007-11-10 12:45:32 UTC (rev 46)
@@ -7,7 +7,6 @@
*/
public static void main(String[] args) throws IOException {
ZeroFileMainWindow.startMainWindow();
- ZeroFileChatWindow.startChatWindow();
ZeroFileSettings.loadSettings();
try
{
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-11-09 12:43:02 UTC (rev 45)
+++ trunk/src/ZeroFileChatWindow.java 2007-11-10 12:45:32 UTC (rev 46)
@@ -1,4 +1,6 @@
import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import javax.swing.*;
@@ -6,22 +8,37 @@
* @author Karl Bengtsson
*/
public class ZeroFileChatWindow {
- static void startChatWindow()
+ private JFrame _chatWindowFrame;
+ private JTextArea _chatTextArea;
+ private JPanel _bottomPanel;
+ private JTextField _entryTextField;
+ private JButton _sendButton;
+ private XMPPLinkLocalChatSession _session;
+ public ZeroFileChatWindow(XMPPLinkLocalHost chatPartner)
{
- JFrame chatWindowFrame = new JFrame();
- chatWindowFrame.setLayout(new GridLayout(0,1,1,1));
- chatWindowFrame.setLocation(0,400);
- chatWindowFrame.setSize(new Dimension(300,200));
- chatWindowFrame.setTitle("chatwindow");
- JTextArea chatTextArea = new JTextArea();
- chatWindowFrame.add(chatTextArea);
- JPanel bottomPanel = new JPanel();
- chatWindowFrame.add(bottomPanel);
- bottomPanel.setLayout(new GridLayout(1,0,1,1));
- JTextField entryTextField = new JTextField();
- JButton sendButton = new JButton("Send");
- bottomPanel.add(entryTextField);
- bottomPanel.add(sendButton);
- chatWindowFrame.setVisible(true);
+ chatPartner.updateData();
+ _session = new XMPPLinkLocalChatSession(chatPartner);
+ _chatWindowFrame = new JFrame();
+ _chatWindowFrame.setTitle(chatPartner.toString());
+ _chatWindowFrame.setLayout(new GridLayout(0,1,1,1));
+ _chatWindowFrame.setLocation(0,400);
+ _chatWindowFrame.setSize(new Dimension(300,200));
+ _chatTextArea = new JTextArea();
+ _chatWindowFrame.add(_chatTextArea);
+ _bottomPanel = new JPanel();
+ _chatWindowFrame.add(_bottomPanel);
+ _bottomPanel.setLayout(new GridLayout(1,0,1,1));
+ _entryTextField = new JTextField();
+ _sendButton = new JButton("Send");
+ _bottomPanel.add(_entryTextField);
+ _bottomPanel.add(_sendButton);
+ _chatWindowFrame.setVisible(true);
+ _sendButton.addActionListener(
+ new ActionListener(){
+ public void actionPerformed(ActionEvent sendButtonPress){
+ _session.sendMessage(_entryTextField.getText());
+ }
+ }
+ );
}
}
Modified: trunk/src/ZeroFileMainWindow.java
===================================================================
--- trunk/src/ZeroFileMainWindow.java 2007-11-09 12:43:02 UTC (rev 45)
+++ trunk/src/ZeroFileMainWindow.java 2007-11-10 12:45:32 UTC (rev 46)
@@ -89,6 +89,29 @@
_contactList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
_contactList.setLayoutOrientation(JList.VERTICAL);
_contactList.setSize(500,700);
+ _contactList.addMouseListener( new MouseListener(){
+ public void mouseEntered(MouseEvent e)
+ {
+
+ }
+ public void mouseExited(MouseEvent e)
+ {
+
+ }
+ public void mouseReleased(MouseEvent e)
+ {
+
+ }
+ public void mousePressed(MouseEvent e)
+ {
+
+ }
+ public void mouseClicked(MouseEvent e)
+ {
+ if (e.getClickCount() == 2)
+ new ZeroFileChatWindow((XMPPLinkLocalHost)_contactList.getSelectedValue());
+ }
+ });
_mainWindowFrame.add(_contactList);
// Show the window
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|