mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
OC-13663 Show run configurations in the same order as they are shown in Xcode (and order back)
This commit is contained in:
@@ -29,4 +29,10 @@ public interface RunManagerListener extends EventListener {
|
||||
void runConfigurationRemoved(@NotNull RunnerAndConfigurationSettings settings);
|
||||
|
||||
void runConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings, String existingId);
|
||||
|
||||
default void beginUpdate() {
|
||||
}
|
||||
|
||||
default void endUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.labels.ActionLink;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -651,51 +650,57 @@ class RunConfigurable extends BaseConfigurable {
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
updateActiveConfigurationFromSelected();
|
||||
|
||||
final RunManagerImpl manager = getRunManager();
|
||||
final ConfigurationType[] types = manager.getConfigurationFactories();
|
||||
List<ConfigurationType> configurationTypes = new ArrayList<ConfigurationType>();
|
||||
for (int i = 0; i < myRoot.getChildCount(); i++) {
|
||||
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)myRoot.getChildAt(i);
|
||||
Object userObject = node.getUserObject();
|
||||
if (userObject instanceof ConfigurationType) {
|
||||
configurationTypes.add((ConfigurationType)userObject);
|
||||
}
|
||||
}
|
||||
for (ConfigurationType type : types) {
|
||||
if (!configurationTypes.contains(type))
|
||||
configurationTypes.add(type);
|
||||
}
|
||||
|
||||
for (ConfigurationType configurationType : configurationTypes) {
|
||||
applyByType(configurationType);
|
||||
}
|
||||
|
||||
getRunManager().fireBeginUpdate();
|
||||
try {
|
||||
int i = Math.max(RunManagerConfig.MIN_RECENT_LIMIT, Integer.parseInt(myRecentsLimit.getText()));
|
||||
int oldLimit = manager.getConfig().getRecentsLimit();
|
||||
if (oldLimit != i) {
|
||||
manager.getConfig().setRecentsLimit(i);
|
||||
manager.checkRecentsLimit();
|
||||
updateActiveConfigurationFromSelected();
|
||||
|
||||
final RunManagerImpl manager = getRunManager();
|
||||
final ConfigurationType[] types = manager.getConfigurationFactories();
|
||||
List<ConfigurationType> configurationTypes = new ArrayList<ConfigurationType>();
|
||||
for (int i = 0; i < myRoot.getChildCount(); i++) {
|
||||
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)myRoot.getChildAt(i);
|
||||
Object userObject = node.getUserObject();
|
||||
if (userObject instanceof ConfigurationType) {
|
||||
configurationTypes.add((ConfigurationType)userObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
manager.getConfig().setRestartRequiresConfirmation(myConfirmation.isSelected());
|
||||
|
||||
for (Configurable configurable : myStoredComponents.values()) {
|
||||
if (configurable.isModified()){
|
||||
configurable.apply();
|
||||
for (ConfigurationType type : types) {
|
||||
if (!configurationTypes.contains(type))
|
||||
configurationTypes.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
for (Pair<UnnamedConfigurable, JComponent> each : myAdditionalSettings) {
|
||||
each.first.apply();
|
||||
}
|
||||
for (ConfigurationType configurationType : configurationTypes) {
|
||||
applyByType(configurationType);
|
||||
}
|
||||
|
||||
manager.saveOrder();
|
||||
try {
|
||||
int i = Math.max(RunManagerConfig.MIN_RECENT_LIMIT, Integer.parseInt(myRecentsLimit.getText()));
|
||||
int oldLimit = manager.getConfig().getRecentsLimit();
|
||||
if (oldLimit != i) {
|
||||
manager.getConfig().setRecentsLimit(i);
|
||||
manager.checkRecentsLimit();
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
manager.getConfig().setRestartRequiresConfirmation(myConfirmation.isSelected());
|
||||
|
||||
for (Configurable configurable : myStoredComponents.values()) {
|
||||
if (configurable.isModified()){
|
||||
configurable.apply();
|
||||
}
|
||||
}
|
||||
|
||||
for (Pair<UnnamedConfigurable, JComponent> each : myAdditionalSettings) {
|
||||
each.first.apply();
|
||||
}
|
||||
|
||||
manager.saveOrder();
|
||||
}
|
||||
finally {
|
||||
getRunManager().fireEndUpdate();
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
myTree.repaint();
|
||||
|
||||
@@ -400,15 +400,25 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
}
|
||||
|
||||
public void saveOrder() {
|
||||
setOrder(null);
|
||||
}
|
||||
|
||||
private void doSaveOrder(@Nullable Comparator<RunnerAndConfigurationSettings> comparator) {
|
||||
List<RunnerAndConfigurationSettings> sorted = new ArrayList<>(
|
||||
ContainerUtil.filter(myConfigurations.values(), o -> !(o.getType() instanceof UnknownConfigurationType)));
|
||||
if (comparator != null) sorted.sort(comparator);
|
||||
|
||||
myOrder.clear();
|
||||
for (RunnerAndConfigurationSettings each : myConfigurations.values()) {
|
||||
if (each.getType() instanceof UnknownConfigurationType) {
|
||||
continue;
|
||||
}
|
||||
for (RunnerAndConfigurationSettings each : sorted) {
|
||||
myOrder.add(each.getUniqueID());
|
||||
}
|
||||
}
|
||||
|
||||
public void setOrder(@Nullable Comparator<RunnerAndConfigurationSettings> comparator) {
|
||||
doSaveOrder(comparator);
|
||||
setOrdered(false);// force recache of configurations list
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeConfiguration(@Nullable RunnerAndConfigurationSettings settings) {
|
||||
if (settings == null) return;
|
||||
@@ -1256,6 +1266,14 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
fireRunConfigurationsRemoved(removed);
|
||||
}
|
||||
|
||||
public void fireBeginUpdate() {
|
||||
myDispatcher.getMulticaster().beginUpdate();
|
||||
}
|
||||
|
||||
public void fireEndUpdate() {
|
||||
myDispatcher.getMulticaster().endUpdate();
|
||||
}
|
||||
|
||||
public void fireRunConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
|
||||
myDispatcher.getMulticaster().runConfigurationChanged(settings, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user