Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5e5ef7a

Browse filesBrowse files
committed
ADAP-150: merge conflicts for layout service
2 parents 1c54ece + beb24d0 commit 5e5ef7a
Copy full SHA for 5e5ef7a

File tree

Expand file treeCollapse file tree

6 files changed

+397
-177
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+397
-177
lines changed
Open diff view settings
Collapse file

‎release/app.asar‎

Copy file name to clipboard
4.47 KB
Binary file not shown.
Collapse file
2.44 KB
Binary file not shown.
Collapse file
11.3 KB
Binary file not shown.
Collapse file
+134Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package com.openfin.desktop.demo;
2+
3+
import com.openfin.desktop.*;
4+
import com.openfin.desktop.channel.ChannelClient;
5+
import com.openfin.desktop.win32.ExternalWindowObserver;
6+
import javafx.embed.swing.JFXPanel;
7+
import javafx.event.EventHandler;
8+
import javafx.scene.Scene;
9+
import javafx.scene.control.Button;
10+
import javafx.scene.layout.StackPane;
11+
import javafx.stage.Stage;
12+
import javafx.stage.WindowEvent;
13+
import org.json.JSONObject;
14+
15+
import java.lang.System;
16+
import java.util.List;
17+
18+
public class FxLayoutFrame {
19+
private ExternalWindowObserver externalWindowObserver;
20+
private String windowName;
21+
private Stage stage;
22+
private static JFXPanel jFXPanel;
23+
24+
public FxLayoutFrame(DesktopConnection desktopConnection, String appUuid, String windowName) {
25+
System.out.println(windowName + " being created ");
26+
this.windowName = windowName;
27+
if (jFXPanel == null) {
28+
jFXPanel = new JFXPanel();
29+
javafx.application.Platform.setImplicitExit(false);
30+
}
31+
javafx.application.Platform.runLater(new Runnable() {
32+
@Override
33+
public void run() {
34+
Button btnUndock = new Button("undock");
35+
btnUndock.setDisable(true);
36+
37+
StackPane secondaryLayout = new StackPane();
38+
secondaryLayout.getChildren().add(btnUndock);
39+
40+
Scene secondScene = new Scene(secondaryLayout, 640, 480);
41+
42+
FxLayoutFrame.this.stage = new Stage();
43+
FxLayoutFrame.this.stage.setTitle(windowName);
44+
FxLayoutFrame.this.stage.setScene(secondScene);
45+
46+
// Set position of second window, related to primary window.
47+
FxLayoutFrame.this.stage.setX(640);
48+
FxLayoutFrame.this.stage.setY(480);
49+
FxLayoutFrame.this.stage.show();
50+
51+
// FxLayoutFrame.this.stage.setOnCloseRequest(event -> FxLayoutFrame.this.cleanup());
52+
53+
try {
54+
FxLayoutFrame.this.externalWindowObserver =
55+
new ExternalWindowObserver(desktopConnection.getPort(), appUuid, windowName, FxLayoutFrame.this.stage,
56+
new AckListener() {
57+
@Override
58+
public void onSuccess(Ack ack) {
59+
ExternalWindowObserver observer = (ExternalWindowObserver) ack.getSource();
60+
observer.getDesktopConnection().getChannel().connect("of-layouts-service-v1",
61+
new AsyncCallback<ChannelClient>() {
62+
@Override
63+
public void onSuccess(ChannelClient client) {
64+
btnUndock.setOnAction(new EventHandler<javafx.event.ActionEvent>() {
65+
@Override
66+
public void handle(javafx.event.ActionEvent e) {
67+
JSONObject payload = new JSONObject();
68+
payload.put("uuid", appUuid);
69+
payload.put("name", windowName);
70+
client.dispatch("UNDOCK-WINDOW", payload, null);
71+
}
72+
});
73+
}
74+
});
75+
}
76+
77+
@Override
78+
public void onError(Ack ack) {
79+
}
80+
});
81+
82+
Window w = Window.wrap(appUuid, windowName, desktopConnection);
83+
w.addEventListener("group-changed", new EventListener() {
84+
@Override
85+
public void eventReceived(com.openfin.desktop.ActionEvent actionEvent) {
86+
JSONObject eventObj = actionEvent.getEventObject();
87+
w.getGroup(new AsyncCallback<List<Window>>() {
88+
@Override
89+
public void onSuccess(java.util.List<Window> result) {
90+
if (result.size() > 0) {
91+
btnUndock.setDisable(false);
92+
} else {
93+
btnUndock.setDisable(true);
94+
}
95+
}
96+
}, null);
97+
}
98+
}, null);
99+
100+
try {
101+
FxLayoutFrame.this.externalWindowObserver.start();
102+
} catch (Exception e) {
103+
e.printStackTrace();
104+
}
105+
106+
} catch (DesktopException e) {
107+
e.printStackTrace();
108+
}
109+
}
110+
});
111+
}
112+
113+
public String getWindowName() {
114+
return windowName;
115+
}
116+
117+
public Stage getStage() {
118+
return stage;
119+
}
120+
121+
public void cleanup() {
122+
try {
123+
System.out.println(windowName + " cleaning up ");
124+
if (this.externalWindowObserver != null) {
125+
this.externalWindowObserver.dispose();
126+
}
127+
}
128+
catch (Exception e) {
129+
e.printStackTrace();
130+
}
131+
this.externalWindowObserver = null;
132+
}
133+
134+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.