Example #1
0
		public override Task Load (FileOpenInformation fileOpenInformation)
		{
			ContentName = fileOpenInformation.FileName;
			entry.Load (fileOpenInformation.FileName);
			widget.DesktopEntry = entry;
			return Task.FromResult (true);
		}
		public override Task Load (FileOpenInformation fileOpenInformation)
		{
			ContentName = GettextCatalog.GetString ("Assembly Browser");
			var loader = widget.AddReferenceByFileName (fileOpenInformation.FileName);
			widget.SelectAssembly (loader.UnresolvedAssembly.AssemblyName);
			return Task.FromResult (true);
		}
		public StartupInfo (IEnumerable<string> args)
		{
			foreach (string arg in args) {
				string a = arg;
				Match fileMatch = FileExpression.Match (a);
				
				// this does not yet work with relative paths
				if (a[0] == '~') {
					a = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), a.Substring (1));
				}
				
				if (fileMatch != null && fileMatch.Success) {
					string filename = fileMatch.Groups["filename"].Value;
					if (File.Exists (filename)) {
						int line = 1, column = 1;
						a = a.Replace (filename, Path.GetFullPath (filename));
						if (fileMatch.Groups["line"].Success)
							int.TryParse (fileMatch.Groups["line"].Value, out line);
						if (fileMatch.Groups["column"].Success)
							int.TryParse (fileMatch.Groups["column"].Value, out column);
						var file = new FileOpenInformation (a, line, column, true);
						requestedFileList.Add (file);
					}
				} else if (a[0] == '-' || a[0] == '/') {
					int markerLength = 1;
					
					if (a.Length >= 2 && a[0] == '-' && a[1] == '-') {
						markerLength = 2;
					}
					
					parameterList.Add(a.Substring (markerLength));
				}
			}
		}
Example #4
0
        public override async Task Load(FileOpenInformation fileOpenInformation)
        {
            var fileName = fileOpenInformation.FileName;

            using (Stream stream = File.OpenRead(fileName)) {
                hexEditor.HexEditorData.Buffer = await ArrayBuffer.LoadAsync(stream);
            }

            ContentName  = fileName;
            this.IsDirty = false;
            hexEditor.SetFocus();
        }
Example #5
0
        public override void Activate()
        {
            var info = new FileOpenInformation(File, null);

            if (symbolInfo.Location.Range?.Start != null)
            {
                info.Line   = symbolInfo.Location.Range.Start.Line + 1;
                info.Column = symbolInfo.Location.Range.Start.Character + 1;
            }

            IdeApp.Workbench.OpenDocument(info).Ignore();
        }
        public override async Task Load(FileOpenInformation fileOpenInformation)
        {
            textEditorImpl.ViewContent.DirtyChanged -= HandleDirtyChanged;
            textEditor.TextChanged -= HandleTextChanged;
            await textEditorImpl.ViewContent.Load(fileOpenInformation);

            await RunFirstTimeFoldUpdate(textEditor.Text);

            textEditorImpl.InformLoadComplete();
            textEditor.TextChanged += HandleTextChanged;
            textEditorImpl.ViewContent.DirtyChanged += HandleDirtyChanged;
        }
        static void OpenDeclaration(Location location)
        {
            var fileInfo = new FileOpenInformation(location.Uri.ToFilePath());

            if (location.Range?.Start != null)
            {
                fileInfo.Line   = location.Range.Start.Line + 1;
                fileInfo.Column = location.Range.Start.Character + 1;
            }

            IdeApp.Workbench.OpenDocument(fileInfo).LogFault();
        }
		public override void Load (FileOpenInformation fileOpenInformation)
		{
			var fileName = fileOpenInformation.FileName;
//			using (IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor (true)) {
			catalog.Load (null, fileName);
//			}
			poEditorWidget.Catalog = catalog;
			poEditorWidget.POFileName = fileName;
			poEditorWidget.UpdateRules (System.IO.Path.GetFileNameWithoutExtension (fileName));
			
			this.ContentName = fileName;
			this.IsDirty = false;
		}
        public override void Load(FileOpenInformation fileOpenInformation)
        {
            var fileName = fileOpenInformation.FileName;

//			using (IProgressMonitor mon = IdeApp.Workbench.ProgressMonitors.GetLoadProgressMonitor (true)) {
            catalog.Load(null, fileName);
//			}
            poEditorWidget.Catalog    = catalog;
            poEditorWidget.POFileName = fileName;
            poEditorWidget.UpdateRules(System.IO.Path.GetFileNameWithoutExtension(fileName));

            this.ContentName = fileName;
            this.IsDirty     = false;
        }
Example #10
0
        void AddOpenDocumentTimerMetadata(OpenDocumentMetadata metadata, FileOpenInformation info, Document document, bool result)
        {
            if (document != null)
            {
                metadata.EditorType = document.DocumentController.GetType().FullName;
            }
            if (info.Owner != null)
            {
                metadata.OwnerProjectGuid = (info.Owner as SolutionItem)?.ItemId;
            }

            metadata.Extension    = info.FileName.Extension;
            metadata.ResultString = result ? "Success" : "Failure";
        }
        public override Task Load(FileOpenInformation fileOpenInformation)
        {
            ContentName = GettextCatalog.GetString("Assembly Browser");
            var loader = widget.AddReferenceByFileName(fileOpenInformation.FileName);

            if (loader == null)
            {
                return(Task.FromResult(true));
            }
            loader.LoadingTask.ContinueWith(delegate {
                widget.SelectAssembly(loader);
            });
            return(Task.FromResult(true));
        }
