Exemplo n.º 1
0
        protected void SwitchedToView(IViewContent newView)
        {
            if (currentView != null)
            {
                if (newView.SupportsSwitchToThisWithoutSaveLoad(this, currentView) ||
                    currentView.SupportsSwitchFromThisWithoutSaveLoad(this, newView))
                {
                    // switch without Save/Load
                    currentView.SwitchFromThisWithoutSaveLoad(this, newView);
                    newView.SwitchToThisWithoutSaveLoad(this, currentView);

                    currentView = newView;
                    return;
                }
            }
            if (currentView != null)
            {
                SaveCurrentView();
            }
            try {
                inLoadOperation = true;
                Properties memento = GetMemento(newView);
                using (Stream sourceStream = OpenRead()) {
                    currentView = newView;
                    fileData    = null;
                    newView.Load(this, sourceStream);
                }
                RestoreMemento(newView, memento);
            } finally {
                inLoadOperation = false;
            }
        }
		public override void Load(OpenedFile file, Stream stream)
		{
			if (file != this.PrimaryFile)
				throw new ArgumentException("file must be the primary file of the primary view content, override Load() to handle other files");
			primaryViewContent.Load(file, stream);
			LoadFromPrimary();
		}
Exemplo n.º 3
0
        /// <summary>
        /// Forces initialization of the specified view.
        /// </summary>
        public virtual void ForceInitializeView(IViewContent view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            if (currentView != view)
            {
                if (currentView == null)
                {
                    SwitchedToView(view);
                }
                else
                {
                    try {
                        inLoadOperation = true;
                        using (Stream sourceStream = OpenRead()) {
                            view.Load(this, sourceStream);
                        }
                    } finally {
                        inLoadOperation = false;
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void SwitchedToView(IViewContent newView)
        {
            if (newView == null)
            {
                throw new ArgumentNullException("newView");
            }
            if (currentView == newView)
            {
                return;
            }
            if (currentView != null)
            {
                if (newView.SupportsSwitchToThisWithoutSaveLoad(this, currentView) ||
                    currentView.SupportsSwitchFromThisWithoutSaveLoad(this, newView))
                {
                    // switch without Save/Load
                    currentView.SwitchFromThisWithoutSaveLoad(this, newView);
                    newView.SwitchToThisWithoutSaveLoad(this, currentView);

                    currentView = newView;
                    return;
                }
            }
            if (currentView != null)
            {
                SaveCurrentView();
            }
            try
            {
                inLoadOperation = true;
                VelerSoftware.SZC.Debugger.Core.Properties memento = GetMemento(newView);
                using (Stream sourceStream = OpenRead())
                {
                    IViewContent oldView = currentView;
                    try
                    {
                        currentView = newView;
                        // don't reset fileData if the file is untitled, because OpenRead() wouldn't be able to read it otherwise
                        if (this.IsUntitled == false)
                        {
                            fileData = null;
                        }
                        newView.Load(this, sourceStream);
                    }
                    catch
                    {
                        // stay with old view in case of exceptions
                        currentView = oldView;
                        throw;
                    }
                }
                RestoreMemento(newView, memento);
            }
            finally
            {
                inLoadOperation = false;
            }
        }
Exemplo n.º 5
0
        public void SwitchedToView(IViewContent newView)
        {
            if (newView == null)
            {
                throw new ArgumentNullException("newView");
            }
            if (currentView == newView)
            {
                return;
            }
            if (currentView != null)
            {
                if (newView.SupportsSwitchToThisWithoutSaveLoad(this, currentView) ||
                    currentView.SupportsSwitchFromThisWithoutSaveLoad(this, newView))
                {
                    // switch without Save/Load
                    currentView.SwitchFromThisWithoutSaveLoad(this, newView);
                    newView.SwitchToThisWithoutSaveLoad(this, currentView);

                    currentView = newView;
                    return;
                }
                SaveCurrentView();
            }
            try {
                inLoadOperation = true;
                Properties memento = GetMemento(newView);
                using (Stream sourceStream = OpenRead()) {
                    IViewContent oldView = currentView;
                    bool         success = false;
                    try {
                        currentView = newView;
                        // don't reset fileData if the file is untitled, because OpenRead() wouldn't be able to read it otherwise
                        if (this.IsUntitled == false)
                        {
                            fileData = null;
                        }
                        newView.Load(this, sourceStream);
                        success = true;
                    } finally {
                        // Use finally instead of catch+rethrow so that the debugger
                        // breaks at the original crash location.
                        if (!success)
                        {
                            // stay with old view in case of exceptions
                            currentView = oldView;
                        }
                    }
                }
                RestoreMemento(newView, memento);
            } finally {
                inLoadOperation = false;
            }
        }
Exemplo n.º 6
0
 void ReloadFromDiskInternal()
 {
     fileData = null;
     if (currentView != null)
     {
         try {
             inLoadOperation = true;
             Properties memento = GetMemento(currentView);
             using (Stream sourceStream = OpenRead()) {
                 currentView.Load(this, sourceStream);
             }
             IsDirty = false;
             RestoreMemento(currentView, memento);
         } finally {
             inLoadOperation = false;
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Forces initialization of the specified view.
        /// </summary>
        public virtual void ForceInitializeView(IViewContent view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            bool success = false;

            try {
                if (currentView != view)
                {
                    if (currentView == null)
                    {
                        SwitchedToView(view);
                    }
                    else
                    {
                        try {
                            inLoadOperation = true;
                            using (Stream sourceStream = OpenRead()) {
                                view.Load(this, sourceStream);
                            }
                        } finally {
                            inLoadOperation = false;
                        }
                    }
                }
                success = true;
            } finally {
                // Only in case of exceptions:
                // (try-finally with bool is better than try-catch-rethrow because it causes the debugger to stop
                // at the original error location, not at the rethrow)
                if (!success)
                {
                    view.Dispose();
                }
            }
        }
 public override void Load(string fileName)
 {
     ContentName = fileName;
     content.Load(fileName);
 }
Exemplo n.º 9
0
		public void SwitchedToView(IViewContent newView)
		{
			if (newView == null)
				throw new ArgumentNullException("newView");
			if (currentView == newView)
				return;
			if (currentView != null) {
				if (newView.SupportsSwitchToThisWithoutSaveLoad(this, currentView)
				    || currentView.SupportsSwitchFromThisWithoutSaveLoad(this, newView))
				{
					// switch without Save/Load
					currentView.SwitchFromThisWithoutSaveLoad(this, newView);
					newView.SwitchToThisWithoutSaveLoad(this, currentView);
					
					currentView = newView;
					return;
				}
				SaveCurrentView();
			}
			try {
				inLoadOperation = true;
				Properties memento = GetMemento(newView);
				using (Stream sourceStream = OpenRead()) {
					IViewContent oldView = currentView;
					bool success = false;
					try {
						currentView = newView;
						// don't reset fileData if the file is untitled, because OpenRead() wouldn't be able to read it otherwise
						if (this.IsUntitled == false)
							fileData = null;
						newView.Load(this, sourceStream);
						success = true;
					} finally {
						// Use finally instead of catch+rethrow so that the debugger
						// breaks at the original crash location.
						if (!success) {
							// stay with old view in case of exceptions
							currentView = oldView;
						}
					}
				}
				RestoreMemento(newView, memento);
			} finally {
				inLoadOperation = false;
			}
		}
Exemplo n.º 10
0
		/// <summary>
		/// Forces initialization of the specified view.
		/// </summary>
		public virtual void ForceInitializeView(IViewContent view)
		{
			if (view == null)
				throw new ArgumentNullException("view");
			
			try {
				if (currentView != view) {
					if (currentView == null) {
						SwitchedToView(view);
					} else {
						try {
							inLoadOperation = true;
							using (Stream sourceStream = OpenRead()) {
								view.Load(this, sourceStream);
							}
						} finally {
							inLoadOperation = false;
						}
					}
				}
			} catch (Exception) {
				view.Dispose();
				throw;
			}
		}
Exemplo n.º 11
0
        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;
        }
Exemplo n.º 12
0
 public override void Load(string fileName)
 {
     preview.SetBuilder(fileName);
     content.Load(fileName);
     base.ContentName = fileName;
 }
Exemplo n.º 13
0
        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;
        }
Exemplo n.º 14
0
		public void SwitchedToView(IViewContent newView)
		{
			if (newView == null)
				throw new ArgumentNullException("newView");
			if (currentView == newView)
				return;
			if (currentView != null) {
				if (newView.SupportsSwitchToThisWithoutSaveLoad(this, currentView)
				    || currentView.SupportsSwitchFromThisWithoutSaveLoad(this, newView))
				{
					// switch without Save/Load
					currentView.SwitchFromThisWithoutSaveLoad(this, newView);
					newView.SwitchToThisWithoutSaveLoad(this, currentView);
					
					currentView = newView;
					return;
				}
			}
			if (currentView != null) {
				SaveCurrentView();
			}
			try {
				inLoadOperation = true;
				Properties memento = GetMemento(newView);
				using (Stream sourceStream = OpenRead()) {
					currentView = newView;
					// don't reset fileData if the file is untitled, because OpenRead() wouldn't be able to read it otherwise
					if (this.IsUntitled == false)
						fileData = null;
					newView.Load(this, sourceStream);
				}
				RestoreMemento(newView, memento);
			} finally {
				inLoadOperation = false;
			}
		}
Exemplo n.º 15
0
        /// <summary>
        /// Forces initialization of the specified view.
        /// </summary>
        public virtual void ForceInitializeView(IViewContent view)
        {
            if (view == null)
                throw new ArgumentNullException("view");

            bool success = false;
            try {
                if (currentView != view) {
                    if (currentView == null) {
                        SwitchedToView(view);
                    } else {
                        try {
                            inLoadOperation = true;
                            using (Stream sourceStream = OpenRead()) {
                                view.Load(this, sourceStream);
                            }
                        } finally {
                            inLoadOperation = false;
                        }
                    }
                }
                success = true;
            } finally {
                // Only in case of exceptions:
                // (try-finally with bool is better than try-catch-rethrow because it causes the debugger to stop
                // at the original error location, not at the rethrow)
                if (!success) {
                    view.Dispose();
                }
            }
        }
Exemplo n.º 16
0
		protected void SwitchedToView(IViewContent newView)
		{
			if (currentView != null) {
				if (newView.SupportsSwitchToThisWithoutSaveLoad(this, currentView)
				    || currentView.SupportsSwitchFromThisWithoutSaveLoad(this, newView))
				{
					// switch without Save/Load
					currentView.SwitchFromThisWithoutSaveLoad(this, newView);
					newView.SwitchToThisWithoutSaveLoad(this, currentView);
					
					currentView = newView;
					return;
				}
			}
			if (currentView != null) {
				SaveCurrentView();
			}
			try {
				inLoadOperation = true;
				Properties memento = GetMemento(newView);
				using (Stream sourceStream = OpenRead()) {
					currentView = newView;
					fileData = null;
					newView.Load(this, sourceStream);
				}
				RestoreMemento(newView, memento);
			} finally {
				inLoadOperation = false;
			}
		}
Exemplo n.º 17
0
 public override void Load(string fileName)
 {
     ShowPage(1);
     ContentName = fileName;
     content.Load(fileName);
 }
 public override void Load(FileOpenInformation fileOpenInformation)
 {
     ContentName = fileOpenInformation.FileName;
     content.Load(ContentName);
 }