mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Python variables view class extracted.
This commit is contained in:
@@ -684,26 +684,10 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
|
||||
mySelected = state;
|
||||
|
||||
if (mySelected) {
|
||||
final XStandaloneVariablesView view = new XStandaloneVariablesView(getProject(), new PyDebuggerEditorsProvider());
|
||||
PyStackFrame stackFrame = new PyStackFrame(getProject(), myPydevConsoleCommunication, new PyStackFrameInfo("", "", "", null), null);
|
||||
view.showVariables(stackFrame);
|
||||
|
||||
getConsoleView().showVariables(view);
|
||||
|
||||
myPydevConsoleCommunication.addCommunicationListener(new ConsoleCommunicationListener() {
|
||||
@Override
|
||||
public void commandExecuted() {
|
||||
view.showMessage("Execution finished");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputRequested() {
|
||||
|
||||
}
|
||||
});
|
||||
getConsoleView().showVariables(myPydevConsoleCommunication);
|
||||
}
|
||||
else {
|
||||
getConsoleView().hideVariables();
|
||||
getConsoleView().restoreWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ import com.intellij.xdebugger.impl.frame.XStandaloneVariablesView;
|
||||
import com.jetbrains.python.PythonLanguage;
|
||||
import com.jetbrains.python.console.completion.PythonConsoleAutopopupBlockingHandler;
|
||||
import com.jetbrains.python.console.pydev.ConsoleCommunication;
|
||||
import com.jetbrains.python.console.pydev.ConsoleCommunicationListener;
|
||||
import com.jetbrains.python.debugger.PyDebuggerEditorsProvider;
|
||||
import com.jetbrains.python.debugger.PyStackFrame;
|
||||
import com.jetbrains.python.debugger.PyStackFrameInfo;
|
||||
import com.jetbrains.python.highlighting.PyHighlighter;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
@@ -59,7 +63,8 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
private boolean myHyperlink;
|
||||
|
||||
private final MyLanguageConsoleViewImpl myLanguageConsoleView;
|
||||
private XStandaloneVariablesView myVariablesView;
|
||||
|
||||
private Disposable mySplittedDisposable;
|
||||
|
||||
public PythonConsoleView(final Project project, final String title, Sdk sdk) {
|
||||
super(new BorderLayout());
|
||||
@@ -361,27 +366,32 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
return myProject;
|
||||
}
|
||||
|
||||
public void showVariables(XStandaloneVariablesView view) {
|
||||
public void showVariables(PydevConsoleCommunication consoleCommunication) {
|
||||
PythonConsoleVariablesView view = new PythonConsoleVariablesView(myProject, consoleCommunication);
|
||||
splitWindow(view.getPanel(), view);
|
||||
}
|
||||
|
||||
private void splitWindow(JComponent component, Disposable componentDisposable) {
|
||||
removeAll();
|
||||
JSplitPane p = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||||
p.add(myLanguageConsoleView.getComponent(), JSplitPane.LEFT);
|
||||
myVariablesView = view;
|
||||
p.add(myVariablesView.getPanel(), JSplitPane.RIGHT);
|
||||
mySplittedDisposable = componentDisposable;
|
||||
p.add(component, JSplitPane.RIGHT);
|
||||
p.setDividerLocation((int)getSize().getWidth()*2/3);
|
||||
add(p, BorderLayout.CENTER);
|
||||
|
||||
|
||||
validate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void hideVariables() {
|
||||
public void restoreWindow() {
|
||||
removeAll();
|
||||
add(myLanguageConsoleView.getComponent(), BorderLayout.CENTER);
|
||||
validate();
|
||||
repaint();
|
||||
if (myVariablesView != null) {
|
||||
Disposer.dispose(myVariablesView);
|
||||
myVariablesView = null;
|
||||
if (mySplittedDisposable != null) {
|
||||
Disposer.dispose(mySplittedDisposable);
|
||||
mySplittedDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,4 +455,31 @@ public class PythonConsoleView extends JPanel implements LanguageConsoleView, Ob
|
||||
super.beforeExternalAddContentToDocument(length, contentType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class PythonConsoleVariablesView extends XStandaloneVariablesView {
|
||||
|
||||
public PythonConsoleVariablesView(final @NotNull Project project,
|
||||
final @NotNull PydevConsoleCommunication consoleCommunication) {
|
||||
super(project, new PyDebuggerEditorsProvider());
|
||||
show(project, consoleCommunication);
|
||||
|
||||
consoleCommunication.addCommunicationListener(new ConsoleCommunicationListener() {
|
||||
@Override
|
||||
public void commandExecuted() {
|
||||
show(project, consoleCommunication); //TODO: use rebuild
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inputRequested() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void show(Project project, PydevConsoleCommunication consoleCommunication) {
|
||||
PyStackFrame stackFrame = new PyStackFrame(project, consoleCommunication, new PyStackFrameInfo("", "", "", null), null);
|
||||
showVariables(stackFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user