mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Allow to use AnimatedIcon in TestTree
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.CellRendererPane;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.Timer;
|
||||
import java.awt.Component;
|
||||
@@ -19,6 +22,17 @@ import static java.util.Arrays.asList;
|
||||
* @author Sergey.Malenkov
|
||||
*/
|
||||
public class AnimatedIcon implements Icon {
|
||||
/**
|
||||
* This key is used to allow animated icons in lists, tables and trees.
|
||||
* If the corresponding client property is set to {@code true} the corresponding component
|
||||
* will be automatically repainted to update an animated icon painted by the renderer of the component.
|
||||
* Note, that animation may cause a performance problems and should not be used everywhere.
|
||||
*
|
||||
* @see UIUtil#putClientProperty
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static final Key<Boolean> ANIMATION_IN_RENDERER_ALLOWED = Key.create("ANIMATION_IN_RENDERER_ALLOWED");
|
||||
|
||||
public interface Frame {
|
||||
@NotNull
|
||||
Icon getIcon();
|
||||
@@ -238,7 +252,8 @@ public class AnimatedIcon implements Icon {
|
||||
@Override
|
||||
public final void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
Icon icon = getUpdatedIcon();
|
||||
requestRefresh(c);
|
||||
CellRendererPane pane = UIUtil.getParentOfType(CellRendererPane.class, c);
|
||||
requestRefresh(pane == null ? c : getRendererOwner(pane.getParent()));
|
||||
icon.paintIcon(c, g, x, y);
|
||||
}
|
||||
|
||||
@@ -259,4 +274,8 @@ public class AnimatedIcon implements Icon {
|
||||
protected void doRefresh(Component component) {
|
||||
if (component != null) component.repaint();
|
||||
}
|
||||
|
||||
protected Component getRendererOwner(Component component) {
|
||||
return UIUtil.isClientPropertyTrue(component, ANIMATION_IN_RENDERER_ALLOWED) ? component : null;
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -18,6 +18,7 @@ package com.intellij.execution.testframework.sm.runner.ui;
|
||||
import com.intellij.execution.testframework.PoolOfTestIcons;
|
||||
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ui.AnimatedIcon;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -36,7 +37,11 @@ public class SMPoolOfTestIcons implements PoolOfTestIcons {
|
||||
public static final Icon IGNORED_E_ICON = addErrorMarkTo(IGNORED_ICON);
|
||||
|
||||
// Test Progress
|
||||
public static final Icon RUNNING_ICON = new AnimatedIcon.Default();
|
||||
public static final Icon RUNNING_E_ICON = addErrorMarkTo(RUNNING_ICON);
|
||||
public static final Icon PAUSED_E_ICON = addErrorMarkTo(AllIcons.RunConfigurations.TestPaused);
|
||||
@Deprecated
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
public static final Icon[] FRAMES_E = new Icon[TestsProgressAnimator.FRAMES.length];
|
||||
static {
|
||||
for (int i = 0, length = FRAMES_E.length; i < length; i++){
|
||||
|
||||
-10
@@ -30,7 +30,6 @@ import com.intellij.execution.testframework.sm.runner.*;
|
||||
import com.intellij.execution.testframework.sm.runner.history.ImportedTestConsoleProperties;
|
||||
import com.intellij.execution.testframework.sm.runner.history.actions.AbstractImportTestsAction;
|
||||
import com.intellij.execution.testframework.ui.TestResultsPanel;
|
||||
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.util.treeView.IndexComparator;
|
||||
@@ -97,8 +96,6 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
|
||||
|
||||
private SMTRunnerTestTreeView myTreeView;
|
||||
|
||||
private TestsProgressAnimator myAnimator;
|
||||
|
||||
/**
|
||||
* Fake parent suite for all tests and suites
|
||||
*/
|
||||
@@ -177,8 +174,6 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
|
||||
Disposer.register(this, myTreeBuilder);
|
||||
Disposer.register(this, asyncTreeModel);
|
||||
|
||||
myAnimator = new TestsProgressAnimator(myTreeBuilder);
|
||||
|
||||
TrackRunningTestUtil.installStopListeners(myTreeView, myProperties, new Pass<AbstractTestProxy>() {
|
||||
@Override
|
||||
public void pass(AbstractTestProxy testProxy) {
|
||||
@@ -238,7 +233,6 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
|
||||
myLastSelected = null;
|
||||
myMentionedCategories.clear();
|
||||
|
||||
myAnimator.setCurrentTestCase(myTestsRootNode);
|
||||
if (myEndTime != 0) { // no need to reset when running for the first time
|
||||
resetTreeAndConsoleOnSubsequentTestingStarted();
|
||||
myEndTime = 0;
|
||||
@@ -291,8 +285,6 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
|
||||
updateStatusLabel(true);
|
||||
updateIconProgress(true);
|
||||
|
||||
myAnimator.stopMovie();
|
||||
|
||||
myRequests.clear();
|
||||
myUpdateTreeRequests.cancelAllRequests();
|
||||
myTreeBuilder.updateFromRoot();
|
||||
@@ -612,8 +604,6 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
|
||||
myUpdateTreeRequests.addRequest(update, 50);
|
||||
}
|
||||
|
||||
myAnimator.setCurrentTestCase(newTestOrSuite);
|
||||
|
||||
if (TestConsoleProperties.TRACK_RUNNING_TEST.value(myProperties)) {
|
||||
if (myLastSelected == null || myLastSelected == newTestOrSuite) {
|
||||
myLastSelected = null;
|
||||
|
||||
+1
-3
@@ -20,7 +20,6 @@ import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.sm.SMTestsRunnerBundle;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.testframework.sm.runner.states.TestStateInfo;
|
||||
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
@@ -282,8 +281,7 @@ public class TestsPresentationUtil {
|
||||
return hasErrors ? PAUSED_E_ICON : AllIcons.RunConfigurations.TestPaused;
|
||||
}
|
||||
else {
|
||||
final int frameIndex = TestsProgressAnimator.getCurrentFrameIndex();
|
||||
return hasErrors ? FRAMES_E[frameIndex] : TestsProgressAnimator.FRAMES[frameIndex];
|
||||
return hasErrors ? RUNNING_E_ICON : RUNNING_ICON;
|
||||
}
|
||||
case SKIPPED_INDEX:
|
||||
return hasErrors ? SKIPPED_E_ICON : SKIPPED_ICON;
|
||||
|
||||
+1
-6
@@ -22,7 +22,6 @@ import com.intellij.execution.testframework.sm.UITestUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.BaseSMTRunnerTestCase;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -731,11 +730,7 @@ public class TestsPresentationUtilTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
private static void assertIsAnimatorProgressIcon(final Icon icon) {
|
||||
for (Icon frame : TestsProgressAnimator.FRAMES) {
|
||||
if (icon == frame) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (icon == SMPoolOfTestIcons.RUNNING_ICON) return;
|
||||
|
||||
fail("Icon isn't an Animator progress frame");
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ public abstract class TestTreeView extends Tree implements DataProvider, CopyPro
|
||||
});
|
||||
installHandlers();
|
||||
setCellRenderer(getRenderer(myModel.getProperties()));
|
||||
putClientProperty(AnimatedIcon.ANIMATION_IN_RENDERER_ALLOWED, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@Deprecated
|
||||
public class TestsProgressAnimator implements Runnable, Disposable {
|
||||
private static final int FRAMES_COUNT = 8;
|
||||
private static final int MOVIE_TIME = 800;
|
||||
|
||||
@@ -17,6 +17,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
@Deprecated
|
||||
public class NodeProgressAnimator implements Runnable, Disposable {
|
||||
private static final int FRAMES_COUNT = 8;
|
||||
private static final int MOVIE_TIME = 800;
|
||||
|
||||
Reference in New Issue
Block a user