fix(gui): hide not needed popup action for not editable code
This commit is contained in:
@@ -84,11 +84,9 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
|
||||
this.node = Objects.requireNonNull(node);
|
||||
|
||||
setMarkOccurrences(false);
|
||||
setEditable(node.isEditable());
|
||||
setCodeFoldingEnabled(false);
|
||||
setFadeCurrentLineHighlight(true);
|
||||
setCloseCurlyBraces(true);
|
||||
setAntiAliasingEnabled(true);
|
||||
applyEditableProperties(node);
|
||||
loadSettings();
|
||||
|
||||
JadxSettings settings = contentPanel.getTabbedPane().getMainWindow().getSettings();
|
||||
@@ -107,6 +105,47 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
|
||||
}
|
||||
}
|
||||
|
||||
private void applyEditableProperties(JNode node) {
|
||||
boolean editable = node.isEditable();
|
||||
setEditable(editable);
|
||||
setCodeFoldingEnabled(editable);
|
||||
if (editable) {
|
||||
setCloseCurlyBraces(true);
|
||||
setCloseMarkupTags(true);
|
||||
setAutoIndentEnabled(true);
|
||||
setClearWhitespaceLinesEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JPopupMenu createPopupMenu() {
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
if (node.isEditable()) {
|
||||
menu.add(createPopupMenuItem(getAction(UNDO_ACTION)));
|
||||
menu.add(createPopupMenuItem(getAction(REDO_ACTION)));
|
||||
menu.addSeparator();
|
||||
menu.add(createPopupMenuItem(cutAction));
|
||||
menu.add(createPopupMenuItem(copyAction));
|
||||
menu.add(createPopupMenuItem(getAction(PASTE_ACTION)));
|
||||
menu.add(createPopupMenuItem(getAction(DELETE_ACTION)));
|
||||
menu.addSeparator();
|
||||
menu.add(createPopupMenuItem(getAction(SELECT_ALL_ACTION)));
|
||||
} else {
|
||||
menu.add(createPopupMenuItem(copyAction));
|
||||
menu.add(createPopupMenuItem(getAction(SELECT_ALL_ACTION)));
|
||||
}
|
||||
appendFoldingMenu(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendFoldingMenu(JPopupMenu popup) {
|
||||
// append code folding popup menu entry only if enabled
|
||||
if (isCodeFoldingEnabled()) {
|
||||
super.appendFoldingMenu(popup);
|
||||
}
|
||||
}
|
||||
|
||||
private void addWrapLineMenuAction(JadxSettings settings) {
|
||||
JPopupMenu popupMenu = getPopupMenu();
|
||||
popupMenu.addSeparator();
|
||||
@@ -280,6 +319,7 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
|
||||
|
||||
public void setLoaded() {
|
||||
this.loaded = true;
|
||||
discardAllEdits(); // disable 'undo' action to empty state (before load)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user