Bug=91673

author=ashuk
ra=edburns

Files modifed
BrowserControl.java BrowserControlFactory.java BrowserControlImpl.java
Files added
BrowserType.java
everything in wrapper_nonnative
everything in test_nonnative

This patch allows Webclient to wrap non-native pure Java browsers like
the ICE browser.

_Ashu


git-svn-id: svn://10.0.0.236/trunk@99982 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ashuk%eng.sun.com 2001-07-27 21:02:15 +00:00
parent 75fdf8746e
commit f9d9eb2750
14 changed files with 1663 additions and 66 deletions

View File

@ -19,11 +19,12 @@
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ann Sunhachawee
* Ashutosh Kulkarni <ashuk@eng.sun.com>
*/
package org.mozilla.webclient;
// BrowserControl.java
/**
@ -35,7 +36,7 @@ package org.mozilla.webclient;
*
* @version $Id: BrowserControl.java,v 1.2 2001-05-24 21:13:30 ashuk%eng.sun.com Exp $
* @version $Id: BrowserControl.java,v 1.3 2001-07-27 20:57:51 ashuk%eng.sun.com Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
* */
@ -43,6 +44,7 @@ package org.mozilla.webclient;
public interface BrowserControl
{
public static String BROWSER_TYPE_NAME = "webclient.BrowserType";
public static String BOOKMARKS_NAME = "webclient.Bookmarks";
public static String BROWSER_CONTROL_CANVAS_NAME = "webclient.BrowserControlCanvas";
public static String CURRENT_PAGE_NAME = "webclient.CurrentPage";
@ -56,6 +58,8 @@ public static String PRINT_NAME = "webclient.Print";
public static String WINDOW_CONTROL_NAME = "webclient.WindowControl";
public static String PROFILE_MANAGER_NAME = "webclient.ProfileManager";
public static String BROWSER_TYPE_NATIVE = "native";
public static String BROWSER_TYPE_NON_NATIVE = "nonnative";
/**

View File

@ -21,6 +21,7 @@
* Ian Wilkinson <iw@ennoble.com>
* Mark Lin <mark.lin@eng.sun.com>
* Ed Burns <edburns@acm.org>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
*/
package org.mozilla.webclient;
@ -43,7 +44,7 @@ import java.io.FileNotFoundException;
* This is a static class, it is neven instantiated.
*
* @version $Id: BrowserControlFactory.java,v 1.4 2001-05-29 18:34:19 ashuk%eng.sun.com Exp $
* @version $Id: BrowserControlFactory.java,v 1.5 2001-07-27 20:57:51 ashuk%eng.sun.com Exp $
*
* @see org.mozilla.webclient.test.EmbeddedMozilla
@ -62,6 +63,7 @@ public class BrowserControlFactory extends Object
private static boolean appDataHasBeenSet = false;
private static Class browserControlCanvasClass = null;
private static String platformCanvasClassName = null;
private static String browserType = null;
//
// Instance Variables
@ -84,80 +86,56 @@ public BrowserControlFactory()
// Class methods
//
public static void setAppData(String absolutePathToNativeBrowserBinDir) throws FileNotFoundException, ClassNotFoundException
{
BrowserControlFactory.setAppData(BrowserControl.BROWSER_TYPE_NATIVE, absolutePathToNativeBrowserBinDir);
}
/**
* This method is used to set per-application instance data, such as
* the location of the browser binary.
* @param myBrowserType. Either "native" or "nonnative"
* @param absolutePathToNativeBrowserBinDir the path to the bin dir
* of the native browser, including the bin. ie:
* "D:\Projects\mozilla\dist\win32_d.obj\bin"
*/
public static void setAppData(String absolutePathToNativeBrowserBinDir) throws FileNotFoundException, ClassNotFoundException
public static void setAppData(String myBrowserType, String absolutePathToNativeBrowserBinDir) throws FileNotFoundException, ClassNotFoundException
{
browserType = myBrowserType;
if (!appDataHasBeenSet) {
ParameterCheck.nonNull(absolutePathToNativeBrowserBinDir);
// verify that the directory exists:
File binDir = new File(absolutePathToNativeBrowserBinDir);
if (!binDir.exists()) {
throw new FileNotFoundException("Directory " + absolutePathToNativeBrowserBinDir + " is not found.");
// figure out the correct value for platformCanvasClassName
if (browserType.equals(BrowserControl.BROWSER_TYPE_NON_NATIVE)) {
platformCanvasClassName = "org.mozilla.webclient.wrapper_nonnative.JavaBrowserControlCanvas";
}
// This hack is necessary for Sun Bug #4303996
java.awt.Canvas c = new java.awt.Canvas();
// cause the native library to be loaded
// PENDING(edburns): do some magic to determine the right kind of
// MozWebShellCanvas to instantiate
// How about this:
// I try loading sun.awt.windows.WDrawingSurfaceInfo. If it doesn't
// load, then I try loading sun.awt.motif.MDrawingSufaceInfo. If
// none loads, then I return a error message.
// If you think up of a better way, let me know.
// -- Mark
Class win32DrawingSurfaceInfoClass;
try {
win32DrawingSurfaceInfoClass =
Class.forName("sun.awt.windows.WDrawingSurfaceInfo");
}
catch (Exception e) {
win32DrawingSurfaceInfoClass = null;
}
if (win32DrawingSurfaceInfoClass != null) {
platformCanvasClassName = "org.mozilla.webclient.wrapper_native.win32.Win32BrowserControlCanvas";
}
if (null == platformCanvasClassName) {
Class motifDrawingSurfaceInfoClass;
try {
motifDrawingSurfaceInfoClass =
Class.forName("sun.awt.motif.MDrawingSurfaceInfo");
}
catch (Exception e) {
motifDrawingSurfaceInfoClass = null;
else {
ParameterCheck.nonNull(absolutePathToNativeBrowserBinDir);
// verify that the directory exists:
File binDir = new File(absolutePathToNativeBrowserBinDir);
if (!binDir.exists()) {
throw new FileNotFoundException("Directory " + absolutePathToNativeBrowserBinDir + " is not found.");
}
if (motifDrawingSurfaceInfoClass != null) {
platformCanvasClassName = "org.mozilla.webclient.wrapper_native.motif.MotifBrowserControlCanvas";
}
// This hack is necessary for Sun Bug #4303996
java.awt.Canvas c = new java.awt.Canvas();
platformCanvasClassName = determinePlatformCanvasClassName();
}
// end of figuring out the correct value for platformCanvasClassName
if (platformCanvasClassName != null) {
browserControlCanvasClass = Class.forName(platformCanvasClassName);
}
else {
throw new ClassNotFoundException("Could not determine WebShellCanvas class to load\n");
throw new ClassNotFoundException("Could not determine BrowserControlCanvas class to load\n");
}
try {
BrowserControlImpl.appInitialize(absolutePathToNativeBrowserBinDir);
BrowserControlImpl.appInitialize(browserType, absolutePathToNativeBrowserBinDir);
}
catch (Exception e) {
throw new ClassNotFoundException("Can't initialize native browser: " +
@ -183,7 +161,7 @@ public static BrowserControl newBrowserControl() throws InstantiationException,
BrowserControl result = null;
newCanvas = (BrowserControlCanvas) browserControlCanvasClass.newInstance();
if (null != newCanvas &&
null != (result = new BrowserControlImpl(newCanvas))) {
null != (result = new BrowserControlImpl(browserType, newCanvas))) {
newCanvas.initialize(result);
}
@ -213,6 +191,63 @@ public static void deleteBrowserControl(BrowserControl toDelete)
// General Methods
//
/**
* Called from setAppData() in the native case. This method simply
* figures out the proper name for the class that is the
* BrowserControlCanvas.
* @return "org.mozilla.webclient.wrapper_native.win32.Win32BrowserControlCanvas" or "org.mozilla.webclient.wrapper_native.motif.MotifBrowserControlCanvas"
*/
private static String determinePlatformCanvasClassName()
{
String result = null;
// cause the native library to be loaded
// PENDING(edburns): do some magic to determine the right kind of
// MozWebShellCanvas to instantiate
// How about this:
// I try loading sun.awt.windows.WDrawingSurfaceInfo. If it doesn't
// load, then I try loading sun.awt.motif.MDrawingSufaceInfo. If
// none loads, then I return a error message.
// If you think up of a better way, let me know.
// -- Mark
Class win32DrawingSurfaceInfoClass;
try {
win32DrawingSurfaceInfoClass =
Class.forName("sun.awt.windows.WDrawingSurfaceInfo");
}
catch (Exception e) {
win32DrawingSurfaceInfoClass = null;
}
if (win32DrawingSurfaceInfoClass != null) {
result = "org.mozilla.webclient.wrapper_native.win32.Win32BrowserControlCanvas";
}
if (null == result) {
Class motifDrawingSurfaceInfoClass;
try {
motifDrawingSurfaceInfoClass =
Class.forName("sun.awt.motif.MDrawingSurfaceInfo");
}
catch (Exception e) {
motifDrawingSurfaceInfoClass = null;
}
if (motifDrawingSurfaceInfoClass != null) {
result = "org.mozilla.webclient.wrapper_native.motif.MotifBrowserControlCanvas";
}
}
return result;
}
// ----UNIT_TEST_START
//
@ -225,18 +260,19 @@ public static void main(String [] args)
Assert.setEnabled(true);
Log.setApplicationName("BrowserControlFactory");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlFactory.java,v 1.4 2001-05-29 18:34:19 ashuk%eng.sun.com Exp $");
Log.setApplicationVersionDate("$Id: BrowserControlFactory.java,v 1.5 2001-07-27 20:57:51 ashuk%eng.sun.com Exp $");
BrowserControlCanvas canvas = null;
BrowserControl control = null;
try {
BrowserControlFactory.setAppData(args[0]);
BrowserControlFactory.setAppData("nonnative", args[0]);
control = BrowserControlFactory.newBrowserControl();
Assert.assert_it(control != null);
canvas = (BrowserControlCanvas) control.queryInterface("webclient.BrowserControlCanvas");
Assert.assert_it(canvas != null);
}
catch (Exception e) {
System.out.println("\n BrowserControl not getting created \n");
System.out.println(e.getMessage());
}
}

View File

@ -29,12 +29,15 @@ import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.Utilities;
class BrowserControlImpl extends Object implements BrowserControl
{
//
// Protected Constants
//
//
// Class Variables
//
@ -64,6 +67,7 @@ private static WrapperFactory wrapperFactory = null;
private BrowserControlCanvas myCanvas = null;
private BrowserType myType = null;
private CurrentPage currentPage = null;
private EventRegistration eventRegistration = null;
private WindowControl windowControl = null;
@ -72,18 +76,23 @@ private History history = null;
private static Bookmarks bookmarks = null;
private static Preferences prefs = null;
private static ProfileManager profileManager = null;
private static String browserType = null;
//
// Constructors and Initializers
//
public BrowserControlImpl(BrowserControlCanvas yourCanvas)
public BrowserControlImpl(String myBrowserType, BrowserControlCanvas yourCanvas)
{
super();
ParameterCheck.nonNull(yourCanvas);
myCanvas = yourCanvas;
if (browserType.equals(BrowserControl.BROWSER_TYPE_NATIVE)) {
ParameterCheck.nonNull(yourCanvas);
myCanvas = yourCanvas;
}
}
/**
* Called from BrowserControlFactory.deleteBrowserControl() <P>
@ -137,11 +146,13 @@ void delete()
// Class methods
//
static void appInitialize(String verifiedBinDirAbsolutePath) throws Exception
static void appInitialize(String myBrowserType, String verifiedBinDirAbsolutePath) throws Exception
{
ParameterCheck.nonNull(verifiedBinDirAbsolutePath);
browserType = myBrowserType;
if (null == wrapperFactory) {
System.out.println("\n+++ In appInitialize - before createWrapperFactory +++ \n");
wrapperFactory = createWrapperFactory();
System.out.println("\n+++ In appInitialize - after createWrapperFactory +++ \n");
}
wrapperFactory.initialize(verifiedBinDirAbsolutePath);
}
@ -188,18 +199,26 @@ private static WrapperFactory createWrapperFactory() throws ClassNotFoundExcepti
throw new ClassNotFoundException("Can't determine current class name");
}
// PENDING(edburns): when we have a java implementation, this is
// where you'll replace the string "native" with either "native" or
// "nonnative".
String PARAMETERIZED_VALUE = "";
String PARAMETERIZED_VALUE = "native";
System.out.println("\n+++ browserType is - " + browserType + " +++\n");
if (browserType.equals(BrowserControl.BROWSER_TYPE_NATIVE)) {
PARAMETERIZED_VALUE = "native";
}
else {
PARAMETERIZED_VALUE = "nonnative";
}
System.out.println("\n+++ PARAMETERIZED_VALUE is " + PARAMETERIZED_VALUE + " +++\n");
// tack on the appropriate stuff
wrapperFactoryClassName = wrapperFactoryClassName + "wrapper_" +
PARAMETERIZED_VALUE + "." + WrapperFactory.IMPL_NAME;
System.out.println("\n+++ WrapperFactory classname is " + wrapperFactoryClassName + " +++\n");
wrapperFactoryClass = Class.forName(wrapperFactoryClassName);
try {
@ -224,7 +243,7 @@ public Object queryInterface(String interfaceName) throws ClassNotFoundException
ParameterCheck.nonNull(interfaceName);
Assert.assert_it(null != wrapperFactory);
wrapperFactory.throwExceptionIfNotInitialized();
// wrapperFactory.throwExceptionIfNotInitialized();
// At some point, it has to come down to hard coded string names,
// right? Well, that point is here. There is an extensibility
@ -248,6 +267,13 @@ public Object queryInterface(String interfaceName) throws ClassNotFoundException
Assert.assert_it(null != myCanvas);
return myCanvas;
}
if (BROWSER_TYPE_NAME.equals(interfaceName)) {
if (null == myType) {
myType = (BrowserType) wrapperFactory.newImpl(BROWSER_TYPE_NAME,
this);
}
return myType;
}
if (CURRENT_PAGE_NAME.equals(interfaceName)) {
if (null == currentPage) {
currentPage =
@ -308,7 +334,7 @@ public static void main(String [] args)
Assert.setEnabled(true);
Log.setApplicationName("BrowserControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.6 2001-05-29 18:34:19 ashuk%eng.sun.com Exp $");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.7 2001-07-27 20:57:52 ashuk%eng.sun.com Exp $");
}

View File

@ -0,0 +1,60 @@
/*
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
package org.mozilla.webclient;
/**
* This abstract class contains methods that pertain to the specific
* underlying browser implemantation type. These methods are the union
* of all such methods for underlying browser implementations. For
* example, the ICE browser needs methods setICEProps(), getStormBase,
* getViewPort(). In the mozilla implementation, these methods do
* nothing.
*/
public abstract class BrowserType extends ImplObject
{
/**
* These 3 methods, setICEProps, getStormBase and getViewPort
* are for Webclient embedding the ICE browser. For Gecko or
* IE, these methods are to be ignored
*
*/
public BrowserType(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl);
}
public abstract void setICEProps(Object base, Object viewport);
public abstract Object getStormBase();
public abstract Object getViewPort();
} // end of interface BrowserType

View File

@ -0,0 +1,82 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
*
*/
package org.mozilla.webclient.test_nonnative;
import ice.storm.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Hashtable;
/**
* A callback class to create new top level windows for the browser.
*/
public class Callback implements StormCallback {
private StormBase base;
private Hashtable windows = new Hashtable();
public void init(StormBase base) {
this.base=base;
}
public Container createTopLevelContainer(Viewport viewport) {
EMWindow f = new EMWindow(base,viewport);
windows.put(viewport.getId(),f);
f.setVisible(true);
return f.getPanel();
}
public void disposeTopLevelContainer(Viewport viewport) {
Window w = (Window)windows.get(viewport.getId());
if (w!=null) {
windows.remove(viewport.getId());
w.setVisible(false);
w.dispose();
if (windows.isEmpty()) {
System.exit(0);
}
}
}
public void message(Viewport vp, String msg) {
// newBox().showMessageBox(vp, msg);
}
public boolean confirm(Viewport vp, String msg) {
// return newBox().showConfirmBox(vp, msg);
return true;
}
public String prompt(Viewport vp, String msg, String defVal) {
// return newBox().showPromptBox(vp, msg, defVal);
return null;
}
// private BoxDialogs newBox() { return new BoxDialogs_awt(); }
}

View File

@ -0,0 +1,354 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
package org.mozilla.webclient.test_nonnative;
/*
* EMWindow.java
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Enumeration;
import java.util.Properties;
import java.util.*;
import org.mozilla.webclient.*;
import org.mozilla.util.Assert;
import org.w3c.dom.Document;
import java.io.File;
import java.io.FileInputStream;
import ice.storm.*;
import java.beans.*;
/**
*
* This is a test application for using the BrowserControl.
*
* @version $Id: EMWindow.java,v 1.1 2001-07-27 21:02:15 ashuk%eng.sun.com Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
*/
public class EMWindow extends Frame implements ActionListener, WindowListener, PropertyChangeListener {
private int winNum;
private TextField urlField;
private BrowserControl browserControl;
private Navigation navigation = null;
private CurrentPage currentPage;
private History history;
private WindowControl windowControl;
private Panel controlPanel;
private Panel statusPanel;
private Panel buttonsPanel;
private Panel panel;
private Label statusLabel;
private Label urlStatusLabel;
private String currentURL = null;
private Component forwardButton;
private Component backButton;
private Component stopButton;
private Component refreshButton;
// Just to have a frame of reference for dialog boxes
static Frame theFrame=null;
private StormBase base;
private String viewportId;
private Thread statusUpdater;
private StormBase ICEbase;
public static void main(String [] arg)
{
// Create a StormBase Object
StormBase iceBase = new StormBase();
// Init the browser for toolkit
try {
Callback myCallBack = new Callback();
StormCallback cb = (StormCallback) myCallBack;
iceBase.setCallback(cb);
}
catch (Exception e) {
System.out.println(e.toString());
}
iceBase.renderContent("http://sunweb.central.sun.com",null, "Webclient and ICE");
}
public EMWindow (StormBase b, Viewport viewport)
{
super(viewport.getName());
this.base=b;
this.viewportId=viewport.getId();
addWindowListener(this);
base.addPropertyChangeListener(this,viewportId);
// Create the URL field
urlField = new TextField("", 30);
urlField.addActionListener(this);
currentURL = "http://sunweb.central.sun.com/";
// urlField.setText();
// Create the buttons sub panel
buttonsPanel = new Panel();
buttonsPanel.setLayout(new GridBagLayout());
// Add the buttons
backButton = makeItem(buttonsPanel, "Back", 0, 0, 1, 1, 0.0, 0.0);
backButton.setEnabled(true);
forwardButton = makeItem(buttonsPanel, "Forward", 1, 0, 1, 1, 0.0, 0.0);
forwardButton.setEnabled(true);
stopButton = makeItem(buttonsPanel, "Stop", 2, 0, 1, 1, 0.0, 0.0);
stopButton.setEnabled(true);
refreshButton = makeItem(buttonsPanel, "Refresh", 3, 0, 1, 1, 0.0, 0.0);
refreshButton.setEnabled(true);
// Create the control panel
controlPanel = new Panel();
controlPanel.setLayout(new BorderLayout());
// Add the URL field, and the buttons panel
Panel centerPanel = new Panel();
centerPanel.setLayout(new BorderLayout());
centerPanel.add(urlField, BorderLayout.NORTH);
// controlPanel.add(urlField, BorderLayout.CENTER);
controlPanel.add(centerPanel, BorderLayout.CENTER);
controlPanel.add(buttonsPanel, BorderLayout.WEST);
// create the status panel
statusPanel = new Panel();
statusPanel.setLayout(new BorderLayout());
// create and add the statusLabel and the urlStatusLabel
statusLabel = new Label("", Label.LEFT);
statusLabel.setBackground(Color.lightGray);
urlStatusLabel = new Label("", Label.LEFT);
urlStatusLabel.setBackground(Color.lightGray);
Panel tPanel = new Panel();
tPanel.setLayout(new BorderLayout());
tPanel.add(statusLabel, BorderLayout.NORTH);
tPanel.add(urlStatusLabel, BorderLayout.SOUTH);
statusPanel.add(tPanel, BorderLayout.CENTER);
add(controlPanel, BorderLayout.NORTH);
add(statusPanel, BorderLayout.SOUTH);
// Create the Webclient objects
try {
BrowserControlFactory.setAppData(BrowserControl.BROWSER_TYPE_NON_NATIVE, null);
browserControl = BrowserControlFactory.newBrowserControl();
BrowserType browserType = (BrowserType)
browserControl.queryInterface(BrowserControl.BROWSER_TYPE_NAME);
browserType.setICEProps((Object) base, (Object) viewport);
}
catch(Exception e) {
System.out.println("test_nonnative: Can't create BrowserControl: " +
e.getMessage());
}
panel = new Panel();
panel.setLayout(new BorderLayout());
add(panel, BorderLayout.CENTER);
setSize(600,600);
try {
navigation = (Navigation)
browserControl.queryInterface(BrowserControl.NAVIGATION_NAME);
currentPage = (CurrentPage)
browserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
history = (History)
browserControl.queryInterface(BrowserControl.HISTORY_NAME);
System.setProperty("http.proxyHost", "webcache-cup.eng.sun.com");
System.setProperty("http.proxyPort", "8080");
}
catch (Exception e) {
System.out.println(e.toString());
System.out.println("\n\n Something went wrong when getting the Interfaces \n");
}
} // EMWindow() ctor
public Container getPanel()
{
return panel;
}
public void actionPerformed (ActionEvent evt)
{
String command = evt.getActionCommand();
try {
if(command.equals("Stop")) {
navigation.stop();
}
else if (command.equals("Refresh")) {
navigation.refresh(Navigation.LOAD_NORMAL);
}
else if (command.equals("Back")) {
System.out.println(" \n At 1 \n");
if (history.canBack()) {
System.out.println(" \n At 2 \n");
history.back();
System.out.println(" \n At 3 \n");
}
}
else if (command.equals("Forward")) {
if (history.canForward()) {
history.forward();
}
}
else if (command.equals(" ")) {
}
else {
navigation.loadURL(urlField.getText());
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
} // actionPerformed()
private Component makeItem (Panel p, Object arg, int x, int y, int w, int h, double weightx, double weighty)
{
GridBagLayout gbl = (GridBagLayout) p.getLayout();
GridBagConstraints c = new GridBagConstraints();
Component comp = null;
c.fill = GridBagConstraints.BOTH;
c.gridx = x;
c.gridy = y;
c.gridwidth = w;
c.gridheight = h;
c.weightx = weightx;
c.weighty = weighty;
if (arg instanceof String) {
Button b;
comp = b = new Button((String) arg);
b.addActionListener(this);
p.add(comp);
gbl.setConstraints(comp, c);
if (((String)arg).equals(" ")) {
b.setEnabled(false);
}
}
return comp;
} // makeItem()
// PropertyChangeListener implementation
public void propertyChange(PropertyChangeEvent e) {
Viewport v = (Viewport)e.getSource();
boolean isMyView=v.getId().equals(viewportId);
String name = e.getPropertyName();
String val = "";
String url = base.getHistoryManager().getCurrentLocation(v.getId());
urlStatusLabel.setText(url);
if (e.getNewValue() instanceof String) {
val = (String) e.getNewValue();
}
if (name.equals("statusLine")) {
statusLabel.setText(val);
}
else if (name.equals("outstandingImages")) {
if (val.equals("0")) {
statusLabel.setText("Loading images: done");
}
else {
statusLabel.setText("loading images: "+val+" left");
}
}
else if (name.equals("contentLoading")) {
if (val.equals("error")) {
ContentLoader cl = (ContentLoader)e.getOldValue();
if (cl != null) {
statusLabel.setText(v.getName()+": "+cl.getException());
}
else {
statusLabel.setText(v.getName()+": loading error");
}
}
}
}
// WindowListener implementation (remove this???)
public void windowClosing(WindowEvent e) {
base.closeViewport(viewportId);
}
public void windowClosed(WindowEvent ev) {}
public void windowOpened(WindowEvent ev) {}
public void windowIconified(WindowEvent ev) {}
public void windowDeiconified(WindowEvent ev) {}
public void windowActivated(WindowEvent ev) {}
public void windowDeactivated(WindowEvent ev) {}
//
// Package methods
//
Navigation getNavigation()
{
return navigation;
}
}
// EOF

View File

@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
package org.mozilla.webclient.wrapper_nonnative;
import org.mozilla.webclient.BrowserType;
import org.mozilla.webclient.WrapperFactory;
import org.mozilla.webclient.BrowserControl;
class BrowserTypeImpl extends BrowserType
{
public Object ICEbase = null;
public Object viewPort = null;
//
// Constructors and Initializers
//
public BrowserTypeImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl);
}
public void setICEProps(Object base, Object viewport)
{
ICEbase = base;
viewPort = viewport;
}
public Object getStormBase()
{
return ICEbase;
}
public Object getViewPort()
{
return viewPort;
}
public static void main(String [] args)
{
//Unit Tests need to go here
}
} // end of class BrowserTypeImpl

View File

@ -0,0 +1,199 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
package org.mozilla.webclient.wrapper_nonnative;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.BrowserType;
import org.mozilla.webclient.CurrentPage;
import org.mozilla.webclient.WrapperFactory;
import java.util.Properties;
import java.io.*;
import java.net.*;
import org.w3c.dom.Document;
import ice.storm.*;
import org.mozilla.webclient.UnimplementedException;
public class CurrentPageImpl extends ImplObjectNonnative implements CurrentPage
{
private StormBase ICEbase;
private Viewport viewPort;
public CurrentPageImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl);
BrowserType browserType = null;
try {
browserType = (BrowserType)
yourBrowserControl.queryInterface(BrowserControl.BROWSER_TYPE_NAME);
}
catch (Exception e) {
System.out.println(e.toString());
System.out.println("\n\n Something went wrong when getting the Interfaces \n");
}
ICEbase = (StormBase) browserType.getStormBase();
viewPort = (Viewport) browserType.getViewPort();
}
public void copyCurrentSelectionToSystemClipboard()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::copyCurrentSelectionToSystemClipboard has not yet been implemented.\n");
}
public void findInPage(String stringToFind, boolean forward, boolean matchCase)
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::findInPage has not yet been implemented.\n");
}
public void findNextInPage()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::findNextInPage has not yet been implemented.\n");
}
public String getCurrentURL()
{
String result = null;
synchronized(myBrowserControl) {
//getCurrentURL
result = ICEbase.getHistoryManager().getCurrentLocation(viewPort.getId());
}
return result;
}
public Document getDOM()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getDOM has not yet been implemented.\n");
}
public Properties getPageInfo()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getPageInfo has not yet been implemented.\n");
}
public String getSource()
{
myFactory.throwExceptionIfNotInitialized();
String HTMLContent = new String();
String currURL = getCurrentURL();
System.out.println("\nThe Current URL is -- " + currURL);
try {
URL aURL = new URL(currURL);
URLConnection connection = aURL.openConnection();
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
boolean more = true;
while (more)
{
String line = in.readLine();
if (line == null) more = false;
else
{
HTMLContent = HTMLContent + line;
}
}
}
catch (Throwable e)
{
System.out.println("Error occurred while establishing connection -- \n ERROR - " + e);
}
return HTMLContent;
}
public byte [] getSourceBytes()
{
byte [] result = null;
myFactory.throwExceptionIfNotInitialized();
String HTMLContent = new String();
String currURL = getCurrentURL();
System.out.println("\nThe Current URL is -- " + currURL);
try {
URL aURL = new URL(currURL);
URLConnection connection = aURL.openConnection();
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
boolean more = true;
while (more)
{
String line = in.readLine();
if (line == null) more = false;
else
{
HTMLContent = HTMLContent + line;
}
}
}
catch (Throwable e)
{
System.out.println("Error occurred while establishing connection -- \n ERROR - " + e);
}
result = HTMLContent.getBytes();
return result;
}
public void resetFind()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::resetFind has not yet been implemented.\n");
}
public void selectAll()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::selectAll has not yet been implemented.\n");
}
// ----VERTIGO_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
Log.setApplicationName("CurrentPageImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.1 2001-07-27 21:01:08 ashuk%eng.sun.com Exp $");
}
// ----VERTIGO_TEST_END
} // end of class CurrentPageImpl

