home *** CD-ROM | disk | FTP | other *** search
- package netscape.application;
-
- import netscape.util.Vector;
-
- public class TargetChain implements ExtendedTarget {
- private Vector preTargets = new Vector();
- private Vector postTargets = new Vector();
- private static TargetChain applicationChain;
-
- private TargetChain() {
- }
-
- public static TargetChain applicationChain() {
- if (applicationChain == null) {
- applicationChain = new TargetChain();
- }
-
- return applicationChain;
- }
-
- public synchronized void addTarget(ExtendedTarget var1, boolean var2) {
- if (var2) {
- this.preTargets.insertElementAt(var1, 0);
- } else {
- this.postTargets.addElement(var1);
- }
- }
-
- public synchronized void removeTarget(ExtendedTarget var1) {
- this.preTargets.removeElement(var1);
- this.postTargets.removeElement(var1);
- }
-
- public synchronized Target targetForCommand(String var1) {
- int var3 = this.preTargets.size();
-
- for(int var2 = 0; var2 < var3; ++var2) {
- ExtendedTarget var13 = (ExtendedTarget)this.preTargets.elementAt(var2);
- if (var13.canPerformCommand(var1)) {
- return var13;
- }
- }
-
- Application var4 = Application.application();
- View var12 = var4.modalView();
- if (var12 == null) {
- RootView var6 = var4.firstRootView();
- if (var6 != null) {
- View var5 = var6.focusedView();
- if (this.objectCanPerformCommand(var5, var1)) {
- return (Target)var5;
- }
- }
-
- Window var8 = var4.currentDocumentWindow();
- if (var8 != null) {
- View var16;
- if (var8 instanceof InternalWindow) {
- var16 = ((InternalWindow)var8).focusedView();
- } else {
- var16 = ((ExternalWindow)var8).rootView().focusedView();
- }
-
- if (this.objectCanPerformCommand(var16, var1)) {
- return (Target)var16;
- }
-
- WindowOwner var10 = var8.owner();
- if (this.objectCanPerformCommand(var10, var1)) {
- return (Target)var10;
- }
-
- if (this.objectCanPerformCommand(var8, var1)) {
- return var8;
- }
- } else {
- RootView var7;
- if ((var7 = var4.mainRootView()) != null) {
- View var17;
- if (var7.mainWindow() == null) {
- var17 = var7.focusedView();
- } else {
- var17 = var7.rootViewFocusedView();
- }
-
- if (this.objectCanPerformCommand(var17, var1)) {
- return (Target)var17;
- }
- }
- }
-
- if (var6 != null) {
- ExternalWindow var9 = var6.externalWindow();
- if (var9 != null) {
- WindowOwner var11 = var9.owner();
- if (this.objectCanPerformCommand(var11, var1)) {
- return (Target)var11;
- }
-
- if (this.objectCanPerformCommand(var9, var1)) {
- return var9;
- }
- }
-
- if (this.objectCanPerformCommand(var6, var1)) {
- return var6;
- }
- }
-
- if (this.objectCanPerformCommand(var4, var1)) {
- return (Target)var4;
- }
- } else {
- View var18;
- RootView var19;
- Object var20;
- if (var12 instanceof RootView) {
- var19 = (RootView)var12;
- var18 = var19.focusedView();
- var20 = var19.externalWindow();
- } else if (var12 instanceof InternalWindow) {
- var19 = null;
- var18 = ((InternalWindow)var12).focusedView();
- var20 = (Window)var12;
- } else {
- var19 = null;
- var18 = var12;
- var20 = null;
- }
-
- if (this.objectCanPerformCommand(var18, var1)) {
- return (Target)var18;
- }
-
- if (var20 != null) {
- WindowOwner var21 = ((Window)var20).owner();
- if (this.objectCanPerformCommand(var21, var1)) {
- return (Target)var21;
- }
-
- if (this.objectCanPerformCommand(var20, var1)) {
- return (Target)var20;
- }
- }
-
- if (var19 != null && this.objectCanPerformCommand(var19, var1)) {
- return var19;
- }
- }
-
- var3 = this.postTargets.size();
-
- for(int var14 = 0; var14 < var3; ++var14) {
- ExtendedTarget var22 = (ExtendedTarget)this.postTargets.elementAt(var14);
- if (var22.canPerformCommand(var1)) {
- return var22;
- }
- }
-
- return null;
- }
-
- public boolean canPerformCommand(String var1) {
- return this.targetForCommand(var1) != null;
- }
-
- public void performCommand(String var1, Object var2) {
- Target var3 = this.targetForCommand(var1);
- if (var3 != null) {
- var3.performCommand(var1, var2);
- }
-
- }
-
- private boolean objectCanPerformCommand(Object var1, String var2) {
- return var1 != null && var1 instanceof ExtendedTarget && ((ExtendedTarget)var1).canPerformCommand(var2);
- }
- }
-