public abstract class SendActionManager extends Object
Note: concrete subclasses must call updateState()
before use
(in the constructor).
Modifier and Type | Field and Description |
---|---|
static String |
BROADCAST_TARGET
ComboBox element indicating broadcast to all clients.
|
Modifier | Constructor and Description |
---|---|
protected |
SendActionManager(GuiHubConnector connector,
ListModel clientListModel)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract Action |
createBroadcastAction()
Returns a new action for broadcast associated with this object.
|
JMenu |
createSendMenu(String name)
Returns a new menu which provides options to send a message to
one of the registered listeners at a time.
|
Action |
createTargetAction(ComboBoxModel targetSelector)
Returns an action suitable for sending the message represented by
this manager to a target selected by a supplied ComboBoxModel.
|
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(JMenu menu)
Releases any resources associated with a menu previously created
using
createSendMenu(java.lang.String) . |
Action |
getBroadcastAction()
Returns an action which will broadcast a message
to all suitable registered applications.
|
static Icon |
getBroadcastIcon()
Returns an icon suitable for depicting a general broadcast send.
|
ListModel |
getClientListModel()
Returns the client list to which this manager will offer sends.
|
GuiHubConnector |
getConnector()
Returns this manager's hub connector.
|
protected abstract Action |
getSendAction(Client client)
Returns an action which can perform a single-client send associated
with this object.
|
static Icon |
getSendIcon()
Returns an icon suitable for depicting a general targetted send.
|
void |
setEnabled(boolean enabled)
Sets the enabled status of this object.
|
void |
updateState()
Updates the state of actions managed by this object when the
list of registered listeners has changed.
|
public static final String BROADCAST_TARGET
protected SendActionManager(GuiHubConnector connector, ListModel clientListModel)
connector
- hub connectorclientListModel
- list model containing only those
clients which are suitable recipients;
all elements must be Client
sprotected abstract Action createBroadcastAction()
protected abstract 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 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 JMenu createSendMenu(String name)
name
- menu titlepublic void disposeSendMenu(JMenu menu)
createSendMenu(java.lang.String)
. Don't use the menu again.menu
- previously created send menupublic void dispose()
public void updateState()
public ListModel getClientListModel()
Client
spublic ComboBoxModel createTargetSelector()
Client
objects, or
BROADCAST_TARGET
to indicate broadcast.
The result of this is suitable for use with createTargetAction(javax.swing.ComboBoxModel)
.public Action createTargetAction(ComboBoxModel targetSelector)
createTargetSelector()
.targetSelector
- combo box model in which the elements are
Client
objects,
or BROADCAST_TARGET
null to indicate broadcastpublic GuiHubConnector getConnector()
public static Icon getSendIcon()
public static Icon getBroadcastIcon()
Copyright © 2008–2024. All rights reserved.