diff options
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java')
-rw-r--r-- | org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java | 470 |
1 files changed, 235 insertions, 235 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java index 641f6beda..c3ce545d2 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java @@ -59,275 +59,275 @@ import org.eclipse.ui.PlatformUI; */ public abstract class DebugCommandAction extends Action implements IDebugContextListener { - private boolean fInitialized = false; + private boolean fInitialized = false; /** * The window this action is working for. */ - private IWorkbenchWindow fWindow; - - /** - * The part this action is working for, or <code>null</code> if global to - * a window. - */ - private IWorkbenchPart fPart; - - /** - * Command service. - */ - private DebugCommandService fUpdateService; - - /** - * Delegate this action is working for or <code>null</code> if none. - */ - private IAction fAction; - - private IEnabledTarget fEnabledTarget = new IEnabledTarget() { - @Override + private IWorkbenchWindow fWindow; + + /** + * The part this action is working for, or <code>null</code> if global to + * a window. + */ + private IWorkbenchPart fPart; + + /** + * Command service. + */ + private DebugCommandService fUpdateService; + + /** + * Delegate this action is working for or <code>null</code> if none. + */ + private IAction fAction; + + private IEnabledTarget fEnabledTarget = new IEnabledTarget() { + @Override public void setEnabled(boolean enabled) { - DebugCommandAction.this.setEnabled(enabled); - } - }; - - /** - * Constructor - */ - public DebugCommandAction() { - super(); - String helpContextId = getHelpContextId(); - if (helpContextId != null) { + DebugCommandAction.this.setEnabled(enabled); + } + }; + + /** + * Constructor + */ + public DebugCommandAction() { + super(); + String helpContextId = getHelpContextId(); + if (helpContextId != null) { PlatformUI.getWorkbench().getHelpSystem().setHelp(this, helpContextId); } - setEnabled(false); - } + setEnabled(false); + } /** - * Sets the current workbench action that is a proxy to an {@link org.eclipse.ui.IActionDelegate} - * that is using this action to perform its actual work. This only needs to be called when - * an {@link org.eclipse.ui.IActionDelegate} is using one of these actions to perform its - * function. - * - * @param action workbench proxy action - */ - public void setActionProxy(IAction action) { - fAction = action; - fAction.setEnabled(isEnabled()); - } - - /** - * Executes this action on the given target object - * @param targets the targets to perform the action on - * @return if the command stays enabled while the command executes - */ - private boolean execute(final Object[] targets) { - return fUpdateService.executeCommand( - getCommandType(), targets, - new ICommandParticipant() { - @Override + * Sets the current workbench action that is a proxy to an {@link org.eclipse.ui.IActionDelegate} + * that is using this action to perform its actual work. This only needs to be called when + * an {@link org.eclipse.ui.IActionDelegate} is using one of these actions to perform its + * function. + * + * @param action workbench proxy action + */ + public void setActionProxy(IAction action) { + fAction = action; + fAction.setEnabled(isEnabled()); + } + + /** + * Executes this action on the given target object + * @param targets the targets to perform the action on + * @return if the command stays enabled while the command executes + */ + private boolean execute(final Object[] targets) { + return fUpdateService.executeCommand( + getCommandType(), targets, + new ICommandParticipant() { + @Override public void requestDone(org.eclipse.debug.core.IRequest request) { - DebugCommandAction.this.postExecute(request, targets); - } - }); - } - - /** - * This method is called after the completion of the execution of this - * command. Extending classes may override this method to perform additional - * operation after command execution. - * - * @param request The completed request object which was given to the - * debug command handler. - * @param targets Objects which were the targets of this action - */ - protected void postExecute(IRequest request, Object[] targets) { - // do nothing by default - } - - /** - * Returns the {@link org.eclipse.debug.core.commands.IDebugCommandHandler} - * command handler that type this action executes. - * - * @return command class. - * - * @see org.eclipse.debug.core.commands.IDebugCommandHandler - */ + DebugCommandAction.this.postExecute(request, targets); + } + }); + } + + /** + * This method is called after the completion of the execution of this + * command. Extending classes may override this method to perform additional + * operation after command execution. + * + * @param request The completed request object which was given to the + * debug command handler. + * @param targets Objects which were the targets of this action + */ + protected void postExecute(IRequest request, Object[] targets) { + // do nothing by default + } + + /** + * Returns the {@link org.eclipse.debug.core.commands.IDebugCommandHandler} + * command handler that type this action executes. + * + * @return command class. + * + * @see org.eclipse.debug.core.commands.IDebugCommandHandler + */ abstract protected Class<?> getCommandType(); - /** - * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent) - */ - @Override + /** + * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent) + */ + @Override public void debugContextChanged(DebugContextEvent event) { - fUpdateService.postUpdateCommand(getCommandType(), fEnabledTarget); + fUpdateService.postUpdateCommand(getCommandType(), fEnabledTarget); } - /** - * @see org.eclipse.jface.action.Action#setEnabled(boolean) - */ - @Override + /** + * @see org.eclipse.jface.action.Action#setEnabled(boolean) + */ + @Override public void setEnabled(boolean enabled) { - synchronized (this) { - if (!fInitialized) { - fInitialized = true; - notifyAll(); - } - } - super.setEnabled(enabled); - if (fAction != null) { - fAction.setEnabled(enabled); - } - } - - /** - * Initializes this action for a specific part. - * - * @param part workbench part - */ - public void init(IWorkbenchPart part) { - fInitialized = false; - fPart = part; - fWindow = part.getSite().getWorkbenchWindow(); - fUpdateService = DebugCommandService.getService(fWindow); - IDebugContextService service = getDebugContextService(); + synchronized (this) { + if (!fInitialized) { + fInitialized = true; + notifyAll(); + } + } + super.setEnabled(enabled); + if (fAction != null) { + fAction.setEnabled(enabled); + } + } + + /** + * Initializes this action for a specific part. + * + * @param part workbench part + */ + public void init(IWorkbenchPart part) { + fInitialized = false; + fPart = part; + fWindow = part.getSite().getWorkbenchWindow(); + fUpdateService = DebugCommandService.getService(fWindow); + IDebugContextService service = getDebugContextService(); String partId = part.getSite().getId(); service.addDebugContextListener(this, partId); - ISelection activeContext = service.getActiveContext(partId); - if (activeContext != null) { - fUpdateService.updateCommand(getCommandType(), fEnabledTarget); - } else { - setEnabled(getInitialEnablement()); - } - } - - /** - * Initializes this action for a workbench window. - * - * @param window the window - */ - public void init(IWorkbenchWindow window) { - fInitialized = false; - fWindow = window; - fUpdateService = DebugCommandService.getService(fWindow); - IDebugContextService contextService = getDebugContextService(); + ISelection activeContext = service.getActiveContext(partId); + if (activeContext != null) { + fUpdateService.updateCommand(getCommandType(), fEnabledTarget); + } else { + setEnabled(getInitialEnablement()); + } + } + + /** + * Initializes this action for a workbench window. + * + * @param window the window + */ + public void init(IWorkbenchWindow window) { + fInitialized = false; + fWindow = window; + fUpdateService = DebugCommandService.getService(fWindow); + IDebugContextService contextService = getDebugContextService(); contextService.addDebugContextListener(this); - ISelection activeContext = contextService.getActiveContext(); - if (activeContext != null) { - fUpdateService.updateCommand(getCommandType(), fEnabledTarget); - } else { - setEnabled(getInitialEnablement()); - } - } - - /** - * Returns whether this action should be enabled when initialized - * and there is no active debug context. By default, <code>false</code> - * is returned. - * - * @return initial enabled state when there is no active context. - */ - protected boolean getInitialEnablement() { - return false; - } - - /** - * Returns the context (selection) this action operates on. By default - * the active debug context in this action's associated part or window is used, - * but subclasses may override as required. - * - * @return the context this action operates on - * @since 3.7 - */ - protected ISelection getContext() { + ISelection activeContext = contextService.getActiveContext(); + if (activeContext != null) { + fUpdateService.updateCommand(getCommandType(), fEnabledTarget); + } else { + setEnabled(getInitialEnablement()); + } + } + + /** + * Returns whether this action should be enabled when initialized + * and there is no active debug context. By default, <code>false</code> + * is returned. + * + * @return initial enabled state when there is no active context. + */ + protected boolean getInitialEnablement() { + return false; + } + + /** + * Returns the context (selection) this action operates on. By default + * the active debug context in this action's associated part or window is used, + * but subclasses may override as required. + * + * @return the context this action operates on + * @since 3.7 + */ + protected ISelection getContext() { if (fPart != null) { getDebugContextService().getActiveContext(fPart.getSite().getId()); - } - return getDebugContextService().getActiveContext(); - } + } + return getDebugContextService().getActiveContext(); + } - @Override + @Override public void run() { - synchronized (this) { - if (!fInitialized) { - try { - wait(); - } catch (InterruptedException e) { - } - } - } - - ISelection selection = getContext(); - if (selection instanceof IStructuredSelection && isEnabled()) { - IStructuredSelection ss = (IStructuredSelection) selection; - boolean enabled = execute(ss.toArray()); - // disable the action according to the command - setEnabled(enabled); - } - } - - @Override + synchronized (this) { + if (!fInitialized) { + try { + wait(); + } catch (InterruptedException e) { + } + } + } + + ISelection selection = getContext(); + if (selection instanceof IStructuredSelection && isEnabled()) { + IStructuredSelection ss = (IStructuredSelection) selection; + boolean enabled = execute(ss.toArray()); + // disable the action according to the command + setEnabled(enabled); + } + } + + @Override public void runWithEvent(Event event) { - run(); - } - - /** - * Clean up when removing - */ - public void dispose() { - IDebugContextService service = getDebugContextService(); - if (fPart != null) { - service.removeDebugContextListener(this, fPart.getSite().getId()); - } else { - service.removeDebugContextListener(this); - } - fWindow = null; - fPart = null; - } - - /** - * Returns the context service this action linked to. By default, this actions is - * associated with the context service for the window this action is operating in. - * - * @return associated context service - */ - protected IDebugContextService getDebugContextService() { - return DebugUITools.getDebugContextManager().getContextService(fWindow); - } - - /** - * Returns the help context id for this action or <code>null</code> if none. - * - * @return The help context id for this action or <code>null</code> - */ - public abstract String getHelpContextId(); - - @Override + run(); + } + + /** + * Clean up when removing + */ + public void dispose() { + IDebugContextService service = getDebugContextService(); + if (fPart != null) { + service.removeDebugContextListener(this, fPart.getSite().getId()); + } else { + service.removeDebugContextListener(this); + } + fWindow = null; + fPart = null; + } + + /** + * Returns the context service this action linked to. By default, this actions is + * associated with the context service for the window this action is operating in. + * + * @return associated context service + */ + protected IDebugContextService getDebugContextService() { + return DebugUITools.getDebugContextManager().getContextService(fWindow); + } + + /** + * Returns the help context id for this action or <code>null</code> if none. + * + * @return The help context id for this action or <code>null</code> + */ + public abstract String getHelpContextId(); + + @Override public abstract String getId(); - @Override + @Override public abstract String getText(); - @Override + @Override public abstract String getToolTipText(); - @Override + @Override public abstract ImageDescriptor getDisabledImageDescriptor(); - @Override + @Override public abstract ImageDescriptor getHoverImageDescriptor(); - @Override + @Override public abstract ImageDescriptor getImageDescriptor(); - /** - * Returns the workbench proxy associated with this action or <code>null</code> - * if none. This is the workbench proxy to an {@link org.eclipse.ui.IActionDelegate} - * that is using this action to perform its actual work. This is only used when - * an {@link org.eclipse.ui.IActionDelegate} is using one of these actions to perform its - * function. - * - * @return workbench proxy action or <code>null</code> - */ - protected IAction getActionProxy() { - return fAction; - } + /** + * Returns the workbench proxy associated with this action or <code>null</code> + * if none. This is the workbench proxy to an {@link org.eclipse.ui.IActionDelegate} + * that is using this action to perform its actual work. This is only used when + * an {@link org.eclipse.ui.IActionDelegate} is using one of these actions to perform its + * function. + * + * @return workbench proxy action or <code>null</code> + */ + protected IAction getActionProxy() { + return fAction; + } } |