]> source.dussan.org Git - vaadin-framework.git/commitdiff
Refactoring terminal
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Tue, 17 Jul 2007 11:27:59 +0000 (11:27 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Tue, 17 Jul 2007 11:27:59 +0000 (11:27 +0000)
svn changeset:1867/svn branch:trunk

33 files changed:
src/com/itmill/toolkit/terminal/gwt/Client.gwt.xml
src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java [new file with mode: 0755]
src/com/itmill/toolkit/terminal/gwt/client/Client.java [deleted file]
src/com/itmill/toolkit/terminal/gwt/client/Paintable.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IAction.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IComponent.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java [deleted file]
src/com/itmill/toolkit/terminal/gwt/server/HttpVariableMap.java [deleted file]
src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java [deleted file]
src/com/itmill/toolkit/terminal/gwt/server/WebBrowserProbe.java [deleted file]

index 19fed850ce839421e7ceb91f6caaf185a9d83df9..71353c526256f04d917f555fb519ba7a48939b77 100644 (file)
@@ -17,6 +17,6 @@
        <stylesheet src="component-themes/collection.css"/>
 
        <!-- Specify the app entry point class.                   -->
-       <entry-point class="com.itmill.toolkit.terminal.gwt.client.Client"/>
+       <entry-point class="com.itmill.toolkit.terminal.gwt.client.ApplicationConnection"/>
   
 </module>
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
new file mode 100755 (executable)
index 0000000..e1c490f
--- /dev/null
@@ -0,0 +1,388 @@
+package com.itmill.toolkit.terminal.gwt.client;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONParser;
+import com.google.gwt.json.client.JSONString;
+import com.google.gwt.json.client.JSONValue;
+import com.google.gwt.user.client.ui.FocusWidget;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.Widget;
+import com.itmill.toolkit.terminal.gwt.client.ui.IContextMenu;
+
+/**
+ * Entry point classes define <code>onModuleLoad()</code>.
+ * 
+ * TODO IDEA: Should be extend Widget here !?!?!
+ */
+public class ApplicationConnection implements EntryPoint {
+
+       private String appUri;
+
+       private HashMap resourcesMap = new HashMap();
+
+       // TODO remove repaintAll until things start to pile up
+       private RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, appUri
+                       + "/UIDL/?repaintAll=1&");
+
+       public Console console;
+
+       private Vector pendingVariables = new Vector();
+
+       private HashMap paintables = new HashMap();
+
+       private WidgetFactory widgetFactory = new DefaultWidgetFactory();
+       
+       private LocaleService locale;
+
+       private IContextMenu contextMenu = null;
+
+       /**
+        * This is the entry point method.
+        */
+       public void onModuleLoad() {
+
+               appUri = getAppUri();
+
+               console = new Console(RootPanel.get("itmtk-loki"));
+
+               console.log("Makin fake UIDL Request to fool servlet of an app init");
+               RequestBuilder rb2 = new RequestBuilder(RequestBuilder.GET, appUri);
+               try {
+                       rb2.sendRequest("", new RequestCallback() {
+
+                               public void onResponseReceived(Request request,
+                                               Response response) {
+                                       console
+                                                       .log("Got fake response... sending initial UIDL request");
+                                       makeUidlRequest("repaintAll=1");
+                               }
+
+                               public void onError(Request request, Throwable exception) {
+                                       // TODO Auto-generated method stub
+
+                               }
+
+                       });
+               } catch (RequestException e1) {
+                       e1.printStackTrace();
+               }
+
+       }
+
+       private native String getAppUri()/*-{
+        return $wnd.itmtk.appUri;
+        }-*/;
+
+       private void makeUidlRequest(String requestData) {
+               console.log("Making UIDL Request with params: " + requestData);
+               rb = new RequestBuilder(RequestBuilder.POST, appUri
+                               + "/UIDL/?requestId=" + (Math.random()) + "&" + requestData);
+               try {
+                       rb.sendRequest(requestData, new RequestCallback() {
+                               public void onError(Request request, Throwable exception) {
+                                       console.error("Got error");
+                               }
+
+                               public void onResponseReceived(Request request,
+                                               Response response) {
+                                       handleReceivedJSONMessage(response);
+                               }
+
+                       });
+
+               } catch (RequestException e) {
+                       console.error(e.getMessage());
+               }
+       }
+
+       private void handleReceivedJSONMessage(Response response) {
+               Date start = new Date();
+               String jsonText = response.getText().substring(3) + "}";
+               System.out.println(jsonText);
+               JSONValue json;
+               try {
+                       json = JSONParser.parse(jsonText);
+               } catch (com.google.gwt.json.client.JSONException e) {
+                       console.log(e.getMessage() + " - Original JSON-text:");
+                       console.log(jsonText);
+                       return;
+               }
+               // Store resources
+               JSONObject resources = (JSONObject) ((JSONObject) json)
+                               .get("resources");
+               for (Iterator i = resources.keySet().iterator(); i.hasNext();) {
+                       String key = (String) i.next();
+                       resourcesMap.put(key, ((JSONString)resources.get(key)).stringValue());
+               }
+               
+               // Store locale data
+               if(((JSONObject)json).containsKey("locales")) {
+                       JSONArray l = (JSONArray) ((JSONObject) json).get("locales");
+                       for(int i=0; i < l.size(); i++)
+                               LocaleService.addLocale((JSONObject) l.get(i));
+               }
+
+               // Process changes
+               JSONArray changes = (JSONArray) ((JSONObject) json).get("changes");
+               for (int i = 0; i < changes.size(); i++) {
+                       try {
+                               UIDL change = new UIDL((JSONArray) changes.get(i));
+                               try {
+                                       console.dirUIDL(change);
+                               } catch (Exception e) {
+                                       console.log(e.getMessage());
+                                       // TODO: dir doesn't work in any browser although it should
+                                       // work (works in hosted mode)
+                                       // it partially did at some part but now broken.
+                               }
+                               UIDL uidl = change.getChildUIDL(0);
+                               Paintable paintable = getPaintable(uidl.getId());
+                               if (paintable != null)
+                                       paintable.updateFromUIDL(uidl, this);
+                               else {
+                                       if (!uidl.getTag().equals("window"))
+                                               throw new IllegalStateException("Received update for "
+                                                               + uidl.getTag()
+                                                               + ", but there is no such paintable ("
+                                                               + uidl.getId() + ") registered yet.");
+                                       Widget window = widgetFactory.createWidget(uidl);
+                                       registerPaintable(uidl.getId(), (Paintable) window);
+                                       ((Paintable) window).updateFromUIDL(uidl, this);
+
+                                       // TODO We should also handle other windows
+                                       RootPanel.get("itmtk-ajax-window").add(window);
+                               }
+
+                       } catch (Throwable e) {
+                               e.printStackTrace();
+                       }
+
+               }
+               long prosessingTime = (new Date().getTime()) - start.getTime();
+               console.log(" Processing time was " + String.valueOf(prosessingTime)
+                               + "ms for " + jsonText.length() + " characters of JSON");
+
+       }
+
+       public void registerPaintable(String id, Paintable paintable) {
+               paintables.put(id, paintable);
+       }
+
+       public Paintable getPaintable(String id) {
+               return (Paintable) paintables.get(id);
+       }
+
+       private void addVariableToQueue(String paintableId, String variableName,
+                       String encodedValue, boolean immediate) {
+               String id = paintableId + "_" + variableName;
+               for (int i = 0; i < pendingVariables.size(); i += 2)
+                       if ((pendingVariables.get(i)).equals(id)) {
+                               pendingVariables.remove(i);
+                               pendingVariables.remove(i);
+                               break;
+                       }
+               pendingVariables.add(id);
+               pendingVariables.add(encodedValue);
+               if (immediate)
+                       sendPendingVariableChanges();
+       }
+
+       public void sendPendingVariableChanges() {
+               StringBuffer req = new StringBuffer();
+
+               for (int i = 0; i < pendingVariables.size(); i++) {
+                       req.append(pendingVariables.get(i++));
+                       req.append("=");
+                       req.append(pendingVariables.get(i));
+                       req.append("&");
+               }
+
+               pendingVariables.clear();
+               makeUidlRequest(req.toString());
+       }
+
+       private String escapeString(String value) {
+               // TODO
+               return value;
+       }
+
+       public void updateVariable(String paintableId, String variableName,
+                       String newValue, boolean immediate) {
+               addVariableToQueue(paintableId, variableName, escapeString(newValue),
+                               immediate);
+       }
+
+       public void updateVariable(String paintableId, String variableName,
+                       int newValue, boolean immediate) {
+               addVariableToQueue(paintableId, variableName, "" + newValue, immediate);
+       }
+
+       public void updateVariable(String paintableId, String variableName,
+                       boolean newValue, boolean immediate) {
+               addVariableToQueue(paintableId, variableName, newValue ? "true"
+                               : "false", immediate);
+       }
+
+       public void updateVariable(String paintableId, String variableName,
+                       Object[] values, boolean immediate) {
+               StringBuffer buf = new StringBuffer();
+               for (int i = 0; i < values.length; i++) {
+                       if (i > 0)
+                               buf.append(",");
+                       buf.append(escapeString(values[i].toString()));
+               }
+               addVariableToQueue("array:" + paintableId, variableName,
+                               buf.toString(), immediate);
+       }
+
+       public WidgetFactory getWidgetFactory() {
+               return widgetFactory;
+       }
+
+       public void setWidgetFactory(WidgetFactory widgetFactory) {
+               this.widgetFactory = widgetFactory;
+       }
+
+       public static Layout getParentLayout(Widget component) {
+               Widget parent = component.getParent();
+               while (parent != null && !(parent instanceof Layout))
+                       parent = parent.getParent();
+               if (parent != null && ((Layout) parent).hasChildComponent(component))
+                       return (Layout) parent;
+               return null;
+       }
+
+       /**
+        * Update generic component features.
+        * 
+        * <h2>Selecting correct implementation</h2>
+        * 
+        * <p>
+        * The implementation of a component depends on many properties, including
+        * styles, component features, etc. Sometimes the user changes those
+        * properties after the component has been created. Calling this method in
+        * the beginning of your updateFromUIDL -method automatically replaces your
+        * component with more appropriate if the requested implementation changes.
+        * </p>
+        * 
+        * <h2>Caption, icon, error messages and description</h2>
+        * 
+        * <p>
+        * Component can delegate management of caption, icon, error messages and
+        * description to parent layout. This is optional an should be decided by
+        * component author
+        * </p>
+        * 
+        * <h2>Component visibility and disabling</h2>
+        * 
+        * This method will manage component visibility automatically and if
+        * component is an instanceof FocusWidget, also handle component disabling
+        * when needed.
+        * 
+        * @param currentWidget
+        *            Current widget that might need replacement
+        * @param uidl
+        *            UIDL to be painted
+        * @param manageCaption
+        *            True if you want to delegate caption, icon, description and
+        *            error message management to parent.
+        * 
+        * @return Returns true iff no further painting is needed by caller
+        */
+       public boolean updateComponent(Widget component, UIDL uidl,
+                       boolean manageCaption) {
+
+               // Switch to correct implementation if neede
+               if (!widgetFactory.isCorrectImplementation(component, uidl)) {
+                       Layout parent = getParentLayout(component);
+                       if (parent != null) {
+                               Widget w = widgetFactory.createWidget(uidl);
+                               registerPaintable(uidl.getId(), (Paintable) w);
+                               parent.replaceChildComponent(component, w);
+                               ((Paintable) w).updateFromUIDL(uidl, this);
+                               return true;
+                       }
+               }
+
+               // Set captions
+               // TODO Manage Error messages
+               if (manageCaption) {
+                       Layout parent = getParentLayout(component);
+                       if (parent != null)
+                               parent.updateCaption(component, uidl);
+               }
+
+               // Visibility, Disabling and read-only status
+               if (component instanceof FocusWidget) {
+                       boolean enabled = true;
+                       if (uidl.hasAttribute("disabled"))
+                               enabled = !uidl.getBooleanAttribute("disabled");
+                       else if (uidl.hasAttribute("readonly"))
+                               enabled = !uidl.getBooleanAttribute("readonly");
+                       ((FocusWidget) component).setEnabled(enabled);
+               } else {
+                       boolean enabled = true;
+                       if (uidl.hasAttribute("disabled"))
+                               enabled = !uidl.getBooleanAttribute("disabled");
+                       if(!enabled)
+                               component.addStyleName("i-disabled");
+                       else
+                               component.removeStyleName("i-disabled");
+               }
+               boolean visible = !uidl.getBooleanAttribute("invisible");
+               component.setVisible(visible);
+               if (!visible)
+                       return true;
+
+               return false;
+       }
+
+       /**
+        * Get either existing or new widget for given UIDL.
+        * 
+        * If corresponding paintable has been previously painted, return it.
+        * Otherwise create and register a new widget from UIDL. Caller must update
+        * the returned widget from UIDL after it has been connected to parent.
+        * 
+        * @param uidl
+        *            UIDL to create widget from.
+        * @return Either existing or new widget corresponding to UIDL.
+        */
+       public Widget getWidget(UIDL uidl) {
+               String id = uidl.getId();
+               Widget w = (Widget) getPaintable(id);
+               if (w != null)
+                       return w;
+               w = widgetFactory.createWidget(uidl);
+               registerPaintable(id, (Paintable) w);
+               return w;
+       }
+       
+       public String getResource(String name) {
+               return (String) resourcesMap.get(name);
+       }
+       
+       /**
+        * Singleton method to get instance of app's context menu.
+        * 
+        * @return IContextMenu object
+        */
+       public IContextMenu getContextMenu() {
+               if(contextMenu  == null) {
+                       contextMenu = new IContextMenu();
+               }
+               return contextMenu;
+       }
+}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Client.java b/src/com/itmill/toolkit/terminal/gwt/client/Client.java
deleted file mode 100755 (executable)
index 02a613f..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-package com.itmill.toolkit.terminal.gwt.client;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Vector;
-
-import com.google.gwt.core.client.EntryPoint;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONParser;
-import com.google.gwt.json.client.JSONString;
-import com.google.gwt.json.client.JSONValue;
-import com.google.gwt.user.client.ui.FocusWidget;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.Widget;
-import com.itmill.toolkit.terminal.gwt.client.ui.IContextMenu;
-
-/**
- * Entry point classes define <code>onModuleLoad()</code>.
- * 
- * TODO IDEA: Should be extend Widget here !?!?!
- */
-public class Client implements EntryPoint {
-
-       private String appUri;
-
-       private HashMap resourcesMap = new HashMap();
-
-       // TODO remove repaintAll until things start to pile up
-       private RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, appUri
-                       + "/UIDL/?repaintAll=1&");
-
-       public Console console;
-
-       private Vector pendingVariables = new Vector();
-
-       private HashMap paintables = new HashMap();
-
-       private WidgetFactory widgetFactory = new DefaultWidgetFactory();
-       
-       private LocaleService locale;
-
-       private IContextMenu contextMenu = null;
-
-       /**
-        * This is the entry point method.
-        */
-       public void onModuleLoad() {
-
-               appUri = getAppUri();
-
-               console = new Console(RootPanel.get("itmtk-loki"));
-
-               console.log("Makin fake UIDL Request to fool servlet of an app init");
-               RequestBuilder rb2 = new RequestBuilder(RequestBuilder.GET, appUri);
-               try {
-                       rb2.sendRequest("", new RequestCallback() {
-
-                               public void onResponseReceived(Request request,
-                                               Response response) {
-                                       console
-                                                       .log("Got fake response... sending initial UIDL request");
-                                       makeUidlRequest("repaintAll=1");
-                               }
-
-                               public void onError(Request request, Throwable exception) {
-                                       // TODO Auto-generated method stub
-
-                               }
-
-                       });
-               } catch (RequestException e1) {
-                       e1.printStackTrace();
-               }
-
-       }
-
-       private native String getAppUri()/*-{
-        return $wnd.itmtk.appUri;
-        }-*/;
-
-       private void makeUidlRequest(String requestData) {
-               console.log("Making UIDL Request with params: " + requestData);
-               rb = new RequestBuilder(RequestBuilder.POST, appUri
-                               + "/UIDL/?requestId=" + (Math.random()) + "&" + requestData);
-               try {
-                       rb.sendRequest(requestData, new RequestCallback() {
-                               public void onError(Request request, Throwable exception) {
-                                       console.error("Got error");
-                               }
-
-                               public void onResponseReceived(Request request,
-                                               Response response) {
-                                       handleReceivedJSONMessage(response);
-                               }
-
-                       });
-
-               } catch (RequestException e) {
-                       console.error(e.getMessage());
-               }
-       }
-
-       private void handleReceivedJSONMessage(Response response) {
-               Date start = new Date();
-               String jsonText = response.getText().substring(3) + "}";
-               System.out.println(jsonText);
-               JSONValue json;
-               try {
-                       json = JSONParser.parse(jsonText);
-               } catch (com.google.gwt.json.client.JSONException e) {
-                       console.log(e.getMessage() + " - Original JSON-text:");
-                       console.log(jsonText);
-                       return;
-               }
-               // Store resources
-               JSONObject resources = (JSONObject) ((JSONObject) json)
-                               .get("resources");
-               for (Iterator i = resources.keySet().iterator(); i.hasNext();) {
-                       String key = (String) i.next();
-                       resourcesMap.put(key, ((JSONString)resources.get(key)).stringValue());
-               }
-               
-               // Store locale data
-               if(((JSONObject)json).containsKey("locales")) {
-                       JSONArray l = (JSONArray) ((JSONObject) json).get("locales");
-                       for(int i=0; i < l.size(); i++)
-                               LocaleService.addLocale((JSONObject) l.get(i));
-               }
-
-               // Process changes
-               JSONArray changes = (JSONArray) ((JSONObject) json).get("changes");
-               for (int i = 0; i < changes.size(); i++) {
-                       try {
-                               UIDL change = new UIDL((JSONArray) changes.get(i));
-                               try {
-                                       console.dirUIDL(change);
-                               } catch (Exception e) {
-                                       console.log(e.getMessage());
-                                       // TODO: dir doesn't work in any browser although it should
-                                       // work (works in hosted mode)
-                                       // it partially did at some part but now broken.
-                               }
-                               UIDL uidl = change.getChildUIDL(0);
-                               Paintable paintable = getPaintable(uidl.getId());
-                               if (paintable != null)
-                                       paintable.updateFromUIDL(uidl, this);
-                               else {
-                                       if (!uidl.getTag().equals("window"))
-                                               throw new IllegalStateException("Received update for "
-                                                               + uidl.getTag()
-                                                               + ", but there is no such paintable ("
-                                                               + uidl.getId() + ") registered yet.");
-                                       Widget window = widgetFactory.createWidget(uidl);
-                                       registerPaintable(uidl.getId(), (Paintable) window);
-                                       ((Paintable) window).updateFromUIDL(uidl, this);
-
-                                       // TODO We should also handle other windows
-                                       RootPanel.get("itmtk-ajax-window").add(window);
-                               }
-
-                       } catch (Throwable e) {
-                               e.printStackTrace();
-                       }
-
-               }
-               long prosessingTime = (new Date().getTime()) - start.getTime();
-               console.log(" Processing time was " + String.valueOf(prosessingTime)
-                               + "ms for " + jsonText.length() + " characters of JSON");
-
-       }
-
-       public void registerPaintable(String id, Paintable paintable) {
-               paintables.put(id, paintable);
-       }
-
-       public Paintable getPaintable(String id) {
-               return (Paintable) paintables.get(id);
-       }
-
-       private void addVariableToQueue(String paintableId, String variableName,
-                       String encodedValue, boolean immediate) {
-               String id = paintableId + "_" + variableName;
-               for (int i = 0; i < pendingVariables.size(); i += 2)
-                       if ((pendingVariables.get(i)).equals(id)) {
-                               pendingVariables.remove(i);
-                               pendingVariables.remove(i);
-                               break;
-                       }
-               pendingVariables.add(id);
-               pendingVariables.add(encodedValue);
-               if (immediate)
-                       sendPendingVariableChanges();
-       }
-
-       public void sendPendingVariableChanges() {
-               StringBuffer req = new StringBuffer();
-
-               for (int i = 0; i < pendingVariables.size(); i++) {
-                       req.append(pendingVariables.get(i++));
-                       req.append("=");
-                       req.append(pendingVariables.get(i));
-                       req.append("&");
-               }
-
-               pendingVariables.clear();
-               makeUidlRequest(req.toString());
-       }
-
-       private String escapeString(String value) {
-               // TODO
-               return value;
-       }
-
-       public void updateVariable(String paintableId, String variableName,
-                       String newValue, boolean immediate) {
-               addVariableToQueue(paintableId, variableName, escapeString(newValue),
-                               immediate);
-       }
-
-       public void updateVariable(String paintableId, String variableName,
-                       int newValue, boolean immediate) {
-               addVariableToQueue(paintableId, variableName, "" + newValue, immediate);
-       }
-
-       public void updateVariable(String paintableId, String variableName,
-                       boolean newValue, boolean immediate) {
-               addVariableToQueue(paintableId, variableName, newValue ? "true"
-                               : "false", immediate);
-       }
-
-       public void updateVariable(String paintableId, String variableName,
-                       Object[] values, boolean immediate) {
-               StringBuffer buf = new StringBuffer();
-               for (int i = 0; i < values.length; i++) {
-                       if (i > 0)
-                               buf.append(",");
-                       buf.append(escapeString(values[i].toString()));
-               }
-               addVariableToQueue("array:" + paintableId, variableName,
-                               buf.toString(), immediate);
-       }
-
-       public WidgetFactory getWidgetFactory() {
-               return widgetFactory;
-       }
-
-       public void setWidgetFactory(WidgetFactory widgetFactory) {
-               this.widgetFactory = widgetFactory;
-       }
-
-       public static Layout getParentLayout(Widget component) {
-               Widget parent = component.getParent();
-               while (parent != null && !(parent instanceof Layout))
-                       parent = parent.getParent();
-               if (parent != null && ((Layout) parent).hasChildComponent(component))
-                       return (Layout) parent;
-               return null;
-       }
-
-       /**
-        * Update generic component features.
-        * 
-        * <h2>Selecting correct implementation</h2>
-        * 
-        * <p>
-        * The implementation of a component depends on many properties, including
-        * styles, component features, etc. Sometimes the user changes those
-        * properties after the component has been created. Calling this method in
-        * the beginning of your updateFromUIDL -method automatically replaces your
-        * component with more appropriate if the requested implementation changes.
-        * </p>
-        * 
-        * <h2>Caption, icon, error messages and description</h2>
-        * 
-        * <p>
-        * Component can delegate management of caption, icon, error messages and
-        * description to parent layout. This is optional an should be decided by
-        * component author
-        * </p>
-        * 
-        * <h2>Component visibility and disabling</h2>
-        * 
-        * This method will manage component visibility automatically and if
-        * component is an instanceof FocusWidget, also handle component disabling
-        * when needed.
-        * 
-        * @param currentWidget
-        *            Current widget that might need replacement
-        * @param uidl
-        *            UIDL to be painted
-        * @param manageCaption
-        *            True if you want to delegate caption, icon, description and
-        *            error message management to parent.
-        * 
-        * @return Returns true iff no further painting is needed by caller
-        */
-       public boolean updateComponent(Widget component, UIDL uidl,
-                       boolean manageCaption) {
-
-               // Switch to correct implementation if neede
-               if (!widgetFactory.isCorrectImplementation(component, uidl)) {
-                       Layout parent = getParentLayout(component);
-                       if (parent != null) {
-                               Widget w = widgetFactory.createWidget(uidl);
-                               registerPaintable(uidl.getId(), (Paintable) w);
-                               parent.replaceChildComponent(component, w);
-                               ((Paintable) w).updateFromUIDL(uidl, this);
-                               return true;
-                       }
-               }
-
-               // Set captions
-               // TODO Manage Error messages
-               if (manageCaption) {
-                       Layout parent = getParentLayout(component);
-                       if (parent != null)
-                               parent.updateCaption(component, uidl);
-               }
-
-               // Visibility, Disabling and read-only status
-               if (component instanceof FocusWidget) {
-                       boolean enabled = true;
-                       if (uidl.hasAttribute("disabled"))
-                               enabled = !uidl.getBooleanAttribute("disabled");
-                       else if (uidl.hasAttribute("readonly"))
-                               enabled = !uidl.getBooleanAttribute("readonly");
-                       ((FocusWidget) component).setEnabled(enabled);
-               } else {
-                       boolean enabled = true;
-                       if (uidl.hasAttribute("disabled"))
-                               enabled = !uidl.getBooleanAttribute("disabled");
-                       if(!enabled)
-                               component.addStyleName("i-disabled");
-                       else
-                               component.removeStyleName("i-disabled");
-               }
-               boolean visible = !uidl.getBooleanAttribute("invisible");
-               component.setVisible(visible);
-               if (!visible)
-                       return true;
-
-               return false;
-       }
-
-       /**
-        * Get either existing or new widget for given UIDL.
-        * 
-        * If corresponding paintable has been previously painted, return it.
-        * Otherwise create and register a new widget from UIDL. Caller must update
-        * the returned widget from UIDL after it has been connected to parent.
-        * 
-        * @param uidl
-        *            UIDL to create widget from.
-        * @return Either existing or new widget corresponding to UIDL.
-        */
-       public Widget getWidget(UIDL uidl) {
-               String id = uidl.getId();
-               Widget w = (Widget) getPaintable(id);
-               if (w != null)
-                       return w;
-               w = widgetFactory.createWidget(uidl);
-               registerPaintable(id, (Paintable) w);
-               return w;
-       }
-       
-       public String getResource(String name) {
-               return (String) resourcesMap.get(name);
-       }
-       
-       /**
-        * Singleton method to get instance of app's context menu.
-        * 
-        * @return IContextMenu object
-        */
-       public IContextMenu getContextMenu() {
-               if(contextMenu  == null) {
-                       contextMenu = new IContextMenu();
-               }
-               return contextMenu;
-       }
-}
index df4ce112cb40a4c0c78eddac743b495839e1e888..4f299465694a920a40d7774afe8f5d16bb2147b0 100644 (file)
@@ -2,5 +2,5 @@ package com.itmill.toolkit.terminal.gwt.client;
 
 public interface Paintable {
 
-       public void updateFromUIDL(UIDL uidl, Client client);
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client);
 }
