public Document OpenDocument(IViewContent content, bool bringToFront) { workbench.ShowView(content, bringToFront); if (bringToFront) { Present(); } return(WrapDocument(content.WorkbenchWindow)); }
public void Invoke(string fileName) { try { Counters.OpenDocumentTimer.Trace("Creating content"); string mimeType = DesktopService.GetMimeTypeForUri(fileName); if (binding.CanHandle(fileName, mimeType, project)) { newContent = binding.CreateContent(fileName, mimeType, project); } else { fileInfo.ProgressMonitor.ReportError(GettextCatalog.GetString("The file '{0}' could not be opened.", fileName), null); } if (newContent == null) { fileInfo.ProgressMonitor.ReportError(GettextCatalog.GetString("The file '{0}' could not be opened.", fileName), null); return; } if (project != null) { newContent.Project = project; } Counters.OpenDocumentTimer.Trace("Loading file"); IEncodedTextContent etc = newContent.GetContent <IEncodedTextContent> (); try { if (fileInfo.Encoding != null && etc != null) { etc.Load(fileName, fileInfo.Encoding); } else { newContent.Load(fileName); } } catch (InvalidEncodingException iex) { fileInfo.ProgressMonitor.ReportError(GettextCatalog.GetString("The file '{0}' could not opened. {1}", fileName, iex.Message), null); return; } catch (OverflowException oex) { fileInfo.ProgressMonitor.ReportError(GettextCatalog.GetString("The file '{0}' could not opened. File too large.", fileName), null); return; } } catch (Exception ex) { fileInfo.ProgressMonitor.ReportError(GettextCatalog.GetString("The file '{0}' could not be opened.", fileName), ex); return; } // content got re-used if (newContent.WorkbenchWindow != null) { newContent.WorkbenchWindow.SelectWindow(); fileInfo.NewContent = newContent; return; } Counters.OpenDocumentTimer.Trace("Showing view"); workbench.ShowView(newContent, fileInfo.Options.HasFlag(OpenDocumentOptions.BringToFront)); DisplayBindingService.AttachSubWindows(newContent.WorkbenchWindow); newContent.WorkbenchWindow.DocumentType = binding.Name; IEditableTextBuffer ipos = newContent.GetContent <IEditableTextBuffer> (); if (fileInfo.Line > 0 && ipos != null) { if (newContent.Control.IsRealized) { JumpToLine(); } else { newContent.Control.Realized += HandleNewContentControlRealized; } } fileInfo.NewContent = newContent; }
public void Invoke(string fileName) { try { Counters.OpenDocumentTimer.Trace("Creating content"); if (binding.CanCreateContentForUri(fileName)) { newContent = binding.CreateContentForUri(fileName); } else { string mimeType = DesktopService.GetMimeTypeForUri(fileName); if (!binding.CanCreateContentForMimeType(mimeType)) { fileInfo.ProgressMonitor.ReportError(GettextCatalog.GetString("The file '{0}' could not be opened.", fileName), null); return; } newContent = binding.CreateContentForMimeType(mimeType, null); } if (newContent == null) { fileInfo.ProgressMonitor.ReportError(GettextCatalog.GetString("The file '{0}' could not be opened.", fileName), null); return; } if (project != null) { newContent.Project = project; } Counters.OpenDocumentTimer.Trace("Loading file"); IEncodedTextContent etc = newContent.GetContent <IEncodedTextContent> (); if (fileInfo.Encoding != null && etc != null) { etc.Load(fileName, fileInfo.Encoding); } else { newContent.Load(fileName); } } catch (Exception ex) { fileInfo.ProgressMonitor.ReportError(GettextCatalog.GetString("The file '{0}' could not be opened.", fileName), ex); return; } // content got re-used if (newContent.WorkbenchWindow != null) { newContent.WorkbenchWindow.SelectWindow(); fileInfo.NewContent = newContent; return; } Counters.OpenDocumentTimer.Trace("Showing view"); workbench.ShowView(newContent, fileInfo.BringToFront); DisplayBindingService.AttachSubWindows(newContent.WorkbenchWindow); newContent.WorkbenchWindow.DocumentType = binding.Name; IEditableTextBuffer ipos = newContent.GetContent <IEditableTextBuffer> (); if (fileInfo.Line != -1 && ipos != null) { GLib.Timeout.Add(10, new GLib.TimeoutHandler(JumpToLine)); } fileInfo.NewContent = newContent; }