Class TargetChain
All Packages Class Hierarchy This Package Previous Next Index
Class TargetChain
public class netscape.application.TargetChain
extends java.lang.Object
implements netscape.application.ExtendedTarget
{
/* Methods
*/
public static TargetChain applicationChain();
public synchronized void addTarget(ExtendedTarget, boolean);
public boolean canPerformCommand(String);
public void performCommand(String, Object);
public synchronized void removeTarget(ExtendedTarget);
public synchronized Target targetForCommand(String);
}
Object subclass used to locate a Target within an application that is
capable of performing a specific command. When asked to perform a command,
the TargetChain asks each of its potential Targets, in turn, whether or
not they implement the ExtendedTarget interface, and if so, calls their
canPerformCommand() method to determine whether or not they can
perform the specified command. The TargetChain forwards the command on
to the first object that can perform the command. The TargetChain
returned by the static applicationChain() method contains the
following potential Targets:
- Each of the Targets added using addTarget() with
atFront == true
- The current focusedView
- The main Window's owner
- The main Window
- The "first" RootView
- The Application
- Each of the Targets added using addTarget() with atFront
== false
The TargetChain is useful in situations where the Target that should
receive a command is context sensitive. For example, a Menu item
representing the "cut" command should send its command to the current
selection. If an application has multiple TextFields, the TextField that
should receive the command will depend upon which TextField the user has
decided to edit. By setting the Menu item's Target to the application's
TargetChain, the application can configure the Menu item's Target once,
with the assurance that the TargetChain will locate and forward the command
to the appropriate object.
- See Also:
- Target
Methods
applicationChain
public static TargetChain applicationChain()
- Returns the Application global TargetChain.
addTarget
public synchronized void addTarget(ExtendedTarget target,
boolean atFront)
- Adds target to the TargetChain. If atFront is
true,the TargetChain will query target before any of the
ExtendedTargets currently in its list. Otherwise, the TargetChain will
query target only after all current ExtendedTargets.
removeTarget
public synchronized void removeTarget(ExtendedTarget target)
- Removes target from the TargetChain (only if target was
added using addTarget()).
- See Also:
- addTarget
targetForCommand
public synchronized Target targetForCommand(String command)
- Returns the first Target that performs command.
canPerformCommand
public boolean canPerformCommand(String command)
- Returns true if any of the TargetChain's Targets can perform
command.
performCommand
public void performCommand(String command,
Object data)
- Forwards the performCommand message to the first Target in the chain
that can perform command.
All Packages Class Hierarchy This Package Previous Next Index