Example #12
0
        void _treeView_Selection_Changed(object sender, EventArgs e)
        {
            var selectedRows = _treeView.Selection.GetSelectedRows();

            if (selectedRows != null && selectedRows.Length > 0)
            {
                var row   = selectedRows [0];
                var index = row.Indices [0];
                _selectedDocument = _filteredDocuments [index];
                _selectedIndex    = index;
            }
            UpdateSrollPosition();
            _searchView.GrabFocus();
            _searchView.SelectRegion(_searchView.Text.Length, _searchView.Text.Length);
        }
Example #13
0
        void ReuseDocument(Document doc, FileOpenInformation info)
        {
            if (info.Owner != null && doc.Owner != info.Owner)
            {
                doc.AttachToProject(info.Owner);
            }

            ScrollToRequestedCaretLocation(doc, info);

            if (info.Options.HasFlag(OpenDocumentOptions.BringToFront))
            {
                doc.Select();
                navigationHistoryManager?.LogActiveDocument();
            }
        }
Example #14
0
        internal StartupInfo(MonoDevelopOptions options, IEnumerable <string> args)
        {
            Options = options;
            foreach (string arg in args)
            {
                string a         = arg;
                Match  fileMatch = FileExpression.Match(a);

                // this does not yet work with relative paths
                if (a[0] == '~')
                {
                    var sf = MonoDevelop.Core.Platform.IsWindows ? Environment.SpecialFolder.UserProfile : Environment.SpecialFolder.Personal;
                    a = Path.Combine(Environment.GetFolderPath(sf), a.Substring(1));
                }

                if (fileMatch != null && fileMatch.Success)
                {
                    string filename = fileMatch.Groups["filename"].Value;
                    if (File.Exists(filename))
                    {
                        int line = 1, column = 1;
                        filename = Path.GetFullPath(filename);
                        if (fileMatch.Groups["line"].Success)
                        {
                            int.TryParse(fileMatch.Groups["line"].Value, out line);
                        }
                        if (fileMatch.Groups["column"].Success)
                        {
                            int.TryParse(fileMatch.Groups["column"].Value, out column);
                        }
                        var file = new FileOpenInformation(filename, null, line, column, OpenDocumentOptions.Default);
                        requestedFileList.Add(file);
                    }
                }
                else if (a[0] == '-' || a[0] == '/')
                {
                    int markerLength = 1;

                    if (a.Length >= 2 && a[0] == '-' && a[1] == '-')
                    {
                        markerLength = 2;
                    }

                    parameterList.Add(a.Substring(markerLength));
                }
            }
        }
Example #15
0
        void InitializeRestServiceAndPair()
        {
            UnityModeAddin.Initialize();

            restService = new RestService(fileOpenRequest =>
            {
                var fileOpenInformation = new FileOpenInformation(fileOpenRequest.File, null, fileOpenRequest.Line, 0, OpenDocumentOptions.BringToFront);

                try
                {
                    DispatchService.GuiDispatch(() =>
                    {
                        if (IdeApp.Workbench.Documents.Any(d => d.FileName == fileOpenInformation.FileName))
                        {
                            var docs = IdeApp.Workbench.Documents.Where(d => d.FileName == fileOpenInformation.FileName);
                            docs.ElementAt(0).Select();
                        }
                        else
                        {
                            IdeApp.Workbench.OpenDocument(fileOpenInformation);
                            DispatchService.GuiDispatch(IdeApp.Workbench.GrabDesktopFocus);
                        }
                    });
                }
                catch (Exception e)
                {
                    LoggingService.LogError(e.ToString());
                }
            }
                                          );

            DispatchService.BackgroundDispatch(() =>
            {
                LoggingService.LogInfo("Sending Unity Pair request");
                var result = RestClient.Pair(restService.Url, "MonoDevelop " + MonoDevelop.BuildInfo.VersionLabel);
                LoggingService.LogInfo("Unity Pair Request: " + result.Result);
                StartupOptions.UnityProcessId = result.unitypid;
            });

            UnityModeAddin.UpdateUnityProjectState();
        }
        protected override Task <Response> HandleOpenFile(OpenFileRequest request)
        {
            DispatchToGuiThread(() =>
            {
                var fileOpenInfo = new FileOpenInformation(new FilePath(request.File),
                                                           project: null /* autodetect */,
                                                           line: request.Line ?? 0,
                                                           column: request.Column ?? 0,
                                                           options: OpenDocumentOptions.Default
                                                           );

                IdeApp.OpenFiles(new[] { fileOpenInfo });

                // Make the Ide window grab focus
                IdeApp.Workbench.Present();
            });

            return(Task.FromResult <Response>(new OpenFileResponse {
                Status = MessageStatus.Ok
            }));
        }
Example #17
0
        public async Task <Document> NewDocument(string defaultName, string mimeType, Stream content)
        {
            defaultName = GetUniqueFileName(defaultName);

            var fileDescriptor = new FileDescriptor(defaultName, mimeType, content, null);

            var documentControllerService = await ServiceProvider.GetService <DocumentControllerService> ();

            var controllerDesc = (await documentControllerService.GetSupportedControllers(fileDescriptor)).FirstOrDefault(c => c.CanUseAsDefault);

            if (controllerDesc == null)
            {
                throw new ApplicationException("Can't create display binding for mime type: " + mimeType);
            }

            var controller = await controllerDesc.CreateController(fileDescriptor);

            using (content) {
                await controller.Initialize(fileDescriptor, new Properties());
            }

            controller.HasUnsavedChanges = false;

            var fileOpenInfo = new FileOpenInformation(defaultName);

            fileOpenInfo.DocumentController            = controller;
            fileOpenInfo.DocumentControllerDescription = controllerDesc;

            var document = await ShowView(fileOpenInfo);

            if (document.Editor != null)
            {
                document.Editor.Encoding = Encoding.UTF8;
            }
            if (document.DocumentContext != null)
            {
                document.DocumentContext.ReparseDocument();
            }
            return(document);
        }
