public virtual void Inject( IStatusWriter statusWriter, ISelectedListener <UserEncounterSelectedEventArgs> encounterSelectedListener) { EncounterSelectedListener = encounterSelectedListener; StatusWriter = statusWriter; }
public StatusWriter( [Inject(Id = SaveType.Server)] IStatusWriter serverStatusWriter, [Inject(Id = SaveType.Local)] IStatusWriter localStatusWriter) { ServerStatusWriter = serverStatusWriter; LocalStatusWriter = localStatusWriter; }
/// <summary> /// Initiates the async highlighting of the search hits. /// </summary> /// <param name="words">Words to be highlighted. MUST belong to a single document section.</param> public void HighlightWords(WordPtr[] words) { #region Preconditions if (words == null) { return; } // Validness check WordPtr.AssertValid(words, true); #endregion Preconditions _wordsSearchHits = null; // Here the real search hits will be stored; in case of main highlighting they correspond to the ones passed in _statuswriter = Core.UIManager.GetStatusWriter(this, StatusPane.UI); _statuswriter.ShowStatus("Highlighting search hits in the document…"); // Initiate the async hilite process _stateHilite = new AsyncHighlightState(words); if (StartHiliteMain(_stateHilite)) { Core.UserInterfaceAP.QueueJobAt(DateTime.Now.AddMilliseconds(500), "Highlight the search hits.", new MethodInvoker(StepHilite)); // Succeeded — queue execution } else { // Failed — deinitialize _stateHilite = null; _statuswriter.ClearStatus(); _statuswriter = null; Trace.WriteLine("Failed to initiate the main highlighting scheme.", "[JRTB]"); } }
protected override void Execute() { IResource resFolder; if (!IsDataCorrect(out resFolder, _folder)) { return; } IStatusWriter statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network); statusWriter.ShowStatus("Synchronizing folder " + _folder.Name + "..."); OutlookSession.ProcessJobs(); try { MailSync mailSync = new MailSync(false, _dateRestriction); mailSync.AddMailResources(Folder.GetMessageList(resFolder)); mailSync.EnumerateMessageItems(_folder); mailSync.RemoveDeletedMailsFromIndex(); } finally { statusWriter.ClearStatus(); } }
public void RemoveSubscriber(IStatusWriter writer) { if (_subscribers.Contains(writer)) { _subscribers.Remove(writer); } }
public void AddSubscriber(IStatusWriter writer) { if (!_subscribers.Contains(writer)) { _subscribers.Add(writer); } }
/// <summary> /// Does the asynchronous highlighting step. /// </summary> private void StepHilite() { if (_stateHilite == null) { return; // Has been shut down } uint dwStart = Win32Declarations.GetTickCount(); uint dwLimit = 222; // Allow running for this much milliseconds continuously // Freeze the control Win32Declarations.SendMessage(Handle, Win32Declarations.WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero); try { int nIterations; for (nIterations = 0; Win32Declarations.GetTickCount() - dwStart < dwLimit; nIterations++) // Work for some limited time { if (!_stateHilite.StepHiliteDelegate(_stateHilite)) // Invoke the individual highlighting step { // Highlighting Completed! // Reset the status bar dials _statuswriter.ClearStatus(); _statuswriter = null; // Retrieve the values _wordsSearchHits = _stateHilite.ActualSearchHits; _nCurrentSearchHit = -1; // Deinitialize the hilite search _stateHilite = null; // Jump to the next search hit GotoNextSearchHit(true, false); // Invalidate Win32Declarations.SendMessage(Handle, Win32Declarations.WM_SETREDRAW, (IntPtr)1, IntPtr.Zero); Invalidate(); // Done! Trace.WriteLine(String.Format("The JetRichTextBox has completed the async highlighting with {0} hits total.", (_wordsSearchHits != null ? _wordsSearchHits.Length.ToString() : "#ERROR#")), "[JRTB]"); return; } } Trace.WriteLine(String.Format("The JetRichTextBox async highlighting has done {0} highlightings on this step.", nIterations), "[JRTB]"); } finally { // Unfreeze the events and repaint Win32Declarations.SendMessage(Handle, Win32Declarations.WM_SETREDRAW, (IntPtr)1, IntPtr.Zero); if ((_stateHilite != null) && (Win32Declarations.GetTickCount() - _stateHilite.LastRepaintTime > 2000)) // Repaint rarely { Invalidate(); _stateHilite.LastRepaintTime = Win32Declarations.GetTickCount(); } } // Requeue the rest of execution Application.DoEvents(); // Without this, the painting events won't occur Core.UserInterfaceAP.QueueJob("Highlight the search hits.", new MethodInvoker(StepHilite)); }
//Remove method of the interface IObservableDevice public void RemoveSubscriber(IStatusWriter writer) { // add subscribers only if is not present // does not accept duplicate if (_subscribers.Contains(writer)) { _subscribers.Remove(writer); } }
protected override void Dispose(bool disposing) { base.Dispose(disposing); _stateHilite = null; // Stop the currently-running highlighting if (_statuswriter != null) { _statuswriter.ClearStatus(); _statuswriter = null; } _wordsSearchHits = null; _nCurrentSearchHit = -1; }
internal void UpdateStatus(IStatusWriter writer, string message, bool doEvents) { lock ( _activeStatusWriters ) { _activeStatusWriters.Remove(writer); if (message != null) { _activeStatusWriters.Insert(0, writer); } } Core.UIManager.QueueUIJob(new UpdateStatusTextDelegate(UpdateStatusText), new object[] { doEvents }); }
public IStatusWriter GetStatusWriter(object owner) { lock ( _statusWriters ) { IStatusWriter writer = (IStatusWriter)_statusWriters [owner]; if (writer == null) { writer = new StatusWriter(this, owner); _statusWriters [owner] = writer; } return(writer); } }
public RSSUnitOfWork(IResource feed, bool parseItems, bool acceptHtmlIfXmlError) { Trace.WriteLineIf(Settings.Trace, "Starting update of feed " + feed.DisplayName); _feed = feed; _parseItems = parseItems; _acceptHtmlIfXmlError = acceptHtmlIfXmlError; _statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network); string feedUrl = feed.GetStringProp(Props.URL); if (!HttpReader.IsSupportedProtocol(feedUrl)) { throw new ArgumentException("Unsupported feed protocol: " + feedUrl); } if (parseItems) { FavIconManager favIconManager = (FavIconManager)Core.GetComponentImplementation(typeof(FavIconManager)); favIconManager.DownloadFavIcon(feedUrl); } _httpReader = new HttpReader(feedUrl); string etag = feed.GetPropText(Props.ETag); if (etag.Length > 0) { _httpReader.IfNoneMatch = etag; } string httpUserName = feed.GetStringProp(Props.HttpUserName); string httpPassword = feed.GetStringProp(Props.HttpPassword); if (httpUserName != null && httpPassword != null) { _httpReader.Credentials = new NetworkCredential(httpUserName, httpPassword); } _httpReader.AcceptInstanceManipulation = "feed"; if (_feed.HasProp(Props.DisableCompression) || Settings.DisableCompression) { _httpReader.AcceptEncoding = null; } _httpReader.CookieProvider = CookiesManager.GetUserCookieProvider(typeof(RSSUnitOfWork)); _status = RSSWorkStatus.NotStarted; Timeout = Settings.TimeoutInSec * 1000; OnTimeout += RSSUnitOfWork_OnTimeout; }
protected void SyncServer() { IStatusWriter statusbar = Core.UIManager.GetStatusWriter(this, StatusPane.Network); try { statusbar.ShowStatus(string.Format(Stringtable.SyncingJiraServer, Server.Name)); Server.Sync(); statusbar.ShowStatus(string.Format(Stringtable.SyncingJiraServerSucceeded, Server.Name), 10); } catch (Exception ex) { statusbar.ShowStatus(string.Format(Stringtable.SyncingJiraServerFailed, Server.Name), 10); Core.UserInterfaceAP.QueueJob((MethodInvoker) delegate { MessageBox.Show(Core.MainWindow, string.Format(Stringtable.SyncingJiraServerFailed, Server.Name) + "\n\n" + ex.Message, Jiffa.Name, MessageBoxButtons.OK, MessageBoxIcon.Error); }); } }
internal TextIndexManager() : base(false) { _processPendingDocsDelegate = new DelegateJob("Indexing documents", new MethodInvoker(ProcessPendingDocs), new object[] {}); if (Core.ResourceStore.PropTypes.Exist("QueuedForIndexing")) { Core.ResourceStore.PropTypes.Delete(Core.ResourceStore.PropTypes["QueuedForIndexing"].Id); } _statusWriter = Core.UIManager.GetStatusWriter(typeof(FullTextIndexer), StatusPane.UI); _isJobTraceSuppressed = Core.SettingStore.ReadBool("TextIndexing", "SuppressJobTraces", false); _textIndexer = new FullTextIndexer(); _textIndexer.IndexLoaded += IndexLoadedNotification; Reenterable = false; ThreadName = "TextIndex AsyncProcessor"; ThreadPriority = System.Threading.ThreadPriority.BelowNormal; ThreadStarted += TextIndexProcessor_ThreadStarted; Core.PluginLoader.RegisterResourceTextProvider(null, new AnnotationTextIndexProvider()); Core.PluginLoader.RegisterResourceTextProvider(null, new TitleTextIndexProvider()); // Register predefined search providers CurrentSearchProvider = new OmeaGlobalSearchProvider(); RegisterSearchProvider(CurrentSearchProvider, "Omea Search", _cStandardProvidersGroupName); RegisterSearchProvider(new OmeaQuickSearchProvider(), "Local Search", _cStandardProvidersGroupName); DefragmentIndexJob._textIndexManager = IndexingJob._textIndexManager = this; SetupDefragmentationQueue(); _switchToIdleJob = new SwitchToIdleModeJob(this); QueueSwitchToIdleModeJob(); Core.UIManager.RegisterIndicatorLight("Text Index Manager", this, 30, MainFrame.LoadIconFromAssembly("textindex_idle.ico"), MainFrame.LoadIconFromAssembly("textindex_busy.ico"), MainFrame.LoadIconFromAssembly("textindex_stuck.ico")); }
protected override void Execute() { if (OutlookSession.OutlookProcessor.ShuttingDown) { return; } IStatusWriter statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network); statusWriter.ShowStatus("Performing background mail synchronization..."); Tracer._Trace("MailSyncBackground is executed"); foreach (IEMsgStore msgStore in OutlookSession.GetMsgStores()) { if (OutlookSession.OutlookProcessor.ShuttingDown) { break; } OutlookSession.ProcessJobs(); if (msgStore == null) { continue; } if (OutlookProcessor.IsIgnoredInfoStore(msgStore)) { continue; } string storeID = msgStore.GetBinProp(MAPIConst.PR_STORE_ENTRYID); string name = msgStore.GetStringProp(MAPIConst.PR_DISPLAY_NAME); FolderDescriptorEnumerator.Do(msgStore, storeID, name, this); } statusWriter.ClearStatus(); ProcessedFolders.DecRef(); }
public static void UpdateHttpStatus(IStatusWriter writer, string name, int bytes) { IAsyncProcessor ap = Core.UserInterfaceAP; if (!ap.IsOwnerThread) { // update status in UI thread, because size formatting requires that ap.QueueJob(JobPriority.Immediate, new UpdateHttpStatusDelegate(UpdateHttpStatus), writer, name, bytes); } else { bytes &= ~1023; StringBuilder builder = StringBuilderPool.Alloc(); try { builder.Append("Downloading "); builder.Append(name); if (bytes == 0) { builder.Append("..."); } else { builder.Append(" ("); builder.Append(SizeToString(bytes)); builder.Append(')'); } writer.ShowStatus(builder.ToString()); } finally { StringBuilderPool.Dispose(builder); } } }
/// <summary> /// Initializes a new instance of the <see cref="ErrorHandler"/> class. /// </summary> /// <param name="caller">The caller.</param> /// <param name="statusWriter">The status writer.</param> /// <param name="afterLogHandler">The handler executed after loggin.</param> internal ErrorHandler(object caller, IStatusWriter statusWriter, Action afterLogHandler) { this.Logger = LogManager.GetLogger(caller.GetType()); this.StatusWriter = statusWriter; this.AfterLogHandler = afterLogHandler; }
/// <summary> /// Configures the status writer. /// </summary> /// <param name="statusWriter">The status writer.</param> public static void ConfigureStatusWriter(IStatusWriter statusWriter) { StatusWriter = statusWriter; }
public void Register() { _repositoryTypes = new List <RepositoryType> { new P4RepositoryType(), new SvnRepositoryType() }; Props.Register(this); // delete remnants of old version of the plugin if (Core.ResourceStore.ResourceTypes.Exist("jetbrains.p4.ChangeSet")) { Core.ResourceStore.GetAllResources("jetbrains.p4.ChangeSet").DeleteAll(); Core.ResourceStore.ResourceTypes.Delete("jetbrains.p4.ChangeSet"); } if (Core.ResourceStore.ResourceTypes.Exist("jetbrains.p4.Folder")) { Core.ResourceStore.GetAllResources("jetbrains.p4.Folder").DeleteAll(); Core.ResourceStore.ResourceTypes.Delete("jetbrains.p4.Folder"); } if (Core.ResourceStore.ResourceTypes.Exist("jetbrains.p4.FileChange")) { Core.ResourceStore.GetAllResources("jetbrains.p4.FileChange").DeleteAll(); Core.ResourceStore.ResourceTypes.Delete("jetbrains.p4.FileChange"); } Core.TabManager.RegisterResourceTypeTab("SCC", "SCC", Props.ChangeSetResource, 80); Core.DisplayColumnManager.RegisterDisplayColumn(Props.ChangeSetResource, 0, new ColumnDescriptor("From", 150)); Core.DisplayColumnManager.RegisterDisplayColumn(Props.ChangeSetResource, 1, new ColumnDescriptor("Subject", 300)); Core.DisplayColumnManager.RegisterDisplayColumn(Props.ChangeSetResource, 2, new ColumnDescriptor("Date", 120)); // Register a standard tree pane for showing the folder structure of the Perforce // repository and the changesets in each folder. _folderTreePane = Core.LeftSidebar.RegisterResourceStructureTreePane("SccFolders", "SCC", "Folders", null, Props.RepositoryResource); _folderTreePane.ToolTipCallback = GetRepositoryToolTip; // Set sorting by name for the folder structure IResource folderRoot = Core.ResourceTreeManager.GetRootForType(Props.RepositoryResource); Core.ResourceTreeManager.SetResourceNodeSort(folderRoot, "Name"); // Register a custom sidebar pane for showing the list of Perforce developers and // the changesets done by each developer. Core.LeftSidebar.RegisterViewPane("SccDevelopers", "SCC", "Developers", null, new SccDeveloperPane()); Core.PluginLoader.RegisterResourceUIHandler(Props.FolderResource, new SccFolderUIHandler()); Core.PluginLoader.RegisterResourceDisplayer(Props.ChangeSetResource, this); Core.PluginLoader.RegisterResourceTextProvider(Props.ChangeSetResource, new ChangeSetTextProvider()); Core.UIManager.RegisterOptionsGroup("Development", "The Development options pane controls different development-related plugins"); Core.UIManager.RegisterOptionsPane("Development", "Source Control", new OptionsPaneCreator(CreateSccOptionsPane), "The Source Control options pane specifies the source control repositories monitored by the SCC plugin"); Core.UIManager.RegisterWizardPane("Source Control", new OptionsPaneCreator(CreateSccOptionsPane), 15); _statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network); Assembly iconAssembly = Assembly.GetExecutingAssembly(); _changeSetIcon = new Icon(iconAssembly.GetManifestResourceStream("SccPlugin.changeset.ico")); _openFolderIcon = new Icon(iconAssembly.GetManifestResourceStream("SccPlugin.OpenFolder.ico")); _closedFolderIcon = new Icon(iconAssembly.GetManifestResourceStream("SccPlugin.ClosedFolder.ico")); _repositoryIcon = new Icon(iconAssembly.GetManifestResourceStream("SccPlugin.repository.ico")); Core.ResourceIconManager.RegisterResourceIconProvider( new string[] { Props.ChangeSetResource, Props.FolderResource, Props.RepositoryResource }, this); // Allow creating rules which affect resources of type ChangeSet Core.FilterEngine.RegisterRuleApplicableResourceType(Props.ChangeSetResource); // Register display columns for multiline view Core.DisplayColumnManager.RegisterMultiLineColumn(Props.ChangeSetResource, Core.ContactManager.Props.LinkFrom, 0, 0, 0, 120, MultiLineColumnFlags.AnchorLeft | MultiLineColumnFlags.AnchorRight, SystemColors.WindowText, HorizontalAlignment.Left); Core.DisplayColumnManager.RegisterMultiLineColumn(Props.ChangeSetResource, Core.Props.Date, 0, 0, 120, 80, MultiLineColumnFlags.AnchorRight, SystemColors.WindowText, HorizontalAlignment.Right); Core.DisplayColumnManager.RegisterMultiLineColumn(Props.ChangeSetResource, Core.Props.Subject, 1, 1, 0, 144, MultiLineColumnFlags.AnchorLeft | MultiLineColumnFlags.AnchorRight, Color.FromArgb(112, 112, 112), HorizontalAlignment.Left); Core.ActionManager.RegisterMainMenuActionGroup("SendReceiveActions", "Tools", ListAnchor.First); Core.ActionManager.RegisterMainMenuAction(new SynchronizeRepositoriesAction(), "SendReceiveActions", ListAnchor.Last, "Synchronize Repositories", null, null, null); Core.ActionManager.RegisterActionComponent(new DeleteRepositoryAction(), "Delete", Props.RepositoryResource, null); Core.ActionManager.RegisterActionComponent(new SynchronizeRepositoryAction(), "Refresh", Props.RepositoryResource, null); Core.ActionManager.RegisterContextMenuActionGroup("PropertiesActions", ListAnchor.Last); Core.ActionManager.RegisterContextMenuAction(new ToggleShowSubfolderContentsAction(), "PropertiesActions", ListAnchor.First, "Show subfolder contents", null, Props.FolderResource, null); Core.ActionManager.RegisterContextMenuAction(new RepositoryPropertiesAction(), "PropertiesActions", ListAnchor.First, "Properties...", null, Props.RepositoryResource, null); }
public override void Execute(IActionContext context) { IResourceStore store = Core.ResourceStore; IResourceList articles = store.GetAllResources("Article").Minus( store.FindResourcesWithProp(null, Core.Props.IsDeleted)); IResourceList resources = context.SelectedResources; if (!resources.AllResourcesOfType("NewsGroup")) { resources = null; } IStatusWriter writer = Core.UIManager.GetStatusWriter(this, StatusPane.UI); try { HashMap readers = new HashMap(); int i = 0; int percent = -1; foreach (IResource article in articles) { int p = (i++ *100) / articles.Count; if (p > percent) { percent = p; writer.ShowStatus("Looking through news articles: " + percent.ToString() + "%"); Application.DoEvents(); } if (resources != null && article.GetLinksOfType("NewsGroup", "Newsgroups").Intersect(resources).Count == 0) { continue; } string[] headers = article.GetPropText("MessageHeaders").Split('\n'); string reader = null; foreach (string headerLine in headers) { if (headerLine.StartsWith("X-Newsreader: ")) { reader = headerLine.Substring("X-Newsreader: ".Length).TrimEnd('\r', '\n'); } else if (headerLine.StartsWith("User-Agent: ")) { reader = headerLine.Substring("User-Agent: ".Length).TrimEnd('\r', '\n'); } if (reader != null) { for (int j = 1; j < reader.Length; ++j) { if (Char.IsDigit(reader[j])) { reader = reader.Substring(0, j - 1); break; } } reader = reader.Trim(); if (reader.Length == 0) { break; } HashMap.Entry entry = readers.GetEntry(reader); if (entry == null) { readers[reader] = 1; } else { entry.Value = ((int)entry.Value) + 1; } break; } } } PriorityQueue queue = new PriorityQueue(); foreach (HashMap.Entry e in readers) { queue.Push((int)e.Value, e.Key); } StringBuilder readersStat = new StringBuilder(); foreach (PriorityQueue.QueueEntry e in queue) { readersStat.Append("\r\n"); readersStat.Append(e.Value); readersStat.Append(": "); readersStat.Append(e.Key); } MessageBox.Show(readersStat.ToString(), "News Readers Statistics", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { writer.ClearStatus(); } }
public PostMan( ) { _statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network); }