aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>2007-07-17 11:27:59 +0000
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>2007-07-17 11:27:59 +0000
commitdbea045513e92d36bb220b9709b27b544b97357d (patch)
treea8c3103fb95c057e255266d5a14560d0d7e4dc9d /src
parent7f104c23f53fee92ffa93cca4e2deb721747fd21 (diff)
downloadvaadin-framework-dbea045513e92d36bb220b9709b27b544b97357d.tar.gz
vaadin-framework-dbea045513e92d36bb220b9709b27b544b97357d.zip
Refactoring terminal
svn changeset:1867/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/Client.gwt.xml2
-rwxr-xr-xsrc/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java (renamed from src/com/itmill/toolkit/terminal/gwt/client/Client.java)2
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/Paintable.java2
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IAction.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IComponent.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalLayout.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java10
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java8
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java156
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java114
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/HttpVariableMap.java791
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java703
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/WebBrowserProbe.java349
32 files changed, 76 insertions, 2167 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/Client.gwt.xml b/src/com/itmill/toolkit/terminal/gwt/Client.gwt.xml
index 19fed850ce..71353c5262 100644
--- a/src/com/itmill/toolkit/terminal/gwt/Client.gwt.xml
+++ b/src/com/itmill/toolkit/terminal/gwt/Client.gwt.xml
@@ -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/Client.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
index 02a613fa46..e1c490f4de 100755
--- a/src/com/itmill/toolkit/terminal/gwt/client/Client.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
@@ -26,7 +26,7 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IContextMenu;
*
* TODO IDEA: Should be extend Widget here !?!?!
*/
-public class Client implements EntryPoint {
+public class ApplicationConnection implements EntryPoint {
private String appUri;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Paintable.java b/src/com/itmill/toolkit/terminal/gwt/client/Paintable.java
index df4ce112cb..4f29946569 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/Paintable.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/Paintable.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAction.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAction.java
index 72c834079b..2288b746a1 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAction.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAction.java
@@ -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
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java
index a4626a3bf8..a6b747b5c2 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java
@@ -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.
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
index b5ce2c7b4b..6092b0cf0a 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
@@ -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.UIDL;
public class ICalendar extends IDateField {
@@ -14,7 +14,7 @@ public class ICalendar extends IDateField {
add(date);
}
- public void updateFromUIDL(UIDL uidl, Client client) {
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
date.updateCalendar();
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java
index 1545c3421b..016c8affc0 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java
@@ -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))
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IComponent.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IComponent.java
index 17a94f91c0..fa8ff944a4 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IComponent.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IComponent.java
@@ -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.UIDL;
public class IComponent extends IPanel {
@@ -10,7 +10,7 @@ public class IComponent extends IPanel {
setStyleName("i-component");
}
- public void updateFromUIDL(UIDL uidl, Client client) {
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
setStyleName("i-component");
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
index 78d415d328..da0eec5b37 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
@@ -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");
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java
index 358ef30c2d..931172197a 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java
@@ -3,7 +3,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
import java.util.Date;
import com.google.gwt.user.client.ui.FlowPanel;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.DateTimeService;
import com.itmill.toolkit.terminal.gwt.client.LocaleNotLoadedException;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
@@ -15,7 +15,7 @@ public class IDateField extends FlowPanel implements Paintable {
String id;
- Client client;
+ ApplicationConnection client;
protected boolean immediate;
@@ -47,7 +47,7 @@ public class IDateField extends FlowPanel implements Paintable {
dts = new DateTimeService();
}
- public void updateFromUIDL(UIDL uidl, Client client) {
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Ensure correct implementation and let layout manage caption
if (client.updateComponent(this, uidl, true))
return;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
index af8ea46e85..5e36793910 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
@@ -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 {
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
index ecc73fc192..260270438c 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
@@ -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"));
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalLayout.java
index 8e0bf0a147..d0ef747f31 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IHorizontalLayout.java
@@ -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))
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java
index dbfff25850..0ea08a2529 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java
@@ -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;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java
index 8ddf6502c0..884a0ccfea 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java
@@ -9,7 +9,7 @@ import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.Panel;
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;
@@ -17,7 +17,7 @@ abstract class IOptionGroupBase extends Composite implements Paintable, ClickLis
public static final String CLASSNAME_OPTION = "i-select-option";
- Client client;
+ ApplicationConnection client;
String id;
@@ -65,7 +65,7 @@ abstract class IOptionGroupBase extends Composite implements Paintable, ClickLis
container.add(optionsContainer);
}
- public void updateFromUIDL(UIDL uidl, Client client) {
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
this.client = client;
this.id = uidl.getId();
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
index 9de0d5112b..9118563107 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
@@ -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;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java
index 99a1a6b95b..baa8ccadb8 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java
@@ -4,7 +4,7 @@ import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.PopupListener;
import com.google.gwt.user.client.ui.PopupPanel;
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 IPopupCalendar extends ITextualDate implements Paintable, ClickList
popup.addPopupListener(this);
}
- public void updateFromUIDL(UIDL uidl, Client client) {
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
calendar.updateCalendar();
calendarToggle.setEnabled(enabled);
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
index f5ac77a1da..7a55fc9972 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
@@ -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;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java
index 912733cc64..19b005d4e1 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITablePaging.java
@@ -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;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
index c85a2b4a79..c21ba67a3d 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
@@ -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();
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java
index ca7aef3a09..9bcc8bc5ac 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java
@@ -1,7 +1,7 @@
package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
-import com.itmill.toolkit.terminal.gwt.client.Client;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
/**
@@ -16,7 +16,7 @@ public class ITextArea extends ITextField {
super(DOM.createTextArea());
}
- public void updateFromUIDL(UIDL uidl, Client client) {
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Call parent renderer explicitly
super.updateFromUIDL(uidl, client);
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java
index e621e3af0d..038777f6f8 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java
@@ -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();
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
index f7945f163b..170fd0ac6b 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
@@ -4,7 +4,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.ChangeListener;
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.DateLocale;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
@@ -25,7 +25,7 @@ public class ITextualDate extends IDateField implements Paintable, ChangeListene
add(text);
}
- public void updateFromUIDL(UIDL uidl, Client client) {
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
buildTime();
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java
index ff05bbb0ea..00cedbec04 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITree.java
@@ -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();) {
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java
index abf167a624..ac757a1745 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java
@@ -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());
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java
index 5f5a9c1492..4888f16b4b 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IVerticalLayout.java
@@ -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))
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
index b7cf50e86c..c6a271f4a6 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
@@ -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"));
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
index 62c561b480..5ba33b7778 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
@@ -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
index b92fb9d451..0000000000
--- a/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java
+++ /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
index 5fd4407971..0000000000
--- a/src/com/itmill/toolkit/terminal/gwt/server/HttpVariableMap.java
+++ /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
index f89db74c0a..0000000000
--- a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java
+++ /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
index d6ca56c1b8..0000000000
--- a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowserProbe.java
+++ /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