index 72c834079bf659a325aa6b3dd77a557caad4ce08..2288b746a1d031a5d91498e1762d37438445748c 100644 (file)
@@ -1,7 +1,7 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
 
 import com.google.gwt.user.client.Command;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 
 /**
  *
@@ -56,7 +56,7 @@ interface IActionOwner {
         */
        public IAction[] getActions();
 
-       public Client getClient();
+       public ApplicationConnection getClient();
        
        public String getPaintableId();
 }
\ No newline at end of file
index a4626a3bf87ad37626c3d99397f596696dbd3679..a6b747b5c21e292d473cb96d346f8dd31eb439b0 100644 (file)
@@ -3,7 +3,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 import com.google.gwt.user.client.ui.ClickListener;
 import com.google.gwt.user.client.ui.Widget;
 import com.google.gwt.user.client.ui.Button;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -13,7 +13,7 @@ public class IButton extends Button implements Paintable {
 
        String id;
 
-       Client client;
+       ApplicationConnection client;
 
        public IButton() {
                setStyleName(CLASSNAME);
@@ -27,7 +27,7 @@ public class IButton extends Button implements Paintable {
                });
        }
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
 
                // Ensure correct implementation,
                // but don't let container manage caption etc.
index b5ce2c7b4b9a2613706a49f8736c8c9511e0df98..6092b0cf0a186956b3c18ecb50635f5f1c3af68e 100644 (file)
@@ -1,6 +1,6 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;\r
 \r
