bug: 20659

r=gbarney
a=edburns

This checkin adds java.awt.event.MouseListener support to webclient for
mozilla.  The following files are include in this checkin.  "A" is new
file "M" is modified file.

A classes_spec/org/mozilla/webclient/WCMouseEvent.java
A classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java
A src_moz/DOMMouseListenerImpl.cpp
A src_moz/DOMMouseListenerImpl.h
A src_moz/dom_util.cpp
A src_moz/dom_util.h

M classes_spec/org/mozilla/webclient/EventRegistration.java
M classes_spec/org/mozilla/webclient/test/EMWindow.java
M classes_spec/org/mozilla/webclient/wrapper_native/EventRegistrationImpl.java
M classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java
M src_moz/DocumentLoaderObserverImpl.cpp
M src_moz/DocumentLoaderObserverImpl.h
M src_moz/EventRegistration.cpp
M src_moz/EventRegistration.h
M src_moz/Makefile.solaris
M src_moz/Makefile.win
M src_moz/NativeEventThread.cpp
M src_moz/NavigationImpl.cpp
M src_moz/RDFTreeNode.cpp
M src_moz/bal_util.cpp
M src_moz/jni_util.cpp
M src_moz/jni_util.h
M src_moz/jni_util_export.cpp
M src_moz/jni_util_export.h



A classes_spec/org/mozilla/webclient/WCMouseEvent.java

 * <P> This java.awt.event.MouseEvent subclass allows the user to access the
 * WebclientEvent.  This eventData of this WebclientEvent, if non-null,
 * is a java.util.Properties instance that contains information about
 * this event.  </P>

 * <P>The following are some interesting keys:</P>

 * <UL>

 * <LI> href
 * </LI>

 * <LI> #text
 * </LI>

 * </UL>

A classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java

 * This class wraps the user provided instance of
 * java.awt.event.MouseListener so it can be installed as a
 * WebclientEventListener.  Note that we implement MouseListener so we
 * can be detected by the webclient event system.  We don't do anything
 * with these methods here, though.


A src_moz/DOMMouseListenerImpl.cpp

A src_moz/DOMMouseListenerImpl.h

 * This class is the shim between the mozilla listener event system for
 * mouse events and the java MouseListener interface.
 * For each of the Mouse* methods, we call the appropriate method in java.
 * See the implementation of MouseOver for an example.

 * For each mouseEvent, we create a Properties object containing
 * information about the event.  We use methods in dom_util to do this.

A src_moz/dom_util.cpp

A src_moz/dom_util.h

/**

 * Methods to simplify webclient accessing the mozilla DOM.

 */

M classes_spec/org/mozilla/webclient/EventRegistration.java

Added support for java.awt.event.MouseListener

M classes_spec/org/mozilla/webclient/test/EMWindow.java

Implemented simle MouseListener

M classes_spec/org/mozilla/webclient/wrapper_native/EventRegistrationImpl.java

Added support for java.awt.event.MouseListener

M classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java

Added support for java.awt.event.MouseListener

M src_moz/DocumentLoaderObserverImpl.cpp
M src_moz/DocumentLoaderObserverImpl.h

 * We define a local IID to allow the addDocumentLoadListener and
 * addMouseListener functions in EventRegistration.{h,cpp} to
 * interrogate the currently installed DocumentLoaderObserver instance
 * in mozilla.

 */

#define NS_IDOCLOADEROBSERVERIMPL_IID_STR "fdadb2e0-3028-11d4-8a96-0080c7b9c5ba"

#define NS_IDOCLOADEROBSERVERIMPL_IID {0xfdadb2e0, 0x3028, 0x11d4, { 0x8a, 0x96, 0x00, 0x80, 0xc7, 0xb9, 0xc5, 0xba }}

