Skip to content

Commit

Permalink
Merge pull request #17 from SoftVarE-Group/feat/intro
Browse files Browse the repository at this point in the history
Feat/intro
  • Loading branch information
st-vi authored Dec 12, 2023
2 parents 1b955c5 + aa66956 commit 19dc352
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 163 deletions.
175 changes: 90 additions & 85 deletions WebSocketClient/index.html
Original file line number Diff line number Diff line change
@@ -1,105 +1,110 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="split.css">
<link rel="stylesheet" href="toggleSwitch.css">
<title>UVL Playground</title>
</head>
<body>
<div class="header">
<h1>UVL Playground</h1>
<h2 id="connection" style="color: red;"></h2>
</div>
<div>
<dialog id="dialog">
<div>
<button autofocus id="modalClose">X</button>
</div>
<h1>Get the UVLS VSCode Extension</h1>
<p>You are trying to access the Configuration Page for Feature Models.
As by now, the Web-Playground does not support this, but it is available in the VSCode Extension!
Here is a preview:
</p>
<img src="https://raw.githubusercontent.com/Universal-Variability-Language/uvl-lsp/master/img/show_editor.gif" id="gif_in_dialog" alt="Preview">
<p>Get the extension <a href="https://marketplace.visualstudio.com/items?itemName=caradhras.uvls-code">here</a></p>
</dialog>
</div>
<div class="splitter">
<div id="first">
<div id="container" class="editor"></div>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="split.css">
<link rel="stylesheet" href="toggleSwitch.css">
<link rel="stylesheet" href="./node_modules/intro.js/introjs.css">
<link rel="stylesheet" href="./node_modules/intro.js/themes/introjs-modern.css">
<title>UVL Playground</title>
</head>
<body>
<div class="header">
<h1>UVL Playground</h1>
<h2 id="connection" style="color: red;"></h2>
</div>
<button id="tutorialButton">Give me a quick tutorial!</button>
<div>
<dialog id="dialog">
<div>
<button autofocus id="modalClose">X</button>
</div>
<div id="separator" ></div>
<h1>Get the UVLS VSCode Extension</h1>
<p>You are trying to access the Configuration Page for Feature Models.
As by now, the Web-Playground does not support this, but it is available in the VSCode Extension!
Here is a preview:
</p>
<img src="https://raw.githubusercontent.com/Universal-Variability-Language/uvl-lsp/master/img/show_editor.gif"
id="gif_in_dialog" alt="Preview">
<p>Get the extension <a href="https://marketplace.visualstudio.com/items?itemName=caradhras.uvls-code">here</a>
</p>
</dialog>
</div>
<div class="splitter">
<div id="first">
<div id="container" class="editor"></div>
</div>
<div id="separator"></div>

<div id="second">
<div class="graph"></div>

<div id="second">
<div class="graph"></div>

</div>
</div>

<div class="footer">
<p>The Universal Variability Language (UVL) is a community effort towards a widely adopted textual specification
for feature models. This playground provides the opportunity to get used to the language with
syntax-highlighting, autocompletion, and simple analysis. It is based on the <a
href="https://github.com/Universal-Variability-Language/uvl-lsp">UVL Language Server</a>. To fully
use all features use the UVLS - Universal Variability Language Server extension for visual studio code. </p>
</div>
<script type="module">
import {startPythonClient} from "./src/main.ts";
</div>

<div class="footer">
<p>The Universal Variability Language (UVL) is a community effort towards a widely adopted textual specification
for feature models. This playground provides the opportunity to get used to the language with
syntax-highlighting, autocompletion, and simple analysis. It is based on the <a
href="https://github.com/Universal-Variability-Language/uvl-lsp">UVL Language Server</a>. To fully
use all features use the UVLS - Universal Variability Language Server extension for visual studio code. </p>
</div>
<script type="module">
import {startPythonClient} from "./src/main.ts";

