Skip to content

Commit

Permalink
Added Swing webclient test code and windows makefile mods.
Browse files Browse the repository at this point in the history
  • Loading branch information
edburns%acm.org committed Oct 20, 1999
1 parent 1178f50 commit e681c41
Show file tree
Hide file tree
Showing 21 changed files with 988 additions and 9 deletions.
2 changes: 1 addition & 1 deletion java/webclient/classes/Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ include <$(DEPTH)\config\config.mak>
include <$(DEPTH)\java\config\localdefs.mak>

JAR_WEBCLIENT_CLASSES = org\mozilla\webclient \
org\mozilla\webclient\test org\mozilla\webclient\win32
org\mozilla\webclient\test org\mozilla\webclient\win32 org\mozilla\webclient\test\swing

!ifdef JAVA_OR_NSJVM
JDIRS = $(JAR_WEBCLIENT_CLASSES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* interfaces.
*
* @version $Id: BrowserControl.java,v 1.1 1999/07/30 01:03:03 edburns%acm.org Exp $
* @version $Id: BrowserControl.java,v 1.2 1999/10/20 00:49:18 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCore
* @see org.mozilla.webclient.BrowserControlExtended
Expand All @@ -36,4 +36,6 @@
public interface BrowserControl extends BrowserControlCore, BrowserControlExtended
{

public EventRegistration getEventRegistration();

} // end of interface BrowserControl
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
*
* <B>Lifetime And Scope</B> <P>
*
* @version $Id: BrowserControlImpl.java,v 1.3 1999/10/08 00:48:01 edburns%acm.org Exp $
* @version $Id: BrowserControlImpl.java,v 1.4 1999/10/20 00:49:18 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControl
*
*/

public class BrowserControlImpl extends Object implements BrowserControl
public class BrowserControlImpl extends Object implements BrowserControl, EventRegistration
{
//
// Protected Constants
Expand Down Expand Up @@ -69,8 +69,7 @@ public class BrowserControlImpl extends Object implements BrowserControl

public BrowserControlImpl(int windowPtr, Rectangle bounds) throws Exception
{
nativeWebShell = BrowserControlMozillaShim.webShellCreate(windowPtr,
bounds);
nativeWebShell = BrowserControlMozillaShim.webShellCreate(windowPtr, bounds);
}

//
Expand Down Expand Up @@ -211,6 +210,21 @@ public boolean refresh() throws Exception
return BrowserControlMozillaShim.webShellRefresh(nativeWebShell);
}

/**
* get EventRegistration object
*/

public EventRegistration getEventRegistration() {
return this;
}

/**
* add document load event listener
*/
public boolean addDocumentLoadListener(DocumentLoadListener dll) throws Exception {
return BrowserControlMozillaShim.webShellAddDocListener(nativeWebShell, dll);
}

/**
*
*/
Expand Down Expand Up @@ -245,7 +259,7 @@ public static void main(String [] args)
// BrowserControlImpl me = new BrowserControlImpl();
Log.setApplicationName("BrowserControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.3 1999/10/08 00:48:01 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.4 1999/10/20 00:49:18 edburns%acm.org Exp $");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* There is one instance of this class and all of the exposed methods
* are static.
* @version $Id: BrowserControlMozillaShim.java,v 1.4 1999/10/08 00:48:02 edburns%acm.org Exp $
* @version $Id: BrowserControlMozillaShim.java,v 1.5 1999/10/20 00:49:19 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlImpl
Expand Down Expand Up @@ -299,6 +299,17 @@ public static void webShellDelete (int webShellPtr) throws Exception
}
}

public static boolean webShellAddDocListener(int webShellPtr, DocumentLoadListener dl) throws Exception
{
synchronized(lock) {
if (initialized) {
return instance.nativeWebShellAddDocListener(webShellPtr, dl);
} else {
throw new Exception ("instance is not initialized");
}
}
}

public static void webShellLoadURL (int webShellPtr,
String urlString) throws Exception
{
Expand Down Expand Up @@ -527,6 +538,7 @@ private native void nativeSendMouseEvent(int windowPtr, int widgetPtr,

private native int nativeWidgetCreate (int windowPtr, int x, int y, int width, int height) throws Exception;
private native void nativeWidgetDelete (int widgetPtr) throws Exception;
private native boolean nativeWebShellAddDocListener(int windowPtr, DocumentLoadListener dl);
private native void nativeWidgetResize (int widgetPtr, int x, int y, int width, int height, boolean repaint);

/*
Expand Down Expand Up @@ -588,7 +600,7 @@ public static void main(String [] args)
BrowserControlMozillaShim me = new BrowserControlMozillaShim();
Log.setApplicationName("BrowserControlMozillaShim");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlMozillaShim.java,v 1.4 1999/10/08 00:48:02 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: BrowserControlMozillaShim.java,v 1.5 1999/10/20 00:49:19 edburns%acm.org Exp $");

}

Expand Down
7 changes: 7 additions & 0 deletions java/webclient/classes/org/mozilla/webclient/DocListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.mozilla.webclient;

public interface DocListener {

public void handleDocLoaderEvent();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.mozilla.webclient;

public interface DocumentLoadListener {
public void docEventPerformed(String event);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.mozilla.webclient;

public interface EventRegistration {

public boolean addDocumentLoadListener(DocumentLoadListener dll) throws Exception;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

package org.mozilla.webclient.test.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import org.mozilla.webclient.*;

class BackAction extends AbstractAction {
private SwingEmbeddedMozilla em;

public BackAction(SwingEmbeddedMozilla em) {
super ("Back");
this.em = em;
}

public void actionPerformed(ActionEvent evt) {
System.out.println("Back was pressed!!");
em.back();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package org.mozilla.webclient.test.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import org.mozilla.webclient.*;

public class CommandPanel extends JPanel implements ActionListener {
private JToolBar urltool;
private JToolBar navtool;
private JTextField urlfield;
private JComboBox cb;
private SwingEmbeddedMozilla em;

public CommandPanel(SwingEmbeddedMozilla em) {
super();
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
setLayout(gbl);
this.em = em;

navtool = createNavToolBar();
urltool = createURLToolBar();

// Layout of the toolbars.
gbc.anchor = GridBagConstraints.NORTHWEST;
add(navtool, gbc);

gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
add(Box.createHorizontalGlue(), gbc);

gbc.gridwidth = 1;
add(urltool, gbc);
}

private JButton makeButton(String arg) {
JButton button = new JButton(arg);
return button;
}

private JToolBar createURLToolBar() {
JToolBar tb = new JToolBar();
// Ann - commented out the combobox for demo purposes. 9/20/99
// String temp[] = {"Fee", "Fi", "Fo", "Fum"};
//cb = new JComboBox(temp);
//cb.setEditable(true);
//cb.setLightWeightPopupEnabled(false);
urlfield = new JTextField(25);

tb.add(urlfield);
//tb.add(cb);
//cb.addActionListener(this);
urlfield.addActionListener(this);
return tb;
}




private JToolBar createNavToolBar() {
JToolBar tb = new JToolBar();

tb.add(new BackAction(em));
tb.add(new ForwardAction(em));
tb.add(new StopAction(em));
tb.add(new RefreshAction(em));
tb.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
return tb;
}


public JTextField getURLField() {
return urlfield;
}

public JToolBar getNavToolBar() {
return navtool;
}

public void actionPerformed (ActionEvent evt) {
String command = evt.getActionCommand();
String url = null;
System.out.println( "ActionComand is "+ command);
if ("comboBoxChanged".equals(command)) {
url = (String) cb.getSelectedItem();
} else {
url = urlfield.getText();
}
em.loadURL(url);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

package org.mozilla.webclient.test.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import org.mozilla.webclient.*;

class ForwardAction extends AbstractAction {
private SwingEmbeddedMozilla em;

public ForwardAction(SwingEmbeddedMozilla em) {
super ("Forward");
this.em = em;
}

public void actionPerformed(ActionEvent evt) {
System.out.println("Forwardwas pressed!!");
em.forward();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

package org.mozilla.webclient.test.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import org.mozilla.webclient.*;

class RefreshAction extends AbstractAction {
private SwingEmbeddedMozilla em;

public RefreshAction(SwingEmbeddedMozilla em) {
super ("Refresh");
this.em = em;
}

public void actionPerformed(ActionEvent evt) {
System.out.println("Refresh was pressed!!");
em.refresh();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.mozilla.webclient.test.swing;
/*
* StatusPanel.java
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.mozilla.webclient.*;

public class StatusTextField extends JTextField implements DocumentLoadListener {

public StatusTextField(BrowserControl bc) {
super();
setEditable(false);
try {
bc.getEventRegistration().addDocumentLoadListener(this);
} catch (Exception ex) {
System.out.println(ex.toString());
}

}
public void docEventPerformed(String event) {
if (event.equals("startdocumentload")) {
this.setText("Loading document...");
} else if (event.equals("enddocumentload")) {
this.setText("Finished loading document.");
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

package org.mozilla.webclient.test.swing;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import org.mozilla.webclient.*;

class StopAction extends AbstractAction {
private SwingEmbeddedMozilla em;

public StopAction(SwingEmbeddedMozilla em) {
super ("Stop");
this.em = em;
}

public void actionPerformed(ActionEvent evt) {
System.out.println("Stop was pressed!!");
em.stop();

}
}
Loading

0 comments on commit e681c41

Please sign in to comment.