commit - 8bb63b724e7ec65191bef2909874305749e37194
commit + 07ec9efc9ee6001b0fab3d5d585588806d10ed0e
blob - ddcc13a6c0c61ba177636e8715b5477bb2ddba83
blob + e718948230f6c5b741d0ad86c2357f6ffa57e44a
--- de/mud/jta/Applet.java
+++ de/mud/jta/Applet.java
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
- * "The Java Telnet Application" is distributed in the hope that it will be
+ * "The Java Telnet Application" is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
*/
package de.mud.jta;
+import de.mud.jta.event.AppletRequest;
+import de.mud.jta.event.FocusStatusListener;
import de.mud.jta.event.OnlineStatusListener;
-import de.mud.jta.event.SocketRequest;
import de.mud.jta.event.ReturnFocusRequest;
-import de.mud.jta.event.FocusStatusListener;
-import de.mud.jta.event.AppletRequest;
+import de.mud.jta.event.SocketRequest;
import de.mud.jta.event.SoundListener;
-import java.util.Properties;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import java.util.Vector;
-
-import java.io.IOException;
-import java.net.URL;
-
-import java.awt.Frame;
-import java.awt.BorderLayout;
-import java.awt.GridLayout;
-import java.awt.Panel;
-import java.awt.Label;
-import java.awt.Button;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Menu;
-import java.awt.MenuBar;
-import java.awt.MenuItem;
-import java.awt.MenuShortcut;
-import java.awt.PrintJob;
-
+import java.awt.*;
import java.awt.datatransfer.Clipboard;
-
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
-
-import java.lang.reflect.Method;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+import java.util.Vector;
/**
* <B>The Java Telnet Applet</B><P>
* This is the implementation of whole set of applications. It's modular
* structure allows to configure the software to act either as a sophisticated
- * terminal emulation and/or, adding the network backend, as telnet
+ * terminal emulation and/or, adding the network backend, as telnet
* implementation. Additional modules provide features like scripting or an
* improved graphical user interface.<P>
* This software is written entirely in Java<SUP>tm</SUP>.<P>
* This is the <I>Applet</I> implementation for the software. It initializes
* the system and adds all needed components, such as the telnet backend and
- * the terminal front end.
+ * the terminal front end.
* <P>
* <B>Maintainer:</B> Matthias L. Jugel
*
private Clipboard clipboard;
private boolean online = false;
+ private HelpFrame helpFrame = null;
+
/**
* Read all parameters from the applet configuration and
* do initializations for the plugins and the applet.
*/
public void init() {
- if(debug > 0) System.err.println("Applet: init()");
- if(pluginLoader == null) {
+ if (debug > 0) System.err.println("Applet: init()");
+ if (pluginLoader == null) {
try {
options.load(Applet.class
- .getResourceAsStream("/de/mud/jta/default.conf"));
- } catch(Exception e) {
- try {
+ .getResourceAsStream("/de/mud/jta/default.conf"));
+ } catch (Exception e) {
+ try {
URL url = new URL(getCodeBase() + "default.conf");
options.load(url.openStream());
- } catch(Exception e1) {
- System.err.println("jta: cannot load default.conf");
- System.err.println("jta: try extracting it from the jar file");
- System.err.println("jta: expected file here: "
- +getCodeBase()+ "default.conf");
+ } catch (Exception e1) {
+ System.err.println("jta: cannot load default.conf");
+ System.err.println("jta: try extracting it from the jar file");
+ System.err.println("jta: expected file here: "
+ + getCodeBase() + "default.conf");
}
}
String value;
// try to load the local configuration and merge it with the defaults
- if((value = getParameter("config")) != null) {
+ if ((value = getParameter("config")) != null) {
Properties appletParams = new Properties();
- URL url = null;
- try {
- url = new URL(value);
- } catch(Exception e) {
- try {
- url = new URL(getCodeBase() + value);
- } catch(Exception ce) {
- System.err.println("jta: could not find config file: "+ce);
- }
- }
+ URL url = null;
+ try {
+ url = new URL(value);
+ } catch (Exception e) {
+ try {
+ url = new URL(getCodeBase() + value);
+ } catch (Exception ce) {
+ System.err.println("jta: could not find config file: " + ce);
+ }
+ }
- if(url != null) {
- try {
- appletParams.load(Applet.class.getResourceAsStream("/de/mud/jta/" + value));
- Enumeration ape = appletParams.keys();
- while(ape.hasMoreElements()) {
- String key = (String)ape.nextElement();
- options.put(key, appletParams.getProperty(key));
- }
- } catch ( Exception e )
- {
- try
- {
- appletParams.load(url.openStream());
- Enumeration ape = appletParams.keys();
- while(ape.hasMoreElements()) {
- String key = (String)ape.nextElement();
- options.put(key, appletParams.getProperty(key));
- }
- } catch ( Exception e2 )
- {
- System.err.println("jta: could not load config file: "+e2);
- }
- }
- }
+ if (url != null) {
+ try {
+ appletParams.load(Applet.class.getResourceAsStream("/de/mud/jta/" + value));
+ Enumeration ape = appletParams.keys();
+ while (ape.hasMoreElements()) {
+ String key = (String) ape.nextElement();
+ options.put(key, appletParams.getProperty(key));
+ }
+ } catch (Exception e) {
+ try {
+ appletParams.load(url.openStream());
+ Enumeration ape = appletParams.keys();
+ while (ape.hasMoreElements()) {
+ String key = (String) ape.nextElement();
+ options.put(key, appletParams.getProperty(key));
+ }
+ } catch (Exception e2) {
+ System.err.println("jta: could not load config file: " + e2);
+ }
+ }
+ }
}
// see if there are parameters in the html to override properties
// set the host to our code base, no other hosts are allowed anyway
host = options.getProperty("Socket.host");
- if(host == null)
+ if (host == null)
host = getCodeBase().getHost();
port = options.getProperty("Socket.port");
- if(port == null)
+ if (port == null)
port = "23";
- if((new Boolean(options.getProperty("Applet.connect"))
- .booleanValue()))
- connect = true;
- if(!(new Boolean(options.getProperty("Applet.disconnect"))
- .booleanValue()))
- disconnect = false;
+ if ((new Boolean(options.getProperty("Applet.connect"))
+ .booleanValue()))
+ connect = true;
+ if (!(new Boolean(options.getProperty("Applet.disconnect"))
+ .booleanValue()))
+ disconnect = false;
- if(!(new Boolean(options.getProperty("Applet.disconnect.closeWindow"))
- .booleanValue()))
- disconnectCloseWindow = false;
+ if (!(new Boolean(options.getProperty("Applet.disconnect.closeWindow"))
+ .booleanValue()))
+ disconnectCloseWindow = false;
- frameTitle = options.getProperty("Applet.detach.title");
+ frameTitle = options.getProperty("Applet.detach.title");
- if((new Boolean(options.getProperty("Applet.detach"))).booleanValue()) {
- if(frameTitle == null)
- appletFrame = new Frame("jta: "+host+(port.equals("23")?"":" "+port));
- else
- appletFrame = new Frame(frameTitle);
- } else
- appletFrame = this;
+ if ((new Boolean(options.getProperty("Applet.detach"))).booleanValue()) {
+ if (frameTitle == null)
+ appletFrame = new Frame("jta: " + host + (port.equals("23")?"":" " + port));
+ else
+ appletFrame = new Frame(frameTitle);
+ } else
+ appletFrame = this;
appletFrame.setLayout(new BorderLayout());
Hashtable componentList = pluginLoader.getComponents();
Enumeration names = componentList.keys();
- while(names.hasMoreElements()) {
- String name = (String)names.nextElement();
- Component c = (Component)componentList.get(name);
- if((value = options.getProperty("layout."+name)) != null) {
+ while (names.hasMoreElements()) {
+ String name = (String) names.nextElement();
+ Component c = (Component) componentList.get(name);
+ if ((value = options.getProperty("layout." + name)) != null) {
appletFrame.add(value, c);
} else {
- System.err.println("jta: no layout property set for '"+name+"'");
- System.err.println("jta: ignoring '"+name+"'");
- }
+ System.err.println("jta: no layout property set for '" + name + "'");
+ System.err.println("jta: ignoring '" + name + "'");
+ }
}
pluginLoader.registerPluginListener(new SoundListener() {
public void playSound(URL audioClip) {
- Applet.this.getAudioClip(audioClip).play();
- }
+ Applet.this.getAudioClip(audioClip).play();
+ }
});
pluginLoader.broadcast(new AppletRequest(this));
- if(appletFrame != this) {
- final String startText = options.getProperty("Applet.detach.startText");
- final String stopText = options.getProperty("Applet.detach.stopText");
- final Button close = new Button();
+ if (appletFrame != this) {
+ final String startText = options.getProperty("Applet.detach.startText");
+ final String stopText = options.getProperty("Applet.detach.stopText");
+ final Button close = new Button();
- // this works for Netscape only!
- Vector privileges =
- Common.split(options.getProperty("Applet.Netscape.privilege"), ',');
- Class privilegeManager = null;
- Method enable = null;
+ // this works for Netscape only!
+ Vector privileges =
+ Common.split(options.getProperty("Applet.Netscape.privilege"), ',');
+ Class privilegeManager = null;
+ Method enable = null;
try {
- privilegeManager =
- Class.forName("netscape.security.PrivilegeManager");
- enable = privilegeManager
- .getMethod("enablePrivilege", new Class[] { String.class });
- } catch(Exception e) {
- System.err.println("Applet: This is not Netscape ...");
+ privilegeManager =
+ Class.forName("netscape.security.PrivilegeManager");
+ enable = privilegeManager
+ .getMethod("enablePrivilege", new Class[]{String.class});
+ } catch (Exception e) {
+ System.err.println("Applet: This is not Netscape ...");
}
- if(privilegeManager != null && enable != null && privileges != null)
- for(int i = 0; i < privileges.size(); i++) try {
- enable.invoke(privilegeManager,
- new Object[] { privileges.elementAt(i) });
- System.out.println("Applet: access for '"+
- privileges.elementAt(i)+"' allowed");
+ if (privilegeManager != null && enable != null && privileges != null)
+ for (int i = 0; i < privileges.size(); i++)
+ try {
+ enable.invoke(privilegeManager,
+ new Object[]{privileges.elementAt(i)});
+ System.out.println("Applet: access for '" +
+ privileges.elementAt(i) + "' allowed");
- } catch(Exception e) {
- System.err.println("Applet: access for '"+
- privileges.elementAt(i)+"' denied");
- }
+ } catch (Exception e) {
+ System.err.println("Applet: access for '" +
+ privileges.elementAt(i) + "' denied");
+ }
// set up the clipboard
- try {
+ try {
clipboard = appletFrame.getToolkit().getSystemClipboard();
- System.err.println("Applet: acquired system clipboard: "+clipboard);
- } catch(Exception e) {
- System.err.println("Applet: system clipboard access denied: "+
- ((e instanceof InvocationTargetException) ?
- ((InvocationTargetException)e).getTargetException() : e));
- // e.printStackTrace();
+ System.err.println("Applet: acquired system clipboard: " + clipboard);
+ } catch (Exception e) {
+ System.err.println("Applet: system clipboard access denied: " +
+ ((e instanceof InvocationTargetException) ?
+ ((InvocationTargetException) e).getTargetException() : e));
+ // e.printStackTrace();
} finally {
- if(clipboard == null) {
+ if (clipboard == null) {
System.err.println("Applet: copy & paste only within the JTA");
clipboard = new Clipboard("de.mud.jta.Main");
- }
+ }
}
-
- if((new Boolean(options.getProperty("Applet.detach.immediately"))
- .booleanValue())) {
- if((new Boolean(options.getProperty("Applet.detach.fullscreen"))
- .booleanValue()))
- ((Frame)appletFrame)
- .setSize(appletFrame.getToolkit().getScreenSize());
- else
- ((Frame)appletFrame).pack();
- ((Frame)appletFrame).show();
- pluginLoader.broadcast(new SocketRequest(host,Integer.parseInt(port)));
- pluginLoader.broadcast(new ReturnFocusRequest());
- close.setLabel(startText != null ? stopText : "Disconnect");
- } else
- close.setLabel(startText != null ? startText : "Connect");
+ if ((new Boolean(options.getProperty("Applet.detach.immediately"))
+ .booleanValue())) {
+ if ((new Boolean(options.getProperty("Applet.detach.fullscreen"))
+ .booleanValue()))
+ ((Frame) appletFrame)
+ .setSize(appletFrame.getToolkit().getScreenSize());
+ else
+ ((Frame) appletFrame).pack();
- close.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- if(((Frame)appletFrame).isVisible()) {
- pluginLoader.broadcast(new SocketRequest());
- ((Frame)appletFrame).setVisible(false);
- close.setLabel(startText != null ? startText : "Connect");
- } else {
- if(frameTitle == null)
- ((Frame)appletFrame)
- .setTitle("jta: "+host+(port.equals("23")?"":" "+port));
- if((new Boolean(options.getProperty("Applet.detach.fullscreen"))
- .booleanValue()))
- ((Frame)appletFrame)
- .setSize(appletFrame.getToolkit().getScreenSize());
- else
- ((Frame)appletFrame).pack();
- ((Frame)appletFrame).show();
- getAppletContext().showStatus("Trying "+host+" "+port+" ...");
- pluginLoader.broadcast(new SocketRequest(host,
- Integer.parseInt(port)));
+ ((Frame) appletFrame).show();
+ pluginLoader.broadcast(new SocketRequest(host, Integer.parseInt(port)));
+ pluginLoader.broadcast(new ReturnFocusRequest());
+ close.setLabel(startText != null ? stopText : "Disconnect");
+ } else
+ close.setLabel(startText != null ? startText : "Connect");
+
+ close.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (((Frame) appletFrame).isVisible()) {
+ pluginLoader.broadcast(new SocketRequest());
+ ((Frame) appletFrame).setVisible(false);
+ close.setLabel(startText != null ? startText : "Connect");
+ } else {
+ if (frameTitle == null)
+ ((Frame) appletFrame)
+ .setTitle("jta: " + host + (port.equals("23")?"":" " + port));
+ if ((new Boolean(options.getProperty("Applet.detach.fullscreen"))
+ .booleanValue()))
+ ((Frame) appletFrame)
+ .setSize(appletFrame.getToolkit().getScreenSize());
+ else
+ ((Frame) appletFrame).pack();
+ ((Frame) appletFrame).show();
+ getAppletContext().showStatus("Trying " + host + " " + port + " ...");
+ pluginLoader.broadcast(new SocketRequest(host,
+ Integer.parseInt(port)));
pluginLoader.broadcast(new ReturnFocusRequest());
- close.setLabel(stopText != null ? stopText : "Disconnect");
- }
+ close.setLabel(stopText != null ? stopText : "Disconnect");
+ }
}
- });
+ });
- setLayout(new BorderLayout());
- add("Center", close);
+ setLayout(new BorderLayout());
+ add("Center", close);
- // add a menu bar
+ // add a menu bar
MenuBar mb = new MenuBar();
Menu file = new Menu("File");
- file.setShortcut(new MenuShortcut(KeyEvent.VK_H, true));
+ file.setShortcut(new MenuShortcut(KeyEvent.VK_F, true));
MenuItem tmp;
file.add(tmp = new MenuItem("Connect"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
- pluginLoader.broadcast(new SocketRequest(host,
- Integer.parseInt(port)));
+ pluginLoader.broadcast(new SocketRequest(host,
+ Integer.parseInt(port)));
}
});
file.add(tmp = new MenuItem("Disconnect"));
pluginLoader.broadcast(new SocketRequest());
}
});
- file.add(new MenuItem("-"));
+ file.add(new MenuItem("-"));
file.add(tmp = new MenuItem("Print"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
- if(pluginLoader.getComponents().get("Terminal") != null) {
- PrintJob printJob =
- appletFrame.getToolkit()
- .getPrintJob((Frame)appletFrame,"JTA Terminal",null);
- ((Component)pluginLoader.getComponents().get("Terminal"))
- .print(printJob.getGraphics());
+ if (pluginLoader.getComponents().get("Terminal") != null) {
+ PrintJob printJob =
+ appletFrame.getToolkit()
+ .getPrintJob((Frame) appletFrame, "JTA Terminal", null);
+ ((Component) pluginLoader.getComponents().get("Terminal"))
+ .print(printJob.getGraphics());
printJob.end();
}
}
file.add(tmp = new MenuItem("Exit"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
- ((Frame)appletFrame).setVisible(false);
- pluginLoader.broadcast(new SocketRequest());
- close.setLabel(startText != null ? startText : "Connect");
+ ((Frame) appletFrame).setVisible(false);
+ pluginLoader.broadcast(new SocketRequest());
+ close.setLabel(startText != null ? startText : "Connect");
}
});
- mb.add(file);
+ mb.add(file);
- Menu edit = new Menu("Edit");
- edit.setShortcut(new MenuShortcut(KeyEvent.VK_H, true));
+ Menu edit = new Menu("Edit");
+ edit.setShortcut(new MenuShortcut(KeyEvent.VK_E, true));
edit.add(tmp = new MenuItem("Copy"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
- if(debug > 2)
- System.err.println("Applet: copy: "+focussedPlugin);
- if(focussedPlugin instanceof VisualTransferPlugin)
- ((VisualTransferPlugin)focussedPlugin).copy(clipboard);
+ if (debug > 2)
+ System.err.println("Applet: copy: " + focussedPlugin);
+ if (focussedPlugin instanceof VisualTransferPlugin)
+ ((VisualTransferPlugin) focussedPlugin).copy(clipboard);
}
});
edit.add(tmp = new MenuItem("Paste"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
- if(debug > 2)
- System.err.println("Applet: paste: "+focussedPlugin);
- if(focussedPlugin instanceof VisualTransferPlugin)
- ((VisualTransferPlugin)focussedPlugin).paste(clipboard);
+ if (debug > 2)
+ System.err.println("Applet: paste: " + focussedPlugin);
+ if (focussedPlugin instanceof VisualTransferPlugin)
+ ((VisualTransferPlugin) focussedPlugin).paste(clipboard);
}
});
mb.add(edit);
- Hashtable menuList = pluginLoader.getMenus();
+ Hashtable menuList = pluginLoader.getMenus();
names = menuList.keys();
- while(names.hasMoreElements()) {
- String name = (String)names.nextElement();
- mb.add((Menu)menuList.get(name));
+ while (names.hasMoreElements()) {
+ String name = (String) names.nextElement();
+ mb.add((Menu) menuList.get(name));
}
- // only add the menubar if the property is true
- if((new Boolean(options.getProperty("Applet.detach.menuBar"))
- .booleanValue()))
- ((Frame)appletFrame).setMenuBar(mb);
+ Menu help = new Menu("Help");
+ help.setShortcut(new MenuShortcut(KeyEvent.VK_HELP, true));
+ help.add(tmp = new MenuItem("General"));
+ tmp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if(helpFrame == null) {
+ helpFrame = new HelpFrame(options.getProperty("Help.url"));
+ }
+ helpFrame.setVisible(true);
+ }
+ });
+ mb.setHelpMenu(help);
- // add window closing event handler
+ // only add the menubar if the property is true
+ if ((new Boolean(options.getProperty("Applet.detach.menuBar"))
+ .booleanValue()))
+ ((Frame) appletFrame).setMenuBar(mb);
+
+ // add window closing event handler
try {
- ((Frame)appletFrame).addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent evt) {
- pluginLoader.broadcast(new SocketRequest());
- ((Frame)appletFrame).setVisible(false);
- close.setLabel(startText != null ? startText : "Connect");
- }
- });
- } catch(Exception e) {
- System.err.println("Applet: could not set up Window event listener");
- System.err.println("Applet: you will not be able to close it");
- }
+ ((Frame) appletFrame).addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent evt) {
+ pluginLoader.broadcast(new SocketRequest());
+ ((Frame) appletFrame).setVisible(false);
+ close.setLabel(startText != null ? startText : "Connect");
+ }
+ });
+ } catch (Exception e) {
+ System.err.println("Applet: could not set up Window event listener");
+ System.err.println("Applet: you will not be able to close it");
+ }
pluginLoader.registerPluginListener(new OnlineStatusListener() {
public void online() {
- if(debug > 0) System.err.println("Terminal: online");
+ if (debug > 0) System.err.println("Terminal: online");
online = true;
- if(((Frame)appletFrame).isVisible() == false)
- ((Frame)appletFrame).setVisible(true);
- }
- public void offline() {
- if(debug > 0) System.err.println("Terminal: offline");
- online=false;
- if(disconnectCloseWindow) {
- ((Frame)appletFrame).setVisible(false);
- close.setLabel(startText != null ? startText : "Connect");
- }
- }
+ if (((Frame) appletFrame).isVisible() == false)
+ ((Frame) appletFrame).setVisible(true);
+ }
+
+ public void offline() {
+ if (debug > 0) System.err.println("Terminal: offline");
+ online = false;
+ if (disconnectCloseWindow) {
+ ((Frame) appletFrame).setVisible(false);
+ close.setLabel(startText != null ? startText : "Connect");
+ }
+ }
});
// register a focus status listener, so we know when a plugin got focus
pluginLoader.registerPluginListener(new FocusStatusListener() {
public void pluginGainedFocus(Plugin plugin) {
- if(Applet.debug > 0)
- System.err.println("Applet: "+plugin+" got focus");
+ if (Applet.debug > 0)
+ System.err.println("Applet: " + plugin + " got focus");
focussedPlugin = plugin;
}
+
public void pluginLostFocus(Plugin plugin) {
// we ignore the lost focus
- if(Applet.debug > 0)
- System.err.println("Applet: "+plugin+" lost focus");
+ if (Applet.debug > 0)
+ System.err.println("Applet: " + plugin + " lost focus");
}
});
} else
- // if we have no external frame use this online status listener
+ // if we have no external frame use this online status listener
pluginLoader.registerPluginListener(new OnlineStatusListener() {
public void online() {
- if(debug > 0) System.err.println("Terminal: online");
+ if (debug > 0) System.err.println("Terminal: online");
online = true;
}
+
public void offline() {
- if(debug > 0) System.err.println("Terminal: offline");
- online=false;
+ if (debug > 0) System.err.println("Terminal: offline");
+ online = false;
}
});
-
+
}
}
* Start the applet. Connect to the remote host.
*/
public void start() {
- if(!online && (appletFrame == this || connect)) {
- if(debug > 0) System.err.println("start("+host+", "+port+")");
- getAppletContext().showStatus("Trying "+host+" "+port+" ...");
+ if (!online && (appletFrame == this || connect)) {
+ if (debug > 0) System.err.println("start(" + host + ", " + port + ")");
+ getAppletContext().showStatus("Trying " + host + " " + port + " ...");
pluginLoader.broadcast(new SocketRequest(host, Integer.parseInt(port)));
pluginLoader.broadcast(new ReturnFocusRequest());
- }
+ }
}
/**
* Stop the applet and disconnect.
*/
public void stop() {
- if(online && disconnect) {
- if(debug > 0) System.err.println("stop()");
+ if (online && disconnect) {
+ if (debug > 0) System.err.println("stop()");
pluginLoader.broadcast(new SocketRequest());
}
}
*/
private void parameterOverride(Properties options) {
Enumeration e = options.keys();
- while(e.hasMoreElements()) {
- String key = (String)e.nextElement(), value = getParameter(key);
- if(value != null) {
- System.out.println("Applet: overriding value of "+key+" with "+value);
+ while (e.hasMoreElements()) {
+ String key = (String) e.nextElement(), value = getParameter(key);
+ if (value != null) {
+ System.out.println("Applet: overriding value of " + key + " with " + value);
// options.setProperty(key, value);
options.put(key, value);
}
blob - 7625f78d282eb7500f00acee1a064e761369dacb
blob + c4c7583567b81f047f070ae14daa2be3e962816e
--- de/mud/jta/Main.java
+++ de/mud/jta/Main.java
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
- * "The Java Telnet Application" is distributed in the hope that it will be
+ * "The Java Telnet Application" is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
*/
package de.mud.jta;
-import de.mud.jta.event.OnlineStatusListener;
import de.mud.jta.event.FocusStatusListener;
-import de.mud.jta.event.SocketRequest;
+import de.mud.jta.event.OnlineStatusListener;
import de.mud.jta.event.ReturnFocusRequest;
+import de.mud.jta.event.SocketRequest;
-import java.util.Properties;
-import java.util.Hashtable;
-import java.util.Enumeration;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import java.net.URL;
-
-import java.awt.Frame;
-import java.awt.PrintJob;
-import java.awt.Dialog;
-import java.awt.Label;
-import java.awt.Button;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Menu;
-import java.awt.MenuBar;
-import java.awt.MenuItem;
-import java.awt.MenuShortcut;
-
-import java.awt.event.ActionListener;
+import java.awt.*;
+import java.awt.datatransfer.Clipboard;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.FocusEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
-import java.awt.datatransfer.Clipboard;
-
/**
* <B>The Java Telnet Application</B><P>
* This is the implementation of whole set of applications. It's modular
* structure allows to configure the software to act either as a sophisticated
- * terminal emulation and/or, adding the network backend, as telnet
+ * terminal emulation and/or, adding the network backend, as telnet
* implementation. Additional modules provide features like scripting or an
* improved graphical user interface.<P>
* This software is written entirely in Java<SUP>tm</SUP>.<P>
/** holds the system clipboard or our own */
private static Clipboard clipboard;
+ private static HelpFrame helpFrame;
public static void main(String args[]) {
- Properties options = new Properties();
+ final Properties options = new Properties();
try {
options.load(Main.class.getResourceAsStream("/de/mud/jta/default.conf"));
- } catch(IOException e) {
+ } catch (IOException e) {
System.err.println("jta: cannot load default.conf");
}
String error = parseOptions(options, args);
- if(error != null) {
+ if (error != null) {
System.err.println(error);
System.err.println("usage: de.mud.jta.Main [-plugins pluginlist] "
- +"[-addplugin plugin] "
- +"[-config url_or_file] "
- +"[-term id] [host [port]]");
+ + "[-addplugin plugin] "
+ + "[-config url_or_file] "
+ + "[-term id] [host [port]]");
System.exit(0);
}
String cfg = options.getProperty("Main.config");
- if(cfg != null) try {
- options.load(new URL(cfg).openStream());
- } catch(IOException e) {
+ if (cfg != null)
try {
- options.load(new FileInputStream(cfg));
- } catch(Exception fe) {
- System.err.println("jta: cannot load "+cfg);
+ options.load(new URL(cfg).openStream());
+ } catch (IOException e) {
+ try {
+ options.load(new FileInputStream(cfg));
+ } catch (Exception fe) {
+ System.err.println("jta: cannot load " + cfg);
+ }
}
- }
final String host = options.getProperty("Socket.host");
final String port = options.getProperty("Socket.port");
- final Frame frame = new Frame("jta: "+host+(port.equals("23")?"":" "+port));
+ final Frame frame = new Frame("jta: " + host + (port.equals("23")?"":" " + port));
// set up the clipboard
try {
clipboard = frame.getToolkit().getSystemClipboard();
- } catch(Exception e) {
+ } catch (Exception e) {
System.err.println("jta: system clipboard access denied");
System.err.println("jta: copy & paste only within the JTA");
clipboard = new Clipboard("de.mud.jta.Main");
final Common setup = new Common(options);
setup.registerPluginListener(new OnlineStatusListener() {
- public void online() {
- frame.setTitle("jta: "+host+(port.equals("23")?"":" "+port));
+ public void online() {
+ frame.setTitle("jta: " + host + (port.equals("23")?"":" " + port));
}
+
public void offline() {
frame.setTitle("jta: offline");
}
// register a focus status listener, so we know when a plugin got focus
setup.registerPluginListener(new FocusStatusListener() {
public void pluginGainedFocus(Plugin plugin) {
- if(Main.debug > 0)
- System.err.println("Main: "+plugin+" got focus");
+ if (Main.debug > 0)
+ System.err.println("Main: " + plugin + " got focus");
focussedPlugin = plugin;
}
+
public void pluginLostFocus(Plugin plugin) {
// we ignore the lost focus
- if(Main.debug > 0)
- System.err.println("Main: "+plugin+" lost focus");
+ if (Main.debug > 0)
+ System.err.println("Main: " + plugin + " lost focus");
}
});
Hashtable componentList = setup.getComponents();
Enumeration names = componentList.keys();
- while(names.hasMoreElements()) {
- String name = (String)names.nextElement();
- Component c = (Component)componentList.get(name);
- if(options.getProperty("layout."+name) == null) {
- System.err.println("jta: no layout property set for '"+name+"'");
- frame.add("South", c);
+ while (names.hasMoreElements()) {
+ String name = (String) names.nextElement();
+ Component c = (Component) componentList.get(name);
+ if (options.getProperty("layout." + name) == null) {
+ System.err.println("jta: no layout property set for '" + name + "'");
+ frame.add("South", c);
} else
- frame.add(options.getProperty("layout."+name), c);
+ frame.add(options.getProperty("layout." + name), c);
}
- if(!personalJava) {
+ if (!personalJava) {
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent evt) {
- setup.broadcast(new SocketRequest());
- frame.setVisible(false);
- frame.dispose();
- System.exit(0);
- }
- });
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent evt) {
+ setup.broadcast(new SocketRequest());
+ frame.setVisible(false);
+ frame.dispose();
+ System.exit(0);
+ }
+ });
- // add a menu bar
- MenuBar mb = new MenuBar();
- Menu file = new Menu("File");
- file.setShortcut(new MenuShortcut(KeyEvent.VK_H, true));
- MenuItem tmp;
- file.add(tmp = new MenuItem("Connect"));
- tmp.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- setup.broadcast(new SocketRequest(host, Integer.parseInt(port)));
- }
- });
- file.add(tmp = new MenuItem("Disconnect"));
- tmp.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- setup.broadcast(new SocketRequest());
- }
- });
- file.add(new MenuItem("-"));
- file.add(tmp = new MenuItem("Print"));
- tmp.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- if(setup.getComponents().get("Terminal") != null) {
- PrintJob printJob =
- frame.getToolkit().getPrintJob(frame,"JTA Terminal",null);
- // return if the user clicked cancel
- if(printJob == null) return;
- ((Component)setup.getComponents().get("Terminal"))
- .print(printJob.getGraphics());
- printJob.end();
- }
- }
- });
- file.add(new MenuItem("-"));
- file.add(tmp = new MenuItem("Exit"));
- tmp.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- frame.dispose();
- System.exit(0);
- }
- });
- mb.add(file);
+ // add a menu bar
+ MenuBar mb = new MenuBar();
+ Menu file = new Menu("File");
+ file.setShortcut(new MenuShortcut(KeyEvent.VK_H, true));
+ MenuItem tmp;
+ file.add(tmp = new MenuItem("Connect"));
+ tmp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ setup.broadcast(new SocketRequest(host, Integer.parseInt(port)));
+ }
+ });
+ file.add(tmp = new MenuItem("Disconnect"));
+ tmp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ setup.broadcast(new SocketRequest());
+ }
+ });
+ file.add(new MenuItem("-"));
+ file.add(tmp = new MenuItem("Print"));
+ tmp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (setup.getComponents().get("Terminal") != null) {
+ PrintJob printJob =
+ frame.getToolkit().getPrintJob(frame, "JTA Terminal", null);
+ // return if the user clicked cancel
+ if (printJob == null) return;
+ ((Component) setup.getComponents().get("Terminal"))
+ .print(printJob.getGraphics());
+ printJob.end();
+ }
+ }
+ });
+ file.add(new MenuItem("-"));
+ file.add(tmp = new MenuItem("Exit"));
+ tmp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ frame.dispose();
+ System.exit(0);
+ }
+ });
+ mb.add(file);
- Menu edit = new Menu("Edit");
- edit.setShortcut(new MenuShortcut(KeyEvent.VK_H, true));
- edit.add(tmp = new MenuItem("Copy"));
- tmp.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- if(focussedPlugin instanceof VisualTransferPlugin)
- ((VisualTransferPlugin)focussedPlugin).copy(clipboard);
+ Menu edit = new Menu("Edit");
+ edit.setShortcut(new MenuShortcut(KeyEvent.VK_H, true));
+ edit.add(tmp = new MenuItem("Copy"));
+ tmp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (focussedPlugin instanceof VisualTransferPlugin)
+ ((VisualTransferPlugin) focussedPlugin).copy(clipboard);
+ }
+ });
+ edit.add(tmp = new MenuItem("Paste"));
+ tmp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (focussedPlugin instanceof VisualTransferPlugin)
+ ((VisualTransferPlugin) focussedPlugin).paste(clipboard);
+ }
+ });
+ mb.add(edit);
+
+ Hashtable menuList = setup.getMenus();
+ names = menuList.keys();
+ while (names.hasMoreElements()) {
+ String name = (String) names.nextElement();
+ mb.add((Menu) menuList.get(name));
}
- });
- edit.add(tmp = new MenuItem("Paste"));
- tmp.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- if(focussedPlugin instanceof VisualTransferPlugin)
- ((VisualTransferPlugin)focussedPlugin).paste(clipboard);
- }
- });
- mb.add(edit);
- Hashtable menuList = setup.getMenus();
- names = menuList.keys();
- while(names.hasMoreElements()) {
- String name = (String)names.nextElement();
- mb.add((Menu)menuList.get(name));
- }
+ Menu help = new Menu("Help");
+ help.setShortcut(new MenuShortcut(KeyEvent.VK_HELP, true));
+ help.add(tmp = new MenuItem("General"));
+ tmp.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if (helpFrame == null) {
+ helpFrame = new HelpFrame(options.getProperty("Help.url"));
+ }
+ helpFrame.setVisible(true);
+ }
+ });
+ mb.setHelpMenu(help);
- Menu help = new Menu("Help");
- help.add(tmp = new MenuItem("About"));
- tmp.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- final Dialog d = new Dialog(frame, "About JTA", true);
- d.add("Center", new Label("Copyright (c) 1996-2000 "
- +"Matthias L Jugel, Marcus Meißner"));
- Button close = new Button("Close");
- close.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- d.dispose();
- }
- });
- d.add("South", close);
- d.pack();
- d.setResizable(false);
- d.show();
- }
- });
- mb.setHelpMenu(help);
- frame.setMenuBar(mb);
+ frame.setMenuBar(mb);
} // !personalJava
frame.pack();
- if((new Boolean(options.getProperty("Applet.detach.fullscreen"))
- .booleanValue()))
+ if ((new Boolean(options.getProperty("Applet.detach.fullscreen"))
+ .booleanValue()))
frame.setSize(frame.getToolkit().getScreenSize());
else
frame.pack();
* with the new values if applicable.
* <P><SMALL>
* This method did not work with jdk 1.1.x as the setProperty()
- * method is not available. So it uses now the put() method from
+ * method is not available. So it uses now the put() method from
* Hashtable instead.
* </SMALL>
* @param options the original options
*/
private static String parseOptions(Properties options, String args[]) {
boolean host = false, port = false;
- for(int n = 0; n < args.length; n++) {
- if(args[n].equals("-config"))
- if(!args[n+1].startsWith("-"))
- options.put("Main.config", args[++n]);
- else
- return "missing parameter for -config";
- else if(args[n].equals("-plugins"))
- if(!args[n+1].startsWith("-"))
- options.put("plugins", args[++n]);
+ for (int n = 0; n < args.length; n++) {
+ if (args[n].equals("-config"))
+ if (!args[n + 1].startsWith("-"))
+ options.put("Main.config", args[++n]);
else
- return "missing parameter for -plugins";
- else if(args[n].equals("-addplugin"))
- if(!args[n+1].startsWith("-"))
- options.put("plugins", args[++n]+","+options.get("plugins"));
+ return "missing parameter for -config";
+ else if (args[n].equals("-plugins"))
+ if (!args[n + 1].startsWith("-"))
+ options.put("plugins", args[++n]);
else
- return "missing parameter for -addplugin";
- else if(args[n].equals("-term"))
- if(!args[n+1].startsWith("-"))
+ return "missing parameter for -plugins";
+ else if (args[n].equals("-addplugin"))
+ if (!args[n + 1].startsWith("-"))
+ options.put("plugins", args[++n] + "," + options.get("plugins"));
+ else
+ return "missing parameter for -addplugin";
+ else if (args[n].equals("-term"))
+ if (!args[n + 1].startsWith("-"))
options.put("Terminal.id", args[++n]);
- else
- return "missing parameter for -term";
- else if(!host) {
- options.put("Socket.host", args[n]); host = true;
- } else if(host && !port) {
- options.put("Socket.port", args[n]); port = true;
+ else
+ return "missing parameter for -term";
+ else if (!host) {
+ options.put("Socket.host", args[n]);
+ host = true;
+ } else if (host && !port) {
+ options.put("Socket.port", args[n]);
+ port = true;
} else
- return "unknown parameter '"+args[n]+"'";
+ return "unknown parameter '" + args[n] + "'";
}
return null;
}
blob - 766c83593b31c6cb3707afc037da73a326381b6d
blob + 0da2e5f8ca87f3808e23b5d661c74dc22b6b5efa
--- de/mud/jta/default.conf
+++ de/mud/jta/default.conf
layout.Terminal = Center
layout.Status = South
+# help url/filename
+Help.url = /README
+
# =======================================================================
# Applet defaults
# =======================================================================
blob - 033dec9adb4dc67538ab3ae32156bc27a32a00cf
blob + b4316a8cdb0514c5dd8361222d3c313e8d479a55
--- de/mud/jta/plugin/Capture.java
+++ de/mud/jta/plugin/Capture.java
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
+import java.util.Hashtable;
/**
* A capture plugin that captures data and stores it in a
* @author Matthias L. Jugel, Marcus Meißner
*/
public class Capture extends Plugin
- implements FilterPlugin, VisualPlugin {
+ implements FilterPlugin, VisualPlugin,ActionListener {
// this enables or disables the compilation of menu entries
private final static boolean personalJava = false;
private final static int debug = 1;
/** The remote storage URL */
- protected URL remoteURL = null;
+ protected Hashtable remoteUrlList = new Hashtable();
/** The plugin menu */
protected Menu menu;
+ protected Dialog dialog;
/** Whether the capture is currently enabled or not */
protected boolean captureEnabled = false;
frame.pack();
// an error dialogue, in case the upload fails
- final Dialog dialog = new Dialog(frame);
+ dialog = new Dialog(frame);
dialog.setLayout(new BorderLayout());
- dialog.add(new TextField("Cannot store data on remote server!"));
+ dialog.add(new Label("Cannot store data on remote server!"));
Button close = new Button("Close Dialog");
dialog.add(close);
close.addActionListener(new ActionListener() {
});
menu.add(view);
- save = new MenuItem("Save Protocol");
- save.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (debug > 0) System.err.println("Capture: storing text: " + remoteURL);
- try {
- URLConnection urlConnection = remoteURL.openConnection();
- DataOutputStream out;
- DataInputStream in;
-
- // Let the RTS know that we want to do output.
- urlConnection.setDoInput(true);
- // Let the RTS know that we want to do output.
- urlConnection.setDoOutput(true);
- // No caching, we want the real thing.
- urlConnection.setUseCaches(false);
- // Specify the content type.
- urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
- // Send POST output.
-
- // send the data to the url receiver ...
- out = new DataOutputStream(urlConnection.getOutputStream());
- String content = "content=" + URLEncoder.encode(textArea.getText());
- if(debug > 0) System.err.println("Capture: " + content);
- out.writeBytes(content);
- out.flush();
- out.close();
-
- // retrieve response from the remote host and display it.
- if(debug > 0) System.err.println("Capture: reading response");
- in = new DataInputStream(urlConnection.getInputStream());
- String str;
- while (null != ((str = in.readLine()))) {
- System.out.println("Capture: "+str);
- }
- in.close();
-
- } catch (IOException ioe) {
- dialog.setVisible(true);
- System.err.println("Capture: cannot store text on remote server: " + remoteURL);
- ioe.printStackTrace();
- }
- if (debug > 0) System.err.println("Capture: storage complete: " + remoteURL);
- }
- });
- save.setEnabled(false);
- menu.add(save);
} // !personalJava
+
// configure the remote URL
bus.registerPluginListener(new ConfigurationListener() {
public void setConfiguration(PluginConfig config) {
String tmp;
- if ((tmp = config.getProperty("Capture", id, "url")) != null) {
+ int i = 1;
+ while ((tmp = config.getProperty("Capture", id, i+".url")) != null) {
try {
- remoteURL = new URL(tmp);
- save.setLabel("Save to: " + tmp);
+ String urlID = "URL."+i;
+ URL remoteURL = new URL(tmp);
+ remoteUrlList.put(urlID, remoteURL);
+ if((tmp = config.getProperty("Capture", id, i+".params")) != null) {
+ remoteUrlList.put(urlID+".params", tmp);
+ }
+ // use name if applicable or URL
+ if((tmp = config.getProperty("Capture", id, i+".name")) != null) {
+ save = new MenuItem("Save As "+tmp);
+ } else {
+ save = new MenuItem("Save As "+remoteURL.toString());
+ }
+ // enable menu entry
save.setEnabled(true);
+ save.addActionListener(Capture.this);
+ save.setActionCommand(urlID);
+ menu.add(save);
+ // count up
+ i++;
} catch (MalformedURLException e) {
System.err.println("capture url invalid: " + e);
}
});
}
+ public void actionPerformed(ActionEvent e) {
+ String urlID = e.getActionCommand();
+ URL url = (URL)remoteUrlList.get(urlID);
+
+ if (debug > 0) System.err.println("Capture: storing text: "
+ + urlID+": "
+ + remoteUrlList.get(urlID));
+ try {
+ URLConnection urlConnection = url.openConnection();
+ DataOutputStream out;
+ DataInputStream in;
+
+ // Let the RTS know that we want to do output.
+ urlConnection.setDoInput(true);
+ // Let the RTS know that we want to do output.
+ urlConnection.setDoOutput(true);
+ // No caching, we want the real thing.
+ urlConnection.setUseCaches(false);
+ // Specify the content type.
+ urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+
+ // retrieve extra arguments
+ // Send POST output.
+ // send the data to the url receiver ...
+ out = new DataOutputStream(urlConnection.getOutputStream());
+ String content = (String)remoteUrlList.get(urlID+".param");
+ content = (content == null ? "" : content + "&") + "content=" + URLEncoder.encode(textArea.getText());
+ if(debug > 0) System.err.println("Capture: " + content);
+ out.writeBytes(content);
+ out.flush();
+ out.close();
+
+ // retrieve response from the remote host and display it.
+ if(debug > 0) System.err.println("Capture: reading response");
+ in = new DataInputStream(urlConnection.getInputStream());
+ String str;
+ while (null != ((str = in.readLine()))) {
+ System.out.println("Capture: "+str);
+ }
+ in.close();
+
+ } catch (IOException ioe) {
+ dialog.setVisible(true);
+ System.err.println("Capture: cannot store text on remote server: " + url );
+ ioe.printStackTrace();
+ }
+ if (debug > 0) System.err.println("Capture: storage complete: " + url);
+ }
+
// this is where we get the data from (left side in plugins list)
protected FilterPlugin source;
blob - e5d0a80d439ffc465c75c42323d2a2a3deb79b54
blob + d515570c4964a3fdf9c5b83b3e9889d010fc4105
--- de/mud/jta/plugin/Terminal.java
+++ de/mud/jta/plugin/Terminal.java
*/
public Terminal(final PluginBus bus, final String id) {
super(bus, id);
+
// initialize colors
colors.put("black", Color.black);
colors.put("red", Color.red);