зеркало из https://github.com/mozilla/gecko-dev.git
a=edburns
r=ashuk bug=2069 Java classes for spec compliant webclient impl.
This commit is contained in:
Родитель
61559aa5d3
Коммит
c231d6c5d9
|
@ -0,0 +1,24 @@
|
|||
# PENDING(mark): I need to make this makefile a little smarter. Right now
|
||||
# it javac's all the java files each time you do a 'make'
|
||||
#
|
||||
# If you're using JDK 1.2
|
||||
JDK_LOCATION = ${JDKHOME}
|
||||
JAVAC = ${JDK_LOCATION}/bin/javac
|
||||
JAVAH = ${JDK_LOCATION}/bin/javah
|
||||
OUTPUT_DIR = ../../../dist/classes
|
||||
# If you're using JDK 1.2
|
||||
CLASSES = ${OUTPUT_DIR}:${JDK_LOCATION}/lib/tools.jar:${JDK_LOCATION}/lib/rt.jar
|
||||
JAVA_FILES = ./org/mozilla/webclient/*.java ./org/mozilla/webclient/motif/*.java ./org/mozilla/webclient/test/*.java
|
||||
JAVAH_OUTPUT_DIR = ../src
|
||||
CP = cp
|
||||
MKDIR = mkdir -p
|
||||
|
||||
all:
|
||||
${MKDIR} ${OUTPUT_DIR}
|
||||
${JAVAC} -g -classpath ${CLASSES} -d ${OUTPUT_DIR} ${JAVA_FILES}
|
||||
${JAVAH} -jni -classpath ${CLASSES} \
|
||||
-o ${JAVAH_OUTPUT_DIR}/motif/MotifBrowserControlCanvas.h org.mozilla.webclient.motif.MotifBrowserControlCanvas
|
||||
${JAVAH} -jni -classpath ${CLASSES} \
|
||||
-o ${JAVAH_OUTPUT_DIR}/motif/MozillaEventThread.h org.mozilla.webclient.motif.NativeEventThread
|
||||
${JAVAH} -jni -classpath ${CLASSES} \
|
||||
-o ${JAVAH_OUTPUT_DIR}/BrowserControlNativeShim.h org.mozilla.webclient.BrowserControlNativeShim
|
|
@ -0,0 +1,70 @@
|
|||
#!nmake
|
||||
#
|
||||
# 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):
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build the java portion of the java wrapper to mozilla
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..\..
|
||||
|
||||
# PENDING(edburns): find out where this should really get defined
|
||||
JAVA_OR_NSJVM=1
|
||||
NO_CAFE=1
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
# for compatibility
|
||||
include <$(DEPTH)\java\config\localdefs.mak>
|
||||
|
||||
JAR_WEBCLIENT_CLASSES = \
|
||||
org\mozilla\webclient \
|
||||
org\mozilla\webclient\wrapper_native \
|
||||
org\mozilla\webclient\wrapper_native\win32 \
|
||||
org\mozilla\webclient\test \
|
||||
|
||||
|
||||
# org\mozilla\webclient\test org\mozilla\webclient\win32 org\mozilla\webclient\test\swing
|
||||
|
||||
!ifdef JAVA_OR_NSJVM
|
||||
JDIRS = $(JAR_WEBCLIENT_CLASSES)
|
||||
!endif
|
||||
|
||||
WEBCLIENT_JAR_NAME=webclient(VERSION_NUMBER).jar
|
||||
|
||||
JAVAC_PROG=$(JDKHOME)\bin\javac
|
||||
|
||||
export::
|
||||
@echo +++ Checking that org.mozilla.util classes have been built...
|
||||
if not exist $(MOZ_SRC)\mozilla\dist\classes\org\mozilla\util\Assert.class \
|
||||
stopbuild.exe
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.swing.tree.MutableTreeNode;
|
||||
|
||||
public interface BookmarkEntry extends MutableTreeNode
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
* Property names
|
||||
|
||||
*/
|
||||
|
||||
public final static String ADD_DATE = "AddDate";
|
||||
public final static String LAST_MODIFIED_DATE = "LastModifiedDate";
|
||||
public final static String LAST_VISIT_DATE = "LastVisitDate";
|
||||
public final static String NAME = "Name";
|
||||
public final static String URL = "URL";
|
||||
public final static String DESCRIPTION = "Description";
|
||||
|
||||
public Properties getProperties();
|
||||
|
||||
public boolean isFolder();
|
||||
|
||||
|
||||
}
|
||||
// end of interface BookmarkEntry
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import javax.swing.tree.TreeModel;
|
||||
|
||||
public interface Bookmarks
|
||||
{
|
||||
|
||||
public void addBookmark(BookmarkEntry mayBeNullParent,
|
||||
BookmarkEntry bookmark);
|
||||
|
||||
public TreeModel getBookmarks() throws IllegalStateException;
|
||||
|
||||
public void removeBookmark(BookmarkEntry bookmark);
|
||||
|
||||
public BookmarkEntry newBookmarkEntry(String url);
|
||||
|
||||
public BookmarkEntry newBookmarkFolder(String name);
|
||||
|
||||
}
|
||||
// end of interface Bookmarks
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
*
|
||||
* 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
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
* Provides a common access point for other webclient interfaces. There
|
||||
* is one instance of this class per application-level browser window.
|
||||
* Instances must be created using BrowserControlFactory.
|
||||
|
||||
|
||||
*
|
||||
* @version $Id: BrowserControl.java,v 1.1 2000/03/04 01:10:51 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlFactory
|
||||
* */
|
||||
|
||||
public interface BrowserControl
|
||||
{
|
||||
|
||||
public static String BOOKMARKS_NAME = "webclient.Bookmarks";
|
||||
public static String BROWSER_CONTROL_CANVAS_NAME = "webclient.BrowserControlCanvas";
|
||||
public static String CURRENT_PAGE_NAME = "webclient.CurrentPage";
|
||||
public static String EVENT_REGISTRATION_NAME = "webclient.EventRegistration";
|
||||
public static String EXTENDED_EVENT_REGISTRATION_NAME = "webclient.ExtendedEventRegistration";
|
||||
public static String HISTORY_NAME = "webclient.History";
|
||||
public static String NAVIGATION_NAME = "webclient.Navigation";
|
||||
public static String CACHE_MANAGER_NAME = "webclient.cache.NetDataCacheManager";
|
||||
public static String PREFERENCES_NAME = "webclient.Preferences";
|
||||
public static String PRINT_NAME = "webclient.Print";
|
||||
public static String WINDOW_CONTROL_NAME = "webclient.WindowControl";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* @param interfaceName valid values for <code>interfaceName</code>
|
||||
* are any of the *_NAME class variables in this interface.
|
||||
|
||||
*/
|
||||
|
||||
public Object queryInterface(String interfaceName) throws ClassNotFoundException;
|
||||
|
||||
} // end of interface BrowserControl
|
|
@ -0,0 +1,263 @@
|
|||
/* -*- 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.1 2000/03/04 01:10:51 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);
|
||||
|
||||
WindowControl wc = (WindowControl)
|
||||
webShell.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
wc.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);
|
||||
Rectangle boundsRect = new Rectangle(0, 0, w - 1, h - 1);
|
||||
if (webShell != null) {
|
||||
System.out.println("in BrowserControlCanvas setBounds: x = " + x + " y = " + y + " w = " + w + " h = " + h);
|
||||
try {
|
||||
WindowControl wc = (WindowControl)
|
||||
webShell.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
wc.setBounds(boundsRect);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
System.out.println("Can't setBounds(" + boundsRect + ") " +
|
||||
ex.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBounds(Rectangle rect)
|
||||
{
|
||||
super.setBounds(rect);
|
||||
}
|
||||
|
||||
} // class BrowserControlCanvas
|
||||
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,222 @@
|
|||
/* -*- 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.1 2000/03/04 01:10:51 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.");
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (motifDrawingSurfaceInfoClass != null) {
|
||||
platformCanvasClassName = "org.mozilla.webclient.wrapper_native.motif.MotifBrowserControlCanvas";
|
||||
}
|
||||
}
|
||||
if (platformCanvasClassName != null) {
|
||||
browserControlCanvasClass = Class.forName(platformCanvasClassName);
|
||||
}
|
||||
else {
|
||||
throw new ClassNotFoundException("Could not determine WebShellCanvas class to load\n");
|
||||
}
|
||||
|
||||
try {
|
||||
BrowserControlImpl.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 BrowserControl instance: 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.1 2000/03/04 01:10:51 edburns%acm.org Exp $");
|
||||
|
||||
BrowserControlCanvas canvas = null;
|
||||
BrowserControl control = null;
|
||||
try {
|
||||
BrowserControlFactory.setAppData(args[0]);
|
||||
control = BrowserControlFactory.newBrowserControl();
|
||||
Assert.assert(control != null);
|
||||
canvas = (BrowserControlCanvas) control.queryInterface("webclient.BrowserControlCanvas");
|
||||
Assert.assert(canvas != null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ----UNIT_TEST_END
|
||||
|
||||
} // end of class BrowserControlFactory
|
|
@ -0,0 +1,241 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
// BrowserControlImpl
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
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
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Strings for the names of the interfaces supported by QI.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* the factory for creating instances of webclient interfaces
|
||||
|
||||
*/
|
||||
|
||||
private static WrapperFactory wrapperFactory = null;
|
||||
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
|
||||
private BrowserControlCanvas myCanvas = null;
|
||||
private CurrentPage currentPage = null;
|
||||
private EventRegistration eventRegistration = null;
|
||||
private WindowControl windowControl = null;
|
||||
private Navigation navigation = null;
|
||||
private History history = null;
|
||||
private static Bookmarks bookmarks = null;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public BrowserControlImpl(BrowserControlCanvas yourCanvas)
|
||||
{
|
||||
super();
|
||||
ParameterCheck.nonNull(yourCanvas);
|
||||
myCanvas = yourCanvas;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
static void initialize(String verifiedBinDirAbsolutePath) throws Exception
|
||||
{
|
||||
if (null == wrapperFactory) {
|
||||
wrapperFactory = createWrapperFactory();
|
||||
}
|
||||
wrapperFactory.initialize(verifiedBinDirAbsolutePath);
|
||||
}
|
||||
|
||||
static void terminate() throws Exception
|
||||
{
|
||||
Assert.assert(null != wrapperFactory);
|
||||
|
||||
wrapperFactory.terminate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Creates an instance of the appropriate wrapper factory, based on the
|
||||
* current package name and a parameterized string value. This method
|
||||
* uses reflection to obtain the right WrapperFactory concrete subclass,
|
||||
* either native or nonnative. This method should only be called once.
|
||||
|
||||
*/
|
||||
|
||||
private static WrapperFactory createWrapperFactory() throws ClassNotFoundException
|
||||
{
|
||||
String wrapperFactoryClassName = null;
|
||||
Class wrapperFactoryClass = null;
|
||||
WrapperFactory result = null;
|
||||
|
||||
// get the current package name
|
||||
if (null == (wrapperFactoryClassName =
|
||||
Utilities.getPackageName(BrowserControlImpl.class))){
|
||||
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 = "native";
|
||||
|
||||
|
||||
// tack on the appropriate stuff
|
||||
wrapperFactoryClassName = wrapperFactoryClassName + "wrapper_" +
|
||||
PARAMETERIZED_VALUE + "." + WrapperFactory.IMPL_NAME;
|
||||
|
||||
wrapperFactoryClass = Class.forName(wrapperFactoryClassName);
|
||||
|
||||
try {
|
||||
result = (WrapperFactory) wrapperFactoryClass.newInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ClassNotFoundException(e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from BrowserControl
|
||||
//
|
||||
|
||||
public Object queryInterface(String interfaceName) throws ClassNotFoundException
|
||||
{
|
||||
ParameterCheck.nonNull(interfaceName);
|
||||
|
||||
Assert.assert(null != wrapperFactory);
|
||||
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
|
||||
// mechanism that doesn't require recompilation. See the last bit
|
||||
// of this big-ass if statement.
|
||||
|
||||
if (NAVIGATION_NAME.equals(interfaceName)) {
|
||||
if (null == navigation) {
|
||||
navigation = (Navigation) wrapperFactory.newImpl(NAVIGATION_NAME,
|
||||
this);
|
||||
}
|
||||
return navigation;
|
||||
}
|
||||
if (HISTORY_NAME.equals(interfaceName)) {
|
||||
if (null == history) {
|
||||
history = (History) wrapperFactory.newImpl(HISTORY_NAME, this);
|
||||
}
|
||||
return history;
|
||||
}
|
||||
if (BROWSER_CONTROL_CANVAS_NAME.equals(interfaceName)) {
|
||||
Assert.assert(null != myCanvas);
|
||||
return myCanvas;
|
||||
}
|
||||
if (CURRENT_PAGE_NAME.equals(interfaceName)) {
|
||||
if (null == currentPage) {
|
||||
currentPage =
|
||||
(CurrentPage) wrapperFactory.newImpl(CURRENT_PAGE_NAME,
|
||||
this);
|
||||
}
|
||||
return currentPage;
|
||||
}
|
||||
if (WINDOW_CONTROL_NAME.equals(interfaceName)) {
|
||||
if (null == windowControl) {
|
||||
windowControl =
|
||||
(WindowControl) wrapperFactory.newImpl(WINDOW_CONTROL_NAME,
|
||||
this);
|
||||
}
|
||||
return windowControl;
|
||||
}
|
||||
if (EVENT_REGISTRATION_NAME.equals(interfaceName)) {
|
||||
if (null == eventRegistration) {
|
||||
eventRegistration = (EventRegistration)
|
||||
wrapperFactory.newImpl(EVENT_REGISTRATION_NAME,
|
||||
this);
|
||||
}
|
||||
return eventRegistration;
|
||||
}
|
||||
if (BOOKMARKS_NAME.equals(interfaceName)) {
|
||||
if (null == bookmarks) {
|
||||
bookmarks = (Bookmarks)
|
||||
wrapperFactory.newImpl(BOOKMARKS_NAME, this);
|
||||
}
|
||||
return bookmarks;
|
||||
}
|
||||
// extensibility mechanism: just see if wrapperFactory can make one!
|
||||
return wrapperFactory.newImpl(interfaceName, this);
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
Log.setApplicationName("BrowserControlImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.1 2000/03/04 01:10:51 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class BrowserControlImpl
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
public interface CurrentPage
|
||||
{
|
||||
public void copyCurrentSelectionToSystemClipboard();
|
||||
|
||||
public void findInPage(String stringToFind, boolean forward, boolean matchCase);
|
||||
|
||||
public void findNextInPage(boolean forward);
|
||||
|
||||
public String getCurrentURL();
|
||||
|
||||
// org.w3c.dom.Document getDOM();
|
||||
|
||||
// webclient.PageInfo getPageInfo();
|
||||
|
||||
public String getSource();
|
||||
|
||||
public byte [] getSourceBytes();
|
||||
|
||||
public void resetFind();
|
||||
|
||||
public void selectAll();
|
||||
}
|
||||
// end of interface CurrentPage
|
|
@ -0,0 +1,46 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
public class DocumentLoadEvent extends WebclientEvent
|
||||
{
|
||||
|
||||
public static long START_DOCUMENT_LOAD_EVENT_MASK = 1;
|
||||
public static long END_DOCUMENT_LOAD_EVENT_MASK = 1 << 2;
|
||||
public static long START_URL_LOAD_EVENT_MASK = 1 << 3;
|
||||
public static long END_URL_LOAD_EVENT_MASK = 1 << 4;
|
||||
public static long PROGRESS_URL_LOAD_EVENT_MASK = 1 << 5;
|
||||
public static long STATUS_URL_LOAD_EVENT_MASK = 1 << 6;
|
||||
public static long UNKNOWN_CONTENT_EVENT_MASK = 1 << 7;
|
||||
public static long FETCH_INTERRUPT_EVENT_MASK = 1 << 8;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
|
||||
public DocumentLoadEvent(Object source, long newType)
|
||||
{
|
||||
super(source, newType);
|
||||
}
|
||||
|
||||
} // end of class DocumentLoadEvent
|
|
@ -0,0 +1,27 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
public interface DocumentLoadListener extends WebclientEventListener {
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import java.awt.event.WindowListener;
|
||||
|
||||
public interface EventRegistration {
|
||||
|
||||
// public void addContainerListener(ContainerListener containerListener);
|
||||
// public void removeContainerListener(ContainerListener containerListener);
|
||||
|
||||
// public void addDocumentListener(DocumentListener documentListener);
|
||||
// public void removeDocumentListener(DocumentListener documentListener);
|
||||
|
||||
public void addDocumentLoadListener(DocumentLoadListener listener);
|
||||
public void removeDocumentLoadListener(DocumentLoadListener listener);
|
||||
|
||||
// public void addDOMListener(DOMListener containerListener);
|
||||
// public void removeDOMListener(DOMListener containerListener);
|
||||
|
||||
// public void addJavaScriptListener(JavaScriptListener containerListener);
|
||||
// public void removeJavaScriptListener(JavaScriptListener containerListener);
|
||||
|
||||
// public void addWindowListener(WindowListener windowListener);
|
||||
// public void removeWindowListener(WindowListener windowListener);
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
public interface History
|
||||
{
|
||||
public void back();
|
||||
|
||||
public boolean canBack();
|
||||
|
||||
public HistoryEntry [] getBackList();
|
||||
|
||||
public void clearHistory();
|
||||
|
||||
public void forward();
|
||||
|
||||
public boolean canForward();
|
||||
|
||||
public HistoryEntry [] getForwardList();
|
||||
|
||||
public HistoryEntry [] getHistory();
|
||||
|
||||
public HistoryEntry getHistoryEntry(int historyIndex);
|
||||
|
||||
public int getCurrentHistoryIndex();
|
||||
|
||||
public void setCurrentHistoryIndex(int historyIndex);
|
||||
|
||||
public int getHistoryLength();
|
||||
|
||||
public String getURLForIndex(int historyIndex);
|
||||
} // end of interface History
|
|
@ -0,0 +1,36 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface HistoryEntry
|
||||
{
|
||||
|
||||
public Date getLastAccessTime();
|
||||
|
||||
public String getURL();
|
||||
|
||||
public int getNumberOfAccesses();
|
||||
|
||||
} // end of interface HistoryEntry
|
|
@ -0,0 +1,113 @@
|
|||
/* -*- 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>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
// ImplObject.java
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
|
||||
* This is the base class for all implementations of the BrowserControl
|
||||
* interfaces. It simply defines the common attributes for all
|
||||
* webclient implementation classes.
|
||||
|
||||
*/
|
||||
|
||||
public abstract class ImplObject extends Object
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* My ivars are public for fast access from subclasses in the wrapper_*
|
||||
* packages.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* The factory that created me. It's true that the WrapperFactory
|
||||
* instance is stored as a static member of BrowserControlImpl, and thus
|
||||
* you might say we don't need to keep it as an ivar here. BUT, we
|
||||
* don't want to introduce the notion of WrapperFactory to the webclient
|
||||
* user, AND we don't want to have webclient interface implementation
|
||||
* classes depend on BrowserControlImpl, SO we keep it as ivar. That
|
||||
* is, given that we don't want to talk to myBrowserControl as anything
|
||||
* but a BrowserControl (and not a BrowserControlImpl), we would have to
|
||||
* add an accessor to the public BrowserControl interface in order to
|
||||
* avoid having this myFactory ivar. But we can't do that, because we
|
||||
* don't want to expose the WrapperFactory concept to the webclient API
|
||||
* end user. Got it?
|
||||
|
||||
*/
|
||||
|
||||
public WrapperFactory myFactory = null;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* The BrowserControl to which I'm attached, used for locking and communication.
|
||||
|
||||
*/
|
||||
|
||||
public BrowserControl myBrowserControl = null;
|
||||
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public ImplObject(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super();
|
||||
ParameterCheck.nonNull(yourFactory);
|
||||
ParameterCheck.nonNull(yourBrowserControl);
|
||||
|
||||
myFactory = yourFactory;
|
||||
myBrowserControl = yourBrowserControl;
|
||||
}
|
||||
|
||||
} // end of class ImplObject
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- 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>
|
||||
* Mark Goddard
|
||||
* Ed Burns <edburns@acm.org>
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
public interface Navigation
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
* These flags can be or'd together for the argument to refresh().
|
||||
|
||||
*/
|
||||
|
||||
public static int LOAD_NORMAL = 0;
|
||||
public static int LOAD_FORCE_RELOAD = 1 << 9;
|
||||
|
||||
public void loadURL(String absoluteURL);
|
||||
public void refresh(long loadFlags);
|
||||
public void stop();
|
||||
|
||||
}
|
||||
// end of interface CurrentPage
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
public class WebclientEvent extends EventObject
|
||||
{
|
||||
|
||||
//
|
||||
// Attribute ivars
|
||||
//
|
||||
|
||||
private long type;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
|
||||
public WebclientEvent(Object source, long newType)
|
||||
{
|
||||
super(source);
|
||||
type = newType;
|
||||
}
|
||||
|
||||
public long getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
} // end of class WebclientLoadEvent
|
|
@ -0,0 +1,30 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
public interface WebclientEventListener
|
||||
{
|
||||
|
||||
public void eventDispatched(WebclientEvent event);
|
||||
|
||||
} // end of interface WebclientEventListener
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
public interface WindowControl
|
||||
{
|
||||
public void setBounds(Rectangle newBounds);
|
||||
|
||||
public void createWindow(int nativeWindow, Rectangle bounds);
|
||||
|
||||
public int getNativeWebShell();
|
||||
|
||||
public void moveWindowTo(int x, int y);
|
||||
|
||||
public void removeFocus();
|
||||
|
||||
public void repaint(boolean forceRepaint);
|
||||
|
||||
public void setVisible(boolean newState);
|
||||
|
||||
public void setFocus();
|
||||
}
|
||||
// end of interface WindowControl
|
|
@ -0,0 +1,83 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
// WrapperFactory
|
||||
|
||||
/**
|
||||
|
||||
* Webclient is intended to be able to wrap both java based and native
|
||||
* web browsers. These two classes of browsers require different
|
||||
* wrapping styles. This is accomodated by requiring each different
|
||||
* wrapping style to provide a subclass of this abstract base class.
|
||||
* This subclass implementation must be called WrapperFactory.IMPL_NAME
|
||||
* and must reside in a package with a name starting with "wrapper-",
|
||||
* which must be a sub-package of the package in which this class
|
||||
* resides. For example, for native browsers, the package is
|
||||
* "wrapper-native". <P>
|
||||
|
||||
|
||||
* The subclass implementation MUST HAVE a public no-arg constructor.
|
||||
|
||||
*/
|
||||
|
||||
public abstract class WrapperFactory extends Object
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
public static String IMPL_NAME = "WrapperFactoryImpl";
|
||||
|
||||
public WrapperFactory()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
public abstract Object newImpl(String interfaceName,
|
||||
BrowserControl browserControl) throws ClassNotFoundException;
|
||||
|
||||
public abstract void initialize(String verifiedBinDirAbsolutePath) throws Exception;
|
||||
|
||||
public abstract void terminate() throws Exception;
|
||||
|
||||
public abstract boolean hasBeenInitialized();
|
||||
|
||||
public void throwExceptionIfNotInitialized() throws IllegalStateException
|
||||
|
||||
{
|
||||
if (!hasBeenInitialized()) {
|
||||
throw new IllegalStateException("webclient has not been properly initialized");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // end of class WrapperFactory
|
|
@ -0,0 +1,29 @@
|
|||
package org.mozilla.webclient.test;
|
||||
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.net.URL;
|
||||
import java.io.IOException;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JFrame;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class BookmarksFrame extends JFrame
|
||||
{
|
||||
|
||||
public JTree tree;
|
||||
|
||||
public BookmarksFrame(TreeModel yourTree)
|
||||
{
|
||||
super("bookmarks");
|
||||
tree = new JTree(yourTree);
|
||||
this.getContentPane().add(tree, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,319 @@
|
|||
/* -*- 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 javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.mozilla.webclient.*;
|
||||
import org.mozilla.util.Assert;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
* This is a test application for using the BrowserControl.
|
||||
|
||||
*
|
||||
* @version $Id: EmbeddedMozilla.java,v 1.1 2000/03/04 01:10:54 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlFactory
|
||||
|
||||
*/
|
||||
|
||||
public class EmbeddedMozilla extends Frame implements ActionListener, DocumentLoadListener {
|
||||
static final int defaultWidth = 640;
|
||||
static final int defaultHeight = 480;
|
||||
|
||||
private TextField urlField;
|
||||
private BrowserControl browserControl;
|
||||
private CurrentPage currentPage;
|
||||
private Bookmarks bookmarks;
|
||||
private TreeModel bookmarksTree;
|
||||
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] : "file:///E|/Projects/tmp/5105.html";
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
makeItem(buttonsPanel, "Bookmarks", 4, 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
|
||||
BrowserControlCanvas browserCanvas = null;
|
||||
|
||||
try {
|
||||
BrowserControlFactory.setAppData(binDir);
|
||||
browserControl = BrowserControlFactory.newBrowserControl();
|
||||
browserCanvas =
|
||||
(BrowserControlCanvas)
|
||||
browserControl.queryInterface(BrowserControl.BROWSER_CONTROL_CANVAS_NAME);
|
||||
|
||||
}
|
||||
catch(Exception e) {
|
||||
System.out.println("Can't create BrowserControl: " +
|
||||
e.getMessage());
|
||||
}
|
||||
Assert.assert(null != browserCanvas);
|
||||
browserCanvas.setSize(defaultWidth, defaultHeight);
|
||||
|
||||
// Add the control panel and the browserCanvas
|
||||
add(controlPanel, BorderLayout.NORTH);
|
||||
add(browserCanvas, BorderLayout.CENTER);
|
||||
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
dispose();
|
||||
System.out.println("Got windowClosing");
|
||||
// should close the BrowserControlCanvas
|
||||
}
|
||||
|
||||
public void windowClosed(WindowEvent e) {
|
||||
System.out.println("Got windowClosed");
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
pack();
|
||||
show();
|
||||
toFront();
|
||||
|
||||
Navigation navigation = null;
|
||||
|
||||
try {
|
||||
navigation = (Navigation)
|
||||
browserControl.queryInterface(BrowserControl.NAVIGATION_NAME);
|
||||
currentPage = (CurrentPage)
|
||||
browserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
EventRegistration eventRegistration =
|
||||
(EventRegistration)
|
||||
browserControl.queryInterface(BrowserControl.EVENT_REGISTRATION_NAME);
|
||||
System.out.println("debug: edburns: adding DocumentLoadListener");
|
||||
eventRegistration.addDocumentLoadListener(this);
|
||||
|
||||
|
||||
// PENDING(edburns): test code, replace with production code
|
||||
bookmarks =
|
||||
(Bookmarks)
|
||||
browserControl.queryInterface(BrowserControl.BOOKMARKS_NAME);
|
||||
System.out.println("debug: edburns: got Bookmarks instance");
|
||||
|
||||
bookmarksTree = bookmarks.getBookmarks();
|
||||
TreeNode bookmarksRoot = (TreeNode) bookmarksTree.getRoot();
|
||||
|
||||
System.out.println("debug: edburns: testing the Enumeration");
|
||||
int childCount = bookmarksRoot.getChildCount();
|
||||
System.out.println("debug: edburns: root has " + childCount +
|
||||
" children.");
|
||||
|
||||
Enumeration rootChildren = bookmarksRoot.children();
|
||||
TreeNode currentChild;
|
||||
|
||||
int i = 0, childIndex;
|
||||
while (rootChildren.hasMoreElements()) {
|
||||
currentChild = (TreeNode) rootChildren.nextElement();
|
||||
System.out.println("debug: edburns: bookmarks root has children! child: " + i + " name: " + currentChild.toString());
|
||||
i++;
|
||||
}
|
||||
|
||||
System.out.println("debug: edburns: testing getChildAt(" + --i + "): ");
|
||||
currentChild = bookmarksRoot.getChildAt(i);
|
||||
System.out.println("debug: edburns: testing getIndex(Child " +
|
||||
i + "): index should be " + i + ".");
|
||||
childIndex = bookmarksRoot.getIndex(currentChild);
|
||||
System.out.println("debug: edburns: index is: " + childIndex);
|
||||
|
||||
/**********
|
||||
BookmarkEntry folder = bookmarks.newBookmarkFolder("newFolder");
|
||||
|
||||
bookmarks.addBookmark(null, folder);
|
||||
|
||||
BookmarkEntry entry = bookmarks.newBookmarkEntry("http://yoyo.com");
|
||||
System.out.println("debug: edburns: got new entry");
|
||||
|
||||
Properties entryProps = entry.getProperties();
|
||||
|
||||
System.out.println("debug: edburns: entry url: " +
|
||||
entryProps.getProperty(BookmarkEntry.URL));
|
||||
bookmarks.addBookmark(folder, entry);
|
||||
**********/
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
}
|
||||
|
||||
if (null != navigation) {
|
||||
navigation.loadURL(url);
|
||||
}
|
||||
} // EmbeddedMozilla() ctor
|
||||
|
||||
|
||||
public void actionPerformed (ActionEvent evt) {
|
||||
String command = evt.getActionCommand();
|
||||
|
||||
|
||||
try {
|
||||
Navigation navigation = (Navigation)
|
||||
browserControl.queryInterface(BrowserControl.NAVIGATION_NAME);
|
||||
CurrentPage currentPage = (CurrentPage)
|
||||
browserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
|
||||
History history = (History)
|
||||
browserControl.queryInterface(BrowserControl.HISTORY_NAME);
|
||||
if (command.equals("Stop")) {
|
||||
navigation.stop();
|
||||
}
|
||||
else if (command.equals("Refresh")) {
|
||||
navigation.refresh(Navigation.LOAD_NORMAL);
|
||||
}
|
||||
else if (command.equals("Bookmarks")) {
|
||||
if (null == bookmarksTree) {
|
||||
bookmarksTree = bookmarks.getBookmarks();
|
||||
}
|
||||
BookmarksFrame frame = new BookmarksFrame(bookmarksTree);
|
||||
frame.setSize(new Dimension(320,480));
|
||||
frame.setVisible(true);
|
||||
}
|
||||
else if (command.equals("Back")) {
|
||||
if (history.canBack()) {
|
||||
history.back();
|
||||
}
|
||||
}
|
||||
else if (command.equals("Forward")) {
|
||||
if (history.canForward()) {
|
||||
history.forward();
|
||||
}
|
||||
}
|
||||
else {
|
||||
navigation.loadURL(urlField.getText());
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
} // 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()
|
||||
|
||||
|
||||
//
|
||||
// From DocumentLoadListener
|
||||
//
|
||||
|
||||
public void eventDispatched(WebclientEvent event)
|
||||
{
|
||||
if (event instanceof DocumentLoadEvent) {
|
||||
String currentURL = currentPage.getCurrentURL();
|
||||
System.out.println("debug: edburns: Currently Viewing: " +
|
||||
currentURL);
|
||||
urlField.setText(currentURL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// EOF
|
|
@ -0,0 +1,119 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.Bookmarks;
|
||||
import org.mozilla.webclient.BookmarkEntry;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class BookmarkEntryImpl extends RDFTreeNode implements BookmarkEntry
|
||||
{
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
Properties properties = null;
|
||||
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
protected BookmarkEntryImpl(int nativeNode, RDFTreeNode yourParent)
|
||||
{
|
||||
super(nativeNode, yourParent);
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Abstract Method Implementations
|
||||
//
|
||||
|
||||
protected RDFTreeNode newRDFTreeNode(int nativeNode,
|
||||
RDFTreeNode yourParent)
|
||||
{
|
||||
return new BookmarkEntryImpl(nativeNode, yourParent);
|
||||
}
|
||||
|
||||
//
|
||||
// Methods from BookmarkEntry
|
||||
//
|
||||
|
||||
public Properties getProperties()
|
||||
{
|
||||
if ((null == properties) &&
|
||||
(null == (properties = new Properties()))) {
|
||||
throw new IllegalStateException("Can't create properties table");
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
public boolean isFolder()
|
||||
{
|
||||
return nativeIsContainer(getNativeRDFNode());
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("BookmarkEntryImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: BookmarkEntryImpl.java,v 1.1 2000/03/04 01:10:55 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class BookmarksImpl
|
|
@ -0,0 +1,240 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.Bookmarks;
|
||||
import org.mozilla.webclient.BookmarkEntry;
|
||||
import org.mozilla.webclient.ImplObject;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
|
||||
public class BookmarksImpl extends ImplObject implements Bookmarks
|
||||
{
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, obtained from WindowControl
|
||||
|
||||
*/
|
||||
|
||||
private int nativeWebShell = -1;
|
||||
|
||||
/**
|
||||
|
||||
* The bookmarks
|
||||
|
||||
*/
|
||||
|
||||
private TreeModel bookmarksTree = null;
|
||||
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public BookmarksImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(yourFactory, yourBrowserControl);
|
||||
|
||||
// save the native webshell ptr
|
||||
try {
|
||||
WindowControl windowControl = (WindowControl)
|
||||
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
nativeWebShell = windowControl.getNativeWebShell();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from Bookmarks
|
||||
//
|
||||
|
||||
public void addBookmark(BookmarkEntry mayBeNullParent,
|
||||
BookmarkEntry bookmark)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
if (!(bookmark instanceof BookmarkEntryImpl)) {
|
||||
throw new IllegalArgumentException("Can't add bookmark unless BookmarkEntry obtained from Bookmarks.newBookmarkEntry()");
|
||||
}
|
||||
|
||||
BookmarkEntry parent = null;
|
||||
int lastChildIndex;
|
||||
getBookmarks();
|
||||
|
||||
// if parent is null, insert as child of the root
|
||||
if (null == mayBeNullParent) {
|
||||
parent = (BookmarkEntry) bookmarksTree.getRoot();
|
||||
}
|
||||
else {
|
||||
if (!(mayBeNullParent instanceof BookmarkEntryImpl)) {
|
||||
throw new IllegalArgumentException("Can't add bookmark unless BookmarkEntry obtained from Bookmarks.newBookmarkEntry()");
|
||||
}
|
||||
parent = mayBeNullParent;
|
||||
}
|
||||
if (!parent.isFolder()) {
|
||||
throw new IllegalArgumentException("Can't add bookmark unless parent BookmarkEntry is a folder");
|
||||
}
|
||||
lastChildIndex = parent.getChildCount();
|
||||
parent.insert(bookmark, lastChildIndex);
|
||||
}
|
||||
|
||||
public TreeModel getBookmarks() throws IllegalStateException
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
if (null == bookmarksTree) {
|
||||
int nativeBookmarks;
|
||||
TreeNode root;
|
||||
if (-1 == (nativeBookmarks = nativeGetBookmarks(nativeWebShell))) {
|
||||
throw new IllegalStateException("BookmarksImpl.getBookmarks(): Can't get bookmarks from native browser.");
|
||||
}
|
||||
// if we can't create a root, or we can't create a tree
|
||||
if ((null == (root = new BookmarkEntryImpl(nativeBookmarks, null))) ||
|
||||
(null == (bookmarksTree = new DefaultTreeModel(root)))) {
|
||||
throw new IllegalStateException("BookmarksImpl.getBookmarks(): Can't create RDFTreeModel.");
|
||||
}
|
||||
}
|
||||
|
||||
return bookmarksTree;
|
||||
}
|
||||
|
||||
public void removeBookmark(BookmarkEntry bookmark)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
}
|
||||
|
||||
public BookmarkEntry newBookmarkEntry(String url)
|
||||
{
|
||||
BookmarkEntry result = null;
|
||||
getBookmarks();
|
||||
int newNode;
|
||||
|
||||
System.out.println("debug: edburns: BookmarksImpl.newBookmarkEntry: url:" + url);
|
||||
if (-1 != (newNode = nativeNewRDFNode(url, false))) {
|
||||
result = new BookmarkEntryImpl(newNode, null);
|
||||
result.getProperties().setProperty(BookmarkEntry.URL, url);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public BookmarkEntry newBookmarkFolder(String name)
|
||||
{
|
||||
BookmarkEntry result = null;
|
||||
getBookmarks();
|
||||
int newNode;
|
||||
|
||||
System.out.println("debug: edburns: BookmarksImpl.newBookmarkFolder: name:" + name);
|
||||
if (-1 != (newNode = nativeNewRDFNode(name, true))) {
|
||||
result = new BookmarkEntryImpl(newNode, null);
|
||||
result.getProperties().setProperty(BookmarkEntry.NAME, name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// native methods
|
||||
//
|
||||
|
||||
private native int nativeGetBookmarks(int webShellPtr);
|
||||
|
||||
/**
|
||||
|
||||
* the returned node has already been XPCOM AddRef'd
|
||||
|
||||
*/
|
||||
|
||||
private native int nativeNewRDFNode(String url, boolean isFolder);
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("BookmarksImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: BookmarksImpl.java,v 1.1 2000/03/04 01:10:55 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
org.mozilla.webclient.BrowserControl control =
|
||||
org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
|
||||
Assert.assert(control != null);
|
||||
|
||||
Bookmarks wc = (Bookmarks)
|
||||
control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
|
||||
Assert.assert(wc != null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("got exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class BookmarksImpl
|
|
@ -0,0 +1,218 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.CurrentPage;
|
||||
import org.mozilla.webclient.ImplObject;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
|
||||
public class CurrentPageImpl extends ImplObject implements CurrentPage
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, obtained from WindowControl
|
||||
|
||||
*/
|
||||
|
||||
private int nativeWebShell = -1;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public CurrentPageImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(yourFactory, yourBrowserControl);
|
||||
|
||||
// save the native webshell ptr
|
||||
try {
|
||||
WindowControl windowControl = (WindowControl)
|
||||
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
nativeWebShell = windowControl.getNativeWebShell();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from CurrentPage
|
||||
//
|
||||
|
||||
public void copyCurrentSelectionToSystemClipboard()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeCopyCurrentSelectionToSystemClipboard(nativeWebShell);
|
||||
}
|
||||
}
|
||||
|
||||
public void findInPage(String stringToFind, boolean forward, boolean matchCase)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeFindInPage(stringToFind, forward, matchCase);
|
||||
}
|
||||
}
|
||||
|
||||
public void findNextInPage(boolean forward)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeFindNextInPage(forward);
|
||||
}
|
||||
}
|
||||
|
||||
public String getCurrentURL()
|
||||
{
|
||||
String result = null;
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetCurrentURL(nativeWebShell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// org.w3c.dom.Document getDOM();
|
||||
|
||||
// webclient.PageInfo getPageInfo();
|
||||
|
||||
public String getSource()
|
||||
{
|
||||
String result = null;
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetSource();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public byte [] getSourceBytes()
|
||||
{
|
||||
byte [] result = null;
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetSourceBytes();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void resetFind()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeResetFind();
|
||||
}
|
||||
}
|
||||
|
||||
public void selectAll()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
native public void nativeCopyCurrentSelectionToSystemClipboard(int webShellPtr);
|
||||
|
||||
native public void nativeFindInPage(String stringToFind, boolean forward, boolean matchCase);
|
||||
|
||||
native public void nativeFindNextInPage(boolean forward);
|
||||
|
||||
native public String nativeGetCurrentURL(int webShellPtr);
|
||||
|
||||
// org.w3c.dom.Document getDOM();
|
||||
|
||||
// webclient.PageInfo getPageInfo();
|
||||
|
||||
native public String nativeGetSource();
|
||||
|
||||
native public byte [] nativeGetSourceBytes();
|
||||
|
||||
native public void nativeResetFind();
|
||||
|
||||
native public void nativeSelectAll();
|
||||
|
||||
|
||||
// ----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 2000/03/04 01:10:55 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class CurrentPageImpl
|
|
@ -0,0 +1,171 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.ImplObject;
|
||||
import org.mozilla.webclient.EventRegistration;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
import org.mozilla.webclient.DocumentLoadEvent;
|
||||
import org.mozilla.webclient.DocumentLoadListener;
|
||||
import org.mozilla.webclient.WebclientEvent;
|
||||
import org.mozilla.webclient.WebclientEventListener;
|
||||
|
||||
public class EventRegistrationImpl extends ImplObject implements EventRegistration
|
||||
{
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, obtained from WindowControl
|
||||
|
||||
*/
|
||||
|
||||
private int nativeWebShell = -1;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* the Java thread for processing events, owned by WindowControlImpl
|
||||
|
||||
*/
|
||||
|
||||
private NativeEventThread nativeEventThread = null;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public EventRegistrationImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(yourFactory, yourBrowserControl);
|
||||
|
||||
// save the native webshell ptr
|
||||
try {
|
||||
WindowControl windowControl = (WindowControl)
|
||||
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
nativeWebShell = windowControl.getNativeWebShell();
|
||||
|
||||
// pull out the NativeEventThread from the WindowControl
|
||||
if (windowControl instanceof WindowControlImpl) {
|
||||
nativeEventThread =
|
||||
((WindowControlImpl)windowControl).getNativeEventThread();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from EventRegistration
|
||||
//
|
||||
|
||||
public void addDocumentLoadListener(DocumentLoadListener listener)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
Assert.assert(null != nativeEventThread);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeEventThread.addListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeDocumentLoadListener(DocumentLoadListener listener)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testListenerSubclass(WebclientEventListener listener)
|
||||
{
|
||||
if (listener instanceof DocumentLoadListener) {
|
||||
System.out.println("debug: edburns: EventRegistrationImpl.testListenerSubclass: DocumentLoadListener");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("EventRegistrationImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.1 2000/03/04 01:10:55 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
org.mozilla.webclient.BrowserControl control =
|
||||
org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
|
||||
Assert.assert(control != null);
|
||||
|
||||
EventRegistration wc = (EventRegistration)
|
||||
control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
|
||||
Assert.assert(wc != null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("got exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class EventRegistrationImpl
|
|
@ -0,0 +1,293 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.History;
|
||||
import org.mozilla.webclient.HistoryEntry;
|
||||
import org.mozilla.webclient.ImplObject;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
|
||||
public class HistoryImpl extends ImplObject implements History
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, obtained from WindowControl
|
||||
|
||||
*/
|
||||
|
||||
private int nativeWebShell = -1;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public HistoryImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(yourFactory, yourBrowserControl);
|
||||
|
||||
// save the native webshell ptr
|
||||
try {
|
||||
WindowControl windowControl = (WindowControl)
|
||||
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
nativeWebShell = windowControl.getNativeWebShell();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from History
|
||||
//
|
||||
|
||||
public void back()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeBack(nativeWebShell);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canBack()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
boolean result = false;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeCanBack(nativeWebShell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public HistoryEntry [] getBackList()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
HistoryEntry [] result = null;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetBackList(nativeWebShell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void clearHistory()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeClearHistory(nativeWebShell);
|
||||
}
|
||||
}
|
||||
|
||||
// org.w3c.dom.Document getDOM();
|
||||
|
||||
// webclient.PageInfo getPageInfo();
|
||||
|
||||
public void forward()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeForward(nativeWebShell);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canForward()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
boolean result = false;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeCanForward(nativeWebShell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public HistoryEntry [] getForwardList()
|
||||
{
|
||||
HistoryEntry [] result = null;
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetForwardList(nativeWebShell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public HistoryEntry [] getHistory()
|
||||
{
|
||||
HistoryEntry [] result = null;
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetHistory(nativeWebShell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public HistoryEntry getHistoryEntry(int historyIndex)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
HistoryEntry result = null;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetHistoryEntry(nativeWebShell, historyIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getCurrentHistoryIndex()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
int result = -1;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetCurrentHistoryIndex(nativeWebShell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setCurrentHistoryIndex(int historyIndex)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSetCurrentHistoryIndex(nativeWebShell, historyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public int getHistoryLength()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
int result = -1;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetHistoryLength(nativeWebShell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getURLForIndex(int historyIndex)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
String result = null;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetURLForIndex(nativeWebShell, historyIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
public native void nativeBack(int nativeWebShell);
|
||||
|
||||
public native boolean nativeCanBack(int webShellPtr);
|
||||
|
||||
public native HistoryEntry [] nativeGetBackList(int webShellPtr);
|
||||
|
||||
public native void nativeClearHistory(int webShellPtr);
|
||||
|
||||
public native void nativeForward(int webShellPtr);
|
||||
|
||||
public native boolean nativeCanForward(int webShellPtr);
|
||||
|
||||
public native HistoryEntry [] nativeGetForwardList(int webShellPtr);
|
||||
|
||||
public native HistoryEntry [] nativeGetHistory(int webShellPtr);
|
||||
|
||||
public native HistoryEntry nativeGetHistoryEntry(int webShellPtr, int historyIndex);
|
||||
|
||||
public native int nativeGetCurrentHistoryIndex(int webShellPtr);
|
||||
|
||||
public native void nativeSetCurrentHistoryIndex(int webShellPtr, int historyIndex);
|
||||
|
||||
public native int nativeGetHistoryLength(int webShellPtr);
|
||||
|
||||
public native String nativeGetURLForIndex(int webShellPtr, int historyIndex);
|
||||
|
||||
// ----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 2000/03/04 01:10:55 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class HistoryImpl
|
|
@ -0,0 +1,96 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
|
||||
* Abstract base class for all java Objects that are peers of XPCOM
|
||||
* objects that need automatic reference counting.
|
||||
|
||||
*/
|
||||
|
||||
public abstract class ISupportsPeer extends Object
|
||||
{
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public ISupportsPeer()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
protected native void nativeAddRef(int nativeNode);
|
||||
protected native void nativeRelease(int nativeNode);
|
||||
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("ISupportsPeer");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: ISupportsPeer.java,v 1.1 2000/03/04 01:10:55 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class ISupportsPeer
|
|
@ -0,0 +1,293 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.BrowserControlCanvas;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.DocumentLoadEvent;
|
||||
import org.mozilla.webclient.DocumentLoadListener;
|
||||
import org.mozilla.webclient.WebclientEvent;
|
||||
import org.mozilla.webclient.WebclientEventListener;
|
||||
|
||||
public class NativeEventThread extends Thread
|
||||
{
|
||||
|
||||
//
|
||||
// Attribute ivars
|
||||
//
|
||||
|
||||
//
|
||||
// Relationship ivars
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Vector of listener objects to add.
|
||||
|
||||
*/
|
||||
|
||||
private Vector listenersToAdd;
|
||||
|
||||
/**
|
||||
|
||||
* Vector of listener objects to remove.
|
||||
|
||||
*/
|
||||
|
||||
private Vector listenersToRemove;
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, obtained in constructor
|
||||
|
||||
*/
|
||||
|
||||
private int nativeWebShell = -1;
|
||||
|
||||
/**
|
||||
|
||||
* a reference to the WindowControl that created us.
|
||||
|
||||
*/
|
||||
|
||||
private WindowControl windowControl;
|
||||
|
||||
private BrowserControl browserControl;
|
||||
|
||||
private BrowserControlCanvas browserControlCanvas;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Used in run()
|
||||
|
||||
*/
|
||||
|
||||
private Enumeration tempEnum;
|
||||
|
||||
//
|
||||
// Attribute ivars
|
||||
//
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
|
||||
public NativeEventThread(String threadName, BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(threadName);
|
||||
ParameterCheck.nonNull(yourBrowserControl);
|
||||
|
||||
browserControl = yourBrowserControl;
|
||||
|
||||
try {
|
||||
windowControl = (WindowControl)
|
||||
browserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
nativeWebShell = windowControl.getNativeWebShell();
|
||||
|
||||
browserControlCanvas = (BrowserControlCanvas)
|
||||
browserControl.queryInterface(BrowserControl.BROWSER_CONTROL_CANVAS_NAME);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread constructor: Exception: " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Methods from Thread
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* This method is the heart of webclient. It should only be called when
|
||||
* WindowControlImpl.createWindow() is called. It calls
|
||||
* nativeInitialize, which does the per-window initialization, including
|
||||
* creating the native event queue which corresponds to this instance,
|
||||
* then enters into an infinite loop where processes native events, then
|
||||
* checks to see if there are any listeners to add, and adds them if
|
||||
* necessary.
|
||||
|
||||
* @see nativeInitialize
|
||||
|
||||
* @see nativeProcessEvents
|
||||
|
||||
* @see nativeAddListener
|
||||
|
||||
*/
|
||||
|
||||
public void run()
|
||||
{
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
Assert.assert(null != windowControl);
|
||||
|
||||
nativeInitialize(nativeWebShell);
|
||||
|
||||
// IMPORTANT: tell the windowControl, who is waiting for this
|
||||
// message, that we have initialized successfully.
|
||||
synchronized(windowControl) {
|
||||
try {
|
||||
windowControl.notify();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("NativeEventThread.run: Exception: trying to send notify() to windowControl: " + e + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
synchronized (this.browserControlCanvas.getTreeLock()) {
|
||||
nativeProcessEvents(nativeWebShell);
|
||||
|
||||
if (null != listenersToAdd && !listenersToAdd.isEmpty()) {
|
||||
tempEnum = listenersToAdd.elements();
|
||||
while (tempEnum.hasMoreElements()) {
|
||||
nativeAddListener(nativeWebShell,
|
||||
(WebclientEventListener)
|
||||
tempEnum.nextElement());
|
||||
}
|
||||
listenersToAdd.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Package methods
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Takes the abstract WebclientEventListener instance and adds it to a
|
||||
* Vector of listeners to be added. This vector is scanned each time
|
||||
* around the event loop in run().
|
||||
|
||||
* @see run
|
||||
|
||||
*/
|
||||
|
||||
void addListener(WebclientEventListener newListener)
|
||||
{
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
Assert.assert(null != windowControl);
|
||||
|
||||
synchronized (this.browserControlCanvas.getTreeLock()) {
|
||||
if (null == listenersToAdd) {
|
||||
listenersToAdd = new Vector();
|
||||
}
|
||||
listenersToAdd.add(newListener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* This method is called from native code when an event occurrs. This
|
||||
* method relies on the fact that all events types that the client can
|
||||
* observe descend from WebclientEventListener. I use instanceOf to
|
||||
* determine what kind of WebclientEvent subclass to create.
|
||||
|
||||
*/
|
||||
|
||||
void nativeEventOccurred(WebclientEventListener target, long eventType)
|
||||
{
|
||||
ParameterCheck.nonNull(target);
|
||||
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
Assert.assert(null != windowControl);
|
||||
|
||||
synchronized(this.browserControlCanvas.getTreeLock()) {
|
||||
WebclientEvent event = null;
|
||||
|
||||
if (target instanceof DocumentLoadListener) {
|
||||
System.out.println("debug: edburns: creating DocumentLoadEvent");
|
||||
event = new DocumentLoadEvent(this, eventType);
|
||||
}
|
||||
// else...
|
||||
|
||||
// PENDING(edburns): maybe we need to put this in some sort of
|
||||
// event queue?
|
||||
|
||||
System.out.println("About to call eventDispatched on listener");
|
||||
target.eventDispatched(event);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// local methods
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Takes the int from WindowControlImpl.nativeCreateInitContext, the
|
||||
* meaning of which is left up to the implementation, and does any
|
||||
* per-window creation and initialization tasks. <P>
|
||||
|
||||
* For mozilla, this means creating the nsIWebShell instance, attaching
|
||||
* to the native event queue, creating the nsISessionHistory instance, etc.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeInitialize(int webShellPtr);
|
||||
|
||||
/**
|
||||
|
||||
* Called from java to allow the native code to process any pending
|
||||
* events, such as: painting the UI, processing mouse and key events,
|
||||
* etc.
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeProcessEvents(int webShellPtr);
|
||||
|
||||
/**
|
||||
|
||||
* Called from Java to allow the native code to add a "listener" to the
|
||||
* underlying browser implementation. The native code should do what's
|
||||
* necessary to add the appropriate listener type. When a listener
|
||||
* event occurrs, the native code should call the nativeEventOccurred
|
||||
* method of this instance, passing the typedListener argument received
|
||||
* from nativeAddListener. See the comments in the native
|
||||
* implementation.
|
||||
|
||||
* @see nativeEventOccurred
|
||||
|
||||
*/
|
||||
|
||||
public native void nativeAddListener(int webShellPtr,
|
||||
WebclientEventListener typedListener);
|
||||
|
||||
} // end of class NativeEventThread
|
|
@ -0,0 +1,167 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.ImplObject;
|
||||
import org.mozilla.webclient.Navigation;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
public class NavigationImpl extends ImplObject implements Navigation
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, obtained from WindowControl
|
||||
|
||||
*/
|
||||
|
||||
private int nativeWebShell = -1;
|
||||
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public NavigationImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(yourFactory, yourBrowserControl);
|
||||
|
||||
// save the native webshell ptr
|
||||
try {
|
||||
WindowControl windowControl = (WindowControl)
|
||||
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
nativeWebShell = windowControl.getNativeWebShell();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from Navigation
|
||||
//
|
||||
|
||||
public void loadURL(String absoluteURL)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeLoadURL(nativeWebShell, absoluteURL);
|
||||
}
|
||||
}
|
||||
|
||||
public void refresh(long loadFlags)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeRefresh(nativeWebShell, loadFlags);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeStop(nativeWebShell);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
public native void nativeLoadURL(int webShellPtr, String absoluteURL);
|
||||
|
||||
public native void nativeRefresh(int webShellPtr, long loadFlags);
|
||||
|
||||
public native void nativeStop(int webShellPtr);
|
||||
|
||||
// ----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 2000/03/04 01:10:56 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
org.mozilla.webclient.BrowserControl control =
|
||||
org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
|
||||
Assert.assert(control != null);
|
||||
|
||||
Navigation wc = (Navigation)
|
||||
control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
|
||||
Assert.assert(wc != null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("got exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class NavigationImpl
|
|
@ -0,0 +1,154 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class RDFEnumeration extends Object implements Enumeration
|
||||
{
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
private int nativeRDFNode = -1;
|
||||
|
||||
private RDFTreeNode parent;
|
||||
|
||||
/**
|
||||
|
||||
* set from native code
|
||||
|
||||
*/
|
||||
|
||||
private int nativeEnum = -1;
|
||||
|
||||
/**
|
||||
|
||||
* set from native code
|
||||
|
||||
*/
|
||||
|
||||
private int nativeContainer = -1;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public RDFEnumeration(RDFTreeNode enumParent)
|
||||
{
|
||||
parent = enumParent;
|
||||
nativeRDFNode = parent.getNativeRDFNode();
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from Object
|
||||
//
|
||||
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
nativeFinalize();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
//
|
||||
// Methods from Enumeration
|
||||
//
|
||||
|
||||
public boolean hasMoreElements()
|
||||
{
|
||||
Assert.assert(-1 != nativeRDFNode);
|
||||
|
||||
return nativeHasMoreElements(nativeRDFNode);
|
||||
}
|
||||
|
||||
public Object nextElement()
|
||||
{
|
||||
Assert.assert(null != parent);
|
||||
Object result = null;
|
||||
int nextNativeRDFNode;
|
||||
|
||||
if (-1 != (nextNativeRDFNode = nativeNextElement(nativeRDFNode))) {
|
||||
result = parent.newRDFTreeNode(nextNativeRDFNode, parent);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Native Methods
|
||||
//
|
||||
|
||||
private native boolean nativeHasMoreElements(int nativeRDFNode);
|
||||
|
||||
/**
|
||||
|
||||
* @return -1 if no more elements, a pointer otherwise.
|
||||
|
||||
*/
|
||||
|
||||
private native int nativeNextElement(int nativeRDFNode);
|
||||
protected native void nativeFinalize();
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("RDFEnumeration");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: RDFEnumeration.java,v 1.1 2000/03/04 01:10:56 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class RDFEnumeration
|
|
@ -0,0 +1,276 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.MutableTreeNode;
|
||||
|
||||
public abstract class RDFTreeNode extends ISupportsPeer implements MutableTreeNode
|
||||
{
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
private int nativeRDFNode = -1;
|
||||
|
||||
private RDFTreeNode parent;
|
||||
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
protected RDFTreeNode(int nativeNode, RDFTreeNode yourParent)
|
||||
{
|
||||
nativeRDFNode = nativeNode;
|
||||
parent = yourParent;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
//
|
||||
// Abstract Methods
|
||||
//
|
||||
|
||||
protected abstract RDFTreeNode newRDFTreeNode(int nativeNode,
|
||||
RDFTreeNode yourParent);
|
||||
|
||||
int getNativeRDFNode()
|
||||
{
|
||||
return nativeRDFNode;
|
||||
}
|
||||
|
||||
private void setNativeRDFNode(int yourNativeRDFNode)
|
||||
{
|
||||
if (-1 != nativeRDFNode) {
|
||||
throw new IllegalStateException("Can't call setNativeRDFNode() more than once on an instance.");
|
||||
}
|
||||
nativeRDFNode = yourNativeRDFNode;
|
||||
}
|
||||
|
||||
//
|
||||
// Methods from Object
|
||||
//
|
||||
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
nativeRelease(nativeRDFNode);
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
String result = null;
|
||||
if (-1 != nativeRDFNode) {
|
||||
result = nativeToString(nativeRDFNode);
|
||||
}
|
||||
else {
|
||||
result = super.toString();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Methods from TreeNode
|
||||
//
|
||||
|
||||
public Enumeration children()
|
||||
{
|
||||
Assert.assert(-1 != nativeRDFNode);
|
||||
Enumeration enum = null;
|
||||
|
||||
enum = new RDFEnumeration(this);
|
||||
|
||||
return enum;
|
||||
}
|
||||
|
||||
public boolean getAllowsChildren()
|
||||
{
|
||||
boolean result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public TreeNode getChildAt(int childIndex)
|
||||
{
|
||||
Assert.assert(-1 != nativeRDFNode);
|
||||
TreeNode result = null;
|
||||
int childNode;
|
||||
|
||||
if (!isLeaf()) {
|
||||
if (-1 != (childNode = nativeGetChildAt(nativeRDFNode, childIndex))) {
|
||||
result = newRDFTreeNode(childNode, this);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getChildCount()
|
||||
{
|
||||
Assert.assert(-1 != nativeRDFNode);
|
||||
int result = -1;
|
||||
|
||||
result = nativeGetChildCount(nativeRDFNode);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getIndex(TreeNode node)
|
||||
{
|
||||
Assert.assert(-1 != nativeRDFNode);
|
||||
int result = -1;
|
||||
if (node instanceof RDFTreeNode) {
|
||||
result = nativeGetIndex(nativeRDFNode,
|
||||
((RDFTreeNode)node).nativeRDFNode);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public TreeNode getParent()
|
||||
{
|
||||
Assert.assert(-1 != nativeRDFNode);
|
||||
return parent;
|
||||
}
|
||||
|
||||
public boolean isLeaf()
|
||||
{
|
||||
Assert.assert(-1 != nativeRDFNode);
|
||||
|
||||
return nativeIsLeaf(nativeRDFNode);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Methods from MutableTreeNode
|
||||
//
|
||||
|
||||
public void insert(MutableTreeNode child, int index)
|
||||
{
|
||||
if (!(child instanceof RDFTreeNode)) {
|
||||
throw new IllegalArgumentException("Can't insert non-RDFTreeNode children");
|
||||
}
|
||||
Assert.assert(-1 != nativeRDFNode);
|
||||
RDFTreeNode childNode = (RDFTreeNode) child;
|
||||
Assert.assert(-1 != childNode.getNativeRDFNode());
|
||||
int childNativeRDFNode = childNode.getNativeRDFNode();
|
||||
|
||||
// hook up the child to its native peer
|
||||
nativeInsertElementAt(nativeRDFNode, childNativeRDFNode, index);
|
||||
// hook up the child to its java parent
|
||||
childNode.setParent(this);
|
||||
|
||||
}
|
||||
|
||||
public void remove(int index)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void remove(MutableTreeNode node)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void removeFromParent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setParent(MutableTreeNode newParent)
|
||||
{
|
||||
if (newParent instanceof RDFTreeNode) {
|
||||
parent = (RDFTreeNode) newParent;
|
||||
}
|
||||
}
|
||||
|
||||
public void setUserObject(Object object)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
public native boolean nativeIsLeaf(int nativeRDFNode);
|
||||
public native boolean nativeIsContainer(int nativeRDFNode);
|
||||
|
||||
/**
|
||||
|
||||
* the returned child has already been XPCOM AddRef'd
|
||||
|
||||
*/
|
||||
|
||||
public native int nativeGetChildAt(int nativeRDFNode, int childIndex);
|
||||
public native int nativeGetChildCount(int nativeRDFNode);
|
||||
public native int nativeGetIndex(int nativeRDFNode, int childRDFNode);
|
||||
public native String nativeToString(int nativeRDFNode);
|
||||
public native void nativeInsertElementAt(int parentNativeRDFNode,
|
||||
int childNativeRDFNode, int index);
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
|
||||
Log.setApplicationName("RDFTreeNode");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: RDFTreeNode.java,v 1.1 2000/03/04 01:10:56 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class RDFTreeNode
|
|
@ -0,0 +1,255 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
import org.mozilla.util.Assert;
|
||||
import org.mozilla.util.Log;
|
||||
import org.mozilla.util.ParameterCheck;
|
||||
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.ImplObject;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
import org.mozilla.webclient.WrapperFactory;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
public class WindowControlImpl extends ImplObject implements WindowControl
|
||||
{
|
||||
//
|
||||
// Protected Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
protected NativeEventThread eventThread = null;
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell
|
||||
|
||||
*/
|
||||
|
||||
private int nativeWebShell = -1;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public WindowControlImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(yourFactory, yourBrowserControl);
|
||||
}
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// General Methods
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Package Methods
|
||||
//
|
||||
|
||||
NativeEventThread getNativeEventThread()
|
||||
{
|
||||
return eventThread;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Methods from WindowControl
|
||||
//
|
||||
|
||||
public void setBounds(Rectangle newBounds)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
Assert.assert(-1 != nativeWebShell);
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSetBounds(nativeWebShell, newBounds.x, newBounds.y,
|
||||
newBounds.width, newBounds.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void createWindow(int nativeWindow, Rectangle bounds)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
synchronized(this) {
|
||||
nativeWebShell = nativeCreateInitContext(nativeWindow, bounds.x,
|
||||
bounds.y, bounds.width,
|
||||
bounds.height);
|
||||
eventThread = new NativeEventThread("EventThread-" +
|
||||
nativeWebShell,
|
||||
myBrowserControl);
|
||||
|
||||
// IMPORTANT: the nativeEventThread initializes all the
|
||||
// native browser stuff, then sends us notify().
|
||||
eventThread.start();
|
||||
try {
|
||||
wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("WindowControlImpl.createWindow: interrupted while waiting\n\t for NativeEventThread to notify(): " + e +
|
||||
" " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getNativeWebShell()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
return nativeWebShell;
|
||||
}
|
||||
|
||||
public void moveWindowTo(int x, int y)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeMoveWindowTo(nativeWebShell, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFocus()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeRemoveFocus(nativeWebShell);
|
||||
}
|
||||
}
|
||||
|
||||
public void repaint(boolean forceRepaint)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeRepaint(nativeWebShell, forceRepaint);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible(boolean newState)
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSetVisible(nativeWebShell, newState);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFocus()
|
||||
{
|
||||
myFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSetFocus(nativeWebShell);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
public native void nativeSetBounds(int webShellPtr, int x, int y,
|
||||
int w, int h);
|
||||
|
||||
/**
|
||||
|
||||
* This method allows the native code to create a "context object" that
|
||||
* is passed to all subsequent native methods. This context object is
|
||||
* opaque to Java and should just be a pointer cast to a jint. For
|
||||
* example, this method could create a struct that encapsulates the
|
||||
* native window (from the nativeWindow argument), the x, y, width,
|
||||
* height parameters for the window, and any other per browser window
|
||||
* information. <P>
|
||||
|
||||
* Subsequent native methods would know how to turn this jint into the
|
||||
* struct.
|
||||
|
||||
*/
|
||||
|
||||
public native int nativeCreateInitContext(int nativeWindow,
|
||||
int x, int y, int width, int height);
|
||||
|
||||
public native void nativeMoveWindowTo(int webShellPtr, int x, int y);
|
||||
|
||||
public native void nativeRemoveFocus(int webShellPtr);
|
||||
|
||||
public native void nativeRepaint(int webShellPtr, boolean forceRepaint);
|
||||
|
||||
public native void nativeSetVisible(int webShellPtr, boolean newState);
|
||||
|
||||
public native void nativeSetFocus(int webShellPtr);
|
||||
|
||||
|
||||
// ----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 2000/03/04 01:10:56 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
org.mozilla.webclient.BrowserControl control =
|
||||
org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
|
||||
Assert.assert(control != null);
|
||||
|
||||
WindowControl wc = (WindowControl)
|
||||
control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
|
||||
Assert.assert(wc != null);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println("got exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class WindowControlImpl
|
|
@ -0,0 +1,232 @@
|
|||
/* -*- 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): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient.wrapper_native;
|
||||
|
||||
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
|
||||
//
|
||||
|
||||
//
|
||||
// Class Variables
|
||||
//
|
||||
|
||||
//
|
||||
// Instance Variables
|
||||
//
|
||||
|
||||
// Attribute Instance Variables
|
||||
|
||||
boolean initialized = false;
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public WrapperFactoryImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
|
||||
//
|
||||
// Methods from webclient.WrapperFactory
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* @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
|
||||
{
|
||||
throwExceptionIfNotInitialized();
|
||||
|
||||
Object result = null;
|
||||
|
||||
synchronized(this) {
|
||||
if (!nativeDoesImplement(interfaceName)) {
|
||||
throw new ClassNotFoundException("Can't instantiate " +
|
||||
interfaceName +
|
||||
": not implemented.");
|
||||
}
|
||||
System.out.println("debug: edburns: native library does implement " +
|
||||
interfaceName);
|
||||
if (BrowserControl.WINDOW_CONTROL_NAME == interfaceName) {
|
||||
result = new WindowControlImpl(this, browserControl);
|
||||
return result;
|
||||
}
|
||||
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.EVENT_REGISTRATION_NAME == interfaceName) {
|
||||
result = new EventRegistrationImpl(this, browserControl);
|
||||
return result;
|
||||
}
|
||||
if (BrowserControl.BOOKMARKS_NAME == interfaceName) {
|
||||
result = new BookmarksImpl(this, browserControl);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void initialize(String verifiedBinDirAbsolutePath) throws Exception
|
||||
{
|
||||
synchronized(this) {
|
||||
if (!hasBeenInitialized()) {
|
||||
nativeInitialize(verifiedBinDirAbsolutePath);
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void terminate() throws Exception
|
||||
{
|
||||
throwExceptionIfNotInitialized();
|
||||
|
||||
synchronized(this) {
|
||||
nativeTerminate();
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasBeenInitialized()
|
||||
{
|
||||
return initialized;
|
||||
}
|
||||
|
||||
//
|
||||
// Native methods
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* This is called only once, at the very beginning of program execution.
|
||||
* This method allows the native code to handle ONE TIME initialization
|
||||
* tasks. Per-window initialization tasks are handled in the
|
||||
* WindowControlImpl native methods. <P>
|
||||
|
||||
* For mozilla, this means initializing XPCOM.
|
||||
|
||||
*/
|
||||
|
||||
private native void nativeInitialize (String verifiedBinDirAbsolutePath) throws Exception;
|
||||
|
||||
/**
|
||||
|
||||
* Called only once, at program termination. Results are undefined if
|
||||
* the number of browser windows currently open is greater than zero.
|
||||
|
||||
*/
|
||||
|
||||
private native void nativeTerminate () throws Exception;
|
||||
|
||||
/**
|
||||
|
||||
* This is called whenever java calls newImpl on an instance of this
|
||||
* class. This method allows the native code to declare which of the
|
||||
* "webclient.*" interfaces it supports. See the comments for the
|
||||
* newImpl method for the format of valid values for interfaceName.
|
||||
|
||||
* @see org.mozilla.webclient.wrapper_native.WrapperFactoryImpl.newImpl
|
||||
|
||||
*/
|
||||
|
||||
private native boolean nativeDoesImplement(String interfaceName);
|
||||
|
||||
|
||||
// ----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 2000/03/04 01:10:56 edburns%acm.org Exp $");
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class WrapperFactoryImpl
|
|
@ -0,0 +1,142 @@
|
|||
/* -*- 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.wrapper_native.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.1 2000/03/04 01:10:57 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
/* -*- 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.wrapper_native.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 2000/03/04 01:10:57 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/* -*- 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_native.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.1 2000/03/04 01:10:58 edburns%acm.org Exp $
|
||||
*
|
||||
* @see org.mozilla.webclient.BrowserControlCanvasFactory
|
||||
*
|
||||
|
||||
*/
|
||||
|
||||
import sun.awt.*;
|
||||
import sun.awt.windows.*;
|
||||
|
||||
import org.mozilla.webclient.BrowserControlCanvas;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче