👔 完善标签页右键菜单的图标支持
This commit is contained in:
parent
6fee8fe4ee
commit
e85340ba06
@ -15,6 +15,7 @@ import org.jcnc.jnotepad.common.constants.TextConstants;
|
|||||||
import org.jcnc.jnotepad.component.module.TextCodeArea;
|
import org.jcnc.jnotepad.component.module.TextCodeArea;
|
||||||
import org.jcnc.jnotepad.views.root.bottom.status.BottomStatusBox;
|
import org.jcnc.jnotepad.views.root.bottom.status.BottomStatusBox;
|
||||||
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTab;
|
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTab;
|
||||||
|
import org.jcnc.jnotepad.views.root.center.main.center.tab.CenterTabPane;
|
||||||
import org.kordamp.ikonli.javafx.FontIcon;
|
import org.kordamp.ikonli.javafx.FontIcon;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
@ -135,7 +136,7 @@ public class BottomStatusBoxManager {
|
|||||||
CenterTab centerTab = instance.getSelected();
|
CenterTab centerTab = instance.getSelected();
|
||||||
if (centerTab != null) {
|
if (centerTab != null) {
|
||||||
updateEncodingLabel(centerTab.getCharset().name());
|
updateEncodingLabel(centerTab.getCharset().name());
|
||||||
|
updateReadOnlyProperty(centerTab, CenterTabPane.getInstance().getTabs());
|
||||||
// 添加光标位置变化监听器
|
// 添加光标位置变化监听器
|
||||||
TextCodeArea textArea = centerTab.getTextCodeArea();
|
TextCodeArea textArea = centerTab.getTextCodeArea();
|
||||||
textArea.caretPositionProperty().addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> updateRowColumnLabel(textArea.getCaretPosition(), textArea.getText()));
|
textArea.caretPositionProperty().addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> updateRowColumnLabel(textArea.getCaretPosition(), textArea.getText()));
|
||||||
@ -205,12 +206,18 @@ public class BottomStatusBoxManager {
|
|||||||
return String.format(encodingLabelFormat, UiResourceBundle.getContent(TextConstants.ENCODE), encoding);
|
return String.format(encodingLabelFormat, UiResourceBundle.getContent(TextConstants.ENCODE), encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the read-only property of a tab in the center tab pane.
|
||||||
|
*
|
||||||
|
* @param tab the tab to update the read-only property for
|
||||||
|
* @param tabs the list of tabs in the center tab pane
|
||||||
|
*/
|
||||||
public void updateReadOnlyProperty(CenterTab tab, ObservableList<Tab> tabs) {
|
public void updateReadOnlyProperty(CenterTab tab, ObservableList<Tab> tabs) {
|
||||||
ObservableList<Node> children = BOTTOM_STATUS_BOX.getChildren();
|
ObservableList<Node> children = BOTTOM_STATUS_BOX.getChildren();
|
||||||
Button readOnlyButton = BOTTOM_STATUS_BOX.getReadOnlyButton();
|
Button readOnlyButton = BOTTOM_STATUS_BOX.getReadOnlyButton();
|
||||||
BottomStatusBoxButtonBuilder builder = new BottomStatusBoxButtonBuilder(readOnlyButton);
|
BottomStatusBoxButtonBuilder builder = new BottomStatusBoxButtonBuilder(readOnlyButton);
|
||||||
if (tab.getTextCodeArea().isEditable()) {
|
if (tab.getTextCodeArea().isEditable()) {
|
||||||
FontIcon icon = FontIcon.of(LOCK);
|
FontIcon icon = FontIcon.of(UNLOCK);
|
||||||
if (children.contains(readOnlyButton)) {
|
if (children.contains(readOnlyButton)) {
|
||||||
readOnlyButton.setGraphic(icon);
|
readOnlyButton.setGraphic(icon);
|
||||||
} else {
|
} else {
|
||||||
@ -221,7 +228,7 @@ public class BottomStatusBoxManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
FontIcon icon = FontIcon.of(UNLOCK);
|
FontIcon icon = FontIcon.of(LOCK);
|
||||||
if (children.contains(readOnlyButton)) {
|
if (children.contains(readOnlyButton)) {
|
||||||
readOnlyButton.setGraphic(icon);
|
readOnlyButton.setGraphic(icon);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -297,7 +297,7 @@ public class CenterTabPaneManager {
|
|||||||
ObservableList<Tab> tabs = centerTabPane.getTabs();
|
ObservableList<Tab> tabs = centerTabPane.getTabs();
|
||||||
tabs.addListener((ListChangeListener<Tab>) c -> {
|
tabs.addListener((ListChangeListener<Tab>) c -> {
|
||||||
tab.contextMenuMonitor();
|
tab.contextMenuMonitor();
|
||||||
BottomStatusBoxManager.getInstance().updateReadOnlyProperty(tab, centerTabPane.getTabs());
|
BottomStatusBoxManager.getInstance().updateReadOnlyProperty(tab, tabs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user