///
/// Copyright © 2003-2008 JetBrains s.r.o.
/// You may distribute under the terms of the GNU General Public License, as published by the Free Software Foundation, version 2 (see License.txt in the repository root folder).
///
using System;
using System.Drawing;
using System.Reflection;
using System.Runtime.Serialization;
using System.Windows.Forms;
namespace JetBrains.Omea.OpenAPI
{
///
/// Specifies possible places from which an action could be invoked.
///
public enum ActionContextKind
{
///
/// The action is invoked from the main menu.
///
MainMenu,
///
/// The action is invoked from the context menu.
///
ContextMenu,
///
/// The action is invoked from the main toolbar, the URL bar or the toolbar in a resource
/// tree pane.
///
Toolbar,
///
/// The action is invoked from a keyboard shortcut.
///
Keyboard,
///
/// The action is invoked from a link in the Actions group of the links pane.
///
LinksPane,
///
/// The action is invoked from a different, unspecified location.
///
Other=255
}
///
/// Provides the information about the context where the action is invoked and
/// the resources to which it can be applied.
///
public interface IActionContext
{
///
/// Gets the type of control which invoked the action (context menu, toolbar etc.)
///
ActionContextKind Kind { get; }
///
/// Gets the specific instance of the control which invoked the action. The exact
/// value of this property depends on the control which invoked the action.
///
object Instance { get; }
///
/// Gets the list of resources to which the action should be applied.
///
/// The value of the property is never null, but can be an empty
/// resource list.
IResourceList SelectedResources { get; }
///
/// Gets the expanded list of resources to which the action should be applied.
/// If the selection contained collapsed threads, the list returned by
/// this property contains all resources in the collapsed threads, even if only
/// the top-level resource was actually selected. If the selection did not contain
/// collapsed threads, returns the same list as .
///
IResourceList SelectedResourcesExpanded { get; }
///
/// If the action was invoked from the resource browser - the resource owning
/// the currently displayed resource list.
///
/// The owner resource is set by the plugin which displayed the resource
/// list. Generally, it is the resource which is currently selected in the left sidebar
/// (for example, a newsgroup resource if the list of newsgroup articles is currently
/// displayed).
IResource ListOwnerResource { get; }
///
/// If the action was invoked by right-clicking a resource link label - the ID of the
/// link property displayed by the link label. Otherwise, -1.
///
int LinkPropId { get; }
///
/// If the action was invoked by right-clicking a resource link label - the resource on
/// the other end of the clicked link. Otherwise, null.
///
/// If the link label in the resource links pane is clicked,
/// holds the resource the link to which was clicked,
/// and LinkTargetResource
holds the resource currently displayed
/// in the resource browser.
IResource LinkTargetResource { get; }
///
/// If a Web page is currently displayed in Omea - the URL of that Web page.
/// Otherwise, null.
///
string CurrentUrl { get; }
///
/// If a Web page is currently displayed in Omea - the title of that Web page.
/// Otherwise, null.
///
/// 2.0
string CurrentPageTitle { get; }
///
/// The command processor which can execute the local (context-dependent) commands
/// for the current context.
///
/// A partial list of the commands which can be executed through the
/// CommandProcessor
is defined by the
/// class.
ICommandProcessor CommandProcessor { get; }
///
/// The form in which the action was invoked.
///
/// 1.0.3
Form OwnerForm { get; }
///
/// The text currently selected in the active display pane (in plain-text format), or
/// null if the action was not invoked from a display pane.
///
string SelectedPlainText { get; }
///
/// The format of the text currently selected in the active display pane. Defined only
/// if is not null.
///
TextFormat SelectedTextFormat { get; }
///
/// The text currently selected in the active display pane (in plain-text, HTML or
/// rich-text format, as specified by , or null if
/// the action was not invoked from a display pane.
///
string SelectedText { get; }
}
///
/// The default implementation of the interface.
///
public class ActionContext: IActionContext
{
private ActionContextKind _kind;
private object _instance;
private IResourceList _selectedResources;
private IResourceList _selectedResourcesExpanded;
private IResource _listOwnerResource;
private string _currentURL;
private string _currentPageTitle;
private ICommandProcessor _commandProcessor;
private string _selectedText;
private string _selectedPlainText;
private TextFormat _selectedTextFormat;
private int _linkPropId = -1;
private IResource _linkTargetResource;
private Form _ownerForm;
private class DummyCommandProcessor: ICommandProcessor
{
public bool CanExecuteCommand( string action )
{
return false;
}
public void ExecuteCommand( string action )
{
}
}
private static DummyCommandProcessor _dummyCommandProcessor = new DummyCommandProcessor();
///
/// Initializes the action context with an unspecified context kind and the specified
/// list of selected resources.
///
/// The list of selected resources in the action context,
/// or null if there are no selected resources.
public ActionContext( IResourceList selectedResources )
{
_kind = ActionContextKind.Other;
_selectedResources = selectedResources;
}
///
/// Initializes the action context with the specified kind, invoker instance and list of
/// selected resources.
///
/// The kind of the action context.
/// The instance of the control invoking the action, or null if
/// not required.
/// The list of selected resources in the action context,
/// or null if there are no selected resources.
public ActionContext( ActionContextKind kind, object instance, IResourceList selectedResources )
{
_kind = kind;
_instance = instance;
_selectedResources = selectedResources;
}
///
/// Creates a copy of the specified action context and replaces the selected resources
/// list with the specified list.
///
/// The context to copy.
/// The resource list to use as selected resources.
/// 1.0.3
public ActionContext( IActionContext other, IResourceList selectedResources )
{
_kind = other.Kind;
_instance = other.Instance;
_selectedResources = selectedResources;
_listOwnerResource = other.ListOwnerResource;
_currentURL = other.CurrentUrl;
_currentPageTitle = other.CurrentPageTitle;
_commandProcessor = other.CommandProcessor;
_selectedText = other.SelectedText;
_selectedPlainText = other.SelectedPlainText;
_selectedTextFormat = other.SelectedTextFormat;
_linkPropId = other.LinkPropId;
_linkTargetResource = other.LinkTargetResource;
_ownerForm = other.OwnerForm;
}
///
/// Gets the type of control which invoked the action (context menu, toolbar etc.)
///
public ActionContextKind Kind
{
get { return _kind; }
}
///
/// Gets the specific instance of the control which invoked the action. The exact
/// value of this property depends on the control which invoked the action.
///
public object Instance
{
get { return _instance; }
}
///
/// Gets the list of resources to which the action should be applied.
///
/// The value of the property is never null, but can be an empty
/// resource list.
public IResourceList SelectedResources
{
get
{
if ( _selectedResources == null ||
( _selectedResources.Count == 1 && _selectedResources.ResourceIds [0] == -1 ) )
{
return Core.ResourceStore.EmptyResourceList;
}
return _selectedResources;
}
}
///
/// Gets the expanded list of resources to which the action should be applied.
/// If the selection contained collapsed threads, the list returned by
/// this property contains all resources in the collapsed threads, even if only
/// the top-level resource was actually selected. If the selection did not contain
/// collapsed threads, returns the same list as .
///
public IResourceList SelectedResourcesExpanded
{
get
{
if ( _selectedResourcesExpanded != null )
{
return _selectedResourcesExpanded;
}
return SelectedResources;
}
}
///
/// Sets the list of selected resources in the action context to the specified value.
///
/// The list of selected resources, or null if there
/// are no selected resources.
public void SetSelectedResources( IResourceList selectedResources )
{
_selectedResources = selectedResources;
}
///
/// Sets the expanded list of selected resources in the action context to the specified
/// value.
///
/// The expanded list of selected resources, or null
/// if there are no selected resources.
public void SetSelectedResourcesExpanded( IResourceList selectedResourcesExpanded )
{
_selectedResourcesExpanded = selectedResourcesExpanded;
}
///
/// If the action was invoked from the resource browser - the resource owning
/// the currently displayed resource list.
///
/// The owner resource is set by the plugin which displayed the resource
/// list. Generally, it is the resource which is currently selected in the left sidebar
/// (for example, a newsgroup resource if the list of newsgroup articles is currently
/// displayed).
public IResource ListOwnerResource
{
get { return _listOwnerResource; }
}
///
/// Sets the resource owning the visible resource list.
///
/// The resource owning the visible resource list, or null if
/// there is none.
///
public void SetListOwner( IResource res )
{
_listOwnerResource = res;
}
///
/// If the action was invoked by right-clicking a resource link label - the ID of the
/// link property displayed by the link label. Otherwise, -1.
///
public int LinkPropId
{
get { return _linkPropId; }
}
///
/// If the action was invoked by right-clicking a resource link label - the resource on
/// the other end of the clicked link. Otherwise, null.
///
/// If the link label in the resource links pane is clicked,
/// holds the resource the link to which was clicked,
/// and LinkTargetResource
holds the resource currently displayed
/// in the resource browser.
public IResource LinkTargetResource
{
get { return _linkTargetResource; }
}
///
/// Sets the ID of the link property and the target resource for actions which are
/// invoked by right-clicking a resource link label.
///
/// The ID of the link property.
/// The target of the link.
public void SetLinkTarget( int linkPropId, IResource linkTargetResource )
{
_linkPropId = linkPropId;
_linkTargetResource = linkTargetResource;
}
///
/// If a Web page is currently displayed in Omea - the URL of that Web page.
/// Otherwise, null.
///
public string CurrentUrl
{
get { return _currentURL; }
}
///
/// If a Web page is currently displayed in Omea - the title of that Web page.
/// Otherwise, null.
///
/// 2.0
public string CurrentPageTitle
{
get { return _currentPageTitle; }
}
///
/// Sets the URL of the Web page currently displayed in Omea.
///
/// Web page URL, or null if not applicable.
public void SetCurrentUrl( string url )
{
_currentURL = url;
}
///
/// Sets the title of the Web page currently displayed in Omea.
///
/// Web page title, or null if not applicable.
/// 2.0
public void SetCurrentPageTitle( string title )
{
_currentPageTitle = title;
}
///
/// The command processor which can execute the local (context-dependent) commands
/// for the current context.
///
/// A partial list of the commands which can be executed through the
/// CommandProcessor
is defined by the
/// class.
public ICommandProcessor CommandProcessor
{
get
{
if ( _commandProcessor == null )
return _dummyCommandProcessor;
return _commandProcessor;
}
}
///
/// Sets the command processor which can execute the local (context-dependent) commands
/// for the current context.
///
/// The command processor implementation, or null if
/// no command processing is required.
public void SetCommandProcessor( ICommandProcessor commandProcessor )
{
_commandProcessor = commandProcessor;
}
///
/// The text currently selected in the active display pane (in plain-text, HTML or
/// rich-text format, as specified by , or null if
/// the action was not invoked from a display pane.
///
public string SelectedText
{
get { return _selectedText; }
}
///
/// The text currently selected in the active display pane (in plain-text format), or
/// null if the action was not invoked from a display pane.
///
public string SelectedPlainText
{
get { return _selectedPlainText; }
}
///
/// The format of the text currently selected in the active display pane. Defined only
/// if is not null.
///
public TextFormat SelectedTextFormat
{
get { return _selectedTextFormat; }
}
///
/// Sets the selected text and its format.
///
/// The selected text in a plain-text, RTF or HTML format.
/// The selected text in plain-text format.
/// The format of text in selectedText.
public void SetSelectedText( string selectedText, string selectedPlainText, TextFormat format )
{
_selectedText = selectedText;
_selectedPlainText = selectedPlainText;
_selectedTextFormat = format;
}
///
/// The form in which the action was invoked.
///
/// 1.0.3
public Form OwnerForm
{
get { return _ownerForm; }
}
///
/// Sets the form in which the action was invoked.
///
/// The form.
/// 1.0.3
public void SetOwnerForm( Form form )
{
_ownerForm = form;
}
}
///
/// The structure which holds the information about the state of the control
/// representing an action in the UI. Instances of this structure are passed
/// to the Update() method of actions and action state filters.
///
public struct ActionPresentation
{
private bool _visible;
private bool _enabled;
private bool _checked;
private bool _textChanged;
private string _text;
private string _toolTip;
///
/// Changes the presentation to a default (unmodified) state.
///
public void Reset()
{
ResetState();
_text = null;
_toolTip = null;
}
///
/// Resets only the state flags of the presentation to the default value,
/// while leaving Text and ToolTip unmodified.
///
public void ResetState()
{
_visible = true;
_enabled = true;
_checked = false;
_textChanged = false;
}
///
/// Gets or sets a value indicating whether the control representing the action
/// is displayed.
///
public bool Visible
{
get { return _visible; }
set { _visible = value; }
}
///
/// Gets or sets a value indicating whether the control representing the action
/// is enabled.
///
public bool Enabled
{
get { return _enabled; }
set { _enabled = value; }
}
///
/// Gets or sets a value indicating whether the control representing the action
/// has a check mark displayed next to it. (This is used only if the action is
/// represented by a menu item).
///
public bool Checked
{
get { return _checked; }
set { _checked = value; }
}
///
/// Gets or sets the text of the control representing the action in the UI.
///
public string Text
{
get { return _text; }
set { _text = value; }
}
public bool TextChanged
{
get { return _textChanged; }
set { _textChanged = value; }
}
///
/// Gets or sets the tooltip of the control representing the action in the UI.
/// (This is used only if the action is represented by a toolbar button.)
///
public string ToolTip
{
get { return _toolTip; }
set { _toolTip = value; }
}
}
///
/// A class which controls the enabled state of an action. When an action is registered,
/// multiple filters can be registered together with it.
///
public interface IActionStateFilter
{
///
/// For the specified context, updates the presentation state of an action.
///
///
/// Context, containing information about resources to which the action will be applied.
///
///
/// The state of the UI element which presents the action to the user. For the
/// first filter in the chain, the presentation is initialized with the default
/// values. For subsequent filters, it contains the data set by previous filters.
///
void Update( IActionContext context, ref ActionPresentation presentation );
}
///
/// An action is a function which can be invoked by the user through one of the user
/// interface controls - menu items, toolbar buttons, keyboard shortcuts and so on.
///
public interface IAction
{
/// Executes the action.
///
/// The context for executing the action. Describes the objects to which the action
/// is applied, like the list of selected resources.
///
void Execute( IActionContext context );
/// For the specified context, updates the presentation state of an action.
///
/// The context for executing the action. Describes the objects to which the action
/// is applied, like the list of selected resources.
///
///
/// The state of the UI element which presents the action to the user. If filters are
/// registered for the action, this presentation state is already updated by the filters.
/// If the action was hidden by the filters, the Update() method of the action is not
/// called.
///
void Update( IActionContext context, ref ActionPresentation presentation );
}
///
/// An action which is always enabled and visible.
///
public abstract class SimpleAction: IAction
{
public abstract void Execute( IActionContext context );
public virtual void Update( IActionContext context, ref ActionPresentation presentation )
{
}
}
///
/// An action which is visible only when there is at least one resource selected.
///
public abstract class ActionOnResource: IAction
{
public abstract void Execute( IActionContext context );
public virtual void Update( IActionContext context, ref ActionPresentation presentation )
{
if ( context.SelectedResources == null || context.SelectedResources.Count == 0 )
{
presentation.Visible = false;
}
}
}
///
/// An action which is visible when exactly one resource is selected.
///
public abstract class ActionOnSingleResource: IAction
{
public abstract void Execute( IActionContext context );
public virtual void Update( IActionContext context, ref ActionPresentation presentation )
{
presentation.Visible = (context.SelectedResources.Count == 1);
}
}
///
/// An action which is executed in the resource thread.
///
public abstract class ResourceAction: IAction
{
private IResourceList _selectedResources;
private bool _asynchronous;
///
/// Creates an instance of which is executed asynchronously.
///
protected ResourceAction()
{
_asynchronous = true;
}
///
/// Creates an instance of with the specified execution mode.
///
/// true if the action is executed asynchronously, false otherwise.
protected ResourceAction( bool asynchronous )
{
_asynchronous = asynchronous;
}
void IAction.Execute( IActionContext context )
{
_selectedResources = context.SelectedResources;
if ( _asynchronous )
{
ICore.Instance.ResourceAP.QueueJob( new MethodInvoker( ExecuteOperation ) );
}
else
{
ICore.Instance.ResourceAP.RunJob( new MethodInvoker( ExecuteOperation ) );
}
}
public virtual void Update( IActionContext context, ref ActionPresentation presentation )
{
}
public abstract void Execute( IResourceList selectedResources );
private void ExecuteOperation()
{
Execute( _selectedResources );
}
}
///
/// Specifies the mode of positioning an item relatively to another item in a list.
///
public enum AnchorType
{
///
/// The item is placed in the beginning of the list.
///
First,
///
/// The item is placed in the end of the list.
///
Last,
///
/// The item is placed before the specified item in the list.
///
Before,
///
/// The item is placed after the specified item in the list.
///
After
};
///
/// Specifies the position of an item relative to other items in a list.
///
public class ListAnchor
{
private string _refId;
private AnchorType _anchorType;
private static ListAnchor _anchorLast = new ListAnchor( AnchorType.Last );
private static ListAnchor _anchorFirst = new ListAnchor( AnchorType.First );
///
/// Initializes a new instance which specifies a position before or after another
/// item in the list.
///
/// Type of the position (before or after).
/// ID of the item relative to which the position is specified.
public ListAnchor( AnchorType anchorType, string refId )
{
_anchorType = anchorType;
_refId = refId;
}
///
/// Initializes a new instance which specifies a position in the beginning or end
/// of the list.
///
/// Type of the position (First or Last).
public ListAnchor( AnchorType anchorType )
{
if ( _anchorType == AnchorType.Before || _anchorType == AnchorType.After )
{
throw new ArgumentException( "refId must be specified for Before and After anchors" );
}
_anchorType = anchorType;
}
///
/// Gets or sets the ID of the item relative to which the position is specified.
/// If the position type is First or Last, the RefId is null.
///
public string RefId
{
get { return _refId; }
set { _refId = value; }
}
///
/// Gets or sets the type of the position.
///
public AnchorType AnchorType
{
get { return _anchorType; }
set { _anchorType = value; }
}
///
/// Returns the standard anchor "end of the list".
///
public static ListAnchor Last
{
get { return _anchorLast; }
}
///
/// Returns the standard anchor "beginning of the list".
///
public static ListAnchor First
{
get { return _anchorFirst; }
}
}
///
/// Allows to register actions - functions which can be invoked by the user through
/// different user interface controls (menu items, toolbar buttons, keyboard and so on).
///
public interface IActionManager
{
#region MainMenu
///
/// Registers a top-level menu item in the main menu.
///
/// Name of the menu item to register.
/// Position of the menu item relative to other menu items.
void RegisterMainMenu( string menuName, ListAnchor anchor );
///
/// Registers a group for main menu actions. Actions from different groups are divided
/// by separators.
///
///
/// The identifier of the group. It is used to specify the group when registering actions
/// and to reference this group when specifying relative position of action groups.
///
///
/// Name of the top-level menu under which the action group is placed. Must contain the
/// name of one of the existing menus (File, Edit, View, Go, Tools, Actions or Help),
/// or a menu registered with .
///
///
/// Anchor for specifying the position of this group relative to other groups.
///
void RegisterMainMenuActionGroup( string groupId, string menuName, ListAnchor anchor );
///
/// Registers a group for actions in a submenu of a main menu.
///
///
/// The identifier of the group. It is used to specify the group when registering actions
/// and to reference this group when specifying relative position of action groups.
///
///
/// Name of the top-level menu under which the action group is placed. Must contain the
/// name of one of the existing menus (File, Edit, View, Go, Tools Actions or Help).
///
///
/// Name of the submenu under the top-level menu in which the action group is placed.
/// If two adjacent action groups have the same submenu name, they are displayed in the
/// same submenu and delimited with a separator.
///
///
/// Anchor for specifying the position of this group relative to other groups.
///
void RegisterMainMenuActionGroup( string groupId, string menuName, string submenuName, ListAnchor anchor );
///
/// Registers an action which is executed when a main menu item is clicked.
///
/// The action which is registered.
///
/// Identifier of the main menu action group where the action is placed. Must not be null.
/// (The menu in which the action is placed is determined by the action group.)
///
/// The relative position of the action within the group.
/// Caption of the menu item.
/// Menu item icon to be shown on the left strip.
///
/// The resource type to which the action applies, or null if the action applies to all
/// resource types. If a type is specified, the menu item is disabled if the selection
/// is empty or contains resources of other types.
///
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
/// If the filters have marked the presentation as hidden, the Update() method of the
/// action itself is not called.
///
void RegisterMainMenuAction( IAction action, string groupId, ListAnchor anchor, string text,
Image icon, string resourceType, IActionStateFilter[] filters );
///
/// Removes an action and its menu item from the main menu.
///
/// The action to remove.
void UnregisterMainMenuAction( IAction action );
///
/// Suppresses the separator between the two specified groups in the main menu.
///
/// The group on one side of the separator.
/// The group on the other side of the separator.
/// 2.0
void SuppressMainMenuGroupSeparator( string groupId1, string groupId2 );
#endregion MainMenu
#region ToolBar
///
/// Registers a group for toolbar actions. Actions from different groups are divided by
/// separators on the toolbar.
///
///
/// The identifier of the group. It is used to specify the group when registering actions
/// and to reference this group when specifying relative position of action groups.
///
///
/// Anchor for specifying the position of this group relative to other groups.
///
void RegisterToolbarActionGroup( string groupId, ListAnchor anchor );
///
/// Registers an action which is executed when a toolbar button is clicked. The button
/// icon is specified as an Icon instance.
///
/// The action which is registered.
///
/// Identifier of the toolbar action group where the action is placed.
/// If null, the default group is used (it is placed before all other groups).
///
/// The relative position of the action within the group.
/// The icon shown on the button.
/// The text shown on the button, or null if the button contains only an icon.
/// The tooltip shown for the button.
///
/// The resource type to which the action applies, or null if the action applies to all
/// resource types. If a type is specified, the toolbar button is disabled if the selection
/// is empty or contains resources of other types.
///
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
/// If the filters have marked the presentation as hidden, the Update() method of the
/// action itself is not called.
///
void RegisterToolbarAction( IAction action, string groupId, ListAnchor anchor,
Icon icon, string text, string tooltip, string resourceType, IActionStateFilter[] filters );
///
/// Registers an action which is executed when a toolbar button is clicked. The button
/// icon is specified as an Image instance.
///
/// The action which is registered.
///
/// Identifier of the toolbar action group where the action is placed.
/// If null, the default group is used (it is placed before all other groups).
///
/// The relative position of the action within the group.
/// The icon shown on the button.
/// The text shown on the button, or null if the button contains only an icon.
/// The tooltip shown for the button.
///
/// The resource type to which the action applies. The toolbar button is disabled if the selection
/// contains resources of other types.
///
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
///
void RegisterToolbarAction( IAction action, string groupId, ListAnchor anchor,
Image icon, string text, string tooltip, string resourceType, IActionStateFilter[] filters );
///
/// Registers an additional filter for a previously registered toolbar action.
///
/// The identifier of the action for which the filter is registered
/// (the string returned by the ToString() method of the action).
/// The filter to be registered.
void RegisterToolbarActionFilter( string actionId, IActionStateFilter filter );
///
/// Removes an action and its menu item from the toolbar.
///
/// The action to remove.
void UnregisterToolbarAction( IAction action );
#endregion ToolBar
#region UrlBar
///
/// Registers a group for URL bar actions. The URL bar is the toolbar displayed to the
/// left of the Web address box when a Web page is viewed. Actions from different groups
/// are divided by separators on the toolbar.
///
///
/// The identifier of the group. It is used to specify the group when registering actions
/// and to reference this group when specifying relative position of action groups.
///
///
/// Anchor for specifying the position of this group relative to other groups.
///
void RegisterUrlBarActionGroup( string groupId, ListAnchor anchor );
///
/// Registers an action which is executed when a button on the URL bar is clicked. The button
/// icon is specified as an Icon instance.
///
/// The action which is registered.
///
/// Identifier of the toolbar action group where the action is placed.
/// If null, the default group is used (it is placed before all other groups).
///
/// The relative position of the action within the group.
/// The icon shown on the button.
/// The text shown on the button, or null if the button contains only an icon.
/// The tooltip shown for the button.
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
///
void RegisterUrlBarAction( IAction action, string groupId, ListAnchor anchor,
Icon icon, string text, string tooltip, IActionStateFilter[] filters );
///
/// Registers an action which is executed when a button on the URL bar is clicked. The button
/// icon is specified as an Image instance.
///
/// The action which is registered.
///
/// Identifier of the toolbar action group where the action is placed.
/// If null, the default group is used (it is placed before all other groups).
///
/// The relative position of the action within the group.
/// The icon shown on the button.
/// The text shown on the button, or null if the button contains only an icon.
/// The tooltip shown for the button.
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
///
void RegisterUrlBarAction( IAction action, string groupId, ListAnchor anchor,
Image icon, string text, string tooltip, IActionStateFilter[] filters );
///
/// Removes an action and its menu item from the URL bar.
///
/// The action to remove.
void UnregisterUrlBarAction( IAction action );
#endregion UrlBar
#region ContextMenu
///
/// Registers a group for context menu actions. Actions from different groups are divided
/// by separators.
///
///
/// The identifier of the group. It is used to specify the group when registering actions
/// and to reference this group when specifying relative position of action groups.
///
///
/// Anchor for specifying the position of this group relative to other groups.
///
void RegisterContextMenuActionGroup( string groupId, ListAnchor anchor );
///
/// Registers a group for actions in a submenu of the context menu.
///
///
/// The identifier of the group. It is used to specify the group when registering actions
/// and to reference this group when specifying relative position of action groups.
///
///
/// Name of the submenu in which the action group is placed.
/// If two adjacent action groups have the same submenu name, they are displayed in the
/// same submenu and delimited with a separator.
///
///
/// Anchor for specifying the position of this group relative to other groups.
///
void RegisterContextMenuActionGroup( string groupId, string submenuName, ListAnchor anchor );
///
/// Registers an action which is executed when a context menu item is clicked.
///
/// The action which is registered.
///
/// Identifier of the context menu action group where the action is placed. Must not be null.
///
/// The relative position of the action within the group.
/// Caption of the menu item.
/// Menu item icon to be shown on the left strip.
///
/// The resource type to which the action applies, or null if the action applies to all
/// resource types. If a type is specified, the menu item is hidden if the selection
/// is empty or contains resources of other types.
///
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
/// If the filters have marked the presentation as hidden, the Update() method of the
/// action itself is not called.
///
void RegisterContextMenuAction( IAction action, string groupId, ListAnchor anchor, string text,
Image icon, string resourceType, IActionStateFilter[] filters );
///
/// Removes an action and its menu item from the context menu.
///
/// The action to remove.
void UnregisterContextMenuAction( IAction action );
///
/// Suppresses the separator between the two specified groups in the context menu.
///
/// The group on one side of the separator.
/// The group on the other side of the separator.
/// 2.0
void SuppressContextMenuGroupSeparator( string groupId1, string groupId2 );
#endregion ContextMenu
#region DoubleClick Actions
///
/// Registers an action which is executed when a resource is double-clicked.
/// There can be only one action registered for each specific resource type,
/// and multiple actions which apply to all types. The actions applying to all
/// types are tried only if no resource-type-specific action is registered for the
/// type of the double-clicked resource, and the first action which is not disabled
/// or hidden is executed.
///
/// The action which is registered.
///
/// Type of the resources to which the action applies, or null if the action applies
/// to all resource types.
///
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
/// If the filters have marked the presentation as hidden, the Update() method of the
/// action itself is not called.
///
void RegisterDoubleClickAction( IAction action, string resourceType, IActionStateFilter[] filters );
///
/// Removes an action from the list of actions executed by double click.
///
/// The action to remove.
void UnregisterDoubleClickAction( IAction action );
#endregion DoubleClick Actions
#region Keyboard Actions
///
/// Registers an action which is executed when a keyboard shortcut is pressed. There can
/// be multiple actions associated with the same keyboard shortcut. The actions are enumerated
/// in undefined order until one is found which matches the selection resource type and is not
/// disabled or hidden. That action is executed, and remaining actions are not processed.
///
/// The action which is registered.
/// The shortcut key for which the action is registered.
///
/// Type of the resources to which the action applies, or null if the action applies
/// to all resource types.
///
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
/// If the filters have marked the presentation as hidden, the Update() method of the
/// action itself is not called.
///
void RegisterKeyboardAction( IAction action, Keys shortcutKey, string resourceType,
IActionStateFilter[] filters );
///
/// Removes an action from the list of actions executed by a keyboard shortcut.
///
/// The action to remove.
void UnregisterKeyboardAction( IAction action );
#endregion Keyboard Actions
#region LinkClick Actions
///
/// Registers an action which is executed when a link to a resource of the specified type
/// is clicked in the links pane or the shortcut bar. Only one link click action can be
/// registered for each resource type; if the function is called multiple times, the
/// last registered action is used.
///
/// The action which is registered.
///
/// The resource type for which the action is registered. May not be null.
///
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
/// If the filters have marked the presentation as hidden, the Update() method of the
/// action itself is not called.
///
void RegisterLinkClickAction( IAction action, string resourceType, IActionStateFilter[] filters );
///
/// Removes an action from the list of actions executed by a link click.
///
/// The action to remove.
void UnregisterLinkClickAction( IAction action );
#endregion LinkClick Actions
#region LinkPane Actions
///
/// Registers an action which is shown as a link label on the links pane for a resource, and
/// executed when the link label is clicked.
///
/// The action which is registered.
/// The text of the link label.
///
/// Type of the resources to which the action applies, or null if the action applies
/// to all resource types.
///
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
/// If the filters have marked the presentation as hidden, the Update() method of the
/// action itself is not called.
///
void RegisterLinksPaneAction( IAction action, string text, string resourceType, IActionStateFilter[] filters );
///
/// Removes an action from the list of link pane label actions.
///
/// The action to remove.
void UnregisterLinksPaneAction( IAction action );
#endregion LinkPane Actions
#region Action Execution
///
/// Shows the context menu with actions for the specified context.
///
/// The context for which the menu is shown.
/// The control with which the context menu is associated.
///
/// The X coordinate at which the menu should be shown, relative to ownerControl.
///
///
/// The X coordinate at which the menu should be shown, relative to ownerControl.
///
void ShowResourceContextMenu( IActionContext context, Control ownerControl, int x, int y );
///
/// Executes the double-click action for the specified resource.
///
/// The resource for which the double-click action should be executed.
void ExecuteDoubleClickAction( IResource res );
///
/// Executes the double-click action for every resource in the specified list.
///
/// The resources for which the double-click action should be executed.
void ExecuteDoubleClickAction( IResourceList selectedResources );
///
/// Executes the keyboard action for the specified shortcut key and context.
///
/// The context in which the action is executed.
/// The shortcut key for which the action is executed.
///
/// true if an enabled action for this shortcut key was found and executed, false otherwise.
///
bool ExecuteKeyboardAction( IActionContext context, Keys shortcutKey );
///
/// Executes the action which is registered for clicking the link to the specified resource.
///
/// The context in which the action is executed.
///
/// true if the action was found and executed, false if there is no action for the type
/// of the specified resource or if the action was hidden or disabled.
///
bool ExecuteLinkClickAction( IActionContext context );
#endregion Action Execution
///
/// Returns the double-click action registered for the specified resource.
///
/// The resource for which the action is returned.
/// The double-click action instance, or null if there is no action registered.
IAction GetDoubleClickAction( IResource res );
///
/// Returns the string representation of the keyboard shortcut for which the specified
/// action is registered. If the action was registered for multiple keyboard shortcuts,
/// returns the one which was most recently registered.
///
/// The action for which the shortcut should be returned.
///
/// The shortcut for which the action is registered, or an empty string if the action
/// has no keyboard shortcut.
///
string GetKeyboardShortcut( IAction action );
///
/// Returns the string representation of the keyboard shortcut for which the specified
/// action is registered, if the shortcut is available in the specified context.
/// If the action was registered for multiple keyboard shortcuts, returns the one which
/// was most recently registered.
///
/// The action for which the shortcut should be returned.
/// The context in which the shortcut is checked for validity.
///
/// The shortcut for which the action is registered, or an empty string if the action
/// has no keyboard shortcut or the shortcut is disabled in the specified context.
///
string GetKeyboardShortcut( IAction action, IActionContext context );
Keys? GetKeyboardShortcutEx( IAction action, IActionContext context );
///
/// Registers a component which is contributed to a composite action. A composite action
/// is an action which is represented by a single UI control (for example, toolbar button
/// or menu item) but executes different things depending on the context (for example,
/// the Delete action runs different code for deleting categories, emails and news articles).
/// Several standard composite actions (Reply, Forward, Delete) are defined in the core of
/// the application.
///
/// The action which is registered.
/// The ID of the composite action to which the component is contributed.
///
/// Type of the resources to which the action applies, or null if the action applies
/// to all resource types.
///
///
/// The filters which provide additional control over the state of the action. Can be equal to
/// null or an empty array if no additional filters are needed.
/// If the filters have marked the presentation as hidden, the Update() method of the
/// action itself is not called.
///
void RegisterActionComponent( IAction action, string compositeId, string resourceType,
IActionStateFilter[] filters );
///
/// Specifies that the XML action configuration for the specified plugin assembly
/// should not be loaded
///
/// This can be useful if the plugin startup fails and it's not possible to
/// execute any of the plugin actions.
/// The plugin assembly
void DisableXmlActionConfiguration( Assembly pluginAssembly );
///
/// Returns the current action context.
///
/// 3.0
IActionContext GetMainMenuActionContext();
}
public class ActionGroups
{
public const string ITEM_OPEN_ACTIONS = "ItemOpenActions";
public const string ITEM_FIND_ACTIONS = "ItemFindActions";
public const string ITEM_MODIFY_ACTIONS = "ItemModifyActions";
public const string VIEW_GOTO_ACTIONS = "ViewGotoActions";
public const string VIEW_VIEWPANE_ACTIONS = "ViewViewpaneActions";
public const string GO_TAB_ACTIONS = "GoTabActions";
public const string TOOLS_OPTIONS_ACTIONS = "ToolsOptionsActions";
public const string ACTION_STANDARD_ACTIONS = "ActionStandardActions";
}
///
/// The exception is thrown when an error happens in the action manager.
///
[Serializable]
public class ActionException: Exception
{
public ActionException()
: base() { }
public ActionException( string message )
: base( message ) { }
public ActionException( string message, Exception innerException )
: base( message, innerException ) { }
protected ActionException( SerializationInfo info, StreamingContext context )
: base( info, context ) { }
}
}