♻️ 重构代码 重构顶部菜单栏与侧边工具栏
This commit is contained in:
parent
13f2f6703d
commit
0f2eee7d5c
@ -5,6 +5,7 @@ import javafx.collections.ObservableList;
|
|||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.input.KeyCombination;
|
import javafx.scene.input.KeyCombination;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
@ -13,7 +14,7 @@ import org.jcnc.jnotepad.controller.config.AppConfigController;
|
|||||||
import org.jcnc.jnotepad.controller.event.handler.menubar.*;
|
import org.jcnc.jnotepad.controller.event.handler.menubar.*;
|
||||||
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
import org.jcnc.jnotepad.controller.i18n.LocalizationController;
|
||||||
import org.jcnc.jnotepad.model.entity.ShortcutKey;
|
import org.jcnc.jnotepad.model.entity.ShortcutKey;
|
||||||
import org.jcnc.jnotepad.plugin.PluginManagerInterface;
|
import org.jcnc.jnotepad.ui.pluginstage.PluginManagementPane;
|
||||||
import org.jcnc.jnotepad.util.LogUtil;
|
import org.jcnc.jnotepad.util.LogUtil;
|
||||||
import org.jcnc.jnotepad.util.UiUtil;
|
import org.jcnc.jnotepad.util.UiUtil;
|
||||||
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTabPane;
|
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTabPane;
|
||||||
@ -111,12 +112,18 @@ public class TopMenuBarManager {
|
|||||||
registerSetMenuItem(topMenuBar.getLanguageMenu(), LANGUAGE, "languageMenu", actionEvent -> {
|
registerSetMenuItem(topMenuBar.getLanguageMenu(), LANGUAGE, "languageMenu", actionEvent -> {
|
||||||
});
|
});
|
||||||
|
|
||||||
//插件菜单
|
// //插件菜单
|
||||||
registerPluginMenuItem(topMenuBar.getAddItem(), ADD_PLUGIN, "addItem", event -> {
|
|
||||||
PluginManagerInterface pluginManagerInterface = PluginManagerInterface.getInstance();
|
registerPluginMenuItem(topMenuBar.getPluginManagerItem(), MANAGER_PLUGIN, "pluginManagerItem", event -> {
|
||||||
Stage stage = new Stage();
|
Stage newStage = new Stage();
|
||||||
stage.getIcons().add(UiUtil.getAppIcon());
|
newStage.getIcons().add(UiUtil.getAppIcon());
|
||||||
pluginManagerInterface.start(stage);
|
newStage.setTitle("插件管理");
|
||||||
|
|
||||||
|
PluginManagementPane pluginManagementPane = new PluginManagementPane();
|
||||||
|
|
||||||
|
Scene scene = new Scene(pluginManagementPane, 900, 500);
|
||||||
|
newStage.setScene(scene);
|
||||||
|
newStage.show();
|
||||||
});
|
});
|
||||||
registerPluginMenuItem(topMenuBar.getCountItem(), STATISTICS, "countItem", event -> {
|
registerPluginMenuItem(topMenuBar.getCountItem(), STATISTICS, "countItem", event -> {
|
||||||
});
|
});
|
||||||
@ -260,7 +267,10 @@ public class TopMenuBarManager {
|
|||||||
// 保证json的key必须和变量名一致
|
// 保证json的key必须和变量名一致
|
||||||
MenuItem menuItem = topMenuBar.getItemMap().get(shortcutKey.getButtonName());
|
MenuItem menuItem = topMenuBar.getItemMap().get(shortcutKey.getButtonName());
|
||||||
String shortKeyValue = shortcutKey.getShortcutKeyValue();
|
String shortKeyValue = shortcutKey.getShortcutKeyValue();
|
||||||
if (Objects.isNull(menuItem) || "".equals(shortKeyValue)) {
|
if (Objects.isNull(menuItem)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ("".equals(shortKeyValue)) {
|
||||||
itemsToUnbind.add(menuItem);
|
itemsToUnbind.add(menuItem);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,11 +61,7 @@ public class TopMenuBar extends MenuBar {
|
|||||||
* 重命名
|
* 重命名
|
||||||
*/
|
*/
|
||||||
private final MenuItem renameItem = new MenuItem();
|
private final MenuItem renameItem = new MenuItem();
|
||||||
/**
|
|
||||||
* 增加
|
|
||||||
*/
|
|
||||||
private final MenuItem addItem = new MenuItem();
|
|
||||||
private MenuItem pluginManagerItem;
|
|
||||||
/**
|
/**
|
||||||
* 查看
|
* 查看
|
||||||
*/
|
*/
|
||||||
@ -91,6 +87,11 @@ public class TopMenuBar extends MenuBar {
|
|||||||
*/
|
*/
|
||||||
private final RadioMenuItem englishItem = new RadioMenuItem();
|
private final RadioMenuItem englishItem = new RadioMenuItem();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件管理菜单项
|
||||||
|
*/
|
||||||
|
private final MenuItem pluginManagerItem = new MenuItem();
|
||||||
|
|
||||||
private TopMenuBar() {
|
private TopMenuBar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,9 +148,6 @@ public class TopMenuBar extends MenuBar {
|
|||||||
return renameItem;
|
return renameItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MenuItem getAddItem() {
|
|
||||||
return addItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuItem getCountItem() {
|
public MenuItem getCountItem() {
|
||||||
return countItem;
|
return countItem;
|
||||||
@ -174,4 +172,8 @@ public class TopMenuBar extends MenuBar {
|
|||||||
public RadioMenuItem getEnglishItem() {
|
public RadioMenuItem getEnglishItem() {
|
||||||
return englishItem;
|
return englishItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MenuItem getPluginManagerItem() {
|
||||||
|
return pluginManagerItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user