The current webclient only works with M13, and the

old webclient, in classes and src, works with pre M13.

This change removes the old webclient.
This commit is contained in:
ashuk%eng.sun.com 2000-06-29 23:59:12 +00:00
Родитель 0e289e0d13
Коммит abbbc6aaff
45 изменённых файлов: 0 добавлений и 2168 удалений

Просмотреть файл

@ -35,15 +35,9 @@ IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
DEPTH = ..\..
!if defined(WEBCLIENT_PRE_SPEC)
DIRS = classes \
src \
$(NULL)
!else
DIRS = classes_spec \
src_moz \
$(NULL)
!endif
!if defined(BAL_INTERFACE)
DIRS = classes_spec \

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,48 +0,0 @@
/* -*- 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): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ann Sunhachawee
*/
package org.mozilla.webclient;
// BrowserControl.java
/**
*
* <B>BrowserControl</B> simply declares the composition of the core and extended
* interfaces.
*
* @version $Id: BrowserControl.java,v 1.3 1999-11-06 02:24:16 dmose%mozilla.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCore
* @see org.mozilla.webclient.BrowserControlExtended
*
*/
public interface BrowserControl extends BrowserControlCore, BrowserControlExtended
{
public EventRegistration getEventRegistration();
} // end of interface BrowserControl

Просмотреть файл

@ -1,254 +0,0 @@
/* -*- 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): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Mark Lin <mark.lin@eng.sun.com>
* Ed Burns <edburns@acm.org>
*/
package org.mozilla.webclient;
// BrowserControlCanvas.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import java.awt.*;
/**
*
* BrowserControlCanvas is the principal class for embedding
* the Mozilla WebShell into the Java framework.
* This component represents the proxy for the native
* WebShell class as provided by the nsIWebShell
* interface.
*
* @see org.mozilla.webclient.BrowserControl
*
* @author Kirk Baker
* @author Ian Wilkinson
* <P>
* <B>Lifetime And Scope</B> <P>
* See concrete subclasses for scope info.
* @version $Id: BrowserControlCanvas.java,v 1.6 1999-12-06 23:42:13 edburns%acm.org Exp $
* @see org.mozilla.webclient.win32.Win32BrowserControlCanvas
* @see org.mozilla.webclient.motif.MotifBrowserControlCanvas
*/
import java.awt.*;
import java.awt.Canvas;
import java.awt.event.*;
import sun.awt.*;
public abstract class BrowserControlCanvas extends Canvas
{
//
// Class Variables
//
private static int webShellCount = 0;
//
// Instance Variables
//
// Attribute Instance Variables
private boolean initializeOK;
private boolean boundsValid;
private boolean hasFocus;
// Relationship Instance Variables
private BrowserControl webShell;
private int nativeWindow;
private Rectangle windowRelativeBounds;
// PENDING(edburns): Is this needed: // private BrowserControlIdleThread idleThread;
//
// Constructors and Initializers
//
/**
* just initialize all the ivars. the initialize() method must be called
* before an instance of this class can be used. Instances are created
* in BrowserControlFactory.newBrowserControl().
*/
protected BrowserControlCanvas ()
{
nativeWindow = 0;
webShell = null;
initializeOK = false;
boundsValid = false;
hasFocus = false;
} // BrowserControlCanvas() ctor
protected void initialize(BrowserControl controlImpl)
{
ParameterCheck.nonNull(controlImpl);
webShell = controlImpl;
}
/**
* Obtain the native window handle for this component's
* peer.
*/
abstract protected int getWindow(DrawingSurfaceInfo dsi);
//
// Methods from Canvas
//
/**
* Instantiate the Mozilla WebShell container.
*/
public void addNotify ()
{
super.addNotify();
DrawingSurface ds = (DrawingSurface)this.getPeer();
DrawingSurfaceInfo dsi = ds.getDrawingSurfaceInfo();
windowRelativeBounds = new Rectangle();
// We must lock() the DrawingSurfaceInfo before
// accessing its native window handle.
dsi.lock();
nativeWindow = getWindow(dsi);
try {
Rectangle r = new Rectangle(getBoundsRelativeToWindow());
Assert.assert(null != webShell);
webShell.createWindow(nativeWindow, r);
} catch (Exception e) {
dsi.unlock();
System.out.println(e.toString());
return;
}
dsi.unlock();
initializeOK = true;
webShellCount++;
/*
requestFocus();
*/
} // addNotify()
public BrowserControl getWebShell ()
{
return webShell;
} // getWebShell()
protected Point getEventCoordsLocalToWindow(MouseEvent evt)
{
Rectangle localBounds = getBoundsRelativeToWindow();
int windowLocalX = evt.getX() + localBounds.x;
int windowLocalY = evt.getY() + localBounds.y;
return new Point(windowLocalX, windowLocalY);
} // getEventCoordsLocalToWindow()
protected Rectangle getWindowBounds ()
{// Throw an Exception?
Container parent = getParent();
if (parent != null) {
do {
// if the parent is a window, then return its bounds
if (parent instanceof Window == true) {
return parent.getBounds();
}
parent = parent.getParent();
} while (parent != null);
}
return new Rectangle();
} // getWindowBounds()
protected Rectangle getBoundsRelativeToWindow ()
{
if (boundsValid) {
return windowRelativeBounds;
}
Container parent = getParent();
Point ourLoc = getLocation();
Rectangle ourBounds = getBounds();
if (parent != null) {
do {
// if the parent is a window, then don't adjust to its offset
// and look no further
if (parent instanceof Window == true) {
break;
}
Point parentLoc = parent.getLocation();
ourLoc.translate(-parentLoc.x, -parentLoc.y);
parent = parent.getParent();
} while (parent != null);
}
windowRelativeBounds.setBounds(-ourLoc.x, -ourLoc.y, ourBounds.width, ourBounds.height);
boundsValid = true;
return windowRelativeBounds;
} // getBoundsRelativeToWindow()
public void setBounds(int x, int y, int w, int h)
{
super.setBounds(x, y, w, h);
if (webShell != null) {
System.out.println("in BrowserControlCanvas setBounds: x = " + x + " y = " + y + " w = " + w + " h = " + h);
try {
webShell.setBounds(new Rectangle(0, 0, w - 1, h - 1));
}
catch(Exception ex) {
}
}
}
public void setBounds(Rectangle rect)
{
super.setBounds(rect);
}
} // class BrowserControlCanvas
// EOF

