diff options
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java')
-rw-r--r-- | org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java index 306e2cd16..34b01df50 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java @@ -24,6 +24,16 @@ import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; import org.eclipse.ui.progress.IWorkbenchSiteProgressService; +/** + * This class provides a base implementation of a selection action delegate, more specifically a delegate + * that uses a selection context to update its underlying <code>IAction</code>. + * + * This class is intended to be extended by clients + * + * @see {@link IViewActionDelegate} + * @see {@link IActionDelegate2} + * + */ public abstract class AbstractSelectionActionDelegate implements IViewActionDelegate, IActionDelegate2 { /** @@ -38,7 +48,7 @@ public abstract class AbstractSelectionActionDelegate implements IViewActionDele private IViewPart fViewPart; /** - * Cache of the most recent seletion + * Cache of the most recent selection */ private IStructuredSelection fSelection = StructuredSelection.EMPTY; @@ -52,8 +62,7 @@ public abstract class AbstractSelectionActionDelegate implements IViewActionDele * they can be reflected into existence when referenced in an action set in * the plugin's plugin.xml file. */ - public AbstractSelectionActionDelegate() { - } + public AbstractSelectionActionDelegate() {} /* * (non-Javadoc) @@ -64,6 +73,9 @@ public abstract class AbstractSelectionActionDelegate implements IViewActionDele fSelection = null; } + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ public void selectionChanged(IAction action, ISelection s) { if (s instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) s; @@ -79,6 +91,8 @@ public abstract class AbstractSelectionActionDelegate implements IViewActionDele * Returns the String to use as an error dialog message for a failed action. * This message appears as the "Message:" in the error dialog for this * action. Default is to return null. + * + * @return the message for the error dialog */ protected String getErrorDialogMessage() { return null; @@ -88,6 +102,8 @@ public abstract class AbstractSelectionActionDelegate implements IViewActionDele * Returns the String to use as a status message for a failed action. This * message appears as the "Reason:" in the error dialog for this action. * Default is to return the empty String. + * + * @return the status message */ protected String getStatusMessage() { return ""; //$NON-NLS-1$ @@ -107,7 +123,7 @@ public abstract class AbstractSelectionActionDelegate implements IViewActionDele * Returns this action's view part, or <code>null</code> if not installed * in a view. * - * @return view part or <code>null</code> + * @return the underlying <code>IViewPart</code> or <code>null</code> */ protected IViewPart getView() { return fViewPart; @@ -131,14 +147,26 @@ public abstract class AbstractSelectionActionDelegate implements IViewActionDele fSelection = context; } + /** + * Allows the underlying <code>IAction</code> to be set to the specified one + * @param action the action to set + */ protected void setAction(IAction action) { fAction = action; } + /** + * Allows access to the underlying <code>IAction</code> + * @return the underlying <code>IAction</code> + */ protected IAction getAction() { return fAction; } + /** + * Allows the underlying <code>IViewPart</code> to be set + * @param viewPart the <code>IViewPart</code> to set + */ protected void setView(IViewPart viewPart) { fViewPart = viewPart; } @@ -146,6 +174,9 @@ public abstract class AbstractSelectionActionDelegate implements IViewActionDele /** * Return whether the action should be enabled or not based on the given * selection. + * + * @return true if the action should be enabled for the specified selection context + * false otherwise */ protected boolean getEnableStateForSelection(IStructuredSelection selection) { if (selection.size() == 0) { @@ -161,6 +192,12 @@ public abstract class AbstractSelectionActionDelegate implements IViewActionDele return true; } + /** + * Returns if the action should be enabled for the specified object context + * @param element the object context + * @return true if the action should be enabled for the specified object context + * false otherwise + */ protected boolean isEnabledFor(Object element) { return true; } |