mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
-109
@@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<MemoryViewManagerState> {
|
||||
public static final String MEMORY_VIEW_CONTENT = "MemoryView";
|
||||
|
||||
private final EventDispatcher<MemoryViewManagerListener> myDispatcher =
|
||||
EventDispatcher.create(MemoryViewManagerListener.class);
|
||||
private MemoryViewManagerState myState = new MemoryViewManagerState();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
+8
-4
@@ -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<ExpressionEvaluator, EvaluateException>)() -> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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<Consumer<Boolean>> 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<Boolean> 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<Boolean> listener) {
|
||||
myRemoteInterpreterModeListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Consumer<Boolean>> 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("<Project Default>"));
|
||||
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<Boolean> 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<Boolean> 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) {
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
<orderEntry type="module" module-name="lang-api" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="python-community" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -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<Boolean> listener);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
<component>
|
||||
<implementation-class>com.intellij.debugger.memory.component.InstancesTracker</implementation-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<implementation-class>com.intellij.debugger.memory.component.MemoryViewComponent</implementation-class>
|
||||
</component>
|
||||
</project-components>
|
||||
|
||||
<!--
|
||||
|
||||
Reference in New Issue
Block a user