View File

@ -0,0 +1,176 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
package org.mozilla.webclient.wrapper_nonnative;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.BrowserType;
import org.mozilla.webclient.History;
import org.mozilla.webclient.HistoryEntry;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.WrapperFactory;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.UnimplementedException;
import ice.storm.*;
import java.beans.*;
public class HistoryImpl extends ImplObjectNonnative implements History
{
private StormBase ICEbase;
private Viewport viewPort;
public HistoryImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl);
BrowserType browserType = null;
try {
browserType = (BrowserType)
yourBrowserControl.queryInterface(BrowserControl.BROWSER_TYPE_NAME);
}
catch (Exception e) {
System.out.println(e.toString());
System.out.println("\n\n Something went wrong when getting the Interfaces \n");
}
ICEbase = (StormBase) browserType.getStormBase();
viewPort = (Viewport) browserType.getViewPort();
}
public void back()
{
synchronized(myBrowserControl) {
// Here make the call to the browserControl.StormBase.HistoryManager
//object
ICEbase.getHistoryManager().goBack(viewPort.getId());
}
}
public boolean canBack()
{
boolean result;
synchronized(myBrowserControl) {
//CanBack call here
result = ICEbase.getHistoryManager().canGoBack(viewPort.getId());
}
return result;
}
public HistoryEntry [] getBackList()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function History::getBackList has not yet been implemented.\n");
}
public void clearHistory()
{
synchronized(myBrowserControl) {
//clearHistory here
ICEbase.getHistoryManager().clearHistoryForViewport(viewPort);
}
}
public void forward()
{
synchronized(myBrowserControl) {
//forward here
ICEbase.getHistoryManager().goForward(viewPort.getId());
}
}
public boolean canForward()
{
boolean result;
synchronized(myBrowserControl) {
//canForward here
result = ICEbase.getHistoryManager().canGoForward(viewPort.getId());
}
return result;
}
public HistoryEntry [] getForwardList()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function History::getForwardList has not yet been implemented.\n");
}
public HistoryEntry [] getHistory()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function History::getForwardList has not yet been implemented.\n");
}
public HistoryEntry getHistoryEntry(int historyIndex)
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function History::getHistoryEntry has not yet been implemented.\n");
}
public int getCurrentHistoryIndex()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function History::getCurrentHistoryIndex has not yet been implemented.\n");
}
public void setCurrentHistoryIndex(int historyIndex)
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function History::setCurrentHistoryIndex has not yet been implemented.\n");
}
public int getHistoryLength()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function History::getHistoryLength has not yet been implemented.\n");
}
public String getURLForIndex(int historyIndex)
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function History::getURLForIndex has not yet been implemented.\n");
}
// ----VERTIGO_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
Log.setApplicationName("HistoryImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.1 2001-07-27 21:01:09 ashuk%eng.sun.com Exp $");
}
// ----VERTIGO_TEST_END
} // end of class HistoryImpl

