public abstract class SendActionManager
extends java.lang.Object
Note: concrete subclasses must call updateState()
before use
(in the constructor).
Modifier and Type | Class and Description |
---|---|
private static class |
SendActionManager.TargetComboBoxModel
ComboBoxModel implementation used for selecting a target client.
|
Modifier and Type | Field and Description |
---|---|
private static javax.swing.Icon |
BROADCAST_ICON |
static java.lang.String |
BROADCAST_TARGET
ComboBox element indicating broadcast to all clients.
|
private javax.swing.Action |
broadcastAct_ |
private boolean |
broadcastActCreated_ |
private javax.swing.event.ChangeListener |
connectionListener_ |
private GuiHubConnector |
connector_ |
private boolean |
enabled_ |
private static java.util.logging.Logger |
logger_ |
private java.util.List |
menuList_ |
private static javax.swing.Icon |
SEND_ICON |
private javax.swing.Action[] |
sendActs_ |
(package private) javax.swing.ListModel |
subscribedClientModel_ |
private javax.swing.event.ListDataListener |
subscriptionListener_ |
Modifier | Constructor and Description |
---|---|
protected |
SendActionManager(GuiHubConnector connector,
javax.swing.ListModel clientListModel)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract javax.swing.Action |
createBroadcastAction()
Returns a new action for broadcast associated with this object.
|
javax.swing.JMenu |
createSendMenu(java.lang.String name)
Returns a new menu which provides options to send a message to
one of the registered listeners at a time.
|
javax.swing.Action |
createTargetAction(javax.swing.ComboBoxModel targetSelector)
Returns an action suitable for sending the message represented by
this manager to a target selected by a supplied ComboBoxModel.
|
javax.swing.ComboBoxModel |
createTargetSelector()
Returns a new ComboBoxModel containing selections for each suitable
client and an additional selection for broadcast to all clients.
|
void |
dispose()
Releases any resources associated with this object.
|
void |
disposeSendMenu(javax.swing.JMenu menu)
Releases any resources associated with a menu previously created
using
createSendMenu(java.lang.String) . |
javax.swing.Action |
getBroadcastAction()
Returns an action which will broadcast a message
to all suitable registered applications.
|
static javax.swing.Icon |
getBroadcastIcon()
Returns an icon suitable for depicting a general broadcast send.
|
javax.swing.ListModel |
getClientListModel()
Returns the client list to which this manager will offer sends.
|
GuiHubConnector |
getConnector()
Returns this manager's hub connector.
|
protected abstract javax.swing.Action |
getSendAction(Client client)
Returns an action which can perform a single-client send associated
with this object.
|
static javax.swing.Icon |
getSendIcon()
Returns an icon suitable for depicting a general targetted send.
|
void |
setEnabled(boolean enabled)
Sets the enabled status of this object.
|
private void |
updateEnabledness()
Updates the enabled status of controlled actions in accordance with
this object's current state.
|
void |
updateState()
Updates the state of actions managed by this object when the
list of registered listeners has changed.
|
private final GuiHubConnector connector_
final javax.swing.ListModel subscribedClientModel_
private final java.util.List menuList_
private final javax.swing.event.ListDataListener subscriptionListener_
private final javax.swing.event.ChangeListener connectionListener_
private boolean enabled_
private javax.swing.Action broadcastAct_
private boolean broadcastActCreated_
private javax.swing.Action[] sendActs_
private static javax.swing.Icon SEND_ICON
private static javax.swing.Icon BROADCAST_ICON
private static final java.util.logging.Logger logger_
public static final java.lang.String BROADCAST_TARGET
protected SendActionManager(GuiHubConnector connector, javax.swing.ListModel clientListModel)
connector
- hub connectorclientListModel
- list model containing only those
clients which are suitable recipients;
all elements must be Client
sprotected abstract javax.swing.Action createBroadcastAction()
protected abstract javax.swing.Action getSendAction(Client client)
equals
(and hashCode
) intelligently there will be efficiency
advantages.
The enabled status of such actions will be managed by this object.client
- recipient clientpublic void setEnabled(boolean enabled)
enabled
- false to ensure that the actions are disabled,
true means they may be enabledpublic javax.swing.Action getBroadcastAction()
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).
public javax.swing.JMenu createSendMenu(java.lang.String name)
name
- menu titlepublic void disposeSendMenu(javax.swing.JMenu menu)
createSendMenu(java.lang.String)
. Don't use the menu again.menu
- previously created send menupublic void dispose()
public void updateState()
public javax.swing.ListModel getClientListModel()
Client
spublic javax.swing.ComboBoxModel createTargetSelector()
Client
objects, or
BROADCAST_TARGET
to indicate broadcast.
The result of this is suitable for use with createTargetAction(javax.swing.ComboBoxModel)
.public javax.swing.Action createTargetAction(javax.swing.ComboBoxModel targetSelector)
createTargetSelector()
.targetSelector
- combo box model in which the elements are
Client
objects,
or BROADCAST_TARGET
null to indicate broadcastpublic GuiHubConnector getConnector()
private void updateEnabledness()
public static javax.swing.Icon getSendIcon()
public static javax.swing.Icon getBroadcastIcon()