/**

 * This class is the shim between the mozilla listener event system for
 * document load events and the java DocumentLoadListener interface.
 * For each of the On* methods, we call the appropriate method in java.
 * See the implementation of OnEndDocumentLoad for an example.

 * A DocumentLoaderObserverImpl instance has a "jobject target", which
 * is the Java object that should ultimately receive the events.  This
 * target will be null if the user just wants to listen for mouse
 * events.  It willl be non-null if the user wants to listen for
 * DocumentLoad events.

 * It also hosts a nsIDOMMouseListener instance, which piggybacks on the
 * nsIDocumentLoaderObserver instance.

M src_moz/EventRegistration.cpp
M src_moz/EventRegistration.h

Add support for MouseListener

M src_moz/Makefile.win

Added classes for MouseListener and Dom access

M src_moz/NativeEventThread.cpp

Added support for MouseListener

M src_moz/NavigationImpl.cpp

Added call to ReleaseStringChars for bal case.

M src_moz/RDFTreeNode.cpp

Added call to ReleaseStringChars for bal case.

M src_moz/bal_util.cpp

Added #include "wchar.h" so this file compiles on Solaris.

M src_moz/jni_util.cpp

Added implementations for util_CreatePropertiesObject,
util_DestroyPropertiesObject and util_StoreIntoPropertiesObject.

M src_moz/jni_util.h

/**

 * A JNI wrapper to create a java.util.Properties object, or the
 * equivalent object in the BAL case.

 */

jobject util_CreatePropertiesObject(JNIEnv *env, jobject reserved_NotUsed);

/**

 * A JNI wrapper to destroy the object from CreatePropertiesObject

 */

void util_DestroyPropertiesObject(JNIEnv *env, jobject propertiesObject,
                                  jobject reserved_NotUsed);

/**

 * A JNI wrapper for storing a name/value pair into the Properties
 * object created by CreatePropertiesObject

 */

void util_StoreIntoPropertiesObject(JNIEnv *env, jobject propertiesObject,
                                    jobject name, jobject value);


M src_moz/jni_util_export.cpp
M src_moz/jni_util_export.h

Added functions for allowing the BAL user to specify functions for
{creating, destroying, setting values into} properties objects.


git-svn-id: svn://10.0.0.236/trunk@70879 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2000-05-25 23:51:51 +00:00
parent 6472af28e8
commit bcbf08419d
24 changed files with 1638 additions and 90 deletions

View File

@@ -23,6 +23,7 @@
package org.mozilla.webclient;
import java.awt.event.WindowListener;
import java.awt.event.MouseListener;
public interface EventRegistration {
@@ -35,6 +36,9 @@ public interface EventRegistration {
public void addDocumentLoadListener(DocumentLoadListener listener);
public void removeDocumentLoadListener(DocumentLoadListener listener);
public void addMouseListener(MouseListener listener);
public void removeMouseListener(MouseListener listener);
// public void addDOMListener(DOMListener containerListener);
// public void removeDOMListener(DOMListener containerListener);

View File

@@ -0,0 +1,79 @@
/* -*- 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.Component;
/**
* <P> This java.awt.event.MouseEvent subclass allows the user to access the
* WebclientEvent. This eventData of this WebclientEvent, if non-null,
* is a java.util.Properties instance that contains information about
* this event. </P>
* <P>The following are some interesting keys:</P>
* <UL>
* <LI> href
* </LI>
* <LI> #text
* </LI>
* </UL>
*/
public class WCMouseEvent extends java.awt.event.MouseEvent
{
public static final long MOUSE_DOWN_EVENT_MASK = 1;
public static final long MOUSE_UP_EVENT_MASK = 1 << 2;
public static final long MOUSE_CLICK_EVENT_MASK = 1 << 3;
public static final long MOUSE_DOUBLE_CLICK_EVENT_MASK = 1 << 4;
public static final long MOUSE_OVER_EVENT_MASK = 1 << 5;
public static final long MOUSE_OUT_EVENT_MASK = 1 << 6;
//
// Constructors
//
private WebclientEvent webclientEvent;
public WCMouseEvent(Component source, int id, long when, int modifiers, int x,
int y, int clickCount, boolean popupTrigger,
WebclientEvent wcEvent)
{
// PENDING(edburns): pull out the clickcount and such from the
// Properties object, pass this data on to the constructor.
super(source, id, when, modifiers, x, y, clickCount, popupTrigger);
webclientEvent = wcEvent;
}
public WebclientEvent getWebclientEvent()
{
return webclientEvent;
}
} // end of class WCMouseEvent

View File

@@ -50,13 +50,13 @@ import org.mozilla.util.Assert;
* This is a test application for using the BrowserControl.
*
* @version $Id: EMWindow.java,v 1.6 2000-05-23 21:06:41 ashuk%eng.sun.com Exp $
* @version $Id: EMWindow.java,v 1.7 2000-05-25 23:51:43 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
*/
public class EMWindow extends Frame implements DialogClient, ActionListener, DocumentLoadListener {
public class EMWindow extends Frame implements DialogClient, ActionListener, DocumentLoadListener, MouseListener {
static final int defaultWidth = 640;
static final int defaultHeight = 480;
@@ -207,7 +207,7 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
browserControl.queryInterface(BrowserControl.EVENT_REGISTRATION_NAME);
System.out.println("debug: edburns: adding DocumentLoadListener");
eventRegistration.addDocumentLoadListener(this);
eventRegistration.addMouseListener(this);
// PENDING(edburns): test code, replace with production code
bookmarks =
@@ -449,7 +449,7 @@ public void dialogCancelled(Dialog d) {
//
// From DocumentLoadListener
// From WebclientEventListener sub-interfaces
//
/**
@@ -473,6 +473,47 @@ public void eventDispatched(WebclientEvent event)
}
}
//
// From MouseListener
//
public void mouseClicked(java.awt.event.MouseEvent e)
{
System.out.println("mouseClicked");
}
public void mouseEntered(java.awt.event.MouseEvent e)
{
System.out.println("mouseEntered");
if (e instanceof WCMouseEvent) {
WCMouseEvent wcMouseEvent = (WCMouseEvent) e;
Properties eventProps =
(Properties) wcMouseEvent.getWebclientEvent().getEventData();
if (null == eventProps) {
return;
}
String href = eventProps.getProperty("href");
if (null != href) {
System.out.println(href);
}
}
}
public void mouseExited(java.awt.event.MouseEvent e)
{
System.out.println("mouseExited");
}
public void mousePressed(java.awt.event.MouseEvent e)
{
System.out.println("mousePressed");
}
public void mouseReleased(java.awt.event.MouseEvent e)
{
System.out.println("mouseReleased");
}
}
// EOF

View File

@@ -22,6 +22,7 @@
package org.mozilla.webclient.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
@@ -32,8 +33,10 @@ import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.WrapperFactory;
import org.mozilla.webclient.DocumentLoadEvent;
import org.mozilla.webclient.DocumentLoadListener;
import java.awt.event.MouseListener;
import org.mozilla.webclient.WebclientEvent;
import org.mozilla.webclient.WebclientEventListener;
import org.mozilla.webclient.UnimplementedException;
public class EventRegistrationImpl extends ImplObjectNative implements EventRegistration
{
@@ -112,6 +115,7 @@ public void addDocumentLoadListener(DocumentLoadListener listener)
myFactory.throwExceptionIfNotInitialized();
Assert.assert(-1 != nativeWebShell);
Assert.assert(null != nativeEventThread);
ParameterCheck.nonNull(listener);
synchronized(myBrowserControl) {
nativeEventThread.addListener(listener);
@@ -123,10 +127,43 @@ public void removeDocumentLoadListener(DocumentLoadListener listener)
myFactory.throwExceptionIfNotInitialized();
Assert.assert(-1 != nativeWebShell);
throw new UnimplementedException("\nUnimplementedException -----\n API Function EventRegistration.removeDocumentLoadListener has not yet been implemented.\n");
// synchronized(myBrowserControl) {
// }
}
public void addMouseListener(MouseListener listener)
{
myFactory.throwExceptionIfNotInitialized();
Assert.assert(-1 != nativeWebShell);
Assert.assert(null != nativeEventThread);
ParameterCheck.nonNull(listener);
// We have to wrap the user provided java.awt.event.MouseListener
// instance in a custom WebclientEventListener subclass that also
// implements java.awt.event.MouseListener. See WCMouseListener for
// more information.
WCMouseListenerImpl mouseListenerWrapper =
new WCMouseListenerImpl(listener);
synchronized(myBrowserControl) {
nativeEventThread.addListener(mouseListenerWrapper);
}
}
public void removeMouseListener(MouseListener listener)
{
myFactory.throwExceptionIfNotInitialized();
Assert.assert(-1 != nativeWebShell);
throw new UnimplementedException("\nUnimplementedException -----\n API Function EventRegistration.removeMouseListener has not yet been implemented.\n");
// synchronized(myBrowserControl) {
// }
}
// ----VERTIGO_TEST_START
//
@@ -139,7 +176,7 @@ public static void main(String [] args)
Log.setApplicationName("EventRegistrationImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.3 2000-03-13 18:42:23 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.4 2000-05-25 23:51:43 edburns%acm.org Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

View File

@@ -34,6 +34,7 @@ import org.mozilla.webclient.BrowserControlCanvas;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.DocumentLoadEvent;
import org.mozilla.webclient.DocumentLoadListener;
import java.awt.event.MouseListener;
import org.mozilla.webclient.WebclientEvent;
import org.mozilla.webclient.WebclientEventListener;
@@ -263,6 +264,18 @@ void nativeEventOccurred(WebclientEventListener target, long eventType,
if (target instanceof DocumentLoadListener) {
event = new DocumentLoadEvent(this, eventType, eventData);
}
else if (target instanceof MouseListener) {
Assert.assert(target instanceof WCMouseListenerImpl);
// We create a plain vanilla WebclientEvent, which the
// WCMouseListenerImpl target knows how to deal with.
// Also, the source happens to be the browserControlCanvas
// to satisfy the java.awt.event.MouseEvent's requirement
// that the source be a java.awt.Component subclass.
event = new WebclientEvent(browserControlCanvas, eventType, eventData);
}
// else...
// PENDING(edburns): maybe we need to put this in some sort of

View File

@@ -0,0 +1,188 @@
/* -*- 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.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.Component;
import org.mozilla.webclient.WCMouseEvent;
import org.mozilla.webclient.WebclientEvent;
import org.mozilla.webclient.WebclientEventListener;
/**
* This class wraps the user provided instance of
* java.awt.event.MouseListener so it can be installed as a
* WebclientEventListener. Note that we implement MouseListener so we
* can be detected by the webclient event system. We don't do anything
* with these methods here, though.
*/
public class WCMouseListenerImpl extends Object implements WebclientEventListener, MouseListener
{
//
// Protected Constants
//
//
// Class Variables
//
//
// Instance Variables
//
// Attribute Instance Variables
// Relationship Instance Variables
/**
* The MouseListener for which I proxy.
*/
protected MouseListener mouseListener;
//
// Constructors and Initializers
//
WCMouseListenerImpl(MouseListener yourListener)
{
super();
// ParameterCheck.nonNull();
mouseListener = yourListener;
}
//
// Class methods
//
//
// General Methods
//
MouseListener getMouseListener()
{
return mouseListener;
}
//
// Methods from WebclientEventListener
//
/**
* Here's where we take the WebclientEvent from mozilla, generate an
* appropriate WCMouseEvent instance, and call the
* appropriate listener event.
*/
public void eventDispatched(WebclientEvent event)
{
ParameterCheck.nonNull(event);
WCMouseEvent mouseEvent;
switch ((int) event.getType()) {
case (int) WCMouseEvent.MOUSE_DOWN_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_PRESSED, -1,
-1, -1, -1, -1, false, event);
mouseListener.mousePressed(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_UP_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_RELEASED, -1,
-1, -1, -1, -1, false, event);
mouseListener.mouseReleased(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_CLICK_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_CLICKED, -1,
-1, -1, -1, 1, false, event);
mouseListener.mouseClicked(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_DOUBLE_CLICK_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_CLICKED, -1,
-1, -1, -1, 2, false, event);
mouseListener.mouseClicked(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_OVER_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_ENTERED, -1,
-1, -1, -1, -1, false, event);
mouseListener.mouseEntered(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_OUT_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_EXITED, -1,
-1, -1, -1, -1, false, event);
mouseListener.mouseExited(mouseEvent);
break;
}
}
//
// From MouseListener
//
public void mouseClicked(MouseEvent e)
{
Assert.assert(false, "This method should not be called.");
}
public void mouseEntered(MouseEvent e)
{
Assert.assert(false, "This method should not be called.");
}
public void mouseExited(MouseEvent e)
{
Assert.assert(false, "This method should not be called.");
}
public void mousePressed(MouseEvent e)
{
Assert.assert(false, "This method should not be called.");
}
public void mouseReleased(MouseEvent e)
{
Assert.assert(false, "This method should not be called.");
}
} // end of class WCMouseListenerImpl