/* * [Go.java] * * Summary: displays glossary indexes, and allows direct jump to corresponding file. * * Copyright: (c) 2001-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2001-03-08 initial * 1.1 2006-01-01 * 1.2 2006-03-05 reformat with IntelliJ, add Javadoc */ package com.mindprod.go; import com.mindprod.common18.VersionCheck; import java.applet.Applet; import java.awt.Choice; import java.awt.Color; import java.awt.event.ItemListener; import java.io.InputStream; import java.net.URL; import static java.lang.System.*; /** * displays glossary indexes, and allows direct jump to corresponding file. *

* Miniature Applet that the end user interacts with. Uses serialised data list of names and targets. Quick find * select human name * and jump to corresponding URL. Applet param golist controls where serialised list comes from. param window controls * target window. See also com\mindprod\keywords\keywords.java which produces the keyword list. * * @author Roedy Green, Canadian Mind Products * @version 1.2 2006-03-05 * @since 2001-03-08 */ public final class Go extends Applet { private static final int FIRST_COPYRIGHT_YEAR = 2001; /** * undisplayed copyright notice */ private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 2001-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; private static final String RELEASE_DATE = "2006-03-06"; /** * embedded version string. */ private static final String VERSION_STRING = "1.2"; /** * displayed human names of the anchors */ private Choice anchorList; /** * List of human names to URLs */ private GoList goList; /** * Called by the browser or Applet viewer to inform * this Applet that it is being reclaimed and that it should destroy * any resources that it has allocated. */ public void destroy() { anchorList = null; goList = null; } /** * Called by the browser or Applet viewer to inform * this Applet that it has been loaded into the system. */ public void init() { if ( !VersionCheck.isJavaVersionOK( 1, 8, 0, this ) ) { return; } setBackground( Color.white ); setLayout( null ); String membername = getParameter( "golist" ); if ( membername == null || membername.length() == 0 ) { out.println( "Missing GoList\n" ); return; } try { InputStream is = Go.class.getResourceAsStream( "/com/mindprod/qf/" + membername ); if ( is == null ) { out.println( "Missing GoList \"" + membername + "\" \n" ); return; } goList = GoList.getData( is ); } catch ( Exception e ) { out.println( "Missing GoList \"" + membername + "\" " + e + "\n" ); return; } anchorList = new Choice(); for ( int i = 0, n = goList.size(); i < n; i++ ) { // use addItem instead of add for 1.1 compatibility. anchorList.addItem( goList.getHumanname( i ) ); } anchorList.select( 0 ); anchorList.setSize( this.getSize() ); add( anchorList ); anchorList.addItemListener( new ItemListener() { public void itemStateChanged( java.awt.event.ItemEvent event ) { try { int index = anchorList.getSelectedIndex(); if ( index >= 0 ) { // send them off to visit the matching page // won't work unless we are in a browser // e.g. relative to E:\mindprod\jgloss String ref; String target = goList.getTarget( index ); if ( target.length() != 0 ) { ref = goList.getFilename( index ) + '#' + target; } else { ref = goList.getFilename( index ); } java.net.URL url = new URL( getDocumentBase(), ref ); String window = getParameter( "window" ); if ( window == null || window.length() == 0 ) { getAppletContext().showDocument( url ); } else { getAppletContext().showDocument( url, window ); } } } catch ( Exception e ) { // don't sweat it if it does not work. } } } ); validate(); this.setVisible( true );// Lights, Camera, Action. } // has no main method. We want this as tiny as possible. }