Package org.eclipse.ui.handlers
Class HandlerUtil
java.lang.Object
org.eclipse.ui.handlers.HandlerUtil
Some common utilities for working with handlers in Platform UI.
 
Note: this class should not be instantiated or extended by clients.
- Since:
- 3.3
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic CollectiongetActiveContexts(ExecutionEvent event) Return the active contexts.static CollectionReturn the active contexts.static IEditorPartgetActiveEditor(ExecutionEvent event) Return the active editor.static IEditorPartReturn the active editor.static StringgetActiveEditorId(ExecutionEvent event) Return the part id of the active editor.static StringReturn the part id of the active editor.static IEditorInputReturn the input of the active editor.static IEditorInputReturn the input of the active editor.static ISelectionReturn the active menu editor input, if available.static ISelectionReturn the active menu editor input.static CollectiongetActiveMenus(ExecutionEvent event) Return the menu IDs that were applied to the registered context menu.static CollectionReturn the menu IDs that were applied to the registered context menu.static ISelectionReturn the active menu selection.static ISelectionReturn the active menu selection.static IWorkbenchPartgetActivePart(ExecutionEvent event) Return the active part.static IWorkbenchPartReturn the active part.static StringgetActivePartId(ExecutionEvent event) Return the part id of the active part.static StringReturn the part id of the active part.static ShellgetActiveShell(ExecutionEvent event) Return the active shell.static ShellReturn the active shell.static IWorkbenchSitegetActiveSite(ExecutionEvent event) Return the active part site.static IWorkbenchSiteReturn the active part site.static IWorkbenchWindowReturn the active workbench window.static IWorkbenchWindowReturn the active workbench window.static ISelectionReturn the current selection.static ISelectionReturn the current selection.static IStructuredSelectionReturn the current structured selection, orStructuredSelection.EMPTYif the current selection is not a structured selection ornull.static ObjectgetShowInInput(ExecutionEvent event) Return the ShowInContext input.static ObjectReturn the ShowInContext input.static ISelectiongetShowInSelection(ExecutionEvent event) Return the ShowInContext selection.static ISelectionReturn the ShowInContext selection.static ObjectgetVariable(Object context, String name) Extract the variable.static ObjectgetVariable(ExecutionEvent event, String name) Extract the variable.static ObjectgetVariableChecked(ExecutionEvent event, String name) Extract the variable.static booleanmatchesRadioState(ExecutionEvent event) Checks whether the radio state of the command is same as the radio state parameter's valuestatic booleantoggleCommandState(Command command) Toggles the command's state.static voidupdateRadioState(Command command, String newState) Updates the radio state of the command to the given value
- 
Constructor Details- 
HandlerUtilpublic HandlerUtil()
 
- 
- 
Method Details- 
getVariableExtract the variable.- Parameters:
- event- The execution event that contains the application context
- name- The variable name to extract.
- Returns:
- The object from the application context, or nullif it could not be found.
 
- 
getVariableCheckedpublic static Object getVariableChecked(ExecutionEvent event, String name) throws ExecutionException Extract the variable.- Parameters:
- event- The execution event that contains the application context
- name- The variable name to extract.
- Returns:
- The object from the application context. Will not return
         null.
- Throws:
- ExecutionException- if the variable is not found.
 
- 
getVariableExtract the variable.- Parameters:
- context- The IEvaluationContext or- null
- name- The variable name to extract.
- Returns:
- The object from the application context, or nullif it could not be found.
- Since:
- 3.4
 
- 
getActiveContextsReturn the active contexts.- Parameters:
- event- The execution event that contains the application context
- Returns:
- a collection of String contextIds, or null.
 
- 
getActiveContextsCheckedReturn the active contexts.- Parameters:
- event- The execution event that contains the application context
- Returns:
- a collection of String contextIds. Will not return null.
- Throws:
- ExecutionException- If the context variable is not found.
 
- 
getActiveShellReturn the active shell. Is not necessarily the active workbench window shell.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active shell, or null.
 
- 
getActiveShellCheckedReturn the active shell. Is not necessarily the active workbench window shell.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active shell. Will not return null.
- Throws:
- ExecutionException- If the active shell variable is not found.
 
- 
getActiveWorkbenchWindowReturn the active workbench window.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active workbench window, or null.
 
- 
getActiveWorkbenchWindowCheckedpublic static IWorkbenchWindow getActiveWorkbenchWindowChecked(ExecutionEvent event) throws ExecutionException Return the active workbench window.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active workbench window. Will not return null.
- Throws:
- ExecutionException- If the active workbench window variable is not found.
 
- 
getActiveEditorReturn the active editor.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active editor, or null.
 
- 
getActiveEditorCheckedReturn the active editor.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active editor. Will not return null.
- Throws:
- ExecutionException- If the active editor variable is not found.
 
- 
getActiveEditorIdReturn the part id of the active editor.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the part id of the active editor, or null.
 
- 
getActiveEditorIdCheckedReturn the part id of the active editor.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the part id of the active editor. Will not return null.
- Throws:
- ExecutionException- If the active editor id variable is not found.
 
- 
getActiveEditorInputReturn the input of the active editor.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the input of the active editor, or null.
- Since:
- 3.7
 
- 
getActiveEditorInputCheckedpublic static IEditorInput getActiveEditorInputChecked(ExecutionEvent event) throws ExecutionException Return the input of the active editor.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the input of the active editor. Will not return null.
- Throws:
- ExecutionException- If the active editor input variable is not found.
- Since:
- 3.7
 
- 
getActivePartReturn the active part.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active part, or null.
 
- 
getActivePartCheckedReturn the active part.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active part. Will not return null.
- Throws:
- ExecutionException- If the active part variable is not found.
 
- 
getActivePartIdReturn the part id of the active part.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the part id of the active part, or null.
 
- 
getActivePartIdCheckedReturn the part id of the active part.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the part id of the active part. Will not return null.
- Throws:
- ExecutionException- If the active part id variable is not found.
 
- 
getActiveSiteReturn the active part site.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active part site, or null.
 
- 
getActiveSiteCheckedReturn the active part site.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active part site. Will not return null.
- Throws:
- ExecutionException- If the active part site variable is not found.
 
- 
getCurrentSelectionReturn the current selection.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the current selection, or null.
 
- 
getCurrentStructuredSelectionReturn the current structured selection, orStructuredSelection.EMPTYif the current selection is not a structured selection ornull.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the current IStructuredSelection, or
         StructuredSelection.EMPTY.
- Since:
- 3.108
 
- 
getCurrentSelectionCheckedReturn the current selection.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the current selection. Will not return null.
- Throws:
- ExecutionException- If the current selection variable is not found.
 
- 
getActiveMenusReturn the menu IDs that were applied to the registered context menu. For example, #CompilationUnitEditorContext.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the menu IDs, or null.
 
- 
getActiveMenusCheckedReturn the menu IDs that were applied to the registered context menu. For example, #CompilationUnitEditorContext.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the menu IDs. Will not return null.
- Throws:
- ExecutionException- If the active menus variable is not found.
 
- 
getActiveMenuSelectionReturn the active menu selection. The active menu is a registered context menu.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active menu selection, or null.
 
- 
getActiveMenuSelectionCheckedpublic static ISelection getActiveMenuSelectionChecked(ExecutionEvent event) throws ExecutionException Return the active menu selection. The active menu is a registered context menu.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active menu selection. Will not return null.
- Throws:
- ExecutionException- If the active menu selection variable is not found.
 
- 
getActiveMenuEditorInputReturn the active menu editor input, if available. The active menu is a registered context menu.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active menu editor, or null.
 
- 
getActiveMenuEditorInputCheckedpublic static ISelection getActiveMenuEditorInputChecked(ExecutionEvent event) throws ExecutionException Return the active menu editor input. The active menu is a registered context menu. Some context menus do not include the editor input which will throw an exception.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the active menu editor input. Will not return null.
- Throws:
- ExecutionException- If the active menu editor input variable is not found.
 
- 
getShowInSelectionReturn the ShowInContext selection.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the show in selection, or null.
- Since:
- 3.4
 
- 
getShowInSelectionCheckedReturn the ShowInContext selection. Will not returnnull.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the show in selection, or null.
- Throws:
- ExecutionException- If the show in selection variable is not found.
- Since:
- 3.4
 
- 
getShowInInputReturn the ShowInContext input.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the show in input, or null.
- Since:
- 3.4
 
- 
getShowInInputCheckedReturn the ShowInContext input. Will not returnnull.- Parameters:
- event- The execution event that contains the application context
- Returns:
- the show in input, or null.
- Throws:
- ExecutionException- If the show in input variable is not found.
- Since:
- 3.4
 
- 
toggleCommandStateToggles the command's state.- Parameters:
- command- The command whose state needs to be toggled
- Returns:
- the original value before toggling
- Throws:
- ExecutionException- When the command doesn't contain the toggle state or when the state doesn't contain a boolean value
- Since:
- 3.5
 
- 
matchesRadioStateChecks whether the radio state of the command is same as the radio state parameter's value- Parameters:
- event- The execution event that contains the application context
- Returns:
- truewhe the values are same,- falseotherwise
- Throws:
- ExecutionException- When the command doesn't have the radio state or the event doesn't have the radio state parameter
- Since:
- 3.5
 
- 
updateRadioStateUpdates the radio state of the command to the given value- Parameters:
- command- the command whose state should be updated
- newState- the new state
- Throws:
- ExecutionException- When the command doesn't have a radio state
- Since:
- 3.5
 
 
-