[diff]: move toggle diff preview action into separated class

This commit is contained in:
Nadya Zabrodina
2017-05-17 17:22:56 +03:00
parent 20ad59ddbb
commit e593d4dff9
2 changed files with 42 additions and 16 deletions
@@ -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 {
@@ -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;
}
}