mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-102508 error status of run configuration is not updated after fix
This commit is contained in:
@@ -31,4 +31,5 @@ public abstract class IconDeferrer {
|
||||
}
|
||||
|
||||
public abstract <T> Icon defer(Icon base, T param, @NotNull Function<T, Icon> f);
|
||||
public abstract <T> Icon deferAutoUpdatable(Icon base, T param, @NotNull Function<T, Icon> f);
|
||||
}
|
||||
@@ -74,7 +74,6 @@ public abstract class RunManagerEx extends RunManager {
|
||||
public abstract RunnerAndConfigurationSettings findConfigurationByName(@Nullable final String name);
|
||||
|
||||
public abstract Icon getConfigurationIcon(@NotNull RunnerAndConfigurationSettings settings);
|
||||
public abstract void invalidateConfigurationIcon(@NotNull RunnerAndConfigurationSettings settings);
|
||||
|
||||
@NotNull
|
||||
public abstract Collection<RunnerAndConfigurationSettings> getSortedConfigurations();
|
||||
|
||||
+1
@@ -127,6 +127,7 @@ public class RunConfigurationsComboBoxAction extends ComboBoxAction implements D
|
||||
final RunnerAndConfigurationSettings settings,
|
||||
final Project project) {
|
||||
try {
|
||||
presentation.setIcon(null);//Hack for same DeferredIcon with new "recalculated" delegate icon inside (events won't pass)
|
||||
presentation.setIcon(RunManagerEx.getInstanceEx(project).getConfigurationIcon(settings));
|
||||
}
|
||||
catch (IndexNotReadyException ignored) {
|
||||
|
||||
@@ -396,11 +396,6 @@ class RunConfigurable extends BaseConfigurable {
|
||||
myRightPanel.add(((SingleConfigurationConfigurable)configurable).getValidationComponent(), BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
if (configurable instanceof SingleConfigurationConfigurable) {
|
||||
RunManagerEx.getInstanceEx(myProject)
|
||||
.invalidateConfigurationIcon((RunnerAndConfigurationSettings)((SingleConfigurationConfigurable)configurable).getSettings());
|
||||
}
|
||||
|
||||
setupDialogBounds();
|
||||
}
|
||||
|
||||
|
||||
@@ -425,7 +425,6 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
mySharedConfigurations.remove(settings.getUniqueID());
|
||||
myConfigurationToBeforeTasksMap.remove(settings.getConfiguration());
|
||||
myRecentlyUsedTemporaries.remove(settings.getConfiguration());
|
||||
invalidateConfigurationIcon(configuration);
|
||||
myDispatcher.getMulticaster().runConfigurationRemoved(configuration);
|
||||
break;
|
||||
}
|
||||
@@ -444,9 +443,6 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
@Override
|
||||
public void setSelectedConfiguration(@Nullable RunnerAndConfigurationSettings settings) {
|
||||
setSelectedConfigurationId(settings == null ? null : settings.getUniqueID());
|
||||
if (settings != null) {
|
||||
invalidateConfigurationIcon(settings);
|
||||
}
|
||||
fireRunConfigurationSelected();
|
||||
}
|
||||
|
||||
@@ -897,7 +893,6 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
if (tempConfiguration == null) return;
|
||||
|
||||
tempConfiguration.setTemporary(true);
|
||||
invalidateConfigurationIcon(tempConfiguration);
|
||||
|
||||
addConfiguration(tempConfiguration, isConfigurationShared(tempConfiguration),
|
||||
getBeforeRunTasks(tempConfiguration.getConfiguration()), false);
|
||||
@@ -950,7 +945,6 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
public void makeStable(@NotNull RunnerAndConfigurationSettings settings) {
|
||||
invalidateConfigurationIcon(settings);
|
||||
settings.setTemporary(false);
|
||||
myRecentlyUsedTemporaries.remove(settings.getConfiguration());
|
||||
if (!myOrder.isEmpty()) {
|
||||
@@ -1012,11 +1006,6 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
return tasks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateConfigurationIcon(@NotNull final RunnerAndConfigurationSettings settings) {
|
||||
myIdToIcon.remove(settings.getUniqueID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getConfigurationIcon(@NotNull final RunnerAndConfigurationSettings settings) {
|
||||
final String uniqueID = settings.getUniqueID();
|
||||
@@ -1032,10 +1021,10 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
Icon icon = myIdToIcon.get(uniqueID);
|
||||
if (icon == null) {
|
||||
icon = IconDeferrer.getInstance().defer(settings.getConfiguration().getIcon(), Pair.create(myProject, settings),
|
||||
new Function<Pair<Project, RunnerAndConfigurationSettings>, Icon>() {
|
||||
icon = IconDeferrer.getInstance().deferAutoUpdatable(settings.getConfiguration().getIcon(), myProject.hashCode() ^ settings.hashCode(),
|
||||
new Function<Integer, Icon>() {
|
||||
@Override
|
||||
public Icon fun(Pair<Project, RunnerAndConfigurationSettings> projectRunnerAndConfigurationSettingsPair) {
|
||||
public Icon fun(Integer param) {
|
||||
if (myProject.isDisposed()) return null;
|
||||
|
||||
myIconCalcTime.remove(uniqueID);
|
||||
@@ -1189,7 +1178,6 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
final RunnerAndConfigurationSettings settings = entry.getValue();
|
||||
if (!settings.isTemplate() && isConfigurationShared(settings) && !existing.contains(settings.getUniqueID())) {
|
||||
removed.add(settings);
|
||||
invalidateConfigurationIcon(settings);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
@@ -1197,7 +1185,6 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
public void fireRunConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
|
||||
invalidateConfigurationIcon(settings);
|
||||
myDispatcher.getMulticaster().runConfigurationChanged(settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,6 +45,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
private static final int MIN_AUTO_UPDATE_MILLIS = 950;
|
||||
private static final RepaintScheduler ourRepaintScheduler = new RepaintScheduler();
|
||||
@NotNull
|
||||
private volatile Icon myDelegateIcon;
|
||||
@@ -54,6 +55,9 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
private static final Icon EMPTY_ICON = EmptyIcon.ICON_16;
|
||||
private final boolean myNeedReadAction;
|
||||
private boolean myDone;
|
||||
private final boolean myAutoUpdatable;
|
||||
private long myLastCalcTime = 0L;
|
||||
private long myLastTimeSpent = 0L;
|
||||
|
||||
private final IconListener<T> myEvalListener;
|
||||
private static final TransferToEDTQueue<Runnable> ourLaterInvocator = new TransferToEDTQueue<Runnable>("Deferred icon later invocator", new Processor<Runnable>() {
|
||||
@@ -64,19 +68,21 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
}
|
||||
}, Condition.FALSE, 200);
|
||||
|
||||
DeferredIconImpl(Icon baseIcon, T param, @NotNull Function<T, Icon> evaluator, @NotNull IconListener<T> listener) {
|
||||
this(baseIcon, param, true, evaluator, listener);
|
||||
public DeferredIconImpl(Icon baseIcon, T param, @NotNull Function<T, Icon> evaluator, @NotNull IconListener<T> listener, boolean autoUpdatable) {
|
||||
this(baseIcon, param, true, evaluator, listener, autoUpdatable);
|
||||
}
|
||||
|
||||
public DeferredIconImpl(Icon baseIcon, T param, final boolean needReadAction, @NotNull Function<T, Icon> evaluator) {
|
||||
this(baseIcon, param, needReadAction, evaluator, null);
|
||||
this(baseIcon, param, needReadAction, evaluator, null, false);
|
||||
}
|
||||
private DeferredIconImpl(Icon baseIcon, T param, final boolean needReadAction, @NotNull Function<T, Icon> evaluator, IconListener<T> listener) {
|
||||
|
||||
private DeferredIconImpl(Icon baseIcon, T param, boolean needReadAction, final Function<T, Icon> evaluator, IconListener<T> listener, boolean autoUpdatable) {
|
||||
myParam = param;
|
||||
myDelegateIcon = nonNull(baseIcon);
|
||||
myEvaluator = evaluator;
|
||||
myNeedReadAction = needReadAction;
|
||||
myEvalListener = listener;
|
||||
myAutoUpdatable = autoUpdatable;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -90,7 +96,7 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
myDelegateIcon.paintIcon(c, g, x, y); //SOE protection
|
||||
}
|
||||
|
||||
if (myIsScheduled || isDone() || PowerSaveMode.isEnabled()) {
|
||||
if (isDone() || myIsScheduled || PowerSaveMode.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
myIsScheduled = true;
|
||||
@@ -119,11 +125,16 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
}
|
||||
};
|
||||
|
||||
final long startTime = System.currentTimeMillis();
|
||||
if (myNeedReadAction) {
|
||||
if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IconDeferrerImpl.evaluateDeferred(evalRunnable);
|
||||
if (myAutoUpdatable) {
|
||||
myLastCalcTime = System.currentTimeMillis();
|
||||
myLastTimeSpent = myLastCalcTime - startTime;
|
||||
}
|
||||
}
|
||||
})) {
|
||||
myIsScheduled = false;
|
||||
@@ -132,6 +143,10 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
}
|
||||
else {
|
||||
IconDeferrerImpl.evaluateDeferred(evalRunnable);
|
||||
if (myAutoUpdatable) {
|
||||
myLastCalcTime = System.currentTimeMillis();
|
||||
myLastTimeSpent = myLastCalcTime - startTime;
|
||||
}
|
||||
}
|
||||
final Icon result = evaluated[0];
|
||||
myDelegateIcon = result;
|
||||
@@ -215,8 +230,10 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
}
|
||||
|
||||
myDone = true;
|
||||
myEvaluator = null;
|
||||
myParam = null;
|
||||
if (!myAutoUpdatable) {
|
||||
myEvaluator = null;
|
||||
myParam = null;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -271,6 +288,10 @@ public class DeferredIconImpl<T> implements DeferredIcon {
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
if (myAutoUpdatable && myDone && myLastCalcTime > 0 && (System.currentTimeMillis() - myLastCalcTime) > Math.max(MIN_AUTO_UPDATE_MILLIS, 10 * myLastTimeSpent)) {
|
||||
myDone = false;
|
||||
myIsScheduled = false;
|
||||
}
|
||||
return myDone;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -74,6 +74,15 @@ public class IconDeferrerImpl extends IconDeferrer {
|
||||
|
||||
@Override
|
||||
public <T> Icon defer(final Icon base, final T param, @NotNull final Function<T, Icon> f) {
|
||||
return deferImpl(base, param, f, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Icon deferAutoUpdatable(Icon base, T param, @NotNull Function<T, Icon> f) {
|
||||
return deferImpl(base, param, f, true);
|
||||
}
|
||||
|
||||
private <T> Icon deferImpl(Icon base, T param, @NotNull Function<T, Icon> f, boolean autoupdatable) {
|
||||
if (myEvaluationIsInProgress.get().booleanValue()) {
|
||||
return f.fun(param);
|
||||
}
|
||||
@@ -92,7 +101,7 @@ public class IconDeferrerImpl extends IconDeferrer {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, autoupdatable);
|
||||
myIconsCache.put(param, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -369,7 +369,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
final Icon icon = getIcon();
|
||||
int x = 7;
|
||||
if (icon != null) {
|
||||
icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2);
|
||||
icon.paintIcon(this, g, x, (size.height - icon.getIconHeight()) / 2);
|
||||
x += icon.getIconWidth() + 3;
|
||||
}
|
||||
if (!StringUtil.isEmpty(getText())) {
|
||||
@@ -404,7 +404,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
final Icon icon = getIcon();
|
||||
int x = 7;
|
||||
if (icon != null) {
|
||||
icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2);
|
||||
icon.paintIcon(this, g, x, (size.height - icon.getIconHeight()) / 2);
|
||||
x += icon.getIconWidth() + 3;
|
||||
}
|
||||
if (!StringUtil.isEmpty(getText())) {
|
||||
|
||||
@@ -29,4 +29,9 @@ public class DefaultIconDeferrer extends IconDeferrer {
|
||||
public <T> Icon defer(final Icon base, final T param, @NotNull final Function<T, Icon> f) {
|
||||
return f.fun(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Icon deferAutoUpdatable(Icon base, T param, @NotNull Function<T, Icon> f) {
|
||||
return f.fun(param);
|
||||
}
|
||||
}
|
||||
@@ -187,10 +187,6 @@ public class MockRunManager extends RunManagerEx {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateConfigurationIcon(@NotNull RunnerAndConfigurationSettings settings) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<RunnerAndConfigurationSettings> getSortedConfigurations() {
|
||||
|
||||
Reference in New Issue
Block a user