Skip to content

Commit b7114a2

Browse files
committed
1.整合新老界面
1 parent e896736 commit b7114a2

7 files changed

Lines changed: 309 additions & 306 deletions

File tree

src/main/java/com/xwintop/xJavaFxTool/XJavaFxToolApplication.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,13 @@ public void start(Stage primaryStage) throws Exception {
4747
// 1. 新UI启动时不扫描插件目录,启动更快;
4848
// 2. 新UI使用独立的ClassLoader加载插件,兼容性更好;
4949
// 3. 新UI本身体验较好。
50-
// loadNewUI(primaryStage);
5150
loadClassicUI(primaryStage);
5251

5352
StageUtils.loadPrimaryStageBound(primaryStage);
5453
primaryStage.show();
5554
StageUtils.updateStageStyle(primaryStage);
5655
}
5756

58-
private void loadNewUI(Stage primaryStage) throws IOException {
59-
FXMLLoader fxmlLoader = new FXMLLoader();
60-
fxmlLoader.setLocation(XJavaFxToolApplication.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/newui/main.fxml"));
61-
fxmlLoader.setResources(RESOURCE_BUNDLE);
62-
63-
Parent root = fxmlLoader.load();
64-
primaryStage.setScene(new Scene(root));
65-
}
66-
6757
private void loadClassicUI(Stage primaryStage) throws IOException {
6858
FXMLLoader fXMLLoader = IndexController.getFXMLLoader();
6959
Parent root = fXMLLoader.load();

src/main/java/com/xwintop/xJavaFxTool/controller/IndexController.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.xwintop.xJavaFxTool.event.PluginEvent;
77
import com.xwintop.xJavaFxTool.model.PluginJarInfo;
88
import com.xwintop.xJavaFxTool.model.ToolFxmlLoaderConfiguration;
9-
import com.xwintop.xJavaFxTool.newui.NewLauncherService;
109
import com.xwintop.xJavaFxTool.newui.PluginCategoryController;
1110
import com.xwintop.xJavaFxTool.newui.PluginItemController;
1211
import com.xwintop.xJavaFxTool.plugin.PluginManager;
@@ -26,7 +25,6 @@
2625
import javafx.fxml.FXML;
2726
import javafx.fxml.FXMLLoader;
2827
import javafx.scene.Parent;
29-
import javafx.scene.control.CheckMenuItem;
3028
import javafx.scene.control.ContextMenu;
3129
import javafx.scene.control.Menu;
3230
import javafx.scene.control.MenuItem;
@@ -74,7 +72,6 @@ public class IndexController extends IndexView {
7472
private IndexService indexService = new IndexService(this);
7573

7674
private ContextMenu contextMenu = new ContextMenu();
77-
private ContextMenu itemContextMenu;
7875

7976
// 实现搜索用
8077
private List<PluginItemController> pluginItemControllers = new ArrayList<>();
@@ -131,36 +128,19 @@ private void initEvent() {
131128
}
132129

133130
private void initService() {
134-
NewLauncherService.getInstance().setTabPane(tabPaneMain);
135131
loadPlugins(); // 加载插件列表到界面上
136132
AppEvents.addEventHandler(PluginEvent.PLUGIN_DOWNLOADED, pluginEvent -> {
137133
loadPlugins();
138134
});
139135
}
140136

141137
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();
158138
}
159139

160140
/**
161141
* 加载/刷新插件列表
162142
*/
163-
private void loadPlugins() {
143+
public void loadPlugins() {
164144
this.pluginCategories.getChildren().clear();
165145
this.pluginItemControllers.clear();
166146
this.categoryControllers.clear();
@@ -199,7 +179,7 @@ private void loadPlugin(PluginJarInfo jarInfo) {
199179
);
200180

201181
PluginItemController item = PluginItemController.newInstance(jarInfo);
202-
item.setContextMenu(itemContextMenu);
182+
item.setIndexController(this);
203183
category.addItem(item);
204184

205185
if (!pluginItemControllers.contains(item)) {

0 commit comments

Comments
 (0)