package jetbrains.mps.ide.refactoring; /*Generated by MPS */ import jetbrains.mps.ide.findusages.view.TabbedUsagesTool; import java.util.List; import java.util.ArrayList; import com.intellij.openapi.project.Project; import jetbrains.mps.ide.icons.IdeIcons; import com.intellij.openapi.wm.ToolWindowAnchor; import jetbrains.mps.ide.findusages.view.UsagesView; import jetbrains.mps.refactoring.framework.RefactoringContext; import org.jetbrains.annotations.NotNull; import jetbrains.mps.ide.platform.refactoring.RefactoringViewAction; import org.jetbrains.annotations.Nullable; import jetbrains.mps.ide.findusages.model.SearchResults; import jetbrains.mps.ide.findusages.model.SearchTask; import jetbrains.mps.ide.project.ProjectHelper; public class RefactoringView extends TabbedUsagesTool { private List<RefactoringViewItemImpl> myRefactoringViews = new ArrayList<RefactoringViewItemImpl>(); protected RefactoringView(Project project) { super(project, "RefactoringView", -1, IdeIcons.DEFAULT_ICON, ToolWindowAnchor.BOTTOM, true); } @Override protected UsagesView getUsagesView(int index) { return myRefactoringViews.get(index).getUsagesView(); } @Override protected void onRemove(int index) { myRefactoringViews.remove(index); } @Override protected boolean forceCloseOnReload() { return true; } public void showRefactoringView(RefactoringContext refactoringContext, @NotNull RefactoringViewAction refactoringViewAction, @Nullable Runnable disposeAction, SearchResults searchResults, SearchTask searchTask) { RefactoringViewItemImpl refactoringViewItem = new RefactoringView.MyRefactoringViewItem(refactoringContext, refactoringViewAction, disposeAction, searchResults, searchTask); myRefactoringViews.add(refactoringViewItem); addContent(refactoringViewItem.getComponent(), refactoringContext.getRefactoring().getUserFriendlyName(), null, false); openTool(true); } public void showRefactoringView(Project p, @NotNull RefactoringViewAction refactorAction, @Nullable Runnable disposeAction, SearchResults searchResults, SearchTask searchTask, String name) { RefactoringViewItemImpl refactoringViewItem = new RefactoringView.MyRefactoringViewItem(ProjectHelper.toMPSProject(p), refactorAction, disposeAction, searchResults, searchTask); myRefactoringViews.add(refactoringViewItem); addContent(refactoringViewItem.getComponent(), name, null, false); openTool(true); } private class MyRefactoringViewItem extends RefactoringViewItemImpl { private Runnable myDisposeAction; public MyRefactoringViewItem(RefactoringContext refactoringContext, RefactoringViewAction refactoringViewAction, Runnable disposeAction, SearchResults searchResults, SearchTask searchTask) { super(refactoringContext, refactoringViewAction, searchResults, searchTask); myDisposeAction = disposeAction; } public MyRefactoringViewItem(jetbrains.mps.project.Project p, RefactoringViewAction refactoringViewAction, Runnable disposeAction, SearchResults searchResults, SearchTask searchTask) { super(p, refactoringViewAction, searchResults, searchTask); myDisposeAction = disposeAction; } @Override public void close() { if (myDisposeAction != null) { myDisposeAction.run(); } int index = myRefactoringViews.indexOf(this); RefactoringView.this.closeTab(index); } } }