diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java index fc0b3e000148..fa324f60b569 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java @@ -43,6 +43,7 @@ import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.actions.IgnoredSettingsAction; +import com.intellij.openapi.vcs.changes.actions.ShowDiffPreviewAction; import com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager; import com.intellij.openapi.vcs.changes.ui.*; import com.intellij.openapi.vfs.VirtualFile; @@ -474,27 +475,13 @@ public class ChangesViewManager implements ChangesViewI, ProjectComponent, Persi } } - private class ToggleDetailsAction extends ToggleAction implements DumbAware { - private ToggleDetailsAction() { - super("Preview Diff", null, AllIcons.Actions.DiffPreview); - } - - @Override - public boolean isSelected(AnActionEvent e) { - return assertNotNull(mySplitterComponent).isDetailsOn(); - } - + private class ToggleDetailsAction extends ShowDiffPreviewAction { @Override public void setSelected(AnActionEvent e, boolean state) { + super.setSelected(e, state); assertNotNull(mySplitterComponent).setDetailsOn(state); VcsConfiguration.getInstance(myProject).LOCAL_CHANGES_DETAILS_PREVIEW_SHOWN = state; } - - @Override - public void update(@NotNull AnActionEvent e) { - super.update(e); - e.getPresentation().setEnabled(mySplitterComponent != null); - } } private class MyChangeProcessor extends CacheChangeProcessor { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ShowDiffPreviewAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ShowDiffPreviewAction.java new file mode 100644 index 000000000000..068a97b8ea16 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ShowDiffPreviewAction.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2017 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.vcs.changes.actions; + +import com.intellij.icons.AllIcons; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.ToggleAction; +import com.intellij.openapi.project.DumbAware; + +public abstract class ShowDiffPreviewAction extends ToggleAction implements DumbAware { + private boolean myState; + + public ShowDiffPreviewAction() { + super("Preview Diff", null, AllIcons.Actions.DiffPreview); + } + + @Override + public boolean isSelected(AnActionEvent e) { + return myState; + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + myState = state; + } +}