diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/AbstractToggleUseSoftWrapsAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/AbstractToggleUseSoftWrapsAction.java index 50b5cd8325cb..5c0158d63a66 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/AbstractToggleUseSoftWrapsAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/AbstractToggleUseSoftWrapsAction.java @@ -19,8 +19,8 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.LogicalPosition; -import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces; import com.intellij.openapi.project.DumbAware; @@ -54,6 +54,7 @@ public abstract class AbstractToggleUseSoftWrapsAction extends ToggleAction impl @Override public boolean isSelected(AnActionEvent e) { + if (myGlobal) return EditorSettingsExternalizable.getInstance().isUseSoftWraps(); Editor editor = getEditor(e); return editor != null && editor.getSettings().isUseSoftWraps(); } @@ -71,15 +72,12 @@ public abstract class AbstractToggleUseSoftWrapsAction extends ToggleAction impl if (myGlobal) { EditorSettingsExternalizable.getInstance().setUseSoftWraps(state, myAppliancePlace); + EditorFactory.getInstance().refreshAllEditors(); } - else { + if (editor.getSettings().isUseSoftWraps() != state) { editor.getSettings().setUseSoftWraps(state); } - if (editor instanceof EditorEx) { - ((EditorEx)editor).reinitSettings(); - } - editor.getScrollingModel().disableAnimation(); editor.getScrollingModel().scrollVertically(editor.logicalPositionToXY(anchorPosition).y + intraLineShift); editor.getScrollingModel().enableAnimation(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleShowIndentLinesGloballyAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleShowIndentLinesGloballyAction.java new file mode 100644 index 000000000000..322c6e930849 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleShowIndentLinesGloballyAction.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor.actions; + +import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.ToggleAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; +import com.intellij.openapi.project.Project; + +public class ToggleShowIndentLinesGloballyAction extends ToggleAction { + @Override + public boolean isSelected(AnActionEvent e) { + return EditorSettingsExternalizable.getInstance().isIndentGuidesShown(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + EditorSettingsExternalizable.getInstance().setIndentGuidesShown(state); + Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext()); + if (editor != null && editor.getSettings().isIndentGuidesShown() != state) { + editor.getSettings().setIndentGuidesShown(state); + } + Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); + if (project != null) { + DaemonCodeAnalyzer.getInstance(project).restart(); + } + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleShowLineNumbersGloballyAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleShowLineNumbersGloballyAction.java new file mode 100644 index 000000000000..816e0232a908 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleShowLineNumbersGloballyAction.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.ToggleAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.EditorFactory; +import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; + +public class ToggleShowLineNumbersGloballyAction extends ToggleAction { + @Override + public boolean isSelected(AnActionEvent e) { + return EditorSettingsExternalizable.getInstance().isLineNumbersShown(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + EditorSettingsExternalizable.getInstance().setLineNumbersShown(state); + Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext()); + if (editor != null && editor.getSettings().isLineNumbersShown() != state) { + editor.getSettings().setLineNumbersShown(state); + } + EditorFactory.getInstance().refreshAllEditors(); + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleSoftWrapsGloballyAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleSoftWrapsGloballyAction.java new file mode 100644 index 000000000000..b5e77757c7bb --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleSoftWrapsGloballyAction.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor.actions; + +import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces; + +public class ToggleSoftWrapsGloballyAction extends AbstractToggleUseSoftWrapsAction { + public ToggleSoftWrapsGloballyAction() { + super(SoftWrapAppliancePlaces.MAIN_EDITOR, true); + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsMenuAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsMenuAction.java index 7bcd536c6149..cfe7b6bf1018 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsMenuAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleUseSoftWrapsMenuAction.java @@ -15,9 +15,11 @@ */ package com.intellij.openapi.editor.actions; +import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.editor.impl.softwrap.SoftWrapAppliancePlaces; +import org.jetbrains.annotations.NotNull; /** * Action that toggles 'show soft wraps at editor' option and is expected to be used at various menus. @@ -32,11 +34,14 @@ public class ToggleUseSoftWrapsMenuAction extends AbstractToggleUseSoftWrapsActi } @Override - public void update(AnActionEvent e){ + public void update(@NotNull AnActionEvent e){ super.update(e); if (!ActionPlaces.isToolbarPlace(e.getPlace())) { e.getPresentation().setIcon(null); } + if (ActionPlaces.UNKNOWN.equals(e.getPlace())) { + e.getPresentation().setText(ActionsBundle.message("action.EditorGutterToggleLocalSoftWraps.gutterText")); + } e.getPresentation().setEnabled(getEditor(e) != null); } } diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index fae884202e48..58435c2cfc1a 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -1451,6 +1451,10 @@ action.CreateLauncherScript.description=Create a script for opening files and pr action.CreateDesktopEntry.text=Create Desktop Entry... action.CreateDesktopEntry.description=Create a desktop entry for integration with system application menu group.EditorGutterPopupMenu.text=Editor Gutter Popup Menu +action.EditorGutterToggleGlobalSoftWraps.text=Soft-Wrap All Files +action.EditorGutterToggleLocalSoftWraps.gutterText=Soft-Wrap Current File +action.EditorGutterToggleGlobalLineNumbers.text=Show Line Numbers +action.EditorGutterToggleGlobalIndentLines.text=Show Indent Guides action.ExcludeFromProject.text=Exclude From Project... group.MarkFileAs.text=Mark File As action.MarkAsPlainTextAction.text=Mark as Plain Text diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 90b4aecc8310..70a8e8cf28ea 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -603,9 +603,11 @@ - - - + + + + +