private void AttachSecondaryViewContent(IBaseViewContent viewContent)
        {
            viewContent.WorkbenchWindow = this;
            TabPage newPage = new TabPage(StringParser.Parse(viewContent.TabPageText));

            newPage.Tag = viewContent;
            viewContent.Control.Dock = DockStyle.Fill;
            newPage.Controls.Add(viewContent.Control);
            viewTabControl.TabPages.Add(newPage);
        }
 void viewTabControlDeselected(object sender, TabControlEventArgs e)
 {
     if (e.Action == TabControlAction.Deselected && e.TabPageIndex >= 0)
     {
         IBaseViewContent secondaryViewContent = GetSubViewContent(e.TabPageIndex);
         if (secondaryViewContent != null)
         {
             secondaryViewContent.Deselected();
         }
     }
 }
Exemple #3
0
        public CocoStudio.Core.Document OpenDocument(FilePath file, Project project, bool bringToFront = true)
        {
            if (string.IsNullOrEmpty(file.FileName))
            {
                return((CocoStudio.Core.Document)null);
            }
            foreach (CocoStudio.Core.Document document in this.Documents)
            {
                IBaseViewContent baseViewContent = (IBaseViewContent)null;
                if (document.Window.ViewContent.CanReuseView((string)file))
                {
                    baseViewContent = (IBaseViewContent)document.Window.ViewContent;
                }
                if (baseViewContent != null)
                {
                    if (project != null && document.Project != project)
                    {
                        document.SetProject(project);
                    }
                    if (bringToFront)
                    {
                        document.Select();
                        document.Window.SelectWindow();
                    }
                    return(document);
                }
            }
            IProgressMonitor statusProgressMonitor = this.ProgressMonitors.GetStatusProgressMonitor();
            FileOpenInfo     openFileInfo          = new FileOpenInfo(file, project, bringToFront);

            this.RealOpenFile(statusProgressMonitor, openFileInfo);
            statusProgressMonitor.Dispose();
            if (openFileInfo.NewContent == null)
            {
                return((CocoStudio.Core.Document)null);
            }
            CocoStudio.Core.Document doc = this.WrapDocument(openFileInfo.NewContent.WorkbenchWindow);
            if (doc != null && openFileInfo.BringToFront)
            {
                doc.RunWhenLoaded((System.Action)(() =>
                {
                    if (doc.Window == null)
                    {
                        return;
                    }
                    doc.Window.SelectWindow();
                }));
            }
            doc.SetProject(project);
            return(doc);
        }
 void viewTabControlSelected(object sender, TabControlEventArgs e)
 {
     if (e.Action == TabControlAction.Selected && e.TabPageIndex >= 0)
     {
         IBaseViewContent secondaryViewContent = GetSubViewContent(e.TabPageIndex);
         if (secondaryViewContent != null)
         {
             secondaryViewContent.SwitchedTo();
             secondaryViewContent.Selected();
         }
     }
     WorkbenchSingleton.Workbench.WorkbenchLayout.OnActiveWorkbenchWindowChanged(EventArgs.Empty);
     ActiveViewContent.Control.Focus();
 }
        public DocumentToolbar GetToolbar(IBaseViewContent targetView)
        {
            DocumentToolbar toolbar;

            if (!documentToolbars.TryGetValue(targetView, out toolbar))
            {
                toolbar = new DocumentToolbar();
                documentToolbars [targetView] = toolbar;
                box.PackStart(toolbar.Container, false, false, 0);
                box.ReorderChild(toolbar.Container, 0);
                toolbar.Visible = (targetView == ActiveViewContent);
            }
            return(toolbar);
        }
		// All line and column numbers are 1-based
		
		public static TextEditor GetTextEditor (IBaseViewContent content)
		{
			IEditableTextBuffer tb = (IEditableTextBuffer) content.GetContent (typeof(IEditableTextBuffer));
			if (tb == null)
				return null;
			
			TextEditor ed = new TextEditor ();
			ed.textBuffer = tb;
			ed.bookmarkBuffer = (IBookmarkBuffer) content.GetContent (typeof(IBookmarkBuffer));
			ed.encodedTextContent = (IEncodedTextContent) content.GetContent (typeof(IEncodedTextContent));
			ed.completionWidget = (ICompletionWidget) content.GetContent (typeof(ICompletionWidget));
			ed.clipboardHandler = (IClipboardHandler) content.GetContent (typeof(IClipboardHandler));
			return ed;
		}
Exemple #7
0
 DocumentView WrapView(IBaseViewContent content)
 {
     if (content == null)
     {
         return(null);
     }
     if (views != null)
     {
         return(views.FirstOrDefault(v => v.BaseContent == content) ?? new DocumentView(this, content));
     }
     else
     {
         return(new DocumentView(this, content));
     }
 }
Exemple #8
0
        static object[] GetWorkbench()
        {
            IWorkbenchWindow activeWorkbenchWindow = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;

            if (activeWorkbenchWindow == null)
            {
                return(null);
            }
            IBaseViewContent activeViewContent = activeWorkbenchWindow.ActiveViewContent;

            if (activeViewContent == null)
            {
                return(null);
            }
            return(new object[] { activeViewContent, activeWorkbenchWindow.ViewContent });
        }
Exemple #9
0
        // All line and column numbers are 1-based

        public static TextEditor GetTextEditor(IBaseViewContent content)
        {
            IEditableTextBuffer tb = (IEditableTextBuffer)content.GetContent(typeof(IEditableTextBuffer));

            if (tb == null)
            {
                return(null);
            }

            TextEditor ed = new TextEditor();

            ed.textBuffer         = tb;
            ed.bookmarkBuffer     = (IBookmarkBuffer)content.GetContent(typeof(IBookmarkBuffer));
            ed.encodedTextContent = (IEncodedTextContent)content.GetContent(typeof(IEncodedTextContent));
            ed.completionWidget   = (ICompletionWidget)content.GetContent(typeof(ICompletionWidget));
            ed.clipboardHandler   = (IClipboardHandler)content.GetContent(typeof(IClipboardHandler));
            return(ed);
        }
        protected Tab InsertButton(int index, string label, IBaseViewContent viewContent)
        {
            CheckCreateSubViewToolbar();
            updating = true;

            var addedContent = (index == 0 || subViewToolbar.TabCount == 0) && IdeApp.Workbench.ActiveDocument == Document;
            var widgetBox    = new Gtk.VBox();
            var tab          = new Tab(subViewToolbar, label)
            {
                Tag = viewContent
            };

            // If this is the current displayed document we need to add the control immediately as the tab is already active.
            if (addedContent)
            {
                widgetBox.Add(viewContent.Control);
                widgetBox.Show();
            }

            subViewToolbar.InsertTab(index, tab);
            subViewNotebook.InsertPage(widgetBox, new Gtk.Label(), index);
            tab.Activated += (sender, e) => {
                if (!addedContent)
                {
                    widgetBox.Add(viewContent.Control);
                    widgetBox.Show();
                    addedContent = true;
                }

                int page = viewContents.IndexOf((IBaseViewContent)tab.Tag);
                SetCurrentView(page);
                QueueDraw();
            };

            EnsureToolbarBoxSeparator();
            updating = false;

            if (index == 0)
            {
                ShowPage(0);
            }

            return(tab);
        }
Exemple #11
0
        protected Tab AddButton(string label, IBaseViewContent viewContent)
        {
            CheckCreateSubViewToolbar();
            updating = true;

            Tab tab = new Tab(subViewToolbar, label);

            tab.Tag        = subViewToolbar.TabCount;
            tab.Activated += (sender, e) => { SetCurrentView((int)((Tab)sender).Tag); QueueDraw(); };
            subViewToolbar.AddTab(tab);

            Gtk.VBox widgetBox = new Gtk.VBox();
            widgetBox.Realized += delegate {
                widgetBox.Add(viewContent.Control);
            };

            subViewNotebook.AppendPage(widgetBox, new Gtk.Label());
            widgetBox.ShowAll();

            EnsureToolbarBoxSeparator();
            updating = false;
            return(tab);
        }
Exemple #12
0
        protected Tab AddButton(string label, IBaseViewContent viewContent)
        {
            CheckCreateSubViewToolbar();
            updating = true;

            var addedContent = subViewToolbar.TabCount == 0 && IdeApp.Workbench.ActiveDocument == Document;
            var widgetBox    = new Gtk.VBox();
            var tab          = new Tab(subViewToolbar, label)
            {
                Tag = subViewToolbar.TabCount
            };

            // If this is the current displayed document we need to add the control immediately as the tab is already active.
            if (addedContent)
            {
                widgetBox.Add(viewContent.Control);
                widgetBox.Show();
            }

            subViewToolbar.AddTab(tab);
            subViewNotebook.AppendPage(widgetBox, new Gtk.Label());
            tab.Activated += (sender, e) => {
                if (!addedContent)
                {
                    widgetBox.Add(viewContent.Control);
                    widgetBox.Show();
                }
                addedContent = true;
                SetCurrentView((int)((Tab)sender).Tag);
                QueueDraw();
            };

            EnsureToolbarBoxSeparator();
            updating = false;
            return(tab);
        }
Exemple #13
0
        internal Document OpenDocument(FilePath fileName, int line, int column, OpenDocumentOptions options, string encoding, IViewDisplayBinding binding)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return(null);
            }
            using (Counters.OpenDocumentTimer.BeginTiming("Opening file " + fileName)) {
                NavigationHistoryService.LogActiveDocument();

                Counters.OpenDocumentTimer.Trace("Look for open document");

                foreach (Document doc in Documents)
                {
                    IBaseViewContent vcFound = null;
                    int vcIndex = 0;

                    //search all ViewContents to see if they can "re-use" this filename
                    if (doc.Window.ViewContent.CanReuseView(fileName))
                    {
                        vcFound = doc.Window.ViewContent;
                    }


                    //old method as fallback
                    if ((vcFound == null) && (doc.FileName == fileName))
                    {
                        vcFound = doc.Window.ViewContent;
                    }

                    //if found, select window and jump to line
                    if (vcFound != null)
                    {
                        IEditableTextBuffer ipos = vcFound.GetContent <IEditableTextBuffer> ();
                        if (line >= 1 && ipos != null)
                        {
                            ipos.SetCaretTo(line, column >= 1 ? column : 1, options.HasFlag(OpenDocumentOptions.HighlightCaretLine));
                        }

                        if (options.HasFlag(OpenDocumentOptions.BringToFront))
                        {
                            doc.Select();
                            doc.Window.SwitchView(vcIndex);
                            doc.Window.SelectWindow();
                            NavigationHistoryService.LogActiveDocument();
                            Present();
                        }
                        return(doc);
                    }
                }

                Counters.OpenDocumentTimer.Trace("Initializing monitor");
                IProgressMonitor pm = ProgressMonitors.GetStatusProgressMonitor(GettextCatalog.GetString("Opening {0}", fileName), Stock.OpenFileIcon, true);
                var openFileInfo    = new FileOpenInformation()
                {
                    ProgressMonitor = pm,
                    FileName        = fileName,
                    Options         = options,
                    Line            = line,
                    Column          = column,
                    DisplayBinding  = binding,
                    Encoding        = encoding
                };
                RealOpenFile(openFileInfo);

                if (!pm.AsyncOperation.Success)
                {
                    return(null);
                }

                if (openFileInfo.NewContent != null)
                {
                    Counters.OpenDocumentTimer.Trace("Wrapping document");
                    Document doc = WrapDocument(openFileInfo.NewContent.WorkbenchWindow);
                    if (options.HasFlag(OpenDocumentOptions.BringToFront))
                    {
                        Present();
                        doc.RunWhenLoaded(() => doc.Window.SelectWindow());
                    }
                    return(doc);
                }
                else
                {
                    return(null);
                }
            }
        }
 public ActiveViewContentEventArgs(IBaseViewContent content)
 {
     this.content = content;
 }
 protected Tab AddButton(string label, IBaseViewContent viewContent)
 {
     return(InsertButton(viewContents.Count, label, viewContent));
 }
		public ActiveViewContentEventArgs (IBaseViewContent content)
		{
			this.content = content;
		}
Exemple #17
0
 DocumentToolbar IWorkbenchWindow.GetToolbar(IBaseViewContent targetView)
 {
     throw new System.NotImplementedException();
 }
Exemple #18
0
 public DocumentToolbar GetToolbar(IBaseViewContent targetView)
 {
     throw new NotImplementedException();
 }
 internal DocumentView(Document doc, IBaseViewContent content)
 {
     document     = doc;
     this.content = content;
 }
 public DocumentToolbar GetToolbar(IBaseViewContent targetView)
 {
     return(null);
 }
		private void AttachSecondaryViewContent(IBaseViewContent viewContent)
		{
			viewContent.WorkbenchWindow = this;
			TabPage newPage = new TabPage(StringParser.Parse(viewContent.TabPageText));
			newPage.Tag = viewContent;
			viewContent.Control.Dock = DockStyle.Fill;
			newPage.Controls.Add(viewContent.Control);
			viewTabControl.TabPages.Add(newPage);
		}
		protected Tab AddButton (string label, IBaseViewContent viewContent)
		{
			CheckCreateSubViewToolbar ();
			updating = true;
			
			Tab tab = new Tab (subViewToolbar, label);
			tab.Tag = subViewToolbar.TabCount;
			tab.Activated += (sender, e) => { SetCurrentView ((int)((Tab)sender).Tag); QueueDraw (); };
			subViewToolbar.AddTab (tab);
			
			Gtk.VBox widgetBox = new Gtk.VBox ();
			widgetBox.Realized += delegate {
				widgetBox.Add (viewContent.Control);
			};
			
			subViewNotebook.AppendPage (widgetBox, new Gtk.Label ());
			widgetBox.ShowAll ();
			
			EnsureToolbarBoxSeparator ();
			updating = false;
			return tab;
		}