continue: avoid to register XDebugSessionTab as disposable parent — to avoid memory leaks (Disposer holds instance of XDebugSession)

lazy init LogFilesManager (not required for all xdebug session tabs)
This commit is contained in:
Vladimir Krivosheev
2014-09-04 20:50:00 +02:00
parent ff7173742b
commit 2ff1570268
19 changed files with 231 additions and 356 deletions
@@ -15,7 +15,6 @@
*/
package com.intellij.debugger;
import com.intellij.diagnostic.logging.LogFilesManager;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
@@ -37,8 +36,6 @@ public interface DebugUIEnvironment {
@Nullable
Icon getIcon();
void initLogs(RunContentDescriptor content, LogFilesManager logFilesManager);
void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup);
@Nullable
@@ -15,14 +15,10 @@
*/
package com.intellij.debugger;
import com.intellij.diagnostic.logging.LogFilesManager;
import com.intellij.diagnostic.logging.OutputFileUtil;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.RemoteConnection;
import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.RestartAction;
import com.intellij.execution.ui.RunContentDescriptor;
@@ -63,21 +59,6 @@ public class DefaultDebugUIEnvironment implements DebugUIEnvironment {
return getRunProfile().getIcon();
}
@Override
public void initLogs(RunContentDescriptor content, LogFilesManager logFilesManager) {
ProcessHandler processHandler = content.getProcessHandler();
if (getRunProfile() instanceof RunConfigurationBase) {
RunConfigurationBase runConfiguration = (RunConfigurationBase)getRunProfile();
logFilesManager.registerFileMatcher(runConfiguration);
if (processHandler != null) {
logFilesManager.initLogConsoles(runConfiguration, processHandler);
OutputFileUtil.attachDumpListener(runConfiguration, processHandler, content.getExecutionConsole());
}
}
}
@Override
public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) {
Executor executor = myExecutionEnvironment.getExecutor();
@@ -41,7 +41,6 @@ import com.intellij.execution.filters.TextConsoleBuilder;
import com.intellij.execution.filters.TextConsoleBuilderFactory;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ExecutionConsoleEx;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunnerLayoutUi;
import com.intellij.execution.ui.layout.PlaceInGrid;
import com.intellij.icons.AllIcons;
@@ -109,7 +108,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
if (XDebuggerSettingsManager.getInstanceImpl().getGeneralSettings().isHideDebuggerOnProcessTermination()) {
try {
ExecutionManager.getInstance(getProject()).getContentManager().hideRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), myRunContentDescriptor);
ExecutionManager.getInstance(project).getContentManager().hideRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), myRunContentDescriptor);
}
catch (NullPointerException e) {
//if we can get closeProcess after the project have been closed
@@ -130,8 +129,8 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
topToolbar.add(Separator.getInstance(), new Constraints(Anchor.AFTER, DebuggerActions.POP_FRAME));
myUi.getOptions().setTopToolbar(topToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
myWatchPanel = new MainWatchPanel(getProject(), getContextManager());
myFramesPanel = new FramesPanel(getProject(), getContextManager());
myWatchPanel = new MainWatchPanel(project, getContextManager());
myFramesPanel = new FramesPanel(project, getContextManager());
final AlertIcon breakpointAlert = new AlertIcon(AllIcons.Debugger.BreakpointAlert);
@@ -151,7 +150,7 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
myUi.addContent(framesContent, 0, PlaceInGrid.left, false);
// variables
myVariablesPanel = new VariablesPanel(getProject(), myStateManager, this);
myVariablesPanel = new VariablesPanel(project, myStateManager, this);
myVariablesPanel.getFrameTree().setAutoVariablesMode(debuggerSettings.AUTO_VARIABLES_MODE);
Content vars = myUi.createContent(DebuggerContentInfo.VARIABLES_CONTENT, myVariablesPanel, XDebuggerBundle.message("debugger.session.tab.variables.title"),
AllIcons.Debugger.Value, null);
@@ -202,8 +201,8 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
ExecutionResult executionResult = debuggerSession.getProcess().getExecutionResult();
myConsole = executionResult.getExecutionConsole();
myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName(),
environment.getIcon());
// myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName(),
// environment.getIcon());
initUI(executionResult);
}
@@ -226,11 +225,6 @@ public class DebuggerSessionTab extends DebuggerSessionTabBase implements Dispos
return myWatchPanel;
}
@Override
public RunContentDescriptor getRunContentDescriptor() {
return myRunContentDescriptor;
}
private void initUI(ExecutionResult executionResult) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
return;
@@ -97,11 +97,12 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
onProcessStarted(env.getRunnerSettings(), executionResult);
final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, env);
Disposer.register(env.getProject(), contentBuilder);
if (shouldAddDefaultActions) {
addDefaultActions(contentBuilder);
}
return contentBuilder.showRunContent(env.getContentToReuse());
RunContentDescriptor contentDescriptor = contentBuilder.showRunContent(env.getContentToReuse());
Disposer.register(env.getProject(), contentDescriptor);
return contentDescriptor;
}
@Deprecated
@@ -116,7 +117,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
final ExecutionResult executionResult = contentBuilder.getExecutionResult();
final ExecutionConsole executionConsole = executionResult.getExecutionConsole();
final JComponent consoleComponent = executionConsole != null ? executionConsole.getComponent() : null;
final ControlBreakAction controlBreakAction = new ControlBreakAction(contentBuilder.getProcessHandler());
final ControlBreakAction controlBreakAction = new ControlBreakAction(executionResult.getProcessHandler());
if (consoleComponent != null) {
controlBreakAction.registerCustomShortcutSet(controlBreakAction.getShortcutSet(), consoleComponent);
final ProcessHandler processHandler = executionResult.getProcessHandler();
@@ -130,7 +131,7 @@ public class DefaultJavaProgramRunner extends JavaPatchableProgramRunner {
});
}
contentBuilder.addAction(controlBreakAction);
contentBuilder.addAction(new SoftExitAction(contentBuilder.getProcessHandler()));
contentBuilder.addAction(new SoftExitAction(executionResult.getProcessHandler()));
}
@@ -7,7 +7,6 @@ import com.intellij.debugger.engine.DebugProcess;
import com.intellij.debugger.engine.DebugProcessAdapter;
import com.intellij.debugger.engine.RemoteDebugProcessHandler;
import com.intellij.debugger.ui.DebuggerPanelsManager;
import com.intellij.diagnostic.logging.LogFilesManager;
import com.intellij.execution.*;
import com.intellij.execution.configurations.RemoteConnection;
import com.intellij.execution.configurations.RunProfile;
@@ -97,10 +96,6 @@ public class JavaDebuggerLauncherImpl extends JavaDebuggerLauncher {
return myExecutionEnvironment.getRunProfile().getIcon();
}
@Override
public void initLogs(RunContentDescriptor content, LogFilesManager logFilesManager) {
}
@Override
public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) {
actionGroup.add(new CloseAction(myExecutionEnvironment.getExecutor(), content, myExecutionEnvironment.getProject()));
@@ -20,6 +20,8 @@ import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.SmartList;
import com.intellij.util.containers.SmartHashSet;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -27,8 +29,7 @@ import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
@@ -80,46 +81,50 @@ public class LogFileOptions implements JDOMExternalizable {
return myPathPattern;
}
@NotNull
public Set<String> getPaths(){
Set<String> result = new HashSet<String>();
final File logFile = new File(myPathPattern);
File logFile = new File(myPathPattern);
if (logFile.exists()){
result.add(myPathPattern);
return Collections.singleton(myPathPattern);
}
int dirIndex = myPathPattern.lastIndexOf(File.separator);
if (dirIndex == -1) {
return Collections.emptySet();
}
List<File> files = new SmartList<File>();
collectMatchedFiles(new File(myPathPattern.substring(0, dirIndex)), Pattern.compile(FileUtil.convertAntToRegexp(myPathPattern.substring(dirIndex + File.separator.length()))), files);
if (files.isEmpty()) {
return Collections.emptySet();
}
if (myShowAll) {
SmartHashSet<String> result = new SmartHashSet<String>();
result.ensureCapacity(files.size());
for (File file : files) {
result.add(file.getPath());
}
return result;
}
final int dirIndex = myPathPattern.lastIndexOf(File.separator);
if (dirIndex != -1) {
final ArrayList<File> files = new ArrayList<File>();
final String basePath = myPathPattern.substring(0, dirIndex);
final String pattern = myPathPattern.substring(dirIndex + File.separator.length());
collectMatchedFiles(new File(basePath), Pattern.compile(FileUtil.convertAntToRegexp(pattern)), files);
if (!files.isEmpty()) {
if (myShowAll) {
for (File file : files) {
result.add(file.getPath());
else {
File lastFile = null;
for (File file : files) {
if (lastFile != null) {
if (file.lastModified() > lastFile.lastModified()) {
lastFile = file;
}
}
else {
File lastFile = null;
for (File file : files) {
if (lastFile != null) {
if (file.lastModified() > lastFile.lastModified()) {
lastFile = file;
}
}
else {
lastFile = file;
}
}
assert lastFile != null;
result.add(lastFile.getPath());
lastFile = file;
}
}
assert lastFile != null;
return Collections.singleton(lastFile.getPath());
}
return result;
}
public static void collectMatchedFiles(final File root, final Pattern pattern, final List<File> files) {
public static void collectMatchedFiles(@NotNull File root, @NotNull Pattern pattern, @NotNull List<File> files) {
final File[] dirs = root.listFiles();
if (dirs == null) return;
for (File dir : dirs) {
@@ -24,13 +24,13 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.util.SmartList;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
/**
@@ -44,8 +44,8 @@ public abstract class RunConfigurationBase extends UserDataHolderBase
private final Project myProject;
private String myName = "";
private ArrayList<LogFileOptions> myLogFiles = new ArrayList<LogFileOptions>();
private ArrayList<PredefinedLogFile> myPredefinedLogFiles = new ArrayList<PredefinedLogFile>();
private List<LogFileOptions> myLogFiles = new SmartList<LogFileOptions>();
private List<PredefinedLogFile> myPredefinedLogFiles = new SmartList<PredefinedLogFile>();
@NonNls private static final String LOG_FILE = "log_file";
@NonNls private static final String PREDEFINED_LOG_FILE_ELEMENT = "predefined_log_file";
@@ -127,8 +127,8 @@ public abstract class RunConfigurationBase extends UserDataHolderBase
@Override
public RunConfiguration clone() {
final RunConfigurationBase runConfiguration = (RunConfigurationBase)super.clone();
runConfiguration.myLogFiles = new ArrayList<LogFileOptions>(myLogFiles);
runConfiguration.myPredefinedLogFiles = new ArrayList<PredefinedLogFile>(myPredefinedLogFiles);
runConfiguration.myLogFiles = new SmartList<LogFileOptions>(myLogFiles);
runConfiguration.myPredefinedLogFiles = new SmartList<PredefinedLogFile>(myPredefinedLogFiles);
runConfiguration.myFileOutputPath = myFileOutputPath;
runConfiguration.mySaveOutput = mySaveOutput;
runConfiguration.myShowConsoleOnStdOut = myShowConsoleOnStdOut;
@@ -150,12 +150,13 @@ public abstract class RunConfigurationBase extends UserDataHolderBase
myPredefinedLogFiles.add(predefinedLogFile);
}
public ArrayList<PredefinedLogFile> getPredefinedLogFiles() {
public List<PredefinedLogFile> getPredefinedLogFiles() {
return myPredefinedLogFiles;
}
public ArrayList<LogFileOptions> getAllLogFiles() {
final ArrayList<LogFileOptions> list = new ArrayList<LogFileOptions>(myLogFiles);
@NotNull
public List<LogFileOptions> getAllLogFiles() {
List<LogFileOptions> list = new SmartList<LogFileOptions>(myLogFiles);
for (PredefinedLogFile predefinedLogFile : myPredefinedLogFiles) {
final LogFileOptions options = getOptionsForPredefinedLogFile(predefinedLogFile);
if (options != null) {
@@ -165,7 +166,7 @@ public abstract class RunConfigurationBase extends UserDataHolderBase
return list;
}
public ArrayList<LogFileOptions> getLogFiles() {
public List<LogFileOptions> getLogFiles() {
return myLogFiles;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.diagnostic.logging;
import com.intellij.diagnostic.DiagnosticBundle;
@@ -32,10 +31,12 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.*;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.table.TableView;
import com.intellij.util.SmartList;
import com.intellij.util.ui.AbstractTableCellEditor;
import com.intellij.util.ui.CellEditorComponentWithBrowseButton;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.ListTableModel;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -44,7 +45,6 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -61,19 +61,20 @@ public class LogConfigurationPanel<T extends RunConfigurationBase> extends Setti
private TextFieldWithBrowseButton myOutputFile;
private JCheckBox myShowConsoleOnStdOutCb;
private JCheckBox myShowConsoleOnStdErrCb;
private final Map<LogFileOptions, PredefinedLogFile> myLog2Predefined = new HashMap<LogFileOptions, PredefinedLogFile>();
private final List<PredefinedLogFile> myUnresolvedPredefined = new ArrayList<PredefinedLogFile>();
private final ColumnInfo<LogFileOptions, Boolean> IS_SHOW = new MyIsActiveColumnInfo();
private final ColumnInfo<LogFileOptions, LogFileOptions> FILE = new MyLogFileColumnInfo();
private final ColumnInfo<LogFileOptions, Boolean> IS_SKIP_CONTENT = new MyIsSkipColumnInfo();
private final Map<LogFileOptions, PredefinedLogFile> myLog2Predefined = new THashMap<LogFileOptions, PredefinedLogFile>();
private final List<PredefinedLogFile> myUnresolvedPredefined = new SmartList<PredefinedLogFile>();
public LogConfigurationPanel() {
ColumnInfo<LogFileOptions, Boolean> IS_SHOW = new MyIsActiveColumnInfo();
ColumnInfo<LogFileOptions, LogFileOptions> FILE = new MyLogFileColumnInfo();
ColumnInfo<LogFileOptions, Boolean> IS_SKIP_CONTENT = new MyIsSkipColumnInfo();
myModel = new ListTableModel<LogFileOptions>(IS_SHOW, FILE, IS_SKIP_CONTENT);
myFilesTable = new TableView<LogFileOptions>(myModel);
myFilesTable.getEmptyText().setText(DiagnosticBundle.message("log.monitor.no.files"));
final JTableHeader tableHeader = myFilesTable.getTableHeader();
@SuppressWarnings("ConstantConditions")
final FontMetrics fontMetrics = tableHeader.getFontMetrics(tableHeader.getFont());
int preferredWidth = fontMetrics.stringWidth(IS_SHOW.getName()) + 20;
@@ -109,7 +110,7 @@ public class LogConfigurationPanel<T extends RunConfigurationBase> extends Setti
public void run(AnActionButton button) {
TableUtil.stopEditing(myFilesTable);
final int[] selected = myFilesTable.getSelectedRows();
if (selected == null || selected.length == 0) return;
if (selected.length == 0) return;
for (int i = selected.length - 1; i >= 0; i--) {
myModel.removeRow(selected[i]);
}
@@ -130,8 +131,8 @@ public class LogConfigurationPanel<T extends RunConfigurationBase> extends Setti
@Override
public void run(AnActionButton button) {
final int selectedRow = myFilesTable.getSelectedRow();
final LogFileOptions selectedOptions = myFilesTable.getSelectedObject();
showEditorDialog(selectedOptions);
//noinspection ConstantConditions
showEditorDialog(myFilesTable.getSelectedObject());
myModel.fireTableDataChanged();
myFilesTable.setRowSelectionInterval(selectedRow, selectedRow);
}
@@ -156,7 +157,7 @@ public class LogConfigurationPanel<T extends RunConfigurationBase> extends Setti
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
myRedirectOutputCb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
myOutputFile.setEnabled(myRedirectOutputCb.isSelected());
}
});
@@ -218,14 +219,14 @@ public class LogConfigurationPanel<T extends RunConfigurationBase> extends Setti
@Override
protected void resetEditorFrom(final RunConfigurationBase configuration) {
ArrayList<LogFileOptions> list = new ArrayList<LogFileOptions>();
final ArrayList<LogFileOptions> logFiles = configuration.getLogFiles();
final List<LogFileOptions> logFiles = configuration.getLogFiles();
for (LogFileOptions setting : logFiles) {
list.add(
new LogFileOptions(setting.getName(), setting.getPathPattern(), setting.isEnabled(), setting.isSkipContent(), setting.isShowAll()));
}
myLog2Predefined.clear();
myUnresolvedPredefined.clear();
final ArrayList<PredefinedLogFile> predefinedLogFiles = configuration.getPredefinedLogFiles();
final List<PredefinedLogFile> predefinedLogFiles = configuration.getPredefinedLogFiles();
for (PredefinedLogFile predefinedLogFile : predefinedLogFiles) {
PredefinedLogFile logFile = new PredefinedLogFile(predefinedLogFile);
final LogFileOptions options = configuration.getOptionsForPredefinedLogFile(logFile);
@@ -306,8 +307,9 @@ public class LogConfigurationPanel<T extends RunConfigurationBase> extends Setti
@Override
public TableCellRenderer getRenderer(final LogFileOptions p0) {
return new DefaultTableCellRenderer() {
@NotNull
@Override
public Component getTableCellRendererComponent(JTable table,
public Component getTableCellRendererComponent(@NotNull JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
@@ -315,6 +317,7 @@ public class LogConfigurationPanel<T extends RunConfigurationBase> extends Setti
int column) {
final Component renderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setText(((LogFileOptions)value).getName());
//noinspection ConstantConditions
setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
setBorder(null);
return renderer;
@@ -418,7 +421,7 @@ public class LogConfigurationPanel<T extends RunConfigurationBase> extends Setti
getChildComponent().setBorder(null);
myComponent.getComponentWithButton().getButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(@NotNull ActionEvent e) {
showEditorDialog(myLogFileOptions);
JTextField textField = getChildComponent();
textField.setText(myLogFileOptions.getName());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -13,22 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.diagnostic.logging;
import com.intellij.execution.configurations.AdditionalTabComponentManager;
import com.intellij.execution.configurations.RunConfigurationBase;
import org.jetbrains.annotations.NotNull;
import java.nio.charset.Charset;
import java.io.Reader;
/**
* User: anna
* Date: 01-Feb-2006
*/
public interface LogConsoleManager extends AdditionalTabComponentManager {
void addLogConsole(final String name, final String path, @NotNull Charset charset, final long skippedContent);
void addLogConsole(final String name, Reader reader, final String id);
void addLogConsole(String name, String path, @NotNull Charset charset, long skippedContent, @NotNull RunConfigurationBase runConfiguration);
void removeLogConsole(final String pathOrId);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -16,8 +16,8 @@
package com.intellij.diagnostic.logging;
import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.RunnerLayoutUi;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
@@ -29,6 +29,7 @@ import com.intellij.ui.content.ContentManagerAdapter;
import com.intellij.ui.content.ContentManagerEvent;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.io.File;
@@ -37,28 +38,13 @@ import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
/**
* Created by IntelliJ IDEA.
* User: michael.golubev
*/
public abstract class LogConsoleManagerBase implements LogConsoleManager, Disposable {
private final Project myProject;
private final Map<AdditionalTabComponent, Content> myAdditionalContent = new HashMap<AdditionalTabComponent, Content>();
private ExecutionEnvironment myEnvironment;
private final GlobalSearchScope mySearchScope;
/**
* @deprecated use {@link #LogConsoleManagerBase(com.intellij.openapi.project.Project, com.intellij.psi.search.GlobalSearchScope)}
* to remove in IDEA 15
*/
@SuppressWarnings("UnusedDeclaration")
protected LogConsoleManagerBase(@NotNull Project project) {
this(project, GlobalSearchScope.allScope(project));
}
protected LogConsoleManagerBase(@NotNull Project project, @NotNull GlobalSearchScope searchScope) {
myProject = project;
mySearchScope = searchScope;
@@ -68,35 +54,22 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos
return myProject;
}
public void setEnvironment(@NotNull ExecutionEnvironment environment) {
myEnvironment = environment;
}
protected final ExecutionEnvironment getEnvironment() {
return myEnvironment;
}
@Override
public void addLogConsole(final String name, final String path, @NotNull Charset charset, final long skippedContent) {
addLogConsole(name, path, charset, skippedContent, getDefaultIcon());
public void addLogConsole(final String name, final String path, @NotNull Charset charset, final long skippedContent, @NotNull RunConfigurationBase runConfiguration) {
addLogConsole(name, path, charset, skippedContent, getDefaultIcon(), runConfiguration);
}
public void addLogConsole(final String name, final String path, @NotNull Charset charset, final long skippedContent, Icon icon) {
public void addLogConsole(final String name, final String path, @NotNull Charset charset, final long skippedContent, Icon icon, @Nullable RunProfile runProfile) {
doAddLogConsole(new LogConsoleImpl(myProject, new File(path), charset, skippedContent, name, false, mySearchScope) {
@Override
public boolean isActive() {
return isConsoleActive(path);
}
}, path, icon);
}, path, icon, runProfile);
}
@Override
public void addLogConsole(String name, Reader reader, final String id) {
addLogConsole(name, reader, id, getDefaultIcon());
}
public void addLogConsole(String name, Reader reader, final String id, Icon icon) {
public void addLogConsole(String name, Reader reader, final String id, Icon icon, @Nullable RunProfile runProfile) {
doAddLogConsole(new LogConsoleBase(myProject,
reader,
name,
@@ -107,14 +80,14 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos
public boolean isActive() {
return isConsoleActive(id);
}
}, id, icon);
}, id, icon, runProfile);
}
private void doAddLogConsole(final LogConsoleBase log,
final String id,
Icon icon) {
if (myEnvironment != null && myEnvironment.getRunProfile() instanceof RunConfigurationBase) {
((RunConfigurationBase)myEnvironment.getRunProfile()).customizeLogConsole(log);
Icon icon, @Nullable RunProfile runProfile) {
if (runProfile instanceof RunConfigurationBase) {
((RunConfigurationBase)runProfile).customizeLogConsole(log);
}
log.attachStopLogConsoleTrackingListener(getProcessHandler());
addAdditionalTabComponent(log, id, icon);
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.diagnostic.logging;
import com.intellij.execution.configurations.LogFileOptions;
@@ -23,108 +22,57 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Conditions;
import com.intellij.util.Alarm;
import com.intellij.util.SingleAlarm;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.io.File;
import java.util.*;
import java.util.Set;
import java.util.TreeMap;
public class LogFilesManager {
private final Map<LogFileOptions, Set<String>> myLogFileManagerMap = new LinkedHashMap<LogFileOptions, Set<String>>();
private final LogConsoleManager myManager;
private final SingleAlarm myUpdateAlarm;
public LogFilesManager(@NotNull final Project project, @NotNull LogConsoleManager manager, @NotNull Disposable parentDisposable) {
myManager = manager;
myUpdateAlarm = new SingleAlarm(new Runnable() {
@Override
public void run() {
if (project.isDisposed()) {
return;
}
myUpdateAlarm.cancelAllRequests();
for (final LogFileOptions logFile : myLogFileManagerMap.keySet()) {
final Set<String> oldFiles = myLogFileManagerMap.get(logFile);
final Set<String> newFiles = logFile.getPaths(); // should not be called in UI thread
myLogFileManagerMap.put(logFile, newFiles);
final Set<String> obsoleteFiles = new THashSet<String>(oldFiles);
obsoleteFiles.removeAll(newFiles);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (project.isDisposed()) {
return;
}
addConfigurationConsoles(logFile, new Condition<String>() {
@Override
public boolean value(final String file) {
return !oldFiles.contains(file);
}
}, newFiles);
for (String each : obsoleteFiles) {
myManager.removeLogConsole(each);
}
myUpdateAlarm.request();
}
});
}
}
}, 500, Alarm.ThreadToUse.POOLED_THREAD, parentDisposable);
}
public void registerFileMatcher(@NotNull RunConfigurationBase runConfiguration) {
final ArrayList<LogFileOptions> logFiles = runConfiguration.getAllLogFiles();
for (LogFileOptions logFile : logFiles) {
if (logFile.isEnabled()) {
myLogFileManagerMap.put(logFile, logFile.getPaths());
public void addLogConsoles(@NotNull RunConfigurationBase runConfiguration, @Nullable ProcessHandler startedProcess) {
for (LogFileOptions logFileOptions : runConfiguration.getAllLogFiles()) {
if (logFileOptions.isEnabled()) {
addConfigurationConsoles(logFileOptions, Conditions.<String>alwaysTrue(), logFileOptions.getPaths(), runConfiguration);
}
}
myUpdateAlarm.request();
runConfiguration.createAdditionalTabComponents(myManager, startedProcess);
}
public void initLogConsoles(@NotNull RunConfigurationBase base, ProcessHandler startedProcess) {
List<LogFileOptions> logFiles = base.getAllLogFiles();
for (LogFileOptions logFile : logFiles) {
if (logFile.isEnabled()) {
addConfigurationConsoles(logFile, Conditions.<String>alwaysTrue(), logFile.getPaths());
private void addConfigurationConsoles(@NotNull LogFileOptions logFile, @NotNull Condition<String> shouldInclude, @NotNull Set<String> paths, @NotNull RunConfigurationBase runConfiguration) {
if (paths.isEmpty()) {
return;
}
TreeMap<String, String> titleToPath = new TreeMap<String, String>();
if (paths.size() == 1) {
String path = paths.iterator().next();
if (shouldInclude.value(path)) {
titleToPath.put(logFile.getName(), path);
}
}
base.createAdditionalTabComponents(myManager, startedProcess);
}
private void addConfigurationConsoles(final LogFileOptions logFile, Condition<String> shouldInclude, final Set<String> paths) {
if (!paths.isEmpty()) {
final TreeMap<String, String> title2Path = new TreeMap<String, String>();
if (paths.size() == 1) {
final String path = paths.iterator().next();
else {
for (String path : paths) {
if (shouldInclude.value(path)) {
title2Path.put(logFile.getName(), path);
}
}
else {
for (String path : paths) {
if (shouldInclude.value(path)) {
String title = new File(path).getName();
if (title2Path.containsKey(title)) {
title = path;
}
title2Path.put(title, path);
String title = new File(path).getName();
if (titleToPath.containsKey(title)) {
title = path;
}
titleToPath.put(title, path);
}
}
for (final String title : title2Path.keySet()) {
final String path = title2Path.get(title);
assert path != null;
myManager.addLogConsole(title, path, logFile.getCharset(), logFile.isSkipContent() ? new File(path).length() : 0);
}
}
for (String title : titleToPath.keySet()) {
String path = titleToPath.get(title);
assert path != null;
myManager.addLogConsole(title, path, logFile.getCharset(), logFile.isSkipContent() ? new File(path).length() : 0, runConfiguration);
}
}
}
@@ -23,7 +23,6 @@ import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.configurations.SearchScopeProvider;
import com.intellij.execution.impl.ConsoleViewImpl;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.*;
import com.intellij.execution.ui.actions.CloseAction;
import com.intellij.execution.ui.layout.PlaceInGrid;
@@ -41,7 +40,6 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Collection;
import java.util.List;
@@ -113,11 +111,9 @@ public class RunContentBuilder extends RunTab {
@NotNull
private RunContentDescriptor createDescriptor() {
final RunProfile profile = getEnvironment().getRunProfile();
final RunProfile profile = myEnvironment.getRunProfile();
if (ApplicationManager.getApplication().isUnitTestMode()) {
RunContentDescriptor contentDescriptor = new RunContentDescriptor(profile, myExecutionResult, myUi);
Disposer.register(contentDescriptor, this);
return contentDescriptor;
return new RunContentDescriptor(profile, myExecutionResult, myUi);
}
final ExecutionConsole console = myExecutionResult.getExecutionConsole();
@@ -131,14 +127,13 @@ public class RunContentBuilder extends RunTab {
}
initLogConsoles(profile, contentDescriptor, console);
}
Disposer.register(contentDescriptor, this);
myUi.getOptions().setLeftToolbar(createActionToolbar(contentDescriptor), ActionPlaces.UNKNOWN);
if (profile instanceof RunConfigurationBase) {
if (console instanceof ObservableConsoleView && !ApplicationManager.getApplication().isUnitTestMode()) {
((ObservableConsoleView)console).addChangeListener(new ConsoleToFrontListener((RunConfigurationBase)profile,
getProject(),
getEnvironment().getExecutor(),
myProject,
myEnvironment.getExecutor(),
contentDescriptor,
myUi),
this);
@@ -215,37 +210,23 @@ public class RunContentBuilder extends RunTab {
actionGroup.add(myUi.getOptions().getLayoutActions());
actionGroup.addSeparator();
actionGroup.add(PinToolwindowTabAction.getPinAction());
actionGroup.add(new CloseAction(getEnvironment().getExecutor(), contentDescriptor, getProject()));
actionGroup.add(new CloseAction(myEnvironment.getExecutor(), contentDescriptor, myProject));
final String helpId = contentDescriptor.getHelpId();
actionGroup.add(new ContextHelpAction(helpId != null ? helpId : getEnvironment().getExecutor().getHelpId()));
actionGroup.add(new ContextHelpAction(helpId != null ? helpId : myEnvironment.getExecutor().getHelpId()));
return actionGroup;
}
@Override
public ProcessHandler getProcessHandler() {
return myExecutionResult.getProcessHandler();
}
/**
* @param reuseContent see {@link RunContentDescriptor#myContent}
*/
public RunContentDescriptor showRunContent(@Nullable RunContentDescriptor reuseContent) {
RunContentDescriptor descriptor = createDescriptor();
RunContentManagerImpl.copyContentAndBehavior(descriptor, reuseContent);
Disposer.register(descriptor, this);
myRunContentDescriptor = descriptor;
RunContentManagerImpl.copyContentAndBehavior(descriptor, reuseContent);
return descriptor;
}
@Override
protected RunnerLayoutUi getUi() {
return myUi;
}
@Override
protected Icon getDefaultIcon() {
return AllIcons.Debugger.Console;
}
public static class ConsoleToFrontListener implements ConsoleViewImpl.ChangeListener {
@NotNull private final RunConfigurationBase myRunConfigurationBase;
@NotNull private final Project myProject;
@@ -25,6 +25,8 @@ import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunnerLayoutUi;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.project.Project;
@@ -33,12 +35,20 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class RunTab extends LogConsoleManagerBase implements DataProvider {
import javax.swing.*;
public abstract class RunTab implements DataProvider, Disposable {
@NotNull
protected final RunnerLayoutUi myUi;
private LogFilesManager myManager;
protected RunContentDescriptor myRunContentDescriptor;
protected ExecutionEnvironment myEnvironment;
protected final Project myProject;
private final GlobalSearchScope mySearchScope;
private LogConsoleManagerBase logConsoleManager;
protected RunTab(@NotNull ExecutionEnvironment environment, @NotNull String runnerType) {
this(environment.getProject(),
SearchScopeProvider.createSearchScope(environment.getProject(), environment.getRunProfile()),
@@ -46,13 +56,21 @@ public abstract class RunTab extends LogConsoleManagerBase implements DataProvid
environment.getExecutor().getId(),
environment.getRunProfile().getName());
setEnvironment(environment);
myEnvironment = environment;
}
@Override
public void dispose() {
myRunContentDescriptor = null;
myEnvironment = null;
logConsoleManager = null;
}
protected RunTab(@NotNull Project project, @NotNull GlobalSearchScope searchScope, @NotNull String runnerType, @NotNull String runnerTitle, @NotNull String sessionName) {
super(project, searchScope);
myProject = project;
mySearchScope = searchScope;
myUi = RunnerLayoutUi.Factory.getInstance(getProject()).create(runnerType, runnerTitle, sessionName, this);
myUi = RunnerLayoutUi.Factory.getInstance(project).create(runnerType, runnerTitle, sessionName, this);
myUi.getContentManager().addDataProvider(this);
}
@@ -60,11 +78,10 @@ public abstract class RunTab extends LogConsoleManagerBase implements DataProvid
@Override
public Object getData(@NonNls String dataId) {
if (LangDataKeys.RUN_PROFILE.is(dataId)) {
ExecutionEnvironment environment = getEnvironment();
return environment == null ? null : environment.getRunProfile();
return myEnvironment == null ? null : myEnvironment.getRunProfile();
}
else if (LangDataKeys.EXECUTION_ENVIRONMENT.is(dataId)) {
return getEnvironment();
return myEnvironment;
}
else if (LangDataKeys.RUN_CONTENT_DESCRIPTOR.is(dataId)) {
return myRunContentDescriptor;
@@ -72,17 +89,27 @@ public abstract class RunTab extends LogConsoleManagerBase implements DataProvid
return null;
}
@Override
public final void setEnvironment(@NotNull ExecutionEnvironment environment) {
super.setEnvironment(environment);
@NotNull
public LogConsoleManagerBase getLogConsoleManager() {
if (logConsoleManager == null) {
logConsoleManager = new LogConsoleManagerBase(myProject, mySearchScope) {
@Override
protected Icon getDefaultIcon() {
return AllIcons.Debugger.Console;
}
RunProfile profile = environment.getRunProfile();
if (profile instanceof RunConfigurationBase) {
if (myManager == null) {
myManager = new LogFilesManager(getProject(), this, this);
}
myManager.registerFileMatcher((RunConfigurationBase)profile);
@Override
protected RunnerLayoutUi getUi() {
return myUi;
}
@Override
public ProcessHandler getProcessHandler() {
return myRunContentDescriptor == null ? null : myRunContentDescriptor.getProcessHandler();
}
};
}
return logConsoleManager;
}
protected final void initLogConsoles(@NotNull RunProfile runConfiguration, @NotNull RunContentDescriptor contentDescriptor, @Nullable ExecutionConsole console) {
@@ -90,9 +117,9 @@ public abstract class RunTab extends LogConsoleManagerBase implements DataProvid
if (runConfiguration instanceof RunConfigurationBase && processHandler != null) {
RunConfigurationBase configuration = (RunConfigurationBase)runConfiguration;
if (myManager == null) {
myManager = new LogFilesManager(getProject(), this, contentDescriptor);
myManager = new LogFilesManager(myProject, getLogConsoleManager(), contentDescriptor);
}
myManager.initLogConsoles(configuration, processHandler);
myManager.addLogConsoles(configuration, processHandler);
OutputFileUtil.attachDumpListener(configuration, processHandler, console);
}
}
@@ -347,17 +347,18 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
}
@Override
public ArrayList<PredefinedLogFile> getPredefinedLogFiles() {
public List<PredefinedLogFile> getPredefinedLogFiles() {
return myConfiguration.getPredefinedLogFiles();
}
@NotNull
@Override
public ArrayList<LogFileOptions> getAllLogFiles() {
public List<LogFileOptions> getAllLogFiles() {
return myConfiguration.getAllLogFiles();
}
@Override
public ArrayList<LogFileOptions> getLogFiles() {
public List<LogFileOptions> getLogFiles() {
return myConfiguration.getLogFiles();
}
}
@@ -24,7 +24,10 @@ import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.runners.RunContentBuilder;
import com.intellij.execution.ui.*;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunContentManager;
import com.intellij.execution.ui.RunContentWithExecutorListener;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.*;
@@ -247,7 +250,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager
// in test-mode RunContentWithExecutorListener.contentRemoved events are not sent (see RunContentManagerImpl.showRunContent)
// so we make sure the mySessions and mySessionData are cleared correctly when session is disposed
Disposer.register(sessionTab, new Disposable() {
Disposer.register(descriptor, new Disposable() {
@Override
public void dispose() {
mySessionData.remove(descriptor);
@@ -16,26 +16,22 @@
package com.intellij.xdebugger.impl.ui;
import com.intellij.debugger.ui.DebuggerContentInfo;
import com.intellij.diagnostic.logging.AdditionalTabComponent;
import com.intellij.diagnostic.logging.DebuggerLogConsoleManager;
import com.intellij.execution.ExecutionManager;
import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.RunContentBuilder;
import com.intellij.execution.runners.RunTab;
import com.intellij.execution.ui.*;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.ObservableConsoleView;
import com.intellij.execution.ui.layout.LayoutAttractionPolicy;
import com.intellij.execution.ui.layout.LayoutViewOptions;
import com.intellij.icons.AllIcons;
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.ide.ui.customization.CustomActionsSchema;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.AppIcon;
@@ -44,20 +40,17 @@ import com.intellij.xdebugger.XDebuggerBundle;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Collection;
/**
* @author nik
*/
public abstract class DebuggerSessionTabBase extends RunTab implements DebuggerLogConsoleManager {
public abstract class DebuggerSessionTabBase extends RunTab {
protected ExecutionConsole myConsole;
public DebuggerSessionTabBase(@NotNull Project project, @NotNull String runnerId, @NotNull String sessionName, @NotNull GlobalSearchScope searchScope) {
super(project, searchScope, runnerId, XDebuggerBundle.message("xdebugger.default.content.title"), sessionName);
Disposer.register(project, this);
myUi.getDefaults()
.initTabDefaults(0, XDebuggerBundle.message("xdebugger.debugger.tab.title"), null)
.initFocusContent(DebuggerContentInfo.FRAME_CONTENT, XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION)
@@ -68,32 +61,6 @@ public abstract class DebuggerSessionTabBase extends RunTab implements DebuggerL
return (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(id);
}
public abstract RunContentDescriptor getRunContentDescriptor();
@Override
public ProcessHandler getProcessHandler() {
return getRunContentDescriptor().getProcessHandler();
}
@Override
protected Content createLogContent(AdditionalTabComponent tabComponent, String id, Icon icon) {
Content result = super.createLogContent(tabComponent, id, icon);
result.setCloseable(false);
result.setDescription(tabComponent.getTooltip());
return result;
}
@Override
protected Icon getDefaultIcon() {
return AllIcons.FileTypes.Text;
}
@Override
@NotNull
public RunnerLayoutUi getUi() {
return myUi;
}
protected void attachNotificationTo(final Content content) {
if (myConsole instanceof ObservableConsoleView) {
ObservableConsoleView observable = (ObservableConsoleView)myConsole;
@@ -107,12 +74,11 @@ public abstract class DebuggerSessionTabBase extends RunTab implements DebuggerL
}, content);
RunProfile profile = getRunProfile();
if (profile instanceof RunConfigurationBase && !ApplicationManager.getApplication().isUnitTestMode()) {
final RunConfigurationBase runConfigurationBase = (RunConfigurationBase)profile;
observable.addChangeListener(new RunContentBuilder.ConsoleToFrontListener(runConfigurationBase,
getProject(),
observable.addChangeListener(new RunContentBuilder.ConsoleToFrontListener((RunConfigurationBase)profile,
myProject,
DefaultDebugExecutor.getDebugExecutorInstance(),
myRunContentDescriptor,
getUi()),
myUi),
content);
}
}
@@ -120,21 +86,20 @@ public abstract class DebuggerSessionTabBase extends RunTab implements DebuggerL
@Nullable
protected RunProfile getRunProfile() {
ExecutionEnvironment environment = getEnvironment();
return environment != null ? environment.getRunProfile() : null;
return myEnvironment != null ? myEnvironment.getRunProfile() : null;
}
public void toFront(boolean focus) {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
ExecutionManager.getInstance(getProject()).getContentManager().toFrontRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), myRunContentDescriptor);
ExecutionManager.getInstance(myProject).getContentManager().toFrontRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), myRunContentDescriptor);
if (focus) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
boolean focusWnd = Registry.is("debugger.mayBringFrameToFrontOnBreakpoint");
ProjectUtil.focusProjectWindow(getProject(), focusWnd);
ProjectUtil.focusProjectWindow(myProject, focusWnd);
if (!focusWnd) {
AppIcon.getInstance().requestAttention(getProject(), true);
AppIcon.getInstance().requestAttention(myProject, true);
}
}
});
@@ -22,6 +22,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.RunContentBuilder;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunnerLayoutUi;
import com.intellij.execution.ui.actions.CloseAction;
import com.intellij.execution.ui.layout.PlaceInGrid;
import com.intellij.execution.ui.layout.impl.ViewImpl;
@@ -83,6 +84,11 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
return new XDebugSessionTab(session, icon, environment);
}
@NotNull
public RunnerLayoutUi getUi() {
return myUi;
}
private XDebugSessionTab(@NotNull XDebugSessionImpl session,
@Nullable Icon icon,
@Nullable ExecutionEnvironment environment) {
@@ -95,7 +101,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
myUi.addContent(createWatchesContent(session), 0, PlaceInGrid.right, false);
for (XDebugView view : myViews) {
Disposer.register(this, view);
Disposer.register(myRunContentDescriptor, view);
}
attachToSession(session);
@@ -115,20 +121,18 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
}
}
}
}, this);
}, myRunContentDescriptor);
rebuildViews();
}
private void setSession(@NotNull XDebugSessionImpl session, @Nullable ExecutionEnvironment environment, @Nullable Icon icon) {
if (environment != null) {
setEnvironment(environment);
}
myEnvironment = environment;
mySession = session;
mySessionData = session.getSessionData();
myConsole = session.getConsoleView();
myRunContentDescriptor = new RunContentDescriptor(myConsole, session.getDebugProcess().getProcessHandler(), myUi.getComponent(), session.getSessionName(), icon);
Disposer.register(myRunContentDescriptor, this);
}
@Nullable
@@ -180,7 +184,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
@NotNull
private Content createFramesContent() {
XFramesView framesView = new XFramesView(getProject());
XFramesView framesView = new XFramesView(myProject);
myViews.add(framesView);
Content framesContent = myUi.createContent(DebuggerContentInfo.FRAME_CONTENT, framesView.getMainPanel(),
XDebuggerBundle.message("debugger.session.tab.frames.title"), AllIcons.Debugger.Frame, null);
@@ -193,7 +197,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
}
public void rebuildViews() {
AppUIUtil.invokeLaterIfProjectAlive(getProject(), new Runnable() {
AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
@Override
public void run() {
for (XDebugView view : myViews) {
@@ -209,7 +213,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
private void attachToSession(@NotNull XDebugSessionImpl session) {
for (XDebugView view : myViews) {
session.addSessionListener(new XDebugViewSessionListener(view), this);
session.addSessionListener(new XDebugViewSessionListener(view), myRunContentDescriptor);
}
XDebugTabLayouter layouter = session.getDebugProcess().createTabLayouter();
@@ -225,8 +229,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
DefaultActionGroup leftToolbar = new DefaultActionGroup();
final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
ExecutionEnvironment environment = getEnvironment();
if (environment != null) {
if (myEnvironment != null) {
leftToolbar.add(ActionManager.getInstance().getAction(IdeActions.ACTION_RERUN));
List<AnAction> additionalRestartActions = session.getRestartActions();
if (!additionalRestartActions.isEmpty()) {
@@ -276,7 +279,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
leftToolbar.addSeparator();
leftToolbar.add(PinToolwindowTabAction.getPinAction());
leftToolbar.add(new CloseAction(environment != null ? environment.getExecutor() : debugExecutor, myRunContentDescriptor, getProject()));
leftToolbar.add(new CloseAction(myEnvironment != null ? myEnvironment.getExecutor() : debugExecutor, myRunContentDescriptor, myProject));
leftToolbar.add(new ContextHelpAction(debugExecutor.getHelpId()));
DefaultActionGroup topToolbar = new DefaultActionGroup();
@@ -286,8 +289,8 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
myUi.getOptions().setLeftToolbar(leftToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
myUi.getOptions().setTopToolbar(topToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
if (environment != null) {
initLogConsoles(environment.getRunProfile(), myRunContentDescriptor, myConsole);
if (myEnvironment != null) {
initLogConsoles(myEnvironment.getRunProfile(), myRunContentDescriptor, myConsole);
}
}
@@ -296,7 +299,6 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
mySession = null;
}
@Override
@Nullable
public RunContentDescriptor getRunContentDescriptor() {
return myRunContentDescriptor;
@@ -15,6 +15,7 @@
*/
package org.jetbrains.idea.devkit.run;
import com.intellij.application.options.ModulesComboBox;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.configurations.LogFileOptions;
import com.intellij.execution.ui.AlternativeJREPanel;
@@ -24,7 +25,6 @@ import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.application.options.ModulesComboBox;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.ui.PanelWithAnchor;
import com.intellij.ui.RawCommandLineEditor;
@@ -46,7 +46,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public class PluginRunConfigurationEditor extends SettingsEditor<PluginRunConfiguration> implements PanelWithAnchor {
private final ModulesComboBox myModules = new ModulesComboBox();
@@ -54,7 +53,7 @@ public class PluginRunConfigurationEditor extends SettingsEditor<PluginRunConfig
private final LabeledComponent<RawCommandLineEditor> myVMParameters = new LabeledComponent<RawCommandLineEditor>();
private final LabeledComponent<RawCommandLineEditor> myProgramParameters = new LabeledComponent<RawCommandLineEditor>();
private JComponent anchor;
private AlternativeJREPanel myAlternativeJREPanel = new AlternativeJREPanel();
private final AlternativeJREPanel myAlternativeJREPanel = new AlternativeJREPanel();
@NonNls private final JCheckBox myShowLogs = new JCheckBox(DevKitBundle.message("show.smth", "idea.log"));
@@ -65,12 +64,14 @@ public class PluginRunConfigurationEditor extends SettingsEditor<PluginRunConfig
myPRC = prc;
myShowLogs.setSelected(isShow(prc));
myShowLogs.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
setShow(prc, myShowLogs.isSelected());
}
});
myModules.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
final Module selectedModule = myModules.getSelectedModule();
if (selectedModule != null){
prc.removeAllLogFiles();
@@ -113,20 +114,19 @@ public class PluginRunConfigurationEditor extends SettingsEditor<PluginRunConfig
}
private static void setShow(PluginRunConfiguration prc, boolean show){
final ArrayList<LogFileOptions> logFiles = prc.getLogFiles();
for (LogFileOptions logFile: logFiles) {
for (LogFileOptions logFile: prc.getLogFiles()) {
logFile.setEnable(show);
}
}
private static boolean isShow(PluginRunConfiguration prc){
final ArrayList<LogFileOptions> logFiles = prc.getLogFiles();
for (LogFileOptions logFile : logFiles) {
for (LogFileOptions logFile : prc.getLogFiles()) {
if (logFile.isEnabled()) return true;
}
return false;
}
@Override
public void resetEditorFrom(PluginRunConfiguration prc) {
myModules.setSelectedModule(prc.getModule());
getVMParameters().setText(prc.VM_PARAMETERS);
@@ -135,6 +135,7 @@ public class PluginRunConfigurationEditor extends SettingsEditor<PluginRunConfig
}
@Override
public void applyEditorTo(PluginRunConfiguration prc) throws ConfigurationException {
prc.setModule(myModules.getSelectedModule());
prc.VM_PARAMETERS = getVMParameters().getText();
@@ -143,6 +144,7 @@ public class PluginRunConfigurationEditor extends SettingsEditor<PluginRunConfig
prc.setAlternativeJreEnabled(myAlternativeJREPanel.isPathEnabled());
}
@Override
@NotNull
public JComponent createEditor() {
myModules.fillModules(myPRC.getProject(), PluginModuleType.getInstance());
@@ -17,11 +17,13 @@
package org.intellij.plugins.xsltDebugger;
import com.intellij.diagnostic.logging.AdditionalTabComponent;
import com.intellij.diagnostic.logging.LogConsoleManagerBase;
import com.intellij.execution.CantRunException;
import com.intellij.execution.configurations.AdditionalTabComponentManager;
import com.intellij.execution.configurations.SimpleJavaParameters;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.process.ProcessListener;
import com.intellij.execution.runners.RunTab;
import com.intellij.icons.AllIcons;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
@@ -39,7 +41,6 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiManager;
import com.intellij.util.PlatformIcons;
import com.intellij.util.net.NetUtils;
import com.intellij.xdebugger.impl.ui.DebuggerSessionTabBase;
import org.intellij.lang.xpath.xslt.XsltSupport;
import org.intellij.lang.xpath.xslt.impl.XsltChecker;
import org.intellij.lang.xpath.xslt.run.XsltRunConfiguration;
@@ -87,11 +88,12 @@ public class XsltDebuggerExtension extends XsltRunnerExtension {
AdditionalTabComponentManager manager,
AdditionalTabComponent outputConsole,
ProcessHandler process) {
if (manager instanceof DebuggerSessionTabBase) {
final DebuggerSessionTabBase mgr = (DebuggerSessionTabBase)manager;
mgr.addAdditionalTabComponent(new OutputTabComponent(outputConsole), "XSLT-Output", AllIcons.Debugger.Console);
mgr.addAdditionalTabComponent(StructureTabComponent.create(process, outputConsole), "XSLT-Structure", PlatformIcons.FLATTEN_PACKAGES_ICON);
} else {
if (manager instanceof RunTab) {
LogConsoleManagerBase runTab = ((RunTab)manager).getLogConsoleManager();
runTab.addAdditionalTabComponent(new OutputTabComponent(outputConsole), "XSLT-Output", AllIcons.Debugger.Console);
runTab.addAdditionalTabComponent(StructureTabComponent.create(process, outputConsole), "XSLT-Structure", PlatformIcons.FLATTEN_PACKAGES_ICON);
}
else {
manager.addAdditionalTabComponent(new OutputTabComponent(outputConsole), "XSLT-Output");
manager.addAdditionalTabComponent(StructureTabComponent.create(process, outputConsole), "XSLT-Structure");
}