internal override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result) { if (cmdGroup == Guids.NodejsNpmCmdSet) { switch (cmd) { case PkgCmdId.cmdidNpmUpdateModules: if (_parent.IsCurrentStateASuppressCommandsMode()) { result = QueryStatusResult.SUPPORTED; } else { if (AllChildren.Any()) { result = QueryStatusResult.ENABLED | QueryStatusResult.SUPPORTED; } else { result = QueryStatusResult.SUPPORTED; } } return(VSConstants.S_OK); case PkgCmdId.cmdidNpmInstallModules: case PkgCmdId.cmdidNpmInstallSingleMissingModule: case PkgCmdId.cmdidNpmUninstallModule: case PkgCmdId.cmdidNpmUpdateSingleModule: result = QueryStatusResult.SUPPORTED | QueryStatusResult.INVISIBLE; return(VSConstants.S_OK); } } return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result)); }
protected override ImageMoniker GetIconMoniker(bool open) { if (!ItemNode.IsExcluded && AllChildren.Any(n => ModulePath.IsInitPyFile(n.Url))) { return(open ? KnownMonikers.PackageFolderOpened : KnownMonikers.PackageFolderClosed); } return(base.GetIconMoniker(open)); }
/// <summary> /// Persists the events. /// </summary> public void PersistEvents() { persistSessionEvents(SessionData.Session); foreach (var child in AllChildren.Where(x => x.ProtocolEvents.Count > 0)) { child.persistSessionEvents(SessionData.Session); } Clear(); }
void HighlightSelectedTab() { foreach (var vm in CurrentNavPath()) { var selected = AllChildren.OfType <Tab>().FirstOrDefault(tab => tab.VM == vm); if (selected != null) { selected.Highlight(); return; } } }
internal override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { if (cmdGroup == Guids.NodejsNpmCmdSet) { switch (cmd) { case PkgCmdId.cmdidNpmUpdateModules: var t = _parent.UpdateModules(AllChildren.ToList()); return(VSConstants.S_OK); } } return(base.ExecCommandOnNode(cmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut)); }
public void ApplyConfigurationToLink(WorkItem item, WorkItem parent) { if (SyncService != null) { if (!SyncService.Value.CheckAccess()) { SyncService.Value.Invoke(new Action <WorkItem, WorkItem>(ApplyConfigurationToLink), item, parent); return; } } foreach (var bcklog in BacklogChildren) { if (bcklog.Backlog.Id == parent.Id) { bcklog.Children.Add(item); FlushWindowsMessageQueue(true); break; } } AllChildren.Add(item); }
public void Disconnect() { TeamProject = null; TeamProjectCollection = null; WorkItemLinkInfos = new WorkItemLinkInfo[0]; if (AllChildren != null) { AllChildren.Clear(); } if (BacklogChildren.Count > 0) { ApplyChildrenChangesOnUIThread(new List <BacklogChildren>()); } if (BackLogItems != null) { BackLogItems.Clear(); } LoginData = new LoginData(); ReportFolder = null; ReportServerUrl = null; WorkItems = null; OnDisconnected(); }
private async Task RefreshPackagesAsync(IPackageManager packageManager) { if (_suppressPackageRefresh || packageManager == null) { return; } bool prevChecked = _checkedItems; // Use _checkingItems to prevent the expanded state from // disappearing too quickly. _checkingItems = true; _checkedItems = true; var packages = new Dictionary <string, PackageSpec>(); foreach (var p in await packageManager.GetInstalledPackagesAsync(CancellationToken.None)) { packages[p.FullSpec] = p; } await ProjectMgr.Site.GetUIThread().InvokeAsync(() => { if (ProjectMgr == null || ProjectMgr.IsClosed) { return; } try { var logger = ProjectMgr.Site.GetPythonToolsService().Logger; if (logger != null) { foreach (var p in packages) { logger.LogEvent(PythonLogEvent.PythonPackage, new PackageInfo { Name = p.Value.Name.ToLowerInvariant() }); } } } catch (Exception ex) { Debug.Fail(ex.ToUnhandledExceptionMessage(GetType())); } bool anyChanges = false; var existing = AllChildren.OfType <InterpretersPackageNode>().ToDictionary(c => c.Url); // remove the nodes which were uninstalled. foreach (var keyValue in existing) { if (!packages.Remove(keyValue.Key)) { RemoveChild(keyValue.Value); anyChanges = true; } } // add the new nodes foreach (var p in packages.OrderBy(kv => kv.Key)) { AddChild(new InterpretersPackageNode(ProjectMgr, p.Value)); anyChanges = true; } _checkingItems = false; ProjectMgr.OnInvalidateItems(this); if (!prevChecked) { if (anyChanges) { ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Expandable, 0); } if (ProjectMgr.ParentHierarchy != null) { ExpandItem(EXPANDFLAGS.EXPF_CollapseFolder); } } }); }
public void ApplyConfiguration(IConfiguration configuration) { if (TeamProjectCollection == null) { return; } if (configuration == null) { return; } if (configuration.QueryId == Guid.Empty) { var errorMessage = StatusService.EnqueueStatusItem("InvalidQuery"); errorMessage.Message = "There is no query defined in the configuration. Please choose a query by clicking \"Edit\""; return; } // Before refreshing the data we should verify whether there are unsaved changes that need to be saved if (!VerifySaveRequest()) { return; } var statusItem = StatusService.EnqueueStatusItem("ApplyConfiguration"); statusItem.Message = string.Format("Applying configuration for team project {0}", TeamProject.Name); statusItem.IsProgressing = true; statusItem.IsProgressIndeterminate = true; // Run the query in order to provide the result data var store = TeamProjectCollection.GetService <WorkItemStore>(); // Get the query based on the Id we keep in the configuration QueryDefinition queryDefinition = SaveGetQueryDefinition(store, configuration.QueryId); Query query = GetQuery(queryDefinition); // Only if the query is a link query we perform the fullblown request for data if ((query != null) && (query.IsLinkQuery)) { // First get the linking information WorkItemLinkInfos = query.RunLinkQuery(); // Get the configured link type in order to respect it when retrieving the work items var linkType = (!string.IsNullOrEmpty(configuration.LinkType)) ? store.WorkItemLinkTypes.FirstOrDefault(type => type.ReferenceName == configuration.LinkType) : null; // Now put all TargetIds into a BatchReadParameterCollection in order to get the work items for the links // Attention: Consider handling the link types correctly var batchReadParams = new BatchReadParameterCollection(); foreach (var linkInfo in WorkItemLinkInfos) { if (linkType == null) { // If there is no link type there is nothing we can check explicitly and therefor we respect any child if (!batchReadParams.Contains(linkInfo.TargetId)) { batchReadParams.Add(new BatchReadParameter(linkInfo.TargetId)); } } else { // Debug.WriteLink("Link: {0} Source: {1} Target: {2} RefName: {3} Forward: {4} Reverse: {5}", linkInfo.LinkTypeId, linkInfo.SourceId, linkInfo.TargetId, linkType.ReferenceName, linkType.ForwardEnd.Id, linkType.ReverseEnd.Id); // We need to respect the link type. if (IsValidLinkInfo(linkInfo, linkType)) { // When the link info is valid according to the current configuration then we consider the work item in our query. if (!batchReadParams.Contains(linkInfo.TargetId)) { batchReadParams.Add(new BatchReadParameter(linkInfo.TargetId)); } } // When the link type is not valid we also do not consider the item. } } // Now construct the query to get the work items string batchQuery = "SELECT {0} FROM WorkItems"; List <string> displayFields = (from FieldDefinition fieldDefinition in query.DisplayFieldList select fieldDefinition.ReferenceName).ToList(); string displayFieldPart = string.Join(",", displayFields.ToArray()); if (batchReadParams.Count != 0) { batchQuery = string.Format(batchQuery, displayFieldPart); // Run the query and remember the results WorkItems = store.Query(batchReadParams, batchQuery); BuildBacklogItemsList(configuration); BuildChildItemsList(configuration); } else { ApplyChildrenChangesOnUIThread(new List <BacklogChildren>()); } } else { WorkItemLinkInfos = null; WorkItems = query != null?query.RunQuery() : null; if (AllChildren != null) { AllChildren.Clear(); } if (BacklogChildren.Count > 0) { BacklogChildren.Clear(); } if (BackLogItems != null) { BackLogItems.Clear(); } } PrepareTransitionsMap(configuration); OnConfigurationApplied(); }
private async Task CheckPackagesAsync() { var uiThread = ProjectMgr.Site.GetUIThread(); uiThread.MustBeCalledFromUIThreadOrThrow(); bool prevChecked = _checkedItems; // Use _checkingItems to prevent the expanded state from // disappearing too quickly. _checkingItems = true; _checkedItems = true; if (!Directory.Exists(_factory.Configuration.LibraryPath)) { _checkingItems = false; ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Expandable, 0); return; } HashSet <string> lines; bool anyChanges = false; try { lines = await Pip.List(_factory).ConfigureAwait(true); } catch (NoInterpretersException) { return; } // Ensure we are back on the UI thread uiThread.MustBeCalledFromUIThread(); if (ProjectMgr == null || ProjectMgr.IsClosed) { return; } var existing = AllChildren.ToDictionary(c => c.Url); // remove the nodes which were uninstalled. foreach (var keyValue in existing) { if (!lines.Contains(keyValue.Key)) { RemoveChild(keyValue.Value); anyChanges = true; } } // remove already existing nodes so we don't add them a 2nd time lines.ExceptWith(existing.Keys); // add the new nodes foreach (var line in lines) { AddChild(new InterpretersPackageNode(ProjectMgr, line)); anyChanges = true; var packageInfo = PythonProjectNode.FindRequirementRegex.Match(line.ToLower()); if (packageInfo.Groups["name"].Success) { //Log the details of the Installation var packageDetails = new Logging.PackageInstallDetails( packageInfo.Groups["name"].Value, packageInfo.Groups["ver"].Success ? packageInfo.Groups["ver"].Value : String.Empty, _factory.GetType().Name, _factory.Configuration.Version.ToString(), _factory.Configuration.Architecture.ToString(), "Existing", //Installer if we tracked it false, //Installer was not run elevated 0); //The installation already existed ProjectMgr.Site.GetPythonToolsService().Logger.LogEvent(Logging.PythonLogEvent.PackageInstalled, packageDetails); } } _checkingItems = false; ProjectMgr.OnInvalidateItems(this); if (!prevChecked) { if (anyChanges) { ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Expandable, 0); } if (ProjectMgr.ParentHierarchy != null) { ExpandItem(EXPANDFLAGS.EXPF_CollapseFolder); } } if (prevChecked && anyChanges) { var withDb = _factory as IPythonInterpreterFactoryWithDatabase; if (withDb != null) { withDb.GenerateDatabase(GenerateDatabaseOptions.SkipUnchanged); } } }
public override string ToString() => base.ToString() + " > " + AllChildren.LastOrDefault();
private async Task RefreshPackagesAsync(IPackageManager packageManager) { if (_suppressPackageRefresh || packageManager == null) { return; } bool prevChecked = _checkedItems; // Use _checkingItems to prevent the expanded state from // disappearing too quickly. _checkingItems = true; _checkedItems = true; var packages = new Dictionary <string, PackageSpec>(); foreach (var p in await packageManager.GetInstalledPackagesAsync(CancellationToken.None)) { packages[p.FullSpec] = p; } await ProjectMgr.Site.GetUIThread().InvokeAsync(() => { if (ProjectMgr == null || ProjectMgr.IsClosed) { return; } bool anyChanges = false; var existing = AllChildren.OfType <InterpretersPackageNode>().ToDictionary(c => c.Url); // remove the nodes which were uninstalled. foreach (var keyValue in existing) { if (!packages.Remove(keyValue.Key)) { RemoveChild(keyValue.Value); anyChanges = true; } } // add the new nodes foreach (var p in packages.OrderBy(kv => kv.Key)) { AddChild(new InterpretersPackageNode(ProjectMgr, p.Value)); anyChanges = true; } _checkingItems = false; ProjectMgr.OnInvalidateItems(this); if (!prevChecked) { if (anyChanges) { ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Expandable, 0); } if (ProjectMgr.ParentHierarchy != null) { ExpandItem(EXPANDFLAGS.EXPF_CollapseFolder); } } if (prevChecked && anyChanges) { var withDb = _factory as IPythonInterpreterFactoryWithDatabase; if (withDb != null) { withDb.GenerateDatabase(GenerateDatabaseOptions.SkipUnchanged); } } }); }
/// <summary> /// Gets the all child elements as flat collection. /// </summary> /// <param name="type">An element type to specifiy which elements to get.</param> /// <returns>All children that have the specified type.</returns> public OlapElements ChildrenFlatHierarchy(OlapElementType type) { return(AllChildren.FlatHierarchy(type)); }