mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed host selector.
This commit is contained in:
@@ -15,16 +15,17 @@
|
||||
*/
|
||||
package com.intellij.tools;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Stores main keys from DataContext.
|
||||
*
|
||||
* Normally nobody needs this. This handles specific case when after action is invoked a dialog can appear, but
|
||||
* we need the DataContext from the action.
|
||||
*
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@@ -40,8 +41,10 @@ class HackyDataContext implements DataContext {
|
||||
|
||||
|
||||
private final Map<String, Object> values = new HashMap<String, Object>();
|
||||
private AnActionEvent myActionEvent;
|
||||
|
||||
public HackyDataContext(DataContext context) {
|
||||
public HackyDataContext(DataContext context, AnActionEvent e) {
|
||||
myActionEvent = e;
|
||||
for (DataKey key : keys) {
|
||||
values.put(key.getName(), key.getData(context));
|
||||
}
|
||||
@@ -56,4 +59,8 @@ class HackyDataContext implements DataContext {
|
||||
System.out.println("Please add " + dataId + " key in " + getClass().getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
AnActionEvent getActionEvent() {
|
||||
return myActionEvent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.util.ExecutionErrorDialog;
|
||||
import com.intellij.ide.macro.Macro;
|
||||
import com.intellij.ide.macro.MacroManager;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
@@ -259,7 +260,7 @@ public class Tool implements SchemeElement {
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
public void execute(DataContext dataContext) {
|
||||
public void execute(AnActionEvent event, DataContext dataContext) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
if (project == null) {
|
||||
return;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ToolAction extends AnAction implements DumbAware {
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
runTool(myActionId, e.getDataContext());
|
||||
runTool(myActionId, e.getDataContext(), e);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,9 +63,13 @@ public class ToolAction extends AnAction implements DumbAware {
|
||||
}
|
||||
|
||||
static void runTool(String actionId, DataContext context) {
|
||||
runTool(actionId, context, null);
|
||||
}
|
||||
|
||||
static void runTool(String actionId, DataContext context, AnActionEvent e) {
|
||||
Tool tool = findTool(actionId, context);
|
||||
if (tool != null) {
|
||||
tool.execute(new HackyDataContext(context));
|
||||
tool.execute(e, new HackyDataContext(context, e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user