mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
shelf: change Restore action to be applied for deleted changeLists
This commit is contained in:
@@ -527,7 +527,7 @@ cannot.apply.file.already.exists=Cannot apply patch to file {0}: it already exis
|
||||
change.lists.manager.add.unversioned=Add unversioned files
|
||||
change.lists.manager.move.changes.to.list=Move Changes to List
|
||||
vcs.shelf.action.restore.text=Restore
|
||||
vcs.shelf.action.restore.description=Makes selected already unshelved changelist(s) available for unshelve again
|
||||
vcs.shelf.action.restore.description=Restore recently deleted {0}
|
||||
vcs.shelf.move.text=Move shelves to the new location
|
||||
vcs.shelf.store.base.content=Shelve base revisions of files under distributed version control systems
|
||||
delete.all.already.unshelved=Delete All Already Unshelved
|
||||
|
||||
+21
-10
@@ -3,13 +3,19 @@ package com.intellij.openapi.vcs.changes.shelf;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.util.containers.ContainerUtil.isEmpty;
|
||||
import static com.intellij.util.containers.ContainerUtil.notNullize;
|
||||
|
||||
public class RestoreShelvedChange extends DumbAwareAction {
|
||||
public RestoreShelvedChange() {
|
||||
@@ -19,19 +25,24 @@ public class RestoreShelvedChange extends DumbAwareAction {
|
||||
@Override
|
||||
public void update(@NotNull final AnActionEvent e) {
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
final Collection<ShelvedChangeList> recycledChanges = e.getData(ShelvedChangesViewManager.SHELVED_RECYCLED_CHANGELIST_KEY);
|
||||
e.getPresentation().setText(VcsBundle.message("vcs.shelf.action.restore.text"));
|
||||
e.getPresentation().setDescription(VcsBundle.message("vcs.shelf.action.restore.description"));
|
||||
e.getPresentation().setEnabled(project != null && recycledChanges != null);
|
||||
Presentation presentation = e.getPresentation();
|
||||
if (project == null || project.isDisposed()) {
|
||||
presentation.setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
Collection<ShelvedChangeList> deletedLists = notNullize(e.getData(ShelvedChangesViewManager.SHELVED_DELETED_CHANGELIST_KEY));
|
||||
presentation.setText(VcsBundle.message("vcs.shelf.action.restore.text"));
|
||||
presentation
|
||||
.setDescription(VcsBundle.message("vcs.shelf.action.restore.description", StringUtil.pluralize("changelist", deletedLists.size())));
|
||||
presentation.setEnabled(!isEmpty(deletedLists));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull final AnActionEvent e) {
|
||||
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
|
||||
final Collection<ShelvedChangeList> recycledChanges = e.getData(ShelvedChangesViewManager.SHELVED_RECYCLED_CHANGELIST_KEY);
|
||||
if (recycledChanges != null && recycledChanges.size() == 1) {
|
||||
//noinspection ConstantConditions
|
||||
ShelveChangesManager.getInstance(project).restoreList(ContainerUtil.getFirstItem(recycledChanges));
|
||||
}
|
||||
ShelveChangesManager shelveChangesManager = ShelveChangesManager.getInstance(project);
|
||||
List<ShelvedChangeList> lists = e.getRequiredData(ShelvedChangesViewManager.SHELVED_DELETED_CHANGELIST_KEY);
|
||||
Date currentDate = new Date(System.currentTimeMillis());
|
||||
lists.forEach(l -> shelveChangesManager.restoreList(l, currentDate));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-6
@@ -951,12 +951,9 @@ public class ShelveChangesManager implements JDOMExternalizable, ProjectComponen
|
||||
return listCopy;
|
||||
}
|
||||
|
||||
public void restoreList(@NotNull final ShelvedChangeList changeList) {
|
||||
ShelvedChangeList list = mySchemeManager.findSchemeByName(changeList.getName());
|
||||
if (list != null) {
|
||||
list.setRecycled(false);
|
||||
list.updateDate();
|
||||
}
|
||||
public void restoreList(@NotNull final ShelvedChangeList shelvedChangeList, @NotNull Date restoreDate) {
|
||||
shelvedChangeList.setDeleted(false);
|
||||
shelvedChangeList.DATE = restoreDate;
|
||||
notifyStateChanged();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user