Example #18
0
        void ScrollToRequestedCaretLocation(Document doc, FileOpenInformation info)
        {
            if (info.Line < 1 && info.Offset < 0)
            {
                return;
            }

            if (editorOperationsFactoryService == null)
            {
                editorOperationsFactoryService = CompositionManager.Instance.GetExportedValue <IEditorOperationsFactoryService> ();
            }

            FileSettingsStore.Remove(doc.FileName);
            doc.DisableAutoScroll();

            doc.RunWhenContentAdded <ITextView> (textView => {
                var ipos = doc.Editor;
                if (ipos != null)
                {
                    var loc = new DocumentLocation(info.Line, info.Column >= 1 ? info.Column : 1);
                    if (info.Offset >= 0)
                    {
                        loc = ipos.OffsetToLocation(info.Offset);
                    }
                    if (loc.IsEmpty)
                    {
                        return;
                    }
                    ipos.SetCaretLocation(loc, info.Options.HasFlag(OpenDocumentOptions.HighlightCaretLine), info.Options.HasFlag(OpenDocumentOptions.CenterCaretLine));
                }
                else
                {
                    var offset = info.Offset;
                    if (offset < 0)
                    {
                        var line = textView.TextSnapshot.GetLineFromLineNumber(info.Line - 1);
                        if (info.Column >= 1)
                        {
                            offset = line.Start + info.Column - 1;
                        }
                        else
                        {
                            offset = line.Start;
                        }
                    }
                    if (editorOperationsFactoryService != null)
                    {
                        var editorOperations = editorOperationsFactoryService.GetEditorOperations(textView);
                        var point            = new VirtualSnapshotPoint(textView.TextSnapshot, offset);
                        editorOperations.SelectAndMoveCaret(point, point, TextSelectionMode.Stream, EnsureSpanVisibleOptions.AlwaysCenter);
                    }
                    else
                    {
                        LoggingService.LogError("Missing editor operations");
                    }
                }
            });

/*			var navigator = (ISourceFileNavigator)newContent.GetContent (typeof (ISourceFileNavigator));
 *                      if (fileInfo.Offset >= 0)
 *                              navigator.JumpToOffset (fileInfo.Offset);
 *                      else
 *                              navigator.JumpToLine (fileInfo.Line, fileInfo.Column);*/
        }
Example #19
0
        async Task <Document> LoadFile(FilePath fileName, ProgressMonitor monitor, DocumentControllerDescription binding, WorkspaceObject project, FileOpenInformation fileInfo)
        {
            // Make sure composition manager is ready since ScrollToRequestedCaretLocation will use it
            await Runtime.GetService <CompositionManager> ();

            string mimeType       = desktopService.GetMimeTypeForUri(fileName);
            var    fileDescriptor = new FileDescriptor(fileName, mimeType, project);

            try {
                Counters.OpenDocumentTimer.Trace("Creating content");
                DocumentController controller;

                try {
                    fileInfo.DocumentControllerDescription = binding;
                    controller = fileInfo.DocumentController = await binding.CreateController(fileDescriptor);
                } catch (InvalidEncodingException iex) {
                    monitor.ReportError(GettextCatalog.GetString("The file '{0}' could not opened. {1}", fileName, iex.Message), null);
                    return(null);
                } catch (OverflowException) {
                    monitor.ReportError(GettextCatalog.GetString("The file '{0}' could not opened. File too large.", fileName), null);
                    return(null);
                }

                if (controller == null)
                {
                    monitor.ReportError(GettextCatalog.GetString("The file '{0}' could not be opened.", fileName), null);
                    return(null);
                }

                Counters.OpenDocumentTimer.Trace("Loading file");

                try {
                    await controller.Initialize(fileDescriptor, GetStoredMemento (fileName));

                    controller.OriginalContentName = fileInfo.OriginalFileName;
                    if (fileInfo.Owner != null)
                    {
                        controller.Owner = fileInfo.Owner;
                    }
                } catch (InvalidEncodingException iex) {
                    monitor.ReportError(GettextCatalog.GetString("The file '{0}' could not opened. {1}", fileName, iex.Message), iex);
                    return(null);
                } catch (OverflowException) {
                    monitor.ReportError(GettextCatalog.GetString("The file '{0}' could not opened. File too large.", fileName), null);
                    return(null);
                }
            } catch (Exception ex) {
                monitor.ReportError(GettextCatalog.GetString("The file '{0}' could not be opened.", fileName), ex);
                return(null);
            }

            Counters.OpenDocumentTimer.Trace("Showing view");

            var doc = await ShowView(fileInfo);

            ScrollToRequestedCaretLocation(doc, fileInfo);

            return(doc);
        }
