Merge commit 'origin/master'

This commit is contained in:
Eugene Kudelevsky
2011-04-13 16:17:50 +04:00
8 changed files with 142 additions and 23 deletions
@@ -287,19 +287,28 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
@Override
public Collection<RunnerAndConfigurationSettings> getSortedConfigurations() {
if (!myOrdered && !myOrder.isEmpty()) { //compatibility
if (!myOrdered) { //compatibility
final HashMap<String, RunnerAndConfigurationSettings> settings =
new HashMap<String, RunnerAndConfigurationSettings>(myConfigurations); //sort shared and local configurations
new HashMap<String, RunnerAndConfigurationSettings>(myConfigurations); //sort shared and local configurations
myConfigurations.clear();
final List<String> order = new ArrayList<String>(settings.keySet());
Collections.sort(order, new Comparator<String>() {
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<String>() {
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();
@@ -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) {
@@ -187,11 +187,18 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
private void getNearestHighlighters(MarkupModelEx markupModel, MouseEvent e, final double width, final Collection<RangeHighlighter> 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<RangeHighlighterEx>() {
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;
}
}
}
@@ -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<ShelvedChangeList> importChangeLists(final Collection<VirtualFile> files, final Consumer<VcsException> exceptionConsumer) {
final List<ShelvedChangeList> result = new ArrayList<ShelvedChangeList>(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<ShelvedBinaryFile>(),
@@ -28,7 +28,7 @@ import java.util.*;
public abstract class GenericNotifierImpl<T, Key> {
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<T, Key> {
private static void log(final String s) {
LOG.debug(s);
}
public boolean isEmpty() {
synchronized (myLock) {
return myState.isEmpty();
}
}
}
@@ -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;
}
}
@@ -45,14 +45,13 @@ import java.util.*;
public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthenticationNotifier.AuthenticationRequest, SVNURL> {
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<SVNURL, Boolean> 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<SVNURL, Boolean>());
@@ -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,24 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
myFrameStateListener = new MyFrameStateListener(changeListManager, vcsDirtyScopeManager);
myWorkingCopiesContent = new WorkingCopiesContent(this);
// remove used some time before old notification group ids
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() {
@@ -328,15 +348,13 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
}
}
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 <a href=\"\">could be upgraded to version 1.6</a>.",
NotificationType.INFORMATION, new NotificationListener() {
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
@@ -374,10 +392,10 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
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);
}
}