mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
generic debugger settings: step 3 — root settings (Debugger node content)
at first, JS debugger root settings transformed
This commit is contained in:
@@ -30,12 +30,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
* <extensions defaultExtensionNs="com.intellij"><br>
|
||||
* <xdebugger.settings implementation="qualified-class-name"/><br>
|
||||
* </extensions>
|
||||
*
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class XDebuggerSettings<T> implements PersistentStateComponent<T> {
|
||||
public enum Category {
|
||||
ROOT, DATA_VIEWS, STEPPING;
|
||||
ROOT, DATA_VIEWS, STEPPING
|
||||
}
|
||||
|
||||
public static final ExtensionPointName<XDebuggerSettings> EXTENSION_POINT = ExtensionPointName.create("com.intellij.xdebugger.settings");
|
||||
@@ -55,7 +55,9 @@ public abstract class XDebuggerSettings<T> implements PersistentStateComponent<T
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract Configurable createConfigurable();
|
||||
public Configurable createConfigurable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Configurable createConfigurable(@NotNull Category category) {
|
||||
|
||||
+53
-15
@@ -18,14 +18,16 @@ package com.intellij.xdebugger.impl.settings;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
import com.intellij.xdebugger.settings.XDebuggerSettings;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -68,7 +70,7 @@ public class DebuggerConfigurable implements SearchableConfigurable.Parent {
|
||||
|
||||
List<DebuggerSettingsPanelProvider> providers = DebuggerConfigurableProvider.getSortedProviders();
|
||||
|
||||
List<Configurable> configurables = new ArrayList<Configurable>();
|
||||
List<Configurable> configurables = new SmartList<Configurable>();
|
||||
configurables.add(new DataViewsConfigurable());
|
||||
|
||||
List<Configurable> steppingConfigurables = DebuggerConfigurableProvider.getConfigurables(XDebuggerSettings.Category.STEPPING, providers);
|
||||
@@ -76,19 +78,7 @@ public class DebuggerConfigurable implements SearchableConfigurable.Parent {
|
||||
configurables.add(new SteppingConfigurable(steppingConfigurables));
|
||||
}
|
||||
|
||||
Configurable rootConfigurable = null;
|
||||
for (DebuggerSettingsPanelProvider provider : providers) {
|
||||
configurables.addAll(provider.getConfigurables());
|
||||
Configurable aRootConfigurable = provider.getRootConfigurable();
|
||||
if (aRootConfigurable != null) {
|
||||
if (rootConfigurable != null) {
|
||||
configurables.add(aRootConfigurable);
|
||||
}
|
||||
else {
|
||||
rootConfigurable = aRootConfigurable;
|
||||
}
|
||||
}
|
||||
}
|
||||
Configurable rootConfigurable = computeRootConfigurable(providers, configurables);
|
||||
|
||||
if (configurables.isEmpty() && rootConfigurable == null) {
|
||||
myChildren = EMPTY_CONFIGURABLES;
|
||||
@@ -103,6 +93,54 @@ public class DebuggerConfigurable implements SearchableConfigurable.Parent {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Configurable computeRootConfigurable(@NotNull List<DebuggerSettingsPanelProvider> providers, @NotNull List<Configurable> configurables) {
|
||||
Configurable deprecatedRootConfigurable = null;
|
||||
for (DebuggerSettingsPanelProvider provider : providers) {
|
||||
configurables.addAll(provider.getConfigurables());
|
||||
Configurable providerRootConfigurable = provider.getRootConfigurable();
|
||||
if (providerRootConfigurable != null) {
|
||||
if (deprecatedRootConfigurable == null) {
|
||||
deprecatedRootConfigurable = providerRootConfigurable;
|
||||
}
|
||||
else {
|
||||
configurables.add(providerRootConfigurable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Configurable> rootConfigurables = DebuggerConfigurableProvider.getConfigurables(XDebuggerSettings.Category.ROOT, providers);
|
||||
if (rootConfigurables.isEmpty()) {
|
||||
return deprecatedRootConfigurable;
|
||||
}
|
||||
else {
|
||||
Configurable[] mergedRootConfigurables = new Configurable[rootConfigurables.size() + (deprecatedRootConfigurable == null ? 0 : 1)];
|
||||
rootConfigurables.toArray(mergedRootConfigurables);
|
||||
if (deprecatedRootConfigurable != null) {
|
||||
System.arraycopy(mergedRootConfigurables, 0, mergedRootConfigurables, 1, mergedRootConfigurables.length - 1);
|
||||
mergedRootConfigurables[0] = deprecatedRootConfigurable;
|
||||
}
|
||||
return new MergedCompositeConfigurable(mergedRootConfigurables) {
|
||||
@Override
|
||||
protected boolean isUseTitledBorder() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getId() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Nls
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
for (DebuggerSupport support : DebuggerSupport.getDebuggerSupports()) {
|
||||
|
||||
+9
-2
@@ -5,6 +5,7 @@ import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.ui.VerticalFlowLayout;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.TitledSeparator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -18,6 +19,10 @@ abstract class MergedCompositeConfigurable implements SearchableConfigurable {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
protected boolean isUseTitledBorder() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Runnable enableSearch(String option) {
|
||||
@@ -38,11 +43,13 @@ abstract class MergedCompositeConfigurable implements SearchableConfigurable {
|
||||
rootComponent = children[0].createComponent();
|
||||
}
|
||||
else {
|
||||
JPanel panel = new JPanel(new VerticalFlowLayout(0, 0));
|
||||
JPanel panel = new JPanel(new VerticalFlowLayout(0, isUseTitledBorder() ? 0 : TitledSeparator.TOP_INSET));
|
||||
for (Configurable child : children) {
|
||||
JComponent component = child.createComponent();
|
||||
assert component != null;
|
||||
component.setBorder(IdeBorderFactory.createTitledBorder(child.getDisplayName(), false));
|
||||
if (isUseTitledBorder()) {
|
||||
component.setBorder(IdeBorderFactory.createTitledBorder(child.getDisplayName(), false));
|
||||
}
|
||||
panel.add(component);
|
||||
}
|
||||
rootComponent = panel;
|
||||
|
||||
Reference in New Issue
Block a user