Example #20
0
        public async Task <Document> OpenDocument(FileOpenInformation info)
        {
            if (string.IsNullOrEmpty(info.FileName))
            {
                return(null);
            }

            if (navigationHistoryManager == null)
            {
                navigationHistoryManager = await ServiceProvider.GetService <NavigationHistoryService> ();
            }

            // Make sure composition manager is ready since ScrollToRequestedCaretLocation will use it
            await Runtime.GetService <CompositionManager> ();

            var metadata       = CreateOpenDocumentTimerMetadata();
            var fileDescriptor = new FileDescriptor(info.FileName, null, info.Owner);

            using (Counters.OpenDocumentTimer.BeginTiming("Opening file " + info.FileName, metadata)) {
                navigationHistoryManager.LogActiveDocument();
                Counters.OpenDocumentTimer.Trace("Look for open document");
                foreach (Document doc in Documents)
                {
                    // Search all ViewContents to see if they can "re-use" this filename.
                    if (!doc.TryReuseDocument(fileDescriptor))
                    {
                        continue;
                    }

                    //if found, try to reuse or close the old view
                    // reuse the view if the binidng didn't change
                    if (info.Options.HasFlag(OpenDocumentOptions.TryToReuseViewer) || doc.DocumentControllerDescription == info.DocumentControllerDescription)
                    {
                        if (info.Owner != null && doc.Owner != info.Owner)
                        {
                            doc.AttachToProject(info.Owner);
                        }

                        ScrollToRequestedCaretLocation(doc, info);

                        if (info.Options.HasFlag(OpenDocumentOptions.BringToFront))
                        {
                            doc.Select();
                            navigationHistoryManager.LogActiveDocument();
                        }
                        return(doc);
                    }
                    else
                    {
                        if (!await doc.Close())
                        {
                            return(doc);
                        }
                        break;
                    }
                }
                Counters.OpenDocumentTimer.Trace("Initializing monitor");
                var progressMonitorManager = await ServiceProvider.GetService <ProgressMonitorManager> ();

                var pm = progressMonitorManager.GetStatusProgressMonitor(
                    GettextCatalog.GetString("Opening {0}", info.Owner is SolutionFolderItem item ?
                                             info.FileName.ToRelative(item.ParentSolution.BaseDirectory) :
                                             info.FileName),
                    Stock.StatusWorking,
                    true
                    );

                var result = await RealOpenFile(pm, info);

                pm.Dispose();

                AddOpenDocumentTimerMetadata(metadata, info, result.Content, result.Success);

                if (result.Content != null)
                {
                    Counters.OpenDocumentTimer.Trace("Wrapping document");
                    Document doc = result.Content;

                    if (doc != null && info.Options.HasFlag(OpenDocumentOptions.BringToFront))
                    {
                        doc.Select();
                    }
                    return(doc);
                }
                return(null);
            }
        }
Example #21
0
 public override Task Load(FileOpenInformation fileOpenInformation)
 {
     ContentName = fileOpenInformation.FileName;
     return(content.Load(ContentName));
 }
		public override void Load (FileOpenInformation fileOpenInformation)
		{
			var fileName = fileOpenInformation.FileName;
			using (Stream stream = File.OpenRead (fileName)) { 
				hexEditor.HexEditorData.Buffer = ArrayBuffer.Load (stream);
			}
			
			ContentName = fileName;
			this.IsDirty = false;
			hexEditor.SetFocus ();
		}
 void IViewContent.Load(FileOpenInformation fileOpenInformation)
 {
     throw new InvalidOperationException();
 }
Example #24
0
        void ScrollToRequestedCaretLocation(Document doc, FileOpenInformation info)
        {
            if (info.Line < 1 && info.Offset < 0)
            {
                return;
            }

            if (editorOperationsFactoryService == null)
            {
                editorOperationsFactoryService = CompositionManager.Instance.GetExportedValue <IEditorOperationsFactoryService> ();
            }

            FileSettingsStore.Remove(doc.FileName);
            doc.DisableAutoScroll();

            doc.RunWhenContentAdded <ITextView> (textView => {
                var ipos = doc.Editor;
                if (ipos != null)
                {
                    var loc = new DocumentLocation(info.Line, info.Column >= 1 ? info.Column : 1);
                    if (info.Offset >= 0)
                    {
                        loc = ipos.OffsetToLocation(info.Offset);
                    }
                    if (loc.IsEmpty)
                    {
                        return;
                    }
                    ipos.SetCaretLocation(loc, info.Options.HasFlag(OpenDocumentOptions.HighlightCaretLine), info.Options.HasFlag(OpenDocumentOptions.CenterCaretLine));
                }
                else
                {
                    var offset = info.Offset;
                    if (offset < 0)
                    {
                        try {
                            if (info.Line - 1 > (textView?.TextSnapshot?.LineCount ?? 0))
                            {
                                LoggingService.LogInfo($"ScrollToRequestedCaretLocation line was over the snapshot's line count. "
                                                       + $"Called with {info.Line - 1} but line count was {textView?.TextSnapshot?.LineCount}");
                                return;
                            }

                            var line = textView.TextSnapshot.GetLineFromLineNumber(info.Line - 1);
                            if (info.Column >= 1)
                            {
                                offset = line.Start + Math.Min(info.Column - 1, line.Length);
                            }
                            else
                            {
                                offset = line.Start;
                            }
                        } catch (ArgumentException ae) {
                            LoggingService.LogError($"Calling GetLineFromLineNumber resulted in an argument exception."
                                                    + $"We tried calling with line number: {info.Line - 1}", ae);
                            // we should just abort in this case, since we can't really do anything
                            return;
                        }
                    }
                    if (editorOperationsFactoryService != null)
                    {
                        var editorOperations = editorOperationsFactoryService.GetEditorOperations(textView);
                        var point            = new VirtualSnapshotPoint(textView.TextSnapshot, offset);
                        editorOperations.SelectAndMoveCaret(point, point, TextSelectionMode.Stream, EnsureSpanVisibleOptions.AlwaysCenter);
                    }
                    else
                    {
                        LoggingService.LogError("Missing editor operations");
                    }
                }
            });

/*			var navigator = (ISourceFileNavigator)newContent.GetContent (typeof (ISourceFileNavigator));
 *                      if (fileInfo.Offset >= 0)
 *                              navigator.JumpToOffset (fileInfo.Offset);
 *                      else
 *                              navigator.JumpToLine (fileInfo.Line, fileInfo.Column);*/
        }
 void _treeView_Selection_Changed(object sender, EventArgs e)
 {
     var selectedRows = _treeView.Selection.GetSelectedRows ();
     if (selectedRows != null && selectedRows.Length > 0) {
         var row = selectedRows [0];
         var index = row.Indices [0];
         _selectedDocument = _filteredDocuments [index];
         _selectedIndex = index;
     }
     _searchView.GrabFocus ();
     _searchView.SelectRegion (_searchView.Text.Length, _searchView.Text.Length);
 }
