This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from zowe/reveal-program-cmd
reveal program command
- Loading branch information
Showing
3 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
* | ||
*/ | ||
|
||
import { commands, TreeView, window } from "vscode"; | ||
import { CICSCombinedTransactionsTree } from "../trees/CICSCombinedTransactionTree"; | ||
import { CICSPlexTree } from "../trees/CICSPlexTree"; | ||
import { CICSProgramTree } from "../trees/CICSProgramTree"; | ||
import { CICSRegionsContainer } from "../trees/CICSRegionsContainer"; | ||
import { CICSRegionTree } from "../trees/CICSRegionTree"; | ||
import { CICSTree } from "../trees/CICSTree"; | ||
import { CICSTransactionTreeItem } from "../trees/treeItems/CICSTransactionTreeItem"; | ||
import { findSelectedNodes } from "../utils/commandUtils"; | ||
|
||
/** | ||
* Reveal the associated transaction tree item from a task tree item | ||
*/ | ||
export function getRevealProgramCommand(tree: CICSTree,treeview: TreeView<any>) { | ||
return commands.registerCommand( | ||
"cics-extension-for-zowe.revealProgram", | ||
async (node) => { | ||
const allSelectedNodes = findSelectedNodes(treeview, CICSTransactionTreeItem, node) as CICSTransactionTreeItem[]; | ||
if (!allSelectedNodes || !allSelectedNodes.length) { | ||
window.showErrorMessage("No CICS Transaction selected"); | ||
return; | ||
} | ||
let resourceFolders; | ||
if (allSelectedNodes[0].getParent() instanceof CICSCombinedTransactionsTree) { | ||
const cicsPlex: CICSPlexTree = allSelectedNodes[0].getParent().getParent(); | ||
const regionsContainer = cicsPlex.getChildren().filter(child => child instanceof CICSRegionsContainer)[0]; | ||
//@ts-ignore | ||
const regionTree: CICSRegionTree = regionsContainer.getChildren()!.filter(region => region.getRegionName() === allSelectedNodes[0].parentRegion.getRegionName())[0]; | ||
resourceFolders = regionTree.getChildren()!; | ||
} else { | ||
resourceFolders = allSelectedNodes[0].parentRegion.getChildren()!; | ||
} | ||
let tranids = []; | ||
for (const localTransactionTreeItem of allSelectedNodes) { | ||
const transaction = localTransactionTreeItem.transaction; | ||
tranids.push(transaction["program"]); | ||
} | ||
// Comma separated filter | ||
const pattern = tranids.join(", "); | ||
const programTree = resourceFolders.filter(child => child instanceof CICSProgramTree)[0] as CICSProgramTree; | ||
programTree.setFilter(pattern); | ||
await programTree.loadContents(); | ||
tree._onDidChangeTreeData.fire(undefined); | ||
|
||
if (allSelectedNodes[0].getParent() instanceof CICSCombinedTransactionsTree) { | ||
let nodeToExpand: any = programTree; | ||
|
||
// TODO: Ideal situation would be to do await treeview.reveal(nodeToExpand), however this is resulting in an error, | ||
// so reveal/highlight parent node instead | ||
await treeview.reveal(nodeToExpand.getParent()); | ||
tree._onDidChangeTreeData.fire(undefined); | ||
|
||
} | ||
tree._onDidChangeTreeData.fire(undefined); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters