protected override async Task<bool> TryHandleCommandAsyncInternal(IProjectTree rDataNode) {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
            
            // Don't do anything for file preview
            var uiShellOpenDocument = VsAppShell.Current.GetGlobalService<IVsUIShellOpenDocument3>(typeof(SVsUIShellOpenDocument));
            if (uiShellOpenDocument != null && ((__VSNEWDOCUMENTSTATE) uiShellOpenDocument.NewDocumentState).HasFlag(__VSNEWDOCUMENTSTATE.NDS_Provisional)) {
                return true;
            }

            return await base.TryHandleCommandAsyncInternal(rDataNode);
        }
Пример #2
0
        public IProjectTree ApplyModifications(IProjectTree tree, IProjectTreeProvider projectTreeProvider)
        {
#if Dev12
            if (tree.Capabilities.Contains(ProjectTreeCapabilities.ProjectRoot))
                tree = tree.SetIcon(Resources.NuProj);
#else
            if (tree.Capabilities.Contains(ProjectTreeCapabilities.ProjectRoot))
                tree = tree.SetIcon(KnownMonikers.NuGet.ToProjectSystemType());
#endif

            return tree;
        }
        public IProjectTree ApplyModifications(IProjectTree tree, IProjectTreeProvider projectTreeProvider)
        {
            // Only set the icon for the root project node.  We could choose to set different icons for nodes based
            // on various criteria, not just Capabilities, if we wished.
            if (tree.Capabilities.Contains(ProjectTreeCapabilities.ProjectRoot))
            {
                tree = tree.SetIcon(XSharpImagesMonikers.ProjectIconImageMoniker.ToProjectSystemType());
            }
            if (tree.BrowseObjectProperties?.ItemType?.ToLower() == "compile")
            //if (tree.Capabilities.Contains(ProjectTreeCapabilities.SourceFile))
            {
                tree = tree.SetIcon(XSharpImagesMonikers.ItemIconImageMoniker.ToProjectSystemType());
            }

            return tree;
        }
Пример #4
0
 public IProjectTree ApplyModifications(IProjectTree tree, IProjectTreeProvider projectTreeProvider) {
     if (tree != null) {
         if (tree.Capabilities.Contains(ProjectTreeCapabilities.ProjectRoot)) {
             tree = tree.SetIcon(ProjectIconProvider.ProjectNodeImage.ToProjectSystemType());
         } else if (tree.Capabilities.Contains(ProjectTreeCapabilities.FileOnDisk)) {
             string ext = Path.GetExtension(tree.FilePath).ToLowerInvariant();
             if (ext == ".r") {
                 tree = tree.SetIcon(ProjectIconProvider.RFileNodeImage.ToProjectSystemType());
             } else if (ext == ".rdata" || ext == ".rhistory") {
                 tree = tree.SetIcon(ProjectIconProvider.RDataFileNodeImage.ToProjectSystemType());
             }
             if (ext == ".md" || ext == ".rmd") {
                 tree = tree.SetIcon(KnownMonikers.MarkdownFile.ToProjectSystemType());
             }
         }
     }
     return tree;
 }
        protected virtual async Task<bool> TryHandleCommandAsyncInternal(IProjectTree rDataNode) {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            MessageButtons messageResult = VsAppShell.Current.ShowMessage(string.Format(CultureInfo.CurrentCulture, Resources.LoadWorkspaceIntoGlobalEnvironment, rDataNode.FilePath), MessageButtons.YesNo);
            if (messageResult == MessageButtons.No) {
                return true;
            }

            var session = _workflowProvider.GetOrCreate().RSession;
            try {
                await session.LoadWorkspaceAsync(rDataNode.FilePath);
            } catch (RException ex) {
                var message = string.Format(CultureInfo.CurrentCulture, Resources.LoadWorkspaceFailedMessageFormat,
                    rDataNode.FilePath, ex.Message);
                VsAppShell.Current.ShowErrorMessage(message);
            } catch (OperationCanceledException) {
            }

            return true;
        }
        protected virtual async Task<bool> TryHandleCommandAsyncInternal(IProjectTree rDataNode) {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            MessageButtons messageResult = VsAppShell.Current.ShowMessage(string.Format(CultureInfo.CurrentCulture, Resources.LoadWorkspaceIntoGlobalEnvironment, rDataNode.FilePath), MessageButtons.YesNo);
            if (messageResult == MessageButtons.No) {
                return true;
            }

            using (var evaluation = await _session.BeginEvaluationAsync()) {
                var result = await evaluation.LoadWorkspace(rDataNode.FilePath);

                if (result.Error != null) {
                    var message = string.Format(CultureInfo.CurrentCulture, Resources.LoadWorkspaceFailedMessageFormat,
                        rDataNode.FilePath, result.Error);
                    VsAppShell.Current.ShowErrorMessage(message);
                }
            }

            return true;
        }
 private bool IsRData(IProjectTree node) {
     var path = node.FilePath;
     return path != null && !_unconfiguredProject.IsOutsideProjectDirectory(path) && Path.GetExtension(path).Equals(".RData", StringComparison.CurrentCultureIgnoreCase);
 }