Просмотреть файл

@ -1,72 +0,0 @@
/* -*- 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): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
*/
package org.mozilla.webclient;
// BrowserControlCore.java
import java.awt.Canvas;
import java.awt.Rectangle;
/**
*
* <B>BrowserControlCore</B> Defines the core methods for browsing
*
* @version $Id: BrowserControlCore.java,v 1.4 1999-12-03 01:55:28 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlExtended
* @see org.mozilla.webclient.BrowserControl
*
*/
public interface BrowserControlCore
{
public void loadURL(String urlString) throws Exception;
public void stop() throws Exception;
public boolean canBack() throws Exception;
public boolean canForward() throws Exception;
public boolean back() throws Exception;
public boolean forward() throws Exception;
// added by Mark Goddard OTMP 9/2/1999
public boolean refresh() throws Exception;
public int getNativeWebShell();
public void createWindow(int windowPtr, Rectangle bounds) throws Exception;
public Canvas getCanvas();
} // end of interface BrowserControlCore

Просмотреть файл

@ -1,68 +0,0 @@
/* -*- 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): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
*/
package org.mozilla.webclient;
// BrowserControlExtended.java
import java.awt.Rectangle;
/**
*
* <B>BrowserControlExtended</B> defines the interface for extended browser
* functionality
*
* @version $Id: BrowserControlExtended.java,v 1.2 1999-11-06 02:24:17 dmose%mozilla.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCore
* */
public interface BrowserControlExtended
{
public void show () throws Exception;
public void hide () throws Exception;
public void setBounds (Rectangle bounds) throws Exception;
public void moveTo (int x, int y) throws Exception;
public void setFocus () throws Exception;
public void removeFocus () throws Exception;
public void repaint (boolean forceRepaint) throws Exception;
public boolean goTo (int historyIndex) throws Exception;
public int getHistoryLength () throws Exception;
public int getHistoryIndex () throws Exception;
public String getURL (int historyIndex) throws Exception;
} // end of interface BrowserControlExtended

Просмотреть файл