startPythonClient();
</script>
<script>
// A function is used for dragging and moving
function dragElement(element, direction)
{
var md; // remember mouse down info
const first = document.getElementById("first");
const second = document.getElementById("second");
startPythonClient();
</script>
<script>
// A function is used for dragging and moving
function dragElement(element, direction) {
var md; // remember mouse down info
const first = document.getElementById("first");
const second = document.getElementById("second");

element.onmousedown = onMouseDown;
element.onmousedown = onMouseDown;

function onMouseDown(e)
{
//console.log("mouse down: " + e.clientX);
md = {e,
offsetLeft: element.offsetLeft,
offsetTop: element.offsetTop,
firstWidth: first.offsetWidth,
secondWidth: second.offsetWidth
};
function onMouseDown(e) {
//console.log("mouse down: " + e.clientX);
md = {
e,
offsetLeft: element.offsetLeft,
offsetTop: element.offsetTop,
firstWidth: first.offsetWidth,
secondWidth: second.offsetWidth
};

document.onmousemove = onMouseMove;
document.onmouseup = () => {
//console.log("mouse up");
document.onmousemove = document.onmouseup = null;
document.onmousemove = onMouseMove;
document.onmouseup = () => {
//console.log("mouse up");
document.onmousemove = document.onmouseup = null;
}
}
}

function onMouseMove(e)
{
//console.log("mouse move: " + e.clientX);
var delta = {x: e.clientX - md.e.clientX,
y: e.clientY - md.e.clientY};
function onMouseMove(e) {
//console.log("mouse move: " + e.clientX);
var delta = {
x: e.clientX - md.e.clientX,
y: e.clientY - md.e.clientY
};

if (direction === "H" ) // Horizontal
{
// Prevent negative-sized elements
delta.x = Math.min(Math.max(delta.x, -md.firstWidth),
md.secondWidth);
if (direction === "H") // Horizontal
{
// Prevent negative-sized elements
delta.x = Math.min(Math.max(delta.x, -md.firstWidth),
md.secondWidth);

element.style.left = md.offsetLeft + delta.x + "px";
first.style.width = (md.firstWidth + delta.x) + "px";
second.style.width = (md.secondWidth - delta.x) + "px";
element.style.left = md.offsetLeft + delta.x + "px";
first.style.width = (md.firstWidth + delta.x) + "px";
second.style.width = (md.secondWidth - delta.x) + "px";
}
}
}
}


dragElement( document.getElementById("separator"), "H" );
</script>
</body>
dragElement(document.getElementById("separator"), "H");
</script>
</body>
</html>
6 changes: 6 additions & 0 deletions WebSocketClient/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions WebSocketClient/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@codingame/monaco-vscode-theme-service-override": "~1.83.2",
"@viz-js/viz": "^3.2.3",
"dotenv": "^16.3.1",
"intro.js": "^7.2.0",
"lodash": "^4.17.21",
"monaco-editor": "^0.44.0",
"monaco-editor-workers": "~0.44.0",
Expand Down
36 changes: 36 additions & 0 deletions WebSocketClient/src/intro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import introJs from "intro.js";
import { sendGenerateGraphCommand } from "./main";


export const initIntroJS = () => {


var intro = introJs();

intro.setOptions({
steps: [{
element: '#container', intro: 'This is the texteditor where you write and edit your uvl feature model.',
}, {
element: '.codelens-decoration', intro: 'You can use the buttons to activate and deactivate functionality.'
}, {
element: "[id='1']",
intro: 'Click here to visualize your feature model und click on it again to hide it again.'
}, {
element: "#separator", intro: 'You can change the size of the editor and the visualization with your mouse.'
}],
});

const button = document.getElementById("tutorialButton");

intro.onchange(function(targetElement) {
if(targetElement.id === "1"){
sendGenerateGraphCommand();
}

});

button?.addEventListener("click", () => {
intro.start();
});

}
27 changes: 19 additions & 8 deletions WebSocketClient/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import lodash from 'lodash';
import { ExecuteCommandRequest } from 'vscode-languageserver-protocol'

import { buildWorkerDefinition } from 'monaco-editor-workers';
import {initIntroJS} from "./intro.ts";
buildWorkerDefinition('./node_modules/monaco-editor-workers/dist/workers', new URL('', window.location.href).href, false);

const languageId = 'uvls';
Expand All @@ -34,6 +35,7 @@ let fileID;
let model;
const connectionText = document.getElementById("connection");
let debounceGenGraph;
let updateGraph = false;
const MAX_NUMBER_LINES = 100;

const createUrl = (hostname: string, port: number, path: string, searchParams: Record<string, any> = {}, secure: boolean): string => {
Expand Down Expand Up @@ -123,6 +125,14 @@ const createLanguageClient = (transports: MessageTransports): MonacoLanguageClie
middleware: {
executeCommand(command, args, next) {
const information = {command: command, arguments: args};
debounceGenGraph = lodash.debounce(() => {
client?.sendRequest(ExecuteCommandRequest.type, information).then((res) => {
createDiagramFromDot(res as string);
});
}, 500);
console.log("command: " + command);
console.log("args: " + args);

if(command === "uvls/open_config") {
const dialog: HTMLDialogElement | null = document.querySelector("#dialog")
const modalClose: HTMLButtonElement | null = document.querySelector('#modalClose');
Expand All @@ -138,12 +148,8 @@ const createLanguageClient = (transports: MessageTransports): MonacoLanguageClie
createDiagramFromDot(res as string);
});

if(debounceGenGraph === undefined){
debounceGenGraph = lodash.debounce(() => {
client?.sendRequest(ExecuteCommandRequest.type, information).then((res) => {
createDiagramFromDot(res as string);
});
}, 500);
if(!updateGraph){
updateGraph = true;

const firstPane = document.getElementById("first");
const secondPane = document.getElementById("second");
Expand All @@ -153,7 +159,7 @@ const createLanguageClient = (transports: MessageTransports): MonacoLanguageClie
}

}else{
debounceGenGraph = undefined;
updateGraph = false;
const div = document.getElementsByClassName("graph");
const firstPane = document.getElementById("first");
while (div[0].firstChild) {
Expand Down Expand Up @@ -277,11 +283,12 @@ export const startPythonClient = async () => {
}
}
debouncedSave();
if(debounceGenGraph !== undefined){
if(updateGraph && debounceGenGraph !== undefined){
debounceGenGraph();
}
})

initIntroJS();
const debouncedSave = lodash.debounce(saveFm, 1000);
};

Expand All @@ -299,4 +306,8 @@ function saveFm(){
const content = model.textEditorModel?.getValue();
window.localStorage.setItem("fm", content);
}
}

export function sendGenerateGraphCommand(){
vscode.commands.executeCommand("uvls/generate_diagram", `file:///workspace/${fileID}.uvl`);
}
Loading

0 comments on commit 19dc352

Please sign in to comment.