You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(3) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(15) |
Feb
(33) |
Mar
(35) |
Apr
(53) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(2) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <wu...@us...> - 2008-04-07 08:32:30
|
Revision: 109 http://davinspector.svn.sourceforge.net/davinspector/?rev=109&view=rev Author: wuest Date: 2008-04-07 01:32:26 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Added files for unit test. Modified Paths: -------------- trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java Added Paths: ----------- trunk/DAVInspector/test/de/dlr/davinspector/http/request.txt trunk/DAVInspector/test/de/dlr/davinspector/http/response-multistatus.txt trunk/DAVInspector/test/de/dlr/davinspector/http/response.txt Modified: trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java =================================================================== --- trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java 2008-04-06 15:17:09 UTC (rev 108) +++ trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java 2008-04-07 08:32:26 UTC (rev 109) @@ -1,9 +1,9 @@ /* * HTTPTest.java * - * TODO: wues_ha Enter comment! + * Unit tests for HTTMessageParser. * - * Created: 10.03.2008 wues_ha <email> + * Created: 10.03.2008 Jochen Wuest <joc...@dl...> * Changed: * * $Id$ @@ -26,6 +26,10 @@ package de.dlr.davinspector.http; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; import java.util.Calendar; import java.util.Date; @@ -42,33 +46,34 @@ /** - * TODO: wues_ha: Enter comment! + * Unit tests for HTTMessageParser. + * TODO: Add tests for parser. * * @version $LastChangedRevision$ * @author Jochen Wuest */ public class HTTPTest { - /** Comment for not yet implemented tests. */ - private static final String NOT_YET = "Not yet implemented"; + /** Filename of a http response. */ + private static final String RESPONSE_FILE = "response.txt"; /** */ private static int idCounter = 0; /** */ - private AMessage message; + private AMessage myMessage; /** */ - private Date timestamp; + private Date myTimestamp; /** */ - private Direction direction; + private Direction myDirection; /** */ - private String data; + private String myData = ""; /** - * TODO: wues_ha: Enter comment! + * Once called on class loading. * * @throws Exception Exception */ @@ -78,7 +83,7 @@ } /** - * TODO: wues_ha: Enter comment! + * Once called on class shutdown. * * @throws Exception Exception */ @@ -87,25 +92,28 @@ } /** - * TODO: wues_ha: Enter comment! + * Called before every test. Set's up the environment. * * @throws Exception Exception */ @Before public void setUp() throws Exception { idCounter++; - timestamp = new Date(); - direction = Direction.ClientToServer; - // TODO: Read test data from file. - data = "This is a test"; - message = new Message(); - message.setMessageDirection(direction); - message.setRawData(data); - message.setTimestamp(timestamp); + myTimestamp = new Date(); + myDirection = Direction.ClientToServer; + try { + myData = loadTestDataFromFile("request.txt"); + } catch (IOException ioe) { + System.err.println(ioe.getMessage()); + } + myMessage = new Message(); + myMessage.setDirection(myDirection); + myMessage.setRawData(myData); + myMessage.setTimestamp(myTimestamp); } /** - * TODO: wues_ha: Enter comment! + * Called after every test. Tear's down the environment. * * @throws Exception Exception */ @@ -114,89 +122,85 @@ } /** - * TODO: wues_ha: Enter comment! - * + * Test of the ID-Counter. */ @Test public void testGetId() { - Assert.assertEquals(idCounter, message.getId()); + Assert.assertEquals(idCounter, myMessage.getId()); } /** - * TODO: wues_ha: Enter comment! - * + * Test of the timestamp field. */ @Test public void testGetTimestamp() { - Assert.assertEquals(timestamp, message.getTimestamp()); + Assert.assertEquals(myTimestamp, myMessage.getTimestamp()); } /** - * TODO: wues_ha: Enter comment! - * + * Test of the timestamp field. */ @Test public void testSetTimestamp() { Calendar cal = Calendar.getInstance(); cal.set(1, 1, 1, 1, 1, 1); // ### - timestamp = cal.getTime(); - message.setTimestamp(timestamp); - Assert.assertEquals(timestamp, message.getTimestamp()); + myTimestamp = cal.getTime(); + myMessage.setTimestamp(myTimestamp); + Assert.assertEquals(myTimestamp, myMessage.getTimestamp()); } /** - * TODO: wues_ha: Enter comment! - * + * Test of the message direction field. */ @Test public void testGetMessageDirection() { - Assert.assertEquals(Direction.ClientToServer, message.getMessageDirection()); + Assert.assertEquals(Direction.ClientToServer, myMessage.getDirection()); } /** - * TODO: wues_ha: Enter comment! - * + * Test of the message direction field. */ @Test public void testSetMessageDirection() { - Direction msgDir = message.getMessageDirection(); + Direction msgDir = myMessage.getDirection(); if (msgDir == Direction.ClientToServer) { msgDir = Direction.ServerToClient; } else { msgDir = Direction.ClientToServer; } - message.setMessageDirection(msgDir); - Assert.assertEquals(msgDir, message.getMessageDirection()); + myMessage.setDirection(msgDir); + Assert.assertEquals(msgDir, myMessage.getDirection()); } /** - * TODO: wues_ha: Enter comment! - * + * Test of the size field. */ @Test public void testGetSize() { - Assert.assertEquals(data.length(), message.getSize()); + Assert.assertEquals(myData.length(), myMessage.getSize()); } /** - * TODO: wues_ha: Enter comment! - * + * Test of the raw data field. */ @Test public void testGetRawData() { - Assert.assertEquals(data, message.getRawData()); + Assert.assertEquals(myData, myMessage.getRawData()); } /** - * TODO: wues_ha: Enter comment! - * + * Test of the raw data field. */ @Test public void testSetRawData() { - // TODO: Read test data from file. - String testdata = "Mir lose de Dom in koelle."; - message.setRawData(testdata); - Assert.assertEquals(testdata, message.getRawData()); + String testdata = ""; + try { + testdata = loadTestDataFromFile(RESPONSE_FILE); + } catch (IOException ioe) { + System.err.println(ioe.getMessage()); + } + myMessage.setRawData(testdata); + Assert.assertEquals(testdata, myMessage.getRawData()); } /** @@ -204,17 +208,15 @@ * */ @Test - public void testGetMessageHeader() { - junit.framework.TestCase.fail(NOT_YET); - } - - /** - * TODO: wues_ha: Enter comment! - * - */ - @Test public void testGetRawHeader() { - junit.framework.TestCase.fail(NOT_YET); + String testdata = ""; + try { + testdata = loadTestDataFromFile(RESPONSE_FILE); + } catch (IOException ioe) { + System.err.println(ioe.getMessage()); + } + myMessage.setRawData(testdata); + Assert.assertEquals(testdata, myMessage.getRawData()); } /** @@ -222,17 +224,15 @@ * */ @Test - public void testGetMessageBody() { - junit.framework.TestCase.fail(NOT_YET); - } - - /** - * TODO: wues_ha: Enter comment! - * - */ - @Test public void testGetRawBody() { - junit.framework.TestCase.fail(NOT_YET); + String testdata = ""; + try { + testdata = loadTestDataFromFile(RESPONSE_FILE); + } catch (IOException ioe) { + System.err.println(ioe.getMessage()); + } + myMessage.setRawData(testdata); + Assert.assertEquals(testdata, myMessage.getRawData()); } /** @@ -241,16 +241,52 @@ */ @Test public void testParseMessage() { - junit.framework.TestCase.fail(NOT_YET); + try { + myData = loadTestDataFromFile(RESPONSE_FILE); + } catch (IOException ioe) { + System.err.println(ioe.getMessage()); + } + + HTTPMessageParser message = new HTTPMessageParser(new Message()); + + message.setDirection(myDirection); + message.setRawData(myData); + message.setTimestamp(myTimestamp); + String carry = message.parse(); + + if (carry.equals("")) { + junit.framework.TestCase.assertTrue(message.isComplete()); + } else { + junit.framework.TestCase.fail("Carry not empty."); + } } /** - * TODO: wues_ha: Enter comment! + * Utility method. Returns the content of a file in a string. * + * @param filename String + * @return String + * @throws IOException IOE */ - @Test - public void testIsComplete() { - junit.framework.TestCase.fail(NOT_YET); + private String loadTestDataFromFile(String filename) throws IOException { + String result = ""; + String buffer; + File inputFile; + FileReader filereader; + BufferedReader bufferedreader; + + File userdir = new File(System.getProperty("user.dir")); + inputFile = new File(userdir + "/test/de/dlr/davinspector/http/" + filename); + + filereader = new FileReader(inputFile); + bufferedreader = new BufferedReader(filereader); + buffer = bufferedreader.readLine(); + while (buffer != null) { + result += buffer; + buffer = bufferedreader.readLine(); + } + bufferedreader.close(); + + return result; } - } Added: trunk/DAVInspector/test/de/dlr/davinspector/http/request.txt =================================================================== --- trunk/DAVInspector/test/de/dlr/davinspector/http/request.txt (rev 0) +++ trunk/DAVInspector/test/de/dlr/davinspector/http/request.txt 2008-04-07 08:32:26 UTC (rev 109) @@ -0,0 +1,18 @@ +PROPFIND /slide/files/ HTTP/1.1 +Host: localhost:9999 +Connection: TE +TE: trailers, deflate, gzip, compress +User-Agent: UCI DAV Explorer/0.91 RPT-HTTPClient/0.3-3E +Depth: 0 +Translate: f +Cookie: JSESSIONID=E7480B4CDAC11E7DAF2A90E1CA145A1F +Cookie2: $Version="1" +Accept-Encoding: deflate, gzip, x-gzip, compress, x-compress +Content-type: text/xml +Content-length: 85 +Expect: 100-continue + +<?xml version="1.0"?> +<A:propfind xmlns:A="DAV:"> + <A:allprop/> +</A:propfind> Added: trunk/DAVInspector/test/de/dlr/davinspector/http/response-multistatus.txt =================================================================== --- trunk/DAVInspector/test/de/dlr/davinspector/http/response-multistatus.txt (rev 0) +++ trunk/DAVInspector/test/de/dlr/davinspector/http/response-multistatus.txt 2008-04-07 08:32:26 UTC (rev 109) @@ -0,0 +1,183 @@ +HTTP/1.1 207 Multi-Status +Server: Apache-Coyote/1.1 +Set-Cookie: JSESSIONID=347CA584900DC234AB760FE5DA3FF814; Path=/slide +Content-Type: text/xml;charset=UTF-8 +Transfer-Encoding: chunked +Date: Thu, 27 Mar 2008 15:17:53 GMT + +345 +<?xml version="1.0" encoding="UTF-8"?> +<D:multistatus xmlns:D="DAV:"> +<D:response xmlns:D="DAV:"> + <D:href>/slide/files</D:href> + <D:propstat> + <D:prop> + <D:displayname>files</D:displayname> + <D:resourcetype> + <D:collection /> + </D:resourcetype> + <D:getcontentlength>0</D:getcontentlength> + <D:getlastmodified>Mon, 01 Oct 2007 11:25:47 GMT</D:getlastmodified> + <D:lockdiscovery /> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + <D:propstat> + <D:prop> + <D:getcontenttype /> + <D:checked-in /> + <D:checked-out /> + <D:version-name /> + </D:prop> + <D:status>HTTP/1.1 404 Not Found</D:status> + </D:propstat> +</D:response> +35d +<D:response xmlns:D="DAV:"> + <D:href>/slide/files/ntop-overviewrgrg.pdf</D:href> + <D:propstat> + <D:prop> + <D:displayname>ntop-overviewrgrg.pdf</D:displayname> + <D:resourcetype /> + <D:getcontenttype>application/pdf</D:getcontenttype> + <D:getcontentlength>320661</D:getcontentlength> + <D:getlastmodified>Thu, 20 Mar 2008 14:17:45 GMT</D:getlastmodified> + <D:lockdiscovery /> + <D:checked-in> + <D:href>/slide/history/1/1.0</D:href> + </D:checked-in> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + <D:propstat> + <D:prop> + <D:checked-out /> + <D:version-name /> + </D:prop> + <D:status>HTTP/1.1 404 Not Found</D:status> + </D:propstat> +</D:response> +2ea +<D:response xmlns:D="DAV:"> + <D:href>/slide/files/gui.java</D:href> + <D:propstat> + <D:prop> + <D:displayname>gui.java</D:displayname> + <D:resourcetype /> + <D:getcontenttype>text/plain</D:getcontenttype> + <D:getcontentlength>7567</D:getcontentlength> + <D:getlastmodified>Tue, 27 Nov 2007 07:57:13 GMT</D:getlastmodified> + <D:lockdiscovery /> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + <D:propstat> + <D:prop> + <D:checked-in /> + <D:checked-out /> + <D:version-name /> + </D:prop> + <D:status>HTTP/1.1 404 Not Found</D:status> + </D:propstat> +</D:response> +2f5 +<D:response xmlns:D="DAV:"> + <D:href>/slide/files/netze_logo.gif</D:href> + <D:propstat> + <D:prop> + <D:displayname>netze_logo.gif</D:displayname> + <D:resourcetype /> + <D:getcontenttype>image/gif</D:getcontenttype> + <D:getcontentlength>3633</D:getcontentlength> + <D:getlastmodified>Tue, 02 Oct 2007 06:50:08 GMT</D:getlastmodified> + <D:lockdiscovery /> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + <D:propstat> + <D:prop> + <D:checked-in /> + <D:checked-out /> + <D:version-name /> + </D:prop> + <D:status>HTTP/1.1 404 Not Found</D:status> + </D:propstat> +</D:response> +303 +<D:response xmlns:D="DAV:"> + <D:href>/slide/files/test</D:href> + <D:propstat> + <D:prop> + <D:displayname>test</D:displayname> + <D:resourcetype> + <D:collection /> + </D:resourcetype> + <D:getcontentlength>0</D:getcontentlength> + <D:getlastmodified>Tue, 27 Nov 2007 07:46:49 GMT</D:getlastmodified> + <D:lockdiscovery /> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + <D:propstat> + <D:prop> + <D:getcontenttype /> + <D:checked-in /> + <D:checked-out /> + <D:version-name /> + </D:prop> + <D:status>HTTP/1.1 404 Not Found</D:status> + </D:propstat> +</D:response> +359 +<D:response xmlns:D="DAV:"> + <D:href>/slide/files/slide-doc.war</D:href> + <D:propstat> + <D:prop> + <D:displayname>slide-doc.war</D:displayname> + <D:resourcetype /> + <D:getcontenttype>application/octet-stream</D:getcontenttype> + <D:getcontentlength>2985562</D:getcontentlength> + <D:getlastmodified>Mon, 01 Oct 2007 11:35:06 GMT</D:getlastmodified> + <D:lockdiscovery /> + <D:checked-in> + <D:href>/slide/history/101/1.0</D:href> + </D:checked-in> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + <D:propstat> + <D:prop> + <D:checked-out /> + <D:version-name /> + </D:prop> + <D:status>HTTP/1.1 404 Not Found</D:status> + </D:propstat> +</D:response> +2fd +<D:response xmlns:D="DAV:"> + <D:href>/slide/files/slide.war</D:href> + <D:propstat> + <D:prop> + <D:displayname>slide.war</D:displayname> + <D:resourcetype /> + <D:getcontenttype>application/octet-stream</D:getcontenttype> + <D:getcontentlength>5270059</D:getcontentlength> + <D:getlastmodified>Mon, 01 Oct 2007 11:35:06 GMT</D:getlastmodified> + <D:lockdiscovery /> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + <D:propstat> + <D:prop> + <D:checked-in /> + <D:checked-out /> + <D:version-name /> + </D:prop> + <D:status>HTTP/1.1 404 Not Found</D:status> + </D:propstat> +</D:response> +12 + +</D:multistatus> + +0 Added: trunk/DAVInspector/test/de/dlr/davinspector/http/response.txt =================================================================== --- trunk/DAVInspector/test/de/dlr/davinspector/http/response.txt (rev 0) +++ trunk/DAVInspector/test/de/dlr/davinspector/http/response.txt 2008-04-07 08:32:26 UTC (rev 109) @@ -0,0 +1,58 @@ +HTTP/1.1 200 OK +Server: Apache-Coyote/1.1 +ETag: "2a75b88cf715807a122dc95b16e89528" +Content-Language: en +Last-Modified: Tue, 27 Nov 2007 07:47:54 GMT +Content-Type: text/plain +Content-Length: 2645 +Date: Thu, 27 Mar 2008 15:32:04 GMT + +Installation procedure + +The preferred Java version to run DAV Explorer is Java 2 (JDK 1.2 and above.) +DAV Explorer also runs with JDK 1.1.8 and Swing 1.1.1. However, this may +restrict the capabilities of DAV Explorer. + +Note: If not compiling from source, skip steps 1-3 and 5. +If use of SSL is not required, step 4 can also be skipped. + +1. Login to the DAV Explorer Subversion archive with any Subversion client. + The Subversion archive is located at + http://louvre.ics.uci.edu:8080/svn/DAVExplorer/ + NOTE: the archive location may change in the near future, so be sure to check + the DAV Explorer download website http://www.ics.uci.edu/~webdav/download.html + for any changes. + +2. Navigate to your chosen source directory. + +3. Retrieve all DAV Explorer source files from the DAV Explorer Subversion + archive, from the trunk directory, using your favorite Subversion client tool. + The command line format: + svn checkout http://louvre.ics.uci.edu:8080/svn/DAVExplorer/trunk DAVExplorer + +4. If SSL support is required, retrieve the Java Secure Socket Extensions from + http://java.sun.com/products/jsse/ + Install the JSSE files according to the JSSE documentation. + Note that from JDK 1.4 on, JSSE is included in the JDK. + Make sure that the appropriate X.509 certificates are installed at the + Webserver. + +5. Compile all Java source files with Java 2 by running make in the dav_explorer + directory directly below your source directory. This also creates a + DAVExplorer.jar file in the dav_explorer directory. + The DAV Explorer sources do not compile without the JSSE files present. + Note that the Makefile does not work under MS Windows. Instead, running the + make.bat file in the dav_explorer directory achieves the same result. + Under MS Windows, you can also run the DAVjar.bat file from the dav_explorer + directory to create the DAVExplorer.jar file. + Under Unix, the DAVjar.sh shell script serves the same purpose. + We also provide an Eclipse workspace file in the source distribution. + +6. Run the DAV Explorer. + Under MS Windows, run the DAVExplorer.bat file from the dav_explorer directory. + Under Unix, run the DAVExplorer.sh shell script from the dav_explorer directory. + You can also run DAVExplorer by using the command 'java -jar DAVExplorer.jar'. + For SSL support, run DAVExplorerSSL.bat or DAVExplorerSSL.sh, respectively. + Alternatively, the command 'java -jar -Dssl=true DAVExplorer.jar' can be used. + SSL support can also be selected from the Edit menu. + Under MacOS 9, you can use the provided MRJ wrapper DAVExplorer.bin. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-04-06 15:17:15
|
Revision: 108 http://davinspector.svn.sourceforge.net/davinspector/?rev=108&view=rev Author: wuest Date: 2008-04-06 08:17:09 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Removed reference to PluginManager from MainView. PluginManager should only be available via the controller. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-04-06 13:57:37 UTC (rev 107) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-04-06 15:17:09 UTC (rev 108) @@ -297,7 +297,7 @@ /** * An edit-plugin signals the completion of an editing activity by calling this method. * All active plugins with the same direction are updated. - * TODO: Raw views are not updated yet + * NOTE: Raw views are not updated! * * @param direction {@link PluginDirection} * @param message {@link AMessage} Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java 2008-04-06 13:57:37 UTC (rev 107) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java 2008-04-06 15:17:09 UTC (rev 108) @@ -126,7 +126,6 @@ try { myStyledDocument.insertString(myStyledDocument.getLength(), text, myAttributeSet); } catch (BadLocationException ble) { - // INFO: Maybe logger instead? myJTextAreaError.append(ble.getLocalizedMessage() + ": " + ble.offsetRequested()); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-04-06 13:57:37 UTC (rev 107) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-04-06 15:17:09 UTC (rev 108) @@ -25,7 +25,11 @@ package de.dlr.davinspector.ui; +import java.util.List; + import de.dlr.davinspector.common.Constant.Direction; +import de.dlr.davinspector.history.AMessage; +import de.dlr.davinspector.plugin.IPlugin; /** @@ -87,4 +91,78 @@ * @param filename String */ void exportHistory(Direction direction, String filename); + + /** + * This method notifys all active plugins to prepare for shutdown. + * @see PluginManager#shutdownActivePlugins() + */ + void shutdownActivePlugins(); + + /** + * Returns a List containing the available plugins. + * @see PluginManager#getAvailablePlugins() + * + * @return List of IPlugins + */ + List<IPlugin> getAvailablePlugins(); + + /** + * This method sets the active plugins for the client side. + * @see PluginManager#setActivePluginsClient(List) + * + * @param pluginNames List of Strings + */ + void setActivePluginsClient(List<String> pluginNames); + + /** + * This method sets the active plugins for the server side. + * @see PluginManager#setActivePluginsServer(List) + * + * @param pluginNames List of Strings + */ + void setActivePluginsServer(List<String> pluginNames); + + /** + * This method clears all client plugins. + * @see PluginManager#clearActivePluginsClient() + */ + void clearActivePluginsClient(); + + /** + * This method clears all server plugins. + * @see PluginManager#clearActivePluginsServer() + */ + void clearActivePluginsServer(); + + /** + * If a new message on the client side has arrived this method is called. + * @see PluginManager#updateActivePluginsClient(AMessage) + * + * @param message AMessage + */ + void updateActivePluginsClient(AMessage message); + + /** + * If a new message on the server side has arrived this method is called. + * @see PluginManager#updateActivePluginsServer(AMessage) + * + * @param message AMessage + */ + void updateActivePluginsServer(AMessage message); + + /** + * Returns a List containing the active plugins on the client side. + * @see PluginManager#getActivePluginsClient() + * + * @return List of IPlugins + */ + List<IPlugin> getActivePluginsClient(); + + /** + * Returns a List containing the active plugins on the server side. + * @see PluginManager#getActivePluginsServer() + * + * @return List of IPlugins + */ + List<IPlugin> getActivePluginsServer(); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-04-06 13:57:37 UTC (rev 107) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-04-06 15:17:09 UTC (rev 108) @@ -25,8 +25,12 @@ package de.dlr.davinspector.ui; +import java.util.List; + import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.configuration.Configuration; +import de.dlr.davinspector.history.AMessage; +import de.dlr.davinspector.plugin.IPlugin; import de.dlr.davinspector.relay.IRelayModel; @@ -157,4 +161,94 @@ public void exportHistory(Direction direction, String filename) { myRelay.exportHistory(direction, filename); } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#shutdownActivePlugins() + */ + public void shutdownActivePlugins() { + myRelay.getPluginManager().shutdownActivePlugins(); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#getAvailablePlugins() + */ + public List<IPlugin> getAvailablePlugins() { + return myRelay.getPluginManager().getAvailablePlugins(); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#setActivePluginsClient(java.util.List) + */ + public void setActivePluginsClient(List<String> pluginNames) { + myRelay.getPluginManager().setActivePluginsClient(pluginNames); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#setActivePluginsServer(java.util.List) + */ + public void setActivePluginsServer(List<String> pluginNames) { + myRelay.getPluginManager().setActivePluginsServer(pluginNames); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#clearActivePluginsClient() + */ + public void clearActivePluginsClient() { + myRelay.getPluginManager().clearActivePluginsClient(); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#clearActivePluginsServer() + */ + public void clearActivePluginsServer() { + myRelay.getPluginManager().clearActivePluginsServer(); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#updateActivePluginsClient(de.dlr.davinspector.history.AMessage) + */ + public void updateActivePluginsClient(AMessage message) { + myRelay.getPluginManager().updateActivePluginsClient(message); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#updateActivePluginsServer(de.dlr.davinspector.history.AMessage) + */ + public void updateActivePluginsServer(AMessage message) { + myRelay.getPluginManager().updateActivePluginsServer(message); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#getActivePluginsClient() + */ + public List<IPlugin> getActivePluginsClient() { + return myRelay.getPluginManager().getActivePluginsClient(); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#getActivePluginsServer() + */ + public List<IPlugin> getActivePluginsServer() { + return myRelay.getPluginManager().getActivePluginsServer(); + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-04-06 13:57:37 UTC (rev 107) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-04-06 15:17:09 UTC (rev 108) @@ -67,7 +67,6 @@ import de.dlr.davinspector.history.MessageEvent; import de.dlr.davinspector.plugin.IPlugin; import de.dlr.davinspector.plugin.IViewPlugin; -import de.dlr.davinspector.plugin.PluginManager; import de.dlr.davinspector.relay.IRelayModel; /** @@ -202,9 +201,6 @@ /** Toggle button for controlling the auto mode. */ private JToggleButton jToggleButtonAutomode = null; - /** The plugin manager. */ - private PluginManager myPluginManager = null; - /** * Action: Exit program. */ @@ -219,8 +215,7 @@ public void actionPerformed(ActionEvent e) { // INFO: Currently shutdownActivePlugins maybe called twice. - // TODO: controller - myPluginManager.shutdownActivePlugins(); + myController.shutdownActivePlugins(); System.exit(0); } }; @@ -291,10 +286,9 @@ public void actionPerformed(ActionEvent e) { if (myPluginConfigurationDialog == null) { - myPluginConfigurationDialog = new PluginConfigurationDialog(jFrame, myPluginManager, myController.getView()); + myPluginConfigurationDialog = new PluginConfigurationDialog(jFrame, myController); } - // TODO: controller - myPluginConfigurationDialog.addPlugins(myPluginManager.getAvailablePlugins()); + myPluginConfigurationDialog.addPlugins(myController.getAvailablePlugins()); myPluginConfigurationDialog.setVisible(true); } }; @@ -338,8 +332,7 @@ putValue(Action.SHORT_DESCRIPTION, Internationalization.getTranslation("ac_start_relay_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_START)); myRelayIsActive = false; - // TODO: controller - myPluginManager.shutdownActivePlugins(); + myController.shutdownActivePlugins(); myController.disableRelay(); } else { putValue(Action.NAME, Internationalization.getTranslation("ac_stop_relay")); @@ -364,8 +357,7 @@ public void actionPerformed(ActionEvent e) { jTextPaneClientRaw.setText(""); - // TODO: controller - myPluginManager.clearActivePluginsClient(); + myController.clearActivePluginsClient(); } }; @@ -382,8 +374,7 @@ public void actionPerformed(ActionEvent e) { jTextPaneServerRaw.setText(""); - // TODO: controller - myPluginManager.clearActivePluginsServer(); + myController.clearActivePluginsServer(); } }; @@ -401,9 +392,8 @@ public void actionPerformed(ActionEvent e) { jTextPaneServerRaw.setText(""); jTextPaneClientRaw.setText(""); - // TODO: controller - myPluginManager.clearActivePluginsClient(); - myPluginManager.clearActivePluginsServer(); + myController.clearActivePluginsClient(); + myController.clearActivePluginsServer(); } }; @@ -473,8 +463,6 @@ myRelay.getMessageHistory().addNewMessageListener(this); myRelay.getMessageHistory().addLoadMessageListener(this); - myPluginManager = myRelay.getPluginManager(); - jFrame = getJFrame(); jFrame.pack(); jFrame.setVisible(true); @@ -561,12 +549,10 @@ private void updateMessage(AMessage message) { if (message.getDirection().equals(Direction.ClientToServer)) { jTextPaneClientRaw.setText(message.getRawData()); - // TODO: controller - myPluginManager.updateActivePluginsClient(message); + myController.updateActivePluginsClient(message); } else { jTextPaneServerRaw.setText(message.getRawData()); - // TODO: controller - myPluginManager.updateActivePluginsServer(message); + myController.updateActivePluginsServer(message); } } @@ -623,15 +609,12 @@ jTabbedPaneClient.addTab(Internationalization.getTranslation("tab_raw"), null, getJScrollPaneClientRaw(), null); //update plugins - // TODO: controller - if (myPluginManager != null) { - List<IPlugin> plugged = myPluginManager.getActivePluginsClient(); - for (Iterator<IPlugin> iterator = plugged.iterator(); iterator.hasNext();) { - IPlugin plugin = (IPlugin) iterator.next(); - if (plugin.isActive()) { - IViewPlugin viewPlugin = (IViewPlugin) plugin; - jTabbedPaneClient.addTab(viewPlugin.getName(), null, viewPlugin.getUI(), null); - } + List<IPlugin> plugged = myController.getActivePluginsClient(); + for (Iterator<IPlugin> iterator = plugged.iterator(); iterator.hasNext();) { + IPlugin plugin = (IPlugin) iterator.next(); + if (plugin.isActive()) { + IViewPlugin viewPlugin = (IViewPlugin) plugin; + jTabbedPaneClient.addTab(viewPlugin.getName(), null, viewPlugin.getUI(), null); } } } @@ -663,15 +646,12 @@ jTabbedPaneServer.addTab(Internationalization.getTranslation("tab_raw"), null, getJScrollPaneServerRaw(), null); //update plugins - // TODO: controller - if (myPluginManager != null) { - List<IPlugin> plugged = myPluginManager.getActivePluginsServer(); - for (Iterator<IPlugin> iterator = plugged.iterator(); iterator.hasNext();) { - IPlugin plugin = (IPlugin) iterator.next(); - if (plugin.isActive()) { - IViewPlugin viewPlugin = (IViewPlugin) plugin; - jTabbedPaneServer.addTab(viewPlugin.getName(), null, viewPlugin.getUI(), null); - } + List<IPlugin> plugged = myController.getActivePluginsServer(); + for (Iterator<IPlugin> iterator = plugged.iterator(); iterator.hasNext();) { + IPlugin plugin = (IPlugin) iterator.next(); + if (plugin.isActive()) { + IViewPlugin viewPlugin = (IViewPlugin) plugin; + jTabbedPaneServer.addTab(viewPlugin.getName(), null, viewPlugin.getUI(), null); } } } @@ -1000,7 +980,7 @@ if (jTableHistory == null) { myHistoryTableModel = new HistoryTableModel(); - // TODO: controller? + // TODO: controller myRelay.getMessageHistory().addNewMessageListener(myHistoryTableModel); jTableHistory = new JTable(myHistoryTableModel); @@ -1018,7 +998,6 @@ int rowIndex = jTableHistory.getSelectedRow(); if (rowIndex >= 0 && rowIndex < jTableHistory.getRowCount()) { int id = (Integer) jTableHistory.getValueAt(rowIndex, 1); - // TODO: controller myController.loadMessage(id); myRelay.getMessageHistory().loadMessageByID(id); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java 2008-04-06 13:57:37 UTC (rev 107) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java 2008-04-06 15:17:09 UTC (rev 108) @@ -50,7 +50,6 @@ import de.dlr.davinspector.common.Util; import de.dlr.davinspector.configuration.PluginConfiguration; import de.dlr.davinspector.plugin.IPlugin; -import de.dlr.davinspector.plugin.PluginManager; /** * Displays the configuration dialog to configure the plugins. @@ -126,8 +125,8 @@ /** Stores the availability of a plugin for client and server. */ private Map<String, Boolean[]> myAvailablePlugins = new HashMap<String, Boolean[]>(); - /** The plugin manager. */ - private PluginManager myPluginManager = null; + /** The Controller. */ + private IMainController myController = null; /** The main window. */ private MainView myMainView = null; @@ -139,13 +138,12 @@ * Constructor of the plugin configuration dialog. * * @param owner Frame - * @param pluginManager {@link PluginManager} - * @param main MainView + * @param controller {@link IMainController} */ - public PluginConfigurationDialog(Frame owner, PluginManager pluginManager, MainView main) { + public PluginConfigurationDialog(Frame owner, IMainController controller) { super(owner); - myPluginManager = pluginManager; - myMainView = main; + myController = controller; + myMainView = myController.getView(); initialize(); } @@ -324,8 +322,8 @@ serverPlugins.add(pluginName); } } - myPluginManager.setActivePluginsClient(clientPlugins); - myPluginManager.setActivePluginsServer(serverPlugins); + myController.setActivePluginsClient(clientPlugins); + myController.setActivePluginsServer(serverPlugins); // Store the states of the plugins to the configuration file. PluginConfiguration myPluginConfiguration = new PluginConfiguration(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-04-06 13:57:44
|
Revision: 107 http://davinspector.svn.sourceforge.net/davinspector/?rev=107&view=rev Author: wuest Date: 2008-04-06 06:57:37 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Corrected some flaws with path/file handling. Added comments. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/ui/JRawTextPane.java Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java 2008-04-06 13:54:38 UTC (rev 106) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java 2008-04-06 13:57:37 UTC (rev 107) @@ -1,7 +1,8 @@ /* * JCategoryTable.java * - * TODO: wues_ha Enter comment! + * This class is an extension of JPanel and displays a table with + * a toggle button on top. The toggle button hides or shows the table. * * Created: 03.04.2008 Jochen Wuest <joc...@dl...> * Changed: @@ -40,7 +41,8 @@ /** - * TODO: wues_ha: Enter comment! + * This class is an extension of JPanel and displays a table with + * a toggle button on top. The toggle button hides or shows the table. * * @version $LastChangedRevision$ * @author Jochen Wuest Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-04-06 13:54:38 UTC (rev 106) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-04-06 13:57:37 UTC (rev 107) @@ -26,6 +26,7 @@ package de.dlr.davinspector.plugins.recordingplugin; import java.io.File; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; @@ -106,14 +107,19 @@ fileChooser.setSelectedFile(new File(myFilename)); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - int returnValue = fileChooser.showSaveDialog(myParent.getUI()); - - if (returnValue == JFileChooser.APPROVE_OPTION) { - File file = fileChooser.getSelectedFile(); + if (fileChooser.showSaveDialog(myParent.getUI()) == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + // if the file does not exist, create it + try { + file.createNewFile(); + } catch (IOException ioe) { + Util.showIOExceptionMessageDialog(ioe); + } myFilename = file.getAbsolutePath(); myParent.setRecordingFile(file); } - jTextFieldFilename.setText(myFilename); + + jTextFieldFilename.setText(myFilename); } /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java 2008-04-06 13:54:38 UTC (rev 106) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java 2008-04-06 13:57:37 UTC (rev 107) @@ -33,6 +33,7 @@ import javax.swing.JComponent; +import de.dlr.davinspector.common.Util; import de.dlr.davinspector.history.AMessage; import de.dlr.davinspector.plugin.IViewPlugin; import de.dlr.davinspector.plugin.PluginManager; @@ -166,8 +167,8 @@ try { myBufferedWriter.close(); } catch (IOException ioe) { - System.err.println(ioe.getMessage()); - } + Util.showIOExceptionMessageDialog(ioe); + } myBufferedWriter = null; } } @@ -204,8 +205,8 @@ try { myBufferedWriter.append(msg.getRawData()); } catch (IOException ioe) { - System.err.println(ioe.getMessage()); - } + Util.showIOExceptionMessageDialog(ioe); + } } } @@ -221,8 +222,8 @@ FileWriter fileWriter = new FileWriter(recordFile, true); myBufferedWriter = new BufferedWriter(fileWriter); } catch (IOException ioe) { - System.err.println(ioe.getMessage()); - } + Util.showIOExceptionMessageDialog(ioe); + } } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/JRawTextPane.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/JRawTextPane.java 2008-04-06 13:54:38 UTC (rev 106) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/JRawTextPane.java 2008-04-06 13:57:37 UTC (rev 107) @@ -44,7 +44,6 @@ import javax.swing.Action; import javax.swing.JFileChooser; import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.JTextPane; import javax.swing.text.BadLocationException; @@ -53,6 +52,7 @@ import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.common.Internationalization; +import de.dlr.davinspector.common.Util; /** @@ -123,7 +123,7 @@ } } }; - + /** * Action: Copy selected text to the clip board. */ @@ -150,7 +150,7 @@ } } }; - + /** * Action: Cut. Selected text is copied to the clip board. */ @@ -220,11 +220,7 @@ out.flush(); out.close(); } catch (IOException ioe) { - JOptionPane.showMessageDialog(myRawTextPane, - Internationalization.getTranslation("dlg_ioerror_text") + "\n" - + ioe.getLocalizedMessage(), - Internationalization.getTranslation("dlg_ioerror_title"), - JOptionPane.ERROR_MESSAGE); + Util.showIOExceptionMessageDialog(ioe); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-04-06 13:54:41
|
Revision: 106 http://davinspector.svn.sourceforge.net/davinspector/?rev=106&view=rev Author: wuest Date: 2008-04-06 06:54:38 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Added export dialog to the main window. You can now export the client or server message history to a file. Added an IOException dialog to Util. Modified Paths: -------------- trunk/DAVInspector/resource/TextBundle.properties trunk/DAVInspector/resource/TextBundle_de_DE.properties trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java Added Paths: ----------- trunk/DAVInspector/resource/fileexport.png trunk/DAVInspector/src/de/dlr/davinspector/ui/ExportDialog.java Modified: trunk/DAVInspector/resource/TextBundle.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle.properties 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/resource/TextBundle.properties 2008-04-06 13:54:38 UTC (rev 106) @@ -7,7 +7,7 @@ ac_send_to_client_description=Send Server data to the Client ac_configure=Configure ac_configure_description=Configure the application -ac_configure_plugins=Configure +ac_configure_plugins=Configure Plugins ac_configure_plugins_description=Configure the loaded plugins ac_about=About ac_about_description=Display information about the application @@ -25,6 +25,9 @@ ac_enable_auto_mode_description=Data is automatically transfered ac_disable_auto_mode=Disable Auto Mode ac_disable_auto_mode_description=No automatic data transfer +ac_export=Export ... +ac_export_description=Export client or server messages to a file + #ac popup menu ac_paste=Paste ac_paste_description=Paste @@ -48,7 +51,6 @@ menu_file=File menu_view=View menu_help=Help -menu_plugins=Plugins #AboutDialog dlg_about_title=About DAVInspector @@ -70,6 +72,13 @@ dlg_plugin_configuration_type_edit=Edit dlg_plugin_configuration_type_view=View +#ExportDialog +dlg_export_title=Export +dlg_export_label_file=File +dlg_export_radio_client=Export Client Messages +dlg_export_radio_server=Export Server Messages +dlg_export_save_dialog_title=Save Export to ... + #PluginConfigurationTableModel #Column names col_plugin_configuration_client=Client Modified: trunk/DAVInspector/resource/TextBundle_de_DE.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-04-06 13:54:38 UTC (rev 106) @@ -7,7 +7,7 @@ ac_send_to_client_description=Server-Daten zum Client \xFCbertragen ac_configure=Einstellungen ac_configure_description=Die Einstellungen des Programms \xE4ndern -ac_configure_plugins=Konfiguration +ac_configure_plugins=Konfiguration Plugins ac_configure_plugins_description=Die geladenen Plugins konfigurieren ac_about=\xDCber... ac_about_description=Information zum Programm anzeigen @@ -25,6 +25,9 @@ ac_enable_auto_mode_description=Die Daten werden automatisch \xFCbertragen ac_disable_auto_mode=Automatik deaktivieren ac_disable_auto_mode_description=Die Daten m\xFCssen manuell \xFCbertragen werden +ac_export=Export ... +ac_export_description=Client- oder Servernachrichten in einer Datei speichern + #ac popup menu ac_paste=Einf\xFCgen ac_paste_description=Text aus Zwischenablage einf\xFCgen @@ -48,7 +51,6 @@ menu_file=Datei menu_view=Ansicht menu_help=Hilfe -menu_plugins=Plugins #AboutDialog dlg_about_title=\xDCber DAVInspector @@ -79,6 +81,13 @@ col_plugin_configuration_author=Autor col_plugin_configuration_description=Beschreibung +#ExportDialog +dlg_export_title=Export +dlg_export_label_file=Datei +dlg_export_radio_client=Exportiere Client-Nachrichten +dlg_export_radio_server=Exportiere Server-Nachrichten +dlg_export_save_dialog_title=Speichere Export unter ... + #HistoryTableModel col_history_type=Richtung col_history_id=ID Added: trunk/DAVInspector/resource/fileexport.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/resource/fileexport.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-04-06 13:54:38 UTC (rev 106) @@ -60,6 +60,12 @@ /** About dialog height. */ public static final int UI_ABOUT_DIALOG_HEIGTH = 275; + /** Export dialog width. */ + public static final int UI_EXPORT_DIALOG_WIDTH = 500; + + /** Export dialog height. */ + public static final int UI_EXPORT_DIALOG_HEIGTH = 175; + /** Background color of replies. */ public static final Color UI_REPLY_COLOR = new Color(255, 232, 140); Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-04-06 13:54:38 UTC (rev 106) @@ -28,8 +28,10 @@ import java.awt.Dimension; import java.awt.Toolkit; import java.awt.Window; +import java.io.IOException; import java.text.DecimalFormat; +import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -106,4 +108,17 @@ DecimalFormat decimalFormat = new DecimalFormat("###,##0.#"); return decimalFormat.format(result) + ' ' + units[unitIndex]; } + + /** + * This method opens a dialog window displaying the IOError. + * + * @param ioe {@link IOException} + */ + public static void showIOExceptionMessageDialog(IOException ioe) { + JOptionPane.showMessageDialog(null, + Internationalization.getTranslation("dlg_ioerror_text") + "\n" + + ioe.getLocalizedMessage(), + Internationalization.getTranslation("dlg_ioerror_title"), + JOptionPane.ERROR_MESSAGE); + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-04-06 13:54:38 UTC (rev 106) @@ -25,14 +25,20 @@ package de.dlr.davinspector.history; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Vector; import javax.swing.event.EventListenerList; +import de.dlr.davinspector.common.Constant.Direction; +import de.dlr.davinspector.common.Util; + /** * This class saves and provides access to the processed messages. * @@ -71,6 +77,33 @@ } /** + * Save the message history of the client or server in a file. + * + * @param direction Direction + * @param filename String + */ + public void exportToFile(Direction direction, String filename) { + String buffer = ""; + File file = new File(filename); + try { + FileOutputStream out = new FileOutputStream(file); + for (Iterator<AMessage> iterator = myMessages.iterator(); iterator.hasNext();) { + AMessage message = (AMessage) iterator.next(); + if (message.getDirection() == direction) { + // INFO: maybe let the user choose to export full data, only headers or body ... + // TODO: write delimiter for export + buffer = message.getRawData(); + out.write(buffer.getBytes()); + } + } + out.flush(); + out.close(); + } catch (IOException ioe) { + Util.showIOExceptionMessageDialog(ioe); + } + } + + /** * Deletes all stored messages. */ public void deleteAllMessages() { Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-04-06 13:54:38 UTC (rev 106) @@ -67,6 +67,14 @@ * @param id Integer */ void loadMessageById(Integer id); + + /** + * Export the message history of one side (client or server) to a file. + * + * @param direction Direction + * @param filename String + */ + void exportHistory(Direction direction, String filename); /** * This method notifies the listeners for server or client depending on the <code>direction</code> Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-04-06 13:54:38 UTC (rev 106) @@ -44,8 +44,6 @@ /** * Implementation of the relay interface. Provides the server socket * and manages the channel threads. - * TODO: edit-plugin - * TODO: breakpoint-plugin * * @version $LastChangedRevision$ * @author Jochen Wuest @@ -136,6 +134,15 @@ /** * {@inheritDoc} * + * @see de.dlr.davinspector.relay.IRelayModel#exportHistory(de.dlr.davinspector.common.Constant.Direction, java.lang.String) + */ + public void exportHistory(Direction direction, String filename) { + myMessageHistory.exportToFile(direction, filename); + } + + /** + * {@inheritDoc} + * * @see de.dlr.davinspector.relay.IRelayModel#isAutomodeActive() */ public Boolean isAutomodeActive() { Added: trunk/DAVInspector/src/de/dlr/davinspector/ui/ExportDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/ExportDialog.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/ExportDialog.java 2008-04-06 13:54:38 UTC (rev 106) @@ -0,0 +1,353 @@ +/* + * ExportDialog.java + * + * This dialog lets the user choose if he wants to export the client or server + * messages to a choosen file. + * + * Created: 05.04.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.ui; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Window; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.LayoutStyle; + +import de.dlr.davinspector.common.Constant; +import de.dlr.davinspector.common.Constant.Direction; +import de.dlr.davinspector.common.Internationalization; +import de.dlr.davinspector.common.Util; + + +/** + * This dialog lets the user choose if he wants to export the client or server + * messages to a choosen file. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public class ExportDialog extends JDialog { + + /** Serial Version UID, not valid. */ + private static final long serialVersionUID = 1L; + + /** */ + private JPanel jContentPane = null; + + /** */ + private JButton jButtonOk = null; + + /** */ + private JButton jButtonCancel = null; + + /** */ + private ButtonGroup buttonGroup = new ButtonGroup(); + + /** */ + private JTextField jTextField = new JTextField(); + + /** */ + private JLabel jLabel = new JLabel(); + + /** */ + private JButton jButton = new JButton(); + + /** */ + private JRadioButton jRadioButtonClient = new JRadioButton(); + + /** */ + private JRadioButton jRadioButtonServer = new JRadioButton(); + + /** */ + private JPanel jPanelButtonBar = null; + + /** */ + private JPanel jPanelExport = null; + + /** The Controller. */ + private IMainController myController; + + /** The parent frame. */ + private Frame myParent; + + /** + * Constructor of AboutDialog. + * + * @param owner Parent Frame + * @param controller IMainController + */ + public ExportDialog(Frame owner, IMainController controller) { + super(owner); + myParent = owner; + myController = controller; + initialize(); + } + + /** + * This method initializes this. + */ + private void initialize() { + setSize(Constant.UI_EXPORT_DIALOG_WIDTH, Constant.UI_EXPORT_DIALOG_HEIGTH); + setTitle(Constant.APP_TITLE + " " + Internationalization.getTranslation("dlg_export_title")); + setContentPane(this.getJContentPane()); + setModal(true); + setResizable(false); + Util.centerWindow((Window) this); + } + + /** + * This method initializes jContentPane. + * + * @return javax.swing.JPanel + */ + private JPanel getJContentPane() { + if (jContentPane == null) { + jContentPane = new JPanel(); + jContentPane.setLayout(new BorderLayout()); + jContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + jContentPane.add(getExportPanel(), BorderLayout.CENTER); + jContentPane.add(getJPanelButtonBar(), BorderLayout.SOUTH); + } + return jContentPane; + } + + /** + * This method initializes jButtonCancel. + * + * @return javax.swing.JButton + */ + private JButton getJButtonCancel() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(); + jButtonCancel.setText(Internationalization.getTranslation("dlg_configuration_cancel")); + jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent e) { + closeWindow(); + } + + }); + } + return jButtonCancel; + } + + /** + * This method closes the window. + */ + public void closeWindow() { + setVisible(false); + dispose(); + } + + /** + * This method returns the default filename. + * + * @return String + */ + private String getDefaultFileName() { + String path = ""; + // if a filename is already set, + // get the path and add the new filename + if (!jTextField.getText().isEmpty()) { + String oldFilename = jTextField.getText(); + path = new File(oldFilename).getParent(); + // if getParent() returns null there is no parent + if (path == null) { + path = ""; + } else { + path += File.separatorChar; + } + } + + Date now = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm"); + + String side = "_server_"; + if (jRadioButtonClient.isSelected()) { + side = "_client_"; + } + return path + "export" + side + dateFormat.format(now) + ".rec"; + } + + /** + * This method initializes jButtonOk. + * + * @return javax.swing.JButton + */ + private JButton getJButtonOk() { + if (jButtonOk == null) { + jButtonOk = new JButton(); + jButtonOk.setText(Internationalization.getTranslation("dlg_configuration_ok")); + jButtonOk.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent e) { + myController.exportHistory(getDirection(), getFilename()); + closeWindow(); + } + }); + } + return jButtonOk; + } + + /** + * This Method returns the chosen filename from the text field. + * + * @return String + */ + private String getFilename() { + return jTextField.getText(); + } + + /** + * This method returns the selected direction from the radio group. + * + * @return Direction + */ + private Direction getDirection() { + if (jRadioButtonClient.isSelected()) { + return Direction.ClientToServer; + } else { + return Direction.ServerToClient; + } + } + + /** + * This method initializes jPanelButtonBar. + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelButtonBar() { + if (jPanelButtonBar == null) { + jPanelButtonBar = new JPanel(); + jPanelButtonBar.setLayout(new BoxLayout(jPanelButtonBar, BoxLayout.LINE_AXIS)); + jPanelButtonBar.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + jPanelButtonBar.setAlignmentX(Component.RIGHT_ALIGNMENT); + jPanelButtonBar.add(Box.createHorizontalGlue()); + jPanelButtonBar.add(getJButtonOk()); + jPanelButtonBar.add(Box.createRigidArea(new Dimension(10, 0))); + jPanelButtonBar.add(getJButtonCancel()); + } + return jPanelButtonBar; + } + + /** + * This method opens a file chooser dialog and evaluates the result. + * If a valid file is chosen, the local variable <code>myFilename</code> is updated and + * the method <code>setRecordingFile()</code> of the RecordingPlugin is called. + * + * @param event Event + */ + private void jButtonOpenFileChooserActionPerformed(java.awt.event.ActionEvent event) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); + fileChooser.setDialogTitle(Internationalization.getTranslation("dlg_export_save_dialog_title")); + fileChooser.setSelectedFile(new File(getDefaultFileName())); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + + if (fileChooser.showSaveDialog(myParent) == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + jTextField.setText(file.getAbsolutePath()); + } + } + + /** + * This method initializes jPanelExport. + * + * @return javax.swing.JPanel + */ + private JPanel getExportPanel() { + if (jPanelExport == null) { + jPanelExport = new JPanel(); + + buttonGroup.add(jRadioButtonClient); + jRadioButtonClient.setSelected(true); + jRadioButtonClient.setText(Internationalization.getTranslation("dlg_export_radio_client")); + jRadioButtonClient.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField.setText(getDefaultFileName()); + } + }); + + buttonGroup.add(jRadioButtonServer); + jRadioButtonServer.setText(Internationalization.getTranslation("dlg_export_radio_server")); + jRadioButtonServer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField.setText(getDefaultFileName()); + } + }); + + jLabel.setText(Internationalization.getTranslation("dlg_export_label_file") + ':'); + jTextField.setText(getDefaultFileName()); + jButton.setText("..."); + jButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonOpenFileChooserActionPerformed(evt); + } + }); + + GroupLayout layout = new GroupLayout(jPanelExport); + jPanelExport.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(jRadioButtonClient) + .addComponent(jRadioButtonServer) + .addGroup(layout.createSequentialGroup() + .addComponent(jTextField, GroupLayout.DEFAULT_SIZE, Byte.MAX_VALUE * 3, Short.MAX_VALUE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(jLabel) + .addComponent(jButton) + .addComponent(jTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jRadioButtonClient) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jRadioButtonServer)) + ); + } + return jPanelExport; + } +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-04-06 13:54:38 UTC (rev 106) @@ -25,7 +25,9 @@ package de.dlr.davinspector.ui; +import de.dlr.davinspector.common.Constant.Direction; + /** * This is the interface of the controller. * @@ -77,4 +79,12 @@ * @param id Integer */ void loadMessage(Integer id); + + /** + * Export the message history of one side (client or server) to a file. + * + * @param direction Direction + * @param filename String + */ + void exportHistory(Direction direction, String filename); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-04-06 13:54:38 UTC (rev 106) @@ -25,6 +25,7 @@ package de.dlr.davinspector.ui; +import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.configuration.Configuration; import de.dlr.davinspector.relay.IRelayModel; @@ -53,6 +54,7 @@ myView = new MainView(this, myRelay); // Init view myView.disableSendToActions(); + myView.disableExportAction(); } /** @@ -63,6 +65,7 @@ public void enableRelay() { Configuration config = new Configuration(); myRelay.startRelay(config); + myView.enableExportAction(); // enable sendTo-Actions only if automode is not active if (myRelay.isAutomodeActive()) { myView.disableSendToActions(); @@ -145,4 +148,13 @@ public void loadMessage(Integer id) { myRelay.loadMessageById(id); } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#exportHistory(de.dlr.davinspector.common.Constant.Direction, java.lang.String) + */ + public void exportHistory(Direction direction, String filename) { + myRelay.exportHistory(direction, filename); + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-04-06 13:54:38 UTC (rev 106) @@ -45,6 +45,7 @@ import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JSeparator; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.JTable; @@ -162,15 +163,18 @@ /** Menu item "about". */ private JMenuItem jMenuItemAbout = null; - /** Plugin menu. */ - private JMenu jMenuPlugins = null; - /** Menu item "configure plugins". */ private JMenuItem jMenuItemConfigurePlugins = null; + /** Menu item export. */ + private JMenuItem jMenuItemExport = null; + /** Configuration dialog. */ private ConfigurationDialog myConfigDialog = null; + /** Export dialog. */ + private ExportDialog myExportDialog = null; + /** Plugin configuration dialog. */ private PluginConfigurationDialog myPluginConfigurationDialog = null; @@ -434,6 +438,25 @@ } }; + /** + * Action: Export history. + */ + private Action exportAction = new AbstractAction() { + static final long serialVersionUID = 1L; + { + putValue(Action.NAME, Internationalization.getTranslation("ac_export")); + putValue(Action.SHORT_DESCRIPTION, Internationalization.getTranslation("ac_export_description")); + putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_EXPORT)); + } + + public void actionPerformed(ActionEvent e) { + if (myExportDialog == null) { + myExportDialog = new ExportDialog(jFrame, myController); + } + myExportDialog.setVisible(true); + } + }; + /** * Constructor of MainView. Initializes the GUI elements, * loads the plugins and registers listeners. @@ -692,7 +715,6 @@ jJMenuBar = new JMenuBar(); jJMenuBar.add(getJMenuFile()); jJMenuBar.add(getJMenuView()); - jJMenuBar.add(getJMenuPlugins()); jJMenuBar.add(getJMenuHelp()); } return jJMenuBar; @@ -708,6 +730,10 @@ jMenuFile = new JMenu(); jMenuFile.setText(Internationalization.getTranslation("menu_file")); jMenuFile.add(getJMenuItemConfigure()); + jMenuFile.add(getJMenuItemConfigurePlugins()); + jMenuFile.add(new JSeparator()); + jMenuFile.add(getJMenuItemExport()); + jMenuFile.add(new JSeparator()); jMenuFile.add(getJMenuItemExit()); } return jMenuFile; @@ -817,20 +843,6 @@ } /** - * This method initializes jMenuPlugins. - * - * @return javax.swing.JMenu - */ - private JMenu getJMenuPlugins() { - if (jMenuPlugins == null) { - jMenuPlugins = new JMenu(); - jMenuPlugins.setText(Internationalization.getTranslation("menu_plugins")); - jMenuPlugins.add(getJMenuItemConfigurePlugins()); - } - return jMenuPlugins; - } - - /** * This method initializes jMenuItemConfigurePlugins. * * @return javax.swing.JMenuItem. @@ -841,6 +853,18 @@ } return jMenuItemConfigurePlugins; } + + /** + * This method initializes jMenuItemExport. + * + * @return javax.swing.JMenuItem. + */ + private JMenuItem getJMenuItemExport() { + if (jMenuItemExport == null) { + jMenuItemExport = new JMenuItem(exportAction); + } + return jMenuItemExport; + } /** * This method initializes jSplitPaneHorizontal. @@ -1058,4 +1082,18 @@ sendToClientAction.setEnabled(false); sendToServerAction.setEnabled(false); } + + /** + * Enable the export menu item. + */ + public void enableExportAction() { + exportAction.setEnabled(true); + } + + /** + * Disable the export menu item. + */ + public void disableExportAction() { + exportAction.setEnabled(false); + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java 2008-04-06 13:54:38 UTC (rev 106) @@ -97,6 +97,9 @@ /** */ public static final String ICON_SAVEAS = "filesaveas.png"; + /** */ + public static final String ICON_EXPORT = "fileexport.png"; + /** This hash map is used to cache the ImageIcons. */ private static final Map<String, ImageIcon> RESOURCE_MAP = new HashMap<String, ImageIcon>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-04-05 15:46:05
|
Revision: 105 http://davinspector.svn.sourceforge.net/davinspector/?rev=105&view=rev Author: wuest Date: 2008-04-05 08:46:01 -0700 (Sat, 05 Apr 2008) Log Message: ----------- Changed error messages to localized error messages. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-04-05 15:43:38 UTC (rev 104) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-04-05 15:46:01 UTC (rev 105) @@ -106,7 +106,7 @@ fileChooser.setSelectedFile(new File(myFilename)); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - int returnValue = fileChooser.showOpenDialog(null); + int returnValue = fileChooser.showSaveDialog(myParent.getUI()); if (returnValue == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java 2008-04-05 15:43:38 UTC (rev 104) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java 2008-04-05 15:46:01 UTC (rev 105) @@ -127,7 +127,7 @@ myStyledDocument.insertString(myStyledDocument.getLength(), text, myAttributeSet); } catch (BadLocationException ble) { // INFO: Maybe logger instead? - myJTextAreaError.append(ble.getMessage() + ": " + ble.offsetRequested()); + myJTextAreaError.append(ble.getLocalizedMessage() + ": " + ble.offsetRequested()); } myStyledDocument.setCharacterAttributes(myStyledDocument.getLength() - text.length(), text.length(), attributeSet, false); Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-04-05 15:43:38 UTC (rev 104) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-04-05 15:46:01 UTC (rev 105) @@ -207,9 +207,9 @@ try { myXMLTextPane.init(msg.getBody(), myJTextArea); } catch (SAXException se) { - myJTextArea.append(se.getMessage()); + myJTextArea.append(se.getLocalizedMessage()); } catch (IOException ioe) { - myJTextArea.append(ioe.getMessage()); + myJTextArea.append(ioe.getLocalizedMessage()); } } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-04-05 15:43:38 UTC (rev 104) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-04-05 15:46:01 UTC (rev 105) @@ -216,9 +216,9 @@ try { myXMLTreeView.init(data); } catch (SAXException se) { - myJTextArea.append(se.getMessage()); + myJTextArea.append(se.getLocalizedMessage()); } catch (IOException ioe) { - myJTextArea.append(ioe.getMessage()); + myJTextArea.append(ioe.getLocalizedMessage()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-04-05 15:43:45
|
Revision: 104 http://davinspector.svn.sourceforge.net/davinspector/?rev=104&view=rev Author: wuest Date: 2008-04-05 08:43:38 -0700 (Sat, 05 Apr 2008) Log Message: ----------- Added a pop up menu for the raw text panes. Now you can cut, copy and paste text from/to the clip board. Furthermore you can save the text to a file. Modified Paths: -------------- trunk/DAVInspector/resource/TextBundle.properties trunk/DAVInspector/resource/TextBundle_de_DE.properties trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java Added Paths: ----------- trunk/DAVInspector/resource/editcopy.png trunk/DAVInspector/resource/editcut.png trunk/DAVInspector/resource/editpaste.png trunk/DAVInspector/resource/filesaveas.png trunk/DAVInspector/src/de/dlr/davinspector/ui/JRawTextPane.java Modified: trunk/DAVInspector/resource/TextBundle.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle.properties 2008-04-03 16:37:44 UTC (rev 103) +++ trunk/DAVInspector/resource/TextBundle.properties 2008-04-05 15:43:38 UTC (rev 104) @@ -25,7 +25,22 @@ ac_enable_auto_mode_description=Data is automatically transfered ac_disable_auto_mode=Disable Auto Mode ac_disable_auto_mode_description=No automatic data transfer +#ac popup menu +ac_paste=Paste +ac_paste_description=Paste +ac_cut=Cut +ac_cut_description=Cut +ac_copy=Copy +ac_copy_description=Copy +ac_saveas=Save as ... +ac_saveas_description=Save text in a file +#save as dialog file chooser +dlg_title_saveas=Save as ... +#io error dialog +dlg_ioerror_title=Error +dlg_ioerror_text=File IO-Error. + #tabs tab_raw=Raw Modified: trunk/DAVInspector/resource/TextBundle_de_DE.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-04-03 16:37:44 UTC (rev 103) +++ trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-04-05 15:43:38 UTC (rev 104) @@ -25,7 +25,22 @@ ac_enable_auto_mode_description=Die Daten werden automatisch \xFCbertragen ac_disable_auto_mode=Automatik deaktivieren ac_disable_auto_mode_description=Die Daten m\xFCssen manuell \xFCbertragen werden +#ac popup menu +ac_paste=Einf\xFCgen +ac_paste_description=Text aus Zwischenablage einf\xFCgen +ac_cut=Ausschneiden +ac_cut_description=Text ausschneiden und in die Zwischenablage einf\xFCgen +ac_copy=Kopieren +ac_copy_description=Text in die Zwischenablage einf\xFCgen +ac_saveas=Speichern unter ... +ac_saveas_description=Text in einer Datei speichern +#save as dialog file chooser +dlg_title_saveas=Speichern unter ... +#io error dialog +dlg_ioerror_title=Fehler +dlg_ioerror_text=Fehler bei der Ein-/Ausgabe. + #tabs tab_raw=Rohdaten Added: trunk/DAVInspector/resource/editcopy.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/resource/editcopy.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/DAVInspector/resource/editcut.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/resource/editcut.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/DAVInspector/resource/editpaste.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/resource/editpaste.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/DAVInspector/resource/filesaveas.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/resource/filesaveas.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/DAVInspector/src/de/dlr/davinspector/ui/JRawTextPane.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/JRawTextPane.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/JRawTextPane.java 2008-04-05 15:43:38 UTC (rev 104) @@ -0,0 +1,282 @@ +/* + * JRawTextPane.java + * + * This is an extended JTextPane with a pop up menu. The pop up menu + * allows the user to cut, copy and paste text from/to the clip board and + * save the text in a file. + * + * Created: 05.04.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.ui; + +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.event.ActionEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JFileChooser; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; +import javax.swing.JTextPane; +import javax.swing.text.BadLocationException; + +import org.apache.log4j.Logger; + +import de.dlr.davinspector.common.Constant.Direction; +import de.dlr.davinspector.common.Internationalization; + + +/** + * This is an extended JTextPane with a pop up menu. The pop up menu + * allows the user to cut, copy and paste text from/to the clip board and + * save the text in a file. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public class JRawTextPane extends JTextPane implements ClipboardOwner { + + /** */ + static final long serialVersionUID = 1L; + + /** Logger, Apache log4j. */ + private static Logger myLogger = Logger.getLogger(JRawTextPane.class); + + /** The clip board. */ + private Clipboard myClipboard; + + /** This. Reference needed for the actions. */ + private JRawTextPane myRawTextPane; + + /** The pop up menu. */ + private JPopupMenu myJPopupMenu; + + /** Direction of the text pane. */ + private Direction myDirection; + + /** + * Action: Insert text from the clip board at the cursor. + * If a text range is selected, the selection will be overwritten with the text from the clip board. + */ + private Action pasteAction = new AbstractAction() { + static final long serialVersionUID = 1L; + { + putValue(Action.NAME, Internationalization.getTranslation("ac_paste")); + putValue(Action.SHORT_DESCRIPTION, Internationalization.getTranslation("ac_paste_description")); + putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_PASTE)); + } + + public void actionPerformed(ActionEvent e) { + // paste + int pos = getCaretPosition(); + int start = getSelectionStart(); + int end = getSelectionEnd(); + + Transferable content = myClipboard.getContents(this); + if (content != null) { + try { + String s = (String) content.getTransferData(DataFlavor.stringFlavor); + if ((start >= 0) && (end >= 0) && (start < end)) { + // some text is selected, overwrite with clip board + setText(getText(0, start) + s + getText(end, getText().length() - end)); + } else { + // no text selected, insert clip board at cursor + setText(getText(0, pos) + s + getText(pos, getText().length() - pos)); + } + // TODO: place the cursor at the end of the edited text + } catch (IOException ioe) { + myLogger.error(ioe.getMessage(), ioe); + } catch (UnsupportedFlavorException usfe) { + myLogger.error(usfe.getMessage(), usfe); + } catch (BadLocationException ble) { + myLogger.error(ble.getMessage(), ble); + } + } + } + }; + + /** + * Action: Copy selected text to the clip board. + */ + private Action copyAction = new AbstractAction() { + static final long serialVersionUID = 1L; + { + putValue(Action.NAME, Internationalization.getTranslation("ac_copy")); + putValue(Action.SHORT_DESCRIPTION, Internationalization.getTranslation("ac_copy_description")); + putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_COPY)); + } + + public void actionPerformed(ActionEvent e) { + // copy + int start = getSelectionStart(); + int end = getSelectionEnd(); + try { + StringSelection content = new StringSelection(getText(start, end - start)); + myClipboard.setContents(content, myRawTextPane); + setText(getText(0, start) + getText(end, getText().length() - end)); + } catch (IllegalStateException ise) { + myLogger.error(ise.getMessage(), ise); + } catch (BadLocationException ble) { + myLogger.error(ble.getMessage(), ble); + } + } + }; + + /** + * Action: Cut. Selected text is copied to the clip board. + */ + private Action cutAction = new AbstractAction() { + static final long serialVersionUID = 1L; + { + putValue(Action.NAME, Internationalization.getTranslation("ac_cut")); + putValue(Action.SHORT_DESCRIPTION, Internationalization.getTranslation("ac_cut_description")); + putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_CUT)); + } + + public void actionPerformed(ActionEvent e) { + // cut + int start = getSelectionStart(); + int end = getSelectionEnd(); + try { + StringSelection content = new StringSelection(getText(start, end - start)); + myClipboard.setContents(content, myRawTextPane); + } catch (IllegalStateException ise) { + myLogger.error(ise.getMessage(), ise); + } catch (BadLocationException ble) { + myLogger.error(ble.getMessage(), ble); + } + } + }; + + /** + * Action: Save as. Selected text is saved in a file. + */ + private Action saveAsAction = new AbstractAction() { + static final long serialVersionUID = 1L; + { + putValue(Action.NAME, Internationalization.getTranslation("ac_saveas")); + putValue(Action.SHORT_DESCRIPTION, Internationalization.getTranslation("ac_saveas_description")); + putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_SAVEAS)); + } + + public void actionPerformed(ActionEvent e) { + // save as + int start = getSelectionStart(); + int end = getSelectionEnd(); + String buffer = ""; + + try { + if ((start >= 0) && (end >= 0) && (start < end)) { + // if text is selected, save only selected text + buffer = getText(start, end - start); + } else { + // save the whole text + buffer = getText(); + } + } catch (BadLocationException ble) { + myLogger.error(ble.getMessage(), ble); + } + + JFileChooser jFileChooser = new JFileChooser(); + jFileChooser.setDialogType(JFileChooser.SAVE_DIALOG); + jFileChooser.setDialogTitle(Internationalization.getTranslation("dlg_title_saveas")); + jFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + jFileChooser.setSelectedFile(new File(getDefaultFileName())); + + if (jFileChooser.showSaveDialog(myRawTextPane) == JFileChooser.APPROVE_OPTION) { + File file = jFileChooser.getSelectedFile(); + try { + FileOutputStream out = new FileOutputStream(file); + out.write(buffer.getBytes()); + out.flush(); + out.close(); + } catch (IOException ioe) { + JOptionPane.showMessageDialog(myRawTextPane, + Internationalization.getTranslation("dlg_ioerror_text") + "\n" + + ioe.getLocalizedMessage(), + Internationalization.getTranslation("dlg_ioerror_title"), + JOptionPane.ERROR_MESSAGE); + } + } + } + }; + + /** + * Constructor of JRawTextPane. + * + * @param direction Direction the text pane is used for displaying content (client or server). + */ + public JRawTextPane(Direction direction) { + myRawTextPane = this; + myDirection = direction; + initPopupMenu(); + myClipboard = getToolkit().getSystemClipboard(); + setComponentPopupMenu(myJPopupMenu); + } + + /** + * Initialize the pop up menu. + */ + private void initPopupMenu() { + myJPopupMenu = new JPopupMenu(); + myJPopupMenu.add(new JMenuItem(cutAction)); + myJPopupMenu.add(new JMenuItem(copyAction)); + myJPopupMenu.add(new JMenuItem(pasteAction)); + myJPopupMenu.add(new JMenuItem(saveAsAction)); + } + + /** + * This method returns the default filename. + * + * @return String + */ + private String getDefaultFileName() { + Date now = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); + + String side = "_server_"; + if (myDirection == Direction.ClientToServer) { + side = "_client_"; + } + + return "msg" + side + dateFormat.format(now) + ".rec"; + } + + /** + * {@inheritDoc} + * + * @see java.awt.datatransfer.ClipboardOwner#lostOwnership(java.awt.datatransfer.Clipboard, java.awt.datatransfer.Transferable) + */ + public void lostOwnership(Clipboard clipboard, Transferable content) { + myLogger.info("Clipboard overwritten by another application!"); + } +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-04-03 16:37:44 UTC (rev 103) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-04-05 15:43:38 UTC (rev 104) @@ -136,7 +136,7 @@ private JMenuItem jMenuItemClearRight = null; /** Client text pane. */ - private JTextPane jTextPaneClientRaw = null; + private JRawTextPane jTextPaneClientRaw = null; /** Client tab pane. */ private JTabbedPane jTabbedPaneClient = null; @@ -157,7 +157,7 @@ private JScrollPane jScrollPaneServerRaw = null; /** Server text pane. */ - private JTextPane jTextPaneServerRaw = null; + private JRawTextPane jTextPaneServerRaw = null; /** Menu item "about". */ private JMenuItem jMenuItemAbout = null; @@ -582,7 +582,7 @@ */ private JTextPane getJTextPaneClientRaw() { if (jTextPaneClientRaw == null) { - jTextPaneClientRaw = new JTextPane(); + jTextPaneClientRaw = new JRawTextPane(Direction.ClientToServer); jTextPaneClientRaw.setText(""); jTextPaneClientRaw.setEditable(true); } @@ -675,7 +675,7 @@ */ private JTextPane getJTextPaneServerRaw() { if (jTextPaneServerRaw == null) { - jTextPaneServerRaw = new JTextPane(); + jTextPaneServerRaw = new JRawTextPane(Direction.ServerToClient); jTextPaneServerRaw.setText(""); jTextPaneServerRaw.setEditable(true); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java 2008-04-03 16:37:44 UTC (rev 103) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java 2008-04-05 15:43:38 UTC (rev 104) @@ -84,7 +84,19 @@ /** */ public static final String ICON_CONFIGURE = "configure.png"; + + /** */ + public static final String ICON_PASTE = "editpaste.png"; + + /** */ + public static final String ICON_COPY = "editcopy.png"; + /** */ + public static final String ICON_CUT = "editcut.png"; + + /** */ + public static final String ICON_SAVEAS = "filesaveas.png"; + /** This hash map is used to cache the ImageIcons. */ private static final Map<String, ImageIcon> RESOURCE_MAP = new HashMap<String, ImageIcon>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-04-03 16:38:09
|
Revision: 103 http://davinspector.svn.sourceforge.net/davinspector/?rev=103&view=rev Author: wuest Date: 2008-04-03 09:37:44 -0700 (Thu, 03 Apr 2008) Log Message: ----------- New plugin: raweditplugin Added Paths: ----------- trunk/DAVInspector/src/de/dlr/davinspector/plugins/raweditplugin/ trunk/DAVInspector/src/de/dlr/davinspector/plugins/raweditplugin/RawEditPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/raweditplugin/package.html Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/raweditplugin/RawEditPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/raweditplugin/RawEditPlugin.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/raweditplugin/RawEditPlugin.java 2008-04-03 16:37:44 UTC (rev 103) @@ -0,0 +1,291 @@ +/* + * RawEdit.java + * + * TODO: wues_ha Enter comment! + * + * Created: 31.03.2008 wues_ha <email> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.plugins.raweditplugin; + +import java.awt.BorderLayout; +import java.awt.Component; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; + +import de.dlr.davinspector.common.Util; +import de.dlr.davinspector.history.AMessage; +import de.dlr.davinspector.plugin.IEditPlugin; +import de.dlr.davinspector.plugin.IViewPlugin; +import de.dlr.davinspector.plugin.PluginManager; + + +/** + * TODO: wues_ha: Enter comment! + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public class RawEditPlugin implements IEditPlugin, IViewPlugin { + + /** State of the plugin. */ + private Boolean isActive = true; + + /** The direction the plugin is assigned to. */ + private PluginDirection myPlugInDirection; + + /** The PluginManager. */ + private PluginManager myPluginManager; + + /** The message. */ + private AMessage myMessage; + + /** The JPanel contains the JTextPane in a JScrollPane and the JPanel with the Apply-Button. */ + private JPanel myJPanel = null; + + /** The button bar, contains the apply-button. */ + private JPanel myJPanelButtonBar = null; + + /** The apply-button. */ + private JButton myJButtonApply = null; + + /** The text pane. */ + private JTextPane myJTextPane = null; + + /** The scroll pane, contains the text pane. */ + private JScrollPane myJScrollPane = null; + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.plugin.IEditPlugin#getOutput() + */ + public AMessage getOutput() { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IViewPlugin#getUI() + */ + public JComponent getUI() { + return myJPanel; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IPlugin#getAuthor() + */ + public String getAuthor() { + return "Jochen Wuest"; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IPlugin#getDescription() + */ + public String getDescription() { + return "Edit the raw data of a message."; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IPlugin#getName() + */ + public String getName() { + return "RawEdit"; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IPlugin#getType() + */ + public PluginType getType() { + return PluginType.EDIT_GENERAL; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IPlugin#getVersion() + */ + public int getVersion() { + return 1; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IPlugin#init() + */ + public void init(PluginManager pluginManager, PluginDirection direction) { + myPluginManager = pluginManager; + myPlugInDirection = direction; + if (myJPanel == null) { + myJPanel = new JPanel(); + myJPanel.setLayout(new BorderLayout()); + + // Scrollpane with Textpane + myJScrollPane = new JScrollPane(); + myJTextPane = new JTextPane(); + myJTextPane.setEditable(true); + myJScrollPane.setViewportView(myJTextPane); + + myJPanel.add(myJScrollPane, BorderLayout.CENTER); + myJPanel.add(getJPanelButtonBar(), BorderLayout.SOUTH); + } + + myJTextPane.setText(""); + Util.setUIDesign(); + } + + /** + * This method initializes jPanelButtonBar. + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelButtonBar() { + if (myJPanelButtonBar == null) { + myJPanelButtonBar = new JPanel(); + myJPanelButtonBar.setLayout(new BoxLayout(myJPanelButtonBar, BoxLayout.LINE_AXIS)); + myJPanelButtonBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + myJPanelButtonBar.setAlignmentX(Component.RIGHT_ALIGNMENT); + myJPanelButtonBar.add(Box.createHorizontalGlue()); + myJPanelButtonBar.add(getJButtonApply()); + } + return myJPanelButtonBar; + } + + /** + * This method initializes jButtonApply. + * + * @return javax.swing.JButton + */ + private JButton getJButtonApply() { + if (myJButtonApply == null) { + myJButtonApply = new JButton(); + myJButtonApply.setText("Apply"); + myJButtonApply.setAlignmentX(Component.RIGHT_ALIGNMENT); + myJButtonApply.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent e) { + // get edited text from the text pane + myMessage.setRawBody(myJTextPane.getText()); + myMessage.setBody(myJTextPane.getText()); + // trigger update event with edited data and direction + myPluginManager.messageEditedEvent(myPlugInDirection, myMessage); + } + }); + } + return myJButtonApply; + } + +// public void setPluginManager(PluginManager pluginManager); + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.plugin.IEditPlugin#enableEditing() + */ + public void enableEditing() { + myJButtonApply.setEnabled(true); + myJTextPane.setEditable(true); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.plugin.IEditPlugin#disableEditing() + */ + public void disableEditing() { + myJButtonApply.setEnabled(false); + myJTextPane.setEditable(false); + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.plugin.IPlugin#shutdown() + */ + public void shutdown() { + // empty + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IPlugin#isActive() + */ + public Boolean isActive() { + return isActive; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IPlugin#setActive(java.lang.Boolean) + */ + public void setActive(Boolean state) { + isActive = state; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.DAVInspector.Plugin.IPlugin#update(java.lang.String) + */ + public void update(AMessage msg) { + if (isActive && myJTextPane != null) { + myMessage = msg; + myJTextPane.setText(myMessage.getRawBody()); + } + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.plugin.IPlugin#clear() + */ + public void clear() { + if (myJTextPane != null) { + myJTextPane.setText(""); + } + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.plugin.IPlugin#getPluginDirection() + */ + public PluginDirection getPluginDirection() { + return myPlugInDirection; + } +} Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/raweditplugin/package.html =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/raweditplugin/package.html (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/raweditplugin/package.html 2008-04-03 16:37:44 UTC (rev 103) @@ -0,0 +1,6 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" +"http://www.w3.org/TR/REC-html40/loose.dtd"> + +<html><head><title>Raw-Edit Plugin</title></head><body> +This package contains all classes needed to edit the raw data of a message. +</body></html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-04-03 16:36:34
|
Revision: 102 http://davinspector.svn.sourceforge.net/davinspector/?rev=102&view=rev Author: wuest Date: 2008-04-03 09:36:25 -0700 (Thu, 03 Apr 2008) Log Message: ----------- Added new visual component to display header information in different categories. Modified Paths: -------------- trunk/DAVInspector/build-user.xml trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java Added Paths: ----------- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/minus.png trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/plus.png Modified: trunk/DAVInspector/build-user.xml =================================================================== --- trunk/DAVInspector/build-user.xml 2008-04-03 16:33:49 UTC (rev 101) +++ trunk/DAVInspector/build-user.xml 2008-04-03 16:36:25 UTC (rev 102) @@ -53,6 +53,10 @@ basedir="bin" includes="de/dlr/davinspector/plugins/recordingplugin/**"> </jar> + <jar jarfile="${dist}/plugins/RawEditPlugin.jar" + basedir="bin" + includes="de/dlr/davinspector/plugins/raweditplugin/**"> + </jar> <!-- Copy DAVInspector resource files --> <copy todir="bin/de/dlr/davinspector/resource"> @@ -67,7 +71,7 @@ <manifest> <attribute name="Main-Class" value="de/dlr/davinspector.DAVInspector"/> <attribute name="Built-By" value="${user.name}"/> - <attribute name="Class-Path" value=". log4j.properties lib/log4j.jar"/> + <attribute name="Class-Path" value=". /plugins/RecordingPlugin.jar log4j.properties lib/log4j.jar"/> <section name="DAVInspector"> <attribute name="Specification-Title" value="${project.name}"/> Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-04-03 16:33:49 UTC (rev 101) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-04-03 16:36:25 UTC (rev 102) @@ -25,9 +25,9 @@ package de.dlr.davinspector.plugins.headerplugin; +import javax.swing.BoxLayout; import javax.swing.JComponent; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; +import javax.swing.JPanel; import de.dlr.davinspector.common.Util; import de.dlr.davinspector.history.AMessage; @@ -49,19 +49,28 @@ /** State of the plugin. */ private Boolean isActive = true; - /** The text pane. */ - private JTextPane myJTextPane = null; + /** The panel. */ + private JPanel myJPanel = null; - /** The scroll pane. */ - private JScrollPane myJScrollPane = null; + /** */ + private JCategoryTable myResponseHeaders; + /** */ + private JCategoryTable myRequestHeaders; + + /** */ + private JCategoryTable myMiscHeaders; + + /** */ + private JCategoryTable myCommonHeaders; + /** * {@inheritDoc} * * @see de.dlr.DAVInspector.Plugin.IViewPlugin#getUI() */ public JComponent getUI() { - return myJScrollPane; + return myJPanel; } /** @@ -106,7 +115,7 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#getVersion() */ public int getVersion() { - return 1; + return 2; } /** @@ -116,13 +125,27 @@ */ public void init(PluginManager pluginManager, PluginDirection direction) { myPlugInDirection = direction; - if (myJScrollPane == null) { - myJScrollPane = new JScrollPane(); - myJTextPane = new JTextPane(); - myJTextPane.setEditable(false); - myJScrollPane.setViewportView(myJTextPane); + if (myJPanel == null) { + + myJPanel = new JPanel(); + myJPanel.setLayout(new BoxLayout(myJPanel, BoxLayout.PAGE_AXIS)); + + myCommonHeaders = new JCategoryTable(myJPanel, "Common"); + myResponseHeaders = new JCategoryTable(myJPanel, "Response"); + myRequestHeaders = new JCategoryTable(myJPanel, "Request"); + myMiscHeaders = new JCategoryTable(myJPanel, "Misc"); + + myJPanel.add(myCommonHeaders); + myJPanel.add(myResponseHeaders); + myJPanel.add(myRequestHeaders); + myJPanel.add(myMiscHeaders); + + // test data + myCommonHeaders.addRow(new Object[]{"ert", "zui"}); + myResponseHeaders.addRow(new Object[]{"test", "test2"}); + myRequestHeaders.addRow(new Object[]{"test3", "test4"}); + myMiscHeaders.addRow(new Object[]{"ghj", "l\xF6\xE4"}); } - myJTextPane.setText(""); Util.setUIDesign(); } @@ -168,8 +191,12 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#update(java.lang.String) */ public void update(AMessage msg) { - if (isActive && myJTextPane != null) { - myJTextPane.setText(msg.getHeader()); + if (isActive && myJPanel != null) { + // TODO: Update tables; +// myCommonHeaders.clearTable(); +// myResponseHeaders.clearTable(); +// myRequestHeaders.clearTable(); +// myMiscHeaders.clearTable(); } } @@ -179,17 +206,11 @@ * @see de.dlr.davinspector.plugin.IPlugin#clear() */ public void clear() { - if (myJTextPane != null) { - myJTextPane.setText(""); + if (myJPanel != null) { + myCommonHeaders.clearTable(); + myResponseHeaders.clearTable(); + myRequestHeaders.clearTable(); + myMiscHeaders.clearTable(); } } - -// /** -// * {@inheritDoc} -// * -// * @see de.dlr.davinspector.plugin.IEditPlugin#getOutput() -// */ -// public AMessage getOutput() { -// return new Message(); -// } } Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java 2008-04-03 16:36:25 UTC (rev 102) @@ -0,0 +1,169 @@ +/* + * JCategoryTable.java + * + * TODO: wues_ha Enter comment! + * + * Created: 03.04.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.plugins.headerplugin; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.SystemColor; + +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JToggleButton; +import javax.swing.SwingConstants; +import javax.swing.table.DefaultTableModel; + + +/** + * TODO: wues_ha: Enter comment! + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public class JCategoryTable extends JPanel { + + /** Serial Version UID, not valid. */ + private static final long serialVersionUID = 1L; + + /** */ + private final ImageIcon iconPlus = + new ImageIcon(JCategoryTable.class.getResource("/de/dlr/davinspector/plugins/headerplugin/plus.png")); + + /** */ + private final ImageIcon iconMinus = + new ImageIcon(JCategoryTable.class.getResource("/de/dlr/davinspector/plugins/headerplugin/minus.png")); + + /** */ + private JToggleButton jToggleButton; + + /** */ + private JScrollPane jScrollPane; + + /** */ + private JTable jTable; + + /** */ + private Dimension sizePanel; + + /** */ + private DefaultTableModel myCategoryTableModel; + + /** */ + private JComponent myComponent; + + /** + * Constructor for JCategoryTable. + * + * @param component {@link JComponent} The parent JComponent object. + * @param tableTitle {@link String} The title of the Table. + */ + public JCategoryTable(JComponent component, String tableTitle) { + myComponent = component; + init(tableTitle); + } + + /** + * This method initializes all visual elements. + * + * @param tableTitle The title of the Table. + */ + private void init(String tableTitle) { + + jToggleButton = new JToggleButton(); + jScrollPane = new JScrollPane(); + jTable = new JTable(); + + jToggleButton.setIcon(iconPlus); + jToggleButton.setSelectedIcon(iconMinus); + jToggleButton.setSelected(true); + jToggleButton.setText(tableTitle); + jToggleButton.setBorder(null); + jToggleButton.setBorderPainted(false); + jToggleButton.setFocusPainted(false); + jToggleButton.setBackground(SystemColor.LIGHT_GRAY); + jToggleButton.setHorizontalAlignment(SwingConstants.LEFT); + + jToggleButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jToggleButtonActionPerformed(evt); + } + }); + + myCategoryTableModel = new DefaultTableModel(); + myCategoryTableModel.addColumn("Key"); + myCategoryTableModel.addColumn("Value"); + + // TODO: do not allow editing of table data + jTable.setModel(myCategoryTableModel); + jTable.setTableHeader(null); + + jScrollPane.setViewportView(jTable); + + setLayout(new BorderLayout()); + add(jToggleButton, BorderLayout.NORTH); + add(jScrollPane, BorderLayout.CENTER); + } + + /** + * This method handles the toggle button event. On action "hide" the current size of + * the panel is stored in <code>sizePanel</code>, the table is set invisible and the + * parent component is forced to refresh the layout. On action "show" the stored panel + * size is restored and the parent component is forced to refresh it's layout. + * + * @param evt Event + */ + private void jToggleButtonActionPerformed(java.awt.event.ActionEvent evt) { + if (jScrollPane.isVisible()) { + jScrollPane.setVisible(false); + sizePanel = getSize(); + setSize(jToggleButton.getSize()); + myComponent.validate(); + } else { + jScrollPane.setVisible(true); + setSize(sizePanel); + myComponent.validate(); + } + } + + /** + * This method adds a row to the table. + * A row consists of two columns: key and value. + * + * @param rowData Object[] + */ + public void addRow(Object[] rowData) { + myCategoryTableModel.addRow(rowData); + } + + /** + * This method deletes all rows. + */ + public void clearTable() { + myCategoryTableModel.setRowCount(0); + } +} Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/minus.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/minus.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/plus.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/plus.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-04-03 16:34:35
|
Revision: 101 http://davinspector.svn.sourceforge.net/davinspector/?rev=101&view=rev Author: wuest Date: 2008-04-03 09:33:49 -0700 (Thu, 03 Apr 2008) Log Message: ----------- Test of i18n for plugins. Does not work at the moment. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/common/Internationalization.java Added Paths: ----------- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/recordingPlugin.properties trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/recordingPlugin_de_DE.properties Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Internationalization.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Internationalization.java 2008-04-02 15:43:10 UTC (rev 100) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Internationalization.java 2008-04-03 16:33:49 UTC (rev 101) @@ -48,7 +48,7 @@ /** * This method returns the translation for the given key. - * The information is extracted from the proper language file. + * The translation is extracted from the proper language file. * * @param key String * @return String @@ -56,4 +56,30 @@ public static String getTranslation(String key) { return Internationalization.RESOURCE_BUNDLE.getString(key); } + + /** + * This method returns the translation for the given key. + * The translation is extracted from the proper language file of the plugin. + * + * @param packageName String + * @param key String + * @return String + */ + public static String getTranslationPlugin(String packageName, String key) { + // plugins\RecordingPlugin.jar\de\dlr\davinspector\plugins\recordingplugin\ + // INFO: caching of resource bundles -> Not necessary, java handles caching on it's own + return ResourceBundle.getBundle("/" + getPackagePath(packageName) + "/" + "recordingPlugin", Locale.getDefault()).getString(key); +// return ResourceBundle.getBundle(packageName + "." + "recordingPlugin", Locale.getDefault()).getString(key); +// return ResourceBundle.getBundle("\\recordingPlugin", Locale.getDefault()).getString(key); + } + + /** + * Converts the class package name to a file system path. + * + * @param packageName String + * @return String + */ + private static String getPackagePath(String packageName) { + return packageName.replace('.', '/'); + } } Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/recordingPlugin.properties =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/recordingPlugin.properties (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/recordingPlugin.properties 2008-04-03 16:33:49 UTC (rev 101) @@ -0,0 +1 @@ +plugin_name=Aufzeichnungs-Plugin Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/recordingPlugin_de_DE.properties =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/recordingPlugin_de_DE.properties (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/recordingPlugin_de_DE.properties 2008-04-03 16:33:49 UTC (rev 101) @@ -0,0 +1 @@ +plugin_name=Recording Plugin This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-04-02 15:43:25
|
Revision: 100 http://davinspector.svn.sourceforge.net/davinspector/?rev=100&view=rev Author: wuest Date: 2008-04-02 08:43:10 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Renaming of vars and classes. Corrected errors in the message processing path. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageEvent.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/IEditPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayThread.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java Added Paths: ----------- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/history/Message.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IClientDataListener.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IServerDataListener.java Removed Paths: ------------- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/history/Message.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/relay/INewClientDataListener.java trunk/DAVInspector/src/de/dlr/davinspector/relay/INewServerDataListener.java Deleted: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-04-02 15:43:10 UTC (rev 100) @@ -1,209 +0,0 @@ -/* - * AMessage.java - * - * The abstract class for messages. - * - * Created: 29.02.2008 Jochen Wuest <joc...@dl...> - * Changed: - * - * $Id$ - * - * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.dlr.davinspector.history; - -import java.util.Date; - -import de.dlr.davinspector.common.Constant.Direction; - - -/** - * The abstract class for messages. - * - * @version $LastChangedRevision$ - * @author Jochen Wuest - */ -public abstract class AMessage { - - /** The counter for unique numbering. */ - protected static int idCounter = 1; - - /** Parsing state of the message. */ - protected Boolean myParsingState; - - /** Unique ID of a message. */ - protected int myID; - - /** Timestamp of the current message. */ - protected Date myTimestamp; - - /** myDirection indicates the direction of the message. @see MessageDirection */ - protected Direction myDirection; - - /** This string contains the raw data of the message. */ - protected String myRawData; - - /** This string contains the unprocessed header of the message. */ - protected String myRawHeader; - - /** This string contains the unprocessed body of the message. */ - protected String myRawBody; - - /** This string contains the processed header of the message. */ - protected String myParsedHeader; - - /** This string contains the processed body of the message. */ - protected String myParsedBody; - - /** The size in bytes of the current message. */ - protected int mySize; - - /** - * This method returns the ID of the message. - * - * @return id - */ - public int getId() { - return myID; - } - - /** - * This method returns the timestamp of the message. - * - * @return timestamp - */ - public Date getTimestamp() { - return myTimestamp; - } - - /** - * This method sets the timestamp of the current message. - * - * @param timestamp Date/Timestamp - */ - public void setTimestamp(Date timestamp) { - myTimestamp = timestamp; - } - - /** - * Returns the direction (request/reply) of the message. - * @see MessageDirection - * - * @return MessageDirection - */ - public Direction getMessageDirection() { - return myDirection; - } - - /** - * This method sets the message direction. - * @see MessageDirection - * - * @param direction Direction - */ - public void setMessageDirection(Direction direction) { - myDirection = direction; - } - - /** - * Returns the size of the message in bytes. - * - * @return size int - */ - public int getSize() { - return mySize; - } - - /** - * This method parses the current raw data. - * If the buffer contains more than the data needed for the current message, - * the remaining data is returned. - * - * @return String - */ - public String parseMessage() { - return ""; - } - - /** - * This method returns <code>true</code> if the message processing is done - * and a valid message has been recognized. - * - * @return Boolean - */ - public Boolean isComplete() { - return myParsingState; - } - - /** - * Returns the raw data of the message. - * - * @return data String - */ - public String getRawData() { - return myRawData; - } - - /** - * Sets the raw data of the current message. - * Message size, ID, body and header are automatically added. - * - * @param msg String - */ - public void setRawData(String msg) { - myRawData = msg; - mySize = msg.length(); - myID = idCounter; - } - - /** - * Returns the parsed head of the message. - * By default this returns the same as <code>getRawHeader</code>. - * - * @return String - */ - public String getMessageHeader() { - return myParsedHeader; - } - - /** - * Returns the raw, unparsed head of the message. - * - * @return String - */ - public String getRawHeader() { - return myRawHeader; - } - - /** - * Returns the parsed body of the message. - * By default this returns the same as <code>getRawBody</code>. - * - * @return String - */ - public String getMessageBody() { - return myParsedBody; - } - - /** - * Returns the raw, unparsed body of the message. - * - * @return String - */ - public String getRawBody() { - return myRawBody; - } -} Added: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-04-02 15:43:10 UTC (rev 100) @@ -0,0 +1,247 @@ +/* + * AMessage.java + * + * The abstract class for messages. + * + * Created: 29.02.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.history; + +import java.util.Date; + +import de.dlr.davinspector.common.Constant.Direction; + + +/** + * The abstract class for messages. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public abstract class AMessage { + + /** The counter for unique numbering. */ + protected static int idCounter = 1; + + /** Parsing state of the message. */ + protected Boolean myParsingState; + + /** Unique ID of a message. */ + protected int myID; + + /** Timestamp of the current message. */ + protected Date myTimestamp; + + /** myDirection indicates the direction of the message. @see MessageDirection */ + protected Direction myDirection; + + /** This string contains the raw data of the message. */ + protected String myRawData; + + /** This string contains the unprocessed header of the message. */ + protected String myRawHeader; + + /** This string contains the unprocessed body of the message. */ + protected String myRawBody; + + /** This string contains the processed header of the message. */ + protected String myParsedHeader; + + /** This string contains the processed body of the message. */ + protected String myParsedBody; + + /** The size in bytes of the current message. */ + protected int mySize; + + /** + * This method returns the ID of the message. + * + * @return id + */ + public int getId() { + return myID; + } + + /** + * This method returns the timestamp of the message. + * + * @return timestamp + */ + public Date getTimestamp() { + return myTimestamp; + } + + /** + * This method sets the timestamp of the current message. + * + * @param timestamp Date/Timestamp + */ + public void setTimestamp(Date timestamp) { + myTimestamp = timestamp; + } + + /** + * Returns the direction (request/reply) of the message. + * @see MessageDirection + * + * @return MessageDirection + */ + public Direction getDirection() { + return myDirection; + } + + /** + * This method sets the message direction. + * @see MessageDirection + * + * @param direction Direction + */ + public void setDirection(Direction direction) { + myDirection = direction; + } + + /** + * Returns the size of the message in bytes. + * + * @return size int + */ + public int getSize() { + return mySize; + } + + /** + * This method parses the current raw data. + * If the buffer contains more than the data needed for the current message, + * the remaining data is returned. + * + * @return String + */ + public abstract String parse(); + + /** + * This method returns <code>true</code> if the message processing is done + * and a valid message has been recognized. + * + * @return Boolean + */ + public Boolean isComplete() { + return myParsingState; + } + + /** + * Returns the raw data of the message. + * + * @return data String + */ + public String getRawData() { + return myRawData; + } + + /** + * Sets the raw data of the current message. + * Message size and ID are automatically added. + * + * @param msg String + */ + public void setRawData(String msg) { + myRawData = msg; + mySize = msg.length(); + myID = idCounter; + } + + /** + * Sets the raw data of the body of the current message. + * Message size is automatically added. + * + * @param msg String + */ + public void setRawBody(String msg) { + myRawBody = msg; + mySize = msg.length(); + } + + /** + * Sets the raw data of the header of the current message. + * + * @param msg String + */ + public void setRawHeader(String msg) { + myRawHeader = msg; + } + + /** + * Sets the data of the body of the current message. + * Message size is automatically added. + * + * @param msg String + */ + public void setBody(String msg) { + myParsedBody = msg; + mySize = msg.length(); + } + + /** + * Sets the data of the header of the current message. + * + * @param msg String + */ + public void setHeader(String msg) { + myParsedHeader = msg; + } + + /** + * Returns the parsed head of the message. + * By default this returns the same as <code>getRawHeader</code>. + * + * @return String + */ + public String getHeader() { + return myParsedHeader; + } + + /** + * Returns the raw, unparsed head of the message. + * + * @return String + */ + public String getRawHeader() { + return myRawHeader; + } + + /** + * Returns the parsed body of the message. + * By default this returns the same as <code>getRawBody</code>. + * + * @return String + */ + public String getBody() { + return myParsedBody; + } + + /** + * Returns the raw, unparsed body of the message. + * + * @return String + */ + public String getRawBody() { + return myRawBody; + } +} Deleted: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java 2008-04-02 15:43:10 UTC (rev 100) @@ -1,55 +0,0 @@ -/* - * AMessageParser.java - * - * The abstract class for message parsers. - * - * Created: 29.02.2008 Jochen Wuest <joc...@dl...> - * Changed: - * - * $Id$ - * - * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.dlr.davinspector.history; - - -/** - * The abstract class for message parsers. - * - * @version $LastChangedRevision$ - * @author Jochen Wuest - */ -public abstract class AMessageParser extends AMessage { - - /** The Message. */ - protected AMessage myMessage; - - /** - * Constructor of the abstract MessageParser class. - * - * @param aMessage AMessage - */ - public AMessageParser(AMessage aMessage) { - myMessage = aMessage; - } - - /** - * {@inheritDoc} - * - * @see de.dlr.davinspector.history.AMessage#parseMessage() - */ - public abstract String parseMessage(); -} Added: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java 2008-04-02 15:43:10 UTC (rev 100) @@ -0,0 +1,59 @@ +/* + * AMessageParser.java + * + * The abstract class for message parsers. + * + * Created: 29.02.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.history; + + + + +/** + * The abstract class for message parsers. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public abstract class AMessageParser extends AMessage { + + /** The message. */ + private AMessage myMessage; + + /** + * Constructor. + * + * @param aMessage AMessage + */ + public AMessageParser(AMessage aMessage) { + myMessage = aMessage; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.history.AMessage#parse() + */ + public String parse() { + return myMessage.parse(); + } +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-04-02 15:43:10 UTC (rev 100) @@ -84,7 +84,7 @@ public void newMessage(MessageEvent newMessageEvent) { // update history table AMessage msg = newMessageEvent.getMessage(); - addRow(new Object[]{msg.getMessageDirection(), msg.getId(), msg.getTimestamp(), msg.getSize()}); + addRow(new Object[]{msg.getDirection(), msg.getId(), msg.getTimestamp(), msg.getSize()}); fireTableDataChanged(); } } Deleted: trunk/DAVInspector/src/de/dlr/davinspector/history/Message.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/Message.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/Message.java 2008-04-02 15:43:10 UTC (rev 100) @@ -1,43 +0,0 @@ -/* - * Message.java - * - * This class represents a single message. - * - * Created: 15.01.2008 Jochen Wuest <joc...@dl...> - * Changed: - * - * $Id$ - * - * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.dlr.davinspector.history; - - -/** - * This class represents a single message. - * - * @version $LastChangedRevision$ - * @author Jochen Wuest - */ -public class Message extends AMessage { - - /** - * Constructor, every new message increases <code>idCounter</code>. - */ - public Message() { - ++idCounter; - } -} Added: trunk/DAVInspector/src/de/dlr/davinspector/history/Message.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/Message.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/Message.java 2008-04-02 15:43:10 UTC (rev 100) @@ -0,0 +1,54 @@ +/* + * Message.java + * + * This class represents a single message. + * + * Created: 15.01.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.history; + + + + +/** + * This class represents a single message. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public class Message extends AMessage { + + /** + * Constructor, every new message increases <code>idCounter</code>. + */ + public Message() { + ++idCounter; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.history.AMessage#parse() + */ + public String parse() { + return ""; + } +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageEvent.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageEvent.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageEvent.java 2008-04-02 15:43:10 UTC (rev 100) @@ -28,6 +28,7 @@ import java.util.EventObject; + /** * This class represents a message event. * Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-04-02 15:43:10 UTC (rev 100) @@ -32,6 +32,7 @@ import javax.swing.event.EventListenerList; + /** * This class saves and provides access to the processed messages. * Deleted: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-04-02 15:43:10 UTC (rev 100) @@ -1,354 +0,0 @@ -/* - * HTTPMessageParser.java - * - * This class is a very simple approach to parse http messages. - * - * Created: 23.01.2008 Jochen Wuest <joc...@dl...> - * Changed: - * - * $Id$ - * - * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.dlr.davinspector.http; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.log4j.Logger; - -import de.dlr.davinspector.common.Constant; -import de.dlr.davinspector.common.Constant.Direction; -import de.dlr.davinspector.history.AMessage; -import de.dlr.davinspector.history.AMessageParser; - -/** - * This class is a very simple approach to parse http messages. - * More information: - * HTTP/1.1 RFC 2616 - * HTTP/1.0 RFC 1945 - * - * @version $LastChangedRevision$ - * @author Jochen Wuest - */ -public class HTTPMessageParser extends AMessageParser { - - /** - * This expression matches the http request line. - * (METHOD) SPACE (URL) SPACE (VERSION) CRLF - * RFC 2616: Request-Line = Method SP Request-URI SP HTTP-Version CRLF - * TODO: URL scanning not complete. - * TODO: add ACL, DASL methods etc. / split into different parts (http, webdav, dasl, acl, ...) / check with markus - * checkout, checkin, uncheckout, update, report, merge -> litmus test? - */ - private static final String REGEX_HTTP_REQUEST_LINE = "^(\\bUNKNOWN\\b|\\bHEAD\\b|\\bGET\\b|\\bPOST\\b|\\bPUT\\b|" - + "\\bDELETE\\b|\\bOPTIONS\\b|\\bTRACE\\b|\\bCONNECT\\b|\\bPROPFIND\\b|\\bPROPPATCH\\b|\\bMKCOL\\b|" - + "\\bCOPY\\b|\\bMOVE\\b|\\bLOCK\\b|\\bUNLOCK\\b|\\bREPORT\\b){1}" - + " ([\\w|/|~|.|_|-]+)" - + " (\\bHTTP/1.1\\b|\\bHTTP/1.0\\b|\\bHTTP/0.9\\b){1}\r\n"; - - /** - * This expression matches the http status line. - * (VERSION) SPACE (STATUS-CODE) SPACE (REASON) CRLF - * RFC 2616: Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF - */ - private static final String REGEX_HTTP_STATUS_LINE = "^(\\bHTTP/1.1\\b|\\bHTTP/1.0\\b|\\bHTTP/0.9\\b){1}" - + " ([0-9]{3})" - + " ([\\w|-]+)\r\n"; - - /** - * This expression matches an empty line. These empty lines divide a message - * into header and body. If the data is chunk-encoded, the chunks are also divided by an empty line. - */ - private static final String REGEX_EMPTY_LINE = "\r\n\r\n"; - - /** - * This expression matches the content-length information of a http message. - * Content-length: SPACE* (LENGTH) CRLF - */ - private static final String REGEX_CONTENT_LENGTH = "Content-length:[ ]*([0-9]+)\r\n"; - - /** - * This expression matches the length information of a chunk. - * CRLF (LENGTH-IN-HEX) CRLF - * INFO: Currently no chunk extensions are handled. - */ - private static final String REGEX_CHUNK_SIZE = "\r\n([0-9a-fA-F]+)\r\n"; - - /** - * This expression matches the transfer encoding of a message. - * Transfer-Encoding: SPACE* chunked CRLF - * INFO: Currently no transfer extensions are handled. - */ - private static final String REGEX_IS_CHUNKED = "Transfer-Encoding:[ ]*chunked\r\n"; - - /** Logger, Apache log4j. */ - private static Logger myLogger = Logger.getLogger(HTTPMessageParser.class); - - /** The http request method. */ - private String myMethod; - - /** The http response status code. */ - private int myStatusCode = 0; - - /** Version of the http protocol uesed by the message. */ - private String myProtocolVersion = ""; - - /** <code>True</code> if the message uses chunked encoding. */ - private Boolean isChunked = false; - - /** Length of the message body in bytes. */ - private int myContentLength = 0; - - /** - * Constructor. - * - * @param aMessage AMessage - */ - public HTTPMessageParser(AMessage aMessage) { - super(aMessage); - myParsingState = false; - } - - /** - * This method extracts the header and body from the raw data of the message. - * The data from the start to the first empty line presents the <code>myRawHeader</code>, - * the data from the first empty line until the end of the raw data presents the <code>myRawBody</code>. - */ - private void extractHeaderBody() { - String[] s = myRawData.split(REGEX_EMPTY_LINE); - myRawHeader = s[0]; - for (int i = 1; i < s.length; i++) { - myRawBody += s[i]; - } - } - - /** - * {@inheritDoc} - * - * @see de.dlr.davinspector.history.AMessageParser#parseMessage() - * - * TODO: extract "100 Continue" Messages - */ - public String parseMessage() { - myLogger.debug("---- new data event ----"); - myLogger.debug("Direction: " + myDirection); - - String carryover = ""; - - myParsedHeader = ""; - myRawHeader = ""; - myParsedBody = ""; - myRawBody = ""; - - if (myDirection == Direction.ServerToClient) { - Pattern pattern = Pattern.compile(REGEX_HTTP_STATUS_LINE, Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(myRawData); - if (matcher.find()) { - myLogger.debug("found status line"); - myMethod = ""; // INFO: set last method - myStatusCode = Integer.parseInt(matcher.group(2)); - myProtocolVersion = matcher.group(1); - isChunked = isChunked(); - myContentLength = getContentLength(); - } else { - myLogger.debug("No status line found."); - } - } else { - Pattern pattern = Pattern.compile(REGEX_HTTP_REQUEST_LINE, Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(myRawData); - if (matcher.find()) { - myLogger.debug("found request line"); - myMethod = matcher.group(1); - myStatusCode = 0; - myProtocolVersion = matcher.group(3); - isChunked = false; - myContentLength = getContentLength(); - } else { - myLogger.debug("No request line found."); - } - } - - if (myLogger.isDebugEnabled()) { - myLogger.debug("########"); - myLogger.debug("Method :" + myMethod); - myLogger.debug("Status :" + myStatusCode); - myLogger.debug("Version:" + myProtocolVersion); - myLogger.debug("Len :" + myContentLength); - myLogger.debug("Chunked:" + isChunked); - myLogger.debug("########"); - } - -// myLogger.debug("\n" + myRawData + "\n"); - - extractHeaderBody(); - myParsedHeader = myRawHeader; - - // Content-length = 0 or no body -> empty body - if (!isChunked && (myContentLength == 0 || !hasBody())) { - myLogger.debug("no body"); - myParsedBody = ""; - carryover = myRawBody; - myParsingState = true; - } else { - if (isChunked) { - myLogger.debug("decode chunked encoding"); - myParsedBody = decodeChunkedEncoding(myRawBody); - carryover = ""; //myRawData; // TODO: Set carry. ### - if (!myParsingState) { - myLogger.debug("decoding chunked encoding not finished"); - } - } else { - myLogger.debug("normal message"); - if (myContentLength > myRawBody.length()) { - myContentLength = 0; - myLogger.debug("normal message not finished"); - } - myParsedBody = myRawBody.substring(0, myContentLength); - carryover = myRawBody.substring(myContentLength, myRawBody.length()); - myParsingState = true; - } - } - - myLogger.debug("Carry: " + carryover.length()); - - return carryover; - } - - /** - * This method returns <code>true</code> if the message has a body. - * In the case that the command does not require a message body - * the method returns <code>false</code>. - * - * @return Boolean - */ - private Boolean hasBody() { - if (myDirection == Direction.ServerToClient) { - if (myStatusCode == HTTPStatusCode.HTTP_CONTINUE - || myStatusCode == HTTPStatusCode.HTTP_SWITCHING_PROTOCOLS - || myStatusCode == HTTPStatusCode.HTTP_NO_CONTENT - || myStatusCode == HTTPStatusCode.HTTP_NOT_MODIFIED) { - // status code 1xx, 204, and 304 -> no body - return false; - } - } else { - if (myMethod == HTTPMethod.HTTP_METHOD_GET - || myMethod == HTTPMethod.HTTP_METHOD_HEAD - || myMethod == HTTPMethod.HTTP_METHOD_OPTIONS) { - // Method Get, Head, options, ... -> no body - return false; - } - } - return true; - } - - /** - * This method returns the content length of the message body in bytes. - * If no content length information is found, the method returns zero. - * - * @return Integer specifying the length of the message body in byte. - */ - private int getContentLength() { - Pattern pattern = Pattern.compile(REGEX_CONTENT_LENGTH, Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(myRawData); - if (matcher.find()) { - myLogger.debug("content length found: " + matcher.group(1)); - return Integer.parseInt(matcher.group(1)); - } - return 0; - } - - /** - * Determines whether the data is chunked or not. - * - * @return Returns <code>true</code> if the data is chunked. - */ - private Boolean isChunked() { - Pattern pattern = Pattern.compile(REGEX_IS_CHUNKED, Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(myRawData); - if (matcher.find()) { - myLogger.debug("message is chunked"); - return true; - } - return false; - } - - /** - * The method <code>decodeChunkedEncoding</code> tries to read all chunks of the message. - * If the all chunks have been recognized the content of all chunks is returned and the - * <code>myParsingState</code> is set to <code>true</code>. - * - * @see RFC 2616: 3.6.1 Chunked Transfer Coding - * Chunked-Body = *chunk - * last-chunk - * trailer - * CRLF - * - * chunk = chunk-size [ chunk-extension ] CRLF - * chunk-data CRLF - * chunk-size = 1*HEX - * last-chunk = 1*("0") [ chunk-extension ] CRLF - * - * @param data String - * @return String - */ - private String decodeChunkedEncoding(String data) { - // size of the current chunk - int chunksize = 0; - // number of chunks - int parts = 0; - // the decoded content - String result = ""; - // the last chunk is empty and has a length of 0 - // have we already read the last chunk? - Boolean readEmptyChunk = false; - - // read chunk-size, chunk-extension (if any) and CRLF - // INFO: chunk-extensions are currently ignored - Pattern pattern = Pattern.compile(REGEX_CHUNK_SIZE); - Matcher matcher = pattern.matcher(myRawData); - while (matcher.find()) { - parts++; - // convert content-length value from hex string to int - chunksize = Integer.parseInt(matcher.group(1), Constant.HEX_RADIX); - // the last chunk is empty and has a length of 0 - if (chunksize == 0) { - readEmptyChunk = true; - myLogger.debug("Last chunk: " + parts); - } - int start = matcher.end(); - int stopp = matcher.end() + chunksize; - - // check if lengths are valid - if (stopp > myRawData.length()) { - myLogger.debug("chunk decoding: invalid right boundary " + stopp); - stopp = myRawData.length(); - } - if (start < 0) { - myLogger.debug("chunk decoding: invalid left boundary " + start); - start = 0; - } - - myLogger.debug("Chunk: " + parts); - myLogger.debug("Chunk from index " + start + " to " + stopp); - - result += myRawData.substring(start, stopp); - } - // if we read the last chunk, the parsing is complete. - myParsingState = readEmptyChunk; - return result; - } -} Added: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-04-02 15:43:10 UTC (rev 100) @@ -0,0 +1,356 @@ +/* + * HTTPMessageParser.java + * + * This class is a very simple approach to parse http messages. + * + * Created: 23.01.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.http; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.log4j.Logger; + +import de.dlr.davinspector.common.Constant; +import de.dlr.davinspector.common.Constant.Direction; +import de.dlr.davinspector.history.AMessage; +import de.dlr.davinspector.history.AMessageParser; + +/** + * This class is a very simple approach to parse http messages. + * More information: + * HTTP/1.1 RFC 2616 + * HTTP/1.0 RFC 1945 + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public class HTTPMessageParser extends AMessageParser { + + /** + * This expression matches the http request line. + * (METHOD) SPACE (URL) SPACE (VERSION) CRLF + * RFC 2616: Request-Line = Method SP Request-URI SP HTTP-Version CRLF + * TODO: URL scanning not complete. + * TODO: add ACL, DASL methods etc. / split into different parts (http, webdav, dasl, acl, ...) / check with markus + * checkout, checkin, uncheckout, update, report, merge -> litmus test? + */ + private static final String REGEX_HTTP_REQUEST_LINE = "^(\\bUNKNOWN\\b|\\bHEAD\\b|\\bGET\\b|\\bPOST\\b|\\bPUT\\b|" + + "\\bDELETE\\b|\\bOPTIONS\\b|\\bTRACE\\b|\\bCONNECT\\b|\\bPROPFIND\\b|\\bPROPPATCH\\b|\\bMKCOL\\b|" + + "\\bCOPY\\b|\\bMOVE\\b|\\bLOCK\\b|\\bUNLOCK\\b|\\bREPORT\\b){1}" + + " ([\\w|/|~|.|_|-]+)" + + " (\\bHTTP/1.1\\b|\\bHTTP/1.0\\b|\\bHTTP/0.9\\b){1}\r\n"; + + /** + * This expression matches the http status line. + * (VERSION) SPACE (STATUS-CODE) SPACE (REASON) CRLF + * RFC 2616: Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF + */ + private static final String REGEX_HTTP_STATUS_LINE = "^(\\bHTTP/1.1\\b|\\bHTTP/1.0\\b|\\bHTTP/0.9\\b){1}" + + " ([0-9]{3})" + + " ([\\w|-]+)\r\n"; + + /** + * This expression matches an empty line. These empty lines divide a message + * into header and body. If the data is chunk-encoded, the chunks are also divided by an empty line. + */ + private static final String REGEX_EMPTY_LINE = "\r\n\r\n"; + + /** + * This expression matches the content-length information of a http message. + * Content-length: SPACE* (LENGTH) CRLF + */ + private static final String REGEX_CONTENT_LENGTH = "Content-length:[ ]*([0-9]+)\r\n"; + + /** + * This expression matches the length information of a chunk. + * CRLF (LENGTH-IN-HEX) CRLF + * INFO: Currently no chunk extensions are handled. + */ + private static final String REGEX_CHUNK_SIZE = "\r\n([0-9a-fA-F]+)\r\n"; + + /** + * This expression matches the transfer encoding of a message. + * Transfer-Encoding: SPACE* chunked CRLF + * INFO: Currently no transfer extensions are handled. + */ + private static final String REGEX_IS_CHUNKED = "Transfer-Encoding:[ ]*chunked\r\n"; + + /** Logger, Apache log4j. */ + private static Logger myLogger = Logger.getLogger(HTTPMessageParser.class); + + /** The http request method. */ + private String myMethod; + + /** The http response status code. */ + private int myStatusCode = 0; + + /** Version of the http protocol uesed by the message. */ + private String myProtocolVersion = ""; + + /** <code>True</code> if the message uses chunked encoding. */ + private Boolean isChunked = false; + + /** Length of the message body in bytes. */ + private int myContentLength = 0; + + /** + * Constructor. + * + * @param aMessage AMessage + */ + public HTTPMessageParser(AMessage aMessage) { + super(aMessage); + myDirection = aMessage.getDirection(); + myRawData = aMessage.getRawData(); + myParsingState = false; + } + + /** + * This method extracts the header and body from the raw data of the message. + * The data from the start to the first empty line presents the <code>myRawHeader</code>, + * the data from the first empty line until the end of the raw data presents the <code>myRawBody</code>. + */ + private void extractHeaderBody() { + String[] s = myRawData.split(REGEX_EMPTY_LINE); + myRawHeader = s[0]; + for (int i = 1; i < s.length; i++) { + myRawBody += s[i]; + } + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.history.AMessageParser#parseMessage() + */ + public String parse() { + myLogger.debug("---- new data event ----"); + myLogger.debug("Direction: " + myDirection); + myLogger.debug("Direction: " + myDirection); + + String carryover = ""; + + myParsedHeader = ""; + myRawHeader = ""; + myParsedBody = ""; + myRawBody = ""; + + if (myDirection == Direction.ServerToClient) { + Pattern pattern = Pattern.compile(REGEX_HTTP_STATUS_LINE, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(myRawData); + if (matcher.find()) { + myLogger.debug("found status line"); + myMethod = ""; // INFO: set last method + myStatusCode = Integer.parseInt(matcher.group(2)); + myProtocolVersion = matcher.group(1); + isChunked = isChunked(); + myContentLength = getContentLength(); + } else { + myLogger.debug("No status line found."); + } + } else { + Pattern pattern = Pattern.compile(REGEX_HTTP_REQUEST_LINE, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(myRawData); + if (matcher.find()) { + myLogger.debug("found request line"); + myMethod = matcher.group(1); + myStatusCode = 0; + myProtocolVersion = matcher.group(3); + isChunked = false; + myContentLength = getContentLength(); + } else { + myLogger.debug("No request line found."); + } + } + + if (myLogger.isDebugEnabled()) { + myLogger.debug("Method :" + myMethod); + myLogger.debug("Status :" + myStatusCode); + myLogger.debug("Version:" + myProtocolVersion); + myLogger.debug("Len :" + myContentLength); + myLogger.debug("Chunked:" + isChunked); + } + + extractHeaderBody(); + myParsedHeader = myRawHeader; + + // Content-length = 0 or no body -> empty body + if (!isChunked && (myContentLength == 0 || !hasBody())) { + myLogger.debug("no body"); + myParsedBody = ""; + carryover = myRawBody; + myParsingState = true; + + myLogger.debug(myRawHeader); + myLogger.debug("\n"); + myLogger.debug(myRawBody); + + } else { + if (isChunked) { + myLogger.debug("decode chunked encoding"); + myParsedBody = decodeChunkedEncoding(myRawBody); + carryover = ""; //myRawData; // TODO: Set carry. ### + if (!myParsingState) { + myLogger.debug("decoding chunked encoding not finished"); + } + } else { + myLogger.debug("normal message"); + if (myContentLength > myRawBody.length()) { + myContentLength = 0; + myLogger.debug("normal message not finished"); + } + myParsedBody = myRawBody.substring(0, myContentLength); + carryover = myRawBody.substring(myContentLength, myRawBody.length()); + myParsingState = true; + } + } + + myLogger.debug("Carry: " + carryover.length()); + + return carryover; + } + + /** + * This method returns <code>true</code> if the message has a body. + * In the case that the command does not require a message body + * the method returns <code>false</code>. + * + * @return Boolean + */ + private Boolean hasBody() { + if (myDirection == Direction.ServerToClient) { + if (myStatusCode == HTTPStatusCode.HTTP_CONTINUE + || myStatusCode == HTTPStatusCode.HTTP_SWITCHING_PROTOCOLS + || myStatusCode == HTTPStatusCode.HTTP_NO_CONTENT + || myStatusCode == HTTPStatusCode.HTTP_NOT_MODIFIED) { + // status code 1xx, 204, and 304 -> no body + return false; + } + } else { + if (myMethod == HTTPMethod.HTTP_METHOD_GET + || myMethod == HTTPMethod.HTTP_METHOD_HEAD + || myMethod == HTTPMethod.HTTP_METHOD_OPTIONS) { + // Method Get, Head, options, ... -> no body + return false; + } + } + return true; + } + + /** + * This method returns the content length of the message body in bytes. + * If no content length information is found, the method returns zero. + * + * @return Integer specifying the length of the message body in byte. + */ + private int getContentLength() { + Pattern pattern = Pattern.compile(REGEX_CONTENT_LENGTH, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(myRawData); + if (matcher.find()) { + myLogger.debug("content length found: " + matcher.group(1)); + return Integer.parseInt(matcher.group(1)); + } + return 0; + } + + /** + * Determines whether the data is chunked or not. + * + * @return Returns <code>true</code> if the data is chunked. + */ + private Boolean isChunked() { + Pattern pattern = Pattern.compile(REGEX_IS_CHUNKED, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(myRawData); + if (matcher.find()) { + myLogger.debug("message is chunked"); + return true; + } + return false; + } + + /** + * The method <code>decodeChunkedEncoding</code> tries to read all chunks of the message. + * If the all chunks have been recognized the content of all chunks is returned and the + * <code>myParsingState</code> is set to <code>true</code>. + * + * @see RFC 2616: 3.6.1 Chunked Transfer Coding + * Chunked-Body = *chunk + * last-chunk + * trailer + * CRLF + * + * chunk = chunk-size [ chunk-extension ] CRLF + * chunk-data CRLF + * chunk-size = 1*HEX + * last-chunk = 1*("0") [ chunk-extension ] CRLF + * + * @param data String + * @return String + */ + private String decodeChunkedEncoding(String data) { + // size of the current chunk + int chunksize = 0; + // number of chunks + int parts = 0; + // the decoded content + String result = ""; + // the last chunk is empty and has a length of 0 + // have we already read the last chunk? + Boolean readEmptyChunk = false; + + // read chunk-size, chunk-extension (if any) and CRLF + // INFO: chunk-extensions are currently ignored + Pattern pattern = Pattern.compile(REGEX_CHUNK_SIZE); + Matcher matcher = pattern.matcher(myRawData); + while (matcher.find()) { + parts++; + // convert content-length value from hex string to int + chunksize = Integer.parseInt(matcher.group(1), Constant.HEX_RADIX); + // the last chunk is empty and has a length of 0 + if (chunksize == 0) { + readEmptyChunk = true; + myLogger.debug("Last chunk: " + parts); + } + int start = matcher.end(); + int stopp = matcher.end() + chunksize; + + // check if lengths are valid + if (stopp > myRawData.length()) { + myLogger.debug("chunk decoding: invalid right boundary " + stopp); + stopp = myRawData.length(); + } + if (start < 0) { + myLogger.debug("chunk decoding: invalid left boundary " + start); + start = 0; + } + + myLogger.debug("Chunk: " + parts); + myLogger.debug("Chunk from index " + start + " to " + stopp); + + result += myRawData.substring(start, stopp); + } + // if we read the last chunk, the parsing is complete. + myParsingState = readEmptyChunk; + return result; + } +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/IEditPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/IEditPlugin.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/IEditPlugin.java 2008-04-02 15:43:10 UTC (rev 100) @@ -44,5 +44,15 @@ * * @return AMessage */ - AMessage getOutput(); + AMessage getOutput(); + + /** + * Activate the controls to permit editing of the data. + */ + void enableEditing(); + + /** + * Deactivate the controls to prevent editing of the data. + */ + void disableEditing(); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java 2008-04-02 15:43:10 UTC (rev 100) @@ -47,7 +47,7 @@ * * @return string */ - PlugInType getType(); + PluginType getType(); /** * Returns the name of the plugin. @@ -69,13 +69,21 @@ * @return String */ String getDescription(); + + /** + * Returns the side the plugin is assigned to. + * + * @return PluginDirection + */ + PluginDirection getPluginDirection(); /** * Initializes the plugin. * + * @param pluginManager PluginManager * @param direction Indicates the assignement of the plugin to server or client side. */ - void init(PlugInDirection direction); + void init(PluginManager pluginManager, PluginDirection direction); /** * Starts processing of the message. @@ -112,7 +120,7 @@ /** * Indentifier for plugin-type. */ - public enum PlugInType { + public enum PluginType { /** Plugin has GUI, client and server. */ VIEW_GENERAL, /** Plugin allows editing of the content, client and server. */ @@ -135,7 +143,7 @@ * @version $LastChangedRevision$ * @author Jochen Wuest */ - public enum PlugInDirection { + public enum PluginDirection { /** Plugin on the client side. */ CLIENT, /** Plugin on the server side. */ Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-04-02 15:43:10 UTC (rev 100) @@ -37,6 +37,7 @@ import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; +import de.dlr.davinspector.plugin.IPlugin.PluginDirection; /** * This class loads all available plugins and manages the activated plugins @@ -112,7 +113,7 @@ // lets try to load the plugin... plugin = (IPlugin) c.newInstance(); myLogger.debug("Plugin loaded: " + name); - plugin.init(null); + plugin.init(null, null); myLogger.debug("Plugin initialised: " + name); // ok, the plugin is initialized if (plugin != null) { @@ -121,10 +122,10 @@ // INFO: only add plugin if specified for client/server side // INFO: alternative Direction could be specified here by PluginType!? plugin = (IPlugin) c.newInstance(); - plugin.init(IPlugin.PlugInDirection.CLIENT); + plugin.init(PluginManager.getInstance(), IPlugin.PluginDirection.CLIENT); myActivePluginsClient.add(plugin); plugin = (IPlugin) c.newInstance(); - plugin.init(IPlugin.PlugInDirection.SERVER); + plugin.init(PluginManager.getInstance(), IPlugin.PluginDirection.SERVER); myActivePluginsServer.add(plugin); } } catch (ClassNotFoundException cnfe) { @@ -190,25 +191,8 @@ plugin.update(message); } } - + /** - * TODO: wues_ha: Enter comment! - * - * @return AMessage - */ - public AMessage getEditedMessageClient() { - AMessage buffer = null; - for (Iterator<IPlugin> iterator = myActivePluginsClient.iterator(); iterator.hasNext();) { - IPlugin plugin = (IPlugin) iterator.next(); - if (plugin.getType() == IPlugin.PlugInType.EDIT_CLIENT) { - IEditPlugin editPlugin = (IEditPlugin) plugin; - buffer = editPlugin.getOutput(); - } - } - return buffer; - } - - /** * This method sets the active plugins for the client side. * * @param pluginNames Vector @@ -265,4 +249,64 @@ plugin.shutdown(); } } + + /** + * Enable all active edit-plugins. + */ + public void enableEditPlugins() { + setStateOfEditPlugins(true); + } + + /** + * Disable all active edit-plugins. + */ + public void disableEditPlugins() { + setStateOfEditPlugins(false); + } + + /** + * Dependent on <code>state</code> the edit-plugins are enabled/disabled. + * + * @param state Boolean + */ + private void setStateOfEditPlugins(Boolean state) { + for (Iterator<IPlugin> iterator = myActivePluginsClient.iterator(); iterator.hasNext();) { + IPlugin plugin = (IPlugin) iterator.next(); + if (plugin.getType() == IPlugin.PluginType.EDIT_CLIENT + || plugin.getType() == IPlugin.PluginType.EDIT_GENERAL) { + if (state) { + ((IEditPlugin) plugin).enableEditing(); + } else { + ((IEditPlugin) plugin).disableEditing(); + } + } + } + for (Iterator<IPlugin> iterator = myActivePluginsServer.iterator(); iterator.hasNext();) { + IPlugin plugin = (IPlugin) iterator.next(); + if (plugin.getType() == IPlugin.PluginType.EDIT_SERVER + || plugin.getType() == IPlugin.PluginType.EDIT_GENERAL) { + if (state) { + ((IEditPlugin) plugin).enableEditing(); + } else { + ((IEditPlugin) plugin).disableEditing(); + } + } + } + } + + /** + * An edit-plugin signals the completion of an editing activity by calling this method. + * All active plugins with the same direction are updated. + * TODO: Raw views are not updated yet + * + * @param direction {@link PluginDirection} + * @param message {@link AMessage} + */ + public void messageEditedEvent(PluginDirection direction, AMessage message) { + if (direction == PluginDirection.CLIENT) { + updateActivePluginsClient(message); + } else { + updateActivePluginsServer(message); + } + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-28 15:55:22 UTC (rev 99) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-04-02 15:43:10 UTC (rev 100) @@ -31,9 +31,8 @@ import de.dlr.davinspector.common.Util; import de.dlr.davinspector.history.AMessage; -import de.dlr.davinspector.history.Message; -import de.dlr.davinspector.plugin.IEditPlugin; import de.dlr.davinspector.plugin.IViewPlugin; +import de.dlr.davinspector.plugin.PluginManager; /** @@ -42,8 +41,11 @@ * @version $LastChangedRevision$ * @author Jochen Wuest */ -public class HeaderPlugin implements IEditPlugin, IViewPlugin { +public class HeaderPlugin implements IViewPlugin { + /** The direction the plugin is assigned to. */ + private PluginDirection myPlugInDirection; + /** State of the plugin. */ private Boolean isActive = true; @@ -94,8 +96,8 @@ * * @see de.dlr.DAVInspector.Plugin.IPlugin#getType() */ - public PlugInType getType() { - return PlugInType.EDIT_CLIENT; + public PluginType getType() { + return PluginType.VIEW_CLIENT; ... [truncated message content] |
From: <wu...@us...> - 2008-03-28 15:55:40
|
Revision: 99 http://davinspector.svn.sourceforge.net/davinspector/?rev=99&view=rev Author: wuest Date: 2008-03-28 08:55:22 -0700 (Fri, 28 Mar 2008) Log Message: ----------- Renamed IRefreshMessageListener to ILoadMessageListener. Moved message creation and handling from MessageHistory into RelayModel. Added enable/disable methods for GUI elements, extended the controller. A couple of minor changes in different classes. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayThread.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayThread.java trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java Added Paths: ----------- trunk/DAVInspector/src/de/dlr/davinspector/history/ILoadMessageListener.java Removed Paths: ------------- trunk/DAVInspector/src/de/dlr/davinspector/history/IRefreshMessageListener.java Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-28 15:55:22 UTC (rev 99) @@ -39,7 +39,7 @@ public abstract class AMessage { /** The counter for unique numbering. */ - protected static int idCounter; + protected static int idCounter = 1; /** Parsing state of the message. */ protected Boolean myParsingState; @@ -129,7 +129,8 @@ /** * This method parses the current raw data. - * If the buffer contains more than only the data for the current message, the rest is returned. + * If the buffer contains more than the data needed for the current message, + * the remaining data is returned. * * @return String */ Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-03-28 15:55:22 UTC (rev 99) @@ -46,7 +46,7 @@ Internationalization.getTranslation("col_history_id"), Internationalization.getTranslation("col_history_timestamp"), Internationalization.getTranslation("col_history_size") - // TODO: display more information depending on message type + // INFO: display more information depending on message type }; /** Copied: trunk/DAVInspector/src/de/dlr/davinspector/history/ILoadMessageListener.java (from rev 97, trunk/DAVInspector/src/de/dlr/davinspector/history/IRefreshMessageListener.java) =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/ILoadMessageListener.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/ILoadMessageListener.java 2008-03-28 15:55:22 UTC (rev 99) @@ -0,0 +1,46 @@ +/* + * IRefreshMessageListener.java + * + * Listeners which implement this interface are notified if a message is + * loaded from the message history. + * + * Created: 19.02.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.history; + +import java.util.EventListener; + + +/** + * Refresh message listener interface. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public interface ILoadMessageListener extends EventListener { + + /** + * Invoked when a message has been loaded. + * + * @param refreshMessageEvent {@link MessageEvent} + */ + void loadMessage(MessageEvent refreshMessageEvent); +} Deleted: trunk/DAVInspector/src/de/dlr/davinspector/history/IRefreshMessageListener.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/IRefreshMessageListener.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/IRefreshMessageListener.java 2008-03-28 15:55:22 UTC (rev 99) @@ -1,46 +0,0 @@ -/* - * IRefreshMessageListener.java - * - * Listeners which implement this interface are notified if a message is - * loaded from the message history. - * - * Created: 19.02.2008 Jochen Wuest <joc...@dl...> - * Changed: - * - * $Id$ - * - * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.dlr.davinspector.history; - -import java.util.EventListener; - - -/** - * Refresh message listener interface. - * - * @version $LastChangedRevision$ - * @author Jochen Wuest - */ -public interface IRefreshMessageListener extends EventListener { - - /** - * Invoked when a message has been loaded. - * - * @param refreshMessageEvent {@link MessageEvent} - */ - void refreshMessage(MessageEvent refreshMessageEvent); -} Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-28 15:55:22 UTC (rev 99) @@ -25,104 +25,48 @@ package de.dlr.davinspector.history; -import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Vector; import javax.swing.event.EventListenerList; -import de.dlr.davinspector.common.Constant.Direction; -import de.dlr.davinspector.http.HTTPMessageParser; -import de.dlr.davinspector.relay.DataEvent; -import de.dlr.davinspector.relay.INewClientDataListener; -import de.dlr.davinspector.relay.INewServerDataListener; -import de.dlr.davinspector.relay.IRelayModel; - /** * This class saves and provides access to the processed messages. * * @version $LastChangedRevision$ * @author Jochen Wuest */ -public class MessageHistory implements INewServerDataListener, INewClientDataListener { +public class MessageHistory { /** List of listeners for new messages. */ private EventListenerList myListenersNewMessage = new EventListenerList(); - /** List of listeners for refresh. */ - private EventListenerList myListenersRefreshMessage = new EventListenerList(); + /** List of listeners for the "loading of a message" event. */ + private EventListenerList myListenersLoadMessage = new EventListenerList(); - /** This string buffers the client side raw data. */ - private String myClientToServerBuffer; - - /** This string buffers the server side raw data. */ - private String myServerToClientBuffer; - /** This vector stores the messages. */ private List<AMessage> myMessages = null; - /** Reference to the relay model. */ - private IRelayModel myRelay = null; - /** * Constructor for message history. Client and server buffers and the - * vector for storing the messages are initialized and listeners for - * server and client side are registered. - * - * @param relay {@link IRelayModel} + * vector for storing the messages are initialized. */ - public MessageHistory(IRelayModel relay) { - myRelay = relay; + public MessageHistory() { myMessages = new Vector<AMessage>(); - myClientToServerBuffer = ""; - myServerToClientBuffer = ""; - - myRelay.addNewClientDataListener(this); - myRelay.addNewServerDataListener(this); } /** - * This method creates a new message and stores it. + * This method stores a message. * Afterwards a {@link MessageEvent} is generated and all {@link INewMessageListener} are notified. * - * @param data String - * @param direction Direction - * @param timestamp Date + * @param message AMessage */ - public void storeMessage(String data, Direction direction, Date timestamp) { - - // INFO: add decorator dependent on protocol (switch http, ...). + public void storeMessage(AMessage message) { // Notice: idCounter != number of messages - HTTPMessageParser message = new HTTPMessageParser(new Message()); - - message.setMessageDirection(direction); - message.setRawData(data); - message.setTimestamp(timestamp); - String carry = message.parseMessage(); - - if (message.isComplete()) { - // store Message - myMessages.add(message); - notifyNewMessage(new MessageEvent(this, message)); - // clear buffer - if (direction == Direction.ServerToClient) { - myClientToServerBuffer = carry; - } else { - myServerToClientBuffer = carry; - } - - // automatic send the message to client/server - // TODO: Steuerung nachrichten aus mainview raus!! - if (myRelay.getStateAutomode()) { - if (direction == Direction.ServerToClient) { - myRelay.writeToClient(message.getRawData()); - } else { - myRelay.writeToServer(message.getRawData()); - } - } - } + myMessages.add(message); + notifyNewMessage(new MessageEvent(this, message)); } /** @@ -134,7 +78,7 @@ /** * This method loads a message identified by the ID. - * Afterwards a {@link MessageEvent} is generated and all {@link IRefreshMessageListener} are notified. + * Afterwards a {@link MessageEvent} is generated and all {@link ILoadMessageListener} are notified. * * @param id int */ @@ -142,32 +86,28 @@ for (Iterator<AMessage> iterator = myMessages.iterator(); iterator.hasNext();) { AMessage message = (AMessage) iterator.next(); if (message.getId() == id) { - notifyRefreshMessage(new MessageEvent(this, message)); + notifyLoadMessage(new MessageEvent(this, message)); break; } } } /** - * {@inheritDoc} - * - * @see de.dlr.davinspector.relay.INewClientDataListener#newClientData(de.dlr.davinspector.relay.DataEvent) + * Returns the message identified by ID. + * + * @param id Integer + * @return {@link AMessage} */ - public void newClientData(DataEvent newDataEvent) { - myClientToServerBuffer += newDataEvent.getData(); - storeMessage(myClientToServerBuffer, Direction.ClientToServer, new Date()); + public AMessage getMessage(int id) { + for (Iterator<AMessage> iterator = myMessages.iterator(); iterator.hasNext();) { + AMessage message = (AMessage) iterator.next(); + if (message.getId() == id) { + return message; + } + } + return null; } - - /** - * {@inheritDoc} - * - * @see de.dlr.davinspector.relay.INewServerDataListener#newServerData(de.dlr.davinspector.relay.DataEvent) - */ - public void newServerData(DataEvent newDataEvent) { - myServerToClientBuffer += newDataEvent.getData(); - storeMessage(myServerToClientBuffer, Direction.ServerToClient, new Date()); - } - + /** * Adds an {@link INewMessageListener} to MessageHistory. * @@ -199,32 +139,32 @@ } /** - * Adds an {@link IRefreshMessageListener} to MessageHistory. + * Adds an {@link ILoadMessageListener} to MessageHistory. * - * @param listener the {@link IRefreshMessageListener} to be added + * @param listener the {@link ILoadMessageListener} to be added */ - public void addRefreshMessageListener(IRefreshMessageListener listener) { - myListenersRefreshMessage.add(IRefreshMessageListener.class, listener); + public void addLoadMessageListener(ILoadMessageListener listener) { + myListenersLoadMessage.add(ILoadMessageListener.class, listener); } /** - * Removes an {@link IRefreshMessageListener} from MessageHistory. + * Removes an {@link ILoadMessageListener} from MessageHistory. * - * @param listener the {@link IRefreshMessageListener} to be removed + * @param listener the {@link ILoadMessageListener} to be removed */ - public void removeRefreshMessageListener(IRefreshMessageListener listener) { - myListenersRefreshMessage.remove(IRefreshMessageListener.class, listener); + public void removeLoadMessageListener(ILoadMessageListener listener) { + myListenersLoadMessage.remove(ILoadMessageListener.class, listener); } /** - * Notifies all {@link IRefreshMessageListener}s that have registered interest for + * Notifies all {@link ILoadMessageListener}s that have registered interest for * notification on an {@link MessageEvent}. * * @param event the {@link MessageEvent} object */ - protected synchronized void notifyRefreshMessage(MessageEvent event) { - for (IRefreshMessageListener listener : myListenersRefreshMessage.getListeners(IRefreshMessageListener.class)) { - listener.refreshMessage(event); + protected synchronized void notifyLoadMessage(MessageEvent event) { + for (ILoadMessageListener listener : myListenersLoadMessage.getListeners(ILoadMessageListener.class)) { + listener.loadMessage(event); } } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-28 15:55:22 UTC (rev 99) @@ -51,7 +51,7 @@ * (METHOD) SPACE (URL) SPACE (VERSION) CRLF * RFC 2616: Request-Line = Method SP Request-URI SP HTTP-Version CRLF * TODO: URL scanning not complete. - * TODO: add ACL, DASL methods etc. + * TODO: add ACL, DASL methods etc. / split into different parts (http, webdav, dasl, acl, ...) / check with markus * checkout, checkin, uncheckout, update, report, merge -> litmus test? */ private static final String REGEX_HTTP_REQUEST_LINE = "^(\\bUNKNOWN\\b|\\bHEAD\\b|\\bGET\\b|\\bPOST\\b|\\bPUT\\b|" @@ -192,6 +192,8 @@ myLogger.debug("########"); } +// myLogger.debug("\n" + myRawData + "\n"); + extractHeaderBody(); myParsedHeader = myRawHeader; @@ -205,7 +207,7 @@ if (isChunked) { myLogger.debug("decode chunked encoding"); myParsedBody = decodeChunkedEncoding(myRawBody); - carryover = ""; // TODO: Set carry. + carryover = ""; //myRawData; // TODO: Set carry. ### if (!myParsingState) { myLogger.debug("decoding chunked encoding not finished"); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-03-28 15:55:22 UTC (rev 99) @@ -123,7 +123,7 @@ */ private String getDefaultFileName() { Date now = new Date(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_hh-mm"); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm"); String side = "_server_"; if (myParent.getDirection() == PlugInDirection.CLIENT) { Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-28 15:55:22 UTC (rev 99) @@ -99,7 +99,7 @@ count = in.read(buffer); while ((count != Constant.EOF) && !isInterrupted()) { synchronized (myRelayThread) { - // TODO: add encoding to configuration and set encoding from configuration + // INFO: add encoding to configuration and set encoding from configuration myLogger.debug(myThreadName + COLON + "Got input " + myDirection); myRelayThread.newData(new String(buffer, 0, count, "utf-8"), myDirection); Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-28 15:55:22 UTC (rev 99) @@ -53,19 +53,26 @@ /** * This method writes data to the client. - * @param data String */ - void writeToClient(String data); + void writeToClient(); /** * This method writes data to the server. - * @param data String */ - void writeToServer(String data); + void writeToServer(); + + /** + * Loads a message and marks it as active. + * + * @param id Integer + */ + void loadMessageById(Integer id); /** * This method notifies the listeners for server or client depending on the <code>direction</code> - * parameter and uses the <code>data</code> to create a new {@link DataEvent}. + * parameter and uses the <code>data</code> to create a new {@link DataEvent}. + * Also a new <code>Message</code> is created and parsed. If the parsing is successful the message is + * stored in the <code>MessageHistory</code>. * * @param data String * @param direction Direction @@ -93,16 +100,24 @@ * * @return Boolean */ - Boolean getStateAutomode(); + Boolean isAutomodeActive(); /** - * Activate/Deactivate the automode.<br> - * true: ON<br> - * false: OFF<br> + * Activate the automode. + */ + void enableAutomode(); + + /** + * Deactivate the automode. + */ + void disableAutomode(); + + /** + * This method returns <code>true</code> if the relay is active, otherwise it returns <code>false</code>. * - * @param state Boolean + * @return Boolean */ - void setStateAutomode(Boolean state); + Boolean isActive(); /** * Adds an {@link INewServerDataListener} to RelayModel. Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayThread.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayThread.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayThread.java 2008-03-28 15:55:22 UTC (rev 99) @@ -1,7 +1,8 @@ /* * IRelayThread.java * - * TODO: wues_ha Enter comment! + * The interface for the relay thread. This thread handles the network connection, + * using two channel threads per connection to receive and send data. * * Created: 26.03.2008 Jochen Wuest <joc...@dl...> * Changed: @@ -30,7 +31,8 @@ /** - * TODO: wues_ha: Enter comment! + * The interface for the relay thread. This thread handles the network connection, + * using two channel threads per connection to receive and send data. * * @version $LastChangedRevision$ * @author Jochen Wuest @@ -39,12 +41,11 @@ /** * Invokes the shutdown of the RelayThread. - * */ void stopRelay(); /** - * TODO: wues_ha: Enter comment! + * Write data to the desired channel depending on the given direction. * * @param data String * @param direction Direction @@ -52,7 +53,8 @@ void write(String data, Direction direction); /** - * TODO: wues_ha: Enter comment! + * This method has to be called if new data is available. The direction parameter is + * used to define the source of the data. * * @param data String * @param direction Direction Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-28 15:55:22 UTC (rev 99) @@ -26,6 +26,8 @@ package de.dlr.davinspector.relay; +import java.util.Date; + import javax.swing.event.EventListenerList; import org.apache.log4j.Logger; @@ -33,13 +35,15 @@ import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.configuration.Configuration; import de.dlr.davinspector.configuration.PluginConfiguration; +import de.dlr.davinspector.history.AMessage; +import de.dlr.davinspector.history.Message; import de.dlr.davinspector.history.MessageHistory; +import de.dlr.davinspector.http.HTTPMessageParser; import de.dlr.davinspector.plugin.PluginManager; /** * Implementation of the relay interface. Provides the server socket * and manages the channel threads. - * TODO: add logging * * @version $LastChangedRevision$ * @author Jochen Wuest @@ -55,6 +59,12 @@ /** List of listeners for server data. */ private EventListenerList myNewServerDataListeners = new EventListenerList(); + /** This string buffers the client side raw data. */ + private String myClientToServerBuffer; + + /** This string buffers the server side raw data. */ + private String myServerToClientBuffer; + /** The plugin manager. */ private PluginManager myPluginManager = null; @@ -64,15 +74,24 @@ /** State of the automode. */ private Boolean myStateAutomode = false; + /** . */ + private Integer myActiveClientMessageID = 0; + + /** . */ + private Integer myActiveServerMessageID = 0; + /** */ private IRelayThread theRelay = null; + /** Current state of the relay. */ + private Boolean myStateRelay; + /** * Constructor of a RelayModel. * The constructor creates a new {@link MessageHistory} object. */ public RelayModel() { - myMessageHistory = new MessageHistory(this); + myMessageHistory = new MessageHistory(); myPluginManager = PluginManager.getInstance(); // load available plugins myPluginManager.loadAllPlugins(); @@ -80,11 +99,23 @@ PluginConfiguration pluginConfiguration = new PluginConfiguration(); myPluginManager.setActivePluginsClient(pluginConfiguration.getActivePluginsClient()); myPluginManager.setActivePluginsServer(pluginConfiguration.getActivePluginsServer()); + // Clear Buffers + myServerToClientBuffer = ""; + myClientToServerBuffer = ""; } /** * {@inheritDoc} * + * @see de.dlr.davinspector.relay.IRelayModel#isActive() + */ + public Boolean isActive() { + return myStateRelay; + } + + /** + * {@inheritDoc} + * * @see de.dlr.davinspector.relay.IRelayModel#getPluginManager() */ public PluginManager getPluginManager() { @@ -103,20 +134,29 @@ /** * {@inheritDoc} * - * @see de.dlr.davinspector.relay.IRelayModel#getStateAutomode() + * @see de.dlr.davinspector.relay.IRelayModel#isAutomodeActive() */ - public Boolean getStateAutomode() { + public Boolean isAutomodeActive() { return myStateAutomode; } /** * {@inheritDoc} * - * @see de.dlr.davinspector.relay.IRelayModel#setStateAutomode(java.lang.Boolean) + * @see de.dlr.davinspector.relay.IRelayModel#enableAutomode(java.lang.Boolean) */ - public void setStateAutomode(Boolean state) { - myStateAutomode = state; + public void enableAutomode() { + myStateAutomode = true; } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.relay.IRelayModel#disableAutomode() + */ + public void disableAutomode() { + myStateAutomode = false; + } /** * {@inheritDoc} @@ -184,7 +224,8 @@ * @see de.dlr.DAVInspector.Relay.IRelayModel#startRelay() */ public void startRelay(Configuration configuration) { - theRelay = new RelayThread(this, configuration); + theRelay = new RelayThread(this, configuration); + myStateRelay = true; } /** @@ -195,6 +236,7 @@ public void stopRelay() { theRelay.stopRelay(); theRelay = null; + myStateRelay = false; } /** @@ -202,9 +244,12 @@ * * @see de.dlr.davinspector.relay.IRelayModel#writeToClient(java.lang.String) */ - public void writeToClient(String data) { + public void writeToClient() { myLogger.debug("Writing data: " + Direction.ServerToClient); - theRelay.write(data, Direction.ServerToClient); + AMessage message = myMessageHistory.getMessage(myActiveClientMessageID); + if (message != null) { + theRelay.write(message.getRawData(), Direction.ServerToClient); + } } /** @@ -212,10 +257,31 @@ * * @see de.dlr.davinspector.relay.IRelayModel#writeToServer(java.lang.String) */ - public void writeToServer(String data) { + public void writeToServer() { myLogger.debug("Writing data: " + Direction.ClientToServer); - theRelay.write(data, Direction.ClientToServer); + AMessage message = myMessageHistory.getMessage(myActiveServerMessageID); + if (message != null) { + theRelay.write(message.getRawData(), Direction.ClientToServer); + } } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.relay.IRelayModel#loadMessageById(java.lang.Integer) + */ + public void loadMessageById(Integer id) { + myMessageHistory.loadMessageByID(id); + // set last message id + AMessage message = myMessageHistory.getMessage(id); + if (message != null) { + if (message.getMessageDirection() == Direction.ClientToServer) { + myActiveClientMessageID = message.getId(); + } else { + myActiveServerMessageID = message.getId(); + } + } + } /** * {@inheritDoc} @@ -224,13 +290,46 @@ */ public void updateData(String data, Direction direction) { myLogger.debug("Update data: " + direction); + + // INFO: add decorator dependent on protocol (switch http, ...). + HTTPMessageParser message = new HTTPMessageParser(new Message()); + message.setMessageDirection(direction); + message.setTimestamp(new Date()); + // NOTICE: // if new data from the server is available the server data listeners are notified // if new data from the client is available the client data listeners are notified if (direction == Direction.ServerToClient) { + myServerToClientBuffer += data; + message.setRawData(myServerToClientBuffer); notifyNewServerDataListeners(new DataEvent(this, data)); } else { + myClientToServerBuffer += data; + message.setRawData(myClientToServerBuffer); notifyNewClientDataListeners(new DataEvent(this, data)); } + String carry = message.parseMessage(); + + + if (message.isComplete()) { + myLogger.debug("Message complete"); + // store Message + myMessageHistory.storeMessage(message); + + // clear buffer and set last message id + if (direction == Direction.ServerToClient) { + myActiveClientMessageID = message.getId(); + myClientToServerBuffer = carry; + } else { + myActiveServerMessageID = message.getId(); + myServerToClientBuffer = carry; + } + + // automatic send the message to client/server + // INFO: Use messages instead of strings/raw data in future + if (myStateAutomode) { + theRelay.write(message.getRawData(), message.getMessageDirection()); + } + } } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayThread.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayThread.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayThread.java 2008-03-28 15:55:22 UTC (rev 99) @@ -2,7 +2,6 @@ * RelayThread.java * * This Thread handles one connection consisting of two channels, each processed by it's own thread. - * INFO: Currently only one Connection at a time is handled. * * Created: 26.03.2008 Jochen Wuest <joc...@dl...> * Changed: @@ -77,7 +76,7 @@ private Boolean isActive = false; /** - * TODO: wues_ha: enter comment! + * The constructor of the RelayThread. * * @param aRelayModel IRelayModel * @param configuration Configuration @@ -114,7 +113,7 @@ public void run() { myLogger.debug("Relay is starting"); try { - while (!isInterrupted()) { + while (isActive && !isInterrupted()) { myLogger.debug("Server socket state: " + isActive); // Accept the client connection Socket clientSideSocket = relayServerSocket.accept(); @@ -153,11 +152,19 @@ * * @see de.dlr.davinspector.relay.IRelayThread#stopRelay() */ - public synchronized void stopRelay() { + public void stopRelay() { myLogger.debug("Stopping stage: Active -> false " + activeCount()); - isActive = false; - clientToServerChannel.interrupt(); - serverToClientChannel.interrupt(); + synchronized (lock) { + isActive = false; + clientToServerChannel.interrupt(); + serverToClientChannel.interrupt(); + } + try { + clientToServerChannel.join(); + serverToClientChannel.join(); + } catch (InterruptedException ie) { + myLogger.debug(ie.getMessage(), ie); + } this.interrupt(); try { myLogger.debug("Stopping stage: Closing Server Socket " + activeCount()); @@ -168,10 +175,9 @@ } /** - * TODO: Add comment! - * - * @param data String - * @param direction Direction + * {@inheritDoc} + * + * @see de.dlr.davinspector.relay.IRelayThread#write(java.lang.String, de.dlr.davinspector.common.Constant.Direction) */ public void write(String data, Direction direction) { if (direction == Direction.ClientToServer) { Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-03-28 15:55:22 UTC (rev 99) @@ -37,26 +37,22 @@ /** * This method starts the relay with the current configuration. */ - void startRelay(); + void enableRelay(); /** * This method stops the relay. */ - void stopRelay(); + void disableRelay(); /** * This method writes data to the server. - * - * @param data String */ - void writeToServer(String data); + void writeToServer(); /** * This method writes data to the client. - * - * @param data String */ - void writeToClient(String data); + void writeToClient(); /** * Returns the main view. @@ -74,4 +70,11 @@ * Deactivates the automode of the relay. */ void disableAutomode(); + + /** + * Loads a message by ID. + * + * @param id Integer + */ + void loadMessage(Integer id); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-03-28 15:55:22 UTC (rev 99) @@ -42,7 +42,7 @@ /** The view. */ private MainView myView; - + /** * Constructor of the MainController. * @@ -51,6 +51,8 @@ public MainController(IRelayModel model) { myRelay = model; myView = new MainView(this, myRelay); + // Init view + myView.disableSendToActions(); } /** @@ -58,9 +60,10 @@ * * @see de.dlr.DAVInspector.UI.IMainController#startRelay() */ - public void startRelay() { + public void enableRelay() { Configuration config = new Configuration(); myRelay.startRelay(config); + myView.enableSendToActions(); } /** @@ -68,8 +71,9 @@ * * @see de.dlr.DAVInspector.UI.IMainController#stopRelay() */ - public void stopRelay() { + public void disableRelay() { myRelay.stopRelay(); + myView.disableSendToActions(); } /** @@ -77,8 +81,8 @@ * * @see de.dlr.DAVInspector.UI.IMainController#writeToClient(java.lang.String) */ - public void writeToClient(String data) { - myRelay.writeToClient(data); + public void writeToClient() { + myRelay.writeToClient(); } /** @@ -86,8 +90,8 @@ * * @see de.dlr.DAVInspector.UI.IMainController#writeToServer(java.lang.String) */ - public void writeToServer(String data) { - myRelay.writeToServer(data); + public void writeToServer() { + myRelay.writeToServer(); } /** @@ -105,8 +109,9 @@ * @see de.dlr.davinspector.ui.IMainController#enableAutomode() */ public void enableAutomode() { - if (!myRelay.getStateAutomode()) { - myRelay.setStateAutomode(true); + if (!myRelay.isAutomodeActive()) { + myRelay.enableAutomode(); + myView.disableSendToActions(); } } @@ -116,8 +121,23 @@ * @see de.dlr.davinspector.ui.IMainController#disableAutomode() */ public void disableAutomode() { - if (myRelay.getStateAutomode()) { - myRelay.setStateAutomode(false); + if (myRelay.isAutomodeActive()) { + myRelay.disableAutomode(); + // enable sendTo-Actions only if relay is still active + if (myRelay.isActive()) { + myView.enableSendToActions(); + } else { + myView.disableSendToActions(); + } } } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#loadMessage(java.lang.Integer) + */ + public void loadMessage(Integer id) { + myRelay.loadMessageById(id); + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-27 14:18:11 UTC (rev 98) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-28 15:55:22 UTC (rev 99) @@ -61,8 +61,8 @@ import de.dlr.davinspector.history.AMessage; import de.dlr.davinspector.history.HistoryTableCellRenderer; import de.dlr.davinspector.history.HistoryTableModel; +import de.dlr.davinspector.history.ILoadMessageListener; import de.dlr.davinspector.history.INewMessageListener; -import de.dlr.davinspector.history.IRefreshMessageListener; import de.dlr.davinspector.history.MessageEvent; import de.dlr.davinspector.plugin.IPlugin; import de.dlr.davinspector.plugin.IViewPlugin; @@ -76,7 +76,7 @@ * @version $LastChangedRevision$ * @author Jochen Wuest */ -public class MainView implements INewMessageListener, IRefreshMessageListener { +public class MainView implements INewMessageListener, ILoadMessageListener { /** Position of the horizontal divider. */ private static final double DIVIDER_HORZ = 0.48; @@ -215,6 +215,7 @@ public void actionPerformed(ActionEvent e) { // INFO: Currently shutdownActivePlugins maybe called twice. + // TODO: controller myPluginManager.shutdownActivePlugins(); System.exit(0); } @@ -232,7 +233,7 @@ } public void actionPerformed(ActionEvent e) { - myController.writeToServer(jTextPaneClientRaw.getText()); + myController.writeToServer(); jTextPaneClientRaw.setText(""); } }; @@ -249,7 +250,7 @@ } public void actionPerformed(ActionEvent e) { - myController.writeToClient(jTextPaneServerRaw.getText()); + myController.writeToClient(); jTextPaneServerRaw.setText(""); } }; @@ -288,6 +289,7 @@ if (myPluginConfigurationDialog == null) { myPluginConfigurationDialog = new PluginConfigurationDialog(jFrame, myPluginManager, myController.getView()); } + // TODO: controller myPluginConfigurationDialog.addPlugins(myPluginManager.getAvailablePlugins()); myPluginConfigurationDialog.setVisible(true); } @@ -332,13 +334,14 @@ putValue(Action.SHORT_DESCRIPTION, Internationalization.getTranslation("ac_start_relay_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_START)); myRelayIsActive = false; + // TODO: controller myPluginManager.shutdownActivePlugins(); - myController.stopRelay(); + myController.disableRelay(); } else { putValue(Action.NAME, Internationalization.getTranslation("ac_stop_relay")); putValue(Action.SHORT_DESCRIPTION, Internationalization.getTranslation("ac_stop_relay_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_STOP)); - myController.startRelay(); + myController.enableRelay(); myRelayIsActive = true; } } @@ -357,6 +360,7 @@ public void actionPerformed(ActionEvent e) { jTextPaneClientRaw.setText(""); + // TODO: controller myPluginManager.clearActivePluginsClient(); } }; @@ -374,6 +378,7 @@ public void actionPerformed(ActionEvent e) { jTextPaneServerRaw.setText(""); + // TODO: controller myPluginManager.clearActivePluginsServer(); } }; @@ -392,6 +397,7 @@ public void actionPerformed(ActionEvent e) { jTextPaneServerRaw.setText(""); jTextPaneClientRaw.setText(""); + // TODO: controller myPluginManager.clearActivePluginsClient(); myPluginManager.clearActivePluginsServer(); } @@ -442,7 +448,7 @@ myController = controller; myRelay.getMessageHistory().addNewMessageListener(this); - myRelay.getMessageHistory().addRefreshMessageListener(this); + myRelay.getMessageHistory().addLoadMessageListener(this); myPluginManager = myRelay.getPluginManager(); @@ -517,9 +523,9 @@ /** * {@inheritDoc} * - * @see de.dlr.davinspector.history.IRefreshMessageListener#refreshMessage(de.dlr.davinspector.history.MessageEvent) + * @see de.dlr.davinspector.history.ILoadMessageListener#loadMessage(de.dlr.davinspector.history.MessageEvent) */ - public void refreshMessage(MessageEvent refreshMessageEvent) { + public void loadMessage(MessageEvent refreshMessageEvent) { AMessage msg = refreshMessageEvent.getMessage(); updateMessage(msg); } @@ -532,9 +538,11 @@ private void updateMessage(AMessage message) { if (message.getMessageDirection().equals(Direction.ClientToServer)) { jTextPaneClientRaw.setText(message.getRawData()); + // TODO: controller myPluginManager.updateActivePluginsClient(message); } else { jTextPaneServerRaw.setText(message.getRawData()); + // TODO: controller myPluginManager.updateActivePluginsServer(message); } } @@ -592,6 +600,7 @@ jTabbedPaneClient.addTab(Internationalization.getTranslation("tab_raw"), null, getJScrollPaneClientRaw(), null); //update plugins + // TODO: controller if (myPluginManager != null) { List<IPlugin> plugged = myPluginManager.getActivePluginsClient(); for (Iterator<IPlugin> iterator = plugged.iterator(); iterator.hasNext();) { @@ -631,6 +640,7 @@ jTabbedPaneServer.addTab(Internationalization.getTranslation("tab_raw"), null, getJScrollPaneServerRaw(), null); //update plugins + // TODO: controller if (myPluginManager != null) { List<IPlugin> plugged = myPluginManager.getActivePluginsServer(); for (Iterator<IPlugin> iterator = plugged.iterator(); iterator.hasNext();) { @@ -922,8 +932,9 @@ * This method restarts the relay with the new configuration. */ public void restartRelay() { - myController.stopRelay(); - myController.startRelay(); + myController.disableRelay(); + // ### wait + myController.enableRelay(); } /** @@ -965,6 +976,7 @@ if (jTableHistory == null) { myHistoryTableModel = new HistoryTableModel(); + // TODO: controller? myRelay.getMessageHistory().addNewMessageListener(myHistoryTableModel); jTableHistory = new JTable(myHistoryTableModel); @@ -982,6 +994,8 @@ int rowIndex = jTableHistory.getSelectedRow(); if (rowIndex >= 0 && rowIndex < jTableHistory.getRowCount()) { int id = (Integer) jTableHistory.getValueAt(rowIndex, 1); + // TODO: controller + myController.loadMessage(id); myRelay.getMessageHistory().loadMessageByID(id); } } @@ -1028,4 +1042,20 @@ } return jToggleButtonAutomode; } + + /** + * Enable actions for sending data manual. + */ + public void enableSendToActions() { + sendToClientAction.setEnabled(true); + sendToServerAction.setEnabled(true); + } + + /** + * Disable actions for sending data manual. + */ + public void disableSendToActions() { + sendToClientAction.setEnabled(false); + sendToServerAction.setEnabled(false); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-27 14:18:23
|
Revision: 98 http://davinspector.svn.sourceforge.net/davinspector/?rev=98&view=rev Author: wuest Date: 2008-03-27 07:18:11 -0700 (Thu, 27 Mar 2008) Log Message: ----------- Corrected spelling in text bundles. Separated RelayModel into model-part and relay-part, work still in progress. Unified naming of data/message directions. Added log4j appender for the relay package. Modified Paths: -------------- trunk/DAVInspector/DAVInspector.bat trunk/DAVInspector/log4j.properties trunk/DAVInspector/resource/TextBundle.properties trunk/DAVInspector/resource/TextBundle_de_DE.properties trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java Added Paths: ----------- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java trunk/DAVInspector/src/de/dlr/davinspector/relay/INewClientDataListener.java trunk/DAVInspector/src/de/dlr/davinspector/relay/INewServerDataListener.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayThread.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayThread.java Removed Paths: ------------- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IClientListener.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IServerListener.java Modified: trunk/DAVInspector/DAVInspector.bat =================================================================== --- trunk/DAVInspector/DAVInspector.bat 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/DAVInspector.bat 2008-03-27 14:18:11 UTC (rev 98) @@ -1,3 +1,3 @@ @echo off -java -jar DAVInspector.jar -D java.util.logging.config.file=C:/Programme/DAVInspector/logging.properties +java -jar DAVInspector.jar Modified: trunk/DAVInspector/log4j.properties =================================================================== --- trunk/DAVInspector/log4j.properties 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/log4j.properties 2008-03-27 14:18:11 UTC (rev 98) @@ -7,6 +7,7 @@ log4j.logger.de.dlr.davinspector.plugins=DEBUG, plugin log4j.logger.de.dlr.davinspector.http=DEBUG, messageparser log4j.logger.de.dlr.davinspector.history=DEBUG, messageparser +log4j.logger.de.dlr.davinspector.relay=DEBUG, relay # Configuration of the general Log-File log4j.appender.system=org.apache.log4j.FileAppender @@ -26,3 +27,9 @@ log4j.appender.messageparser.File=log/messageparser.log log4j.appender.messageparser.layout=org.apache.log4j.PatternLayout log4j.appender.messageparser.layout.ConversionPattern=%p %t %c - %m%n + +# Configuration of the Log-File for relay and channel threads +log4j.appender.relay=org.apache.log4j.FileAppender +log4j.appender.relay.File=log/relay.log +log4j.appender.relay.layout=org.apache.log4j.PatternLayout +log4j.appender.relay.layout.ConversionPattern=%p %t %c - %m%n Modified: trunk/DAVInspector/resource/TextBundle.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle.properties 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/resource/TextBundle.properties 2008-03-27 14:18:11 UTC (rev 98) @@ -1,30 +1,30 @@ # actions ac_exit=Exit -ac_exit_description=Exit the program. +ac_exit_description=Exit the program ac_send_to_server=Send to Server -ac_send_to_server_description=Send Client data to the Server. +ac_send_to_server_description=Send Client data to the Server ac_send_to_client=Send to Client -ac_send_to_client_description=Send Server data to the Client. +ac_send_to_client_description=Send Server data to the Client ac_configure=Configure -ac_configure_description=Configure the application. +ac_configure_description=Configure the application ac_configure_plugins=Configure -ac_configure_plugins_description=Configure the loaded plugins. +ac_configure_plugins_description=Configure the loaded plugins ac_about=About -ac_about_description=Display information about the application. +ac_about_description=Display information about the application ac_start_relay=Start Relay -ac_start_relay_description=Start the relay. +ac_start_relay_description=Start the relay ac_stop_relay=Stop Relay -ac_stop_relay_description=Stop the relay. +ac_stop_relay_description=Stop the relay ac_clear_client=Clear Client -ac_clear_client_description=Clear the Client side data. +ac_clear_client_description=Clear the Client side data ac_clear_server=Clear Server -ac_clear_server_description=Clear the Server side data. +ac_clear_server_description=Clear the Server side data ac_clear_all=Clear All -ac_clear_all_description=Clear all data. +ac_clear_all_description=Clear all data ac_enable_auto_mode=Enable Auto Mode -ac_enable_auto_mode_description=Data is automatically transfered. +ac_enable_auto_mode_description=Data is automatically transfered ac_disable_auto_mode=Disable Auto Mode -ac_disable_auto_mode_description=No automtic data transfer. +ac_disable_auto_mode_description=No automatic data transfer #tabs tab_raw=Raw Modified: trunk/DAVInspector/resource/TextBundle_de_DE.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-03-27 14:18:11 UTC (rev 98) @@ -1,30 +1,30 @@ #actions ac_exit=Beenden -ac_exit_description=Das Programm schlie\xDFen. +ac_exit_description=Das Programm schlie\xDFen ac_send_to_server=Sende zum Server -ac_send_to_server_description=Client Daten zum Server \xFCbertragen. +ac_send_to_server_description=Client-Daten zum Server \xFCbertragen ac_send_to_client=Sende zum Client -ac_send_to_client_description=Server Daten zum Client \xFCbertragen. +ac_send_to_client_description=Server-Daten zum Client \xFCbertragen ac_configure=Einstellungen -ac_configure_description=Die Einstellungen des Programms \xE4ndern. +ac_configure_description=Die Einstellungen des Programms \xE4ndern ac_configure_plugins=Konfiguration -ac_configure_plugins_description=Die geladene Plugins konfigurieren. +ac_configure_plugins_description=Die geladenen Plugins konfigurieren ac_about=\xDCber... -ac_about_description=Information zum Programm anzeigen. +ac_about_description=Information zum Programm anzeigen ac_start_relay=Relais starten -ac_start_relay_description=Startet das Relais. +ac_start_relay_description=Startet das Relais ac_stop_relay=Relais stoppen -ac_stop_relay_description=Stoppt das Relais. +ac_stop_relay_description=Stoppt das Relais ac_clear_client=Client leeren -ac_clear_client_description=Client Ansicht leeren. +ac_clear_client_description=Client-Ansicht leeren ac_clear_server=Server leeren -ac_clear_server_description=Server Ansicht leeren. +ac_clear_server_description=Server-Ansicht leeren ac_clear_all=Alle leeren -ac_clear_all_description=Alle Ansichten leeren. +ac_clear_all_description=Alle Ansichten leeren ac_enable_auto_mode=Automatik aktivieren -ac_enable_auto_mode_description=Die Daten werden automatisch \xFCbertragen. +ac_enable_auto_mode_description=Die Daten werden automatisch \xFCbertragen ac_disable_auto_mode=Automatik deaktivieren -ac_disable_auto_mode_description=Die Daten m\xFCssen manuell \xFCbertragen werden. +ac_disable_auto_mode_description=Die Daten m\xFCssen manuell \xFCbertragen werden #tabs tab_raw=Rohdaten @@ -49,7 +49,7 @@ dlg_configuration_client_port=Client-Port #PluginConfigurationDialog -dlg_plugin_configuration_title=Plugin Einstellungen +dlg_plugin_configuration_title=Plugin-Einstellungen dlg_plugin_configuration_ok=Ok dlg_plugin_configuration_cancel=Abbrechen dlg_plugin_configuration_type_edit=R/W Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-27 14:18:11 UTC (rev 98) @@ -36,9 +36,6 @@ */ public final class Constant { - /** Basis of the hexadecimal number system. */ - public static final int HEX_RADIX = 16; - /** Main window width. */ public static final int UI_MAIN_WINDOW_WIDTH = 800; @@ -94,13 +91,13 @@ public static final String APP_PLUGIN_CONFIGURATION_FILENAME = "plugin-config.properties"; /** Timeout waiting for a ChannelThread to finish in ms. */ - public static final int RELAY_THREADTIMEOUT = 100; + public static final int RELAY_THREADTIMEOUT = 10; /** Linger time in seconds for socket. */ - public static final int RELAY_LINGERTIME = 100; + public static final int RELAY_LINGERTIME = 10; /** Size of the receive buffer. */ - public static final int RELAY_RECVBUFFERSIZE = 2048; + public static final int RELAY_RECVBUFFERSIZE = 1024; /** Backlog parameter used when creating the ServerSocket. */ public static final int RELAY_BACKLOG = 1; @@ -135,6 +132,22 @@ /** System logger configuration file (log4j). */ public static final String SYSTEM_LOGGER_CONFIGURATION = "log4j.properties"; + /** Basis of the hexadecimal number system. */ + public static final int HEX_RADIX = 16; + + /** + * Indicates the direction of the message. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ + public enum Direction { + /** From client to server. */ + ClientToServer, + /** From server to client. */ + ServerToClient + } + /** * Hide class constructor. */ Deleted: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-27 14:18:11 UTC (rev 98) @@ -1,237 +0,0 @@ -/* - * AMessage.java - * - * The abstract class for messages. - * - * Created: 29.02.2008 Jochen Wuest <joc...@dl...> - * Changed: - * - * $Id$ - * - * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.dlr.davinspector.history; - -import java.util.Date; - - -/** - * The abstract class for messages. - * - * @version $LastChangedRevision$ - * @author Jochen Wuest - */ -public abstract class AMessage { - - /** The counter for unique numbering. */ - protected static int idCounter; - - /** - * Message type indicates the direction of the message: - * <ul> - * <li>Message from client to server: Request.</li> - * <li>Message from server to client: Response.</li> - * </ul> - * - * @version $LastChangedRevision$ - * @author Jochen Wuest - */ - public enum MessageDirection { - /** Data from client to server. */ - Request, - /** Data from server to client. */ - Response - } - - /** Parsing state of the message. */ - protected Boolean myParsingState; - - /** Unique ID of a message. */ - protected int myID; - - /** Timestamp of the current message. */ - protected Date myTimestamp; - - /** myDirection indicates the direction of the message. @see MessageDirection */ - protected MessageDirection myDirection; - - /** This string contains the raw data of the message. */ - protected String myRawData; - - /** This string contains the unprocessed header of the message. */ - protected String myRawHeader; - - /** This string contains the unprocessed body of the message. */ - protected String myRawBody; - - /** This string contains the processed header of the message. */ - protected String myParsedHeader; - - /** This string contains the processed body of the message. */ - protected String myParsedBody; - - /** The size in bytes of the current message. */ - protected int mySize; - - /** - * This method returns the ID of the message. - * - * @return id - */ - public int getId() { - return myID; - } - - /** - * This method returns the timestamp of the message. - * - * @return timestamp - */ - public Date getTimestamp() { - return myTimestamp; - } - - /** - * This method sets the timestamp of the current message. - * - * @param timestamp Date/Timestamp - */ - public void setTimestamp(Date timestamp) { - myTimestamp = timestamp; - } - - /** - * Returns the direction (request/reply) of the message. - * @see MessageDirection - * - * @return MessageDirection - */ - public MessageDirection getMessageDirection() { - return myDirection; - } - - /** - * This method sets the direction (request/reply) of the message. - * @see MessageDirection - * - * @param direction MessageDirection - */ - public void setMessageType(MessageDirection direction) { - myDirection = direction; - } - - /** - * This method sets the message direction. - * @see MessageDirection - * - * @param toClient Boolean - */ - public void setMessageDirection(Boolean toClient) { - if (toClient) { - myDirection = MessageDirection.Response; - } else { - myDirection = MessageDirection.Request; - } - } - - /** - * Returns the size of the message in bytes. - * - * @return size int - */ - public int getSize() { - return mySize; - } - - /** - * This method parses the current raw data. - * If the buffer contains more than only the data for the current message, the rest is returned. - * - * @return String - */ - public String parseMessage() { - return ""; - } - - /** - * This method returns <code>true</code> if the message processing is done - * and a valid message has been recognized. - * - * @return Boolean - */ - public Boolean isComplete() { - return myParsingState; - } - - /** - * Returns the raw data of the message. - * - * @return data String - */ - public String getRawData() { - return myRawData; - } - - /** - * Sets the raw data of the current message. - * Message size, ID, body and header are automatically added. - * - * @param msg String - */ - public void setRawData(String msg) { - myRawData = msg; - mySize = msg.length(); - myID = idCounter; - } - - /** - * Returns the parsed head of the message. - * By default this returns the same as <code>getRawHeader</code>. - * - * @return String - */ - public String getMessageHeader() { - return myParsedHeader; - } - - /** - * Returns the raw, unparsed head of the message. - * - * @return String - */ - public String getRawHeader() { - return myRawHeader; - } - - /** - * Returns the parsed body of the message. - * By default this returns the same as <code>getRawBody</code>. - * - * @return String - */ - public String getMessageBody() { - return myParsedBody; - } - - /** - * Returns the raw, unparsed body of the message. - * - * @return String - */ - public String getRawBody() { - return myRawBody; - } -} Added: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-27 14:18:11 UTC (rev 98) @@ -0,0 +1,208 @@ +/* + * AMessage.java + * + * The abstract class for messages. + * + * Created: 29.02.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.history; + +import java.util.Date; + +import de.dlr.davinspector.common.Constant.Direction; + + +/** + * The abstract class for messages. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public abstract class AMessage { + + /** The counter for unique numbering. */ + protected static int idCounter; + + /** Parsing state of the message. */ + protected Boolean myParsingState; + + /** Unique ID of a message. */ + protected int myID; + + /** Timestamp of the current message. */ + protected Date myTimestamp; + + /** myDirection indicates the direction of the message. @see MessageDirection */ + protected Direction myDirection; + + /** This string contains the raw data of the message. */ + protected String myRawData; + + /** This string contains the unprocessed header of the message. */ + protected String myRawHeader; + + /** This string contains the unprocessed body of the message. */ + protected String myRawBody; + + /** This string contains the processed header of the message. */ + protected String myParsedHeader; + + /** This string contains the processed body of the message. */ + protected String myParsedBody; + + /** The size in bytes of the current message. */ + protected int mySize; + + /** + * This method returns the ID of the message. + * + * @return id + */ + public int getId() { + return myID; + } + + /** + * This method returns the timestamp of the message. + * + * @return timestamp + */ + public Date getTimestamp() { + return myTimestamp; + } + + /** + * This method sets the timestamp of the current message. + * + * @param timestamp Date/Timestamp + */ + public void setTimestamp(Date timestamp) { + myTimestamp = timestamp; + } + + /** + * Returns the direction (request/reply) of the message. + * @see MessageDirection + * + * @return MessageDirection + */ + public Direction getMessageDirection() { + return myDirection; + } + + /** + * This method sets the message direction. + * @see MessageDirection + * + * @param direction Direction + */ + public void setMessageDirection(Direction direction) { + myDirection = direction; + } + + /** + * Returns the size of the message in bytes. + * + * @return size int + */ + public int getSize() { + return mySize; + } + + /** + * This method parses the current raw data. + * If the buffer contains more than only the data for the current message, the rest is returned. + * + * @return String + */ + public String parseMessage() { + return ""; + } + + /** + * This method returns <code>true</code> if the message processing is done + * and a valid message has been recognized. + * + * @return Boolean + */ + public Boolean isComplete() { + return myParsingState; + } + + /** + * Returns the raw data of the message. + * + * @return data String + */ + public String getRawData() { + return myRawData; + } + + /** + * Sets the raw data of the current message. + * Message size, ID, body and header are automatically added. + * + * @param msg String + */ + public void setRawData(String msg) { + myRawData = msg; + mySize = msg.length(); + myID = idCounter; + } + + /** + * Returns the parsed head of the message. + * By default this returns the same as <code>getRawHeader</code>. + * + * @return String + */ + public String getMessageHeader() { + return myParsedHeader; + } + + /** + * Returns the raw, unparsed head of the message. + * + * @return String + */ + public String getRawHeader() { + return myRawHeader; + } + + /** + * Returns the parsed body of the message. + * By default this returns the same as <code>getRawBody</code>. + * + * @return String + */ + public String getMessageBody() { + return myParsedBody; + } + + /** + * Returns the raw, unparsed body of the message. + * + * @return String + */ + public String getRawBody() { + return myRawBody; + } +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java 2008-03-27 14:18:11 UTC (rev 98) @@ -36,6 +36,7 @@ import javax.swing.table.TableCellRenderer; import de.dlr.davinspector.common.Constant; +import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.common.Internationalization; import de.dlr.davinspector.common.Util; @@ -82,7 +83,7 @@ if (column == COLUMN_INDEX_TYPE){ setHorizontalAlignment(SwingConstants.LEFT); - if (value.equals(AMessage.MessageDirection.Request)) { + if (value.equals(Direction.ClientToServer)) { setText(Internationalization.getTranslation("col_history_type_request")); isRequest = true; } else { Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-27 14:18:11 UTC (rev 98) @@ -32,11 +32,12 @@ import javax.swing.event.EventListenerList; +import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.http.HTTPMessageParser; import de.dlr.davinspector.relay.DataEvent; -import de.dlr.davinspector.relay.IClientListener; +import de.dlr.davinspector.relay.INewClientDataListener; +import de.dlr.davinspector.relay.INewServerDataListener; import de.dlr.davinspector.relay.IRelayModel; -import de.dlr.davinspector.relay.IServerListener; /** @@ -45,7 +46,7 @@ * @version $LastChangedRevision$ * @author Jochen Wuest */ -public class MessageHistory implements IServerListener, IClientListener { +public class MessageHistory implements INewServerDataListener, INewClientDataListener { /** List of listeners for new messages. */ private EventListenerList myListenersNewMessage = new EventListenerList(); @@ -54,10 +55,10 @@ private EventListenerList myListenersRefreshMessage = new EventListenerList(); /** This string buffers the client side raw data. */ - private String myClientsideBuffer; + private String myClientToServerBuffer; /** This string buffers the server side raw data. */ - private String myServersideBuffer; + private String myServerToClientBuffer; /** This vector stores the messages. */ private List<AMessage> myMessages = null; @@ -75,11 +76,11 @@ public MessageHistory(IRelayModel relay) { myRelay = relay; myMessages = new Vector<AMessage>(); - myClientsideBuffer = ""; - myServersideBuffer = ""; + myClientToServerBuffer = ""; + myServerToClientBuffer = ""; - myRelay.addClientListener(this); - myRelay.addServerListener(this); + myRelay.addNewClientDataListener(this); + myRelay.addNewServerDataListener(this); } /** @@ -87,16 +88,16 @@ * Afterwards a {@link MessageEvent} is generated and all {@link INewMessageListener} are notified. * * @param data String - * @param toClient Boolean + * @param direction Direction * @param timestamp Date */ - public void storeMessage(String data, Boolean toClient, Date timestamp) { + public void storeMessage(String data, Direction direction, Date timestamp) { // INFO: add decorator dependent on protocol (switch http, ...). // Notice: idCounter != number of messages HTTPMessageParser message = new HTTPMessageParser(new Message()); - message.setMessageDirection(toClient); + message.setMessageDirection(direction); message.setRawData(data); message.setTimestamp(timestamp); String carry = message.parseMessage(); @@ -106,16 +107,16 @@ myMessages.add(message); notifyNewMessage(new MessageEvent(this, message)); // clear buffer - if (!toClient) { - myClientsideBuffer = carry; + if (direction == Direction.ServerToClient) { + myClientToServerBuffer = carry; } else { - myServersideBuffer = carry; + myServerToClientBuffer = carry; } // automatic send the message to client/server // TODO: Steuerung nachrichten aus mainview raus!! if (myRelay.getStateAutomode()) { - if (toClient) { + if (direction == Direction.ServerToClient) { myRelay.writeToClient(message.getRawData()); } else { myRelay.writeToServer(message.getRawData()); @@ -150,21 +151,21 @@ /** * {@inheritDoc} * - * @see de.dlr.davinspector.relay.IClientListener#newClientData(de.dlr.davinspector.relay.DataEvent) + * @see de.dlr.davinspector.relay.INewClientDataListener#newClientData(de.dlr.davinspector.relay.DataEvent) */ public void newClientData(DataEvent newDataEvent) { - myClientsideBuffer += newDataEvent.getData(); - storeMessage(myClientsideBuffer, false, new Date()); + myClientToServerBuffer += newDataEvent.getData(); + storeMessage(myClientToServerBuffer, Direction.ClientToServer, new Date()); } /** * {@inheritDoc} * - * @see de.dlr.davinspector.relay.IServerListener#newServerData(de.dlr.davinspector.relay.DataEvent) + * @see de.dlr.davinspector.relay.INewServerDataListener#newServerData(de.dlr.davinspector.relay.DataEvent) */ public void newServerData(DataEvent newDataEvent) { - myServersideBuffer += newDataEvent.getData(); - storeMessage(myServersideBuffer, true, new Date()); + myServerToClientBuffer += newDataEvent.getData(); + storeMessage(myServerToClientBuffer, Direction.ServerToClient, new Date()); } /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-27 14:18:11 UTC (rev 98) @@ -31,6 +31,7 @@ import org.apache.log4j.Logger; import de.dlr.davinspector.common.Constant; +import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.history.AMessage; import de.dlr.davinspector.history.AMessageParser; @@ -139,6 +140,8 @@ * {@inheritDoc} * * @see de.dlr.davinspector.history.AMessageParser#parseMessage() + * + * TODO: extract "100 Continue" Messages */ public String parseMessage() { myLogger.debug("---- new data event ----"); @@ -151,7 +154,7 @@ myParsedBody = ""; myRawBody = ""; - if (myDirection == MessageDirection.Response) { + if (myDirection == Direction.ServerToClient) { Pattern pattern = Pattern.compile(REGEX_HTTP_STATUS_LINE, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(myRawData); if (matcher.find()) { @@ -231,7 +234,7 @@ * @return Boolean */ private Boolean hasBody() { - if (myDirection == MessageDirection.Response) { + if (myDirection == Direction.ServerToClient) { if (myStatusCode == HTTPStatusCode.HTTP_CONTINUE || myStatusCode == HTTPStatusCode.HTTP_SWITCHING_PROTOCOLS || myStatusCode == HTTPStatusCode.HTTP_NO_CONTENT Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java 2008-03-27 14:18:11 UTC (rev 98) @@ -75,7 +75,7 @@ * * @param direction Indicates the assignement of the plugin to server or client side. */ - void init(Direction direction); + void init(PlugInDirection direction); /** * Starts processing of the message. @@ -128,14 +128,14 @@ } /** - * The <tt>Direction</tt> indicates the assignment of + * The <tt>PlugInDirection</tt> indicates the assignment of * a plugin object to the server or client side. * Only needed by <code>*_GENERAL</code> plugins. * * @version $LastChangedRevision$ * @author Jochen Wuest */ - public enum Direction { + public enum PlugInDirection { /** Plugin on the client side. */ CLIENT, /** Plugin on the server side. */ Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-27 14:18:11 UTC (rev 98) @@ -121,10 +121,10 @@ // INFO: only add plugin if specified for client/server side // INFO: alternative Direction could be specified here by PluginType!? plugin = (IPlugin) c.newInstance(); - plugin.init(IPlugin.Direction.CLIENT); + plugin.init(IPlugin.PlugInDirection.CLIENT); myActivePluginsClient.add(plugin); plugin = (IPlugin) c.newInstance(); - plugin.init(IPlugin.Direction.SERVER); + plugin.init(IPlugin.PlugInDirection.SERVER); myActivePluginsServer.add(plugin); } } catch (ClassNotFoundException cnfe) { Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-27 14:18:11 UTC (rev 98) @@ -112,7 +112,7 @@ * * @see de.dlr.DAVInspector.Plugin.IPlugin#init() */ - public void init(Direction direction) { + public void init(PlugInDirection direction) { if (myJScrollPane == null) { myJScrollPane = new JScrollPane(); myJTextPane = new JTextPane(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-03-27 14:18:11 UTC (rev 98) @@ -38,7 +38,7 @@ import javax.swing.LayoutStyle; import de.dlr.davinspector.common.Util; -import de.dlr.davinspector.plugin.IPlugin.Direction; +import de.dlr.davinspector.plugin.IPlugin.PlugInDirection; /** * This class is the UI for the RecordingPlugin. @@ -126,7 +126,7 @@ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_hh-mm"); String side = "_server_"; - if (myParent.getDirection() == Direction.CLIENT) { + if (myParent.getDirection() == PlugInDirection.CLIENT) { side = "_client_"; } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java 2008-03-27 14:18:11 UTC (rev 98) @@ -59,7 +59,7 @@ private BufferedWriter myBufferedWriter = null; /** This saves the side assigned to the current plugin object. */ - private Direction myDirection; + private PlugInDirection myDirection; /** * {@inheritDoc} @@ -129,7 +129,7 @@ * * @see de.dlr.davinspector.plugin.IPlugin#init() */ - public void init(Direction direction) { + public void init(PlugInDirection direction) { myDirection = direction; if (myPanel == null) { myPanel = new RecordingConfigurationPanel(this); @@ -221,7 +221,7 @@ * * @return Returns the direction of the plugin object. */ - public Direction getDirection() { + public PlugInDirection getDirection() { return myDirection; } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-03-27 14:18:11 UTC (rev 98) @@ -128,7 +128,7 @@ * * @see de.dlr.DAVInspector.Plugin.IPlugin#init() */ - public void init(Direction direction) { + public void init(PlugInDirection direction) { if (myJSplitPane == null) { myJTextArea = new JTextArea(); myJTextArea.setLineWrap(true); Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-03-27 14:18:11 UTC (rev 98) @@ -128,7 +128,7 @@ * * @see de.dlr.DAVInspector.Plugin.IPlugin#init() */ - public void init(Direction direction) { + public void init(PlugInDirection direction) { if (myJSplitPane == null) { myJTextArea = new JTextArea(); myJTextArea.setLineWrap(true); Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-27 14:18:11 UTC (rev 98) @@ -30,11 +30,11 @@ import java.io.OutputStream; import java.net.Socket; import java.net.SocketException; -import java.util.List; import org.apache.log4j.Logger; import de.dlr.davinspector.common.Constant; +import de.dlr.davinspector.common.Constant.Direction; /** * This class copies data from one socket to another. @@ -47,6 +47,9 @@ /** */ public static final String COLON = ": "; + /** Logger, Apache log4j. */ + private static Logger myLogger = Logger.getLogger(ChannelThread.class); + /** */ private Socket myInputSocket; @@ -60,36 +63,25 @@ private ChannelThread myPeer; /** */ - private boolean myDirection; + private Direction myDirection; - /** The logger. */ - private Logger myLogger; - /** */ private String myThreadName = ""; /** */ - private IRelayModel myRelay = null; + private IRelayThread myRelayThread = null; - /** */ - private List<ChannelThread> myConnections; - /** * Constructor of a ChannelThread. * * @param inputSocket Socket input socket * @param outputSocket Socket output socket - * @param relay lock object - * @param logger Logger - * @param connections List + * @param relayThread lock object */ - public ChannelThread(Socket inputSocket, Socket outputSocket, IRelayModel relay, - Logger logger, List<ChannelThread> connections) { + public ChannelThread(Socket inputSocket, Socket outputSocket, IRelayThread relayThread) { myInputSocket = inputSocket; myOutputSocket = outputSocket; - myRelay = relay; - myLogger = logger; - myConnections = connections; + myRelayThread = relayThread; } /** @@ -106,52 +98,51 @@ try { count = in.read(buffer); while ((count != Constant.EOF) && !isInterrupted()) { - synchronized (myRelay) { + synchronized (myRelayThread) { // TODO: add encoding to configuration and set encoding from configuration - myRelay.updateData(new String(buffer, 0, count, "utf-8"), myDirection); + myLogger.debug(myThreadName + COLON + "Got input " + myDirection); + + myRelayThread.newData(new String(buffer, 0, count, "utf-8"), myDirection); } count = in.read(buffer); } } catch (IOException ioe) { myLogger.error(myThreadName + COLON + ioe.getMessage(), ioe); } finally { - myLogger.debug(myThreadName + COLON + "flushing"); + myLogger.debug(myThreadName + COLON + "Flushing " + activeCount()); flushOut(); } } catch (IOException ioe) { myLogger.error(myThreadName + ioe.getMessage(), ioe); } - synchronized (myRelay) { + synchronized (myRelayThread) { + myLogger.debug(myThreadName + COLON + "Done " + activeCount()); myDone = true; try { if ((myPeer == null) || myPeer.isDone()) { // if the peer is already closed or has transferred all data, shutdown myInputSocket.close(); myOutputSocket.close(); - myLogger.debug(myThreadName + COLON + "closing"); + // TODO: irgendwie mitteilen, dass sockets nun geschlossen sind + myLogger.debug(myThreadName + COLON + "Closing sockets " + activeCount()); } else { // signal the peer we are done myPeer.interrupt(); - myLogger.debug(myThreadName + COLON + "interrupting peer"); + myLogger.debug(myThreadName + COLON + "Interrupting peer " + activeCount()); } } catch (IOException ioe) { myLogger.error(myThreadName + COLON + ioe.getMessage(), ioe); - } finally { - myLogger.debug(myThreadName + COLON + "removing connection"); - myConnections.remove(this); } } } /** - * Defines whether this is a client or server connection.<br> - * true = from server to client<br> - * false = from client to server<br> + * Defines whether this is a client or server connection. * - * @param direction Boolean + * @param direction Direction */ - public void setDirection(boolean direction) { + public void setDirection(Direction direction) { this.myDirection = direction; } @@ -190,6 +181,7 @@ */ public void write(String data) { try { + myLogger.debug(myThreadName + COLON + "Writing data"); OutputStream out = myOutputSocket.getOutputStream(); if (isChunked(data)) { sendChunkedData(out, data); @@ -225,13 +217,11 @@ } /** - * Returns the direction of the connection.<br> - * true = from server to client<br> - * false = from client to server<br> + * Returns the direction of the connection. * - * @return Boolean + * @return Direction */ - public Boolean getDirection() { + public Direction getDirection() { return myDirection; } @@ -289,5 +279,5 @@ myLogger.error(myThreadName + COLON + ioe.getMessage(), ioe); } } - } + } } Deleted: trunk/DAVInspector/src/de/dlr/davinspector/relay/IClientListener.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IClientListener.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IClientListener.java 2008-03-27 14:18:11 UTC (rev 98) @@ -1,45 +0,0 @@ -/* - * IClientListener.java - * - * New data from client listener interface. - * - * Created: 29.01.2008 Jochen Wuest <joc...@dl...> - * Changed: - * - * $Id$ - * - * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.dlr.davinspector.relay; - -import java.util.EventListener; - - -/** - * New data from client listener interface. - * - * @version $LastChangedRevision$ - * @author Jochen Wuest - */ -public interface IClientListener extends EventListener { - - /** - * Invoked when new data from the client has arrived. - * - * @param newDataEvent {@link DataEvent} - */ - void newClientData(DataEvent newDataEvent); -} Copied: trunk/DAVInspector/src/de/dlr/davinspector/relay/INewClientDataListener.java (from rev 97, trunk/DAVInspector/src/de/dlr/davinspector/relay/IClientListener.java) =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/INewClientDataListener.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/INewClientDataListener.java 2008-03-27 14:18:11 UTC (rev 98) @@ -0,0 +1,45 @@ +/* + * IClientListener.java + * + * New data from client listener interface. + * + * Created: 29.01.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.relay; + +import java.util.EventListener; + + +/** + * New data from client listener interface. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public interface INewClientDataListener extends EventListener { + + /** + * Invoked when new data from the client has arrived. + * + * @param newDataEvent {@link DataEvent} + */ + void newClientData(DataEvent newDataEvent); +} Copied: trunk/DAVInspector/src/de/dlr/davinspector/relay/INewServerDataListener.java (from rev 97, trunk/DAVInspector/src/de/dlr/davinspector/relay/IServerListener.java) =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/INewServerDataListener.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/INewServerDataListener.java 2008-03-27 14:18:11 UTC (rev 98) @@ -0,0 +1,44 @@ +/* + * IServerListener.java + * + * New data from server listener interface. + * + * Created: 29.01.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.relay; + +import java.util.EventListener; + +/** + * New data from server listener interface. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public interface INewServerDataListener extends EventListener { + + /** + * Invoked when new data from the server has arrived. + * + * @param newDataEvent {@link DataEvent} + */ + void newServerData(DataEvent newDataEvent); +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-27 14:18:11 UTC (rev 98) @@ -25,8 +25,7 @@ package de.dlr.davinspector.relay; -import org.apache.log4j.Logger; - +import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.configuration.Configuration; import de.dlr.davinspector.history.MessageHistory; import de.dlr.davinspector.plugin.PluginManager; @@ -65,13 +64,13 @@ void writeToServer(String data); /** - * This method notifies the listeners for server or client depending on the <code>toClient</code> + * This method notifies the listeners for server or client depending on the <code>direction</code> * parameter and uses the <code>data</code> to create a new {@link DataEvent}. * * @param data String - * @param toClient Boolean + * @param direction Direction */ - void updateData(String data, Boolean toClient); + void updateData(String data, Direction direction); /** * Returns the MessageHistory object. @@ -88,13 +87,6 @@ PluginManager getPluginManager(); /** - * Returns Log object from Apache log4j Logging. - * - * @return Logger - */ - Logger getSystemLog(); - - /** * Returns the state of the automode.<br> * true: ON<br> * false: OFF<br> @@ -113,30 +105,30 @@ void setStateAutomode(Boolean state); /** - * Adds an {@link IServerListener} to RelayModel. + * Adds an {@link INewServerDataListener} to RelayModel. * - * @param listener the {@link IServerListener} to be added + * @param listener the {@link INewServerDataListener} to be added */ - void addServerListener(IServerListener listener); + void addNewServerDataListener(INewServerDataListener listener); /** - * Removes an {@link IServerListener} from RelayModel. + * Removes an {@link INewServerDataListener} from RelayModel. * - * @param listener the {@link IServerListener} to be removed + * @param listener the {@link INewServerDataListener} to be removed */ - void removeServerListener(IServerListener listener); + void removeNewServerDataListener(INewServerDataListener listener); /** - * Adds an {@link IClientListener} to RelayModel. + * Adds an {@link INewClientDataListener} to RelayModel. * - * @param listener the {@link IClientListener} to be added + * @param listener the {@link INewClientDataListener} to be added */ - void addClientListener(IClientListener listener); + void addNewClientDataListener(INewClientDataListener listener); /** - * Removes an {@link IClientListener} from RelayModel. + * Removes an {@link INewClientDataListener} from RelayModel. * - * @param listener the {@link IClientListener} to be removed + * @param listener the {@link INewClientDataListener} to be removed */ - void removeClientListener(IClientListener listener); + void removeNewClientDataListener(INewClientDataListener listener); } Added: trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayThread.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayThread.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayThread.java 2008-03-27 14:18:11 UTC (rev 98) @@ -0,0 +1,61 @@ +/* + * IRelayThread.java + * + * TODO: wues_ha Enter comment! + * + * Created: 26.03.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.relay; + +import de.dlr.davinspector.common.Constant.Direction; + + + +/** + * TODO: wues_ha: Enter comment! + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public interface IRelayThread { + + /** + * Invokes the shutdown of the RelayThread. + * + */ + void stopRelay(); + + /** + * TODO: wues_ha: Enter comment! + * + * @param data String + * @param direction Direction + */ + void write(String data, Direction direction); + + /** + * TODO: wues_ha: Enter comment! + * + * @param data String + * @param direction Direction + */ + void newData(String data, Direction direction); +} Deleted: trunk/DAVInspector/src/de/dlr/davinspector/relay/IServerListener.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IServerListener.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IServerListener.java 2008-03-27 14:18:11 UTC (rev 98) @@ -1,44 +0,0 @@ -/* - * IServerListener.java - * - * New data from server listener interface. - * - * Created: 29.01.2008 Jochen Wuest <joc...@dl...> - * Changed: - * - * $Id$ - * - * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) - * - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.dlr.davinspector.relay; - -import java.util.EventListener; - -/** - * New data from server listener interface. - * - * @version $LastChangedRevision$ - * @author Jochen Wuest - */ -public interface IServerListener extends EventListener { - - /** - * Invoked when new data from the server has arrived. - * - * @param newDataEvent {@link DataEvent} - */ - void newServerData(DataEvent newDataEvent); -} Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-24 12:46:42 UTC (rev 97) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-27 14:18:11 UTC (rev 98) @@ -26,20 +26,11 @@ package de.dlr.davinspector.relay; -import java.io.IOException; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.util.List; -import java.util.Vector; - import javax.swing.event.EventListenerList; import org.apache.log4j.Logger; -import de.dlr.davinspector.common.Constant; +import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.configuration.Configuration; import de.dlr.davinspector.configuration.PluginConfiguration; import de.dlr.davinspector.history.MessageHistory; @@ -48,46 +39,34 @@ /** * Implementation of the relay interface. Provides the server socket * and manages the channel threads. - * FIXME: stopping of the relay and freeing of the server socket. + * TODO: add logging * * @version $LastChangedRevision$ * @author Jochen Wuest */ -public class RelayModel extends Thread implements IRelayModel { +public class RelayModel implements IRelayModel { /** Logger, Apache log4j. */ private static Logger myLogger = Logger.getLogger(RelayModel.class); /** List of listeners for new client data. */ - private EventListenerList myClientListeners = new EventListenerList(); + private EventListenerList myNewClientDataListeners = new EventListenerList(); /** List of listeners for server data. */ - private EventListenerList myServerListeners = new EventListenerList(); + private EventListenerList myNewServerDataListeners = new EventListenerList(); - /** Address to forward connections to. */ - private InetAddress myDestinationAddress; - - /** Port to forward connections to. */ - private int myDestinationPort; - - /** This proxy's server socket. */ - private ServerSocket serverSocket; - /** The plugin manager. */ private PluginManager myPluginManager = null; - /** The lock object is used for synchronizing the ChannelThreads. */ - private Object lock = new Object(); - - /** Contains all current connections (ChannelThreads). */ - private List<ChannelThread> connections = new Vector<ChannelThread>(); - /** The message history object. */ private MessageHistory myMessageHistory = null; /** State of the automode. */ private Boolean myStateAutomode = false; + /** */ + private IRelayThread theRelay = null; + /** * Constructor of a RelayModel. * The constructor creates a new {@link MessageHistory} object. @@ -120,15 +99,6 @@ public MessageHistory getMessageHistory() { return myMessageHistory; } - - /** - * {@inheritDoc} - * - * @see de.dlr.davinspector.relay.IRelayModel#getSystemLog() - */ - public Logger getSystemLog() { - return myLogger; - } /** * {@inheritDoc} @@ -151,29 +121,29 @@ /** * {@inheritDoc} * - * @see de.dlr.davinspector.relay.IRelayModel#addServerListener(de.dlr.davinspector.relay.IServerListener) + * @see de.dlr.davinspector.relay.IRelayModel#addNewServerDataListener(de.dlr.davinspector.relay.INewServerDataListener) */ - public void addServerListener(IServerListener listener) { - myServerListeners.add(IServerListener.class, listener); + public void addNewServerDataListener(INewServerDataListener listener) { + myNewServerDataListeners.add(INewServerDataListener.class, listener); } /** * {@inheritDoc} * - * @see de.dlr.davinspector.relay.IRelayModel#removeServerListener(de.dlr.davinspector.relay.IServerListener) + * @see de.dlr.davinspector.relay.IRelayModel#removeNewServerDataListener(de.dlr.davinspector.relay.INewServerDataListener) */ - public void removeServerListener(IServerListener listener) { - myServerListeners.remove(IServerListener.class, listener); + public void removeNewServerDataListener(INewServerDataListener listener) { + myNewServerDataListeners.remove(INewServerDataListener.class, listener); } /** - * Notifies all {@link IServerListener}s that have registered interest for + * Notifies all {@link INewServerDataListener}s that have registered interest for * notification on a {@link DataEvent}. * * @param event the {@link DataEvent} object */ - protected synchronized void notifyServerListeners... [truncated message content] |
From: <wu...@us...> - 2008-03-24 12:46:56
|
Revision: 97 http://davinspector.svn.sourceforge.net/davinspector/?rev=97&view=rev Author: wuest Date: 2008-03-24 05:46:42 -0700 (Mon, 24 Mar 2008) Log Message: ----------- Aligned dialog buttons and added hyperlinks to about dialog. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java trunk/DAVInspector/src/de/dlr/davinspector/ui/ConfigurationDialog.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java Added Paths: ----------- trunk/DAVInspector/src/de/dlr/davinspector/ui/JHyperlinkLabel.java Modified: trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-20 17:28:27 UTC (rev 96) +++ trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-24 12:46:42 UTC (rev 97) @@ -25,7 +25,7 @@ package de.dlr.davinspector; -import java.util.Locale; +//import java.util.Locale; import org.apache.log4j.PropertyConfigurator; @@ -57,7 +57,7 @@ // Configure Logger PropertyConfigurator.configure(Constant.SYSTEM_LOGGER_CONFIGURATION); // for testing i18n support - Locale.setDefault(new Locale("en")); +// Locale.setDefault(new Locale("en")); // Locale.setDefault(new Locale("de")); IRelayModel model = new RelayModel(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-20 17:28:27 UTC (rev 96) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-24 12:46:42 UTC (rev 97) @@ -58,7 +58,7 @@ public static final int UI_PLUGIN_CONFIG_DIALOG_HEIGTH = 250; /** About dialog width. */ - public static final int UI_ABOUT_DIALOG_WIDTH = 250; + public static final int UI_ABOUT_DIALOG_WIDTH = 275; /** About dialog height. */ public static final int UI_ABOUT_DIALOG_HEIGTH = 275; Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java 2008-03-20 17:28:27 UTC (rev 96) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java 2008-03-24 12:46:42 UTC (rev 97) @@ -26,17 +26,19 @@ package de.dlr.davinspector.ui; import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.Font; import java.awt.Frame; -import java.awt.SystemColor; import java.awt.Window; import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JTextPane; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.common.Internationalization; @@ -60,20 +62,11 @@ private JPanel jContentPane = null; /** */ - private JButton jButtonOk = null; + private JPanel jPanelInformation = null; /** */ - private JTextPane jTextPane = null; + private JPanel jPanelButton = null; - /** */ - private JPanel jPanel = null; - - /** */ - private JLabel jLabelAppIcon = null; - - /** */ - private JLabel jLabelAppName = null; - /** * Constructor of AboutDialog. * @@ -88,9 +81,10 @@ * This method initializes this. */ private void initialize() { - this.setSize(Constant.UI_ABOUT_DIALOG_WIDTH, Constant.UI_ABOUT_DIALOG_HEIGTH); - this.setTitle(Internationalization.getTranslation("dlg_about_title")); - this.setContentPane(getJContentPane()); + setSize(Constant.UI_ABOUT_DIALOG_WIDTH, Constant.UI_ABOUT_DIALOG_HEIGTH); + setTitle(Internationalization.getTranslation("dlg_about_title")); + setContentPane(getJContentPane()); + setResizable(false); Util.centerWindow((Window) this); } @@ -102,11 +96,11 @@ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); - jContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); jContentPane.setLayout(new BorderLayout()); - jContentPane.add(getJButtonOk(), BorderLayout.SOUTH); - jContentPane.add(getJTextPane(), BorderLayout.CENTER); - jContentPane.add(getJPanel(), BorderLayout.NORTH); + jContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + jContentPane.add(getJPanelInformation(), BorderLayout.CENTER); + jContentPane.add(getJPanelButton(), BorderLayout.SOUTH); } return jContentPane; } @@ -118,60 +112,60 @@ this.setVisible(false); this.dispose(); } + + /** + * This method initializes jPanelInformation. + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelInformation() { + if (jPanelInformation == null) { + jPanelInformation = new JPanel(); + jPanelInformation.setLayout(new BoxLayout(jPanelInformation, BoxLayout.PAGE_AXIS)); + jPanelInformation.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + JLabel jLabelTitel = new JLabel(); + jLabelTitel.setIcon(UIResource.getIcon(UIResource.ICON_APP32)); + jLabelTitel.setText(' ' + Constant.APP_TITLE); + jLabelTitel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, FONT_SIZE_LARGE)); + jPanelInformation.add(jLabelTitel); + jPanelInformation.add(Box.createRigidArea(new Dimension(0, 5))); + + jPanelInformation.add(new JLabel("<html>Version " + Constant.APP_VERSION + ", Apache 2.0 License" + + "<br>(c) Copyright Jochen Wuest, Markus Litz, DLR 2007-2008</html>")); + jPanelInformation.add(new JHyperlinkLabel("http://davinspector.sourceforge.net/")); + jPanelInformation.add(Box.createRigidArea(new Dimension(0, 5))); + + jPanelInformation.add(new JLabel("<html>Apache log4j</html>")); + jPanelInformation.add(new JHyperlinkLabel("http://logging.apache.org/log4j/")); + jPanelInformation.add(Box.createRigidArea(new Dimension(0, 5))); + + jPanelInformation.add(new JLabel("<html>Icons used by this Application:<br>Crystal Project Icons by Everaldo Coelho</html>")); + jPanelInformation.add(new JHyperlinkLabel("http://www.everaldo.com/")); + + jPanelInformation.add(Box.createRigidArea(new Dimension(0, 10))); + } + return jPanelInformation; + } /** - * This method initializes jButton. + * This method initializes jPanelButton. * - * @return javax.swing.JButton + * @return javax.swing.JPanel */ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); + private JPanel getJPanelButton() { + if (jPanelButton == null) { + jPanelButton = new JPanel(); + JButton jButtonOk = new JButton(); jButtonOk.setText(Internationalization.getTranslation("dlg_about_close")); + jButtonOk.setAlignmentY(Component.CENTER_ALIGNMENT); jButtonOk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { closeWindow(); } }); + jPanelButton.add(jButtonOk); } - return jButtonOk; + return jPanelButton; } - - /** - * This method initializes jTextPane. - * - * @return javax.swing.JTextPane - */ - private JTextPane getJTextPane() { - if (jTextPane == null) { - jTextPane = new JTextPane(); - jTextPane.setBackground(SystemColor.control); - jTextPane.setEditable(false); - jTextPane.setText("Version " + Constant.APP_VERSION + ", Apache 2.0 License" - + "\n(c) Copyright Jochen Wuest, Markus Litz, DLR 2007-2008" - + "\n\nCommons Logging, Apache 2.0 License\nhttp://commons.apache.org/logging/" - + "\n\nIcons used by this Application:\nCrystal Project Icons by Everaldo Coelho\nhttp://www.everaldo.com\n"); - } - return jTextPane; - } - - /** - * This method initializes jPanel. - * - * @return javax.swing.JPanel - */ - private JPanel getJPanel() { - if (jPanel == null) { - jLabelAppName = new JLabel(); - jLabelAppName.setText(" " + Constant.APP_TITLE); - jLabelAppName.setFont(new Font(Font.SANS_SERIF, Font.BOLD, FONT_SIZE_LARGE)); - jLabelAppIcon = new JLabel(); - jLabelAppIcon.setIcon(UIResource.getIcon(UIResource.ICON_APP32)); - jPanel = new JPanel(); - jPanel.setLayout(new BorderLayout()); - jPanel.add(jLabelAppIcon, BorderLayout.WEST); - jPanel.add(jLabelAppName, BorderLayout.CENTER); - } - return jPanel; - } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/ConfigurationDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/ConfigurationDialog.java 2008-03-20 17:28:27 UTC (rev 96) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/ConfigurationDialog.java 2008-03-24 12:46:42 UTC (rev 97) @@ -25,11 +25,16 @@ package de.dlr.davinspector.ui; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.Frame; import java.awt.GridLayout; import java.awt.Window; import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JLabel; @@ -86,6 +91,12 @@ /** */ private JButton jButtonOk = null; + /** */ + private JPanel jPanelButtonBar = null; + + /** */ + private JPanel jPanelGrid = null; + /** The View. */ private MainView myMainView = null; @@ -125,6 +136,23 @@ */ private JPanel getJContentPane() { if (jContentPane == null) { + jContentPane = new JPanel(); + jContentPane.setLayout(new BorderLayout()); + jContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + jContentPane.add(getJPanelGrid(), BorderLayout.CENTER); + jContentPane.add(getJPanelButtonBar(), BorderLayout.SOUTH); + } + return jContentPane; + } + + + /** + * This method initializes jPanelGrid. + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelGrid() { + if (jPanelGrid == null) { jLabelServerAddress = new JLabel(); jLabelServerAddress.setText(Internationalization.getTranslation("dlg_configuration_server_address") + ':'); jLabelServerAddress.setHorizontalAlignment(SwingConstants.RIGHT); @@ -137,24 +165,23 @@ jLabelServerPort = new JLabel(); jLabelServerPort.setText(Internationalization.getTranslation("dlg_configuration_server_port") + ':'); jLabelServerPort.setHorizontalAlignment(SwingConstants.RIGHT); - GridLayout gridLayout = new GridLayout(5, 2, 10, 10); - jContentPane = new JPanel(); - jContentPane.setLayout(gridLayout); - jContentPane.add(jLabelClientAddress, null); - jContentPane.add(getJTextFieldClientAddress(), null); - jContentPane.add(jLabelClientPort, null); - jContentPane.add(getJTextFieldClientPort(), null); - jContentPane.add(jLabelServerAddress, null); - jContentPane.add(getJTextFieldServerAddress(), null); - jContentPane.add(jLabelServerPort, null); - jContentPane.add(getJTextFieldServerPort(), null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + jPanelGrid = new JPanel(); + GridLayout gridLayout = new GridLayout(4, 2, 5, 10); + jPanelGrid.setLayout(gridLayout); + jPanelGrid.add(jLabelClientAddress, null); + jPanelGrid.add(getJTextFieldClientAddress(), null); + jPanelGrid.add(jLabelClientPort, null); + jPanelGrid.add(getJTextFieldClientPort(), null); + jPanelGrid.add(jLabelServerAddress, null); + jPanelGrid.add(getJTextFieldServerAddress(), null); + jPanelGrid.add(jLabelServerPort, null); + jPanelGrid.add(getJTextFieldServerPort(), null); } - return jContentPane; + return jPanelGrid; } + /** * This method initializes jButtonCancel. * @@ -266,4 +293,23 @@ } return jButtonOk; } + + /** + * This method initializes jPanelButtonBar. + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelButtonBar() { + if (jPanelButtonBar == null) { + jPanelButtonBar = new JPanel(); + jPanelButtonBar.setLayout(new BoxLayout(jPanelButtonBar, BoxLayout.LINE_AXIS)); + jPanelButtonBar.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + jPanelButtonBar.setAlignmentX(Component.RIGHT_ALIGNMENT); + jPanelButtonBar.add(Box.createHorizontalGlue()); + jPanelButtonBar.add(getJButtonOk()); + jPanelButtonBar.add(Box.createRigidArea(new Dimension(10, 0))); + jPanelButtonBar.add(getJButtonCancel()); + } + return jPanelButtonBar; + } } Added: trunk/DAVInspector/src/de/dlr/davinspector/ui/JHyperlinkLabel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/JHyperlinkLabel.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/JHyperlinkLabel.java 2008-03-24 12:46:42 UTC (rev 97) @@ -0,0 +1,126 @@ +/* + * HyperLinkLabel.java + * + * This class extends JLabel and displays the text as a hyperlink. + * If the text is clicked, the default browser is started with the given hyperlink. + * + * Created: 20.03.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.ui; + +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.Graphics; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import javax.swing.JLabel; + +/** + * This class extends JLabel and displays the text as a hyperlink. + * If the text is clicked, the default browser is started with the given hyperlink. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public class JHyperlinkLabel extends JLabel { + + /** Serial Version UID, not valid. */ + private static final long serialVersionUID = 1L; + + /** State of the underlining of the text. */ + protected boolean underline; + + /** + * The mouse listener. + */ + protected MouseListener mouseListener = new MouseAdapter() { + + public void mouseEntered(MouseEvent me) { + underline = true; + repaint(); + } + + public void mouseExited(MouseEvent me) { + underline = false; + repaint(); + } + + public void mouseClicked(MouseEvent me) { + fireActionEvent(); + } + }; + + /** + * Constructor of HyperlinkLabel. + * The assigned text is the displayed and also the destination of the hyperlink. + * + * @param text String + */ + public JHyperlinkLabel(String text) { + super(text); + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + setForeground(Color.BLUE); + addMouseListener(mouseListener); + } + + + /** + * This method handles the execution of the hyperlink. + * The default browser on the local system is started with the hyperlink as parameter. + */ + protected void fireActionEvent() { + Desktop desktop = Desktop.getDesktop(); + try { + desktop.browse(new URI(this.getText())); + } catch (URISyntaxException urise) { + System.err.append(urise.getLocalizedMessage()); + } catch (IOException ioe) { + System.err.append(ioe.getLocalizedMessage()); + } + } + + /** + * {@inheritDoc} + * + * @see javax.swing.JComponent#paint(java.awt.Graphics) + */ + public void paint(Graphics g) { + super.paint(g); + if (underline) { + // get the rectangle around the text + Rectangle2D textBounds = getFontMetrics(getFont()).getStringBounds(getText(), g); + // calculate the lower border as height for the underline + int y = getHeight() / 2 + (int) (textBounds.getHeight() / 2); + // underline the whole label + int x = (int) textBounds.getWidth(); + // and now let's draw + g.setColor(getForeground()); + g.drawLine(0, y, x, y); + } + } +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-20 17:28:27 UTC (rev 96) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-24 12:46:42 UTC (rev 97) @@ -70,10 +70,6 @@ /** * The main window of the application. - * GUI todos: - * INFO: Place buttons of the dialog windows in the lower right corner of the window. - * INFO: Adjust alignment of table columns ID and size of the history table. - * * TODO: getMessageHistory restructure model/relay * * @version $LastChangedRevision$ Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java 2008-03-20 17:28:27 UTC (rev 96) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java 2008-03-24 12:46:42 UTC (rev 97) @@ -26,6 +26,8 @@ package de.dlr.davinspector.ui; import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.Frame; import java.awt.Window; import java.util.HashMap; @@ -34,6 +36,8 @@ import java.util.Vector; import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; @@ -58,12 +62,12 @@ /** Serial Version UID, not valid. */ private static final long serialVersionUID = 1L; - + /** Width of the column client (checkbox) in pixel. */ - private static final int COLUMN_WIDTH_CLIENT = 40; + private static final int COLUMN_WIDTH_CLIENT = 50; /** Width of the column server (checkbox) in pixel. */ - private static final int COLUMN_WIDTH_SERVER = 40; + private static final int COLUMN_WIDTH_SERVER = 50; /** Width of the column name in pixel. */ private static final int COLUMN_WIDTH_NAME = 100; @@ -72,7 +76,7 @@ private static final int COLUMN_WIDTH_TYPE = 50; /** Width of the column version in pixel. */ - private static final int COLUMN_WIDTH_VERSION = 50; + private static final int COLUMN_WIDTH_VERSION = 75; /** Width of the column author in pixel. */ private static final int COLUMN_WIDTH_AUTHOR = 100; @@ -215,9 +219,9 @@ if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); + jContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); jContentPane.add(getJScrollPane(), BorderLayout.CENTER); jContentPane.add(getJPanelButtonBar(), BorderLayout.SOUTH); - jContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); } return jContentPane; } @@ -243,9 +247,13 @@ private JPanel getJPanelButtonBar() { if (jPanelButtonBar == null) { jPanelButtonBar = new JPanel(); - jPanelButtonBar.setLayout(new BorderLayout()); - jPanelButtonBar.add(getJButtonCancel(), BorderLayout.EAST); - jPanelButtonBar.add(getJButtonOk(), BorderLayout.WEST); + jPanelButtonBar.setLayout(new BoxLayout(jPanelButtonBar, BoxLayout.LINE_AXIS)); + jPanelButtonBar.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + jPanelButtonBar.setAlignmentX(Component.RIGHT_ALIGNMENT); + jPanelButtonBar.add(Box.createHorizontalGlue()); + jPanelButtonBar.add(getJButtonOk()); + jPanelButtonBar.add(Box.createRigidArea(new Dimension(10, 0))); + jPanelButtonBar.add(getJButtonCancel()); } return jPanelButtonBar; } @@ -340,6 +348,7 @@ if (jButtonCancel == null) { jButtonCancel = new JButton(); jButtonCancel.setText(Internationalization.getTranslation("dlg_plugin_configuration_cancel")); + jButtonCancel.setAlignmentX(RIGHT_ALIGNMENT); jButtonCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { closeWindow(); @@ -358,6 +367,7 @@ if (jButtonOk == null) { jButtonOk = new JButton(); jButtonOk.setText(Internationalization.getTranslation("dlg_plugin_configuration_ok")); + jButtonOk.setAlignmentX(RIGHT_ALIGNMENT); jButtonOk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { savePluginConfiguration(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-20 17:28:48
|
Revision: 96 http://davinspector.svn.sourceforge.net/davinspector/?rev=96&view=rev Author: wuest Date: 2008-03-20 10:28:27 -0700 (Thu, 20 Mar 2008) Log Message: ----------- Work on message processing still in progress. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-20 15:12:50 UTC (rev 95) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-20 17:28:27 UTC (rev 96) @@ -92,7 +92,7 @@ */ public void storeMessage(String data, Boolean toClient, Date timestamp) { - //TODO: add decorator dependent on protocol (switch http, ...). + // INFO: add decorator dependent on protocol (switch http, ...). // Notice: idCounter != number of messages HTTPMessageParser message = new HTTPMessageParser(new Message()); @@ -105,8 +105,8 @@ // store Message myMessages.add(message); notifyNewMessage(new MessageEvent(this, message)); - // Clear buffer - if (toClient) { + // clear buffer + if (!toClient) { myClientsideBuffer = carry; } else { myServersideBuffer = carry; Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-20 15:12:50 UTC (rev 95) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-20 17:28:27 UTC (rev 96) @@ -50,10 +50,12 @@ * (METHOD) SPACE (URL) SPACE (VERSION) CRLF * RFC 2616: Request-Line = Method SP Request-URI SP HTTP-Version CRLF * TODO: URL scanning not complete. + * TODO: add ACL, DASL methods etc. + * checkout, checkin, uncheckout, update, report, merge -> litmus test? */ private static final String REGEX_HTTP_REQUEST_LINE = "^(\\bUNKNOWN\\b|\\bHEAD\\b|\\bGET\\b|\\bPOST\\b|\\bPUT\\b|" + "\\bDELETE\\b|\\bOPTIONS\\b|\\bTRACE\\b|\\bCONNECT\\b|\\bPROPFIND\\b|\\bPROPPATCH\\b|\\bMKCOL\\b|" - + "\\bCOPY\\b|\\bMOVE\\b|\\bLOCK\\b|\\bUNLOCK\\b){1}" + + "\\bCOPY\\b|\\bMOVE\\b|\\bLOCK\\b|\\bUNLOCK\\b|\\bREPORT\\b){1}" + " ([\\w|/|~|.|_|-]+)" + " (\\bHTTP/1.1\\b|\\bHTTP/1.0\\b|\\bHTTP/0.9\\b){1}\r\n"; @@ -194,7 +196,7 @@ if (!isChunked && (myContentLength == 0 || !hasBody())) { myLogger.debug("no body"); myParsedBody = ""; - carryover = ""; // TODO: Set carry. + carryover = myRawBody; myParsingState = true; } else { if (isChunked) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-20 15:12:53
|
Revision: 95 http://davinspector.svn.sourceforge.net/davinspector/?rev=95&view=rev Author: wuest Date: 2008-03-20 08:12:50 -0700 (Thu, 20 Mar 2008) Log Message: ----------- Changed configuration file name logging.properties to log4j.properties. Removed scroll panes for the plugins from MainView. Now every plugin can have it's own scroll pane, if needed. Modified Paths: -------------- trunk/DAVInspector/build-user.xml trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/JTreeContentHandler.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableCellRenderer.java Added Paths: ----------- trunk/DAVInspector/log4j.properties Removed Paths: ------------- trunk/DAVInspector/logging.properties trunk/DAVInspector/test/de/dlr/davinspector/http/package.html Modified: trunk/DAVInspector/build-user.xml =================================================================== --- trunk/DAVInspector/build-user.xml 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/build-user.xml 2008-03-20 15:12:50 UTC (rev 95) @@ -67,7 +67,7 @@ <manifest> <attribute name="Main-Class" value="de/dlr/davinspector.DAVInspector"/> <attribute name="Built-By" value="${user.name}"/> - <attribute name="Class-Path" value=". logging.properties lib/log4j.jar"/> + <attribute name="Class-Path" value=". log4j.properties lib/log4j.jar"/> <section name="DAVInspector"> <attribute name="Specification-Title" value="${project.name}"/> Copied: trunk/DAVInspector/log4j.properties (from rev 94, trunk/DAVInspector/logging.properties) =================================================================== --- trunk/DAVInspector/log4j.properties (rev 0) +++ trunk/DAVInspector/log4j.properties 2008-03-20 15:12:50 UTC (rev 95) @@ -0,0 +1,28 @@ +# Log-Level of the root Logger +log4j.rootLogger=FATAL, system + +# Set Log-Level for DAVInspector +log4j.logger.de.dlr.davinspector=ERROR, system +log4j.logger.de.dlr.davinspector.plugin=DEBUG, plugin +log4j.logger.de.dlr.davinspector.plugins=DEBUG, plugin +log4j.logger.de.dlr.davinspector.http=DEBUG, messageparser +log4j.logger.de.dlr.davinspector.history=DEBUG, messageparser + +# Configuration of the general Log-File +log4j.appender.system=org.apache.log4j.FileAppender +log4j.appender.system.File=log/davinspector.log +log4j.appender.system.Append=false +log4j.appender.system.layout=org.apache.log4j.PatternLayout +log4j.appender.system.layout.ConversionPattern=%p %t %c - %m%n + +# Configuration of the Log-File for plugin manager and plugins +log4j.appender.plugin=org.apache.log4j.FileAppender +log4j.appender.plugin.File=log/plugin.log +log4j.appender.plugin.layout=org.apache.log4j.PatternLayout +log4j.appender.plugin.layout.ConversionPattern=%p %t %c - %m%n + +# Configuration of the Log-File for http parser and history +log4j.appender.messageparser=org.apache.log4j.FileAppender +log4j.appender.messageparser.File=log/messageparser.log +log4j.appender.messageparser.layout=org.apache.log4j.PatternLayout +log4j.appender.messageparser.layout.ConversionPattern=%p %t %c - %m%n Deleted: trunk/DAVInspector/logging.properties =================================================================== --- trunk/DAVInspector/logging.properties 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/logging.properties 2008-03-20 15:12:50 UTC (rev 95) @@ -1,17 +0,0 @@ -# Log-Level of the root Logger -log4j.rootLogger=ERROR - -# Set Log-Level for DAVInspector -log4j.logger.de.dlr.davinpsector=DEBUG - -# Configuration of the Log-File -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=log/log4j.log - -# Max Log-File size -log4j.appender.file.MaxFileSize=100KB -# Keep one Backup -log4j.appender.file.MaxBackupIndex=1 -# Define logger layout -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%p %t %c - %m%n Modified: trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-20 15:12:50 UTC (rev 95) @@ -27,6 +27,9 @@ import java.util.Locale; +import org.apache.log4j.PropertyConfigurator; + +import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.relay.IRelayModel; import de.dlr.davinspector.relay.RelayModel; import de.dlr.davinspector.ui.MainController; @@ -51,6 +54,8 @@ * @param args String[] */ public static void main(String[] args) { + // Configure Logger + PropertyConfigurator.configure(Constant.SYSTEM_LOGGER_CONFIGURATION); // for testing i18n support Locale.setDefault(new Locale("en")); // Locale.setDefault(new Locale("de")); Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-20 15:12:50 UTC (rev 95) @@ -133,7 +133,7 @@ public static final int PLUGIN_CONFIG_NAME_COL = 2; /** System logger configuration file (log4j). */ - public static final String SYSTEM_LOGGER_CONFIGURATION = "logging.properties"; + public static final String SYSTEM_LOGGER_CONFIGURATION = "log4j.properties"; /** * Hide class constructor. Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-20 15:12:50 UTC (rev 95) @@ -29,7 +29,6 @@ import java.util.regex.Pattern; import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; @@ -119,8 +118,6 @@ public HTTPMessageParser(AMessage aMessage) { super(aMessage); myParsingState = false; - // Configure Logger - PropertyConfigurator.configure(Constant.SYSTEM_LOGGER_CONFIGURATION); } /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-20 15:12:50 UTC (rev 95) @@ -34,7 +34,6 @@ import java.util.Vector; import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; @@ -77,8 +76,6 @@ * @return PluginManager */ public static PluginManager getInstance() { - // Configure Logger - PropertyConfigurator.configure(Constant.SYSTEM_LOGGER_CONFIGURATION); return instance; } @@ -94,7 +91,7 @@ String pathToPluginDir = pluginDirectory.getAbsolutePath(); for (String jarFile : jarFiles) { File plug = new File(pathToPluginDir + "/" + jarFile); - myLogger.debug("Loading plugin: " + jarFile); + myLogger.debug("Loading file: " + jarFile); loadPlugin(plug.getAbsoluteFile()); } } @@ -109,7 +106,7 @@ IPlugin plugin = null; String name = jarFile.getName().substring(0, jarFile.getName().lastIndexOf(".")); try { - myLogger.debug("Trying to load class: " + name); + myLogger.debug("Loading plugin: " + name); URLClassLoader jClassLoader = new URLClassLoader(new URL[] { jarFile.toURI().toURL() }); Class<?> c = jClassLoader.loadClass(Constant.PLUGIN_CLASSPATH + name.toLowerCase() + "." + name); // lets try to load the plugin... Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-20 15:12:50 UTC (rev 95) @@ -26,6 +26,7 @@ package de.dlr.davinspector.plugins.headerplugin; import javax.swing.JComponent; +import javax.swing.JScrollPane; import javax.swing.JTextPane; import de.dlr.davinspector.common.Util; @@ -49,13 +50,16 @@ /** The text pane. */ private JTextPane myJTextPane = null; + /** The scroll pane. */ + private JScrollPane myJScrollPane = null; + /** * {@inheritDoc} * * @see de.dlr.DAVInspector.Plugin.IViewPlugin#getUI() */ public JComponent getUI() { - return myJTextPane; + return myJScrollPane; } /** @@ -109,9 +113,11 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#init() */ public void init(Direction direction) { - if (myJTextPane == null) { + if (myJScrollPane == null) { + myJScrollPane = new JScrollPane(); myJTextPane = new JTextPane(); myJTextPane.setEditable(false); + myJScrollPane.setViewportView(myJTextPane); } myJTextPane.setText(""); Util.setUIDesign(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-03-20 15:12:50 UTC (rev 95) @@ -29,6 +29,7 @@ import java.io.IOException; import javax.swing.JComponent; +import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextArea; @@ -52,15 +53,21 @@ /** State of the plugin. */ private Boolean isActive = true; + + /** The scroll pane of the view. */ + private JScrollPane myJScrollPaneView = null; + + /** The scroll pane of the text area for errors. */ + private JScrollPane myJScrollPaneError = null; /** The GUI object. */ - private JSplitPane jSplitPane; + private JSplitPane myJSplitPane; /** This text pane displays the formated XML. */ private XMLTextPane myXMLTextPane; /** This text area displays XML errors. */ - private JTextArea jTextArea; + private JTextArea myJTextArea; /** * {@inheritDoc} @@ -68,7 +75,7 @@ * @see de.dlr.DAVInspector.Plugin.IViewPlugin#getUI() */ public JComponent getUI() { - return jSplitPane; + return myJSplitPane; } /** @@ -122,23 +129,30 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#init() */ public void init(Direction direction) { - if (jSplitPane == null) { - jTextArea = new JTextArea(); - jTextArea.setLineWrap(true); - jTextArea.setEditable(false); - jTextArea.setForeground(SystemColor.RED); + if (myJSplitPane == null) { + myJTextArea = new JTextArea(); + myJTextArea.setLineWrap(true); + myJTextArea.setEditable(false); + myJTextArea.setForeground(SystemColor.RED); + myJScrollPaneError = new JScrollPane(); + myJScrollPaneError.setViewportView(myJTextArea); + myXMLTextPane = new XMLTextPane(); myXMLTextPane.setEditable(false); - jSplitPane = new JSplitPane(); - jSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); - jSplitPane.setResizeWeight(SPLITTER_POSITION); - jSplitPane.setBottomComponent(jTextArea); - jSplitPane.setTopComponent(myXMLTextPane); + myJScrollPaneView = new JScrollPane(); + myJScrollPaneView.setViewportView(myXMLTextPane); + + myJSplitPane = new JSplitPane(); + myJSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); + myJSplitPane.setDividerLocation(SPLITTER_POSITION); + myJSplitPane.setResizeWeight(SPLITTER_POSITION); + myJSplitPane.setBottomComponent(myJScrollPaneError); + myJSplitPane.setTopComponent(myJScrollPaneView); } myXMLTextPane.setText(""); - jTextArea.setText(""); + myJTextArea.setText(""); Util.setUIDesign(); } @@ -177,11 +191,11 @@ public void update(AMessage msg) { if (isActive && myXMLTextPane != null) { try { - myXMLTextPane.init(msg.getMessageBody(), jTextArea); + myXMLTextPane.init(msg.getMessageBody(), myJTextArea); } catch (SAXException se) { - jTextArea.append(se.getMessage()); + myJTextArea.append(se.getMessage()); } catch (IOException ioe) { - jTextArea.append(ioe.getMessage()); + myJTextArea.append(ioe.getMessage()); } } } @@ -194,7 +208,7 @@ public void clear() { if (myXMLTextPane != null) { myXMLTextPane.setText(""); - jTextArea.setText(""); + myJTextArea.setText(""); } } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/JTreeContentHandler.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/JTreeContentHandler.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/JTreeContentHandler.java 2008-03-20 15:12:50 UTC (rev 95) @@ -192,8 +192,10 @@ public void characters(char[] ch, int start, int length) throws SAXException { String s = new String(ch, start, length).trim(); - DefaultMutableTreeNode data = new DefaultMutableTreeNode("Character Data: '" + s + APOSTROPHE); - current.add(data); + if (!s.isEmpty()) { + DefaultMutableTreeNode data = new DefaultMutableTreeNode("Character Data: '" + s + APOSTROPHE); + current.add(data); + } } /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-03-20 15:12:50 UTC (rev 95) @@ -29,6 +29,7 @@ import java.io.IOException; import javax.swing.JComponent; +import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextArea; @@ -52,15 +53,21 @@ /** State of the plugin. */ private Boolean isActive = true; - + + /** The scroll pane of the tree. */ + private JScrollPane myJScrollPaneTree = null; + + /** The scroll pane of the text area for errors. */ + private JScrollPane myJScrollPaneError = null; + /** The GUI object. */ - private JSplitPane jSplitPane; + private JSplitPane myJSplitPane = null; /** This text area displays XML errors. */ - private JTextArea jTextArea; + private JTextArea myJTextArea = null; /** The XMLTree component. */ - private XMLTreeView myXMLTreeView; + private XMLTreeView myXMLTreeView = null; /** * {@inheritDoc} @@ -68,7 +75,7 @@ * @see de.dlr.DAVInspector.Plugin.IViewPlugin#getUI() */ public JComponent getUI() { - return jSplitPane; + return myJSplitPane; } /** @@ -122,22 +129,28 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#init() */ public void init(Direction direction) { - if (jSplitPane == null) { - jTextArea = new JTextArea(); - jTextArea.setLineWrap(true); - jTextArea.setEditable(false); - jTextArea.setForeground(SystemColor.RED); + if (myJSplitPane == null) { + myJTextArea = new JTextArea(); + myJTextArea.setLineWrap(true); + myJTextArea.setEditable(false); + myJTextArea.setForeground(SystemColor.RED); + myJScrollPaneError = new JScrollPane(); + myJScrollPaneError.setViewportView(myJTextArea); + myXMLTreeView = new XMLTreeView(); myXMLTreeView.setEditable(false); - jSplitPane = new JSplitPane(); - jSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); - jSplitPane.setResizeWeight(SPLITTER_POSITION); - jSplitPane.setBottomComponent(jTextArea); - jSplitPane.setTopComponent(myXMLTreeView); + myJScrollPaneTree = new JScrollPane(); + myJScrollPaneTree.setViewportView(myXMLTreeView); + + myJSplitPane = new JSplitPane(); + myJSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); + myJSplitPane.setDividerLocation(SPLITTER_POSITION); + myJSplitPane.setBottomComponent(myJScrollPaneError); + myJSplitPane.setTopComponent(myJScrollPaneTree); } - jTextArea.setText(""); + myJTextArea.setText(""); updateTree(""); Util.setUIDesign(); } @@ -189,9 +202,9 @@ try { myXMLTreeView.init(data); } catch (SAXException se) { - jTextArea.append(se.getMessage()); + myJTextArea.append(se.getMessage()); } catch (IOException ioe) { - jTextArea.append(ioe.getMessage()); + myJTextArea.append(ioe.getMessage()); } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-20 15:12:50 UTC (rev 95) @@ -38,7 +38,6 @@ import javax.swing.event.EventListenerList; import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.configuration.Configuration; @@ -50,7 +49,6 @@ * Implementation of the relay interface. Provides the server socket * and manages the channel threads. * FIXME: stopping of the relay and freeing of the server socket. - * TODO:No appenders could be found for logger (de.dlr.davinspector.relay.RelayModel). * * @version $LastChangedRevision$ * @author Jochen Wuest @@ -95,16 +93,12 @@ * The constructor creates a new {@link MessageHistory} object. */ public RelayModel() { - // Configure Logger - PropertyConfigurator.configure(Constant.SYSTEM_LOGGER_CONFIGURATION); - myMessageHistory = new MessageHistory(this); myPluginManager = PluginManager.getInstance(); // load available plugins myPluginManager.loadAllPlugins(); // load plugin configuration (if available) PluginConfiguration pluginConfiguration = new PluginConfiguration(); - pluginConfiguration.loadConfiguration(); myPluginManager.setActivePluginsClient(pluginConfiguration.getActivePluginsClient()); myPluginManager.setActivePluginsServer(pluginConfiguration.getActivePluginsServer()); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-20 15:12:50 UTC (rev 95) @@ -601,9 +601,7 @@ IPlugin plugin = (IPlugin) iterator.next(); if (plugin.isActive()) { IViewPlugin viewPlugin = (IViewPlugin) plugin; - JScrollPane jScrollPane = new JScrollPane(); - jScrollPane.setViewportView(viewPlugin.getUI()); - jTabbedPaneClient.addTab(viewPlugin.getName(), null, jScrollPane, null); + jTabbedPaneClient.addTab(viewPlugin.getName(), null, viewPlugin.getUI(), null); } } } @@ -642,9 +640,7 @@ IPlugin plugin = (IPlugin) iterator.next(); if (plugin.isActive()) { IViewPlugin viewPlugin = (IViewPlugin) plugin; - JScrollPane jScrollPane = new JScrollPane(); - jScrollPane.setViewportView(viewPlugin.getUI()); - jTabbedPaneServer.addTab(viewPlugin.getName(), null, jScrollPane, null); + jTabbedPaneServer.addTab(viewPlugin.getName(), null, viewPlugin.getUI(), null); } } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableCellRenderer.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableCellRenderer.java 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableCellRenderer.java 2008-03-20 15:12:50 UTC (rev 95) @@ -108,7 +108,6 @@ /** * This method returns the availability of the plugin with <code>pluginName</code> * for client and server side. (client = 0, server = 1) - * INFO: use constants instead of int * * @param pluginName String * @param columnIndex int Deleted: trunk/DAVInspector/test/de/dlr/davinspector/http/package.html =================================================================== --- trunk/DAVInspector/test/de/dlr/davinspector/http/package.html 2008-03-20 12:06:59 UTC (rev 94) +++ trunk/DAVInspector/test/de/dlr/davinspector/http/package.html 2008-03-20 15:12:50 UTC (rev 95) @@ -1,6 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" -"http://www.w3.org/TR/REC-html40/loose.dtd"> - -<html><head><title>Package unit tests for HTTP</title></head><body> -This package contains all unit test classes for the basic HTTP message parser. -</body></html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-20 12:07:06
|
Revision: 94 http://davinspector.svn.sourceforge.net/davinspector/?rev=94&view=rev Author: wuest Date: 2008-03-20 05:06:59 -0700 (Thu, 20 Mar 2008) Log Message: ----------- Added plugin type column to plugin configuration dialog. Changed alignment and format of the history table columns. Added translations to the EN and DE resource files. Modified Paths: -------------- trunk/DAVInspector/logging.properties trunk/DAVInspector/resource/TextBundle.properties trunk/DAVInspector/resource/TextBundle_de_DE.properties trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableModel.java Modified: trunk/DAVInspector/logging.properties =================================================================== --- trunk/DAVInspector/logging.properties 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/logging.properties 2008-03-20 12:06:59 UTC (rev 94) @@ -5,7 +5,7 @@ log4j.logger.de.dlr.davinpsector=DEBUG # Configuration of the Log-File -# log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.File=log/log4j.log # Max Log-File size Modified: trunk/DAVInspector/resource/TextBundle.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle.properties 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/resource/TextBundle.properties 2008-03-20 12:06:59 UTC (rev 94) @@ -52,17 +52,27 @@ dlg_plugin_configuration_title=Plugin Configuration dlg_plugin_configuration_ok=Ok dlg_plugin_configuration_cancel=Cancel +dlg_plugin_configuration_type_edit=Edit +dlg_plugin_configuration_type_view=View #PluginConfigurationTableModel -column_name_client=Client -column_name_server=Server -column_name_name=Name -column_name_version=Version -column_name_author=Author -column_name_description=Description +#Column names +col_plugin_configuration_client=Client +col_plugin_configuration_server=Server +col_plugin_configuration_name=Name +col_plugin_configuration_type=Type +col_plugin_configuration_version=Version +col_plugin_configuration_author=Author +col_plugin_configuration_description=Description #HistoryTableModel -column_name_type=Direction -column_name_id=ID -column_name_timestamp=Timestamp -column_name_size=Size +#Column names +col_history_type=Direction +col_history_id=ID +col_history_timestamp=Timestamp +col_history_size=Size + +#HistoryTableCellRenderer +#Column type terms +col_history_type_request=Request +col_history_type_response=Response Modified: trunk/DAVInspector/resource/TextBundle_de_DE.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-03-20 12:06:59 UTC (rev 94) @@ -52,17 +52,26 @@ dlg_plugin_configuration_title=Plugin Einstellungen dlg_plugin_configuration_ok=Ok dlg_plugin_configuration_cancel=Abbrechen +dlg_plugin_configuration_type_edit=R/W +dlg_plugin_configuration_type_view=RO #PluginConfigurationTableModel -column_name_client=Client -column_name_server=Server -column_name_name=Name -column_name_version=Version -column_name_author=Autor -column_name_description=Beschreibung +col_plugin_configuration_client=Client +col_plugin_configuration_server=Server +col_plugin_configuration_name=Name +col_plugin_configuration_type=Typ +col_plugin_configuration_version=Version +col_plugin_configuration_author=Autor +col_plugin_configuration_description=Beschreibung #HistoryTableModel -column_name_type=Richtung -column_name_id=ID -column_name_timestamp=Zeitmarke -column_name_size=Gr\xF6\xDFe +col_history_type=Richtung +col_history_id=ID +col_history_timestamp=Zeitmarke +col_history_size=Gr\xF6\xDFe + +#HistoryTableCellRenderer +#Column type terms +col_history_type_request=Anfrage +col_history_type_response=Antwort + Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-20 12:06:59 UTC (rev 94) @@ -63,10 +63,10 @@ /** About dialog height. */ public static final int UI_ABOUT_DIALOG_HEIGTH = 275; - /** Backgroundcolor of replies. */ + /** Background color of replies. */ public static final Color UI_REPLY_COLOR = new Color(255, 232, 140); - /** Backgroundcolor of requests. */ + /** Background color of requests. */ public static final Color UI_REQUEST_COLOR = new Color(210, 255, 210); /** Line Feed + Carriage Return. */ Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-03-20 12:06:59 UTC (rev 94) @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Toolkit; import java.awt.Window; +import java.text.DecimalFormat; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -80,4 +81,29 @@ } window.setLocation((screenSize.width - windowSize.width) / 2, (screenSize.height - windowSize.height) / 2); } + + /** + * This method formats bytes. + * NOTE: This method does *NOT* use the correct SI Units. + * See http://en.wikipedia.org/wiki/Byte + * + * @param size Size in Bytes. + * @return String with the formated quantity of bytes with the correct unit. + */ + public static String formatByteSize(int size) { + final int divider = 1024; + String[] units = { " B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; + + int unitsLength = units.length - 1; + int unitIndex = 0; + double result = size; + + while (result >= divider && unitIndex < unitsLength) { + result /= divider; + unitIndex++; + } + + DecimalFormat decimalFormat = new DecimalFormat("###,##0.#"); + return decimalFormat.format(result) + ' ' + units[unitIndex]; + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java 2008-03-20 12:06:59 UTC (rev 94) @@ -26,13 +26,18 @@ package de.dlr.davinspector.history; import java.awt.Component; -import java.awt.SystemColor; +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; import javax.swing.JTable; +import javax.swing.SwingConstants; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; import de.dlr.davinspector.common.Constant; +import de.dlr.davinspector.common.Internationalization; +import de.dlr.davinspector.common.Util; /** @@ -46,8 +51,23 @@ /** Serial Version UID, not valid. */ private static final long serialVersionUID = 1L; + /** Index of the column type. */ + private static final int COLUMN_INDEX_TYPE = 0; + + /** Index of the column ID. */ + private static final int COLUMN_INDEX_ID = 1; + + /** Index of the column timestamp. */ + private static final int COLUMN_INDEX_TIMESTAMP = 2; + + /** Index of the column size. */ + private static final int COLUMN_INDEX_SIZE = 3; + /** Used to save the direction of a message to color a complete row. */ private Boolean isRequest; + + /** Definition of the format for the timestamp column. */ + private DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.getDefault()); /** * {@inheritDoc} @@ -60,23 +80,34 @@ super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - if (value instanceof AMessage.MessageDirection){ + if (column == COLUMN_INDEX_TYPE){ + setHorizontalAlignment(SwingConstants.LEFT); if (value.equals(AMessage.MessageDirection.Request)) { - setText("Request"); + setText(Internationalization.getTranslation("col_history_type_request")); isRequest = true; } else { - setText("Reply"); + setText(Internationalization.getTranslation("col_history_type_response")); isRequest = false; } + } else if (column == COLUMN_INDEX_ID) { + setHorizontalAlignment(SwingConstants.RIGHT); + setText(value.toString()); + } else if (column == COLUMN_INDEX_TIMESTAMP) { + setHorizontalAlignment(SwingConstants.RIGHT); + setText(dateFormat.format((Date) value)); + } else if (column == COLUMN_INDEX_SIZE) { + setHorizontalAlignment(SwingConstants.RIGHT); + setText(Util.formatByteSize(Integer.parseInt(value.toString()))); } else { + setHorizontalAlignment(SwingConstants.LEFT); setText(value.toString()); } if (hasFocus || isSelected) { - setForeground(SystemColor.textHighlightText); - setBackground(SystemColor.textHighlight); + setForeground(table.getSelectionForeground()); + setBackground(table.getSelectionBackground()); } else { - setForeground(SystemColor.textText); + setForeground(table.getForeground()); if (isRequest) { setBackground(Constant.UI_REQUEST_COLOR); } else { Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-03-20 12:06:59 UTC (rev 94) @@ -42,10 +42,11 @@ /** Column Definition for history table. */ private String[] columnNames = { - Internationalization.getTranslation("column_name_type"), - Internationalization.getTranslation("column_name_id"), - Internationalization.getTranslation("column_name_timestamp"), - Internationalization.getTranslation("column_name_size") + Internationalization.getTranslation("col_history_type"), + Internationalization.getTranslation("col_history_id"), + Internationalization.getTranslation("col_history_timestamp"), + Internationalization.getTranslation("col_history_size") + // TODO: display more information depending on message type }; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-20 12:06:59 UTC (rev 94) @@ -32,6 +32,7 @@ import de.dlr.davinspector.history.AMessage; import de.dlr.davinspector.history.Message; import de.dlr.davinspector.plugin.IEditPlugin; +import de.dlr.davinspector.plugin.IViewPlugin; /** @@ -40,7 +41,7 @@ * @version $LastChangedRevision$ * @author Jochen Wuest */ -public class HeaderPlugin implements IEditPlugin { +public class HeaderPlugin implements IEditPlugin, IViewPlugin { /** State of the plugin. */ private Boolean isActive = true; Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-20 12:06:59 UTC (rev 94) @@ -72,8 +72,7 @@ * The main window of the application. * GUI todos: * INFO: Place buttons of the dialog windows in the lower right corner of the window. - * INFO: Adjust alignment of table columns. - * INFO: i18n support into separate class!? + * INFO: Adjust alignment of table columns ID and size of the history table. * * TODO: getMessageHistory restructure model/relay * @@ -405,7 +404,6 @@ * Action: Enable or disable automode. */ private Action automodeAction = new AbstractAction() { - // INFO: myAutomodeIsActive local var!? static final long serialVersionUID = 1L; { putValue(Action.NAME, Internationalization.getTranslation("ac_enable_auto_mode")); @@ -922,8 +920,7 @@ jPanelRight = null; jSplitPaneHorizontal.setLeftComponent(getJTabbedPaneClient()); jSplitPaneHorizontal.setRightComponent(getJPanelRight()); - // set divider location - jSplitPaneHorizontal.setResizeWeight(DIVIDER_HORZ); + jSplitPaneHorizontal.setDividerLocation(DIVIDER_HORZ); jSplitPaneHorizontal.repaint(); } } @@ -945,8 +942,7 @@ if (jSplitPaneVertical == null) { jSplitPaneVertical = new JSplitPane(); jSplitPaneVertical.setOrientation(JSplitPane.VERTICAL_SPLIT); - // set divider location - jSplitPaneVertical.setResizeWeight(DIVIDER_VERT); + jSplitPaneVertical.setDividerLocation(DIVIDER_VERT); jSplitPaneVertical.setBottomComponent(getJPanelHistory()); jSplitPaneVertical.setTopComponent(getJSplitPaneHorizontal()); } @@ -981,17 +977,9 @@ jTableHistory = new JTable(myHistoryTableModel); jTableHistory.setShowGrid(true); jTableHistory.setAutoCreateRowSorter(true); -// // Disable auto resizing -// jTableHistory.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); -// // Set the column widths -// TableColumn column = jTableHistory.getColumnModel().getColumn(0); -// column.setPreferredWidth(100); -// column = jTableHistory.getColumnModel().getColumn(1); -// column.setPreferredWidth(100); -// column = jTableHistory.getColumnModel().getColumn(2); -// column.setPreferredWidth(100); -// column = jTableHistory.getColumnModel().getColumn(3); -// column.setPreferredWidth(100); + // do NOT allow reordering of the columns! + // in future you may enable this, but you also have to convert the column indices (view/table data model) + jTableHistory.getTableHeader().setReorderingAllowed(false); jTableHistory.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java 2008-03-20 12:06:59 UTC (rev 94) @@ -60,14 +60,17 @@ private static final long serialVersionUID = 1L; /** Width of the column client (checkbox) in pixel. */ - private static final int COLUMN_WIDTH_CLIENT = 50; + private static final int COLUMN_WIDTH_CLIENT = 40; /** Width of the column server (checkbox) in pixel. */ - private static final int COLUMN_WIDTH_SERVER = 50; + private static final int COLUMN_WIDTH_SERVER = 40; /** Width of the column name in pixel. */ private static final int COLUMN_WIDTH_NAME = 100; + /** Width of the column type in pixel. */ + private static final int COLUMN_WIDTH_TYPE = 50; + /** Width of the column version in pixel. */ private static final int COLUMN_WIDTH_VERSION = 50; @@ -86,14 +89,17 @@ /** Index of the column name. */ private static final int COLUMN_INDEX_NAME = 2; + /** Index of the column type. */ + private static final int COLUMN_INDEX_TYPE = 3; + /** Index of the column version. */ - private static final int COLUMN_INDEX_VERSION = 3; + private static final int COLUMN_INDEX_VERSION = 4; /** Index of the column author. */ - private static final int COLUMN_INDEX_AUTHOR = 4; + private static final int COLUMN_INDEX_AUTHOR = 5; /** Index of the column description. */ - private static final int COLUMN_INDEX_DESCRIPTION = 5; + private static final int COLUMN_INDEX_DESCRIPTION = 6; /** */ private JPanel jContentPane = null; @@ -147,6 +153,7 @@ public void addPlugins(List<IPlugin> availablePlugins) { Boolean isAvailableForClient = false; Boolean isAvailableForServer = false; + String pluginType; // empty the table first myTableModel.setRowCount(0); @@ -154,6 +161,7 @@ PluginConfiguration myPluginConfiguration = new PluginConfiguration(); for (IPlugin plugin : availablePlugins) { + // check availability of the plugin (client/server) if (plugin.getType() == (IPlugin.PlugInType.VIEW_CLIENT) || plugin.getType() == (IPlugin.PlugInType.EDIT_CLIENT) || plugin.getType() == (IPlugin.PlugInType.VIEW_GENERAL) @@ -166,13 +174,22 @@ || plugin.getType() == (IPlugin.PlugInType.EDIT_GENERAL)) { isAvailableForServer = true; } + // check the plugin type + if (plugin.getType() == (IPlugin.PlugInType.EDIT_CLIENT) + || plugin.getType() == (IPlugin.PlugInType.EDIT_SERVER) + || plugin.getType() == (IPlugin.PlugInType.EDIT_GENERAL)) { + pluginType = Internationalization.getTranslation("dlg_plugin_configuration_type_edit"); + } else { + pluginType = Internationalization.getTranslation("dlg_plugin_configuration_type_view"); + } + myAvailablePlugins.put(plugin.getName(), new Boolean[] {isAvailableForClient, isAvailableForServer}); // Is the plugin in the list of loaded plugins? If so mark the plugin as enabled. Boolean clientEnabled = myPluginConfiguration.getActivePluginsClient().contains(plugin.getName()); Boolean serverEnabled = myPluginConfiguration.getActivePluginsServer().contains(plugin.getName()); - myTableModel.addRow(new Object[]{clientEnabled, serverEnabled, plugin.getName(), + myTableModel.addRow(new Object[]{clientEnabled, serverEnabled, plugin.getName(), pluginType, plugin.getVersion(), plugin.getAuthor(), plugin.getDescription()}); } myTableModel.fireTableDataChanged(); @@ -255,6 +272,8 @@ column.setPreferredWidth(COLUMN_WIDTH_SERVER); column = jTable.getColumnModel().getColumn(COLUMN_INDEX_NAME); column.setPreferredWidth(COLUMN_WIDTH_NAME); + column = jTable.getColumnModel().getColumn(COLUMN_INDEX_TYPE); + column.setPreferredWidth(COLUMN_WIDTH_TYPE); column = jTable.getColumnModel().getColumn(COLUMN_INDEX_VERSION); column.setPreferredWidth(COLUMN_WIDTH_VERSION); column = jTable.getColumnModel().getColumn(COLUMN_INDEX_AUTHOR); Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableModel.java 2008-03-19 19:16:55 UTC (rev 93) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableModel.java 2008-03-20 12:06:59 UTC (rev 94) @@ -43,12 +43,13 @@ /** Column definition. */ private String[] columnNames = { - Internationalization.getTranslation("column_name_client"), - Internationalization.getTranslation("column_name_server"), - Internationalization.getTranslation("column_name_name"), - Internationalization.getTranslation("column_name_version"), - Internationalization.getTranslation("column_name_author"), - Internationalization.getTranslation("column_name_description") + Internationalization.getTranslation("col_plugin_configuration_client"), + Internationalization.getTranslation("col_plugin_configuration_server"), + Internationalization.getTranslation("col_plugin_configuration_name"), + Internationalization.getTranslation("col_plugin_configuration_type"), + Internationalization.getTranslation("col_plugin_configuration_version"), + Internationalization.getTranslation("col_plugin_configuration_author"), + Internationalization.getTranslation("col_plugin_configuration_description") }; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-19 19:17:13
|
Revision: 93 http://davinspector.svn.sourceforge.net/davinspector/?rev=93&view=rev Author: wuest Date: 2008-03-19 12:16:55 -0700 (Wed, 19 Mar 2008) Log Message: ----------- Added hidden constructor and declared class as final. Changed path of log4j to relative path. Modified Paths: -------------- trunk/DAVInspector/.classpath trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java Modified: trunk/DAVInspector/.classpath =================================================================== --- trunk/DAVInspector/.classpath 2008-03-19 17:42:10 UTC (rev 92) +++ trunk/DAVInspector/.classpath 2008-03-19 19:16:55 UTC (rev 93) @@ -3,7 +3,7 @@ <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> - <classpathentry kind="lib" path="C:/Dokumente und Einstellungen/wues_ha/workspace/DAVInspector/lib/log4j.jar"/> + <classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> + <classpathentry kind="lib" path="lib/log4j.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java 2008-03-19 17:42:10 UTC (rev 92) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java 2008-03-19 19:16:55 UTC (rev 93) @@ -32,7 +32,7 @@ * @version $LastChangedRevision$ * @author Jochen Wuest */ -public class HTTPMethod { +public final class HTTPMethod { /** */ public static final String HTTP_METHOD_UNKNOWN = "UNKOWN"; @@ -81,4 +81,9 @@ /** */ public static final String HTTP_METHOD_UNLOCK = "UNLOCK"; + + /** + * Hide class constructor. + */ + private HTTPMethod() { } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-19 17:42:53
|
Revision: 92 http://davinspector.svn.sourceforge.net/davinspector/?rev=92&view=rev Author: wuest Date: 2008-03-19 10:42:10 -0700 (Wed, 19 Mar 2008) Log Message: ----------- Updated i18n support (moved from Util to Internationalization). Added and reformated documentation and comments. Moved state variables of the toggle buttons from MainView into the corresponding actions. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java trunk/DAVInspector/src/de/dlr/davinspector/configuration/Configuration.java trunk/DAVInspector/src/de/dlr/davinspector/configuration/PluginConfiguration.java trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageEvent.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPStatusCode.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/IEditPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/IViewPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/JarFilenameFilter.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLTextPane.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/JTreeContentHandler.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreeView.java trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java trunk/DAVInspector/src/de/dlr/davinspector/relay/DataEvent.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/package.html trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java trunk/DAVInspector/src/de/dlr/davinspector/ui/ConfigurationDialog.java trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableCellRenderer.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableModel.java trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java Added Paths: ----------- trunk/DAVInspector/src/de/dlr/davinspector/common/Internationalization.java Modified: trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-19 17:42:10 UTC (rev 92) @@ -27,7 +27,6 @@ import java.util.Locale; -import de.dlr.davinspector.common.Util; import de.dlr.davinspector.relay.IRelayModel; import de.dlr.davinspector.relay.RelayModel; import de.dlr.davinspector.ui.MainController; @@ -53,8 +52,8 @@ */ public static void main(String[] args) { // for testing i18n support -// Locale.setDefault(new Locale("EN")); -// Locale.setDefault(new Locale("DE")); + Locale.setDefault(new Locale("en")); +// Locale.setDefault(new Locale("de")); IRelayModel model = new RelayModel(); new MainController(model); Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-19 17:42:10 UTC (rev 92) @@ -36,176 +36,107 @@ */ public final class Constant { - /** - * Basis of the hexadecimal number system. - */ + /** Basis of the hexadecimal number system. */ public static final int HEX_RADIX = 16; - - /** - * Main window width. - */ + + /** Main window width. */ public static final int UI_MAIN_WINDOW_WIDTH = 800; - - /** - * Main window height. - */ + + /** Main window height. */ public static final int UI_MAIN_WINDOW_HEIGHT = 600; - - /** - * Configuration dialog width. - */ + + /** Configuration dialog width. */ public static final int UI_CONFIG_DIALOG_WIDTH = 300; - - /** - * Configuration dialog height. - */ + + /** Configuration dialog height. */ public static final int UI_CONFIG_DIALOG_HEIGHT = 200; - - /** - * Plugin configuration width. - */ + + /** Plugin configuration width. */ public static final int UI_PLUGIN_CONFIG_DIALOG_WIDTH = 650; - - /** - * Plugin configuration height. - */ + + /** Plugin configuration height. */ public static final int UI_PLUGIN_CONFIG_DIALOG_HEIGTH = 250; - - /** - * About dialog width. - */ + + /** About dialog width. */ public static final int UI_ABOUT_DIALOG_WIDTH = 250; - - /** - * About dialog height. - */ + + /** About dialog height. */ public static final int UI_ABOUT_DIALOG_HEIGTH = 275; - - /** - * Backgroundcolor of replies. - */ - public static final Color UI_REPLY_COLOR = new Color(255, 204, 102); - - /** - * Backgroundcolor of requests. - */ - public static final Color UI_REQUEST_COLOR = new Color(170, 240, 240); - - /** - * Line Feed + Carriage Return. - */ + + /** Backgroundcolor of replies. */ + public static final Color UI_REPLY_COLOR = new Color(255, 232, 140); + + /** Backgroundcolor of requests. */ + public static final Color UI_REQUEST_COLOR = new Color(210, 255, 210); + + /** Line Feed + Carriage Return. */ public static final String LFCR = "\r\n"; - - /** - * Line Feed. - */ + + /** Line Feed. */ public static final String LF = "\r"; - - /** - * Carriage Return. - */ + + /** Carriage Return. */ public static final String CR = "\n"; - - /** - * End Of File. - */ + + /** End Of File. */ public static final int EOF = -1; - - /** - * Application Title. - */ + + /** Application Title. */ public static final String APP_TITLE = "DAVInspector"; - - /** - * Version of the application. - */ + + /** Version of the application. */ public static final String APP_VERSION = "0.1"; - - /** - * Filename of the configuration file. - */ + + /** Filename of the configuration file. */ public static final String APP_CONFIGURATION_FILENAME = "config.properties"; - - /** - * Filename of the plugin configuration file. - */ + + /** Filename of the plugin configuration file. */ public static final String APP_PLUGIN_CONFIGURATION_FILENAME = "plugin-config.properties"; - - /** - * Timeout waiting for a ChannelThread to finish in ms. - */ + + /** Timeout waiting for a ChannelThread to finish in ms. */ public static final int RELAY_THREADTIMEOUT = 100; - - /** - * Linger time in seconds for socket. - */ + + /** Linger time in seconds for socket. */ public static final int RELAY_LINGERTIME = 100; - - /** - * Size of the receive buffer. - */ + + /** Size of the receive buffer. */ public static final int RELAY_RECVBUFFERSIZE = 2048; - /** - * Backlog parameter used when creating the ServerSocket. - */ + /** Backlog parameter used when creating the ServerSocket. */ public static final int RELAY_BACKLOG = 1; - - /** - * Address of the Server. IP address or domain name. - */ - public static final String RELAY_SERVERADDRESS = "localhost"; //"bsasdf01.as.bs.dlr.de"; - - /** - * Server port. - */ + + /** Address of the Server. IP address or domain name. */ + public static final String RELAY_SERVERADDRESS = "localhost"; + + /** Server port. */ public static final int RELAY_SERVERPORT = 8080; - - /** - * Address of the Client. Normally this is empty and - * the address of the client is of no importance. - */ + + /** Address of the Client. Normally this is empty and the address of the client is of no importance. */ public static final String RELAY_CLIENTADDRESS = ""; - - /** - * Client port. - */ + + /** Client port. */ public static final int RELAY_CLIENTPORT = 8888; - /** - * Classpath to the plugins. - */ + /** Classpath to the plugins. */ public static final String PLUGIN_CLASSPATH = "de.dlr.davinspector.plugins."; - /** - * Path to the resources, e.g. graphics and icons. - */ - public static final String RESOURCE_PATH = "/de/dlr/davinspector/resource/"; + /** Path to the resources, e.g. graphics, icons and language files. */ + public static final String RESOURCE_PATH = "de/dlr/davinspector/resource/"; - /** - * Column index of the enable/disable plugin for the client column in the plugin configuration dialog. - */ + /** Column index of the enable/disable plugin for the client column in the plugin configuration dialog. */ public static final int PLUGIN_CONFIG_CLIENT_COL = 0; - /** - * Column index of the enable/disable plugin for the server column in the plugin configuration dialog. - */ + /** Column index of the enable/disable plugin for the server column in the plugin configuration dialog. */ public static final int PLUGIN_CONFIG_SERVER_COL = 1; - /** - * Column index of the plugin name column in the plugin configuration dialog. - */ + /** Column index of the plugin name column in the plugin configuration dialog. */ public static final int PLUGIN_CONFIG_NAME_COL = 2; - /** - * System logger configuration file (log4j). - */ + /** System logger configuration file (log4j). */ public static final String SYSTEM_LOGGER_CONFIGURATION = "logging.properties"; - /** - * Empty Constructor. + /** + * Hide class constructor. */ - private Constant() { - - } + private Constant() { } } Added: trunk/DAVInspector/src/de/dlr/davinspector/common/Internationalization.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Internationalization.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Internationalization.java 2008-03-19 17:42:10 UTC (rev 92) @@ -0,0 +1,59 @@ +/* + * Internationalization.java + * + * This class provides all methods needed for internationalization. + * + * Created: 19.03.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.common; + +import java.util.Locale; +import java.util.ResourceBundle; + + +/** + * This class provides all methods needed for internationalization. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public final class Internationalization { + + /** The resource bundle. */ + static final ResourceBundle RESOURCE_BUNDLE = + ResourceBundle.getBundle(Constant.RESOURCE_PATH + "TextBundle", Locale.getDefault()); + + /** + * Hide class constructor. + */ + private Internationalization() { } + + /** + * This method returns the translation for the given key. + * The information is extracted from the proper language file. + * + * @param key String + * @return String + */ + public static String getTranslation(String key) { + return Internationalization.RESOURCE_BUNDLE.getString(key); + } +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-03-19 17:42:10 UTC (rev 92) @@ -28,8 +28,6 @@ import java.awt.Dimension; import java.awt.Toolkit; import java.awt.Window; -import java.util.Locale; -import java.util.ResourceBundle; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -43,30 +41,12 @@ */ public final class Util { - /** - * + /** + * Hide class constructor. */ - private static final ResourceBundle RESOURCE_BUNDLE = - ResourceBundle.getBundle("de/dlr/davinspector/resource/TextBundle", Locale.getDefault()); - - /** - * Empty Contructor for utility class. - */ - private Util() { - - } + private Util() { } /** - * TODO: wues_ha: Enter comment! - * - * @param key String - * @return String - */ - public static String getTranslation(String key) { - return RESOURCE_BUNDLE.getString(key); - } - - /** * This method tries to set the look & feel of the current OS. */ public static void setUIDesign() { Modified: trunk/DAVInspector/src/de/dlr/davinspector/configuration/Configuration.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/configuration/Configuration.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/configuration/Configuration.java 2008-03-19 17:42:10 UTC (rev 92) @@ -41,31 +41,21 @@ */ public class Configuration { - /** - * - */ + /** The properties object. */ private Properties myProperties; - /** - * Port number of the server connection. - */ + /** Port number of the server connection. */ private int myServerPort; - /** - * Port number of the client connection. - */ + /** Port number of the client connection. */ private int myClientPort; - /** - * Address of the server. - */ + /** Address of the server.*/ private String myServerAddress; - /** - * Address of the client. - */ + /** Address of the client. */ private String myClientAddress; - + /** * Constructor, loads the configuration from the configuration file. */ Modified: trunk/DAVInspector/src/de/dlr/davinspector/configuration/PluginConfiguration.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/configuration/PluginConfiguration.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/configuration/PluginConfiguration.java 2008-03-19 17:42:10 UTC (rev 92) @@ -43,24 +43,16 @@ */ public class PluginConfiguration { - /** - * Symbol used for separating the plugin names. - */ + /** Symbol used for separating the plugin names. */ private static final String DELIMITER = ","; - /** - * - */ + /** The properties object. */ private Properties myProperties; - - /** - * This list contains the names of all plugins to view messages to the server. - */ + + /** This list contains the names of all plugins to view messages to the server. */ private List<String> myActivePluginsServer; - /** - * This list contains the names of all plugins to view messages to the client. - */ + /** This list contains the names of all plugins to view messages to the client. */ private List<String> myActivePluginsClient; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-19 17:42:10 UTC (rev 92) @@ -1,9 +1,9 @@ /* * AMessage.java * - * TODO: wues_ha Enter comment! + * The abstract class for messages. * - * Created: 29.02.2008 wues_ha <email> + * Created: 29.02.2008 Jochen Wuest <joc...@dl...> * Changed: * * $Id$ @@ -29,16 +29,14 @@ /** - * TODO: wues_ha: Enter comment! + * The abstract class for messages. * * @version $LastChangedRevision$ * @author Jochen Wuest */ public abstract class AMessage { - /** - * - */ + /** The counter for unique numbering. */ protected static int idCounter; /** @@ -52,69 +50,42 @@ * @author Jochen Wuest */ public enum MessageDirection { - /** - * - */ + /** Data from client to server. */ Request, - /** - * - */ + /** Data from server to client. */ Response } - /** - * Parsing state of the message. - */ + /** Parsing state of the message. */ protected Boolean myParsingState; - /** - * Unique ID of a message. - */ + /** Unique ID of a message. */ protected int myID; - - /** - * Timestamp of the current message. - */ + + /** Timestamp of the current message. */ protected Date myTimestamp; - /** - * myDirection indicates the direction of the message. - * @see MessageDirection - */ + /** myDirection indicates the direction of the message. @see MessageDirection */ protected MessageDirection myDirection; - /** - * This string contains the raw data of the message. - */ + /** This string contains the raw data of the message. */ protected String myRawData; - /** - * - */ + /** This string contains the unprocessed header of the message. */ protected String myRawHeader; - /** - * - */ + /** This string contains the unprocessed body of the message. */ protected String myRawBody; - - /** - * - */ + + /** This string contains the processed header of the message. */ protected String myParsedHeader; - /** - * - */ + /** This string contains the processed body of the message. */ protected String myParsedBody; - - /** - * The size in bytes of the current message. - */ + + /** The size in bytes of the current message. */ protected int mySize; - - /** * This method returns the ID of the message. * @@ -186,7 +157,9 @@ } /** - * TODO: wues_ha: Enter comment! + * This method parses the current raw data. + * If the buffer contains more than only the data for the current message, the rest is returned. + * * @return String */ public String parseMessage() { @@ -194,7 +167,8 @@ } /** - * TODO: wues_ha: Enter comment! + * This method returns <code>true</code> if the message processing is done + * and a valid message has been recognized. * * @return Boolean */ Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java 2008-03-19 17:42:10 UTC (rev 92) @@ -1,9 +1,9 @@ /* * AMessageParser.java * - * TODO: wues_ha Enter comment! + * The abstract class for message parsers. * - * Created: 29.02.2008 wues_ha <email> + * Created: 29.02.2008 Jochen Wuest <joc...@dl...> * Changed: * * $Id$ @@ -27,20 +27,18 @@ /** - * TODO: wues_ha: Enter comment! + * The abstract class for message parsers. * * @version $LastChangedRevision$ * @author Jochen Wuest */ public abstract class AMessageParser extends AMessage { - /** - * - */ + /** The Message. */ protected AMessage myMessage; /** - * TODO: wues_ha: enter comment! + * Constructor of the abstract MessageParser class. * * @param aMessage AMessage */ Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableCellRenderer.java 2008-03-19 17:42:10 UTC (rev 92) @@ -43,14 +43,10 @@ */ public class HistoryTableCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer { - /** - * - */ + /** Serial Version UID, not valid. */ private static final long serialVersionUID = 1L; - /** - * Used to save the direction of a message to color a complete row. - */ + /** Used to save the direction of a message to color a complete row. */ private Boolean isRequest; /** @@ -87,7 +83,7 @@ setBackground(Constant.UI_REPLY_COLOR); } } - + return this; } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-03-19 17:42:10 UTC (rev 92) @@ -27,7 +27,7 @@ import javax.swing.table.DefaultTableModel; -import de.dlr.davinspector.common.Util; +import de.dlr.davinspector.common.Internationalization; /** * Data model for the history table. @@ -37,19 +37,15 @@ */ public class HistoryTableModel extends DefaultTableModel implements INewMessageListener { - /** - * - */ + /** Serial Version UID, not valid. */ private static final long serialVersionUID = 0L; - /** - * Column Definition for history table. - */ + /** Column Definition for history table. */ private String[] columnNames = { - Util.getTranslation("column_name_type"), - Util.getTranslation("column_name_id"), - Util.getTranslation("column_name_timestamp"), - Util.getTranslation("column_name_size") + Internationalization.getTranslation("column_name_type"), + Internationalization.getTranslation("column_name_id"), + Internationalization.getTranslation("column_name_timestamp"), + Internationalization.getTranslation("column_name_size") }; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageEvent.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageEvent.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageEvent.java 2008-03-19 17:42:10 UTC (rev 92) @@ -36,14 +36,10 @@ */ public class MessageEvent extends EventObject { - /** - * - */ + /** Serial Version UID, not valid. */ private static final long serialVersionUID = 1L; - /** - * The message. - */ + /** The message. */ private AMessage myMessage; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-19 17:42:10 UTC (rev 92) @@ -40,43 +40,29 @@ /** - * This class saves and provides access - * to the processed messages. + * This class saves and provides access to the processed messages. * * @version $LastChangedRevision$ * @author Jochen Wuest */ public class MessageHistory implements IServerListener, IClientListener { - - /** - * List of listeners for new messages. - */ + /** List of listeners for new messages. */ private EventListenerList myListenersNewMessage = new EventListenerList(); - /** - * List of listeners for refresh. - */ + /** List of listeners for refresh. */ private EventListenerList myListenersRefreshMessage = new EventListenerList(); - - /** - * This string buffers the client side raw data. - */ + + /** This string buffers the client side raw data. */ private String myClientsideBuffer; - /** - * This string buffers the server side raw data. - */ + /** This string buffers the server side raw data. */ private String myServersideBuffer; - - /** - * This vector stores the messages. - */ + + /** This vector stores the messages. */ private List<AMessage> myMessages = null; - /** - * Reference to the relay model. - */ + /** Reference to the relay model. */ private IRelayModel myRelay = null; /** @@ -107,7 +93,7 @@ public void storeMessage(String data, Boolean toClient, Date timestamp) { //TODO: add decorator dependent on protocol (switch http, ...). - //INFO: idCounter != number of messages + // Notice: idCounter != number of messages HTTPMessageParser message = new HTTPMessageParser(new Message()); message.setMessageDirection(toClient); @@ -140,7 +126,6 @@ /** * Deletes all stored messages. - * */ public void deleteAllMessages() { myMessages.clear(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-19 17:42:10 UTC (rev 92) @@ -85,42 +85,30 @@ * INFO: Currently no chunk extensions are handled. */ private static final String REGEX_CHUNK_SIZE = "\r\n([0-9a-fA-F]+)\r\n"; - + /** * This expression matches the transfer encoding of a message. * Transfer-Encoding: SPACE* chunked CRLF * INFO: Currently no transfer extensions are handled. */ private static final String REGEX_IS_CHUNKED = "Transfer-Encoding:[ ]*chunked\r\n"; - - /** - * Logger, Apache log4j. - */ + + /** Logger, Apache log4j. */ private static Logger myLogger = Logger.getLogger(HTTPMessageParser.class); - /** - * The http request method. - */ + /** The http request method. */ private String myMethod; - /** - * The http response status code. - */ + /** The http response status code. */ private int myStatusCode = 0; - /** - * Version of the http protocol uesed by the message. - */ + /** Version of the http protocol uesed by the message. */ private String myProtocolVersion = ""; - /** - * <code>True</code> if the message uses chunked encoding. - */ + /** <code>True</code> if the message uses chunked encoding. */ private Boolean isChunked = false; - /** - * Length of the message body in bytes. - */ + /** Length of the message body in bytes. */ private int myContentLength = 0; /** @@ -136,8 +124,9 @@ } /** - * TODO: wues_ha: Enter comment! - * + * This method extracts the header and body from the raw data of the message. + * The data from the start to the first empty line presents the <code>myRawHeader</code>, + * the data from the first empty line until the end of the raw data presents the <code>myRawBody</code>. */ private void extractHeaderBody() { String[] s = myRawData.split(REGEX_EMPTY_LINE); @@ -168,7 +157,7 @@ Matcher matcher = pattern.matcher(myRawData); if (matcher.find()) { myLogger.debug("found status line"); - myMethod = ""; // TODO: set last method + myMethod = ""; // INFO: set last method myStatusCode = Integer.parseInt(matcher.group(2)); myProtocolVersion = matcher.group(1); isChunked = isChunked(); @@ -294,7 +283,9 @@ } /** - * TODO: wues_ha: Enter comment! + * The method <code>decodeChunkedEncoding</code> tries to read all chunks of the message. + * If the all chunks have been recognized the content of all chunks is returned and the + * <code>myParsingState</code> is set to <code>true</code>. * * @see RFC 2616: 3.6.1 Chunked Transfer Coding * Chunked-Body = *chunk @@ -337,7 +328,7 @@ int start = matcher.end(); int stopp = matcher.end() + chunksize; - // TODO: ung\xFCltige l\xE4ngen abfangen! + // check if lengths are valid if (stopp > myRawData.length()) { myLogger.debug("chunk decoding: invalid right boundary " + stopp); stopp = myRawData.length(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java 2008-03-19 17:42:10 UTC (rev 92) @@ -1,7 +1,7 @@ /* * HTTPMethod.java * - * TODO: wues_ha Enter comment! + * HTTP methodes according to RFC2616 (HTTP1.1) and RFC 4918 (WebDAV). * * Created: 23.01.2008 Jochen Wuest <joc...@dl...> * Changed: @@ -27,29 +27,58 @@ /** - * HTTP methodes according to - * RFC2616 (HTTP1.1) and RFC 4918 (WebDAV). + * HTTP methodes according to RFC2616 (HTTP1.1) and RFC 4918 (WebDAV). * * @version $LastChangedRevision$ * @author Jochen Wuest */ public class HTTPMethod { - // CHECKSTYLE:OFF + + /** */ public static final String HTTP_METHOD_UNKNOWN = "UNKOWN"; + + /** */ public static final String HTTP_METHOD_HEAD = "HEAD"; + + /** */ public static final String HTTP_METHOD_GET = "GET"; + + /** */ public static final String HTTP_METHOD_POST = "POST"; + + /** */ public static final String HTTP_METHOD_PUT = "PUT"; + + /** */ public static final String HTTP_METHOD_DELETE = "DELETE"; + + /** */ public static final String HTTP_METHOD_OPTIONS = "OPTIONS"; + + /** */ public static final String HTTP_METHOD_TRACE = "TRACE"; + + /** */ public static final String HTTP_METHOD_CONNECT = "CONNECT"; + + /** */ public static final String HTTP_METHOD_PROPFIND = "PROPFIND"; + + /** */ public static final String HTTP_METHOD_PROPPATCH = "PROPPATCH"; + + /** */ public static final String HTTP_METHOD_MKCOL = "MKCOL"; + + /** */ public static final String HTTP_METHOD_COPY = "COPY"; + + /** */ public static final String HTTP_METHOD_MOVE = "MOVE"; + + /** */ public static final String HTTP_METHOD_LOCK = "LOCK"; + + /** */ public static final String HTTP_METHOD_UNLOCK = "UNLOCK"; -// CHECKSTYLE:ON } Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPStatusCode.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPStatusCode.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPStatusCode.java 2008-03-19 17:42:10 UTC (rev 92) @@ -1,7 +1,7 @@ /* * HTTPStatusCode.java * - * TODO: wues_ha Enter comment! + * HTTP status codes according to RFC2616 (HTTP1.1) and RFC 4918 (WebDAV). * * Created: 23.01.2008 Jochen Wuest <joc...@dl...> * Changed: @@ -26,13 +26,13 @@ package de.dlr.davinspector.http; /** - * HTTP status codes according to - * RFC2616 (HTTP1.1) and RFC 4918 (WebDAV). + * HTTP status codes according to RFC2616 (HTTP1.1) and RFC 4918 (WebDAV). * * @version $LastChangedRevision$ * @author Jochen Wuest */ public final class HTTPStatusCode { + // CHECKSTYLE:OFF /* * 1xx: Informational - Request received, continuing process @@ -101,10 +101,7 @@ // CHECKSTYLE:ON /** - * TODO: HJW: enter comment! - * + * Hide class constructor. */ - private HTTPStatusCode() { - - } + private HTTPStatusCode() { } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/IEditPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/IEditPlugin.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/IEditPlugin.java 2008-03-19 17:42:10 UTC (rev 92) @@ -38,6 +38,7 @@ * @author Jochen Wuest */ public interface IEditPlugin extends IPlugin { + /** * Returns the processed {@link AMessage} of the plugin. * Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/IPlugin.java 2008-03-19 17:42:10 UTC (rev 92) @@ -113,29 +113,17 @@ * Indentifier for plugin-type. */ public enum PlugInType { - /** - * Plugin has GUI, client and server. - */ + /** Plugin has GUI, client and server. */ VIEW_GENERAL, - /** - * Plugin allows editing of the content, client and server. - */ + /** Plugin allows editing of the content, client and server. */ EDIT_GENERAL, - /** - * Plugin has GUI, only client. - */ + /** Plugin has GUI, only client. */ VIEW_CLIENT, - /** - * Plugin has GUI, only server. - */ + /** Plugin has GUI, only server. */ VIEW_SERVER, - /** - * Plugin allows editing of the content, only client. - */ + /** Plugin allows editing of the content, only client. */ EDIT_CLIENT, - /** - * Plugin allows editing of the content, only server. - */ + /** Plugin allows editing of the content, only server. */ EDIT_SERVER } @@ -148,13 +136,9 @@ * @author Jochen Wuest */ public enum Direction { - /** - * - */ + /** Plugin on the client side. */ CLIENT, - /** - * - */ + /** Plugin on the server side. */ SERVER } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/IViewPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/IViewPlugin.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/IViewPlugin.java 2008-03-19 17:42:10 UTC (rev 92) @@ -36,6 +36,7 @@ * @author Jochen Wuest */ public interface IViewPlugin extends IPlugin { + /** * Returns the JComponent of the plugin. * Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/JarFilenameFilter.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/JarFilenameFilter.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/JarFilenameFilter.java 2008-03-19 17:42:10 UTC (rev 92) @@ -45,5 +45,4 @@ public boolean accept(File directory, String filename) { return filename.toLowerCase().endsWith(".jar"); } - } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-19 17:42:10 UTC (rev 92) @@ -38,7 +38,6 @@ import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; -import de.dlr.davinspector.history.Message; /** * This class loads all available plugins and manages the activated plugins @@ -51,29 +50,19 @@ */ public final class PluginManager { - /** - * - */ + /** The plugin manager. */ private static PluginManager instance = new PluginManager(); - - /** - * Logger, Apache log4j. - */ + + /** Logger, Apache log4j. */ private static Logger myLogger = Logger.getLogger(PluginManager.class); - - /** - * Vector containing all loaded plugins. - */ + + /** Vector containing all loaded plugins. */ private List<IPlugin> myPluginVector = new Vector<IPlugin>(); - - /** - * This list contains all plugins to view/edit messages to the server. - */ + + /** This list contains all plugins to view/edit messages to the server. */ private List<IPlugin> myActivePluginsServer = new Vector<IPlugin>(); - /** - * This list contains all plugins to view/edit messages to the client. - */ + /** This list contains all plugins to view/edit messages to the client. */ private List<IPlugin> myActivePluginsClient = new Vector<IPlugin>(); /** @@ -132,7 +121,7 @@ if (plugin != null) { myPluginVector.add(plugin); - // TODO: only add plugin if specified for client/server side + // INFO: only add plugin if specified for client/server side // INFO: alternative Direction could be specified here by PluginType!? plugin = (IPlugin) c.newInstance(); plugin.init(IPlugin.Direction.CLIENT); @@ -205,6 +194,11 @@ } } + /** + * TODO: wues_ha: Enter comment! + * + * @return AMessage + */ public AMessage getEditedMessageClient() { AMessage buffer = null; for (Iterator<IPlugin> iterator = myActivePluginsClient.iterator(); iterator.hasNext();) { Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-19 17:42:10 UTC (rev 92) @@ -42,14 +42,10 @@ */ public class HeaderPlugin implements IEditPlugin { - /** - * State of the plugin. - */ + /** State of the plugin. */ private Boolean isActive = true; - /** - * The text pane. - */ + /** The text pane. */ private JTextPane myJTextPane = null; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingConfigurationPanel.java 2008-03-19 17:42:10 UTC (rev 92) @@ -42,45 +42,32 @@ /** * This class is the UI for the RecordingPlugin. - * TODO: constant def, complete comments. * * @version $LastChangedRevision$ * @author Jochen Wuest */ public class RecordingConfigurationPanel extends JPanel { - /** - * - */ + /** Serial Version UID, not valid. */ private static final long serialVersionUID = 1L; - /** - * - */ + /** This button opens the file chooser dialog. */ private JButton jButtonOpenFileChooser; - /** - * - */ + /** The label for the file name field. */ private JLabel jLabelFilename; - /** - * - */ + /** The file name field. */ private JTextField jTextFieldFilename; - /** - * The filename. - */ + /** The filename. */ private String myFilename = ""; - /** - * The RecordingPlugin. - */ + /** The RecordingPlugin. */ private RecordingPlugin myParent; - /** - * Constructor. + /** + * Constructor of RecordingConfigurationPanel. * * @param plugin Reference to the plugin object. */ @@ -98,7 +85,7 @@ * @return String */ public String getFilename() { - if (myFilename.equals("")) { + if (myFilename.isEmpty()) { return getDefaultFileName(); } else { return myFilename; @@ -106,21 +93,22 @@ } /** - * TODO: HJW: Enter comment! + * This method opens a file chooser dialog and evaluates the result. + * If a valid file is chosen, the local variable <code>myFilename</code> is updated and + * the method <code>setRecordingFile()</code> of the RecordingPlugin is called. * - * @param evt - * Event + * @param event Event */ - private void jButtonOpenFileChooserActionPerformed(java.awt.event.ActionEvent evt) { + private void jButtonOpenFileChooserActionPerformed(java.awt.event.ActionEvent event) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); fileChooser.setDialogTitle("Select recording file"); fileChooser.setSelectedFile(new File(myFilename)); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - int returnVal = fileChooser.showOpenDialog(null); + int returnValue = fileChooser.showOpenDialog(null); - if (returnVal == JFileChooser.APPROVE_OPTION) { + if (returnValue == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); myFilename = file.getAbsolutePath(); myParent.setRecordingFile(file); @@ -146,8 +134,7 @@ } /** - * TODO: HJW: Enter comment! - * + * This method initializes the graphical elements of the plugin. */ private void initComponents() { jTextFieldFilename = new JTextField(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/recordingplugin/RecordingPlugin.java 2008-03-19 17:42:10 UTC (rev 92) @@ -46,29 +46,19 @@ */ public class RecordingPlugin implements IViewPlugin { - /** - * State of the plugin. - */ + /** State of the plugin. */ private Boolean isActive = true; - /** - * The UI of the RecordingPlugin. - */ + /** The UI of the RecordingPlugin. */ private RecordingConfigurationPanel myPanel = null; - /** - * The filename of the file to which the data is written. - */ + /** The filename of the file to which the data is written. */ private String myFilename; - /** - * The BufferedWriter for writing the data to the file. - */ + /** The BufferedWriter for writing the data to the file. */ private BufferedWriter myBufferedWriter = null; - /** - * This saves the side assigned to the current plugin object. - */ + /** This saves the side assigned to the current plugin object. */ private Direction myDirection; /** @@ -203,7 +193,6 @@ /** * This method opens the file <code>myFilename</code> and * initializes the <code>BufferedWriter</code>. - * */ private void openBufferedWriter() { if (myBufferedWriter == null) { Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java 2008-03-19 17:42:10 UTC (rev 92) @@ -52,69 +52,43 @@ */ public class JTextPaneContentHandler implements ContentHandler { - /** - * Character/s for newline. - */ + /** Character/s for newline. */ private static final String NEWLINE = "\r\n"; - /** - * Character/s for indent. - */ + /** Character/s for indent. */ private static final String INDENT = " "; - /** - * - */ + /** Foreground color definition for XML tags. */ private static final Color STYLE_XML_TAG = Color.BLUE; - /** - * - */ + /** Foreground color definition for content between XML tags. */ private static final Color STYLE_XML_CONTENT = Color.BLACK; - /** - * - */ + /** Foreground color definition for XML definition. */ private static final Color STYLE_XML_DEF = Color.LIGHT_GRAY; - /** - * Store URI to prefix mappings. - */ + /** Store URI to prefix mappings. */ private Map<String, String> namespaceMappings; - /** - * The document. - */ + /** The document. */ private StyledDocument myStyledDocument; - /** - * The attributes of the document. - */ + /** The attributes of the document. */ private AttributeSet myAttributeSet; - /** - * This stores the current nesting level. - */ + /** This stores the current nesting level. */ private int myLevel; - /** - * String buffer for the character data. - */ + /** String buffer for the character data. */ private String myBufferCharacterData; - /** - * String buffer for the end tag. - */ + /** String buffer for the end tag. */ private String myBufferEndTag; - /** - * String buffer for the start tag. - */ + /** String buffer for the start tag. */ private String myBufferStartTag; - /** - * This text area displays errors. - */ + /** This text area displays errors. */ private JTextArea myJTextAreaError; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-03-19 17:42:10 UTC (rev 92) @@ -47,29 +47,19 @@ */ public class XMLPlugin implements IViewPlugin { - /** - * - */ + /** */ private static final double SPLITTER_POSITION = 0.8; - /** - * State of the plugin. - */ + /** State of the plugin. */ private Boolean isActive = true; - /** - * The GUI object. - */ + /** The GUI object. */ private JSplitPane jSplitPane; - /** - * This text pane displays the formated XML. - */ + /** This text pane displays the formated XML. */ private XMLTextPane myXMLTextPane; - /** - * This text area displays XML errors. - */ + /** This text area displays XML errors. */ private JTextArea jTextArea; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLTextPane.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLTextPane.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLTextPane.java 2008-03-19 17:42:10 UTC (rev 92) @@ -48,23 +48,17 @@ */ public class XMLTextPane extends JTextPane { - /** - * - */ - static final long serialVersionUID = 0; + /** Serial Version UID, not valid. */ + static final long serialVersionUID = 0L; - /** - * The document. - */ + /** The document. */ private StyledDocument myDocument; /** * Constructor, empty. */ - public XMLTextPane() { + public XMLTextPane() { } - } - /** * To achieve no word wrap. * {@inheritDoc} Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/JTreeContentHandler.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/JTreeContentHandler.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/JTreeContentHandler.java 2008-03-19 17:42:10 UTC (rev 92) @@ -47,19 +47,13 @@ */ class JTreeContentHandler implements ContentHandler { - /** - * - */ + /** */ private static final String APOSTROPHE = "'"; - /** - * Store URI to prefix mappings. - */ + /** Store URI to prefix mappings. */ private Map<String, String> namespaceMappings; - /** - * Current node to add sub-nodes to. - */ + /** Current node to add sub-nodes to. */ private DefaultMutableTreeNode current; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-03-19 17:42:10 UTC (rev 92) @@ -47,29 +47,19 @@ */ public class XMLTreePlugin implements IViewPlugin { - /** - * - */ + /** */ private static final double SPLITTER_POSITION = 0.8; - /** - * State of the plugin. - */ + /** State of the plugin. */ private Boolean isActive = true; - /** - * The GUI object. - */ + /** The GUI object. */ private JSplitPane jSplitPane; - /** - * This text area displays XML errors. - */ + /** This text area displays XML errors. */ private JTextArea jTextArea; - /** - * The XMLTree component. - */ + /** The XMLTree component. */ private XMLTreeView myXMLTreeView; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreeView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreeView.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreeView.java 2008-03-19 17:42:10 UTC (rev 92) @@ -47,23 +47,17 @@ */ public class XMLTreeView extends JTree { - /** - * - */ - static final long serialVersionUID = 0; + /** Serial Version UID, not valid. */ + static final long serialVersionUID = 0L; - /** - * Data model for the tree. - */ + /** Data model for the tree. */ private DefaultTreeModel myDefaultTreeModel; /** * Constructor, empty. */ - public XMLTreeView() { + public XMLTreeView() { } - } - /** * This method initializes the tree and the tree data model. * Afterwards <code>buildTree</code> is called. Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-19 17:42:10 UTC (rev 92) @@ -44,58 +44,38 @@ */ public class ChannelThread extends Thread { - /** - * - */ + /** */ public static final String COLON = ": "; - /** - * - */ + /** */ private Socket myInputSocket; - /** - * - */ + /** */ private Socket myOutputSocket; - /** - * - */ + /** */ private boolean myDone = false; - /** - * - */ + /** */ private ChannelThread myPeer; - /** - * - */ + /** */ private boolean myDirection; - /** - * The logger. - */ + /** The logger. */ private Logger myLogger; - /** - * - */ + /** */ private String myThreadName = ""; - /** - * - */ + /** */ private IRelayModel myRelay = null; - /** - * - */ + /** */ private List<ChannelThread> myConnections; /** - * Constructor. + * Constructor of a ChannelThread. * * @param inputSocket Socket input socket * @param outputSocket Socket output socket Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/DataEvent.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/DataEvent.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/DataEvent.java 2008-03-19 17:42:10 UTC (rev 92) @@ -36,14 +36,10 @@ */ public class DataEvent extends EventObject { - /** - * - */ + /** Serial Version UID, not valid. */ private static final long serialVersionUID = 1L; - /** - * The data. - */ + /** The data. */ private String myData; /** @@ -65,5 +61,4 @@ public String getData() { return myData; } - } Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-19 17:42:10 UTC (rev 92) @@ -39,6 +39,7 @@ * @author Jochen Wuest */ public interface IRelayModel { + /** * This method starts the relay with the given configuration. * Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-19 17:42:10 UTC (rev 92) @@ -50,69 +50,48 @@ * Implementation of the relay interface. Provides the server socket * and manages the channel threads. * FIXME: stopping of the relay and freeing of the server socket. + * TODO:No appenders could be found for logger (de.dlr.davinspector.relay.RelayModel). * * @version $LastChangedRevision$ * @author Jochen Wuest */ public class RelayModel extends Thread implements IRelayModel { - /** - * Logger, Apache log4j. - */ + /** Logger, Apache log4j. */ private static Logger myLogger = Logger.getLogger(RelayModel.class); - /** - * List of listeners for new client data. - */ + /** List of listeners for new client data. */ private EventListenerList myClientListeners = new EventListenerList(); - /** - * List of listeners for server data. - */ + /** List of listeners for server data. */ private EventListenerList myServerListeners = new EventListenerList(); - /** - * Address to forward connections to. - */ + /** Address to forward connections to. */ private InetAddress myDestinationAddress; - /** - * Port to forward connections to. - */ + /** Port to forward connections to. */ private int myDestinationPort; - /** - * This proxy's server socket. - */ + /** This proxy's server socket. */ private ServerSocket serverSocket; - /** - * Plugin manager. - */ + /** The plugin manager. */ private PluginManager myPluginManager = null; - /** - * The lock object is used for synchronizing the ChannelThreads. - */ + /** The lock object is used for synchronizing the ChannelThreads. */ private Object lock = new Object(); - /** - * Contains all current connections (ChannelThreads). - */ + /** Contains all current connections (ChannelThreads). */ private List<ChannelThread> connections = new Vector<ChannelThread>(); - /** - * The message history object. - */ + /** The message history object. */ private MessageHistory myMessageHistory = null; - /** - * State of the automode. - */ + /** State of the automode. */ private Boolean myStateAutomode = false; /** - * Constructor of RelayModel. + * Constructor of a RelayModel. * The constructor creates a new {@link MessageHistory} object. */ public RelayModel() { Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/package.html =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/package.html 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/package.html 2008-03-19 17:42:10 UTC (rev 92) @@ -1,12 +1,6 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> -<html><head><title>BLUB B</title></head><body> - -BLUB B - -<h2>Package Specification</h2> - -BLUB B - +<html><head><title>Relay package</title></head><body> +This package contains all classes to handle the network traffic. </body></html> \ No newline at end of file Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java 2008-03-19 13:05:53 UTC (rev 91) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java 2008-03-19 17:42:10 UTC (rev 92) @@ -39,6 +39,7 @@ import javax.swing.JTextPane; import de.dlr.davinspector.common.Constant; +import de.dlr.davinspector.common.Internationalization; import de.dlr.davinspector.common.Util; /** @@ -49,47 +50,33 @@ */ public class AboutDialog extends JDialog { - /** - * - */ + /** Serial Version UID, not valid. */ private static final long serialVersionUID = 1L; - /** - * - */ + /** */ private static final int FONT_SIZE_... [truncated message content] |
From: <wu...@us...> - 2008-03-19 13:06:38
|
Revision: 91 http://davinspector.svn.sourceforge.net/davinspector/?rev=91&view=rev Author: wuest Date: 2008-03-19 06:05:53 -0700 (Wed, 19 Mar 2008) Log Message: ----------- Language files for EN (default) and DE. Added Paths: ----------- trunk/DAVInspector/resource/TextBundle.properties trunk/DAVInspector/resource/TextBundle_de_DE.properties Added: trunk/DAVInspector/resource/TextBundle.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle.properties (rev 0) +++ trunk/DAVInspector/resource/TextBundle.properties 2008-03-19 13:05:53 UTC (rev 91) @@ -0,0 +1,68 @@ +# actions +ac_exit=Exit +ac_exit_description=Exit the program. +ac_send_to_server=Send to Server +ac_send_to_server_description=Send Client data to the Server. +ac_send_to_client=Send to Client +ac_send_to_client_description=Send Server data to the Client. +ac_configure=Configure +ac_configure_description=Configure the application. +ac_configure_plugins=Configure +ac_configure_plugins_description=Configure the loaded plugins. +ac_about=About +ac_about_description=Display information about the application. +ac_start_relay=Start Relay +ac_start_relay_description=Start the relay. +ac_stop_relay=Stop Relay +ac_stop_relay_description=Stop the relay. +ac_clear_client=Clear Client +ac_clear_client_description=Clear the Client side data. +ac_clear_server=Clear Server +ac_clear_server_description=Clear the Server side data. +ac_clear_all=Clear All +ac_clear_all_description=Clear all data. +ac_enable_auto_mode=Enable Auto Mode +ac_enable_auto_mode_description=Data is automatically transfered. +ac_disable_auto_mode=Disable Auto Mode +ac_disable_auto_mode_description=No automtic data transfer. + +#tabs +tab_raw=Raw + +#menu +menu_file=File +menu_view=View +menu_help=Help +menu_plugins=Plugins + +#AboutDialog +dlg_about_title=About DAVInspector +dlg_about_close=Close + +#ConfigurationDialog +dlg_configuration_title=Configuration +dlg_configuration_ok=Ok +dlg_configuration_cancel=Cancel +dlg_configuration_server_address=Server Address +dlg_configuration_server_port=Server Port +dlg_configuration_client_address=Client Address +dlg_configuration_client_port=Client Port + +#PluginConfigurationDialog +dlg_plugin_configuration_title=Plugin Configuration +dlg_plugin_configuration_ok=Ok +dlg_plugin_configuration_cancel=Cancel + +#PluginConfigurationTableModel +column_name_client=Client +column_name_server=Server +column_name_name=Name +column_name_version=Version +column_name_author=Author +column_name_description=Description + +#HistoryTableModel +column_name_type=Direction +column_name_id=ID +column_name_timestamp=Timestamp +column_name_size=Size Added: trunk/DAVInspector/resource/TextBundle_de_DE.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle_de_DE.properties (rev 0) +++ trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-03-19 13:05:53 UTC (rev 91) @@ -0,0 +1,68 @@ +#actions +ac_exit=Beenden +ac_exit_description=Das Programm schlie\xDFen. +ac_send_to_server=Sende zum Server +ac_send_to_server_description=Client Daten zum Server \xFCbertragen. +ac_send_to_client=Sende zum Client +ac_send_to_client_description=Server Daten zum Client \xFCbertragen. +ac_configure=Einstellungen +ac_configure_description=Die Einstellungen des Programms \xE4ndern. +ac_configure_plugins=Konfiguration +ac_configure_plugins_description=Die geladene Plugins konfigurieren. +ac_about=\xDCber... +ac_about_description=Information zum Programm anzeigen. +ac_start_relay=Relais starten +ac_start_relay_description=Startet das Relais. +ac_stop_relay=Relais stoppen +ac_stop_relay_description=Stoppt das Relais. +ac_clear_client=Client leeren +ac_clear_client_description=Client Ansicht leeren. +ac_clear_server=Server leeren +ac_clear_server_description=Server Ansicht leeren. +ac_clear_all=Alle leeren +ac_clear_all_description=Alle Ansichten leeren. +ac_enable_auto_mode=Automatik aktivieren +ac_enable_auto_mode_description=Die Daten werden automatisch \xFCbertragen. +ac_disable_auto_mode=Automatik deaktivieren +ac_disable_auto_mode_description=Die Daten m\xFCssen manuell \xFCbertragen werden. + +#tabs +tab_raw=Rohdaten + +#menu +menu_file=Datei +menu_view=Ansicht +menu_help=Hilfe +menu_plugins=Plugins + +#AboutDialog +dlg_about_title=\xDCber DAVInspector +dlg_about_close=Schlie\xDFen + +#ConfigurationDialog +dlg_configuration_title=Einstellungen +dlg_configuration_ok=Ok +dlg_configuration_cancel=Abbrechen +dlg_configuration_server_address=Server-Adresse +dlg_configuration_server_port=Server-Port +dlg_configuration_client_address=Client-Adresse +dlg_configuration_client_port=Client-Port + +#PluginConfigurationDialog +dlg_plugin_configuration_title=Plugin Einstellungen +dlg_plugin_configuration_ok=Ok +dlg_plugin_configuration_cancel=Abbrechen + +#PluginConfigurationTableModel +column_name_client=Client +column_name_server=Server +column_name_name=Name +column_name_version=Version +column_name_author=Autor +column_name_description=Beschreibung + +#HistoryTableModel +column_name_type=Richtung +column_name_id=ID +column_name_timestamp=Zeitmarke +column_name_size=Gr\xF6\xDFe This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-19 13:04:57
|
Revision: 90 http://davinspector.svn.sourceforge.net/davinspector/?rev=90&view=rev Author: wuest Date: 2008-03-19 06:04:03 -0700 (Wed, 19 Mar 2008) Log Message: ----------- Added basic i18n support. Modified Paths: -------------- trunk/DAVInspector/build-user.xml trunk/DAVInspector/resource/wizard_off.png trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java trunk/DAVInspector/src/de/dlr/davinspector/http/package.html trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java trunk/DAVInspector/src/de/dlr/davinspector/ui/ConfigurationDialog.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableModel.java trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java Added Paths: ----------- trunk/DAVInspector/test/de/dlr/davinspector/http/package.html Modified: trunk/DAVInspector/build-user.xml =================================================================== --- trunk/DAVInspector/build-user.xml 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/build-user.xml 2008-03-19 13:04:03 UTC (rev 90) @@ -56,7 +56,7 @@ <!-- Copy DAVInspector resource files --> <copy todir="bin/de/dlr/davinspector/resource"> - <fileset dir="resource" includes="*.png" /> + <fileset dir="resource" includes="*.png *.properties" /> </copy> <!-- Create DAVInspector jar file --> Modified: trunk/DAVInspector/resource/wizard_off.png =================================================================== (Binary files differ) Modified: trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-19 13:04:03 UTC (rev 90) @@ -25,9 +25,9 @@ package de.dlr.davinspector; -import java.io.FileInputStream; -import java.io.IOException; +import java.util.Locale; +import de.dlr.davinspector.common.Util; import de.dlr.davinspector.relay.IRelayModel; import de.dlr.davinspector.relay.RelayModel; import de.dlr.davinspector.ui.MainController; @@ -51,20 +51,10 @@ * * @param args String[] */ - public static void main(String[] args) { - // init java internal logging - try { - FileInputStream file = new FileInputStream("logging.properties"); - java.util.logging.LogManager.getLogManager().readConfiguration(file); - } catch (IOException ioe) { - System.err.println(ioe); - } - - // TODO: i18n - //Locale loc = Locale.getDefault(); - //Locale loc = Locale.GERMANY; - //Locale loc = Locale.US; - //ResourceBundle resourceBundle = ResourceBundle.getBundle("DAVInspectorLang", loc); + public static void main(String[] args) { + // for testing i18n support +// Locale.setDefault(new Locale("EN")); +// Locale.setDefault(new Locale("DE")); IRelayModel model = new RelayModel(); new MainController(model); Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-03-19 13:04:03 UTC (rev 90) @@ -28,6 +28,8 @@ import java.awt.Dimension; import java.awt.Toolkit; import java.awt.Window; +import java.util.Locale; +import java.util.ResourceBundle; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -40,6 +42,12 @@ * @author Jochen Wuest */ public final class Util { + + /** + * + */ + private static final ResourceBundle RESOURCE_BUNDLE = + ResourceBundle.getBundle("de/dlr/davinspector/resource/TextBundle", Locale.getDefault()); /** * Empty Contructor for utility class. @@ -47,6 +55,16 @@ private Util() { } + + /** + * TODO: wues_ha: Enter comment! + * + * @param key String + * @return String + */ + public static String getTranslation(String key) { + return RESOURCE_BUNDLE.getString(key); + } /** * This method tries to set the look & feel of the current OS. Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/HistoryTableModel.java 2008-03-19 13:04:03 UTC (rev 90) @@ -27,6 +27,8 @@ import javax.swing.table.DefaultTableModel; +import de.dlr.davinspector.common.Util; + /** * Data model for the history table. * @@ -44,10 +46,10 @@ * Column Definition for history table. */ private String[] columnNames = { - "Type", - "ID", - "Timestamp", - "Size" + Util.getTranslation("column_name_type"), + Util.getTranslation("column_name_id"), + Util.getTranslation("column_name_timestamp"), + Util.getTranslation("column_name_size") }; /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/package.html =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/package.html 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/package.html 2008-03-19 13:04:03 UTC (rev 90) @@ -1,12 +1,6 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> -<html><head><title>BLUB B</title></head><body> - -BLUB B - -<h2>Package Specification</h2> - -BLUB B - +<html><head><title>Package HTTP</title></head><body> +This package contains all classes needed for basic HTTP message parsing. </body></html> \ No newline at end of file Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-19 13:04:03 UTC (rev 90) @@ -38,6 +38,7 @@ import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; +import de.dlr.davinspector.history.Message; /** * This class loads all available plugins and manages the activated plugins @@ -204,6 +205,18 @@ } } + public AMessage getEditedMessageClient() { + AMessage buffer = null; + for (Iterator<IPlugin> iterator = myActivePluginsClient.iterator(); iterator.hasNext();) { + IPlugin plugin = (IPlugin) iterator.next(); + if (plugin.getType() == IPlugin.PlugInType.EDIT_CLIENT) { + IEditPlugin editPlugin = (IEditPlugin) plugin; + buffer = editPlugin.getOutput(); + } + } + return buffer; + } + /** * This method sets the active plugins for the client side. * Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-03-19 13:04:03 UTC (rev 90) @@ -30,7 +30,8 @@ import de.dlr.davinspector.common.Util; import de.dlr.davinspector.history.AMessage; -import de.dlr.davinspector.plugin.IViewPlugin; +import de.dlr.davinspector.history.Message; +import de.dlr.davinspector.plugin.IEditPlugin; /** @@ -39,7 +40,7 @@ * @version $LastChangedRevision$ * @author Jochen Wuest */ -public class HeaderPlugin implements IViewPlugin { +public class HeaderPlugin implements IEditPlugin { /** * State of the plugin. @@ -93,7 +94,7 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#getType() */ public PlugInType getType() { - return PlugInType.VIEW_CLIENT; + return PlugInType.EDIT_CLIENT; } /** @@ -167,4 +168,13 @@ myJTextPane.setText(""); } } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.plugin.IEditPlugin#getOutput() + */ + public AMessage getOutput() { + return new Message(); + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/AboutDialog.java 2008-03-19 13:04:03 UTC (rev 90) @@ -102,7 +102,7 @@ */ private void initialize() { this.setSize(Constant.UI_ABOUT_DIALOG_WIDTH, Constant.UI_ABOUT_DIALOG_HEIGTH); - this.setTitle(Constant.APP_TITLE + " About"); + this.setTitle(Util.getTranslation("dlg_about_title")); this.setContentPane(getJContentPane()); Util.centerWindow((Window) this); } @@ -140,7 +140,7 @@ private JButton getJButtonOk() { if (jButtonOk == null) { jButtonOk = new JButton(); - jButtonOk.setText("Ok"); + jButtonOk.setText(Util.getTranslation("dlg_about_close")); jButtonOk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { closeWindow(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/ConfigurationDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/ConfigurationDialog.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/ConfigurationDialog.java 2008-03-19 13:04:03 UTC (rev 90) @@ -28,7 +28,6 @@ import java.awt.Frame; import java.awt.GridLayout; import java.awt.Window; -import java.awt.event.KeyEvent; import javax.swing.BorderFactory; import javax.swing.JButton; @@ -132,7 +131,7 @@ */ private void initialize() { this.setSize(Constant.UI_CONFIG_DIALOG_WIDTH, Constant.UI_CONFIG_DIALOG_HEIGHT); - this.setTitle(Constant.APP_TITLE + " Configuration"); + this.setTitle(Constant.APP_TITLE + " " + Util.getTranslation("dlg_configuration_title")); this.setContentPane(this.getJContentPane()); this.setModal(true); Util.centerWindow((Window) this); @@ -152,16 +151,16 @@ private JPanel getJContentPane() { if (jContentPane == null) { jLabelServerAddress = new JLabel(); - jLabelServerAddress.setText("Server Address:"); + jLabelServerAddress.setText(Util.getTranslation("dlg_configuration_server_address") + ':'); jLabelServerAddress.setHorizontalAlignment(SwingConstants.RIGHT); jLabelClientPort = new JLabel(); - jLabelClientPort.setText("Client Port:"); + jLabelClientPort.setText(Util.getTranslation("dlg_configuration_client_port") + ':'); jLabelClientPort.setHorizontalAlignment(SwingConstants.RIGHT); jLabelClientAddress = new JLabel(); - jLabelClientAddress.setText("Client Address:"); + jLabelClientAddress.setText(Util.getTranslation("dlg_configuration_client_address") + ':'); jLabelClientAddress.setHorizontalAlignment(SwingConstants.RIGHT); jLabelServerPort = new JLabel(); - jLabelServerPort.setText("Server Port:"); + jLabelServerPort.setText(Util.getTranslation("dlg_configuration_server_port") + ':'); jLabelServerPort.setHorizontalAlignment(SwingConstants.RIGHT); GridLayout gridLayout = new GridLayout(5, 2, 10, 10); jContentPane = new JPanel(); @@ -189,8 +188,7 @@ private JButton getJButtonCancel() { if (jButtonCancel == null) { jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setMnemonic(KeyEvent.VK_C); + jButtonCancel.setText(Util.getTranslation("dlg_configuration_cancel")); jButtonCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { closeWindow(); @@ -283,8 +281,7 @@ private JButton getJButtonOk() { if (jButtonOk == null) { jButtonOk = new JButton(); - jButtonOk.setText("Ok"); - jButtonOk.setMnemonic(KeyEvent.VK_O); + jButtonOk.setText(Util.getTranslation("dlg_configuration_ok")); jButtonOk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { saveConfiguration(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-19 13:04:03 UTC (rev 90) @@ -69,10 +69,10 @@ /** * The main window of the application. - * Gui todos: + * GUI todos: * INFO: Place buttons of the dialog windows in the lower right corner of the window. - * INFO: Resize columns of the tables to the needed space. * INFO: Adjust alignment of table columns. + * INFO: i18n support into separate class!? * * TODO: getMessageHistory restructure model/relay * @@ -302,12 +302,12 @@ private Action exitAction = new AbstractAction() { static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Exit"); - putValue(Action.SHORT_DESCRIPTION, "Exit the program"); + putValue(Action.NAME, Util.getTranslation("ac_exit")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_exit_description")); putValue(Action.MNEMONIC_KEY, KeyEvent.VK_X); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_EXIT)); } - + public void actionPerformed(ActionEvent e) { // INFO: Currently shutdownActivePlugins maybe called twice. myPluginManager.shutdownActivePlugins(); @@ -321,8 +321,8 @@ private Action sendToServerAction = new AbstractAction() { static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Send to Server"); - putValue(Action.SHORT_DESCRIPTION, "Send Client data to the Server."); + putValue(Action.NAME, Util.getTranslation("ac_send_to_server")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_send_to_server_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_RIGHT_ARROW)); } @@ -338,8 +338,8 @@ private Action sendToClientAction = new AbstractAction() { static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Send to Client"); - putValue(Action.SHORT_DESCRIPTION, "Send Server data to the Client."); + putValue(Action.NAME, Util.getTranslation("ac_send_to_client")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_send_to_client_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_LEFT_ARROW)); } @@ -355,8 +355,8 @@ private Action configureAction = new AbstractAction() { static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Configure"); - putValue(Action.SHORT_DESCRIPTION, "Configure the application."); + putValue(Action.NAME, Util.getTranslation("ac_configure")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_configure_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_CONFIGURE)); } @@ -374,8 +374,8 @@ private Action configurePluginsAction = new AbstractAction() { static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Configure"); - putValue(Action.SHORT_DESCRIPTION, "Configure the loaded plugins."); + putValue(Action.NAME, Util.getTranslation("ac_configure_plugins")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_configure_plugins_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_PLUGINS)); } @@ -394,8 +394,8 @@ private Action aboutAction = new AbstractAction() { static final long serialVersionUID = 1L; { - putValue(Action.NAME, "About"); - putValue(Action.SHORT_DESCRIPTION, "Display information about the application."); + putValue(Action.NAME, Util.getTranslation("ac_about")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_about_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_ABOUT)); } @@ -414,22 +414,22 @@ // INFO: myRelayIsActive local var!? static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Start Relay"); - putValue(Action.SHORT_DESCRIPTION, "Start the relay."); + putValue(Action.NAME, Util.getTranslation("ac_start_relay")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_start_relay_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_START)); } public void actionPerformed(ActionEvent e) { if (myRelayIsActive) { - putValue(Action.NAME, "Start Relay"); - putValue(Action.SHORT_DESCRIPTION, "Start the relay."); + putValue(Action.NAME, Util.getTranslation("ac_start_relay")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_start_relay_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_START)); myRelayIsActive = false; myPluginManager.shutdownActivePlugins(); myController.stopRelay(); } else { - putValue(Action.NAME, "Stop Relay"); - putValue(Action.SHORT_DESCRIPTION, "Stop the relay."); + putValue(Action.NAME, Util.getTranslation("ac_stop_relay")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_stop_relay_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_STOP)); myController.startRelay(); myRelayIsActive = true; @@ -438,13 +438,13 @@ }; /** - * Action: Clear content of left (client) raw pane. + * Action: Clear content of client raw pane. */ - private Action clearLeftAction = new AbstractAction() { + private Action clearClientAction = new AbstractAction() { static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Clear Client"); - putValue(Action.SHORT_DESCRIPTION, "Clear the Client side data."); + putValue(Action.NAME, Util.getTranslation("ac_clear_client")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_clear_client_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_CLEAR_CLIENT)); } @@ -455,13 +455,13 @@ }; /** - * Action: Clear content of right (server) raw pane. + * Action: Clear content of server raw pane. */ - private Action clearRightAction = new AbstractAction() { + private Action clearServerAction = new AbstractAction() { static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Clear Server"); - putValue(Action.SHORT_DESCRIPTION, "Clear the Server side data."); + putValue(Action.NAME, Util.getTranslation("ac_clear_server")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_clear_server_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_CLEAR_SERVER)); } @@ -477,8 +477,8 @@ private Action clearAllAction = new AbstractAction() { static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Clear All"); - putValue(Action.SHORT_DESCRIPTION, "Clear all data."); + putValue(Action.NAME, Util.getTranslation("ac_clear_all")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_clear_all_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_CLEAR_ALL)); } @@ -497,21 +497,21 @@ // INFO: myAutomodeIsActive local var!? static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Enable Auto Mode"); - putValue(Action.SHORT_DESCRIPTION, "Data is automatically transfered."); + putValue(Action.NAME, Util.getTranslation("ac_enable_auto_mode")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_enable_auto_mode_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_AUTOMODE_ON)); } public void actionPerformed(ActionEvent e) { if (myAutomodeIsActive) { - putValue(Action.NAME, "Enable Auto Mode"); - putValue(Action.SHORT_DESCRIPTION, "Data is automatically transfered."); + putValue(Action.NAME, Util.getTranslation("ac_enable_auto_mode")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_enable_auto_mode_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_AUTOMODE_ON)); myAutomodeIsActive = false; myController.disableAutomode(); } else { - putValue(Action.NAME, "Disable Auto Mode"); - putValue(Action.SHORT_DESCRIPTION, "No automtic data transfer."); + putValue(Action.NAME, Util.getTranslation("ac_disable_auto_mode")); + putValue(Action.SHORT_DESCRIPTION, Util.getTranslation("ac_disable_auto_mode_description")); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_AUTOMODE_OFF)); myController.enableAutomode(); myAutomodeIsActive = true; @@ -680,7 +680,7 @@ private JTabbedPane getJTabbedPaneClient() { if (jTabbedPaneClient == null) { jTabbedPaneClient = new JTabbedPane(); - jTabbedPaneClient.addTab("Raw", null, getJScrollPaneClientRaw(), null); + jTabbedPaneClient.addTab(Util.getTranslation("tab_raw"), null, getJScrollPaneClientRaw(), null); //update plugins if (myPluginManager != null) { @@ -721,7 +721,7 @@ private JTabbedPane getJTabbedPaneServer() { if (jTabbedPaneServer == null) { jTabbedPaneServer = new JTabbedPane(); - jTabbedPaneServer.addTab("Raw", null, getJScrollPaneServerRaw(), null); + jTabbedPaneServer.addTab(Util.getTranslation("tab_raw"), null, getJScrollPaneServerRaw(), null); //update plugins if (myPluginManager != null) { @@ -791,8 +791,7 @@ private JMenu getJMenuFile() { if (jMenuFile == null) { jMenuFile = new JMenu(); - jMenuFile.setText("File"); - jMenuFile.setMnemonic(KeyEvent.VK_F); + jMenuFile.setText(Util.getTranslation("menu_file")); jMenuFile.add(getJMenuItemConfigure()); jMenuFile.add(getJMenuItemExit()); } @@ -820,8 +819,7 @@ private JMenu getJMenuView() { if (jMenuView == null) { jMenuView = new JMenu(); - jMenuView.setText("View"); - jMenuView.setMnemonic(KeyEvent.VK_V); + jMenuView.setText(Util.getTranslation("menu_view")); jMenuView.add(getJMenuItemClearAll()); jMenuView.add(getJMenuItemClearClient()); jMenuView.add(getJMenuItemClearServer()); @@ -848,7 +846,7 @@ */ private JMenuItem getJMenuItemClearClient() { if (jMenuItemClearLeft == null) { - jMenuItemClearLeft = new JMenuItem(clearLeftAction); + jMenuItemClearLeft = new JMenuItem(clearClientAction); } return jMenuItemClearLeft; } @@ -860,7 +858,7 @@ */ private JMenuItem getJMenuItemClearServer() { if (jMenuItemClearRight == null) { - jMenuItemClearRight = new JMenuItem(clearRightAction); + jMenuItemClearRight = new JMenuItem(clearServerAction); } return jMenuItemClearRight; } @@ -873,8 +871,7 @@ private JMenu getJMenuHelp() { if (jMenuHelp == null) { jMenuHelp = new JMenu(); - jMenuHelp.setText("Help"); - jMenuHelp.setMnemonic(KeyEvent.VK_HELP); + jMenuHelp.setText(Util.getTranslation("menu_help")); jMenuHelp.add(getJMenuItemAbout()); } return jMenuHelp; @@ -912,7 +909,7 @@ private JMenu getJMenuPlugins() { if (jMenuPlugins == null) { jMenuPlugins = new JMenu(); - jMenuPlugins.setText("Plugins"); + jMenuPlugins.setText(Util.getTranslation("menu_plugins")); jMenuPlugins.add(getJMenuItemConfigurePlugins()); } return jMenuPlugins; @@ -1011,7 +1008,8 @@ jPanelRight = null; jSplitPaneHorizontal.setLeftComponent(getJTabbedPaneClient()); jSplitPaneHorizontal.setRightComponent(getJPanelRight()); - jSplitPaneHorizontal.setDividerLocation(DIVIDER_HORZ); + // set divider location + jSplitPaneHorizontal.setResizeWeight(DIVIDER_HORZ); jSplitPaneHorizontal.repaint(); } } @@ -1034,11 +1032,10 @@ */ private JSplitPane getJSplitPaneVertical() { if (jSplitPaneVertical == null) { - //TODO: splitter settings -// splitPane.setResizeWeight(0.5); jSplitPaneVertical = new JSplitPane(); jSplitPaneVertical.setOrientation(JSplitPane.VERTICAL_SPLIT); - jSplitPaneVertical.setDividerLocation(DIVIDER_VERT); + // set divider location + jSplitPaneVertical.setResizeWeight(DIVIDER_VERT); jSplitPaneVertical.setBottomComponent(getJPanelHistory()); jSplitPaneVertical.setTopComponent(getJSplitPaneHorizontal()); } @@ -1073,6 +1070,18 @@ jTableHistory = new JTable(myHistoryTableModel); jTableHistory.setShowGrid(true); jTableHistory.setAutoCreateRowSorter(true); +// // Disable auto resizing +// jTableHistory.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); +// // Set the column widths +// TableColumn column = jTableHistory.getColumnModel().getColumn(0); +// column.setPreferredWidth(100); +// column = jTableHistory.getColumnModel().getColumn(1); +// column.setPreferredWidth(100); +// column = jTableHistory.getColumnModel().getColumn(2); +// column.setPreferredWidth(100); +// column = jTableHistory.getColumnModel().getColumn(3); +// column.setPreferredWidth(100); + jTableHistory.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting()) { Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationDialog.java 2008-03-19 13:04:03 UTC (rev 90) @@ -39,6 +39,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; +import javax.swing.table.TableColumn; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.common.Util; @@ -60,6 +61,56 @@ private static final long serialVersionUID = 1L; /** + * Width of the column client (checkbox) in pixel. + */ + private static final int COLUMN_WIDTH_CLIENT = 50; + /** + * Width of the column server (checkbox) in pixel. + */ + private static final int COLUMN_WIDTH_SERVER = 50; + /** + * Width of the column name in pixel. + */ + private static final int COLUMN_WIDTH_NAME = 100; + /** + * Width of the column version in pixel. + */ + private static final int COLUMN_WIDTH_VERSION = 50; + /** + * Width of the column author in pixel. + */ + private static final int COLUMN_WIDTH_AUTHOR = 100; + /** + * Width of the column description in pixel. + */ + private static final int COLUMN_WIDTH_DESCRIPTION = 350; + + /** + * Index of the column client (checkbox). + */ + private static final int COLUMN_INDEX_CLIENT = 0; + /** + * Index of the column server (checkbox). + */ + private static final int COLUMN_INDEX_SERVER = 1; + /** + * Index of the column name. + */ + private static final int COLUMN_INDEX_NAME = 2; + /** + * Index of the column version. + */ + private static final int COLUMN_INDEX_VERSION = 3; + /** + * Index of the column author. + */ + private static final int COLUMN_INDEX_AUTHOR = 4; + /** + * Index of the column description. + */ + private static final int COLUMN_INDEX_DESCRIPTION = 5; + + /** * */ private JPanel jContentPane = null; @@ -167,7 +218,7 @@ */ private void initialize() { this.setSize(Constant.UI_PLUGIN_CONFIG_DIALOG_WIDTH, Constant.UI_PLUGIN_CONFIG_DIALOG_HEIGTH); - this.setTitle(Constant.APP_TITLE + " Plugin Configuration Dialog"); + this.setTitle(Constant.APP_TITLE + " " + Util.getTranslation("dlg_plugin_configuration_title")); this.setContentPane(getJContentPane()); this.setModal(true); Util.centerWindow((Window) this); @@ -229,6 +280,23 @@ // do NOT allow reordering of the columns! // in future you may enable this, but you also have to convert the column indices (view/table data model) jTable.getTableHeader().setReorderingAllowed(false); + + // Disable auto resizing + jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + // Set the column widths + TableColumn column = jTable.getColumnModel().getColumn(COLUMN_INDEX_CLIENT); + column.setPreferredWidth(COLUMN_WIDTH_CLIENT); + column = jTable.getColumnModel().getColumn(COLUMN_INDEX_SERVER); + column.setPreferredWidth(COLUMN_WIDTH_SERVER); + column = jTable.getColumnModel().getColumn(COLUMN_INDEX_NAME); + column.setPreferredWidth(COLUMN_WIDTH_NAME); + column = jTable.getColumnModel().getColumn(COLUMN_INDEX_VERSION); + column.setPreferredWidth(COLUMN_WIDTH_VERSION); + column = jTable.getColumnModel().getColumn(COLUMN_INDEX_AUTHOR); + column.setPreferredWidth(COLUMN_WIDTH_AUTHOR); + column = jTable.getColumnModel().getColumn(COLUMN_INDEX_DESCRIPTION); + column.setPreferredWidth(COLUMN_WIDTH_DESCRIPTION); + jTable.setDefaultRenderer(Boolean.class, new PluginConfigurationTableCellRenderer(myAvailablePlugins)); } return jTable; @@ -287,7 +355,7 @@ private JButton getJButtonCancel() { if (jButtonCancel == null) { jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); + jButtonCancel.setText(Util.getTranslation("dlg_plugin_configuration_cancel")); jButtonCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { closeWindow(); @@ -305,7 +373,7 @@ private JButton getJButtonOk() { if (jButtonOk == null) { jButtonOk = new JButton(); - jButtonOk.setText("Ok"); + jButtonOk.setText(Util.getTranslation("dlg_plugin_configuration_ok")); jButtonOk.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { savePluginConfiguration(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableModel.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/PluginConfigurationTableModel.java 2008-03-19 13:04:03 UTC (rev 90) @@ -27,7 +27,9 @@ import javax.swing.table.DefaultTableModel; +import de.dlr.davinspector.common.Util; + /** * Table model for the table in the plugin configuration dialog. * @@ -45,12 +47,12 @@ * Column definition. */ private String[] columnNames = { - "Client", - "Server", - "Name", - "Version", - "Author", - "Description" + Util.getTranslation("column_name_client"), + Util.getTranslation("column_name_server"), + Util.getTranslation("column_name_name"), + Util.getTranslation("column_name_version"), + Util.getTranslation("column_name_author"), + Util.getTranslation("column_name_description") }; /** Modified: trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java =================================================================== --- trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java 2008-03-18 17:22:46 UTC (rev 89) +++ trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java 2008-03-19 13:04:03 UTC (rev 90) @@ -50,6 +50,11 @@ public class HTTPTest { /** + * Comment for not yet implemented tests. + */ + private static final String NOT_YET = "Not yet implemented"; + + /** * */ private static int idCounter = 0; @@ -103,6 +108,7 @@ idCounter++; timestamp = new Date(); direction = false; + // TODO: Read test data from file. data = "This is a test"; message = new Message(); message.setMessageDirection(direction); @@ -144,7 +150,7 @@ @Test public void testSetTimestamp() { Calendar cal = Calendar.getInstance(); - cal.set(2008, 11, 11, 11, 11, 11); + cal.set(1, 1, 1, 1, 1, 1); // ### timestamp = cal.getTime(); message.setTimestamp(timestamp); Assert.assertEquals(timestamp, message.getTimestamp()); @@ -218,6 +224,7 @@ */ @Test public void testSetRawData() { + // TODO: Read test data from file. String testdata = "Mir lose de Dom in koelle."; message.setRawData(testdata); Assert.assertEquals(testdata, message.getRawData()); @@ -229,7 +236,7 @@ */ @Test public void testGetMessageHeader() { - junit.framework.TestCase.fail("Not yet implemented"); + junit.framework.TestCase.fail(NOT_YET); } /** @@ -238,7 +245,7 @@ */ @Test public void testGetRawHeader() { - junit.framework.TestCase.fail("Not yet implemented"); + junit.framework.TestCase.fail(NOT_YET); } /** @@ -247,7 +254,7 @@ */ @Test public void testGetMessageBody() { - junit.framework.TestCase.fail("Not yet implemented"); + junit.framework.TestCase.fail(NOT_YET); } /** @@ -256,7 +263,7 @@ */ @Test public void testGetRawBody() { - junit.framework.TestCase.fail("Not yet implemented"); + junit.framework.TestCase.fail(NOT_YET); } /** @@ -265,7 +272,7 @@ */ @Test public void testParseMessage() { - junit.framework.TestCase.fail("Not yet implemented"); + junit.framework.TestCase.fail(NOT_YET); } /** @@ -274,7 +281,7 @@ */ @Test public void testIsComplete() { - junit.framework.TestCase.fail("Not yet implemented"); + junit.framework.TestCase.fail(NOT_YET); } } Added: trunk/DAVInspector/test/de/dlr/davinspector/http/package.html =================================================================== --- trunk/DAVInspector/test/de/dlr/davinspector/http/package.html (rev 0) +++ trunk/DAVInspector/test/de/dlr/davinspector/http/package.html 2008-03-19 13:04:03 UTC (rev 90) @@ -0,0 +1,6 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" +"http://www.w3.org/TR/REC-html40/loose.dtd"> + +<html><head><title>Package unit tests for HTTP</title></head><body> +This package contains all unit test classes for the basic HTTP message parser. +</body></html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-18 17:22:49
|
Revision: 89 http://davinspector.svn.sourceforge.net/davinspector/?rev=89&view=rev Author: wuest Date: 2008-03-18 10:22:46 -0700 (Tue, 18 Mar 2008) Log Message: ----------- Enabled auto mode for automatic data transfer from client to server and vice versa. Modified Paths: -------------- trunk/DAVInspector/build-user.xml trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java Added Paths: ----------- trunk/DAVInspector/logging.properties trunk/DAVInspector/resource/wizard_off.png Modified: trunk/DAVInspector/build-user.xml =================================================================== --- trunk/DAVInspector/build-user.xml 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/build-user.xml 2008-03-18 17:22:46 UTC (rev 89) @@ -67,7 +67,7 @@ <manifest> <attribute name="Main-Class" value="de/dlr/davinspector.DAVInspector"/> <attribute name="Built-By" value="${user.name}"/> - <attribute name="Class-Path" value=". lib/commons-logging.jar logging.properties lib/log4j.jar"/> + <attribute name="Class-Path" value=". logging.properties lib/log4j.jar"/> <section name="DAVInspector"> <attribute name="Specification-Title" value="${project.name}"/> Added: trunk/DAVInspector/logging.properties =================================================================== --- trunk/DAVInspector/logging.properties (rev 0) +++ trunk/DAVInspector/logging.properties 2008-03-18 17:22:46 UTC (rev 89) @@ -0,0 +1,17 @@ +# Log-Level of the root Logger +log4j.rootLogger=ERROR + +# Set Log-Level for DAVInspector +log4j.logger.de.dlr.davinpsector=DEBUG + +# Configuration of the Log-File +# log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=log/log4j.log + +# Max Log-File size +log4j.appender.file.MaxFileSize=100KB +# Keep one Backup +log4j.appender.file.MaxBackupIndex=1 +# Define logger layout +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%p %t %c - %m%n Added: trunk/DAVInspector/resource/wizard_off.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/resource/wizard_off.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-18 17:22:46 UTC (rev 89) @@ -198,6 +198,11 @@ public static final int PLUGIN_CONFIG_NAME_COL = 2; /** + * System logger configuration file (log4j). + */ + public static final String SYSTEM_LOGGER_CONFIGURATION = "logging.properties"; + + /** * Empty Constructor. */ private Constant() { Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-18 17:22:46 UTC (rev 89) @@ -125,6 +125,16 @@ } else { myServersideBuffer = carry; } + + // automatic send the message to client/server + // TODO: Steuerung nachrichten aus mainview raus!! + if (myRelay.getStateAutomode()) { + if (toClient) { + myRelay.writeToClient(message.getRawData()); + } else { + myRelay.writeToServer(message.getRawData()); + } + } } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-18 17:22:46 UTC (rev 89) @@ -25,14 +25,11 @@ package de.dlr.davinspector.http; -import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.log4j.FileAppender; -import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.apache.log4j.SimpleLayout; +import org.apache.log4j.PropertyConfigurator; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; @@ -134,16 +131,8 @@ public HTTPMessageParser(AMessage aMessage) { super(aMessage); myParsingState = false; - // configure logging - SimpleLayout layout = new SimpleLayout(); - try { - FileAppender fileAppender = new FileAppender(layout, "HTTPMessageParser.log", false); - myLogger.addAppender(fileAppender); - // ALL | DEBUG | INFO | WARN | ERROR | FATAL | OFF: - myLogger.setLevel(Level.ALL); - } catch (IOException ioe) { - System.err.println("Could not initilaize logger! " + ioe.getMessage()); - } + // Configure Logger + PropertyConfigurator.configure(Constant.SYSTEM_LOGGER_CONFIGURATION); } /** @@ -203,13 +192,13 @@ } if (myLogger.isDebugEnabled()) { - myLogger.debug("###############"); - myLogger.debug("Method:" + myMethod); - myLogger.debug("Status:" + myStatusCode); + myLogger.debug("########"); + myLogger.debug("Method :" + myMethod); + myLogger.debug("Status :" + myStatusCode); myLogger.debug("Version:" + myProtocolVersion); - myLogger.debug("Len:" + myContentLength); + myLogger.debug("Len :" + myContentLength); myLogger.debug("Chunked:" + isChunked); - myLogger.debug("###############"); + myLogger.debug("########"); } extractHeaderBody(); @@ -219,26 +208,22 @@ if (!isChunked && (myContentLength == 0 || !hasBody())) { myLogger.debug("no body"); myParsedBody = ""; - carryover = ""; // TODO: + carryover = ""; // TODO: Set carry. myParsingState = true; } else { if (isChunked) { myLogger.debug("decode chunked encoding"); myParsedBody = decodeChunkedEncoding(myRawBody); - carryover = ""; // TODO: + carryover = ""; // TODO: Set carry. if (!myParsingState) { myLogger.debug("decoding chunked encoding not finished"); } } else { myLogger.debug("normal message"); if (myContentLength > myRawBody.length()) { + myContentLength = 0; myLogger.debug("normal message not finished"); } - // TODO: ung\xFCltige l\xE4nge abfangen! - if (myContentLength > myRawBody.length()) { - myContentLength = myRawBody.length(); - myLogger.debug("invalid content length"); - } myParsedBody = myRawBody.substring(0, myContentLength); carryover = myRawBody.substring(myContentLength, myRawBody.length()); myParsingState = true; Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-18 17:22:46 UTC (rev 89) @@ -34,6 +34,7 @@ import java.util.Vector; import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; @@ -86,6 +87,8 @@ * @return PluginManager */ public static PluginManager getInstance() { + // Configure Logger + PropertyConfigurator.configure(Constant.SYSTEM_LOGGER_CONFIGURATION); return instance; } @@ -116,7 +119,7 @@ IPlugin plugin = null; String name = jarFile.getName().substring(0, jarFile.getName().lastIndexOf(".")); try { - myLogger.debug("Trying to load plugin: " + name); + myLogger.debug("Trying to load class: " + name); URLClassLoader jClassLoader = new URLClassLoader(new URL[] { jarFile.toURI().toURL() }); Class<?> c = jClassLoader.loadClass(Constant.PLUGIN_CLASSPATH + name.toLowerCase() + "." + name); // lets try to load the plugin... Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-18 17:22:46 UTC (rev 89) @@ -93,6 +93,24 @@ */ Logger getSystemLog(); + /** + * Returns the state of the automode.<br> + * true: ON<br> + * false: OFF<br> + * + * @return Boolean + */ + Boolean getStateAutomode(); + + /** + * Activate/Deactivate the automode.<br> + * true: ON<br> + * false: OFF<br> + * + * @param state Boolean + */ + void setStateAutomode(Boolean state); + /** * Adds an {@link IServerListener} to RelayModel. * Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-18 17:22:46 UTC (rev 89) @@ -38,6 +38,7 @@ import javax.swing.event.EventListenerList; import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.configuration.Configuration; @@ -106,10 +107,18 @@ private MessageHistory myMessageHistory = null; /** + * State of the automode. + */ + private Boolean myStateAutomode = false; + + /** * Constructor of RelayModel. * The constructor creates a new {@link MessageHistory} object. */ public RelayModel() { + // Configure Logger + PropertyConfigurator.configure(Constant.SYSTEM_LOGGER_CONFIGURATION); + myMessageHistory = new MessageHistory(this); myPluginManager = PluginManager.getInstance(); // load available plugins @@ -151,6 +160,24 @@ /** * {@inheritDoc} * + * @see de.dlr.davinspector.relay.IRelayModel#getStateAutomode() + */ + public Boolean getStateAutomode() { + return myStateAutomode; + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.relay.IRelayModel#setStateAutomode(java.lang.Boolean) + */ + public void setStateAutomode(Boolean state) { + myStateAutomode = state; + } + + /** + * {@inheritDoc} + * * @see de.dlr.davinspector.relay.IRelayModel#addServerListener(de.dlr.davinspector.relay.IServerListener) */ public void addServerListener(IServerListener listener) { Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-03-18 17:22:46 UTC (rev 89) @@ -63,4 +63,14 @@ * @return MainView */ MainView getView(); + + /** + * Activates the automode of the relay. + */ + void enableAutomode(); + + /** + * Deactivates the automode of the relay. + */ + void disableAutomode(); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-03-18 17:22:46 UTC (rev 89) @@ -102,4 +102,26 @@ public MainView getView() { return myView; } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#enableAutomode() + */ + public void enableAutomode() { + if (!myRelay.getStateAutomode()) { + myRelay.setStateAutomode(true); + } + } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#disableAutomode() + */ + public void disableAutomode() { + if (myRelay.getStateAutomode()) { + myRelay.setStateAutomode(false); + } + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-03-18 17:22:46 UTC (rev 89) @@ -282,6 +282,11 @@ private Boolean myRelayIsActive = false; /** + * Current state of the automode. + */ + private Boolean myAutomodeIsActive = false; + + /** * Toggle button for controlling the auto mode. */ private JToggleButton jToggleButtonAutomode = null; @@ -406,6 +411,7 @@ * Action: Start or stop the relay. */ private Action relayAction = new AbstractAction() { + // INFO: myRelayIsActive local var!? static final long serialVersionUID = 1L; { putValue(Action.NAME, "Start Relay"); @@ -414,12 +420,10 @@ } public void actionPerformed(ActionEvent e) { - if (myRelayIsActive) { putValue(Action.NAME, "Start Relay"); putValue(Action.SHORT_DESCRIPTION, "Start the relay."); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_START)); - // TODO: Move to ctrl myRelayIsActive = false; myPluginManager.shutdownActivePlugins(); myController.stopRelay(); @@ -427,7 +431,6 @@ putValue(Action.NAME, "Stop Relay"); putValue(Action.SHORT_DESCRIPTION, "Stop the relay."); putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_STOP)); - // TODO: Move to ctrl myController.startRelay(); myRelayIsActive = true; } @@ -491,15 +494,28 @@ * Action: Enable or disable automode. */ private Action automodeAction = new AbstractAction() { + // INFO: myAutomodeIsActive local var!? static final long serialVersionUID = 1L; { - putValue(Action.NAME, "Automode"); - putValue(Action.SHORT_DESCRIPTION, "Data is automatically transfered from Client to Server and vice versa."); - putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_AUTOMODE)); + putValue(Action.NAME, "Enable Auto Mode"); + putValue(Action.SHORT_DESCRIPTION, "Data is automatically transfered."); + putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_AUTOMODE_ON)); } - + public void actionPerformed(ActionEvent e) { - // TODO: ctrl activate automode + if (myAutomodeIsActive) { + putValue(Action.NAME, "Enable Auto Mode"); + putValue(Action.SHORT_DESCRIPTION, "Data is automatically transfered."); + putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_AUTOMODE_ON)); + myAutomodeIsActive = false; + myController.disableAutomode(); + } else { + putValue(Action.NAME, "Disable Auto Mode"); + putValue(Action.SHORT_DESCRIPTION, "No automtic data transfer."); + putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_AUTOMODE_OFF)); + myController.enableAutomode(); + myAutomodeIsActive = true; + } } }; Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java 2008-03-18 13:58:05 UTC (rev 88) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java 2008-03-18 17:22:46 UTC (rev 89) @@ -63,11 +63,16 @@ /** * */ - public static final String ICON_AUTOMODE = "wizard.png"; + public static final String ICON_AUTOMODE_ON = "wizard.png"; /** * */ + public static final String ICON_AUTOMODE_OFF = "wizard_off.png"; + + /** + * + */ public static final String ICON_EXIT = "exit.png"; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-18 13:58:17
|
Revision: 88 http://davinspector.svn.sourceforge.net/davinspector/?rev=88&view=rev Author: wuest Date: 2008-03-18 06:58:05 -0700 (Tue, 18 Mar 2008) Log Message: ----------- Deleted Apache Commons Logging. Modified Paths: -------------- trunk/DAVInspector/.classpath trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java Removed Paths: ------------- trunk/DAVInspector/lib/commons-logging.jar trunk/DAVInspector/logging.properties Modified: trunk/DAVInspector/.classpath =================================================================== --- trunk/DAVInspector/.classpath 2008-03-17 15:57:00 UTC (rev 87) +++ trunk/DAVInspector/.classpath 2008-03-18 13:58:05 UTC (rev 88) @@ -5,6 +5,5 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="lib" path="C:/Dokumente und Einstellungen/wues_ha/workspace/DAVInspector/lib/log4j.jar"/> - <classpathentry kind="lib" path="C:/Dokumente und Einstellungen/wues_ha/workspace/DAVInspector/lib/commons-logging.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Deleted: trunk/DAVInspector/lib/commons-logging.jar =================================================================== (Binary files differ) Deleted: trunk/DAVInspector/logging.properties =================================================================== --- trunk/DAVInspector/logging.properties 2008-03-17 15:57:00 UTC (rev 87) +++ trunk/DAVInspector/logging.properties 2008-03-18 13:58:05 UTC (rev 88) @@ -1,9 +0,0 @@ -# Add a FileHandler -handlers=java.util.logging.FileHandler -# global -java.util.logging.level=FINE -# Describes specific configuration info for the Handlers. -java.util.logging.FileHandler.level=FINEST -java.util.logging.FileHandler.pattern=log/relay.log -java.util.logging.FileHandler.limit=50000 -java.util.logging.FileHandler.count=1 Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-17 15:57:00 UTC (rev 87) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-18 13:58:05 UTC (rev 88) @@ -99,7 +99,7 @@ /** * Logger, Apache log4j. */ - private static Logger myLogger = Logger.getLogger("de.dlr.http.HTTPMessageParser"); + private static Logger myLogger = Logger.getLogger(HTTPMessageParser.class); /** * The http request method. Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-17 15:57:00 UTC (rev 87) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugin/PluginManager.java 2008-03-18 13:58:05 UTC (rev 88) @@ -33,6 +33,8 @@ import java.util.List; import java.util.Vector; +import org.apache.log4j.Logger; + import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; @@ -53,6 +55,11 @@ private static PluginManager instance = new PluginManager(); /** + * Logger, Apache log4j. + */ + private static Logger myLogger = Logger.getLogger(PluginManager.class); + + /** * Vector containing all loaded plugins. */ private List<IPlugin> myPluginVector = new Vector<IPlugin>(); @@ -89,10 +96,12 @@ public void loadAllPlugins() { File pluginDirectory = new File("plugins"); if (pluginDirectory.isDirectory()) { + myLogger.debug("Reading plugin directory"); String[] jarFiles = pluginDirectory.list(new JarFilenameFilter()); String pathToPluginDir = pluginDirectory.getAbsolutePath(); for (String jarFile : jarFiles) { File plug = new File(pathToPluginDir + "/" + jarFile); + myLogger.debug("Loading plugin: " + jarFile); loadPlugin(plug.getAbsoluteFile()); } } @@ -107,11 +116,14 @@ IPlugin plugin = null; String name = jarFile.getName().substring(0, jarFile.getName().lastIndexOf(".")); try { + myLogger.debug("Trying to load plugin: " + name); URLClassLoader jClassLoader = new URLClassLoader(new URL[] { jarFile.toURI().toURL() }); Class<?> c = jClassLoader.loadClass(Constant.PLUGIN_CLASSPATH + name.toLowerCase() + "." + name); // lets try to load the plugin... plugin = (IPlugin) c.newInstance(); + myLogger.debug("Plugin loaded: " + name); plugin.init(null); + myLogger.debug("Plugin initialised: " + name); // ok, the plugin is initialized if (plugin != null) { myPluginVector.add(plugin); @@ -126,14 +138,13 @@ myActivePluginsServer.add(plugin); } } catch (ClassNotFoundException cnfe) { - System.err.println(cnfe); + myLogger.warn("Class Not Found: " + cnfe.getMessage(), cnfe); } catch (InstantiationException ie) { - System.err.println(ie); + myLogger.warn("Instantiation: " + ie.getMessage(), ie); } catch (IllegalAccessException iae) { - System.err.println(iae); + myLogger.warn("Illegal Access: " + iae.getMessage(), iae); } catch (IOException ioe) { - System.err.println(ioe); - jarFile.delete(); + myLogger.warn("IO Error: " + ioe.getMessage(), ioe); } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-17 15:57:00 UTC (rev 87) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-18 13:58:05 UTC (rev 88) @@ -32,7 +32,7 @@ import java.net.SocketException; import java.util.List; -import org.apache.commons.logging.Log; +import org.apache.log4j.Logger; import de.dlr.davinspector.common.Constant; @@ -77,7 +77,7 @@ /** * The logger. */ - private Log myLogger; + private Logger myLogger; /** * @@ -104,7 +104,7 @@ * @param connections List */ public ChannelThread(Socket inputSocket, Socket outputSocket, IRelayModel relay, - Log logger, List<ChannelThread> connections) { + Logger logger, List<ChannelThread> connections) { myInputSocket = inputSocket; myOutputSocket = outputSocket; myRelay = relay; @@ -264,6 +264,7 @@ private Boolean isChunked(String data) { // TODO: RFC 2616 14.39 TE / 14.41 Transfer-Encoding // Output decorator!? + // see: HTTPMessageParser Boolean result = false; if (data.contains("Transfer-Encoding: chunked")) { result = true; Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-17 15:57:00 UTC (rev 87) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-03-18 13:58:05 UTC (rev 88) @@ -25,7 +25,7 @@ package de.dlr.davinspector.relay; -import org.apache.commons.logging.Log; +import org.apache.log4j.Logger; import de.dlr.davinspector.configuration.Configuration; import de.dlr.davinspector.history.MessageHistory; @@ -87,11 +87,11 @@ PluginManager getPluginManager(); /** - * Returns Log object from Apache Commons Logging. + * Returns Log object from Apache log4j Logging. * - * @return Log + * @return Logger */ - Log getSystemLog(); + Logger getSystemLog(); /** * Adds an {@link IServerListener} to RelayModel. Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-17 15:57:00 UTC (rev 87) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-18 13:58:05 UTC (rev 88) @@ -37,8 +37,7 @@ import javax.swing.event.EventListenerList; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.log4j.Logger; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.configuration.Configuration; @@ -57,6 +56,11 @@ public class RelayModel extends Thread implements IRelayModel { /** + * Logger, Apache log4j. + */ + private static Logger myLogger = Logger.getLogger(RelayModel.class); + + /** * List of listeners for new client data. */ private EventListenerList myClientListeners = new EventListenerList(); @@ -67,11 +71,6 @@ private EventListenerList myServerListeners = new EventListenerList(); /** - * Logger, Apache Commons Logging. - */ - private Log myLogger = LogFactory.getLog(RelayModel.class); - - /** * Address to forward connections to. */ private InetAddress myDestinationAddress; @@ -145,7 +144,7 @@ * * @see de.dlr.davinspector.relay.IRelayModel#getSystemLog() */ - public Log getSystemLog() { + public Logger getSystemLog() { return myLogger; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-17 15:57:52
|
Revision: 87 http://davinspector.svn.sourceforge.net/davinspector/?rev=87&view=rev Author: wuest Date: 2008-03-17 08:57:00 -0700 (Mon, 17 Mar 2008) Log Message: ----------- Added Apache log4j. XML-errors are now displayed by the XML-Plugins in a text area. Modified Paths: -------------- trunk/DAVInspector/.classpath trunk/DAVInspector/build-user.xml trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLTextPane.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java Added Paths: ----------- trunk/DAVInspector/lib/log4j.jar Modified: trunk/DAVInspector/.classpath =================================================================== --- trunk/DAVInspector/.classpath 2008-03-12 16:13:29 UTC (rev 86) +++ trunk/DAVInspector/.classpath 2008-03-17 15:57:00 UTC (rev 87) @@ -3,7 +3,8 @@ <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="lib" path="lib/commons-logging.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> + <classpathentry kind="lib" path="C:/Dokumente und Einstellungen/wues_ha/workspace/DAVInspector/lib/log4j.jar"/> + <classpathentry kind="lib" path="C:/Dokumente und Einstellungen/wues_ha/workspace/DAVInspector/lib/commons-logging.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: trunk/DAVInspector/build-user.xml =================================================================== --- trunk/DAVInspector/build-user.xml 2008-03-12 16:13:29 UTC (rev 86) +++ trunk/DAVInspector/build-user.xml 2008-03-17 15:57:00 UTC (rev 87) @@ -67,7 +67,7 @@ <manifest> <attribute name="Main-Class" value="de/dlr/davinspector.DAVInspector"/> <attribute name="Built-By" value="${user.name}"/> - <attribute name="Class-Path" value=". lib/commons-logging.jar logging.properties"/> + <attribute name="Class-Path" value=". lib/commons-logging.jar logging.properties lib/log4j.jar"/> <section name="DAVInspector"> <attribute name="Specification-Title" value="${project.name}"/> Added: trunk/DAVInspector/lib/log4j.jar =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/lib/log4j.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-12 16:13:29 UTC (rev 86) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-17 15:57:00 UTC (rev 87) @@ -25,16 +25,18 @@ package de.dlr.davinspector.http; +import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; import de.dlr.davinspector.history.AMessageParser; -import de.dlr.davinspector.relay.RelayModel; /** * This class is a very simple approach to parse http messages. @@ -95,9 +97,9 @@ private static final String REGEX_IS_CHUNKED = "Transfer-Encoding:[ ]*chunked\r\n"; /** - * Logger, Apache Commons Logging. + * Logger, Apache log4j. */ - private static Log myLogger = LogFactory.getLog(RelayModel.class); + private static Logger myLogger = Logger.getLogger("de.dlr.http.HTTPMessageParser"); /** * The http request method. @@ -132,6 +134,16 @@ public HTTPMessageParser(AMessage aMessage) { super(aMessage); myParsingState = false; + // configure logging + SimpleLayout layout = new SimpleLayout(); + try { + FileAppender fileAppender = new FileAppender(layout, "HTTPMessageParser.log", false); + myLogger.addAppender(fileAppender); + // ALL | DEBUG | INFO | WARN | ERROR | FATAL | OFF: + myLogger.setLevel(Level.ALL); + } catch (IOException ioe) { + System.err.println("Could not initilaize logger! " + ioe.getMessage()); + } } /** @@ -151,8 +163,9 @@ * * @see de.dlr.davinspector.history.AMessageParser#parseMessage() */ - public String parseMessage() { - myLogger.debug("\n" + myDirection); + public String parseMessage() { + myLogger.debug("---- new data event ----"); + myLogger.debug("Direction: " + myDirection); String carryover = ""; @@ -203,8 +216,7 @@ myParsedHeader = myRawHeader; // Content-length = 0 or no body -> empty body - // TODO: && content-encoding != chunked - if (myStatusCode != HTTPStatusCode.HTTP_MULTISTATUS && (myContentLength == 0 || !hasBody())) { + if (!isChunked && (myContentLength == 0 || !hasBody())) { myLogger.debug("no body"); myParsedBody = ""; carryover = ""; // TODO: @@ -222,13 +234,18 @@ if (myContentLength > myRawBody.length()) { myLogger.debug("normal message not finished"); } + // TODO: ung\xFCltige l\xE4nge abfangen! + if (myContentLength > myRawBody.length()) { + myContentLength = myRawBody.length(); + myLogger.debug("invalid content length"); + } myParsedBody = myRawBody.substring(0, myContentLength); carryover = myRawBody.substring(myContentLength, myRawBody.length()); myParsingState = true; } } - myLogger.debug("Carry:" + carryover + "\n\n"); + myLogger.debug("Carry: " + carryover.length()); return carryover; } @@ -270,6 +287,7 @@ Pattern pattern = Pattern.compile(REGEX_CONTENT_LENGTH, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(myRawData); if (matcher.find()) { + myLogger.debug("content length found: " + matcher.group(1)); return Integer.parseInt(matcher.group(1)); } return 0; @@ -284,6 +302,7 @@ Pattern pattern = Pattern.compile(REGEX_IS_CHUNKED, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(myRawData); if (matcher.find()) { + myLogger.debug("message is chunked"); return true; } return false; @@ -332,10 +351,21 @@ } int start = matcher.end(); int stopp = matcher.end() + chunksize; - result += myRawData.substring(start, stopp); - + + // TODO: ung\xFCltige l\xE4ngen abfangen! + if (stopp > myRawData.length()) { + myLogger.debug("chunk decoding: invalid right boundary " + stopp); + stopp = myRawData.length(); + } + if (start < 0) { + myLogger.debug("chunk decoding: invalid left boundary " + start); + start = 0; + } + myLogger.debug("Chunk: " + parts); myLogger.debug("Chunk from index " + start + " to " + stopp); + + result += myRawData.substring(start, stopp); } // if we read the last chunk, the parsing is complete. myParsingState = readEmptyChunk; Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java 2008-03-12 16:13:29 UTC (rev 86) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/JTextPaneContentHandler.java 2008-03-17 15:57:00 UTC (rev 87) @@ -30,6 +30,7 @@ import java.util.Iterator; import java.util.Map; +import javax.swing.JTextArea; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.Element; @@ -59,16 +60,18 @@ /** * Character/s for indent. */ - private static final String INDENT = " "; + private static final String INDENT = " "; /** * */ private static final Color STYLE_XML_TAG = Color.BLUE; + /** * */ private static final Color STYLE_XML_CONTENT = Color.BLACK; + /** * */ @@ -108,13 +111,20 @@ * String buffer for the start tag. */ private String myBufferStartTag; + + /** + * This text area displays errors. + */ + private JTextArea myJTextAreaError; /** * Constructor, initializes all buffers and sets up the document. * * @param document StyledDocument + * @param jTextAreaError JTextArea */ - public JTextPaneContentHandler(StyledDocument document) { + public JTextPaneContentHandler(StyledDocument document, JTextArea jTextAreaError) { + myJTextAreaError = jTextAreaError; namespaceMappings = new HashMap<String, String>(); myStyledDocument = document; Element rootElement = myStyledDocument.getDefaultRootElement(); @@ -142,7 +152,8 @@ try { myStyledDocument.insertString(myStyledDocument.getLength(), text, myAttributeSet); } catch (BadLocationException ble) { - System.err.println(ble); + // INFO: Maybe logger instead? + myJTextAreaError.append(ble.getMessage() + ": " + ble.offsetRequested()); } myStyledDocument.setCharacterAttributes(myStyledDocument.getLength() - text.length(), text.length(), attributeSet, false); Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-03-12 16:13:29 UTC (rev 86) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLPlugin.java 2008-03-17 15:57:00 UTC (rev 87) @@ -25,9 +25,12 @@ package de.dlr.davinspector.plugins.xmlplugin; +import java.awt.SystemColor; import java.io.IOException; import javax.swing.JComponent; +import javax.swing.JSplitPane; +import javax.swing.JTextArea; import org.xml.sax.SAXException; @@ -45,6 +48,11 @@ public class XMLPlugin implements IViewPlugin { /** + * + */ + private static final double SPLITTER_POSITION = 0.8; + + /** * State of the plugin. */ private Boolean isActive = true; @@ -52,7 +60,17 @@ /** * The GUI object. */ + private JSplitPane jSplitPane; + + /** + * This text pane displays the formated XML. + */ private XMLTextPane myXMLTextPane; + + /** + * This text area displays XML errors. + */ + private JTextArea jTextArea; /** * {@inheritDoc} @@ -60,7 +78,7 @@ * @see de.dlr.DAVInspector.Plugin.IViewPlugin#getUI() */ public JComponent getUI() { - return myXMLTextPane; + return jSplitPane; } /** @@ -114,11 +132,23 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#init() */ public void init(Direction direction) { - if (myXMLTextPane == null) { + if (jSplitPane == null) { + jTextArea = new JTextArea(); + jTextArea.setLineWrap(true); + jTextArea.setEditable(false); + jTextArea.setForeground(SystemColor.RED); + myXMLTextPane = new XMLTextPane(); myXMLTextPane.setEditable(false); + + jSplitPane = new JSplitPane(); + jSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); + jSplitPane.setResizeWeight(SPLITTER_POSITION); + jSplitPane.setBottomComponent(jTextArea); + jSplitPane.setTopComponent(myXMLTextPane); } myXMLTextPane.setText(""); + jTextArea.setText(""); Util.setUIDesign(); } @@ -157,12 +187,12 @@ public void update(AMessage msg) { if (isActive && myXMLTextPane != null) { try { - myXMLTextPane.init(msg.getMessageBody()); + myXMLTextPane.init(msg.getMessageBody(), jTextArea); } catch (SAXException se) { - System.err.println(se.getMessage()); + jTextArea.append(se.getMessage()); } catch (IOException ioe) { - System.err.println(ioe.getMessage()); - } + jTextArea.append(ioe.getMessage()); + } } } @@ -174,6 +204,7 @@ public void clear() { if (myXMLTextPane != null) { myXMLTextPane.setText(""); + jTextArea.setText(""); } } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLTextPane.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLTextPane.java 2008-03-12 16:13:29 UTC (rev 86) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmlplugin/XMLTextPane.java 2008-03-17 15:57:00 UTC (rev 87) @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.StringReader; +import javax.swing.JTextArea; import javax.swing.JTextPane; import javax.swing.text.StyledDocument; @@ -56,13 +57,12 @@ * The document. */ private StyledDocument myDocument; - + /** * Constructor, empty. */ public XMLTextPane() { -// myDocument = new XmlStyledDocument(); -// setStyledDocument(myDocument); + } /** @@ -93,17 +93,18 @@ * This method initializes the <code>StyledDocument</code> and starts the XML parser. * * @param xmlInput String + * @param jTextAreaError JTextArea * @throws IOException if IO fails * @throws SAXException if SAX fails */ - public void init(String xmlInput) throws IOException, SAXException { + public void init(String xmlInput, JTextArea jTextAreaError) throws IOException, SAXException { setText(""); myDocument = getStyledDocument(); if (!xmlInput.trim().equals("")) { // Create instances needed for parsing XMLReader reader = XMLReaderFactory.createXMLReader(); - ContentHandler jTextPaneContentHandler = new JTextPaneContentHandler(myDocument); + ContentHandler jTextPaneContentHandler = new JTextPaneContentHandler(myDocument, jTextAreaError); // Register content handler reader.setContentHandler(jTextPaneContentHandler); Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-03-12 16:13:29 UTC (rev 86) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/xmltreeplugin/XMLTreePlugin.java 2008-03-17 15:57:00 UTC (rev 87) @@ -25,9 +25,12 @@ package de.dlr.davinspector.plugins.xmltreeplugin; +import java.awt.SystemColor; import java.io.IOException; import javax.swing.JComponent; +import javax.swing.JSplitPane; +import javax.swing.JTextArea; import org.xml.sax.SAXException; @@ -43,6 +46,11 @@ * @author Jochen Wuest */ public class XMLTreePlugin implements IViewPlugin { + + /** + * + */ + private static final double SPLITTER_POSITION = 0.8; /** * State of the plugin. @@ -50,6 +58,16 @@ private Boolean isActive = true; /** + * The GUI object. + */ + private JSplitPane jSplitPane; + + /** + * This text area displays XML errors. + */ + private JTextArea jTextArea; + + /** * The XMLTree component. */ private XMLTreeView myXMLTreeView; @@ -60,7 +78,7 @@ * @see de.dlr.DAVInspector.Plugin.IViewPlugin#getUI() */ public JComponent getUI() { - return myXMLTreeView; + return jSplitPane; } /** @@ -114,11 +132,24 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#init() */ public void init(Direction direction) { - if (myXMLTreeView == null) { + if (jSplitPane == null) { + jTextArea = new JTextArea(); + jTextArea.setLineWrap(true); + jTextArea.setEditable(false); + jTextArea.setForeground(SystemColor.RED); + myXMLTreeView = new XMLTreeView(); - } + myXMLTreeView.setEditable(false); + + jSplitPane = new JSplitPane(); + jSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); + jSplitPane.setResizeWeight(SPLITTER_POSITION); + jSplitPane.setBottomComponent(jTextArea); + jSplitPane.setTopComponent(myXMLTreeView); + } + jTextArea.setText(""); + updateTree(""); Util.setUIDesign(); - updateTree(""); } /** @@ -168,9 +199,9 @@ try { myXMLTreeView.init(data); } catch (SAXException se) { - System.err.println(se); + jTextArea.append(se.getMessage()); } catch (IOException ioe) { - System.err.println(ioe); + jTextArea.append(ioe.getMessage()); } } Modified: trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java =================================================================== --- trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java 2008-03-12 16:13:29 UTC (rev 86) +++ trunk/DAVInspector/test/de/dlr/davinspector/http/HTTPTest.java 2008-03-17 15:57:00 UTC (rev 87) @@ -25,7 +25,6 @@ package de.dlr.davinspector.http; -import static org.junit.Assert.fail; import java.util.Calendar; import java.util.Date; @@ -38,27 +37,67 @@ import org.junit.Test; import de.dlr.davinspector.history.AMessage; +import de.dlr.davinspector.history.AMessage.MessageDirection; import de.dlr.davinspector.history.Message; -import de.dlr.davinspector.history.AMessage.MessageDirection; +/** + * TODO: wues_ha: Enter comment! + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ public class HTTPTest { + /** + * + */ + private static int idCounter = 0; + + /** + * + */ private AMessage message; + + /** + * + */ private Date timestamp; + + /** + * + */ private Boolean direction; + + /** + * + */ private String data; - private static int idCounter = 0; + /** + * TODO: wues_ha: Enter comment! + * + * @throws Exception Exception + */ @BeforeClass //once public static void setUpBeforeClass() throws Exception { } + /** + * TODO: wues_ha: Enter comment! + * + * @throws Exception Exception + */ @AfterClass //once public static void tearDownAfterClass() throws Exception { } + /** + * TODO: wues_ha: Enter comment! + * + * @throws Exception Exception + */ @Before public void setUp() throws Exception { idCounter++; @@ -71,20 +110,37 @@ message.setTimestamp(timestamp); } + /** + * TODO: wues_ha: Enter comment! + * + * @throws Exception Exception + */ @After public void tearDown() throws Exception { } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testGetId() { Assert.assertEquals(idCounter, message.getId()); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testGetTimestamp() { Assert.assertEquals(timestamp, message.getTimestamp()); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testSetTimestamp() { Calendar cal = Calendar.getInstance(); @@ -94,11 +150,19 @@ Assert.assertEquals(timestamp, message.getTimestamp()); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testGetMessageDirection() { Assert.assertEquals(MessageDirection.Request, message.getMessageDirection()); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testSetMessageType() { MessageDirection msgDir = message.getMessageDirection(); @@ -111,6 +175,10 @@ Assert.assertEquals(msgDir, message.getMessageDirection()); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testSetMessageDirection() { Boolean toClient; @@ -126,16 +194,28 @@ Assert.assertEquals(msgDir, message.getMessageDirection()); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testGetSize() { Assert.assertEquals(data.length(), message.getSize()); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testGetRawData() { Assert.assertEquals(data, message.getRawData()); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testSetRawData() { String testdata = "Mir lose de Dom in koelle."; @@ -143,34 +223,58 @@ Assert.assertEquals(testdata, message.getRawData()); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testGetMessageHeader() { - fail("Not yet implemented"); + junit.framework.TestCase.fail("Not yet implemented"); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testGetRawHeader() { - fail("Not yet implemented"); + junit.framework.TestCase.fail("Not yet implemented"); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testGetMessageBody() { - fail("Not yet implemented"); + junit.framework.TestCase.fail("Not yet implemented"); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testGetRawBody() { - fail("Not yet implemented"); + junit.framework.TestCase.fail("Not yet implemented"); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testParseMessage() { - fail("Not yet implemented"); + junit.framework.TestCase.fail("Not yet implemented"); } + /** + * TODO: wues_ha: Enter comment! + * + */ @Test public void testIsComplete() { - fail("Not yet implemented"); + junit.framework.TestCase.fail("Not yet implemented"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-12 16:13:36
|
Revision: 86 http://davinspector.svn.sourceforge.net/davinspector/?rev=86&view=rev Author: wuest Date: 2008-03-12 09:13:29 -0700 (Wed, 12 Mar 2008) Log Message: ----------- Added documentation to HTTPMessageParser. Modified Paths: -------------- trunk/DAVInspector/.classpath trunk/DAVInspector/logging.properties trunk/DAVInspector/plugin-config.properties trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java Modified: trunk/DAVInspector/.classpath =================================================================== --- trunk/DAVInspector/.classpath 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/.classpath 2008-03-12 16:13:29 UTC (rev 86) @@ -1,11 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> - <classpathentry exported="true" kind="lib" path="lib/commons-logging.jar"> - <attributes> - <attribute name="javadoc_location" value="jar:platform:/resource/DAVInspector/lib/commons-logging-javadoc.jar!/"/> - </attributes> - </classpathentry> + <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="lib" path="lib/commons-logging.jar"/> + <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: trunk/DAVInspector/logging.properties =================================================================== --- trunk/DAVInspector/logging.properties 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/logging.properties 2008-03-12 16:13:29 UTC (rev 86) @@ -1,8 +1,9 @@ # Add a FileHandler handlers=java.util.logging.FileHandler -# Default global logging level. -.level = ALL +# global +java.util.logging.level=FINE # Describes specific configuration info for the Handlers. -java.util.logging.FileHandler.pattern = log/relay.log -java.util.logging.FileHandler.limit = 50000 -java.util.logging.FileHandler.count = 1 +java.util.logging.FileHandler.level=FINEST +java.util.logging.FileHandler.pattern=log/relay.log +java.util.logging.FileHandler.limit=50000 +java.util.logging.FileHandler.count=1 Modified: trunk/DAVInspector/plugin-config.properties =================================================================== --- trunk/DAVInspector/plugin-config.properties 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/plugin-config.properties 2008-03-12 16:13:29 UTC (rev 86) @@ -1,3 +1,3 @@ -#Fri Feb 29 14:08:56 CET 2008 +#Thu Mar 06 14:38:28 CET 2008 PluginsServer= PluginsClient= Modified: trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/src/de/dlr/davinspector/DAVInspector.java 2008-03-12 16:13:29 UTC (rev 86) @@ -25,6 +25,9 @@ package de.dlr.davinspector; +import java.io.FileInputStream; +import java.io.IOException; + import de.dlr.davinspector.relay.IRelayModel; import de.dlr.davinspector.relay.RelayModel; import de.dlr.davinspector.ui.MainController; @@ -49,6 +52,13 @@ * @param args String[] */ public static void main(String[] args) { + // init java internal logging + try { + FileInputStream file = new FileInputStream("logging.properties"); + java.util.logging.LogManager.getLogManager().readConfiguration(file); + } catch (IOException ioe) { + System.err.println(ioe); + } // TODO: i18n //Locale loc = Locale.getDefault(); Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-03-12 16:13:29 UTC (rev 86) @@ -35,6 +35,11 @@ * @author Jochen Wuest */ public final class Constant { + + /** + * Basis of the hexadecimal number system. + */ + public static final int HEX_RADIX = 16; /** * Main window width. Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-12 16:13:29 UTC (rev 86) @@ -187,7 +187,7 @@ /** * TODO: wues_ha: Enter comment! - * + * @return String */ public String parseMessage() { return ""; Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-12 16:13:29 UTC (rev 86) @@ -107,6 +107,7 @@ public void storeMessage(String data, Boolean toClient, Date timestamp) { //TODO: add decorator dependent on protocol (switch http, ...). + //INFO: idCounter != number of messages HTTPMessageParser message = new HTTPMessageParser(new Message()); message.setMessageDirection(toClient); @@ -124,9 +125,6 @@ } else { myServersideBuffer = carry; } - System.err.println("Complete\n"); - } else { - System.err.println("Not Complete\n"); } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-12 16:13:29 UTC (rev 86) @@ -28,19 +28,30 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import de.dlr.davinspector.common.Constant; import de.dlr.davinspector.history.AMessage; import de.dlr.davinspector.history.AMessageParser; +import de.dlr.davinspector.relay.RelayModel; /** * This class is a very simple approach to parse http messages. - * TODO: Add comments and logging. + * More information: + * HTTP/1.1 RFC 2616 + * HTTP/1.0 RFC 1945 + * * @version $LastChangedRevision$ * @author Jochen Wuest */ public class HTTPMessageParser extends AMessageParser { /** - * + * This expression matches the http request line. + * (METHOD) SPACE (URL) SPACE (VERSION) CRLF + * RFC 2616: Request-Line = Method SP Request-URI SP HTTP-Version CRLF + * TODO: URL scanning not complete. */ private static final String REGEX_HTTP_REQUEST_LINE = "^(\\bUNKNOWN\\b|\\bHEAD\\b|\\bGET\\b|\\bPOST\\b|\\bPUT\\b|" + "\\bDELETE\\b|\\bOPTIONS\\b|\\bTRACE\\b|\\bCONNECT\\b|\\bPROPFIND\\b|\\bPROPPATCH\\b|\\bMKCOL\\b|" @@ -49,37 +60,68 @@ + " (\\bHTTP/1.1\\b|\\bHTTP/1.0\\b|\\bHTTP/0.9\\b){1}\r\n"; /** - * + * This expression matches the http status line. + * (VERSION) SPACE (STATUS-CODE) SPACE (REASON) CRLF + * RFC 2616: Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF */ private static final String REGEX_HTTP_STATUS_LINE = "^(\\bHTTP/1.1\\b|\\bHTTP/1.0\\b|\\bHTTP/0.9\\b){1}" + " ([0-9]{3})" + " ([\\w|-]+)\r\n"; /** - * + * This expression matches an empty line. These empty lines divide a message + * into header and body. If the data is chunk-encoded, the chunks are also divided by an empty line. */ private static final String REGEX_EMPTY_LINE = "\r\n\r\n"; /** - * + * This expression matches the content-length information of a http message. + * Content-length: SPACE* (LENGTH) CRLF */ private static final String REGEX_CONTENT_LENGTH = "Content-length:[ ]*([0-9]+)\r\n"; /** - * Currently no chunk extensions are handled. - * chunk-extension = ( ";" chunk-ext-name [ "=" chunk-ext-val ] ). + * This expression matches the length information of a chunk. + * CRLF (LENGTH-IN-HEX) CRLF + * INFO: Currently no chunk extensions are handled. */ private static final String REGEX_CHUNK_SIZE = "\r\n([0-9a-fA-F]+)\r\n"; /** - * Currently no transfer extensions are handled. + * This expression matches the transfer encoding of a message. + * Transfer-Encoding: SPACE* chunked CRLF + * INFO: Currently no transfer extensions are handled. */ private static final String REGEX_IS_CHUNKED = "Transfer-Encoding:[ ]*chunked\r\n"; + + /** + * Logger, Apache Commons Logging. + */ + private static Log myLogger = LogFactory.getLog(RelayModel.class); - private String method; - private int status = 0; - private String protocolVersion = ""; + /** + * The http request method. + */ + private String myMethod; + + /** + * The http response status code. + */ + private int myStatusCode = 0; + + /** + * Version of the http protocol uesed by the message. + */ + private String myProtocolVersion = ""; + + /** + * <code>True</code> if the message uses chunked encoding. + */ private Boolean isChunked = false; + + /** + * Length of the message body in bytes. + */ private int myContentLength = 0; /** @@ -93,6 +135,7 @@ } /** + * TODO: wues_ha: Enter comment! * */ private void extractHeaderBody() { @@ -107,9 +150,12 @@ * {@inheritDoc} * * @see de.dlr.davinspector.history.AMessageParser#parseMessage() - */ + */ public String parseMessage() { -System.out.println("\n" + myDirection); + myLogger.debug("\n" + myDirection); + + String carryover = ""; + myParsedHeader = ""; myRawHeader = ""; myParsedBody = ""; @@ -119,68 +165,62 @@ Pattern pattern = Pattern.compile(REGEX_HTTP_STATUS_LINE, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(myRawData); if (matcher.find()) { -System.out.println("found status line"); - method = ""; // TODO: set last method - status = Integer.parseInt(matcher.group(2)); - protocolVersion = matcher.group(1); + myLogger.debug("found status line"); + myMethod = ""; // TODO: set last method + myStatusCode = Integer.parseInt(matcher.group(2)); + myProtocolVersion = matcher.group(1); isChunked = isChunked(); myContentLength = getContentLength(); } else { - System.out.println("No status line found."); - return ""; + myLogger.debug("No status line found."); } - } else { Pattern pattern = Pattern.compile(REGEX_HTTP_REQUEST_LINE, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(myRawData); if (matcher.find()) { -System.out.println("found request line"); - method = matcher.group(1); - status = 0; - protocolVersion = matcher.group(3); + myLogger.debug("found request line"); + myMethod = matcher.group(1); + myStatusCode = 0; + myProtocolVersion = matcher.group(3); isChunked = false; myContentLength = getContentLength(); } else { - System.out.println("No request line found."); - return ""; + myLogger.debug("No request line found."); } } -System.out.println("###############"); -System.out.println("Method:" + method); -System.out.println("Status:" + status); -System.out.println("Version:" + protocolVersion); -System.out.println("Len:" + myContentLength); -System.out.println("Chunked:" + isChunked); -System.out.println("###############"); + if (myLogger.isDebugEnabled()) { + myLogger.debug("###############"); + myLogger.debug("Method:" + myMethod); + myLogger.debug("Status:" + myStatusCode); + myLogger.debug("Version:" + myProtocolVersion); + myLogger.debug("Len:" + myContentLength); + myLogger.debug("Chunked:" + isChunked); + myLogger.debug("###############"); + } - // versuchen eine nachricht lesen extractHeaderBody(); - - String carryover = ""; - myParsedHeader = myRawHeader; // Content-length = 0 or no body -> empty body - if (status != HTTPStatusCode.HTTP_MULTISTATUS && (myContentLength == 0 || !hasBody())) { -System.out.println("no body"); + // TODO: && content-encoding != chunked + if (myStatusCode != HTTPStatusCode.HTTP_MULTISTATUS && (myContentLength == 0 || !hasBody())) { + myLogger.debug("no body"); myParsedBody = ""; - carryover = ""; // TODO + carryover = ""; // TODO: myParsingState = true; } else { if (isChunked) { -System.out.println("decode chunk"); + myLogger.debug("decode chunked encoding"); myParsedBody = decodeChunkedEncoding(myRawBody); - carryover = ""; // TODO + carryover = ""; // TODO: if (!myParsingState) { -System.out.println("decode chunk not finished"); - return ""; + myLogger.debug("decoding chunked encoding not finished"); } } else { -System.out.println("normal msg"); + myLogger.debug("normal message"); if (myContentLength > myRawBody.length()) { -System.out.println("early return"); - return ""; + myLogger.debug("normal message not finished"); } myParsedBody = myRawBody.substring(0, myContentLength); carryover = myRawBody.substring(myContentLength, myRawBody.length()); @@ -188,9 +228,7 @@ } } -System.out.println("Body:" + myParsedBody); -System.out.println("Carry:" + carryover); -System.out.println("------------------\n"); + myLogger.debug("Carry:" + carryover + "\n\n"); return carryover; } @@ -204,17 +242,17 @@ */ private Boolean hasBody() { if (myDirection == MessageDirection.Response) { - if (status == HTTPStatusCode.HTTP_CONTINUE - || status == HTTPStatusCode.HTTP_SWITCHING_PROTOCOLS - || status == HTTPStatusCode.HTTP_NO_CONTENT - || status == HTTPStatusCode.HTTP_NOT_MODIFIED) { + if (myStatusCode == HTTPStatusCode.HTTP_CONTINUE + || myStatusCode == HTTPStatusCode.HTTP_SWITCHING_PROTOCOLS + || myStatusCode == HTTPStatusCode.HTTP_NO_CONTENT + || myStatusCode == HTTPStatusCode.HTTP_NOT_MODIFIED) { // status code 1xx, 204, and 304 -> no body return false; } } else { - if (method == HTTPMethod.HTTP_METHOD_GET - || method == HTTPMethod.HTTP_METHOD_HEAD - || method == HTTPMethod.HTTP_METHOD_OPTIONS) { + if (myMethod == HTTPMethod.HTTP_METHOD_GET + || myMethod == HTTPMethod.HTTP_METHOD_HEAD + || myMethod == HTTPMethod.HTTP_METHOD_OPTIONS) { // Method Get, Head, options, ... -> no body return false; } @@ -222,6 +260,12 @@ return true; } + /** + * This method returns the content length of the message body in bytes. + * If no content length information is found, the method returns zero. + * + * @return Integer specifying the length of the message body in byte. + */ private int getContentLength() { Pattern pattern = Pattern.compile(REGEX_CONTENT_LENGTH, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(myRawData); @@ -245,31 +289,55 @@ return false; } + /** + * TODO: wues_ha: Enter comment! + * + * @see RFC 2616: 3.6.1 Chunked Transfer Coding + * Chunked-Body = *chunk + * last-chunk + * trailer + * CRLF + * + * chunk = chunk-size [ chunk-extension ] CRLF + * chunk-data CRLF + * chunk-size = 1*HEX + * last-chunk = 1*("0") [ chunk-extension ] CRLF + * + * @param data String + * @return String + */ private String decodeChunkedEncoding(String data) { - int length = 0; + // size of the current chunk int chunksize = 0; + // number of chunks int parts = 0; + // the decoded content String result = ""; + // the last chunk is empty and has a length of 0 + // have we already read the last chunk? Boolean readEmptyChunk = false; // read chunk-size, chunk-extension (if any) and CRLF + // INFO: chunk-extensions are currently ignored Pattern pattern = Pattern.compile(REGEX_CHUNK_SIZE); Matcher matcher = pattern.matcher(myRawData); while (matcher.find()) { parts++; - // hex umwandlung? - chunksize = Integer.parseInt(matcher.group(1), 16); + // convert content-length value from hex string to int + chunksize = Integer.parseInt(matcher.group(1), Constant.HEX_RADIX); + // the last chunk is empty and has a length of 0 if (chunksize == 0) { readEmptyChunk = true; -System.out.println("LAST CHUNK " + parts); + myLogger.debug("Last chunk: " + parts); } int start = matcher.end(); int stopp = matcher.end() + chunksize; -System.out.println("CHUNK " + parts); result += myRawData.substring(start, stopp); -System.out.println(start + " - " + stopp); + + myLogger.debug("Chunk: " + parts); + myLogger.debug("Chunk from index " + start + " to " + stopp); } - + // if we read the last chunk, the parsing is complete. myParsingState = readEmptyChunk; return result; } Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/ChannelThread.java 2008-03-12 16:13:29 UTC (rev 86) @@ -87,7 +87,7 @@ /** * */ - private IRelayModel myLock = null; + private IRelayModel myRelay = null; /** * @@ -107,7 +107,7 @@ Log logger, List<ChannelThread> connections) { myInputSocket = inputSocket; myOutputSocket = outputSocket; - myLock = relay; + myRelay = relay; myLogger = logger; myConnections = connections; } @@ -126,39 +126,39 @@ try { count = in.read(buffer); while ((count != Constant.EOF) && !isInterrupted()) { - synchronized (myLock) { + synchronized (myRelay) { // TODO: add encoding to configuration and set encoding from configuration - myLock.updateData(new String(buffer, 0, count, "utf-8"), myDirection); + myRelay.updateData(new String(buffer, 0, count, "utf-8"), myDirection); } count = in.read(buffer); } } catch (IOException ioe) { myLogger.error(myThreadName + COLON + ioe.getMessage(), ioe); } finally { - myLogger.info(myThreadName + COLON + "flushing"); + myLogger.debug(myThreadName + COLON + "flushing"); flushOut(); } } catch (IOException ioe) { myLogger.error(myThreadName + ioe.getMessage(), ioe); } - synchronized (myLock) { + synchronized (myRelay) { myDone = true; try { if ((myPeer == null) || myPeer.isDone()) { // if the peer is already closed or has transferred all data, shutdown myInputSocket.close(); myOutputSocket.close(); - myLogger.info(myThreadName + COLON + "closing"); + myLogger.debug(myThreadName + COLON + "closing"); } else { // signal the peer we are done myPeer.interrupt(); - myLogger.info(myThreadName + COLON + "interrupting peer"); + myLogger.debug(myThreadName + COLON + "interrupting peer"); } } catch (IOException ioe) { myLogger.error(myThreadName + COLON + ioe.getMessage(), ioe); } finally { - myLogger.info(myThreadName + COLON + "removing connection"); + myLogger.debug(myThreadName + COLON + "removing connection"); myConnections.remove(this); } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-11 17:39:06 UTC (rev 85) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-03-12 16:13:29 UTC (rev 86) @@ -241,7 +241,7 @@ * @see java.lang.Thread#run() */ public void run() { - myLogger.info("Relay is starting"); + myLogger.debug("Relay is starting"); try { while (!isInterrupted()) { //looping Socket serverSideSocket = serverSocket.accept(); @@ -280,7 +280,7 @@ myLogger.error(ioe.getMessage(), ioe); } finally { cleanup(); - myLogger.info("Relay stopped"); + myLogger.debug("Relay stopped"); } } @@ -292,16 +292,16 @@ * @see de.dlr.davinspector.relay.IRelayModel#stopRelay() */ public void stopRelay() { - myLogger.info("stopping stage 1"); + myLogger.debug("stopping stage 1"); try { this.interrupt(); // this.join(); } catch (SecurityException se) { - myLogger.info(se); + myLogger.debug(se); // } catch (InterruptedException ie) { // myLogger.info(ie); } - myLogger.info("stopping stage 2"); + myLogger.debug("stopping stage 2"); } /** @@ -309,7 +309,7 @@ */ private void cleanup() { synchronized (lock) { - myLogger.info("stopping stage 3"); + myLogger.debug("stopping stage 3"); try { while (connections.size() > 0) { ChannelThread channelThread = (ChannelThread) connections.get(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wu...@us...> - 2008-03-11 17:39:12
|
Revision: 85 http://davinspector.svn.sourceforge.net/davinspector/?rev=85&view=rev Author: wuest Date: 2008-03-11 10:39:06 -0700 (Tue, 11 Mar 2008) Log Message: ----------- Still work on message parser in progress. Modified Paths: -------------- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-10 14:31:00 UTC (rev 84) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessage.java 2008-03-11 17:39:06 UTC (rev 85) @@ -189,8 +189,8 @@ * TODO: wues_ha: Enter comment! * */ - public void parseMessage() { - + public String parseMessage() { + return ""; } /** Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java 2008-03-10 14:31:00 UTC (rev 84) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/AMessageParser.java 2008-03-11 17:39:06 UTC (rev 85) @@ -53,5 +53,5 @@ * * @see de.dlr.davinspector.history.AMessage#parseMessage() */ - public abstract void parseMessage(); + public abstract String parseMessage(); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-10 14:31:00 UTC (rev 84) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-03-11 17:39:06 UTC (rev 85) @@ -112,7 +112,7 @@ message.setMessageDirection(toClient); message.setRawData(data); message.setTimestamp(timestamp); - message.parseMessage(); + String carry = message.parseMessage(); if (message.isComplete()) { // store Message @@ -120,12 +120,13 @@ notifyNewMessage(new MessageEvent(this, message)); // Clear buffer if (toClient) { - myClientsideBuffer = ""; + myClientsideBuffer = carry; } else { - myServersideBuffer = ""; + myServersideBuffer = carry; } + System.err.println("Complete\n"); } else { - System.err.println("Not Complete"); + System.err.println("Not Complete\n"); } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-10 14:31:00 UTC (rev 84) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMessageParser.java 2008-03-11 17:39:06 UTC (rev 85) @@ -1,7 +1,7 @@ /* * HTTPMessageParser.java * - * TODO: wues_ha Enter comment! + * This class is a very simple approach to parse http messages. * * Created: 23.01.2008 Jochen Wuest <joc...@dl...> * Changed: @@ -32,8 +32,8 @@ import de.dlr.davinspector.history.AMessageParser; /** - * TODO: wues_ha: Enter comment! - * + * This class is a very simple approach to parse http messages. + * TODO: Add comments and logging. * @version $LastChangedRevision$ * @author Jochen Wuest */ @@ -42,15 +42,16 @@ /** * */ - private static final String REGEX_HTTP_REQUEST_LINE = "^([UNKNOWN|HEAD|GET|POST|PUT|" - + "DELETE|OPTIONS|TRACE|CONNECT|PROPFIND|PROPPATCH|MKCOL|COPY|MOVE|LOCK|UNLOCK]{1})" - + " (/[\\w|/|.|_|-]*/)" - + " ([HTTP/1.1|HTTP/1.0|HTTP/0.9]{1})\r\n"; + private static final String REGEX_HTTP_REQUEST_LINE = "^(\\bUNKNOWN\\b|\\bHEAD\\b|\\bGET\\b|\\bPOST\\b|\\bPUT\\b|" + + "\\bDELETE\\b|\\bOPTIONS\\b|\\bTRACE\\b|\\bCONNECT\\b|\\bPROPFIND\\b|\\bPROPPATCH\\b|\\bMKCOL\\b|" + + "\\bCOPY\\b|\\bMOVE\\b|\\bLOCK\\b|\\bUNLOCK\\b){1}" + + " ([\\w|/|~|.|_|-]+)" + + " (\\bHTTP/1.1\\b|\\bHTTP/1.0\\b|\\bHTTP/0.9\\b){1}\r\n"; /** * */ - private static final String REGEX_HTTP_STATUS_LINE = "^([HTTP/1.1|HTTP/1.0|HTTP/0.9]+)" + private static final String REGEX_HTTP_STATUS_LINE = "^(\\bHTTP/1.1\\b|\\bHTTP/1.0\\b|\\bHTTP/0.9\\b){1}" + " ([0-9]{3})" + " ([\\w|-]+)\r\n"; @@ -60,14 +61,26 @@ private static final String REGEX_EMPTY_LINE = "\r\n\r\n"; /** + * + */ + private static final String REGEX_CONTENT_LENGTH = "Content-length:[ ]*([0-9]+)\r\n"; + + /** + * Currently no chunk extensions are handled. * chunk-extension = ( ";" chunk-ext-name [ "=" chunk-ext-val ] ). */ - private static final String REGEX_CHUNK = "(\r\n[0-9a-fA-F]+\r\n)"; + private static final String REGEX_CHUNK_SIZE = "\r\n([0-9a-fA-F]+)\r\n"; + + /** + * Currently no transfer extensions are handled. + */ + private static final String REGEX_IS_CHUNKED = "Transfer-Encoding:[ ]*chunked\r\n"; - private String method = ""; + private String method; private int status = 0; private String protocolVersion = ""; private Boolean isChunked = false; + private int myContentLength = 0; /** * Constructor. @@ -77,82 +90,109 @@ public HTTPMessageParser(AMessage aMessage) { super(aMessage); myParsingState = false; - } - + } + /** - * Extracts the body of the message from the raw data. - * - * @param input String containig http packet - * @return String with body + * */ - private String extractMessageBody(String input) { - String result = ""; - - // HTTP/1.1 HTTP/1.0 HTTP/0.9 - // TODO: split input into different HTTP messages - //String[] httpMessages = input.split("HTTP/[1.1|1.0|0.9]{1}"); - - // TODO: nur die erste Nachricht wird angezeigt - //input = httpMessages[0]; - - if (input != null) { - String[] s = input.split(REGEX_EMPTY_LINE); - for (int i = 1; i < s.length; i++) { - result = s[i]; - } - } else { - result = "--empty--"; + private void extractHeaderBody() { + String[] s = myRawData.split(REGEX_EMPTY_LINE); + myRawHeader = s[0]; + for (int i = 1; i < s.length; i++) { + myRawBody += s[i]; } - - // detect and process chunked data - // split the input in the different chunks. - // each chunk starts with the length of the chunk in hex. - String[] lines = result.split(REGEX_CHUNK); - result = ""; - for (int i = 0; i < lines.length; i++) { - result += lines[i]; - } - - return result; } - - /** - * Extracts the header of the message from the raw data. - * - * @param input String containing http packet - * @return String with headers - */ - private String extractMessageHeader(String input) { - if (input != null) { - String[] s = input.split(REGEX_EMPTY_LINE); - return s[0]; - } else { - return "--empty--"; - } - } /** * {@inheritDoc} * * @see de.dlr.davinspector.history.AMessageParser#parseMessage() */ - public void parseMessage() { - // TODO: rest string zur\xFCck ... -System.out.println(myDirection); - // versuchen eine nachricht lesen - myRawHeader = extractMessageHeader(myRawData); - myRawBody = extractMessageBody(myRawData); - myParsedHeader = myRawHeader; - myParsedBody = myRawBody; + public String parseMessage() { +System.out.println("\n" + myDirection); + myParsedHeader = ""; + myRawHeader = ""; + myParsedBody = ""; + myRawBody = ""; if (myDirection == MessageDirection.Response) { - if (isChunked() && hasBody()) { - decodeChunkedEncoding(); + Pattern pattern = Pattern.compile(REGEX_HTTP_STATUS_LINE, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(myRawData); + if (matcher.find()) { +System.out.println("found status line"); + method = ""; // TODO: set last method + status = Integer.parseInt(matcher.group(2)); + protocolVersion = matcher.group(1); + isChunked = isChunked(); + myContentLength = getContentLength(); + } else { + System.out.println("No status line found."); + return ""; } + + } else { + Pattern pattern = Pattern.compile(REGEX_HTTP_REQUEST_LINE, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(myRawData); + if (matcher.find()) { +System.out.println("found request line"); + method = matcher.group(1); + status = 0; + protocolVersion = matcher.group(3); + isChunked = false; + myContentLength = getContentLength(); + } else { + System.out.println("No request line found."); + return ""; + } } + +System.out.println("###############"); +System.out.println("Method:" + method); +System.out.println("Status:" + status); +System.out.println("Version:" + protocolVersion); +System.out.println("Len:" + myContentLength); +System.out.println("Chunked:" + isChunked); +System.out.println("###############"); + + // versuchen eine nachricht lesen + extractHeaderBody(); + + String carryover = ""; + + myParsedHeader = myRawHeader; + + // Content-length = 0 or no body -> empty body + if (status != HTTPStatusCode.HTTP_MULTISTATUS && (myContentLength == 0 || !hasBody())) { +System.out.println("no body"); + myParsedBody = ""; + carryover = ""; // TODO + myParsingState = true; + } else { + if (isChunked) { +System.out.println("decode chunk"); + myParsedBody = decodeChunkedEncoding(myRawBody); + carryover = ""; // TODO + if (!myParsingState) { +System.out.println("decode chunk not finished"); + return ""; + } + } else { +System.out.println("normal msg"); + if (myContentLength > myRawBody.length()) { +System.out.println("early return"); + return ""; + } + myParsedBody = myRawBody.substring(0, myContentLength); + carryover = myRawBody.substring(myContentLength, myRawBody.length()); + myParsingState = true; + } + } +System.out.println("Body:" + myParsedBody); +System.out.println("Carry:" + carryover); +System.out.println("------------------\n"); - myParsingState = true; + return carryover; } /** @@ -171,38 +211,66 @@ // status code 1xx, 204, and 304 -> no body return false; } + } else { + if (method == HTTPMethod.HTTP_METHOD_GET + || method == HTTPMethod.HTTP_METHOD_HEAD + || method == HTTPMethod.HTTP_METHOD_OPTIONS) { + // Method Get, Head, options, ... -> no body + return false; + } } return true; } + private int getContentLength() { + Pattern pattern = Pattern.compile(REGEX_CONTENT_LENGTH, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(myRawData); + if (matcher.find()) { + return Integer.parseInt(matcher.group(1)); + } + return 0; + } + /** * Determines whether the data is chunked or not. * - * @return Boolean Returns true if the data is chunked. + * @return Returns <code>true</code> if the data is chunked. */ private Boolean isChunked() { - // TODO: RFC 2616 14.39 TE / 14.41 Transfer-Encoding - if (myRawHeader.contains("Transfer-Encoding: chunked")) { + Pattern pattern = Pattern.compile(REGEX_IS_CHUNKED, Pattern.CASE_INSENSITIVE); + Matcher matcher = pattern.matcher(myRawData); + if (matcher.find()) { return true; } return false; } - private void decodeChunkedEncoding() { -// length = 0; -// read chunk-size, chunk-extension (if any) and CRLF -// while (chunk-size > 0) { -// read chunk-data and CRLF -// append chunk-data to entity-body -// length = length + chunk-size -// read chunk-size and CRLF -// } -// read entity-header -// while (entity-header not empty) { -// append entity-header to existing header fields -// read entity-header -// } -// Content-Length = length -// Remove "chunked" from Transfer-Encoding + private String decodeChunkedEncoding(String data) { + int length = 0; + int chunksize = 0; + int parts = 0; + String result = ""; + Boolean readEmptyChunk = false; + + // read chunk-size, chunk-extension (if any) and CRLF + Pattern pattern = Pattern.compile(REGEX_CHUNK_SIZE); + Matcher matcher = pattern.matcher(myRawData); + while (matcher.find()) { + parts++; + // hex umwandlung? + chunksize = Integer.parseInt(matcher.group(1), 16); + if (chunksize == 0) { + readEmptyChunk = true; +System.out.println("LAST CHUNK " + parts); + } + int start = matcher.end(); + int stopp = matcher.end() + chunksize; +System.out.println("CHUNK " + parts); + result += myRawData.substring(start, stopp); +System.out.println(start + " - " + stopp); + } + + myParsingState = readEmptyChunk; + return result; } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java 2008-03-10 14:31:00 UTC (rev 84) +++ trunk/DAVInspector/src/de/dlr/davinspector/http/HTTPMethod.java 2008-03-11 17:39:06 UTC (rev 85) @@ -35,26 +35,21 @@ */ public class HTTPMethod { // CHECKSTYLE:OFF - /* - * HTTP methods - */ - public enum HttpMethod { - UNKNOWN, - HEAD, - GET, - POST, - PUT, - DELETE, - OPTIONS, - TRACE, - CONNECT, - PROPFIND, - PROPPATCH, - MKCOL, - COPY, - MOVE, - LOCK, - UNLOCK - } + public static final String HTTP_METHOD_UNKNOWN = "UNKOWN"; + public static final String HTTP_METHOD_HEAD = "HEAD"; + public static final String HTTP_METHOD_GET = "GET"; + public static final String HTTP_METHOD_POST = "POST"; + public static final String HTTP_METHOD_PUT = "PUT"; + public static final String HTTP_METHOD_DELETE = "DELETE"; + public static final String HTTP_METHOD_OPTIONS = "OPTIONS"; + public static final String HTTP_METHOD_TRACE = "TRACE"; + public static final String HTTP_METHOD_CONNECT = "CONNECT"; + public static final String HTTP_METHOD_PROPFIND = "PROPFIND"; + public static final String HTTP_METHOD_PROPPATCH = "PROPPATCH"; + public static final String HTTP_METHOD_MKCOL = "MKCOL"; + public static final String HTTP_METHOD_COPY = "COPY"; + public static final String HTTP_METHOD_MOVE = "MOVE"; + public static final String HTTP_METHOD_LOCK = "LOCK"; + public static final String HTTP_METHOD_UNLOCK = "UNLOCK"; // CHECKSTYLE:ON } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |