mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-38409 reduce direct usage of getState()
This commit is contained in:
@@ -221,14 +221,20 @@ class UISettings(private val notRoamableOptions: NotRoamableUiSettings) : Persis
|
||||
state.wideScreenSupport = value
|
||||
}
|
||||
|
||||
val sortBookmarks: Boolean
|
||||
var sortBookmarks: Boolean
|
||||
get() = state.sortBookmarks
|
||||
set(value) {
|
||||
state.sortBookmarks = value
|
||||
}
|
||||
|
||||
val showCloseButton: Boolean
|
||||
get() = state.showCloseButton
|
||||
|
||||
val presentationMode: Boolean
|
||||
var presentationMode: Boolean
|
||||
get() = state.presentationMode
|
||||
set(value) {
|
||||
state.presentationMode = value
|
||||
}
|
||||
|
||||
val presentationModeFontSize: Int
|
||||
get() = state.presentationModeFontSize
|
||||
@@ -287,6 +293,24 @@ class UISettings(private val notRoamableOptions: NotRoamableUiSettings) : Persis
|
||||
state.pinFindInPath = value
|
||||
}
|
||||
|
||||
var activeRightEditorOnClose: Boolean
|
||||
get() = state.activeRightEditorOnClose
|
||||
set(value) {
|
||||
state.activeRightEditorOnClose = value
|
||||
}
|
||||
|
||||
var showTabsTooltips: Boolean
|
||||
get() = state.showTabsTooltips
|
||||
set(value) {
|
||||
state.showTabsTooltips = value
|
||||
}
|
||||
|
||||
var markModifiedTabsWithAsterisk: Boolean
|
||||
get() = state.markModifiedTabsWithAsterisk
|
||||
set(value) {
|
||||
state.markModifiedTabsWithAsterisk = value
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
var overrideConsoleCycleBufferSize: Boolean
|
||||
get() = state.overrideConsoleCycleBufferSize
|
||||
|
||||
+4
-4
@@ -115,7 +115,7 @@ public class EditorAppearanceConfigurable extends CompositeConfigurable<UnnamedC
|
||||
myCbShowIntentionBulbCheckBox.setSelected(editorSettings.isShowIntentionBulb());
|
||||
//myAntialiasingInEditorCheckBox.setSelected(UISettings.getInstance().ANTIALIASING_IN_EDITOR);
|
||||
//myUseLCDRendering.setSelected(UISettings.getInstance().USE_LCD_RENDERING_IN_EDITOR);
|
||||
myShowCodeLensInEditorCheckBox.setSelected(UISettings.getInstance().getState().getShowEditorToolTip());
|
||||
myShowCodeLensInEditorCheckBox.setSelected(UISettings.getInstance().getShowEditorToolTip());
|
||||
|
||||
updateWhitespaceCheckboxesState();
|
||||
|
||||
@@ -162,8 +162,8 @@ public class EditorAppearanceConfigurable extends CompositeConfigurable<UnnamedC
|
||||
// uiSettingsModified = true;
|
||||
//}
|
||||
|
||||
if (uiSettings.getState().getShowEditorToolTip() != myShowCodeLensInEditorCheckBox.isSelected()) {
|
||||
uiSettings.getState().setShowEditorToolTip(myShowCodeLensInEditorCheckBox.isSelected());
|
||||
if (uiSettings.getShowEditorToolTip() != myShowCodeLensInEditorCheckBox.isSelected()) {
|
||||
uiSettings.setShowEditorToolTip(myShowCodeLensInEditorCheckBox.isSelected());
|
||||
uiSettingsModified = true;
|
||||
lafSettingsModified = true;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public class EditorAppearanceConfigurable extends CompositeConfigurable<UnnamedC
|
||||
isModified |= isModified(myCbShowMethodSeparators, DaemonCodeAnalyzerSettings.getInstance().SHOW_METHOD_SEPARATORS);
|
||||
//isModified |= myAntialiasingInEditorCheckBox.isSelected() != UISettings.getInstance().ANTIALIASING_IN_EDITOR;
|
||||
//isModified |= myUseLCDRendering.isSelected() != UISettings.getInstance().USE_LCD_RENDERING_IN_EDITOR;
|
||||
isModified |= myShowCodeLensInEditorCheckBox.isSelected() != UISettings.getInstance().getState().getShowEditorToolTip();
|
||||
isModified |= myShowCodeLensInEditorCheckBox.isSelected() != UISettings.getInstance().getShowEditorToolTip();
|
||||
isModified |= myShowParameterNameHints.isSelected() != editorSettings.isShowParameterNameHints();
|
||||
|
||||
return isModified;
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public class DefaultConsoleHistoryModel extends SimpleModificationTracker implem
|
||||
|
||||
@Override
|
||||
public int getMaxHistorySize() {
|
||||
return UISettings.getInstance().getState().getConsoleCommandHistoryLimit();
|
||||
return UISettings.getInstance().getConsoleCommandHistoryLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ViewNavigationBarAction extends ToggleAction implements DumbAware {
|
||||
@Override
|
||||
public boolean isSelected(@NotNull AnActionEvent e) {
|
||||
return UISettings.getInstance().getState().getShowNavigationBar();
|
||||
return UISettings.getInstance().getShowNavigationBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class MoveBookmarkDownAction extends DumbAwareAction {
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
int modelSize = myList.getModel().getSize();
|
||||
if (modelSize == 0 || !BookmarksAction.notFiltered(myList) || UISettings.getInstance().getState().getSortBookmarks()) {
|
||||
if (modelSize == 0 || !BookmarksAction.notFiltered(myList) || UISettings.getInstance().getSortBookmarks()) {
|
||||
e.getPresentation().setEnabled(false);
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-2
@@ -16,12 +16,12 @@ class ToggleSortBookmarksAction extends ToggleAction {
|
||||
|
||||
@Override
|
||||
public boolean isSelected(@NotNull AnActionEvent e) {
|
||||
return UISettings.getInstance().getState().getSortBookmarks();
|
||||
return UISettings.getInstance().getSortBookmarks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(@NotNull AnActionEvent e, boolean state) {
|
||||
UISettings.getInstance().getState().setSortBookmarks(state);
|
||||
UISettings.getInstance().setSortBookmarks(state);
|
||||
UISettings.getInstance().fireUISettingsChanged();
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class CopyPasteManagerEx extends CopyPasteManager implements ClipboardOwn
|
||||
}
|
||||
|
||||
private void deleteAfterAllowedMaximum() {
|
||||
int max = UISettings.getInstance().getState().getMaxClipboardContents();
|
||||
int max = UISettings.getInstance().getMaxClipboardContents();
|
||||
for (int i = myData.size() - 1; i >= max; i--) {
|
||||
myData.remove(i);
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class TogglePresentationModeAction extends AnAction implements DumbAware
|
||||
|
||||
public static void setPresentationMode(final Project project, final boolean inPresentation) {
|
||||
final UISettings settings = UISettings.getInstance();
|
||||
settings.getState().setPresentationMode(inPresentation);
|
||||
settings.setPresentationMode(inPresentation);
|
||||
|
||||
final boolean layoutStored = storeToolWindows(project);
|
||||
|
||||
|
||||
+2
-2
@@ -182,7 +182,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
int visualY = myEditor.getLineHeight() * visualLine;
|
||||
boolean isVisible = myWheelAccumulator == 0 && area.contains(area.x, visualY);
|
||||
|
||||
if (UIUtil.uiParents(myEditor.getComponent(), false).filter(EditorWindowHolder.class).isEmpty() || isVisible || !UISettings.getInstance().getState().getShowEditorToolTip()) {
|
||||
if (UIUtil.uiParents(myEditor.getComponent(), false).filter(EditorWindowHolder.class).isEmpty() || isVisible || !UISettings.getInstance().getShowEditorToolTip()) {
|
||||
final Set<RangeHighlighter> highlighters = new THashSet<>();
|
||||
getNearestHighlighters(this, me.getY(), highlighters);
|
||||
getNearestHighlighters(((EditorEx)getEditor()).getFilteredDocumentMarkupModel(), me.getY(), highlighters);
|
||||
@@ -527,7 +527,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
|
||||
@Override
|
||||
public void uiSettingsChanged(UISettings uiSettings) {
|
||||
if (!uiSettings.getState().getShowEditorToolTip()) {
|
||||
if (!uiSettings.getShowEditorToolTip()) {
|
||||
hideMyEditorPreviewHint();
|
||||
}
|
||||
setMinMarkHeight(DaemonCodeAnalyzerSettings.getInstance().getErrorStripeMarkMinHeight());
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.intellij.openapi.fileEditor.impl;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.actions.CloseAction;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.ui.UISettingsState;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
@@ -98,7 +99,7 @@ public class EditorWindow {
|
||||
private final Stack<Pair<String, Integer>> myRemovedTabs = new Stack<Pair<String, Integer>>() {
|
||||
@Override
|
||||
public void push(Pair<String, Integer> pair) {
|
||||
if (size() >= UISettings.getInstance().getState().getEditorTabLimit()) {
|
||||
if (size() >= UISettings.getInstance().getEditorTabLimit()) {
|
||||
remove(0);
|
||||
}
|
||||
super.push(pair);
|
||||
@@ -335,8 +336,8 @@ public class EditorWindow {
|
||||
// if the file being closed is not currently selected, keep the currently selected file open
|
||||
return currentlySelectedIndex;
|
||||
}
|
||||
UISettings uiSettings = UISettings.getInstance();
|
||||
if (uiSettings.getState().getActiveMruEditorOnClose()) {
|
||||
UISettingsState uiSettings = UISettings.getInstance().getState();
|
||||
if (uiSettings.getActiveMruEditorOnClose()) {
|
||||
// try to open last visited file
|
||||
final List<VirtualFile> histFiles = EditorHistoryManager.getInstance(getManager ().getProject()).getFileList();
|
||||
for (int idx = histFiles.size() - 1; idx >= 0; idx--) {
|
||||
@@ -355,7 +356,7 @@ public class EditorWindow {
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (uiSettings.getState().getActiveRightEditorOnClose() && fileIndex + 1 < myTabbedPane.getTabCount()) {
|
||||
if (uiSettings.getActiveRightEditorOnClose() && fileIndex + 1 < myTabbedPane.getTabCount()) {
|
||||
return fileIndex + 1;
|
||||
}
|
||||
|
||||
@@ -716,7 +717,7 @@ public class EditorWindow {
|
||||
final VirtualFile file = editor.getFile();
|
||||
final Icon template = AllIcons.FileTypes.Text;
|
||||
myTabbedPane.insertTab(file, EmptyIcon.create(template.getIconWidth(), template.getIconHeight()), new TComp(this, editor), null, indexToInsert);
|
||||
trimToSize(UISettings.getInstance().getState().getEditorTabLimit(), file, false);
|
||||
trimToSize(UISettings.getInstance().getEditorTabLimit(), file, false);
|
||||
if (selectEditor) {
|
||||
setSelectedEditor(editor, focusEditor);
|
||||
}
|
||||
@@ -901,7 +902,7 @@ public class EditorWindow {
|
||||
final int index = findEditorIndex(findFileComposite(file));
|
||||
if (index != -1) {
|
||||
setTitleAt(index, EditorTabPresentationUtil.getEditorTabTitle(getManager().getProject(), file, this));
|
||||
setToolTipTextAt(index, UISettings.getInstance().getState().getShowTabsTooltips()
|
||||
setToolTipTextAt(index, UISettings.getInstance().getShowTabsTooltips()
|
||||
? getManager().getFileTooltipText(file)
|
||||
: null);
|
||||
}
|
||||
@@ -933,9 +934,8 @@ public class EditorWindow {
|
||||
|
||||
final Icon modifiedIcon;
|
||||
UISettings settings = UISettings.getInstance();
|
||||
if (settings.getState().getMarkModifiedTabsWithAsterisk() || !settings.getHideTabsIfNeed()) {
|
||||
modifiedIcon =
|
||||
settings.getState().getMarkModifiedTabsWithAsterisk() && composite != null && composite.isModified() ? MODIFIED_ICON : GAP_ICON;
|
||||
if (settings.getMarkModifiedTabsWithAsterisk() || !settings.getHideTabsIfNeed()) {
|
||||
modifiedIcon = settings.getMarkModifiedTabsWithAsterisk() && composite != null && composite.isModified() ? MODIFIED_ICON : GAP_ICON;
|
||||
count++;
|
||||
}
|
||||
else {
|
||||
|
||||
+1
-1
@@ -797,7 +797,7 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener
|
||||
final List<Element> children = new ArrayList<>(fileElements.size());
|
||||
|
||||
// trim to EDITOR_TAB_LIMIT, ignoring CLOSE_NON_MODIFIED_FILES_FIRST policy
|
||||
int toRemove = fileElements.size() - UISettings.getInstance().getState().getEditorTabLimit();
|
||||
int toRemove = fileElements.size() - UISettings.getInstance().getEditorTabLimit();
|
||||
for (Element fileElement : fileElements) {
|
||||
if (toRemove <= 0 || Boolean.valueOf(fileElement.getAttributeValue(PINNED)).booleanValue()) {
|
||||
children.add(fileElement);
|
||||
|
||||
@@ -779,13 +779,13 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi
|
||||
UISettings settings = UISettings.getInstance();
|
||||
if (anchor == ToolWindowAnchor.LEFT) {
|
||||
if (settings.getLeftHorizontalSplit() != isSplitterHorizontalNow) {
|
||||
settings.getState().setLeftHorizontalSplit(isSplitterHorizontalNow);
|
||||
settings.setLeftHorizontalSplit(isSplitterHorizontalNow);
|
||||
settings.fireUISettingsChanged();
|
||||
}
|
||||
}
|
||||
if (anchor == ToolWindowAnchor.RIGHT) {
|
||||
if (settings.getRightHorizontalSplit() != isSplitterHorizontalNow) {
|
||||
settings.getState().setRightHorizontalSplit(isSplitterHorizontalNow);
|
||||
settings.setRightHorizontalSplit(isSplitterHorizontalNow);
|
||||
settings.fireUISettingsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user