uk.ac.starlink.plastic
Class PlasticTransmitter

java.lang.Object
  extended byuk.ac.starlink.plastic.PlasticTransmitter

public abstract class PlasticTransmitter
extends Object

Provides actions for transmitting messages of a particular kind using PLASTIC. The purpose of this class is to provide actions and menus which allow the user to send a message to either one or multiple appropriate listeners. These actions/menus are kept up to date with respect to the current set of registered listener applications. Only applications which claim to support a particular message are considerered. If there are no such applications the send actions are disabled.

Since:
12 Apr 2006
Author:
Mark Taylor

Constructor Summary
PlasticTransmitter(HubManager hubman, URI messageId, String sendType)
          Constructs a new transmitter.
 
Method Summary
 JMenu createSendMenu()
          Returns a new menu which provides options to send a message to one of the registered listeners at a time.
 Action getBroadcastAction()
          Returns an action which will broadcast a message to all suitable registered applications.
 void setEnabled(boolean enabled)
          Sets the enabled status of this transmitter.
protected abstract  void transmit(PlasticHubListener hub, URI clientId, ApplicationItem app)
          This performs the actual work of transmission to one or all registered applications.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlasticTransmitter

public PlasticTransmitter(HubManager hubman,
                          URI messageId,
                          String sendType)
Constructs a new transmitter.

Parameters:
hubman - hub manager which keeps track of registered apps
messageId - the message ID this transmitter will transmit; only registered applications which claim to suppor this message are considered
sendType - short string representing the type of object which is transmitted; this is used only for setting up text names for actions etc
Method Detail

transmit

protected abstract void transmit(PlasticHubListener hub,
                                 URI clientId,
                                 ApplicationItem app)
                          throws IOException
This performs the actual work of transmission to one or all registered applications.

Parameters:
hub - hub object
clientId - identifier under which this application is registered with hub
app - application to which the transmit should be done. If null, broadcast to all suitable listeners.
Throws:
IOException

setEnabled

public void setEnabled(boolean enabled)
Sets the enabled status of this transmitter. This acts as a restriction (AND) on the enabled status of the menus and actions controlled by this transmitter. If there are no suitable recipient applications registered they will be disabled anyway.

Parameters:
enabled - false to ensure that the actions are disabled, true means they may be enabled

getBroadcastAction

public Action getBroadcastAction()
Returns an action which will broadcast a message to all suitable registered applications.

This action is currently not disabled when there are no suitable listeners, mainly for debugging purposes (so you can see if a message is getting sent and what it looks like even in absence of suitable listeners).

Returns:
broadcast action

createSendMenu

public JMenu createSendMenu()
Returns a new menu which provides options to send a message to one of the registered listeners at a time. This menu will be disabled when no suitable listeners are registered.

Returns:
new message send menu


Copyright © 2006 \\ CLRC: Central Laboratory of the Research Councils. All Rights Reserved.