From 9e06f0c46f440425f6570245ed174fb653fb6d6e Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 16 Oct 2009 17:34:32 +0400 Subject: [PATCH 01/10] IDEADEV-40832 --- .../daemon/impl/ShowIntentionsPass.java | 39 +--------- .../intention/impl/IntentionListStep.java | 73 ++++++++++--------- .../impl/ShowIntentionActionsHandler.java | 46 ++++++++++-- 3 files changed, 83 insertions(+), 75 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java index b69e1672cbbb..82aeb3423aaa 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java @@ -23,15 +23,14 @@ import com.intellij.codeInsight.hint.HintManager; import com.intellij.codeInsight.intention.AbstractIntentionAction; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.IntentionManager; -import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; import com.intellij.codeInsight.intention.impl.IntentionHintComponent; +import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler; import com.intellij.codeInsight.intention.impl.config.IntentionManagerSettings; import com.intellij.codeInsight.lookup.LookupManager; import com.intellij.codeInsight.template.impl.TemplateManagerImpl; import com.intellij.codeInsight.template.impl.TemplateState; import com.intellij.ide.DataManager; import com.intellij.lang.annotation.HighlightSeverity; -import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -44,14 +43,13 @@ import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.JBPopupFactory; +import com.intellij.openapi.util.Pair; import com.intellij.psi.IntentionFilterOwner; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; @@ -188,27 +186,13 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass { public static void getActionsToShow(@NotNull final Editor editor, @NotNull final PsiFile psiFile, @NotNull IntentionsInfo intentions, int passIdToShowIntentionsFor) { final PsiElement psiElement = psiFile.findElementAt(editor.getCaretModel().getOffset()); LOG.assertTrue(psiElement == null || psiElement.isValid(), psiElement); - final boolean isInProject = psiFile.getManager().isInProject(psiFile); int offset = editor.getCaretModel().getOffset(); Project project = psiFile.getProject(); - PsiElement injected = InjectedLanguageManager.getInstance(project).findInjectedElementAt(psiFile, offset); - PsiFile injectedFile; - Editor injectedEditor; - if (injected != null) { - injectedFile = injected.getContainingFile(); - injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile); - } - else { - injectedFile = null; - injectedEditor = null; - } - for (IntentionAction action : IntentionManager.getInstance().getIntentionActions()) { - if (injectedFile != null && isAvailableHere(injectedEditor, injectedFile, injected, isInProject, project, action) || - isAvailableHere(editor, psiFile, psiElement, isInProject, project, action) - ) { + Pair place = ShowIntentionActionsHandler.availableFor(psiFile, editor, action, psiElement); + if (place != null) { List enableDisableIntentionAction = new ArrayList(); enableDisableIntentionAction.add(new IntentionHintComponent.EnableDisableIntentionAction(action)); intentions.intentionsToShow.add(new HighlightInfo.IntentionActionDescriptor(action, enableDisableIntentionAction, null)); @@ -256,19 +240,4 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass { } } - private static boolean isAvailableHere(Editor editor, PsiFile psiFile, PsiElement psiElement, boolean inProject, Project project, - IntentionAction action) { - try { - if (action instanceof PsiElementBaseIntentionAction) { - if (!inProject || !((PsiElementBaseIntentionAction)action).isAvailable(project, editor, psiElement)) return false; - } - else if (!action.isAvailable(project, editor, psiFile)) { - return false; - } - } - catch (IndexNotReadyException e) { - return false; - } - return true; - } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java index 73ac167c645e..7d25cc3b1d59 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionListStep.java @@ -29,6 +29,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.*; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Iconable; +import com.intellij.openapi.util.Pair; import com.intellij.psi.*; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.util.PsiUtilBase; @@ -83,52 +84,56 @@ class IntentionListStep implements ListPopupStep private boolean wrapActionsTo(final List descriptors, final Set cachedActions) { boolean result = true; - for (HighlightInfo.IntentionActionDescriptor descriptor : descriptors) { - IntentionAction action = descriptor.getAction(); - IntentionActionWithTextCaching cachedAction = new IntentionActionWithTextCaching(action, descriptor.getDisplayName(), descriptor.getIcon()); - result &= !cachedActions.add(cachedAction); - final int caretOffset = myEditor.getCaretModel().getOffset(); - final int fileOffset = caretOffset > 0 && caretOffset == myFile.getTextLength() ? caretOffset - 1 : caretOffset; - PsiElement element; - if (myFile instanceof PsiCompiledElement) { - element = myFile; - } - else if (PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument())) { - //??? - FileViewProvider viewProvider = myFile.getViewProvider(); - element = viewProvider.findElementAt(fileOffset, viewProvider.getBaseLanguage()); - } - else { - element = InjectedLanguageUtil.findElementAtNoCommit(myFile, fileOffset); - } - final List options; - if (element != null && (options = descriptor.getOptions(element)) != null) { - for (IntentionAction option : options) { - boolean isErrorFix = myCachedErrorFixes.contains(new IntentionActionWithTextCaching(option, option.getText())); - if (isErrorFix) { - cachedAction.addErrorFix(option); - } - boolean isInspectionFix = myCachedInspectionFixes.contains(new IntentionActionWithTextCaching(option, option.getText())); - if (isInspectionFix) { - cachedAction.addInspectionFix(option); - } - else { - cachedAction.addIntention(option); + final int caretOffset = myEditor.getCaretModel().getOffset(); + final int fileOffset = caretOffset > 0 && caretOffset == myFile.getTextLength() ? caretOffset - 1 : caretOffset; + PsiElement element; + if (myFile instanceof PsiCompiledElement) { + element = myFile; + } + else if (PsiDocumentManager.getInstance(myProject).isUncommited(myEditor.getDocument())) { + //??? + FileViewProvider viewProvider = myFile.getViewProvider(); + element = viewProvider.findElementAt(fileOffset, viewProvider.getBaseLanguage()); + } + else { + element = InjectedLanguageUtil.findElementAtNoCommit(myFile, fileOffset); + } + if (!descriptors.isEmpty()) { + + for (HighlightInfo.IntentionActionDescriptor descriptor : descriptors) { + IntentionAction action = descriptor.getAction(); + IntentionActionWithTextCaching cachedAction = new IntentionActionWithTextCaching(action, descriptor.getDisplayName(), descriptor.getIcon()); + result &= !cachedActions.add(cachedAction); + final List options; + if (element != null && (options = descriptor.getOptions(element)) != null) { + for (IntentionAction option : options) { + boolean isErrorFix = myCachedErrorFixes.contains(new IntentionActionWithTextCaching(option, option.getText())); + if (isErrorFix) { + cachedAction.addErrorFix(option); + } + boolean isInspectionFix = myCachedInspectionFixes.contains(new IntentionActionWithTextCaching(option, option.getText())); + if (isInspectionFix) { + cachedAction.addInspectionFix(option); + } + else { + cachedAction.addIntention(option); + } } } } } - result &= removeInvalidActions(cachedActions); + result &= removeInvalidActions(cachedActions, element); return result; } - private boolean removeInvalidActions(final Collection cachedActions) { + private boolean removeInvalidActions(final Collection cachedActions, final PsiElement element) { boolean result = true; Iterator iterator = cachedActions.iterator(); while (iterator.hasNext()) { IntentionActionWithTextCaching cachedAction = iterator.next(); IntentionAction action = cachedAction.getAction(); - if (!myFile.isValid() || !action.isAvailable(myProject, myEditor, myFile)) { + Pair place = ShowIntentionActionsHandler.availableFor(myFile, myEditor, action, element); + if (place == null) { iterator.remove(); result = false; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java index df1c94197e6b..f20747b27c14 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/ShowIntentionActionsHandler.java @@ -39,6 +39,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; +import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; @@ -50,6 +51,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -142,7 +144,10 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler { return false; } - public static void chooseActionAndInvoke(PsiFile file, final Editor editor, final IntentionAction action, final String text) { + // returns editor,file where the action is available or null if there are none + @Nullable + public static Pair availableFor(PsiFile file, final Editor editor, final IntentionAction action, final PsiElement element) { + if (!file.isValid()) return null; final Project project = file.getProject(); final Editor editorToApply; @@ -150,29 +155,58 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler { int offset = editor.getCaretModel().getOffset(); PsiElement injected = InjectedLanguageManager.getInstance(project).findInjectedElementAt(file, offset); + boolean inProject = file.getManager().isInProject(file); if (injected != null) { PsiFile injectedFile = injected.getContainingFile(); Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile); - if (action.isAvailable(project, injectedEditor, injectedFile)) { + if (isAvailableHere(injectedEditor, injectedFile, injected, inProject, action)) { editorToApply = injectedEditor; fileToApply = injectedFile; } - else if (!action.isAvailable(project, editor, file)) { - return; + else if (!isAvailableHere(editor, file, element, inProject, action)) { + return null; } else { editorToApply = editor; fileToApply = file; } } - else if (!action.isAvailable(project, editor, file)) { - return; + else if (!isAvailableHere(editor, file, element, inProject, action)) { + return null; } else { editorToApply = editor; fileToApply = file; } + return Pair.create(fileToApply, editorToApply); + } + + private static boolean isAvailableHere(Editor editor, PsiFile psiFile, PsiElement psiElement, boolean inProject, IntentionAction action) { + try { + Project project = psiFile.getProject(); + if (action instanceof PsiElementBaseIntentionAction) { + if (!inProject || !((PsiElementBaseIntentionAction)action).isAvailable(project, editor, psiElement)) return false; + } + else if (!action.isAvailable(project, editor, psiFile)) { + return false; + } + } + catch (IndexNotReadyException e) { + return false; + } + return true; + } + + public static void chooseActionAndInvoke(PsiFile file, final Editor editor, final IntentionAction action, final String text) { + final Project project = file.getProject(); + + int offset = editor.getCaretModel().getOffset(); + PsiElement element = file.findElementAt(offset); + Pair pair = availableFor(file, editor, action, element); + if (pair == null) return; + final Editor editorToApply = pair.second; + final PsiFile fileToApply = pair.first; Runnable runnable = new Runnable() { public void run() { From c91033f021b1ff445c951e0e07b963b9c22458f7 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 16 Oct 2009 17:44:19 +0400 Subject: [PATCH 02/10] remove sources, attached out of the project root --- plugins/maven/maven.iml | 42 +---------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/plugins/maven/maven.iml b/plugins/maven/maven.iml index 401bac01486b..084702bf62a3 100644 --- a/plugins/maven/maven.iml +++ b/plugins/maven/maven.iml @@ -25,47 +25,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + From 11229da89314a4fea12b0c31aa47216aba17347d Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Oct 2009 17:47:35 +0400 Subject: [PATCH 03/10] memory leak fixed (part of IDEADEV-40877) --- .../moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java index adcd4da4db83..bb5dede39a82 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/move/moveFilesOrDirectories/MoveFilesOrDirectoriesDialog.java @@ -24,6 +24,7 @@ import com.intellij.openapi.help.HelpManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; +import com.intellij.openapi.util.Disposer; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -96,6 +97,7 @@ public class MoveFilesOrDirectoriesDialog extends DialogWrapper{ validateOKButton(); } }); + Disposer.register(getDisposable(), myTargetDirectoryField); return panel; } From 05de29c9fbbc2e032aa7fc15f5cb659ecc02f707 Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Fri, 16 Oct 2009 18:12:20 +0400 Subject: [PATCH 04/10] notifications statusbar icons --- .../icons/src/ide/error_notifications.png | Bin 0 -> 646 bytes platform/icons/src/ide/info_notifications.png | Bin 0 -> 533 bytes platform/icons/src/ide/read_notifications.png | Bin 381 -> 423 bytes .../icons/src/ide/unread_notifications.png | Bin 368 -> 0 bytes .../icons/src/ide/warning_notifications.png | Bin 0 -> 619 bytes .../notification/impl/NotificationModel.java | 23 ++++++++++++++++- .../impl/NotificationsManagerImpl.java | 5 ++++ .../impl/ui/NotificationComponent.java | 24 +++++++++++++----- 8 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 platform/icons/src/ide/error_notifications.png create mode 100644 platform/icons/src/ide/info_notifications.png delete mode 100644 platform/icons/src/ide/unread_notifications.png create mode 100644 platform/icons/src/ide/warning_notifications.png diff --git a/platform/icons/src/ide/error_notifications.png b/platform/icons/src/ide/error_notifications.png new file mode 100644 index 0000000000000000000000000000000000000000..ef68f6af420910f1a483cc045eee3b917f151961 GIT binary patch literal 646 zcmV;10(t$3P)| zP4rkS)QhotX+@~pV(_3s!CS$A2ZIO&!KzsCAS5Sy^4LRr%E1a&JXsGyRq7#!1~wMN zHfF5}Xx+_bcYL$EiAnKL=)ms0_h#Ok?|t(PUm zd|T-sa?PGIH||5dIRp3k(^M&cC-nw>*GB#7L>Gw>XLz-co2F^Hbdue5IUXI?X+y0V ztf|`-2p>*$V2fcA|3z>$J43Wzo>F>Goaa^;{JIVlKf&K92JRus`0T+ zU=I+4wuleT;jE3|otDHVN5-3KwsrhQ{%xwbTbgQ5vXf7iG(0W)5wv;b#V(d zZks(ve_DuB@DI%!4PagED~_T%Podi#Erf7hFXppic1Q<~&;hZ%y7u0v53sflM6%F9 z*Dd(q=2;_?XsJ;T_zgDAMqk$udt=Nu+XbARW{>OU z5lA&6yWs7gk3iesFueTz0gnODKy(W)Yyz_VfzbkY!GZTz7!I7ufLj97$_O=q3E8w= zEBot!uF&7LqF*0oQ>2(3!+)Qv3{m0^sJ>@Jasd-848jZhfs_++7`*%Q8BD+Z{Sh@f zp{{0uupyk?t0ok}6__giXZY}kVJE{;2F7Db7`|tOdI@a6KZgJJY`ilRQBosPVnGKs z-kFO382{aa8vx1}?A&Ytu3-gAV5b2C5uAzsqk8#2)B*pQ{@?rY<<|yCU{aW!0RjvF Xg3GSsRi?bQ00000NkvXXu0mjfT^Z%0;dCzNq3AA_os^0Fc?w1QK9kU{)el zGYA~rHvK*m1CtU&FW6~hgu{QNFo0=y4K3&Z@;n)s7#aTm1AiLKh)~anP`6?CstNTd zfd~V;R`pi^sR}}tGp?Ed4`dVr+`NiR zDJPID*xRUnhhSN>9XX&;0udNJg+wOEC~(6pEapK(;gf2WF;U8=$F}vg`~HU;sGgbia4KW?KvXQ?1pgVH{%814gaM2=eemr6e?}a^Lxc-}YF;wpHXLC9E=O)%(tQ}L zcxexQFW?G7@92^ssO&mi(ZGZ^4j372fljr>E{EiTzyJT;v+>SUL{E*|mi824(+g7j zpYh*4xB)-E{WjUa#>Eog8d{(Pa~CL-8DYVV7LvfI1!pF(LnzJ8009O7+yi0pIi4e^ P00000NkvXXu0mjf=~9vv diff --git a/platform/icons/src/ide/unread_notifications.png b/platform/icons/src/ide/unread_notifications.png deleted file mode 100644 index 022bb1b3e8d1a4dc6ecb95c171b2d2aa7e4e0b63..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 368 zcmV-$0gwKPP)bA%zh@2022eV5?0NtG~&S+4IJGz{XWRGa4#_64u@PQy%1dj<{c*d zj%CCt^B*}7afAP_@fm{T1)MIpjZ^YJvH`d)xrftjjKq225uwmw!RLc#Hv86rXel7X z>jg#}(I|DqDG$n=gv$v`1fnYtC>My&lVAh>G5)(}b?IkuQ4)W`1?Q8|9d~a{MrEZK4sY%Aiw~A%Um9jPxp5K O0000Y;KzXQ3EnWLYRT!>vx7sSQcPGHemOv356g!&y3;E^@j}b zB;w!#Ogxtv5WxkE1R(1U+ filterNotifications(@NotNull PairFunction filter) { final LinkedList result = new LinkedList(); - final HashSet>> entries = new HashSet>>(myNotifications.entrySet()); + final HashSet>> entries = + new HashSet>>(myNotifications.entrySet()); for (final Map.Entry> entry : entries) { if (filter.fun(entry.getKey(), entry.getValue().first)) { result.addFirst(entry.getKey()); @@ -183,4 +184,24 @@ public class NotificationModel { public boolean hasRead(PairFunction filter) { return getUnreadCount(filter) < myNotifications.size(); } + + @Nullable + public NotificationType getMaximumType(PairFunction filter) { + final LinkedList notifications = filterNotifications(filter); + NotificationType result = null; + for (Notification notification : notifications) { + if (NotificationType.ERROR == notification.getType()) { + return NotificationType.ERROR; + } + + if (NotificationType.WARNING == notification.getType()) { + result = NotificationType.WARNING; + } + else if (result == null && NotificationType.INFORMATION == notification.getType()) { + result = NotificationType.INFORMATION; + } + } + + return result; + } } diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java index ac076e5ece21..5130a80723d7 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java @@ -268,6 +268,11 @@ public class NotificationsManagerImpl extends NotificationsManager implements No return myModel.getByType(type, createFilter(project, false)); } + @Nullable + public NotificationType getMaximumType(@Nullable final Project project) { + return myModel.getMaximumType(createFilter(project, false)); + } + public boolean hasUnread(@Nullable final Project project) { return myModel.hasUnread(createFilter(project, false)); } diff --git a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationComponent.java b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationComponent.java index c876faf73e14..29aaf0aadd1e 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationComponent.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationComponent.java @@ -17,6 +17,7 @@ package com.intellij.notification.impl.ui; import com.intellij.concurrency.JobScheduler; import com.intellij.notification.Notification; +import com.intellij.notification.NotificationType; import com.intellij.notification.impl.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.JBPopup; @@ -39,7 +40,9 @@ import java.util.concurrent.TimeUnit; public class NotificationComponent extends JLabel implements NotificationModelListener { private static final Icon EMPTY_ICON = IconLoader.getIcon("/ide/notifications.png"); private static final Icon READ_ICON = IconLoader.getIcon("/ide/read_notifications.png"); - private static final Icon UNREAD_ICON = IconLoader.getIcon("/ide/unread_notifications.png"); + private static final Icon ERROR_ICON = IconLoader.getIcon("/ide/error_notifications.png"); + private static final Icon WARNING_ICON = IconLoader.getIcon("/ide/warning_notifications.png"); + private static final Icon INFO_ICON = IconLoader.getIcon("/ide/info_notifications.png"); private WeakReference myPopupRef; @@ -112,11 +115,20 @@ public class NotificationComponent extends JLabel implements NotificationModelLi final NotificationsManagerImpl manager = getManager(); Icon icon = EMPTY_ICON; - if (manager.hasUnread(getProject())) { - icon = UNREAD_ICON; - } - else if (manager.hasRead(getProject())) { - icon = READ_ICON; + final NotificationType maximumType = manager.getMaximumType(getProject()); + if (maximumType != null) { + switch (maximumType) { + case WARNING: + icon = WARNING_ICON; + break; + case ERROR: + icon = ERROR_ICON; + break; + case INFORMATION: + default: + icon = INFO_ICON; + break; + } } myCurrentIcon = new BlinkIconWrapper(icon, false); From af87d8034ee185cf3d02e1ed97da6640d84d99b1 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 16 Oct 2009 18:34:17 +0400 Subject: [PATCH 05/10] wait for smart mode before searching annotations --- .../compiler/AnnotationBasedInstrumentingCompiler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/AnnotationBasedInstrumentingCompiler.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/AnnotationBasedInstrumentingCompiler.java index e228fa426636..390375f727c8 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/AnnotationBasedInstrumentingCompiler.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/pattern/compiler/AnnotationBasedInstrumentingCompiler.java @@ -23,6 +23,7 @@ import com.intellij.openapi.compiler.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.CompilerModuleExtension; @@ -65,6 +66,9 @@ public abstract class AnnotationBasedInstrumentingCompiler implements ClassInstr final Project project = context.getProject(); final Set result = new HashSet(); final PsiSearchHelper searchHelper = PsiManager.getInstance(context.getProject()).getSearchHelper(); + + DumbService.getInstance(project).waitForSmartMode(); + ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { final String[] names = getAnnotationNames(project); From b14a21b4b7540264a926fc13853c6137f08c07f7 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Oct 2009 17:54:10 +0400 Subject: [PATCH 06/10] one more memory leak fixed (part of IDEADEV-40877) --- .../com/intellij/openapi/project/impl/ProjectManagerImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java index 749e8d94e0c3..86c290934d02 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java @@ -884,6 +884,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt fireProjectClosing(project); myOpenProjects.remove(project); + myChangedProjectFiles.remove(project); fireProjectClosed(project); if (save) { From 9d1df38d9191e454e7c9a31884c5c3b28f8dbebe Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Oct 2009 18:44:09 +0400 Subject: [PATCH 07/10] copyrights in native sources --- .../VistaUpdaterLauncher.cpp | 17 ++++++++-- native/breakgen/AppMain.c | 15 +++++++++ native/fileWatcher/ReadMe.txt | 33 ------------------- native/fileWatcher/fileWatcher3.cpp | 17 ++++++++-- native/fsNotifier/mac/fsnotifier.c | 16 +++++++++ native/restarter/ReadMe.txt | 33 ------------------- native/restarter/restarter.cpp | 17 ++++++++-- 7 files changed, 76 insertions(+), 72 deletions(-) delete mode 100644 native/fileWatcher/ReadMe.txt delete mode 100644 native/restarter/ReadMe.txt diff --git a/native/VistaUpdaterLauncher/VistaUpdaterLauncher/VistaUpdaterLauncher.cpp b/native/VistaUpdaterLauncher/VistaUpdaterLauncher/VistaUpdaterLauncher.cpp index bd14d4d4163e..dd2e41980873 100644 --- a/native/VistaUpdaterLauncher/VistaUpdaterLauncher/VistaUpdaterLauncher.cpp +++ b/native/VistaUpdaterLauncher/VistaUpdaterLauncher/VistaUpdaterLauncher.cpp @@ -1,5 +1,18 @@ -// VistaUpdaterLauncher.cpp : Defines the entry point for the console application. -// +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "stdafx.h" #include diff --git a/native/breakgen/AppMain.c b/native/breakgen/AppMain.c index bf4603365dac..4b33f16fa89c 100644 --- a/native/breakgen/AppMain.c +++ b/native/breakgen/AppMain.c @@ -1,3 +1,18 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #if defined(WIN32) #include diff --git a/native/fileWatcher/ReadMe.txt b/native/fileWatcher/ReadMe.txt deleted file mode 100644 index 959f007d34f3..000000000000 --- a/native/fileWatcher/ReadMe.txt +++ /dev/null @@ -1,33 +0,0 @@ -======================================================================== - CONSOLE APPLICATION : fileWatcher3 Project Overview -======================================================================== - -AppWizard has created this fileWatcher3 application for you. - -This file contains a summary of what you will find in each of the files that -make up your fileWatcher3 application. - - -fileWatcher3.vcproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -fileWatcher3.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named fileWatcher3.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/native/fileWatcher/fileWatcher3.cpp b/native/fileWatcher/fileWatcher3.cpp index 8c61739b8398..97c32fdbfafb 100644 --- a/native/fileWatcher/fileWatcher3.cpp +++ b/native/fileWatcher/fileWatcher3.cpp @@ -1,5 +1,18 @@ -// fileWatcher3.cpp : Defines the entry point for the console application. -// +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "stdafx.h" diff --git a/native/fsNotifier/mac/fsnotifier.c b/native/fsNotifier/mac/fsnotifier.c index bae724d3b6fb..cefe730156ad 100644 --- a/native/fsNotifier/mac/fsnotifier.c +++ b/native/fsNotifier/mac/fsnotifier.c @@ -1,3 +1,19 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include #include diff --git a/native/restarter/ReadMe.txt b/native/restarter/ReadMe.txt deleted file mode 100644 index 80a9a1c63148..000000000000 --- a/native/restarter/ReadMe.txt +++ /dev/null @@ -1,33 +0,0 @@ -======================================================================== - CONSOLE APPLICATION : restarter Project Overview -======================================================================== - -AppWizard has created this restarter application for you. - -This file contains a summary of what you will find in each of the files that -make up your restarter application. - - -restarter.vcproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -restarter.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named restarter.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// diff --git a/native/restarter/restarter.cpp b/native/restarter/restarter.cpp index da1682182475..65b1eb214a55 100644 --- a/native/restarter/restarter.cpp +++ b/native/restarter/restarter.cpp @@ -1,5 +1,18 @@ -// restarter.cpp : Defines the entry point for the console application. -// +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "stdafx.h" From 4707ff06bad7f564060e248ddb3f6f52171c4e22 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Oct 2009 18:51:52 +0400 Subject: [PATCH 08/10] don't check transparency via JNA if the JDK API is available (IDEADEV-40878) --- .../com/intellij/openapi/wm/impl/AWTUtilitiesWrapper.java | 8 +++++--- .../com/intellij/openapi/wm/impl/WindowManagerImpl.java | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/AWTUtilitiesWrapper.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/AWTUtilitiesWrapper.java index 51ede83b5cac..fe756a1da8b2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/AWTUtilitiesWrapper.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/AWTUtilitiesWrapper.java @@ -82,12 +82,14 @@ public class AWTUtilitiesWrapper { } public static boolean isTranslucencySupported(Object kind) { - if (translucencyClass == null) { - return false; - } + if (!isTranslucencyAPISupported()) return false; return isSupported(mIsTranslucencySupported, kind); } + public static boolean isTranslucencyAPISupported() { + return translucencyClass != null; + } + public static boolean isTranslucencyCapable(GraphicsConfiguration gc) { return isSupported(mIsTranslucencyCapable, gc); } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index 4b1bcc8c6dff..81b7a07acaec 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -226,7 +226,9 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat } private static boolean calcAlphaModelSupported() { - if (AWTUtilitiesWrapper.isTranslucencySupported(AWTUtilitiesWrapper.TRANSLUCENT)) return true; + if (AWTUtilitiesWrapper.isTranslucencyAPISupported()) { + return AWTUtilitiesWrapper.isTranslucencySupported(AWTUtilitiesWrapper.TRANSLUCENT); + } try { return WindowUtils.isWindowAlphaSupported(); } From f6a0f212db857bb8d32423f16b977b17101046af Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Oct 2009 19:08:51 +0400 Subject: [PATCH 09/10] use correct context when copying template which has just been modified (IDEADEV-40881) --- .../intellij/codeInsight/template/impl/TemplateListPanel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index ba3c7d5d291e..77b4f3d931b7 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -532,8 +532,8 @@ class TemplateListPanel extends JPanel { TemplateImpl orTemplate = getTemplate(selected); LOG.assertTrue(orTemplate != null); TemplateImpl template = orTemplate.copy(); - myTemplateOptions.put(getKey(template), template.createOptions()); - myTemplateContext.put(getKey(template), template.createContext()); + myTemplateOptions.put(getKey(template), getOptions(orTemplate)); + myTemplateContext.put(getKey(template), getContext(orTemplate)); EditTemplateDialog dialog = new EditTemplateDialog(this, CodeInsightBundle.message("dialog.copy.live.template.title"), template, getTemplateGroups(), (String)myExpandByCombo.getSelectedItem(), getOptions(template), getContext(template)); dialog.show(); From 205697d17dbd8391497c176554adc745379df0f5 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 16 Oct 2009 19:16:26 +0400 Subject: [PATCH 10/10] readme telling where to find the source of JPS --- build/lib/gant/lib/README_JPS.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 build/lib/gant/lib/README_JPS.txt diff --git a/build/lib/gant/lib/README_JPS.txt b/build/lib/gant/lib/README_JPS.txt new file mode 100644 index 000000000000..dc927aa0c583 --- /dev/null +++ b/build/lib/gant/lib/README_JPS.txt @@ -0,0 +1,4 @@ +The source code for JPS, JetBrains' Gant-based build system used for +building IntelliJ, can be found on GitHub: + + http://github.com/shafirov/JPS