|
From: <tre...@us...> - 2007-09-17 22:39:47
|
Revision: 409
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=409&view=rev
Author: trevorolio
Date: 2007-09-17 15:39:50 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
A handy test window for the body editor applet
Added Paths:
-----------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/BodyAppletTestWindow.java
Added: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/BodyAppletTestWindow.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/BodyAppletTestWindow.java (rev 0)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/BodyAppletTestWindow.java 2007-09-17 22:39:50 UTC (rev 409)
@@ -0,0 +1,155 @@
+/* Copyright 2007 Transmutable (http://transmutable.com/)
+
+ 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 com.ogoglio.client.test;
+
+import java.applet.AppletContext;
+import java.applet.AppletStub;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.HashMap;
+
+import com.ogoglio.bodyeditor.BodyEditorApplet;
+import com.ogoglio.client.WebAPIAuthenticator;
+import com.ogoglio.client.WebAPIClientWire;
+import com.ogoglio.client.WebAPIDescriptor;
+import com.ogoglio.util.ArgumentUtils;
+import com.ogoglio.util.PropStorage;
+
+public class BodyAppletTestWindow extends Frame {
+
+ Dimension appDimension = new Dimension(500, 500);
+
+ public BodyEditorApplet applet = null;
+
+ EnvironmentStub clientStub1 = null;
+
+ URI serviceURI = null;
+
+ public BodyAppletTestWindow(URI serviceURI, String authCookie, Dimension appDimension, boolean decorated) {
+ ArgumentUtils.assertNotNull(appDimension);
+ this.appDimension = appDimension;
+ ArgumentUtils.assertNotNull(serviceURI);
+ this.serviceURI = serviceURI;
+
+ setLayout(new BorderLayout());
+ setSize(appDimension);
+ setLocation(30, 50);
+ setResizable(false);
+ if (!decorated) {
+ this.setUndecorated(true);
+ }
+ HashMap parameters1 = new HashMap();
+ parameters1.put("loginCookie", authCookie);
+ parameters1.put("serviceURI", serviceURI.toString());
+
+ clientStub1 = new EnvironmentStub(parameters1);
+ applet = new BodyEditorApplet();
+ applet.setStub(clientStub1);
+ add(applet, BorderLayout.CENTER);
+ }
+
+ private class EnvironmentStub implements AppletStub {
+
+ HashMap parameters = null;
+
+ public EnvironmentStub(HashMap parameters) {
+ this.parameters = parameters;
+ }
+
+ public void appletResize(int width, int height) {
+ }
+
+ public AppletContext getAppletContext() {
+ return null;
+ }
+
+ public URL getCodeBase() {
+ try {
+ return serviceURI.toURL();
+ } catch (MalformedURLException e) {
+ throw new IllegalStateException("Could not convert serviceURI to URL: " + serviceURI);
+ }
+ }
+
+ public URL getDocumentBase() {
+ try {
+ return serviceURI.toURL();
+ } catch (MalformedURLException e) {
+ throw new IllegalStateException("Could not convert serviceURI to URL: " + serviceURI);
+ }
+ }
+
+ public String getParameter(String name) {
+ return (String) parameters.get(name);
+ }
+
+ public boolean isActive() {
+ return true;
+ }
+
+ }
+
+ public void start() {
+ applet.init();
+ applet.start();
+ }
+
+ public void cleanup(){
+ applet.destroy();
+ }
+
+ public static void main(String[] args) {
+ GraphicsEnvironment graphicsEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ GraphicsDevice device = graphicsEnv.getDefaultScreenDevice();
+ Dimension dim = new Dimension(1024, 800);
+ boolean fullScreen = args.length > 0 && "fullscreen".equals(args[0]);
+ if (fullScreen) {
+ dim = new Dimension(device.getDisplayMode().getWidth(), device.getDisplayMode().getWidth());
+ }
+ String serviceURI=null;
+ String loginCookie=null;
+ try {
+ PropStorage ps=new PropStorage();
+ ps.loadPropertySet(PropStorage.BASIC_PROPS);
+ serviceURI = ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseUrl");
+ ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS);
+ WebAPIAuthenticator authenticator = new WebAPIAuthenticator(new WebAPIClientWire(), new WebAPIDescriptor(new URI(serviceURI)), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUser"), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUserPW"));
+ loginCookie = authenticator.getAuthCookie();
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ try {
+ BodyAppletTestWindow test = new BodyAppletTestWindow(new URI(serviceURI), loginCookie, dim, fullScreen);
+ test.setVisible(true);
+ if (fullScreen) {
+ device.setFullScreenWindow(test);
+ }
+ test.start();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|