View File

@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
package org.mozilla.webclient.wrapper_nonnative;
// ImplObjectNative.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.ImplObject;
import org.mozilla.webclient.WrapperFactory;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.WindowControl;
public abstract class ImplObjectNonnative extends ImplObject
{
/**
* My ivars are public for fast access from subclasses in the wrapper_*
* packages.
*/
//
// Constructors and Initializers
//
public ImplObjectNonnative(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl);
}
public ImplObjectNonnative(WrapperFactory yourFactory,
BrowserControl yourBrowserControl,
boolean notUsed)
{
super(yourFactory, yourBrowserControl);
}
public void delete()
{
System.out.println("ImplObjectNative.delete()");
super.delete();
}
} // end of class ImplObject

View File

@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
package org.mozilla.webclient.wrapper_nonnative;
// JavaBrowserControlCanvas.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControlCanvas;
import org.mozilla.webclient.BrowserControl;
/**
* JavaBrowserControlCanvas provides a concrete realization of the
* BrowserControlCanvas. This is a no-op class in the java case.
* <B>Lifetime And Scope</B> <P>
* There is one instance of the BrowserControlCanvas per top level awt Frame.
* @version $Id: JavaBrowserControlCanvas.java,v 1.1 2001-07-27 21:01:11 ashuk%eng.sun.com Exp $
*
* @see org.mozilla.webclient.BrowserControlCanvasFactory
*
*/
/**
* JavaBrowserControlCanvas provides a concrete realization
* of the BrowserControlCanvas.
*/
// PENDING(ashuk) remove JavaBrowserControlCanvas.
public class JavaBrowserControlCanvas extends BrowserControlCanvas {
protected int getWindow()
{
return 1;
}
protected void initialize(BrowserControl controlImpl)
{
return;
}
}

