Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #240 from zowe/reveal-program-cmd
Browse files Browse the repository at this point in the history
reveal program command
  • Loading branch information
JeffinSiby committed Jun 16, 2022
2 parents 253a87f + d8ea495 commit 126269a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 4 deletions.
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@
"title": "Reveal Transaction",
"category": "Zowe Explorer for IBM CICS"
},
{
"command": "cics-extension-for-zowe.revealProgram",
"title": "Reveal Program",
"category": "Zowe Explorer for IBM CICS"
},
{
"command": "cics-extension-for-zowe.purgeTask",
"title": "Purge Task",
Expand Down Expand Up @@ -386,7 +391,7 @@
{
"when": "view == cics-view && viewItem =~ /^cicstransaction.*/",
"command": "cics-extension-for-zowe.showTransactionAttributes",
"group": ""
"group": "000_zowecics_main@0"
},
{
"when": "view == cics-view && viewItem =~ /^cicslocalfile.*/",
Expand All @@ -411,12 +416,12 @@
{
"when": "view == cics-view && viewItem =~ /^cicstransaction.disabled.*/",
"command": "cics-extension-for-zowe.enableTransaction",
"group": ""
"group": "000_zowecics_main@1"
},
{
"when": "view == cics-view && viewItem =~ /^cicstransaction.enabled.*/",
"command": "cics-extension-for-zowe.disableTransaction",
"group": ""
"group": "000_zowecics_main@1"
},
{
"when": "view == cics-view && viewItem =~ /^cicslocalfile.disabled.*/",
Expand Down Expand Up @@ -463,6 +468,11 @@
"command": "cics-extension-for-zowe.revealTransaction",
"group": "001_zowecics_reveal@0"
},
{
"when": "view == cics-view && viewItem =~ /^cicstransaction.*/",
"command": "cics-extension-for-zowe.revealProgram",
"group": "001_zowecics_reveal@0"
},
{
"when": "view == cics-view && viewItem =~ /^cicstask.*/",
"command": "cics-extension-for-zowe.purgeTask",
Expand Down
68 changes: 68 additions & 0 deletions src/commands/revealProgram.ts
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);
}
);
}
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { getRevealTransactionCommand } from "./commands/revealTransaction";
import { getPurgeTaskCommand } from "./commands/purgeTaskCommand";
import { getFilterAllTasksCommand } from "./commands/filterAllTasksCommand";
import { getFilterTasksCommand } from "./commands/filterTasksCommand";
import { getRevealProgramCommand } from "./commands/revealProgram";

export async function activate(context: ExtensionContext) {
const log = Logger.getAppLogger();
Expand Down Expand Up @@ -269,7 +270,8 @@ export async function activate(context: ExtensionContext) {

viewMoreCommand(treeDataProv, treeview),

getRevealTransactionCommand(treeDataProv, treeview)
getRevealTransactionCommand(treeDataProv, treeview),
getRevealProgramCommand(treeDataProv, treeview)
);
}

0 comments on commit 126269a

Please sign in to comment.