WI-24554 Move all PHP script-specific menu options into PHP section (master-only version)

This commit is contained in:
Shaverdova Elena
2014-11-27 21:27:11 +03:00
parent 36ea8a7d0a
commit b036663202
2 changed files with 30 additions and 1 deletions
@@ -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();
}
}
@@ -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;
}
}