diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java index 6748046d8e05..779f05007773 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaDebugProcess.java @@ -23,6 +23,10 @@ import com.intellij.debugger.engine.events.SuspendContextCommandImpl; import com.intellij.debugger.impl.*; import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.jdi.ThreadReferenceProxyImpl; +import com.intellij.debugger.memory.component.InstancesTracker; +import com.intellij.debugger.memory.component.MemoryViewDebugProcessData; +import com.intellij.debugger.memory.component.MemoryViewManager; +import com.intellij.debugger.memory.ui.ClassesFilteredView; import com.intellij.debugger.settings.DebuggerSettings; import com.intellij.debugger.ui.AlternativeSourceNotificationProvider; import com.intellij.debugger.ui.DebuggerContentInfo; @@ -32,6 +36,8 @@ import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; import com.intellij.debugger.ui.impl.watch.MessageDescriptor; import com.intellij.debugger.ui.impl.watch.NodeManagerImpl; import com.intellij.debugger.ui.tree.NodeDescriptor; +import com.intellij.execution.process.ProcessAdapter; +import com.intellij.execution.process.ProcessEvent; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.ExecutionConsole; import com.intellij.execution.ui.ExecutionConsoleEx; @@ -39,6 +45,7 @@ import com.intellij.execution.ui.RunnerLayoutUi; import com.intellij.execution.ui.layout.PlaceInGrid; import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; @@ -310,6 +317,25 @@ public class JavaDebugProcess extends XDebugProcess { return new XDebugTabLayouter() { @Override public void registerAdditionalContent(@NotNull RunnerLayoutUi ui) { + registerThreadsPanel(ui); + registerMemoryViewPanel(ui); + } + + @NotNull + @Override + public Content registerConsoleContent(@NotNull RunnerLayoutUi ui, @NotNull ExecutionConsole console) { + Content content = null; + if (console instanceof ExecutionConsoleEx) { + ((ExecutionConsoleEx)console).buildUi(ui); + content = ui.findContent(DebuggerContentInfo.CONSOLE_CONTENT); + } + if (content == null) { + content = super.registerConsoleContent(ui, console); + } + return content; + } + + private void registerThreadsPanel(@NotNull RunnerLayoutUi ui) { final ThreadsPanel panel = new ThreadsPanel(myJavaSession.getProject(), getDebuggerStateManager()); final Content threadsContent = ui.createContent( DebuggerContentInfo.THREADS_CONTENT, panel, XDebuggerBundle.message("debugger.session.tab.threads.title"), @@ -335,24 +361,69 @@ public class JavaDebugProcess extends XDebugProcess { }, threadsContent); } - @NotNull - @Override - public Content registerConsoleContent(@NotNull RunnerLayoutUi ui, @NotNull ExecutionConsole console) { - Content content = null; - if (console instanceof ExecutionConsoleEx) { - ((ExecutionConsoleEx)console).buildUi(ui); - content = ui.findContent(DebuggerContentInfo.CONSOLE_CONTENT); - } - if (content == null) { - content = super.registerConsoleContent(ui, console); - } - return content; + private void registerMemoryViewPanel(@NotNull RunnerLayoutUi ui) { + final XDebugSession session = getSession(); + final DebugProcessImpl process = myJavaSession.getProcess(); + final InstancesTracker tracker = InstancesTracker.getInstance(myJavaSession.getProject()); + + final ClassesFilteredView classesFilteredView = new ClassesFilteredView(session, process, tracker); + + final Content memoryViewContent = + ui.createContent(MemoryViewManager.MEMORY_VIEW_CONTENT, classesFilteredView, "Memory View", + AllIcons.Debugger.MemoryView.Active, null); + + memoryViewContent.setCloseable(false); + memoryViewContent.setPinned(true); + memoryViewContent.setShouldDisposeContent(true); + + final MemoryViewDebugProcessData data = new MemoryViewDebugProcessData(classesFilteredView); + process.putUserData(MemoryViewDebugProcessData.KEY, data); + + ui.addListener(new ContentManagerAdapter() { + @Override + public void contentAdded(ContentManagerEvent event) { + changeMemoryViewMode(event); + } + + @Override + public void contentRemoved(ContentManagerEvent event) { + changeMemoryViewMode(event); + } + + @Override + public void selectionChanged(ContentManagerEvent event) { + changeMemoryViewMode(event); + } + + private void changeMemoryViewMode(@Nullable ContentManagerEvent event) { + if (event != null && event.getContent() == memoryViewContent) { + final ContentManagerEvent.ContentOperation operation = event.getOperation(); + final boolean isAddOperation = operation.equals(ContentManagerEvent.ContentOperation.add); + + if (isAddOperation || operation.equals(ContentManagerEvent.ContentOperation.remove)) { + classesFilteredView.setActive(isAddOperation, process.getManagerThread()); + } + } + } + }, classesFilteredView); + + ui.addContent(memoryViewContent, 0, PlaceInGrid.right, true); + + process.addProcessListener(new ProcessAdapter() { + @Override + public void processTerminated(ProcessEvent event) { + ApplicationManager.getApplication().invokeLater(() -> memoryViewContent.setIcon(AllIcons.Debugger.MemoryView.Inactive)); + process.removeProcessListener(this); + } + }); } }; } @Override - public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, @NotNull DefaultActionGroup topToolbar, @NotNull DefaultActionGroup settings) { + public void registerAdditionalActions(@NotNull DefaultActionGroup leftToolbar, + @NotNull DefaultActionGroup topToolbar, + @NotNull DefaultActionGroup settings) { Constraints beforeRunner = new Constraints(Anchor.BEFORE, "Runner.Layout"); leftToolbar.add(Separator.getInstance(), beforeRunner); leftToolbar.add(ActionManager.getInstance().getAction(DebuggerActions.DUMP_THREADS), beforeRunner); diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/DecompiledLocalVariable.java b/java/debugger/impl/src/com/intellij/debugger/jdi/DecompiledLocalVariable.java index 76e7956fb33c..6a0486ca88d5 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/DecompiledLocalVariable.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/DecompiledLocalVariable.java @@ -79,13 +79,15 @@ public class DecompiledLocalVariable{ return getDisplayName() + " (slot " + mySlot + ", " + mySignature + ")"; } - public static int getParamId(String name) { - String idString = StringUtil.substringAfter(name, PARAM_PREFIX); - if (idString != null) { - try { - return Integer.parseInt(idString); - } - catch (NumberFormatException ignored) { + public static int getParamId(@Nullable String name) { + if (!StringUtil.isEmpty(name)) { + String idString = StringUtil.substringAfter(name, PARAM_PREFIX); + if (idString != null) { + try { + return Integer.parseInt(idString); + } + catch (NumberFormatException ignored) { + } } } return -1; diff --git a/java/debugger/impl/src/com/intellij/debugger/memory/component/MemoryViewComponent.java b/java/debugger/impl/src/com/intellij/debugger/memory/component/MemoryViewComponent.java deleted file mode 100644 index 52c9772f0257..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/memory/component/MemoryViewComponent.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.debugger.memory.component; - -import com.intellij.debugger.DebuggerManager; -import com.intellij.debugger.engine.DebugProcess; -import com.intellij.debugger.engine.DebugProcessImpl; -import com.intellij.debugger.memory.ui.ClassesFilteredView; -import com.intellij.execution.process.ProcessAdapter; -import com.intellij.execution.process.ProcessEvent; -import com.intellij.execution.ui.RunnerLayoutUi; -import com.intellij.execution.ui.layout.PlaceInGrid; -import com.intellij.icons.AllIcons; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.AbstractProjectComponent; -import com.intellij.openapi.project.Project; -import com.intellij.ui.content.Content; -import com.intellij.ui.content.ContentManagerAdapter; -import com.intellij.ui.content.ContentManagerEvent; -import com.intellij.util.messages.MessageBusConnection; -import com.intellij.xdebugger.XDebugProcess; -import com.intellij.xdebugger.XDebugSession; -import com.intellij.xdebugger.XDebuggerManager; -import com.intellij.xdebugger.XDebuggerManagerListener; -import org.jetbrains.annotations.NotNull; - -/** - * @author Vitaliy.Bibaev - */ -public class MemoryViewComponent extends AbstractProjectComponent { - private static final String MEMORY_VIEW_CONTENT_ID = "MemoryView"; - - public MemoryViewComponent(@NotNull Project project) { - super(project); - final MessageBusConnection connection = project.getMessageBus().connect(project); - connection.subscribe(XDebuggerManager.TOPIC, new MyDebuggerStatusChangedListener()); - } - - private static final class MyDebuggerStatusChangedListener implements XDebuggerManagerListener { - @Override - public void processStarted(@NotNull XDebugProcess debugProcess) { - final XDebugSession session = debugProcess.getSession(); - final Project project = session.getProject(); - final DebugProcess javaProcess = - DebuggerManager.getInstance(project).getDebugProcess(debugProcess.getProcessHandler()); - if (javaProcess instanceof DebugProcessImpl) { - final DebugProcessImpl processImpl = (DebugProcessImpl)javaProcess; - ApplicationManager.getApplication().invokeLater(() -> { - final InstancesTracker tracker = InstancesTracker.getInstance(project); - final RunnerLayoutUi ui = session.getUI(); - final ClassesFilteredView classesFilteredView = new ClassesFilteredView(session, processImpl, tracker); - final Content memoryViewContent = - ui.createContent(MEMORY_VIEW_CONTENT_ID, classesFilteredView, "Memory View", - AllIcons.Debugger.MemoryView.Active, null); - - memoryViewContent.setCloseable(false); - memoryViewContent.setPinned(true); - memoryViewContent.setShouldDisposeContent(true); - - final MemoryViewDebugProcessData data = new MemoryViewDebugProcessData(classesFilteredView); - processImpl.putUserData(MemoryViewDebugProcessData.KEY, data); - - ui.addListener(new ContentManagerAdapter() { - @Override - public void contentAdded(ContentManagerEvent event) { - if (event.getContent() == memoryViewContent) { - classesFilteredView.setActive(true); - } - } - - @Override - public void contentRemoved(ContentManagerEvent event) { - if (event.getContent() == memoryViewContent) { - classesFilteredView.setActive(false); - } - } - }, classesFilteredView); - - ui.addContent(memoryViewContent, 0, PlaceInGrid.right, true); - - processImpl.addProcessListener(new ProcessAdapter() { - @Override - public void processTerminated(ProcessEvent event) { - ApplicationManager.getApplication().invokeLater(() -> memoryViewContent.setIcon(AllIcons.Debugger.MemoryView.Inactive)); - processImpl.removeProcessListener(this); - } - }); - }, o -> project.isDisposed()); - } - } - - @Override - public void processStopped(@NotNull XDebugProcess debugProcess) { - } - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/memory/component/MemoryViewManager.java b/java/debugger/impl/src/com/intellij/debugger/memory/component/MemoryViewManager.java index b72a7d180907..9ff657ba3667 100644 --- a/java/debugger/impl/src/com/intellij/debugger/memory/component/MemoryViewManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/memory/component/MemoryViewManager.java @@ -28,6 +28,8 @@ import org.jetbrains.annotations.NotNull; @State(name = "MemoryViewSettings", storages = @Storage("memory.view.xml")) public class MemoryViewManager extends ApplicationComponent.Adapter implements PersistentStateComponent { + public static final String MEMORY_VIEW_CONTENT = "MemoryView"; + private final EventDispatcher myDispatcher = EventDispatcher.create(MemoryViewManagerListener.class); private MemoryViewManagerState myState = new MemoryViewManagerState(); diff --git a/java/debugger/impl/src/com/intellij/debugger/memory/ui/ClassesFilteredView.java b/java/debugger/impl/src/com/intellij/debugger/memory/ui/ClassesFilteredView.java index 015a8f90ce14..51c59147a5c9 100644 --- a/java/debugger/impl/src/com/intellij/debugger/memory/ui/ClassesFilteredView.java +++ b/java/debugger/impl/src/com/intellij/debugger/memory/ui/ClassesFilteredView.java @@ -19,6 +19,7 @@ import com.intellij.debugger.DebuggerManager; import com.intellij.debugger.DebuggerManagerEx; import com.intellij.debugger.engine.DebugProcess; import com.intellij.debugger.engine.DebugProcessImpl; +import com.intellij.debugger.engine.DebuggerManagerThreadImpl; import com.intellij.debugger.engine.SuspendContextImpl; import com.intellij.debugger.engine.events.DebuggerCommandImpl; import com.intellij.debugger.memory.component.InstancesTracker; @@ -112,6 +113,7 @@ public class ClassesFilteredView extends BorderLayoutPanel implements Disposable myProject = debugSession.getProject(); + final DebuggerManagerThreadImpl managerThread = debugProcess.getManagerThread(); myInstancesTracker = tracker; final InstancesTrackerListener instancesTrackerListener = new InstancesTrackerListener() { @Override @@ -119,17 +121,16 @@ public class ClassesFilteredView extends BorderLayoutPanel implements Disposable ReferenceType ref = myTable.getClassByName(name); if (ref != null) { final boolean activated = myIsTrackersActivated.get(); - debugProcess.getManagerThread() - .schedule(new LowestPriorityCommand(getSuspendContext()) { - @Override - public void contextAction(@NotNull SuspendContextImpl suspendContext) throws Exception { - final XDebugProcess process = suspendContext.getDebugProcess().getXdebugProcess(); - if (process != null) { - final XDebugSession session = process.getSession(); - trackClass(session, ref, type, activated); - } + managerThread.schedule(new LowestPriorityCommand(getSuspendContext()) { + @Override + public void contextAction(@NotNull SuspendContextImpl suspendContext) throws Exception { + final XDebugProcess process = suspendContext.getDebugProcess().getXdebugProcess(); + if (process != null) { + final XDebugSession session = process.getSession(); + trackClass(session, ref, type, activated); } - }); + } + }); } myTable.repaint(); } @@ -145,7 +146,7 @@ public class ClassesFilteredView extends BorderLayoutPanel implements Disposable } }; - debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() { + managerThread.schedule(new DebuggerCommandImpl() { @Override public Priority getPriority() { return Priority.LOWEST; @@ -244,8 +245,7 @@ public class ClassesFilteredView extends BorderLayoutPanel implements Disposable myLastSuspendContext = getSuspendContext(); if (myLastSuspendContext != null) { ApplicationManager.getApplication().invokeLater(() -> myTable.setBusy(true)); - debugProcess.getManagerThread() - .schedule(new MyUpdateClassesCommand(myLastSuspendContext)); + managerThread.schedule(new MyUpdateClassesCommand(myLastSuspendContext)); } }, this); @@ -343,28 +343,24 @@ public class ClassesFilteredView extends BorderLayoutPanel implements Disposable myConstructorTrackedClasses.clear(); } - public void setActive(boolean active) { + public void setActive(boolean active, @NotNull DebuggerManagerThreadImpl managerThread) { if (myIsActive == active) { return; } myIsActive = active; - final XDebugSession debugSession = XDebuggerManager.getInstance(myProject).getCurrentSession(); - if (debugSession != null) { - final DebugProcessImpl debugProcess = - (DebugProcessImpl)DebuggerManager.getInstance(myProject).getDebugProcess(debugSession.getDebugProcess().getProcessHandler()); - debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() { - @Override - protected void action() throws Exception { - if (active) { - doActivate(); - } - else { - doPause(); - } + + managerThread.schedule(new DebuggerCommandImpl() { + @Override + protected void action() throws Exception { + if (active) { + doActivate(); } - }); - } + else { + doPause(); + } + } + }); } private void doActivate() { diff --git a/java/debugger/impl/src/com/intellij/debugger/memory/ui/ClassesTable.java b/java/debugger/impl/src/com/intellij/debugger/memory/ui/ClassesTable.java index 438f37805702..ee46079fcb23 100644 --- a/java/debugger/impl/src/com/intellij/debugger/memory/ui/ClassesTable.java +++ b/java/debugger/impl/src/com/intellij/debugger/memory/ui/ClassesTable.java @@ -306,7 +306,12 @@ public class ClassesTable extends JBTable implements DataProvider, Disposable { @Override public void dispose() { - ApplicationManager.getApplication().invokeLater(() -> clean()); + if (ApplicationManager.getApplication().isDispatchThread()) { + clean(); + } + else { + ApplicationManager.getApplication().invokeLater(this::clean); + } } @Nullable diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java index b5471e12f283..aa0db6fb032d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/StackCapturingLineBreakpoint.java @@ -253,8 +253,9 @@ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint { myCached = cached; } + @Nullable Value evaluate(final EvaluationContext context) throws EvaluateException { - if (!myCached || myEvaluator == null) { + if ((!myCached || myEvaluator == null) && !StringUtil.isEmpty(myExpression)) { myEvaluator = ApplicationManager.getApplication().runReadAction( (ThrowableComputable)() -> { SourcePosition sourcePosition = ContextUtil.getSourcePosition(context); @@ -263,9 +264,12 @@ public class StackCapturingLineBreakpoint extends WildcardMethodBreakpoint { new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, myExpression), contextElement, sourcePosition, context.getProject()); }); } - Value value = myEvaluator.evaluate(context); - DebuggerUtilsEx.keep(value, context); - return value; + if (myEvaluator != null) { + Value value = myEvaluator.evaluate(context); + DebuggerUtilsEx.keep(value, context); + return value; + } + return null; } } } diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitDeclarationAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitDeclarationAction.java index b869d5b66d7a..e56f88302e11 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitDeclarationAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/SplitDeclarationAction.java @@ -137,7 +137,7 @@ public class SplitDeclarationAction extends PsiElementBaseIntentionAction { } final PsiElement parent = block.getParent(); - final PsiAssignmentExpression replaced = (PsiAssignmentExpression)decl.replace(statement); + PsiExpressionStatement replaced = (PsiExpressionStatement)decl.replace(statement); if (!(parent instanceof PsiCodeBlock)) { final PsiBlockStatement blockStatement = (PsiBlockStatement)JavaPsiFacade.getElementFactory(project).createStatementFromText("{}", null); @@ -149,7 +149,7 @@ public class SplitDeclarationAction extends PsiElementBaseIntentionAction { else { parent.addBefore(varDeclStatement, block); } - return replaced; + return (PsiAssignmentExpression)replaced.getExpression(); } else { return (PsiAssignmentExpression)((PsiExpressionStatement)block.addAfter(statement, decl)).getExpression(); diff --git a/platform/platform-impl/src/com/intellij/terminal/ProcessHandlerTtyConnector.java b/platform/platform-impl/src/com/intellij/terminal/ProcessHandlerTtyConnector.java index c103f0092a2b..9a4812216b42 100644 --- a/platform/platform-impl/src/com/intellij/terminal/ProcessHandlerTtyConnector.java +++ b/platform/platform-impl/src/com/intellij/terminal/ProcessHandlerTtyConnector.java @@ -51,7 +51,6 @@ public class ProcessHandlerTtyConnector implements TtyConnector { myCharset = charset; } - @Override public boolean init(Questioner q) { return true; @@ -85,6 +84,7 @@ public class ProcessHandlerTtyConnector implements TtyConnector { @Override public void write(byte[] bytes) throws IOException { myProcessHandler.getProcessInput().write(bytes); + myProcessHandler.getProcessInput().flush(); } @Override @@ -95,6 +95,7 @@ public class ProcessHandlerTtyConnector implements TtyConnector { @Override public void write(String string) throws IOException { myProcessHandler.getProcessInput().write(string.getBytes(myCharset)); + myProcessHandler.getProcessInput().flush(); } @Override diff --git a/platform/platform-impl/src/com/intellij/terminal/TerminalExecutionConsole.java b/platform/platform-impl/src/com/intellij/terminal/TerminalExecutionConsole.java index c99a3773602f..d7b40d521fc0 100644 --- a/platform/platform-impl/src/com/intellij/terminal/TerminalExecutionConsole.java +++ b/platform/platform-impl/src/com/intellij/terminal/TerminalExecutionConsole.java @@ -28,6 +28,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.encoding.EncodingProjectManager; import com.jediterm.terminal.HyperlinkStyle; +import com.jediterm.terminal.TerminalKeyEncoder; import com.jediterm.terminal.TerminalStarter; import com.jediterm.terminal.TtyConnector; import com.jediterm.terminal.model.JediTerminal; @@ -48,6 +49,12 @@ public class TerminalExecutionConsole implements ConsoleView { private Project myProject; private final AppendableTerminalDataStream myDataStream; + private final TerminalKeyEncoder myKeyEncoder = new TerminalKeyEncoder(); + + { + myKeyEncoder.setAutoNewLine(true); + } + public TerminalExecutionConsole(@NotNull Project project, @NotNull ProcessHandler processHandler) { myProject = project; final JBTerminalSystemSettingsProviderBase provider = new JBTerminalSystemSettingsProviderBase() { @@ -63,7 +70,16 @@ public class TerminalExecutionConsole implements ConsoleView { myTerminalWidget = new JBTerminalWidget(project, 200, 24, provider, this) { @Override protected TerminalStarter createTerminalStarter(JediTerminal terminal, TtyConnector connector) { - return new TerminalStarter(terminal, connector, myDataStream); + return new TerminalStarter(terminal, connector, myDataStream) { + @Override + public byte[] getCode(int key, int modifiers) { + if (key == 10) { + return myKeyEncoder.getCode(key, modifiers); + } else { + return super.getCode(key, modifiers); + } + } + }; } }; @@ -102,7 +118,7 @@ public class TerminalExecutionConsole implements ConsoleView { } }); } - + private void printText(@NotNull String text, @Nullable ConsoleViewContentType contentType) throws IOException { if (contentType != null) { myDataStream.append(encodeColor(contentType.getAttributes().getForegroundColor())); diff --git a/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java b/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java index 1a2d8437dece..a6f26d25db17 100644 --- a/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java +++ b/python/ide/src/com/jetbrains/python/PyIdeCommonOptionsForm.java @@ -15,6 +15,7 @@ */ package com.jetbrains.python; +import com.google.common.collect.Lists; import com.intellij.application.options.ModulesComboBox; import com.intellij.execution.configuration.EnvironmentVariablesComponent; import com.intellij.execution.util.PathMappingsComponent; @@ -52,6 +53,7 @@ import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.Consumer; /** * @author yole @@ -78,6 +80,9 @@ public class PyIdeCommonOptionsForm implements AbstractPyCommonOptionsForm { private boolean myInterpreterRemote; private final HideableDecorator myDecorator; + private final List> myRemoteInterpreterModeListeners = Lists.newArrayList(); + + public PyIdeCommonOptionsForm(PyCommonOptionsFormData data) { myProject = data.getProject(); myWorkingDirectoryTextField.addBrowseFolderListener("Select Working Directory", "", data.getProject(), @@ -116,11 +121,11 @@ public class PyIdeCommonOptionsForm implements AbstractPyCommonOptionsForm { } addInterpreterComboBoxActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent event) { - updateRemoteInterpreterMode(); - } - } + @Override + public void actionPerformed(ActionEvent event) { + updateRemoteInterpreterMode(); + } + } ); updateRemoteInterpreterMode(); @@ -137,12 +142,18 @@ public class PyIdeCommonOptionsForm implements AbstractPyCommonOptionsForm { super.off(); storeState(); } + private void storeState() { PropertiesComponent.getInstance().setValue(EXPAND_PROPERTY_KEY, String.valueOf(isExpanded()), "true"); } }; myDecorator.setOn(PropertiesComponent.getInstance().getBoolean(EXPAND_PROPERTY_KEY, true)); myDecorator.setContentComponent(myMainPanel); + + + addInterpreterModeListener((b) -> + myPathMappingsComponent.setVisible(b) + ); } @Override @@ -301,11 +312,13 @@ public class PyIdeCommonOptionsForm implements AbstractPyCommonOptionsForm { private void setRemoteInterpreterMode(boolean isInterpreterRemote) { myInterpreterRemote = isInterpreterRemote; - myPathMappingsComponent.setVisible(isInterpreterRemote); } private void updateRemoteInterpreterMode() { setRemoteInterpreterMode(PySdkUtil.isRemote(getSdkSelected())); + for (Consumer f : myRemoteInterpreterModeListeners) { + f.accept(myInterpreterRemote); + } } @Nullable @@ -368,6 +381,11 @@ public class PyIdeCommonOptionsForm implements AbstractPyCommonOptionsForm { @Override public String getModuleName() { Module module = getModule(); - return module != null? module.getName() : null; + return module != null ? module.getName() : null; + } + + @Override + public void addInterpreterModeListener(Consumer listener) { + myRemoteInterpreterModeListeners.add(listener); } } diff --git a/python/pluginCore/com/jetbrains/python/run/PyPluginCommonOptionsForm.java b/python/pluginCore/com/jetbrains/python/run/PyPluginCommonOptionsForm.java index ca62d4cc75fd..3c6364de4421 100644 --- a/python/pluginCore/com/jetbrains/python/run/PyPluginCommonOptionsForm.java +++ b/python/pluginCore/com/jetbrains/python/run/PyPluginCommonOptionsForm.java @@ -15,6 +15,7 @@ */ package com.jetbrains.python.run; +import com.google.common.collect.Lists; import com.intellij.application.options.ModulesComboBox; import com.intellij.execution.configuration.EnvironmentVariablesComponent; import com.intellij.execution.util.PathMappingsComponent; @@ -48,6 +49,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.Consumer; /** * @author yole @@ -72,6 +74,8 @@ public class PyPluginCommonOptionsForm implements AbstractPyCommonOptionsForm { private JComponent labelAnchor; private final HideableDecorator myDecorator; + private final List> myRemoteInterpreterModeListeners = Lists.newArrayList(); + public PyPluginCommonOptionsForm(PyCommonOptionsFormData data) { // setting modules myProject = data.getProject(); @@ -84,7 +88,7 @@ public class PyPluginCommonOptionsForm implements AbstractPyCommonOptionsForm { myInterpreterComboBox.setMinimumAndPreferredWidth(100); myInterpreterComboBox.setRenderer(new SdkListCellRenderer("")); myWorkingDirectoryTextField.addBrowseFolderListener("Select Working Directory", "", data.getProject(), - FileChooserDescriptorFactory.createSingleFolderDescriptor()); + FileChooserDescriptorFactory.createSingleFolderDescriptor()); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -111,6 +115,7 @@ public class PyPluginCommonOptionsForm implements AbstractPyCommonOptionsForm { super.off(); storeState(); } + private void storeState() { PropertiesComponent.getInstance().setValue(EXPAND_PROPERTY_KEY, String.valueOf(isExpanded()), "true"); } @@ -119,6 +124,15 @@ public class PyPluginCommonOptionsForm implements AbstractPyCommonOptionsForm { myDecorator.setContentComponent(myMainPanel); myPathMappingsComponent.setAnchor(myEnvsComponent.getLabel()); updateControls(); + + addInterpreterComboBoxActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + for (Consumer f : myRemoteInterpreterModeListeners) { + f.accept(PySdkUtil.isRemote(getSelectedSdk())); + } + } + }); } private void updateControls() { @@ -145,6 +159,11 @@ public class PyPluginCommonOptionsForm implements AbstractPyCommonOptionsForm { myInterpreterComboBox.removeActionListener(listener); } + @Override + public void addInterpreterModeListener(Consumer listener) { + myRemoteInterpreterModeListeners.add(listener); + } + public String getInterpreterOptions() { return myInterpreterOptionsTextField.getText().trim(); } @@ -189,7 +208,7 @@ public class PyPluginCommonOptionsForm implements AbstractPyCommonOptionsForm { @Override public String getModuleName() { Module module = getModule(); - return module != null? module.getName() : null; + return module != null ? module.getName() : null; } public void setModule(Module module) { diff --git a/python/pluginCore/python-community-plugin-core.iml b/python/pluginCore/python-community-plugin-core.iml index e4eafd35625f..8cd932ceb19b 100644 --- a/python/pluginCore/python-community-plugin-core.iml +++ b/python/pluginCore/python-community-plugin-core.iml @@ -10,5 +10,6 @@ + \ No newline at end of file diff --git a/python/src/com/jetbrains/python/run/AbstractPyCommonOptionsForm.java b/python/src/com/jetbrains/python/run/AbstractPyCommonOptionsForm.java index f188eea00432..626d94f6e9da 100644 --- a/python/src/com/jetbrains/python/run/AbstractPyCommonOptionsForm.java +++ b/python/src/com/jetbrains/python/run/AbstractPyCommonOptionsForm.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NonNls; import javax.swing.*; import java.awt.event.ActionListener; +import java.util.function.Consumer; /** * @author yole @@ -34,4 +35,6 @@ public interface AbstractPyCommonOptionsForm extends AbstractPythonRunConfigurat void addInterpreterComboBoxActionListener(ActionListener listener); void removeInterpreterComboBoxActionListener(ActionListener listener); + + void addInterpreterModeListener(Consumer listener); } diff --git a/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java b/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java index bf9ca13ba021..3861546efb27 100644 --- a/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java +++ b/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java @@ -53,6 +53,9 @@ public class PythonRunConfigurationForm implements PythonRunConfigurationParams, public PythonRunConfigurationForm(PythonRunConfiguration configuration) { myCommonOptionsForm = PyCommonOptionsFormFactory.getInstance().createForm(configuration.getCommonOptionsFormData()); + myCommonOptionsForm.addInterpreterModeListener((isRemoteInterpreter) -> { + emulateTerminalEnabled(!isRemoteInterpreter); + }); myCommonOptionsPlaceholder.add(myCommonOptionsForm.getMainPanel(), BorderLayout.CENTER); myProject = configuration.getProject(); @@ -80,19 +83,30 @@ public class PythonRunConfigurationForm implements PythonRunConfigurationParams, if (SystemInfo.isWindows) { //TODO: enable it on Windows when it works there - myEmulateTerminalCheckbox.setVisible(false); + emulateTerminalEnabled(false); } + myEmulateTerminalCheckbox.setSelected(false); + myEmulateTerminalCheckbox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - myShowCommandLineCheckbox.setEnabled(!myEmulateTerminalCheckbox.isSelected()); + updateShowCommandLineEnabled(); } }); setAnchor(myCommonOptionsForm.getAnchor()); } + private void updateShowCommandLineEnabled() { + myShowCommandLineCheckbox.setEnabled(!myEmulateTerminalCheckbox.isVisible() || !myEmulateTerminalCheckbox.isSelected()); + } + + private void emulateTerminalEnabled(boolean flag) { + myEmulateTerminalCheckbox.setVisible(flag); + updateShowCommandLineEnabled(); + } + public JComponent getPanel() { return myRootPanel; } diff --git a/resources/src/componentSets/Debugger.xml b/resources/src/componentSets/Debugger.xml index 21391a0897ac..a330d38bf889 100644 --- a/resources/src/componentSets/Debugger.xml +++ b/resources/src/componentSets/Debugger.xml @@ -29,10 +29,6 @@ com.intellij.debugger.memory.component.InstancesTracker - - - com.intellij.debugger.memory.component.MemoryViewComponent -