Skip to content

Commit e9ab932

Browse files
committed
Save as Png button changed to a dropdown. Node positions now messagesd back to the command when clicking Save as Dgml.
1 parent 6f5d16d commit e9ab932

File tree

6 files changed

+85
-2
lines changed

6 files changed

+85
-2
lines changed

src/commands/generateDependencyInjectionGraph.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ export class GenerateDependencyInjectionGraph extends ShowHierarchyBase {
2020
undefined,
2121
this.extensionContext.subscriptions
2222
);
23+
webview.onDidReceiveMessage(
24+
message => {
25+
switch (message.command) {
26+
case 'saveAsDgml':
27+
console.log(message.text);
28+
return;
29+
}
30+
},
31+
undefined,
32+
this.extensionContext.subscriptions
33+
);
2334
var workspaceFolder = this.fsUtils.getWorkspaceFolder();
2435
const errors: string[] = [];
2536
const project: Project = ModuleManager.scanProject(workspaceFolder, errors, this.isTypescriptFile);

src/commands/showComponentHierarchy.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ export class ShowComponentHierarchy extends ShowHierarchyBase {
2020
undefined,
2121
this.extensionContext.subscriptions
2222
);
23+
webview.onDidReceiveMessage(
24+
message => {
25+
switch (message.command) {
26+
case 'saveAsDgml':
27+
console.log(message.text);
28+
return;
29+
}
30+
},
31+
undefined,
32+
this.extensionContext.subscriptions
33+
);
2334

2435
var directoryPath: string = this.fsUtils.getWorkspaceFolder();
2536
const components = ComponentManager.findComponents(directoryPath);

src/commands/showModuleHierarchy.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ export class ShowModuleHierarchy extends ShowHierarchyBase {
2020
undefined,
2121
this.extensionContext.subscriptions
2222
);
23+
webview.onDidReceiveMessage(
24+
message => {
25+
switch (message.command) {
26+
case 'saveAsDgml':
27+
console.log(message.text);
28+
return;
29+
}
30+
},
31+
undefined,
32+
this.extensionContext.subscriptions
33+
);
2334
var workspaceFolder = this.fsUtils.getWorkspaceFolder();
2435
const errors: string[] = [];
2536
const project: Project = ModuleManager.scanProject(workspaceFolder, errors, this.isTypescriptFile);

stylesheet/showHierarchy.css

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,30 @@ input[type=button] {
4040
#hierarchicalOptions_direction, #hierarchicalOptions_sortmethod {
4141
display: none;
4242
margin-left: 3px;
43-
}
43+
}
44+
45+
.dropdown {
46+
position: relative;
47+
display: inline-block;
48+
}
49+
50+
.dropdown-content {
51+
display: none;
52+
position: absolute;
53+
background-color: #f1f1f1;
54+
min-width: 130px;
55+
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
56+
z-index: 1;
57+
}
58+
59+
.dropdown-content a {
60+
color: black;
61+
padding: 12px 16px;
62+
text-decoration: none;
63+
display: block;
64+
}
65+
66+
.dropdown-content a:hover {background-color: #ddd;}
67+
68+
.dropdown:hover .dropdown-content {display: block;}
69+

templates/showHierarchy_Template.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313

1414
<body>
1515
<div id="buttons">
16-
<input type="button" id="saveAsPngButton" value="Save as png">
16+
<div class="dropdown">
17+
<input type="button" id="saveAsButton" value="Save as ...">
18+
<div class="dropdown-content">
19+
<a href="#" id="saveAsPngButton">Save as Png</a>
20+
<a href="#" Id="saveAsDgmlButton">Save as Dgml</a>
21+
</div>
22+
</div>
1723
<input type="button" id="saveSelectionAsPngButton" value="Save selection as png">
1824
<input type="button" id="copyToClipboardButton" value="Copy to clipboard">
1925
<div id="hierarchical">Change layout:<input type="checkbox" id="showHierarchicalOptions"></div>

templates/showHierarchy_Template.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
// add button event listeners
5454
const saveAsPngButton = document.getElementById('saveAsPngButton');
5555
saveAsPngButton.addEventListener('click', saveAsPng);
56+
const saveAsDgmlButton = document.getElementById('saveAsDgmlButton');
57+
saveAsDgmlButton.addEventListener('click', saveAsDgml);
5658
const saveSelectionAsPngButton = document.getElementById('saveSelectionAsPngButton');
5759
saveSelectionAsPngButton.addEventListener('click', saveSelectionAsPng);
5860
const copyToClipboardButton = document.getElementById('copyToClipboardButton');
@@ -242,6 +244,22 @@
242244
};
243245
}
244246

247+
function saveAsDgml() {
248+
const nodeExport = [];
249+
nodes.forEach(node => {
250+
nodeExport.push({
251+
id: node.id,
252+
label: node.label,
253+
color: node.color,
254+
position: network.getPosition(node.id)
255+
});
256+
});
257+
vscode.postMessage({
258+
command: 'saveAsDgml',
259+
text: nodeExport
260+
});
261+
}
262+
245263
function copyToClipboard() {
246264
console.log('Not implemented yet...');
247265
}

0 commit comments

Comments
 (0)