-import com.itmill.toolkit.terminal.gwt.client.Client;\r
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;\r
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 public class ICalendar extends IDateField {\r
@@ -14,7 +14,7 @@ public class ICalendar extends IDateField {
                add(date);\r
        }\r
        \r
-       public void updateFromUIDL(UIDL uidl, Client client) {\r
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                super.updateFromUIDL(uidl, client);\r
                date.updateCalendar();\r
        }\r
index 1545c3421bd3c9f99a844f2e46e18a5455fe4e02..016c8affc099b14cdd99dbdf158add60bf325207 100644 (file)
@@ -2,7 +2,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 
 import com.google.gwt.user.client.ui.ClickListener;
 import com.google.gwt.user.client.ui.Widget;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -13,7 +13,7 @@ public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox
 
        boolean immediate;
 
-       Client client;
+       ApplicationConnection client;
 
        public ICheckBox() {
                addClickListener(new ClickListener() {
@@ -27,7 +27,7 @@ public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox
                });
        }
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                
                // Ensure correct implementation
                if (client.updateComponent(this, uidl, false))
index 17a94f91c05d66b874748b9eb2985cc6b2c903ee..fa8ff944a4bfe69a54e641caa29d00b2d0e97efd 100644 (file)
@@ -1,6 +1,6 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;\r
 \r
-import com.itmill.toolkit.terminal.gwt.client.Client;\r
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;\r
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 public class IComponent extends IPanel {\r
@@ -10,7 +10,7 @@ public class IComponent extends IPanel {
                setStyleName("i-component");\r
        }\r
        \r
-       public void updateFromUIDL(UIDL uidl, Client client) {\r
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                super.updateFromUIDL(uidl, client);\r
                setStyleName("i-component");\r
        }\r
index 78d415d32835c8d5d4c7459663e7964048962aac..da0eec5b3747c652a687e89a4949184a9f35858c 100644 (file)
@@ -11,7 +11,7 @@ import com.google.gwt.user.client.ui.HTMLPanel;
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.itmill.toolkit.terminal.gwt.client.CaptionWrapper;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Layout;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
@@ -76,7 +76,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Layout {
        }
 
        /** Update the layout from UIDL */
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
 
                // Client manages general cases
                if (client.updateComponent(this, uidl, false))
@@ -106,7 +106,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Layout {
        }
 
        /** Update implementing HTML-layout if needed. */
-       private void updateHTML(UIDL uidl, Client client) {
+       private void updateHTML(UIDL uidl, ApplicationConnection client) {
 
                // Update only if style has changed
                String newStyle = uidl.getStringAttribute("style");
index 358ef30c2db0abd3d02b56f7b0a04674e8690bf3..931172197ae6bec5a1050cc8f69da226809949bc 100644 (file)
@@ -3,7 +3,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 import java.util.Date;\r
 \r
 import com.google.gwt.user.client.ui.FlowPanel;\r
-import com.itmill.toolkit.terminal.gwt.client.Client;\r
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;\r
 import com.itmill.toolkit.terminal.gwt.client.DateTimeService;\r
 import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException;\r
 import com.itmill.toolkit.terminal.gwt.client.Paintable;\r
@@ -15,7 +15,7 @@ public class IDateField extends FlowPanel implements Paintable {
        \r
        String id;\r
        \r
-       Client client;\r
+       ApplicationConnection client;\r
        \r
        protected boolean immediate;\r
        \r
@@ -47,7 +47,7 @@ public class IDateField extends FlowPanel implements Paintable {
                dts = new DateTimeService();\r
        }\r
        \r
-       public void updateFromUIDL(UIDL uidl, Client client) {\r
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                // Ensure correct implementation and let layout manage caption\r
                if (client.updateComponent(this, uidl, true))\r
                        return;\r
index af8ea46e857719eaa40713fcd0191be41d19507a..5e3679391083d55fc0594cff8c3505ee3549d8c3 100644 (file)
@@ -1,13 +1,13 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
 
 import com.google.gwt.user.client.ui.HTML;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class IEmbedded extends HTML implements Paintable {
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                if(uidl.hasAttribute("type") && uidl.getStringAttribute("type").equals("image")) {
                        setHTML("<img src=\""+ uidl.getStringAttribute("src") +"\"/>");
                } else {
index ecc73fc1924688ee2e423db3e01b77de3c4e596c..260270438ca41b014624c48ea87e2a9fca410b14 100644 (file)
@@ -4,13 +4,13 @@ import java.util.Iterator;
 
 import com.google.gwt.user.client.ui.FlexTable;
 import com.google.gwt.user.client.ui.Widget;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class IGridLayout extends FlexTable implements Paintable {
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                clear();
                if (uidl.hasAttribute("caption"))
                        setTitle(uidl.getStringAttribute("caption"));
index 8e0bf0a1473e9031b43c35de2e793400a9f3350e..d0ef747f31fb6453b4f02ab2329b42ee032bcdfe 100644 (file)
@@ -6,7 +6,7 @@ import java.util.Iterator;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.itmill.toolkit.terminal.gwt.client.CaptionWrapper;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Layout;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
@@ -15,7 +15,7 @@ public class IHorizontalLayout extends HorizontalPanel implements Paintable, Lay
 
        private HashMap componentToWrapper = new HashMap();
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                
                // Ensure correct implementation
                if (client.updateComponent(this, uidl, false))
index dbfff25850adcbf08c56e30066e9f28d6168b927..0ea08a2529be7211eb9bf41fec2cdab9511dbe24 100644 (file)
@@ -1,7 +1,7 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
 
 import com.google.gwt.user.client.ui.HTML;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -18,7 +18,7 @@ public class ILabel extends HTML implements Paintable {
                setStyleName(CLASSNAME);
        }
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
 
                if (client.updateComponent(this, uidl, true))
                        return;
index 8ddf6502c09e274fdbb79191e7b1158c549a5333..884a0ccfea3aa2ebb977fa5a2157170607298e35 100644 (file)
@@ -9,7 +9,7 @@ import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.KeyboardListener;\r
 import com.google.gwt.user.client.ui.Panel;\r
 import com.google.gwt.user.client.ui.Widget;\r
-import com.itmill.toolkit.terminal.gwt.client.Client;\r
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;\r
 import com.itmill.toolkit.terminal.gwt.client.Paintable;\r
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
@@ -17,7 +17,7 @@ abstract class IOptionGroupBase extends Composite implements Paintable, ClickLis
        \r
        public static final String CLASSNAME_OPTION = "i-select-option";\r
 \r
-       Client client;\r
+       ApplicationConnection client;\r
        \r
        String id;\r
        \r
@@ -65,7 +65,7 @@ abstract class IOptionGroupBase extends Composite implements Paintable, ClickLis
                container.add(optionsContainer);\r
        }\r
        \r
-       public void updateFromUIDL(UIDL uidl, Client client) {\r
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                this.client = client;\r
                this.id = uidl.getId();\r
                \r
index 9de0d5112b71d1471586628924660ae8f7ae2648..9118563107dbc4d63abd2bc9bba87cdb6a4bebed 100644 (file)
@@ -4,7 +4,7 @@ import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.Widget;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -12,7 +12,7 @@ public class IPanel extends FlowPanel implements Paintable {
        
        public static final String CLASSNAME = "i-panel";
        
-       Client client;
+       ApplicationConnection client;
        
        String id;
        
@@ -29,7 +29,7 @@ public class IPanel extends FlowPanel implements Paintable {
                content.setStyleName(CLASSNAME+"-content");
        }
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                // Ensure correct implementation
                if (client.updateComponent(this, uidl, false))
                        return;
index 99a1a6b95b3b1cfb60d146559269cfd6d4021b2f..baa8ccadb8ce7bff05c858c06eaf96e7732e4fe1 100644 (file)
@@ -4,7 +4,7 @@ import com.google.gwt.user.client.ui.ClickListener;
 import com.google.gwt.user.client.ui.PopupListener;\r
 import com.google.gwt.user.client.ui.PopupPanel;\r
 import com.google.gwt.user.client.ui.Widget;\r
-import com.itmill.toolkit.terminal.gwt.client.Client;\r
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;\r
 import com.itmill.toolkit.terminal.gwt.client.Paintable;\r
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
@@ -31,7 +31,7 @@ public class IPopupCalendar extends ITextualDate implements Paintable, ClickList
                popup.addPopupListener(this);\r
        }\r
        \r
-       public void updateFromUIDL(UIDL uidl, Client client) {\r
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                super.updateFromUIDL(uidl, client);\r
                calendar.updateCalendar();\r
                calendarToggle.setEnabled(enabled);\r
index f5ac77a1da30f4678496d40b6fbfcbdbded94e99..7a55fc99723bedccd1bf01e2398122a7f022754d 100644 (file)
@@ -19,7 +19,7 @@ import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.ScrollListener;
 import com.google.gwt.user.client.ui.ScrollPanel;
 import com.google.gwt.user.client.ui.Widget;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 import com.itmill.toolkit.terminal.gwt.client.ui.IScrollTable.IScrollTableBody.IScrollTableRow;
@@ -49,7 +49,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
        
        private String[] columnOrder;
        
-       private Client client;
+       private ApplicationConnection client;
        private String paintableId;
        
        private boolean immediate;
@@ -106,7 +106,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                initWidget(panel);
        }
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                if (client.updateComponent(this, uidl, true))
                        return;
 
@@ -1142,7 +1142,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                        return availableCells.size();
                }
 
-               public Client getClient() {
+               public ApplicationConnection getClient() {
                        return client;
                }
 
@@ -1579,7 +1579,7 @@ public class IScrollTable extends Composite implements Paintable, ITable, Scroll
                                return actions;
                        }
 
-                       public Client getClient() {
+                       public ApplicationConnection getClient() {
                                return client;
                        }
 
index 912733cc645c2848be721977a79b6626cdd85ec8..19b005d4e1d4bef54d02d4313b9ed543b671a4a7 100644 (file)
@@ -19,7 +19,7 @@ import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -38,7 +38,7 @@ public class ITablePaging extends Composite implements ITable, Paintable, ClickL
        
        private Map columnOrder = new HashMap();
        
-       private Client client;
+       private ApplicationConnection client;
        private String id;
        
        private boolean immediate = false;
@@ -83,7 +83,7 @@ public class ITablePaging extends Composite implements ITable, Paintable, ClickL
                initWidget(panel);
        }
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                if (client.updateComponent(this, uidl, true))
                        return;
 
index c85a2b4a797f3e381710d03cc1f1d1266c1f8584..c21ba67a3d13aaeb8300bdbcedd97d46a5cbecd3 100644 (file)
@@ -10,7 +10,7 @@ import com.google.gwt.user.client.ui.TabBar;
 import com.google.gwt.user.client.ui.TabListener;
 import com.google.gwt.user.client.ui.TabPanel;
 import com.google.gwt.user.client.ui.Widget;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -20,7 +20,7 @@ public class ITabsheet extends TabPanel implements Paintable {
 
        String id;
 
-       Client client;
+       ApplicationConnection client;
 
        ArrayList tabKeys = new ArrayList();
 
@@ -61,7 +61,7 @@ public class ITabsheet extends TabPanel implements Paintable {
 
        }
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                this.client = client;
                id = uidl.getId();
                
index ca7aef3a0917e2a79147cd46a7b28115f4b8cae0..9bcc8bc5ac80de00f925028fd2a540e1665dc368 100644 (file)
@@ -1,7 +1,7 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;\r
 \r
 import com.google.gwt.user.client.DOM;\r
-import com.itmill.toolkit.terminal.gwt.client.Client;\r
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;\r
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 /**\r
@@ -16,7 +16,7 @@ public class ITextArea extends ITextField {
                super(DOM.createTextArea());\r
        }\r
        \r
-       public void updateFromUIDL(UIDL uidl, Client client) {\r
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                // Call parent renderer explicitly\r
                super.updateFromUIDL(uidl, client);\r
                \r
index e621e3af0dbaff56b1d1c0d2d722cd76dcdaf84d..038777f6f8e2a9e980b1e6a3f7671e89dd8ad4aa 100644 (file)
@@ -6,7 +6,7 @@ import com.google.gwt.user.client.ui.ChangeListener;
 import com.google.gwt.user.client.ui.FocusListener;
 import com.google.gwt.user.client.ui.TextBoxBase;
 import com.google.gwt.user.client.ui.Widget;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -31,7 +31,7 @@ public class ITextField extends TextBoxBase implements
 
        protected String id;
 
-       protected Client client;
+       protected ApplicationConnection client;
 
        private boolean immediate = false;
        
@@ -46,7 +46,7 @@ public class ITextField extends TextBoxBase implements
                addFocusListener(this);
        }
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                this.client = client;
                id = uidl.getId();
                
index f7945f163b0dcae16aea75e71a941efa17726f89..170fd0ac6bf22385613edefa362128bdf8503f24 100644 (file)
@@ -4,7 +4,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 import com.google.gwt.user.client.Timer;\r
 import com.google.gwt.user.client.ui.ChangeListener;\r
 import com.google.gwt.user.client.ui.Widget;\r
-import com.itmill.toolkit.terminal.gwt.client.Client;\r
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;\r
 import com.itmill.toolkit.terminal.gwt.client.DateLocale;\r
 import com.itmill.toolkit.terminal.gwt.client.Paintable;\r
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
@@ -25,7 +25,7 @@ public class ITextualDate extends IDateField implements Paintable, ChangeListene
                add(text);\r
        }\r
        \r
-       public void updateFromUIDL(UIDL uidl, Client client) {\r
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                super.updateFromUIDL(uidl, client);\r
                buildTime();\r
        }\r
index ff05bbb0ea100131df6f9900a62466c978965798..00cedbec0476ded684e7262a2dbf21136b7e4b75 100644 (file)
@@ -7,7 +7,7 @@ import java.util.Set;
 import com.google.gwt.user.client.ui.Tree;
 import com.google.gwt.user.client.ui.TreeItem;
 import com.google.gwt.user.client.ui.TreeListener;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -16,7 +16,7 @@ public class ITree extends Tree implements Paintable {
        public static final String CLASSNAME = "i-tree";
 
        Set selectedIds = new HashSet();
-       Client client;
+       ApplicationConnection client;
        String id;
        private boolean selectable;
        private boolean multiselect;
@@ -26,7 +26,7 @@ public class ITree extends Tree implements Paintable {
                setStyleName(CLASSNAME);
        }
 
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                // Ensure correct implementation and let container manage caption
                if (client.updateComponent(this, uidl, true))
                        return;
@@ -72,7 +72,7 @@ public class ITree extends Tree implements Paintable {
                
                String key;
                
-               public void updateFromUIDL(UIDL uidl, Client client) {
+               public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                        this.setText(uidl.getStringAttribute("caption"));
                        key = uidl.getStringAttribute("key");
                        for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
index abf167a62415686c4e2145ad1977aeb9a9faeada..ac757a1745a3ce642d36df93d0cceefd9abdccfb 100644 (file)
@@ -3,7 +3,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.Tree;
 import com.google.gwt.user.client.ui.VerticalPanel;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -21,7 +21,7 @@ public class IUnknownComponent extends Composite implements Paintable{
                caption.setStyleName("itmtk-unknown-caption");
        }
        
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                setCaption("Client faced an unknown component type. Unrendered UIDL:");
                uidlTree.addItem(uidl.dir());
        }
index 5f5a9c14924f02e3ddc2d1c656c90d1b5018a6e0..4888f16b4be4be2726c5066bf05eaeae82cd2192 100644 (file)
@@ -6,7 +6,7 @@ import java.util.Iterator;
 import com.google.gwt.user.client.ui.VerticalPanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.itmill.toolkit.terminal.gwt.client.CaptionWrapper;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Layout;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
@@ -15,7 +15,7 @@ public class IVerticalLayout extends VerticalPanel implements Paintable, Layout
 
        private HashMap componentToWrapper = new HashMap();
        
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                
                // Ensure correct implementation
                if (client.updateComponent(this, uidl, false))
index b7cf50e86c23ff1cc33288e08144dc1fc9f7d4fe..c6a271f4a6952bd373fcd92f4fb05904f6f2be49 100644 (file)
@@ -1,6 +1,6 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
 
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
@@ -12,7 +12,7 @@ public class IWindow extends IVerticalLayout implements Paintable {
                return theme;
        }
        
-       public void updateFromUIDL(UIDL uidl, Client client) {
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                theme = uidl.getStringAttribute("theme");
                super.updateFromUIDL( uidl,  client);
                com.google.gwt.user.client.Window.setTitle(uidl.getStringAttribute("caption"));
index 62c561b480620e9bd0ecd263b5613d741164c58c..5ba33b7778090b33282ea8799335b7d35f95d542 100644 (file)
@@ -296,7 +296,6 @@ public class ApplicationServlet extends HttpServlet {
                        HttpServletResponse response) throws ServletException, IOException {
 
                // Transformer and output stream for the result
-               HttpVariableMap variableMap = null;
                OutputStream out = response.getOutputStream();
                Application application = null;
                try {
@@ -333,39 +332,7 @@ public class ApplicationServlet extends HttpServlet {
                                        return;
                                }
 
-                               // Gets the variable map
-                               variableMap = getVariableMap(application, request);
-                               if (variableMap == null)
-                                       return;
-
-                               // Change all variables based on request parameters
-                               Map unhandledParameters = variableMap.handleVariables(request,
-                                               application);
-
-                               // Check/handle client side feature checks
-                               WebBrowserProbe
-                                               .handleProbeRequest(request, unhandledParameters);
-
-                               // If rendering mode is not defined or detecting requested
-                               // try to detect it
-                               WebBrowser wb = WebBrowserProbe.getTerminalType(request
-                                               .getSession());
-
-                               boolean detect = false;
-                               if (unhandledParameters.get("renderingMode") != null) {
-                                       detect = ((String) ((Object[]) unhandledParameters
-                                                       .get("renderingMode"))[0]).equals("detect");
-                               }
-                               if (detect) {
-                                       String themeName = application.getTheme();
-                                       if (themeName == null)
-                                               themeName = DEFAULT_THEME;
-                                       if (unhandledParameters.get("theme") != null) {
-                                               themeName = (String) ((Object[]) unhandledParameters
-                                                               .get("theme"))[0];
-                                       }
-                               }
-                       
+                               
                                // Handles the URI if the application is still running
                                if (application.isRunning())
                                        download = handleURI(application, request, response);
@@ -381,21 +348,7 @@ public class ApplicationServlet extends HttpServlet {
                                        // Finds the window within the application
                                        Window window = null;
                                        if (application.isRunning())
-                                               window = getApplicationWindow(request, application,
-                                                               unhandledParameters);
-
-                                       // Handles the unhandled parameters if the application is
-                                       // still running
-                                       if (window != null && unhandledParameters != null
-                                                       && !unhandledParameters.isEmpty()) {
-                                               try {
-                                                       window.handleParameters(unhandledParameters);
-                                               } catch (Throwable t) {
-                                                       application
-                                                                       .terminalError(new ParameterHandlerErrorImpl(
-                                                                                       window, t));
-                                               }
-                                       }
+                                               window = getApplicationWindow(request, application);
 
                                        // Removes application if it has stopped
                                        if (!application.isRunning()) {
@@ -421,24 +374,23 @@ public class ApplicationServlet extends HttpServlet {
 
                                        // Sets terminal type for the window, if not already set
                                        if (window.getTerminal() == null) {
-                                               window.setTerminal(wb);
+                                               // TODO !!!!
+                                               window.setTerminal(new WebBrowser());
                                        }
 
                                        // Finds theme
                                        String themeName = window.getTheme() != null ? window
                                                        .getTheme() : DEFAULT_THEME;
-                                       if (unhandledParameters.get("theme") != null) {
-                                               themeName = (String) ((Object[]) unhandledParameters
-                                                               .get("theme"))[0];
+                                       if (request.getParameter("theme") != null) {
+                                               themeName = request.getParameter("theme");
                                        }
                                        
-                                                                               // Handles resource requests
+                                       // Handles resource requests
                                        if (handleResourceRequest(request, response, themeName))
                                                return;
 
-                                       
                                                writeAjaxPage(request, response, out,
-                                                               unhandledParameters, window, wb, themeName);
+                                                               window, themeName);
                                }
                        }
 
@@ -482,7 +434,7 @@ public class ApplicationServlet extends HttpServlet {
         */
        private void writeAjaxPage(HttpServletRequest request,
                        HttpServletResponse response, OutputStream out,
-                       Map unhandledParameters, Window window, WebBrowser terminalType, String themeName) throws IOException, MalformedURLException {
+                        Window window, String themeName) throws IOException, MalformedURLException {
                response.setContentType("text/html");
                BufferedWriter page = new BufferedWriter(new OutputStreamWriter(out));
 
@@ -521,62 +473,7 @@ public class ApplicationServlet extends HttpServlet {
                                "       <div style=\"position: absolute; right: 5px; top: 5px; color: gray;\"><strong>IT Mill Toolkit 5 Prototype</strong></div>\n" + 
                                "       </body>\n" + 
                                "</html>\n");
-               
-               
-               
-//             Theme t = theme;
-//             Vector themes = new Vector();
-//             themes.add(t);
-//             while (t.getParent() != null) {
-//                     String parentName = t.getParent();
-//                     t = themeSource.getThemeByName(parentName);
-//                     themes.add(t);
-//             }
-//             for (int k = themes.size() - 1; k >= 0; k--) {
-//                     t = (Theme) themes.get(k);
-//                     Collection files = t.getFileNames(terminalType, Theme.MODE_AJAX);
-//                     for (Iterator i = files.iterator(); i.hasNext();) {
-//                             String file = (String) i.next();
-//                             if (file.endsWith(".css"))
-//                                     page.write("<link rel=\"stylesheet\" href=\""
-//                                                     + getResourceLocation(t.getName(),
-//                                                                     new ThemeResource(file))
-//                                                     + "\" type=\"text/css\" />\n");
-//                             else if (file.endsWith(".js")) {
-//                                     page.write("<script src=\"");
-//
-//                                     // TODO remove this and implement behaviour in themes
-//                                     // description.xml files
-//                                     if (file.endsWith("firebug.js")
-//                                                     && !isDebugMode(unhandledParameters)) {
-//                                             file = file.replaceFirst("bug.js", "bugx.js");
-//                                     }
-//                                     page.write(getResourceLocation(t.getName(),
-//                                                     new ThemeResource(file)));
-//                                     page.write("\" type=\"text/javascript\"></script>\n");
-//                             }
-//                     }
-//
-//             }
-
-
-//             page.write("itmill.tmp = new itmill.Client("
-//                             + "document.getElementById('ajax-window')," + "\"" + appUrl
-//                             + "/UIDL/" + "\",\"" + resourcePath
-//                             + ((Theme) themes.get(themes.size() - 1)).getName() + "/"
-//
-//                             + "client/\",document.getElementById('ajax-wait'));\n");
-
-               // TODO Only current theme is registered to the client
-               // for (int k = themes.size() - 1; k >= 0; k--) {
-               // t = (Theme) themes.get(k);
-//             t = theme;
-//             String themeObjName = "itmill.themes."
-//                             + t.getName().substring(0, 1).toUpperCase()
-//                             + t.getName().substring(1);
-//             page.write(" (new " + themeObjName + "(\"" + resourcePath + t.getName()
-//                             + "/\")).registerTo(itmill.tmp);\n");
-               // }
+       
 
                page.close();
        }
@@ -777,37 +674,6 @@ public class ApplicationServlet extends HttpServlet {
                return true;
        }
 
-       /**
-        * Gets the variable map for the session.
-        * 
-        * @param application
-        * @param request
-        *            the HTTP request.
-        * @return the variable map.
-        * 
-        */
-       private static synchronized HttpVariableMap getVariableMap(
-                       Application application, HttpServletRequest request) {
-
-               HttpSession session = request.getSession();
-
-               // Gets the application to variablemap map
-               Map varMapMap = (Map) session.getAttribute(SESSION_ATTR_VARMAP);
-               if (varMapMap == null) {
-                       varMapMap = new WeakHashMap();
-                       session.setAttribute(SESSION_ATTR_VARMAP, varMapMap);
-               }
-
-               // Creates a variable map, if it does not exists.
-               HttpVariableMap variableMap = (HttpVariableMap) varMapMap
-                               .get(application);
-               if (variableMap == null) {
-                       variableMap = new HttpVariableMap();
-                       varMapMap.put(application, variableMap);
-               }
-
-               return variableMap;
-       }
 
        /**
         * Gets the current application URL from request.
@@ -1155,7 +1021,7 @@ public class ApplicationServlet extends HttpServlet {
         *             servlet's normal operation.
         */
        private Window getApplicationWindow(HttpServletRequest request,
-                       Application application, Map params) throws ServletException {
+                       Application application) throws ServletException {
 
                Window window = null;
 
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java b/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java
deleted file mode 100644 (file)
index b92fb9d..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/* *************************************************************************
- IT Mill Toolkit 
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might 
- require purchasing a commercial license from IT Mill Ltd. For guidelines 
- on usage, see licensing-guidelines.html
-
- *************************************************************************
- For more information, contact:
- IT Mill Ltd                           phone: +358 2 4802 7180
- Ruukinkatu 2-4                        fax:   +358 2 4802 7181
- 20540, Turku                          email:  info@itmill.com
- Finland                               company www: www.itmill.com
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
-
-package com.itmill.toolkit.terminal.gwt.server;
-
-import java.io.InputStream;
-
-/**
- * WebAdapter implementation of the UploadStream interface.
- * 
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
-public class HttpUploadStream implements
-               com.itmill.toolkit.terminal.UploadStream {
-
-       /**
-        * Holds value of property variableName.
-        */
-       private String streamName;
-
-       private String contentName;
-
-       private String contentType;
-
-       /**
-        * Holds value of property variableValue.
-        */
-       private InputStream stream;
-
-       /**
-        * Creates a new instance of UploadStreamImpl
-        * 
-        * @param name
-        *            the name of the stream.
-        * @param stream
-        *            the input stream.
-        * @param contentName
-        *            the name of the content.
-        * @param contentType
-        *            the type of the content.
-        */
-       public HttpUploadStream(String name, InputStream stream,
-                       String contentName, String contentType) {
-               this.streamName = name;
-               this.stream = stream;
-               this.contentName = contentName;
-               this.contentType = contentType;
-       }
-
-       /**
-        * Gets the name of the stream.
-        * 
-        * @return the name of the stream.
-        */
-       public String getStreamName() {
-               return this.streamName;
-       }
-
-       /**
-        * Gets the input stream.
-        * 
-        * @return the Input stream.
-        */
-       public InputStream getStream() {
-               return this.stream;
-       }
-
-       /**
-        * Gets the input stream content type.
-        * 
-        * @return the content type of the input stream.
-        */
-       public String getContentType() {
-               return this.contentType;
-       }
-
-       /**
-        * Gets the stream content name. Stream content name usually differs from
-        * the actual stream name. It is used to identify the content of the stream.
-        * 
-        * @return the Name of the stream content.
-        */
-       public String getContentName() {
-               return this.contentName;
-       }
-}
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/HttpVariableMap.java b/src/com/itmill/toolkit/terminal/gwt/server/HttpVariableMap.java
deleted file mode 100644 (file)
index 5fd4407..0000000
+++ /dev/null
@@ -1,791 +0,0 @@
-/* *************************************************************************
- IT Mill Toolkit 
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might 
- require purchasing a commercial license from IT Mill Ltd. For guidelines 
- on usage, see licensing-guidelines.html
-
- *************************************************************************
- For more information, contact:
- IT Mill Ltd                           phone: +358 2 4802 7180
- Ruukinkatu 2-4                        fax:   +358 2 4802 7181
- 20540, Turku                          email:  info@itmill.com
- Finland                               company www: www.itmill.com
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
-
-package com.itmill.toolkit.terminal.gwt.server;
-
-import com.itmill.toolkit.terminal.SystemError;
-import com.itmill.toolkit.terminal.Terminal;
-import com.itmill.toolkit.terminal.UploadStream;
-import com.itmill.toolkit.terminal.VariableOwner;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Enumeration;
-import java.util.WeakHashMap;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.LinkedList;
-import java.util.Iterator;
-
-/**
- * Class implementing the variable mappings.
- * 
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
-public class HttpVariableMap {
-
-       // Id <-> (Owner,Name) mapping
-       private Map idToNameMap = new HashMap();
-
-       private Map idToTypeMap = new HashMap();
-
-       private Map idToOwnerMap = new HashMap();
-
-       private Map idToValueMap = new HashMap();
-
-       private Map ownerToNameToIdMap = new WeakHashMap();
-
-       private Object mapLock = new Object();
-
-       // Id generator
-       private long lastId = 0;
-
-       /**
-        * Converts the string to a supported class.
-        * 
-        * @param type
-        * @param value
-        * @throws java.lang.ClassCastException
-        */
-       private static Object convert(Class type, String value)
-                       throws java.lang.ClassCastException {
-               try {
-
-                       // Boolean typed variables
-                       if (type.equals(Boolean.class))
-                               return new Boolean(!(value.equals("") || value.equals("false")));
-
-                       // Integer typed variables
-                       if (type.equals(Integer.class))
-                               return new Integer(value.trim());
-
-                       // String typed variables
-                       if (type.equals(String.class))
-                               return value;
-
-                       throw new ClassCastException("Unsupported type: " + type.getName());
-               } catch (NumberFormatException e) {
-                       return null;
-               }
-       }
-
-       /**
-        * Registers a new variable.
-        * 
-        * @param name
-        *            the name of the variable.
-        * @param type
-        * @param value
-        * @param owner
-        *            the Listener for variable changes.
-        * 
-        * @return id to assigned for this variable.
-        */
-       public String registerVariable(String name, Class type, Object value,
-                       VariableOwner owner) {
-
-               // Checks that the type of the class is supported
-               if (!(type.equals(Boolean.class) || type.equals(Integer.class)
-                               || type.equals(String.class) || type.equals(String[].class) || type
-                               .equals(UploadStream.class)))
-                       throw new SystemError("Unsupported variable type: "
-                                       + type.getClass());
-
-               synchronized (mapLock) {
-
-                       // Checks if the variable is already mapped
-                       HashMap nameToIdMap = (HashMap) ownerToNameToIdMap.get(owner);
-                       if (nameToIdMap == null) {
-                               nameToIdMap = new HashMap();
-                               ownerToNameToIdMap.put(owner, nameToIdMap);
-                       }
-                       String id = (String) nameToIdMap.get(name);
-
-                       if (id == null) {
-                               // Generates new id and register it
-                               id = "v" + String.valueOf(++lastId);
-                               nameToIdMap.put(name, id);
-                               idToOwnerMap.put(id, new WeakReference(owner));
-                               idToNameMap.put(id, name);
-                               idToTypeMap.put(id, type);
-                       }
-
-                       idToValueMap.put(id, value);
-
-                       return id;
-               }
-       }
-
-       /**
-        * Unregisters the variable.
-        * 
-        * @param name
-        *            the name of the variable.
-        * @param owner
-        *            the Listener for variable changes.
-        */
-       public void unregisterVariable(String name, VariableOwner owner) {
-
-               synchronized (mapLock) {
-
-                       // Gets the id
-                       HashMap nameToIdMap = (HashMap) ownerToNameToIdMap.get(owner);
-                       if (nameToIdMap == null)
-                               return;
-                       String id = (String) nameToIdMap.get(name);
-                       if (id != null)
-                               return;
-
-                       // Removes all the mappings
-                       nameToIdMap.remove(name);
-                       if (nameToIdMap.isEmpty())
-                               ownerToNameToIdMap.remove(owner);
-                       idToNameMap.remove(id);
-                       idToTypeMap.remove(id);
-                       idToValueMap.remove(id);
-                       idToOwnerMap.remove(id);
-
-               }
-       }
-
-       /**
-        * @author IT Mill Ltd.
-        * @version
-        * @VERSION@
-        * @since 3.0
-        */
-       private class ParameterContainer {
-
-               /**
-                * Constructs the mapping: listener to set of listened parameter names.
-                */
-               private HashMap parameters = new HashMap();
-
-               /**
-                * Parameter values.
-                */
-               private HashMap values = new HashMap();
-
-               /**
-                * Multipart parser used for parsing the request.
-                */
-               private ServletMultipartRequest parser = null;
-
-               /**
-                * Name - Value mapping of parameters that are not variables.
-                */
-               private HashMap nonVariables = new HashMap();
-
-               /**
-                * Creates a new parameter container and parse the parameters from the
-                * request using GET, POST and POST/MULTIPART parsing.
-                * 
-                * @param req
-                *            the HTTP request.
-                * @throws IOException
-                *             if the writing failed due to input/output error.
-                */
-               public ParameterContainer(HttpServletRequest req) throws IOException {
-                       // Parse GET / POST parameters
-                       for (Enumeration e = req.getParameterNames(); e.hasMoreElements();) {
-                               String paramName = (String) e.nextElement();
-                               String[] paramValues = req.getParameterValues(paramName);
-                               addParam(paramName, paramValues);
-                       }
-
-                       // Parse multipart variables
-                       try {
-                               parser = new ServletMultipartRequest(req,
-                                               MultipartRequest.MAX_READ_BYTES);
-                       } catch (IllegalArgumentException ignored) {
-                               parser = null;
-                       }
-
-                       if (parser != null) {
-                               for (Enumeration e = parser.getFileParameterNames(); e
-                                               .hasMoreElements();) {
-                                       String paramName = (String) e.nextElement();
-                                       addParam(paramName, null);
-                               }
-                               for (Enumeration e = parser.getParameterNames(); e
-                                               .hasMoreElements();) {
-                                       String paramName = (String) e.nextElement();
-                                       Enumeration val = parser.getURLParameters(paramName);
-
-                                       // Create a linked list from enumeration to calculate
-                                       // elements
-                                       LinkedList l = new LinkedList();
-                                       while (val.hasMoreElements())
-                                               l.addLast(val.nextElement());
-
-                                       // String array event constructor
-                                       String[] s = new String[l.size()];
-                                       Iterator i = l.iterator();
-                                       for (int j = 0; j < s.length; j++)
-                                               s[j] = (String) i.next();
-
-                                       addParam(paramName, s);
-                               }
-                       }
-
-               }
-
-               /**
-                * Adds the parameter to container.
-                * 
-                * @param name
-                *            the name of the parameter.
-                * @param value
-                */
-               private void addParam(String name, String[] value) {
-
-                       // Support name="set:name=value" value="ignored" notation
-                       if (name.startsWith("set:")) {
-                               int equalsIndex = name.indexOf('=');
-                               value[0] = name.substring(equalsIndex + 1, name.length());
-                               name = name.substring(4, equalsIndex);
-                               String[] curVal = (String[]) values.get(name);
-                               if (curVal != null) {
-                                       String[] newVal = new String[1 + curVal.length];
-                                       newVal[curVal.length] = value[0];
-                                       for (int i = 0; i < curVal.length; i++)
-                                               newVal[i] = curVal[i];
-                                       value = newVal;
-
-                                       // Special case - if the set:-method is used for
-                                       // declaring array of length 2, where either of the
-                                       // following conditions are true:
-                                       // - the both items are the same
-                                       // - the both items have the same length and
-                                       // - the items only differ on last character
-                                       // - second last character is '.'
-                                       // - last char of one string is 'x' and other is 'y'
-                                       // Browser is unporposely modifying the name.
-                                       if (value.length == 2
-                                                       && value[0].length() == value[1].length()) {
-                                               boolean same = true;
-                                               for (int i = 0; i < value[0].length() - 1 && same; i++)
-                                                       if (value[0].charAt(i) != value[1].charAt(i))
-                                                               same = false;
-                                               if (same
-                                                               && ((value[0].charAt(value[0].length() - 1) == 'x' && value[1]
-                                                                               .charAt(value[1].length() - 1) == 'y') || (value[0]
-                                                                               .charAt(value[0].length() - 1) == 'y' && value[1]
-                                                                               .charAt(value[1].length() - 1) == 'x'))) {
-                                                       value = new String[] { value[0].substring(0,
-                                                                       value[1].length() - 2) };
-                                               } else if (same && value[0].equals(value[1]))
-                                                       value = new String[] { value[0] };
-                                       }
-
-                                       // Special case - if the set:-method is used for
-                                       // declaring array of length 3, where all of the
-                                       // following conditions are true:
-                                       // - two last items have the same length
-                                       // - the first item is 2 chars shorter
-                                       // - the longer items only differ on last character
-                                       // - the shortest item is a prefix of the longer ones
-                                       // - second last character of longer ones is '.'
-                                       // - last char of one long string is 'x' and other is 'y'
-                                       // Browser is unporposely modifying the name. (Mozilla,
-                                       // Firefox, ..)
-                                       if (value.length == 3
-                                                       && value[1].length() == value[2].length()
-                                                       && value[0].length() + 2 == value[1].length()) {
-                                               boolean same = true;
-                                               for (int i = 0; i < value[1].length() - 1 && same; i++)
-                                                       if (value[2].charAt(i) != value[1].charAt(i))
-                                                               same = false;
-                                               for (int i = 0; i < value[0].length() && same; i++)
-                                                       if (value[0].charAt(i) != value[1].charAt(i))
-                                                               same = false;
-                                               if (same
-                                                               && (value[2].charAt(value[2].length() - 1) == 'x' && value[1]
-                                                                               .charAt(value[1].length() - 1) == 'y')
-                                                               || (value[2].charAt(value[2].length() - 1) == 'y' && value[1]
-                                                                               .charAt(value[1].length() - 1) == 'x')) {
-                                                       value = new String[] { value[0] };
-                                               }
-                                       }
-
-                               }
-                       }
-
-                       // Support for setting arrays in format
-                       // set-array:name=value1,value2,value3,...
-                       else if (name.startsWith("set-array:")) {
-                               int equalsIndex = name.indexOf('=');
-                               if (equalsIndex < 0)
-                                       return;
-
-                               StringTokenizer commalist = new StringTokenizer(name
-                                               .substring(equalsIndex + 1), ",");
-                               name = name.substring(10, equalsIndex);
-                               String[] curVal = (String[]) values.get(name);
-                               ArrayList elems = new ArrayList();
-
-                               // Adds old values if present.
-                               if (curVal != null) {
-                                       for (int i = 0; i < curVal.length; i++)
-                                               elems.add(curVal[i]);
-                               }
-                               while (commalist.hasMoreTokens()) {
-                                       String token = commalist.nextToken();
-                                       if (token != null && token.length() > 0)
-                                               elems.add(token);
-                               }
-                               value = new String[elems.size()];
-                               for (int i = 0; i < value.length; i++)
-                                       value[i] = (String) elems.get(i);
-
-                       }
-
-                       // Support name="array:name" value="val1,val2,val3" notation
-                       // All the empty elements are ignored
-                       else if (name.startsWith("array:")) {
-
-                               name = name.substring(6);
-                               StringTokenizer commalist = new StringTokenizer(value[0], ",");
-                               String[] curVal = (String[]) values.get(name);
-                               ArrayList elems = new ArrayList();
-
-                               // Adds old values if present.
-                               if (curVal != null) {
-                                       for (int i = 0; i < curVal.length; i++)
-                                               elems.add(curVal[i]);
-                               }
-                               while (commalist.hasMoreTokens()) {
-                                       String token = commalist.nextToken();
-                                       if (token != null && token.length() > 0)
-                                               elems.add(token);
-                               }
-                               value = new String[elems.size()];
-                               for (int i = 0; i < value.length; i++)
-                                       value[i] = (String) elems.get(i);
-                       }
-
-                       // Support declaring variables with name="declare:name"
-                       else if (name.startsWith("declare:")) {
-                               name = name.substring(8);
-                               value = (String[]) values.get(name);
-                               if (value == null)
-                                       value = new String[0];
-                       }
-
-                       // Gets the owner
-                       WeakReference ref = (WeakReference) idToOwnerMap.get(name);
-                       VariableOwner owner = null;
-                       if (ref != null)
-                               owner = (VariableOwner) ref.get();
-
-                       // Adds the parameter to mapping only if they have owners
-                       if (owner != null) {
-                               Set p = (Set) parameters.get(owner);
-                               if (p == null)
-                                       parameters.put(owner, p = new HashSet());
-                               p.add(name);
-                               if (value != null)
-                                       values.put(name, value);
-                       }
-
-                       // If the owner can not be found
-                       else {
-
-                               // If parameter has been mapped before, remove the old owner
-                               // mapping
-                               if (ref != null) {
-
-                                       // The owner has been destroyed, so we remove the mappings
-                                       idToNameMap.remove(name);
-                                       idToOwnerMap.remove(name);
-                                       idToTypeMap.remove(name);
-                                       idToValueMap.remove(name);
-                               }
-
-                               // Adds the parameter to set of non-variables
-                               nonVariables.put(name, value);
-                       }
-
-               }
-
-               /**
-                * Gets the set of all parameters connected to given variable owner.
-                * 
-                * @param owner
-                *            the Listener for variable changes.
-                * @return the set of all parameters connected to variable owner.
-                */
-               public Set getParameters(VariableOwner owner) {
-                       if (owner == null)
-                               return null;
-                       return (Set) parameters.get(owner);
-               }
-
-               /**
-                * Gets the set of all variable owners owning parameters in this
-                * request.
-                * 
-                * @return
-                */
-               public Set getOwners() {
-                       return parameters.keySet();
-               }
-
-               /**
-                * Gets the value of a parameter.
-                * 
-                * @param parameterName
-                *            the name of the parameter.
-                * @return the value of the parameter.
-                */
-               public String[] getValue(String parameterName) {
-                       return (String[]) values.get(parameterName);
-               }
-
-               /**
-                * Gets the servlet multipart parser.
-                * 
-                * @return the parser.
-                */
-               public ServletMultipartRequest getParser() {
-                       return parser;
-               }
-
-               /**
-                * Gets the name - value[] mapping of non variable paramteres.
-                * 
-                * @return
-                */
-               public Map getNonVariables() {
-                       return nonVariables;
-               }
-       }
-
-       /**
-        * Handles all variable changes in this request.
-        * 
-        * @param req
-        *            the Http request to handle.
-        * @param errorListener
-        *            If the list is non null, only the listed listeners are served.
-        *            Otherwise all the listeners are served.
-        * @return Name to Value[] mapping of unhandled variables.
-        * @throws IOException
-        *             if the writing failed due to input/output error.
-        */
-       public Map handleVariables(HttpServletRequest req,
-                       Terminal.ErrorListener errorListener) throws IOException {
-
-               // Gets the parameters
-               ParameterContainer parcon = new ParameterContainer(req);
-
-               // Sorts listeners to dependency order
-               List listeners = getDependencySortedListenerList(parcon.getOwners());
-
-               // Handles all parameters for all listeners
-               while (!listeners.isEmpty()) {
-                       VariableOwner listener = (VariableOwner) listeners.remove(0);
-                       boolean changed = false; // Has any of this owners variabes
-                                                                               // changed
-                       // Handle all parameters for listener
-                       Set params = parcon.getParameters(listener);
-                       if (params != null) { // Name value mapping
-                               Map variables = new HashMap();
-                               for (Iterator pi = params.iterator(); pi.hasNext();) {
-                                       // Gets the name of the parameter
-                                       String param = (String) pi.next();
-                                       // Extracts more information about the parameter
-                                       String varName = (String) idToNameMap.get(param);
-                                       Class varType = (Class) idToTypeMap.get(param);
-                                       Object varOldValue = idToValueMap.get(param);
-                                       if (varName == null || varType == null)
-                                               Log
-                                                               .warn("VariableMap: No variable found for parameter "
-                                                                               + param
-                                                                               + " ("
-                                                                               + varName
-                                                                               + ","
-                                                                               + listener + ")");
-                                       else {
-
-                                               ServletMultipartRequest parser = parcon.getParser();
-
-                                               // Upload events
-                                               if (varType.equals(UploadStream.class)) {
-                                                       if (parser != null
-                                                                       && parser.getFileParameter(param,
-                                                                                       MultipartRequest.FILENAME) != null) {
-                                                               String filename = (String) parser
-                                                                               .getFileParameter(param,
-                                                                                               MultipartRequest.FILENAME);
-                                                               String contentType = (String) parser
-                                                                               .getFileParameter(param,
-                                                                                               MultipartRequest.CONTENT_TYPE);
-                                                               UploadStream upload = new HttpUploadStream(
-                                                                               varName, parser.getFileContents(param),
-                                                                               filename, contentType);
-                                                               variables.put(varName, upload);
-                                                               changed = true;
-                                                       }
-                                               }
-
-                                               // Normal variable change events
-                                               else {
-                                                       // First try to parse the event without multipart
-                                                       String[] values = parcon.getValue(param);
-                                                       if (values != null) {
-
-                                                               if (varType.equals(String[].class)) {
-                                                                       variables.put(varName, values);
-                                                                       changed |= (!Arrays.equals(values,
-                                                                                       (String[]) varOldValue));
-                                                               } else {
-                                                                       try {
-                                                                               if (values.length == 1) {
-                                                                                       Object val = convert(varType,
-                                                                                                       values[0]);
-                                                                                       variables.put(varName, val);
-                                                                                       changed |= ((val == null && varOldValue != null) || (val != null && !val
-                                                                                                       .equals(varOldValue)));
-                                                                               } else if (values.length == 0
-                                                                                               && varType
-                                                                                                               .equals(Boolean.class)) {
-                                                                                       Object val = new Boolean(false);
-                                                                                       variables.put(varName, val);
-                                                                                       changed |= (!val
-                                                                                                       .equals(varOldValue));
-                                                                               } else {
-                                                                                       Log.warn("Empty variable '"
-                                                                                                       + varName + "' of type "
-                                                                                                       + varType.toString());
-                                                                               }
-
-                                                                       } catch (java.lang.ClassCastException e) {
-                                                                               Log
-                                                                                               .except(
-                                                                                                               "WebVariableMap conversion exception",
-                                                                                                               e);
-                                                                               errorListener
-                                                                                               .terminalError(new TerminalErrorImpl(
-                                                                                                               e));
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-
-                               // Do the valuechange if the listener is enabled
-                               if (listener.isEnabled() && changed) {
-                                       try {
-                                               listener.changeVariables(req, variables);
-                                       } catch (Throwable t) {
-                                               // Notify the error listener
-                                               errorListener.terminalError(new VariableOwnerErrorImpl(
-                                                               listener, t));
-                                       }
-                               }
-                       }
-               }
-
-               return parcon.getNonVariables();
-       }
-
-       /**
-        * Implementation of VariableOwner.Error interface.
-        */
-       public class TerminalErrorImpl implements Terminal.ErrorEvent {
-               private Throwable throwable;
-
-               /**
-                * 
-                * @param throwable
-                */
-               private TerminalErrorImpl(Throwable throwable) {
-                       this.throwable = throwable;
-               }
-
-               /**
-                * Gets the contained throwable.
-                * 
-                * @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
-                */
-               public Throwable getThrowable() {
-                       return this.throwable;
-               }
-
-       }
-
-       /**
-        * Implementation of VariableOwner.Error interface.
-        */
-       public class VariableOwnerErrorImpl extends TerminalErrorImpl implements
-                       VariableOwner.ErrorEvent {
-
-               private VariableOwner owner;
-
-               /**
-                * 
-                * @param owner
-                *            the Listener for variable changes.
-                * @param throwable
-                */
-               private VariableOwnerErrorImpl(VariableOwner owner, Throwable throwable) {
-                       super(throwable);
-                       this.owner = owner;
-               }
-
-               /**
-                * Gets the source VariableOwner.
-                * 
-                * @see com.itmill.toolkit.terminal.VariableOwner.ErrorEvent#getVariableOwner()
-                */
-               public VariableOwner getVariableOwner() {
-                       return this.owner;
-               }
-
-       }
-
-       /**
-        * Resolves the VariableOwners needed from the request and sort them to
-        * assure that the dependencies are met (as well as possible).
-        * 
-        * @param listeners
-        * @return List of variable list changers, that are needed for handling all
-        *         the variables in the request
-        */
-       private List getDependencySortedListenerList(Set listeners) {
-
-               LinkedList resultNormal = new LinkedList();
-               LinkedList resultImmediate = new LinkedList();
-
-               // Go trough the listeners and either add them to result or resolve
-               // their dependencies
-               HashMap deepdeps = new HashMap();
-               LinkedList unresolved = new LinkedList();
-               for (Iterator li = listeners.iterator(); li.hasNext();) {
-
-                       VariableOwner listener = (VariableOwner) li.next();
-                       if (listener != null) {
-                               Set dependencies = listener.getDirectDependencies();
-
-                               // The listeners with no dependencies are added to the front of
-                               // the
-                               // list directly
-                               if (dependencies == null || dependencies.isEmpty()) {
-                                       if (listener.isImmediate())
-                                               resultImmediate.addFirst(listener);
-                                       else
-                                               resultNormal.addFirst(listener);
-                               }
-
-                               // Resolve deep dependencies for the listeners with dependencies
-                               // (the listeners will be added to the end of results in correct
-                               // dependency order later). Also the dependencies of all the
-                               // depended listeners are resolved.
-                               else if (deepdeps.get(listener) == null) {
-
-                                       // Set the fifo for unresolved parents to contain only the
-                                       // listener to be resolved
-                                       unresolved.clear();
-                                       unresolved.add(listener);
-
-                                       // Resolve dependencies
-                                       HashSet tmpdeepdeps = new HashSet();
-                                       while (!unresolved.isEmpty()) {
-
-                                               VariableOwner l = (VariableOwner) unresolved
-                                                               .removeFirst();
-                                               if (!tmpdeepdeps.contains(l)) {
-                                                       tmpdeepdeps.add(l);
-                                                       if (deepdeps.containsKey(l)) {
-                                                               tmpdeepdeps.addAll((Set) deepdeps.get(l));
-                                                       } else {
-                                                               Set deps = l.getDirectDependencies();
-                                                               if (deps != null && !deps.isEmpty())
-                                                                       for (Iterator di = deps.iterator(); di
-                                                                                       .hasNext();) {
-                                                                               Object d = di.next();
-                                                                               if (d != null
-                                                                                               && !tmpdeepdeps.contains(d))
-                                                                                       unresolved.addLast(d);
-                                                                       }
-                                                       }
-                                               }
-                                       }
-
-                                       tmpdeepdeps.remove(listener);
-                                       deepdeps.put(listener, tmpdeepdeps);
-                               }
-                       }
-               }
-
-               // Adds the listeners with dependencies in sane order to the result
-               for (Iterator li = deepdeps.keySet().iterator(); li.hasNext();) {
-                       VariableOwner l = (VariableOwner) li.next();
-                       boolean immediate = l.isImmediate();
-
-                       // Adds each listener after the last depended listener already in
-                       // the list
-                       int index = -1;
-                       for (Iterator di = ((Set) deepdeps.get(l)).iterator(); di.hasNext();) {
-                               int k;
-                               Object depended = di.next();
-                               if (immediate) {
-                                       k = resultImmediate.lastIndexOf(depended);
-                               } else {
-                                       k = resultNormal.lastIndexOf(depended);
-                               }
-                               if (k > index)
-                                       index = k;
-                       }
-                       if (immediate) {
-                               resultImmediate.add(index + 1, l);
-                       } else {
-                               resultNormal.add(index + 1, l);
-                       }
-               }
-
-               // Appends immediate listeners to normal listeners
-               // This way the normal handlers are always called before
-               // immediate ones
-               resultNormal.addAll(resultImmediate);
-               return resultNormal;
-       }
-}
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java
deleted file mode 100644 (file)
index f89db74..0000000
+++ /dev/null
@@ -1,703 +0,0 @@
-/* *************************************************************************
- IT Mill Toolkit 
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might 
- require purchasing a commercial license from IT Mill Ltd. For guidelines 
- on usage, see licensing-guidelines.html
-
- *************************************************************************
- For more information, contact:
- IT Mill Ltd                           phone: +358 2 4802 7180
- Ruukinkatu 2-4                        fax:   +358 2 4802 7181
- 20540, Turku                          email:  info@itmill.com
- Finland                               company www: www.itmill.com
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
-
-package com.itmill.toolkit.terminal.gwt.server;
-
-import com.itmill.toolkit.terminal.Terminal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Locale;
-
-/**
- * Web browser terminal type.
- * 
- * This class implements web browser properties, which declare the features of
- * the web browser.
- * 
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
-public class WebBrowser implements Terminal {
-
-       private static WebBrowser DEFAULT = new WebBrowser();
-
-       /**
-        * Content type.
-        */
-       private String contentType = "text/html; charset=utf-8";
-
-       /**
-        * Holds the collection of accepted locales.
-        */
-       private Collection locales = new ArrayList();
-
-       /**
-        * Holds value of property browserApplication.
-        */
-       private String browserApplication = null;
-
-       /**
-        * Should the client side checkking be done.
-        */
-       private boolean performClientCheck = true;
-
-       /**
-        * Holds value for property isClientSideChecked.
-        */
-       private boolean clientSideChecked = false;
-
-       /**
-        * Holds value of property javaScriptVersion.
-        */
-       private JavaScriptVersion javaScriptVersion = JAVASCRIPT_UNCHECKED;
-
-       /**
-        * Holds value of property javaEnabled.
-        */
-       private boolean javaEnabled = false;
-
-       /**
-        * Holds value of property frameSupport.
-        */
-       private boolean frameSupport = false;
-
-       /**
-        * Holds value of property markup version.
-        */
-       private MarkupVersion markupVersion = MARKUP_HTML_3_2;
-
-       /**
-        * Pixel width of the terminal screen.
-        */
-       private int screenWidth = -1;
-
-       /**
-        * Pixel height of the terminal screen.
-        */
-       private int screenHeight = -1;
-
-       /**
-        * Constuctor with some autorecognition capabilities Retrieves all
-        * capability information reported in http request headers:
-        * <ul>
-        * <li>User web browser (User-Agent)</li>
-        * <li>Supported locale(s)</li>
-        * </ul>
-        */
-
-       /**
-        * Constructor WebBrowserType. Creates a default WebBrowserType instance.
-        */
-       public WebBrowser() {
-       }
-
-       /**
-        * Gets the name of the default theme.
-        * 
-        * @return the Name of the terminal window.
-        */
-       public String getDefaultTheme() {
-               return ApplicationServlet.DEFAULT_THEME;
-       }
-
-       /**
-        * Gets the name and version of the web browser application. This is the
-        * version string reported by the web-browser in http headers.
-        * 
-        * @return the Web browser application.
-        */
-       public String getBrowserApplication() {
-               return this.browserApplication;
-       }
-
-       /**
-        * Gets the version of the supported Java Script by the browser.
-        * 
-        * <code>Null</code> if the Java Script is not supported.
-        * 
-        * @return the Version of the supported Java Script.
-        */
-       public JavaScriptVersion getJavaScriptVersion() {
-               return this.javaScriptVersion;
-       }
-
-       /**
-        * Does the browser support frames ?
-        * 
-        * @return <code>true</code> if the browser supports frames, otherwise
-        *         <code>false</code>.
-        */
-       public boolean isFrameSupport() {
-               return this.frameSupport;
-       }
-
-       /**
-        * Sets the browser frame support.
-        * 
-        * @param frameSupport
-        *            True if the browser supports frames, False if not.
-        */
-       public void setFrameSupport(boolean frameSupport) {
-               this.frameSupport = frameSupport;
-       }
-
-       /**
-        * Gets the supported markup language.
-        * 
-        * @return the Supported markup language
-        */
-       public MarkupVersion getMarkupVersion() {
-               return this.markupVersion;
-       }
-
-       /**
-        * Gets the height of the terminal window in pixels.
-        * 
-        * @return the Height of the terminal window.
-        */
-       public int getScreenHeight() {
-               return this.screenHeight;
-       }
-
-       /**
-        * Gets the width of the terminal window in pixels.
-        * 
-        * @return the Width of the terminal window.
-        */
-       public int getScreenWidth() {
-               return this.screenWidth;
-       }
-
-       /**
-        * Gets the default locale requested by the browser.
-        * 
-        * @return the Default locale.
-        */
-       public Locale getDefaultLocale() {
-               if (this.locales.isEmpty())
-                       return null;
-               return (Locale) this.locales.iterator().next();
-       }
-
-       /**
-        * Hash code composed of the properties of the web browser type.
-        * 
-        * @see java.lang.Object#hashCode()
-        */
-       public int hashCode() {
-               return toString().hashCode();
-       }
-
-       /**
-        * Tests the equality of the properties for two web browser types.
-        * 
-        * @see java.lang.Object#equals(java.lang.Object)
-        */
-       public boolean equals(Object obj) {
-               if (obj != null && obj instanceof WebBrowser) {
-                       return toString().equals(obj.toString());
-               }
-               return false;
-       }
-
-       /**
-        * @see java.lang.Object#toString()
-        */
-       public String toString() {
-
-               String localeString = "[";
-               for (Iterator i = this.locales.iterator(); i.hasNext(); localeString += ",") {
-                       localeString += ((Locale) i.next()).toString();
-               }
-               localeString += "]";
-
-               // Returns catenation of the properties
-               return "Browser:" + this.browserApplication + ", " + "Locales:"
-                               + localeString + ", " + "Frames:" + this.frameSupport + ", "
-                               + "JavaScript:" + this.javaScriptVersion + ", " + "Java: "
-                               + this.javaEnabled + ", " + "Markup:" + this.markupVersion
-                               + ", " + "Height:" + this.screenHeight + ", " + "Width:"
-                               + this.screenWidth + ", ClientCheck:" + this.performClientCheck
-                               + ", ClientCheckDone:" + this.clientSideChecked;
-       }
-
-       /**
-        * Gets the preferred content type.
-        * 
-        * @return the content type.
-        */
-       public String getContentType() {
-               return contentType;
-       }
-
-       /**
-        * Checks if this type supports also given browser.
-        * 
-        * @param browser
-        *            the browser type.
-        * @return true if this type matches the given browser.
-        */
-       public boolean supports(String browser) {
-               return this.getBrowserApplication().indexOf(browser) >= 0;
-       }
-
-       /**
-        * Checks if this type supports given markup language version.
-        * 
-        * @param html
-        *            the markup language version.
-        * @return <code>true</ocde> if this type supports the given markup version,otherwise <code>false</code>.
-        */
-       public boolean supports(MarkupVersion html) {
-               return this.getMarkupVersion().supports(html);
-       }
-
-       /**
-        * Checks if this type supports given javascript version.
-        * 
-        * @param js
-        *            the javascript version to check for.
-        * @return true if this type supports the given javascript version.
-        */
-       public boolean supports(JavaScriptVersion js) {
-               return this.getJavaScriptVersion().supports(js);
-       }
-
-       /**
-        * Parses HTML version from string.
-        * 
-        * @param html
-        * @return HTMLVersion instance.
-        */
-       private MarkupVersion doParseHTMLVersion(String html) {
-               for (int i = 0; i < MARKUP_VERSIONS.length; i++) {
-                       if (MARKUP_VERSIONS[i].name.equals(html))
-                               return MARKUP_VERSIONS[i];
-               }
-               return MARKUP_UNKNOWN;
-       }
-
-       /**
-        * Parses JavaScript version from string.
-        * 
-        * @param js
-        *            the javascript version to check for.
-        * @return HTMLVersion instance.
-        */
-       private JavaScriptVersion doParseJavaScriptVersion(String js) {
-               for (int i = 0; i < JAVASCRIPT_VERSIONS.length; i++) {
-                       if (JAVASCRIPT_VERSIONS[i].name.toLowerCase().startsWith(
-                                       js.toLowerCase()))
-                               return JAVASCRIPT_VERSIONS[i];
-               }
-               return JAVASCRIPT_NONE;
-       }
-
-       /**
-        * Parses HTML version from string.
-        * 
-        * @param html
-        * @return the HTMLVersion instance.
-        */
-       public static MarkupVersion parseHTMLVersion(String html) {
-               return DEFAULT.doParseHTMLVersion(html);
-       }
-
-       /**
-        * Parse JavaScript version from string.
-        * 
-        * @param js
-        *            the javascript version to check for.
-        * @return the HTMLVersion instance.
-        */
-       public static JavaScriptVersion parseJavaScriptVersion(String js) {
-               return DEFAULT.doParseJavaScriptVersion(js);
-       }
-
-       /**
-        * Gets the client side cheked property. Certain terminal features can only
-        * be detected at client side. This property indicates if the client side
-        * detections have been performed for this type.
-        * 
-        * @return <code>true</code> if client has sent information about its
-        *         properties. Default is <code>false</code>.
-        */
-       public boolean isClientSideChecked() {
-               return this.clientSideChecked;
-       }
-
-       /**
-        * Sets the client side checked property. Certain terminal features can only
-        * be detected at client side. This property indicates if the client side
-        * detections have been performed for this type.
-        * 
-        * @param value
-        *            true if client has sent information about its properties,
-        *            false otherweise.
-        */
-       public void setClientSideChecked(boolean value) {
-               this.clientSideChecked = value;
-       }
-
-       /**
-        * Should the client features be checked using remote scripts. Should the
-        * client side terminal feature check be performed.
-        * 
-        * @return <code>true</code> if client side checking should be performed
-        *         for this terminal type. Default is <code>false</code>.
-        */
-       public boolean performClientCheck() {
-               return this.performClientCheck;
-       }
-
-       /**
-        * Should the client features be checked using remote scripts.
-        * 
-        * @param value
-        * @return <code>true</code> if client side checking should be performed
-        *         for this terminal type. Default <code>false</code>.
-        */
-       public void performClientCheck(boolean value) {
-               this.performClientCheck = value;
-       }
-
-       /**
-        * Checks if web browser supports Java.
-        * 
-        * @return <code>true<code> if the browser supports java otherwise <code>false</code>.
-        */
-       public boolean isJavaEnabled() {
-               return javaEnabled;
-       }
-
-       /**
-        * Returns the locales supported by the web browser.
-        * 
-        * @return the Collection.
-        */
-       public Collection getLocales() {
-               return locales;
-       }
-
-       /**
-        * Sets the browser application. This corresponds to User-Agent HTTP header.
-        * 
-        * @param browserApplication
-        *            the browserApplication to set.
-        */
-       public void setBrowserApplication(String browserApplication) {
-               this.browserApplication = browserApplication;
-       }
-
-       /**
-        * Sets the default content type. Default is <code>text/html</code>
-        * 
-        * @param contentType
-        *            the contentType to set.
-        */
-       public void setContentType(String contentType) {
-               this.contentType = contentType;
-       }
-
-       /**
-        * Sets the java enabled property.
-        * 
-        * @param javaEnabled
-        *            the javaEnabled to set.
-        */
-       public void setJavaEnabled(boolean javaEnabled) {
-               this.javaEnabled = javaEnabled;
-       }
-
-       /**
-        * Sets the JavaScript version.
-        * 
-        * @param javaScriptVersion
-        *            the JavaScript version to set.
-        */
-       public void setJavaScriptVersion(JavaScriptVersion javaScriptVersion) {
-               this.javaScriptVersion = javaScriptVersion;
-       }
-
-       /**
-        * Sets the markup language version.
-        * 
-        * @param markupVersion
-        *            the markup language version to set.
-        */
-       public void setMarkupVersion(MarkupVersion markupVersion) {
-               this.markupVersion = markupVersion;
-       }
-
-       /**
-        * Sets the screen height.
-        * 
-        * @param screenHeight
-        *            the screen height to set in pixels.
-        */
-       public void setScreenHeight(int screenHeight) {
-               this.screenHeight = screenHeight;
-       }
-
-       /**
-        * Sets the screen width.
-        * 
-        * @param screenWidth
-        *            the screenWidth to set in pixels.
-        */
-       public void setScreenWidth(int screenWidth) {
-               this.screenWidth = screenWidth;
-       }
-
-       /*
-        * Consts defining the supported markup language versions @author IT Mill
-        * Ltd.
-        * 
-        * @version @VERSION@
-        * @since 3.0
-        */
-       public class MarkupVersion {
-               private String name;
-
-               private int order;
-
-               /**
-                * Returns <code>true</code> if and only if the argument is not
-                * <code>null</code> and is a Boolean object that represents the same
-                * boolean value as this object.
-                * 
-                * @param obj
-                *            the object to compare with.
-                * @see java.lang.Object#equals(Object)
-                */
-               public boolean equals(Object obj) {
-                       if (obj != null && obj instanceof MarkupVersion)
-                               return name.equals(((MarkupVersion) obj).name);
-                       return false;
-               }
-
-               /**
-                * @see java.lang.Object#toString()
-                */
-               public String toString() {
-                       return name;
-               }
-
-               /**
-                * 
-                * @param name
-                * @param order
-                */
-               private MarkupVersion(String name, int order) {
-                       this.name = name;
-                       this.order = order;
-               }
-
-               /**
-                * Checks the compability with other HTML version.
-                * 
-                * @param other
-                *            the HTML version.
-                * @return <code>true</code> if this is compatible with the other,
-                *         otherwise <code>false</code>.
-                */
-               public boolean supports(MarkupVersion other) {
-                       return (this.order >= other.order);
-               }
-
-       }
-
-       public static final MarkupVersion MARKUP_UNKNOWN = DEFAULT.new MarkupVersion(
-                       "HTML unknown", 0);
-
-       public static final MarkupVersion MARKUP_HTML_2_0 = DEFAULT.new MarkupVersion(
-                       "HTML 2.0", 20);
-
-       public static final MarkupVersion MARKUP_HTML_3_2 = DEFAULT.new MarkupVersion(
-                       "HTML 3.2", 32);
-
-       public static final MarkupVersion MARKUP_HTML_4_0 = DEFAULT.new MarkupVersion(
-                       "HTML 4.0", 40);
-
-       public static final MarkupVersion MARKUP_XHTML_1_0 = DEFAULT.new MarkupVersion(
-                       "XHTML 1.0", 110);
-
-       public static final MarkupVersion MARKUP_XHTML_2_0 = DEFAULT.new MarkupVersion(
-                       "XHTML 2.0", 120);
-
-       public static final MarkupVersion MARKUP_WML_1_0 = DEFAULT.new MarkupVersion(
-                       "WML 1.0", 10);
-
-       public static final MarkupVersion MARKUP_WML_1_1 = DEFAULT.new MarkupVersion(
-                       "WML 1.1", 11);
-
-       public static final MarkupVersion MARKUP_WML_1_2 = DEFAULT.new MarkupVersion(
-                       "WML 1.2", 12);
-
-       public static final MarkupVersion[] MARKUP_VERSIONS = new MarkupVersion[] {
-                       MARKUP_UNKNOWN, MARKUP_HTML_2_0, MARKUP_HTML_3_2, MARKUP_HTML_4_0,
-                       MARKUP_XHTML_1_0, MARKUP_XHTML_2_0, MARKUP_WML_1_0, MARKUP_WML_1_1,
-                       MARKUP_WML_1_2 };
-
-       /*
-        * Consts defining the supported JavaScript versions @author IT Mill Ltd.
-        * 
-        * @version @VERSION@
-        * @since 3.0
-        */
-       public class JavaScriptVersion {
-               private String name;
-
-               private int order;
-
-               /**
-                * @see java.lang.Object#equals(Object)
-                */
-               public boolean equals(Object obj) {
-                       if (obj != null && obj instanceof JavaScriptVersion)
-                               return name.equals(((JavaScriptVersion) obj).name);
-                       return false;
-               }
-
-               /**
-                * @see java.lang.Object#toString()
-                */
-               public String toString() {
-                       return name;
-               }
-
-               /**
-                * 
-                * @param name
-                * @param order
-                */
-               private JavaScriptVersion(String name, int order) {
-                       this.name = name;
-                       this.order = order;
-               }
-
-               /**
-                * Checks the compability with other JavaScript version. Use this like:
-                * <code>boolean isEcma = someVersion.supports(ECMA_262);</code>
-                * 
-                * @param other
-                *            the java script version.
-                * @return <code>true</code> if this supports the other, otherwise
-                *         <code>false</code>.
-                */
-               public boolean supports(JavaScriptVersion other) {
-
-                       // ECMA-262 support compare
-                       if (other.equals(ECMA_262)) {
-
-                               // JScript over 5.0 support ECMA-262
-                               if (this.order >= 100) {
-                                       return (this.order >= JSCRIPT_5_0.order);
-                               } else {
-                                       return (this.order >= JAVASCRIPT_1_3.order);
-                               }
-                       }
-
-                       // JavaScript version compare
-                       else if (this.order < 100 && other.order < 100) {
-                               return (this.order >= other.order);
-                       }
-
-                       // JScript version compare
-                       else if (this.order >= 100 && other.order >= 100) {
-                               return (this.order >= other.order);
-                       }
-
-                       return false;
-
-               }
-
-       }
-
-       public static final JavaScriptVersion JAVASCRIPT_UNCHECKED = DEFAULT.new JavaScriptVersion(
-                       "JavaScript unchecked", -1);
-
-       public static final JavaScriptVersion JAVASCRIPT_NONE = DEFAULT.new JavaScriptVersion(
-                       "JavaScript none", -1);
-
-       public static final JavaScriptVersion JAVASCRIPT_1_0 = DEFAULT.new JavaScriptVersion(
-                       "JavaScript 1.0", 10);
-
-       public static final JavaScriptVersion JAVASCRIPT_1_1 = DEFAULT.new JavaScriptVersion(
-                       "JavaScript 1.1", 11);
-
-       public static final JavaScriptVersion JAVASCRIPT_1_2 = DEFAULT.new JavaScriptVersion(
-                       "JavaScript 1.2", 12);
-
-       public static final JavaScriptVersion JAVASCRIPT_1_3 = DEFAULT.new JavaScriptVersion(
-                       "JavaScript 1.3", 13);
-
-       public static final JavaScriptVersion JAVASCRIPT_1_4 = DEFAULT.new JavaScriptVersion(
-                       "JavaScript 1.4", 14);
-
-       public static final JavaScriptVersion JAVASCRIPT_1_5 = DEFAULT.new JavaScriptVersion(
-                       "JavaScript 1.5", 15);
-
-       public static final JavaScriptVersion JSCRIPT_1_0 = DEFAULT.new JavaScriptVersion(
-                       "JScript 1.0", 110);
-
-       public static final JavaScriptVersion JSCRIPT_3_0 = DEFAULT.new JavaScriptVersion(
-                       "JScript 3.0", 130);
-
-       public static final JavaScriptVersion JSCRIPT_4_0 = DEFAULT.new JavaScriptVersion(
-                       "JScript 4.0", 140);
-
-       public static final JavaScriptVersion JSCRIPT_5_0 = DEFAULT.new JavaScriptVersion(
-                       "JScript 5.0", 150);
-
-       public static final JavaScriptVersion JSCRIPT_5_1 = DEFAULT.new JavaScriptVersion(
-                       "JScript 5.1", 151);
-
-       public static final JavaScriptVersion JSCRIPT_5_5 = DEFAULT.new JavaScriptVersion(
-                       "JScript 5.5", 155);
-
-       public static final JavaScriptVersion JSCRIPT_5_6 = DEFAULT.new JavaScriptVersion(
-                       "JScript 5.6", 156);
-
-       public static final JavaScriptVersion JSCRIPT_5_7 = DEFAULT.new JavaScriptVersion(
-                       "JScript 5.7", 157);
-
-       public static final JavaScriptVersion ECMA_262 = DEFAULT.new JavaScriptVersion(
-                       "ECMA-262", 262);
-
-       public static final JavaScriptVersion[] JAVASCRIPT_VERSIONS = new JavaScriptVersion[] {
-                       JAVASCRIPT_UNCHECKED, JAVASCRIPT_NONE, JAVASCRIPT_1_0,
-                       JAVASCRIPT_1_1, JAVASCRIPT_1_2, JAVASCRIPT_1_3, JAVASCRIPT_1_4,
-                       JAVASCRIPT_1_5, JSCRIPT_1_0, JSCRIPT_3_0, JSCRIPT_4_0, JSCRIPT_5_0,
-                       JSCRIPT_5_1, JSCRIPT_5_5, JSCRIPT_5_6, JSCRIPT_5_7, ECMA_262 };
-
-}
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowserProbe.java b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowserProbe.java
deleted file mode 100644 (file)
index d6ca56c..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-/* *************************************************************************
- IT Mill Toolkit 
-
- Development of Browser User Interfaces Made Easy
-
- Copyright (C) 2000-2006 IT Mill Ltd
- *************************************************************************
-
- This product is distributed under commercial license that can be found
- from the product package on license.pdf. Use of this product might 
- require purchasing a commercial license from IT Mill Ltd. For guidelines 
- on usage, see licensing-guidelines.html
-
- *************************************************************************
- For more information, contact:
- IT Mill Ltd                           phone: +358 2 4802 7180
- Ruukinkatu 2-4                        fax:   +358 2 4802 7181
- 20540, Turku                          email:  info@itmill.com
- Finland                               company www: www.itmill.com
- Primary source for information and releases: www.itmill.com
-
- ********************************************************************** */
-
-package com.itmill.toolkit.terminal.gwt.server;
-
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Map;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-/**
- * The <code>WebBrowserProbe</code> uses JavaScript to determine the
- * capabilities of the client browser.
- * 
- * @author IT Mill Ltd.
- * @version
- * @VERSION@
- * @since 3.0
- */
-public class WebBrowserProbe {
-
-       private static final String WA_NOSCRIPT = "WA_NOSCRIPT";
-
-       private static final String CLIENT_TYPE = "wa_browser";
-
-       /**
-        * Returns the terminal type from the given session.
-        * 
-        * @param session
-        *            the HTTP session.
-        * @return WebBrowser instance for the given session.
-        */
-       public static WebBrowser getTerminalType(HttpSession session) {
-               if (session != null)
-                       return (WebBrowser) session.getAttribute(CLIENT_TYPE);
-               return null;
-       }
-
-       /**
-        * Sets the terminal type for the given session.
-        * 
-        * @param session
-        *            the HTTP session.
-        * @param terminal
-        *            the web browser.
-        * @return WebBrowser instance for the given session.
-        */
-       public static void setTerminalType(HttpSession session, WebBrowser terminal) {
-               if (session != null)
-                       session.setAttribute(CLIENT_TYPE, terminal);
-       }
-
-       /**
-        * Handles the client checking.
-        * 
-        * @param request
-        *            the HTTP request to process.
-        * @param parameters
-        *            the Parameters to be used as defaults.
-        * @return <code>true</code> if response should include a probe
-        *         script,otherwise <code>false</code>.
-        * @throws ServletException
-        *             if an exception has occurred that interferes with the
-        *             servlet's normal operation.
-        */
-       public static boolean handleProbeRequest(HttpServletRequest request,
-                       Map parameters) throws ServletException {
-
-               HttpSession s = request.getSession();
-               WebBrowser browser = getTerminalType(s);
-               if (browser != null) {
-
-                       // Check if no-script was requested
-                       if (parameters.containsKey(WA_NOSCRIPT)) {
-                               String val = ((String[]) parameters.get(WA_NOSCRIPT))[0];
-                               if (val != null && "1".equals(val)) {
-                                       browser.setJavaScriptVersion(WebBrowser.JAVASCRIPT_NONE);
-                                       browser.setClientSideChecked(true);
-                               } else {
-                                       // Recheck
-                                       browser.setClientSideChecked(false);
-                               }
-                       }
-
-                       // If client is alredy checked disable further checking
-                       if (browser.isClientSideChecked())
-                               return false;
-
-               }
-
-               // Creates new type based on client parameters
-               browser = probe(browser, request, parameters);
-               setTerminalType(s, browser);
-
-               // Sets client as checked if parameters were found
-               if (parameters.containsKey("wa_clientprobe")) {
-                       String val = ((String[]) parameters.get("wa_clientprobe"))[0];
-                       browser.setClientSideChecked(val != null && "1".equals(val));
-               }
-
-               // Include probe script if requested and not alredy probed
-               return browser.performClientCheck() && !browser.isClientSideChecked();
-
-       }
-
-       /**
-        * Determines versions based on user agent string.
-        * 
-        * @param agent
-        *            the HTTP User-Agent request header.
-        * @return new WebBrowser instance initialized based on agent features.
-        */
-       public static WebBrowser probe(String agent) {
-               WebBrowser res = new WebBrowser();
-               if (agent == null)
-                       return res;
-
-               // Set the agent string
-               res.setBrowserApplication(agent);
-
-               // Konqueror
-               if (agent.indexOf("Konqueror") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JSCRIPT_5_6);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-               }
-
-               // Opera
-               else if (agent.indexOf("Opera 3.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_3);
-                       res.setJavaEnabled(false);
-                       res.setFrameSupport(true);
-               } else if (agent.indexOf("Opera") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_3);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_4_0);
-                       if (agent.indexOf("Opera/9") >= 0)
-                               res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_5);
-               }
-
-               // OmniWeb
-               else if (agent.indexOf("OmniWeb") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_3);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-               }
-
-               // Mosaic
-               else if (agent.indexOf("Mosaic") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_3);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_2_0);
-               }
-
-               // Lynx
-               else if (agent.indexOf("Lynx") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_NONE);
-                       res.setJavaEnabled(false);
-                       res.setFrameSupport(true);
-               }
-
-               // Microsoft Browsers
-               // See Microsoft documentation for details:
-               // http://msdn.microsoft.com/library/default.asp?url=/library/
-               // en-us/script56/html/js56jsoriversioninformation.asp
-               else if (agent.indexOf("MSIE 7.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JSCRIPT_5_7);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_4_0);
-               } else if (agent.indexOf("MSIE 6.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JSCRIPT_5_6);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_4_0);
-               } else if (agent.indexOf("MSIE 5.5") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JSCRIPT_5_5);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_4_0);
-               } else if (agent.indexOf("MSIE 5.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JSCRIPT_5_0);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_4_0);
-               } else if (agent.indexOf("MSIE 4.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JSCRIPT_3_0);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_4_0);
-               } else if (agent.indexOf("MSIE 3.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JSCRIPT_3_0);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-               } else if (agent.indexOf("MSIE 2.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_NONE);
-                       res.setJavaEnabled(false);
-                       if (agent.indexOf("Mac") >= 0) {
-                               res.setFrameSupport(true);
-                       } else {
-                               res.setFrameSupport(false);
-                       }
-               }
-
-               // Netscape browsers
-               else if (agent.indexOf("Netscape6") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_5);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_4_0);
-               } else if ((agent.indexOf("Mozilla/4.06") >= 0)
-                               || (agent.indexOf("Mozilla/4.7") >= 0)) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_3);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_4_0);
-               } else if (agent.indexOf("Mozilla/4.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_2);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-               } else if (agent.indexOf("Mozilla/3.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_1);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-               } else if (agent.indexOf("Mozilla/2.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_0);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-               }
-
-               // Mozilla Open-Source Browsers
-               else if (agent.indexOf("Mozilla/5.") >= 0) {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_1_5);
-                       res.setJavaEnabled(true);
-                       res.setFrameSupport(true);
-                       res.setMarkupVersion(WebBrowser.MARKUP_HTML_4_0);
-               }
-
-               // Unknown browser
-               else {
-                       res.setJavaScriptVersion(WebBrowser.JAVASCRIPT_UNCHECKED);
-                       res.setJavaEnabled(false);
-                       res.setMarkupVersion(WebBrowser.MARKUP_UNKNOWN);
-                       res.setFrameSupport(false);
-               }
-
-               return res;
-       }
-
-       /**
-        * Creates new instance of WebBrowser by initializing the values based on
-        * user request.
-        * 
-        * @param browser
-        *            the browser to be updated. If null a new instance is created.
-        * @param request
-        *            the Request to be used as defaults.
-        * @param params
-        *            the Parameters to be used as defaults.
-        * @return new WebBrowser instance initialized based on request parameters.
-        */
-       public static WebBrowser probe(WebBrowser browser,
-                       HttpServletRequest request, Map params) {
-
-               // Initialize defaults based on client features
-               WebBrowser res = browser;
-               if (res == null) {
-                       res = probe(request.getHeader("User-Agent"));
-               }
-
-               // Client locales
-               Collection locales = res.getLocales();
-               locales.clear();
-               for (Enumeration e = request.getLocales(); e.hasMoreElements();) {
-                       locales.add(e.nextElement());
-               }
-
-               // Javascript version
-               if (params.containsKey("wa_jsversion")) {
-                       String val = ((String[]) params.get("wa_jsversion"))[0];
-                       if (val != null) {
-                               res
-                                               .setJavaScriptVersion(WebBrowser
-                                                               .parseJavaScriptVersion(val));
-                       }
-               }
-               // Java support
-               if (params.containsKey("wa_javaenabled")) {
-                       String val = ((String[]) params.get("wa_javaenabled"))[0];
-                       if (val != null) {
-                               res.setJavaEnabled(Boolean.valueOf(val).booleanValue());
-                       }
-               }
-               // Screen width
-               if (params.containsKey("wa_screenwidth")) {
-                       String val = ((String[]) params.get("wa_screenwidth"))[0];
-                       if (val != null) {
-                               try {
-                                       res.setScreenWidth(Integer.parseInt(val));
-                               } catch (NumberFormatException e) {
-                                       res.setScreenWidth(-1);
-                               }
-                       }
-               }
-               // Screen height
-               if (params.containsKey("wa_screenheight")) {
-                       String val = ((String[]) params.get("wa_screenheight"))[0];
-                       if (val != null) {
-                               try {
-                                       res.setScreenHeight(Integer.parseInt(val));
-                               } catch (NumberFormatException e) {
-                                       res.setScreenHeight(-1);
-                               }
-                       }
-               }
-
-               return res;
-       }
-}
\ No newline at end of file