Example #26
0
 public override Task Load(FileOpenInformation fileOpenInformation)
 {
     ContentName = GettextCatalog.GetString("Assembly Browser");
     widget.AddReferenceByFileName(fileOpenInformation.FileName);
     return(Task.FromResult(true));
 }
Example #27
0
 public override void Load(FileOpenInformation fileOpenInformation)
 {
 }
Example #28
0
		public override void Load (FileOpenInformation fileOpenInformation)
		{
			throw new System.NotImplementedException ();
		}
        public KeyActions PreProcessKey(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            bool isSelected;

            switch (key) {
            case Gdk.Key.Home:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                    return KeyActions.Process;
                //TODO
                return KeyActions.Ignore;
            case Gdk.Key.End:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                    return KeyActions.Process;
                //TODO
                return KeyActions.Ignore;

            case Gdk.Key.Up:
                if (_selectedIndex - 1 >= 0) {
                    SelectRowIndex (_selectedIndex - 1);
                }
                return KeyActions.Ignore;

            case Gdk.Key.Tab:
                //tab always completes current item even if selection is disabled
                goto case Gdk.Key.Return;
            //
            case Gdk.Key.Return:
            case Gdk.Key.ISO_Enter:
            case Gdk.Key.Key_3270_Enter:
            case Gdk.Key.KP_Enter:
                if (_selectedDocument != null) {
                    //MemberExtensionsHelper.Instance.GotoMember (_selectedDocument);
                    return KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow;
                }
                return KeyActions.Ignore;
            case Gdk.Key.Escape:
                _selectedDocument = null;
                return KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow;
            case Gdk.Key.Down:
                if (_selectedIndex + 1 < _filteredDocuments.Count) {
                    SelectRowIndex (_selectedIndex + 1);
                }
                return KeyActions.Ignore;

            case Gdk.Key.Page_Up:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                    return KeyActions.Process;
                //TODO
                return KeyActions.Ignore;

            case Gdk.Key.Page_Down:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                    return KeyActions.Process;
                //TODO
                return KeyActions.Ignore;

            case Gdk.Key.Left:
                //if (curPos == 0) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos--;
                return KeyActions.Process;

            case Gdk.Key.Right:
                //if (curPos == word.Length) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos++;
                return KeyActions.Process;

            case Gdk.Key.Caps_Lock:
            case Gdk.Key.Num_Lock:
            case Gdk.Key.Scroll_Lock:
                return KeyActions.Ignore;

            case Gdk.Key.Control_L:
            case Gdk.Key.Control_R:
            case Gdk.Key.Alt_L:
            case Gdk.Key.Alt_R:
            case Gdk.Key.Shift_L:
            case Gdk.Key.Shift_R:
            case Gdk.Key.ISO_Level3_Shift:
                // AltGr
                return KeyActions.Process;
            default:
                return KeyActions.Ignore;
            }
            if (keyChar == '\0')
                return KeyActions.Process;

            if (keyChar == ' ' && (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                return KeyActions.CloseWindow | KeyActions.Process;

            // special case end with punctuation like 'param:' -> don't input double punctuation, otherwise we would end up with 'param::'
            if (char.IsPunctuation (keyChar) && keyChar != '_') {
                return KeyActions.Ignore;
            }
            return KeyActions.Process;
        }
 public override void Load(FileOpenInformation fileOpenInformation)
 {
     ContentName = GettextCatalog.GetString("Assembly Browser");
     widget.AddReferenceByFileName(fileOpenInformation.FileName);
 }
Example #31
0
        public static void Open()
        {
            var fileInfo = new FileOpenInformation(FileName);

            IdeApp.Workbench.OpenDocument(fileInfo).Ignore();
        }
        public override void Load (FileOpenInformation fileName)
		{
		    if (openFile.Behaviour != null) {
                openFile.Behaviour.Load (fileName.FileName);
		    }
            ContentName = fileName.FileName;
		}
Example #33
0
        public KeyActions PreProcessKey(Gdk.Key key, char keyChar, Gdk.ModifierType modifier)
        {
            bool isSelected;

            switch (key)
            {
            case Gdk.Key.Home:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                //TODO
                return(KeyActions.Ignore);

            case Gdk.Key.End:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                //TODO
                return(KeyActions.Ignore);

            case Gdk.Key.Up:
                if (_selectedIndex - 1 >= 0)
                {
                    SelectRowIndex(_selectedIndex - 1);
                }
                return(KeyActions.Ignore);

            case Gdk.Key.Tab:
                //tab always completes current item even if selection is disabled
                goto case Gdk.Key.Return;

//
            case Gdk.Key.Return:
            case Gdk.Key.ISO_Enter:
            case Gdk.Key.Key_3270_Enter:
            case Gdk.Key.KP_Enter:
                if (_selectedDocument != null)
                {
                    //MemberExtensionsHelper.Instance.GotoMember (_selectedDocument);
                    return(KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow);
                }
                return(KeyActions.Ignore);

            case Gdk.Key.Escape:
                _selectedDocument = null;
                return(KeyActions.Complete | KeyActions.Ignore | KeyActions.CloseWindow);

            case Gdk.Key.Down:
                if (_selectedIndex + 1 < _filteredDocuments.Count)
                {
                    SelectRowIndex(_selectedIndex + 1);
                }
                return(KeyActions.Ignore);

            case Gdk.Key.Page_Up:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                //TODO
                return(KeyActions.Ignore);

            case Gdk.Key.Page_Down:
                if ((modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
                {
                    return(KeyActions.Process);
                }
                //TODO
                return(KeyActions.Ignore);

            case Gdk.Key.Left:
                //if (curPos == 0) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos--;
                return(KeyActions.Process);

            case Gdk.Key.Right:
                //if (curPos == word.Length) return KeyActions.CloseWindow | KeyActions.Process;
                //curPos++;
                return(KeyActions.Process);

            case Gdk.Key.Caps_Lock:
            case Gdk.Key.Num_Lock:
            case Gdk.Key.Scroll_Lock:
                return(KeyActions.Ignore);

            case Gdk.Key.Control_L:
            case Gdk.Key.Control_R:
            case Gdk.Key.Alt_L:
            case Gdk.Key.Alt_R:
            case Gdk.Key.Shift_L:
            case Gdk.Key.Shift_R:
            case Gdk.Key.ISO_Level3_Shift:
                // AltGr
                return(KeyActions.Process);

            default:
                return(KeyActions.Ignore);
            }
            if (keyChar == '\0')
            {
                return(KeyActions.Process);
            }

            if (keyChar == ' ' && (modifier & ModifierType.ShiftMask) == ModifierType.ShiftMask)
            {
                return(KeyActions.CloseWindow | KeyActions.Process);
            }

            // special case end with punctuation like 'param:' -> don't input double punctuation, otherwise we would end up with 'param::'
            if (char.IsPunctuation(keyChar) && keyChar != '_')
            {
                return(KeyActions.Ignore);
            }
            return(KeyActions.Process);
        }
		void InitializeRestServiceAndPair()
		{
			UnityModeAddin.Initialize ();

			restService = new RestService ( fileOpenRequest => 
			{
				var fileOpenInformation = new FileOpenInformation (fileOpenRequest.File, null, fileOpenRequest.Line, 0, OpenDocumentOptions.BringToFront);

				try
				{
					DispatchService.GuiDispatch(() =>
					{
						if (IdeApp.Workbench.Documents.Any(d => d.FileName == fileOpenInformation.FileName))
						{
							var docs = IdeApp.Workbench.Documents.Where(d => d.FileName == fileOpenInformation.FileName);
							docs.ElementAt(0).Select();
						}
						else
						{
							IdeApp.Workbench.OpenDocument(fileOpenInformation);
							DispatchService.GuiDispatch(IdeApp.Workbench.GrabDesktopFocus);
							
						}
					});
				}
				catch (Exception e)
				{
					LoggingService.LogError(e.ToString());
				}
			}
			);

			DispatchService.BackgroundDispatch(() =>
			{
				LoggingService.LogInfo("Sending Unity Pair request");
				var result = RestClient.Pair(restService.Url, "MonoDevelop " + MonoDevelop.BuildInfo.VersionLabel);
				LoggingService.LogInfo("Unity Pair Request: " + result.Result);
				StartupOptions.UnityProcessId = result.unitypid;
			});

			UnityModeAddin.UpdateUnityProjectState();
		}
		public override void Load (FileOpenInformation fileOpenInformation)
		{
			ContentName = GettextCatalog.GetString ("Assembly Browser");
			widget.AddReferenceByFileName (fileOpenInformation.FileName);
		}
Example #36
0
 public override void Load(FileOpenInformation fileOpenInformation)
 {
     ContentName = fileOpenInformation.FileName;
     entry.Load(fileOpenInformation.FileName);
     widget.DesktopEntry = entry;
 }
		public override async Task Load (FileOpenInformation fileOpenInformation)
		{
			textEditorImpl.ViewContent.DirtyChanged -= HandleDirtyChanged;
			textEditor.TextChanged -= HandleTextChanged;
			await textEditorImpl.ViewContent.Load (fileOpenInformation);
			await RunFirstTimeFoldUpdate (textEditor.Text);
			textEditorImpl.InformLoadComplete ();
			textEditor.TextChanged += HandleTextChanged;
			textEditorImpl.ViewContent.DirtyChanged += HandleDirtyChanged;
		}
 public override void Load(FileOpenInformation fileOpenInformation)
 {
     ContentName = fileOpenInformation.FileName;
     content.Load(ContentName);
 }
		public override Task Load (FileOpenInformation fileOpenInformation)
		{
			ContentName = GettextCatalog.GetString ("Assembly Browser");
			widget.AddReferenceByFileName (fileOpenInformation.FileName);
			return Task.FromResult (true);
		}
        void UpdateFileOpenInfo(MonoDevelop.Ide.Gui.Document document, int line, int column)
        {
            try {

                var existingFileInfo = _recentDocuments.FirstOrDefault ((arg) => arg.Project == document.Project && arg.FileName.FullPath == document.FileName.FullPath);
                if (existingFileInfo != null) {
                    _recentDocuments.Remove (existingFileInfo);
                }
                if (GetProjectWithId (document.Project.ItemId) != null && File.Exists (document.FileName.FullPath)) {
                    var fileInfo = new FileOpenInformation (document.FileName.FullPath, document.Project, line, column, OpenDocumentOptions.BringToFront | OpenDocumentOptions.TryToReuseViewer);
                    _recentDocuments.Insert (0, fileInfo);
                }
            } catch (Exception ex) {
                Console.WriteLine ("error updating file info " + ex.Message);
            }
        }
		public override Task Load (FileOpenInformation fileOpenInformation)
		{
			throw new NotSupportedException ();
		}
		public override void Load (FileOpenInformation fileOpenInformation)
		{
			Load (fileOpenInformation.FileName, fileOpenInformation.Encoding, fileOpenInformation.IsReloadOperation);
		}
Example #43
0
        async Task <(bool Success, Document Content)> RealOpenFile(ProgressMonitor monitor, FileOpenInformation openFileInfo)
        {
            FilePath fileName;

            await InitDesktopService();

            Counters.OpenDocumentTimer.Trace("Checking file");

            string origName = openFileInfo.FileName;

            if (origName == null)
            {
                monitor.ReportError(GettextCatalog.GetString("Invalid file name"), null);
                return(false, null);
            }

            fileName = openFileInfo.FileName;
            if (!origName.StartsWith("http://", StringComparison.Ordinal))
            {
                fileName = fileName.FullPath;
            }

            //Debug.Assert(FileService.IsValidPath(fileName));
            if (FileService.IsDirectory(fileName))
            {
                monitor.ReportError(GettextCatalog.GetString("{0} is a directory", fileName), null);
                return(false, null);
            }

            // test, if file fileName exists
            if (!origName.StartsWith("http://", StringComparison.Ordinal))
            {
                // test, if an untitled file should be opened
                if (!Path.IsPathRooted(origName))
                {
                    foreach (Document doc in Documents)
                    {
                        if (doc.IsNewDocument && doc.FilePath == origName)
                        {
                            doc.Select();
                            ScrollToRequestedCaretLocation(doc, openFileInfo);
                            return(true, doc);
                        }
                    }
                }

                if (!File.Exists(fileName))
                {
                    monitor.ReportError(GettextCatalog.GetString("File not found: {0}", fileName), null);
                    return(false, null);
                }
            }

            Counters.OpenDocumentTimer.Trace("Looking for binding");

            var documentControllerService = await ServiceProvider.GetService <DocumentControllerService> ();

            IExternalDisplayBinding       externalBinding = null;
            DocumentControllerDescription internalBinding = null;
            WorkspaceObject project = null;

            if (openFileInfo.Owner == null)
            {
                var workspace = await ServiceProvider.GetService <RootWorkspace> ();

                // Set the project if one can be found. The project on the FileOpenInformation
                // is used to add project metadata to the OpenDocumentTimer counter.
                project = workspace.GetProjectContainingFile(fileName);

                // In some cases, the file may be a symlinked file. We cannot find the resolved symlink path
                // in the project, so we should try looking up the original file.
                if (project == null)
                {
                    project = workspace.GetProjectContainingFile(openFileInfo.OriginalFileName);
                }
                openFileInfo.Owner = project;
            }
            else
            {
                project = openFileInfo.Owner;
            }

            var displayBindingService = await ServiceProvider.GetService <DisplayBindingService> ();

            var fileDescriptor  = new FileDescriptor(fileName, null, project);
            var internalViewers = await documentControllerService.GetSupportedControllers(fileDescriptor);

            var externalViewers = displayBindingService.GetDisplayBindings(fileName, null, project as Project).OfType <IExternalDisplayBinding> ().ToList();

            if (openFileInfo.DocumentControllerDescription != null)
            {
                internalBinding = openFileInfo.DocumentControllerDescription;
            }
            else
            {
                var bindings = displayBindingService.GetDisplayBindings(fileName, null, project as Project).ToList();
                if (openFileInfo.Options.HasFlag(OpenDocumentOptions.OnlyInternalViewer))
                {
                    internalBinding = internalViewers.FirstOrDefault(d => d.CanUseAsDefault) ?? internalViewers.FirstOrDefault();
                }
                else if (openFileInfo.Options.HasFlag(OpenDocumentOptions.OnlyExternalViewer))
                {
                    externalBinding = externalViewers.FirstOrDefault(d => d.CanUseAsDefault) ?? externalViewers.FirstOrDefault();
                }
                else
                {
                    internalBinding = internalViewers.FirstOrDefault(d => d.CanUseAsDefault);
                    if (internalBinding == null)
                    {
                        externalBinding = externalViewers.FirstOrDefault(d => d.CanUseAsDefault);
                        if (externalBinding == null)
                        {
                            internalBinding = internalViewers.FirstOrDefault();
                            if (internalBinding == null)
                            {
                                externalBinding = externalViewers.FirstOrDefault();
                            }
                        }
                    }
                }
            }

            Document newContent = null;

            try {
                if (internalBinding != null)
                {
                    newContent = await LoadFile(fileName, monitor, internalBinding, project, openFileInfo);
                }
                else if (externalBinding != null)
                {
                    var extBinding = (IExternalDisplayBinding)externalBinding;
                    var app        = extBinding.GetApplication(fileName, null, project as Project);
                    app.Launch(fileName);
                }
                else if (!openFileInfo.Options.HasFlag(OpenDocumentOptions.OnlyInternalViewer))
                {
                    try {
                        Counters.OpenDocumentTimer.Trace("Showing in browser");
                        desktopService.OpenFile(fileName);
                    } catch (Exception ex) {
                        LoggingService.LogError("Error opening file: " + fileName, ex);
                        MessageService.ShowError(GettextCatalog.GetString("File '{0}' could not be opened", fileName));
                        return(false, null);
                    }
                }
                Counters.OpenDocumentTimer.Trace("Adding to recent files");
                desktopService.RecentFiles.AddFile(fileName, project);
            } catch (Exception ex) {
                monitor.ReportError(GettextCatalog.GetString("The file '{0}' could not be opened.", fileName), ex);
                return(false, null);
            }
            return(true, newContent);
        }
		public abstract void Load (FileOpenInformation fileOpenInformation);
        public override void Load (FileOpenInformation fileName)
		{
            openFile.NetworkRequestLayer.Load(fileName.FileName);
            ContentName = fileName.FileName;
		}
		public override void Load (FileOpenInformation fileOpenInformation)
		{
			ContentName = fileOpenInformation.FileName;
			entry.Load (fileOpenInformation.FileName);
			widget.DesktopEntry = entry;
		}
Example #47
0
		public override async Task Load (FileOpenInformation fileOpenInformation)
		{
			await content.Load (fileOpenInformation);
		}
Example #48
0
        public async Task <Document> OpenDocument(FileOpenInformation info)
        {
            if (string.IsNullOrEmpty(info.FileName))
            {
                return(null);
            }

            // Make sure composition manager is ready since ScrollToRequestedCaretLocation will use it
            await Runtime.GetService <CompositionManager> ();

            var metadata       = CreateOpenDocumentTimerMetadata();
            var fileDescriptor = new FileDescriptor(info.FileName, null, info.Owner);

            using (var timer = Counters.OpenDocumentTimer.BeginTiming("Opening file " + info.FileName, metadata)) {
                navigationHistoryManager?.LogActiveDocument();
                timer.Trace("Look for open document");
                foreach (Document doc in Documents)
                {
                    if (info.Options.HasFlag(OpenDocumentOptions.TryToReuseViewer) && doc.TryReuseDocument(fileDescriptor))
                    {
                        // If TryReuseDocument returns true it means that the document can be reused and has been reused, so look no further
                        ReuseDocument(doc, info);
                        return(doc);
                    }

                    // If the document can't explicitly handle the new descriptor, check the file names.
                    // If the file of the document is the same, let's just focus it

                    if (!doc.IsFile || doc.FilePath != fileDescriptor.FilePath)
                    {
                        continue;
                    }

                    // Reuse the document if the controller factory didn't change

                    if (info.Options.HasFlag(OpenDocumentOptions.TryToReuseViewer) || doc.DocumentControllerDescription == info.DocumentControllerDescription)
                    {
                        ReuseDocument(doc, info);
                        return(doc);
                    }
                    else
                    {
                        if (!await doc.Close())
                        {
                            return(doc);
                        }
                        break;
                    }
                }
                timer.Trace("Initializing monitor");
                var progressMonitorManager = await ServiceProvider.GetService <ProgressMonitorManager> ();

                var pm = progressMonitorManager.GetStatusProgressMonitor(
                    GettextCatalog.GetString("Opening {0}", info.Owner is SolutionFolderItem item ?
                                             info.FileName.ToRelative(item?.ParentSolution?.BaseDirectory ?? item.BaseDirectory) :
                                             info.FileName),
                    Stock.StatusWorking,
                    true
                    );

                var result = await RealOpenFile(pm, info, timer);

                pm.Dispose();

                AddOpenDocumentTimerMetadata(metadata, info, result.Content, result.Success);

                if (result.Content != null)
                {
                    timer.Trace("Wrapping document");
                    Document doc = result.Content;

                    if (doc != null && info.Options.HasFlag(OpenDocumentOptions.BringToFront))
                    {
                        doc.Select();
                    }
                    return(doc);
                }
                return(null);
            }
        }
 public override void Load(FileOpenInformation fileOpenInformation)
 {
 }
		void IViewContent.Load (FileOpenInformation fileOpenInformation)
		{
			throw new InvalidOperationException();
		}
		public override Task Load (FileOpenInformation fileOpenInformation)
		{
			return Load (fileOpenInformation.FileName, fileOpenInformation.Encoding, fileOpenInformation.IsReloadOperation);
		}
 public override Task Load(FileOpenInformation fileOpenInformation)
 {
     throw new NotSupportedException();
 }
Example #53
0
		public virtual Task Load (FileOpenInformation fileOpenInformation)
		{
			return Task.FromResult (true);
		}
		public override Task Load (FileOpenInformation fileOpenInformation)
		{
			ContentName = fileOpenInformation.FileName;
			return content.Load (ContentName);
		}
		public override void Load (FileOpenInformation fileOpenInformation)
		{
			ContentName = fileOpenInformation.FileName;
			content.Load (ContentName);
		}
 /// <summary>
 /// Loads the history.
 /// </summary>
 void LoadHistory()
 {
     var historyItems = new Collection<FileOpenInformation> ();
     try {
         var paths = File.ReadAllLines (GetSavedStatePath ());
         var splitItems = paths.Select ((arg) => arg.Split (new string[] { PathDelimeter }, StringSplitOptions.None));
         foreach (var item in splitItems) {
             var project = GetProjectWithId (item [1]);
             var line = int.Parse (item [2]);
             var column = int.Parse (item [3]);
             if (project != null && File.Exists (item [0])) {
                 var fileOpenInformation = new FileOpenInformation (item [0], project, line, column, OpenDocumentOptions.BringToFront | OpenDocumentOptions.TryToReuseViewer);
                 historyItems.Add (fileOpenInformation);
             }
         }
         //TODO - need to refactor the _recentDocuments to store FileOpenInformation objects
     } catch (Exception e) {
         Console.WriteLine ("error loading history " + e.Message);
     }
     _recentDocuments = historyItems;
 }