View File

@ -0,0 +1,145 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
package org.mozilla.webclient.wrapper_nonnative;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.RangeException;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.BrowserType;
import org.mozilla.webclient.Navigation;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.WrapperFactory;
import org.mozilla.webclient.Prompt;
import org.mozilla.webclient.UnimplementedException;
import java.io.InputStream;
import java.util.Properties;
import ice.storm.*;
import java.beans.*;
public class NavigationImpl extends ImplObjectNonnative implements Navigation
{
private StormBase ICEbase;
private Viewport viewPort;
public NavigationImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl);
BrowserType browserType = null;
try {
browserType = (BrowserType)
yourBrowserControl.queryInterface(BrowserControl.BROWSER_TYPE_NAME);
}
catch (Exception e) {
System.out.println(e.toString());
System.out.println("\n\n Something went wrong when getting the Interfaces \n");
}
ICEbase = (StormBase) browserType.getStormBase();
viewPort = (Viewport) browserType.getViewPort();
}
public void loadURL(String absoluteURL)
{
synchronized(myBrowserControl) {
// Here make the call to the browserControl.StormBase
//object
ICEbase.renderContent(absoluteURL, null, viewPort.getName());
}
}
public void loadFromStream(InputStream stream, String uri,
String contentType, int contentLength,
Properties loadInfo)
{
//cant do anything here
throw new UnimplementedException("\nUnimplementedException -----\n API Function Navigation::loadFromStream has not yet been implemented.\n");
}
public void refresh(long loadFlags)
{
synchronized(myBrowserControl) {
// Reload method call here
String url = ICEbase.getHistoryManager().getCurrentLocation(viewPort.getId());
ICEbase.renderContent(url, null, viewPort.getName());
}
}
public void stop()
{
synchronized(myBrowserControl) {
// Stop call here
ICEbase.stopLoading(viewPort.getName());
}
}
public void setPrompt(Prompt yourPrompt)
{
//Nothing here
throw new UnimplementedException("\nUnimplementedException -----\n API Function Navigation::setPrompt has not yet been implemented.\n");
}
// ----VERTIGO_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
Log.setApplicationName("NavigationImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.1 2001-07-27 21:01:12 ashuk%eng.sun.com Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData("nonnative", args[0]);
org.mozilla.webclient.BrowserControl control =
org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
Assert.assert_it(control != null);
Navigation wc = (Navigation)
control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
Assert.assert_it(wc != null);
}
catch (Exception e) {
System.out.println("got exception: " + e.getMessage());
}
}
// ----VERTIGO_TEST_END
} // end of class NavigationImpl

View File

@ -0,0 +1,125 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
package org.mozilla.webclient.wrapper_nonnative;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.WrapperFactory;
import org.mozilla.webclient.UnimplementedException;
import ice.storm.*;
import java.awt.Rectangle;
public class WindowControlImpl extends ImplObjectNonnative implements WindowControl
{
public WindowControlImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl, false);
}
public void delete()
{
}
public void setBounds(Rectangle newBounds)
{
}
public void createWindow(int nativeWindow, Rectangle bounds)
{
}
public int getNativeWebShell()
{
return 0;
}
public void moveWindowTo(int x, int y)
{
}
public void removeFocus()
{
}
public void repaint(boolean forceRepaint)
{
}
public void setVisible(boolean newState)
{
}
public void setFocus()
{
}
// ----VERTIGO_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
Log.setApplicationName("WindowControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.1 2001-07-27 21:01:12 ashuk%eng.sun.com Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData("nonnative",args[0]);
org.mozilla.webclient.BrowserControl control =
org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
Assert.assert_it(control != null);
WindowControl wc = (WindowControl)
control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
Assert.assert_it(wc != null);
}
catch (Exception e) {
System.out.println("got exception: " + e.getMessage());
}
}
// ----VERTIGO_TEST_END
} // end of class WindowControlImpl

