mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WI-24554 Move all PHP script-specific menu options into PHP section (master-only version)
This commit is contained in:
@@ -20,6 +20,8 @@ import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Named component which provides a configuration user interface.
|
||||
*
|
||||
@@ -92,4 +94,11 @@ public interface Configurable extends UnnamedConfigurable {
|
||||
*/
|
||||
interface NoMargin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a way to sort children of a configurables
|
||||
*/
|
||||
interface SortingConfigurable {
|
||||
Comparator<Configurable> getChildComparator();
|
||||
}
|
||||
}
|
||||
|
||||
+21
-1
@@ -28,6 +28,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -255,6 +257,9 @@ public class ConfigurableWrapper implements SearchableConfigurable {
|
||||
}
|
||||
}
|
||||
myKids = kids;
|
||||
if (getConfigurable() instanceof Configurable.SortingConfigurable) {
|
||||
Arrays.sort(myKids, ((SortingConfigurable)getConfigurable()).getChildComparator());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -264,7 +269,22 @@ public class ConfigurableWrapper implements SearchableConfigurable {
|
||||
|
||||
@Override
|
||||
public ConfigurableWrapper addChild(Configurable configurable) {
|
||||
myKids = ArrayUtil.append(myKids, configurable);
|
||||
final UnnamedConfigurable thisConfigurable = getConfigurable();
|
||||
if (thisConfigurable instanceof Configurable.SortingConfigurable) {
|
||||
final int preIndex = Arrays.binarySearch(myKids, configurable, ((SortingConfigurable)thisConfigurable).getChildComparator());
|
||||
LOG.assertTrue(preIndex < 0);
|
||||
int index = -preIndex - 1;
|
||||
|
||||
int length = myKids.length;
|
||||
Configurable[] result = (Configurable[])Array.newInstance(myKids.getClass().getComponentType(), length + 1);
|
||||
System.arraycopy(myKids, 0, result, 0, index);
|
||||
result[index] = configurable;
|
||||
System.arraycopy(myKids, index, result, index + 1, length - index);
|
||||
myKids = result;
|
||||
}
|
||||
else {
|
||||
myKids = ArrayUtil.append(myKids, configurable);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user