mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-153759 diff: remember "Disable editing" toggle state
This commit is contained in:
@@ -1076,7 +1076,7 @@ public class UnifiedDiffViewer extends ListenerDiffViewerBase {
|
||||
private class MyReadOnlyLockAction extends TextDiffViewerUtil.ReadOnlyLockAction {
|
||||
public MyReadOnlyLockAction() {
|
||||
super(getContext());
|
||||
init();
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,6 +58,7 @@ public class TextDiffSettingsHolder implements PersistentStateComponent<TextDiff
|
||||
public boolean SHOW_INDENT_LINES = false;
|
||||
public boolean USE_SOFT_WRAPS = false;
|
||||
public HighlightingLevel HIGHLIGHTING_LEVEL = HighlightingLevel.INSPECTIONS;
|
||||
public boolean READ_ONLY_LOCK = true;
|
||||
|
||||
// Fragments settings
|
||||
public boolean EXPAND_BY_DEFAULT = true;
|
||||
@@ -165,6 +166,14 @@ public class TextDiffSettingsHolder implements PersistentStateComponent<TextDiff
|
||||
PLACE_SETTINGS.EXPAND_BY_DEFAULT = value;
|
||||
}
|
||||
|
||||
public boolean isReadOnlyLock() {
|
||||
return PLACE_SETTINGS.READ_ONLY_LOCK;
|
||||
}
|
||||
|
||||
public void setReadOnlyLock(boolean state) {
|
||||
PLACE_SETTINGS.READ_ONLY_LOCK = state;
|
||||
}
|
||||
|
||||
//
|
||||
// Impl
|
||||
//
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.intellij.openapi.editor.event.EditorMouseEvent;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.ui.ToggleActionButton;
|
||||
import com.intellij.util.EditorPopupHandler;
|
||||
import com.intellij.util.Function;
|
||||
@@ -52,7 +51,6 @@ import java.util.List;
|
||||
|
||||
public class TextDiffViewerUtil {
|
||||
public static final Logger LOG = Logger.getInstance(TextDiffViewerUtil.class);
|
||||
public static final Key<Boolean> READ_ONLY_LOCK_KEY = Key.create("ReadOnlyLockAction");
|
||||
|
||||
@NotNull
|
||||
public static List<AnAction> createEditorPopupActions() {
|
||||
@@ -341,14 +339,16 @@ public class TextDiffViewerUtil {
|
||||
|
||||
public static abstract class ReadOnlyLockAction extends ToggleAction implements DumbAware {
|
||||
@NotNull protected final DiffContext myContext;
|
||||
@NotNull protected final TextDiffSettings mySettings;
|
||||
|
||||
public ReadOnlyLockAction(@NotNull DiffContext context) {
|
||||
super("Disable editing", null, AllIcons.Nodes.Padlock);
|
||||
myContext = context;
|
||||
mySettings = getTextSettings(context);
|
||||
setEnabledInModalContext(true);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
protected void applyDefaults() {
|
||||
if (isVisible()) { // apply default state
|
||||
setSelected(null, isSelected(null));
|
||||
}
|
||||
@@ -366,12 +366,12 @@ public class TextDiffViewerUtil {
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
return myContext.getUserData(READ_ONLY_LOCK_KEY) != Boolean.FALSE;
|
||||
return mySettings.isReadOnlyLock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
myContext.putUserData(READ_ONLY_LOCK_KEY, state);
|
||||
mySettings.setReadOnlyLock(state);
|
||||
doApply(state);
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ public class TextDiffViewerUtil {
|
||||
public EditorReadOnlyLockAction(@NotNull DiffContext context, @NotNull List<? extends EditorEx> editableEditors) {
|
||||
super(context);
|
||||
myEditableEditors = editableEditors;
|
||||
init();
|
||||
applyDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user