44import com .xwintop .xJavaFxTool .controller .IndexController ;
55import com .xwintop .xJavaFxTool .model .PluginJarInfo ;
66import com .xwintop .xJavaFxTool .plugin .PluginLoader ;
7+ import com .xwintop .xJavaFxTool .plugin .PluginManager ;
78import com .xwintop .xJavaFxTool .utils .Config ;
89import com .xwintop .xJavaFxTool .utils .FxmlUtils ;
910import com .xwintop .xcore .javafx .dialog .FxAlerts ;
2728
2829@ Setter
2930public class IndexService {
31+
3032 private IndexController indexController ;
3133
3234 public IndexService (IndexController indexController ) {
@@ -77,7 +79,8 @@ public void addLogConsoleAction(ActionEvent event) {
7779 textArea .setFocusTraversable (true );
7880 ConsoleLogAppender .textAreaList .add (textArea );
7981 if (indexController .getSingleWindowBootCheckBox ().isSelected ()) {
80- Stage newStage = JavaFxViewUtil .getNewStage (indexController .getBundle ().getString ("addLogConsole" ), null , textArea );
82+ Stage newStage = JavaFxViewUtil
83+ .getNewStage (indexController .getBundle ().getString ("addLogConsole" ), null , textArea );
8184 newStage .setOnCloseRequest (event1 -> {
8285 ConsoleLogAppender .textAreaList .remove (textArea );
8386 });
@@ -95,21 +98,19 @@ public void addLogConsoleAction(ActionEvent event) {
9598 }
9699
97100 /**
98- * @Title: addContent
99- * @Description: 添加Content内容
101+ * 添加Content内容
100102 */
101- public void addContent (String title , String url , String resourceBundleName , String iconPath ) {
103+ public void addContent (String title , String fxmlPath , String resourceBundleName , String iconPath ) {
102104
103- PluginJarInfo plugin = new PluginJarInfo ();
104- plugin .setTitle (title );
105- plugin .setFxmlPath (url );
106- plugin .setBundleName (resourceBundleName );
107- plugin .setIconPath (iconPath );
105+ PluginJarInfo pluginJarInfo = PluginManager .getInstance ().getPluginByFxmlPath (fxmlPath );
106+ if (pluginJarInfo == null ) {
107+ FxAlerts .error ("打开失败" , "没有找到指定的插件" );
108+ }
108109
109110 if (indexController .getSingleWindowBootCheckBox ().isSelected ()) {
110- PluginLoader .loadPluginAsWindow (plugin );
111+ PluginLoader .loadPluginAsWindow (pluginJarInfo );
111112 } else {
112- PluginLoader .loadPluginAsTab (plugin , indexController .getTabPaneMain ());
113+ PluginLoader .loadPluginAsTab (pluginJarInfo , indexController .getTabPaneMain ());
113114 }
114115 }
115116
0 commit comments