Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature history view #47

Open
wants to merge 112 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
8ed0a29
Initial commit
Kuzzi04 Dec 21, 2023
4287f00
requestHandling
Kuzzi04 Jan 2, 2024
7ae2363
added feature Annotation with HAnS
Kuzzi04 Jan 2, 2024
5d23dc4
removed hans dependency
Kuzzi04 Jan 2, 2024
6f0f74f
changed Index.html and css
HerrKermet Jan 2, 2024
96eb276
removed hans dependency
Kuzzi04 Jan 2, 2024
8d382e3
bugfix
HerrKermet Jan 2, 2024
e285d5d
bugfix
HerrKermet Jan 2, 2024
e8fd30d
workaround for runIde task
Kuzzi04 Jan 3, 2024
454886c
workaround for runIde task 2.0
Kuzzi04 Jan 3, 2024
102f844
added functionality to run javascript functions from plugin.
Kuzzi04 Jan 3, 2024
9ad5951
added TODO
Kuzzi04 Jan 3, 2024
0b55ad8
added loading animation while initial indexing
HerrKermet Jan 3, 2024
d354718
added sidepanel
HerrKermet Jan 3, 2024
edb325f
added comments
Kuzzi04 Jan 4, 2024
4fb4ec0
added comments
Kuzzi04 Jan 4, 2024
8183d3b
added comments
Kuzzi04 Jan 4, 2024
882d217
added comments
Kuzzi04 Jan 4, 2024
3dee2e0
added searchbar
HerrKermet Jan 4, 2024
f35a64e
Merge remote-tracking branch 'origin/browserWindowSetup' into browser…
HerrKermet Jan 4, 2024
a2de511
Plotting Tangling with response through "TEST"-Button
Kuzzi04 Jan 4, 2024
bf2a021
cleaning up
Kuzzi04 Jan 4, 2024
db10c6f
adjusted burgermenu
HerrKermet Jan 4, 2024
db315c2
index3.html + main2.js + style3.css new browser layout
Kuzzi04 Jan 5, 2024
9ddb84c
added selection for treemap
HerrKermet Jan 6, 2024
9da9c10
adjusted loadingscreen hint
HerrKermet Jan 6, 2024
2921f4c
added prototype for featureInfoWindow
HerrKermet Jan 6, 2024
d910697
adjusted prototype for featureInfoWindow
HerrKermet Jan 6, 2024
fe166ff
added autofocus on searchbar.open
HerrKermet Jan 7, 2024
4f17fca
refactored main2 and index3
HerrKermet Jan 8, 2024
b67a503
moved function from HAnS to HAnS-viz JSONHandler.java
HerrKermet Jan 8, 2024
15e2e1e
added new searchalgorithm
HerrKermet Jan 8, 2024
4db9714
Browser UI fixes
Kuzzi04 Jan 9, 2024
7ac9e0e
Added first version of feature-info-window
Kuzzi04 Jan 9, 2024
878de8e
feature-info-window
Kuzzi04 Jan 9, 2024
990982b
timestamp
Kuzzi04 Jan 9, 2024
e69f1a2
added css for featureWindow
HerrKermet Jan 9, 2024
2620eb7
Merge remote-tracking branch 'origin/browserWindowSetup' into browser…
HerrKermet Jan 9, 2024
0b3e026
added icons to featureWindow
HerrKermet Jan 9, 2024
40c3ea8
clean up index.html + main.js + style.css
Kuzzi04 Jan 12, 2024
a8791dd
fixed initialization
Kuzzi04 Jan 12, 2024
7a584ce
build-settings for installation
Kuzzi04 Jan 12, 2024
66dfef3
added scattering window + button in feature info window
Kuzzi04 Jan 12, 2024
6a1c8d7
Added ToolWindowListener for "ToolWindow = open"-detection
Kuzzi04 Jan 13, 2024
027e0b3
Added feature: Fetching data after reopening tool window
Kuzzi04 Jan 13, 2024
50da1f1
Scattering Window closes with click anywhere but inside the window
Kuzzi04 Jan 13, 2024
886c071
added backdrop to scattering window
HerrKermet Jan 13, 2024
f0b470e
added different colors for each first level child
HerrKermet Jan 13, 2024
9613e73
added toggle for hide lpq names
HerrKermet Jan 13, 2024
8a4bc24
added fetchintervall logic
HerrKermet Jan 13, 2024
5282985
adjusted node repulsion and label position for non-circular graph
HerrKermet Jan 13, 2024
021a457
adjusted edge length for non-circular graph
HerrKermet Jan 13, 2024
b3aa826
adjusted line width
HerrKermet Jan 13, 2024
ab9f785
fixed searchbar issues
HerrKermet Jan 14, 2024
21fcf2c
implemented scattering window prototype
HerrKermet Jan 14, 2024
6b98b75
Cleanup
HerrKermet Jan 14, 2024
11d9fc9
refactoring and cleanup
HerrKermet Jan 14, 2024
1440446
added feature annotations
HerrKermet Jan 14, 2024
60760d0
Added README.md + CONTRIBUTORS.md
Kuzzi04 Jan 14, 2024
0080e8a
README.md fix
Kuzzi04 Jan 14, 2024
48dab7d
Changed import of HAnSCallback, because of change in origin.
Kuzzi04 Jan 15, 2024
b46a5a2
fixed feature location line-count within JSONHandler.java
HerrKermet Jan 15, 2024
3a1baa6
error-handling for null exception in JSONHandler.java
HerrKermet Jan 15, 2024
f21e094
adjusted scattering window prototype
HerrKermet Jan 15, 2024
447d7ff
fixed hiding scattering window
Kuzzi04 Jan 15, 2024
1e22771
adjusted search highlighting
HerrKermet Jan 15, 2024
51e3783
bugfix settings switch will now reload the chart
HerrKermet Jan 15, 2024
2aa682d
added toolWindow Icon
Kuzzi04 Jan 16, 2024
135eef9
updated gradleIntellijPlugin -> 1.16.1
Kuzzi04 Jan 16, 2024
8e1d5b4
updated org.gradle.toolchains.foojay-resolver-convention -> 0.8.0
Kuzzi04 Jan 16, 2024
b2b09a6
improved search
HerrKermet Jan 16, 2024
875a887
improved search
HerrKermet Jan 16, 2024
e3b254a
Updated JSONHandler with changes on HAnS plugin (FeatureService)
Kuzzi04 Jan 17, 2024
16f9f1c
Added plugin Icon and changed Toolwindow name
Kuzzi04 Jan 17, 2024
dfecba0
Retrieving current project from Services and Listeners, not from Proj…
Kuzzi04 Jan 18, 2024
f2ff0fd
added prototype to highlight feature in featuremodel on rightclick
HerrKermet Jan 18, 2024
9bf5eed
implemented changes from HAnS FeatureFileMapping
HerrKermet Jan 18, 2024
ee25026
updated JSON to accept fullPath and only fileName for charts
HerrKermet Jan 18, 2024
513a3c9
changed tooltip positin in scattering window view
HerrKermet Jan 18, 2024
a14da28
Made JSONHandler non-static.
Kuzzi04 Jan 19, 2024
8c08fcf
fixed "Scattering"-position of scattering window
Kuzzi04 Jan 19, 2024
9d75601
using convenient method of HAnS
Kuzzi04 Jan 19, 2024
f12cb60
Highlight Feature Location in Editor
Kuzzi04 Jan 19, 2024
05fcd60
moved eChart eventListeners to function
HerrKermet Jan 19, 2024
799a610
added clickable elements in scattering window and searchsettings
HerrKermet Jan 19, 2024
629318a
Changed import settings
Kuzzi04 Jan 20, 2024
bea94c2
enabled cursor as pointer and made highlighting of clickable a little…
Kuzzi04 Jan 20, 2024
1655290
removed prints
HerrKermet Jan 20, 2024
10e45f6
formatted index.html
HerrKermet Jan 20, 2024
7a5dc92
changed formatter style of scattering chart
HerrKermet Jan 20, 2024
23bf193
changed formatter style of scattering chart
HerrKermet Jan 20, 2024
000cc54
Update README.md
HerrKermet Jan 20, 2024
a031684
fixed settingsbox
Kuzzi04 Jan 21, 2024
a4b1641
Added Contributor-Info
HerrKermet Jan 21, 2024
3c06815
fixed scattering-window background
Kuzzi04 Jan 21, 2024
73c8c4e
updated README.md
Kuzzi04 Jan 21, 2024
f18f354
Update README.md
Kuzzi04 Jan 21, 2024
4555348
updated plugin.xml vendor
Kuzzi04 Feb 1, 2024
e83038e
added background color
HerrKermet Feb 5, 2024
a36e641
enable light mode per default
Kuzzi04 Feb 6, 2024
69faf3b
Refactoring to adapt to new services / changes of HAnS
HerrKermet Sep 9, 2024
b4385bf
Added Feature History View
RimanHoubbi Sep 26, 2024
3357d7e
Remove unnecessary code
RimanHoubbi Sep 26, 2024
ac7d018
Added a Features selector to the timeline
RimanHoubbi Sep 26, 2024
3596724
fix series data
RimanHoubbi Sep 28, 2024
23cb1f2
fix tooltip for filtering features
RimanHoubbi Sep 29, 2024
9702f86
Restructured code
RimanHoubbi Oct 12, 2024
db0bd3c
Restructured a bit
RimanHoubbi Oct 31, 2024
079cc70
fix
RimanHoubbi Nov 5, 2024
2eb8afc
fix& add features deselect button
RimanHoubbi Nov 6, 2024
2c4e0b0
fix build workflow
RimanHoubbi Nov 21, 2024
5e43b96
fix jar file
RimanHoubbi Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
requestHandling
Kuzzi04 committed Jan 2, 2024
commit 4287f007b86a1f72b6dba954879f3c89b6191953
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

334 changes: 13 additions & 321 deletions src/main/java/com/github/johmara/hansviz/BrowserViewerWindow.java
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@

package com.github.johmara.hansviz;

import com.github.johmara.hansviz.JSHandler.JSMessageRouterHandler;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
@@ -23,6 +24,8 @@
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.jcef.JBCefBrowser;
import org.cef.CefApp;
import org.cef.CefClient;
import org.cef.browser.CefMessageRouter;

import javax.swing.*;

@@ -35,8 +38,7 @@ public class BrowserViewerWindow {

private final Box content;
private final Project project;
private String tangleFeature = "";
private String locationFeature = "";


/**
* Constructs a JCEF view containing the Feature Localisation View and Tangling View
@@ -46,6 +48,7 @@ public class BrowserViewerWindow {
public BrowserViewerWindow(BrowserViewerService service, Project project) {
webView = new JBCefBrowser();
registerAppSchemeHandler();
initialiseJSHandler(webView.getCefBrowser().getClient());
webView.loadURL("http://hans/index.html");

/**
@@ -56,51 +59,21 @@ public BrowserViewerWindow(BrowserViewerService service, Project project) {

// Setup the menubar in JCEF
JMenuBar menuBar = new JMenuBar();
/*JMenuItem fileMenuItem = new JMenuItem("Feature Location Visualization");
JMenuItem tanglingMenuItem = new JMenuItem("Feature Tangling Visualization");
JBColor menuItemColor = new JBColor(
fileMenuItem.getBackground(), fileMenuItem.getBackground());*/


/*MouseAdapter miMouseAdapter = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
String url = "http://myapp/html/";
if (e.getComponent() == fileMenuItem) {
url += "fileView.html";
locationFeature = "";
} else if (e.getComponent() == tanglingMenuItem) {
try {
String featureTangling = JSONHandler.toJSONString(iFeatureAnnotationUtil.getFeatureAnnotationTanglings(project.getBasePath()));
} catch (IOException ioException) {
ioException.printStackTrace();
}
url += "tanglingView.html";
}
webView.loadURL(url);
}

@Override
public void mouseEntered(MouseEvent e) {
e.getComponent().setBackground(JBColor.CYAN);
}

@Override
public void mouseExited(MouseEvent e) {
e.getComponent().setBackground(menuItemColor);
}
};*/
/*fileMenuItem.addMouseListener(miMouseAdapter);
tanglingMenuItem.addMouseListener(miMouseAdapter);*/

/*menuBar.add(fileMenuItem);
menuBar.add(tanglingMenuItem);*/
content = new Box(BoxLayout.Y_AXIS);
content.add(menuBar);
content.add(webView.getComponent());
this.project = project;
}

