mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
svn: Utilized common "VcsShowToolWindowTabAction" for "ShowSvnMapAction" implementation (opening "Subversion Working Copies Information" tab)
Note that no new tab will be created - just existing tab (if any) will be opened (currently corresponding tab is created right after project initialization - see "SvnVcs.postStartup()")
This commit is contained in:
@@ -25,10 +25,19 @@ import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.assertNotNull;
|
||||
|
||||
public abstract class VcsShowToolWindowTabAction extends DumbAwareAction {
|
||||
|
||||
protected VcsShowToolWindowTabAction() {
|
||||
}
|
||||
|
||||
protected VcsShowToolWindowTabAction(@Nullable String text, @Nullable String description, @Nullable Icon icon) {
|
||||
super(text, description, icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
|
||||
|
||||
@@ -27,6 +27,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.svn.dialogs.CopiesPanel;
|
||||
|
||||
public class WorkingCopiesContent {
|
||||
|
||||
public static final String TAB_NAME = SvnBundle.message("dialog.show.svn.map.title");
|
||||
|
||||
private final SvnVcs myVcs;
|
||||
private Content myShownContent;
|
||||
|
||||
@@ -39,7 +42,7 @@ public class WorkingCopiesContent {
|
||||
final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
|
||||
|
||||
final CopiesPanel copiesPanel = new CopiesPanel(myVcs.getProject());
|
||||
myShownContent = contentFactory.createContent(copiesPanel.getComponent(), SvnBundle.message("dialog.show.svn.map.title"), true);
|
||||
myShownContent = contentFactory.createContent(copiesPanel.getComponent(), TAB_NAME, true);
|
||||
myShownContent.setCloseable(false);
|
||||
cvcm.addContent(myShownContent);
|
||||
myShownContent.setPreferredFocusableComponent(copiesPanel.getPreferredFocusedComponent());
|
||||
@@ -60,7 +63,7 @@ public class WorkingCopiesContent {
|
||||
if (window != null) {
|
||||
window.show(null);
|
||||
final ContentManager cm = window.getContentManager();
|
||||
final Content content = cm.findContent(SvnBundle.message("dialog.show.svn.map.title"));
|
||||
final Content content = cm.findContent(TAB_NAME);
|
||||
if (content != null) {
|
||||
cm.setSelectedContent(content, true);
|
||||
}
|
||||
|
||||
@@ -15,63 +15,21 @@
|
||||
*/
|
||||
package org.jetbrains.idea.svn.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentFactory;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.util.ContentsUtil;
|
||||
import com.intellij.vcs.VcsShowToolWindowTabAction;
|
||||
import icons.SvnIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.svn.SvnBundle;
|
||||
import org.jetbrains.idea.svn.dialogs.CopiesPanel;
|
||||
import org.jetbrains.idea.svn.WorkingCopiesContent;
|
||||
|
||||
public class ShowSvnMapAction extends VcsShowToolWindowTabAction {
|
||||
|
||||
public class ShowSvnMapAction extends AnAction implements DumbAware {
|
||||
public ShowSvnMapAction() {
|
||||
super(SvnBundle.message("action.show.svn.map.text"));
|
||||
super(SvnBundle.message("action.show.svn.map.text"), SvnBundle.message("action.show.svn.map.description"), SvnIcons.ShowWorkingCopies);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
|
||||
final Presentation presentation = e.getPresentation();
|
||||
presentation.setVisible(project != null);
|
||||
presentation.setEnabled(project != null);
|
||||
|
||||
presentation.setDescription(SvnBundle.message("action.show.svn.map.description"));
|
||||
presentation.setIcon(SvnIcons.ShowWorkingCopies);
|
||||
}
|
||||
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CopiesPanel copiesPanel = new CopiesPanel(project);
|
||||
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);
|
||||
final ContentManager contentManager = toolWindow.getContentManager();
|
||||
|
||||
Content content = ContentFactory.SERVICE.getInstance().createContent(copiesPanel.getComponent(), SvnBundle.message("dialog.show.svn.map.title"), true);
|
||||
ContentsUtil.addOrReplaceContent(contentManager, content, true);
|
||||
toolWindow.activate(new Runnable() {
|
||||
public void run() {
|
||||
IdeFocusManager.getInstance(project).requestFocus(copiesPanel.getPreferredFocusedComponent(), true);
|
||||
}
|
||||
});
|
||||
/*SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
IdeFocusManager.getInstance(project).requestFocus(copiesPanel.getPrefferedFocusComponent(), true);
|
||||
}
|
||||
});*/
|
||||
protected String getTabName() {
|
||||
return WorkingCopiesContent.TAB_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user