Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IDE-Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DP-Group 14
IDE-Plugin
Commits
1029001e
Commit
1029001e
authored
3 years ago
by
Smit, P.J.M. (Peter, Student M-CS)
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of
https://gitlab.utwente.nl/dp-group-14/ide-plugin
parents
687d01bd
af2e5b00
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
package.json
+19
-4
19 additions, 4 deletions
package.json
src/extension.ts
+65
-32
65 additions, 32 deletions
src/extension.ts
with
84 additions
and
36 deletions
package.json
+
19
−
4
View file @
1029001e
...
...
@@ -128,19 +128,27 @@
},
{
"command"
:
"modest.dotSaveSvg"
,
"title"
:
"Save
to .svg
file"
"title"
:
"Save
as SVG
file"
},
{
"command"
:
"modest.dotCopySvg"
,
"title"
:
"Copy
svg
to clipboard"
"title"
:
"Copy
SVG
to clipboard"
},
{
"command"
:
"modest.dotSaveDot"
,
"title"
:
"Save
to .dot
file"
"title"
:
"Save
as DOT
file"
},
{
"command"
:
"modest.dotCopyDot"
,
"title"
:
"Copy dot to clipboard"
"title"
:
"Copy DOT to clipboard"
},
{
"command"
:
"modest.savePlot"
,
"title"
:
"Save plot as image"
,
"icon"
:
{
"light"
:
"media/light/save.svg"
,
"dark"
:
"media/dark/save.svg"
}
}
],
"menus"
:
{
...
...
@@ -240,6 +248,13 @@
"command"
:
"modest.dotZoomIn"
,
"group"
:
"navigation@3"
},
{
"when"
:
"modest:plotViewFocused"
,
"command"
:
"modest.savePlot"
,
"group"
:
"navigation"
}
],
"editor/title/context"
:
[
{
"when"
:
"modest:dotViewFocused"
,
"command"
:
"modest.dotSaveSvg"
...
...
This diff is collapsed.
Click to expand it.
src/extension.ts
+
65
−
32
View file @
1029001e
...
...
@@ -28,6 +28,8 @@ export let clientReady: boolean = false;
export
let
disposalQueue
:
Array
<
vscode
.
Disposable
>
=
[];
export
let
resultHandlers
:
Array
<
(
notification
:
ResultNotification
)
=>
void
>
=
[];
export
let
activePlotView
:
vscode
.
Webview
;
export
function
modestExecutable
():
string
|
undefined
{
let
executable
:
string
|
undefined
=
vscode
.
workspace
.
getConfiguration
(
"
modest
"
)
...
...
@@ -223,67 +225,72 @@ export function activate(context: ExtensionContext) {
);
//#region register commands
vscode
.
commands
.
registerCommand
(
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.copyValue
"
,
(
res
:
Result
)
=>
copyToClipboard
(
res
.
getValue
())
);
vscode
.
commands
.
registerCommand
(
)
);
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.copyItem
"
,
(
res
:
Result
)
=>
copyItemToClipboard
(
res
)
);
vscode
.
commands
.
registerCommand
(
)
);
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.openInEditor
"
,
(
res
:
Result
)
=>
openInEditor
(
analysisResultsProvider
,
res
)
);
vscode
.
commands
.
registerCommand
(
)
);
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.highlight
"
,
(
res
:
Result
)
=>
highlight
(
res
)
);
vscode
.
commands
.
registerCommand
(
)
);
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.plotValue
"
,
(
res
:
Result
)
=>
plotValue
(
res
,
context
)
);
)
);
vscode
.
commands
.
registerCommand
(
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.load
"
,
()
=>
loadResults
(
analysisResultsProvider
)
);
vscode
.
commands
.
registerCommand
(
)
);
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResultsCompView.load
"
,
()
=>
loadResults
(
analysisResultsCompProvider
)
);
)
);
vscode
.
commands
.
registerCommand
(
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.export
"
,
()
=>
exportResults
(
analysisResultsProvider
)
);
vscode
.
commands
.
registerCommand
(
)
);
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResultsCompView.export
"
,
()
=>
exportResults
(
analysisResultsCompProvider
)
);
)
);
vscode
.
commands
.
registerCommand
(
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.openFileInEditor
"
,
()
=>
openFileInEditor
(
analysisResultsProvider
)
);
vscode
.
commands
.
registerCommand
(
)
);
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResultsCompView.openFileInEditor
"
,
()
=>
openFileInEditor
(
analysisResultsCompProvider
)
);
)
);
vscode
.
commands
.
registerCommand
(
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.clear
"
,
()
=>
clearView
(
analysisResultsProvider
)
);
vscode
.
commands
.
registerCommand
(
)
);
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResultsCompView.clearCompView
"
,
()
=>
clearView
(
analysisResultsCompProvider
)
);
)
);
vscode
.
commands
.
registerCommand
(
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
analysisResults.openInCompView
"
,
()
=>
analysisResultsCompProvider
.
setJsonObject
(
analysisResultsProvider
.
getJsonObject
())
);
));
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
"
modest.savePlot
"
,
()
=>
savePlot
()
));
//#endregion
}
...
...
@@ -464,6 +471,10 @@ function highlight(res: Result) {
analysisResultsCompProvider
.
refresh
();
}
function
savePlot
()
{
activePlotView
.
postMessage
({
command
:
'
savePlot
'
});
}
function
plotValue
(
res
:
Result
,
context
:
ExtensionContext
)
{
const
panel
=
vscode
.
window
.
createWebviewPanel
(
'
plotGraph
'
,
...
...
@@ -475,6 +486,20 @@ function plotValue(res: Result, context: ExtensionContext) {
}
);
activePlotView
=
panel
.
webview
;
panel
.
onDidDispose
(()
=>
{
vscode
.
commands
.
executeCommand
(
'
setContext
'
,
'
modest:plotViewFocused
'
,
false
);
});
panel
.
onDidChangeViewState
(
e
=>
{
vscode
.
commands
.
executeCommand
(
'
setContext
'
,
'
modest:plotViewFocused
'
,
e
.
webviewPanel
.
active
);
if
(
e
.
webviewPanel
.
active
)
{
activePlotView
=
e
.
webviewPanel
.
webview
;
}
}
);
vscode
.
commands
.
executeCommand
(
'
setContext
'
,
'
modest:plotViewFocused
'
,
panel
.
active
);
var
dataPoints
:
{
x
:
number
,
y
:
number
}[]
=
[];
const
value
=
res
.
getValue
();
const
regex
=
/
\((\d
+
\.?
d*
)
,.
(\d
+
\.?\d
*
)\)
/gm
;
...
...
@@ -497,8 +522,6 @@ function plotValue(res: Result, context: ExtensionContext) {
</head>
<body>
<canvas id="myChart"></canvas>
<button style="width: fit-content; position: absolute; top: 2%; right: 2%; padding: var(--input-margin-vertical) 0.8em;" onclick="save()">Save as Image</button>
<script nonce="
${
nonce
}
" src="
${
chart
}
"></script>
<script nonce="
${
nonce
}
">
var htmlStyle = document.documentElement.style;
...
...
@@ -564,11 +587,21 @@ function plotValue(res: Result, context: ExtensionContext) {
function save(){
if (image) {
vscode.postMessage({
command: 'save',
command: 'save
Image
',
url: image.toString()
})
}
}
window.addEventListener('message', event => {
const message = event.data;
switch (message.command) {
case 'savePlot':
save()
break;
}
});
</script>
</body>
</html>
...
...
@@ -577,7 +610,7 @@ function plotValue(res: Result, context: ExtensionContext) {
panel
.
webview
.
onDidReceiveMessage
(
message
=>
{
switch
(
message
.
command
)
{
case
'
save
'
:
case
'
save
Image
'
:
var
data
=
message
.
url
.
replace
(
/^data:image
\/\w
+;base64,/
,
""
);
var
buf
=
new
Buffer
(
data
,
'
base64
'
);
saveImage
(
res
,
buf
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment