mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
fixed project leak in debugger configurables
This commit is contained in:
+16
-25
@@ -23,6 +23,7 @@ import com.intellij.debugger.engine.evaluation.TextWithImports;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.ui.DebuggerExpressionTextField;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.debugger.ui.tree.render.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
@@ -37,6 +38,7 @@ import com.intellij.ui.TableUtil;
|
||||
import com.intellij.util.ui.AbstractTableCellEditor;
|
||||
import com.intellij.util.ui.Table;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
@@ -47,7 +49,6 @@ import javax.swing.table.TableColumn;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,7 @@ import java.util.List;
|
||||
public class CompoundRendererConfigurable implements UnnamedConfigurable{
|
||||
private CompoundReferenceRenderer myRenderer;
|
||||
private CompoundReferenceRenderer myOriginalRenderer;
|
||||
private final Project myProject;
|
||||
private Project myProject;
|
||||
private TextFieldWithBrowseButton myClassNameField;
|
||||
private JRadioButton myRbDefaultLabel;
|
||||
private JRadioButton myRbExpressionLabel;
|
||||
@@ -81,7 +82,7 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
|
||||
private static final int NAME_TABLE_COLUMN = 0;
|
||||
private static final int EXPRESSION_TABLE_COLUMN = 1;
|
||||
|
||||
public CompoundRendererConfigurable(Project project) {
|
||||
public CompoundRendererConfigurable(@Nullable Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@@ -101,6 +102,9 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
|
||||
}
|
||||
|
||||
public JComponent createComponent() {
|
||||
if (myProject == null) {
|
||||
myProject = JavaDebuggerSupport.getCurrentProject();
|
||||
}
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
myClassNameField = new TextFieldWithBrowseButton(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -373,6 +377,11 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
|
||||
myChildrenEditor.dispose();
|
||||
myChildrenExpandedEditor.dispose();
|
||||
myListChildrenEditor.dispose();
|
||||
myLabelEditor = null;
|
||||
myChildrenEditor = null;
|
||||
myChildrenExpandedEditor = null;
|
||||
myListChildrenEditor = null;
|
||||
myProject = null;
|
||||
}
|
||||
|
||||
private MyTableModel getTableModel() {
|
||||
@@ -380,19 +389,14 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
|
||||
}
|
||||
|
||||
private final class MyTableModel extends AbstractTableModel {
|
||||
private final java.util.List<Row> myData = new ArrayList<Row>();
|
||||
|
||||
public MyTableModel(java.util.List<Pair<String, TextWithImports>> data) {
|
||||
init(data);
|
||||
}
|
||||
private final List<Row> myData = new ArrayList<Row>();
|
||||
|
||||
public MyTableModel() {
|
||||
}
|
||||
|
||||
public void init(java.util.List<Pair<String, TextWithImports>> data) {
|
||||
public void init(List<Pair<String, TextWithImports>> data) {
|
||||
myData.clear();
|
||||
for (Iterator<Pair<String, TextWithImports>> it = data.iterator(); it.hasNext();) {
|
||||
final Pair<String, TextWithImports> pair = it.next();
|
||||
for (final Pair<String, TextWithImports> pair : data) {
|
||||
myData.add(new Row(pair.getFirst(), pair.getSecond()));
|
||||
}
|
||||
}
|
||||
@@ -465,14 +469,6 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
|
||||
}
|
||||
}
|
||||
|
||||
public String getNameAt(int row) {
|
||||
return (row >= 0 && row < myData.size())? myData.get(row).name : null;
|
||||
}
|
||||
|
||||
public TextWithImports getExpressionAt(int row) {
|
||||
return (row >= 0 && row < myData.size())? myData.get(row).value : null;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
myData.clear();
|
||||
fireTableDataChanged();
|
||||
@@ -480,8 +476,7 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
|
||||
|
||||
public List<Pair<String, TextWithImports>> getExpressions() {
|
||||
final ArrayList<Pair<String, TextWithImports>> pairs = new ArrayList<Pair<String, TextWithImports>>(myData.size());
|
||||
for (Iterator<Row> it = myData.iterator(); it.hasNext();) {
|
||||
final Row row = it.next();
|
||||
for (final Row row : myData) {
|
||||
pairs.add(new Pair<String, TextWithImports>(row.name, row.value));
|
||||
}
|
||||
return pairs;
|
||||
@@ -495,10 +490,6 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable{
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Row() {
|
||||
this("", new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-4
@@ -17,6 +17,7 @@ package com.intellij.debugger.settings;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.debugger.ui.tree.render.ClassRenderer;
|
||||
import com.intellij.debugger.ui.tree.render.ToStringRenderer;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
@@ -28,6 +29,7 @@ import com.intellij.ui.StateRestoringCheckBox;
|
||||
import com.intellij.ui.classFilter.ClassFilterEditor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
@@ -58,16 +60,18 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
private ClassFilterEditor myToStringFilterEditor;
|
||||
private JTextField myValueTooltipDelayField;
|
||||
|
||||
private final Project myProject;
|
||||
private Project myProject;
|
||||
private RegistryCheckBox myAutoTooltip;
|
||||
|
||||
public DebuggerDataViewsConfigurable(Project project) {
|
||||
public DebuggerDataViewsConfigurable(@Nullable Project project) {
|
||||
myProject = project;
|
||||
myArrayRendererConfigurable = new ArrayRendererConfigurable(NodeRendererSettings.getInstance().getArrayRenderer());
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
myArrayRendererConfigurable.disposeUIResources();
|
||||
myToStringFilterEditor = null;
|
||||
myProject = null;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
@@ -75,6 +79,9 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
}
|
||||
|
||||
public JComponent createComponent() {
|
||||
if (myProject == null) {
|
||||
myProject = JavaDebuggerSupport.getCurrentProject();
|
||||
}
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
|
||||
myCbAutoscroll = new JCheckBox(DebuggerBundle.message("label.base.renderer.configurable.autoscroll"));
|
||||
@@ -174,7 +181,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
try {
|
||||
DebuggerSettings.getInstance().VALUE_LOOKUP_DELAY = Integer.parseInt(myValueTooltipDelayField.getText().trim());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
catch (NumberFormatException ignored) {
|
||||
}
|
||||
generalSettings.AUTOSCROLL_TO_NEW_LOCALS = myCbAutoscroll.isSelected();
|
||||
rendererSettings.setAlternateCollectionViewsEnabled(myCbEnableAlternateViews.isSelected());
|
||||
@@ -243,7 +250,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
try {
|
||||
return DebuggerSettings.getInstance().VALUE_LOOKUP_DELAY != Integer.parseInt(myValueTooltipDelayField.getText().trim());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
catch (NumberFormatException ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -289,6 +296,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getHelpTopic() {
|
||||
return "reference.idesettings.debugger.dataviews";
|
||||
}
|
||||
|
||||
+6
-6
@@ -16,6 +16,7 @@
|
||||
package com.intellij.debugger.settings;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.classFilter.ClassFilterEditor;
|
||||
@@ -33,11 +34,7 @@ public class DebuggerSteppingConfigurable implements SearchableConfigurable {
|
||||
private JCheckBox myCbSkipClassLoaders;
|
||||
private ClassFilterEditor mySteppingFilterEditor;
|
||||
private JCheckBox myCbSkipSimpleGetters;
|
||||
private final Project myProject;
|
||||
|
||||
public DebuggerSteppingConfigurable(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
private Project myProject;
|
||||
|
||||
public void reset() {
|
||||
final DebuggerSettings settings = DebuggerSettings.getInstance();
|
||||
@@ -84,6 +81,7 @@ public class DebuggerSteppingConfigurable implements SearchableConfigurable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getHelpTopic() {
|
||||
return "reference.idesettings.debugger.stepping";
|
||||
}
|
||||
@@ -99,7 +97,7 @@ public class DebuggerSteppingConfigurable implements SearchableConfigurable {
|
||||
|
||||
public JComponent createComponent() {
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
|
||||
myProject = JavaDebuggerSupport.getCurrentProject();
|
||||
myCbSkipSyntheticMethods = new JCheckBox(DebuggerBundle.message("label.debugger.general.configurable.skip.synthetic.methods"));
|
||||
myCbSkipConstructors = new JCheckBox(DebuggerBundle.message("label.debugger.general.configurable.skip.constructors"));
|
||||
myCbSkipClassLoaders = new JCheckBox(DebuggerBundle.message("label.debugger.general.configurable.skip.classloaders"));
|
||||
@@ -123,6 +121,8 @@ public class DebuggerSteppingConfigurable implements SearchableConfigurable {
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
mySteppingFilterEditor = null;
|
||||
myProject = null;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.util.containers.InternalIterator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
@@ -53,7 +54,7 @@ public class UserRenderersConfigurable implements SearchableConfigurable {
|
||||
private NodeRenderer myCurrentRenderer = null;
|
||||
private final CompoundRendererConfigurable myRendererDataConfigurable;
|
||||
|
||||
public UserRenderersConfigurable(Project project) {
|
||||
public UserRenderersConfigurable(@Nullable Project project) {
|
||||
myRendererDataConfigurable = new CompoundRendererConfigurable(project);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,13 @@ import com.intellij.debugger.settings.*;
|
||||
import com.intellij.debugger.ui.breakpoints.Breakpoint;
|
||||
import com.intellij.debugger.ui.breakpoints.BreakpointFactory;
|
||||
import com.intellij.debugger.ui.breakpoints.BreakpointPanel;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.xdebugger.AbstractDebuggerSession;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
@@ -206,11 +209,11 @@ public class JavaDebuggerSupport extends DebuggerSupport {
|
||||
return new DebuggerLaunchingConfigurable();
|
||||
}
|
||||
|
||||
public Collection<? extends Configurable> getConfigurables(final Project project) {
|
||||
public Collection<? extends Configurable> getConfigurables() {
|
||||
final ArrayList<Configurable> configurables = new ArrayList<Configurable>();
|
||||
configurables.add(new DebuggerDataViewsConfigurable(project));
|
||||
configurables.add(new DebuggerSteppingConfigurable(project));
|
||||
configurables.add(new UserRenderersConfigurable(project));
|
||||
configurables.add(new DebuggerDataViewsConfigurable(null));
|
||||
configurables.add(new DebuggerSteppingConfigurable());
|
||||
configurables.add(new UserRenderersConfigurable(null));
|
||||
configurables.add(new DebuggerHotswapConfigurable());
|
||||
return configurables;
|
||||
}
|
||||
@@ -219,4 +222,13 @@ public class JavaDebuggerSupport extends DebuggerSupport {
|
||||
NodeRendererSettings.getInstance().fireRenderersChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public static Project getCurrentProject() {
|
||||
//todo[nik] improve
|
||||
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
|
||||
if (project != null) {
|
||||
return project;
|
||||
}
|
||||
return ProjectManager.getInstance().getDefaultProject();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-10
@@ -15,12 +15,8 @@
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.settings;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurableProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -47,14 +43,9 @@ public class DebuggerConfigurableProvider extends ConfigurableProvider {
|
||||
}
|
||||
});
|
||||
|
||||
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
|
||||
if(project == null) {
|
||||
project = ProjectManager.getInstance().getDefaultProject();
|
||||
}
|
||||
|
||||
Configurable rootConfigurable = null;
|
||||
for (DebuggerSettingsPanelProvider provider : providers) {
|
||||
configurables.addAll(provider.getConfigurables(project));
|
||||
configurables.addAll(provider.getConfigurables());
|
||||
final Configurable aRootConfigurable = provider.getRootConfigurable();
|
||||
if (aRootConfigurable != null) {
|
||||
if (rootConfigurable != null) {
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package com.intellij.xdebugger.impl.settings;
|
||||
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -28,7 +27,7 @@ public abstract class DebuggerSettingsPanelProvider {
|
||||
|
||||
public abstract int getPriority();
|
||||
|
||||
public abstract Collection<? extends Configurable> getConfigurables(final Project project);
|
||||
public abstract Collection<? extends Configurable> getConfigurables();
|
||||
|
||||
public void apply() {
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class XDebuggerSettingsPanelProviderImpl extends DebuggerSettingsPanelPro
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Collection<? extends Configurable> getConfigurables(final Project project) {
|
||||
public Collection<? extends Configurable> getConfigurables() {
|
||||
ArrayList<Configurable> list = new ArrayList<Configurable>();
|
||||
for (XDebuggerSettings settings : XDebuggerSettingsManager.getInstance().getSettingsList()) {
|
||||
list.add(settings.createConfigurable());
|
||||
|
||||
Reference in New Issue
Block a user