Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2012-03-21 16:31:58 +01:00
18 changed files with 184 additions and 91 deletions
@@ -22,6 +22,9 @@ import com.intellij.openapi.util.JDOMExternalizable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @see com.intellij.execution.RunManager
*/
public interface RunConfiguration extends RunProfile, JDOMExternalizable, Cloneable {
ConfigurationFactory getFactory();
@@ -32,6 +32,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiFile;
import com.intellij.util.containers.HashMap;
import com.intellij.util.ui.update.Update;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -163,7 +164,18 @@ public class ExternalToolPass extends TextEditorHighlightingPass {
r.run();
}
else {
myExternalToolPassFactory.scheduleExternalActivity(myFile, r);
myExternalToolPassFactory.scheduleExternalActivity(new Update(myFile) {
@Override
public void run() {
r.run();
}
@Override
public void setRejected() {
super.setRejected();
doFinish();
}
});
}
}
@@ -78,12 +78,7 @@ public class ExternalToolPassFactory extends AbstractProjectComponent implements
return false;
}
void scheduleExternalActivity(@NotNull PsiFile file, @NotNull final Runnable r) {
myExternalActivitiesQueue.queue(new Update(file) {
@Override
public void run() {
r.run();
}
});
}
void scheduleExternalActivity(@NotNull Update update) {
myExternalActivitiesQueue.queue(update);
}
}
@@ -135,7 +135,7 @@ public class FileStructurePopup implements Disposable {
else {
myTreeActionsOwner = null;
myTreeModel = structureViewModel;
}
}
myTreeStructure = new SmartTreeStructure(project, myTreeModel){
public void rebuildTree() {
@@ -233,7 +233,7 @@ public class FileStructurePopup implements Disposable {
}
})
.createPopup();
myTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
@@ -255,6 +255,7 @@ public class FileStructurePopup implements Disposable {
}
}
});
myTree.getEmptyText().setText("Loading...");
final Point location = DimensionService.getInstance().getLocation(getDimensionServiceKey(), myProject);
if (location != null) {
myPopup.showInScreenCoordinates(myEditor.getContentComponent(), location);
@@ -267,29 +268,24 @@ public class FileStructurePopup implements Disposable {
myPopup.setSize(new Dimension(myPreferredWidth + 10, myPopup.getSize().height));
}
//final long cur = System.currentTimeMillis();
final Runnable expandIsDone = new Runnable() {
IdeFocusManager.getInstance(myProject).requestFocus(myTree, true);
myAbstractTreeBuilder.queueUpdate().doWhenDone(new Runnable() {
@Override
public void run() {
//System.out.println(System.currentTimeMillis() - cur);
IdeFocusManager.getInstance(myProject).requestFocus(myTree, true);
myAbstractTreeBuilder.queueUpdate().doWhenDone(new Runnable() {
@Override
myTreeHasBuilt.setDone();
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
selectPsiElement(myInitialPsiElement);
myTreeHasBuilt.setDone();
//long t = System.currentTimeMillis() - time;
//System.out.println("Shown in " + t + "ms");
myFilteringStructure.rebuild();
myAbstractTreeBuilder.queueUpdate(true).doWhenDone(new Runnable() {
@Override
public void run() {
selectPsiElement(myInitialPsiElement);
}
});
}
});
}
};
//if (myTree.isAlwaysExpanded() || true) {
expandIsDone.run();
//} else {
// myAbstractTreeBuilder.expandAll(expandIsDone);
//}
});
if (!ApplicationManager.getApplication().isUnitTestMode()) {
final Alarm alarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, myPopup);
@@ -457,11 +453,11 @@ public class FileStructurePopup implements Disposable {
}
}
}.registerCustomShortcutSet(CustomShortcutSet.fromString("ESCAPE"), myTree);
myTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1) {
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1) {
navigateSelectedElement();
}
}
@@ -497,7 +493,7 @@ public class FileStructurePopup implements Disposable {
return null;
}
});
myFilteringStructure.rebuild();
return panel;
}
@@ -566,7 +562,7 @@ public class FileStructurePopup implements Disposable {
private void addCheckbox(final JPanel panel, final TreeAction action) {
String text = action instanceof FileStructureFilter ? ((FileStructureFilter)action).getCheckBoxText() :
action instanceof FileStructureNodeProvider ? ((FileStructureNodeProvider)action).getCheckBoxText() : null;
action instanceof FileStructureNodeProvider ? ((FileStructureNodeProvider)action).getCheckBoxText() : null;
if (text == null) return;
@@ -574,7 +570,7 @@ public class FileStructurePopup implements Disposable {
((FileStructureFilter)action).getShortcut() : ((FileStructureNodeProvider)action).getShortcut();
final JCheckBox chkFilter = new JCheckBox();
final boolean selected = getDefaultValue(action);
chkFilter.setSelected(selected);
@@ -592,7 +588,7 @@ public class FileStructurePopup implements Disposable {
}
myTreeStructure.rebuildTree();
myFilteringStructure.rebuild();
final Object sel = selection;
final Runnable runnable = new Runnable() {
public void run() {
@@ -745,8 +741,8 @@ public class FileStructurePopup implements Disposable {
} else {
return false;
}
}
}
return true;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -16,6 +16,7 @@
package com.intellij.openapi.fileTypes;
import com.intellij.internal.statistic.AbstractApplicationUsagesCollector;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.application.ApplicationManager;
@@ -46,30 +47,35 @@ public class FileTypeUsagesCollector extends AbstractApplicationUsagesCollector
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@NotNull final Project project) {
public Set<UsageDescriptor> getProjectUsages(@NotNull final Project project) throws CollectUsagesException {
final Set<FileType> usedFileTypes = new HashSet<FileType>();
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
if (!project.isDisposed()) {
final FileType[] registeredFileTypes = FileTypeManager.getInstance().getRegisteredFileTypes();
for (final FileType fileType : registeredFileTypes) {
FileBasedIndex.getInstance().processValues(
FileTypeIndex.NAME,
fileType,
null,
new FileBasedIndex.ValueProcessor<Void>() {
@Override
public boolean process(VirtualFile file, Void value) {
usedFileTypes.add(fileType);
return false;
}
}, GlobalSearchScope.projectScope(project));
}
usedFileTypes.add(UnknownFileType.INSTANCE);
}
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
if (fileTypeManager == null) {
throw new CollectUsagesException("Cannot get instance of FileTypeManager");
}
final FileType[] registeredFileTypes = fileTypeManager.getRegisteredFileTypes();
for (final FileType fileType : registeredFileTypes) {
if (project.isDisposed()) {
throw new CollectUsagesException("Project is disposed");
}
});
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
FileBasedIndex.getInstance().processValues(
FileTypeIndex.NAME,
fileType,
null,
new FileBasedIndex.ValueProcessor<Void>() {
@Override
public boolean process(VirtualFile file, Void value) {
usedFileTypes.add(fileType);
return false;
}
}, GlobalSearchScope.projectScope(project));
}
});
}
usedFileTypes.add(UnknownFileType.INSTANCE);
return ContainerUtil.map2Set(usedFileTypes, new NotNullFunction<FileType, UsageDescriptor>() {
@NotNull
@Override
@@ -300,7 +300,7 @@ public class UISettings implements PersistentStateComponent<UISettings>, Exporta
UISettings uiSettings=getInstance();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
GraphicsUtil.setupAntialiasing(g2d, uiSettings == null || uiSettings.ANTIALIASING_IN_EDITOR);
GraphicsUtil.setupAntialiasing(g2d, uiSettings == null || uiSettings.ANTIALIASING_IN_EDITOR, true);
}
/**
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -18,6 +18,7 @@ package com.intellij.internal.statistic;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistence;
import com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistenceComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
@@ -29,8 +30,17 @@ import java.util.Map;
import java.util.Set;
public abstract class AbstractApplicationUsagesCollector extends UsagesCollector {
private static final Logger LOG = Logger.getInstance("#com.intellij.internal.statistic.AbstractApplicationUsagesCollector");
public void persistProjectUsages(@NotNull Project project) {
persistProjectUsages(project, getProjectUsages(project));
try {
final Set<UsageDescriptor> projectUsages = getProjectUsages(project);
persistProjectUsages(project, projectUsages);
}
catch (CollectUsagesException e) {
LOG.info(e);
}
}
public void persistProjectUsages(@NotNull Project project, @NotNull Set<UsageDescriptor> usages) {
@@ -69,14 +79,15 @@ public abstract class AbstractApplicationUsagesCollector extends UsagesCollector
}
@NotNull
public Set<UsageDescriptor> getUsages(@Nullable Project project) {
public Set<UsageDescriptor> getUsages(@Nullable Project project) throws CollectUsagesException {
if (project != null) {
persistProjectUsages(project, getProjectUsages(project));
final Set<UsageDescriptor> projectUsages = getProjectUsages(project);
persistProjectUsages(project, projectUsages);
}
return getApplicationUsages();
}
@NotNull
public abstract Set<UsageDescriptor> getProjectUsages(@NotNull Project project);
public abstract Set<UsageDescriptor> getProjectUsages(@NotNull Project project) throws CollectUsagesException;
}
@@ -0,0 +1,26 @@
/*
* 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.internal.statistic;
/**
* @author Nikolay Matveev
*/
public class CollectUsagesException extends Exception {
public CollectUsagesException(String message) {
super(message);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -24,6 +24,7 @@ import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.internal.statistic.persistence.SentUsagesPersistence;
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
@@ -39,6 +40,8 @@ import java.util.*;
public class StatisticsUploadAssistant {
private static final Logger LOG = Logger.getInstance("#com.intellij.internal.statistic.StatisticsUploadAssistant");
public String getData() {
return getData(Collections.<String>emptySet());
}
@@ -233,7 +236,13 @@ public class StatisticsUploadAssistant {
final GroupDescriptor groupDescriptor = usagesCollector.getGroupId();
if (!disabledGroups.contains(groupDescriptor.getId())) {
usageDescriptors.put(groupDescriptor, usagesCollector.getUsages(project));
try {
final Set<UsageDescriptor> usages = usagesCollector.getUsages(project);
usageDescriptors.put(groupDescriptor, usages);
}
catch (CollectUsagesException e) {
LOG.info(e);
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* 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.
@@ -16,9 +16,9 @@
package com.intellij.internal.statistic;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,7 +27,7 @@ import java.util.Set;
public abstract class UsagesCollector {
public static ExtensionPointName<UsagesCollector> EP_NAME = ExtensionPointName.create("com.intellij.statistics.usagesCollector");
public abstract @NotNull Set<UsageDescriptor> getUsages(@Nullable Project project);
public abstract @NotNull Set<UsageDescriptor> getUsages(@Nullable Project project) throws CollectUsagesException;
public abstract @NotNull GroupDescriptor getGroupId();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* 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.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -303,16 +303,22 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh
});
c.addMouseListener(new MouseAdapter() {
public void mouseReleased(final MouseEvent e) {
public void mousePressed(final MouseEvent e) {
myLastPoint[0] = e.getPoint();
SwingUtilities.convertPointToScreen(myLastPoint[0], c);
if (!e.isPopupTrigger()) {
if (!UIUtil.isCloseClick(e)) {
ui.myWindow.fireActivated();
}
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (!e.isPopupTrigger()) {
if (UIUtil.isCloseClick(e, MouseEvent.MOUSE_RELEASED)) {
ui.processHide(e);
}
else {
ui.myWindow.fireActivated();
}
}
}
});
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.fileTypes;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
import com.intellij.util.NotNullFunction;
@@ -30,7 +31,7 @@ import java.util.Set;
*/
public class FileTypeUsagesCollectorTest extends LightPlatformCodeInsightFixtureTestCase {
private void doTest(@NotNull Collection<FileType> fileTypes) {
private void doTest(@NotNull Collection<FileType> fileTypes) throws CollectUsagesException {
final Set<UsageDescriptor> usages = new FileTypeUsagesCollector().getProjectUsages(getProject());
for (UsageDescriptor usage : usages) {
assertEquals(1, usage.getValue());
@@ -53,16 +54,16 @@ public class FileTypeUsagesCollectorTest extends LightPlatformCodeInsightFixture
);
}
public void testEmptyProject() {
public void testEmptyProject() throws CollectUsagesException {
doTest(Arrays.asList(UnknownFileType.INSTANCE));
}
public void testSingleFileProject() {
public void testSingleFileProject() throws CollectUsagesException {
myFixture.configureByText("a.txt", "");
doTest(Arrays.asList(UnknownFileType.INSTANCE, PlainTextFileType.INSTANCE));
}
public void testSeveralSameFilesProject() {
public void testSeveralSameFilesProject() throws CollectUsagesException {
myFixture.configureByText("a.txt", "");
myFixture.configureByText("b.txt", "");
doTest(Arrays.asList(UnknownFileType.INSTANCE, PlainTextFileType.INSTANCE));
@@ -25,21 +25,21 @@ import java.util.Map;
*/
public class GraphicsUtil {
public static void setupAntialiasing(@NotNull Graphics g2) {
setupAntialiasing(g2, true);
setupAntialiasing(g2, true, false);
}
public static void setupAntialiasing(Graphics g2, boolean enable) {
public static void setupAntialiasing(Graphics g2, boolean enableAA, boolean ignoreSystemSettings) {
if (g2 instanceof Graphics2D) {
Graphics2D g = (Graphics2D)g2;
Toolkit tk = Toolkit.getDefaultToolkit();
//noinspection HardCodedStringLiteral
Map map = (Map)tk.getDesktopProperty("awt.font.desktophints");
if (map != null) {
if (map != null && !ignoreSystemSettings) {
g.addRenderingHints(map);
} else {
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
enable ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
enableAA ? RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
}
}
}
@@ -15,6 +15,8 @@
*/
package org.jetbrains.idea.maven.importing;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.*;
@@ -215,7 +217,13 @@ public class MavenRootModelAdapter {
e = myRootModel.addModuleOrderEntry(m);
}
else {
e = myRootModel.addInvalidModuleEntry(moduleName);
AccessToken accessToken = ReadAction.start();
try {
e = myRootModel.addInvalidModuleEntry(moduleName);
}
finally {
accessToken.finish();
}
}
e.setScope(scope);
@@ -63,6 +63,7 @@ public class SvnRecursiveStatusWalker {
myHandler.setCurrentItem(item);
try {
item.getClient(ioFile).doStatus(ioFile, SVNRevision.WORKING, item.getDepth(), false, false, true, false, myHandler, null);
myHandler.checkIfCopyRootWasReported();
}
catch (SVNException e) {
if (e.getErrorMessage().getErrorCode() == SVNErrorCode.WC_NOT_DIRECTORY) {
@@ -172,17 +173,30 @@ public class SvnRecursiveStatusWalker {
myMetCurrentItem = false;
}
public void handleStatus(final SVNStatus status) throws SVNException {
myPartner.checkCanceled();
final File ioFile = status.getFile();
public void checkIfCopyRootWasReported() {
if (! myMetCurrentItem && myCurrentItem.isIsInnerCopyRoot()) {
myMetCurrentItem = true;
final SVNStatus statusInner = SvnUtil.getStatus(SvnVcs.getInstance(myProject), myCurrentItem.getPath().getIOFile());
if (myCurrentItem.getPath().getVirtualFile() != null || statusInner != null) {
if (statusInner == null) return;
final SVNStatusType status = statusInner.getNodeStatus();
if (SVNStatusType.OBSTRUCTED.equals(status) || SVNStatusType.STATUS_IGNORED.equals(status) ||
SVNStatusType.STATUS_NONE.equals(status) || SVNStatusType.STATUS_UNVERSIONED.equals(status) ||
SVNStatusType.UNKNOWN.equals(status)) {
return;
}
if (myCurrentItem.getPath().getVirtualFile() != null) {
myReceiver.processCopyRoot(myCurrentItem.getPath().getVirtualFile(), statusInner.getURL(),
WorkingCopyFormat.getInstance(statusInner.getWorkingCopyFormat()));
}
}
}
public void handleStatus(final SVNStatus status) throws SVNException {
myPartner.checkCanceled();
final File ioFile = status.getFile();
checkIfCopyRootWasReported();
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile vFile = lfs.findFileByIoFile(ioFile);
if (vFile == null) {
@@ -17,6 +17,7 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
@@ -27,7 +28,11 @@ public class CollectionChildDescriptionImpl extends DomChildDescriptionImpl impl
private final NotNullFunction<DomInvocationHandler, List<XmlTag>> myTagsGetter = new NotNullFunction<DomInvocationHandler, List<XmlTag>>() {
@NotNull
public List<XmlTag> fun(final DomInvocationHandler handler) {
return DomImplUtil.findSubTags(handler.getXmlTag(), handler.createEvaluatedXmlName(getXmlName()), handler.getFile());
XmlTag tag = handler.getXmlTag();
if (tag == null) {
return Collections.emptyList();
}
return DomImplUtil.findSubTags(tag, handler.createEvaluatedXmlName(getXmlName()), handler.getFile());
}
};
@@ -26,6 +26,7 @@ import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.xml.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ConcurrentFactoryMap;
import com.intellij.util.containers.FactoryMap;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
@@ -78,7 +79,7 @@ public class ComplexTypeDescriptor extends TypeDescriptor {
}
};
private final FactoryMap<String, CachedValue<CanContainAttributeType>> myAnyAttributeCache = new FactoryMap<String, CachedValue<CanContainAttributeType>>() {
private final FactoryMap<String, CachedValue<CanContainAttributeType>> myAnyAttributeCache = new ConcurrentFactoryMap<String, CachedValue<CanContainAttributeType>>() {
@Override
protected CachedValue<CanContainAttributeType> create(final String key) {
return CachedValuesManager.getManager(myTag.getProject()).createCachedValue(new CachedValueProvider<CanContainAttributeType>() {