mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-75097 Every keystroke in runconfig/vm-options field triggers network listening firewall dialog on Mac OS
This commit is contained in:
+33
-24
@@ -19,17 +19,21 @@ import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.engine.DebuggerUtils;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.xdebugger.impl.settings.DebuggerConfigurable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class GenericDebuggerParametersRunnerConfigurable extends SettingsEditor<GenericDebuggerRunnerSettings> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.impl.GenericDebuggerParametersRunnerConfigurable");
|
||||
private JPanel myPanel;
|
||||
private JTextField myAddressField;
|
||||
private JPanel myShMemPanel;
|
||||
@@ -45,21 +49,14 @@ public class GenericDebuggerParametersRunnerConfigurable extends SettingsEditor<
|
||||
myDebuggerSettings.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(project, DebuggerConfigurable.DISPLAY_NAME);
|
||||
if("".equals(getPort())) {
|
||||
try {
|
||||
String address = DebuggerUtils.getInstance().findAvailableDebugAddress(getTransport() == DebuggerSettings.SOCKET_TRANSPORT);
|
||||
setPort(address);
|
||||
}
|
||||
catch (ExecutionException e1) {
|
||||
setPort("");
|
||||
}
|
||||
}
|
||||
suggestAvailablePortIfNotSpecified();
|
||||
updateUI();
|
||||
}
|
||||
});
|
||||
|
||||
final ActionListener listener = new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
suggestAvailablePortIfNotSpecified();
|
||||
updateUI();
|
||||
myPanel.repaint();
|
||||
}
|
||||
@@ -80,15 +77,7 @@ public class GenericDebuggerParametersRunnerConfigurable extends SettingsEditor<
|
||||
return getTransport() == DebuggerSettings.SOCKET_TRANSPORT;
|
||||
}
|
||||
|
||||
public void apply() throws ConfigurationException {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JComponent createEditor() {
|
||||
return myPanel;
|
||||
}
|
||||
@@ -102,16 +91,36 @@ public class GenericDebuggerParametersRunnerConfigurable extends SettingsEditor<
|
||||
}
|
||||
|
||||
public void resetEditorFrom(GenericDebuggerRunnerSettings runnerSettings) {
|
||||
String port = runnerSettings.DEBUG_PORT;
|
||||
if (port == null) port = "";
|
||||
|
||||
setIsLocal(runnerSettings.LOCAL);
|
||||
setTransport(runnerSettings.getTransport());
|
||||
setPort(port);
|
||||
|
||||
setPort(StringUtil.notNullize(runnerSettings.getDebugPort()));
|
||||
suggestAvailablePortIfNotSpecified();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
private void suggestAvailablePortIfNotSpecified() {
|
||||
String port = getPort();
|
||||
boolean portSpecified = !StringUtil.isEmpty(port);
|
||||
boolean isSocketTransport = getTransport() == DebuggerSettings.SOCKET_TRANSPORT;
|
||||
if (isSocketTransport) {
|
||||
try {
|
||||
Integer.parseInt(port);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
portSpecified = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!portSpecified) {
|
||||
try {
|
||||
setPort(DebuggerUtils.getInstance().findAvailableDebugAddress(isSocketTransport));
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getTransport() {
|
||||
if(myIsLocal) {
|
||||
return DebuggerSettings.getInstance().DEBUGGER_TRANSPORT;
|
||||
@@ -146,7 +155,7 @@ public class GenericDebuggerParametersRunnerConfigurable extends SettingsEditor<
|
||||
|
||||
private void setTransport(int transport) {
|
||||
mySocketTransport.setSelected(transport == DebuggerSettings.SOCKET_TRANSPORT);
|
||||
myShmemTransport.setSelected (transport != DebuggerSettings.SOCKET_TRANSPORT);
|
||||
myShmemTransport.setSelected(transport != DebuggerSettings.SOCKET_TRANSPORT);
|
||||
}
|
||||
|
||||
private void setIsLocal(boolean b) {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.engine.DebuggerUtils;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.debugger.ui.DebuggerPanelsManager;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
@@ -28,6 +28,7 @@ import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -102,6 +103,9 @@ public class GenericDebuggerRunner extends JavaPatchableProgramRunner<GenericDeb
|
||||
|
||||
private static RemoteConnection doPatch(final JavaParameters javaParameters, final RunnerSettings settings) throws ExecutionException {
|
||||
final GenericDebuggerRunnerSettings debuggerSettings = ((GenericDebuggerRunnerSettings)settings.getData());
|
||||
if (StringUtil.isEmpty(debuggerSettings.getDebugPort())) {
|
||||
debuggerSettings.setDebugPort(DebuggerUtils.getInstance().findAvailableDebugAddress(debuggerSettings.getTransport() == DebuggerSettings.SOCKET_TRANSPORT));
|
||||
}
|
||||
return DebuggerManagerImpl.createDebugParameters(javaParameters, debuggerSettings, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.debugger.engine.DebuggerUtils;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.DebuggingRunnerData;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
@@ -45,44 +43,16 @@ public class GenericDebuggerRunnerSettings implements JDOMExternalizable, Debugg
|
||||
LOCAL = isLocal;
|
||||
}
|
||||
|
||||
private void updateDefaultAddress() {
|
||||
boolean useDefaultPort = "".equals(DEBUG_PORT);
|
||||
|
||||
if (getTransport() == DebuggerSettings.SOCKET_TRANSPORT) {
|
||||
try {
|
||||
Integer.parseInt(DEBUG_PORT);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
useDefaultPort = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (useDefaultPort) {
|
||||
try {
|
||||
DEBUG_PORT = DebuggerUtils.getInstance().findAvailableDebugAddress(getTransport() == DebuggerSettings.SOCKET_TRANSPORT);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
DEBUG_PORT = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDebugPort(String port) {
|
||||
DEBUG_PORT = port;
|
||||
updateDefaultAddress();
|
||||
}
|
||||
|
||||
public void setTransport(int transport) {
|
||||
if (getTransport() != transport) {
|
||||
setDebugPort("");
|
||||
}
|
||||
TRANSPORT = transport;
|
||||
updateDefaultAddress();
|
||||
}
|
||||
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
DefaultJDOMExternalizer.readExternal(this, element);
|
||||
updateDefaultAddress();
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
|
||||
Reference in New Issue
Block a user