Skip to content

Commit d49b382

Browse files
committed
Merge remote-tracking branch 'origin/jdk17dev' into jdk17dev
2 parents c2141b8 + 08ceb45 commit d49b382

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/main/java/com/xwintop/xJavaFxTool/plugin/PluginContainer.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import com.xwintop.xJavaFxTool.model.PluginJarInfo;
55
import com.xwintop.xJavaFxTool.utils.Config;
66
import com.xwintop.xcore.javafx.dialog.FxAlerts;
7+
import com.xwintop.xcore.plugin.PluginEvent;
78
import javafx.fxml.FXMLLoader;
9+
import javafx.scene.Node;
810
import org.apache.commons.lang3.StringUtils;
911

1012
import java.io.IOException;
@@ -21,6 +23,8 @@ public class PluginContainer {
2123

2224
private final PluginJarInfo pluginJarInfo;
2325

26+
private Node rootNode;
27+
2428
public PluginContainer(PluginJarInfo pluginJarInfo) {
2529
this(ClassLoader.getSystemClassLoader(), pluginJarInfo);
2630
}
@@ -30,6 +34,10 @@ public PluginContainer(ClassLoader parentClassLoader, PluginJarInfo pluginJarInf
3034
this.pluginClassLoader = PluginClassLoader.create(parentClassLoader, pluginJarInfo.getFile());
3135
}
3236

37+
public void setRootNode(Node rootNode) {
38+
this.rootNode = rootNode;
39+
}
40+
3341
public <T> T createInstance(Class<T> type) {
3442
try {
3543
return type.getDeclaredConstructor().newInstance();
@@ -79,9 +87,18 @@ public FXMLLoader createFXMLLoader() {
7987
*/
8088
public void unload() {
8189
try {
90+
if (this.rootNode != null) {
91+
this.rootNode.fireEvent(new PluginEvent(this.rootNode, PluginEvent.PLUGIN_UNLOADING));
92+
}
8293
this.pluginClassLoader.close();
8394
} catch (IOException e) {
8495
throw new AppException(e);
8596
}
8697
}
98+
99+
public void onPluginInitialized() {
100+
if (this.rootNode != null) {
101+
this.rootNode.fireEvent(new PluginEvent(this.rootNode, PluginEvent.PLUGIN_INITIALIZED));
102+
}
103+
}
87104
}

src/main/java/com/xwintop/xJavaFxTool/services/IndexService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ public static Tab loadIsolatedPluginAsTab(PluginJarInfo plugin, TabPane tabPane,
166166
tabPane.getTabs().add(tab);
167167
tabPane.getSelectionModel().select(tab);
168168

169+
pluginContainer.setRootNode(root);
170+
pluginContainer.onPluginInitialized();
169171
tab.setOnCloseRequest(
170172
event -> {
171173
JavaFxViewUtil.setControllerOnCloseRequest(generatingCodeFXMLLoader.getController(), event);

0 commit comments

Comments
 (0)