@ -1,218 +0,0 @@
/* -*- 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): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Mark Lin <mark.lin@eng.sun.com>
* Ed Burns <edburns@acm.org>
*/
package org.mozilla.webclient;
// BrowserControlFactory.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import java.io.File;
import java.io.FileNotFoundException;
/**
*
* <B>BrowserControlFactory</B> creates concrete instances of BrowserControl
* <B>Lifetime And Scope</B> <P>
* This is a static class, it is neven instantiated.
*
* @version $Id: BrowserControlFactory.java,v 1.3 1999-12-23 04:09:27 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.test.EmbeddedMozilla
*/
public class BrowserControlFactory extends Object
{
//
// Protected Constants
//
//
// Class Variables
//
private static boolean appDataHasBeenSet = false;
private static Class browserControlCanvasClass = null;
private static String platformCanvasClassName = null;
//
// Instance Variables
//
// Attribute Instance Variables
// Relationship Instance Variables
//
// Constructors and Initializers
//
public BrowserControlFactory()
{
Assert.assert(false, "This class shouldn't be constructed.");
}
//
// Class methods
//
/**
* This method is used to set per-application instance data, such as
* the location of the browser binary.
* @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
{
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.");
}
// 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.win32.Win32BrowserControlCanvas";
}
if (null == platformCanvasClassName) {
Class motifDrawingSurfaceInfoClass;
try {
motifDrawingSurfaceInfoClass =
Class.forName("sun.awt.motif.MDrawingSurfaceInfo");
}
catch (Exception e) {
motifDrawingSurfaceInfoClass = null;
}
if (motifDrawingSurfaceInfoClass != null) {
platformCanvasClassName = "org.mozilla.webclient.motif.MotifBrowserControlCanvas";
}
}
if (platformCanvasClassName != null) {
browserControlCanvasClass = Class.forName(platformCanvasClassName);
}
else {
throw new ClassNotFoundException("Could not determine WebShellCanvas class to load\n");
}
try {
BrowserControlNativeShim.initialize(absolutePathToNativeBrowserBinDir);
}
catch (Exception e) {
throw new ClassNotFoundException("Can't initialize native browser: " +
e.getMessage());
}
appDataHasBeenSet = true;
}
}
public static BrowserControl newBrowserControl() throws InstantiationException, IllegalAccessException, IllegalStateException
{
if (!appDataHasBeenSet) {
throw new IllegalStateException("Can't create BrowserControlCanvasInstance: setAppData() has not been called.");
}
Assert.assert(null != browserControlCanvasClass);
BrowserControlCanvas newCanvas = null;
BrowserControl result = null;
newCanvas = (BrowserControlCanvas) browserControlCanvasClass.newInstance();
if (null != newCanvas &&
null != (result = new BrowserControlImpl(newCanvas))) {
newCanvas.initialize(result);
}
return result;
}
//
// General Methods
//
// ----UNIT_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
System.out.println("doing asserts");
Assert.setEnabled(true);
Log.setApplicationName("BrowserControlFactory");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlFactory.java,v 1.3 1999-12-23 04:09:27 edburns%acm.org Exp $");
java.awt.Canvas canvas = null;
BrowserControl control = null;
try {
BrowserControlFactory.setAppData(args[0]);
control = BrowserControlFactory.newBrowserControl();
Assert.assert(control != null);
canvas = control.getCanvas();
Assert.assert(canvas != null);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
// ----UNIT_TEST_END
} // end of class BrowserControlFactory

Просмотреть файл

@ -1,290 +0,0 @@
/* -*- 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): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
* Ann Sunhachawee
*/
package org.mozilla.webclient;
// BrowserControlImpl.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import java.awt.Rectangle;
import java.awt.Canvas;
/**
*
* <B>BrowserControlImpl</B> provides the implementation for BrowserControl
*
* <B>Lifetime And Scope</B> <P>
*
* @version $Id: BrowserControlImpl.java,v 1.9 2000-02-18 19:32:22 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControl
*
*/
public class BrowserControlImpl extends Object implements BrowserControl, EventRegistration
{
//
// Protected Constants
//
//
// Class Variables
//
//
// Instance Variables
//
// Attribute Instance Variables
// Relationship Instance Variables
/**
* a handle to the actual mozilla webShell
*/
private int nativeWebShell;
private Canvas myCanvas;
//
// Constructors and Initializers
//
protected BrowserControlImpl(Canvas yourCanvas)
{
ParameterCheck.nonNull(yourCanvas);
myCanvas = yourCanvas;
}
//
// Class methods
//
//
// General Methods
//
//
// Methods from BrowserControl
//
public void createWindow(int windowPtr, Rectangle bounds) throws Exception
{
nativeWebShell = BrowserControlNativeShim.webShellCreate(windowPtr, bounds, this);
}
public Canvas getCanvas()
{
return myCanvas;
}
public void loadURL(String urlString) throws Exception
{
BrowserControlNativeShim.webShellLoadURL(nativeWebShell, urlString);
}
public void stop() throws Exception
{
BrowserControlNativeShim.webShellStop(nativeWebShell);
}
public void show () throws Exception
{
BrowserControlNativeShim.webShellShow(nativeWebShell);
}
public void hide () throws Exception
{
BrowserControlNativeShim.webShellHide(nativeWebShell);
}
public void setBounds (Rectangle bounds) throws Exception
{
BrowserControlNativeShim.webShellSetBounds(nativeWebShell, bounds);
}
public void moveTo (int x, int y) throws Exception
{
BrowserControlNativeShim.webShellMoveTo(nativeWebShell, x, y);
}
/**
*
*/
public void setFocus () throws Exception
{
BrowserControlNativeShim.webShellSetFocus(nativeWebShell);
}
/**
*
*/
public void removeFocus () throws Exception
{
BrowserControlNativeShim.webShellRemoveFocus(nativeWebShell);
}
/**
*
*/
public void repaint (boolean forceRepaint) throws Exception
{
BrowserControlNativeShim.webShellRepaint(nativeWebShell, forceRepaint);
}
/**
*
*/
public boolean canBack () throws Exception
{
return BrowserControlNativeShim.webShellCanBack(nativeWebShell);
}
/**
*
*/
public boolean canForward () throws Exception
{
return BrowserControlNativeShim.webShellCanForward(nativeWebShell);
}
/**
*
*/
public boolean back () throws Exception
{
return BrowserControlNativeShim.webShellBack(nativeWebShell);
}
/**
*
*/
public boolean forward () throws Exception
{
return BrowserControlNativeShim.webShellForward(nativeWebShell);
}
/**
*
*/
public boolean goTo (int historyIndex) throws Exception
{
return BrowserControlNativeShim.webShellGoTo(nativeWebShell, historyIndex);
}
/**
*
*/
public int getHistoryLength () throws Exception
{
return BrowserControlNativeShim.webShellGetHistoryLength(nativeWebShell);
}
/**
*
*/
public int getHistoryIndex () throws Exception
{
return BrowserControlNativeShim.webShellGetHistoryIndex(nativeWebShell);
}
/**
*
*/
public String getURL (int historyIndex) throws Exception
{
return BrowserControlNativeShim.webShellGetURL(nativeWebShell, historyIndex);
}
/**
* Added by Mark Goddard OTMP 9/2/1999
*/
public boolean refresh() throws Exception
{
return BrowserControlNativeShim.webShellRefresh(nativeWebShell);
}
/**
* get EventRegistration object
*/
public EventRegistration getEventRegistration() {
return this;
}
/**
* add document load event listener
*/
public boolean addDocumentLoadListener(DocumentLoadListener dll) throws Exception {
return BrowserControlNativeShim.webShellAddDocListener(nativeWebShell, dll);
}
/**
*
*/
public int getNativeWebShell ()
{
return nativeWebShell;
}
/**
*
*/
public void finalize ()
{
try {
BrowserControlNativeShim.webShellDelete(nativeWebShell);
}
catch (Exception ex) {
System.out.println(ex.toString());
}
nativeWebShell = 0;
}
// ----UNIT_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
// BrowserControlImpl me = new BrowserControlImpl();
Log.setApplicationName("BrowserControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.9 2000-02-18 19:32:22 edburns%acm.org Exp $");
}
// ----UNIT_TEST_END
} // end of class BrowserControlImpl

