From a03489930be40b40dee9b0c11d29dc5db1d92a37 Mon Sep 17 00:00:00 2001 From: irengrig Date: Fri, 17 Feb 2012 15:27:44 +0400 Subject: [PATCH 01/23] SVN 1.7: bug numbers for failing tests --- .../testSource/org/jetbrains/idea/svn/SvnNativeListsTest.java | 4 ++-- .../testSource/org/jetbrains/idea/svn/SvnRenameTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeListsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeListsTest.java index ab1f83d0b2f9..9cad4ef70887 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeListsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeListsTest.java @@ -104,7 +104,7 @@ public class SvnNativeListsTest extends SvnTestCase { verify(runSvn("status"), "", "--- Changelist 'newOne':", "M a.txt"); } - @Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix") + @Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix SVNKIT-211") @Test public void testEditAndMove() throws Throwable { final LocalChangeList newL = myChangeListManager.addChangeList("newOne", null); @@ -156,7 +156,7 @@ public class SvnNativeListsTest extends SvnTestCase { verify(runSvn("status"), "", "--- Changelist 'newOne':", "A + b.txt", "D a.txt"); } - @Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix") + @Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix SVNKIT-211") @Test public void testMoveMove() throws Throwable { final LocalChangeList newL = myChangeListManager.addChangeList("newOne", null); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRenameTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRenameTest.java index 54c99ac2b17c..7ed6a12f8417 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRenameTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRenameTest.java @@ -221,7 +221,7 @@ public class SvnRenameTest extends SvnTestCase { } // IDEA-13824 - @Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix") + @Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix SVNKIT-136") @Test public void testRenameFileRenameDir() throws Exception { final VirtualFile child = prepareDirectoriesForRename(); From c77fb5172673f593e89b2e1c698fd964434933ba Mon Sep 17 00:00:00 2001 From: "kirill.safonov" Date: Wed, 15 Feb 2012 11:30:58 +0400 Subject: [PATCH 02/23] unnecessary capitalization of checkbox text --- .../src/messages/DiagnosticBundle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-resources-en/src/messages/DiagnosticBundle.properties b/platform/platform-resources-en/src/messages/DiagnosticBundle.properties index 661d6dafcb3a..be8ba8439491 100644 --- a/platform/platform-resources-en/src/messages/DiagnosticBundle.properties +++ b/platform/platform-resources-en/src/messages/DiagnosticBundle.properties @@ -64,7 +64,7 @@ log.monitor.is.skipped.column=Skip Content log.monitor.edit.aliases.title=Edit Log Files Aliases log.monitor.edit.aliases.name=&Alias: log.monitor.edit.aliases.location=&Log File Location: -log.monitor.edit.aliases.show.all.checkbox.title=&Show All Files Coverable By Pattern +log.monitor.edit.aliases.show.all.checkbox.title=&Show all files coverable by pattern log.console.filter.show.errors=errors log.console.filter.show.errors.and.warnings=warnings log.console.filter.show.all=all From f5c29a1020ec63e94bc36fbf9bbb711387854c82 Mon Sep 17 00:00:00 2001 From: "kirill.safonov" Date: Thu, 16 Feb 2012 14:52:05 +0400 Subject: [PATCH 03/23] cosmetics --- .../platform-resources-en/src/messages/ProjectBundle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-resources-en/src/messages/ProjectBundle.properties b/platform/platform-resources-en/src/messages/ProjectBundle.properties index 1b1c40ee67c0..e77a4be3929a 100644 --- a/platform/platform-resources-en/src/messages/ProjectBundle.properties +++ b/platform/platform-resources-en/src/messages/ProjectBundle.properties @@ -163,7 +163,7 @@ module.add.error.title=Add Module module.add.action=Add module.remove.action=Remove module.remove.last.confirmation=Are you sure you want to remove the only module from this project?\nNo files will be deleted on disk. -module.remove.confirmation=Remove module \"{0}\" from the project?\nNo files will be deleted on disk. +module.remove.confirmation=Remove module ''{0}'' from the project?\nNo files will be deleted on disk. module.remove.confirmation.title=Remove Module module.classpath.button.edit=Ed&it... module.libraries.include.all.button=Include All From e1989ea5abe1459ec393fb8df42b18d37fd3147f Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 17 Feb 2012 18:22:35 +0400 Subject: [PATCH 04/23] save *.iml file immediately when new module/project is created (IDEA-67033, and also fixes IDEA-81435) --- java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java | 1 + .../openapi/roots/ui/configuration/actions/NewModuleAction.java | 1 + 2 files changed, 2 insertions(+) diff --git a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java index 91d04d04dc3a..5bb0502d480b 100644 --- a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java +++ b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java @@ -142,6 +142,7 @@ public class NewProjectUtil { if (projectBuilder != null) { projectBuilder.commit(newProject, null, ModulesProvider.EMPTY_MODULES_PROVIDER); + newProject.save(); } final boolean need2OpenProjectStructure = projectBuilder == null || projectBuilder.isOpenProjectSettingsAfter(); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/actions/NewModuleAction.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/actions/NewModuleAction.java index f49b98656919..16d17701194c 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/actions/NewModuleAction.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/actions/NewModuleAction.java @@ -73,6 +73,7 @@ public class NewModuleAction extends AnAction implements DumbAware { ModulesConfigurator.showDialog(project, null, null); } } + project.save(); } } From a2f4e05bb44ec65bb213fb833a65296a40213de1 Mon Sep 17 00:00:00 2001 From: irengrig Date: Fri, 17 Feb 2012 18:37:20 +0400 Subject: [PATCH 05/23] fix for IDEA-81304 "Show history for selection" for Subversion is not working! (exception reporting + correct revisions preload) --- .../actions/SelectedBlockHistoryAction.java | 12 +++- .../openapi/vcs/history/VcsHistoryUtil.java | 2 +- .../history/impl/CachedRevisionsContents.java | 34 +++++---- .../vcs/history/impl/VcsHistoryDialog.java | 70 ++++++++++++++----- .../vcs/ui/VcsBalloonProblemNotifier.java | 28 ++++++++ 5 files changed, 113 insertions(+), 33 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/SelectedBlockHistoryAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/SelectedBlockHistoryAction.java index b6700c6a5ea4..39767266e618 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/SelectedBlockHistoryAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/SelectedBlockHistoryAction.java @@ -32,6 +32,7 @@ import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl; import com.intellij.openapi.vcs.impl.VcsBackgroundableActions; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; +import com.intellij.util.WaitForProgressToShow; import com.intellij.vcsUtil.VcsSelection; import com.intellij.vcsUtil.VcsSelectionUtil; @@ -77,11 +78,15 @@ public class SelectedBlockHistoryAction extends AbstractVcsAction { final int selectionStart = selection.getSelectionStartLineNumber(); final int selectionEnd = selection.getSelectionEndLineNumber(); + final VcsException[] preloadException = new VcsException[1]; final CachedRevisionsContents cachedRevisionsContents = new CachedRevisionsContents(project, file); new VcsHistoryProviderBackgroundableProxy(activeVcs, provider, activeVcs.getDiffProvider()). createSessionFor(activeVcs.getKeyInstanceMethod(), new FilePathImpl(file), new Consumer() { public void consume(VcsHistorySession session) { + if (preloadException[0] != null) { + reportError(preloadException[0]); + } if (session == null) return; final VcsHistoryDialog vcsHistoryDialog = new VcsHistoryDialog(project, @@ -103,7 +108,12 @@ public class SelectedBlockHistoryAction extends AbstractVcsAction { cachedRevisionsContents.setRevisions(revisionList); if (VcsConfiguration.getInstance(project).SHOW_ONLY_CHANGED_IN_SELECTION_DIFF) { // preload while in bckgrnd - cachedRevisionsContents.loadContentsFor(revisionList.toArray(new VcsFileRevision[revisionList.size()])); + try { + cachedRevisionsContents.loadContentsFor(revisionList.toArray(new VcsFileRevision[revisionList.size()])); + } + catch (VcsException e) { + preloadException[0] = e; + } } } }); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java index 95a1f025e061..27e5bac31e18 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java @@ -64,7 +64,7 @@ public class VcsHistoryUtil { } } - private static int compareNumbers(VcsFileRevision first, VcsFileRevision second) { + public static int compareNumbers(VcsFileRevision first, VcsFileRevision second) { return first.getRevisionNumber().compareTo(second.getRevisionNumber()); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/CachedRevisionsContents.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/CachedRevisionsContents.java index a293bb7f1555..87dd5fedc259 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/CachedRevisionsContents.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/CachedRevisionsContents.java @@ -42,7 +42,7 @@ import java.util.*; */ public class CachedRevisionsContents { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.history.impl.CachedRevisionsContents"); - private final Map myCachedContents = new HashMap(); + private final Map myCachedContents; private final Project myProject; // managed outside, for reference here private List myRevisions; @@ -51,13 +51,14 @@ public class CachedRevisionsContents { public CachedRevisionsContents(final Project project, final VirtualFile file) { myProject = project; myFile = file; + myCachedContents = Collections.synchronizedMap(new HashMap()); } public void setRevisions(List revisions) { myRevisions = revisions; } - public void loadContentsFor(final VcsFileRevision[] revisions) { + public void loadContentsFor(final VcsFileRevision[] revisions) throws VcsException { final VcsFileRevision[] revisionsToLoad = revisionsNeededToBeLoaded(revisions); final List toBeLoaded = new LinkedList(); @@ -67,6 +68,7 @@ public class CachedRevisionsContents { } if (toBeLoaded.isEmpty()) return; + final VcsException[] exception = new VcsException[1]; final Runnable process = new Runnable() { public void run() { ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); @@ -91,19 +93,17 @@ public class CachedRevisionsContents { vcsFileRevision.loadContent(); } catch (final VcsException e) { - WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() { - public void run() { - Messages.showErrorDialog(VcsBundle.message("message.text.cannot.load.version.because.of.error", - vcsFileRevision.getRevisionNumber(), e.getLocalizedMessage()), - VcsBundle.message("message.title.load.version")); - } - }, null, myProject); + exception[0] = new VcsException(e); + LOG.info(e); + return; } catch (ProcessCanceledException ex) { return; } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + exception[0] = new VcsException(e); + LOG.info(e); + return; } String content = null; try { @@ -113,13 +113,16 @@ public class CachedRevisionsContents { } } catch (IOException e) { + exception[0] = new VcsException(e); LOG.info(e); + return; } catch (VcsException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + exception[0] = new VcsException(e); + LOG.info(e); + return; } myCachedContents.put(vcsFileRevision.getRevisionNumber(), content); - } } } @@ -136,9 +139,12 @@ public class CachedRevisionsContents { } else { process.run(); } + if (exception[0] != null) { + throw exception[0]; + } } - public String getContentOf(VcsFileRevision revision) { + public String getContentOf(VcsFileRevision revision) throws VcsException { if (! myCachedContents.containsKey(revision.getRevisionNumber())) { loadContentsFor(new VcsFileRevision[]{revision}); } @@ -157,7 +163,7 @@ public class CachedRevisionsContents { private Collection collectRevisionsFromFirstTo(VcsFileRevision revision) { ArrayList result = new ArrayList(); for (VcsFileRevision vcsFileRevision : myRevisions) { - if (VcsHistoryUtil.compare(revision, vcsFileRevision) > 0) continue; + if (VcsHistoryUtil.compareNumbers(revision, vcsFileRevision) > 0) continue; result.add(vcsFileRevision); } return result; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java index fcd27d07828e..0d573bcf4a06 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java @@ -20,6 +20,7 @@ import com.intellij.diff.FindBlock; import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diff.DiffManager; import com.intellij.openapi.diff.DiffPanel; @@ -29,12 +30,11 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.help.HelpManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Splitter; -import com.intellij.openapi.vcs.AbstractVcs; -import com.intellij.openapi.vcs.VcsBundle; -import com.intellij.openapi.vcs.VcsConfiguration; -import com.intellij.openapi.vcs.VcsDataKeys; +import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.history.*; +import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.table.TableView; @@ -61,6 +61,7 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { private final int mySelectionStart; private final int mySelectionEnd; + // todo equals??? private final Map myRevisionToContentMap = new com.intellij.util.containers.HashMap(); private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.history.impl.VcsHistoryDialog"); @@ -173,11 +174,11 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { }); - myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + final ListSelectionListener selectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { final VcsFileRevision revision; - if (myList.getSelectedRowCount() == 1) { - revision = (VcsFileRevision) myList.getItems().get(myList.getSelectedRow()); + if (myList.getSelectedRowCount() == 1 && !myList.isEmpty()) { + revision = (VcsFileRevision)myList.getItems().get(myList.getSelectedRow()); myComments.setText(revision.getCommitMessage()); myComments.setCaretPosition(0); } @@ -190,21 +191,34 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { } updateDiff(); } - }); + }; + myList.getSelectionModel().addListSelectionListener(selectionListener); myChangesOnlyCheckBox.setSelected(configuration.SHOW_ONLY_CHANGED_IN_SELECTION_DIFF); - updateRevisionsList(); + try { + updateRevisionsList(); + } + catch (final VcsException e) { + // todo test it, always exception + canNotLoadRevisionMessage(e); + } myChangesOnlyCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { configuration.SHOW_ONLY_CHANGED_IN_SELECTION_DIFF = myChangesOnlyCheckBox.isSelected(); - updateRevisionsList(); + try { + updateRevisionsList(); + } + catch (VcsException e1) { + canNotLoadRevisionMessage(e1); + } } }); init(); - ApplicationManager.getApplication().invokeLater(new Runnable() { + SwingUtilities.invokeLater(new Runnable() { public void run() { + if (! VcsHistoryDialog.this.isShowing()) return; myList.getSelectionModel().addSelectionInterval(0, 0); } }); @@ -212,6 +226,21 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { setTitle(VcsBundle.message("dialog.title.history.for.file", file.getName())); } + private void canNotLoadRevisionMessage(final VcsException e) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (! VcsHistoryDialog.this.isShowing()) return; + VcsBalloonProblemNotifier.showBalloonForComponent(VcsHistoryDialog.this.getRootPane(), + canNoLoadMessage(e), MessageType.ERROR, true); + } + }); + } + + private String canNoLoadMessage(VcsException e) { + return "Can not load revision contents: " + e.getMessage(); + } + @Override public JComponent getPreferredFocusedComponent() { return myList; @@ -235,15 +264,15 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { return result; } - protected String getContentOf(VcsFileRevision revision) { + protected String getContentOf(VcsFileRevision revision) throws VcsException { return myCachedContents.getContentOf(revision); } - private void loadContentsFor(final VcsFileRevision[] revisions) { + private void loadContentsFor(final VcsFileRevision[] revisions) throws VcsException { myCachedContents.loadContentsFor(revisions); } - private void updateRevisionsList() { + private void updateRevisionsList() throws VcsException { if (myIsInLoading) return; if (myChangesOnlyCheckBox.isSelected()) { loadContentsFor(myRevisions.toArray(new VcsFileRevision[myRevisions.size()])); @@ -267,7 +296,7 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { } - private List filteredRevisions() throws FilesTooBigForDiffException { + private List filteredRevisions() throws FilesTooBigForDiffException, VcsException { ArrayList result = new ArrayList(); VcsFileRevision nextRevision = myRevisions.get(myRevisions.size() - 1); result.add(nextRevision); @@ -282,6 +311,7 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { } private synchronized void updateDiff() { + if (myList.isEmpty()) return; int[] selectedIndices = myList.getSelectedRows(); if (selectedIndices.length == 0) { updateDiff(CURRENT, CURRENT); @@ -314,6 +344,12 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { catch (FilesTooBigForDiffException e) { myDiffPanel.setTooBigFileErrorContents(); } + catch (VcsException e) { + final String text = canNoLoadMessage(e); + myDiffPanel.setContents(new SimpleContent(text, myContentFileType), + new SimpleContent(text, myContentFileType)); + canNotLoadRevisionMessage(e); + } myDiffPanel.setTitle1(VcsBundle.message("diff.content.title.revision.number", firstRev.getRevisionNumber())); myDiffPanel.setTitle2(VcsBundle.message("diff.content.title.revision.number", secondRev.getRevisionNumber())); @@ -414,14 +450,14 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { return null; } - protected String getContentToShow(VcsFileRevision revision) throws FilesTooBigForDiffException { + protected String getContentToShow(VcsFileRevision revision) throws FilesTooBigForDiffException, VcsException { final Block block = getBlock(revision); if (block == null) return ""; return block.getBlockContent(); } @Nullable - private Block getBlock(VcsFileRevision revision) throws FilesTooBigForDiffException { + private Block getBlock(VcsFileRevision revision) throws FilesTooBigForDiffException, VcsException { if (myRevisionToContentMap.containsKey(revision)) return myRevisionToContentMap.get(revision); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/VcsBalloonProblemNotifier.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/VcsBalloonProblemNotifier.java index 23780caadc75..8adad110695a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/VcsBalloonProblemNotifier.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/VcsBalloonProblemNotifier.java @@ -20,9 +20,17 @@ import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; +import com.intellij.openapi.ui.popup.Balloon; +import com.intellij.openapi.ui.popup.BalloonBuilder; +import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager; +import com.intellij.ui.awt.RelativePoint; import org.jetbrains.annotations.NotNull; +import javax.swing.*; +import java.awt.*; +import java.util.concurrent.TimeUnit; + /** * Shows a notification balloon over one of version control related tool windows: Changes View or Version Control View. * By default the notification is shown over the Changes View. @@ -74,4 +82,24 @@ public class VcsBalloonProblemNotifier implements Runnable { public void run() { NOTIFICATION_GROUP.createNotification(myMessage, myMessageType).notify(myProject.isDefault() ? null : myProject); } + + public static void showBalloonForComponent(@NotNull JComponent component, @NotNull final String message, final MessageType type, + final boolean atTop) { + BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, type, null); + Balloon balloon = balloonBuilder.createBalloon(); + Dimension size = component.getSize(); + Balloon.Position position; + int x; + int y; + if (size == null) { + x = y = 0; + position = Balloon.Position.above; + } + else { + x = Math.min(10, size.width / 2); + y = size.height; + position = Balloon.Position.below; + } + balloon.show(new RelativePoint(component, new Point(x, y)), position); + } } From 6abfd875d3ddffd64e0ccb1facf6610fd928af81 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 17 Feb 2012 13:25:54 +0100 Subject: [PATCH 06/23] don't check uncommitted documents, allow inspection validators to provide some custom checks --- .../openapi/compiler/util/InspectionValidator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/util/InspectionValidator.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/util/InspectionValidator.java index 00ae0970c118..64088c825e2b 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/util/InspectionValidator.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/util/InspectionValidator.java @@ -19,18 +19,20 @@ package com.intellij.openapi.compiler.util; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInspection.InspectionToolProvider; import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.compiler.CompileContext; import com.intellij.openapi.compiler.CompileScope; import com.intellij.openapi.compiler.CompilerMessageCategory; import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.Collections; +import java.util.Map; /** * @author peter @@ -86,4 +88,8 @@ public abstract class InspectionValidator { return CompilerMessageCategory.INFORMATION; } + @NotNull + public Map checkAdditionally(PsiFile file) { + return Collections.emptyMap(); + } } From 9f5f1f81c2427e9bcb8c23000bb7e1018f92e148 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 17 Feb 2012 15:17:55 +0100 Subject: [PATCH 07/23] don't user String#intern --- .../plugins/groovy/extensions/GroovyMethodInfo.java | 2 +- .../com/intellij/psi/impl/source/xml/XsContentDFA.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java index 36dc266865cc..9b9a10f31202 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java @@ -158,7 +158,7 @@ public class GroovyMethodInfo { Map> methodMap = res.get(key); if (methodMap == null) { methodMap = new HashMap>(); - res.put(key.intern(), methodMap); + res.put(key, methodMap); } List methodsList = methodMap.get(methodName); diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java index 11fefd140226..8d52bebfa18a 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java @@ -125,10 +125,10 @@ class XsContentDFA extends XmlContentDFA { private static QName createQName(XmlTag tag) { String namespace = tag.getNamespace(); - return new QName(tag.getNamespacePrefix().intern(), - tag.getLocalName().intern(), - tag.getName().intern(), - namespace.length() == 0 ? null : namespace.intern()); + return new QName(tag.getNamespacePrefix(), + tag.getLocalName(), + tag.getName(), + namespace.length() == 0 ? null : namespace); } @Nullable From 413bb84f3753ffed911aa4185babc70c005b00b4 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 17 Feb 2012 15:34:36 +0100 Subject: [PATCH 08/23] IDEA-81346 Support "freemarker validation" in "validate on build" tab --- ...efaultHighlightVisitorBasedInspection.java | 76 ++++++++++--------- .../actions/CleanupInspectionIntention.java | 36 +++++---- 2 files changed, 64 insertions(+), 48 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java index 9fb5aa36ccc6..9337a22bd768 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java @@ -29,6 +29,7 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiFile; +import com.intellij.util.PairConsumer; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -86,12 +87,41 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl @Override public void checkFile(@NotNull PsiFile file, - @NotNull InspectionManager manager, + @NotNull final InspectionManager manager, @NotNull ProblemsHolder problemsHolder, - @NotNull GlobalInspectionContext globalContext, - @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) { - PsiElementVisitor visitor = new MyPsiElementVisitor(manager, globalContext, problemDescriptionsProcessor, highlightErrorElements,runAnnotators); - file.accept(visitor); + @NotNull final GlobalInspectionContext globalContext, + @NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) { + runGeneralHighlighting(file, highlightErrorElements, runAnnotators, new PairConsumer() { + @Override + public void consume(PsiFile file, HighlightInfo info) { + TextRange range = new TextRange(info.startOffset, info.endOffset); + PsiElement element = file.findElementAt(info.startOffset); + + while (element != null && !element.getTextRange().contains(range)) { + element = element.getParent(); + } + + if (element == null) { + element = file; + } + GlobalInspectionUtil.createProblem( + element, + info.description, + HighlightInfo.convertType(info.type), + range.shiftRight(-element.getNode().getStartOffset()), + manager, + problemDescriptionsProcessor, + globalContext + ); + } + }); + } + + public static void runGeneralHighlighting(PsiFile file, + final boolean highlightErrorElements, + final boolean runAnnotators, + PairConsumer consumer) { + file.accept(new MyPsiElementVisitor(highlightErrorElements, runAnnotators, consumer)); } @Nls @@ -102,22 +132,16 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl } private static class MyPsiElementVisitor extends PsiElementVisitor { - private final InspectionManager myManager; - private final GlobalInspectionContext myGlobalContext; - private final ProblemDescriptionsProcessor myProblemDescriptionsProcessor; private final boolean highlightErrorElements; private final boolean runAnnotators; + private final PairConsumer myConsumer; - public MyPsiElementVisitor(final InspectionManager manager, - final GlobalInspectionContext globalContext, - final ProblemDescriptionsProcessor problemDescriptionsProcessor, - boolean highlightErrorElements, - boolean runAnnotators) { - myManager = manager; - myGlobalContext = globalContext; - myProblemDescriptionsProcessor = problemDescriptionsProcessor; + public MyPsiElementVisitor(boolean highlightErrorElements, + boolean runAnnotators, final PairConsumer consumer) { this.highlightErrorElements = highlightErrorElements; this.runAnnotators = runAnnotators; + myConsumer = consumer; + } @Override @@ -147,27 +171,9 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl if (info == null) return true; if (info.type == HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT) return true; if (info.severity == HighlightSeverity.INFORMATION) return true; - ProblemHighlightType problemHighlightType = HighlightInfo.convertType(info.type); - TextRange range = new TextRange(info.startOffset, info.endOffset); - PsiElement element = file.findElementAt(info.startOffset); - while (element != null && !element.getTextRange().contains(range)) { - element = element.getParent(); - } + myConsumer.consume(file, info); - if (element == null) { - element = file; - } - - GlobalInspectionUtil.createProblem( - element, - info.description, - problemHighlightType, - range.shiftRight(-element.getNode().getStartOffset()), - myManager, - myProblemDescriptionsProcessor, - myGlobalContext - ); return true; } }; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java index 6ee9c3ecaa68..988e3cd4b874 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java @@ -63,17 +63,8 @@ public class CleanupInspectionIntention implements IntentionAction, HighPriority public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { if (!CodeInsightUtilBase.preparePsiElementForWrite(file)) return; - final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManagerEx.getInstance(project); - final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false); - final LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(myTool); - tool.initialize(context); - ((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted(); - ((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable() { - public void run() { - tool.processFile(file, true, managerEx, true); - } - }, new EmptyProgressIndicator()); - final List descriptions = new ArrayList(tool.getProblemDescriptors()); + final List descriptions = runInspectionOnFile(file, myTool); + Collections.sort(descriptions, new Comparator() { public int compare(final CommonProblemDescriptor o1, final CommonProblemDescriptor o2) { final ProblemDescriptorImpl d1 = (ProblemDescriptorImpl)o1; @@ -95,8 +86,27 @@ public class CleanupInspectionIntention implements IntentionAction, HighPriority } } } - ((RefManagerImpl)context.getRefManager()).inspectionReadActionFinished(); - context.cleanup(managerEx); + } + + public static List runInspectionOnFile(final PsiFile file, + final LocalInspectionTool inspectionTool) { + final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(file.getProject()); + final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false); + final LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(inspectionTool); + tool.initialize(context); + ((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted(); + try { + ((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable() { + public void run() { + tool.processFile(file, true, managerEx, true); + } + }, new EmptyProgressIndicator()); + return new ArrayList(tool.getProblemDescriptors()); + } + finally { + ((RefManagerImpl)context.getRefManager()).inspectionReadActionFinished(); + context.cleanup(managerEx); + } } public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) { From 2cf9aba56ba9361bce78f0a9f5fb0e111849aded Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 22 Sep 2010 15:39:00 +0400 Subject: [PATCH 09/23] Maven: correctly configuring dependency paths for dated snapshot versions. --- .../org/jetbrains/idea/maven/model/MavenArtifact.java | 9 ++------- .../jetbrains/idea/maven/server/MavenModelConverter.java | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java index 950a9ae65e8d..5779a12db383 100644 --- a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java +++ b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java @@ -29,7 +29,6 @@ public class MavenArtifact implements Serializable { private final String myGroupId; private final String myArtifactId; private final String myVersion; - private final String myBaseVersion; private final String myType; private final String myClassifier; @@ -57,8 +56,7 @@ public class MavenArtifact implements Serializable { boolean stubbed) { myGroupId = groupId; myArtifactId = artifactId; - myVersion = version; - myBaseVersion = baseVersion; + myVersion = !StringUtil.isEmptyOrSpaces(baseVersion) ? baseVersion : version; myType = type; myClassifier = classifier; myScope = scope; @@ -249,8 +247,7 @@ public class MavenArtifact implements Serializable { if (!StringUtil.isEmptyOrSpaces(myType) && !MavenConstants.TYPE_JAR.equals(myType)) MavenId.append(builder, myType); if (!StringUtil.isEmptyOrSpaces(myClassifier)) MavenId.append(builder, myClassifier); - String version = !StringUtil.isEmptyOrSpaces(myBaseVersion) ? myBaseVersion : myVersion; - if (!StringUtil.isEmptyOrSpaces(version)) MavenId.append(builder, version); + MavenId.append(builder, myVersion); return builder.toString(); } @@ -270,7 +267,6 @@ public class MavenArtifact implements Serializable { if (myGroupId != null ? !myGroupId.equals(that.myGroupId) : that.myGroupId != null) return false; if (myArtifactId != null ? !myArtifactId.equals(that.myArtifactId) : that.myArtifactId != null) return false; if (myVersion != null ? !myVersion.equals(that.myVersion) : that.myVersion != null) return false; - if (myBaseVersion != null ? !myBaseVersion.equals(that.myBaseVersion) : that.myBaseVersion != null) return false; if (myType != null ? !myType.equals(that.myType) : that.myType != null) return false; if (myClassifier != null ? !myClassifier.equals(that.myClassifier) : that.myClassifier != null) return false; if (myScope != null ? !myScope.equals(that.myScope) : that.myScope != null) return false; @@ -285,7 +281,6 @@ public class MavenArtifact implements Serializable { int result = myGroupId != null ? myGroupId.hashCode() : 0; result = 31 * result + (myArtifactId != null ? myArtifactId.hashCode() : 0); result = 31 * result + (myVersion != null ? myVersion.hashCode() : 0); - result = 31 * result + (myBaseVersion != null ? myBaseVersion.hashCode() : 0); result = 31 * result + (myType != null ? myType.hashCode() : 0); result = 31 * result + (myClassifier != null ? myClassifier.hashCode() : 0); result = 31 * result + (myScope != null ? myScope.hashCode() : 0); diff --git a/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/MavenModelConverter.java b/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/MavenModelConverter.java index 2d4248762c8b..8ff4b1119633 100644 --- a/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/MavenModelConverter.java +++ b/plugins/maven/maven3-server-impl/src/org/jetbrains/idea/maven/server/MavenModelConverter.java @@ -200,7 +200,8 @@ public class MavenModelConverter { } public static MavenArtifact convertArtifact(Artifact artifact, File localRepository) { - return new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), + return new MavenArtifact(artifact.getGroupId(), + artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), artifact.getType(), From fdfe62d1abaf13faea86bd3c701cea0e5a290334 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Thu, 2 Feb 2012 11:42:38 +0100 Subject: [PATCH 10/23] AppCode:Schemes: different scheme types --- .../src/com/intellij/testFramework/UsefulTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index a24b83e62008..98067ba583dc 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -479,7 +479,7 @@ public abstract class UsefulTestCase extends TestCase { public static T assertInstanceOf(Object o, Class aClass) { Assert.assertNotNull(o); - Assert.assertTrue(o.getClass().getName(), aClass.isInstance(o)); + Assert.assertTrue("Expected instance of: " + aClass.getName() + " actual: " + o.getClass().getName(), aClass.isInstance(o)); return (T)o; } From 8d4dd7e15990aa322ec41209e09d7c4dcd27263e Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Sat, 4 Feb 2012 17:40:26 +0100 Subject: [PATCH 11/23] AppCode:Schemes: building schemes --- .../src/com/intellij/execution/ExecutionException.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/platform-api/src/com/intellij/execution/ExecutionException.java b/platform/platform-api/src/com/intellij/execution/ExecutionException.java index 72c07aa5623b..21fbdd60dcc3 100644 --- a/platform/platform-api/src/com/intellij/execution/ExecutionException.java +++ b/platform/platform-api/src/com/intellij/execution/ExecutionException.java @@ -22,6 +22,10 @@ public class ExecutionException extends Exception { super(s); } + public ExecutionException(final Throwable cause) { + super(cause == null ? null : cause.getMessage(), cause); + } + public ExecutionException(final String s, Throwable cause) { super(s, cause); } From 0cdda33a769dd58f347e862c4a08e21c31942695 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Fri, 17 Feb 2012 15:40:56 +0100 Subject: [PATCH 12/23] Maven: old change reverter --- .../org/jetbrains/idea/maven/model/MavenArtifact.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java index 5779a12db383..950a9ae65e8d 100644 --- a/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java +++ b/plugins/maven/maven-server-api/src/org/jetbrains/idea/maven/model/MavenArtifact.java @@ -29,6 +29,7 @@ public class MavenArtifact implements Serializable { private final String myGroupId; private final String myArtifactId; private final String myVersion; + private final String myBaseVersion; private final String myType; private final String myClassifier; @@ -56,7 +57,8 @@ public class MavenArtifact implements Serializable { boolean stubbed) { myGroupId = groupId; myArtifactId = artifactId; - myVersion = !StringUtil.isEmptyOrSpaces(baseVersion) ? baseVersion : version; + myVersion = version; + myBaseVersion = baseVersion; myType = type; myClassifier = classifier; myScope = scope; @@ -247,7 +249,8 @@ public class MavenArtifact implements Serializable { if (!StringUtil.isEmptyOrSpaces(myType) && !MavenConstants.TYPE_JAR.equals(myType)) MavenId.append(builder, myType); if (!StringUtil.isEmptyOrSpaces(myClassifier)) MavenId.append(builder, myClassifier); - MavenId.append(builder, myVersion); + String version = !StringUtil.isEmptyOrSpaces(myBaseVersion) ? myBaseVersion : myVersion; + if (!StringUtil.isEmptyOrSpaces(version)) MavenId.append(builder, version); return builder.toString(); } @@ -267,6 +270,7 @@ public class MavenArtifact implements Serializable { if (myGroupId != null ? !myGroupId.equals(that.myGroupId) : that.myGroupId != null) return false; if (myArtifactId != null ? !myArtifactId.equals(that.myArtifactId) : that.myArtifactId != null) return false; if (myVersion != null ? !myVersion.equals(that.myVersion) : that.myVersion != null) return false; + if (myBaseVersion != null ? !myBaseVersion.equals(that.myBaseVersion) : that.myBaseVersion != null) return false; if (myType != null ? !myType.equals(that.myType) : that.myType != null) return false; if (myClassifier != null ? !myClassifier.equals(that.myClassifier) : that.myClassifier != null) return false; if (myScope != null ? !myScope.equals(that.myScope) : that.myScope != null) return false; @@ -281,6 +285,7 @@ public class MavenArtifact implements Serializable { int result = myGroupId != null ? myGroupId.hashCode() : 0; result = 31 * result + (myArtifactId != null ? myArtifactId.hashCode() : 0); result = 31 * result + (myVersion != null ? myVersion.hashCode() : 0); + result = 31 * result + (myBaseVersion != null ? myBaseVersion.hashCode() : 0); result = 31 * result + (myType != null ? myType.hashCode() : 0); result = 31 * result + (myClassifier != null ? myClassifier.hashCode() : 0); result = 31 * result + (myScope != null ? myScope.hashCode() : 0); From 4cc4b351c4e141603aa7382ec095d016c314a5ac Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Fri, 17 Feb 2012 15:50:46 +0100 Subject: [PATCH 13/23] Maven: profiles should not be inherited (it causes inheriting modules from profiles) --- .../maven/project/MavenProjectReader.java | 7 +- .../idea/maven/server/MavenServerManager.java | 2 +- .../importing/StructureImportingTest.java | 53 +++++++++--- .../maven/project/MavenProjectReaderTest.java | 83 +++++++++---------- 4 files changed, 81 insertions(+), 64 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java index f1240c95aeaa..ce1cb6907529 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectReader.java @@ -422,12 +422,7 @@ public class MavenProjectReader { MavenProjectProblem.ProblemType.PARENT)); } - model = MavenServerManager.getInstance().assembleInheritance(model, parentModel); - List profiles = model.getProfiles(); - for (MavenProfile each : parentModel.getProfiles()) { - addProfileIfDoesNotExist(each, profiles); - } - return model; + return MavenServerManager.getInstance().assembleInheritance(model, parentModel); } finally { recursionGuard.remove(file); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java index 9019e02d8e9d..cd96e0e3f10a 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/server/MavenServerManager.java @@ -208,7 +208,7 @@ public class MavenServerManager extends RemoteObjectWrapper { } params.getVMParametersList().addParametersString("-Xmx512m"); - //params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5009"); + //params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5009"); return params; } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.java index 16f6fc4e89d6..fb31c457f070 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.java @@ -24,6 +24,7 @@ import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.java.LanguageLevel; import org.jetbrains.idea.maven.MavenImportingTestCase; +import org.jetbrains.idea.maven.model.MavenId; import org.jetbrains.idea.maven.project.MavenProject; import java.io.File; @@ -107,6 +108,36 @@ public class StructureImportingTest extends MavenImportingTestCase { assertModules("project", "m1", "m2"); } + public void testModulesAreNotInheritedFromParentsProfiles() throws Exception { + createProjectPom("test" + + "project" + + "1" + + "pom" + + + "\n" + + " \n" + + " one\n" + + " " + + " m" + + " " + + " " + + ""); + + createModulePom("m", "test" + + "m" + + "1" + + "" + + " test" + + " project" + + " 1" + + ""); + + importProjectWithProfiles("one"); + + assertSize(1, myProjectsManager.findProject(new MavenId("test", "project", "1")).getModulePaths()); + assertSize(0, myProjectsManager.findProject(new MavenId("test", "m", "1")).getModulePaths()); + } + public void testModulesWithSlashesAtTheEnds() throws Exception { createProjectPom("test" + "project" + @@ -344,18 +375,18 @@ public class StructureImportingTest extends MavenImportingTestCase { if (!hasMavenInstallation()) return; final VirtualFile parent = createModulePom("parent", - "test" + - "parent" + - "1" + - "pom" + + "test" + + "parent" + + "1" + + "pom" + - "" + - " " + - " junit" + - " junit" + - " 4.0" + - " " + - ""); + "" + + " " + + " junit" + + " junit" + + " 4.0" + + " " + + ""); executeGoal("parent", "install"); new WriteAction() { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.java index 9a180d612115..912f8b9d1f5a 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.java @@ -23,10 +23,11 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; -import com.intellij.util.Function; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.idea.maven.MavenTestCase; -import org.jetbrains.idea.maven.model.*; +import org.jetbrains.idea.maven.model.MavenId; +import org.jetbrains.idea.maven.model.MavenModel; +import org.jetbrains.idea.maven.model.MavenProjectProblem; +import org.jetbrains.idea.maven.model.MavenResource; import org.jetbrains.idea.maven.utils.MavenUtil; import java.io.File; @@ -493,7 +494,7 @@ public class MavenProjectReaderTest extends MavenTestCase { assertEquals("${prop2}", p.getPackaging()); } - public void testHandlingRecursionProprielyAndDoNotForgetCoClearRecursionGuard() throws Exception { + public void testHandlingRecursionProperlyAndDoNotForgetCoClearRecursionGuard() throws Exception { File repositoryPath = new File(myDir, "repository"); setRepositoryPath(repositoryPath.getPath()); @@ -999,44 +1000,6 @@ public class MavenProjectReaderTest extends MavenTestCase { assertEquals("xxx", p.getBuild().getFinalName()); } - - public void testInheritingParentProfiles() throws Exception { - createProjectPom("test" + - "parent" + - "1" + - - "" + - " " + - " profileFromParent" + - " " + - ""); - - VirtualFile module = createModulePom("module", - "test" + - "module" + - "1" + - - "" + - " test" + - " parent" + - " 1" + - "" + - - "" + - " " + - " profileFromChild" + - " " + - ""); - - MavenModel p = readProject(module); - assertOrderedElementsAreEqual(ContainerUtil.map(p.getProfiles(), new Function() { - @Override - public Object fun(MavenProfile profile) { - return profile.getId(); - } - }), "profileFromChild", "profileFromParent"); - } - public void testCorrectlyCollectProfilesFromDifferentSources() throws Exception { createProjectPom("test" + "parent" + @@ -1116,8 +1079,8 @@ public class MavenProjectReaderTest extends MavenTestCase { p = readProject(module); assertEquals(1, p.getProfiles().size()); - assertEquals("parent", p.getProfiles().get(0).getModules().get(0)); - assertEquals("pom", p.getProfiles().get(0).getSource()); + assertEquals("settings", p.getProfiles().get(0).getModules().get(0)); + assertEquals("settings.xml", p.getProfiles().get(0).getSource()); createProjectPom("test" + "parent" + @@ -1125,8 +1088,8 @@ public class MavenProjectReaderTest extends MavenTestCase { p = readProject(module); assertEquals(1, p.getProfiles().size()); - assertEquals("parentProfiles", p.getProfiles().get(0).getModules().get(0)); - assertEquals("profiles.xml", p.getProfiles().get(0).getSource()); + assertEquals("settings", p.getProfiles().get(0).getModules().get(0)); + assertEquals("settings.xml", p.getProfiles().get(0).getSource()); new WriteCommandAction.Simple(myProject) { @Override @@ -1142,6 +1105,34 @@ public class MavenProjectReaderTest extends MavenTestCase { assertEquals("settings.xml", p.getProfiles().get(0).getSource()); } + public void testModulesAreNotInheritedFromParentsProfiles() throws Exception { + VirtualFile p = createProjectPom("test" + + "project" + + "1" + + "pom" + + + "" + + " " + + " one" + + " " + + " m" + + " " + + " " + + ""); + + VirtualFile m = createModulePom("m", "test" + + "m" + + "1" + + "" + + " test" + + " project" + + " 1" + + ""); + + assertSize(1, readProject(p, "one").getModules()); + assertSize(0, readProject(m, "one").getModules()); + } + public void testActivatingProfilesByDefault() throws Exception { createProjectPom("" + " " + From 0ff811bcf3c0172564adac6f37089ee57ccd9d66 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Fri, 17 Feb 2012 18:59:02 +0400 Subject: [PATCH 14/23] plain borders forever --- platform/util/src/com/intellij/util/ui/UIUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 20e4e38d3bc9..73ecb4d054b5 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -1553,9 +1553,9 @@ public class UIUtil { if (size == FontSize.MINI) { defFont = defFont.deriveFont(Math.max(defFont.getSize() - 4f, 9f)); } - if (isBold) { - defFont = defFont.deriveFont(Font.BOLD); - } + //if (isBold) { + // defFont = defFont.deriveFont(Font.BOLD); + //} return defFont; } From c9dc14c842d1ca189917911a4bf228a7be12d495 Mon Sep 17 00:00:00 2001 From: irengrig Date: Fri, 17 Feb 2012 19:11:17 +0400 Subject: [PATCH 15/23] SVN 1.7: fixed 2 native lists tests (correctly determine current changelist through status) --- .../idea/svn17/SvnChangelistListener.java | 19 +++++-------------- .../idea/svn/SvnNativeListsTest.java | 2 -- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn17/SvnChangelistListener.java b/plugins/svn4idea/src/org/jetbrains/idea/svn17/SvnChangelistListener.java index 327ff5b71212..e71d1932c801 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn17/SvnChangelistListener.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn17/SvnChangelistListener.java @@ -31,6 +31,8 @@ import org.tmatesoft.svn.core.SVNErrorCode; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.ISVNChangelistHandler; import org.tmatesoft.svn.core.wc.SVNChangelistClient; +import org.tmatesoft.svn.core.wc.SVNStatus; +import org.tmatesoft.svn.core.wc.SVNStatusClient; import java.io.File; import java.util.ArrayList; @@ -177,21 +179,10 @@ public class SvnChangelistListener implements ChangeListListener { public static String getCurrentMapping(final Project project, final File file) { final SvnVcs17 vcs = SvnVcs17.getInstance(project); final SVNChangelistClient client = vcs.createChangelistClient(); + final SVNStatusClient statusClient = vcs.createStatusClient(); try { - final Ref refResult = new Ref(); - final ISVNChangelistHandler handler = new ISVNChangelistHandler() { - public void handle(final File path, final String changelistName) { - if (refResult.isNull() && Comparing.equal(path, file)) { - refResult.set(changelistName); - } - } - }; - if (file.exists()) { - client.doGetChangeLists(file, null, SVNDepth.EMPTY, handler); - } else if (file.getParentFile() != null) { - client.doGetChangeLists(file.getParentFile(), null, SVNDepth.IMMEDIATES, handler); - } - return refResult.get(); + final SVNStatus status = statusClient.doStatus(file, false); + return status.getChangelistName(); } catch (SVNException e) { final SVNErrorCode errorCode = e.getErrorMessage().getErrorCode(); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeListsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeListsTest.java index 9cad4ef70887..abadade660e7 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeListsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeListsTest.java @@ -104,7 +104,6 @@ public class SvnNativeListsTest extends SvnTestCase { verify(runSvn("status"), "", "--- Changelist 'newOne':", "M a.txt"); } - @Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix SVNKIT-211") @Test public void testEditAndMove() throws Throwable { final LocalChangeList newL = myChangeListManager.addChangeList("newOne", null); @@ -156,7 +155,6 @@ public class SvnNativeListsTest extends SvnTestCase { verify(runSvn("status"), "", "--- Changelist 'newOne':", "A + b.txt", "D a.txt"); } - @Bombed(user = "irengrig", month = Calendar.FEBRUARY, day = 20, description = "waiting for svnkit bugfix SVNKIT-211") @Test public void testMoveMove() throws Throwable { final LocalChangeList newL = myChangeListManager.addChangeList("newOne", null); From 1e8e30cf81114e8ffa726b21eeefdeeb799c9632 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Fri, 17 Feb 2012 16:29:58 +0100 Subject: [PATCH 16/23] AppCode: supported xcode version validation on lion (4.3), mountain lion (4.2) --- .../com/intellij/openapi/util/SystemInfo.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/SystemInfo.java b/platform/util/src/com/intellij/openapi/util/SystemInfo.java index 86a50c9f74e7..b453b01c30b8 100644 --- a/platform/util/src/com/intellij/openapi/util/SystemInfo.java +++ b/platform/util/src/com/intellij/openapi/util/SystemInfo.java @@ -105,12 +105,23 @@ public class SystemInfo { */ public static final boolean isMacOSLion = isLion(); + /** + * Running under MacOS X version 10.8 or later; + * + * @since 11.1 + */ + public static final boolean isMacOSMountainLion = isMountainLion(); + /** * Operating system is supposed to have middle mouse button click occupied by paste action. * @since 6.0 */ public static boolean X11PasteEnabledSystem = isUnix && !isMac; + private static boolean isIntelMac() { + return isMac && "i386".equals(OS_ARCH); + } + private static boolean isTiger() { return isMac && !OS_VERSION.startsWith("10.0") && @@ -119,10 +130,6 @@ public class SystemInfo { !OS_VERSION.startsWith("10.3"); } - private static boolean isIntelMac() { - return isMac && "i386".equals(OS_ARCH); - } - private static boolean isLeopard() { return isMac && isTiger() && !OS_VERSION.startsWith("10.4"); } @@ -135,6 +142,10 @@ public class SystemInfo { return isMac && isSnowLeopard() && !OS_VERSION.startsWith("10.6"); } + private static boolean isMountainLion() { + return isMac && isLion() && !OS_VERSION.startsWith("10.7"); + } + @NotNull public static String getMacOSVersionCode() { return getMacOSVersionCode(OS_VERSION); From 2b140cebb18796523bba93519e06ccd963c24976 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 17 Feb 2012 17:54:35 +0400 Subject: [PATCH 17/23] IDEA-52158 Debugger views stop to update after changing layout --- .../com/intellij/debugger/ui/impl/UpdatableDebuggerView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/UpdatableDebuggerView.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/UpdatableDebuggerView.java index a8c7bbc8e753..f042bf22a7c2 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/UpdatableDebuggerView.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/UpdatableDebuggerView.java @@ -64,7 +64,7 @@ public abstract class UpdatableDebuggerView extends JPanel implements DebuggerVi } protected final boolean isUpdateEnabled() { - return myUpdateEnabled; + return myUpdateEnabled || isShowing(); } public final void setUpdateEnabled(final boolean enabled) { From f16c1b4d3fccae13f8d6aa0b673a002bc15bbfd7 Mon Sep 17 00:00:00 2001 From: irengrig Date: Fri, 17 Feb 2012 20:55:29 +0400 Subject: [PATCH 18/23] IDEA-81170 NPE at org.jetbrains.idea.svn17.commandLine.SvnCommandLineStatusClient$1.switchPath --- .../commandLine/SvnCommandLineStatusClient.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn17/commandLine/SvnCommandLineStatusClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn17/commandLine/SvnCommandLineStatusClient.java index 79bfd9a949f5..c99cc95fa0bc 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn17/commandLine/SvnCommandLineStatusClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn17/commandLine/SvnCommandLineStatusClient.java @@ -98,13 +98,6 @@ public class SvnCommandLineStatusClient implements SvnStatusClientI { final SVNInfo infoBase = myInfoClient.doInfo(base, revision); - // TODO check file case - // TODO check file case - // TODO check file case - // TODO check file case - // TODO check file case - - // todo can not understand why revision can be used here final SvnSimpleCommand command = new SvnSimpleCommand(myProject, base, SvnCommandName.st); @@ -136,8 +129,10 @@ public class SvnCommandLineStatusClient implements SvnStatusClientI { final PortableStatus pending = svnHandl[0].getPending(); pending.setChangelistName(changelistName[0]); try { - final String append = SVNPathUtil.append(infoBase.getURL().toString(), FileUtil.toSystemIndependentName(pending.getPath())); - pending.setURL(SVNURL.parseURIEncoded(append)); + if (infoBase != null) { + final String append = SVNPathUtil.append(infoBase.getURL().toString(), FileUtil.toSystemIndependentName(pending.getPath())); + pending.setURL(SVNURL.parseURIEncoded(append)); + } handler.handleStatus(pending); } catch (SVNException e) { From 43e5f35bd8e4e3a1159f49b50b0174d44d4baff3 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 17 Feb 2012 15:49:02 +0100 Subject: [PATCH 19/23] a more scala-friendly source-level accessibility check --- .../codeInsight/completion/JavaCompletionUtil.java | 9 ++++++--- java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java index 461751b00258..6a3acdb9c1fb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java @@ -903,9 +903,12 @@ public class JavaCompletionUtil { } if (pkgContext) { - PsiFile classFile = psiClass.getContainingFile(); - if (classFile instanceof PsiClassOwner && StringUtil.isEmpty(((PsiClassOwner)classFile).getPackageName())) { - return false; + PsiClass topLevel = PsiUtil.getTopLevelClass(psiClass); + if (topLevel != null) { + String fqName = topLevel.getQualifiedName(); + if (fqName != null && StringUtil.isEmpty(StringUtil.getPackageName(fqName))) { + return false; + } } } diff --git a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java index 728c714321cd..3b703fcea897 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java @@ -579,8 +579,8 @@ public final class PsiUtil extends PsiUtilCore { @Nullable public static PsiClass getTopLevelClass(@NotNull PsiElement element) { final PsiFile file = element.getContainingFile(); - if (file instanceof PsiJavaFile) { - final PsiClass[] classes = ((PsiJavaFile)file).getClasses(); + if (file instanceof PsiClassOwner) { + final PsiClass[] classes = ((PsiClassOwner)file).getClasses(); for (PsiClass aClass : classes) { if (PsiTreeUtil.isAncestor(aClass, element, false)) return aClass; } From 0f3f2f622266e163107a5087eb7662dad0c4a396 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 17 Feb 2012 18:53:50 +0100 Subject: [PATCH 20/23] thread-safe DefaultHighlightVisitorBasedInspection --- ...efaultHighlightVisitorBasedInspection.java | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java index 9337a22bd768..1a10a665d7a3 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/DefaultHighlightVisitorBasedInspection.java @@ -23,17 +23,21 @@ import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiFile; -import com.intellij.util.PairConsumer; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.List; + public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpleInspectionTool { private final boolean highlightErrorElements; private final boolean runAnnotators; @@ -86,42 +90,43 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl } @Override - public void checkFile(@NotNull PsiFile file, + public void checkFile(@NotNull PsiFile originalFile, @NotNull final InspectionManager manager, @NotNull ProblemsHolder problemsHolder, @NotNull final GlobalInspectionContext globalContext, @NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) { - runGeneralHighlighting(file, highlightErrorElements, runAnnotators, new PairConsumer() { - @Override - public void consume(PsiFile file, HighlightInfo info) { - TextRange range = new TextRange(info.startOffset, info.endOffset); - PsiElement element = file.findElementAt(info.startOffset); + for (Pair pair : runGeneralHighlighting(originalFile, highlightErrorElements, runAnnotators)) { + PsiFile file = pair.first; + HighlightInfo info = pair.second; + TextRange range = new TextRange(info.startOffset, info.endOffset); + PsiElement element = file.findElementAt(info.startOffset); - while (element != null && !element.getTextRange().contains(range)) { - element = element.getParent(); - } - - if (element == null) { - element = file; - } - GlobalInspectionUtil.createProblem( - element, - info.description, - HighlightInfo.convertType(info.type), - range.shiftRight(-element.getNode().getStartOffset()), - manager, - problemDescriptionsProcessor, - globalContext - ); + while (element != null && !element.getTextRange().contains(range)) { + element = element.getParent(); } - }); + + if (element == null) { + element = file; + } + GlobalInspectionUtil.createProblem( + element, + info.description, + HighlightInfo.convertType(info.type), + range.shiftRight(-element.getNode().getStartOffset()), + manager, + problemDescriptionsProcessor, + globalContext + ); + + } } - public static void runGeneralHighlighting(PsiFile file, + public static List> runGeneralHighlighting(PsiFile file, final boolean highlightErrorElements, - final boolean runAnnotators, - PairConsumer consumer) { - file.accept(new MyPsiElementVisitor(highlightErrorElements, runAnnotators, consumer)); + final boolean runAnnotators) { + MyPsiElementVisitor visitor = new MyPsiElementVisitor(highlightErrorElements, runAnnotators); + file.accept(visitor); + return new ArrayList>(visitor.result); } @Nls @@ -134,14 +139,11 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl private static class MyPsiElementVisitor extends PsiElementVisitor { private final boolean highlightErrorElements; private final boolean runAnnotators; - private final PairConsumer myConsumer; + final List> result = ContainerUtil.createEmptyCOWList(); - public MyPsiElementVisitor(boolean highlightErrorElements, - boolean runAnnotators, final PairConsumer consumer) { + public MyPsiElementVisitor(boolean highlightErrorElements, boolean runAnnotators) { this.highlightErrorElements = highlightErrorElements; this.runAnnotators = runAnnotators; - myConsumer = consumer; - } @Override @@ -172,7 +174,7 @@ public abstract class DefaultHighlightVisitorBasedInspection extends GlobalSimpl if (info.type == HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT) return true; if (info.severity == HighlightSeverity.INFORMATION) return true; - myConsumer.consume(file, info); + result.add(Pair.create(file, info)); return true; } From 7dd1d87c9da65580ae42c002da4ae051552b8328 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 17 Feb 2012 19:16:41 +0100 Subject: [PATCH 21/23] more thread-safety in DescriptorProviderInspection --- .../ex/DescriptorProviderInspection.java | 93 +++++++++++-------- 1 file changed, 54 insertions(+), 39 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java index 6503e871fc90..ea79a754e836 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java @@ -48,6 +48,7 @@ import java.util.*; * @author max */ public abstract class DescriptorProviderInspection extends InspectionTool implements ProblemDescriptionsProcessor { + private static final Object lock = new Object(); private Map myProblemElements; private HashMap> myContents = null; private HashSet myModulesProblems = null; @@ -68,14 +69,12 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem if (descriptions == null || descriptions.length == 0) return; if (filterSuppressed) { if (ourOutputPath == null || !(this instanceof LocalInspectionToolWrapper)) { - CommonProblemDescriptor[] problems = getProblemElements().get(refElement); - if (problems == null) { - problems = descriptions; + synchronized (lock) { + Map problemElements = getProblemElements(); + CommonProblemDescriptor[] problems = problemElements.get(refElement); + problems = problems == null ? descriptions : ArrayUtil.mergeArrays(problems, descriptions); + problemElements.put(refElement, problems); } - else { - problems = ArrayUtil.mergeArrays(problems, descriptions); - } - getProblemElements().put(refElement, problems); for (CommonProblemDescriptor description : descriptions) { getProblemToElements().put(description, refElement); collectQuickFixes(description.getFixes(), refElement); @@ -164,19 +163,22 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem final QuickFix[] fixes = problem.getFixes(); if (isIgnoreProblem(fixes, localQuickFixes, idx)){ getProblemToElements().remove(problem); - CommonProblemDescriptor[] descriptors = getProblemElements().get(refEntity); - if (descriptors != null) { - ArrayList newDescriptors = new ArrayList(Arrays.asList(descriptors)); - newDescriptors.remove(problem); - getQuickFixActions().put(refEntity, null); - if (!newDescriptors.isEmpty()) { - getProblemElements().put(refEntity, newDescriptors.toArray(new CommonProblemDescriptor[newDescriptors.size()])); - for (CommonProblemDescriptor descriptor : newDescriptors) { - collectQuickFixes(descriptor.getFixes(), refEntity); + Map problemElements = getProblemElements(); + synchronized (lock) { + CommonProblemDescriptor[] descriptors = problemElements.get(refEntity); + if (descriptors != null) { + ArrayList newDescriptors = new ArrayList(Arrays.asList(descriptors)); + newDescriptors.remove(problem); + getQuickFixActions().put(refEntity, null); + if (!newDescriptors.isEmpty()) { + problemElements.put(refEntity, newDescriptors.toArray(new CommonProblemDescriptor[newDescriptors.size()])); + for (CommonProblemDescriptor descriptor : newDescriptors) { + collectQuickFixes(descriptor.getFixes(), refEntity); + } + } + else { + ignoreProblemElement(refEntity); } - } - else { - ignoreProblemElement(refEntity); } } } @@ -224,10 +226,13 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem myOldProblemElements = null; } - myProblemElements = null; - myProblemToElements = null; - myQuickFixActions = null; - myIgnoredElements = null; + synchronized (lock) { + myProblemElements = null; + myProblemToElements = null; + myQuickFixActions = null; + myIgnoredElements = null; + } + myContents = null; myModulesProblems = null; } @@ -261,10 +266,12 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem public void exportResults(@NotNull final Element parentNode) { getRefManager().iterate(new RefVisitor() { @Override public void visitElement(final RefEntity refEntity) { - if (getProblemElements().containsKey(refEntity)) { - CommonProblemDescriptor[] descriptions = getDescriptions(refEntity); - if (descriptions != null) { - exportResults(descriptions, refEntity, parentNode); + synchronized (lock) { + if (getProblemElements().containsKey(refEntity)) { + CommonProblemDescriptor[] descriptions = getDescriptions(refEntity); + if (descriptions != null) { + exportResults(descriptions, refEntity, parentNode); + } } } } @@ -524,10 +531,12 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem } public Map getProblemElements() { - if (myProblemElements == null) { - myProblemElements = Collections.synchronizedMap(new THashMap()); + synchronized (lock) { + if (myProblemElements == null) { + myProblemElements = Collections.synchronizedMap(new THashMap()); + } + return myProblemElements; } - return myProblemElements; } @Nullable @@ -536,23 +545,29 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem } private Map getProblemToElements() { - if (myProblemToElements == null) { - myProblemToElements = Collections.synchronizedMap(new THashMap()); + synchronized (lock) { + if (myProblemToElements == null) { + myProblemToElements = Collections.synchronizedMap(new THashMap()); + } + return myProblemToElements; } - return myProblemToElements; } private Map> getQuickFixActions() { - if (myQuickFixActions == null) { - myQuickFixActions = Collections.synchronizedMap(new HashMap>()); + synchronized (lock) { + if (myQuickFixActions == null) { + myQuickFixActions = Collections.synchronizedMap(new HashMap>()); + } + return myQuickFixActions; } - return myQuickFixActions; } private Map getIgnoredElements() { - if (myIgnoredElements == null) { - myIgnoredElements = Collections.synchronizedMap(new HashMap()); + synchronized (lock) { + if (myIgnoredElements == null) { + myIgnoredElements = Collections.synchronizedMap(new HashMap()); + } + return myIgnoredElements; } - return myIgnoredElements; } } From 38c9cbb845897cff7f261f5c117a4f43fc8b14b0 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 17 Feb 2012 19:31:56 +0100 Subject: [PATCH 22/23] xml smart completion can't live without intern --- .../com/intellij/psi/impl/source/xml/XsContentDFA.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java index 8d52bebfa18a..3aff250f2d54 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java @@ -124,11 +124,12 @@ class XsContentDFA extends XmlContentDFA { } private static QName createQName(XmlTag tag) { + //todo don't use intern to not pollute PermGen String namespace = tag.getNamespace(); - return new QName(tag.getNamespacePrefix(), - tag.getLocalName(), - tag.getName(), - namespace.length() == 0 ? null : namespace); + return new QName(tag.getNamespacePrefix().intern(), + tag.getLocalName().intern(), + tag.getName().intern(), + namespace.length() == 0 ? null : namespace.intern()); } @Nullable From cdffa4c5fe2377b09ef123f175eeb74e9364bddd Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Fri, 17 Feb 2012 22:32:23 +0400 Subject: [PATCH 23/23] Work on Tools & Feedbacks --- .../AndroidDesignerEditorPanel.java | 18 +- .../designSurface/ResizeOperation.java | 83 +++++++++ .../designSurface/DesignerEditorPanel.java | 9 + .../designer/designSurface/EditOperation.java | 37 ++++ .../designer/designSurface/EditableArea.java | 14 ++ .../designSurface/FeedbackTreeLayer.java | 22 +++ .../designSurface/OperationContext.java | 118 ++++++++++++ .../feedbacks/AlphaComponent.java | 57 ++++++ .../selection/DirectionResizePoint.java | 9 +- .../designSurface/tools/InputTool.java | 8 +- .../designSurface/tools/MarqueeTracker.java | 22 +-- .../designSurface/tools/ResizeTracker.java | 169 +++++++++++++++++- .../designSurface/tools/SelectionTool.java | 48 ++--- .../intellij/designer/model/RadComponent.java | 30 ++++ .../intellij/designer/model/RadLayout.java | 8 + 15 files changed, 594 insertions(+), 58 deletions(-) create mode 100644 plugins/android-designer/src/com/intellij/android/designer/designSurface/ResizeOperation.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/EditOperation.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FeedbackTreeLayer.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/OperationContext.java create mode 100644 plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/AlphaComponent.java diff --git a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java index 9dfb452b8223..a4b1faefc92d 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java +++ b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java @@ -25,9 +25,7 @@ import com.android.sdklib.IAndroidTarget; import com.intellij.android.designer.componentTree.AndroidTreeDecorator; import com.intellij.android.designer.model.RadViewComponent; import com.intellij.designer.componentTree.TreeComponentDecorator; -import com.intellij.designer.designSurface.ComponentDecorator; -import com.intellij.designer.designSurface.DecorationLayer; -import com.intellij.designer.designSurface.DesignerEditorPanel; +import com.intellij.designer.designSurface.*; import com.intellij.designer.designSurface.selection.DirectionResizePoint; import com.intellij.designer.designSurface.selection.NonResizeSelectionDecorator; import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator; @@ -193,9 +191,17 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { @Override protected ComponentDecorator getRootSelectionDecorator() { - return new ResizeSelectionDecorator(Color.RED, 1, new DirectionResizePoint(Position.EAST), - new DirectionResizePoint(Position.SOUTH_EAST), - new DirectionResizePoint(Position.SOUTH)); + return new ResizeSelectionDecorator(Color.RED, 1, new DirectionResizePoint(Position.EAST, "top_resize_"), + new DirectionResizePoint(Position.SOUTH_EAST, "top_resize"), + new DirectionResizePoint(Position.SOUTH, "top_resize")); + } + + @Override + protected EditOperation processRootOperation(OperationContext context) { + if (context.is("top_resize")) { + return new ResizeOperation(context); + } + return null; } private static class RootView extends JComponent { diff --git a/plugins/android-designer/src/com/intellij/android/designer/designSurface/ResizeOperation.java b/plugins/android-designer/src/com/intellij/android/designer/designSurface/ResizeOperation.java new file mode 100644 index 000000000000..158d95424ef0 --- /dev/null +++ b/plugins/android-designer/src/com/intellij/android/designer/designSurface/ResizeOperation.java @@ -0,0 +1,83 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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.android.designer.designSurface; + +import com.intellij.designer.designSurface.EditOperation; +import com.intellij.designer.designSurface.FeedbackLayer; +import com.intellij.designer.designSurface.OperationContext; +import com.intellij.designer.model.RadComponent; +import com.intellij.designer.designSurface.feedbacks.AlphaComponent; +import com.intellij.designer.utils.Position; + +import javax.swing.*; +import java.awt.*; +import java.util.List; + +/** + * @author Alexander Lobas + */ +public class ResizeOperation implements EditOperation { + private final OperationContext myContext; + private RadComponent myComponent; + private JComponent myFeedback; + + public ResizeOperation(OperationContext context) { + myContext = context; + } + + @Override + public void setComponent(RadComponent component) { + myComponent = component; + } + + @Override + public void setComponents(List component) { + } + + @Override + public void showFeedback() { + FeedbackLayer layer = myContext.getArea().getFeedbackLayer(); + + if (myFeedback == null) { + myFeedback = new AlphaComponent(Color.GREEN, Color.LIGHT_GRAY); + layer.add(myFeedback); + } + + Rectangle bounds = myComponent.getBounds(); + Point location = myComponent.convertPoint(bounds.x, bounds.y, layer); + myFeedback.setBounds(myContext.getTransformedRectangle(location.x, location.y, bounds.width, bounds.height)); + layer.repaint(); + } + + @Override + public void eraseFeedback() { + if (myFeedback != null) { + FeedbackLayer layer = myContext.getArea().getFeedbackLayer(); + layer.remove(myFeedback); + layer.repaint(); + myFeedback = null; + } + } + + @Override + public boolean canExecute() { + return myContext.getResizeDirection() != Position.SOUTH; + } + + @Override + public void execute() throws Exception { + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java index 03bc9080a430..efb1101d1ad7 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java @@ -30,6 +30,7 @@ import com.intellij.ui.ScrollPaneFactory; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -130,6 +131,11 @@ public abstract class DesignerEditorPanel extends JPanel implements ToolProvider return DesignerEditorPanel.this.getRootSelectionDecorator(); } + @Nullable + public EditOperation processRootOperation(OperationContext context) { + return DesignerEditorPanel.this.processRootOperation(context); + } + @Override public FeedbackLayer getFeedbackLayer() { return myFeedbackLayer; @@ -175,6 +181,9 @@ public abstract class DesignerEditorPanel extends JPanel implements ToolProvider protected abstract ComponentDecorator getRootSelectionDecorator(); + @Nullable + protected abstract EditOperation processRootOperation(OperationContext context); + public InputTool getActiveTool() { return myTool; } diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/EditOperation.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/EditOperation.java new file mode 100644 index 000000000000..266a4d711307 --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/EditOperation.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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.designer.designSurface; + +import com.intellij.designer.model.RadComponent; + +import java.util.List; + +/** + * @author Alexander Lobas + */ +public interface EditOperation { + void setComponent(RadComponent component); + + void setComponents(List component); + + void showFeedback(); + + void eraseFeedback(); + + boolean canExecute(); + + void execute() throws Exception; +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/EditableArea.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/EditableArea.java index a4b4b37a7695..8f38c638b2e2 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/EditableArea.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/EditableArea.java @@ -92,7 +92,21 @@ public abstract class EditableArea { public abstract ComponentDecorator getRootSelectionDecorator(); + @Nullable + public EditOperation processRootOperation(OperationContext context) { + return null; + } + public abstract FeedbackLayer getFeedbackLayer(); public abstract RadComponent getRootComponent(); + + public boolean isTree() { + return false; + } + + @Nullable + public FeedbackTreeLayer getFeedbackTreeLayer() { + return null; + } } \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FeedbackTreeLayer.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FeedbackTreeLayer.java new file mode 100644 index 000000000000..2c3bf8b39dd3 --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FeedbackTreeLayer.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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.designer.designSurface; + +/** + * @author Alexander Lobas + */ +public interface FeedbackTreeLayer { +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/OperationContext.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/OperationContext.java new file mode 100644 index 000000000000..be1095a83979 --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/OperationContext.java @@ -0,0 +1,118 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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.designer.designSurface; + +import com.intellij.designer.model.RadComponent; + +import java.awt.*; +import java.awt.event.InputEvent; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Alexander Lobas + */ +public final class OperationContext { + private final Object myType; + private EditableArea myArea; + private List myComponents; + private InputEvent myInputEvent; + private Point myLocation; + private Point myMoveDelta; + private Dimension mySizeDelta; + private int myResizeDirection; + private Object myNewObject; + + public OperationContext(Object type) { + myType = type; + } + + public Object getType() { + return myType; + } + + public boolean is(Object type) { + return type == null ? myType == null : type.equals(myType); + } + + public EditableArea getArea() { + return myArea; + } + + public void setArea(EditableArea area) { + myArea = area; + } + + public List getComponents() { + return myComponents; + } + + public void setComponents(List components) { + myComponents = components; + } + + public InputEvent getInputEvent() { + return myInputEvent; + } + + public void setInputEvent(InputEvent inputEvent) { + myInputEvent = inputEvent; + } + + public Point getLocation() { + return myLocation; + } + + public void setLocation(Point location) { + myLocation = location; + } + + public Point getMoveDelta() { + return myMoveDelta; + } + + public void setMoveDelta(Point moveDelta) { + myMoveDelta = moveDelta; + } + + public Dimension getSizeDelta() { + return mySizeDelta; + } + + public void setSizeDelta(Dimension sizeDelta) { + mySizeDelta = sizeDelta; + } + + public Rectangle getTransformedRectangle(int x, int y, int width, int height) { + return new Rectangle(x + myMoveDelta.x, y + myMoveDelta.y, width + mySizeDelta.width, height + mySizeDelta.height); + } + + public int getResizeDirection() { + return myResizeDirection; + } + + public void setResizeDirection(int resizeDirection) { + myResizeDirection = resizeDirection; + } + + public Object getNewObject() { + return myNewObject; + } + + public void setNewObject(Object newObject) { + myNewObject = newObject; + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/AlphaComponent.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/AlphaComponent.java new file mode 100644 index 000000000000..313d77a3e05d --- /dev/null +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/AlphaComponent.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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.designer.designSurface.feedbacks; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Alexander Lobas + */ +public class AlphaComponent extends JComponent { + private static final AlphaComposite myComposite1 = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.3f); + private static final AlphaComposite myComposite2 = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.6f); + + private final Color myColor; + private final Color myBorderColor; + + public AlphaComponent(Color color) { + this(color, color); + } + + public AlphaComponent(Color color, Color borderColor) { + myColor = color; + myBorderColor = borderColor; + } + + protected void paintComponent(final Graphics g) { + Graphics2D g2d = (Graphics2D)g; + super.paintComponent(g); + final Composite oldComposite = g2d.getComposite(); + final Color oldColor = g2d.getColor(); + + g2d.setColor(myColor); + g2d.setComposite(myComposite1); + g2d.fillRect(0, 0, getWidth(), getHeight()); + + g2d.setColor(myBorderColor); + g2d.setComposite(myComposite2); + g2d.drawRect(0, 0, getWidth() - 1, getHeight() - 1); + + g2d.setColor(oldColor); + g2d.setComposite(oldComposite); + } +} \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/selection/DirectionResizePoint.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/selection/DirectionResizePoint.java index 038ae1189ba8..012e6d305426 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/selection/DirectionResizePoint.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/selection/DirectionResizePoint.java @@ -28,16 +28,19 @@ import java.awt.*; */ public class DirectionResizePoint extends ResizePoint { private int myDirection; + private Object myType; private double myXSeparator; private double myYSeparator; - public DirectionResizePoint(int direction) { + public DirectionResizePoint(int direction, Object type) { setDirection(direction); + myType = type; } - public DirectionResizePoint(Color color, Color border, int direction) { + public DirectionResizePoint(Color color, Color border, int direction, Object type) { super(color, border); setDirection(direction); + myType = type; } private void setDirection(int direction) { @@ -68,7 +71,7 @@ public class DirectionResizePoint extends ResizePoint { @Override protected InputTool createTool(RadComponent component) { - return new ResizeTracker(myDirection); + return new ResizeTracker(myDirection, myType); } @Override diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/InputTool.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/InputTool.java index dcb9aefedd73..1a051b6b790c 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/InputTool.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/InputTool.java @@ -37,7 +37,7 @@ public abstract class InputTool { protected ToolProvider myToolProvider; protected EditableArea myArea; - private Object myCommand; + protected Object myCommand; private boolean myActive; private boolean myCanUnload = true; @@ -100,10 +100,6 @@ public abstract class InputTool { } } - protected final boolean unloadWhenFinished() { - return myCanUnload; - } - public final void setUnloadWhenFinished(boolean value) { myCanUnload = value; } @@ -228,7 +224,7 @@ public abstract class InputTool { protected void handleAreaExited() { } - protected void handleFinished() { + protected final void handleFinished() { if (myCanUnload) { myToolProvider.loadDefaultTool(); } diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/MarqueeTracker.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/MarqueeTracker.java index fa352b45c4ec..910fdf9edcae 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/MarqueeTracker.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/MarqueeTracker.java @@ -18,6 +18,7 @@ package com.intellij.designer.designSurface.tools; import com.intellij.designer.designSurface.FeedbackLayer; import com.intellij.designer.model.RadComponent; import com.intellij.designer.model.RadComponentVisitor; +import com.intellij.designer.designSurface.feedbacks.AlphaComponent; import com.intellij.designer.utils.Cursors; import javax.swing.*; @@ -30,8 +31,6 @@ import java.util.List; * @author Alexander Lobas */ public class MarqueeTracker extends InputTool { - private static final AlphaComposite myComposite1 = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.3f); - private static final AlphaComposite myComposite2 = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.6f); private static final Color myColor = new Color(47, 67, 96); private static final int TOGGLE_MODE = 1; @@ -111,24 +110,7 @@ public class MarqueeTracker extends InputTool { FeedbackLayer layer = myArea.getFeedbackLayer(); if (myFeedback == null) { - myFeedback = new JComponent() { - protected void paintComponent(final Graphics g) { - Graphics2D g2d = (Graphics2D)g; - super.paintComponent(g); - final Composite oldComposite = g2d.getComposite(); - final Color oldColor = g2d.getColor(); - g2d.setColor(myColor); - - g2d.setComposite(myComposite1); - g2d.fillRect(0, 0, getWidth(), getHeight()); - - g2d.setComposite(myComposite2); - g2d.drawRect(0, 0, getWidth() - 1, getHeight() - 1); - - g2d.setColor(oldColor); - g2d.setComposite(oldComposite); - } - }; + myFeedback = new AlphaComponent(myColor); layer.add(myFeedback); } diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/ResizeTracker.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/ResizeTracker.java index 5008ad3efff8..51fd16846d38 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/ResizeTracker.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/ResizeTracker.java @@ -15,13 +15,180 @@ */ package com.intellij.designer.designSurface.tools; +import com.intellij.designer.designSurface.EditOperation; +import com.intellij.designer.designSurface.OperationContext; +import com.intellij.designer.model.RadComponent; import com.intellij.designer.utils.Cursors; +import com.intellij.designer.utils.Position; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; /** * @author Alexander Lobas */ public class ResizeTracker extends InputTool { - public ResizeTracker(int direction) { + private OperationContext myContext; + private List myOperations; + private boolean myShowFeedback; + private final int myDirection; + + public ResizeTracker(int direction, Object type) { + myDirection = direction; + myContext = new OperationContext(type); + myContext.setResizeDirection(direction); setDefaultCursor(Cursors.getResizeCursor(direction)); + setDisabledCursor(Cursors.getNoCursor()); + } + + @Override + public void deactivate() { + eraseFeedback(); + myContext = null; + myOperations = null; + super.deactivate(); + } + + @Override + protected Cursor calculateCursor() { + if (myState == STATE_DRAG) { + return getDefaultCursor(); + } + return super.calculateCursor(); + } + + @Override + protected void handleButtonDown(int button) { + if (button == 1) { + if (myState == STATE_INIT) { + myState = STATE_DRAG; + } + } + else { + myState = STATE_INVALID; + eraseFeedback(); + setCommand(null); + } + } + + @Override + protected void handleButtonUp(int button) { + if (myState == STATE_DRAG_IN_PROGRESS) { + myState = STATE_NONE; + eraseFeedback(); + executeCommand(); + } + } + + @Override + protected void handleDragStarted() { + if (myState == STATE_DRAG) { + myState = STATE_DRAG_IN_PROGRESS; + } + } + + @Override + protected void handleDragInProgress() { + if (myState == STATE_DRAG_IN_PROGRESS) { + updateContext(); + showFeedback(); + setCommand(); + } + } + + private void showFeedback() { + for (EditOperation operation : getOperations()) { + operation.showFeedback(); + } + myShowFeedback = true; + } + + private void eraseFeedback() { + if (myShowFeedback) { + myShowFeedback = false; + for (EditOperation operation : getOperations()) { + operation.eraseFeedback(); + } + } + } + + private void executeCommand() { + if (myCommand != null) { + try { + for (EditOperation operation : getOperations()) { + if (operation.canExecute()) { + operation.execute(); + } + } + } + catch (Exception e) { + myToolProvider.showError("Execute command: ", e); + } + } + } + + private void setCommand() { + for (EditOperation operation : getOperations()) { + if (operation.canExecute()) { + setCommand(this); + return; + } + } + setCommand(null); + } + + private void updateContext() { + myContext.setArea(myArea); + myContext.setInputEvent(myInputEvent); + + Point corner = new Point(); + Dimension resize = new Dimension(); + + int moveDeltaHeight = myCurrentScreenY - myStartScreenY; + if ((myDirection & Position.NORTH) != 0) { + corner.y += moveDeltaHeight; + resize.height -= moveDeltaHeight; + } + else if ((myDirection & Position.SOUTH) != 0) { + resize.height += moveDeltaHeight; + } + + int moveDeltaWidth = myCurrentScreenX - myStartScreenX; + if ((myDirection & Position.WEST) != 0) { + corner.x += moveDeltaWidth; + resize.width -= moveDeltaWidth; + } + else if ((myDirection & Position.EAST) != 0) { + resize.width += moveDeltaWidth; + } + + myContext.setMoveDelta(corner); + myContext.setSizeDelta(resize); + myContext.setLocation(new Point(myCurrentScreenX, myCurrentScreenY)); + } + + private List getOperations() { + if (myOperations == null) { + myContext.setComponents(new ArrayList(myArea.getSelection())); + myOperations = new ArrayList(); + + for (RadComponent component : myContext.getComponents()) { + EditOperation operation; + RadComponent parent = component.getParent(); + if (parent == null) { + operation = myArea.processRootOperation(myContext); + } + else { + operation = parent.getLayout().processChildOperation(myContext); + } + if (operation != null) { + myOperations.add(operation); + operation.setComponent(component); + } + } + } + return myOperations; } } \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java index e7c478361d7b..fb2c18780aa2 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java @@ -32,26 +32,43 @@ import java.util.List; public class SelectionTool extends InputTool { private InputTool myTracker; + @Override + public void deactivate() { + deactivateTracker(); + super.deactivate(); + } + + @Override + public void refreshCursor() { + if (myTracker == null) { + super.refreshCursor(); + } + } + @Override protected void handleButtonDown(int button) { if (myState == STATE_INIT) { myState = STATE_DRAG; deactivateTracker(); - if (myInputEvent.isAltDown()) { - setTracker(new MarqueeTracker()); - return; - } + if (!myArea.isTree()) { + if (myInputEvent.isAltDown()) { + setTracker(new MarqueeTracker()); + return; + } - InputTool tracker = myArea.findTargetTool(myCurrentScreenX, myCurrentScreenY); - if (tracker != null) { - setTracker(tracker); - return; + InputTool tracker = myArea.findTargetTool(myCurrentScreenX, myCurrentScreenY); + if (tracker != null) { + setTracker(tracker); + return; + } } RadComponent component = myArea.findTarget(myCurrentScreenX, myCurrentScreenY); if (component == null) { - setTracker(new MarqueeTracker()); + if (!myArea.isTree()) { + setTracker(new MarqueeTracker()); + } } else { setTracker(component.getDragTracker()); @@ -78,19 +95,6 @@ public class SelectionTool extends InputTool { } } - @Override - public void deactivate() { - deactivateTracker(); - super.deactivate(); - } - - @Override - public void refreshCursor() { - if (myTracker == null) { - super.refreshCursor(); - } - } - private void setTracker(@Nullable InputTool tracker) { if (myTracker != tracker) { deactivateTracker(); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadComponent.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadComponent.java index c04497da738e..5d8a978b7b2a 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadComponent.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadComponent.java @@ -36,6 +36,12 @@ public abstract class RadComponent { private RadLayout myLayout; private final Map myClientProperties = new HashMap(); + ////////////////////////////////////////////////////////////////////////////////////////// + // + // Hierarchy + // + ////////////////////////////////////////////////////////////////////////////////////////// + public RadComponent getRoot() { return myParent == null ? this : myParent.getRoot(); } @@ -56,6 +62,12 @@ public abstract class RadComponent { return getChildren().toArray(); } + ////////////////////////////////////////////////////////////////////////////////////////// + // + // Visual + // + ////////////////////////////////////////////////////////////////////////////////////////// + public Rectangle getBounds() { return null; } @@ -72,6 +84,12 @@ public abstract class RadComponent { return new DragTracker(this); } + ////////////////////////////////////////////////////////////////////////////////////////// + // + // layout + // + ////////////////////////////////////////////////////////////////////////////////////////// + public RadLayout getLayout() { return myLayout; } @@ -85,6 +103,12 @@ public abstract class RadComponent { return null; } + ////////////////////////////////////////////////////////////////////////////////////////// + // + // Properties + // + ////////////////////////////////////////////////////////////////////////////////////////// + public List getProperties() { return null; } @@ -97,6 +121,12 @@ public abstract class RadComponent { myClientProperties.put(key, value); } + ////////////////////////////////////////////////////////////////////////////////////////// + // + // Visitor + // + ////////////////////////////////////////////////////////////////////////////////////////// + public void accept(RadComponentVisitor visitor, boolean forward) { if (visitor.visit(this)) { List children = getChildren(); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadLayout.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadLayout.java index 094b581827a2..a4a3e310c691 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadLayout.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadLayout.java @@ -16,10 +16,18 @@ package com.intellij.designer.model; import com.intellij.designer.designSurface.ComponentDecorator; +import com.intellij.designer.designSurface.EditOperation; +import com.intellij.designer.designSurface.OperationContext; +import org.jetbrains.annotations.Nullable; /** * @author Alexander Lobas */ public abstract class RadLayout { public abstract ComponentDecorator getChildSelectionDecorator(RadComponent component); + + @Nullable + public EditOperation processChildOperation(OperationContext context) { + return null; + } } \ No newline at end of file