1 11 12 package org.eclipse.debug.internal.ui.commands.actions; 13 14 import org.eclipse.jface.action.IAction; 15 import org.eclipse.jface.viewers.ISelection; 16 import org.eclipse.swt.widgets.Event; 17 import org.eclipse.ui.IActionDelegate2; 18 import org.eclipse.ui.IWorkbenchWindow; 19 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 20 21 26 public abstract class DebugCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 { 27 28 31 private DebugCommandAction fDebugAction; 32 33 36 private IAction fWindowAction; 37 38 42 private boolean fInitialized = false; 43 44 public DebugCommandActionDelegate() { 45 } 46 47 51 public void dispose() { 52 fDebugAction.dispose(); 53 54 } 55 56 60 public void init(IAction action) { 61 fWindowAction = action; 62 } 63 64 68 public void init(IWorkbenchWindow window) { 69 fDebugAction.init(window); 70 } 71 72 76 public void run(IAction action) { 77 synchronized (this) { 78 if (!fInitialized) { 79 try { 80 wait(); 81 } catch (InterruptedException e) { 82 } 83 } 84 } 85 fDebugAction.run(); 86 } 87 88 89 93 public void runWithEvent(IAction action, Event event) { 94 run(action); 95 } 96 97 101 public void selectionChanged(IAction action, ISelection s) { 102 } 104 105 protected DebugCommandAction getAction() { 106 return fDebugAction; 107 } 108 109 protected void setAction(DebugCommandAction action) { 110 fDebugAction = action; 111 action.setDelegate(this); 112 } 113 114 public void setEnabled(boolean enabled) { 115 synchronized (this) { 116 if (!fInitialized) { 117 fInitialized = true; 118 notifyAll(); 119 } 120 } 121 fWindowAction.setEnabled(enabled); 122 } 123 124 public void setChecked(boolean checked) { 125 fWindowAction.setChecked(checked); 126 } 127 128 protected IAction getWindowAction() 129 { 130 return fWindowAction; 131 } 132 133 134 } 135 | Popular Tags |