View File

@ -0,0 +1,175 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
package org.mozilla.webclient.wrapper_nonnative;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.WrapperFactory;
public class WrapperFactoryImpl extends WrapperFactory
{
//
// Protected Constants
//
final String [] implementedInterfaces =
{
BrowserControl.NAVIGATION_NAME,
BrowserControl.HISTORY_NAME,
BrowserControl.CURRENT_PAGE_NAME,
BrowserControl.BROWSER_TYPE_NAME
};
boolean initialized = false;
public WrapperFactoryImpl()
{
super();
}
/**
* @param interfaceName IMPORTANT!!!! This method assumes that
* interfaceName is one of the actual strings from the interface
* definition for BrowserControl. That is, this method is only called
* from BrowserControlImpl, and is only invoked like this
<CODE><PRE>
// BrowserControlImpl code...
if (WINDOW_CONTROL_NAME.equals(interfaceName)) {
if (null == windowControl) {
windowControl =
(WindowControl) wrapperFactory.newImpl(WINDOW_CONTROL_NAME,
this);
}
return windowControl;
}
</PRE></CODE>
* <P>
* This is done to avoid a costly string compare. This shortcut is
* justified since WrapperFactoryImpl is only called from
* BrowserControlImpl <B>and</B> the only values for interfaceName that
* make sense are those defined in BrowserControl class variables ending
* with _NAME.
* </P>
* @see org.mozilla.webclient.BrowserControl.BROWSER_CONTROL_CANVAS_NAME
*/
public Object newImpl(String interfaceName,
BrowserControl browserControl) throws ClassNotFoundException
{
Object result = null;
synchronized(this) {
if (!doesImplement(interfaceName)) {
throw new ClassNotFoundException("Can't instantiate " +
interfaceName +
": not implemented.");
}
System.out.println("non-native classes do implement " +
interfaceName);
if (BrowserControl.NAVIGATION_NAME == interfaceName) {
result = new NavigationImpl(this, browserControl);
return result;
}
if (BrowserControl.HISTORY_NAME == interfaceName) {
result = new HistoryImpl(this, browserControl);
return result;
}
if (BrowserControl.CURRENT_PAGE_NAME == interfaceName) {
result = new CurrentPageImpl(this, browserControl);
return result;
}
if (BrowserControl.BROWSER_TYPE_NAME == interfaceName) {
result = new BrowserTypeImpl(this, browserControl);
return result;
}
}
return result;
}
private boolean doesImplement(String interfaceName)
{
boolean foundInterface = false;
for (int i=0; i<implementedInterfaces.length; i++) {
if (interfaceName.equals(implementedInterfaces[i])) {
foundInterface = true;
}
}
return foundInterface;
}
public boolean hasBeenInitialized()
{
System.out.println("\n\n\n +++++ You should Never have reached Here - in hasBeenInitialized +++++ \n\n\n");
return false;
}
public void initialize(String verifiedBinDirAbsolutePath) throws Exception
{
}
public void terminate() throws Exception
{
System.out.println("\n\n\n +++++ You should Never have reached Here - in terminate +++++ \n\n\n");
}
// ----VERTIGO_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
WrapperFactory me = new WrapperFactoryImpl();
Log.setApplicationName("WrapperFactoryImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: WrapperFactoryImpl.java,v 1.1 2001-07-27 21:01:13 ashuk%eng.sun.com Exp $");
}
// ----VERTIGO_TEST_END
} // end of class WrapperFactoryImpl