private void initialiseJSHandler(CefClient client) {
// create routing point for JS -> window.java ({})
CefMessageRouter.CefMessageRouterConfig cefMessageRouterConfig = new CefMessageRouter.CefMessageRouterConfig("java","javaCancel");
CefMessageRouter cefMessageRouter = CefMessageRouter.create(cefMessageRouterConfig);
cefMessageRouter.addHandler(new JSMessageRouterHandler(), true);
client.addMessageRouter(cefMessageRouter);
}

private void registerAppSchemeHandler() {
CefApp.getInstance().registerSchemeHandlerFactory(
"http",
@@ -118,289 +91,8 @@ public JComponent content() {
return content;
}

/**
* Register a new SchemeHandlerFactory using CustomSchemeHandlerFactory
*/
/*private void registerAppSchemeHandler() {
CefApp.getInstance().registerSchemeHandlerFactory(
"http",
"myapp",
new CustomSchemeHandlerFactory()
);
}*/

/**
* Makes a client able to process JS requests
* @param client The browser client that should handle JS requests
*/
/*private void handleJS(CefClient client) {
// Query a route configuration, html pages used window.java ({}) and window.javaCancel ({}) to call this method
CefMessageRouter.CefMessageRouterConfig cmrConfig = new CefMessageRouter.CefMessageRouterConfig(
"java","javaCancel");
// Create query routing
CefMessageRouter cmr = CefMessageRouter.create(cmrConfig);
cmr.addHandler(new CefMessageRouterHandler() {

@Override
public void setNativeRef(String str, long val) {
System.out.println(str+" "+val);
}

@Override
public long getNativeRef(String str) {
System.out.println(str);
return 0;
}

@Override
public void onQueryCanceled(CefBrowser browser, CefFrame frame, long query_id) {
System.out.println("Cancel the query:" + query_id);
}

@Override
public boolean onQuery(CefBrowser browser, CefFrame frame, long query_id, String request,
boolean persistent, CefQueryCallback callback) {
System.out.println("Request:"+request+"\nQuery_id:"+query_id+"\nPersistent:"+persistent);

String[] temp = request.split(" ");
String cmd = temp[0];
boolean handled = false;
String cbSyntaxFailureMsg = "\"Message syntax incorrect!\nCorrect syntax: ";
String debugSyntax = "Debug <data>";
String deleteFeSyntax = "DeleteFe <featureName>";
String deleteFiSyntax = "DeleteFi <fileName>";
String getDataSyntax = "getData [feature | tangle]";
String openSyntax = "OpenFile <fileName>";
String renameFeSyntax = "RenameFe <oldName> <newName>";
String renameFiSyntax = "RenameFi <oldName> <newName>";
*//* Supported operations:
* - Debug:
* Description: Print data to java console (Used for debug purposes)
* Syntax: Debug <data>
* - DeleteFe:
* Description: Deletes a feature
* Syntax: DeleteFe <featureName>
* - DeleteFi:
* Description: Deletes a file/folder
* Syntax: DeleteFi <fileName/folderName>
* - GetData:
* Description: Requests data for feature- or tangleview
* Syntax: GetData [feature | tangle]
* - OpenFile:
* Description: Opens a file in editor or expands folder in project view
* Syntax: OpenFile <fileName/folderName>
* - RenameFe:
* Description: Renames a feature
* Syntax: RenameFe <oldName> <newName>
* - RenameFi:
* Description: Renames a file
* Syntax: RenameFi <oldFileName> <newFileName>
*//*
switch (cmd) {
case "Debug":
try {
String data = temp[1];
System.out.println(data);
callback.success("Debug message '" + data + "' was received!");
handled = true;
} catch (IndexOutOfBoundsException e) {
// Incorrect syntax
callback.failure(400, cbSyntaxFailureMsg + debugSyntax);
}
break;
case "DeleteFe":
try {
String featureName = temp[1];
// TODO: Implement actual deletion of feature (require editing API)
callback.success(featureName + " was deleted!");
handled = true;
} catch (IndexOutOfBoundsException e) {
// Incorrect syntax
callback.failure(400, cbSyntaxFailureMsg + deleteFeSyntax);
}
break;
case "DeleteFi":
try {
String fileName = temp[1];
// Send handling of deleting file to be processed by an EDT thread when available
ApplicationManager.getApplication().invokeLater(() -> {
final VirtualFile vFile = getVirtualFile(fileName);
if (vFile != null) {
ApplicationManager.getApplication().runWriteAction(() -> {
try {
vFile.delete(this);
callback.success(fileName + " was deleted!");
} catch (IOException e) {
// Failed to delete
callback.failure(500, fileName + "could not be deleted!");
}
});
} else {
// File/Folder not found
callback.failure(404, fileName + " could not be found!");
}
});
handled = true;
} catch (IndexOutOfBoundsException e) {
// Incorrect syntax
callback.failure(400, cbSyntaxFailureMsg + deleteFiSyntax);
}
break;
case "GetData":
try {
String requestedData = temp[1];
if (requestedData.equals("feature")) {
// TODO: Assign actual data to fileData string
String fileData = "fileViewData test";
callback.success(fileData);
} else if (requestedData.equals("tangle")) {
// TODO: Assign actual data to tangleData string
String tangleData = "tangleViewData test";
callback.success(tangleData);
} else {
// Requested data was not a supported datatype
// Must be either feature or tangle
callback.failure(400, requestedData + " is not a valid datatype!");
}
handled = true;
} catch (IndexOutOfBoundsException e) {
// Incorrect syntax
callback.failure(400, cbSyntaxFailureMsg + getDataSyntax);
}
break;
case "OpenFile":
try {
String fileName = temp[1];
// Send handling of file opening to be processed by an EDT thread when available
ApplicationManager.getApplication().invokeLater(() -> {
final VirtualFile vFile = getVirtualFile(fileName);
if (vFile != null) {
OpenFileDescriptor ofd = new OpenFileDescriptor(project, vFile);
boolean isDir = vFile.isDirectory();
ofd.navigate(!isDir);
String cbMsg = isDir ? "expanded " : "opened ";
cbMsg += fileName;
callback.success(cbMsg);
} else {
// File/Folder not found
callback.failure(404, fileName + " could not be found!");
}
});
handled = true;
} catch (IndexOutOfBoundsException e) {
// Incorrect syntax
callback.failure(400, cbSyntaxFailureMsg + openSyntax);
}
break;
case "RenameFe":
try {
String oldName = temp[1];
String newName = temp[2];
// TODO: Implement actual renaming of feature (require editing API)
callback.success(oldName + " was renamed to " + newName);
handled = true;
} catch (IndexOutOfBoundsException e) {
// Incorrect syntax
callback.failure(400, cbSyntaxFailureMsg + renameFeSyntax);
}
break;
case "RenameFi":
try {
String oldName = temp[1];
String newName = temp[2];
// Send handling of file renaming to be processed by an EDT thread when available
ApplicationManager.getApplication().invokeLater(() -> {
final VirtualFile vFile = getVirtualFile(oldName);
if (vFile != null) {
ApplicationManager.getApplication().runWriteAction(() -> {
try {
vFile.rename(this, newName);
callback.success(oldName + " was renamed to " + newName);
} catch (IOException e) {
// Failed to rename
callback.failure(500, oldName + "could not be renamed!");
}
});
} else {
// File/Folder not found
callback.failure(404, oldName + " could not be found!");
}
});
handled = true;
} catch (IndexOutOfBoundsException e) {
// Incorrect syntax
callback.failure(400, cbSyntaxFailureMsg + renameFiSyntax);
}
break;
case "featureLocation":
try {
String featureLocation = "";
System.out.println(locationFeature);
if(locationFeature.equals("")) {
featureLocation = JSONHandler.toJSONString(iFeatureAnnotationUtil.getFeatureAnnotationLocations(project.getBasePath()));
}
else {
Map<String, ArrayList<Object>> featureMap = new HashMap<>();
ArrayList<Object> locationsForFeature = iFeatureAnnotationUtil.getFeatureAnnotationLocations(project.getBasePath()).get(locationFeature);
featureMap.put(locationFeature, locationsForFeature);
featureLocation = JSONHandler.toJSONString(featureMap);
}
System.out.println(featureLocation);
callback.success(featureLocation);
handled = true;
} catch (IndexOutOfBoundsException | IOException e) {
callback.failure(400, "Could not get feature mappings.");
}
break;
case "OpenTangle": //Used by featureView.js to get the chosen feature
try {
Map<String, ArrayList<Object>> test = iFeatureAnnotationUtil.getFeatureAnnotationTanglings(project.getBasePath());
Map<String, ArrayList<Object>>mapper = new HashMap<>();
if(test.containsKey(tangleFeature)) {
mapper.put(tangleFeature, test.get(tangleFeature));
} else
{
mapper.put(tangleFeature, new ArrayList<>());
}
String json = JSONHandler.toJSONString(mapper);
System.out.println(json);
callback.success(json);
handled = true;
} catch (IOException ioException) {
//
ioException.printStackTrace();
callback.failure(400, cbSyntaxFailureMsg + "Wrong with tangling");
}
break;
case "ChooseTangle": //Should be used from location view to choose the tangle feature
try {
tangleFeature = temp[1];
String url = "http://myapp/html/";
url += "tanglingView.html";
webView.loadURL(url);
callback.success("Choose feature for tangling view success");
handled = true;
} catch (IndexOutOfBoundsException e) {
// Incorrect syntax
callback.failure(400, cbSyntaxFailureMsg + "ChooseTangle <featureName>"); //Syntax for choosing the feature
}
break;
case "OpenLocation":
locationFeature = temp[1];
String url = "http://myapp/html/";
url += "fileView.html";
webView.loadURL(url);
handled = true;
break;
default:
// Command not recognized
callback.failure(400, "Command not recognized!");
}
return handled;
}
}, true);
client.addMessageRouter(cmr);
}*/

/**
* Searches the project for a file (or folder) with the specified filename
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.github.johmara.hansviz.JSHandler;

import org.cef.browser.CefBrowser;
import org.cef.browser.CefFrame;
import org.cef.callback.CefQueryCallback;
import org.cef.handler.CefMessageRouterHandlerAdapter;


public class JSMessageRouterHandler extends CefMessageRouterHandlerAdapter {

@Override
public boolean onQuery(CefBrowser browser, CefFrame frame, long queryId, String request, boolean persistent, CefQueryCallback callback) {
System.out.println("Request: " + request); // For testing purposes
switch(request) {
// Add all queries that need to be handled
case "buttonClicked":
System.out.println("Button Clicked!");
return true;
case "refresh":
System.out.println("Refreshing!");
// return JSON through parameter of success function
callback.success("JSON");
return true;
}
return false;
}
}
37 changes: 10 additions & 27 deletions src/main/resources/webcontent/index.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
<!DOCTYPE html>
<html>
<body>
<head>
<meta charset="utf-8">
<title>Katzenblog</title>
<table>
<tr>
<th>Überschrift Spalte 1</th>
<th>Überschrift Spalte 2</th>
</tr>
<tr>
<td>Zelle 50</td>
<td rowspan="2">Zelle 2 und 4</td>
</tr>
<tr>
<td>Zelle 56</td>
</tr>
</table>
</head>
<main>
<h1>Informationen über Katzen</h1>
<p>Ich weiß nicht so ganz was ich sagen soll, außer dass mir sehr langweilig ist</p>
</main>
<footer>
<p>Hier ist es auch echt langweilig</p>
</footer>
</body>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HAnS</title>
</head>
<body>
<button id="myButton">Click me</button>
<script src="index.js"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions src/main/resources/webcontent/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
document.getElementById('myButton').addEventListener('click', function() {
// Every button can use requestData(option) to request data from HAnS-Viz
// Send message to JCEF
requestData("buttonClicked")
requestData("refresh")
});

function requestData(option) {
window.java({
request: option,
persistent: false,
success: function(response) {
// response should contain JSON
handleData(option, response);
},
failure: function(error_code, error_message) {
console.log(error_code, error_message);
}
})
}

function handleData(option, response) {
switch(option) {
case "refresh":
// handle refresh data
break;
case "tanglingdegree":
// handle tangling degree data
break;
}
}