From dc7343986c10f344a4fa203990489abf2bbf372b Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Wed, 13 Apr 2011 15:28:50 +0400 Subject: [PATCH 1/7] IDEA-63663 Sort run configurations alphabetically if clean checkout (no workspace.xml were found) [r=ann] --- .../execution/impl/RunManagerImpl.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index ceb8b8d985bc..361ccb059d16 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -287,19 +287,28 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, @Override public Collection getSortedConfigurations() { - if (!myOrdered && !myOrder.isEmpty()) { //compatibility + if (!myOrdered) { //compatibility final HashMap settings = - new HashMap(myConfigurations); //sort shared and local configurations + new HashMap(myConfigurations); //sort shared and local configurations myConfigurations.clear(); + final List order = new ArrayList(settings.keySet()); - Collections.sort(order, new Comparator() { - public int compare(final String o1, final String o2) { - return myOrder.indexOf(o1) - myOrder.indexOf(o2); - } - }); - for (String configName : order) { + if (myOrder.isEmpty()) { + // IDEA-63663 Sort run configurations alphabetically if clean checkout + Collections.sort(order); + } + else { + Collections.sort(order, new Comparator() { + public int compare(final String o1, final String o2) { + return myOrder.indexOf(o1) - myOrder.indexOf(o2); + } + }); + } + + for (final String configName : order) { myConfigurations.put(configName, settings.get(configName)); } + myOrdered = true; } return myConfigurations.values(); From e02e7562e8e9133482186ee282afba46f9dde0e4 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Wed, 13 Apr 2011 15:27:05 +0400 Subject: [PATCH 2/7] IDEA-63971: mouse hits for marks inside folded ranges. --- .../editor/impl/EditorMarkupModelImpl.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java index dd41e8a8a8e4..c665fe5f779f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java @@ -187,11 +187,18 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark private void getNearestHighlighters(MarkupModelEx markupModel, MouseEvent e, final double width, final Collection nearest) { if (0 > e.getX() || e.getX() >= width) return; - int startOffset = yPositionToOffset(e.getY()-getMinHeight(), true); - int endOffset = yPositionToOffset(e.getY()+getMinHeight(), false); + final int y = e.getY(); + int startOffset = yPositionToOffset(y -getMinHeight(), true); + int endOffset = yPositionToOffset(y +getMinHeight(), false); markupModel.processHighlightsOverlappingWith(startOffset, endOffset, new Processor() { public boolean process(RangeHighlighterEx highlighter) { - if (highlighter.getErrorStripeMarkColor() != null) nearest.add(highlighter); + if (highlighter.getErrorStripeMarkColor() != null) { + ProperTextRange range = offsetToYPosition(highlighter.getStartOffset(), highlighter.getEndOffset()); + if (range.getStartOffset() >= y - getMinHeight() * 2 && + range.getEndOffset() <= y + getMinHeight() * 2) { + nearest.add(highlighter); + } + } return true; } }); @@ -797,6 +804,16 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark if (line < 0) return 0; if (line >= document.getLineCount()) return document.getTextLength(); - return beginLine ? document.getLineStartOffset(line) : document.getLineEndOffset(line); + final FoldingModelEx foldingModel = myEditor.getFoldingModel(); + if (beginLine) { + final int offset = document.getLineStartOffset(line); + final FoldRegion startCollapsed = foldingModel.getCollapsedRegionAtOffset(offset); + return startCollapsed != null ? Math.min(offset, startCollapsed.getStartOffset()) : offset; + } + else { + final int offset = document.getLineEndOffset(line); + final FoldRegion startCollapsed = foldingModel.getCollapsedRegionAtOffset(offset); + return startCollapsed != null ? Math.max(offset, startCollapsed.getEndOffset()) : offset; + } } } From 4784542e30211dea881aad4d5815072a8e10da11 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Wed, 13 Apr 2011 15:28:39 +0400 Subject: [PATCH 3/7] Tolerate to missing searchableOptions.xml --- .../ide/ui/search/SearchableOptionsRegistrarImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/search/SearchableOptionsRegistrarImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/search/SearchableOptionsRegistrarImpl.java index 9da67123c1b8..7c4d63da879b 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/search/SearchableOptionsRegistrarImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/search/SearchableOptionsRegistrarImpl.java @@ -40,6 +40,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.event.DocumentEvent; +import java.net.URL; import java.util.*; import java.util.regex.Pattern; @@ -80,8 +81,14 @@ public class SearchableOptionsRegistrarImpl extends SearchableOptionsRegistrar { ContainerUtil.addAll(myStopWords, stopWords); //index + final URL indexResource = ResourceUtil.getResource(SearchableOptionsRegistrar.class, "/search/", "searchableOptions.xml"); + if (indexResource == null) { + LOG.info("No /search/searchableOptions.xml found, settings search won't work!"); + return; + } + Document document = - JDOMUtil.loadDocument(ResourceUtil.getResource(SearchableOptionsRegistrar.class, "/search/", "searchableOptions.xml")); + JDOMUtil.loadDocument(indexResource); Element root = document.getRootElement(); List configurables = root.getChildren("configurable"); for (final Object o : configurables) { From 37a88f9b3d6b6e258ba4288c0c7ad7c0a52b855d Mon Sep 17 00:00:00 2001 From: irengrig Date: Fri, 8 Apr 2011 17:53:17 +0400 Subject: [PATCH 4/7] progress for files --- .../changes/shelf/ShelveChangesManager.java | 5 +- .../com/intellij/vcsUtil/FilesProgress.java | 62 +++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 platform/vcs-impl/src/com/intellij/vcsUtil/FilesProgress.java diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java index 97ec0edcd960..f904fb734eb7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelveChangesManager.java @@ -51,6 +51,7 @@ import com.intellij.util.continuation.*; import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.Topic; import com.intellij.util.text.CharArrayCharSequence; +import com.intellij.vcsUtil.FilesProgress; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -237,9 +238,9 @@ public class ShelveChangesManager implements ProjectComponent, JDOMExternalizabl public List importChangeLists(final Collection files, final Consumer exceptionConsumer) { final List result = new ArrayList(files.size()); try { + final FilesProgress filesProgress = new FilesProgress(files.size(), "Processing "); for (VirtualFile file : files) { - ProgressManager.checkCanceled(); - + filesProgress.updateIndicator(file); final String description = file.getNameWithoutExtension().replace('_', ' '); final File patchPath = getPatchPath(description); final ShelvedChangeList list = new ShelvedChangeList(patchPath.getPath(), description, new SmartList(), diff --git a/platform/vcs-impl/src/com/intellij/vcsUtil/FilesProgress.java b/platform/vcs-impl/src/com/intellij/vcsUtil/FilesProgress.java new file mode 100644 index 000000000000..60dfc96bdf09 --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/vcsUtil/FilesProgress.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2011 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.vcsUtil; + +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.vfs.VirtualFile; + +/** + * @author irengrig + * Date: 4/8/11 + * Time: 5:15 PM + */ +public class FilesProgress { + private final double myTotal; + private final String myPrefix; + private final ProgressIndicator myProgressIndicator; + private int myCnt; + private boolean myInText2; + + public FilesProgress(double total, final String prefix) { + myTotal = total; + myPrefix = prefix; + myProgressIndicator = ProgressManager.getInstance().getProgressIndicator(); + myCnt = 0; + myInText2 = false; + } + + public void updateIndicator(final VirtualFile vf) { + if (myProgressIndicator == null) return; + myProgressIndicator.checkCanceled(); + if (myInText2) { + myProgressIndicator.setText2(myPrefix + getFileDescriptionForProgress(vf)); + } else { + myProgressIndicator.setText(myPrefix + getFileDescriptionForProgress(vf)); + } + myProgressIndicator.setFraction(myCnt/myTotal); + ++ myCnt; + } + + private static String getFileDescriptionForProgress(final VirtualFile file) { + final VirtualFile parent = file.getParent(); + return file.getName() + " (" + (parent == null ? file.getPath() : parent.getPath()) + ")"; + } + + public void setInText2(boolean inText2) { + myInText2 = inText2; + } +} From ab9d0b32e3a215fa31e14297f692b96ec94a8965 Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 13 Apr 2011 13:19:11 +0400 Subject: [PATCH 5/7] VCS: use VCS plugin name for notifications group id --- .../idea/svn/SvnAuthenticationNotifier.java | 3 +-- .../src/org/jetbrains/idea/svn/SvnVcs.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java index fd0e7e06eb24..8a2fdae3ed98 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationNotifier.java @@ -45,14 +45,13 @@ import java.util.*; public class SvnAuthenticationNotifier extends GenericNotifierImpl { private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.svn.SvnAuthenticationNotifier"); - private static final String ourGroupId = "SubversionId"; private final SvnVcs myVcs; private final RootsToWorkingCopies myRootsToWorkingCopies; private final Map myCopiesPassiveResults; private Timer myTimer; public SvnAuthenticationNotifier(final SvnVcs svnVcs) { - super(svnVcs.getProject(), ourGroupId, "Not Logged In to Subversion", NotificationType.ERROR); + super(svnVcs.getProject(), svnVcs.getDisplayName(), "Not Logged In to Subversion", NotificationType.ERROR); myVcs = svnVcs; myRootsToWorkingCopies = myVcs.getRootsToWorkingCopies(); myCopiesPassiveResults = Collections.synchronizedMap(new HashMap()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java index b7f6a5aaba33..8b8af3ba5ce8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java @@ -21,6 +21,8 @@ import com.intellij.ide.FrameStateListener; import com.intellij.ide.FrameStateManager; import com.intellij.idea.RareLogger; import com.intellij.notification.*; +import com.intellij.notification.impl.NotificationSettings; +import com.intellij.notification.impl.NotificationsConfiguration; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; @@ -221,6 +223,10 @@ public class SvnVcs extends AbstractVcs { myFrameStateListener = new MyFrameStateListener(changeListManager, vcsDirtyScopeManager); myWorkingCopiesContent = new WorkingCopiesContent(this); + + // remove used some time before old notification group ids + NotificationsConfiguration.remove(new NotificationSettings[] {new NotificationSettings("SVN_NO_JNA", null), + new NotificationSettings("SVN_NO_CRYPT32", null), new NotificationSettings("SubversionId", null)}); } public void postStartup() { @@ -328,15 +334,13 @@ public class SvnVcs extends AbstractVcs { } } - private final static String UPGRADE_SUBVERSION_FORMAT = "Subversion"; - private void upgradeToRecentVersion(final SvnConfiguration.SvnSupportOptions supportOptions) { if (! supportOptions.upgradeTo16Asked()) { final SvnWorkingCopyChecker workingCopyChecker = new SvnWorkingCopyChecker(); if (workingCopyChecker.upgradeNeeded()) { - Notifications.Bus.notify(new Notification(UPGRADE_SUBVERSION_FORMAT, SvnBundle.message("upgrade.format.to16.question.title"), + Notifications.Bus.notify(new Notification(getDisplayName(), SvnBundle.message("upgrade.format.to16.question.title"), "Old format Subversion working copies could be upgraded to version 1.6.", NotificationType.INFORMATION, new NotificationListener() { public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { @@ -374,10 +378,10 @@ public class SvnVcs extends AbstractVcs { if (SystemInfo.isWindows) { if (! SVNJNAUtil.isJNAPresent()) { - Notifications.Bus.notify(new Notification("SVN_NO_JNA", "Subversion plugin: no JNA", + Notifications.Bus.notify(new Notification(getDisplayName(), "Subversion plugin: no JNA", "A problem with JNA initialization for svnkit library. Encryption is not available.", NotificationType.WARNING), NotificationDisplayType.BALLOON, myProject); } else if (! SVNJNAUtil.isWinCryptEnabled()) { - Notifications.Bus.notify(new Notification("SVN_NO_CRYPT32", "Subversion plugin: no encryption", + Notifications.Bus.notify(new Notification(getDisplayName(), "Subversion plugin: no encryption", "A problem with encryption module (Crypt32.dll) initialization for svnkit library. Encryption is not available.", NotificationType.WARNING), NotificationDisplayType.BALLOON, myProject); } } From f008573b3fa6612ec3cca922887929ec1840b9f1 Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 13 Apr 2011 14:04:25 +0400 Subject: [PATCH 6/7] SVN: when changing notification ids, also make Subversion group sticky balloon - since group was used before, but for other kinds (will be done once) --- .../src/org/jetbrains/idea/svn/SvnVcs.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java index 8b8af3ba5ce8..f4dd88bc9e23 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java @@ -225,8 +225,22 @@ public class SvnVcs extends AbstractVcs { myWorkingCopiesContent = new WorkingCopiesContent(this); // remove used some time before old notification group ids - NotificationsConfiguration.remove(new NotificationSettings[] {new NotificationSettings("SVN_NO_JNA", null), - new NotificationSettings("SVN_NO_CRYPT32", null), new NotificationSettings("SubversionId", null)}); + correctNotificationIds(); + } + + private void correctNotificationIds() { + boolean notEmpty = NotificationsConfiguration.getSettings("SVN_NO_JNA") != null || + NotificationsConfiguration.getSettings("SVN_NO_CRYPT32") != null || + NotificationsConfiguration.getSettings("SubversionId") != null; + if (notEmpty) { + NotificationsConfiguration.remove(new NotificationSettings[] {new NotificationSettings("SVN_NO_JNA", null), + new NotificationSettings("SVN_NO_CRYPT32", null), new NotificationSettings("SubversionId", null)}); + // if group ids is being changed, set highest level first + final NotificationSettings settings = NotificationsConfiguration.getSettings(getDisplayName()); + if (settings != null) { + settings.setDisplayType(NotificationDisplayType.STICKY_BALLOON); + } + } } public void postStartup() { From 223eba72a6f03a23233097b43c26eeb6fc51ad9b Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 13 Apr 2011 16:01:23 +0400 Subject: [PATCH 7/7] P4: detect offline state. Offline notification. Also when offline state edited from settings --- .../intellij/openapi/vcs/impl/GenericNotifierImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/GenericNotifierImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/GenericNotifierImpl.java index 245e377bc1ff..a2ca4b56f722 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/GenericNotifierImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/GenericNotifierImpl.java @@ -28,7 +28,7 @@ import java.util.*; public abstract class GenericNotifierImpl { private final static Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.impl.GenericNotifier"); - private final Project myProject; + protected final Project myProject; @NotNull private final String myGroupId; //+- here @NotNull @@ -181,4 +181,10 @@ public abstract class GenericNotifierImpl { private static void log(final String s) { LOG.debug(s); } + + public boolean isEmpty() { + synchronized (myLock) { + return myState.isEmpty(); + } + } }