Beispiel #1
0
		public EditorView(ViewContent content)
		{
			try {
				this.content = content;
				
				var editorWidget = content.Control.GetNativeWidget<Gtk.Widget> ();
				editorWidget.ShowAll ();
				MonoDevelop.Components.Control previewNative;
				if (Platform.Instance.IsMac)
				{
					var editor = new GtkEmbed2(editorWidget);
					var editorEto = editor.ToEto();
					preview = new PreviewEditorView(editorEto, null, null, () => content?.WorkbenchWindow?.Document?.Editor?.Text);
					var nspreview = XamMac2Helpers.ToNative(preview, true);
					var nsviewContainer = new NSViewContainer2(nspreview);
					previewNative = nsviewContainer;
				}
				else
				{
					preview = new PreviewEditorView(editorWidget.ToEto(), null, null, () => content?.WorkbenchWindow?.Document?.Editor?.Text);
					previewNative = Gtk2Helpers.ToNative(preview, true);
				}

				var commandRouterContainer = new CommandRouterContainer (previewNative, content, true);
				commandRouterContainer.ShowAll ();
				control = commandRouterContainer;

				content.DirtyChanged += content_DirtyChanged;
				IdeApp.Workbench.ActiveDocumentChanged += Workbench_ActiveDocumentChanged;
				ContentName = content.ContentName;

			} catch (Exception ex) {
				Debug.WriteLine ($"{ex}");
			}
		}
		public WrapperDesignView  (ViewContent content)
		{
			this.content = content;
			this.contentBox = new Gtk.VBox ();
			this.contentBox.PackEnd (content.Control, true, true, 0);
			this.contentBox.ShowAll ();
			
			content.DirtyChanged += new EventHandler (OnTextDirtyChanged);

			IdeApp.Workbench.ActiveDocumentChanged += new EventHandler (OnActiveDocumentChanged);
		}
Beispiel #3
0
		public GuiBuilderView (ViewContent content, GuiBuilderWindow window): base (content)
		{
			rootName = window.Name;
			
			designerPage = new DesignerPage (window.Project);
			designerPage.Show ();
			AddButton (GettextCatalog.GetString ("Designer"), designerPage);
			
			actionsPage = new ActionGroupPage ();
			actionsPage.Show ();
			
			AttachWindow (window);
		}
		public CombinedDesignView (ViewContent content)
		{
			this.content = content;
	/* This code causes that chagnes in a version control view always select the source code view.
				if (content is IEditableTextBuffer) {
				((IEditableTextBuffer)content).CaretPositionSet += delegate {
					ShowPage (0);
				};
			}*/
			content.DirtyChanged += new EventHandler (OnTextDirtyChanged);
			
			CommandRouterContainer crc = new CommandRouterContainer (content.Control, content, true);
			crc.Show ();
			control = crc;
			
			IdeApp.Workbench.ActiveDocumentChanged += new EventHandler (OnActiveDocumentChanged);
		}
Beispiel #5
0
		void CheckRemovedFile (object sender, FileEventArgs args)
		{
			foreach (var e in args) {
				if (e.IsDirectory) {
					var views = new ViewContent [viewContentCollection.Count];
					viewContentCollection.CopyTo (views, 0);
					foreach (var content in views) {
						if (content.ContentName.StartsWith (e.FileName, StringComparison.CurrentCulture)) {
							if (content.IsDirty) {
								content.UntitledName = content.ContentName;
								content.ContentName = null;
							} else {
								((SdiWorkspaceWindow)content.WorkbenchWindow).CloseWindow (true, true);
							}
						}
					}
				} else {
					foreach (var content in viewContentCollection) {
						if (content.ContentName != null &&
							content.ContentName == e.FileName) {
							if (content.IsDirty) {
								content.UntitledName = content.ContentName;
								content.ContentName = null;
							} else {
								((SdiWorkspaceWindow)content.WorkbenchWindow).CloseWindow (true, true);
							}
							return;
						}
					}
				}
			}
		}
Beispiel #6
0
		public Properties GetStoredMemento (ViewContent content)
		{
			if (content != null && content.ContentName != null) {
				string directory = UserProfile.Current.CacheDir.Combine ("temp");
				if (!Directory.Exists(directory)) {
					Directory.CreateDirectory(directory);
				}
				string fileName = content.ContentName.Substring(3).Replace('/', '.').Replace('\\', '.').Replace(System.IO.Path.DirectorySeparatorChar, '.');
				string fullFileName = directory + System.IO.Path.DirectorySeparatorChar + fileName;
				// check the file name length because it could be more than the maximum length of a file name
				if (FileService.IsValidPath(fullFileName) && File.Exists(fullFileName)) {
					return Properties.Load (fullFileName);
				}
			}
			return null;
		}
