Skip to content

Commit e550247

Browse files
committed
Added GraphState class
1 parent a4685c3 commit e550247

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

src/commands/showHierarchyBase.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CommandBase } from '@commands';
22
import { Config, DgmlManager, FileSystemUtils, GraphVizManager } from '@src';
3-
import { Edge, Node } from '@model';
3+
import { Edge, GraphState, Node } from '@model';
44
import { Base64 } from 'js-base64';
55
import * as fs from 'fs';
66
import * as path from 'path';
@@ -14,6 +14,7 @@ export class ShowHierarchyBase extends CommandBase {
1414
protected fsUtils: FileSystemUtils = new FileSystemUtils();
1515
protected config = new Config();
1616
protected extensionContext: vscode.ExtensionContext;
17+
protected graphState: GraphState;
1718
protected nodes: Node[] = [];
1819
protected edges: Edge[] = [];
1920
protected templateJsFilename: string = 'showHierarchy_Template.js';
@@ -23,9 +24,10 @@ export class ShowHierarchyBase extends CommandBase {
2324
protected showHierarchyCssFilename: string = 'showHierarchy.css';
2425
protected workspaceDirectory = this.fsUtils.getWorkspaceFolder();
2526

26-
constructor(context: vscode.ExtensionContext) {
27+
constructor(context: vscode.ExtensionContext, graphState: GraphState) {
2728
super();
2829
this.extensionContext = context;
30+
this.graphState = graphState;
2931
}
3032
protected appendNodes = (nodeList: Node[]) => {
3133
nodeList.forEach(newNode => {

src/extension.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ShowModuleHierarchy,
1313
GenerateDependencyInjectionGraph
1414
} from '@commands';
15+
import { GraphState } from '@model';
1516

1617
export function activate(context: vscode.ExtensionContext) {
1718

@@ -48,6 +49,7 @@ export function activate(context: vscode.ExtensionContext) {
4849
context.subscriptions.push(componentHierarchyMarkdownDisposable);
4950

5051
let componentHierarchyPanel: vscode.WebviewPanel | undefined = undefined;
52+
const componentHierarchyGraphState: GraphState = new GraphState();
5153
const showComponentHierarchyDisposable = vscode.commands.registerCommand(`${cmdPrefix}.${ShowComponentHierarchy.commandName}`, () => {
5254
if (componentHierarchyPanel !== undefined) {
5355
componentHierarchyPanel.reveal(vscode.ViewColumn.One);
@@ -64,12 +66,13 @@ export function activate(context: vscode.ExtensionContext) {
6466
}, null, context.subscriptions);
6567
}
6668
componentHierarchyPanel.onDidDispose(() => componentHierarchyPanel = undefined, undefined, context.subscriptions);
67-
const command = new ShowComponentHierarchy(context);
69+
const command = new ShowComponentHierarchy(context, componentHierarchyGraphState);
6870
command.execute(componentHierarchyPanel.webview);
6971
});
7072
context.subscriptions.push(showComponentHierarchyDisposable);
7173

7274
let moduleHierarchyPanel: vscode.WebviewPanel | undefined = undefined;
75+
const moduleHierarchyGraphState: GraphState = new GraphState();
7376
const showModuleHierarchyDisposable = vscode.commands.registerCommand(`${cmdPrefix}.${ShowModuleHierarchy.commandName}`, () => {
7477
if (moduleHierarchyPanel !== undefined) {
7578
moduleHierarchyPanel.reveal(vscode.ViewColumn.One);
@@ -86,12 +89,13 @@ export function activate(context: vscode.ExtensionContext) {
8689
}, null, context.subscriptions);
8790
}
8891
moduleHierarchyPanel.onDidDispose(() => moduleHierarchyPanel = undefined, undefined, context.subscriptions);
89-
const command = new ShowModuleHierarchy(context);
92+
const command = new ShowModuleHierarchy(context, moduleHierarchyGraphState);
9093
command.execute(moduleHierarchyPanel.webview);
9194
});
9295
context.subscriptions.push(showModuleHierarchyDisposable);
9396

9497
let dependencyInjectionGraphPanel: vscode.WebviewPanel | undefined = undefined;
98+
const dependencyInjectionGraphState: GraphState = new GraphState();
9599
const generateDependencyInjectionGraphDisposable = vscode.commands.registerCommand(`${cmdPrefix}.${GenerateDependencyInjectionGraph.commandName}`, () => {
96100
if (dependencyInjectionGraphPanel !== undefined) {
97101
dependencyInjectionGraphPanel.reveal(vscode.ViewColumn.One);
@@ -108,7 +112,7 @@ export function activate(context: vscode.ExtensionContext) {
108112
}, null, context.subscriptions);
109113
}
110114
dependencyInjectionGraphPanel.onDidDispose(() => dependencyInjectionGraphPanel = undefined, undefined, context.subscriptions);
111-
const command = new GenerateDependencyInjectionGraph(context);
115+
const command = new GenerateDependencyInjectionGraph(context, dependencyInjectionGraphState);
112116
command.execute(dependencyInjectionGraphPanel.webview);
113117
});
114118
context.subscriptions.push(generateDependencyInjectionGraphDisposable);

src/model/GraphState.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Position } from "./Position";
2+
3+
export class GraphState {
4+
public graphLayout: string | undefined;
5+
public networkSeed: number | undefined;
6+
public nodePositions: Position | undefined;
7+
}

src/model/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from './BoundingBox';
44
export * from './Category';
55
export * from './Component';
66
export * from './Edge';
7+
export * from './GraphState';
78
export * from './NamedEntity';
89
export * from './NetworkNode';
910
export * from './Node';

0 commit comments

Comments
 (0)