///
/// 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.Diagnostics;
using System.Drawing;
using System.Net;
using System.Windows.Forms;
namespace JetBrains.Omea.OpenAPI
{
///
/// Current state of the Omea application.
///
public enum CoreState
{
///
/// The application is performing startup initialization.
/// This is the first state of Omea application when it starts. Changes to .
///
Initializing,
///
/// The plugins are being started at application startup.
/// Occurs after and before .
///
StartingPlugins,
///
/// The application is running.
/// When the application is started, it falls into the state after the startup initialization ( and states). This is the state which Omea has most of time, between startup and shutdown. When shutdown is initiated, the state changes to .
///
Running,
///
/// The application and all of the plugins are being shut down.
/// Occurs after . Do not initiate lengthy
/// actions not related to shutdown tasks when Omea application has this state.
///
ShuttingDown
};
///
/// Defines the flags affecting exception reporting. You may combine more than one value.
///
[Flags]
public enum ExceptionReportFlags
{
///
/// The exception being submitted is fatal.
///
Fatal = 1,
///
/// The log file should be attached when the exception is submitted.
///
AttachLog = 2
};
///
/// Provides data for events related to exceptions happening in threads not managed by
/// instances.
///
/// 2.0
public class OmeaThreadExceptionEventArgs: EventArgs
{
private Exception _exception;
private bool _handled = false;
public OmeaThreadExceptionEventArgs( Exception exception )
{
_exception = exception;
}
///
/// Gets the exception which occurred in a background thread.
///
public Exception Exception
{
get { return _exception; }
}
///
/// Gets or sets the value indicating whether the exception was handled by the
/// plugin or it needs to be passed to other plugins.
///
public bool Handled
{
get { return _handled; }
set { _handled = value; }
}
}
///
/// Allows a plugin to handle exceptions happening in threads not managed by
/// instances.
///
/// 2.0
public delegate void OmeaThreadExceptionEventHandler( object sender, OmeaThreadExceptionEventArgs e );
///
/// The static class that provides access to all core service interfaces.
///
/// Plugin implementors interact with Omea through interfaces which they get from this static class.
public static class Core
{
///
/// The main interface for creating and accessing resources.
///
/// At most times when Omea is running (except for the time when the
/// method is called), only one thread is designated
/// as the resource store write thread, and all operations that modify the resource store
/// (creating resources, changing resource properties, deleting resources) must be executed
/// in that thread. The class provides an easy way to run a resource write
/// operation synchronously or asynchronously.
public static IResourceStore ResourceStore { [DebuggerStepThrough] get { return ICore.Instance.ResourceStore; } }
///
/// The interface controls the progress window
/// which is displayed at program startup and when is used.
///
public static IProgressWindow ProgressWindow { [DebuggerStepThrough] get { return ICore.Instance.ProgressWindow; } }
///
/// The Action Manager 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 static IActionManager ActionManager
{
[DebuggerStepThrough]
get
{
if ( ICore.Instance == null )
{
return null;
}
return ICore.Instance.ActionManager;
}
}
///
/// The User Interface manager provides access
/// to UI elements and their settings.
///
public static IUIManager UIManager { [DebuggerStepThrough] get { return ICore.Instance.UIManager; } }
///
/// The Tab Manager that allows to register resource type tabs
/// and to get information about the registered resource type tabs.
///
public static ITabManager TabManager { [DebuggerStepThrough] get { return ICore.Instance.TabManager; } }
///
/// The Resource Browser manages the display of
/// resources and resource lists in Omea.
///
public static IResourceBrowser ResourceBrowser { [DebuggerStepThrough] get { return ICore.Instance.ResourceBrowser; } }
///
/// The sidebar at the left side of Omea main window.
/// Supports showing different sidebars depending on the active tab.
///
public static ISidebarSwitcher LeftSidebar { [DebuggerStepThrough] get { return ICore.Instance.LeftSidebar; } }
///
/// The sidebar at the right side of Omea main window.
///
public static ISidebar RightSidebar { [DebuggerStepThrough] get { return ICore.Instance.RightSidebar; } }
///
/// The Setting Store is a facility for storing
/// the settings of Omea application and plugins.
///
/// You should use the Setting Store rather than implement your own settings-storing facilities.
public static ISettingStore SettingStore { [DebuggerStepThrough] get { return ICore.Instance.SettingStore; } }
///
/// The Plugin Loader manages the registration of
/// interfaces for handling resources of specific types provided by plugins.
///
public static IPluginLoader PluginLoader { [DebuggerStepThrough] get { return ICore.Instance.PluginLoader; } }
///
/// The Text Index Manager provides services
/// for indexing documents and executing text index queries.
///
public static ITextIndexManager TextIndexManager { [DebuggerStepThrough] get { return ICore.Instance.TextIndexManager; } }
///
/// The Filter Manager provides interfaces for
/// working with custom views, rules, conditions and rule actions.
///
public static IFilterRegistry FilterRegistry { [DebuggerStepThrough] get { return ICore.Instance.FilterRegistry; } }
///
/// The Filter Manager provides interfaces for
/// working with custom views, rules, conditions and rule actions.
///
public static IFilterEngine FilterEngine { [DebuggerStepThrough] get { return ICore.Instance.FilterEngine; } }
///
/// The Tray Icon Manager provides interfaces
/// for working with tray icon rules.
///
/// 2.0
public static ITrayIconManager TrayIconManager { [DebuggerStepThrough] get { return ICore.Instance.TrayIconManager; } }
///
/// The Formatting Rule Manager provides interfaces
/// for working with formatting rules.
///
/// 2.0
public static IFormattingRuleManager FormattingRuleManager { [DebuggerStepThrough] get { return ICore.Instance.FormattingRuleManager; } }
///
/// The Expiration Rule Manager provides interfaces
/// for working with expiration rules.
///
/// 2.0
public static IExpirationRuleManager ExpirationRuleManager { [DebuggerStepThrough] get { return ICore.Instance.ExpirationRuleManager; } }
///
/// The Filtering Forms Manager allows plugins
/// to open standard dialogs for advanced search and creating/editing views and rules of different types.
///
/// 2.0
public static IFilteringFormsManager FilteringFormsManager { [DebuggerStepThrough] get { return ICore.Instance.FilteringFormsManager; } }
/// 3.0
public static ISearchQueryExtensions SearchQueryExtensions { [DebuggerStepThrough] get { return ICore.Instance.SearchQueryExtensions; } }
///
/// The Unread Manager allows to retrieve
/// unread counts for views and other resources.
///
public static IUnreadManager UnreadManager { [DebuggerStepThrough] get { return ICore.Instance.UnreadManager; } }
///
/// Handle to the main window.
///
public static IWin32Window MainWindow { [DebuggerStepThrough] get { return ICore.Instance.MainWindow; } }
///
/// The Web browser embedded in Omea.
///
public static AbstractWebBrowser WebBrowser { [DebuggerStepThrough] get { return ICore.Instance.WebBrowser; } }
///
/// The async processor for executing operations
/// in the resource thread.
///
public static IAsyncProcessor ResourceAP { [DebuggerStepThrough] get { return ICore.Instance.ResourceAP; } }
///
/// The async processor for executing operations
/// in the network thread.
///
public static IAsyncProcessor NetworkAP { [DebuggerStepThrough] get { return ICore.Instance.NetworkAP; } }
///
/// The async processor for executing operations
/// in the UI thread. It is recommended to use this call instead of Control.BeginInvoke().
/// Is equal to null until CoreState is not Running.
/// It is always safe to use Core.UIManager.QueueUIJob
/// as an alternative.
/// 2.0
///
public static IAsyncProcessor UserInterfaceAP { [DebuggerStepThrough] get { return ICore.Instance.UserInterfaceAP; } }
///
/// The workspace manager which provides information
/// about workspaces and services for registering the relationship between resources and
/// workspaces.
///
public static IWorkspaceManager WorkspaceManager { [DebuggerStepThrough] get { return ICore.Instance.WorkspaceManager; } }
///
/// Returns the category manager interface.
///
public static ICategoryManager CategoryManager { [DebuggerStepThrough] get { return ICore.Instance.CategoryManager; } }
///
/// The Resource Tree Manager which handles
/// resource tree roots for specific resource types and sorting of items in resource trees.
///
public static IResourceTreeManager ResourceTreeManager { [DebuggerStepThrough] get { return ICore.Instance.ResourceTreeManager; } }
///
/// The Display Column Manager that handles
/// the default resource list columns used when displaying resource lists
/// and the columns which are available in the "Configure Columns" dialog.
///
public static IDisplayColumnManager DisplayColumnManager { [DebuggerStepThrough] get { return ICore.Instance.DisplayColumnManager; } }
///
/// The Icon Manager that handles registration
/// and retrieval of icons for resources.
///
/// All small (16x16) resource icons are put in one global image list,
/// which can be accessed through the property.
public static IResourceIconManager ResourceIconManager { [DebuggerStepThrough] get { return ICore.Instance.ResourceIconManager; } }
///
/// The Notification Manager that handles the rules
/// that are used for notifying the user about arriving resources.
///
public static INotificationManager NotificationManager { [DebuggerStepThrough] get { return ICore.Instance.NotificationManager; } }
///
/// The Message Formatter which provides services
/// for getting an HTML formatted presentation of plain-text messages and for quoting
/// replies.
///
public static IMessageFormatter MessageFormatter { [DebuggerStepThrough] get { return ICore.Instance.MessageFormatter; } }
///
/// The Contact Manager that handles various core operations with contacts.
///
public static IContactManager ContactManager { [DebuggerStepThrough] get { return ICore.Instance.ContactManager; } }
///
/// The File Resource Manager that handles the
/// relationship between file extensions, MIME types and format-describing resources.
///
public static IFileResourceManager FileResourceManager { [DebuggerStepThrough] get { return ICore.Instance.FileResourceManager; } }
///
/// IDs of the resource properties which are registered by the core.
///
/// 2.0
public static ICoreProps Props { [DebuggerStepThrough] get { return ICore.Instance.Props; } }
public static ICorePropIds PropIds { get { return ICore.Instance.PropIds; } }
///
/// Omea product short name.
///
public static string ProductName { [DebuggerStepThrough] get { return ICore.Instance.ProductName; } }
///
/// Omea product full name.
///
public static string ProductFullName { [DebuggerStepThrough] get { return ICore.Instance.ProductFullName; } }
///
/// Omea product build number.
///
public static Version ProductVersion { [DebuggerStepThrough] get { return ICore.Instance.ProductVersion; } }
///
/// Omea product release version, marketing-style. Non-Null in RTM builds only, Null in internal/beta builds.
///
public static string ProductReleaseVersion { [DebuggerStepThrough] get { return ICore.Instance.ProductReleaseVersion; } }
///
/// The current scale factor.
///
public static SizeF ScaleFactor { [DebuggerStepThrough] get { return ICore.Instance.ScaleFactor; } }
///
/// The idle period, in minutes.
///
/// The idle time is detected by monitoring the user activity. This information allows to run complex tasks at a time when they would not interfere with normal work.
public static int IdlePeriod // in minutes
{
[DebuggerStepThrough] get { return ICore.Instance.IdlePeriod; }
[DebuggerStepThrough] set { ICore.Instance.IdlePeriod = value; }
}
///
/// Detects whether the system is in the idle state or not depending on the value.
///
public static bool IsSystemIdle { [DebuggerStepThrough] get { return ICore.Instance.IsSystemIdle; } }
///
/// Current state of the Omea application.
///
public static CoreState State { [DebuggerStepThrough] get { return ICore.Instance.State; } }
///
/// Fires when Omea application state changes.
///
public static event EventHandler StateChanged
{
add
{
ICore.Instance.StateChanged += value;
}
remove
{
ICore.Instance.StateChanged -= value;
}
}
///
/// The default proxy configured in the Omea options dialog.
///
public static IWebProxy DefaultProxy
{
get { return ICore.Instance.DefaultProxy; }
}
///
/// Reports a non-fatal exception to the UI and provides an opportunity to submit this exception to the tracker.
///
/// The exception being reported.
/// 3
public static void ReportException( Exception e ) {ReportException(e, false);
}
///
/// Reports an exception to the UI and provides an opportunity to submit this exception to the tracker.
///
/// The exception being reported.
/// Specifies whether the exception is fatal or not.
public static void ReportException( Exception e, bool fatal ) { ICore.Instance.ReportException( e, fatal ); }
///
/// Reports an exception to the UI and provides an opportunity to submit this exception to the tracker.
///
/// The exception being reported.
/// Provides a combination of flags that specify whether the exception is fatal or if the log file is to be attached when the exception is submitted. See for possible values.
public static void ReportException( Exception e, ExceptionReportFlags flags ) { ICore.Instance.ReportException( e, flags ); }
///
/// Shows an icon notifying a user that an exception occurred during background processing.
///
/// Double-clicking the icon shows a dialog for submitting the exception to the
/// tracker.
/// The exception to report.
public static void ReportBackgroundException( Exception e ) { ICore.Instance.ReportBackgroundException( e ); }
///
/// Forces self-restart of the application. Can be invoked in the arbitrary thread.
///
/// 2.2
public static void RestartApplication()
{
ICore.Instance.RestartApplication();
}
///
/// Adds the specified text string to the environment data included in exception reports
/// submitted to the tracker.
///
/// The string to include in exception reports.
public static void AddExceptionReportData( string data ) { ICore.Instance.AddExceptionReportData( data ); }
///
/// Occurs when an exception happens in an Omea thread which is not managed by an
/// .
///
/// 2.0
public static event OmeaThreadExceptionEventHandler BackgroundThreadException
{
add { ICore.Instance.BackgroundThreadException += value; }
remove { ICore.Instance.BackgroundThreadException -= value; }
}
///
/// The Remote controller Manager registers
/// methods for remote invokation.
///
/// 2.0
public static IRemoteControlManager RemoteControllerManager { [DebuggerStepThrough] get { return ICore.Instance.RemoteControllerManager; } }
///
/// The Protocol Handler Manager for registering of protocol handlers.
///
/// 2.0
public static IProtocolHandlerManager ProtocolHandlerManager { get { return ICore.Instance.ProtocolHandlerManager; } }
///
/// Returns the registered implementation of a component of the specified type.
///
/// Type of the component.
/// Component implementation, or null if none was registered.
/// 2.0
public static object GetComponentImplementation( Type componentType )
{
return ICore.Instance.GetComponentImplementation( componentType );
}
}
///
/// An interface for the static class that provides access to all core service interfaces.
///
/// Plugin implementors interact with Omea through interfaces which they get from a class implementing the interface. Use the static class to obtain an implementor.
public abstract class ICore
{
///
/// The one and only instance.
///
protected static ICore theInstance;
///
/// The main interface for creating and accessing resources.
///
///
/// Do not modify resources in non-resource threads! At most times when Omea is running (except for the time when the
/// method is called), only one thread is designated
/// as the resource store write thread, and all operations that modify the resource store
/// (creating resources, changing resource properties, deleting resources) must be executed
/// in that thread. The class provides an easy way to run a resource write
/// operation synchronously or asynchronously.
public abstract IResourceStore ResourceStore { get; }
///
/// Controls the progress window which is displayed at program startup and when
/// is used.
///
public abstract IProgressWindow ProgressWindow { get; }
///
/// The Action Manager that 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 abstract IActionManager ActionManager { get; }
///
/// The User Interface manager that provides access to UI elements and their settings.
///
public abstract IUIManager UIManager { get; }
///
/// The Tab Manager that allows to register resource type tabs and to get information about the
/// registered resource type tabs.
///
public abstract ITabManager TabManager { get; }
///
/// The Resource Browser that manages the display of resources and resource lists in Omea.
///
public abstract IResourceBrowser ResourceBrowser { get; }
///
/// The sidebar at the left side of Omea main window. Supports showing different sidebars depending on the active tab.
///
public abstract ISidebarSwitcher LeftSidebar { get; }
///
/// The sidebar at the right side of Omea main window.
///
public abstract ISidebar RightSidebar { get; }
///
/// The Setting Store that is a facility for storing the settings of Omea application and plugins.
///
/// You should use the Setting Store rather than implement your own settings-storing facilities.
public abstract ISettingStore SettingStore { get; }
///
/// The Plugin Loader that manages the registration of interfaces for handling resources of specific types
/// provided by plugins.
///
public abstract IPluginLoader PluginLoader { get; }
///
/// TextIndexManager controls the text indexing process - queues indexing requests,
/// checks the existence of the index, queues query processing.
///
public abstract ITextIndexManager TextIndexManager { get; }
///
/// FilterRegistry controls the creation and maintenance of
/// rules, views and views-derived structures (like formatting, expiration,
/// and tray icon rules).
///
public abstract IFilterRegistry FilterRegistry { get; }
///
/// FilterEngine controls the execution of rules and views.
///
public abstract IFilterEngine FilterEngine { get; }
///
/// The Tray Icon Manager provides interfaces
/// for working with tray icon rules.
///
/// 2.0
public abstract ITrayIconManager TrayIconManager { get; }
///
/// The Formatting Rule Manager provides interfaces
/// for working with formatting rules.
///
/// 2.0
public abstract IFormattingRuleManager FormattingRuleManager { get; }
///
/// The Expiration Rule Manager provides interfaces
/// for working with expiration rules.
///
/// 2.0
public abstract IExpirationRuleManager ExpirationRuleManager { get; }
///
/// The Filtering Forms Manager allows plugins
/// to open standard dialogs for advanced search and creating/editing views and rules of different types.
///
/// 2.0
public abstract IFilteringFormsManager FilteringFormsManager { get; }
///
/// Search query extensions allow plugins
/// to extend search query with predefined conditions in a very simple way.
///
/// 2.2
public abstract ISearchQueryExtensions SearchQueryExtensions { get; }
///
/// The Unread Manager which allows to retrieve
/// unread counts for views and other resources.
///
public abstract IUnreadManager UnreadManager { get; }
///
/// Handle to the main window.
///
public abstract IWin32Window MainWindow { get; }
///
/// The Web browser embedded in Omea.
///
public abstract AbstractWebBrowser WebBrowser { get; }
///
/// Provides an asynchronous processor for the resource thread.
/// Allows to queue jobs for execution on the resource thread, or execute them immediately and wait for them to complete.
///
public abstract IAsyncProcessor ResourceAP { get; }
///
/// Provides an asynchronous processor for the network thread.
/// Allows to queue jobs for execution on the network thread, or execute them immediately and wait for them to complete.
///
public abstract IAsyncProcessor NetworkAP { get; }
///
/// Provides an asynchronous processor for the user interface thread.
/// Allows to queue jobs for execution on the user interface thread, or execute them immediately and wait for them to complete.
///
///
/// This async processor supercedes the old method and provides the full-scale asynchronous processor for the user interface thread.
/// Normally, the Windows Message Queue is not used for executing the UI tasks. However, if an UI job has to be executed from inside another UI job, the standard is still used.
///
/// 2.0
public abstract IAsyncProcessor UserInterfaceAP { get; }
///
/// Returns the workspace manager interface.
///
public abstract IWorkspaceManager WorkspaceManager { get; }
///
/// Returns the category manager interface.
///
public abstract ICategoryManager CategoryManager { get; }
///
/// Returns the resource tree manager interface.
///
public abstract IResourceTreeManager ResourceTreeManager { get; }
///
/// The Display Column Manager that arranges the default resource list columns used when displaying resource lists
/// and the columns which are available in the "Configure Columns" dialog.
///
public abstract IDisplayColumnManager DisplayColumnManager { get; }
///
/// The Icon Manager that handles registration and retrieval of icons for resources.
///
/// All small (16x16) resource icons are put in one global image list,
/// which can be accessed through the property.
public abstract IResourceIconManager ResourceIconManager { get; }
///
/// The Notification Manager that handles the rules that are used for notifying the user about arriving resources.
///
public abstract INotificationManager NotificationManager { get; }
///
/// The Contact Manager that handles various core operations with contacts.
///
public abstract IContactManager ContactManager { get; }
///
/// The File Resource Manager that handles the
/// relationship between file extensions, MIME types and format-describing resources.
///
public abstract IFileResourceManager FileResourceManager { get; }
///
/// The Message Formatter which provides services
/// for getting an HTML formatted presentation of plain-text messages and for quoting
/// replies.
///
public abstract IMessageFormatter MessageFormatter { get; }
///
/// IDs of the resource properties which are registered by the core.
///
/// 2.0
public abstract ICoreProps Props { get; }
public abstract ICorePropIds PropIds { get; }
///
/// Omea product short name.
///
public abstract string ProductName { get; }
///
/// Omea product full name.
///
public abstract string ProductFullName { get; }
///
/// Omea product build number.
///
public abstract Version ProductVersion { get; }
///
/// Omea product release version.
///
public abstract string ProductReleaseVersion { get; }
///
/// The current scale factor.
///
public abstract SizeF ScaleFactor { get; }
///
/// The idle period, in minutes.
///
/// The idle time is detected by monitoring the user activity. This information allows to run complex tasks at a time when they would not interfere with normal work.
public abstract int IdlePeriod { get; set; } // in minutes
///
/// Detects whether the system is in the idle state or not depending on the value.
///
public abstract bool IsSystemIdle { get; }
///
/// Current state of the Omea application.
///
public abstract CoreState State { get; }
///
/// Fires when Omea application state changes.
///
public abstract event EventHandler StateChanged;
///
/// Reports an exception to the UI and provides an opportunity to submit this exception to the ITN tracker.
///
/// The exception being reported.
/// Specifies whether the exception is fatal or not.
public abstract void ReportException( Exception e, bool fatal );
///
/// Reports an exception to the UI and provides an opportunity to submit this exception to the ITN tracker.
///
/// The exception being reported.
/// Provides a combination of flags that specify whether the exception is fatal or if the log file is to be attached when the exception is submitted. See for possible values.
public abstract void ReportException( Exception e, ExceptionReportFlags flags );
///
/// Adds the specified text string to the environment data included in exception reports
/// submitted to the tracker.
///
/// The string to include in exception reports.
public abstract void AddExceptionReportData( string data );
///
/// Shows an icon notifying a user that an exception occurred during background processing.
///
/// Double-clicking the icon shows a dialog for submitting the exception to the
/// tracker.
/// The exception to report.
public abstract void ReportBackgroundException( Exception e );
///
/// Forces self-restart of the application. Can be invoked in the arbitrary thread.
///
/// 2.2
public abstract void RestartApplication();
///
/// Occurs when an exception happens in an Omea thread which is not managed by an
/// .
///
/// 2.0
public abstract event OmeaThreadExceptionEventHandler BackgroundThreadException;
///
/// The default proxy configured in the Omea options dialog.
///
public abstract IWebProxy DefaultProxy
{
get;
}
///
/// The one and only Core instance implementing the interface.
///
public static ICore Instance
{
[DebuggerStepThrough] get { return theInstance; }
}
///
/// The Remote controller Manager that registers
/// methods for remote invokation.
///
/// 2.0
public abstract IRemoteControlManager RemoteControllerManager { get ; }
///
/// The Protocol Handler Manager for registering of protocol handlers.
///
/// 2.0
public abstract IProtocolHandlerManager ProtocolHandlerManager { get; }
///
/// Returns the registered implementation of a component of the specified type.
///
/// Type of the component.
/// Component implementation, or null if none was registered.
/// 2.0
public abstract object GetComponentImplementation( Type componentType );
}
}