Core Interfaces
ActionsRegistry
The main registry for managing actions throughout the IDE. Source:core/actions/src/main/java/com/tom/rv2ide/actions/ActionsRegistry.kt:24
ActionItem
Interface for defining custom actions. Source:core/actions/src/main/java/com/tom/rv2ide/actions/ActionItem.kt:35
ActionData
Container for passing data to actions. Source:core/actions/src/main/java/com/tom/rv2ide/actions/ActionData.java:30
Creating Actions
Basic Action Implementation
Create a simple action:Editor Action
Create an action specific to the editor:Sidebar Action
Create a sidebar navigation action:Registering Actions
Register with Registry
Add your action to the IDE:Unregister Actions
Remove actions when no longer needed:Clear Location Actions
Remove all actions from a specific location:Action Locations
Available Locations
Actions can be placed in various locations:Location-Specific Actions
Create actions for specific locations:Action Data
Accessing Context Data
Retrieve data passed to actions:Storing Custom Data
Add your own data to ActionData:Action Preparation
Dynamic State Updates
Update action state before display:Conditional Visibility
Action Execution
Background Execution
Actions run in background by default:UI Thread Execution
Force execution on UI thread:Post-Execution Callback
Handle results on UI thread:Action Listeners
Monitor Action Execution
Listen for action execution events:Menu Operations
Fill Menu with Actions
Populate a menu with registered actions:Custom Action Views
Provide custom views for actions:Complete Example
Here’s a complete action implementation:Best Practices
Action Performance
Action Performance
- Keep
prepare()fast - it’s called frequently - Use
requiresUIThread = falsefor long operations - Return meaningful results from
execAction() - Clean up resources in
destroy()
Action State
Action State
- Update
visibleandenabledinprepare() - Don’t store mutable state in action instances
- Use ActionData to pass context
User Experience
User Experience
- Provide clear, concise labels
- Use subtitles for additional context
- Show feedback in
postExec() - Handle errors gracefully
Related APIs
Editor API
Work with editor instances in actions
Project API
Access project information in actions