From: <doc...@us...> - 2007-12-05 05:27:23
|
Revision: 198 http://openpcl.svn.sourceforge.net/openpcl/?rev=198&view=rev Author: documentsystems Date: 2007-12-04 21:27:26 -0800 (Tue, 04 Dec 2007) Log Message: ----------- Howard Hoagland. Added new feature to get the optional initial PCL file name to open at applet startup time from the HTML file that runs the applet, and automatically show that PCL file on the screen without the user needing to click anything when the applet starts up. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/applet/OpenPCLApplet.java Modified: openpcl/src/com/openpcl/viewer/applet/OpenPCLApplet.java =================================================================== --- openpcl/src/com/openpcl/viewer/applet/OpenPCLApplet.java 2007-12-05 05:11:57 UTC (rev 197) +++ openpcl/src/com/openpcl/viewer/applet/OpenPCLApplet.java 2007-12-05 05:27:26 UTC (rev 198) @@ -6,6 +6,10 @@ import com.openpcl.viewer.OpenPCLViewer; +/** + * Run OpenPCLViewer in an applet in your browser (IE, Firefox) instead of from WebStart JNLP. + * @author DocMagic, Document Systems Inc, Howard Hoagland 11/16/06 + */ public class OpenPCLApplet extends JApplet { private static final long serialVersionUID = 1L; protected OpenPCLViewer mOpenPCLViewer = null; @@ -13,6 +17,7 @@ public OpenPCLApplet() { } + @Override public void init() { System.out.println("OpenPCLViewer applet init"); @@ -22,21 +27,47 @@ // If running on Macintosh. MUST be done before the OpenPCLViewer constructor is called. OpenPCLViewer.sIsRunningOnMacintosh = OpenPCLViewer.detectIfMacintosh(OpenPCLViewer.sOsNameString); - mOpenPCLViewer = new OpenPCLViewer(this, null); + String tSourceFileString = getParameter("SourceFile"); + String tOpenFileString = getParameter("OpenFile"); + String tFileToOpen = null; + + // If there is a file to open in the HTML file that launched the applet, then auto open the PCL at applet startup time + if (tSourceFileString != null && tSourceFileString.length() > 1) { + tFileToOpen = tSourceFileString; + } else if (tOpenFileString != null && tOpenFileString.length() > 1) { + tFileToOpen = tOpenFileString; + } + + String[] tCommandLineOptions = null; + if (tFileToOpen != null) { + // Create a command line parameter String array that will be passed in the constructor below + tCommandLineOptions = new String[] { "-OpenFile=" + tFileToOpen }; + } + + // Instantiate the OpenPCLViewer which is a subclass of JPanel, then put it in this Applet taking up the full height and width on screen + mOpenPCLViewer = new OpenPCLViewer(this, tCommandLineOptions); + setLayout(new BorderLayout()); add(mOpenPCLViewer, BorderLayout.CENTER); + + if (tFileToOpen != null) { + // Needed to automatically show the startup file in the applet after the above "add(mOpenPCLViewer, BorderLayout.CENTER)" + mOpenPCLViewer.executeAfterUiIsShowing(); + } } - public void start() { + @Override +public void start() { System.out.println("OpenPCLViewer applet start"); } + @Override public void stop() { System.out.println("OpenPCLViewer applet stop"); } + @Override public void destroy() { - System.out.println("OpenPCLViewer applet destroy"); - } - + System.out.println("OpenPCLViewer applet destroy"); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |