|
6 | 6 | import com.xwintop.xJavaFxTool.event.PluginEvent; |
7 | 7 | import com.xwintop.xJavaFxTool.model.PluginJarInfo; |
8 | 8 | import com.xwintop.xJavaFxTool.model.ToolFxmlLoaderConfiguration; |
9 | | -import com.xwintop.xJavaFxTool.newui.NewLauncherService; |
10 | 9 | import com.xwintop.xJavaFxTool.newui.PluginCategoryController; |
11 | 10 | import com.xwintop.xJavaFxTool.newui.PluginItemController; |
12 | 11 | import com.xwintop.xJavaFxTool.plugin.PluginManager; |
|
26 | 25 | import javafx.fxml.FXML; |
27 | 26 | import javafx.fxml.FXMLLoader; |
28 | 27 | import javafx.scene.Parent; |
29 | | -import javafx.scene.control.CheckMenuItem; |
30 | 28 | import javafx.scene.control.ContextMenu; |
31 | 29 | import javafx.scene.control.Menu; |
32 | 30 | import javafx.scene.control.MenuItem; |
@@ -74,7 +72,6 @@ public class IndexController extends IndexView { |
74 | 72 | private IndexService indexService = new IndexService(this); |
75 | 73 |
|
76 | 74 | private ContextMenu contextMenu = new ContextMenu(); |
77 | | - private ContextMenu itemContextMenu; |
78 | 75 |
|
79 | 76 | // 实现搜索用 |
80 | 77 | private List<PluginItemController> pluginItemControllers = new ArrayList<>(); |
@@ -131,36 +128,19 @@ private void initEvent() { |
131 | 128 | } |
132 | 129 |
|
133 | 130 | private void initService() { |
134 | | - NewLauncherService.getInstance().setTabPane(tabPaneMain); |
135 | 131 | loadPlugins(); // 加载插件列表到界面上 |
136 | 132 | AppEvents.addEventHandler(PluginEvent.PLUGIN_DOWNLOADED, pluginEvent -> { |
137 | 133 | loadPlugins(); |
138 | 134 | }); |
139 | 135 | } |
140 | 136 |
|
141 | 137 | private void initContextMenu() { |
142 | | - CheckMenuItem chkFavorite = new CheckMenuItem("置顶"); |
143 | | - chkFavorite.setStyle("-fx-padding: 0 35 0 0"); |
144 | | - this.itemContextMenu = new ContextMenu(chkFavorite); |
145 | | - chkFavorite.setOnAction(event -> { |
146 | | - CheckMenuItem _this = (CheckMenuItem) event.getSource(); |
147 | | - PluginItemController pluginItemController = NewLauncherService.getInstance().getCurrentPluginItem(); |
148 | | - setFavorite(pluginItemController, _this.isSelected()); |
149 | | - }); |
150 | | - } |
151 | | - private void setFavorite(PluginItemController itemController, boolean isFavorite) { |
152 | | - if (itemController == null) { |
153 | | - return; |
154 | | - } |
155 | | - itemController.getPluginJarInfo().setIsFavorite(isFavorite); |
156 | | - PluginManager.getInstance().saveToFileQuietly(); |
157 | | - loadPlugins(); |
158 | 138 | } |
159 | 139 |
|
160 | 140 | /** |
161 | 141 | * 加载/刷新插件列表 |
162 | 142 | */ |
163 | | - private void loadPlugins() { |
| 143 | + public void loadPlugins() { |
164 | 144 | this.pluginCategories.getChildren().clear(); |
165 | 145 | this.pluginItemControllers.clear(); |
166 | 146 | this.categoryControllers.clear(); |
@@ -199,7 +179,7 @@ private void loadPlugin(PluginJarInfo jarInfo) { |
199 | 179 | ); |
200 | 180 |
|
201 | 181 | PluginItemController item = PluginItemController.newInstance(jarInfo); |
202 | | - item.setContextMenu(itemContextMenu); |
| 182 | + item.setIndexController(this); |
203 | 183 | category.addItem(item); |
204 | 184 |
|
205 | 185 | if (!pluginItemControllers.contains(item)) { |
|
0 commit comments