Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.ui.handlers
Class HandlerUtil


java.lang.Object
  extended by 
org.eclipse.ui.handlers.HandlerUtil

public class HandlerUtil
extends Object

Some common utilities for working with handlers in Platform UI.

Note: this class should not be instantiated or extended by clients.

Since:
3.3

Constructor Summary
HandlerUtil ()
           
 
Method Summary
static  Collection getActiveContexts ( ExecutionEvent event)
          Return the active contexts.
static  Collection getActiveContextsChecked ( ExecutionEvent event)
          Return the active contexts.
static  IEditorPart getActiveEditor ( ExecutionEvent event)
          Return the active editor.
static  IEditorPart getActiveEditorChecked ( ExecutionEvent event)
          Return the active editor.
static  String getActiveEditorId ( ExecutionEvent event)
          Return the part id of the active editor.
static  String getActiveEditorIdChecked ( ExecutionEvent event)
          Return the part id of the active editor.
static  ISelection getActiveMenuEditorInput ( ExecutionEvent event)
          Return the active menu editor input, if available.
static  ISelection getActiveMenuEditorInputChecked ( ExecutionEvent event)
          Return the active menu editor input.
static  Collection getActiveMenus ( ExecutionEvent event)
          Return the menu IDs that were applied to the registered context menu.
static  Collection getActiveMenusChecked ( ExecutionEvent event)
          Return the menu IDs that were applied to the registered context menu.
static  ISelection getActiveMenuSelection ( ExecutionEvent event)
          Return the active menu selection.
static  ISelection getActiveMenuSelectionChecked ( ExecutionEvent event)
          Return the active menu selection.
static  IWorkbenchPart getActivePart ( ExecutionEvent event)
          Return the active part.
static  IWorkbenchPart getActivePartChecked ( ExecutionEvent event)
          Return the active part.
static  String getActivePartId ( ExecutionEvent event)
          Return the part id of the active part.
static  String getActivePartIdChecked ( ExecutionEvent event)
          Return the part id of the active part.
static  Shell getActiveShell ( ExecutionEvent event)
          Return the active shell.
static  Shell getActiveShellChecked ( ExecutionEvent event)
          Return the active shell.
static  IWorkbenchSite getActiveSite ( ExecutionEvent event)
          Return the active part site.
static  IWorkbenchSite getActiveSiteChecked ( ExecutionEvent event)
          Return the active part site.
static  IWorkbenchWindow getActiveWorkbenchWindow ( ExecutionEvent event)
          Return the active workbench window.
static  IWorkbenchWindow getActiveWorkbenchWindowChecked ( ExecutionEvent event)
          Return the active workbench window.
static  ISelection getCurrentSelection ( ExecutionEvent event)
          Return the current selection.
static  ISelection getCurrentSelectionChecked ( ExecutionEvent event)
          Return the current selection.
static  Object getShowInInput ( ExecutionEvent event)
          Return the ShowInContext input.
static  Object getShowInInputChecked ( ExecutionEvent event)
          Return the ShowInContext input.
static  ISelection getShowInSelection ( ExecutionEvent event)
          Return the ShowInContext selection.
static  ISelection getShowInSelectionChecked ( ExecutionEvent event)
          Return the ShowInContext selection.
static  Object getVariable ( ExecutionEvent event, String name)
          Extract the variable.
static  Object getVariable ( Object context, String name)
          Extract the variable.
static  Object getVariableChecked ( ExecutionEvent event, String name)
          Extract the variable.
static boolean matchesRadioState ( ExecutionEvent event)
          Checks whether the radio state of the command is same as the radio state parameter's value
static boolean toggleCommandState ( Command command)
          Toggles the command's state.
static void updateRadioState ( Command command, String newState)
          Updates the radio state of the command to the given value
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HandlerUtil

public HandlerUtil()
Method Detail

getVariable

public static 
Object getVariable(
ExecutionEvent event,
                                 
String name)
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, or null if it could not be found.

getVariableChecked

public 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.

getVariable

public static 
Object getVariable(
Object context,
                                 
String name)
Extract the variable.

Parameters:
context - The IEvaluationContext or null
name - The variable name to extract.
Returns:
The object from the application context, or null if it could not be found.
Since:
3.4

getActiveContexts

public static 
Collection getActiveContexts(
ExecutionEvent event)
Return the active contexts.

Parameters:
event - The execution event that contains the application context
Returns:
a collection of String contextIds, or null.

getActiveContextsChecked

public static 
Collection getActiveContextsChecked(
ExecutionEvent event)
                                           throws 
ExecutionException
Return 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.

getActiveShell

public static 
Shell getActiveShell(
ExecutionEvent event)
Return 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.

getActiveShellChecked

public static 
Shell getActiveShellChecked(
ExecutionEvent event)
                                   throws 
ExecutionException
Return 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.

getActiveWorkbenchWindow

public static 
IWorkbenchWindow getActiveWorkbenchWindow(
ExecutionEvent event)
Return the active workbench window.

Parameters:
event - The execution event that contains the application context
Returns:
the active workbench window, or null.

getActiveWorkbenchWindowChecked

public 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.

getActiveEditor

public static 
IEditorPart getActiveEditor(
ExecutionEvent event)
Return the active editor.

Parameters:
event - The execution event that contains the application context
Returns:
the active editor, or null.

getActiveEditorChecked

public static 
IEditorPart getActiveEditorChecked(
ExecutionEvent event)
                                          throws 
ExecutionException
Return 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.

getActiveEditorId

public static 
String getActiveEditorId(
ExecutionEvent event)
Return 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.

getActiveEditorIdChecked

public static 
String getActiveEditorIdChecked(
ExecutionEvent event)
                                       throws 
ExecutionException
Return 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.

getActivePart

public static 
IWorkbenchPart getActivePart(
ExecutionEvent event)
Return the active part.

Parameters:
event - The execution event that contains the application context
Returns:
the active part, or null.

getActivePartChecked

public static 
IWorkbenchPart getActivePartChecked(
ExecutionEvent event)
                                           throws 
ExecutionException
Return 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.

getActivePartId

public static 
String getActivePartId(
ExecutionEvent event)
Return 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.

getActivePartIdChecked

public static 
String getActivePartIdChecked(
ExecutionEvent event)
                                     throws 
ExecutionException
Return 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.

getActiveSite

public static 
IWorkbenchSite getActiveSite(
ExecutionEvent event)
Return the active part site.

Parameters:
event - The execution event that contains the application context
Returns:
the active part site, or null.

getActiveSiteChecked

public static 
IWorkbenchSite getActiveSiteChecked(
ExecutionEvent event)
                                           throws 
ExecutionException
Return 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.

getCurrentSelection

public static 
ISelection getCurrentSelection(
ExecutionEvent event)
Return the current selection.

Parameters:
event - The execution event that contains the application context
Returns:
the current selection, or null.

getCurrentSelectionChecked

public static 
ISelection getCurrentSelectionChecked(
ExecutionEvent event)
                                             throws 
ExecutionException
Return 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.

getActiveMenus

public static 
Collection getActiveMenus(
ExecutionEvent event)
Return 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.

getActiveMenusChecked

public static 
Collection getActiveMenusChecked(
ExecutionEvent event)
                                        throws 
ExecutionException
Return 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.

getActiveMenuSelection

public static 
ISelection getActiveMenuSelection(
ExecutionEvent event)
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, or null.

getActiveMenuSelectionChecked

public 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.

getActiveMenuEditorInput

public static 
ISelection getActiveMenuEditorInput(
ExecutionEvent event)
Return 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.

getActiveMenuEditorInputChecked

public 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.

getShowInSelection

public static 
ISelection getShowInSelection(
ExecutionEvent event)
Return the ShowInContext selection.

Parameters:
event - The execution event that contains the application context
Returns:
the show in selection, or null.
Since:
3.4

getShowInSelectionChecked

public static 
ISelection getShowInSelectionChecked(
ExecutionEvent event)
                                            throws 
ExecutionException
Return the ShowInContext selection. Will not return null.

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

getShowInInput

public static 
Object getShowInInput(
ExecutionEvent event)
Return the ShowInContext input.

Parameters:
event - The execution event that contains the application context
Returns:
the show in input, or null.
Since:
3.4

getShowInInputChecked

public static 
Object getShowInInputChecked(
ExecutionEvent event)
                                    throws 
ExecutionException
Return the ShowInContext input. Will not return null.

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

toggleCommandState

public static boolean toggleCommandState(
Command command)
                                  throws 
ExecutionException
Toggles 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

matchesRadioState

public static boolean matchesRadioState(
ExecutionEvent event)
                                 throws 
ExecutionException
Checks 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:
true whe the values are same, false otherwise
Throws:
ExecutionException - When the command doesn't have the radio state or the event doesn't have the radio state parameter
Since:
3.5

updateRadioState

public static void updateRadioState(
Command command,
                                    
String newState)
                             throws 
ExecutionException
Updates 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

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire