You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2005/06/04 05:24:08 UTC
svn commit: r179928 - in
/webservices/axis/trunk/java/modules/samples/src/sample:
amazon/amazonSimpleQueueService/ amazon/amazonSimpleQueueService/util/
amazon/common/ amazon/common/conf/ google/common/ google/common/conf/
google/common/resource/ google/common/util/ google/search/ google/spellcheck/
Author: ajith
Date: Fri Jun 3 20:24:06 2005
New Revision: 179928
URL: http://svn.apache.org/viewcvs?rev=179928&view=rev
Log:
Modified the samples. Now they look nice and are functionally sound
Added:
webservices/axis/trunk/java/modules/samples/src/sample/amazon/common/
webservices/axis/trunk/java/modules/samples/src/sample/amazon/common/conf/
webservices/axis/trunk/java/modules/samples/src/sample/google/common/
webservices/axis/trunk/java/modules/samples/src/sample/google/common/conf/
webservices/axis/trunk/java/modules/samples/src/sample/google/common/conf/key.properties
webservices/axis/trunk/java/modules/samples/src/sample/google/common/resource/
webservices/axis/trunk/java/modules/samples/src/sample/google/common/util/
webservices/axis/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java
Removed:
webservices/axis/trunk/java/modules/samples/src/sample/google/search/key.properties
Modified:
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java
webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java
webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java
webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java
webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java
webservices/axis/trunk/java/modules/samples/src/sample/google/search/GUIHandler.java
webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/AsyncPanel.java
webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/FormModel.java
webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/Observer.java
webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SuggestionForm.java
webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/CreateQueue.java Fri Jun 3 20:24:06 2005
@@ -15,7 +15,9 @@
*/
package sample.amazon.amazonSimpleQueueService;
-import org.apache.axis.om.*;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
import org.apache.axis.soap.SOAPFactory;
/**
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/DeleteQueue.java Fri Jun 3 20:24:06 2005
@@ -15,8 +15,8 @@
*/
package sample.amazon.amazonSimpleQueueService;
-import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMNamespace;
import org.apache.axis.soap.SOAPFactory;
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Enqueue.java Fri Jun 3 20:24:06 2005
@@ -15,7 +15,9 @@
*/
package sample.amazon.amazonSimpleQueueService;
-import org.apache.axis.om.*;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
import org.apache.axis.soap.SOAPFactory;
/**
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListMyQueues.java Fri Jun 3 20:24:06 2005
@@ -15,7 +15,9 @@
*/
package sample.amazon.amazonSimpleQueueService;
-import org.apache.axis.om.*;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
import org.apache.axis.soap.SOAPFactory;
/**
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersIn.java Fri Jun 3 20:24:06 2005
@@ -16,11 +16,10 @@
package sample.amazon.amazonSimpleQueueService;
import sample.amazon.amazonSimpleQueueService.util.RunnableCreateQueue;
-import sample.amazon.amazonSimpleQueueService.util.RunnableCreateQueue;
import javax.swing.*;
-import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
/**
* Listeners for relevent Components in the IN operation
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/ListenersOut.java Fri Jun 3 20:24:06 2005
@@ -15,14 +15,17 @@
*/
package sample.amazon.amazonSimpleQueueService;
-import sample.amazon.amazonSimpleQueueService.util.RunnableListMyQueues;
-import sample.amazon.amazonSimpleQueueService.util.RunnableReadQueue;
import sample.amazon.amazonSimpleQueueService.util.RunnableDeleteQueue;
import sample.amazon.amazonSimpleQueueService.util.RunnableListMyQueues;
import sample.amazon.amazonSimpleQueueService.util.RunnableReadQueue;
import javax.swing.*;
-import java.awt.event.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
/**
* This will create the OMElement needed to be used in invokeNonBlocking() method
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/Read.java Fri Jun 3 20:24:06 2005
@@ -15,7 +15,9 @@
*/
package sample.amazon.amazonSimpleQueueService;
-import org.apache.axis.om.*;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMNamespace;
import org.apache.axis.soap.SOAPFactory;
/**
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUICQ.java Fri Jun 3 20:24:06 2005
@@ -15,7 +15,7 @@
*/
package sample.amazon.amazonSimpleQueueService;
-import sample.amazon.amazonSimpleQueueService.AmazonSimpleQueueServiceIn;
+
/**
* @author Saminda Abeyruwan <sa...@opensource.lk>
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/RunGUIRQ.java Fri Jun 3 20:24:06 2005
@@ -15,7 +15,7 @@
*/
package sample.amazon.amazonSimpleQueueService;
-import sample.amazon.amazonSimpleQueueService.AmazonSimpleQueueServiceOut;
+
/**
* @author Saminda Abeyruwan <sa...@opensource.lk>
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/QueueManager.java Fri Jun 3 20:24:06 2005
@@ -23,18 +23,9 @@
public class QueueManager {
protected String getKeyFromPropertyFile() {
-
-
-
Class clazz = new Object().getClass();
InputStream stream = clazz.getResourceAsStream("/sample/amazon/amazonSimpleQueueService/key.properties");
String key = null;
-
-// String userDir = System.getProperty("user.dir");
-
-// String keyPathName = userDir + File.separator + "modules" + File.separator + "sample"
-// + File.separator
-// + "properties";
Properties properties = new Properties();
try {
properties.load(stream);
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableCreateQueue.java Fri Jun 3 20:24:06 2005
@@ -15,25 +15,17 @@
*/
package sample.amazon.amazonSimpleQueueService.util;
-import org.apache.axis.om.OMElement;
+import org.apache.axis.Constants;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
import org.apache.axis.clientapi.Call;
import org.apache.axis.clientapi.Callback;
-import org.apache.axis.addressing.EndpointReference;
-import org.apache.axis.addressing.AddressingConstants;
import org.apache.axis.engine.AxisFault;
-import org.apache.axis.Constants;
-
-import javax.swing.*;
-
+import org.apache.axis.om.OMElement;
import sample.amazon.amazonSimpleQueueService.CreateQueue;
import sample.amazon.amazonSimpleQueueService.Enqueue;
-import sample.amazon.amazonSimpleQueueService.CreateQueue;
-import java.io.File;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
+import javax.swing.*;
/**
* This will create the Excutable code which runs seperately of GUI interations
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableDeleteQueue.java Fri Jun 3 20:24:06 2005
@@ -15,23 +15,16 @@
*/
package sample.amazon.amazonSimpleQueueService.util;
-import org.apache.axis.om.OMElement;
-import org.apache.axis.clientapi.Callback;
-import org.apache.axis.clientapi.Call;
-import org.apache.axis.addressing.EndpointReference;
-import org.apache.axis.addressing.AddressingConstants;
import org.apache.axis.Constants;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.clientapi.Callback;
import org.apache.axis.engine.AxisFault;
-
-import javax.swing.*;
-
-import sample.amazon.amazonSimpleQueueService.DeleteQueue;
+import org.apache.axis.om.OMElement;
import sample.amazon.amazonSimpleQueueService.DeleteQueue;
-import java.io.File;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.util.Properties;
+import javax.swing.*;
/**
* This will create the Excutable code which runs seperately of GUI interations
@@ -75,5 +68,5 @@
e.printStackTrace();
}
}
-
+
}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableListMyQueues.java Fri Jun 3 20:24:06 2005
@@ -15,22 +15,16 @@
*/
package sample.amazon.amazonSimpleQueueService.util;
-import javax.swing.*;
-
-import org.apache.axis.om.OMElement;
-import org.apache.axis.clientapi.Callback;
-import org.apache.axis.clientapi.Call;
-import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.Constants;
import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.clientapi.Callback;
import org.apache.axis.engine.AxisFault;
-import org.apache.axis.Constants;
-import sample.amazon.amazonSimpleQueueService.ListMyQueues;
+import org.apache.axis.om.OMElement;
import sample.amazon.amazonSimpleQueueService.ListMyQueues;
-import java.io.File;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.util.Properties;
+import javax.swing.*;
/**
* This will create the Excutable code which runs seperately of GUI interations
@@ -75,5 +69,5 @@
e.printStackTrace();
}
}
-
+
}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/RunnableReadQueue.java Fri Jun 3 20:24:06 2005
@@ -15,22 +15,16 @@
*/
package sample.amazon.amazonSimpleQueueService.util;
-import javax.swing.*;
-
-import org.apache.axis.om.OMElement;
-import org.apache.axis.clientapi.Callback;
-import org.apache.axis.clientapi.Call;
-import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.Constants;
import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.clientapi.Callback;
import org.apache.axis.engine.AxisFault;
-import org.apache.axis.Constants;
-import sample.amazon.amazonSimpleQueueService.Read;
+import org.apache.axis.om.OMElement;
import sample.amazon.amazonSimpleQueueService.Read;
-import java.io.File;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.util.Properties;
+import javax.swing.*;
/**
* This will create the Excutable code which runs seperately of GUI interations
@@ -72,5 +66,5 @@
e.printStackTrace();
}
}
-
+
}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueCreateQueueCallbackHandler.java Fri Jun 3 20:24:06 2005
@@ -15,8 +15,8 @@
*/
package sample.amazon.amazonSimpleQueueService.util;
-import org.apache.axis.clientapi.Callback;
import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.clientapi.Callback;
import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMNode;
import org.apache.axis.soap.SOAPBody;
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueDeleteQueueCallbackHandler.java Fri Jun 3 20:24:06 2005
@@ -17,9 +17,9 @@
import org.apache.axis.clientapi.AsyncResult;
import org.apache.axis.clientapi.Callback;
-import org.apache.axis.soap.SOAPBody;
import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMNode;
+import org.apache.axis.soap.SOAPBody;
import javax.swing.*;
import java.util.Iterator;
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueEnqueueCallbackHandler.java Fri Jun 3 20:24:06 2005
@@ -15,11 +15,11 @@
*/
package sample.amazon.amazonSimpleQueueService.util;
-import org.apache.axis.clientapi.Callback;
import org.apache.axis.clientapi.AsyncResult;
-import org.apache.axis.soap.SOAPBody;
+import org.apache.axis.clientapi.Callback;
import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMNode;
+import org.apache.axis.soap.SOAPBody;
import javax.swing.*;
import java.util.Iterator;
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueListMyQueuesCallbackHandler.java Fri Jun 3 20:24:06 2005
@@ -17,9 +17,9 @@
import org.apache.axis.clientapi.AsyncResult;
import org.apache.axis.clientapi.Callback;
-import org.apache.axis.soap.SOAPBody;
import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMNode;
+import org.apache.axis.soap.SOAPBody;
import javax.swing.*;
import java.util.Iterator;
Modified: webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/amazon/amazonSimpleQueueService/util/SimpleQueueReadCallbackHandler.java Fri Jun 3 20:24:06 2005
@@ -15,11 +15,12 @@
*/
package sample.amazon.amazonSimpleQueueService.util;
-import org.apache.axis.clientapi.Callback;
import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.clientapi.Callback;
import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMNode;
import org.apache.axis.soap.SOAPBody;
+
import javax.swing.*;
import java.util.Iterator;
/**
Added: webservices/axis/trunk/java/modules/samples/src/sample/google/common/conf/key.properties
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/common/conf/key.properties?rev=179928&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/common/conf/key.properties (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/common/conf/key.properties Fri Jun 3 20:24:06 2005
@@ -0,0 +1,10 @@
+###################################################################################################
+###################### Property file for the google sample ######################################
+###################################################################################################
+#License Key
+#Wed Jun 01 15:28:16 LKT 2005
+google.key=wzdxGcZQFHJ71w7IgCj5ddQGLmODsP9g
+#Google URL
+google.url=api.google.com
+#Google service name
+google.name=/search/beta2
Added: webservices/axis/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java?rev=179928&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java (added)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/common/util/PropertyLoader.java Fri Jun 3 20:24:06 2005
@@ -0,0 +1,62 @@
+package sample.google.common.util;
+
+import java.util.Properties;
+import java.io.InputStream;
+import java.io.IOException;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ *
+ *
+ */
+public class PropertyLoader {
+
+ private static String googleKey;
+ private static String googleEndpointURL;
+ private static String googleEndpointServiceName;
+
+ static{
+ try {
+ Properties prop = new Properties();
+ Class clazz = new Object().getClass();
+ InputStream stream = clazz.getResourceAsStream("/sample/google/common/conf/key.properties");
+ prop.load(stream);
+
+ googleKey = prop.getProperty("google.key");
+ googleEndpointURL = prop.getProperty("google.url");
+ googleEndpointServiceName = prop.getProperty("google.name");
+
+ } catch (IOException e) {
+ System.exit(0);
+ }
+
+ }
+ public static String getGoogleKey() {
+ return googleKey;
+ }
+
+ public static String getGoogleEndpointURL() {
+ return googleEndpointURL;
+ }
+
+ public static String getGoogleEndpointServiceName() {
+ return googleEndpointServiceName;
+ }
+
+ public static void setGoogleKey(String googleKey) {
+ PropertyLoader.googleKey = googleKey;
+ }
+
+}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/search/AsynchronousClient.java Fri Jun 3 20:24:06 2005
@@ -18,6 +18,8 @@
import java.net.URL;
import java.util.Properties;
+import sample.google.common.util.PropertyLoader;
+
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -78,23 +80,7 @@
GUIHandler gui = new GUIHandler();
System.out.println(search);
- prop = new Properties();
-
- Class clazz = new Object().getClass();
- InputStream stream = clazz.getResourceAsStream("/sample/google/search/key.properties");
-
-
-
-
- try {
- prop.load(stream);
- key = prop.getProperty("Key");
- if (key==null) {
- gui.setKey();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
+ key = PropertyLoader.getGoogleKey();
gui.buildFrame();
Thread linkThread = new Thread(page);
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientCallbackHandler.java Fri Jun 3 20:24:06 2005
@@ -70,7 +70,6 @@
* @param result
*/
public void onComplete(AsyncResult result) {
- //System.out.println("Responce message received to the ClientCallbackHandler ...");
AsyncResult myResult = result;
extractDetails(myResult);
}
@@ -89,20 +88,21 @@
OMElement body, operation, elem;
SOAPEnvelope resEnvelope;
- try {
- XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(
- System.out);
- result.getResponseEnvelope().serialize(writer);
- //part.serialize(writer,false);
- writer.flush();
-
- } catch (XMLStreamException e) {
- // System.out.println("Error occured after responce is received");
- e.printStackTrace();
- } catch (FactoryConfigurationError e) {
- //System.out.println("Error occured after responce is received");
- e.printStackTrace();
- }
+// try {
+// XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(
+// System.out);
+// result.getResponseEnvelope().serialize(writer);
+// //part.serialize(writer,false);
+// writer.flush();
+//
+// } catch (XMLStreamException e) {
+// // System.out.println("Error occured after responce is received");
+// e.printStackTrace();
+// } catch (FactoryConfigurationError e) {
+// //System.out.println("Error occured after responce is received");
+// e.printStackTrace();
+// }
+
resEnvelope = result.getResponseEnvelope();
body = resEnvelope.getBody();
operation = body.getFirstElement();
@@ -163,13 +163,10 @@
}
}
snippet = snippet + endHTML;
- //System.out.println(snippet);
-
GUIHandler.showResults(snippet);
}
public void reportError(Exception e) {
- //System.out.println("Error occured after responce is received3");
e.printStackTrace();
}
}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/search/ClientUtil.java Fri Jun 3 20:24:06 2005
@@ -42,21 +42,21 @@
* @return msgContext
*/
public static MessageContext getMessageContext() throws DeploymentException {
- OMNamespace namespace,defNs;
- OMElement operation,part1,part2,part3,part4,part5,part6,part7,part8,part9,part10;
+ OMNamespace defNs;
+ OMElement operation;
String str_ST_index = Integer.toString(AsynchronousClient.StartIndex);
defNs = OMAbstractFactory.getSOAP11Factory().createOMNamespace("", "");
SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = omFactory.getDefaultEnvelope();
- namespace = envelope.declareNamespace(
+ envelope.declareNamespace(
"http://schemas.xmlsoap.org/soap/envelope/", "SOAP-ENV");
- namespace = envelope.declareNamespace(
+ envelope.declareNamespace(
"http://schemas.xmlsoap.org/soap/encoding/", "SOAP-ENC");
- namespace = envelope.declareNamespace(
+ envelope.declareNamespace(
"http://www.w3.org/1999/XMLSchema-instance/", "xsi");
- namespace = envelope.declareNamespace("http://www.w3.org/1999/XMLSchema",
+ envelope.declareNamespace("http://www.w3.org/1999/XMLSchema",
"xsd");
operation = omFactory.createOMElement("doGoogleSearch", "urn:GoogleSearch", "ns1");
@@ -64,55 +64,16 @@
operation.addAttribute("SOAP-ENV:encordingStyle",
"http://schemas.xmlsoap.org/soap/encoding/", null);
- part1 = omFactory.createOMElement("key", defNs);
- part1.addAttribute("xsi:type", "xsd:string", null);
- part1.addChild(omFactory.createText(AsynchronousClient.key));
- //a sample valid key "F0wt5EFQFHKxTs+rl3P+27o6D112BTWd"));
-
- part2 = omFactory.createOMElement("q", defNs);
- part2.addAttribute("xsi:type", "xsd:string", null);
- part2.addChild(omFactory.createText(AsynchronousClient.search));
-
- part3 = omFactory.createOMElement("start", defNs);
- part3.addAttribute("xsi:type", "xsd:int", null);
- part3.addChild(omFactory.createText(str_ST_index));
-
- part4 = omFactory.createOMElement("maxResults", defNs);
- part4.addAttribute("xsi:type", "xsd:int", null);
- part4.addChild(omFactory.createText(AsynchronousClient.maxResults));
-
- part5 = omFactory.createOMElement("filter", defNs);
- part5.addAttribute("xsi:type", "xsd:boolean", null);
- part5.addChild(omFactory.createText("true"));
-
- part6 = omFactory.createOMElement("restrict", defNs);
- part6.addAttribute("xsi:type", "xsd:string", null);
-
- part7 = omFactory.createOMElement("safeSearch", defNs);
- part7.addAttribute("xsi:type", "xsd:boolean", null);
- part7.addChild(omFactory.createText("false"));
-
- part8 = omFactory.createOMElement("lr", defNs);
- part8.addAttribute("xsi:type", "xsd:string", null);
-
- part9 = omFactory.createOMElement("ie", defNs);
- part9.addAttribute("xsi:type", "xsd:string", null);
- part9.addChild(omFactory.createText("latin1"));
-
- part10 = omFactory.createOMElement("oe", defNs);
- part10.addAttribute("xsi:type", "xsd:string", null);
- part10.addChild(omFactory.createText("latin1"));
-
- operation.addChild(part10);
- operation.addChild(part9);
- operation.addChild(part8);
- operation.addChild(part7);
- operation.addChild(part6);
- operation.addChild(part5);
- operation.addChild(part4);
- operation.addChild(part3);
- operation.addChild(part2);
- operation.addChild(part1);
+ operation.addChild(getOMElement(omFactory,defNs,"oe","xsd:string","latin1"));
+ operation.addChild(getOMElement(omFactory,defNs,"ie","xsd:string","latin1"));
+ operation.addChild(getOMElement(omFactory,defNs,"lr","xsd:string",""));
+ operation.addChild(getOMElement(omFactory,defNs,"safeSearch","xsd:boolean","false"));
+ operation.addChild(getOMElement(omFactory,defNs,"restrict","xsd:string",""));
+ operation.addChild(getOMElement(omFactory,defNs,"filter","xsd:boolean","true"));
+ operation.addChild(getOMElement(omFactory,defNs,"maxResults","xsd:int",AsynchronousClient.maxResults));
+ operation.addChild(getOMElement(omFactory,defNs,"start","xsd:int",str_ST_index));
+ operation.addChild(getOMElement(omFactory,defNs,"q","xsd:string",AsynchronousClient.search));
+ operation.addChild(getOMElement(omFactory,defNs,"key","xsd:string",AsynchronousClient.key));
ConfigurationContextFactory fac = new ConfigurationContextFactory();
ConfigurationContext configContext = fac.buildClientEngineContext("doGoogleSearch");
@@ -123,6 +84,13 @@
}
msgContext.setEnvelope(envelope);
return msgContext;
+ }
+
+ private static OMElement getOMElement(OMFactory factory,OMNamespace ns,String elementName,String type,String text){
+ OMElement part = factory.createOMElement(elementName, ns);
+ part.addAttribute("xsi:type", type, null);
+ part.addChild(factory.createText(text));
+ return part;
}
}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/search/GUIHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/search/GUIHandler.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/search/GUIHandler.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/search/GUIHandler.java Fri Jun 3 20:24:06 2005
@@ -1,18 +1,18 @@
/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
+* Copyright 2001-2004 The Apache Software Foundation.
+*
+* 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 sample.google.search;
@@ -26,6 +26,8 @@
import java.awt.*;
import java.io.*;
+import sample.google.common.util.PropertyLoader;
+
/**
* Build and desplay the GUI
* implements both KeyListner and ActionListner
@@ -35,27 +37,27 @@
*
* @author Gayan Asanka (gayan@opensource.lk)
*/
-public class GUIHandler implements KeyListener, ActionListener, Runnable {
+public class GUIHandler implements Runnable {
/**
* Results are desplayed here
*/
- private static JEditorPane text;
+ private static JEditorPane textEditorPane;
/**
- * Query parameters typed here
+ * Query parameters typed here b
*/
private static JTextField textBox;
/**
- * Buttons clicked to view more results and back
+ * Buttons clicked to view more results and backButton
*/
- private static JButton next, back;
+ private static JButton nextButton, backButton;
/**
* Menu commands to set the key and maximum no of results per page
*/
- private static JMenuItem mnuKey, mnuMaxResults;
+ private static JMenuItem keyMenuItem, maxResultsMenuItem;
/**
* Build the GUI using awt and swing components
@@ -64,7 +66,7 @@
JFrame frame;
SpringLayout layout;
JMenuBar menuBar;
- JMenu setMenu;
+ JMenu settingsMenu;
Spring xSpring, ySpring, hSpring, wSpring;
frame = new JFrame("Google Search");
@@ -75,17 +77,25 @@
menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
- setMenu = new JMenu("Set"); // Create Set menu
- menuBar.add(setMenu);
- setMenu.addActionListener(this);
- mnuKey = new JMenuItem("Key");
- mnuMaxResults = new JMenuItem("Result per page");
+ settingsMenu = new JMenu("Settings"); // Create Set menu
+ menuBar.add(settingsMenu);
- setMenu.add(mnuKey);
- setMenu.add(mnuMaxResults);
+ keyMenuItem = new JMenuItem("Key");
+ keyMenuItem.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ setKey();
+ }
+ });
+ settingsMenu.add(keyMenuItem);
+
+ maxResultsMenuItem = new JMenuItem("Result per page");
+ maxResultsMenuItem.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ setMaxResults();
+ }
+ });
+ settingsMenu.add(maxResultsMenuItem);
- mnuKey.addActionListener(this);
- mnuMaxResults.addActionListener(this);
Toolkit theKit = frame.getToolkit(); // Get the window toolkit
Dimension wndSize = theKit.getScreenSize(); // Get screen size
@@ -95,23 +105,42 @@
wndSize.width * 3 / 5, wndSize.height * 3 / 4); // Size
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- next = new JButton("More Results");
- back = new JButton("Previous Page");
- back.setVisible(false);
- text = new JEditorPane();
- text.setEditable(false);
- text.setContentType("text/html");
- text.addHyperlinkListener(new LinkFollower());
+ nextButton = new JButton("More Results");
+ pane.add(nextButton);
+ nextButton.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ processNextButton();
+ }
+ });
+
+ backButton = new JButton("Previous Page");
+ backButton.setVisible(false);
+ pane.add(backButton);
+ backButton.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ processBackButton();
+ }
+ });
- JScrollPane scroll = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ textEditorPane = new JEditorPane();
+ textEditorPane.setEditable(false);
+ textEditorPane.setContentType("text/html");
+ textEditorPane.addHyperlinkListener(new LinkFollower());
+ JScrollPane scroll = new JScrollPane(textEditorPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
pane.add(scroll);
- pane.add(next);
- pane.add(back);
- next.addActionListener(this);
- back.addActionListener(this);
+
+
+
+
textBox = new JTextField();
- textBox.addKeyListener(this);
+ textBox.addKeyListener(new KeyListener(){
+ public void keyPressed(KeyEvent e) {}
+ public void keyReleased(KeyEvent e) {}
+ public void keyTyped(KeyEvent e) {
+ processKeyEvent(e.getKeyChar());
+ }
+ });
pane.add(textBox);
@@ -135,7 +164,7 @@
scrollConstraints.setX(xSpring); // Set the WEST edge constraint
scrollConstraints.setY(ySpring); // Set the NORTH edge constraint
- SpringLayout.Constraints backBtnConstraints = layout.getConstraints(back);
+ SpringLayout.Constraints backBtnConstraints = layout.getConstraints(backButton);
xSpring = Spring.constant(50); // Spring well use for X
ySpring = Spring.constant(480); // Spring well use for Y
wSpring = Spring.constant(200); // Spring well use for width
@@ -145,7 +174,7 @@
backBtnConstraints.setX(xSpring); // Set the WEST edge constraint
backBtnConstraints.setY(ySpring);
- SpringLayout.Constraints nextBtnConstraints = layout.getConstraints(next);
+ SpringLayout.Constraints nextBtnConstraints = layout.getConstraints(nextButton);
xSpring = Spring.constant(250); // Spring well use for X
ySpring = Spring.constant(480); // Spring well use for Y
wSpring = Spring.constant(200); // Spring well use for width
@@ -164,7 +193,7 @@
* @param results
*/
protected static void showResults(String results) {
- text.setText(results);
+ textEditorPane.setText(results);
}
/**
@@ -173,41 +202,30 @@
* store it in the properties file
*/
protected void setKey() {
- File propertyFile;
-
- AsynchronousClient.key = JOptionPane.showInputDialog(null, "Enter the license Key");
- if (AsynchronousClient.key == null) {
- setKey();
- }
- OutputStream propOut;
- try {
- String workingDir = System.getProperty("user.dir");
- propertyFile =
- new File(
- workingDir + File.separator + "samples" + File.separator +
- "/key.properties");
- propOut = new FileOutputStream(propertyFile);
-
- AsynchronousClient.prop.setProperty("gglKey", AsynchronousClient.key);
- AsynchronousClient.prop.store(propOut, "License Key");
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ String key = JOptionPane.showInputDialog(null,"Set the Google Key",PropertyLoader.getGoogleKey());
+ if (key!=null && !key.trim().equals("")){
+ PropertyLoader.setGoogleKey(key);
}
}
+ private void processBackButton(){
+ if (AsynchronousClient.StartIndex != 0) {
+ int i = Integer.parseInt(AsynchronousClient.maxResults);
+ AsynchronousClient.StartIndex = AsynchronousClient.StartIndex - i;
+ if (AsynchronousClient.StartIndex == 0) {
+ backButton.setVisible(false);
+ }
+ AsynchronousClient.doSearch = true;
+ }
+ }
/**
* method keyTyped
* fires when user typing in TextField textBox
* act when detects space and Enter key only
*
- * @param e
+ * @param event
*/
- public void keyTyped(KeyEvent e) {
- System.out.println("inside");
- int event = e.getKeyChar();
-
+ private void processKeyEvent(int event) {
if (event == KeyEvent.VK_SPACE || event == KeyEvent.VK_ENTER) {
AsynchronousClient.search = textBox.getText().trim();
AsynchronousClient.search.trim();
@@ -218,52 +236,28 @@
}
}
- public void keyPressed(KeyEvent e) {
- }
-
- public void keyReleased(KeyEvent s) {
-
- }
- /**
- * method actionPerformed
- * Detects menu click events and btn click events
- * set flags
- * @param e
- */
- public void actionPerformed(ActionEvent e) {
+ private void processNextButton() {
int i;
+ i = Integer.parseInt(AsynchronousClient.maxResults);
+ AsynchronousClient.StartIndex = AsynchronousClient.StartIndex + i;
+ backButton.setVisible(true);
+ AsynchronousClient.doSearch = true;
+ }
- System.out.println("action is " + e.getSource());
- if (e.getSource() == next) {
- i = Integer.parseInt(AsynchronousClient.maxResults);
- AsynchronousClient.StartIndex = AsynchronousClient.StartIndex + i;
- back.setVisible(true);
- AsynchronousClient.doSearch = true;
- }
- if (e.getSource() == back) {
- if (AsynchronousClient.StartIndex != 0) {
- i = Integer.parseInt(AsynchronousClient.maxResults);
- AsynchronousClient.StartIndex = AsynchronousClient.StartIndex - i;
- if (AsynchronousClient.StartIndex == 0) {
- back.setVisible(false);
- }
- AsynchronousClient.doSearch = true;
+ private void setMaxResults() {
+ do {
+ String maxResults =
+ JOptionPane.showInputDialog(null,
+ "Enter the number of maximum results per page (Maximum allowed is 10)",AsynchronousClient.maxResults);
+ if (maxResults==null){
+ break;
+ }else{
+ AsynchronousClient.maxResults=maxResults;
}
- }
- if (e.getSource() == mnuMaxResults) {
- do {
- System.out.println("come to the place");
- AsynchronousClient.maxResults =
- JOptionPane.showInputDialog(null,
- "Enter the number of maximum results per page (Maximum allowed is 10)");
- } while (Integer.parseInt(AsynchronousClient.maxResults) > 10 ||
- Integer.parseInt(AsynchronousClient.maxResults) < 0);
- }
- if (e.getSource() == mnuKey) {
- setKey();
- }
+ } while (Integer.parseInt(AsynchronousClient.maxResults) > 10 ||
+ Integer.parseInt(AsynchronousClient.maxResults) < 0);
}
/**
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/AsyncPanel.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/AsyncPanel.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/AsyncPanel.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/AsyncPanel.java Fri Jun 3 20:24:06 2005
@@ -24,49 +24,73 @@
*/
public class AsyncPanel extends javax.swing.JPanel implements Observer,KeyListener{
FormModel formModel;
- javax.swing.JTextArea textAreaget;
- javax.swing.JTextArea textAreaset;
+ JTextArea writingTextArea;
+ JTextArea displayTextArea;
+ JTextField errorMessageField;
public AsyncPanel()
{
- formModel = new FormModel(this);
- textAreaget = new javax.swing.JTextArea(15,10);
- textAreaset = new javax.swing.JTextArea(15,10);
- JScrollPane scrollPaneGet = new JScrollPane(textAreaget);
- JScrollPane scrollPaneSet = new JScrollPane(textAreaset);
- setPreferredSize(new Dimension(450, 460));
+ GridBagLayout gbLayout = new GridBagLayout();
+ GridBagConstraints constraint = new GridBagConstraints();
+ this.setLayout(gbLayout);
- textAreaget.setText("Enter a String");
- textAreaget.addKeyListener(this);
+ formModel = new FormModel(this);
+ writingTextArea = new JTextArea();
+ writingTextArea.setLineWrap(true);
- this.add(scrollPaneGet,BorderLayout.NORTH);
- this.add(scrollPaneSet,BorderLayout.SOUTH);
+ displayTextArea = new JTextArea();
+ displayTextArea.setEditable(false);
+ displayTextArea.setLineWrap(true);
+
+ errorMessageField = new JTextField();
+ errorMessageField.setEditable(false);
+ errorMessageField.setBackground(Color.LIGHT_GRAY);
+ errorMessageField.setForeground(Color.RED);
+
+ JScrollPane scrollPaneGet = new JScrollPane(writingTextArea);
+ JScrollPane scrollPaneSet = new JScrollPane(displayTextArea);
+
+ writingTextArea.setText("Enter a String");
+ writingTextArea.addKeyListener(this);
+
+ constraint.fill = GridBagConstraints.BOTH;
+ constraint.gridx=0;
+ constraint.weightx=1;
+ constraint.weighty=8;
+ gbLayout.setConstraints(scrollPaneGet,constraint);
+ this.add(scrollPaneGet);
+ gbLayout.setConstraints(scrollPaneSet,constraint);
+ this.add(scrollPaneSet);
+ constraint.weighty=1;
+ gbLayout.setConstraints(errorMessageField,constraint);
+ this.add(errorMessageField);
}
- public void update(String suggestion)
+
+ public void update(String message)
{
- textAreaset.setText(suggestion);
+ displayTextArea.setText(displayTextArea.getText() + " " + message);
+ }
- // put the suggestion string in the reaponse box along with the misspelt word
+ //updates the error message to the error message display area
+ public void updateError(String message) {
+ errorMessageField.setText(message);
}
public void keyPressed(KeyEvent e) {
- //To change body of implemented methods use File | Settings | File Templates.
int key=e.getKeyChar();
- if((key==32)||(key==10)){
- String suggesion=textAreaget.getText().trim();
- //suggesion.trim();
- formModel.doAsyncSpellingSuggestion(suggesion);
+ if((key==KeyEvent.VK_SPACE)||(key==KeyEvent.VK_ENTER)){
+ String[] words=writingTextArea.getText().split("\\s");
+ if (words.length > 0)
+ formModel.doAsyncSpellingSuggestion(words[words.length-1]);
}
}
public void keyReleased(KeyEvent e) {
- //To change body of implemented methods use File | Settings | File Templates.
}
public void keyTyped(KeyEvent e) {
- //To change body of implemented methods use File | Settings | File Templates.
}
}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/FormModel.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/FormModel.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/FormModel.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/FormModel.java Fri Jun 3 20:24:06 2005
@@ -2,6 +2,7 @@
import org.apache.axis.soap.SOAPFactory;
import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.SOAPBody;
import org.apache.axis.om.OMAbstractFactory;
import org.apache.axis.om.OMNamespace;
import org.apache.axis.om.OMElement;
@@ -19,15 +20,19 @@
import java.net.URL;
import java.net.MalformedURLException;
+import sample.google.common.util.PropertyLoader;
+
/**
* class sample.google.spellcheck.FormModel
* This is the Impementation of the Asynchronous Client
* @author Nadana Gunarathna
*
*/
-public class FormModel extends Callback {
+public class FormModel {
Observer observer;
+ private static final String PROTOCOL = "http";
+
public FormModel(Observer observer)
{
this.observer = observer;
@@ -39,133 +44,122 @@
OMNamespace emptyNs=omfactory.createOMNamespace("", null);
OMElement method = omfactory.createOMElement("doSpellingSuggestion", opN);
- //reqEnv.getBody().addChild(method);
+ method.declareNamespace("http://www.w3.org/1999/XMLSchema-instance","xsi");
+ method.declareNamespace("http://www.w3.org/1999/XMLSchema","xsd");
+
+ //reqEnv.getBody().addChild(method);
method.addAttribute("soapenv:encodingStyle","http://schemas.xmlsoap.org/soap/encoding/",null);
OMElement value1 = omfactory.createOMElement("key",emptyNs);
OMElement value2=omfactory.createOMElement("phrase",emptyNs);
value1.addAttribute("xsi:type","xsd:string",null);
value2.addAttribute("xsi:type","xsd:string",null);
- value1.addChild(omfactory.createText(value1, "wzdxGcZQFHJ71w7IgCj5ddQGLmODsP9g"));
+ value1.addChild(omfactory.createText(value1,PropertyLoader.getGoogleKey() ));
value2.addChild(omfactory.createText(value2,word));
method.addChild(value2);
method.addChild(value1);
return method;
}
- private SOAPEnvelope getEnvelope(String word)
- {
- SOAPFactory omfactory=OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope reqEnv=omfactory.getDefaultEnvelope();
- OMNamespace emptyNs=omfactory.createOMNamespace("", null);
- OMNamespace xsi = reqEnv.declareNamespace("http://www.w3.org/1999/XMLSchema-instance","xsi");
- OMNamespace xsd = reqEnv.declareNamespace("http://www.w3.org/1999/XMLSchema","xsd");
- OMNamespace opN = reqEnv.declareNamespace("urn:GoogleSearch","ns1");
- OMElement method = omfactory.createOMElement("doSpellingSuggestion", opN);
- reqEnv.getBody().addChild(method);
- method.addAttribute("soapenv:encodingStyle","http://schemas.xmlsoap.org/soap/encoding/",null);
- OMElement value1 = omfactory.createOMElement("key",emptyNs);
- OMElement value2=omfactory.createOMElement("phrase",emptyNs);
- value1.addAttribute("xsi:type","xsd:string",null);
- value2.addAttribute("xsi:type","xsd:string",null);
- value1.addChild(omfactory.createText(value1, "wzdxGcZQFHJ71w7IgCj5ddQGLmODsP9g"));
- value2.addChild(omfactory.createText(value2,word));
- method.addChild(value2);
- method.addChild(value1);
- return reqEnv;
- }
public void doAsyncSpellingSuggestion(String word)
{
OMElement requestElement = getElement(word);
- System.out.println("Initializing the Client Call....");
Call call = null;
try {
call = new Call();
} catch (AxisFault axisFault) {
- axisFault.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ observer.updateError(axisFault.getMessage());
}
- System.out.println("Setting the Endpointreference ");
URL url = null;
try {
-// url = new URL("http","127.0.0.1",8080,"/search/beta2");
- url = new URL("http","api.google.com","/search/beta2");
+ url = new URL(PROTOCOL,PropertyLoader.getGoogleEndpointURL(),PropertyLoader.getGoogleEndpointServiceName());
} catch (MalformedURLException e) {
-
- e.printStackTrace();
- System.exit(0);
+ observer.updateError(e.getMessage());;
}
call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
- //call.invokeNonBlocking("doGoogleSpellingSugg",requestEnvelop, new ClientCallbackHandler(parent));
try {
- call.invokeNonBlocking("doGoogleSpellingSugg",requestElement,this);
+ call.invokeNonBlocking("doGoogleSpellingSugg",requestElement,new GoogleCallBack(word));
} catch (AxisFault axisFault) {
- axisFault.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ observer.updateError(axisFault.getMessage());
}
}
public void doSyncSpellingSuggestion(String word)
{
- SOAPEnvelope response=null;
- SOAPEnvelope requestEnvelope = getEnvelope(word);
- System.out.println("Initializing the Client Call....");
+ OMElement responseElement=null;
+ OMElement requestElement = getElement(word);
Call call = null;
try {
call = new Call();
} catch (AxisFault axisFault) {
- axisFault.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ observer.updateError(axisFault.getMessage());
}
- System.out.println("Setting the Endpointreference ");
URL url = null;
try {
- url = new URL("http","api.google.com","/search/beta2");
+ url = new URL(PROTOCOL,PropertyLoader.getGoogleEndpointURL(),PropertyLoader.getGoogleEndpointServiceName());
} catch (MalformedURLException e) {
-
- e.printStackTrace();
- System.exit(0);
+ observer.updateError(e.getMessage());
}
call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
try {
- response=(SOAPEnvelope)call.invokeBlocking("doGoogleSpellingSugg",requestEnvelope);
+ responseElement=(OMElement)call.invokeBlocking("doGoogleSpellingSugg",requestElement);
} catch (AxisFault axisFault) {
- axisFault.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ observer.updateError(axisFault.getMessage());
}
- this.getResponse(response);
+ this.getResponseFromElement(responseElement);
}
- public String getResponse(SOAPEnvelope responseEnvelope){
- ////////////////////////////////////////////
- try {
- XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
- responseEnvelope.serialize(writer);
- writer.flush();
- } catch (XMLStreamException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- ////////////////////////////////////////////
- QName qName1 = new QName("urn:GoogleSearch", "doSpellingSuggestionResponse");
- QName qName2 = new QName("urn:GoogleSearch", "return");
- OMElement returnvalue1 = responseEnvelope.getBody().getFirstChildWithName(qName1);
- OMElement val = returnvalue1.getFirstChildWithName(qName2);
- org.apache.axis.om.OMNode omtext = val.getFirstChild();
- String sugession = null;
- sugession = ((org.apache.axis.om.OMText) omtext).getText();
- this.observer.update(sugession);
+ public String getResponseFromElement(OMElement responseElement){
+ OMElement val = responseElement.getFirstElement();
+ String sugession = val.getText();
+ this.observer.update(sugession);
return sugession;
}
- public void onComplete(AsyncResult asyncResult) {
- String sugession = getResponse(asyncResult.getResponseEnvelope());
- this.observer.update(sugession);
- //To change body of implemented methods use File | Settings | File Templates.
+ public String getResponse(SOAPEnvelope responseEnvelope){
+ QName qName1 = new QName("urn:GoogleSearch", "doSpellingSuggestionResponse");
+ QName qName2 = new QName("urn:GoogleSearch", "return");
+ SOAPBody body = responseEnvelope.getBody();
+ if (body.hasFault()) {
+ observer.updateError(body.getFault().getException().getMessage());
+ return null;
+ } else{
+ OMElement val = body.getFirstChildWithName(qName1).getFirstChildWithName(qName2);
+ String sugession = val.getText();
+ if ((sugession==null) ||(sugession.trim().equals(""))){
+ return null;
+ }else{
+ return sugession;
+ }
+
+ }
}
- public void reportError(Exception e) {
- //To change body of implemented methods use File | Settings | File Templates.
+ private class GoogleCallBack extends Callback{
+ private String originalWord;
+ public GoogleCallBack(String originalWord) {
+ this.originalWord = originalWord;
+ }
+
+ public void onComplete(AsyncResult result) {
+ String suggestion = getResponse(result.getResponseEnvelope());
+ if (suggestion==null){
+ observer.update(originalWord);
+ observer.updateError("No suggestions found!");
+ }else{
+ observer.update(suggestion);
+ }
+ }
+
+ public void reportError(Exception e) {
+ observer.updateError(e.getMessage());
+ }
}
+
}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/Observer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/Observer.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/Observer.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/Observer.java Fri Jun 3 20:24:06 2005
@@ -10,5 +10,9 @@
*
*/
public interface Observer {
- public void update(String suggestion);
- }
+ // updates the message to the main test display area
+ public void update(String message);
+
+ //updates the error message to the error message display area
+ public void updateError(String message);
+}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SuggestionForm.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SuggestionForm.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SuggestionForm.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SuggestionForm.java Fri Jun 3 20:24:06 2005
@@ -1,6 +1,7 @@
package sample.google.spellcheck;
import sample.google.spellcheck.AsyncPanel;
+import sample.google.common.util.PropertyLoader;
import javax.swing.*;
import java.awt.*;
@@ -14,43 +15,102 @@
* @author Nadana Gunarathna
*
*/
-public class SuggestionForm extends javax.swing.JFrame implements ActionListener {
- AsyncPanel asyncPanel;
- SyncPanel syncPanel;
+public class SuggestionForm extends javax.swing.JFrame {
+ private AsyncPanel asyncPanel;
+ private SyncPanel syncPanel;
+
+ private JMenuItem syncMenuItem;
+ private JMenuItem asyncMenuItem;
+
public SuggestionForm() throws HeadlessException {
asyncPanel = new AsyncPanel();
syncPanel = new SyncPanel();
+
JMenuBar menuBar;
//Create the menu bar.
menuBar = new JMenuBar();
- JMenu mainMenu = new JMenu("Select");
-
- mainMenu.setMnemonic(KeyEvent.VK_A);
- JMenuItem syncMenuItem = new JMenuItem("Sync Call", KeyEvent.VK_T);
- syncMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
+ JMenu modeMenu = new JMenu("Mode");
+ modeMenu.setMnemonic(KeyEvent.VK_M);
+ syncMenuItem = new JMenuItem("Sync Mode", KeyEvent.VK_S);
+ syncMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
+ syncMenuItem.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ setSyncPanel();
+ }
+ });
+ asyncMenuItem = new JMenuItem("ASync Mode", KeyEvent.VK_A);
+ asyncMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
+ asyncMenuItem.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ setAsyncPanel();
+ }
+ });
+ modeMenu.add(syncMenuItem);
+ modeMenu.add(asyncMenuItem);
+
+ JMenu settingsMenu = new JMenu("Settings");
+ settingsMenu.setMnemonic(KeyEvent.VK_S);
+ JMenuItem googleKeyMenu = new JMenuItem("Google Key",KeyEvent.VK_G);
+ googleKeyMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK));
+ googleKeyMenu.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e) {
+ setKey();
+ }
+ });
+ settingsMenu.add(googleKeyMenu);
- syncMenuItem.addActionListener(this);
- mainMenu.add(syncMenuItem);
+ menuBar.add(modeMenu);
+ menuBar.add(settingsMenu);
this.setJMenuBar(menuBar);
- menuBar.add(mainMenu);
- //this.getContentPane().add(menuBar);
- //this.getContentPane().add(syncPanel);
- this.getContentPane().add(asyncPanel);
+ this.getContentPane().setLayout(new GridLayout(1,1));
+ setAsyncPanel();
+
+
+
}
public static void main(String[] args) {
SuggestionForm form = new SuggestionForm();
- form.setSize(800, 800);
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ form.setLocation(screenSize.width/4,
+ screenSize.height/4);
+ form.setSize(screenSize.width/2,screenSize.height/2);
form.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- form.pack();
+ //form.setResizable(false);
+ //form.pack();
form.show();
}
- public void actionPerformed(ActionEvent e) {
- //To change body of implemented methods use File | Settings | File Templates.
+ private void setAsyncPanel(){
+ this.getContentPane().removeAll();
+ this.getContentPane().add(asyncPanel);
+ this.syncMenuItem.setEnabled(true);
+ this.asyncMenuItem.setEnabled(false);
+ this.getContentPane().repaint();
+ this.setTitle("Google Spell checker - Async Mode");
+ this.show();
+
+ }
+
+ private void setSyncPanel(){
+ this.getContentPane().removeAll();
+ this.getContentPane().add(syncPanel);
+ this.syncMenuItem.setEnabled(false);
+ this.asyncMenuItem.setEnabled(true);
+ this.getContentPane().repaint();
+ this.setTitle("Google Spell checker - Sync Mode");
+ this.show();
}
+
+ private void setKey(){
+ String key = JOptionPane.showInputDialog(this,"Set the Google Key",PropertyLoader.getGoogleKey());
+ if (key!=null && !key.trim().equals("")){
+ PropertyLoader.setGoogleKey(key);
+ }
+ }
+
}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java?rev=179928&r1=179927&r2=179928&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/google/spellcheck/SyncPanel.java Fri Jun 3 20:24:06 2005
@@ -17,41 +17,69 @@
*/
public class SyncPanel extends javax.swing.JPanel implements Observer, ActionListener{
FormModel formModel;
- javax.swing.JTextField tFieldget;
- javax.swing.JTextField tFieldset;
- javax.swing.JButton button;
+ JTextArea writingTextArea;
+ JTextArea displayTextArea;
+ JTextField errorMessageField;
+ JButton sendButton;
+
public SyncPanel()
{
+ GridBagLayout gbLayout = new GridBagLayout();
+ GridBagConstraints constraint = new GridBagConstraints();
+
+// GridLayout layout = new GridLayout();
+// layout.setColumns(1);
+// layout.setRows(3);
+ this.setLayout(gbLayout);
+
formModel = new FormModel(this);
- tFieldget = new javax.swing.JTextField(10);
- tFieldset = new javax.swing.JTextField(10);
- button=new javax.swing.JButton("Send");
- JScrollPane scrollPaneget = new JScrollPane(tFieldget);
- JScrollPane scrollPaneset = new JScrollPane(tFieldset);
-
- setPreferredSize(new Dimension(150, 150));
-
- tFieldget.setText("Enter a String");
-
- this.add(tFieldget,BorderLayout.CENTER );
- this.add(scrollPaneget,BorderLayout.CENTER);
- this.add(button);
- this.add(tFieldset ,BorderLayout.CENTER);
- this.add(scrollPaneset,BorderLayout.CENTER);
- //this.setLayout(new GridLayout(0,1));
- button.addActionListener(this);
+ writingTextArea = new javax.swing.JTextArea();
+ writingTextArea.setLineWrap(true);
+
+ displayTextArea = new javax.swing.JTextArea();
+ displayTextArea.setLineWrap(true);
+ displayTextArea.setEditable(false);
+
+ errorMessageField = new JTextField();
+ errorMessageField.setEditable(false);
+ errorMessageField.setBackground(Color.LIGHT_GRAY);
+ errorMessageField.setForeground(Color.RED);
+
+ sendButton=new javax.swing.JButton("Send");
+ JScrollPane scrollPaneget = new JScrollPane(writingTextArea);
+ JScrollPane scrollPaneset = new JScrollPane(displayTextArea);
+ writingTextArea.setText("Enter a String");
+
+ constraint.fill = GridBagConstraints.BOTH;
+ constraint.gridx=0;
+ constraint.weightx=1;
+ constraint.weighty=8;
+ gbLayout.setConstraints(scrollPaneget,constraint);
+ this.add(scrollPaneget);
+ gbLayout.setConstraints(scrollPaneset,constraint);
+ this.add(scrollPaneset);
+ constraint.weighty=1;
+ gbLayout.setConstraints(sendButton,constraint);
+ this.add(sendButton);
+ gbLayout.setConstraints(errorMessageField,constraint);
+ this.add(errorMessageField);
+
+ sendButton.addActionListener(this);
}
public void update(String suggestion)
{
- tFieldset.setText(suggestion); // put the suggestion string in the reaponse box along with the misspelt word
+ displayTextArea.setText(suggestion);
}
+ //updates the error message to the error message display area
+ public void updateError(String message) {
+ errorMessageField.setText(message);
+ }
public void actionPerformed(ActionEvent e) {
- String str=tFieldget.getText().trim();
+ String str=writingTextArea.getText().trim();
formModel.doSyncSpellingSuggestion(str);
- //formModel.getResponse();
}