'Exit' action enabled for running application on Mac (IDEA-56273)

This commit is contained in:
nik
2011-03-28 16:11:12 +04:00
parent 436805ba4e
commit 52505f5f12
4 changed files with 40 additions and 33 deletions
@@ -32,10 +32,8 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.JDOMExternalizable;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -52,14 +50,6 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
!(profile instanceof RunConfigurationWithSuppressedDefaultRunAction);
}
public JDOMExternalizable createConfigurationData(ConfigurationInfoProvider settingsProvider) {
return null;
}
public SettingsEditor<JDOMExternalizable> getSettingsEditor(final Executor executor, RunConfiguration configuration) {
return null;
}
public void patch(JavaParameters javaParameters, RunnerSettings settings, final boolean beforeExecution) throws ExecutionException {
runCustomPatchers(javaParameters, settings, Executor.EXECUTOR_EXTENSION_NAME.findExtension(DefaultRunExecutor.class));
}
@@ -151,7 +141,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
public void update(final AnActionEvent event) {
final Presentation presentation = event.getPresentation();
if (ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler) == null) {
if (!isVisible()) {
presentation.setVisible(false);
presentation.setEnabled(false);
return;
@@ -159,6 +149,10 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
presentation.setVisible(true);
presentation.setEnabled(!myProcessHandler.isProcessTerminated());
}
protected boolean isVisible() {
return ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler) != null;
}
}
protected static class ControlBreakAction extends LauncherBasedAction {
@@ -168,8 +162,16 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
setShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_CANCEL, InputEvent.CTRL_DOWN_MASK)));
}
@Override
protected boolean isVisible() {
return super.isVisible() && ProcessProxyFactory.getInstance().isBreakGenLibraryAvailable();
}
public void actionPerformed(final AnActionEvent e) {
ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler).sendBreak();
ProcessProxy proxy = ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler);
if (proxy != null) {
proxy.sendBreak();
}
}
}
@@ -179,7 +181,10 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
}
public void actionPerformed(final AnActionEvent e) {
ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler).sendStop();
ProcessProxy proxy = ProcessProxyFactory.getInstance().getAttachedProxy(myProcessHandler);
if (proxy != null) {
proxy.sendStop();
}
}
}
@@ -22,6 +22,10 @@ import com.intellij.execution.configurations.ParametersList;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.openapi.projectRoots.ex.JavaSdkUtil;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.annotations.NonNls;
import java.io.File;
public class ProcessProxyFactoryImpl extends ProcessProxyFactory {
public ProcessProxy createCommandLineProxy(final JavaCommandLine javaCmdLine) throws ExecutionException {
@@ -32,7 +36,7 @@ public class ProcessProxyFactoryImpl extends ProcessProxyFactory {
final JavaParameters javaParameters = javaCmdLine.getJavaParameters();
JavaSdkUtil.addRtJar(javaParameters.getClassPath());
final ParametersList vmParametersList = javaParameters.getVMParametersList();
vmParametersList.defineProperty(ProcessProxyImpl.PROPERTY_PORT_NUMBER, "" + proxy.getPortNumber());
vmParametersList.defineProperty(ProcessProxyImpl.PROPERTY_PORT_NUMBER, String.valueOf(proxy.getPortNumber()));
vmParametersList.defineProperty(ProcessProxyImpl.PROPERTY_BINPATH, PathManager.getBinPath());
javaParameters.getProgramParametersList().prepend(javaParameters.getMainClass());
javaParameters.setMainClass(ProcessProxyImpl.LAUNCH_MAIN_CLASS);
@@ -47,4 +51,10 @@ public class ProcessProxyFactoryImpl extends ProcessProxyFactory {
public ProcessProxy getAttachedProxy(final ProcessHandler processHandler) {
return processHandler != null ? processHandler.getUserData(ProcessProxyImpl.KEY) : null;
}
@Override
public boolean isBreakGenLibraryAvailable() {
@NonNls final String libName = SystemInfo.isWindows ? "breakgen.dll" : "libbreakgen.so";
return new File(PathManager.getBinPath() + File.separator + libName).exists();
}
}
@@ -16,17 +16,17 @@
package com.intellij.execution.runners;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.annotations.NonNls;
import java.io.*;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import org.jetbrains.annotations.NonNls;
/**
* @author ven
*/
@@ -112,18 +112,6 @@ class ProcessProxyImpl implements ProcessProxy {
}
public static boolean useLauncher() {
if (Boolean.valueOf(System.getProperty(DONT_USE_LAUNCHER_PROPERTY))) {
return false;
}
if (!SystemInfo.isWindows && !SystemInfo.isLinux) {
return false;
}
return new File(getLaunchertLibName()).exists();
}
public static String getLaunchertLibName() {
@NonNls final String libName = SystemInfo.isWindows ? "breakgen.dll" : "libbreakgen.so";
return PathManager.getBinPath() + File.separator + libName;
return !Boolean.valueOf(System.getProperty(DONT_USE_LAUNCHER_PROPERTY));
}
}
@@ -19,14 +19,18 @@ import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.JavaCommandLine;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.openapi.components.ServiceManager;
import org.jetbrains.annotations.Nullable;
public abstract class ProcessProxyFactory {
public abstract boolean isBreakGenLibraryAvailable();
public static ProcessProxyFactory getInstance() {
return ServiceManager.getService(ProcessProxyFactory.class);
}
@Nullable
public abstract ProcessProxy createCommandLineProxy(JavaCommandLine javaCmdLine) throws ExecutionException;
@Nullable
public abstract ProcessProxy getAttachedProxy(ProcessHandler processHandler);
}