diff --git a/bin/idea.properties b/bin/idea.properties index a1ebc752115c..68a4adfa94bd 100644 --- a/bin/idea.properties +++ b/bin/idea.properties @@ -1,11 +1,11 @@ # path to IDEA config folder -idea.config.path=${idea.home}/config +idea.config.path=${user.home}/.IdeaIC90/config # path to IDEA system folder -idea.system.path=${idea.home}/system +idea.system.path=${user.home}/.IdeaIC90/system # path to user installed plugins folder -idea.plugins.path=${idea.home}/config/plugins +idea.plugins.path=${user.home}/.IdeaIC90/config/plugins #--------------------------------------------------------------------- # Maximum file size (kilobytes) IDEA should provide intellisense for. diff --git a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java b/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java index 8f6b0799eaa1..0ff19abc6296 100644 --- a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java +++ b/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java @@ -65,7 +65,9 @@ public class PaletteManager implements ProjectComponent { myPaletteWindow = new PaletteWindow(myProject); myPaletteToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(IdeBundle.message("toolwindow.palette"), myPaletteWindow, - ToolWindowAnchor.RIGHT); + ToolWindowAnchor.RIGHT, + myProject, + true); myPaletteToolWindow.setIcon(IconLoader.getIcon("/general/toolWindowPalette.png")); myPaletteToolWindow.setAvailable(false, null); final MyFileEditorManagerListener myListener = new MyFileEditorManagerListener(); @@ -75,10 +77,6 @@ public class PaletteManager implements ProjectComponent { } public void projectClosed() { - if (myPaletteWindow != null) { - ToolWindowManager.getInstance(myProject).unregisterToolWindow(IdeBundle.message("toolwindow.palette")); - myPaletteWindow = null; - } } @NotNull diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathPanel.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathPanel.java index 60341f0b1df2..1ccc733676aa 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathPanel.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathPanel.java @@ -896,7 +896,7 @@ public class ClasspathPanel extends JPanel { if (columnIndex == EXPORT_COLUMN) { item.setExported(((Boolean)aValue).booleanValue()); } - else if (columnIndex == SCOPE_COLUMN) { + else if (columnIndex == SCOPE_COLUMN && aValue instanceof DependencyScope) { item.setScope((DependencyScope) aValue); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/AddImportAction.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/AddImportAction.java index f2ea6b38db2e..2bfc5e615541 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/AddImportAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/AddImportAction.java @@ -24,7 +24,7 @@ import com.intellij.codeInsight.CodeInsightUtilBase; import com.intellij.codeInsight.actions.OptimizeImportsProcessor; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.daemon.QuickFixBundle; -import com.intellij.codeInsight.hint.PriorityQuestionAction; +import com.intellij.codeInsight.hint.QuestionAction; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; @@ -52,7 +52,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class AddImportAction implements PriorityQuestionAction { +public class AddImportAction implements QuestionAction { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.actions.AddImportAction"); private final Project myProject; @@ -246,8 +246,4 @@ public class AddImportAction implements PriorityQuestionAction { protected void bindReference(PsiReference ref, PsiClass targetClass) { ref.bindToElement(targetClass); } - - public int getPriority() { - return 10; - } } diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialog.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialog.java index 0c69f4a5ac5b..feaec1066b1f 100644 --- a/java/java-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/ChangeSignatureDialog.java @@ -49,6 +49,7 @@ import com.intellij.util.IncorrectOperationException; import com.intellij.util.VisibilityUtil; import com.intellij.util.ui.Table; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.TableModelEvent; @@ -132,6 +133,7 @@ public class ChangeSignatureDialog extends RefactoringDialog { } } + @Nullable private CanonicalTypes.Type getReturnType() { if (myReturnTypeField != null) { try { @@ -220,16 +222,6 @@ public class ChangeSignatureDialog extends RefactoringDialog { namePrompt.setText(RefactoringBundle.message("name.prompt")); panel.add(namePrompt); panel.add(myNameField); - - JLabel typePrompt = new JLabel(); - panel.add(typePrompt); - final PsiElementFactory factory = JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory(); - myReturnTypeCodeFragment = factory.createTypeCodeFragment(myMethod.getReturnTypeElement().getText(), myMethod.getParameterList(), true, true); - final Document document = PsiDocumentManager.getInstance(myProject).getDocument(myReturnTypeCodeFragment); - myReturnTypeField = new EditorTextField(document, myProject, StdFileTypes.JAVA); - typePrompt.setText(RefactoringBundle.message("changeSignature.return.type.prompt")); - panel.add(myReturnTypeField); - final DocumentListener documentListener = new DocumentListener() { public void beforeDocumentChange(DocumentEvent event) { } @@ -238,8 +230,21 @@ public class ChangeSignatureDialog extends RefactoringDialog { updateSignature(); } }; - myNameField.addDocumentListener(documentListener); + + JLabel typePrompt = new JLabel(); + panel.add(typePrompt); + final PsiElementFactory factory = JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory(); + final PsiTypeElement typeElement = myMethod.getReturnTypeElement(); + if (typeElement == null) { + LOG.assertTrue(false, myMethod.getClass().getName()); + return panel; + } + myReturnTypeCodeFragment = factory.createTypeCodeFragment(typeElement.getText(), myMethod.getParameterList(), true, true); + final Document document = PsiDocumentManager.getInstance(myProject).getDocument(myReturnTypeCodeFragment); + myReturnTypeField = new EditorTextField(document, myProject, StdFileTypes.JAVA); + typePrompt.setText(RefactoringBundle.message("changeSignature.return.type.prompt")); + panel.add(myReturnTypeField); myReturnTypeField.addDocumentListener(documentListener); } @@ -260,8 +265,8 @@ public class ChangeSignatureDialog extends RefactoringDialog { JPanel subPanel = new JPanel(new BorderLayout()); subPanel.add(createParametersPanel(), BorderLayout.CENTER); - if (myMethod.getContainingClass() != null - && !myMethod.getContainingClass().isInterface()) { + final PsiClass containingClass = myMethod.getContainingClass(); + if (containingClass != null && !containingClass.isInterface()) { myVisibilityPanel = new VisibilityPanel(false, false); myVisibilityPanel.setVisibility(VisibilityUtil.getVisibilityModifier(myMethod.getModifierList())); myVisibilityPanel.addStateChangedListener(new VisibilityPanel.StateChanged() { diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java index ac2a6f2927a9..98813e54275a 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java @@ -88,7 +88,7 @@ public class ExtractMethodHandler implements RefactoringActionHandler { IntroduceVariableBase.showChooser(editor, expressions, new Pass() { @Override public void pass(PsiExpression psiExpression) { - callback.pass(new PsiExpression[]{psiExpression}); + callback.pass(new PsiElement[]{psiExpression}); } }); return; diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java index a4c5aa45b129..017c5a722852 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java @@ -334,11 +334,12 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme tempExpr.putUserData(ElementToWorkOn.PARENT, parent); final String fakeInitializer = "intellijidearulezzz"; - final PsiExpression toBeExpression = createReplacement(fakeInitializer, project, prefix, suffix, parent, rangeMarker); + final int[] refIdx = new int[1]; + final PsiExpression toBeExpression = createReplacement(fakeInitializer, project, prefix, suffix, parent, rangeMarker, refIdx); toBeExpression.accept(errorsVisitor); if (hasErrors[0]) return null; - final PsiReferenceExpression refExpr = PsiTreeUtil.getParentOfType(toBeExpression.findElementAt(toBeExpression.getText().indexOf(fakeInitializer)), PsiReferenceExpression.class); + final PsiReferenceExpression refExpr = PsiTreeUtil.getParentOfType(toBeExpression.findElementAt(refIdx[0]), PsiReferenceExpression.class); assert refExpr != null; if (ReplaceExpressionUtil.isNeedParenthesis(refExpr.getNode(), tempExpr.getNode())) { return null; @@ -602,14 +603,14 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme final PsiElement parent = expr1.getUserData(ElementToWorkOn.PARENT); final RangeMarker rangeMarker = expr1.getUserData(ElementToWorkOn.TEXT_RANGE); - return parent.replace(createReplacement(ref.getText(), project, prefix, suffix, parent, rangeMarker)); + return parent.replace(createReplacement(ref.getText(), project, prefix, suffix, parent, rangeMarker, new int[1])); } } private static PsiExpression createReplacement(final String refText, final Project project, final String prefix, final String suffix, - final PsiElement parent, final RangeMarker rangeMarker) { + final PsiElement parent, final RangeMarker rangeMarker, int[] refIdx) { final String allText = parent.getContainingFile().getText(); final TextRange parentRange = parent.getTextRange(); @@ -619,7 +620,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme String end = allText.substring(rangeMarker.getEndOffset(), parentRange.getEndOffset()); if (StringUtil.stripQuotesAroundValue(end).trim().length() == 0 && suffix == null) end = ""; - final String text = beg + (prefix != null ? prefix : "") + refText + (suffix != null ? suffix : "") + end; + final String start = beg + (prefix != null ? prefix : ""); + refIdx[0] = start.length(); + final String text = start + refText + (suffix != null ? suffix : "") + end; return JavaPsiFacade.getInstance(project).getElementFactory().createExpressionFromText(text, parent); } diff --git a/java/java-tests/testData/refactoring/introduceVariable/SubExpressionFromIntellijidearulezzz.after.java b/java/java-tests/testData/refactoring/introduceVariable/SubExpressionFromIntellijidearulezzz.after.java new file mode 100644 index 000000000000..a7277f4468ed --- /dev/null +++ b/java/java-tests/testData/refactoring/introduceVariable/SubExpressionFromIntellijidearulezzz.after.java @@ -0,0 +1,6 @@ +class A { + public void test() { + String str = "sintellijidearulezzzs"; + String s = "intellijidearulezzz" + str + "sintellijidearulezzz"; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/introduceVariable/SubExpressionFromIntellijidearulezzz.java b/java/java-tests/testData/refactoring/introduceVariable/SubExpressionFromIntellijidearulezzz.java new file mode 100644 index 000000000000..55d687e0892b --- /dev/null +++ b/java/java-tests/testData/refactoring/introduceVariable/SubExpressionFromIntellijidearulezzz.java @@ -0,0 +1,5 @@ +class A { + public void test() { + String s = "intellijidearulezzzsintellijidearulezzzssintellijidearulezzz"; + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java index 3e0793b9351b..7e6b61327d86 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java @@ -174,6 +174,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase { doTest(new MockIntroduceVariableHandler("str", false, false, false, "java.lang.String")); } + public void testSubExpressionFromIntellijidearulezzz() throws Exception { + doTest(new MockIntroduceVariableHandler("str", false, false, false, "java.lang.String")); + } + public void testSubPrimitiveLiteral() throws Exception { doTest(new MockIntroduceVariableHandler("str", false, false, false, "boolean")); } diff --git a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionManager.java b/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionManager.java index 0d0ac47bfa7b..b5c9897b09eb 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionManager.java +++ b/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionManager.java @@ -42,7 +42,7 @@ public abstract class IntentionManager { */ @Deprecated public static IntentionManager getInstance(Project project) { - return ServiceManager.getService(IntentionManager.class); + return getInstance(); } public static IntentionManager getInstance() { @@ -54,15 +54,25 @@ public abstract class IntentionManager { * * @param action the intention action to register. */ - public abstract void addAction(IntentionAction action); + public abstract void addAction(@NotNull IntentionAction action); /** * Returns all registered intention actions. * * @return array of registered actions. */ + @NotNull public abstract IntentionAction[] getIntentionActions(); + /** + * Returns all registered intention actions which are available now + * (not disabled via Settings|Intentions or Alt-Enter|Disable intention quick fix) + * + * @return array of actions. + */ + @NotNull + public abstract IntentionAction[] getAvailableIntentionActions(); + /** * Registers an intention action which can be enabled or disabled through the "Intention * Settings" dialog. To provide the description and the example code for the intention, @@ -79,25 +89,32 @@ public abstract class IntentionManager { * @param category the name of the category or categories under which the intention will be shown * in the "Intention Settings" dialog. */ - public abstract void registerIntentionAndMetaData(IntentionAction action, String... category); + public abstract void registerIntentionAndMetaData(@NotNull IntentionAction action, @NotNull String... category); /** - * @deprecated custom directory name causes problem with internationalization of inspection descriptions. + * @deprecated custom directory name causes problem with internationalization of intention descriptions. + * Register intention class via extension point {@link IntentionManager.EP_INTENTION_ACTIONS} instead. */ @Deprecated - public abstract void registerIntentionAndMetaData(IntentionAction action, String[] category, String descriptionDirectoryName); + public abstract void registerIntentionAndMetaData(@NotNull IntentionAction action, + @NotNull String[] category, + @NotNull String descriptionDirectoryName); - public abstract void registerIntentionAndMetaData(IntentionAction action, String[] category, - String description, String exampleFileExtension, - String[] exampleTextBefore, String[] exampleTextAfter); + public abstract void registerIntentionAndMetaData(@NotNull IntentionAction action, + @NotNull String[] category, + @NotNull String description, + @NotNull String exampleFileExtension, + @NotNull String[] exampleTextBefore, + @NotNull String[] exampleTextAfter); - public abstract void unregisterIntention(IntentionAction intentionAction); + public abstract void unregisterIntention(@NotNull IntentionAction intentionAction); /** * @return actions used as additional options for the given problem. * E.g. actions for suppress the problem via comment, javadoc or annotation, * and edit corresponding inspection settings. */ + @NotNull public abstract List getStandardIntentionOptions(@NotNull HighlightDisplayKey displayKey, @NotNull PsiElement context); /** @@ -105,5 +122,6 @@ public abstract class IntentionManager { * @param action action to convert. * @return quick fix instance. */ - public abstract LocalQuickFix convertToFix(IntentionAction action); + @NotNull + public abstract LocalQuickFix convertToFix(@NotNull IntentionAction action); } 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 82aeb3423aaa..d24c827650c6 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 @@ -190,7 +190,7 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass { int offset = editor.getCaretModel().getOffset(); Project project = psiFile.getProject(); - for (IntentionAction action : IntentionManager.getInstance().getIntentionActions()) { + for (IntentionAction action : IntentionManager.getInstance().getAvailableIntentionActions()) { Pair place = ShowIntentionActionsHandler.availableFor(psiFile, editor, action, psiElement); if (place != null) { List enableDisableIntentionAction = new ArrayList(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionHintComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionHintComponent.java index 5fa9bc51f1b7..ce5d5b5f9202 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionHintComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/IntentionHintComponent.java @@ -156,6 +156,7 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll myComponentHint.setShouldDelay(delay); HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl(); + PriorityQuestionAction action = new PriorityQuestionAction() { public boolean execute() { showPopup(); @@ -163,7 +164,7 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll } public int getPriority() { - return 0; + return -10; } }; if (hintManager.canShowQuestionAction(action)) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java index e2fe36e585cd..656e6b2d7bc4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionManagerImpl.java @@ -26,23 +26,23 @@ import com.intellij.codeInspection.actions.RunInspectionIntention; import com.intellij.codeInspection.ex.DisableInspectionToolAction; import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction; import com.intellij.codeInspection.ex.EditInspectionToolsSettingsInSuppressedPlaceIntention; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.extensions.ExtensionPointListener; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.extensions.PluginDescriptor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.util.Alarm; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -51,7 +51,7 @@ import java.util.List; public class IntentionManagerImpl extends IntentionManager { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.config.IntentionManagerImpl"); - private final List myActions = Collections.synchronizedList(new ArrayList()); + private final List myActions = ContainerUtil.createEmptyCOWList(); private final IntentionManagerSettings mySettings; private final Alarm myInitActionsAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD); @@ -108,7 +108,7 @@ public class IntentionManagerImpl extends IntentionManager { return new IntentionActionWrapper(intentionActionBean,categories); } - public void registerIntentionAndMetaData(IntentionAction action, String... category) { + public void registerIntentionAndMetaData(@NotNull IntentionAction action, @NotNull String... category) { registerIntentionAndMetaData(action, category, getDescriptionDirectoryName(action)); } @@ -132,12 +132,12 @@ public class IntentionManagerImpl extends IntentionManager { mySettings.registerIntentionMetaData(action, category, descriptionDirectoryName); } - public void registerIntentionAndMetaData(final IntentionAction action, - final String[] category, - final String description, - final String exampleFileExtension, - final String[] exampleTextBefore, - final String[] exampleTextAfter) { + public void registerIntentionAndMetaData(@NotNull final IntentionAction action, + @NotNull final String[] category, + @NotNull final String description, + @NotNull final String exampleFileExtension, + @NotNull final String[] exampleTextBefore, + @NotNull final String[] exampleTextAfter) { addAction(action); IntentionActionMetaData metaData = new IntentionActionMetaData(action, category, @@ -148,19 +148,20 @@ public class IntentionManagerImpl extends IntentionManager { } @Override - public void unregisterIntention(IntentionAction intentionAction) { + public void unregisterIntention(@NotNull IntentionAction intentionAction) { myActions.remove(intentionAction); mySettings.unregisterMetaData(intentionAction); } - private static TextDescriptor[] mapToDescriptors(String[] texts, String fileName) { + private static TextDescriptor[] mapToDescriptors(String[] texts, @NonNls String fileName) { TextDescriptor[] result = new TextDescriptor[texts.length]; for (int i = 0; i < texts.length; i++) { - result [i] = new PlainTextDescriptor(texts [i], fileName); + result [i] = new PlainTextDescriptor(texts[i], fileName); } return result; } + @NotNull public List getStandardIntentionOptions(@NotNull final HighlightDisplayKey displayKey, @NotNull final PsiElement context) { List options = new ArrayList(9); options.add(new EditInspectionToolsSettingsAction(displayKey)); @@ -169,7 +170,8 @@ public class IntentionManagerImpl extends IntentionManager { return options; } - public LocalQuickFix convertToFix(final IntentionAction action) { + @NotNull + public LocalQuickFix convertToFix(@NotNull final IntentionAction action) { if (action instanceof LocalQuickFix) { return (LocalQuickFix)action; } @@ -196,12 +198,24 @@ public class IntentionManagerImpl extends IntentionManager { }; } - public void addAction(IntentionAction action) { + public void addAction(@NotNull IntentionAction action) { myActions.add(action); } + @NotNull public IntentionAction[] getIntentionActions() { return myActions.toArray(new IntentionAction[myActions.size()]); } + @NotNull + @Override + public IntentionAction[] getAvailableIntentionActions() { + List list = new ArrayList(myActions.size()); + for (IntentionAction action : myActions) { + if (mySettings.isEnabled(action)) { + list.add(action); + } + } + return list.toArray(new IntentionAction[list.size()]); + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/PlainTextDescriptor.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/PlainTextDescriptor.java index 8939ad2c7732..c2c4421c131f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/PlainTextDescriptor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/config/PlainTextDescriptor.java @@ -16,6 +16,9 @@ package com.intellij.codeInsight.intention.impl.config; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + import java.io.IOException; /** @@ -25,15 +28,17 @@ public class PlainTextDescriptor implements TextDescriptor { private final String myText; private final String myFileName; - public PlainTextDescriptor(final String text, final String fileName) { + public PlainTextDescriptor(@NotNull String text, @NonNls @NotNull String fileName) { myText = text; myFileName = fileName; } + @NotNull public String getText() throws IOException { return myText; } + @NotNull public String getFileName() { return myFileName; } diff --git a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateManagerImpl.java b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateManagerImpl.java index 941c89108a1e..b1dda7a1eaa5 100644 --- a/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/fileTemplates/impl/FileTemplateManagerImpl.java @@ -597,9 +597,9 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Expo return getTemplateFromManager(templateName, myJ2eeTemplatesManager); } - private FileTemplate getTemplateFromManager(@NotNull @NonNls String templateName, @NotNull FileTemplateManagerImpl templatesManager) { + private static FileTemplate getTemplateFromManager(@NotNull @NonNls String templateName, @NotNull FileTemplateManagerImpl templatesManager) { String name = templateName; - String extension = myTypeManager.getExtension(name); + String extension = templatesManager.myTypeManager.getExtension(name); if (extension.length() > 0) { name = name.substring(0, name.length() - extension.length() - 1); } @@ -612,24 +612,39 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Expo else { if (ApplicationManager.getApplication().isUnitTestMode() && templateName.endsWith("ForTest")) return null; - String message = templateNotFound(templateName, templatesManager); + String message = templatesManager.templateNotFoundMessage(templateName); LOG.error(message); } return null; } - private static String templateNotFound(String templateName, FileTemplateManagerImpl templatesManager) { - Collection defaultTemplates = templatesManager.getDefaultTemplates(); + private String templateNotFoundMessage(String templateName) { + Collection defaultTemplates = getDefaultTemplates(); @NonNls String message = - "Unable to find template '" + templateName + "' in " + templatesManager + " in '"+templatesManager.myDefaultTemplatesDir+"'" + - "\n" + - "Default templates are: "; - message += StringUtil.join(defaultTemplates, new Function() { + "Unable to find template '" + templateName + "' in " + this + + "\n Default templates are: " + toString(defaultTemplates); + message+= "\n Default template dir: '"+ myDefaultTemplatesDir+"'"; + for (VirtualFile topDir : getTopTemplatesDir()) { + VirtualFile parentDir = myDefaultTemplatesDir.equals(".") ? topDir : topDir.findChild(myDefaultTemplatesDir); + if (parentDir == null) { + message += "\n No templates in '" + topDir.getPath() + "'"; + } + else { + message += "\n " + parentDir.getPath() + ": " + toString(listDir(parentDir)); + } + } + + message += "\n Deleted templates: " + myDeletedTemplatesManager.DELETED_DEFAULT_TEMPLATES; + + return message; + } + + private static String toString(Collection defaultTemplates) { + return StringUtil.join(defaultTemplates, new Function() { public String fun(VirtualFile virtualFile) { return virtualFile.getPresentableUrl(); } - }, ","); - return message; + }, ", "); } @@ -722,7 +737,7 @@ public class FileTemplateManagerImpl extends FileTemplateManager implements Expo if (file == null) { String message = ""; for (FileTemplateManagerImpl child : ArrayUtil.append(myChildren,this)) { - message += templateNotFound(name, child) + "\n"; + message += child.templateNotFoundMessage(name) + "\n"; } LOG.error(message); return null; diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewToolWindowFactory.java b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewToolWindowFactory.java index b3df9aae5674..79bc9b871934 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewToolWindowFactory.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewToolWindowFactory.java @@ -16,15 +16,16 @@ package com.intellij.ide.structureView.impl; -import com.intellij.openapi.wm.ToolWindowFactory; -import com.intellij.openapi.wm.ToolWindow; -import com.intellij.openapi.project.Project; import com.intellij.ide.structureView.StructureViewFactory; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.wm.ToolWindow; +import com.intellij.openapi.wm.ToolWindowFactory; /** * @author yole */ -public class StructureViewToolWindowFactory implements ToolWindowFactory { +public class StructureViewToolWindowFactory implements ToolWindowFactory, DumbAware { public void createToolWindowContent(Project project, ToolWindow toolWindow) { StructureViewFactoryImpl factory = (StructureViewFactoryImpl)StructureViewFactory.getInstance(project); factory.initToolWindow(toolWindow); diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeActionWrapper.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeActionWrapper.java index cca504bd7eb1..fd0d55138f6a 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeActionWrapper.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/TreeActionWrapper.java @@ -21,8 +21,9 @@ import com.intellij.ide.util.treeView.smartTree.TreeAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.actionSystem.ToggleAction; +import com.intellij.openapi.project.DumbAware; -public class TreeActionWrapper extends ToggleAction{ +public class TreeActionWrapper extends ToggleAction implements DumbAware { private final TreeAction myAction; private final TreeActionsOwner myStructureView; diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameHandlerRegistry.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameHandlerRegistry.java index 1b3a45b30633..84081b98783a 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameHandlerRegistry.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameHandlerRegistry.java @@ -18,6 +18,7 @@ package com.intellij.refactoring.rename; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; @@ -66,11 +67,13 @@ public class RenameHandlerRegistry { final Map availableHandlers = new TreeMap(); for (RenameHandler renameHandler : Extensions.getExtensions(RenameHandler.EP_NAME)) { if (renameHandler.isRenaming(dataContext)) { + if (ApplicationManager.getApplication().isUnitTestMode()) return renameHandler; availableHandlers.put(getHandlerTitle(renameHandler), renameHandler); } } for (RenameHandler renameHandler : myHandlers) { if (renameHandler.isRenaming(dataContext)) { + if (ApplicationManager.getApplication().isUnitTestMode()) return renameHandler; availableHandlers.put(getHandlerTitle(renameHandler), renameHandler); } } diff --git a/platform/platform-api/src/com/intellij/ui/AutoScrollFromSourceHandler.java b/platform/platform-api/src/com/intellij/ui/AutoScrollFromSourceHandler.java index 2df46b8e3328..e479c489ad3f 100644 --- a/platform/platform-api/src/com/intellij/ui/AutoScrollFromSourceHandler.java +++ b/platform/platform-api/src/com/intellij/ui/AutoScrollFromSourceHandler.java @@ -19,6 +19,7 @@ package com.intellij.ui; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; +import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.IconLoader; @@ -42,16 +43,22 @@ public abstract class AutoScrollFromSourceHandler implements Disposable { public abstract void install(); public ToggleAction createToggleAction() { - return new ToggleAction(UIBundle.message("autoscroll.from.source.action.name"), - UIBundle.message("autoscroll.from.source.action.description"), IconLoader.getIcon("/general/autoscrollFromSource.png")) { - public boolean isSelected(AnActionEvent event) { - return isAutoScrollMode(); - } + return new AutoScrollFromSourceAction(); + } - public void setSelected(AnActionEvent event, boolean flag) { - setAutoScrollMode(flag); - } - }; + private class AutoScrollFromSourceAction extends ToggleAction implements DumbAware { + public AutoScrollFromSourceAction() { + super(UIBundle.message("autoscroll.from.source.action.name"), UIBundle.message("autoscroll.from.source.action.description"), + IconLoader.getIcon("/general/autoscrollFromSource.png")); + } + + public boolean isSelected(AnActionEvent event) { + return isAutoScrollMode(); + } + + public void setSelected(AnActionEvent event, boolean flag) { + setAutoScrollMode(flag); + } } } diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java index 5c8c1d567f2a..2c90dfe8d348 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java @@ -67,10 +67,13 @@ public class HintManagerImpl extends HintManager implements Disposable { private Editor myLastEditor = null; private final Alarm myHideAlarm = new Alarm(); - public boolean canShowQuestionAction(PriorityQuestionAction action) { + private static int getPriority(QuestionAction action) { + return action instanceof PriorityQuestionAction ? ((PriorityQuestionAction)action).getPriority() : 0; + } + + public boolean canShowQuestionAction(QuestionAction action) { ApplicationManager.getApplication().assertIsDispatchThread(); - return !(myQuestionAction instanceof PriorityQuestionAction) || - ((PriorityQuestionAction)myQuestionAction).getPriority() <= action.getPriority(); + return myQuestionAction == null || getPriority(myQuestionAction) <= getPriority(action); } public interface ActionToIgnore { @@ -244,7 +247,7 @@ public class HintManagerImpl extends HintManager implements Disposable { hideAllHints(); } - if (!editor.getContentComponent().isShowing()) return; + if (!ApplicationManager.getApplication().isUnitTestMode() && !editor.getContentComponent().isShowing()) return; updateLastEditor(editor); @@ -338,13 +341,18 @@ public class HintManagerImpl extends HintManager implements Disposable { } private static void doShowInGivenLocation(final LightweightHint hint, final Editor editor, final Point p) { + if (ApplicationManager.getApplication().isUnitTestMode()) return; JLayeredPane layeredPane = editor.getComponent().getRootPane().getLayeredPane(); Dimension size = hint.getComponent().getPreferredSize(); if(layeredPane.getWidth() < p.x + size.width) { p.x = Math.max(0, layeredPane.getWidth() - size.width); } - if (!hint.isVisible()) hint.show(layeredPane, p.x, p.y, editor.getContentComponent()); - else hint.setLocation(p.x, p.y); + if (hint.isVisible()) { + hint.setLocation(p.x, p.y); + } + else { + hint.show(layeredPane, p.x, p.y, editor.getContentComponent()); + } } public static void adjustEditorHintPosition(final LightweightHint hint, final Editor editor, final Point p) { diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/LineTooltipRenderer.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/LineTooltipRenderer.java index 8cd93fd594b0..cb1e903f019e 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/LineTooltipRenderer.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/LineTooltipRenderer.java @@ -61,30 +61,13 @@ public class LineTooltipRenderer implements TooltipRenderer { //setup text myText = myText.replaceAll(String.valueOf(UIUtil.MNEMONIC), ""); - final boolean [] expanded = new boolean[] { myCurrentWidth > 0 && dressDescription(editor)}; + final boolean expanded = myCurrentWidth > 0 && dressDescription(editor); //pane final JEditorPane pane = initPane(myText); pane.setCaretPosition(0); final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl(); final JComponent contentComponent = editor.getContentComponent(); - // This listener makes hint transparent for mouse events. It means that hint is closed - // by MousePressed and this MousePressed goes into the underlying editor component. - pane.addMouseListener(new MouseAdapter() { - public void mouseReleased(final MouseEvent e) { - if (!myActiveLink) { - MouseEvent newMouseEvent = SwingUtilities.convertMouseEvent(e.getComponent(), e, contentComponent); - hintManager.hideAllHints(); - contentComponent.dispatchEvent(newMouseEvent); - } - } - - public void mouseExited(final MouseEvent e) { - if (!expanded[0]) { - hintManager.hideAllHints(); - } - } - }); final JComponent editorComponent = editor.getComponent(); final JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane(); @@ -94,8 +77,8 @@ public class LineTooltipRenderer implements TooltipRenderer { final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane); scrollPane.setBorder(null); - int width = expanded[0] ? 3 * myCurrentWidth / 2 : pane.getPreferredSize().width; - int height = expanded[0] ? Math.max(pane.getPreferredSize().height, 150) : pane.getPreferredSize().height; + int width = expanded ? 3 * myCurrentWidth / 2 : pane.getPreferredSize().width; + int height = expanded ? Math.max(pane.getPreferredSize().height, 150) : pane.getPreferredSize().height; if (alignToRight) { p.x -= width; @@ -166,7 +149,7 @@ public class LineTooltipRenderer implements TooltipRenderer { return; } if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - if (!expanded[0]) { // more -> less + if (!expanded) { // more -> less for (final TooltipLinkHandlerEP handlerEP : Extensions.getExtensions(TooltipLinkHandlerEP.EP_NAME)) { if (handlerEP.handleLink(e.getDescription(), editor, pane)) { myText = convertTextOnLinkHandled(myText); @@ -189,6 +172,25 @@ public class LineTooltipRenderer implements TooltipRenderer { } } }); + + // This listener makes hint transparent for mouse events. It means that hint is closed + // by MousePressed and this MousePressed goes into the underlying editor component. + pane.addMouseListener(new MouseAdapter() { + public void mouseReleased(final MouseEvent e) { + if (!myActiveLink) { + MouseEvent newMouseEvent = SwingUtilities.convertMouseEvent(e.getComponent(), e, contentComponent); + hint.hide(); + contentComponent.dispatchEvent(newMouseEvent); + } + } + + public void mouseExited(final MouseEvent e) { + if (!expanded) { + hint.hide(); + } + } + }); + hintManager.showEditorHint(hint, editor, p, HintManagerImpl.HIDE_BY_ANY_KEY | HintManagerImpl.HIDE_BY_TEXT_CHANGE | HintManagerImpl.HIDE_BY_OTHER_HINT | HintManagerImpl.HIDE_BY_SCROLLING, 0, false); @@ -260,9 +262,7 @@ public class LineTooltipRenderer implements TooltipRenderer { final LineTooltipRenderer lineTooltipRenderer = (LineTooltipRenderer)o; - if (myText != null ? !myText.equals(lineTooltipRenderer.myText) : lineTooltipRenderer.myText != null) return false; - - return true; + return myText == null ? lineTooltipRenderer.myText == null : myText.equals(lineTooltipRenderer.myText); } public int hashCode() { diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandLog.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandLog.java new file mode 100644 index 000000000000..ab4d30759d62 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandLog.java @@ -0,0 +1,22 @@ +/* + * 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. + */ +package com.intellij.openapi.command.impl; + +import com.intellij.openapi.diagnostic.Logger; + +public class CommandLog { + public static final Logger LOG = Logger.getInstance("#" + CommandLog.class.getPackage().getName()); +} diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandProcessorImpl.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandProcessorImpl.java index 81a9f6531aec..b072fa8e5e9e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandProcessorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/CommandProcessorImpl.java @@ -38,8 +38,6 @@ import java.util.concurrent.CopyOnWriteArrayList; * */ public class CommandProcessorImpl extends CommandProcessorEx { - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.command.impl.CommandProcessorImpl"); - private static class CommandDescriptor { public final Runnable myCommand; public final Project myProject; @@ -97,8 +95,8 @@ public class CommandProcessorImpl extends CommandProcessorEx { ApplicationManager.getApplication().assertIsDispatchThread(); if (project != null && project.isDisposed()) return; - if (LOG.isDebugEnabled()) { - LOG.debug("executeCommand: " + command + ", name = " + name + ", groupId = " + groupId); + if (CommandLog.LOG.isDebugEnabled()) { + CommandLog.LOG.debug("executeCommand: " + command + ", name = " + name + ", groupId = " + groupId); } if (myCurrentCommand != null) { @@ -127,8 +125,8 @@ public class CommandProcessorImpl extends CommandProcessorEx { ApplicationManager.getApplication().assertIsDispatchThread(); if (project != null && project.isDisposed()) return null; - if (LOG.isDebugEnabled()) { - LOG.debug("startCommand: name = " + name + ", groupId = " + groupId); + if (CommandLog.LOG.isDebugEnabled()) { + CommandLog.LOG.debug("startCommand: name = " + name + ", groupId = " + groupId); } if (myCurrentCommand != null) { @@ -143,7 +141,7 @@ public class CommandProcessorImpl extends CommandProcessorEx { public void finishCommand(final Project project, final Object command, final Throwable throwable) { ApplicationManager.getApplication().assertIsDispatchThread(); - LOG.assertTrue(myCurrentCommand != null, "no current command in progress"); + CommandLog.LOG.assertTrue(myCurrentCommand != null, "no current command in progress"); if (myCurrentCommand != command) return; final boolean failed; try { @@ -160,7 +158,7 @@ public class CommandProcessorImpl extends CommandProcessorEx { throw (Error)throwable; } else if (throwable instanceof RuntimeException) throw (RuntimeException)throwable; - LOG.error(throwable); + CommandLog.LOG.error(throwable); } else { failed = false; @@ -194,7 +192,7 @@ public class CommandProcessorImpl extends CommandProcessorEx { listener.beforeCommandFinished(event); } catch (Throwable e) { - LOG.error(e); + CommandLog.LOG.error(e); } } } @@ -205,7 +203,7 @@ public class CommandProcessorImpl extends CommandProcessorEx { listener.commandFinished(event); } catch (Throwable e) { - LOG.error(e); + CommandLog.LOG.error(e); } } } @@ -219,7 +217,7 @@ public class CommandProcessorImpl extends CommandProcessorEx { } public void leaveModal() { - LOG.assertTrue(myCurrentCommand == null); + CommandLog.LOG.assertTrue(myCurrentCommand == null); myCurrentCommand = myInterruptedCommands.pop(); if (myCurrentCommand != null) { fireCommandStarted(); @@ -227,12 +225,12 @@ public class CommandProcessorImpl extends CommandProcessorEx { } public void setCurrentCommandName(String name) { - LOG.assertTrue(myCurrentCommand != null); + CommandLog.LOG.assertTrue(myCurrentCommand != null); myCurrentCommand.myName = name; } public void setCurrentCommandGroupId(Object groupId) { - LOG.assertTrue(myCurrentCommand != null); + CommandLog.LOG.assertTrue(myCurrentCommand != null); myCurrentCommand.myGroupId = groupId; } @@ -317,7 +315,7 @@ public class CommandProcessorImpl extends CommandProcessorEx { listener.commandStarted(event); } catch (Throwable e) { - LOG.error(e); + CommandLog.LOG.error(e); } } } @@ -328,7 +326,7 @@ public class CommandProcessorImpl extends CommandProcessorEx { listener.undoTransparentActionStarted(); } catch (Throwable e) { - LOG.error(e); + CommandLog.LOG.error(e); } } } @@ -339,7 +337,7 @@ public class CommandProcessorImpl extends CommandProcessorEx { listener.undoTransparentActionFinished(); } catch (Throwable e) { - LOG.error(e); + CommandLog.LOG.error(e); } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java index 396a6552b927..77bfe1d0eab1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/UndoManagerImpl.java @@ -260,7 +260,7 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap clearUndoRedoQueue(DocumentReferenceManager.getInstance().create(file)); } - public void compact() { + protected void compact() { if (myCurrentOperationState == NONE && myCommandTimestamp % COMMAND_TO_RUN_COMPACT == 0) { doCompact(); } @@ -314,6 +314,8 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap } public void undoableActionPerformed(UndoableAction action) { + ApplicationManager.getApplication().assertIsDispatchThread(); + if (myCurrentOperationState != NONE) return; if (myCommandLevel == 0) { @@ -330,6 +332,7 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap @Override public void nonundoableActionPerformed(final DocumentReference ref, final boolean isGlobal) { + ApplicationManager.getApplication().assertIsDispatchThread(); undoableActionPerformed(new NonUndoableAction(ref, isGlobal)); } @@ -342,13 +345,17 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap } public void undo(@Nullable FileEditor editor) { + ApplicationManager.getApplication().assertIsDispatchThread(); LOG.assertTrue(isUndoAvailable(editor)); + myCurrentOperationState = UNDO; undoOrRedo(editor); } public void redo(@Nullable FileEditor editor) { + ApplicationManager.getApplication().assertIsDispatchThread(); LOG.assertTrue(isRedoAvailable(editor)); + myCurrentOperationState = REDO; undoOrRedo(editor); } @@ -381,12 +388,16 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap } public boolean isUndoAvailable(@Nullable FileEditor editor) { + ApplicationManager.getApplication().assertIsDispatchThread(); + Collection refs = getDocRefs(editor); if (refs == null) return false; return isUndoOrRedoAvailable(refs, true); } public boolean isRedoAvailable(@Nullable FileEditor editor) { + ApplicationManager.getApplication().assertIsDispatchThread(); + Collection refs = getDocRefs(editor); if (refs == null) return false; return isUndoOrRedoAvailable(refs, false); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java index d5a93eb8da0b..932a5b18b6a9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java @@ -1113,7 +1113,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements target.y = 0; } else if (ToolWindowAnchor.BOTTOM == anchor) { - target.y = bounds.height; + target.y = bounds.height - 3; } else if (ToolWindowAnchor.LEFT == anchor) { target.x = 0; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java index f1f19022baa9..c0f79ded8f58 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java @@ -25,6 +25,7 @@ import com.intellij.openapi.ui.popup.BalloonHandler; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.util.MultiValuesMap; import com.intellij.openapi.wm.StatusBar; +import com.intellij.openapi.wm.ToolWindowAnchor; import com.intellij.openapi.wm.ex.ProgressIndicatorEx; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.labels.LinkLabel; @@ -33,6 +34,7 @@ import com.intellij.ui.components.panels.Wrapper; import com.intellij.util.Alarm; import com.intellij.util.ui.AbstractLayoutManager; import com.intellij.util.ui.AsyncProcessIcon; +import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; import org.jetbrains.annotations.NotNull; @@ -87,7 +89,7 @@ public class InfoAndProgressPanel extends JPanel implements StatusBarPatch { } } }); - + myProgressIcon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); StatusBarTooltipper.install(this, myProgressIcon, statusBar); @@ -279,9 +281,20 @@ public class InfoAndProgressPanel extends JPanel implements StatusBarPatch { SwingUtilities.invokeLater(new Runnable() { public void run() { Component comp = InfoAndProgressPanel.this; - int offset = comp.getHeight() / 2; - Point point = new Point(comp.getWidth() - offset, comp.getHeight() - offset); - balloon.show(new RelativePoint(comp, point), Balloon.Position.above); + if (comp.isShowing()) { + int offset = comp.getHeight() / 2; + Point point = new Point(comp.getWidth() - offset, comp.getHeight() - offset); + balloon.show(new RelativePoint(comp, point), Balloon.Position.above); + } else { + final JRootPane rootPane = SwingUtilities.getRootPane(comp); + if (rootPane != null && rootPane.isShowing()) { + final Container contentPane = rootPane.getContentPane(); + final Rectangle bounds = contentPane.getBounds(); + final Point target = UIUtil.getCenterPoint(bounds, new Dimension(1, 1)); + target.y = bounds.height - 3; + balloon.show(new RelativePoint(contentPane, target), Balloon.Position.above); + } + } } }); diff --git a/platform/platform-impl/src/com/intellij/ui/LightweightHint.java b/platform/platform-impl/src/com/intellij/ui/LightweightHint.java index 8533c9f2b1bf..fee011278f7f 100644 --- a/platform/platform-impl/src/com/intellij/ui/LightweightHint.java +++ b/platform/platform-impl/src/com/intellij/ui/LightweightHint.java @@ -226,4 +226,9 @@ public class LightweightHint extends UserDataHolderBase implements Hint { hide(); } } + + @Override + public String toString() { + return getComponent().toString(); + } } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 8263966c0ac3..44f99146b3f5 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -83,6 +83,7 @@ import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.*; import com.intellij.psi.impl.PsiManagerImpl; +import com.intellij.psi.impl.cache.impl.todo.TodoIndex; import com.intellij.psi.impl.source.PostprocessReformattingAspect; import com.intellij.psi.impl.source.PsiFileImpl; import com.intellij.psi.impl.source.resolve.FileContextUtil; @@ -1082,8 +1083,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @NotNull public static List instantiateAndRun(PsiFile file, Editor editor, int[] toIgnore, boolean allowDirt) { Project project = file.getProject(); - FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, null); - assertTrue(!DumbServiceImpl.getInstance(project).isDumb()); + ensureIndexesUpToDate(project); FileStatusMap fileStatusMap = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project)).getFileStatusMap(); for (int ignoreId : toIgnore) { fileStatusMap.markFileUpToDate(editor.getDocument(), file, ignoreId); @@ -1111,6 +1111,12 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig } } + private static void ensureIndexesUpToDate(Project project) { + FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, null); + FileBasedIndex.getInstance().ensureUpToDate(TodoIndex.NAME, project, null); + assertTrue(!DumbServiceImpl.getInstance(project).isDumb()); + } + public String getTestDataPath() { return myTestDataPath; } diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java index 0e35d68c1964..e11682b4567d 100644 --- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java +++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java @@ -301,6 +301,10 @@ public class ContainerUtil { }; } + public static Iterable iterate(T[] arrays, final Condition condition) { + return iterate(Arrays.asList(arrays), condition); + } + public static Iterable iterate(final Collection collection, final Condition condition) { if (collection.isEmpty()) return emptyIterable(); return new Iterable() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CachesHolder.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CachesHolder.java index b6a7a2173795..8c01d46714a7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CachesHolder.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CachesHolder.java @@ -50,8 +50,8 @@ public class CachesHolder { /** * Returns all paths that will be used to collect committed changes about. ideally, for one checkout there should be one file */ - public List getAllRootsUnderVcs(final AbstractVcs vcs) { - final RootsCalculator calculator = new RootsCalculator(myProject, vcs); + public Map getAllRootsUnderVcs(final AbstractVcs vcs) { + final RootsCalculator calculator = new RootsCalculator(myProject, vcs, myLocationCache); return calculator.getRoots(); } @@ -60,14 +60,12 @@ public class CachesHolder { for (AbstractVcs vcs : vcses) { final CommittedChangesProvider provider = vcs.getCommittedChangesProvider(); if (provider instanceof CachingCommittedChangesProvider) { - final List roots = getAllRootsUnderVcs(vcs); - for (VirtualFile root : roots) { - final RepositoryLocation location = myLocationCache.getLocation(vcs, new FilePathImpl(root), false); - if (location != null) { - final ChangesCacheFile cacheFile = getCacheFile(vcs, root, location); - if (Boolean.TRUE.equals(consumer.fun(cacheFile))) { - return; - } + final Map map = getAllRootsUnderVcs(vcs); + for (VirtualFile root : map.keySet()) { + final RepositoryLocation location = map.get(root); + final ChangesCacheFile cacheFile = getCacheFile(vcs, root, location); + if (Boolean.TRUE.equals(consumer.fun(cacheFile))) { + return; } } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java index 74484d6fc541..d4a9141b41fb 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java @@ -224,13 +224,12 @@ public class CommittedChangesCache implements PersistentStateComponent roots = myCachesHolder.getAllRootsUnderVcs(vcs); + final Map map = myCachesHolder.getAllRootsUnderVcs(vcs); - for (VirtualFile root : roots) { + for (VirtualFile root : map.keySet()) { if (myProject.isDisposed()) return; - final RepositoryLocation location = myLocationCache.getLocation(vcs, new FilePathImpl(root), false); - if (location == null) continue; + final RepositoryLocation location = map.get(root); try { final List lists = getChanges(mySettings, root, vcs, myMaxCount, myCacheOnly, provider, location); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/RootsCalculator.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/RootsCalculator.java index 618092c5169e..ec33c5ba92da 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/RootsCalculator.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/RootsCalculator.java @@ -17,14 +17,12 @@ package com.intellij.openapi.vcs.changes.committed; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.vcs.AbstractVcs; -import com.intellij.openapi.vcs.ProjectLevelVcsManager; -import com.intellij.openapi.vcs.VcsDirectoryMapping; +import com.intellij.openapi.util.Pair; +import com.intellij.openapi.vcs.*; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; -import java.util.ArrayList; -import java.util.List; +import java.util.*; public class RootsCalculator { private final static Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.committed.RootsCalculator"); @@ -32,14 +30,16 @@ public class RootsCalculator { private final AbstractVcs myVcs; private final ProjectLevelVcsManager myPlManager; private VirtualFile[] myContentRoots; + private final RepositoryLocationCache myLocationCache; - public RootsCalculator(final Project project, final AbstractVcs vcs) { + public RootsCalculator(final Project project, final AbstractVcs vcs, final RepositoryLocationCache locationCache) { myProject = project; + myLocationCache = locationCache; myPlManager = ProjectLevelVcsManager.getInstance(myProject); myVcs = vcs; } - public List getRoots() { + public Map getRoots() { myContentRoots = myPlManager.getRootsUnderVcs(myVcs); List roots = new ArrayList(); @@ -59,13 +59,22 @@ public class RootsCalculator { } } } - for (VirtualFile contentRoot : myContentRoots) { - roots.add(contentRoot); + roots.addAll(Arrays.asList(myContentRoots)); + final Map result = new HashMap(); + for (Iterator iterator = roots.iterator(); iterator.hasNext();) { + final VirtualFile vf = iterator.next(); + final RepositoryLocation location = myLocationCache.getLocation(myVcs, new FilePathImpl(vf), false); + if (location != null) { + result.put(vf, location); + } else { + iterator.remove(); + } } roots = myVcs.filterUniqueRoots(roots, IntoSelfVirtualFileConvertor.getInstance()); + result.keySet().retainAll(roots); logRoots(roots); - return roots; + return result; } private void logRoots(final List roots) { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/DeclareCollectionAsInterfaceInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/DeclareCollectionAsInterfaceInspection.java index c0ed0b6df4ac..0d41e1749d99 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/DeclareCollectionAsInterfaceInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/DeclareCollectionAsInterfaceInspection.java @@ -153,6 +153,9 @@ public class DeclareCollectionAsInterfaceInspection extends BaseInspection { extends BaseInspectionVisitor { @Override public void visitVariable(@NotNull PsiVariable variable) { + if (isOnTheFly() && variable.hasModifierProperty(PsiModifier.PUBLIC)) { + return; + } if (ignoreLocalVariables && variable instanceof PsiLocalVariable) { return; } @@ -228,8 +231,11 @@ public class DeclareCollectionAsInterfaceInspection extends BaseInspection { method.hasModifierProperty(PsiModifier.PRIVATE)) { return; } + if (isOnTheFly() && method.hasModifierProperty(PsiModifier.PUBLIC)) { + return; + } final PsiType type = method.getReturnType(); - if (!CollectionUtils.isCollectionClass(type)) { + if (type == null || !CollectionUtils.isCollectionClass(type)) { return; } if (LibraryUtil.isOverrideOfLibraryMethod(method)) { @@ -263,7 +269,10 @@ public class DeclareCollectionAsInterfaceInspection extends BaseInspection { final PsiClass objectClass = javaLangObject.resolve(); weaklingList.remove(objectClass); if (weaklingList.isEmpty()) { - registerError(nameElement, "java.util.Collection"); + final String typeText = type.getCanonicalText(); + final String interfaceText = + CollectionUtils.getInterfaceForClass(typeText); + registerError(nameElement, interfaceText); } else { final PsiClass weakling = weaklingList.get(0); registerError(nameElement, weakling.getQualifiedName()); diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/CollectionUtils.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/CollectionUtils.java index e15b5cf0e827..773141d9a446 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/CollectionUtils.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/CollectionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2009 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,22 +31,22 @@ public class CollectionUtils{ * @noinspection StaticCollection */ @NonNls private static final Set s_collectionClassesRequiringCapacity = - new HashSet(10); + new HashSet(); /** * @noinspection StaticCollection */ @NonNls private static final Set s_allCollectionClasses = - new HashSet(10); + new HashSet(); /** * @noinspection StaticCollection */ @NonNls private static final Set s_allCollectionClassesAndInterfaces = - new HashSet(10); + new HashSet(); /** * @noinspection StaticCollection */ @NonNls private static final Map s_interfaceForCollection = - new HashMap(10); + new HashMap(); static { s_collectionClassesRequiringCapacity.add("java.util.BitSet"); diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/WeakestTypeFinder.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/WeakestTypeFinder.java index e37bb1300f6b..09d6147ecf0b 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/WeakestTypeFinder.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/WeakestTypeFinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2008 Bas Leijdekkers + * Copyright 2008-2009 Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,9 +46,9 @@ public class WeakestTypeFinder { } else if (variableOrMethod instanceof PsiMethod) { final PsiMethod method = (PsiMethod) variableOrMethod; variableOrMethodType = method.getReturnType(); - if (PsiType.VOID.equals(variableOrMethodType)) { - return Collections.EMPTY_LIST; - } + if (PsiType.VOID.equals(variableOrMethodType)) { + return Collections.EMPTY_LIST; + } } else { throw new IllegalArgumentException( "PsiMethod or PsiVariable expected: " + diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/declare_collection_as_interface/DeclareCollectionsAsInterfaceInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/declare_collection_as_interface/DeclareCollectionsAsInterfaceInspection.java index efade503f3be..23329c6d42ac 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/declare_collection_as_interface/DeclareCollectionsAsInterfaceInspection.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/declare_collection_as_interface/DeclareCollectionsAsInterfaceInspection.java @@ -4,33 +4,33 @@ import java.util.*; public class DeclareCollectionsAsInterfaceInspection { - private HashSet m_setThree = new HashSet(2); - private HashSet m_setOne = new HashSet(2); - private Set m_setTwo = new HashSet(2); + private HashMap m_mapThree = new HashMap(2); + private HashMap m_setOne = new HashMap(2); + private Map m_setTwo = new HashMap(2); public DeclareCollectionsAsInterfaceInspection() { - m_setOne.add("foo"); - m_setTwo.add("bar"); + m_setOne.put("foo", "foo"); + m_setTwo.put("bar", "bar"); } public void fooBar() { - final HashSet set1 = new HashSet(2); - final Set set2 = new HashSet(2); - set1.add("foo"); - set2.add("bar"); + final HashMap map1 = new HashMap(2); + final Map map2 = new HashMap(2); + map1.put("foo", "foo"); + map2.put("bar", "bar"); } - public void fooBaz(TreeSet set1, Set set2) + public void fooBaz(HashMap set1, Map set2) { - set1.add("foo"); - set2.add("bar"); + set1.put("foo", "foo"); + set2.put("bar", "bar"); } - public HashSet fooBaz() + public HashMap fooBaz() { - return new HashSet(); + return new HashMap(); } void writeContent() { @@ -39,4 +39,12 @@ public class DeclareCollectionsAsInterfaceInspection } void processTemplate(Object o) {} + + void foo() { + Object o = theRoad(); + } + + HashMap theRoad() { + return null; + } } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/declare_collection_as_interface/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/declare_collection_as_interface/expected.xml index 7c63517b9342..40b14989373a 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/declare_collection_as_interface/expected.xml +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/declare_collection_as_interface/expected.xml @@ -1,25 +1,25 @@ - + DeclareCollectionsAsInterfaceInspection.java 8 Collection declared by class, not interface - Declaration of <code>HashSet</code> should probably be weakened to 'java.util.Collection' #loc + Declaration of <code>HashMap</code> should probably be weakened to 'java.util.Map' #loc DeclareCollectionsAsInterfaceInspection.java 25 Collection declared by class, not interface - Declaration of <code>TreeSet</code> should probably be weakened to 'java.util.Collection' #loc + Declaration of <code>HashMap</code> should probably be weakened to 'java.util.Map' #loc DeclareCollectionsAsInterfaceInspection.java 19 Collection declared by class, not interface - Declaration of <code>HashSet</code> should probably be weakened to 'java.util.Collection' #loc + Declaration of <code>HashMap</code> should probably be weakened to 'java.util.Map' #loc @@ -28,4 +28,11 @@ Collection declared by class, not interface Declaration of <code>HashMap</code> should probably be weakened to 'java.util.Map' #loc + + + DeclareCollectionsAsInterfaceInspection.java + 47 + Collection declared by class, not interface + Declaration of <code>HashMap</code> should probably be weakened to 'java.util.Map' #loc + \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/DeclareCollectionAsInterfaceInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/DeclareCollectionAsInterfaceInspectionTest.java index 1fd58f704ee6..618c2501bd34 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/DeclareCollectionAsInterfaceInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/DeclareCollectionAsInterfaceInspectionTest.java @@ -5,7 +5,7 @@ import com.IGInspectionTestCase; public class DeclareCollectionAsInterfaceInspectionTest extends IGInspectionTestCase { public void test() throws Exception { - //doTest("com/siyeh/igtest/abstraction/declare_collection_as_interface", - // new DeclareCollectionAsInterfaceInspection()); + doTest("com/siyeh/igtest/abstraction/declare_collection_as_interface", + new DeclareCollectionAsInterfaceInspection()); } } \ No newline at end of file diff --git a/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java b/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java index 00ae19650ae0..5408fea95a2f 100644 --- a/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java +++ b/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java @@ -308,7 +308,7 @@ public class GitRootTracker implements VcsListener { * @param directory the content root to check * @param rootSet the mapped root set */ - private static boolean hasUnmappedSubroots(final VirtualFile directory, final @Nullable HashSet rootSet) { + private static boolean hasUnmappedSubroots(final VirtualFile directory, final @NotNull HashSet rootSet) { VirtualFile[] children = ApplicationManager.getApplication().runReadAction(new Computable() { public VirtualFile[] compute() { return directory.isValid() ? directory.getChildren() : VirtualFile.EMPTY_ARRAY; @@ -319,8 +319,8 @@ public class GitRootTracker implements VcsListener { if (!child.isDirectory()) { continue; } - if (child.getName().equals(".git") && (rootSet == null || !rootSet.contains(child.getParent()))) { - return true; + if (child.getName().equals(".git")) { + return !rootSet.contains(child.getParent()); } if (hasUnmappedSubroots(child, rootSet)) { return true; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenSchemaProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenSchemaProvider.java index df5bbcf66d30..ae4d91a80d27 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenSchemaProvider.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenSchemaProvider.java @@ -21,6 +21,7 @@ import com.intellij.javaee.StandardResourceProvider; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.maven.utils.MavenLog; public class MavenSchemaProvider implements StandardResourceProvider { public static final String MAVEN_PROJECT_SCHEMA_URL = "http://maven.apache.org/xsd/maven-4.0.0.xsd"; @@ -37,7 +38,12 @@ public class MavenSchemaProvider implements StandardResourceProvider { @NotNull public static VirtualFile getSchemaFile(@NotNull String url) { - return VfsUtil.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(url), null); + String location = ExternalResourceManager.getInstance().getResourceLocation(url); + VirtualFile result = VfsUtil.findRelativeFile(location, null); + if (result == null) { + MavenLog.LOG.error("Cannot find a schema file for URL: " + url + " location: " + location); + } + return result; } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java index eb2b2d272566..d0b930a9bf39 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenPropertyPsiReference.java @@ -23,10 +23,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.Navigatable; -import com.intellij.psi.ElementManipulators; -import com.intellij.psi.PsiDirectory; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiManager; +import com.intellij.psi.*; import com.intellij.psi.xml.XmlDocument; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; @@ -368,7 +365,10 @@ public class MavenPropertyPsiReference extends MavenPsiReference { @Nullable private T processSchema(String schema, SchemaProcessor processor) { VirtualFile file = MavenSchemaProvider.getSchemaFile(schema); - XmlFile xmlFile = (XmlFile)PsiManager.getInstance(myProject).findFile(file); + PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file); + if (!(psiFile instanceof XmlFile)) return null; + + XmlFile xmlFile = (XmlFile)psiFile; XmlDocument document = xmlFile.getDocument(); XmlNSDescriptor desc = (XmlNSDescriptor)document.getMetaData(); XmlElementDescriptor[] descriptors = desc.getRootElementsDescriptors(document); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndex.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndex.java index 3c0a0ea78da3..6c0850fb80a2 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndex.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/indices/MavenIndex.java @@ -18,8 +18,10 @@ package org.jetbrains.idea.maven.indices; import com.intellij.openapi.progress.EmptyProgressIndicator; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.io.*; import gnu.trove.THashMap; import gnu.trove.THashSet; @@ -397,7 +399,10 @@ public class MavenIndex { myUpdateTimestamp = System.currentTimeMillis(); oldData.close(); - FileUtil.delete(getDataDir(oldDataDir)); + for (File each : getAllDataDirs()) { + if (each.getName().equals(newDataDirName)) continue; + FileUtil.delete(each); + } } } @@ -493,6 +498,14 @@ public class MavenIndex { return MavenIndices.findAvailableDir(myDir, DATA_DIR_PREFIX, 100).getName(); } + private Iterable getAllDataDirs() { + return ContainerUtil.iterate(myDir.listFiles(), new Condition() { + public boolean value(File file) { + return file.getName().startsWith(DATA_DIR_PREFIX); + } + }); + } + public synchronized void addArtifact(final File artifactFile) { doIndexTask(new IndexTask() { public Object doTask() throws Exception { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigatorPanel.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigatorPanel.java index 0aa838a10678..72dde8a81314 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigatorPanel.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigatorPanel.java @@ -68,7 +68,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement myTree.addMouseListener(new PopupHandler() { public void invokePopup(final Component comp, final int x, final int y) { - final String id = getMenuId(getSelectedNodes(MavenProjectsStructure.CustomNode.class)); + final String id = getMenuId(getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class)); if (id != null) { final ActionGroup actionGroup = (ActionGroup)actionManager.getAction(id); if (actionGroup != null) { @@ -78,9 +78,9 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement } @Nullable - private String getMenuId(Collection nodes) { + private String getMenuId(Collection nodes) { String id = null; - for (MavenProjectsStructure.CustomNode node : nodes) { + for (MavenProjectsStructure.MavenSimpleNode node : nodes) { String menuId = node.getMenuId(); if (menuId == null) { return null; @@ -124,7 +124,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement } private VirtualFile extractVirtualFile() { - for (MavenProjectsStructure.CustomNode each : getSelectedNodes(MavenProjectsStructure.CustomNode.class)) { + for (MavenProjectsStructure.MavenSimpleNode each : getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class)) { VirtualFile file = each.getVirtualFile(); if (file != null) return file; } @@ -138,7 +138,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement private Object extractVirtualFiles() { final List files = new ArrayList(); - for (MavenProjectsStructure.CustomNode each : getSelectedNodes(MavenProjectsStructure.CustomNode.class)) { + for (MavenProjectsStructure.MavenSimpleNode each : getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class)) { VirtualFile file = each.getVirtualFile(); if (file != null) files.add(file); } @@ -147,7 +147,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement private Object extractNavigatables() { final List navigatables = new ArrayList(); - for (MavenProjectsStructure.CustomNode each : getSelectedNodes(MavenProjectsStructure.CustomNode.class)) { + for (MavenProjectsStructure.MavenSimpleNode each : getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class)) { Navigatable navigatable = each.getNavigatable(); if (navigatable != null) navigatables.add(navigatable); } @@ -195,7 +195,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement return profiles; } - private List getSelectedNodes(Class aClass) { + private List getSelectedNodes(Class aClass) { return MavenProjectsStructure.getSelectedNodes(myTree, aClass); } @@ -213,7 +213,7 @@ public class MavenProjectsNavigatorPanel extends SimpleToolWindowPanel implement private MavenProjectsStructure.ProjectNode getContextProjectNode() { MavenProjectsStructure.ProjectNode projectNode = getSelectedProjectNode(); if (projectNode != null) return projectNode; - return MavenProjectsStructure.getCommonProjectNode(getSelectedNodes(MavenProjectsStructure.CustomNode.class)); + return MavenProjectsStructure.getCommonProjectNode(getSelectedNodes(MavenProjectsStructure.MavenSimpleNode.class)); } private int getStandardGoalOrder(String goal) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsStructure.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsStructure.java index 6708aac730dd..267ca30d4ae7 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsStructure.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/MavenProjectsStructure.java @@ -19,11 +19,9 @@ import com.intellij.ide.projectView.impl.nodes.NamedLibraryElement; import com.intellij.ide.util.treeView.NodeDescriptor; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.OrderEntry; -import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -35,6 +33,7 @@ import com.intellij.util.containers.ContainerUtil; import gnu.trove.THashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import org.jetbrains.idea.maven.embedder.MavenEmbedderFactory; import org.jetbrains.idea.maven.importing.MavenRootModelAdapter; import org.jetbrains.idea.maven.project.*; @@ -54,16 +53,12 @@ import static org.jetbrains.idea.maven.project.ProjectBundle.message; public class MavenProjectsStructure extends SimpleTreeStructure { private static final URL ERROR_ICON_URL = MavenProjectsStructure.class.getResource("/images/error.png"); - private static final CustomNode[] EMPTY_NODES_ARRAY = new CustomNode[0]; private static final Collection BASIC_PHASES = MavenEmbedderFactory.getBasicPhasesList(); private static final Collection PHASES = MavenEmbedderFactory.getPhasesList(); - private static final Comparator NODE_COMPARATOR = new Comparator() { - public int compare(CustomNode o1, CustomNode o2) { - if (o1 instanceof ProfilesNode) return -1; - if (o2 instanceof ProfilesNode) return 1; - - return o1.getTemplateName().compareToIgnoreCase(o2.getTemplateName()); + private static final Comparator NODE_COMPARATOR = new Comparator() { + public int compare(MavenSimpleNode o1, MavenSimpleNode o2) { + return Comparing.compare(o1.getName(), o2.getName()); } }; @@ -136,6 +131,14 @@ public class MavenProjectsStructure extends SimpleTreeStructure { myTreeBuilder.addSubtreeToUpdateByElement(node); } + private void updateUpTo(SimpleNode node) { + SimpleNode each = node; + while (each != null) { + updateFrom(each); + each = each.getParent(); + } + } + public void updateProjects(List updated, List deleted) { for (MavenProject each : updated) { ProjectNode node = findNodeFor(each); @@ -149,9 +152,8 @@ public class MavenProjectsStructure extends SimpleTreeStructure { for (MavenProject each : deleted) { ProjectNode node = myProjectToNodeMapping.remove(each); if (node != null) { - ProjectsGroupNode parent = node.getStructuralParent(); + ProjectsGroupNode parent = node.getGroup(); parent.remove(node); - updateFrom(parent); } } @@ -173,44 +175,40 @@ public class MavenProjectsStructure extends SimpleTreeStructure { } } - node.updateNode(); + node.updateProject(); reconnectNode(node, newParentNode); ProjectsGroupNode newModulesParentNode = myProjectsNavigator.getGroupModules() && node.isVisible() ? node.getModulesNode() : myRoot; for (MavenProject each : myProjectsManager.getModules(project)) { ProjectNode moduleNode = findNodeFor(each); - if (moduleNode != null && !moduleNode.getStructuralParent().equals(newModulesParentNode)) { + if (moduleNode != null && !moduleNode.getParent().equals(newModulesParentNode)) { reconnectNode(moduleNode, newModulesParentNode); } } } private void reconnectNode(ProjectNode node, ProjectsGroupNode newParentNode) { - ProjectsGroupNode oldParentNode = node.getStructuralParent(); + ProjectsGroupNode oldParentNode = node.getGroup(); if (oldParentNode == null || !oldParentNode.equals(newParentNode)) { if (oldParentNode != null) { oldParentNode.remove(node); - updateFrom(oldParentNode); } newParentNode.add(node); - updateFrom(newParentNode); } else { newParentNode.sortProjects(); - updateFrom(newParentNode); } } public void setActiveProfiles(List profiles) { myRoot.setActiveProfiles(profiles); - updateFrom(myRoot.getProfilesNode()); } public void updateIgnored(List projects) { for (MavenProject each : projects) { ProjectNode node = findNodeFor(each); if (node == null) continue; - updateFrom(node.getStructuralParent()); + node.updateIgnored(); } } @@ -221,7 +219,6 @@ public class MavenProjectsStructure extends SimpleTreeStructure { public void updateGoals() { for (ProjectNode each : myProjectToNodeMapping.values()) { each.updateGoals(); - updateFrom(each); } } @@ -242,7 +239,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure { ALWAYS, NEVER, NORMAL } - protected Class[] getVisibleNodesClasses() { + protected Class[] getVisibleNodesClasses() { return null; } @@ -254,7 +251,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure { return myProjectsNavigator.getShowBasicPhasesOnly(); } - public static List getSelectedNodes(SimpleTree tree, Class nodeClass) { + public static List getSelectedNodes(SimpleTree tree, Class nodeClass) { final List filtered = new ArrayList(); for (SimpleNode node : getSelectedNodes(tree)) { if ((nodeClass != null) && (!nodeClass.isInstance(node))) { @@ -278,16 +275,11 @@ public class MavenProjectsStructure extends SimpleTreeStructure { return nodes; } - private static void insertSorted(List list, T newObject) { - int pos = Collections.binarySearch(list, newObject, NODE_COMPARATOR); - list.add(pos >= 0 ? pos : -pos - 1, newObject); - } - @Nullable - public static ProjectNode getCommonProjectNode(Collection nodes) { + public static ProjectNode getCommonProjectNode(Collection nodes) { ProjectNode parent = null; - for (CustomNode node : nodes) { - ProjectNode nextParent = node.getParent(ProjectNode.class); + for (MavenSimpleNode node : nodes) { + ProjectNode nextParent = node.findParent(ProjectNode.class); if (parent == null) { parent = nextParent; } @@ -302,35 +294,29 @@ public class MavenProjectsStructure extends SimpleTreeStructure { NONE, ERROR } - public abstract class CustomNode extends SimpleNode { - protected Project myProject; - private CustomNode myStructuralParent; - private ErrorLevel myNodeErrorLevel = ErrorLevel.NONE; - private ErrorLevel myOverallErrorLevelCache = null; + public abstract class MavenSimpleNode extends CachingSimpleNode { + private MavenSimpleNode myParent; + private ErrorLevel myErrorLevel = ErrorLevel.NONE; + private ErrorLevel myTotalErrorLevel = null; - public CustomNode(CustomNode parent) { - super(parent); - myProject = MavenProjectsStructure.this.myProject; - setStructuralParent(parent); + public MavenSimpleNode(MavenSimpleNode parent) { + super(MavenProjectsStructure.this.myProject, null); + setParent(parent); } - public void setStructuralParent(CustomNode structuralParent) { - myStructuralParent = structuralParent; - } - - public CustomNode getStructuralParent() { - return myStructuralParent; + public void setParent(MavenSimpleNode parent) { + myParent = parent; } @Override public NodeDescriptor getParentDescriptor() { - return myStructuralParent; + return myParent; } - public T getParent(Class parentClass) { - CustomNode node = this; + public T findParent(Class parentClass) { + MavenSimpleNode node = this; while (true) { - node = node.myStructuralParent; + node = node.myParent; if (node == null || parentClass.isInstance(node)) { //noinspection unchecked return (T)node; @@ -352,77 +338,68 @@ public class MavenProjectsStructure extends SimpleTreeStructure { return DisplayKind.NEVER; } - public CustomNode[] getChildren() { - List children = getStructuralChildren(); - if (children.isEmpty()) return EMPTY_NODES_ARRAY; - List result = new ArrayList(); - for (CustomNode each : children) { + @Override + protected SimpleNode[] buildChildren() { + List children = doGetChildren(); + if (children.isEmpty()) return NO_CHILDREN; + + List result = new ArrayList(); + for (MavenSimpleNode each : children) { if (each.isVisible()) result.add(each); } - return result.toArray(new CustomNode[result.size()]); + return result.toArray(new MavenSimpleNode[result.size()]); } - protected List getStructuralChildren() { + protected List doGetChildren() { return Collections.emptyList(); } - protected void resetChildrenCaches() { - myOverallErrorLevelCache = null; + @Override + public void cleanUpCache() { + super.cleanUpCache(); + myTotalErrorLevel = null; } - public ErrorLevel getOverallErrorLevel() { - if (myOverallErrorLevelCache == null) { - myOverallErrorLevelCache = calcOverallErrorLevel(); + protected void childrenChanged() { + MavenSimpleNode each = this; + while (each != null) { + each.cleanUpCache(); + each = (MavenSimpleNode)each.getParent(); } - return myOverallErrorLevelCache; + updateUpTo(this); } - private ErrorLevel calcOverallErrorLevel() { + public ErrorLevel getTotalErrorLevel() { + if (myTotalErrorLevel == null) { + myTotalErrorLevel = calcTotalErrorLevel(); + } + return myTotalErrorLevel; + } + + private ErrorLevel calcTotalErrorLevel() { ErrorLevel childrenErrorLevel = getChildrenErrorLevel(); - return childrenErrorLevel.compareTo(myNodeErrorLevel) > 0 ? childrenErrorLevel : myNodeErrorLevel; + return childrenErrorLevel.compareTo(myErrorLevel) > 0 ? childrenErrorLevel : myErrorLevel; } public ErrorLevel getChildrenErrorLevel() { ErrorLevel result = ErrorLevel.NONE; - for (CustomNode each : getStructuralChildren()) { - ErrorLevel eachLevel = each.getOverallErrorLevel(); + for (SimpleNode each : getChildren()) { + ErrorLevel eachLevel = ((MavenSimpleNode)each).getTotalErrorLevel(); if (eachLevel.compareTo(result) > 0) result = eachLevel; } return result; } - public String getTemplateName() { - if (getTemplatePresentation().getColoredText().size() > 0) { - StringBuilder result = new StringBuilder(""); - for (ColoredFragment each : getTemplatePresentation().getColoredText()) { - result.append(each.getText()); - } - return result.toString(); - } - else { - return myName; - } + public void setErrorLevel(ErrorLevel level) { + if (myErrorLevel == level) return; + myErrorLevel = level; + updateUpTo(this); } - public void setNodeErrorLevel(ErrorLevel level) { - if (myNodeErrorLevel == level) return; - myNodeErrorLevel = level; - - CustomNode each = this; - while (each != null) { - each.resetChildrenCaches(); - each.updateNameAndDescription(); - each = each.myStructuralParent; - } - } - - protected abstract void updateNameAndDescription(); - @Override protected void doUpdate() { - super.doUpdate(); - updateNameAndDescription(); + setNameAndTooltip(getName(), null); } protected void setNameAndTooltip(String name, @Nullable String tooltip) { @@ -434,7 +411,6 @@ public class MavenProjectsStructure extends SimpleTreeStructure { if (showDescriptions() && !StringUtil.isEmptyOrSpaces(hint)) { addColoredFragment(" (" + hint + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); } - getTemplatePresentation().setTooltip(tooltip); } protected void setNameAndTooltip(String name, @Nullable String tooltip, SimpleTextAttributes attribs) { @@ -444,7 +420,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure { } private SimpleTextAttributes prepareAttribs(SimpleTextAttributes from) { - ErrorLevel level = getOverallErrorLevel(); + ErrorLevel level = getTotalErrorLevel(); Color waveColor = level == ErrorLevel.NONE ? null : Color.RED; int style = from.getStyle(); if (waveColor != null) style |= SimpleTextAttributes.STYLE_WAVED; @@ -471,8 +447,8 @@ public class MavenProjectsStructure extends SimpleTreeStructure { @Nullable public Navigatable getNavigatable() { VirtualFile file = getVirtualFile(); - if (file == null) return null; - return PsiManager.getInstance(myProject).findFile(file); + if (file == null || !file.isValid()) return null; + return PsiManager.getInstance(getProject()).findFile(file); } public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) { @@ -483,8 +459,8 @@ public class MavenProjectsStructure extends SimpleTreeStructure { } } - public abstract class GroupNode extends CustomNode { - public GroupNode(CustomNode parent) { + public abstract class GroupNode extends MavenSimpleNode { + public GroupNode(MavenSimpleNode parent) { super(parent); } @@ -492,45 +468,57 @@ public class MavenProjectsStructure extends SimpleTreeStructure { public boolean isVisible() { if (getDisplayKind() == DisplayKind.ALWAYS) return true; - for (CustomNode each : getStructuralChildren()) { - if (each.isVisible()) { - return true; - } + for (SimpleNode each : getChildren()) { + if (((MavenSimpleNode)each).isVisible()) return true; } return false; } + + protected void insertSorted(List list, T newObject) { + int pos = Collections.binarySearch(list, newObject, NODE_COMPARATOR); + list.add(pos >= 0 ? pos : -pos - 1, newObject); + } + + protected void sort(List list) { + Collections.sort(list, NODE_COMPARATOR); + } } public abstract class ProjectsGroupNode extends GroupNode { - protected final List myProjectNodes = new ArrayList(); + private final List myProjectNodes = new ArrayList(); - public ProjectsGroupNode(CustomNode parent) { + public ProjectsGroupNode(MavenSimpleNode parent) { super(parent); setIcons(MavenIcons.CLOSED_MODULES_ICON, MavenIcons.OPEN_MODULES_ICON); } - protected List getStructuralChildren() { + @Override + protected List doGetChildren() { return myProjectNodes; } - public List getProjectNodes() { + @TestOnly + public List getProjectNodesInTests() { return myProjectNodes; } protected void add(ProjectNode projectNode) { - projectNode.setStructuralParent(this); + projectNode.setParent(this); insertSorted(myProjectNodes, projectNode); - resetChildrenCaches(); + + childrenChanged(); } public void remove(ProjectNode projectNode) { - projectNode.setStructuralParent(null); + projectNode.setParent(null); myProjectNodes.remove(projectNode); - resetChildrenCaches(); + + childrenChanged(); } public void sortProjects() { - Collections.sort(myProjectNodes, NODE_COMPARATOR); + sort(myProjectNodes); + childrenChanged(); } } @@ -540,11 +528,6 @@ public class MavenProjectsStructure extends SimpleTreeStructure { public RootNode() { super(null); myProfilesNode = new ProfilesNode(this); - updateNameAndDescription(); - } - - protected void updateNameAndDescription() { - setNameAndTooltip(message("view.node.root"), null); } @Override @@ -552,12 +535,9 @@ public class MavenProjectsStructure extends SimpleTreeStructure { return true; } - protected List getStructuralChildren() { - return ContainerUtil.concat(Collections.singletonList(myProfilesNode), myProjectNodes); - } - - public ProfilesNode getProfilesNode() { - return myProfilesNode; + @Override + protected List doGetChildren() { + return ContainerUtil.concat(Collections.singletonList(myProfilesNode), super.doGetChildren()); } public void updateProfiles() { @@ -569,6 +549,87 @@ public class MavenProjectsStructure extends SimpleTreeStructure { } } + public class ProfilesNode extends GroupNode { + private final List myProfileNodes = new ArrayList(); + + public ProfilesNode(MavenSimpleNode parent) { + super(parent); + setIcons(MavenIcons.CLOSED_PROFILES_ICON, MavenIcons.OPEN_PROFILES_ICON); + } + + protected List doGetChildren() { + return myProfileNodes; + } + + @Override + public String getName() { + return message("view.node.profiles"); + } + + public void updateProfiles() { + List allProfiles = myProjectsManager.getAvailableProfiles(); + for (ProfileNode each : new ArrayList(myProfileNodes)) { + if (!allProfiles.contains(each.getProfileName())) myProfileNodes.remove(each); + } + for (String each : allProfiles) { + if (!hasNodeFor(each)) { + myProfileNodes.add(new ProfileNode(this, each)); + } + } + sort(myProfileNodes); + childrenChanged(); + + setActiveProfiles(myProjectsManager.getActiveProfiles()); + } + + private boolean hasNodeFor(String profileName) { + for (ProfileNode each : myProfileNodes) { + if (each.getProfileName().equals(profileName)) return true; + } + return false; + } + + public void setActiveProfiles(List activeProfiles) { + for (ProfileNode each : myProfileNodes) { + each.setActive(activeProfiles.contains(each.getProfileName())); + } + updateFrom(this); + } + } + + public class ProfileNode extends MavenSimpleNode { + private final String myProfileName; + private boolean isActive; + + public ProfileNode(ProfilesNode parent, String profileName) { + super(parent); + myProfileName = profileName; + } + + @Override + public String getName() { + return myProfileName; + } + + public String getProfileName() { + return myProfileName; + } + + public boolean isActive() { + return isActive; + } + + private void setActive(boolean active) { + isActive = active; + } + + @Nullable + @NonNls + protected String getActionId() { + return "Maven.ToggleProfile"; + } + } + public class ProjectNode extends GroupNode { private final MavenProject myMavenProject; private final LifecycleNode myLifecycleNode; @@ -576,6 +637,8 @@ public class MavenProjectsStructure extends SimpleTreeStructure { private final DependenciesNode myDependenciesNode; private final ModulesNode myModulesNode; + private String myTooltipCache; + public ProjectNode(MavenProject mavenProject) { super(null); myMavenProject = mavenProject; @@ -585,56 +648,61 @@ public class MavenProjectsStructure extends SimpleTreeStructure { myDependenciesNode = new DependenciesNode(this); myModulesNode = new ModulesNode(this); - updateNode(); setUniformIcon(MavenIcons.MAVEN_PROJECT_ICON); - } - - @Override - public ProjectsGroupNode getStructuralParent() { - return (ProjectsGroupNode)super.getStructuralParent(); - } - - @Override - public boolean isVisible() { - return super.isVisible() && (myProjectsNavigator.getShowIgnored() || !myProjectsManager.isIgnored(myMavenProject)); - } - - protected List getStructuralChildren() { - return Arrays.asList(myLifecycleNode, myPluginsNode, myDependenciesNode, myModulesNode); - } - - public ModulesNode getModulesNode() { - return myModulesNode; - } - - public String getProjectName() { - return myMavenProject.getDisplayName(); + updateProject(); } public MavenProject getMavenProject() { return myMavenProject; } + public ProjectsGroupNode getGroup() { + return (ProjectsGroupNode)super.getParent(); + } + @Override - public VirtualFile getVirtualFile() { - return myMavenProject.getFile(); + public boolean isVisible() { + if (!myProjectsNavigator.getShowIgnored() && myProjectsManager.isIgnored(myMavenProject)) return false; + return super.isVisible(); } - @Nullable - @NonNls - protected String getMenuId() { - return "Maven.NavigatorProjectMenu"; + @Override + protected List doGetChildren() { + return Arrays.asList(myLifecycleNode, myPluginsNode, myDependenciesNode, myModulesNode); } - private void updateNode() { - updateErrorLevel(); - updateNameAndDescription(); + + public ModulesNode getModulesNode() { + return myModulesNode; + } + + private void updateProject() { + setErrorLevel(myMavenProject.getProblems().isEmpty() ? ErrorLevel.NONE : ErrorLevel.ERROR); myPluginsNode.updatePlugins(myMavenProject); myDependenciesNode.updateDependencies(myMavenProject); + + myTooltipCache = makeDescription(); + + updateFrom(getParent()); } - private void updateErrorLevel() { - setNodeErrorLevel(myMavenProject.getProblems().isEmpty() ? ErrorLevel.NONE : ErrorLevel.ERROR); + public void updateIgnored() { + getGroup().childrenChanged(); + } + + public void updateGoals() { + updateFrom(myLifecycleNode); + updateFrom(myPluginsNode); + } + + @Override + public String getName() { + return myMavenProject.getDisplayName(); + } + + @Override + protected void doUpdate() { + setNameAndTooltip(getName(), myTooltipCache); } @Override @@ -645,11 +713,6 @@ public class MavenProjectsStructure extends SimpleTreeStructure { return super.getPlainAttributes(); } - @Override - protected void updateNameAndDescription() { - setNameAndTooltip(getProjectName(), makeDescription()); - } - private String makeDescription() { StringBuilder desc = new StringBuilder(); desc.append(""); @@ -670,26 +733,11 @@ public class MavenProjectsStructure extends SimpleTreeStructure { desc.append(""); appendProblems(desc); - if (getModulesErrorLevel() != ErrorLevel.NONE) { - desc.append(""); - desc.append("Some modules have problems."); - desc.append(""); - } - desc.append(""); desc.append(""); return desc.toString(); } - private ErrorLevel getModulesErrorLevel() { - ErrorLevel result = ErrorLevel.NONE; - for (ProjectNode each : myModulesNode.myProjectNodes) { - ErrorLevel moduleLevel = each.getOverallErrorLevel(); - if (moduleLevel.compareTo(result) > 0) result = moduleLevel; - } - return result; - } - private void appendProblems(StringBuilder desc) { List problems = myMavenProject.getProblems(); if (problems.isEmpty()) return; @@ -734,9 +782,15 @@ public class MavenProjectsStructure extends SimpleTreeStructure { return result.toString(); } - public void updateGoals() { - myLifecycleNode.updateGoals(); - myPluginsNode.updateGoals(); + @Override + public VirtualFile getVirtualFile() { + return myMavenProject.getFile(); + } + + @Nullable + @NonNls + protected String getMenuId() { + return "Maven.NavigatorProjectMenu"; } } @@ -747,40 +801,33 @@ public class MavenProjectsStructure extends SimpleTreeStructure { } @Override - protected void updateNameAndDescription() { - setNameAndTooltip(message("view.node.modules"), null); + public String getName() { + return message("view.node.modules"); } } public abstract class GoalsGroupNode extends GroupNode { protected final List myGoalNodes = new ArrayList(); - public GoalsGroupNode(CustomNode parent) { + public GoalsGroupNode(MavenSimpleNode parent) { super(parent); } - protected List getStructuralChildren() { + protected List doGetChildren() { return myGoalNodes; } - - public void updateGoals() { - for (GoalNode each : myGoalNodes) { - each.update(); - } - } } - public abstract class GoalNode extends CustomNode { + public abstract class GoalNode extends MavenSimpleNode { private final MavenProject myMavenProject; private final String myGoal; private final String myDisplayName; public GoalNode(GoalsGroupNode parent, String goal, String displayName) { super(parent); - myMavenProject = getParent(ProjectNode.class).getMavenProject(); + myMavenProject = findParent(ProjectNode.class).getMavenProject(); myGoal = goal; myDisplayName = displayName; - updateNameAndDescription(); setUniformIcon(MavenIcons.PHASE_ICON); } @@ -788,12 +835,20 @@ public class MavenProjectsStructure extends SimpleTreeStructure { return myMavenProject.getPath(); } + public String getGoal() { + return myGoal; + } + @Override - protected void updateNameAndDescription() { - String hint = StringUtil.join( - Arrays.asList(myShortcutsManager.getDescription(myMavenProject, myGoal), myTasksManager.getDescription(myMavenProject, myGoal)), - ", "); - setNameAndTooltip(myDisplayName, null, hint); + public String getName() { + return myDisplayName; + } + + @Override + protected void doUpdate() { + String hint = StringUtil.join(Arrays.asList(myShortcutsManager.getDescription(myMavenProject, myGoal), + myTasksManager.getDescription(myMavenProject, myGoal)), ", "); + setNameAndTooltip(getName(), null, hint); } @Override @@ -804,10 +859,6 @@ public class MavenProjectsStructure extends SimpleTreeStructure { return super.getPlainAttributes(); } - public String getGoal() { - return myGoal; - } - @Nullable @NonNls protected String getActionId() { @@ -828,13 +879,12 @@ public class MavenProjectsStructure extends SimpleTreeStructure { for (String goal : PHASES) { myGoalNodes.add(new StandardGoalNode(this, goal)); } - updateNameAndDescription(); setIcons(MavenIcons.CLOSED_PHASES_ICON, MavenIcons.OPEN_PHASES_ICON); } @Override - protected void updateNameAndDescription() { - setNameAndTooltip(message("view.node.lifecycle"), null); + public String getName() { + return message("view.node.lifecycle"); } } @@ -843,87 +893,10 @@ public class MavenProjectsStructure extends SimpleTreeStructure { super(parent, goal, goal); } + @Override public boolean isVisible() { - return super.isVisible() && (!showOnlyBasicPhases() || BASIC_PHASES.contains(getGoal())); - } - } - - public class ProfilesNode extends GroupNode { - private final List myProfileNodes = new ArrayList(); - - public ProfilesNode(CustomNode parent) { - super(parent); - updateNameAndDescription(); - setIcons(MavenIcons.CLOSED_PROFILES_ICON, MavenIcons.OPEN_PROFILES_ICON); - } - - @Override - protected void updateNameAndDescription() { - setNameAndTooltip(message("view.node.profiles"), null); - } - - protected List getStructuralChildren() { - return myProfileNodes; - } - - public void updateProfiles() { - List allProfiles = myProjectsManager.getAvailableProfiles(); - for (ProfileNode each : new ArrayList(myProfileNodes)) { - if (!allProfiles.contains(each.getProfileName())) myProfileNodes.remove(each); - } - for (String each : allProfiles) { - if (!hasNodeFor(each)) { - insertSorted(myProfileNodes, new ProfileNode(this, each)); - } - } - setActiveProfiles(myProjectsManager.getActiveProfiles()); - } - - private boolean hasNodeFor(String profileName) { - for (ProfileNode each : myProfileNodes) { - if (each.getProfileName().equals(profileName)) return true; - } - return false; - } - - public void setActiveProfiles(List activeProfiles) { - for (ProfileNode each : myProfileNodes) { - each.setActive(activeProfiles.contains(each.getProfileName())); - } - } - } - - public class ProfileNode extends CustomNode { - private final String myProfileName; - private boolean isActive; - - public ProfileNode(ProfilesNode parent, String profileName) { - super(parent); - myProfileName = profileName; - updateNameAndDescription(); - } - - @Override - protected void updateNameAndDescription() { - setNameAndTooltip(myProfileName, null); - } - - public String getProfileName() { - return myProfileName; - } - - @Nullable - @NonNls - protected String getActionId() { - return "Maven.ToggleProfile"; - } - - public boolean isActive() { - return isActive; - } - - private void setActive(boolean active) { - isActive = active; + if (showOnlyBasicPhases() && !BASIC_PHASES.contains(getGoal())) return false; + return super.isVisible(); } } @@ -932,29 +905,35 @@ public class MavenProjectsStructure extends SimpleTreeStructure { public PluginsNode(ProjectNode parent) { super(parent); - updateNameAndDescription(); setIcons(MavenIcons.CLOSED_PLUGINS_ICON, MavenIcons.OPEN_PLUGINS_ICON); } @Override - protected void updateNameAndDescription() { - setNameAndTooltip(message("view.node.plugins"), null); + public String getName() { + return message("view.node.plugins"); } - protected List getStructuralChildren() { + protected List doGetChildren() { return myPluginNodes; } public void updatePlugins(MavenProject mavenProject) { List plugins = mavenProject.getPlugins(); for (PluginNode each : new ArrayList(myPluginNodes)) { - if (!plugins.contains(each.getPlugin())) myPluginNodes.remove(each); + if (plugins.contains(each.getPlugin())) { + each.updatePlugin(); + } + else { + myPluginNodes.remove(each); + } } for (MavenPlugin each : plugins) { if (!hasNodeFor(each)) { - insertSorted(myPluginNodes, new PluginNode(this, each)); + myPluginNodes.add(new PluginNode(this, each)); } } + sort(myPluginNodes); + childrenChanged(); } private boolean hasNodeFor(MavenPlugin plugin) { @@ -965,12 +944,6 @@ public class MavenProjectsStructure extends SimpleTreeStructure { } return false; } - - public void updateGoals() { - for (PluginNode each : myPluginNodes) { - each.updateGoals(); - } - } } public class PluginNode extends GoalsGroupNode { @@ -981,34 +954,51 @@ public class MavenProjectsStructure extends SimpleTreeStructure { super(parent); myPlugin = plugin; - updateNameAndDescription(); setUniformIcon(MavenIcons.PLUGIN_ICON); - } - - @Override - protected void updateNameAndDescription() { - boolean hadPluginInfo = myPluginInfo != null; - - myPluginInfo = MavenArtifactUtil.readPluginInfo(myProjectsManager.getLocalRepository(), myPlugin.getMavenId()); - if (myPluginInfo == null) { - setNameAndTooltip(myPlugin.getDisplayString(), null); - } - else { - setNameAndTooltip(myPluginInfo.getGoalPrefix(), null, myPlugin.getDisplayString()); - } - setNodeErrorLevel(myPluginInfo == null ? ErrorLevel.ERROR : ErrorLevel.NONE); - - // there is no need to update goals since plugins do not change - if (hadPluginInfo || myPluginInfo == null) return; - - for (MavenPluginInfo.Mojo mojo : myPluginInfo.getMojos()) { - myGoalNodes.add(new PluginGoalNode(this, mojo.getQualifiedGoal(), mojo.getDisplayName())); - } + updatePlugin(); } public MavenPlugin getPlugin() { return myPlugin; } + + @Override + public String getName() { + return myPluginInfo == null ? myPlugin.getDisplayString() : myPluginInfo.getGoalPrefix(); + } + + @Override + protected void doUpdate() { + setNameAndTooltip(getName(), null, myPluginInfo != null ? myPlugin.getDisplayString() : null); + } + + public void updatePlugin() { + boolean hadPluginInfo = myPluginInfo != null; + + myPluginInfo = MavenArtifactUtil.readPluginInfo(myProjectsManager.getLocalRepository(), myPlugin.getMavenId()); + + boolean hasPluginInfo = myPluginInfo != null; + + setErrorLevel(myPluginInfo == null ? ErrorLevel.ERROR : ErrorLevel.NONE); + + if (hadPluginInfo == hasPluginInfo) return; + + myGoalNodes.clear(); + if (myPluginInfo != null) { + for (MavenPluginInfo.Mojo mojo : myPluginInfo.getMojos()) { + myGoalNodes.add(new PluginGoalNode(this, mojo.getQualifiedGoal(), mojo.getDisplayName())); + } + } + + updateFrom(this); + childrenChanged(); + } + + @Override + public boolean isVisible() { + // show regardless absence of children + return getDisplayKind() != DisplayKind.NEVER; + } } public class PluginGoalNode extends GoalNode { @@ -1021,12 +1011,12 @@ public class MavenProjectsStructure extends SimpleTreeStructure { public abstract class BaseDependenciesNode extends GroupNode { private final List myChildren = new ArrayList(); - protected BaseDependenciesNode(CustomNode parent) { + protected BaseDependenciesNode(MavenSimpleNode parent) { super(parent); } @Override - protected List getStructuralChildren() { + protected List doGetChildren() { return myChildren; } @@ -1034,12 +1024,14 @@ public class MavenProjectsStructure extends SimpleTreeStructure { List newNodes = new ArrayList(children.size()); for (MavenArtifactNode each : children) { DependencyNode newNode = findOrCreateNodeFor(each, mavenProject); - newNode.updateNameAndDescription(); newNodes.add(newNode); newNode.updateChildren(each.getDependencies(), mavenProject); + newNode.updateDependency(); } myChildren.clear(); myChildren.addAll(newNodes); + + childrenChanged(); } private DependencyNode findOrCreateNodeFor(MavenArtifactNode artifact, MavenProject mavenProject) { @@ -1051,22 +1043,18 @@ public class MavenProjectsStructure extends SimpleTreeStructure { } public class DependenciesNode extends BaseDependenciesNode { - private final ProjectNode myProjectNode; - public DependenciesNode(ProjectNode parent) { super(parent); - myProjectNode = parent; setIcons(MavenIcons.CLOSED_DEPENDENCIES_ICON, MavenIcons.OPEN_DEPENDENCIES_ICON); - updateNameAndDescription(); } @Override - protected void updateNameAndDescription() { - setNameAndTooltip(message("view.node.dependencies"), null); + public String getName() { + return message("view.node.dependencies"); } public void updateDependencies(MavenProject mavenProject) { - updateChildren(mavenProject.getDependenciesNodes(), myProjectNode.getMavenProject()); + updateChildren(mavenProject.getDependenciesNodes(), mavenProject); } } @@ -1074,20 +1062,26 @@ public class MavenProjectsStructure extends SimpleTreeStructure { private final MavenArtifact myArtifact; private final MavenProject myMavenProject; - public DependencyNode(CustomNode parent, MavenArtifactNode artifactNode, MavenProject mavenProject) { + public DependencyNode(MavenSimpleNode parent, MavenArtifactNode artifactNode, MavenProject mavenProject) { super(parent); myMavenProject = mavenProject; myArtifact = artifactNode.getArtifact(); setUniformIcon(MavenIcons.DEPENDENCY_ICON); - updateNameAndDescription(); } @Override - protected void updateNameAndDescription() { + public String getName() { + return myArtifact.getDisplayStringForLibraryName(); + } + + @Override + protected void doUpdate() { String scope = myArtifact.getScope(); - setNameAndTooltip(myArtifact.getDisplayStringForLibraryName(), null, - MavenConstants.SCOPE_COMPILE.equals(scope) ? null : scope); - setNodeErrorLevel(myArtifact.isResolved() ? ErrorLevel.NONE : ErrorLevel.ERROR); + setNameAndTooltip(getName(), null, MavenConstants.SCOPE_COMPILE.equals(scope) ? null : scope); + } + + private void updateDependency() { + setErrorLevel(myArtifact.isResolved() ? ErrorLevel.NONE : ErrorLevel.ERROR); } @Override @@ -1113,6 +1107,7 @@ public class MavenProjectsStructure extends SimpleTreeStructure { @Override public boolean isVisible() { + // show regardless absence of children return getDisplayKind() != DisplayKind.NEVER; } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/SelectFromMavenProjectsDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/SelectFromMavenProjectsDialog.java index 6f34d7c60806..6af883ec78db 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/SelectFromMavenProjectsDialog.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/SelectFromMavenProjectsDialog.java @@ -36,7 +36,7 @@ public class SelectFromMavenProjectsDialog extends DialogWrapper { public SelectFromMavenProjectsDialog(Project project, String title, - final Class nodeClass, + final Class nodeClass, NodeSelector selector) { super(project, false); myProject = project; @@ -53,7 +53,7 @@ public class SelectFromMavenProjectsDialog extends DialogWrapper { MavenProjectsNavigator.getInstance(myProject), myTree) { @Override - protected Class[] getVisibleNodesClasses() { + protected Class[] getVisibleNodesClasses() { return new Class[]{nodeClass}; } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/SelectMavenProjectDialog.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/SelectMavenProjectDialog.java index 93699ef76288..5c3c3c791ec7 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/SelectMavenProjectDialog.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/navigator/SelectMavenProjectDialog.java @@ -57,7 +57,7 @@ public class SelectMavenProjectDialog extends SelectFromMavenProjectsDialog { if (node != null) { if (!(node instanceof MavenProjectsStructure.ProjectNode)) { - ((MavenProjectsStructure.CustomNode)node).getParent(MavenProjectsStructure.ProjectNode.class); + ((MavenProjectsStructure.MavenSimpleNode)node).findParent(MavenProjectsStructure.ProjectNode.class); } } myResult = node != null ? ((MavenProjectsStructure.ProjectNode)node).getMavenProject() : null; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenImportNotifier.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenImportNotifier.java index d9acd3a371a4..b19a830ff76e 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenImportNotifier.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenImportNotifier.java @@ -30,6 +30,7 @@ import org.jetbrains.idea.maven.project.MavenProjectsManager; import org.jetbrains.idea.maven.project.ProjectBundle; import javax.swing.*; +import javax.swing.border.LineBorder; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import java.awt.*; @@ -119,24 +120,17 @@ public class MavenImportNotifier extends SimpleProjectComponent { private JLabel myLabel; private NotifierPanel() { - super(new BorderLayout()); + super(new GridBagLayout()); setBackground(LightColors.YELLOW); setBorder(BorderFactory.createEmptyBorder(7, 15, 7, 15)); - myLabel = new JLabel(MavenIcons.MAVEN_ICON); - - add(myLabel, BorderLayout.WEST); + myLabel = new JLabel(MavenIcons.MAVEN_ICON, JLabel.LEFT); JComponent importChangedButton = createButton(ProjectBundle.message("maven.project.import.changed"), new Runnable() { public void run() { myMavenProjectsManager.performScheduledImport(); } }); - JComponent importAllButton = createButton(ProjectBundle.message("maven.project.import.all"), new Runnable() { - public void run() { - myMavenProjectsManager.forceUpdateAllProjectsOrFindAllAvailablePomFiles(); - } - }); JComponent enableAutoImportButton = createButton(ProjectBundle.message("maven.project.import.enable.auto"), new Runnable() { public void run() { myMavenProjectsManager.getImportingSettings().setImportAutomatically(true); @@ -146,12 +140,23 @@ public class MavenImportNotifier extends SimpleProjectComponent { JPanel buttonsPanel = new JPanel(); buttonsPanel.setOpaque(false); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS)); + buttonsPanel.add(myLabel); buttonsPanel.add(importChangedButton); - buttonsPanel.add(importAllButton); buttonsPanel.add(Box.createHorizontalStrut(10)); buttonsPanel.add(enableAutoImportButton); - add(buttonsPanel, BorderLayout.EAST); + GridBagConstraints c = new GridBagConstraints(); + c.fill = GridBagConstraints.HORIZONTAL; + + c.gridx = 0; + c.anchor = GridBagConstraints.WEST; + c.weightx = 1; + add(myLabel, c); + + c.gridx = 1; + c.weightx = 0; + c.anchor = GridBagConstraints.EAST; + add(buttonsPanel, c); } private JComponent createButton(String text, final Runnable action) { @@ -174,9 +179,10 @@ public class MavenImportNotifier extends SimpleProjectComponent { s = ProjectBundle.message("maven.project.something.changed"); } else { - s = ProjectBundle.message("maven.project.changed", projectsCount, projectsCount == 1 ? " has" : "s have"); + s = ProjectBundle.message("maven.project.changed", projectsCount, projectsCount == 1 ? " is" : "s are"); } myLabel.setText(s); + myLabel.setToolTipText(s); } } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java index ad2fc1ab981d..f5f9a53ff6ee 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java @@ -70,9 +70,11 @@ public class MavenActionUtil { MavenProject project = getProjectsManager(e).findProject(each); if (project != null) result.add(project); } - for (Module each : getModules(e)) { - MavenProject project = getProjectsManager(e).findProject(each); - if (project != null) result.add(project); + if (result.isEmpty()) { + for (Module each : getModules(e)) { + MavenProject project = getProjectsManager(e).findProject(each); + if (project != null) result.add(project); + } } return new ArrayList(result); } diff --git a/plugins/maven/src/main/resources/ProjectBundle.properties b/plugins/maven/src/main/resources/ProjectBundle.properties index 2731c61f0009..b216fed37498 100644 --- a/plugins/maven/src/main/resources/ProjectBundle.properties +++ b/plugins/maven/src/main/resources/ProjectBundle.properties @@ -18,8 +18,8 @@ maven.downloading.artifact=Downloading {0} maven.transfer.progress={0}/{1}K [{2}] {3} maven.transfer.start=Checking [{0}] {1} -maven.project.changed={0} Maven project{1} been changed. -maven.project.something.changed=Some settings have been changed that require reimport. +maven.project.changed={0} Maven project{1} ready to be imported +maven.project.something.changed=Changes have been made that require reimport maven.project.import.changed=Import Changes maven.project.import.all=Force Reimport All maven.project.import.enable.auto=Enable Auto-Import @@ -83,7 +83,6 @@ maven.select.maven.settings.file=Select Maven settings file maven.select.local.repository=Select Maven local repository maven.file.type.descr=Maven project files -view.node.root=Maven Projects view.node.lifecycle=Lifecycle view.node.profiles=Profiles view.node.plugins=Plugins diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java index 1121aefbc956..d74a311d497a 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java @@ -423,6 +423,12 @@ public abstract class MavenImportingTestCase extends MavenTestCase { FileUtil.delete(new File(getRepositoryPath(), relativePath)); } + protected void setupJdkForModules(String... moduleNames) { + for (String each : moduleNames) { + setupJdkForModule(each); + } + } + protected Sdk setupJdkForModule(String moduleName) { ModifiableRootModel m = ModuleRootManager.getInstance(getModule(moduleName)).getModifiableModel(); Sdk sdk = createJdk("Java 1.5"); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/JavaClasspathConfigurationTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/JavaClasspathConfigurationTest.java index 976a3f657b73..5b500684a459 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/JavaClasspathConfigurationTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/JavaClasspathConfigurationTest.java @@ -74,20 +74,17 @@ public class JavaClasspathConfigurationTest extends MavenImportingTestCase { assertModuleModuleDeps("m1", "m2", "m3"); assertModuleModuleDeps("m2", "m3", "m4"); - setupJdkForModule("m1"); - setupJdkForModule("m2"); - setupJdkForModule("m3"); - setupJdkForModule("m4"); + setupJdkForModules("m1", "m2", "m3", "m4"); assertModuleClasspath("m1", - getProjectPath() + "/m1/target/classes", - getProjectPath() + "/m2/target/classes", - getProjectPath() + "/m3/target/classes"); + getProjectPath() + "/m1/target/classes", + getProjectPath() + "/m2/target/classes", + getProjectPath() + "/m3/target/classes"); assertModuleClasspath("m2", - getProjectPath() + "/m2/target/classes", - getProjectPath() + "/m3/target/classes", - getProjectPath() + "/m4/target/classes"); + getProjectPath() + "/m2/target/classes", + getProjectPath() + "/m3/target/classes", + getProjectPath() + "/m4/target/classes"); } public void testOptionalLibraryDependencies() throws Exception { @@ -128,18 +125,17 @@ public class JavaClasspathConfigurationTest extends MavenImportingTestCase { assertModuleLibDeps("m1", "Maven: jmock:jmock:1.0"); assertModuleLibDeps("m2", "Maven: jmock:jmock:1.0", "Maven: junit:junit:4.0"); - setupJdkForModule("m1"); - setupJdkForModule("m2"); + setupJdkForModules("m1", "m2"); assertModuleClasspath("m1", - getProjectPath() + "/m1/target/classes", - getProjectPath() + "/m2/target/classes", - getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar"); + getProjectPath() + "/m1/target/classes", + getProjectPath() + "/m2/target/classes", + getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar"); assertModuleClasspath("m2", - getProjectPath() + "/m2/target/classes", - getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar", - getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar"); + getProjectPath() + "/m2/target/classes", + getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar", + getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar"); } public void testDoNotChangeClasspathForRegularModules() throws Exception { @@ -184,20 +180,18 @@ public class JavaClasspathConfigurationTest extends MavenImportingTestCase { assertModuleModuleDeps("user", "m1"); assertModuleLibDeps("user"); - setupJdkForModule("user"); - setupJdkForModule("m1"); - setupJdkForModule("m2"); + setupJdkForModules("m1", "m2", "user"); assertModuleClasspath("user", - getProjectPath() + "/user/output", - getProjectPath() + "/m1/target/classes", - getProjectPath() + "/m2/target/classes", - getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar"); + getProjectPath() + "/user/output", + getProjectPath() + "/m1/target/classes", + getProjectPath() + "/m2/target/classes", + getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar"); assertModuleClasspath("m1", - getProjectPath() + "/m1/target/classes", - getProjectPath() + "/m2/target/classes", - getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar"); + getProjectPath() + "/m1/target/classes", + getProjectPath() + "/m2/target/classes", + getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar"); } public void testDoNotIncludeProvidedAndTestTransitiveDependencies() throws Exception { @@ -239,17 +233,72 @@ public class JavaClasspathConfigurationTest extends MavenImportingTestCase { assertModuleLibDeps("m1"); assertModuleLibDeps("m2", "Maven: jmock:jmock:1.0", "Maven: junit:junit:4.0"); - setupJdkForModule("m1"); - setupJdkForModule("m2"); + setupJdkForModules("m1", "m2"); assertModuleClasspath("m1", - getProjectPath() + "/m1/target/classes", - getProjectPath() + "/m2/target/classes"); + getProjectPath() + "/m1/target/classes", + getProjectPath() + "/m2/target/classes"); assertModuleClasspath("m2", - getProjectPath() + "/m2/target/classes", - getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar", - getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar"); + getProjectPath() + "/m2/target/classes", + getRepositoryPath() + "/jmock/jmock/1.0/jmock-1.0.jar", + getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar"); + } + + public void testDoNotIncludeConflictingTransitiveDependenciesInTheClasspath() throws Exception { + VirtualFile m1 = createModulePom("m1", "test" + + "m1" + + "1" + + + "" + + " " + + " test" + + " m2" + + " 1" + + " " + + " " + + " test" + + " m3" + + " 1" + + " " + + ""); + + VirtualFile m2 = createModulePom("m2", "test" + + "m2" + + "1" + + + "" + + " " + + " junit" + + " junit" + + " 4.0" + + " " + + ""); + VirtualFile m3 = createModulePom("m3", "test" + + "m3" + + "1" + + + "" + + " " + + " junit" + + " junit" + + " 4.5" + + " " + + ""); + + importProjects(m1, m2, m3); + assertModules("m1", "m2", "m3"); + + assertModuleModuleDeps("m1", "m2", "m3"); + assertModuleLibDeps("m1", "Maven: junit:junit:4.0"); + + setupJdkForModules("m1", "m2", "m3"); + + assertModuleClasspath("m1", + getProjectPath() + "/m1/target/classes", + getProjectPath() + "/m2/target/classes", + getRepositoryPath() + "/junit/junit/4.0/junit-4.0.jar", + getProjectPath() + "/m3/target/classes"); } private void assertModuleClasspath(String moduleName, String... paths) throws CantRunException { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigatorTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigatorTest.java index b19376c5d185..7d277c5c3de6 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigatorTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/navigator/MavenProjectsNavigatorTest.java @@ -55,7 +55,7 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase { myProjectsManager.fireActivatedInTests(); assertEquals(1, getRootNodes().size()); - assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size()); + assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size()); } public void testReconnectingModulesWhenModuleRead() throws Exception { @@ -72,7 +72,7 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase { assertEquals(1, getRootNodes().size()); assertEquals(myProjectPom, getRootNodes().get(0).getVirtualFile()); - assertEquals(0, getRootNodes().get(0).getModulesNode().getProjectNodes().size()); + assertEquals(0, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size()); VirtualFile m = createModulePom("m", "test" + "m" + @@ -81,8 +81,8 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase { assertEquals(1, getRootNodes().size()); assertEquals(myProjectPom, getRootNodes().get(0).getVirtualFile()); - assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size()); - assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getVirtualFile()); + assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size()); + assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getVirtualFile()); } public void testReconnectingModulesWhenParentRead() throws Exception { @@ -107,8 +107,8 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase { assertEquals(1, getRootNodes().size()); assertEquals(myProjectPom, getRootNodes().get(0).getVirtualFile()); - assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size()); - assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getVirtualFile()); + assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size()); + assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getVirtualFile()); } public void testReconnectingModulesWhenProjectBecomesParent() throws Exception { @@ -136,8 +136,8 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase { assertEquals(1, getRootNodes().size()); assertEquals(myProjectPom, getRootNodes().get(0).getVirtualFile()); - assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size()); - assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getVirtualFile()); + assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size()); + assertEquals(m, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getVirtualFile()); } public void testUpdatingWhenManagedFilesChange() throws Exception { @@ -180,16 +180,16 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase { readFiles(myProjectPom, m, mm); assertEquals(1, getRootNodes().size()); - assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size()); - assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getModulesNode().getProjectNodes().size()); + assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size()); + assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getModulesNode().getProjectNodesInTests().size()); myNavigator.setGroupModules(false); assertEquals(3, getRootNodes().size()); myNavigator.setGroupModules(true); assertEquals(1, getRootNodes().size()); - assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size()); - assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().get(0).getModulesNode().getProjectNodes().size()); + assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size()); + assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().get(0).getModulesNode().getProjectNodesInTests().size()); } public void testIgnoringProjects() throws Exception { @@ -242,14 +242,14 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase { assertEquals(1, myStructure.getRootElement().getChildren().length); MavenProjectsStructure.ProjectNode projectNode = (MavenProjectsStructure.ProjectNode)myStructure.getRootElement().getChildren()[0]; assertEquals(myProjectPom, projectNode.getVirtualFile()); - assertEquals(1, projectNode.getModulesNode().getProjectNodes().size()); + assertEquals(1, projectNode.getModulesNode().getProjectNodesInTests().size()); myNavigator.setShowIgnored(false); assertEquals(2, getRootNodes().size()); assertEquals(1, myStructure.getRootElement().getChildren().length); // only one of them is visible projectNode = (MavenProjectsStructure.ProjectNode)myStructure.getRootElement().getChildren()[0]; assertEquals(m, projectNode.getVirtualFile()); - assertEquals(0, projectNode.getModulesNode().getProjectNodes().size()); + assertEquals(0, projectNode.getModulesNode().getProjectNodesInTests().size()); } public void testReorderingProjectsWhenNameChanges() throws Exception { @@ -295,7 +295,7 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase { readFiles(myProjectPom, m); assertEquals(1, getRootNodes().size()); - assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodes().size()); + assertEquals(1, getRootNodes().get(0).getModulesNode().getProjectNodesInTests().size()); MavenProjectsNavigatorState newState = new MavenProjectsNavigatorState(); newState.groupStructurally = false; @@ -321,6 +321,6 @@ public class MavenProjectsNavigatorTest extends MavenImportingTestCase { } private List getRootNodes() { - return myStructure.getRootElement().getProjectNodes(); + return myStructure.getRootElement().getProjectNodesInTests(); } } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditorProvider.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditorProvider.java index bd7061ce1714..546b5cfd791a 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditorProvider.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditorProvider.java @@ -23,6 +23,7 @@ import com.intellij.openapi.fileEditor.FileEditorProvider; import com.intellij.openapi.fileEditor.FileEditorState; import com.intellij.openapi.fileTypes.FileTypeConsumer; import com.intellij.openapi.fileTypes.FileTypeFactory; +import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.VirtualFile; @@ -31,7 +32,7 @@ import com.intellij.psi.PsiManager; import org.jdom.Element; import org.jetbrains.annotations.NotNull; -public class ResourceBundleEditorProvider extends FileTypeFactory implements FileEditorProvider { +public class ResourceBundleEditorProvider extends FileTypeFactory implements FileEditorProvider, DumbAware { private static final ResourceBundleFileType RESOURCE_BUNDLE_FILE_TYPE = new ResourceBundleFileType(); public boolean accept(@NotNull Project project, @NotNull VirtualFile file){ diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnMapDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnMapDialog.java index a96c87c4e390..996fcc9ea0b9 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnMapDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnMapDialog.java @@ -136,6 +136,11 @@ public class SvnMapDialog extends DialogWrapper { }); } + @Override + protected String getHelpId() { + return "reference.vcs.svn.working.copies.information"; + } + private void subscribeToUpdates(final SvnVcs vcs) { if (myMessageBusConnection == null) { myMessageBusConnection = myProject.getMessageBus().connect(getDisposable()); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractCreateFormAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractCreateFormAction.java index 89708fe60b33..421e486836bc 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractCreateFormAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractCreateFormAction.java @@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.actionSystem.Presentation; +import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; @@ -40,7 +41,7 @@ import java.io.InputStream; /** * @author yole */ -public abstract class AbstractCreateFormAction extends CreateElementActionBase { +public abstract class AbstractCreateFormAction extends CreateElementActionBase implements DumbAware { public AbstractCreateFormAction(String text, String description, Icon icon) { super(text, description, icon); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractGuiEditorAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractGuiEditorAction.java index 0876bb1a951e..b4f74c76a87a 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractGuiEditorAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractGuiEditorAction.java @@ -19,9 +19,10 @@ package com.intellij.uiDesigner.actions; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.project.DumbAware; import com.intellij.uiDesigner.FormEditingUtil; -import com.intellij.uiDesigner.radComponents.RadComponent; import com.intellij.uiDesigner.designSurface.GuiEditor; +import com.intellij.uiDesigner.radComponents.RadComponent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,7 +32,7 @@ import java.util.List; /** * @author yole */ -public abstract class AbstractGuiEditorAction extends AnAction { +public abstract class AbstractGuiEditorAction extends AnAction implements DumbAware { private final boolean myModifying; protected AbstractGuiEditorAction() { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractMoveSelectionAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractMoveSelectionAction.java index a5591f971730..b47b3ab1085a 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractMoveSelectionAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/AbstractMoveSelectionAction.java @@ -18,6 +18,7 @@ package com.intellij.uiDesigner.actions; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.util.Ref; import com.intellij.uiDesigner.FormEditingUtil; import com.intellij.uiDesigner.designSurface.GuiEditor; @@ -27,14 +28,14 @@ import com.intellij.uiDesigner.radComponents.RadContainer; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import java.awt.Point; +import java.awt.*; import java.util.ArrayList; /** * @author Anton Katilin * @author Vladimir Kondratyev */ -abstract class AbstractMoveSelectionAction extends AnAction{ +abstract class AbstractMoveSelectionAction extends AnAction implements DumbAware { private static final Logger LOG=Logger.getInstance("#com.intellij.uiDesigner.actions.MoveSelectionToRightAction"); private final GuiEditor myEditor; diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditorProvider.java b/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditorProvider.java index bac8bd5735b6..3d6f02baa522 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditorProvider.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditorProvider.java @@ -24,6 +24,7 @@ import com.intellij.openapi.fileEditor.FileEditorState; import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.VirtualFile; @@ -31,7 +32,7 @@ import com.intellij.util.ArrayUtil; import org.jdom.Element; import org.jetbrains.annotations.NotNull; -public final class UIFormEditorProvider implements FileEditorProvider { +public final class UIFormEditorProvider implements FileEditorProvider, DumbAware { private static final Logger LOG = Logger.getInstance("#com.intellij.uiDesigner.editor.UIFormEditorProvider"); public boolean accept(@NotNull final Project project, @NotNull final VirtualFile file){ diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/UIDesignerToolWindowManager.java b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/UIDesignerToolWindowManager.java index 346ae4760427..5b68d47f0ddc 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/UIDesignerToolWindowManager.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/propertyInspector/UIDesignerToolWindowManager.java @@ -93,7 +93,7 @@ public class UIDesignerToolWindowManager implements ProjectComponent { myToolWindowPanel.setSecondComponent(myPropertyInspector); myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(UIDesignerBundle.message("toolwindow.ui.designer"), myToolWindowPanel, - ToolWindowAnchor.LEFT, myProject); + ToolWindowAnchor.LEFT, myProject, true); myToolWindow.setIcon(IconLoader.getIcon("/com/intellij/uiDesigner/icons/toolWindowUIDesigner.png")); myToolWindow.setAvailable(false, null); }