👔 完善标签页右键菜单
This commit is contained in:
parent
9b6ec0734e
commit
0e3b7dcaab
@ -1,5 +1,6 @@
|
||||
package org.jcnc.jnotepad.util;
|
||||
|
||||
import javafx.scene.control.CheckMenuItem;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.input.KeyCode;
|
||||
@ -40,6 +41,7 @@ import static org.jcnc.jnotepad.util.FileUtil.getFileText;
|
||||
public class TabUtil {
|
||||
private static final ApplicationCacheManager CACHE_MANAGER = ApplicationCacheManager.getInstance();
|
||||
static Logger logger = LogUtil.getLogger(TabUtil.class);
|
||||
|
||||
private TabUtil() {
|
||||
}
|
||||
|
||||
@ -379,8 +381,9 @@ public class TabUtil {
|
||||
})
|
||||
.build(), tab.isRelevance())
|
||||
.addSeparatorMenuItem()
|
||||
.addMenuItem("固定标签页", e -> centerTabPaneManager.updateTabPinnedState(tab), !tab.isFixed())
|
||||
.addMenuItem("取消固定", e -> centerTabPaneManager.updateTabPinnedState(tab), tab.isFixed())
|
||||
.addCheckMenuItem("固定标签页", e -> centerTabPaneManager.updateTabPinnedState(tab, (CheckMenuItem) e.getSource()))
|
||||
.addSeparatorMenuItem()
|
||||
.addCheckMenuItem("只读", e -> centerTabPaneManager.updateReadOnlyProperty(tab, (CheckMenuItem) e.getSource()))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package org.jcnc.jnotepad.views.manager;
|
||||
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.control.CheckMenuItem;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.stage.Stage;
|
||||
import org.jcnc.jnotepad.common.manager.ApplicationCacheManager;
|
||||
@ -10,7 +11,6 @@ import org.jcnc.jnotepad.controller.config.UserConfigController;
|
||||
import org.jcnc.jnotepad.model.enums.CacheExpirationTime;
|
||||
import org.jcnc.jnotepad.util.FileUtil;
|
||||
import org.jcnc.jnotepad.util.PopUpUtil;
|
||||
import org.jcnc.jnotepad.util.TabUtil;
|
||||
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTab;
|
||||
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTabPane;
|
||||
import org.jcnc.jnotepad.views.root.top.menubar.TopMenuBar;
|
||||
@ -273,11 +273,20 @@ public class CenterTabPaneManager {
|
||||
*
|
||||
* @param tab the center tab to update
|
||||
*/
|
||||
public void updateTabPinnedState(CenterTab tab) {
|
||||
public void updateTabPinnedState(CenterTab tab, CheckMenuItem checkMenuItem) {
|
||||
tab.setFixed(!tab.isFixed());
|
||||
TabUtil.updateTabContextMenu(tab);
|
||||
checkMenuItem.setSelected(tab.isFixed());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates the read-only property of a given tab and its associated check menu item.
|
||||
*
|
||||
* @param tab the center tab to update
|
||||
* @param checkMenuItem the check menu item associated with the tab
|
||||
*/
|
||||
public void updateReadOnlyProperty(CenterTab tab, CheckMenuItem checkMenuItem) {
|
||||
TextCodeArea textCodeArea = tab.getTextCodeArea();
|
||||
textCodeArea.setEditable(!textCodeArea.isEditable());
|
||||
checkMenuItem.setSelected(!textCodeArea.isEditable());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user