Skip to content
Snippets Groups Projects
Commit 045ddd9b authored by Sytze de Witte's avatar Sytze de Witte
Browse files

added final features analysis results window

parent 910305c1
No related branches found
No related tags found
No related merge requests found
No preview for this file type
File added
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white" width="18px" height="18px"><path d="M0 0h24v24H0z" fill="none"/><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#FFFFFF"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M16 1H2v16h2V3h12V1zm5 4H6v18h15V5zm-2 16H8V7h11v14z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black" width="18px" height="18px"><path d="M0 0h24v24H0z" fill="none"/><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M16 1H2v16h2V3h12V1zm5 4H6v18h15V5zm-2 16H8V7h11v14z"/></svg>
\ No newline at end of file
......@@ -48,24 +48,36 @@
},
{
"command": "analysisResults.load",
"title": "Load analysis results"
"title": "Open analysis results"
},
{
"command": "analysisResults.export",
"title": "Save as JSON file"
"title": "Save analysis results"
},
{
"command": "analysisResults.openFileInEditor",
"title": "Open in editor"
"title": "Show results in editor"
},
{
"command": "analysisResults.openInEditor",
"title": "Open value in editor"
"title": "Show value in editor"
},
{
"command": "analysisResults.openInCompView",
"title": "Move results to second view"
"title": "Show results in comparison view"
},
{
"command": "analysisResultsCompView.load",
"title": "Open analysis results"
},
{
"command": "analysisResultsCompView.export",
"title": "Save analysis results"
},
{
"command": "analysisResultsCompView.openFileInEditor",
"title": "Show results in editor"
},
{
"command": "analysisResultsCompView.clearCompView",
"title": "Clear comparison view"
......@@ -75,11 +87,13 @@
"view/title": [
{
"command": "analysisResults.load",
"when": "view == analysisResults"
"when": "view == analysisResults",
"group": "file"
},
{
"command": "analysisResults.export",
"when": "view == analysisResults"
"when": "view == analysisResults",
"group": "file"
},
{
"command": "analysisResults.openFileInEditor",
......@@ -88,6 +102,20 @@
{
"command": "analysisResults.openInCompView",
"when": "view == analysisResults"
},
{
"command": "analysisResultsCompView.load",
"when": "view == analysisResultsCompView",
"group": "file"
},
{
"command": "analysisResultsCompView.export",
"when": "view == analysisResultsCompView",
"group": "file"
},
{
"command": "analysisResultsCompView.openFileInEditor",
"when": "view == analysisResultsCompView"
},
{
"command": "analysisResultsCompView.clearCompView",
......@@ -97,20 +125,22 @@
"view/item/context": [
{
"command": "analysisResults.copyValue",
"when": "(view == analysisResults || view == analysisResultsCompView) && viewItem != empty",
"when": "view == analysisResults && viewItem != empty || view == analysisResultsCompView && viewItem != empty",
"group": "inline"
},
{
"command": "analysisResults.copyValue",
"when": "(view == analysisResults || view == analysisResultsCompView) && viewItem != empty"
"when": "view == analysisResults && viewItem != empty || view == analysisResultsCompView && viewItem != empty",
"group": "copy"
},
{
"command": "analysisResults.copyItem",
"when": "(view == analysisResults || view == analysisResultsCompView)"
"when": "view == analysisResults || view == analysisResultsCompView",
"group": "copy"
},
{
"command": "analysisResults.openInEditor",
"when": "(view == analysisResults || view == analysisResultsCompView) && viewItem != empty"
"when": "view == analysisResults && viewItem != empty || view == analysisResultsCompView && viewItem != empty"
}
]
},
......@@ -209,7 +239,7 @@
},
{
"view": "analysisResultsCompView",
"contents": "Move additional analysis results to this view to compare."
"contents": "Show additional analysis results in this view to compare."
}
],
"snippets": [
......
......@@ -101,14 +101,29 @@ export class AnalysisResultsProvider
);
data.push(openParameterValues);
}
const analysisResultsData = new Result(
"Analysis results",
"",
[],
this.dataToResult(root["data"], null),
vscode.TreeItemCollapsibleState.Expanded,
label
);
var analysisResultsData: Result;
// Check or simulate
if (root["data"].length === 1 && !root["data"][0]["group"] && !root["data"][0]["group"]) {
// Simulate
analysisResultsData = new Result(
"Analysis results",
"",
this.valuesToResults(root["data"][0]["values"], null),
this.dataToResult(root["data"][0]["data"], null),
vscode.TreeItemCollapsibleState.Expanded,
label
);
} else {
// Check
analysisResultsData = new Result(
"Analysis results",
"",
[],
this.dataToResult(root["data"], null),
vscode.TreeItemCollapsibleState.Expanded,
label
);
}
data.push(analysisResultsData);
return new Result(this.modestFile, "", values, data, vscode.TreeItemCollapsibleState.Expanded, null);
......@@ -117,31 +132,27 @@ export class AnalysisResultsProvider
dataToResult(data: JSON[], parentName: string | null) {
var results: Result[] = [];
data.forEach((element: { [x: string]: any }) => {
var label = "";
if (element["group"]) {
label = element["group"];
} else if (element["property"]) {
label = element["property"];
}
var value = element["value"] ? String(element["value"]) : "";
var values = element["values"]
? this.valuesToResults(element["values"], label)
: [];
var data = element["data"]
? this.dataToResult(element["data"], label)
: [];
results.push(
new Result(
label,
value,
values,
data,
vscode.TreeItemCollapsibleState.Collapsed,
parentName
)
);
});
if (data) {
data.forEach((element: { [x: string]: any }) => {
var label = "";
if (element["group"]) {
label = element["group"];
} else if (element["property"]) {
label = element["property"];
}
var value = element["value"] ? String(element["value"]) : "";
results.push(
new Result(
label,
value,
this.valuesToResults(element["values"], label),
this.dataToResult(element["data"], label),
vscode.TreeItemCollapsibleState.Collapsed,
parentName
)
);
});
}
return results;
}
......@@ -149,22 +160,24 @@ export class AnalysisResultsProvider
valuesToResults(values: JSON[], parentName: string | null) {
var results: Result[] = [];
values.forEach((v: { [x: string]: any }) => {
var label = String(v["name"]);
var unit = v["unit"] ? " " + String(v["unit"]) : "";
var value = v["value"] + unit;
results.push(
new Result(
label,
value,
[],
[],
vscode.TreeItemCollapsibleState.None,
parentName
)
);
});
if (values) {
values.forEach((v: { [x: string]: any }) => {
var label = String(v["name"]);
var unit = v["unit"] ? " " + String(v["unit"]) : "";
var value = v["value"] + unit;
results.push(
new Result(
label,
value,
[],
[],
vscode.TreeItemCollapsibleState.None,
parentName
)
);
});
}
return results;
}
......@@ -202,7 +215,11 @@ export class Result extends vscode.TreeItem {
private parentName: string | null
) {
super(label, collapsibleState);
this.tooltip = `${this.label}: ${this.value}`;
if (value !== "") {
this.tooltip = `${this.label}: ${this.value}`;
} else {
this.tooltip = this.label;
}
this.description = this.value;
}
......
......@@ -187,7 +187,7 @@ export function activate(context: ExtensionContext) {
vscode.commands.registerCommand(
"analysisResults.copyItem",
(res: Result) => copyToClipboard(`${res.getLabel()}: ${res.getValue()}`)
(res: Result) => copyItemToClipboard(res)
);
vscode.commands.registerCommand(
......@@ -199,16 +199,28 @@ export function activate(context: ExtensionContext) {
"analysisResults.load",
() => loadResults(analysisResultsProvider)
);
vscode.commands.registerCommand(
"analysisResultsCompView.load",
() => loadResults(analysisResultsCompProvider)
);
vscode.commands.registerCommand(
"analysisResults.export",
() => exportResults(analysisResultsProvider)
);
vscode.commands.registerCommand(
"analysisResultsCompView.export",
() => exportResults(analysisResultsCompProvider)
);
vscode.commands.registerCommand(
"analysisResults.openFileInEditor",
() => openFileInEditor(analysisResultsProvider)
);
vscode.commands.registerCommand(
"analysisResultsCompView.openFileInEditor",
() => openFileInEditor(analysisResultsCompProvider)
);
vscode.commands.registerCommand(
"analysisResults.openInCompView",
......@@ -235,6 +247,14 @@ function copyToClipboard(text: string) {
vscode.window.showInformationMessage(`Copied ${text} to clipboard.`);
}
function copyItemToClipboard(res: Result) {
if (res.getValue() !== "") {
return copyToClipboard(`${res.getLabel()}: ${res.getValue()}`);
} else {
return copyToClipboard(res.getLabel());
}
}
function loadResults(provider: AnalysisResultsProvider) {
vscode.window.showOpenDialog().then(fileUri => {
if (fileUri) {
......@@ -248,11 +268,11 @@ function loadResults(provider: AnalysisResultsProvider) {
function exportResults(prov: AnalysisResultsProvider) {
if (prov.getJsonObject()) {
const defaultUri = vscode.workspace.workspaceFolders
? vscode.Uri.parse(`${vscode.workspace.workspaceFolders[0].uri.path}/analysis/${prov.getModestFile()}-results.json`)
? vscode.Uri.parse(`${vscode.workspace.workspaceFolders[0].uri.fsPath}/analysis/${prov.getModestFile()}-results.json`)
: undefined;
vscode.window.showSaveDialog({defaultUri : defaultUri}).then(f => {
if (f) {
fs.writeFileSync(f.path, JSON.stringify(prov.getJsonObject()));
fs.writeFileSync(f.fsPath, JSON.stringify(prov.getJsonObject()));
}
});
} else {
......@@ -262,7 +282,7 @@ function exportResults(prov: AnalysisResultsProvider) {
function openInEditor(prov: AnalysisResultsProvider, res: Result) {
if(vscode.workspace.workspaceFolders !== undefined) {
let wsPath = vscode.workspace.workspaceFolders[0].uri.path;
let wsPath = vscode.workspace.workspaceFolders[0].uri.fsPath;
const date = new Date().toISOString().split('.')[0];
const parent = res.getParentName() ? res.getParentName() + "-" : "";
const newPath = `${wsPath}/analysis/${prov.getModestFile()}-${parent}${res.getLabel()}.txt`;
......@@ -315,7 +335,7 @@ function openInEditor(prov: AnalysisResultsProvider, res: Result) {
function openFileInEditor(prov: AnalysisResultsProvider) {
if (prov.getJsonObject()) {
if(vscode.workspace.workspaceFolders !== undefined) {
let wsPath = vscode.workspace.workspaceFolders[0].uri.path;
let wsPath = vscode.workspace.workspaceFolders[0].uri.fsPath;
const date = new Date().toISOString().split('.')[0];
const newPath = `${wsPath}/analysis/${prov.getModestFile()}-results.json`;
const newText = JSON.stringify(prov.getJsonObject());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment