de.mud.jta.plugin
Class ButtonBar

java.lang.Object
  |
  +--de.mud.jta.Plugin
        |
        +--de.mud.jta.plugin.ButtonBar
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, FilterPlugin, javax.swing.event.ListSelectionListener, VisualPlugin

public class ButtonBar
extends Plugin
implements FilterPlugin, VisualPlugin, java.awt.event.ActionListener, javax.swing.event.ListSelectionListener

Implementation of a programmable button bar to be used as a plugin in the Java(tm) Telnet Applet/Application. The button bar is configured using a input file that contains the setup for the button bar.

A typical setup file may look like:

 #
 # Example for writing a button bar config file.
 #
 # The syntaxt for defining buttons, input fields and breaks is as follows:
 #
 # - defining a button:
 # A button is defined by giving the keyword 'button' followed by the text
 # of the button and the command that should be sent when pressing the
 # button. If the command contains whitespace characters, enclode it in
 # quote (") characters!
 #
 button		Connect		"\$connect(\@host@,\@port@)"
 #
 # - defining a label:
 # A labvel is defined by giving the keyword 'label' followed by the text
 # of the label. If the label contains whitespace characters, enclode it in
 # quote (") characters!
 #
 label 		"Hello User"
 #
 # - defining an input field:
 # An input field is defined just like the button above, but it has one more
 # parameter, the size of the input field. So you define it, by giving the
 # keyword 'input' followed by the name of the input field (for reference)
 # followed by the size of the input field and optionally a third parameter
 # which is the initial text to be displayed in that field.
 #
 input		host	20	"tanis"
 stretch
 input		port	4	"23"
 #
 # Now after the button and two input fields we define another button which
 # will be shown last in the row. Order is significant for the order in
 # which the buttons and fields appear.
 #
 button		Disconnect	"\\$disconnect()" break
 #
 # To implement an input line that is cleared and sends text use this:
 # The following line send the text in the input field "send" and appends
 # a newline.
 input		send	20	"\\@send@\n"	"ls"
 #
 # - Defining a choice
 # A choice is defined just like the button above, but it has multiple
 # text/command pairs. If the text or command contain whitespace characters,
 # enclose them in quote (") characters. The text and command data may be
 # spread over several lines for better readability. Make the first command
 # empty because it is initially selected, and choosing it will have no
 # effect until some other item has been chosen.
 #choice       "- choose -"   ""
 #             "Text 1"       "Command 1"
 #             "Text 2"       "Command 2"
 #             "Text 3"       "Command 3"
 # etc...

 
Other possible keywords are break which does introduce a new line so that buttons and input fields defined next will appear in a new line below and stretch to make the just defined button or input field stretched as far as possible on the line. That last keyword is useful to fill the space.

Version:
$Id: ButtonBar.java,v 2.13 2002/05/06 07:24:20 leo Exp $
Author:
Matthias L. Jugel, Marcus Meißner

Field Summary
protected  javax.swing.JPanel panel
          the panel that contains the buttons and input fields
 
Fields inherited from class de.mud.jta.Plugin
bus, id
 
Constructor Summary
ButtonBar(PluginBus bus, java.lang.String id)
          Initialize the button bar and register plugin listeners
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
           
 FilterPlugin getFilterSource()
           
 javax.swing.JMenu getPluginMenu()
          Get the menu entry for this component.
 javax.swing.JComponent getPluginVisual()
          Get the visible components from the plugin.
 int read(byte[] b)
          Read a block of data from the back end.
 void setFilterSource(FilterPlugin source)
          Set the source plugin where we get our data from and where the data sink (write) is.
 void valueChanged(javax.swing.event.ListSelectionEvent evt)
           
 void write(byte[] b)
          Write a block of data to the back end.
 
Methods inherited from class de.mud.jta.Plugin
error, getId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

panel

protected javax.swing.JPanel panel
the panel that contains the buttons and input fields
Constructor Detail

ButtonBar

public ButtonBar(PluginBus bus,
                 java.lang.String id)
Initialize the button bar and register plugin listeners
Method Detail

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent evt)
Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

getPluginVisual

public javax.swing.JComponent getPluginVisual()
Description copied from interface: VisualPlugin
Get the visible components from the plugin.
Specified by:
getPluginVisual in interface VisualPlugin
Following copied from interface: de.mud.jta.VisualPlugin
Returns:
a component that represents the plugin

getPluginMenu

public javax.swing.JMenu getPluginMenu()
Description copied from interface: VisualPlugin
Get the menu entry for this component.
Specified by:
getPluginMenu in interface VisualPlugin
Following copied from interface: de.mud.jta.VisualPlugin
Returns:
a menu that can be used to change the plugin state

setFilterSource

public void setFilterSource(FilterPlugin source)
Description copied from interface: FilterPlugin
Set the source plugin where we get our data from and where the data sink (write) is. The actual data handling should be done in the read() and write() methods.
Specified by:
setFilterSource in interface FilterPlugin
Following copied from interface: de.mud.jta.FilterPlugin
Parameters:
source - the data source

getFilterSource

public FilterPlugin getFilterSource()
Specified by:
getFilterSource in interface FilterPlugin

read

public int read(byte[] b)
         throws java.io.IOException
Description copied from interface: FilterPlugin
Read a block of data from the back end.
Specified by:
read in interface FilterPlugin
Following copied from interface: de.mud.jta.FilterPlugin
Parameters:
b - the buffer to read the data into
Returns:
the amount of bytes actually read

write

public void write(byte[] b)
           throws java.io.IOException
Description copied from interface: FilterPlugin
Write a block of data to the back end.
Specified by:
write in interface FilterPlugin
Following copied from interface: de.mud.jta.FilterPlugin
Parameters:
b - the buffer to be sent