Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit af976b5

Browse files
committed
Build for deploying on server
1 parent d97c8fd commit af976b5

8 files changed

Lines changed: 37 additions & 18 deletions

File tree

bundles/org.dataflowanalysis.standalone/resources/WebEditor/src/features/serialize/analyze.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Action, SModelRoot } from "sprotty-protocol";
1313
import { LabelType, LabelTypeRegistry } from "../labels/labelTypeRegistry";
1414
import { DynamicChildrenProcessor } from "../dfdElements/dynamicChildren";
1515
import { EditorMode, EditorModeController } from "../editorMode/editorModeController";
16-
import { ws, wsId } from "../../index";
16+
import { sendMessageToWebsocket } from "../../index";
1717

1818
/**
1919
* Type that contains all data related to a diagram.
@@ -72,7 +72,7 @@ export class AnalyzeDiagramCommand extends Command {
7272
editorMode: this.editorModeController?.getCurrentMode(),
7373
};
7474
const diagramJson = JSON.stringify(diagram, undefined, 4);
75-
ws.send(wsId + ":Json:" + diagramJson);
75+
sendMessageToWebsocket(":Json:" + diagramJson);
7676
return context.root;
7777
}
7878

bundles/org.dataflowanalysis.standalone/resources/WebEditor/src/features/serialize/loadDFDandDD.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { SavedDiagram } from "./save";
1818
import { LabelType, LabelTypeRegistry } from "../labels/labelTypeRegistry";
1919
import { LayoutModelAction } from "../autoLayout/command";
2020
import { EditorMode, EditorModeController } from "../editorMode/editorModeController";
21-
import { ws, wsId, setModelFileName } from "../../index";
21+
import { sendMessageToWebsocket, setModelFileName } from "../../index";
2222
import { Console } from "console";
2323

2424
export interface LoadDFDandDDAction extends Action {
@@ -89,8 +89,7 @@ export class LoadDFDandDDCommand extends Command {
8989
const dictionaryFileContent = await this.readFileContent(dictionaryFile);
9090

9191
// Send each file's content in separate WebSocket messages
92-
ws.send(
93-
wsId +
92+
sendMessageToWebsocket(
9493
":DFD:" +
9594
this.getFileNameWithoutExtension(dataflowFile) +
9695
":" +
@@ -99,7 +98,6 @@ export class LoadDFDandDDCommand extends Command {
9998
dictionaryFileContent,
10099
);
101100
setModelFileName(dataflowFile.name.substring(0, dataflowFile.name.lastIndexOf(".")));
102-
setFileNameInPageTitle(dataflowFile.name);
103101
return context.root;
104102
} catch (error) {
105103
return context.root;

bundles/org.dataflowanalysis.standalone/resources/WebEditor/src/features/serialize/loadPalladio.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { SavedDiagram } from "./save";
1818
import { LabelType, LabelTypeRegistry } from "../labels/labelTypeRegistry";
1919
import { LayoutModelAction } from "../autoLayout/command";
2020
import { EditorMode, EditorModeController } from "../editorMode/editorModeController";
21-
import { ws, wsId, setModelFileName } from "../../index";
21+
import { sendMessageToWebsocket, setModelFileName } from "../../index";
2222
import { Console } from "console";
2323

2424
export interface LoadPalladioAction extends Action {
@@ -107,13 +107,12 @@ export class LoadPalladioCommand extends Command {
107107
);
108108

109109
// Construct the message format for WebSocket
110-
const message = [
111-
wsId + ":", // Add wsId only once at the start
110+
const message = [ // Add wsId only once at the start
112111
...fileContents.map(({ name, content }) => `${name}:${content}`),
113112
].join("---FILE---");
114113

115114
// Send the structured message over WebSocket
116-
ws.send(message);
115+
sendMessageToWebsocket(message);
117116

118117
// Set the model file name and page title based on one of the files (e.g., the first file)
119118
setModelFileName(files[0].name.substring(0, files[0].name.lastIndexOf(".")));

bundles/org.dataflowanalysis.standalone/resources/WebEditor/src/features/serialize/saveDFDandDD.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Action, SModelRoot } from "sprotty-protocol";
1313
import { LabelType, LabelTypeRegistry } from "../labels/labelTypeRegistry";
1414
import { DynamicChildrenProcessor } from "../dfdElements/dynamicChildren";
1515
import { EditorMode, EditorModeController } from "../editorMode/editorModeController";
16-
import { ws, wsId, modelFileName } from "../../index";
16+
import { sendMessageToWebsocket, modelFileName } from "../../index";
1717

1818
export interface SaveDFDandDDAction extends Action {
1919
kind: typeof SaveDFDandDDAction.KIND;
@@ -68,7 +68,7 @@ export class SaveDFDandDDCommand extends Command {
6868
editorMode: this.editorModeController?.getCurrentMode(),
6969
};
7070
const diagramJson = JSON.stringify(diagram, undefined, 4);
71-
ws.send(wsId + ":Json2DFD:" + modelFileName + ":" + diagramJson);
71+
sendMessageToWebsocket("Json2DFD:" + modelFileName + ":" + diagramJson);
7272
return context.root;
7373
}
7474

bundles/org.dataflowanalysis.standalone/resources/WebEditor/src/index.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,19 @@ modelSource
9494
console.error("Failed to show default UIs and load default diagram", error);
9595
});
9696

97-
export const ws = new WebSocket(`ws://${window.location.hostname}:3000/events/`); // Change to the dynamic WebSocket port
98-
export var wsId = 0;
97+
var ws = new WebSocket(`wss://${window.location.hostname}/events/`); // Change to the dynamic WebSocket port
98+
var wsId = 0;
9999

100100
export var modelFileName = "diagram";
101101

102102
export function setModelFileName(name: string): void {
103103
modelFileName = name;
104104
}
105105

106+
function reconnectWebSocket() {
107+
ws = new WebSocket(`wss://${window.location.hostname}/events/`);
108+
}
109+
106110
ws.onmessage = (event) => {
107111
console.log(event.data);
108112
if (event.data.startsWith("Error:")) {
@@ -130,6 +134,24 @@ ws.onmessage = (event) => {
130134
);
131135
};
132136

137+
ws.onclose = () => {
138+
reconnectWebSocket();
139+
}
140+
141+
ws.onerror = () => {
142+
reconnectWebSocket();
143+
}
144+
145+
export function sendMessageToWebsocket(message: String) {
146+
if (!ws || ws.readyState !== WebSocket.OPEN) {
147+
console.warn("WebSocket not open. Attempting to reconnect...");
148+
reconnectWebSocket();
149+
}
150+
ws.send(wsId + ":" + message);
151+
152+
153+
}
154+
133155
export function setModelSource(file: File): void {
134156
modelSource
135157
.setModel({

bundles/org.dataflowanalysis.standalone/src/org/dataflowanalysis/standalone/analysis/Converter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static WebEditorDfd convertPCM(File usageModelFile, File allocationModelF
5959

6060

6161
var dfdConverter = new DataFlowDiagramConverter();
62-
return dfdConverter.dfdToWebAndAnalyzeAndAnnotateWithCustomTFGFinder(dfd, null, DFDTransposeFlowGraphFinder.class);
62+
return dfdConverter.dfdToWebAndAnalyzeAndAnnotateWithCustomTFGFinder(dfd, null, DFDSimpleTransposeFlowGraphFinder.class);
6363

6464
} catch (Exception e) {
6565
e.printStackTrace();

bundles/org.dataflowanalysis.standalone/src/org/dataflowanalysis/standalone/websocket/WebSocketServerUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private static void startServer() {
3636
{
3737
// Configure default max size
3838
wsContainer.setMaxTextMessageSize(Long.MAX_VALUE);
39-
wsContainer.setIdleTimeout(Duration.ofMinutes(20));
39+
wsContainer.setIdleTimeout(Duration.ofSeconds(-1));
4040

4141
// Add websockets
4242
wsContainer.addMapping("/events/*", WebSocketServerHandler.class);

releng/org.dataflowanalysis.standalone.targetplatform/org.dataflowanalysis.standalone.targetplatform.targetplatform.target

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@
153153
</location>
154154
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
155155
<repository location="https://dataflowanalysis.github.io/updatesite/nightly/dataflowanalysis/"/>
156-
<unit id="org.dataflowanalysis.analysis.feature.feature.group" version="3.0.0.202411120241"/>
156+
<unit id="org.dataflowanalysis.analysis.feature.feature.group" version="3.0.0.202411180256"/>
157157
</location>
158-
<location path="C:\Users\Huell\Desktop\Newfolder\AnalysisNew\workspace\plugins" type="Directory"/>
158+
<location path="C:\Users\Huell\Desktop\AnalysisNew\workspace\plugins" type="Directory"/>
159159
</locations>
160160
</target>

0 commit comments

Comments
 (0)