[shelf]: EA-76344 change required project data to simple data and handle null cases

This commit is contained in:
Nadya Zabrodina
2015-12-22 18:34:52 +03:00
parent cde070a569
commit 7c254e9853
@@ -17,7 +17,6 @@ package com.intellij.openapi.vcs.changes.shelf;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.DumbAware;
@@ -29,7 +28,7 @@ public class ShowHideRecycledAction extends ToggleAction implements DumbAware {
@Override
public void update(@NotNull final AnActionEvent e) {
super.update(e);
final Project project = e.getData(CommonDataKeys.PROJECT);
final Project project = getEventProject(e);
final Presentation presentation = e.getPresentation();
presentation.setEnabledAndVisible(project != null);
if (project != null) {
@@ -41,14 +40,15 @@ public class ShowHideRecycledAction extends ToggleAction implements DumbAware {
@Override
public boolean isSelected(AnActionEvent e) {
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
final ShelveChangesManager manager = ShelveChangesManager.getInstance(project);
return manager.isShowRecycled();
final Project project = getEventProject(e);
return project != null && ShelveChangesManager.getInstance(project).isShowRecycled();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
ShelveChangesManager.getInstance(project).setShowRecycled(state);
final Project project = getEventProject(e);
if (project != null) {
ShelveChangesManager.getInstance(project).setShowRecycled(state);
}
}
}