Beispiel #7
0
		public virtual void ShowView (ViewContent content, bool bringToFront, IViewDisplayBinding binding = null, DockNotebook notebook = null)
		{
			bool isFile = content.IsFile;
			if (!isFile) {
				try {
					isFile = File.Exists (content.ContentName);
				} catch { /*Ignore*/ }
			}

			string type;
			if (isFile) {
				type = System.IO.Path.GetExtension (content.ContentName);
				var mt = DesktopService.GetMimeTypeForUri (content.ContentName);
				if (!string.IsNullOrEmpty (mt))
					type += " (" + mt + ")";
			} else
				type = "(not a file)";

			var metadata = new Dictionary<string,string> () {
				{ "FileType", type },
				{ "DisplayBinding", content.GetType ().FullName },
			};

			if (isFile)
				metadata ["DisplayBindingAndType"] = type + " | " + content.GetType ().FullName;

			Counters.DocumentOpened.Inc (metadata);

			var mimeimage = PrepareShowView (content);
			var addToControl = notebook ?? DockNotebook.ActiveNotebook ?? tabControl;
			var tab = addToControl.AddTab ();

			SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow (this, content, addToControl, tab);
			sdiWorkspaceWindow.TitleChanged += delegate { SetWorkbenchTitle (); };
			sdiWorkspaceWindow.Closed += CloseWindowEvent;
			sdiWorkspaceWindow.Show ();
			if (binding != null)
				DisplayBindingService.AttachSubWindows (sdiWorkspaceWindow, binding);

			sdiWorkspaceWindow.CreateCommandHandler ();

			tab.Content = sdiWorkspaceWindow;
			if (mimeimage != null)
				tab.Icon = mimeimage;

			if (content.Project != null)
				content.Project.NameChanged += HandleProjectNameChanged;
			if (bringToFront)
				content.WorkbenchWindow.SelectWindow();

			// The insertion of the tab may have changed the active view (or maybe not, this is checked in OnActiveWindowChanged)
			OnActiveWindowChanged (null, null);
		}
Beispiel #8
0
		private Xwt.Drawing.Image PrepareShowView (ViewContent content)
		{
			viewContentCollection.Add (content);

			if (IdeApp.Preferences.LoadDocumentUserProperties && content is IMementoCapable) {
				try {
					Properties memento = GetStoredMemento(content);
					if (memento != null) {
						((IMementoCapable)content).Memento = memento;
					}
				} catch (Exception e) {
					LoggingService.LogError ("Can't get/set memento : " + e.ToString());
				}
			}

			Xwt.Drawing.Image mimeimage = null;

			if (content.StockIconId != null ) {
				mimeimage = ImageService.GetIcon (content.StockIconId, IconSize.Menu);
			}
			else if (content.IsUntitled && content.UntitledName == null) {
				mimeimage = DesktopService.GetIconForType ("gnome-fs-regular", Gtk.IconSize.Menu);
			} else {
				mimeimage = DesktopService.GetIconForFile (content.ContentName ?? content.UntitledName, Gtk.IconSize.Menu);
			}

			return mimeimage;
		}
Beispiel #9
0
		public void CloseContent (ViewContent content)
		{
			if (viewContentCollection.Contains(content)) {
				if (content.Project != null)
					content.Project.NameChanged -= HandleProjectNameChanged;
				viewContentCollection.Remove(content);
			}
		}
Beispiel #10
0
		public ActionGroupView (ViewContent content, Stetic.ActionGroupInfo group, GuiBuilderProject project): base (content)
		{
			groupName = group.Name;
			this.project = project;
			LoadDesigner ();
		}
		public override void Dispose ()
		{
			if (content == null)
				return;

			content.DirtyChanged -= new EventHandler (OnTextDirtyChanged);
			IdeApp.Workbench.ActiveDocumentChanged -= new EventHandler (OnActiveDocumentChanged);
			content.Dispose ();
			
			content = null;
			control = null;
			
			base.Dispose ();
		}
Beispiel #12
0
        void SetCurrentView(int newIndex)
        {
            IAttachableViewContent subViewContent;

            int oldIndex = subViewNotebook.CurrentPage;

            subViewNotebook.CurrentPage = newIndex;

            if (oldIndex != -1)
            {
                subViewContent = viewContents[oldIndex] as IAttachableViewContent;
                if (subViewContent != null)
                {
                    subViewContent.Deselected();
                }
            }

            subViewContent = viewContents[newIndex] as IAttachableViewContent;
            if (subViewContent != null)
            {
                subViewContent.Selected();
            }

            DetachFromPathedDocument();

            MonoDevelop.Ide.Gui.Content.IPathedDocument pathedDocument;
            if (newIndex < 0 || newIndex == viewContents.IndexOf(ViewContent))
            {
                pathedDocument = Document != null?Document.GetContent <IPathedDocument> () : (IPathedDocument)ViewContent.GetContent(typeof(IPathedDocument));
            }
            else
            {
                pathedDocument = (IPathedDocument)viewContents[newIndex].GetContent(typeof(IPathedDocument));
            }

            if (pathedDocument != null)
            {
                AttachToPathedDocument(pathedDocument);
            }

            foreach (var t in documentToolbars)
            {
                t.Value.Container.Visible = ActiveViewContent == t.Key;
            }

            OnActiveViewContentChanged(new ActiveViewContentEventArgs(this.ActiveViewContent));
        }
        void SetCurrentView(int newIndex)
        {
            BaseViewContent subViewContent;

            int oldIndex = subViewNotebook.CurrentPage;

            subViewNotebook.CurrentPage = newIndex;

            if (oldIndex != -1)
            {
                subViewContent = viewContents[oldIndex] as BaseViewContent;
                if (subViewContent != null)
                {
                    subViewContent.OnDeselected();
                }
            }

            subViewContent = viewContents[newIndex] as BaseViewContent;

            DetachFromPathedDocument();

            MonoDevelop.Ide.Gui.Content.IPathedDocument pathedDocument;
            if (newIndex < 0 || newIndex == viewContents.IndexOf((BaseViewContent)ViewContent))
            {
                pathedDocument = Document != null?Document.GetContent <IPathedDocument> () : (IPathedDocument)ViewContent.GetContent(typeof(IPathedDocument));
            }
            else
            {
                pathedDocument = (IPathedDocument)viewContents[newIndex].GetContent(typeof(IPathedDocument));
            }

            var toolbarVisible = false;

            foreach (var t in documentToolbars)
            {
                toolbarVisible = ActiveViewContent == t.Key;
                t.Value.Container.GetNativeWidget <Gtk.Widget> ().Visible = toolbarVisible;
            }

            if (pathedDocument != null && !toolbarVisible)
            {
                AttachToPathedDocument(pathedDocument);
            }

            if (subViewContent != null)
            {
                subViewContent.OnSelected();
            }

            OnActiveViewContentChanged(new ActiveViewContentEventArgs(this.ActiveViewContent));
        }
Beispiel #14
0
        void SetCurrentView(int newIndex)
        {
            subViewNotebook.CurrentPage = newIndex;

            if (oldIndex > 0)
            {
                IAttachableViewContent secondaryViewContent = subViewContents[oldIndex - 1] as IAttachableViewContent;
                if (secondaryViewContent != null)
                {
                    secondaryViewContent.Deselected();
                }
            }

            if (subViewNotebook.CurrentPage > 0)
            {
                IAttachableViewContent secondaryViewContent = subViewContents[subViewNotebook.CurrentPage - 1] as IAttachableViewContent;
                if (secondaryViewContent != null)
                {
                    secondaryViewContent.Selected();
                }
            }
            oldIndex = subViewNotebook.CurrentPage;
            DetachFromPathedDocument();

            MonoDevelop.Ide.Gui.Content.IPathedDocument pathedDocument;
            if (oldIndex <= 0)
            {
                pathedDocument = Document != null?Document.GetContent <MonoDevelop.Ide.Gui.Content.IPathedDocument> () : ViewContent.GetContent <MonoDevelop.Ide.Gui.Content.IPathedDocument> ();
            }
            else
            {
                pathedDocument = subViewContents[oldIndex - 1].GetContent <MonoDevelop.Ide.Gui.Content.IPathedDocument> ();
            }

            if (pathedDocument != null)
            {
                AttachToPathedDocument(pathedDocument);
            }
            OnActiveViewContentChanged(new ActiveViewContentEventArgs(this.ActiveViewContent));
        }