From d304b58746ea46b87690caaa43984d163fcc5949 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Thu, 20 May 2010 14:52:37 +0400 Subject: [PATCH 1/4] AppIcon fixed --- .../src/com/intellij/ui/AppIcon.java | 63 ++++++++++--------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/AppIcon.java b/platform/platform-impl/src/com/intellij/ui/AppIcon.java index 8103572dfdc9..94cd52668cd4 100644 --- a/platform/platform-impl/src/com/intellij/ui/AppIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/AppIcon.java @@ -31,9 +31,9 @@ public abstract class AppIcon { static AppIcon ourMacImpl; static AppIcon ourEmptyImpl; - public abstract void setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk); + public abstract boolean setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk); - public abstract void hideProgress(IdeFrame frame, Object processId); + public abstract boolean hideProgress(IdeFrame frame, Object processId); public abstract void setBadge(String text); @@ -60,7 +60,6 @@ public abstract class AppIcon { private Object myCurrentProcessId; - private double myUpdateFraction = 0.05d; private double myLastValue; private BufferedImage getAppImage() { @@ -100,46 +99,43 @@ public abstract class AppIcon { @Override public void requestAttention(boolean critical) { try { - getAppMethod("requestUserAttention", Boolean.class).invoke(getApp(), Boolean.valueOf(critical)); + getAppMethod("requestUserAttention", boolean.class).invoke(getApp(), critical); } catch (NoSuchMethodException e) { return; - } catch (Exception e) { + } + catch (Exception e) { LOG.error(e); } } @Override - public void hideProgress(IdeFrame frame, Object processId) { - if (getAppImage() == null) return; + public boolean hideProgress(IdeFrame frame, Object processId) { + if (getAppImage() == null) return false; + if (myCurrentProcessId != null && !myCurrentProcessId.equals(processId)) return false; - try { - if (myCurrentProcessId != null && myCurrentProcessId.equals(processId)) { - setDockIcon(getAppImage()); - } - } - finally { - myCurrentProcessId = null; - myLastValue = 0; - } + setDockIcon(getAppImage()); + myCurrentProcessId = null; + myLastValue = 0; + + return true; } - public void setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { - if (getAppImage() == null) return; - - if (myCurrentProcessId != null && !myCurrentProcessId.equals(processId)) return; + public boolean setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { + if (getAppImage() == null) return false; + if (myCurrentProcessId != null && !myCurrentProcessId.equals(processId)) return false; myCurrentProcessId = processId; - if (Math.abs(myLastValue - value) < myUpdateFraction) return; + if (Math.abs(myLastValue - value) < 0.01d) return true; try { - int progressHeight = 65; - int xInset = 30; - int yInset = 25; + int progressHeight = 20; + int xInset = 15; + int yInset = 10; int arc = 25; - Rectangle progressRec = new Rectangle(new Point(xInset, myAppImage.getHeight() - yInset - progressHeight), + Rectangle progressRec = new Rectangle(new Point(xInset, myAppImage.getHeight() - progressHeight - yInset), new Dimension(myAppImage.getWidth() - xInset * 2, progressHeight)); BufferedImage current = new BufferedImage(myAppImage.getWidth(), myAppImage.getHeight(), BufferedImage.TYPE_INT_ARGB); @@ -149,13 +145,13 @@ public abstract class AppIcon { g.drawImage(getAppImage(), null, null); g.setColor(Color.black); - g.fillRoundRect(progressRec.x, progressRec.y, progressRec.width, progressRec.height, arc, arc); + g.fillRect(progressRec.x, progressRec.y, progressRec.width, progressRec.height); g.setColor(isOk ? scheme.getOkColor() : scheme.getErrorColor()); int currentWidth = (int)Math.ceil(progressRec.width * value); - g.fillRoundRect(progressRec.x, progressRec.y, currentWidth, progressRec.height, arc, arc); + g.fillRect(progressRec.x, progressRec.y, currentWidth, progressRec.height); setDockIcon(current); @@ -163,9 +159,12 @@ public abstract class AppIcon { } catch (Exception e) { LOG.error(e); - } finally { + } + finally { myCurrentProcessId = null; } + + return true; } private void setDockIcon(BufferedImage image) { @@ -188,16 +187,18 @@ public abstract class AppIcon { private Class getAppClass() throws ClassNotFoundException { return Class.forName("com.apple.eawt.Application"); } - + } private static class EmptyIcon extends AppIcon { @Override - public void setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { + public boolean setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { + return false; } @Override - public void hideProgress(IdeFrame frame, Object processId) { + public boolean hideProgress(IdeFrame frame, Object processId) { + return false; } @Override From e3cd6a55af697c8f7ced11a7ade116565dbfeb50 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Thu, 20 May 2010 14:52:57 +0400 Subject: [PATCH 2/4] junit test runner supports app icon --- .../execution/junit2/ui/TestProgress.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java index 601cffecb9fe..c8d6a308704b 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java @@ -130,12 +130,17 @@ public class TestProgress extends DefaultBoundedRangeModel implements Disposable super.setValue(n); AppIcon icon = AppIcon.getInstance(); if (n < getMaximum()) { - icon.setProgress(null, TESTS, AppIconScheme.Progress.TESTS, (double)n / (double)getMaximum(), myProblemsCounter == 0); + if (icon.setProgress(null, TESTS, AppIconScheme.Progress.TESTS, (double)n / (double)getMaximum(), myProblemsCounter == 0)) { + if (myProblemsCounter > 0) { + icon.setBadge(String.valueOf(myProblemsCounter)); + } + } } else { - icon.hideProgress(null, TESTS); - if (myProblemsCounter > 0) { - icon.setBadge(String.valueOf(myProblemsCounter)); - icon.requestAttention(false); + if (icon.hideProgress(null, TESTS)) { + if (myProblemsCounter > 0) { + icon.setBadge(String.valueOf(myProblemsCounter)); + icon.requestAttention(true); + } } } } From ec8f951dcfeff2edee71dd9c7c7af25be5ba2c08 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Thu, 20 May 2010 15:27:45 +0400 Subject: [PATCH 3/4] compilation supports app icon --- .../compiler/progress/CompilerTask.java | 33 +++++++++++++++++++ .../com/intellij/openapi/progress/Task.java | 9 +++++ .../intellij/openapi/wm}/AppIconScheme.java | 12 ++++++- .../src/com/intellij/ui/AppIcon.java | 9 ++++- .../execution/junit2/ui/TestProgress.java | 2 +- 5 files changed, 62 insertions(+), 3 deletions(-) rename platform/{platform-impl/src/com/intellij/ui => platform-api/src/com/intellij/openapi/wm}/AppIconScheme.java (82%) diff --git a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java index 5112ef7a29dd..79e546a1b1cd 100644 --- a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java +++ b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java @@ -47,12 +47,15 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.openapi.wm.ToolWindowManager; +import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.ex.ProgressIndicatorEx; import com.intellij.peer.PeerFactory; import com.intellij.pom.Navigatable; import com.intellij.problems.WolfTheProblemSolver; +import com.intellij.ui.AppIcon; import com.intellij.ui.content.*; import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; @@ -73,6 +76,7 @@ public class CompilerTask extends Task.Backgroundable { private static final boolean IS_UNIT_TEST_MODE = ApplicationManager.getApplication().isUnitTestMode(); private static final int UPDATE_INTERVAL = 50; //msec. 20 frames per second. private static final Key> CONTENT_ID_KEY = Key.create("CONTENT_ID"); + private static final String APP_ICON_ID = "compiler"; private Key> myContentIdKey = CONTENT_ID_KEY; private final Key> myContentId = Key.create("compile_content"); private CompilerProgressDialog myDialog; @@ -90,12 +94,14 @@ public class CompilerTask extends Task.Backgroundable { private Runnable myCompileWork; private final AtomicBoolean myMessageViewWasPrepared = new AtomicBoolean(false); private Runnable myRestartWork; + private IdeFrame myIdeFrame; public CompilerTask(@NotNull Project project, boolean compileInBackground, String contentName, final boolean headlessMode) { super(project, contentName); myIsBackgroundMode = compileInBackground; myContentName = contentName; myHeadlessMode = headlessMode || IS_UNIT_TEST_MODE; + myIdeFrame = (IdeFrame)WindowManager.getInstance().getFrame(myProject); } public void setContentIdKey(Key> contentIdKey) { @@ -115,6 +121,11 @@ public class CompilerTask extends Task.Backgroundable { return myIsBackgroundMode; } + @Override + public boolean isAppIconProcess() { + return true; + } + public ProgressIndicator getIndicator() { return myIndicator; } @@ -179,6 +190,7 @@ public class CompilerTask extends Task.Backgroundable { public void cancel() { super.cancel(); closeUI(); + stopAppIconProgress(); } public void stop() { @@ -186,6 +198,21 @@ public class CompilerTask extends Task.Backgroundable { if (!isCanceled()) { closeUI(); } + stopAppIconProgress(); + } + + private void stopAppIconProgress() { + if (isAppIconProcess()) { + AppIcon appIcon = AppIcon.getInstance(); + if (appIcon.hideProgress(myIdeFrame, APP_ICON_ID)) { + if (myErrorCount > 0) { + appIcon.setBadge(String.valueOf(myErrorCount)); + appIcon.requestAttention(true); + } else { + appIcon.setBadge(null); + } + } + } } public void setText(final String text) { @@ -198,6 +225,9 @@ public class CompilerTask extends Task.Backgroundable { public void setFraction(final double fraction) { updateProgressText(); + if (isAppIconProcess()) { + AppIcon.getInstance().setProgress(myIdeFrame, APP_ICON_ID, getAppIconScheme(), fraction, true); + } } protected void onProgressChange() { @@ -559,6 +589,9 @@ public class CompilerTask extends Task.Backgroundable { if (myIndicator.isRunning()) { cancel(); } + if (AppIcon.getInstance().hideProgress(myIdeFrame, "compiler")) { + AppIcon.getInstance().setBadge(null); + } } } myContentManager.removeContentManagerListener(this); diff --git a/platform/platform-api/src/com/intellij/openapi/progress/Task.java b/platform/platform-api/src/com/intellij/openapi/progress/Task.java index 18983b7321a3..95b7659ce96c 100644 --- a/platform/platform-api/src/com/intellij/openapi/progress/Task.java +++ b/platform/platform-api/src/com/intellij/openapi/progress/Task.java @@ -19,6 +19,7 @@ import com.intellij.CommonBundle; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.DumbModeAction; +import com.intellij.openapi.wm.AppIconScheme; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -76,6 +77,14 @@ public abstract class Task implements TaskInfo, Progressive { return this; } + public boolean isAppIconProcess() { + return false; + } + + public AppIconScheme.Progress getAppIconScheme() { + return AppIconScheme.Progress.BUILD; + } + public final String getCancelText() { return myCancelText; } diff --git a/platform/platform-impl/src/com/intellij/ui/AppIconScheme.java b/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java similarity index 82% rename from platform/platform-impl/src/com/intellij/ui/AppIconScheme.java rename to platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java index 75e342a8a9a4..0ef08736f3b7 100644 --- a/platform/platform-impl/src/com/intellij/ui/AppIconScheme.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.ui; +package com.intellij.openapi.wm; import java.awt.*; @@ -41,6 +41,16 @@ public class AppIconScheme { } }; + static final Progress INDEXING = new Progress() { + public Color getOkColor() { + return Color.yellow; + } + + public Color getErrorColor() { + return Color.red; + } + }; + Color getOkColor(); Color getErrorColor(); diff --git a/platform/platform-impl/src/com/intellij/ui/AppIcon.java b/platform/platform-impl/src/com/intellij/ui/AppIcon.java index 94cd52668cd4..920a559d2625 100644 --- a/platform/platform-impl/src/com/intellij/ui/AppIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/AppIcon.java @@ -17,6 +17,7 @@ package com.intellij.ui; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.wm.AppIconScheme; import com.intellij.openapi.wm.IdeFrame; import java.awt.*; @@ -133,7 +134,7 @@ public abstract class AppIcon { int progressHeight = 20; int xInset = 15; int yInset = 10; - int arc = 25; + int bound = 2; Rectangle progressRec = new Rectangle(new Point(xInset, myAppImage.getHeight() - progressHeight - yInset), new Dimension(myAppImage.getWidth() - xInset * 2, progressHeight)); @@ -144,6 +145,11 @@ public abstract class AppIcon { g.drawImage(getAppImage(), null, null); + Rectangle bgRec = new Rectangle(progressRec.x - bound, progressRec.y - bound, progressRec.width + bound * 2, progressRec.height + bound * 2); + g.setColor(Color.white); + g.fillRect(bgRec.x, bgRec.y, bgRec.width, bgRec.height); + + g.setColor(Color.black); g.fillRect(progressRec.x, progressRec.y, progressRec.width, progressRec.height); @@ -153,6 +159,7 @@ public abstract class AppIcon { g.fillRect(progressRec.x, progressRec.y, currentWidth, progressRec.height); + setDockIcon(current); myLastValue = value; diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java index c8d6a308704b..b2c4caea4c8e 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java @@ -31,7 +31,7 @@ import com.intellij.rt.execution.junit.states.PoolOfTestStates; import javax.swing.*; import com.intellij.ui.AppIcon; -import com.intellij.ui.AppIconScheme; +import com.intellij.openapi.wm.AppIconScheme; import org.jetbrains.annotations.NonNls; public class TestProgress extends DefaultBoundedRangeModel implements Disposable { From 9a9efb47ff1c46a05f7013b358eb7d3319968358 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Thu, 20 May 2010 16:13:24 +0400 Subject: [PATCH 4/4] app icon - index update --- .../compiler/progress/CompilerTask.java | 32 ++++++------------- .../com/intellij/openapi/progress/Task.java | 9 ------ .../openapi/project/DumbServiceImpl.java | 22 +++++++++++++ .../src/com/intellij/ui/AppIcon.java | 21 +++++++----- .../execution/junit2/ui/TestProgress.java | 6 ++-- 5 files changed, 48 insertions(+), 42 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java index 79e546a1b1cd..32f38b234cf1 100644 --- a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java +++ b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java @@ -47,10 +47,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.wm.IdeFrame; -import com.intellij.openapi.wm.ToolWindowId; -import com.intellij.openapi.wm.ToolWindowManager; -import com.intellij.openapi.wm.WindowManager; +import com.intellij.openapi.wm.*; import com.intellij.openapi.wm.ex.ProgressIndicatorEx; import com.intellij.peer.PeerFactory; import com.intellij.pom.Navigatable; @@ -121,11 +118,6 @@ public class CompilerTask extends Task.Backgroundable { return myIsBackgroundMode; } - @Override - public boolean isAppIconProcess() { - return true; - } - public ProgressIndicator getIndicator() { return myIndicator; } @@ -202,15 +194,13 @@ public class CompilerTask extends Task.Backgroundable { } private void stopAppIconProgress() { - if (isAppIconProcess()) { - AppIcon appIcon = AppIcon.getInstance(); - if (appIcon.hideProgress(myIdeFrame, APP_ICON_ID)) { - if (myErrorCount > 0) { - appIcon.setBadge(String.valueOf(myErrorCount)); - appIcon.requestAttention(true); - } else { - appIcon.setBadge(null); - } + AppIcon appIcon = AppIcon.getInstance(); + if (appIcon.hideProgress(APP_ICON_ID)) { + if (myErrorCount > 0) { + appIcon.setBadge(String.valueOf(myErrorCount)); + appIcon.requestAttention(true); + } else { + appIcon.setBadge(null); } } } @@ -225,9 +215,7 @@ public class CompilerTask extends Task.Backgroundable { public void setFraction(final double fraction) { updateProgressText(); - if (isAppIconProcess()) { - AppIcon.getInstance().setProgress(myIdeFrame, APP_ICON_ID, getAppIconScheme(), fraction, true); - } + AppIcon.getInstance().setProgress(APP_ICON_ID, AppIconScheme.Progress.BUILD, fraction, true); } protected void onProgressChange() { @@ -589,7 +577,7 @@ public class CompilerTask extends Task.Backgroundable { if (myIndicator.isRunning()) { cancel(); } - if (AppIcon.getInstance().hideProgress(myIdeFrame, "compiler")) { + if (AppIcon.getInstance().hideProgress("compiler")) { AppIcon.getInstance().setBadge(null); } } diff --git a/platform/platform-api/src/com/intellij/openapi/progress/Task.java b/platform/platform-api/src/com/intellij/openapi/progress/Task.java index 95b7659ce96c..18983b7321a3 100644 --- a/platform/platform-api/src/com/intellij/openapi/progress/Task.java +++ b/platform/platform-api/src/com/intellij/openapi/progress/Task.java @@ -19,7 +19,6 @@ import com.intellij.CommonBundle; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.DumbModeAction; -import com.intellij.openapi.wm.AppIconScheme; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -77,14 +76,6 @@ public abstract class Task implements TaskInfo, Progressive { return this; } - public boolean isAppIconProcess() { - return false; - } - - public AppIconScheme.Progress getAppIconScheme() { - return AppIconScheme.Progress.BUILD; - } - public final String getCancelText() { return myCancelText; } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index 7fae9a276158..6919f5aa4359 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -22,13 +22,17 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.*; +import com.intellij.openapi.progress.util.ProgressIndicatorBase; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.popup.BalloonHandler; import com.intellij.openapi.util.Ref; +import com.intellij.openapi.wm.AppIconScheme; import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; +import com.intellij.openapi.wm.ex.ProgressIndicatorEx; import com.intellij.openapi.wm.ex.StatusBarEx; +import com.intellij.ui.AppIcon; import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.Queue; import com.intellij.util.io.storage.HeavyProcessLatch; @@ -264,6 +268,24 @@ public class DumbServiceImpl extends DumbService { // /*no override for interfaces in jdk 1.5 */ @Override public void run(@NotNull final ProgressIndicator indicator) { + if (indicator instanceof ProgressIndicatorEx) { + ((ProgressIndicatorEx)indicator).addStateDelegate(new ProgressIndicatorBase() { + @Override + public void setFraction(double fraction) { + AppIcon.getInstance().setProgress("indexUpdate", AppIconScheme.Progress.INDEXING, fraction, true); + } + + @Override + public void finish(@NotNull TaskInfo task) { + AppIcon appIcon = AppIcon.getInstance(); + if (appIcon.hideProgress("indexUpdate")) { + appIcon.requestAttention(false); + } + } + }); + } + + final ProgressIndicator proxy = (ProgressIndicator)Proxy.newProxyInstance(indicator.getClass().getClassLoader(), new Class[]{ProgressIndicator.class}, new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { diff --git a/platform/platform-impl/src/com/intellij/ui/AppIcon.java b/platform/platform-impl/src/com/intellij/ui/AppIcon.java index 920a559d2625..9881e73cd5ab 100644 --- a/platform/platform-impl/src/com/intellij/ui/AppIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/AppIcon.java @@ -18,7 +18,6 @@ package com.intellij.ui; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.AppIconScheme; -import com.intellij.openapi.wm.IdeFrame; import java.awt.*; import java.awt.image.BufferedImage; @@ -32,9 +31,9 @@ public abstract class AppIcon { static AppIcon ourMacImpl; static AppIcon ourEmptyImpl; - public abstract boolean setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk); + public abstract boolean setProgress(Object processId, AppIconScheme.Progress scheme, double value, boolean isOk); - public abstract boolean hideProgress(IdeFrame frame, Object processId); + public abstract boolean hideProgress(Object processId); public abstract void setBadge(String text); @@ -80,6 +79,9 @@ public abstract class AppIcon { myAppImage = img; } + catch (NoSuchMethodException e) { + return null; + } catch (Exception e) { LOG.error(e); } @@ -92,6 +94,9 @@ public abstract class AppIcon { try { getAppMethod("setDockIconBadge", String.class).invoke(getApp(), text); } + catch (NoSuchMethodException e) { + return; + } catch (Exception e) { LOG.error(e); } @@ -111,7 +116,7 @@ public abstract class AppIcon { } @Override - public boolean hideProgress(IdeFrame frame, Object processId) { + public boolean hideProgress(Object processId) { if (getAppImage() == null) return false; if (myCurrentProcessId != null && !myCurrentProcessId.equals(processId)) return false; @@ -122,13 +127,13 @@ public abstract class AppIcon { return true; } - public boolean setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { + public boolean setProgress(Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { if (getAppImage() == null) return false; if (myCurrentProcessId != null && !myCurrentProcessId.equals(processId)) return false; myCurrentProcessId = processId; - if (Math.abs(myLastValue - value) < 0.01d) return true; + if (Math.abs(myLastValue - value) < 0.02d) return true; try { int progressHeight = 20; @@ -199,12 +204,12 @@ public abstract class AppIcon { private static class EmptyIcon extends AppIcon { @Override - public boolean setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { + public boolean setProgress(Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { return false; } @Override - public boolean hideProgress(IdeFrame frame, Object processId) { + public boolean hideProgress(Object processId) { return false; } diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java index b2c4caea4c8e..1af61f70b080 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/TestProgress.java @@ -130,13 +130,13 @@ public class TestProgress extends DefaultBoundedRangeModel implements Disposable super.setValue(n); AppIcon icon = AppIcon.getInstance(); if (n < getMaximum()) { - if (icon.setProgress(null, TESTS, AppIconScheme.Progress.TESTS, (double)n / (double)getMaximum(), myProblemsCounter == 0)) { + if (icon.setProgress(TESTS, AppIconScheme.Progress.TESTS, (double)n / (double)getMaximum(), myProblemsCounter == 0)) { if (myProblemsCounter > 0) { icon.setBadge(String.valueOf(myProblemsCounter)); } } } else { - if (icon.hideProgress(null, TESTS)) { + if (icon.hideProgress(TESTS)) { if (myProblemsCounter > 0) { icon.setBadge(String.valueOf(myProblemsCounter)); icon.requestAttention(true); @@ -146,7 +146,7 @@ public class TestProgress extends DefaultBoundedRangeModel implements Disposable } public void dispose() { - AppIcon.getInstance().hideProgress(null, TESTS); + AppIcon.getInstance().hideProgress(TESTS); AppIcon.getInstance().setBadge(null); } }