mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-30617 Open new Console instance by default for "Run with Python Console"
This commit is contained in:
@@ -61,6 +61,14 @@ public class PyConsoleOptions implements PersistentStateComponent<PyConsoleOptio
|
||||
myState.myIpythonEnabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isUseExistingConsole() {
|
||||
return myState.myUseExistingConsole;
|
||||
}
|
||||
|
||||
public void setUseExistingConsole(boolean enabled) {
|
||||
myState.myUseExistingConsole = enabled;
|
||||
}
|
||||
|
||||
public static PyConsoleOptions getInstance(Project project) {
|
||||
return ServiceManager.getService(project, PyConsoleOptions.class);
|
||||
}
|
||||
@@ -76,6 +84,7 @@ public class PyConsoleOptions implements PersistentStateComponent<PyConsoleOptio
|
||||
myState.myShowVariablesByDefault = state.myShowVariablesByDefault;
|
||||
myState.myPythonConsoleState = state.myPythonConsoleState;
|
||||
myState.myIpythonEnabled = state.myIpythonEnabled;
|
||||
myState.myUseExistingConsole = state.myUseExistingConsole;
|
||||
}
|
||||
|
||||
public static class State {
|
||||
@@ -84,6 +93,7 @@ public class PyConsoleOptions implements PersistentStateComponent<PyConsoleOptio
|
||||
public boolean myShowDebugConsoleByDefault = false;
|
||||
public boolean myShowVariablesByDefault = true;
|
||||
public boolean myIpythonEnabled = true;
|
||||
public boolean myUseExistingConsole = false;
|
||||
}
|
||||
|
||||
@Tag("console-settings")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<grid id="27dc6" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
<xy x="20" y="20" width="522" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -13,7 +13,7 @@
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="b4377" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="b4377" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -34,7 +34,7 @@
|
||||
</component>
|
||||
<vspacer id="c732">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="cccd6" class="com.intellij.ui.components.JBCheckBox" binding="myIpythonEnabledCheckbox">
|
||||
@@ -53,6 +53,14 @@
|
||||
<text value="Show console variables by default"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="79e81" class="com.intellij.ui.components.JBCheckBox" binding="myUseExistingConsole">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Use existing console for "Run with Python console""/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<hspacer id="4135">
|
||||
|
||||
@@ -163,6 +163,7 @@ public class PyConsoleOptionsConfigurable extends SearchableConfigurable.Parent.
|
||||
private JBCheckBox myShowDebugConsoleByDefault;
|
||||
private JBCheckBox myIpythonEnabledCheckbox;
|
||||
private JBCheckBox myShowsVariablesByDefault;
|
||||
private JBCheckBox myUseExistingConsole;
|
||||
private PyConsoleOptions myOptionsProvider;
|
||||
|
||||
public JPanel createPanel(PyConsoleOptions optionsProvider) {
|
||||
@@ -173,20 +174,23 @@ public class PyConsoleOptionsConfigurable extends SearchableConfigurable.Parent.
|
||||
|
||||
public void apply() {
|
||||
myOptionsProvider.setShowDebugConsoleByDefault(myShowDebugConsoleByDefault.isSelected());
|
||||
myOptionsProvider.setShowVariablesByDefault(myShowsVariablesByDefault.isSelected());
|
||||
myOptionsProvider.setIpythonEnabled(myIpythonEnabledCheckbox.isSelected());
|
||||
myOptionsProvider.setShowVariablesByDefault(myShowsVariablesByDefault.isSelected());
|
||||
myOptionsProvider.setUseExistingConsole(myUseExistingConsole.isSelected());
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
myShowDebugConsoleByDefault.setSelected(myOptionsProvider.isShowDebugConsoleByDefault());
|
||||
myShowsVariablesByDefault.setSelected(myOptionsProvider.isShowVariableByDefault());
|
||||
myIpythonEnabledCheckbox.setSelected(myOptionsProvider.isIpythonEnabled());
|
||||
myShowsVariablesByDefault.setSelected(myOptionsProvider.isShowVariableByDefault());
|
||||
myUseExistingConsole.setSelected(myOptionsProvider.isUseExistingConsole());
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return myShowDebugConsoleByDefault.isSelected() != myOptionsProvider.isShowDebugConsoleByDefault() ||
|
||||
myIpythonEnabledCheckbox.isSelected() != myOptionsProvider.isIpythonEnabled() ||
|
||||
myShowsVariablesByDefault.isSelected() != myOptionsProvider.isShowVariableByDefault();
|
||||
myShowsVariablesByDefault.isSelected() != myOptionsProvider.isShowVariableByDefault() ||
|
||||
myUseExistingConsole.isSelected() != myOptionsProvider.isUseExistingConsole();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,8 @@ public class PythonScriptCommandLineState extends PythonCommandLineState {
|
||||
}
|
||||
|
||||
final String runFileText = buildScriptWithConsoleRun();
|
||||
if (PyExecuteSelectionAction.canFindConsole(project, myConfig.getSdkHome())) {
|
||||
final boolean useExistingConsole = PyConsoleOptions.getInstance(project).isUseExistingConsole();
|
||||
if (useExistingConsole && PyExecuteSelectionAction.canFindConsole(project, myConfig.getSdkHome())) {
|
||||
// there are existing consoles, don't care about Rerun action
|
||||
PyExecuteSelectionAction.selectConsoleAndExecuteCode(project, runFileText);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user