Просмотреть файл

@ -1,430 +0,0 @@
/* -*- 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): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Mark Lin <mark.lin@eng.sun.com>
* Ed Burns <edburns@acm.org>
* Mark Goddard
* Ann Sunhachawee
*/
package org.mozilla.webclient;
// MWebShellMozillaShim.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import java.awt.*;
/**
*
* <B>MWebShellMozillaShim</B> is a class with native methods that
* provides the glue between MWebShell and nsIWebShell. <P>
* WAS: instance <P>
* <B>Lifetime And Scope</B> <P>
* There is one instance of this class and all of the exposed methods
* are static.
* @version $Id: BrowserControlNativeShim.java,v 1.2 2000-02-18 19:16:26 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlImpl
*
*/
public class BrowserControlNativeShim extends Object
{
//
// Protected Constants
//
//
// Class Variables
//
private static boolean initialized = false;
private static BrowserControlNativeShim instance = null;
private static Object lock = null;
//private static int myGtkwinptr;
//
// Instance Variables
//
// Attribute Instance Variables
// Relationship Instance Variables
//
// Constructors and Initializers
//
public BrowserControlNativeShim()
{
super();
lock = new Object();
}
//
// Class methods
//
/**
* it is safe to call this method multiple times, it is guaranteed
* to only actually do something once.
*/
public static void initialize(String verifiedBinDirAbsolutePath) throws Exception
{
if (!initialized) {
instance = new BrowserControlNativeShim();
instance.nativeInitialize(verifiedBinDirAbsolutePath);
initialized = true;
}
}
public static void terminate () throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeTerminate();
initialized = false;
}
}
}
//
// WebShell methods
//
public static int webShellCreate (int windowPtr,
Rectangle bounds, BrowserControlImpl abrowsercontrolimpl) throws Exception
{
synchronized(lock) {
if (initialized) {
return(instance.nativeWebShellCreate(windowPtr,
bounds.x, bounds.y,
bounds.width + 1,
bounds.height + 1,
abrowsercontrolimpl));
}
else {
throw new Exception("Error: unable to create native nsIWebShell");
}
}
}
public static void webShellDelete (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellDelete(webShellPtr);
}
}
}
public static boolean webShellAddDocListener(int webShellPtr, DocumentLoadListener dl) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellAddDocListener(webShellPtr, dl);
} else {
throw new Exception ("instance is not initialized");
}
}
}
public static void webShellLoadURL (int webShellPtr,
String urlString) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellLoadURL(webShellPtr, urlString);
}
}
}
public static void webShellStop (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellStop(webShellPtr);
}
}
}
public static void webShellShow (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellShow(webShellPtr);
}
}
}
public static void webShellHide (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellHide(webShellPtr);
}
}
}
public static void webShellSetBounds (int webShellPtr,
Rectangle bounds) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellSetBounds(webShellPtr, bounds.x, bounds.y, bounds.width + 1, bounds.height + 1);
}
}
}
public static void webShellMoveTo (int webShellPtr,
int x, int y) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellMoveTo(webShellPtr, x, y);
}
}
}
public static void webShellSetFocus (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellSetFocus(webShellPtr);
}
}
}
public static void webShellRemoveFocus (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellRemoveFocus(webShellPtr);
}
}
}
public static void webShellRepaint (int webShellPtr,
boolean forceRepaint) throws Exception
{
synchronized(lock) {
if (initialized) {
instance.nativeWebShellRepaint(webShellPtr, forceRepaint);
}
}
}
public static boolean webShellCanBack (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellCanBack(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static boolean webShellCanForward (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellCanForward(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static boolean webShellBack (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellBack(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static boolean webShellForward (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellForward(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static boolean webShellGoTo (int webShellPtr,
int historyIndex) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellGoTo(webShellPtr, historyIndex);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static int webShellGetHistoryLength (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellGetHistoryLength(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static int webShellGetHistoryIndex (int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellGetHistoryIndex(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
public static String webShellGetURL(int webShellPtr,
int historyIndex) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellGetURL(webShellPtr, historyIndex);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
/**
* Added by Mark Goddard OTMP 9/2/1999
*/
public static boolean webShellRefresh(int webShellPtr) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellRefresh(webShellPtr);
}
else {
throw new Exception("instance is not initialized.");
}
}
}
//
// Native interfaces
//
private native void nativeInitialize (String verifiedBinDirAbsolutePath) throws Exception;
private native void nativeTerminate () throws Exception;
//
// WebShell interface
//
private native void nativeDummy (BrowserControlNativeShim testShim);
private native int nativeWebShellCreate (int windowPtr,
int x, int y, int width, int height, BrowserControlImpl abrowsercontrolimpl) throws Exception;
private native void nativeWebShellDelete (int webShellPtr) throws Exception;
private native void nativeWebShellLoadURL (int webShellPtr, String urlString) throws Exception;
private native void nativeWebShellStop (int webShellPtr) throws Exception;
private native void nativeWebShellShow (int webShellPtr) throws Exception;
private native void nativeWebShellHide (int webShellPtr) throws Exception;
private native void nativeWebShellSetBounds (int webShellPtr, int x, int y, int width, int height) throws Exception;
private native void nativeWebShellMoveTo (int webShellPtr, int x, int y) throws Exception;
private native void nativeWebShellSetFocus (int webShellPtr) throws Exception;
private native void nativeWebShellRemoveFocus (int webShellPtr) throws Exception;
private native void nativeWebShellRepaint (int webShellPtr, boolean forceRepaint) throws Exception;
private native boolean nativeWebShellCanBack (int webShellPtr) throws Exception;
private native boolean nativeWebShellCanForward (int webShellPtr) throws Exception;
private native boolean nativeWebShellBack (int webShellPtr) throws Exception;
private native boolean nativeWebShellForward (int webShellPtr) throws Exception;
private native boolean nativeWebShellGoTo (int webShellPtr, int aHistoryIndex) throws Exception;
private native int nativeWebShellGetHistoryLength (int webShellPtr) throws Exception;
private native int nativeWebShellGetHistoryIndex (int webShellPtr) throws Exception;
private native String nativeWebShellGetURL (int webShellPtr, int aHistoryIndex) throws Exception;
/**
* Added by Mark Goddard OTMP 9/2/1999
*/
private native boolean nativeWebShellRefresh (int webShellPtr) throws Exception;
private native boolean nativeWebShellAddDocListener(int webShellPtr, DocumentLoadListener dl);
public static native void nativeDebugBreak(String fileName, int lineNumber);
//
// General Methods
//
// ----UNIT_TEST_START
//
// Test methods
//
public static void main(String [] args)
{
Assert.setEnabled(true);
BrowserControlNativeShim me = new BrowserControlNativeShim();
Log.setApplicationName("BrowserControlNativeShim");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlNativeShim.java,v 1.2 2000-02-18 19:16:26 edburns%acm.org Exp $");
}
// ----UNIT_TEST_END
} // end of class BrowserControlNativeShim

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,142 +0,0 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Sun
* Microsystems, Inc. Portions created by Sun are
* Copyright (C) 1999 Sun Microsystems, Inc. All
* Rights Reserved.
*
* Contributor(s):
*/
package org.mozilla.webclient.motif;
// MotifBrowserControlCanvas.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
/**
* MotifBrowserControlCanvas provides a concrete realization
* of the RaptorCanvas for Motif.
* <B>Lifetime And Scope</B> <P>
* There is one instance of the WebShellCanvas per top level awt Frame.
* @version $Id: MotifBrowserControlCanvas.java,v 1.6 1999-12-23 04:09:30 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCanvasFactory
*
*/
import sun.awt.*;
import sun.awt.motif.*;
import java.awt.*;
import org.mozilla.webclient.*;
/**
* MotifBrowserControlCanvas provides a concrete realization
* of the RaptorCanvas.
*/
public class MotifBrowserControlCanvas extends BrowserControlCanvas /* implements ActionListener*/ {
static {
System.loadLibrary("webclientstub");
MotifBrowserControlCanvas.loadMainDll();
}
static private boolean firstTime = true;
private int gtkWinID;
private int gtkTopWindow;
private int canvasWinID;
private int gtkWinPtr;
private MDrawingSurfaceInfo drawingSurfaceInfo;
static private native void loadMainDll();
private native int createTopLevelWindow();
private native int createContainerWindow(int parent, int width, int height);
private native int getGTKWinID(int gtkWinPtr);
private native void reparentWindow(int child, int parent);
private native void processEvents();
private native void setGTKWindowSize(int gtkWinPtr, int width, int height);
public MotifBrowserControlCanvas() {
super();
this.gtkWinID = 0;
this.canvasWinID = 0;
this.gtkWinPtr = 0;
this.drawingSurfaceInfo = null;
}
public void paint(Graphics g) {
super.paint(g);
if (firstTime) {
synchronized(getTreeLock()) {
canvasWinID = this.drawingSurfaceInfo.getDrawable();
this.reparentWindow(this.gtkWinID, this.canvasWinID);
firstTime = false;
}
}
}
public void setBounds(int x, int y, int width, int height) {
super.setBounds(x, y, width, height);
synchronized(getTreeLock()) {
this.setGTKWindowSize(this.gtkTopWindow, width, height);
}
}
/**
* Needed for the hashtable look up of gtkwinid <-> WebShellInitContexts
*/
public int getGTKWinPtr() {
return this.gtkWinPtr;
}
/**
* Obtain the native window handle for this
* component's peer.
*
* @returns The native window handle.
*/
protected int getWindow(DrawingSurfaceInfo dsi) {
synchronized(getTreeLock()) {
this.drawingSurfaceInfo = (MDrawingSurfaceInfo) dsi;
this.gtkTopWindow = this.createTopLevelWindow();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.gtkWinPtr =
this.createContainerWindow(this.gtkTopWindow, screenSize.width,
screenSize.height);
this.gtkWinID = this.getGTKWinID(gtkWinPtr);
Thread nativeEventThread = new NativeEventThread(this);
nativeEventThread.start();
}
return this.gtkWinPtr;
}
}

Просмотреть файл

@ -1,98 +0,0 @@
/* -*- 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 mozilla.org code.
*
* The Initial Developer of the Original Code is Sun
* Microsystems, Inc. Portions created by Sun are
* Copyright (C) 1999 Sun Microsystems, Inc. All
* Rights Reserved.
*
* Contributor(s):
*/
package org.mozilla.webclient.motif;
/**
* This is NativeEventThread. It's job is to process any pending mozilla events
* which have been queued up.
*
* It also contains a private static hashtable mapping of GTK window to
* WebShellInitContexts (see BrowserControllMozillaShim.cpp). It needs this
* because in order to process any GTK / Mozilla events, it needs a pointer
* to the native event queue, the native web shell, as well as native pointers
* to other things which it can't readily access.
* So what we do is when the WebShellInitContext for a GTK Window first gets
* created, it gets stored in the webShellContextMapping hashtable below. Then
* we can now easily lookup the appropriate WebShellInitContext when it is needed.
*
* <B>Lifetime And Scope</B> <P>
* There will be one of these per BrowserControlCanvas (but hasn't been tested yet)
*
* @version $Id: NativeEventThread.java,v 1.1 1999-12-23 04:09:31 edburns%acm.org Exp $
* @see org.mozilla.webclient.motif.NativeEventThread
*
*/
import java.util.*;
public class NativeEventThread extends Thread {
static private int eventQueueCount = 0;
// A mapping of gtkWindowID <-> WebShellInitContext structs
static private Hashtable webShellContextMapping = null;
protected MotifBrowserControlCanvas browserCanvas;
// Calling this will process any GTK / Mozilla events which have been pending
public native void processNativeEventQueue(int nativeWebShellContext);
public static void storeContext(int gtkWinID, int nativeWebShellContext) {
if (webShellContextMapping == null) {
webShellContextMapping = new Hashtable();
}
webShellContextMapping.put(new Integer(gtkWinID), new Integer(nativeWebShellContext));
}
public static int getContext(int gtkWinID) {
Integer result = (Integer) webShellContextMapping.get(new Integer(gtkWinID));
if (result != null) {
return result.intValue();
}
System.out.println("Requested invalid NativeWebShellInitContext!\n");
return 0;
}
public NativeEventThread(MotifBrowserControlCanvas canvas) {
super("Mozilla-Event-Thread-" + eventQueueCount);
this.browserCanvas = canvas;
eventQueueCount++;
this.setPriority(Thread.MAX_PRIORITY);
}
public void run() {
// Infinite loop to eternity.
while (true) {
// PENDING(mark): Do we need to yield?
// Thread.currentThread().yield();
synchronized(this.browserCanvas.getTreeLock()) {
this.processNativeEventQueue(getContext(this.browserCanvas.getGTKWinPtr()));
}
}
}
}

Просмотреть файл

@ -1,218 +0,0 @@
/* -*- 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): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
*/
package org.mozilla.webclient.test;
/*
* EmbeddedMozilla.java
*/
import java.awt.*;
import java.awt.event.*;
import org.mozilla.webclient.*;
import org.mozilla.util.Assert;
/**
*
* This is a test application for using the BrowserControl.
*
* @version $Id: EmbeddedMozilla.java,v 1.6 1999-12-06 23:31:06 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
*/
public class EmbeddedMozilla extends Frame implements ActionListener {
static final int defaultWidth = 640;
static final int defaultHeight = 480;
private TextField urlField;
private BrowserControl browserControl;
private Panel controlPanel;
private Panel buttonsPanel;
public static void printUsage()
{
System.out.println("usage: java org.mozilla.webclient.test.EmbeddedMozilla <path> [url]");
System.out.println(" <path> is the absolute path to the native browser bin directory, ");
System.out.println(" including the bin.");
}
public static void main (String[] arg) {
if (1 > arg.length) {
printUsage();
System.exit(-1);
}
String urlArg =(2 == arg.length) ? arg[1] : "http://www.mozilla.org/";
EmbeddedMozilla gecko =
new EmbeddedMozilla("Embedded Mozilla", arg[0], urlArg);
} // main()
public EmbeddedMozilla (String title, String binDir, String url) {
super(title);
System.out.println("constructed with binDir: " + binDir + " url: " +
url);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
// should close the BrowserControlCanvas
}
public void windowClosed(WindowEvent e) {
System.exit(0);
}
});
setSize(defaultWidth, defaultHeight);
// Create the URL field
urlField = new TextField("", 30);
urlField.addActionListener(this);
// Create the buttons sub panel
buttonsPanel = new Panel();
buttonsPanel.setLayout(new GridBagLayout());
// Add the buttons
makeItem(buttonsPanel, "Back", 0, 0, 1, 1, 0.0, 0.0);
makeItem(buttonsPanel, "Forward", 1, 0, 1, 1, 0.0, 0.0);
makeItem(buttonsPanel, "Stop", 2, 0, 1, 1, 0.0, 0.0);
makeItem(buttonsPanel, "Refresh", 3, 0, 1, 1, 0.0, 0.0);
// Create the control panel
controlPanel = new Panel();
controlPanel.setLayout(new BorderLayout());
// Add the URL field, and the buttons panel
controlPanel.add(urlField, BorderLayout.CENTER);
controlPanel.add(buttonsPanel, BorderLayout.WEST);
// Create the browser
Canvas browserCanvas = null;
try {
BrowserControlFactory.setAppData(binDir);
browserControl = BrowserControlFactory.newBrowserControl();
}
catch(Exception e) {
System.out.println("Can't create BrowserControl: " +
e.getMessage());
}
browserCanvas = browserControl.getCanvas();
Assert.assert(null != browserCanvas);
browserCanvas.setSize(defaultWidth, defaultHeight);
// Add the control panel and the browserCanvas
add(controlPanel, BorderLayout.NORTH);
add(browserCanvas, BorderLayout.CENTER);
pack();
show();
toFront();
try {
browserControl.loadURL(url);
urlField.setText(url);
}
catch (Exception e) {
System.out.println(e.toString());
}
} // EmbeddedMozilla() ctor
public void actionPerformed (ActionEvent evt) {
String command = evt.getActionCommand();
try {
if (command.equals("Back")) {
if (browserControl.canBack()) {
browserControl.back();
int index = browserControl.getHistoryIndex();
String newURL = browserControl.getURL(index);
System.out.println(newURL);
urlField.setText(newURL);
}
}
else if (command.equals("Forward")) {
if (browserControl.canForward()) {
browserControl.forward();
int index = browserControl.getHistoryIndex();
String newURL = browserControl.getURL(index);
System.out.println(newURL);
urlField.setText(newURL);
}
}
else if (command.equals("Stop")) {
browserControl.stop();
}
else if (command.equals("Refresh")) {
browserControl.refresh();
}
else {
browserControl.loadURL(urlField.getText());
}
}
catch (Exception e) {
System.out.println(e.toString());
}
} // actionPerformed()
private void 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;
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);
}
} // makeItem()
}
// EOF

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,251 +0,0 @@
/* -*- 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): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Ann Sunhachawee
*/
package org.mozilla.webclient.test.swing;
/*
* SwingEmbeddedMozilla.java
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.mozilla.webclient.*;
import org.mozilla.util.Assert;
/**
*
* This is a test application for using the BrowserControl.
*
* @version $Id: SwingEmbeddedMozilla.java,v 1.3 1999-12-03 01:55:31 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
*/
public class SwingEmbeddedMozilla extends JFrame
{
static final int defaultWidth = 640;
static final int defaultHeight = 480;
static String binDir = null;
private TextField urlField;
private BrowserControl browserControl;
private CommandPanel controlPanel;
public static void printUsage()
{
System.out.println("usage: java org.mozilla.webclient.test.SwingEmbeddedMozilla <path> [url]");
System.out.println(" <path> is the absolute path to the native browser bin directory, ");
System.out.println(" including the bin.");
}
public static void main (String[] arg) {
if (1 > arg.length) {
printUsage();
System.exit(-1);
}
String urlArg =(2 == arg.length) ? arg[1] : "http://www.mozilla.org/";
SwingEmbeddedMozilla.binDir = arg[0];
SwingEmbeddedMozilla gecko =
new SwingEmbeddedMozilla("Embedded Mozilla", arg[0], urlArg);
} // main()
public SwingEmbeddedMozilla (String title, String binDir, String url)
{
super(title);
Container contentPane = getContentPane();
JMenuBar menubar = createMenuBar();
System.out.println("constructed with " + url);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
// should close the BrowserControlCanvas
}
public void windowClosed(WindowEvent e) {
System.exit(0);
}
});
setSize(defaultWidth, defaultHeight);
// Create the browser
Canvas browserCanvas = null;
try {
BrowserControlFactory.setAppData(binDir);
browserControl = BrowserControlFactory.newBrowserControl();
}
catch(Exception e) {
System.out.println("Can't create BrowserControlCanvas: " +
e.getMessage());
}
browserCanvas = browserControl.getCanvas();
Assert.assert(null != browserCanvas);
browserCanvas.setSize(defaultWidth, defaultHeight);
// Add the control panel and the browser
contentPane.add(browserCanvas, BorderLayout.CENTER);
controlPanel = new CommandPanel(this);
contentPane.add(controlPanel, BorderLayout.NORTH);
getRootPane().setMenuBar(menubar);
pack();
show();
toFront();
// DocumentLoadListener dll;
try {
// dll = new DocumentLoadListener();
// browserControl.getEventRegistration().addDocumentLoadListener(dll);
contentPane.add(new StatusTextField(browserControl), BorderLayout.SOUTH);
} catch (Exception ex) {
System.out.println(ex.toString());
}
try {
browserControl.loadURL(url);
controlPanel.getURLField().setText(url);
}
catch (Exception e) {
System.out.println(e.toString());
}
} // SwingEmbeddedMozilla() ctor
private JMenuBar createMenuBar()
{
JMenuBar menubar = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem exitItem = new JMenuItem("Exit");
JMenuItem newItem = new JMenuItem("New Window");
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK);
KeyStroke ks_new = KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK);
menu.getPopupMenu().setLightWeightPopupEnabled(false);
newItem.setAccelerator(ks_new);
newItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new SwingEmbeddedMozilla("New Window", SwingEmbeddedMozilla.binDir,
controlPanel.getURLField().getText());
}
});
exitItem.setAccelerator(ks);
exitItem.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
menu.setMnemonic('F');
exitItem.setMnemonic(KeyEvent.VK_X);
newItem.setMnemonic(KeyEvent.VK_N);
menu.add(newItem);
menu.add(exitItem);
menubar.add(menu);
return menubar;
}
public void back()
{
try {
if (browserControl.canBack()) {
browserControl.back();
int index = browserControl.getHistoryIndex();
String newURL = browserControl.getURL(index);
System.out.println(newURL);
controlPanel.getURLField().setText(newURL);
}
} catch (Exception e) {
System.out.println( "anns: exception in back "+ e.toString());
}
}
public void forward()
{
try {
if (browserControl.canForward()) {
browserControl.forward();
int index = browserControl.getHistoryIndex();
String newURL = browserControl.getURL(index);
System.out.println(newURL);
controlPanel.getURLField().setText(newURL);
}
} catch (Exception e) {
System.out.println( "anns: exception in forward "+ e.toString());
}
}
public void stop()
{
try {
browserControl.stop();
} catch (Exception e) {
System.out.println("anns: exception in stop "+ e.toString());
}
}
public void refresh()
{
try {
browserControl.refresh();
} catch (Exception e) {
System.out.println("anns: exception in refresh" + e.toString());
}
}
public void loadURL(String url)
{
try {
browserControl.loadURL(url);
} catch (Exception e) {
System.out.println("anns: exception in load "+ e.toString());
}
}
}
// EOF

Просмотреть файл

@ -1,73 +0,0 @@
/* -*- 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.win32;
// Win32BrowserControlCanvas.java
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
/**
* Win32RaptorCanvas provides a concrete realization
* of the RaptorCanvas.
* <B>Lifetime And Scope</B> <P>
* There is one instance of the BrowserControlCanvas per top level awt Frame.
* @version $Id: Win32BrowserControlCanvas.java,v 1.2 1999-11-06 02:24:19 dmose%mozilla.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCanvasFactory
*
*/
import sun.awt.*;
import sun.awt.windows.*;
import org.mozilla.webclient.*;
/**
* Win32BrowserControlCanvas provides a concrete realization
* of the RaptorCanvas.
*/
public class Win32BrowserControlCanvas extends BrowserControlCanvas {
static {
System.loadLibrary("webclient");
}
/**
* Obtain the native window handle for this
* component's peer.
*
* @returns The native window handle.
*/
protected int getWindow(DrawingSurfaceInfo dsi) {
WDrawingSurfaceInfo ds = (WDrawingSurfaceInfo)dsi;
return ds.getHWnd();
}
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл