Creating and handling actions

Skip to end of metadata
Go to start of metadata

Action system

Action is a command executed by user in the specific context. Action can be available or not available in the context. Presentation of the action (text, icon, checked state, visibility) may depend on the context.

Action should have associated handler, which processes requests to update action for the context and execute an action. One handler can handle multiply actions, thought it is not common case.

Actions can be created either dynamically by using ActionManager shell component, or in a declarative way by providing XML file in plugin assembly resources.

References

JetBrains.ReSharper.ActionManagement.dll – provides interfaces and attributes for actions
JetBrains.ReSharper.IDECore.dll – provides constants and types specific to ReSharper environment
JetBrains.ReSharper.Util.dll – contains utility classes used throughout the project

Examples below using ISolution, which requires referencing one more assembly:
JetBrains.ReSharper.ProjectModel.dll – contains types and components exposing project model, i.e. solution, projects and files

Actions.xml - declarative way

  • Create embedded resource file actions.xml (or any other name you want)
  • Specify actions and their locations
  • Add assembly attribute to point to file containing actions. Value of the attribute will be used in call to Assembly.GetManifestResourceStream()
  • Create action handler by deriving class from IActionHandler and decorating with ActionHandler attribute. Parameter of ActionHandlerAttribute specifies id of the action it is going to handle.
  • Implement IActionHandler interface

ActionManager - dynamic way

To be described

Samples and power toys

Icon
The license could not be verified: There is no license certificate installed for CustomWare Linking Plugin for Confluence.

  • No labels