~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-02-05 10:49:36 UTC
  • mto: (10.3.1)
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: package-import@ubuntu.com-20120205104936-4ujoylapu24cquuo
Tags: upstream-2.8.6.3+dfsg
ImportĀ upstreamĀ versionĀ 2.8.6.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
343
343
                {
344
344
                        if (string.IsNullOrEmpty (fileName))
345
345
                                return null;
 
346
                        
346
347
                        using (Counters.OpenDocumentTimer.BeginTiming ("Opening file " + fileName)) {
347
348
                                NavigationHistoryService.LogActiveDocument ();
348
349
                                
349
 
                                Counters.OpenDocumentTimer.Trace ("Look for open document");
350
 
                                
351
 
                                foreach (Document doc in Documents) {
352
 
                                        IBaseViewContent vcFound = null;
353
 
                                        int vcIndex = 0;
354
 
                                        
355
 
                                        //search all ViewContents to see if they can "re-use" this filename
356
 
                                        if (doc.Window.ViewContent.CanReuseView (fileName))
357
 
                                                vcFound = doc.Window.ViewContent;
358
 
                                        
359
 
                                        
360
 
                                        //old method as fallback
361
 
                                        if ((vcFound == null) && (doc.FileName == fileName))
362
 
                                                vcFound = doc.Window.ViewContent;
363
 
                                        
364
 
                                        //if found, select window and jump to line
365
 
                                        if (vcFound != null) {
366
 
                                                IEditableTextBuffer ipos = vcFound.GetContent<IEditableTextBuffer> ();
367
 
                                                if (line >= 1 && ipos != null) {
368
 
                                                        ipos.SetCaretTo (line, column >= 1 ? column : 1, options.HasFlag (OpenDocumentOptions.HighlightCaretLine), options.HasFlag (OpenDocumentOptions.CenterCaretLine));
369
 
                                                }
370
 
                                                
371
 
                                                if (options.HasFlag (OpenDocumentOptions.BringToFront)) {
372
 
                                                        doc.Select ();
373
 
                                                        doc.Window.SwitchView (vcIndex);
374
 
                                                        doc.Window.SelectWindow ();
375
 
                                                        NavigationHistoryService.LogActiveDocument ();
376
 
                                                        Present ();
377
 
                                                }
378
 
                                                return doc;
 
350
                                if (options.HasFlag (OpenDocumentOptions.TryToReuseViewer)) {
 
351
                                        Counters.OpenDocumentTimer.Trace ("Look for open document");
 
352
                                        
 
353
                                        foreach (Document doc in Documents) {
 
354
                                                IBaseViewContent vcFound = null;
 
355
                                                int vcIndex = 0;
 
356
                                                
 
357
                                                //search all ViewContents to see if they can "re-use" this filename
 
358
                                                if (doc.Window.ViewContent.CanReuseView (fileName))
 
359
                                                        vcFound = doc.Window.ViewContent;
 
360
                                                
 
361
                                                //old method as fallback
 
362
                                                if ((vcFound == null) && (doc.FileName == fileName))
 
363
                                                        vcFound = doc.Window.ViewContent;
 
364
                                                
 
365
                                                //if found, select window and jump to line
 
366
                                                if (vcFound != null) {
 
367
                                                        IEditableTextBuffer ipos = vcFound.GetContent<IEditableTextBuffer> ();
 
368
                                                        if (line >= 1 && ipos != null) {
 
369
                                                                ipos.SetCaretTo (line, column >= 1 ? column : 1, options.HasFlag (OpenDocumentOptions.HighlightCaretLine), options.HasFlag (OpenDocumentOptions.CenterCaretLine));
 
370
                                                        }
 
371
                                                        
 
372
                                                        if (options.HasFlag (OpenDocumentOptions.BringToFront)) {
 
373
                                                                doc.Select ();
 
374
                                                                doc.Window.SwitchView (vcIndex);
 
375
                                                                doc.Window.SelectWindow ();
 
376
                                                                NavigationHistoryService.LogActiveDocument ();
 
377
                                                                Present ();
 
378
                                                        }
 
379
                                                        return doc;
 
380
                                                }
379
381
                                        }
380
382
                                }
381
383
                                
699
701
                                        monitor.ReportError (GettextCatalog.GetString ("{0} is a directory", fileName), null);
700
702
                                        return;
701
703
                                }
 
704
                                
702
705
                                // test, if file fileName exists
703
706
                                if (!origName.StartsWith("http://")) {
704
707
                                        // test, if an untitled file should be opened
717
720
                                        }
718
721
                                }
719
722
                                
720
 
                                foreach (Document doc in Documents) {
721
 
                                        if (doc.FileName == fileName) {
722
 
                                                if (openFileInfo.Options.HasFlag (OpenDocumentOptions.BringToFront)) {
723
 
                                                        doc.Select ();
724
 
                                                        doc.RunWhenLoaded (delegate {
725
 
                                                                IEditableTextBuffer ipos = doc.GetContent <IEditableTextBuffer> ();
726
 
                                                                if (openFileInfo.Line > 0 && ipos != null) {
727
 
                                                                        ipos.SetCaretTo (openFileInfo.Line, Math.Max (1, openFileInfo.Column), openFileInfo.Options.HasFlag (OpenDocumentOptions.HighlightCaretLine));
728
 
                                                                }
729
 
                                                        });
730
 
                                                }
731
 
                                                openFileInfo.NewContent = doc.Window.ViewContent;
732
 
                                                return;
733
 
                                        }
734
 
                                }
735
 
                                
736
723
                                Counters.OpenDocumentTimer.Trace ("Looking for binding");
737
724
                                
738
725
                                IDisplayBinding binding = null;
756
743
                                                viewBinding = binding as IViewDisplayBinding;
757
744
                                        }
758
745
                                }
 
746
                                
759
747
                                try {
760
748
                                        if (binding != null) {
761
749
                                                if (viewBinding != null)  {
1075
1063
                                fileInfo.ProgressMonitor.ReportError (GettextCatalog.GetString ("The file '{0}' could not be opened.", fileName), ex);
1076
1064
                                return;
1077
1065
                        }
 
1066
                        
1078
1067
                        // content got re-used
1079
1068
                        if (newContent.WorkbenchWindow != null) {
1080
1069
                                newContent.WorkbenchWindow.SelectWindow ();
1092
1081
                        IEditableTextBuffer ipos = newContent.GetContent<IEditableTextBuffer> ();
1093
1082
                        if (fileInfo.Line > 0 && ipos != null)
1094
1083
                                JumpToLine ();
 
1084
                        
1095
1085
                        fileInfo.NewContent = newContent;
1096
1086
                }
1097
1087
                
1113
1103
                HighlightCaretLine = 1 << 2,
1114
1104
                OnlyInternalViewer = 1 << 3,
1115
1105
                OnlyExternalViewer = 1 << 4,
 
1106
                TryToReuseViewer = 1 << 5,
1116
1107
                
1117
 
                Default = BringToFront | CenterCaretLine | HighlightCaretLine
 
1108
                Default = BringToFront | CenterCaretLine | HighlightCaretLine | TryToReuseViewer,
 
1109
                Debugger = BringToFront | CenterCaretLine | TryToReuseViewer
1118
1110
        }
1119
1111
}