mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -114,10 +114,8 @@ public class DefaultDebugUIEnvironment implements DebugUIEnvironment {
|
||||
|
||||
@Override
|
||||
public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) {
|
||||
ProcessHandler processHandler = content.getProcessHandler();
|
||||
RestartAction restartAction = new RestartAction(myExecutor,
|
||||
myRunner,
|
||||
processHandler,
|
||||
content,
|
||||
myExecutionEnvironment);
|
||||
actionGroup.add(restartAction, Constraints.FIRST);
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class JavaRerunFailedTestsAction extends AbstractRerunFailedTestsAction {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Filter getFilter(Project project, GlobalSearchScope searchScope) {
|
||||
return Filter.FAILED_OR_INTERRUPTED.and(JavaAwareFilter.METHOD(project, searchScope));
|
||||
return super.getFilter(project, searchScope).and(JavaAwareFilter.METHOD(project, searchScope));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1936,6 +1936,11 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
!thisOrSuperReference(((PsiReferenceExpression)expression).getQualifierExpression(), aClass)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (expression instanceof PsiJavaCodeReferenceElement && !aClass.equals(PsiTreeUtil.getParentOfType(expression, PsiClass.class))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final HighlightInfo highlightInfo = createMemberReferencedError(resolvedName, expression.getTextRange());
|
||||
if (expression instanceof PsiReferenceExpression && PsiUtil.isInnerClass(aClass)) {
|
||||
final String referenceName = ((PsiReferenceExpression)expression).getReferenceName();
|
||||
|
||||
@@ -51,8 +51,7 @@ public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment {
|
||||
|
||||
registerFileType(JavaClassFileType.INSTANCE, "class");
|
||||
registerFileType(JavaFileType.INSTANCE, "java");
|
||||
registerFileType(ArchiveFileType.INSTANCE, "jar");
|
||||
registerFileType(ArchiveFileType.INSTANCE, "zip");
|
||||
registerFileType(ArchiveFileType.INSTANCE, "jar;zip");
|
||||
|
||||
addExplicitExtension(FileTypeFileViewProviders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileViewProviderFactory());
|
||||
addExplicitExtension(BinaryFileStubBuilders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileStubBuilder());
|
||||
|
||||
+30
@@ -1,5 +1,7 @@
|
||||
// reference before ctr called
|
||||
import java.io.*;
|
||||
import java.lang.Override;
|
||||
import java.lang.String;
|
||||
import java.net.*;
|
||||
|
||||
class A {
|
||||
@@ -171,4 +173,32 @@ class WithAnonymous {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class InnerClassRefInsideAnonymous {
|
||||
static class Foo {}
|
||||
static class SuperClass {
|
||||
SuperClass(Foo foo) {
|
||||
}
|
||||
|
||||
SuperClass(String s, Foo foo) {
|
||||
}
|
||||
}
|
||||
|
||||
static class Child extends SuperClass {
|
||||
Child(Foo foo) {
|
||||
super(new Foo() {
|
||||
public String toString() {
|
||||
AFoo afoo = null;
|
||||
return super.toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Child(String s, Foo foo) {
|
||||
super(s, new <error descr="Cannot reference 'AFoo' before supertype constructor has been called">AFoo</error>());
|
||||
}
|
||||
|
||||
class AFoo extends Foo {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package com.intellij.index;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.indexing.MapIndexStorage;
|
||||
import com.intellij.util.indexing.StorageException;
|
||||
import com.intellij.util.io.*;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Dec 12, 2007
|
||||
*/
|
||||
public class IndexTest extends IdeaTestCase {
|
||||
|
||||
public void testUpdate() throws StorageException, IOException {
|
||||
final File storageFile = FileUtil.createTempFile("indextest", "storage");
|
||||
final File metaIndexFile = FileUtil.createTempFile("indextest_inputs", "storage");
|
||||
final MapIndexStorage indexStorage = new MapIndexStorage(storageFile, new EnumeratorStringDescriptor(), new EnumeratorStringDescriptor(), 16 * 1024);
|
||||
final StringIndex index = new StringIndex(indexStorage, new Factory<PersistentHashMap<Integer, Collection<String>>>() {
|
||||
@Override
|
||||
public PersistentHashMap<Integer, Collection<String>> create() {
|
||||
try {
|
||||
return createMetaIndex(metaIndexFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// build index
|
||||
index.update("com/ppp/a.java", "a b c d", null);
|
||||
index.update("com/ppp/b.java", "a b g h", null);
|
||||
index.update("com/ppp/c.java", "a z f", null);
|
||||
index.update("com/ppp/d.java", "a a u y z", null);
|
||||
index.update("com/ppp/e.java", "a n chj e c d", null);
|
||||
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/b.java", "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("b"), "com/ppp/a.java", "com/ppp/b.java");
|
||||
assertDataEquals(index.getFilesByWord("c"), "com/ppp/a.java", "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("d"), "com/ppp/a.java", "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("g"), "com/ppp/b.java");
|
||||
assertDataEquals(index.getFilesByWord("h"), "com/ppp/b.java");
|
||||
assertDataEquals(index.getFilesByWord("z"), "com/ppp/c.java", "com/ppp/d.java");
|
||||
assertDataEquals(index.getFilesByWord("f"), "com/ppp/c.java");
|
||||
assertDataEquals(index.getFilesByWord("u"), "com/ppp/d.java");
|
||||
assertDataEquals(index.getFilesByWord("y"), "com/ppp/d.java");
|
||||
assertDataEquals(index.getFilesByWord("n"), "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("chj"), "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("e"), "com/ppp/e.java");
|
||||
|
||||
// update index
|
||||
|
||||
index.update("com/ppp/d.java", "a u y z", "a a u y z");
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/b.java", "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
index.update("com/ppp/d.java", "u y z", "a u y z");
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/b.java", "com/ppp/c.java", "com/ppp/e.java");
|
||||
index.update("com/ppp/d.java", "a a a u y z", "u y z");
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/b.java", "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
|
||||
index.update("com/ppp/e.java", "a n chj e c d z", "a n chj e c d");
|
||||
assertDataEquals(index.getFilesByWord("z"), "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
|
||||
index.update("com/ppp/b.java", null, "a b g h");
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("b"), "com/ppp/a.java");
|
||||
assertDataEquals(index.getFilesByWord("g"));
|
||||
assertDataEquals(index.getFilesByWord("h"));
|
||||
}
|
||||
finally {
|
||||
indexStorage.close();
|
||||
FileUtil.delete(storageFile);
|
||||
}
|
||||
}
|
||||
|
||||
private PersistentHashMap<Integer, Collection<String>> createMetaIndex(File metaIndexFile) throws IOException {
|
||||
return new PersistentHashMap<Integer, Collection<String>>(metaIndexFile, new EnumeratorIntegerDescriptor(), new DataExternalizer<Collection<String>>() {
|
||||
@Override
|
||||
public void save(DataOutput out, Collection<String> value) throws IOException {
|
||||
DataInputOutputUtil.writeINT(out, value.size());
|
||||
for (String key : value) {
|
||||
out.writeUTF(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> read(DataInput in) throws IOException {
|
||||
final int size = DataInputOutputUtil.readINT(in);
|
||||
final List<String> list = new ArrayList<String>();
|
||||
for (int idx = 0; idx < size; idx++) {
|
||||
list.add(in.readUTF());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
public void testStubIndexUnsavedDocumentsIndexing() throws IncorrectOperationException, IOException, StorageException {
|
||||
IdeaTestUtil.registerExtension(StubIndexExtension.EP_NAME, new TextStubIndexExtension(), getTestRootDisposable());
|
||||
IdeaTestUtil.registerExtension(StubIndexExtension.EP_NAME, new ClassNameStubIndexExtension(), getTestRootDisposable());
|
||||
FileTypeManager.getInstance().registerFileType(TestFileType.INSTANCE, "fff");
|
||||
final FFFLangParserDefinition parserDefinition = new FFFLangParserDefinition();
|
||||
LanguageParserDefinitions.INSTANCE.addExplicitExtension(FFFLanguage.INSTANCE, parserDefinition);
|
||||
|
||||
final TestStubElementType stubType = new TestStubElementType();
|
||||
SerializationManager.getInstance().registerSerializer(TestStubElement.class, stubType);
|
||||
|
||||
final File fffFile = new File(FileUtil.createTempDirectory("testing", "stubindex"), "MyClass.fff");
|
||||
fffFile.createNewFile();
|
||||
|
||||
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(fffFile);
|
||||
|
||||
assertNotNull(vFile);
|
||||
assertEquals(TestFileType.INSTANCE, vFile.getFileType());
|
||||
|
||||
try {
|
||||
final MockPsiFile psiFile = new MockPsiFile(vFile, MockPsiManager.getInstance(myProject));
|
||||
|
||||
final MockPsiClass cls = new MockPsiClass("com.company.MyClass");
|
||||
psiFile.add(cls);
|
||||
|
||||
final MockPsiMethod aaaMethod = new MockPsiMethod("aaa");
|
||||
cls.addMethod(aaaMethod);
|
||||
final MockPsiMethod bbbMethod = new MockPsiMethod("bbb");
|
||||
cls.addMethod(bbbMethod);
|
||||
|
||||
final PsiFileStubImpl fileStub = new PsiFileStubImpl(psiFile);
|
||||
final TestStubElement clsStub = stubType.createStub(cls, fileStub);
|
||||
stubType.createStub(aaaMethod, clsStub);
|
||||
stubType.createStub(bbbMethod, clsStub);
|
||||
|
||||
final ByteArrayOutputStream arrayStream = new ByteArrayOutputStream();
|
||||
SerializationManager.getInstance().serialize(fileStub, new DataOutputStream(arrayStream));
|
||||
|
||||
final FileBasedIndex fbi = FileBasedIndex.getInstance();
|
||||
final UpdatableIndex<Integer, SerializedStubTree, FileContent> stubUpdatingIndex = fbi.getIndex(StubUpdatingIndex.INDEX_ID);
|
||||
final MemoryIndexStorage storage = (MemoryIndexStorage)((MapReduceIndex)stubUpdatingIndex).getStorage();
|
||||
|
||||
// initial
|
||||
final int fileId = FileBasedIndex.getFileId(vFile);
|
||||
final byte[] bytes = arrayStream.toByteArray();
|
||||
stubUpdatingIndex.update(fileId, new FileContent(vFile, bytes), null);
|
||||
|
||||
final ValueContainer<SerializedStubTree> data = stubUpdatingIndex.getData(fileId);
|
||||
final List<SerializedStubTree> trees = data.toValueList();
|
||||
|
||||
final SerializedStubTree tree = assertOneElement(trees);
|
||||
|
||||
assertTrue(Comparing.equal(bytes, tree.getBytes()));
|
||||
|
||||
final StubElement deserialized = tree.getStub();
|
||||
}
|
||||
finally {
|
||||
LanguageParserDefinitions.INSTANCE.removeExplicitExtension(FFFLanguage.INSTANCE, parserDefinition);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
private static <T> void assertDataEquals(List<T> actual, T... expected) {
|
||||
assertTrue(new HashSet<T>(Arrays.asList(expected)).equals(new HashSet<T>(actual)));
|
||||
}
|
||||
|
||||
public void _testCollectedPsiWithChangedDocument() throws IOException {
|
||||
VirtualFile dir = getVirtualFile(createTempDirectory());
|
||||
PsiTestUtil.addSourceContentToRoots(myModule, dir);
|
||||
|
||||
final VirtualFile vFile = createChildData(dir, "Foo.java");
|
||||
VfsUtil.saveText(vFile, "class Foo {}");
|
||||
|
||||
final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
|
||||
assertNotNull(facade.findClass("Foo", scope));
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
|
||||
assertNotNull(psiFile);
|
||||
|
||||
Document document = FileDocumentManager.getInstance().getDocument(vFile);
|
||||
document.deleteString(0, document.getTextLength());
|
||||
assertNotNull(facade.findClass("Foo", scope));
|
||||
|
||||
psiFile = null;
|
||||
PlatformTestUtil.tryGcSoftlyReachableObjects();
|
||||
assertNull(((PsiManagerEx)PsiManager.getInstance(getProject())).getFileManager().getCachedPsiFile(vFile));
|
||||
|
||||
// should be assertNull(facade.findClass("Foo", scope));
|
||||
// or the file should not be allowed to be gc'ed
|
||||
facade.findClass("Foo", scope).getText();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.intellij.index;
|
||||
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.util.indexing.DataIndexer;
|
||||
import com.intellij.util.indexing.IndexStorage;
|
||||
import com.intellij.util.indexing.MapReduceIndex;
|
||||
import com.intellij.util.indexing.StorageException;
|
||||
import com.intellij.util.io.PersistentHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Dec 12, 2007
|
||||
*/
|
||||
public class StringIndex {
|
||||
private final MapReduceIndex<String, String, PathContentPair> myIndex;
|
||||
|
||||
public StringIndex(final IndexStorage<String, String> storage, final Factory<PersistentHashMap<Integer, Collection<String>>> factory)
|
||||
throws IOException {
|
||||
myIndex = new MapReduceIndex<String, String, PathContentPair>(null, new Indexer(), storage);
|
||||
myIndex.setInputIdToDataKeysIndex(factory);
|
||||
}
|
||||
|
||||
public List<String> getFilesByWord(String word) throws StorageException {
|
||||
return myIndex.getData(word).toValueList();
|
||||
}
|
||||
|
||||
public void update(final String path, @Nullable String content, @Nullable String oldContent) throws StorageException {
|
||||
myIndex.update(path.hashCode(), toInput(path, content));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PathContentPair toInput(@NotNull String path, @Nullable String content) {
|
||||
return content != null ? new PathContentPair(path, content) : null;
|
||||
}
|
||||
|
||||
private static class Indexer implements DataIndexer<String, String, PathContentPair> {
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<String,String> map(final PathContentPair inputData) {
|
||||
final Map<String,String> _map = new HashMap<String, String>();
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final String content = inputData.content;
|
||||
for (int idx = 0; idx < content.length(); idx++) {
|
||||
final char ch = content.charAt(idx);
|
||||
if (Character.isWhitespace(ch)) {
|
||||
if (builder.length() > 0) {
|
||||
_map.put(builder.toString(), inputData.path);
|
||||
builder.setLength(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
builder.append(ch);
|
||||
}
|
||||
}
|
||||
// emit the last word
|
||||
if (builder.length() > 0) {
|
||||
_map.put(builder.toString(), inputData.path);
|
||||
builder.setLength(0);
|
||||
}
|
||||
return _map;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class PathContentPair {
|
||||
final String path;
|
||||
final String content;
|
||||
|
||||
public PathContentPair(final String path, final String content) {
|
||||
this.path = path;
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -17,7 +17,6 @@ package com.intellij.ide;
|
||||
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -29,31 +28,19 @@ import java.util.List;
|
||||
public class Bootstrap {
|
||||
private static final String PLUGIN_MANAGER = "com.intellij.ide.plugins.PluginManager";
|
||||
|
||||
private Bootstrap() {}
|
||||
private Bootstrap() { }
|
||||
|
||||
public static void main(final String[] args, final String mainClass, final String methodName) {
|
||||
public static void main(String[] args, String mainClass, String methodName) throws Exception {
|
||||
main(args, mainClass, methodName, new ArrayList<URL>());
|
||||
}
|
||||
|
||||
public static void main(final String[] args, final String mainClass, final String methodName, final List<URL> classpathElements) {
|
||||
final UrlClassLoader newClassLoader = ClassloaderUtil.initClassloader(classpathElements);
|
||||
try {
|
||||
WindowsCommandLineProcessor.ourMirrorClass = Class.forName(WindowsCommandLineProcessor.class.getName(), true, newClassLoader);
|
||||
public static void main(String[] args, String mainClass, String methodName, List<URL> classpathElements) throws Exception {
|
||||
UrlClassLoader newClassLoader = ClassloaderUtil.initClassloader(classpathElements);
|
||||
WindowsCommandLineProcessor.ourMirrorClass = Class.forName(WindowsCommandLineProcessor.class.getName(), true, newClassLoader);
|
||||
|
||||
final Class<?> klass = Class.forName(PLUGIN_MANAGER, true, newClassLoader);
|
||||
|
||||
final Method startMethod = klass.getDeclaredMethod("start", String.class, String.class, String[].class);
|
||||
startMethod.setAccessible(true);
|
||||
startMethod.invoke(null, mainClass, methodName, args);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if ("true".equals(System.getProperty("java.awt.headless"))) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(null, e.getClass().getName() + ": " + e.getMessage(), "Error starting IntelliJ Platform", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
Class<?> klass = Class.forName(PLUGIN_MANAGER, true, newClassLoader);
|
||||
Method startMethod = klass.getDeclaredMethod("start", String.class, String.class, String[].class);
|
||||
startMethod.setAccessible(true);
|
||||
startMethod.invoke(null, mainClass, methodName, args);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -30,7 +30,6 @@ import com.intellij.util.lang.UrlClassLoader;
|
||||
import com.intellij.util.text.StringTokenizer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -44,76 +43,33 @@ import java.util.regex.Pattern;
|
||||
public class ClassloaderUtil extends ClassUtilCore {
|
||||
@NonNls public static final String PROPERTY_IGNORE_CLASSPATH = "ignore.classpath";
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private static final String ERROR = "Error";
|
||||
|
||||
private ClassloaderUtil() {}
|
||||
|
||||
public static Logger getLogger() {
|
||||
return Logger.getInstance("ClassloaderUtil");
|
||||
}
|
||||
|
||||
public static UrlClassLoader initClassloader(final List<URL> classpathElements) {
|
||||
public static UrlClassLoader initClassloader(final List<URL> classpathElements) throws Exception {
|
||||
PathManager.loadProperties();
|
||||
|
||||
try {
|
||||
addParentClasspath(classpathElements);
|
||||
addIDEALibraries(classpathElements);
|
||||
addAdditionalClassPath(classpathElements);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
if (Main.isHeadless()) {
|
||||
getLogger().error(e);
|
||||
} else {
|
||||
JOptionPane
|
||||
.showMessageDialog(JOptionPane.getRootFrame(), e.getMessage(), ERROR, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
System.exit(1);
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
if (Main.isHeadless()) {
|
||||
getLogger().error(e.getMessage());
|
||||
} else {
|
||||
JOptionPane
|
||||
.showMessageDialog(JOptionPane.getRootFrame(), e.getMessage(), ERROR, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
System.exit(1);
|
||||
}
|
||||
addParentClasspath(classpathElements);
|
||||
addIDEALibraries(classpathElements);
|
||||
addAdditionalClassPath(classpathElements);
|
||||
|
||||
filterClassPath(classpathElements);
|
||||
UrlClassLoader newClassLoader = new UrlClassLoader(classpathElements, null, true, true);
|
||||
|
||||
UrlClassLoader newClassLoader = null;
|
||||
try {
|
||||
newClassLoader = new UrlClassLoader(classpathElements, null, true, true);
|
||||
|
||||
// prepare plugins
|
||||
if (!isLoadingOfExternalPluginsDisabled()) {
|
||||
try {
|
||||
StartupActionScriptManager.executeActionScript();
|
||||
}
|
||||
catch (IOException e) {
|
||||
final String errorMessage = "Error executing plugin installation script: " + e.getMessage();
|
||||
if (Main.isHeadless()) {
|
||||
System.out.println(errorMessage);
|
||||
} else {
|
||||
JOptionPane
|
||||
.showMessageDialog(JOptionPane.getRootFrame(), errorMessage, ERROR, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
}
|
||||
// prepare plugins
|
||||
if (!isLoadingOfExternalPluginsDisabled()) {
|
||||
try {
|
||||
StartupActionScriptManager.executeActionScript();
|
||||
}
|
||||
|
||||
Thread.currentThread().setContextClassLoader(newClassLoader);
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger logger = getLogger();
|
||||
if (logger == null) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
else {
|
||||
logger.error(e);
|
||||
catch (IOException e) {
|
||||
Main.showMessage("Plugin Installation Error", e);
|
||||
}
|
||||
}
|
||||
|
||||
Thread.currentThread().setContextClassLoader(newClassLoader);
|
||||
return newClassLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.idea;
|
||||
|
||||
import com.intellij.ide.Bootstrap;
|
||||
@@ -21,102 +20,99 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.Restarter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "MethodNamesDifferingOnlyByCase"})
|
||||
public class Main {
|
||||
public static final int UPDATE_FAILED = 1;
|
||||
public static final int STARTUP_EXCEPTION = 2;
|
||||
public static final int STARTUP_IMPOSSIBLE = 3;
|
||||
public static final int LICENSE_ERROR = 4;
|
||||
public static final int PLUGIN_ERROR = 5;
|
||||
|
||||
private static boolean isHeadless;
|
||||
private static boolean isCommandLine;
|
||||
|
||||
private Main() {
|
||||
}
|
||||
private Main() { }
|
||||
|
||||
@SuppressWarnings("MethodNamesDifferingOnlyByCase")
|
||||
public static void main(final String[] args) {
|
||||
isHeadless = isHeadless(args);
|
||||
if (isHeadless) {
|
||||
setFlags(args);
|
||||
|
||||
if (isHeadless()) {
|
||||
System.setProperty("java.awt.headless", Boolean.TRUE.toString());
|
||||
}
|
||||
else if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException("Unable to detect graphics environment");
|
||||
}
|
||||
else {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException("Unable to detect graphics environment");
|
||||
}
|
||||
|
||||
if (!isHeadless) {
|
||||
try {
|
||||
installPatch();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
File log = null;
|
||||
try {
|
||||
log = FileUtilRt.createTempFile("patch", ".log", false);
|
||||
PrintWriter writer = new PrintWriter(log);
|
||||
try {
|
||||
e.printStackTrace(writer);
|
||||
}
|
||||
finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
}
|
||||
String message = e.getMessage()
|
||||
+ "\n" + (log == null ? "Log cannot be saved" : "Log is saved in " + log)
|
||||
+ "\n\nPlease download and install update manually" ;
|
||||
JOptionPane.showMessageDialog(null, message, "Cannot Apply Patch", JOptionPane.ERROR_MESSAGE);
|
||||
catch (Throwable t) {
|
||||
showMessage("Update Failed", t);
|
||||
System.exit(UPDATE_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
Bootstrap.main(args, Main.class.getName() + "Impl", "start");
|
||||
}
|
||||
|
||||
public static boolean isHeadless(final String[] args) {
|
||||
final Boolean forceEnabledHeadlessMode = Boolean.valueOf(System.getProperty("java.awt.headless"));
|
||||
|
||||
@NonNls final String antAppCode = "ant";
|
||||
@NonNls final String duplocateCode = "duplocate";
|
||||
@NonNls final String traverseUI = "traverseUI";
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
try {
|
||||
Bootstrap.main(args, Main.class.getName() + "Impl", "start");
|
||||
}
|
||||
catch (Throwable t) {
|
||||
showMessage("Start Failed", t);
|
||||
System.exit(STARTUP_EXCEPTION);
|
||||
}
|
||||
final String firstArg = args[0];
|
||||
return forceEnabledHeadlessMode ||
|
||||
Comparing.strEqual(firstArg, antAppCode) ||
|
||||
Comparing.strEqual(firstArg, duplocateCode) ||
|
||||
Comparing.strEqual(firstArg, traverseUI) ||
|
||||
(firstArg.length() < 20 && firstArg.endsWith("inspect"));
|
||||
}
|
||||
|
||||
public static boolean isUITraverser(final String[] args) {
|
||||
return args.length > 0 && Comparing.strEqual(args[0], "traverseUI");
|
||||
}
|
||||
|
||||
public static boolean isCommandLine(final String[] args) {
|
||||
if (isHeadless(args)) return true;
|
||||
@NonNls final String diffAppCode = "diff";
|
||||
return args.length > 0 && Comparing.strEqual(args[0], diffAppCode);
|
||||
}
|
||||
|
||||
public static boolean isHeadless() {
|
||||
return isHeadless;
|
||||
}
|
||||
|
||||
public static boolean isCommandLine() {
|
||||
return isCommandLine;
|
||||
}
|
||||
|
||||
public static void setFlags(String[] args) {
|
||||
isHeadless = isHeadless(args);
|
||||
isCommandLine = isCommandLine(args);
|
||||
}
|
||||
|
||||
private static boolean isHeadless(String[] args) {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String firstArg = args[0];
|
||||
return Comparing.strEqual(firstArg, "ant") ||
|
||||
Comparing.strEqual(firstArg, "duplocate") ||
|
||||
Comparing.strEqual(firstArg, "traverseUI") ||
|
||||
(firstArg.length() < 20 && firstArg.endsWith("inspect"));
|
||||
}
|
||||
|
||||
private static boolean isCommandLine(String[] args) {
|
||||
if (isHeadless()) return true;
|
||||
return args.length > 0 && Comparing.strEqual(args[0], "diff");
|
||||
}
|
||||
|
||||
public static boolean isUITraverser(final String[] args) {
|
||||
return args.length > 0 && Comparing.strEqual(args[0], "traverseUI");
|
||||
}
|
||||
|
||||
private static void installPatch() throws IOException {
|
||||
String platform = System.getProperty("idea.platform.prefix", "idea");
|
||||
String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase();
|
||||
@@ -124,28 +120,67 @@ public class Main {
|
||||
File copyPatchFile = new File(System.getProperty("java.io.tmpdir"), patchFileName + "_copy");
|
||||
|
||||
// always delete previous patch copy
|
||||
if (!FileUtilRt.delete(copyPatchFile)) throw new IOException("Cannot create temporary patch file");
|
||||
if (!FileUtilRt.delete(copyPatchFile)) {
|
||||
throw new IOException("Cannot create temporary patch file");
|
||||
}
|
||||
|
||||
if (!originalPatchFile.exists()) return;
|
||||
if (!originalPatchFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!originalPatchFile.renameTo(copyPatchFile) || !FileUtilRt.delete(originalPatchFile)) {
|
||||
throw new IOException("Cannot create temporary patch file");
|
||||
}
|
||||
|
||||
List<String> args = new ArrayList<String>();
|
||||
if (SystemInfo.isWindows) {
|
||||
args.add(Restarter.createTempExecutable(new File(PathManager.getBinPath(), "vistalauncher.exe")).getPath());
|
||||
int status = 0;
|
||||
if (Restarter.isSupported()) {
|
||||
List<String> args = new ArrayList<String>();
|
||||
|
||||
if (SystemInfo.isWindows) {
|
||||
File launcher = new File(PathManager.getBinPath(), "VistaLauncher.exe");
|
||||
args.add(Restarter.createTempExecutable(launcher).getPath());
|
||||
}
|
||||
|
||||
Collections.addAll(args,
|
||||
System.getProperty("java.home") + "/bin/java",
|
||||
"-Xmx500m",
|
||||
"-classpath",
|
||||
copyPatchFile.getPath(),
|
||||
"com.intellij.updater.Runner",
|
||||
"install",
|
||||
PathManager.getHomePath());
|
||||
|
||||
status = Restarter.scheduleRestart(ArrayUtilRt.toStringArray(args));
|
||||
}
|
||||
else {
|
||||
String message = "Patch update is not supported - please do it manually";
|
||||
showMessage("Update Error", message, true);
|
||||
}
|
||||
|
||||
Collections.addAll(args,
|
||||
System.getProperty("java.home") + "/bin/java",
|
||||
"-Xmx500m",
|
||||
"-classpath",
|
||||
copyPatchFile.getPath(),
|
||||
"com.intellij.updater.Runner",
|
||||
"install",
|
||||
PathManager.getHomePath());
|
||||
System.exit(status);
|
||||
}
|
||||
|
||||
System.exit(Restarter.scheduleRestart(args.toArray(new String[args.size()])));
|
||||
public static void showMessage(String title, Throwable t) {
|
||||
String message = "Internal exception, please report to http://youtrack.jetbrains.com\n\n" + ExceptionUtil.getThrowableText(t);
|
||||
showMessage(title, message, true);
|
||||
}
|
||||
|
||||
public static void showMessage(String title, String message, boolean error) {
|
||||
if (isCommandLine()) {
|
||||
PrintStream stream = error ? System.err : System.out;
|
||||
stream.println(title + ": " + message);
|
||||
}
|
||||
else {
|
||||
try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
|
||||
catch (Throwable ignore) { }
|
||||
|
||||
JTextPane textPane = new JTextPane();
|
||||
textPane.setEditable(false);
|
||||
textPane.setText(message.replaceAll("\t", " "));
|
||||
textPane.setBackground(UIManager.getColor("Panel.background"));
|
||||
|
||||
int type = error ? JOptionPane.ERROR_MESSAGE : JOptionPane.INFORMATION_MESSAGE;
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), textPane, title, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -19,11 +19,8 @@ import com.intellij.openapi.extensions.PluginId;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: stathik
|
||||
* Date: Jan 8, 2004
|
||||
* Time: 3:06:43 PM
|
||||
* To change this template use Options | File Templates.
|
||||
* @author stathik
|
||||
* @since Jan 8, 2004
|
||||
*/
|
||||
public class PluginException extends RuntimeException {
|
||||
private final PluginId myPluginId;
|
||||
|
||||
+14
-14
@@ -44,7 +44,7 @@ public class BulkVirtualFileListenerAdapter implements BulkFileListener {
|
||||
public void before(@NotNull final List<? extends VFileEvent> events) {
|
||||
for (VFileEvent event : events) {
|
||||
if (myFileSystem == null || myFileSystem == event.getFileSystem()) {
|
||||
fireBefore(event);
|
||||
fireBefore(myAdapted, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,16 +53,16 @@ public class BulkVirtualFileListenerAdapter implements BulkFileListener {
|
||||
public void after(@NotNull final List<? extends VFileEvent> events) {
|
||||
for (VFileEvent event : events) {
|
||||
if (myFileSystem == null || myFileSystem == event.getFileSystem()) {
|
||||
fireAfter(event);
|
||||
fireAfter(myAdapted, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fireAfter(final VFileEvent event) {
|
||||
public static void fireAfter(VirtualFileListener adapted, final VFileEvent event) {
|
||||
if (event instanceof VFileContentChangeEvent) {
|
||||
final VFileContentChangeEvent ce = (VFileContentChangeEvent)event;
|
||||
final VirtualFile file = ce.getFile();
|
||||
myAdapted.contentsChanged(
|
||||
adapted.contentsChanged(
|
||||
new VirtualFileEvent(event.getRequestor(), file, file.getParent(), ce.getOldModificationStamp(), ce.getModificationStamp()));
|
||||
}
|
||||
else if (event instanceof VFileCopyEvent) {
|
||||
@@ -70,49 +70,49 @@ public class BulkVirtualFileListenerAdapter implements BulkFileListener {
|
||||
final VirtualFile original = ce.getFile();
|
||||
final VirtualFile copy = ce.getNewParent().findChild(ce.getNewChildName());
|
||||
if (original != null && copy != null) {
|
||||
myAdapted.fileCopied(new VirtualFileCopyEvent(event.getRequestor(), original, copy));
|
||||
adapted.fileCopied(new VirtualFileCopyEvent(event.getRequestor(), original, copy));
|
||||
}
|
||||
}
|
||||
else if (event instanceof VFileCreateEvent) {
|
||||
final VFileCreateEvent ce = (VFileCreateEvent)event;
|
||||
final VirtualFile newChild = ce.getFile();
|
||||
if (newChild != null) {
|
||||
myAdapted.fileCreated(new VirtualFileEvent(event.getRequestor(), newChild, ce.getChildName(), ce.getParent()));
|
||||
adapted.fileCreated(new VirtualFileEvent(event.getRequestor(), newChild, ce.getChildName(), ce.getParent()));
|
||||
}
|
||||
}
|
||||
else if (event instanceof VFileDeleteEvent) {
|
||||
final VFileDeleteEvent de = (VFileDeleteEvent)event;
|
||||
myAdapted.fileDeleted(new VirtualFileEvent(event.getRequestor(), de.getFile(), de.getFile().getParent(), 0, 0));
|
||||
adapted.fileDeleted(new VirtualFileEvent(event.getRequestor(), de.getFile(), de.getFile().getParent(), 0, 0));
|
||||
}
|
||||
else if (event instanceof VFileMoveEvent) {
|
||||
final VFileMoveEvent me = (VFileMoveEvent)event;
|
||||
myAdapted.fileMoved(new VirtualFileMoveEvent(event.getRequestor(), me.getFile(), me.getOldParent(), me.getNewParent()));
|
||||
adapted.fileMoved(new VirtualFileMoveEvent(event.getRequestor(), me.getFile(), me.getOldParent(), me.getNewParent()));
|
||||
}
|
||||
else if (event instanceof VFilePropertyChangeEvent) {
|
||||
final VFilePropertyChangeEvent pce = (VFilePropertyChangeEvent)event;
|
||||
myAdapted.propertyChanged(
|
||||
adapted.propertyChanged(
|
||||
new VirtualFilePropertyEvent(event.getRequestor(), pce.getFile(), pce.getPropertyName(), pce.getOldValue(), pce.getNewValue()));
|
||||
}
|
||||
}
|
||||
|
||||
private void fireBefore(final VFileEvent event) {
|
||||
public static void fireBefore(VirtualFileListener adapted, final VFileEvent event) {
|
||||
if (event instanceof VFileContentChangeEvent) {
|
||||
final VFileContentChangeEvent ce = (VFileContentChangeEvent)event;
|
||||
final VirtualFile file = ce.getFile();
|
||||
myAdapted.beforeContentsChange(
|
||||
adapted.beforeContentsChange(
|
||||
new VirtualFileEvent(event.getRequestor(), file, file.getParent(), ce.getOldModificationStamp(), ce.getModificationStamp()));
|
||||
}
|
||||
else if (event instanceof VFileDeleteEvent) {
|
||||
final VFileDeleteEvent de = (VFileDeleteEvent)event;
|
||||
myAdapted.beforeFileDeletion(new VirtualFileEvent(event.getRequestor(), de.getFile(), de.getFile().getParent(), 0, 0));
|
||||
adapted.beforeFileDeletion(new VirtualFileEvent(event.getRequestor(), de.getFile(), de.getFile().getParent(), 0, 0));
|
||||
}
|
||||
else if (event instanceof VFileMoveEvent) {
|
||||
final VFileMoveEvent me = (VFileMoveEvent)event;
|
||||
myAdapted.beforeFileMovement(new VirtualFileMoveEvent(event.getRequestor(), me.getFile(), me.getOldParent(), me.getNewParent()));
|
||||
adapted.beforeFileMovement(new VirtualFileMoveEvent(event.getRequestor(), me.getFile(), me.getOldParent(), me.getNewParent()));
|
||||
}
|
||||
else if (event instanceof VFilePropertyChangeEvent) {
|
||||
final VFilePropertyChangeEvent pce = (VFilePropertyChangeEvent)event;
|
||||
myAdapted.beforePropertyChange(
|
||||
adapted.beforePropertyChange(
|
||||
new VirtualFilePropertyEvent(event.getRequestor(), pce.getFile(), pce.getPropertyName(), pce.getOldValue(), pce.getNewValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +64,11 @@ public class CoreFileTypeRegistry extends FileTypeRegistry {
|
||||
return result == null ? UnknownFileType.INSTANCE : result;
|
||||
}
|
||||
|
||||
public void registerFileType(FileType fileType, String extension) {
|
||||
public void registerFileType(@NotNull FileType fileType, @NotNull @NonNls String extension) {
|
||||
myAllFileTypes.add(fileType);
|
||||
myExtensionsMap.put(extension, fileType);
|
||||
for (final String ext : extension.split(";")) {
|
||||
myExtensionsMap.put(ext, fileType);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+72
-111
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -105,21 +105,10 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
try {
|
||||
myComponentsRegistry.loadClasses();
|
||||
|
||||
final Class[] componentInterfaces = myComponentsRegistry.getComponentInterfaces();
|
||||
Class[] componentInterfaces = myComponentsRegistry.getComponentInterfaces();
|
||||
for (Class componentInterface : componentInterfaces) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
try {
|
||||
createComponent(componentInterface);
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
createComponent(componentInterface);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -209,35 +198,12 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
return null;
|
||||
}
|
||||
|
||||
private void initComponent(Object component) {
|
||||
final ProgressIndicator indicator = getProgressIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
|
||||
try {
|
||||
initializeComponent(component, false);
|
||||
if (component instanceof BaseComponent) {
|
||||
((BaseComponent)component).initComponent();
|
||||
}
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
handleInitComponentError(ex, false, component.getClass().getName(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static ProgressIndicator getProgressIndicator() {
|
||||
return ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
}
|
||||
|
||||
protected double getPercentageOfComponentsLoaded() {
|
||||
protected float getPercentageOfComponentsLoaded() {
|
||||
return myComponentsRegistry.getPercentageOfComponentsLoaded();
|
||||
}
|
||||
|
||||
@@ -245,8 +211,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
public void initializeComponent(Object component, boolean service) {
|
||||
}
|
||||
|
||||
|
||||
protected void handleInitComponentError(final Throwable ex, final boolean fatal, final String componentClassName, ComponentConfig config) {
|
||||
protected void handleInitComponentError(Throwable ex, String componentClassName, ComponentConfig config) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
|
||||
@@ -358,7 +323,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
getComponents();
|
||||
}
|
||||
|
||||
protected void loadComponentsConfiguration(ComponentConfig[] components, @Nullable final PluginDescriptor descriptor, final boolean defaultProject) {
|
||||
protected void loadComponentsConfiguration(ComponentConfig[] components, @Nullable PluginDescriptor descriptor, boolean defaultProject) {
|
||||
myConfigurator.loadComponentsConfiguration(components, descriptor, defaultProject);
|
||||
}
|
||||
|
||||
@@ -426,7 +391,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
protected class ComponentsRegistry {
|
||||
private final Map<Class, Object> myInterfaceToLockMap = new THashMap<Class, Object>();
|
||||
private final Map<Class, Class> myInterfaceToClassMap = new THashMap<Class, Class>();
|
||||
private final ArrayList<Class> myComponentInterfaces = new ArrayList<Class>(); // keeps order of component's registration
|
||||
private final List<Class> myComponentInterfaces = new ArrayList<Class>(); // keeps order of component's registration
|
||||
private final Map<String, BaseComponent> myNameToComponent = new THashMap<String, BaseComponent>();
|
||||
private final List<ComponentConfig> myComponentConfigs = new ArrayList<ComponentConfig>();
|
||||
private final List<Object> myImplementations = new ArrayList<Object>();
|
||||
@@ -452,7 +417,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
interfaceClass : Class.forName(config.getImplementationClass(), true, loader);
|
||||
|
||||
if (myInterfaceToClassMap.get(interfaceClass) != null) {
|
||||
throw new ComponentAlreadyRegisteredException(interfaceClass);
|
||||
throw new RuntimeException("Component already registered: " + interfaceClass.getName());
|
||||
}
|
||||
|
||||
getPicoContainer().registerComponent(new ComponentConfigComponentAdapter(config, implementationClass));
|
||||
@@ -460,17 +425,8 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
myComponentClassToConfig.put(implementationClass, config);
|
||||
myComponentInterfaces.add(interfaceClass);
|
||||
}
|
||||
catch (ComponentAlreadyRegisteredException ex) {
|
||||
throw new Error(ex);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
handleInitComponentError(e, false, null, config);
|
||||
}
|
||||
}
|
||||
|
||||
private class ComponentAlreadyRegisteredException extends Exception {
|
||||
private ComponentAlreadyRegisteredException(Class interfaceClass) {
|
||||
super(interfaceClass.getName() + " component already registered");
|
||||
catch (Throwable t) {
|
||||
handleInitComponentError(t, null, config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,8 +448,8 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
return myInterfaceToClassMap.containsKey(interfaceClass);
|
||||
}
|
||||
|
||||
public double getPercentageOfComponentsLoaded() {
|
||||
return ((double)myImplementations.size()) / myComponentConfigs.size();
|
||||
public float getPercentageOfComponentsLoaded() {
|
||||
return ((float)myImplementations.size()) / myComponentConfigs.size();
|
||||
}
|
||||
|
||||
private void registerComponentInstance(final Object component) {
|
||||
@@ -565,57 +521,66 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
|
||||
public ComponentConfigComponentAdapter(final ComponentConfig config, Class<?> implementationClass) {
|
||||
myConfig = config;
|
||||
|
||||
final String componentKey = config.getInterfaceClass();
|
||||
myDelegate = new CachingComponentAdapter(new ConstructorInjectionComponentAdapter(componentKey, implementationClass, null, true)) {
|
||||
@Override
|
||||
public Object getComponentInstance(PicoContainer picoContainer) throws PicoInitializationException, PicoIntrospectionException {
|
||||
Object componentInstance = null;
|
||||
try {
|
||||
long startTime = myInitialized ? 0 : System.nanoTime();
|
||||
componentInstance = super.getComponentInstance(picoContainer);
|
||||
|
||||
if (!myInitialized) {
|
||||
if (myInitializing) {
|
||||
if (myConfig.pluginDescriptor != null) {
|
||||
LOG.error(new PluginException("Cyclic component initialization: " + componentKey, myConfig.pluginDescriptor.getPluginId()));
|
||||
}
|
||||
else {
|
||||
LOG.error(new Throwable("Cyclic component initialization: " + componentKey));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
myInitializing = true;
|
||||
myComponentsRegistry.registerComponentInstance(componentInstance);
|
||||
initComponent(componentInstance);
|
||||
long endTime = System.nanoTime();
|
||||
long ms = (endTime - startTime) / 1000000;
|
||||
if (ms > 10) {
|
||||
if (logSlowComponents()) {
|
||||
LOG.info(componentInstance.getClass().getName() + " initialized in " + ms + " ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myInitializing = false;
|
||||
}
|
||||
|
||||
myInitialized = true;
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
handleInitComponentError(t, componentInstance == null, componentKey, config);
|
||||
}
|
||||
return componentInstance;
|
||||
@Override
|
||||
public Object getComponentInstance(PicoContainer picoContainer) throws PicoInitializationException, PicoIntrospectionException {
|
||||
ProgressIndicator indicator = getProgressIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
};
|
||||
|
||||
Object componentInstance = null;
|
||||
try {
|
||||
long startTime = myInitialized ? 0 : System.nanoTime();
|
||||
|
||||
componentInstance = super.getComponentInstance(picoContainer);
|
||||
|
||||
if (!myInitialized) {
|
||||
if (myInitializing) {
|
||||
if (myConfig.pluginDescriptor != null) {
|
||||
LOG.error(new PluginException("Cyclic component initialization: " + componentKey, myConfig.pluginDescriptor.getPluginId()));
|
||||
}
|
||||
else {
|
||||
LOG.error(new Throwable("Cyclic component initialization: " + componentKey));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
myInitializing = true;
|
||||
myComponentsRegistry.registerComponentInstance(componentInstance);
|
||||
|
||||
initializeComponent(componentInstance, false);
|
||||
if (componentInstance instanceof BaseComponent) {
|
||||
((BaseComponent)componentInstance).initComponent();
|
||||
}
|
||||
|
||||
long ms = (System.nanoTime() - startTime) / 1000000;
|
||||
if (ms > 10 && logSlowComponents()) {
|
||||
LOG.info(componentInstance.getClass().getName() + " initialized in " + ms + " ms");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myInitializing = false;
|
||||
}
|
||||
|
||||
myInitialized = true;
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
handleInitComponentError(t, componentKey, config);
|
||||
}
|
||||
|
||||
return componentInstance;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -625,27 +590,23 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
|
||||
@Override
|
||||
public Class getComponentImplementation() {
|
||||
return getDelegate().getComponentImplementation();
|
||||
return myDelegate.getComponentImplementation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComponentInstance(final PicoContainer container) throws PicoInitializationException, PicoIntrospectionException {
|
||||
return getDelegate().getComponentInstance(container);
|
||||
return myDelegate.getComponentInstance(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify(final PicoContainer container) throws PicoIntrospectionException {
|
||||
getDelegate().verify(container);
|
||||
myDelegate.verify(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(final PicoVisitor visitor) {
|
||||
visitor.visitComponentAdapter(this);
|
||||
getDelegate().accept(visitor);
|
||||
}
|
||||
|
||||
private ComponentAdapter getDelegate() {
|
||||
return myDelegate;
|
||||
myDelegate.accept(visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,17 +122,17 @@ public class TreeChangeImpl implements TreeChange {
|
||||
}
|
||||
myChanges.put(child, info);
|
||||
}
|
||||
|
||||
private static boolean ourDoAddChangeAtOffsetChecks = ourDoChecks;
|
||||
|
||||
private static boolean ourEnableAddChangeAtOffsetOptimization = true;
|
||||
|
||||
private void addChangeAtOffset(final ASTNode child, final int nodeOffset) {
|
||||
int optimizedIndex = haveNotCalculated;
|
||||
|
||||
if (mySortedChanges.size() > 0) { // check adding at end
|
||||
if (ourEnableAddChangeAtOffsetOptimization && mySortedChanges.size() > 0) { // check adding at end
|
||||
Pair<ASTNode, Integer> pair = mySortedChanges.get(mySortedChanges.size() - 1);
|
||||
if (pair.getFirst() == child.getTreePrev() && pair.getSecond() <= nodeOffset) {
|
||||
optimizedIndex = mySortedChanges.size();
|
||||
if (!ourDoAddChangeAtOffsetChecks) {
|
||||
if (!ourDoChecks) {
|
||||
mySortedChanges.add(new Pair<ASTNode, Integer>(child, Integer.valueOf(nodeOffset)));
|
||||
return;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class TreeChangeImpl implements TreeChange {
|
||||
ChangeInfo changeInfo = myChanges.get(child);
|
||||
ASTNode prev = child.getTreePrev();
|
||||
LOG.error("Failed to calculate optimized index for add change at offset:"+changeInfo + "," + prev + "," + myChanges.get(prev));
|
||||
ourDoAddChangeAtOffsetChecks = false;
|
||||
ourEnableAddChangeAtOffsetOptimization = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,9 +330,11 @@ public class TreeChangeImpl implements TreeChange {
|
||||
|
||||
private static final int haveNotCalculated = -1;
|
||||
|
||||
private static boolean ourDoOptimizedNodeOldOffsetChecks = ourDoChecks;
|
||||
private static boolean ourEnableOptimizedNodeOldOffset = true;
|
||||
|
||||
private int getOptimizedNodeOldOffset(ASTNode child, ChangeInfo changeInfo) {
|
||||
if (!ourEnableOptimizedNodeOldOffset) return haveNotCalculated;
|
||||
|
||||
// we usually add / remove ranges so old offset can be tried to calculate from change with previous sibling
|
||||
ASTNode prevSibling = child.getTreePrev();
|
||||
if (prevSibling != null) {
|
||||
@@ -349,11 +351,11 @@ public class TreeChangeImpl implements TreeChange {
|
||||
)
|
||||
) {
|
||||
int optimizedResult = pair.getSecond() + prevSiblingChange.getOldLength();
|
||||
if (ourDoOptimizedNodeOldOffsetChecks) {
|
||||
if (ourDoChecks) {
|
||||
int oldOffset = calculateOldOffsetLinearly(child);
|
||||
if (optimizedResult != oldOffset) {
|
||||
LOG.error("Failed optimized node old offset check:"+changeInfo + ", previous:" + prevSibling + "," + prevSiblingChange);
|
||||
ourDoOptimizedNodeOldOffsetChecks = false;
|
||||
ourEnableOptimizedNodeOldOffset = false;
|
||||
optimizedResult = oldOffset;
|
||||
}
|
||||
}
|
||||
@@ -412,27 +414,30 @@ public class TreeChangeImpl implements TreeChange {
|
||||
|
||||
private int myLastOffsetInNewTree;
|
||||
private ASTNode myLastNode;
|
||||
private static boolean ourDoGetNewOffsetChecks = ourDoChecks;
|
||||
private static boolean ourEnableGetNewOffset = true;
|
||||
|
||||
private int getNewOffset(ASTNode node){
|
||||
int optimizedResult = haveNotCalculated;
|
||||
|
||||
ASTNode prev = node.getTreePrev();
|
||||
if (myLastNode == prev) {
|
||||
ChangeInfo prevChangeInfo = myChanges.get(prev);
|
||||
ChangeInfo changeInfo = myChanges.get(node);
|
||||
ASTNode prev = null;
|
||||
if (ourEnableGetNewOffset) {
|
||||
prev = node.getTreePrev();
|
||||
if (myLastNode == prev) {
|
||||
ChangeInfo prevChangeInfo = myChanges.get(prev);
|
||||
ChangeInfo changeInfo = myChanges.get(node);
|
||||
|
||||
// newoffset of removed element is the same of removed previous sibling
|
||||
if (prevChangeInfo != null &&
|
||||
changeInfo != null &&
|
||||
prevChangeInfo.getChangeType() == ChangeInfo.REMOVED &&
|
||||
changeInfo.getChangeType() == ChangeInfo.REMOVED
|
||||
) {
|
||||
optimizedResult = myLastOffsetInNewTree;
|
||||
// newoffset of removed element is the same of removed previous sibling
|
||||
if (prevChangeInfo != null &&
|
||||
changeInfo != null &&
|
||||
prevChangeInfo.getChangeType() == ChangeInfo.REMOVED &&
|
||||
changeInfo.getChangeType() == ChangeInfo.REMOVED
|
||||
) {
|
||||
optimizedResult = myLastOffsetInNewTree;
|
||||
|
||||
myLastNode = node;
|
||||
myLastOffsetInNewTree = optimizedResult;
|
||||
if (!ourDoGetNewOffsetChecks) return optimizedResult;
|
||||
myLastNode = node;
|
||||
myLastOffsetInNewTree = optimizedResult;
|
||||
if (!ourDoChecks) return optimizedResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,11 +480,10 @@ public class TreeChangeImpl implements TreeChange {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (ourDoGetNewOffsetChecks &&
|
||||
optimizedResult != haveNotCalculated &&
|
||||
if (optimizedResult != haveNotCalculated &&
|
||||
optimizedResult != currentOffsetInNewTree) {
|
||||
LOG.error("Failed to calculate optimized getNewOffset:"+myChanges.get(node) + "," + prev + "," + myChanges.get(prev));
|
||||
ourDoGetNewOffsetChecks = false;
|
||||
ourEnableGetNewOffset = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public abstract class PsiAnchor {
|
||||
|
||||
if (element instanceof PsiFile) {
|
||||
VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
|
||||
if (virtualFile != null) return new PsiFileReference(virtualFile, element.getProject(), element.getLanguage());
|
||||
if (virtualFile != null) return new PsiFileReference(virtualFile, (PsiFile)element);
|
||||
return new HardReference(element);
|
||||
}
|
||||
if (element instanceof PsiDirectory) {
|
||||
@@ -262,12 +262,23 @@ public abstract class PsiAnchor {
|
||||
private static class PsiFileReference extends PsiAnchor {
|
||||
private final VirtualFile myFile;
|
||||
private final Project myProject;
|
||||
@Nullable private final Language myLanguage;
|
||||
@NotNull private final Language myLanguage;
|
||||
|
||||
private PsiFileReference(@NotNull VirtualFile file, @NotNull Project project, @NotNull Language language) {
|
||||
private PsiFileReference(@NotNull VirtualFile file, @NotNull PsiFile psiFile) {
|
||||
myFile = file;
|
||||
myProject = project;
|
||||
myLanguage = language;
|
||||
myProject = psiFile.getProject();
|
||||
myLanguage = findLanguage(psiFile);
|
||||
}
|
||||
|
||||
private static Language findLanguage(PsiFile file) {
|
||||
FileViewProvider vp = file.getViewProvider();
|
||||
Set<Language> languages = vp.getLanguages();
|
||||
for (Language language : languages) {
|
||||
if (file.equals(vp.getPsi(language))) {
|
||||
return language;
|
||||
}
|
||||
}
|
||||
throw new AssertionError("Non-retrievable file: " + file.getClass() + "; " + file.getLanguage() + "; " + languages);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -299,7 +310,7 @@ public abstract class PsiAnchor {
|
||||
PsiFileReference reference = (PsiFileReference)o;
|
||||
|
||||
if (!myFile.equals(reference.myFile)) return false;
|
||||
if (myLanguage != null ? !myLanguage.equals(reference.myLanguage) : reference.myLanguage != null) return false;
|
||||
if (!myLanguage.equals(reference.myLanguage)) return false;
|
||||
if (!myProject.equals(reference.myProject)) return false;
|
||||
|
||||
return true;
|
||||
@@ -307,9 +318,7 @@ public abstract class PsiAnchor {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myFile.hashCode();
|
||||
result = 31 * result + (myLanguage != null ? myLanguage.hashCode() : 0);
|
||||
return result;
|
||||
return 31 * myFile.hashCode() + (myLanguage.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,21 @@
|
||||
*/
|
||||
package com.intellij.dvcs;
|
||||
|
||||
import com.intellij.dvcs.repo.Repository;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.StatusBarWidget;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
@@ -41,4 +49,43 @@ public class DvcsUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getShortRepositoryName(@NotNull Project project, @NotNull VirtualFile root) {
|
||||
VirtualFile projectDir = project.getBaseDir();
|
||||
|
||||
String repositoryPath = root.getPresentableUrl();
|
||||
if (projectDir != null) {
|
||||
String relativePath = VfsUtilCore.getRelativePath(root, projectDir, File.separatorChar);
|
||||
if (relativePath != null) {
|
||||
repositoryPath = relativePath;
|
||||
}
|
||||
}
|
||||
|
||||
return repositoryPath.isEmpty() ? root.getName() : repositoryPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getShortRepositoryName(@NotNull Repository repository) {
|
||||
return getShortRepositoryName(repository.getProject(), repository.getRoot());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getShortNames(@NotNull Collection<? extends Repository> repositories) {
|
||||
return StringUtil.join(repositories, new Function<Repository, String>() {
|
||||
@Override
|
||||
public String fun(Repository repository) {
|
||||
return getShortRepositoryName(repository);
|
||||
}
|
||||
}, ", ");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String joinRootsPaths(@NotNull Collection<VirtualFile> roots) {
|
||||
return StringUtil.join(roots, new Function<VirtualFile, String>() {
|
||||
@Override
|
||||
public String fun(VirtualFile virtualFile) {
|
||||
return virtualFile.getPresentableUrl();
|
||||
}
|
||||
}, ", ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.dvcs.ui;
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.ui.ErrorLabel;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.panels.OpaquePanel;
|
||||
import com.intellij.ui.popup.PopupFactoryImpl;
|
||||
import com.intellij.ui.popup.WizardPopup;
|
||||
import com.intellij.ui.popup.list.PopupListElementRenderer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Nadya Zabrodina
|
||||
*/
|
||||
public class BranchActionGroupPopup extends PopupFactoryImpl.ActionGroupPopup {
|
||||
public BranchActionGroupPopup(@NotNull String title, @NotNull Project project,
|
||||
@NotNull Condition<AnAction> preselectActionCondition, @NotNull ActionGroup actions) {
|
||||
super(title, actions, SimpleDataContext.getProjectContext(project), false, false, false, true, null, -1,
|
||||
preselectActionCondition, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WizardPopup createPopup(WizardPopup parent, PopupStep step, Object parentValue) {
|
||||
WizardPopup popup = super.createPopup(parent, step, parentValue);
|
||||
RootAction rootAction = getRootAction(parentValue);
|
||||
if (rootAction != null) {
|
||||
popup.setAdText((rootAction).getCaption());
|
||||
}
|
||||
return popup;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static RootAction getRootAction(Object value) {
|
||||
if (value instanceof PopupFactoryImpl.ActionItem) {
|
||||
AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction();
|
||||
if (action instanceof RootAction) {
|
||||
return (RootAction)action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListCellRenderer getListElementRenderer() {
|
||||
return new PopupListElementRenderer(this) {
|
||||
|
||||
private ErrorLabel myBranchLabel;
|
||||
|
||||
@Override
|
||||
protected void customizeComponent(JList list, Object value, boolean isSelected) {
|
||||
super.customizeComponent(list, value, isSelected);
|
||||
|
||||
RootAction rootAction = getRootAction(value);
|
||||
if (rootAction != null) {
|
||||
myBranchLabel.setVisible(true);
|
||||
myBranchLabel.setText(String.format("[%s]", rootAction.getBranch()));
|
||||
|
||||
if (isSelected) {
|
||||
setSelected(myBranchLabel);
|
||||
}
|
||||
else {
|
||||
myBranchLabel.setBackground(getBackground());
|
||||
myBranchLabel.setForeground(JBColor.GRAY); // different foreground than for other elements
|
||||
}
|
||||
|
||||
adjustOpacity(myBranchLabel, isSelected);
|
||||
}
|
||||
else {
|
||||
myBranchLabel.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createItemComponent() {
|
||||
myTextLabel = new ErrorLabel();
|
||||
myTextLabel.setOpaque(true);
|
||||
myTextLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
|
||||
|
||||
myBranchLabel = new ErrorLabel();
|
||||
myBranchLabel.setOpaque(true);
|
||||
myBranchLabel.setBorder(BorderFactory.createEmptyBorder(1, UIUtil.DEFAULT_HGAP, 1, 1));
|
||||
|
||||
JPanel compoundPanel = new OpaquePanel(new BorderLayout(), JBColor.WHITE);
|
||||
compoundPanel.add(myTextLabel, BorderLayout.CENTER);
|
||||
compoundPanel.add(myBranchLabel, BorderLayout.EAST);
|
||||
|
||||
return layoutComponent(compoundPanel);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.dvcs.ui;
|
||||
|
||||
import com.intellij.dvcs.repo.Repository;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.IconUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Nadya Zabrodina
|
||||
*/
|
||||
public abstract class NewBranchAction<T extends Repository> extends DumbAwareAction {
|
||||
protected final List<T> myRepositories;
|
||||
protected Project myProject;
|
||||
|
||||
public NewBranchAction(@NotNull Project project, @NotNull List<T> repositories) {
|
||||
super("New Branch", "Create and checkout new branch", IconUtil.getAddIcon());
|
||||
myRepositories = repositories;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
if (anyRepositoryIsFresh()) {
|
||||
e.getPresentation().setEnabled(false);
|
||||
e.getPresentation().setDescription("Checkout of a new branch is not possible before the first commit.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void actionPerformed(AnActionEvent e);
|
||||
|
||||
private boolean anyRepositoryIsFresh() {
|
||||
for (Repository repository : myRepositories) {
|
||||
if (repository.isFresh()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.dvcs.ui;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.dvcs.repo.Repository;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Nadya Zabrodina
|
||||
*/
|
||||
public class RootAction<T extends Repository> extends ActionGroup {
|
||||
|
||||
@NotNull protected final T myRepository;
|
||||
@NotNull private ActionGroup myGroup;
|
||||
@NotNull private String myBranchText;
|
||||
@NotNull private String myBranchOrRev;
|
||||
|
||||
|
||||
/**
|
||||
* @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then.
|
||||
* @param actionsGroup
|
||||
* @param branchText
|
||||
* @param branchName
|
||||
*/
|
||||
public RootAction(@NotNull T repository,
|
||||
@Nullable T currentRepository,
|
||||
@NotNull ActionGroup actionsGroup,
|
||||
@NotNull String branchText,
|
||||
@NotNull String branchName) {
|
||||
super(DvcsUtil.getShortRepositoryName(repository), true);
|
||||
myRepository = repository;
|
||||
myGroup = actionsGroup;
|
||||
myBranchText = branchText;
|
||||
myBranchOrRev = branchName;
|
||||
if (repository.equals(currentRepository)) {
|
||||
getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public String getCaption() {
|
||||
return "Current branch in " + DvcsUtil.getShortRepositoryName(myRepository) + ": " +
|
||||
getDisplayableBranchText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getDisplayableBranchText() {
|
||||
return myBranchText;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getBranch() {
|
||||
return myBranchOrRev;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
return myGroup.getChildren(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+14
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -183,9 +183,9 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
result = myExtensionsCache;
|
||||
if (result == null) {
|
||||
processAdapters();
|
||||
final Class<T> extensionClass = getExtensionClass();
|
||||
//noinspection unchecked
|
||||
result = myExtensions.toArray((T[])Array.newInstance(extensionClass, myExtensions.size()));
|
||||
Class<T> extensionClass = getExtensionClass();
|
||||
@SuppressWarnings("unchecked") T[] a = (T[])Array.newInstance(extensionClass, myExtensions.size());
|
||||
result = myExtensions.toArray(a);
|
||||
|
||||
for (int i = result.length - 1; i >= 0; i--) {
|
||||
T t = result[i];
|
||||
@@ -237,8 +237,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
ExtensionComponentAdapter[] adapters = allAdapters.toArray(new ExtensionComponentAdapter[myExtensionAdapters.size()]);
|
||||
LoadingOrder.sort(adapters);
|
||||
for (ExtensionComponentAdapter adapter : adapters) {
|
||||
//noinspection unchecked
|
||||
T extension = (T)adapter.getExtension();
|
||||
@SuppressWarnings("unchecked") T extension = (T)adapter.getExtension();
|
||||
assertClass(extension.getClass());
|
||||
|
||||
internalRegisterExtension(extension, adapter, myExtensions.size(), ArrayUtilRt.find(loadedAdapters, adapter) == -1);
|
||||
@@ -334,8 +333,8 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
if (myEPListeners.add(listener)) {
|
||||
for (ExtensionComponentAdapter componentAdapter : myLoadedAdapters.toArray(new ExtensionComponentAdapter[myLoadedAdapters.size()])) {
|
||||
try {
|
||||
//noinspection unchecked
|
||||
listener.extensionAdded((T)componentAdapter.getExtension(), componentAdapter.getPluginDescriptor());
|
||||
@SuppressWarnings("unchecked") T extension = (T)componentAdapter.getExtension();
|
||||
listener.extensionAdded(extension, componentAdapter.getPluginDescriptor());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
@@ -348,8 +347,8 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
public synchronized void removeExtensionPointListener(@NotNull ExtensionPointListener<T> listener) {
|
||||
for (ExtensionComponentAdapter componentAdapter : myLoadedAdapters.toArray(new ExtensionComponentAdapter[myLoadedAdapters.size()])) {
|
||||
try {
|
||||
//noinspection unchecked
|
||||
listener.extensionRemoved((T)componentAdapter.getExtension(), componentAdapter.getPluginDescriptor());
|
||||
@SuppressWarnings("unchecked") T extension = (T)componentAdapter.getExtension();
|
||||
listener.extensionRemoved(extension, componentAdapter.getPluginDescriptor());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
@@ -379,10 +378,9 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
if (extensionClass == null) {
|
||||
try {
|
||||
ClassLoader pluginClassLoader = myDescriptor.getPluginClassLoader();
|
||||
//noinspection unchecked
|
||||
myExtensionClass = extensionClass = pluginClassLoader == null
|
||||
? (Class<T>)Class.forName(myClassName)
|
||||
: (Class<T>)Class.forName(myClassName, true, pluginClassLoader);
|
||||
@SuppressWarnings("unchecked") Class<T> extClass = pluginClassLoader == null
|
||||
? (Class<T>)Class.forName(myClassName) : (Class<T>)Class.forName(myClassName, true, pluginClassLoader);
|
||||
myExtensionClass = extensionClass = extClass;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -422,8 +420,8 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
pluginContainer.unregisterComponent(componentKey);
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
internalUnregisterExtension((T)componentAdapter.getExtension(), componentAdapter.getPluginDescriptor());
|
||||
@SuppressWarnings("unchecked") T extension = (T)componentAdapter.getExtension();
|
||||
internalUnregisterExtension(extension, componentAdapter.getPluginDescriptor());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -132,7 +132,7 @@ public class LibraryDataService implements ProjectDataService<LibraryData, Libra
|
||||
String.format("Can't find %s of the library '%s' at path '%s'", entry.getKey(), libraryName, file.getAbsolutePath())
|
||||
);
|
||||
}
|
||||
String url = VfsUtilCore.pathToUrl(file.getAbsolutePath());
|
||||
String url = VfsUtil.getUrlForLibraryRoot(file);
|
||||
model.addRoot(url, entry.getKey());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.execution;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunContentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -60,4 +61,10 @@ public abstract class ExecutionManager {
|
||||
@NotNull ExecutionTarget target,
|
||||
@Nullable RunnerAndConfigurationSettings configuration,
|
||||
@Nullable RunContentDescriptor currentDescriptor);
|
||||
|
||||
public abstract void restartRunProfile(@NotNull Project project,
|
||||
@NotNull Executor executor,
|
||||
@Nullable ProgramRunner runner,
|
||||
@NotNull ExecutionEnvironment environment,
|
||||
@Nullable RunContentDescriptor currentDescriptor);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
@@ -269,28 +266,55 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) {
|
||||
final ProcessHandler handler = descriptor.getProcessHandler();
|
||||
if (handler == processHandler) {
|
||||
restartRunProfile(project, executor, target, configuration, descriptor);
|
||||
restartRunProfile(project, null, null, null, null, executor, target, configuration, descriptor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
restartRunProfile(project, executor, target, configuration, (RunContentDescriptor)null);
|
||||
restartRunProfile(project, null, null, null, null, executor, target, configuration, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartRunProfile(@NotNull final Project project,
|
||||
public void restartRunProfile(@NotNull Project project,
|
||||
@NotNull Executor executor,
|
||||
@NotNull ExecutionTarget target,
|
||||
@Nullable RunnerAndConfigurationSettings configuration,
|
||||
@Nullable RunContentDescriptor currentDescriptor) {
|
||||
restartRunProfile(project, null, null, null, null, executor, target, configuration, currentDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartRunProfile(@NotNull Project project,
|
||||
@NotNull Executor executor,
|
||||
@Nullable ProgramRunner runner,
|
||||
@NotNull ExecutionEnvironment environment,
|
||||
@Nullable RunContentDescriptor currentDescriptor) {
|
||||
restartRunProfile(project,
|
||||
runner,
|
||||
environment.getRunProfile(),
|
||||
environment.getRunnerSettings(),
|
||||
environment.getConfigurationSettings(),
|
||||
executor,
|
||||
environment.getExecutionTarget(),
|
||||
environment.getRunnerAndConfigurationSettings(), currentDescriptor);
|
||||
}
|
||||
|
||||
|
||||
private void restartRunProfile(@NotNull final Project project,
|
||||
@Nullable ProgramRunner r,
|
||||
@Nullable final RunProfile runProfile,
|
||||
@Nullable final RunnerSettings runnerSettings,
|
||||
@Nullable final ConfigurationPerRunnerSettings configurationPerRunnerSettings,
|
||||
@NotNull final Executor executor,
|
||||
@NotNull final ExecutionTarget target,
|
||||
@Nullable final RunnerAndConfigurationSettings configuration,
|
||||
@Nullable final RunContentDescriptor currentDescriptor) {
|
||||
if (configuration != null && ProgramRunnerUtil.getRunner(executor.getId(), configuration) == null) {
|
||||
final ProgramRunner runner = r != null ? r : ProgramRunnerUtil.getRunner(executor.getId(), configuration);
|
||||
if (configuration != null && runner == null) {
|
||||
LOG.error("Cannot find runner for " + configuration.getName());
|
||||
return;
|
||||
}
|
||||
if (configuration == null && (currentDescriptor == null || currentDescriptor.getRestarter() == null)) {
|
||||
LOG.error("Nothing to restart for descriptor ["+currentDescriptor+"]");
|
||||
return;
|
||||
}
|
||||
|
||||
final List<RunContentDescriptor> descriptorsToStop = new ArrayList<RunContentDescriptor>();
|
||||
if (configuration != null && configuration.isSingleton()) {
|
||||
descriptorsToStop.addAll(getRunningDescriptors(configuration));
|
||||
@@ -312,7 +336,6 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProgramRunner runner = ProgramRunnerUtil.getRunner(executor.getId(), configuration);
|
||||
if (runner != null && ExecutorRegistry.getInstance().isStarting(project, executor.getId(), runner.getRunnerId())) {
|
||||
awaitingTerminationAlarm.addRequest(this, 100);
|
||||
return;
|
||||
@@ -324,19 +347,39 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
return;
|
||||
}
|
||||
}
|
||||
start(project, configuration, executor, target, currentDescriptor);
|
||||
start(project, runner, runProfile, runnerSettings, configurationPerRunnerSettings, configuration, executor, target, currentDescriptor);
|
||||
}
|
||||
};
|
||||
awaitingTerminationAlarm.addRequest(runnable, 50);
|
||||
}
|
||||
|
||||
private static void start(@NotNull Project project,
|
||||
@Nullable ProgramRunner runner,
|
||||
@Nullable RunProfile runProfile,
|
||||
@Nullable RunnerSettings runnerSettings,
|
||||
@Nullable ConfigurationPerRunnerSettings configurationPerRunnerSettings,
|
||||
@Nullable RunnerAndConfigurationSettings configuration,
|
||||
@NotNull Executor executor,
|
||||
@NotNull ExecutionTarget target,
|
||||
@Nullable RunContentDescriptor descriptor) {
|
||||
Runnable restarter = descriptor != null ? descriptor.getRestarter() : null;
|
||||
if (configuration != null) {
|
||||
if (runner != null && runProfile != null) {
|
||||
try {
|
||||
runner.execute(executor, new ExecutionEnvironment(runProfile,
|
||||
target,
|
||||
project,
|
||||
runnerSettings,
|
||||
configurationPerRunnerSettings,
|
||||
descriptor,
|
||||
configuration));
|
||||
}
|
||||
catch (RunCanceledByUserException ignore) {
|
||||
}
|
||||
catch (ExecutionException e1) {
|
||||
Messages.showErrorDialog(project, e1.getMessage(), ExecutionBundle.message("restart.error.message.title"));
|
||||
}
|
||||
}
|
||||
else if (configuration != null) {
|
||||
ProgramRunnerUtil.executeConfiguration(project, configuration, executor, target, descriptor, true);
|
||||
}
|
||||
else if (restarter != null) {
|
||||
|
||||
@@ -43,7 +43,6 @@ import java.util.List;
|
||||
*/
|
||||
public class RestartAction extends FakeRerunAction implements DumbAware, AnAction.TransparentUpdate, Disposable {
|
||||
|
||||
private final ProcessHandler myProcessHandler;
|
||||
private final ProgramRunner myRunner;
|
||||
@NotNull private final RunContentDescriptor myDescriptor;
|
||||
@NotNull private final Executor myExecutor;
|
||||
@@ -51,7 +50,6 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
|
||||
|
||||
public RestartAction(@NotNull final Executor executor,
|
||||
final ProgramRunner runner,
|
||||
final ProcessHandler processHandler,//todo kill ProcessHandler here, use descriptor.getProcessHandler() is need
|
||||
@NotNull final RunContentDescriptor descriptor,
|
||||
@NotNull final ExecutionEnvironment env) {
|
||||
Disposer.register(descriptor, this);
|
||||
@@ -59,7 +57,6 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
|
||||
|
||||
myEnvironment = env;
|
||||
getTemplatePresentation().setEnabled(false);
|
||||
myProcessHandler = processHandler;
|
||||
myRunner = runner;
|
||||
myDescriptor = descriptor;
|
||||
myExecutor = executor;
|
||||
@@ -108,22 +105,8 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
|
||||
|
||||
public void restart() {
|
||||
Project project = myEnvironment.getProject();
|
||||
if (project == null)
|
||||
return;
|
||||
if (myProcessHandler != null) {
|
||||
ExecutionManager.getInstance(project).restartRunProfile(project,
|
||||
myExecutor,
|
||||
myEnvironment.getExecutionTarget(),
|
||||
myEnvironment.getRunnerAndConfigurationSettings(),
|
||||
myProcessHandler);
|
||||
}
|
||||
else {
|
||||
ExecutionManager.getInstance(project).restartRunProfile(project,
|
||||
myExecutor,
|
||||
myEnvironment.getExecutionTarget(),
|
||||
myEnvironment.getRunnerAndConfigurationSettings(),
|
||||
myDescriptor);
|
||||
}
|
||||
if (project != null && !ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), myRunner.getRunnerId()))
|
||||
ExecutionManager.getInstance(project).restartRunProfile(project, myExecutor, myRunner, myEnvironment, myDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -205,8 +205,7 @@ public class RunContentBuilder extends LogConsoleManagerBase {
|
||||
private ActionGroup createActionToolbar(final RunContentDescriptor contentDescriptor, final JComponent component) {
|
||||
final DefaultActionGroup actionGroup = new DefaultActionGroup();
|
||||
|
||||
final RestartAction restartAction = new RestartAction(myExecutor, myRunner, getProcessHandler(),
|
||||
contentDescriptor, getEnvironment());
|
||||
final RestartAction restartAction = new RestartAction(myExecutor, myRunner, contentDescriptor, getEnvironment());
|
||||
restartAction.registerShortcut(component);
|
||||
actionGroup.add(restartAction);
|
||||
contentDescriptor.setRestarter(new Runnable() {
|
||||
|
||||
@@ -685,7 +685,10 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
|
||||
}, false);
|
||||
}
|
||||
else if (propertyName.equals(PsiTreeChangeEvent.PROP_DIRECTORY_NAME)) {
|
||||
queueRefreshScope(scope, (PsiDirectory)element);
|
||||
final PackageSet value = getCurrentScope().getValue();
|
||||
if (!(value instanceof PackageSetBase) || ((PackageSetBase)value).contains(((PsiDirectory)element).getVirtualFile(), myProject, myDependencyValidationManager)) {
|
||||
queueRefreshScope(scope, (PsiDirectory)element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,14 +114,16 @@ public class ScopeViewPane extends AbstractProjectViewPane {
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
myViewPanel = new ScopeTreeViewPanel(myProject);
|
||||
Disposer.register(this, myViewPanel);
|
||||
myViewPanel.initListeners();
|
||||
myViewPanel.selectScope(NamedScopesHolder.getScope(myProject, getSubId()));
|
||||
myTree = myViewPanel.getTree();
|
||||
PopupHandler.installPopupHandler(myTree, IdeActions.GROUP_SCOPE_VIEW_POPUP, ActionPlaces.SCOPE_VIEW_POPUP);
|
||||
enableDnD();
|
||||
if (myViewPanel == null) {
|
||||
myViewPanel = new ScopeTreeViewPanel(myProject);
|
||||
Disposer.register(this, myViewPanel);
|
||||
myViewPanel.initListeners();
|
||||
myTree = myViewPanel.getTree();
|
||||
PopupHandler.installPopupHandler(myTree, IdeActions.GROUP_SCOPE_VIEW_POPUP, ActionPlaces.SCOPE_VIEW_POPUP);
|
||||
enableDnD();
|
||||
}
|
||||
|
||||
myViewPanel.selectScope(NamedScopesHolder.getScope(myProject, getSubId()));
|
||||
return myViewPanel.getPanel();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,12 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.FileNameCache;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -143,7 +147,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
}
|
||||
});
|
||||
|
||||
myConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkVirtualFileListenerAdapter(new MyVirtualFileListener()));
|
||||
myConnection.subscribe(VirtualFileManager.VFS_CHANGES, new MyVirtualFileListener());
|
||||
}
|
||||
|
||||
private void markContentRootsForRefresh() {
|
||||
@@ -162,7 +166,10 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
myConnection.deliverImmediately();
|
||||
}
|
||||
|
||||
private class MyVirtualFileListener extends VirtualFileAdapter {
|
||||
private class MyVirtualFileListener extends VirtualFileAdapter implements BulkFileListener {
|
||||
private static final int MAX_DEPTH_TO_COUNT = 20;
|
||||
private static final int DIRECTORIES_CHANGED_THRESHOLD = 50;
|
||||
|
||||
@Override
|
||||
public void fileCreated(VirtualFileEvent event) {
|
||||
VirtualFile file = event.getFile();
|
||||
@@ -177,7 +184,6 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
replaceState(newState);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private IndexState updateStateWithNewFile(@NotNull NewVirtualFile file, @NotNull NewVirtualFile parent) {
|
||||
final IndexState originalState = myState;
|
||||
@@ -224,22 +230,24 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
state.fillMapWithModuleContent(file, module, (NewVirtualFile)parentContentRoot, null);
|
||||
|
||||
String parentPackage = state.getPackageNameForDirectory(parent);
|
||||
TObjectIntHashMap<String> interned = new TObjectIntHashMap<String>();
|
||||
|
||||
if (module != null) {
|
||||
if (parentInfo.isInModuleSource()) {
|
||||
String newDirPackageName = getPackageNameForSubdir(parentPackage, file.getName());
|
||||
state.fillMapWithModuleSource(module, (NewVirtualFile)parentContentRoot, file, newDirPackageName, (NewVirtualFile)parentInfo.getSourceRoot(), parentInfo.isTestSource(), null);
|
||||
state.fillMapWithModuleSource(module, (NewVirtualFile)parentContentRoot, file, newDirPackageName,
|
||||
(NewVirtualFile)parentInfo.getSourceRoot(), parentInfo.isTestSource(), null, interned);
|
||||
}
|
||||
}
|
||||
|
||||
if (parentInfo.hasLibraryClassRoot()) {
|
||||
String newDirPackageName = getPackageNameForSubdir(parentPackage, file.getName());
|
||||
state.fillMapWithLibraryClasses(file, newDirPackageName, (NewVirtualFile)parentInfo.getLibraryClassRoot(), null);
|
||||
state.fillMapWithLibraryClasses(file, newDirPackageName, (NewVirtualFile)parentInfo.getLibraryClassRoot(), null, interned);
|
||||
}
|
||||
|
||||
if (parentInfo.isInLibrarySource()) {
|
||||
String newDirPackageName = getPackageNameForSubdir(parentPackage, file.getName());
|
||||
state.fillMapWithLibrarySources(file, newDirPackageName, (NewVirtualFile)parentInfo.getSourceRoot(), null);
|
||||
state.fillMapWithLibrarySources(file, newDirPackageName, (NewVirtualFile)parentInfo.getSourceRoot(), null, interned);
|
||||
}
|
||||
|
||||
OrderEntry[] entries = parentInfo.getOrderEntries();
|
||||
@@ -303,11 +311,6 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
myState.assertAncestorsConsistent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeFileMovement(VirtualFileMoveEvent event) {
|
||||
super.beforeFileMovement(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileMoved(VirtualFileMoveEvent event) {
|
||||
VirtualFile file = event.getFile();
|
||||
@@ -327,6 +330,64 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
}
|
||||
myState.assertAncestorsConsistent();
|
||||
}
|
||||
|
||||
private boolean myBatchChangePlanned;
|
||||
private static final boolean ourCanHaveBatchUpdate = true;
|
||||
|
||||
@Override
|
||||
public void before(@NotNull List<? extends VFileEvent> events) {
|
||||
myBatchChangePlanned = false;
|
||||
int directoriesRemoved = 0;
|
||||
int directoriesCreated = 0;
|
||||
|
||||
for(VFileEvent event:events) {
|
||||
if (event instanceof VFileDeleteEvent) {
|
||||
VirtualFile file = event.getFile();
|
||||
if (file != null && file.isDirectory()) {
|
||||
directoriesRemoved += 1 + countDirectories(file, MAX_DEPTH_TO_COUNT);
|
||||
}
|
||||
} else if(event instanceof VFileCreateEvent) {
|
||||
VirtualFile file = event.getFile();
|
||||
if (file != null && file.isDirectory()) directoriesCreated += 1 + countDirectories(file, MAX_DEPTH_TO_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
final boolean willDoBatchUpdate = directoriesCreated + directoriesRemoved > DIRECTORIES_CHANGED_THRESHOLD;
|
||||
|
||||
if (willDoBatchUpdate && ourCanHaveBatchUpdate) {
|
||||
myBatchChangePlanned = true;
|
||||
LOG.info("Too many directories created / deleted: " + directoriesCreated + "," + directoriesRemoved + ", will rebuild indexstate");
|
||||
} else {
|
||||
for (VFileEvent event : events) {
|
||||
BulkVirtualFileListenerAdapter.fireBefore(this, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int countDirectories(VirtualFile file, int depth) {
|
||||
if (!(file instanceof NewVirtualFile)) return 0;
|
||||
|
||||
int counter = 0;
|
||||
for(VirtualFile child:((NewVirtualFile)file).iterInDbChildren()) {
|
||||
if (child.isDirectory()) counter += 1 + (depth > 0 ? countDirectories(child, depth - 1):0);
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void after(@NotNull List<? extends VFileEvent> events) {
|
||||
if (myBatchChangePlanned) {
|
||||
myBatchChangePlanned = false;
|
||||
long started = System.currentTimeMillis();
|
||||
doInitialize();
|
||||
LOG.info("Rebuilt indexstate for " + (System.currentTimeMillis() - started));
|
||||
}
|
||||
else {
|
||||
for (VFileEvent event : events) {
|
||||
BulkVirtualFileListenerAdapter.fireAfter(this, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void replaceState(IndexState newState) {
|
||||
@@ -365,7 +426,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
dispatchPendingEvents();
|
||||
|
||||
IndexState state = myState;
|
||||
int[] allDirs = state.getDirsForPackage(internPackageName(packageName));
|
||||
int[] allDirs = state.getDirsForPackage(internPackageName(packageName, null));
|
||||
if (allDirs == null) allDirs = ArrayUtil.EMPTY_INT_ARRAY;
|
||||
|
||||
List<VirtualFile> files = new ArrayList<VirtualFile>(allDirs.length);
|
||||
@@ -511,7 +572,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static int[] internPackageName(@Nullable String packageName) {
|
||||
private static int[] internPackageName(@Nullable String packageName, @Nullable TObjectIntHashMap<String> alreadyEnumerated) {
|
||||
if (packageName == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -531,7 +592,13 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
if (tokenEnd < 0) {
|
||||
tokenEnd = packageName.length();
|
||||
}
|
||||
result[tokenIndex + 1] = FileNameCache.storeName(packageName.substring(tokenStart, tokenEnd));
|
||||
String nextName = packageName.substring(tokenStart, tokenEnd);
|
||||
int internedId = alreadyEnumerated != null ? alreadyEnumerated.get(nextName) : 0;
|
||||
if (internedId == 0) {
|
||||
internedId = FileNameCache.storeName(nextName);
|
||||
if (alreadyEnumerated != null) alreadyEnumerated.put(nextName, internedId);
|
||||
}
|
||||
result[tokenIndex + 1] = internedId;
|
||||
tokenStart = tokenEnd + 1;
|
||||
tokenIndex++;
|
||||
}
|
||||
@@ -788,7 +855,8 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
}
|
||||
}
|
||||
|
||||
private void initModuleSources(@NotNull Module module, boolean reverseAllSets, @NotNull ProgressIndicator progress) {
|
||||
private void initModuleSources(@NotNull Module module, boolean reverseAllSets, @NotNull ProgressIndicator progress,
|
||||
@Nullable TObjectIntHashMap<String> interned) {
|
||||
assertWritable();
|
||||
progress.checkCanceled();
|
||||
progress.setText2(ProjectBundle.message("project.index.processing.module.sources.progress", module.getName()));
|
||||
@@ -808,7 +876,8 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
for (SourceFolder sourceFolder : sourceFolders) {
|
||||
VirtualFile dir = sourceFolder.getFile();
|
||||
if (dir instanceof NewVirtualFile && contentRoot instanceof NewVirtualFile) {
|
||||
fillMapWithModuleSource(module, (NewVirtualFile)contentRoot, (NewVirtualFile)dir, sourceFolder.getPackagePrefix(), (NewVirtualFile)dir, sourceFolder.isTestSource(), progress);
|
||||
fillMapWithModuleSource(module, (NewVirtualFile)contentRoot, (NewVirtualFile)dir, sourceFolder.getPackagePrefix(),
|
||||
(NewVirtualFile)dir, sourceFolder.isTestSource(), progress, interned);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -820,7 +889,9 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
@NotNull final String packageName,
|
||||
@NotNull final NewVirtualFile sourceRoot,
|
||||
final boolean isTestSource,
|
||||
@Nullable final ProgressIndicator progress) {
|
||||
@Nullable final ProgressIndicator progress,
|
||||
final @Nullable TObjectIntHashMap<String> interned
|
||||
) {
|
||||
assertWritable();
|
||||
if (!isValid(dir)) return;
|
||||
assert VfsUtilCore.isAncestor(sourceRoot, dir, false) : "SourceRoot: "+sourceRoot+" ("+sourceRoot.getFileSystem()+"); dir: "+dir+" ("+dir.getFileSystem()+")";
|
||||
@@ -850,7 +921,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
|
||||
String currentPackage = myPackages.isEmpty() ? packageName : getPackageNameForSubdir(myPackages.peek(), file.getName());
|
||||
myPackages.push(currentPackage);
|
||||
setPackageName(id, internPackageName(currentPackage));
|
||||
setPackageName(id, internPackageName(currentPackage, interned));
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -866,7 +937,8 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
return myDirToPackageName.get(id) == ArrayUtil.EMPTY_INT_ARRAY;
|
||||
}
|
||||
|
||||
private void initLibrarySources(@NotNull Module module, @NotNull ProgressIndicator progress) {
|
||||
private void initLibrarySources(@NotNull Module module, @NotNull ProgressIndicator progress,
|
||||
@Nullable TObjectIntHashMap<String> interned) {
|
||||
assertWritable();
|
||||
progress.checkCanceled();
|
||||
progress.setText2(ProjectBundle.message("project.index.processing.library.sources.progress", module.getName()));
|
||||
@@ -876,7 +948,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
VirtualFile[] sourceRoots = ((LibraryOrSdkOrderEntry)orderEntry).getRootFiles(OrderRootType.SOURCES);
|
||||
for (final VirtualFile sourceRoot : sourceRoots) {
|
||||
if (sourceRoot instanceof NewVirtualFile) {
|
||||
fillMapWithLibrarySources((NewVirtualFile)sourceRoot, "", (NewVirtualFile)sourceRoot, progress);
|
||||
fillMapWithLibrarySources((NewVirtualFile)sourceRoot, "", (NewVirtualFile)sourceRoot, progress, interned);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -884,9 +956,10 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
}
|
||||
|
||||
private void fillMapWithLibrarySources(@NotNull final NewVirtualFile dir,
|
||||
@Nullable final String packageName,
|
||||
@NotNull final NewVirtualFile sourceRoot,
|
||||
@Nullable final ProgressIndicator progress) {
|
||||
@Nullable final String packageName,
|
||||
@NotNull final NewVirtualFile sourceRoot,
|
||||
@Nullable final ProgressIndicator progress,
|
||||
@Nullable final TObjectIntHashMap<String> interned) {
|
||||
assertWritable();
|
||||
if (!isValid(dir)) return;
|
||||
VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor<String>() {
|
||||
@@ -908,7 +981,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
|
||||
final String packageName = getCurrentValue();
|
||||
final String newPackageName = Comparing.equal(file, dir) ? packageName : getPackageNameForSubdir(packageName, file.getName());
|
||||
setPackageName(dirId, internPackageName(newPackageName));
|
||||
setPackageName(dirId, internPackageName(newPackageName, interned));
|
||||
setValueForChildren(newPackageName);
|
||||
|
||||
return true;
|
||||
@@ -916,7 +989,8 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
});
|
||||
}
|
||||
|
||||
private void initLibraryClasses(@NotNull Module module, @NotNull ProgressIndicator progress) {
|
||||
private void initLibraryClasses(@NotNull Module module, @NotNull ProgressIndicator progress,
|
||||
@Nullable TObjectIntHashMap<String> interned) {
|
||||
assertWritable();
|
||||
progress.checkCanceled();
|
||||
progress.setText2(ProjectBundle.message("project.index.processing.library.classes.progress", module.getName()));
|
||||
@@ -926,7 +1000,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
VirtualFile[] classRoots = ((LibraryOrSdkOrderEntry)orderEntry).getRootFiles(OrderRootType.CLASSES);
|
||||
for (final VirtualFile classRoot : classRoots) {
|
||||
if (classRoot instanceof NewVirtualFile) {
|
||||
fillMapWithLibraryClasses((NewVirtualFile)classRoot, "", (NewVirtualFile)classRoot, progress);
|
||||
fillMapWithLibraryClasses((NewVirtualFile)classRoot, "", (NewVirtualFile)classRoot, progress, interned);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -936,7 +1010,9 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
private void fillMapWithLibraryClasses(@NotNull final NewVirtualFile dir,
|
||||
@NotNull final String packageName,
|
||||
@NotNull final NewVirtualFile classRoot,
|
||||
@Nullable final ProgressIndicator progress) {
|
||||
@Nullable final ProgressIndicator progress,
|
||||
@Nullable final TObjectIntHashMap<String> interned
|
||||
) {
|
||||
assertWritable();
|
||||
if (!isValid(dir)) return;
|
||||
VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor<String>() {
|
||||
@@ -959,7 +1035,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
final String packageName = getCurrentValue();
|
||||
final String childPackageName = Comparing.equal(file, dir) ? packageName : getPackageNameForSubdir(packageName, file.getName());
|
||||
if (!info.isInModuleSource() && !info.isInLibrarySource()) {
|
||||
setPackageName(dirId, internPackageName(childPackageName));
|
||||
setPackageName(dirId, internPackageName(childPackageName, interned));
|
||||
}
|
||||
setValueForChildren(childPackageName);
|
||||
|
||||
@@ -1135,13 +1211,16 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
for (Module module : modules) {
|
||||
initModuleContents(module, reverseAllSets, progress);
|
||||
}
|
||||
|
||||
TObjectIntHashMap<String> interned = new TObjectIntHashMap<String>(100);
|
||||
|
||||
// Important! Because module's contents may overlap,
|
||||
// first modules should be marked and only after that sources markup
|
||||
// should be added. (src markup depends on module markup)
|
||||
for (Module module : modules) {
|
||||
initModuleSources(module, reverseAllSets, progress);
|
||||
initLibrarySources(module, progress);
|
||||
initLibraryClasses(module, progress);
|
||||
initModuleSources(module, reverseAllSets, progress, interned);
|
||||
initLibrarySources(module, progress, interned);
|
||||
initLibraryClasses(module, progress , interned);
|
||||
}
|
||||
|
||||
progress.checkCanceled();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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,7 +16,6 @@
|
||||
package com.intellij.diagnostic;
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationDisplayType;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -35,13 +34,14 @@ import java.lang.reflect.InvocationTargetException;
|
||||
* @author kir
|
||||
*/
|
||||
public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
private static boolean ourOomOccured = false;
|
||||
private static boolean ourOomOccurred = false;
|
||||
private static boolean ourLoggerBroken = false;
|
||||
private static boolean mappingFailedNotificationPosted = false;
|
||||
private static boolean ourMappingFailedNotificationPosted = false;
|
||||
|
||||
@NonNls private static final String FATAL_ERROR_NOTIFICATION_PROPERTY = "idea.fatal.error.notification";
|
||||
@NonNls private static final String DISABLED_VALUE = "disabled";
|
||||
@NonNls private static final String ENABLED_VALUE = "enabled";
|
||||
@NonNls private static final String PARAM_PERMGEN = "PermGen";
|
||||
@NonNls private static final String PARAM_PERM_GEN = "PermGen";
|
||||
|
||||
public boolean canHandle(IdeaLoggingEvent event) {
|
||||
if (ourLoggerBroken) return false;
|
||||
@@ -56,7 +56,7 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
return notificationEnabled ||
|
||||
showPluginError ||
|
||||
ApplicationManagerEx.getApplicationEx().isInternal() ||
|
||||
isOOMError(event.getThrowable()) ||
|
||||
isOOMError(event.getThrowable()) ||
|
||||
event.getThrowable() instanceof MappingFailedException;
|
||||
}
|
||||
catch (LinkageError e) {
|
||||
@@ -68,13 +68,8 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection CallToPrintStackTrace
|
||||
*/
|
||||
public void handle(IdeaLoggingEvent event) {
|
||||
if (ourLoggerBroken) {
|
||||
return;
|
||||
}
|
||||
if (ourLoggerBroken) return;
|
||||
|
||||
try {
|
||||
Throwable throwable = event.getThrowable();
|
||||
@@ -84,11 +79,11 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
else if (throwable instanceof MappingFailedException) {
|
||||
processMappingFailed(event);
|
||||
}
|
||||
else if (!ourOomOccured) {
|
||||
else if (!ourOomOccurred) {
|
||||
MessagePool messagePool = MessagePool.getInstance();
|
||||
LogMessage message = messagePool.addIdeFatalMessage(event);
|
||||
if (message != null && ApplicationManager.getApplication() != null) {
|
||||
notifyUi(messagePool, message);
|
||||
ErrorNotifier.notifyUi(message, messagePool);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,14 +94,9 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
ourLoggerBroken = true;
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void notifyUi(MessagePool messagePool, LogMessage message) {
|
||||
ErrorNotifier.notifyUi(message, messagePool);
|
||||
}
|
||||
|
||||
private static boolean isOOMError(Throwable throwable) {
|
||||
return throwable instanceof OutOfMemoryError ||
|
||||
(throwable instanceof VirtualMachineError &&
|
||||
@@ -114,17 +104,13 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
throwable.getMessage().contains("CodeCache"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection CallToPrintStackTrace
|
||||
*/
|
||||
private static void processOOMError(final Throwable throwable) throws InterruptedException, InvocationTargetException {
|
||||
ourOomOccured = true;
|
||||
throwable.printStackTrace();
|
||||
ourOomOccurred = true;
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
String message = throwable.getMessage();
|
||||
OutOfMemoryDialog.MemoryKind k = message != null && message.contains(PARAM_PERMGEN)
|
||||
OutOfMemoryDialog.MemoryKind k = message != null && message.contains(PARAM_PERM_GEN)
|
||||
? OutOfMemoryDialog.MemoryKind.PERM_GEN
|
||||
: message != null && message.contains("CodeCache")
|
||||
? OutOfMemoryDialog.MemoryKind.CODE_CACHE
|
||||
@@ -135,13 +121,13 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
}
|
||||
|
||||
private static void processMappingFailed(final IdeaLoggingEvent event) throws InterruptedException, InvocationTargetException {
|
||||
if (!mappingFailedNotificationPosted && SystemInfo.isWindows && SystemInfo.is32Bit) {
|
||||
mappingFailedNotificationPosted = true;
|
||||
final String exceptionMessage = event.getThrowable().getMessage();
|
||||
final String text = exceptionMessage +
|
||||
"<br>Possible cause: unable to allocate continuous memory chunk of necessary size.<br>Reducing JVM's maximum heap size (-Xmx) may help.";
|
||||
Notifications.Bus.notify(new Notification("Memory", "Memory Mapping Failed", text, NotificationType.WARNING), NotificationDisplayType.BALLOON, null);
|
||||
if (!ourMappingFailedNotificationPosted && SystemInfo.isWindows && SystemInfo.is32Bit) {
|
||||
ourMappingFailedNotificationPosted = true;
|
||||
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") String exceptionMessage = event.getThrowable().getMessage();
|
||||
String text = exceptionMessage +
|
||||
"<br>Possible cause: unable to allocate continuous memory chunk of necessary size.<br>" +
|
||||
"Reducing JVM maximum heap size (-Xmx) may help.";
|
||||
Notifications.Bus.notify(new Notification("Memory", "Memory Mapping Failed", text, NotificationType.WARNING), null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -903,11 +903,11 @@ public class IdeEventQueue extends EventQueue {
|
||||
myWaiterScheduled = false;
|
||||
}
|
||||
else {
|
||||
Application app = ApplicationManager.getApplication();
|
||||
if (app == null ||
|
||||
if (ApplicationManager.getApplication() == null ||
|
||||
UISettings.getInstance() == null ||
|
||||
!SystemInfo.isWindows ||
|
||||
!Registry.is("actionSystem.win.suppressAlt") ||
|
||||
(!UISettings.getInstance().HIDE_TOOL_STRIPES && !UISettings.getInstance().PRESENTATION_MODE)) {
|
||||
!(UISettings.getInstance().HIDE_TOOL_STRIPES || UISettings.getInstance().PRESENTATION_MODE)) {
|
||||
return !dispatch;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ public class ActionInstallPlugin extends AnAction implements DumbAware {
|
||||
installedPluginsToModel(list);
|
||||
if (!installed.isDisposed()) {
|
||||
getPluginTable().updateUI();
|
||||
installed.setRequireShutdown(true);
|
||||
}
|
||||
else {
|
||||
boolean needToRestart = false;
|
||||
|
||||
@@ -13,16 +13,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.ide.plugins;
|
||||
|
||||
import com.intellij.ide.ClassUtilCore;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.idea.Main;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.components.ComponentConfig;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -30,7 +32,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -39,12 +41,11 @@ import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
*/
|
||||
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"}) // No logger is loaded at this time so we have to use these.
|
||||
public class PluginManager extends PluginManagerCore {
|
||||
@NonNls public static final String INSTALLED_TXT = "installed.txt";
|
||||
|
||||
@@ -55,93 +56,103 @@ public class PluginManager extends PluginManagerCore {
|
||||
/**
|
||||
* Called via reflection
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
@SuppressWarnings({"UnusedDeclaration", "HardCodedStringLiteral", "finally"})
|
||||
protected static void start(final String mainClass, final String methodName, final String[] args) {
|
||||
startupStart = System.nanoTime();
|
||||
try {
|
||||
//noinspection HardCodedStringLiteral
|
||||
ThreadGroup threadGroup = new ThreadGroup("Idea Thread Group") {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
if (!(e instanceof ProcessCanceledException)) {
|
||||
PluginManagerCore.getLogger().error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Main.setFlags(args);
|
||||
|
||||
if (!Main.isHeadless()) {
|
||||
UIUtil.initDefaultLAF();
|
||||
}
|
||||
|
||||
ThreadGroup threadGroup = new ThreadGroup("Idea Thread Group") {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
if (e instanceof StartupAbortedException) {
|
||||
StartupAbortedException se = (StartupAbortedException)e;
|
||||
try {
|
||||
ClassUtilCore.clearJarURLCache();
|
||||
|
||||
Class<?> aClass = Class.forName(mainClass);
|
||||
Method method = aClass.getDeclaredMethod(methodName, ArrayUtil.EMPTY_STRING_ARRAY.getClass());
|
||||
method.setAccessible(true);
|
||||
|
||||
//noinspection RedundantArrayCreation
|
||||
method.invoke(null, new Object[]{args});
|
||||
if (se.logError()) {
|
||||
if (Logger.isInitialized()) {
|
||||
getLogger().error(e);
|
||||
}
|
||||
Main.showMessage("Start Failed", e);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
String message = "Error while accessing " + mainClass + "." + methodName + " with arguments: " + Arrays.asList(args);
|
||||
if ("true".equals(System.getProperty("java.awt.headless"))) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.err.println(message);
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(null, message + ": " + e.getClass().getName() + ": " + e.getMessage() + "\n" + ExceptionUtil.getThrowableText(e), "Error starting IntelliJ Platform", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
finally {
|
||||
System.exit(se.exitCode());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//noinspection HardCodedStringLiteral
|
||||
new Thread(threadGroup, runnable, "Idea Main Thread").start();
|
||||
}
|
||||
catch (Exception e) {
|
||||
PluginManagerCore.getLogger().error(e);
|
||||
}
|
||||
if (!(e instanceof ProcessCanceledException)) {
|
||||
getLogger().error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ClassUtilCore.clearJarURLCache();
|
||||
|
||||
Class<?> aClass = Class.forName(mainClass);
|
||||
Method method = aClass.getDeclaredMethod(methodName, ArrayUtil.EMPTY_STRING_ARRAY.getClass());
|
||||
method.setAccessible(true);
|
||||
Object[] argsArray = {args};
|
||||
method.invoke(null, argsArray);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
throw new StartupAbortedException(t);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
new Thread(threadGroup, runnable, "Idea Main Thread").start();
|
||||
}
|
||||
|
||||
public static void reportPluginError() {
|
||||
if (myPluginError != null) {
|
||||
Notifications.Bus.notify(new Notification(IdeBundle.message("title.plugin.error"), IdeBundle.message("title.plugin.error"),
|
||||
myPluginError, NotificationType.ERROR, new NotificationListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
notification.expire();
|
||||
final String description = event.getDescription();
|
||||
if (EDIT.equals(description)) {
|
||||
final PluginManagerConfigurable configurable = new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
|
||||
IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null);
|
||||
ShowSettingsUtil.getInstance().editConfigurable((JFrame)ideFrame, configurable);
|
||||
return;
|
||||
}
|
||||
final List<String> disabledPlugins = PluginManagerCore.getDisabledPlugins();
|
||||
if (myPlugins2Disable != null && DISABLE.equals(description)) {
|
||||
for (String pluginId : myPlugins2Disable) {
|
||||
if (!disabledPlugins.contains(pluginId)) {
|
||||
disabledPlugins.add(pluginId);
|
||||
}
|
||||
}
|
||||
} else if (myPlugins2Enable != null && ENABLE.equals(description)) {
|
||||
disabledPlugins.removeAll(myPlugins2Enable);
|
||||
}
|
||||
try {
|
||||
PluginManagerCore.saveDisabledPlugins(disabledPlugins, false);
|
||||
}
|
||||
catch (IOException ignore) {
|
||||
}
|
||||
myPlugins2Enable = null;
|
||||
myPlugins2Disable = null;
|
||||
String message = IdeBundle.message("title.plugin.error");
|
||||
Notifications.Bus.notify(new Notification(message, message, myPluginError, NotificationType.ERROR, new NotificationListener() {
|
||||
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
notification.expire();
|
||||
|
||||
String description = event.getDescription();
|
||||
if (EDIT.equals(description)) {
|
||||
PluginManagerConfigurable configurable = new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
|
||||
IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null);
|
||||
ShowSettingsUtil.getInstance().editConfigurable((JFrame)ideFrame, configurable);
|
||||
return;
|
||||
}
|
||||
}));
|
||||
|
||||
List<String> disabledPlugins = getDisabledPlugins();
|
||||
if (myPlugins2Disable != null && DISABLE.equals(description)) {
|
||||
for (String pluginId : myPlugins2Disable) {
|
||||
if (!disabledPlugins.contains(pluginId)) {
|
||||
disabledPlugins.add(pluginId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (myPlugins2Enable != null && ENABLE.equals(description)) {
|
||||
disabledPlugins.removeAll(myPlugins2Enable);
|
||||
}
|
||||
|
||||
try {
|
||||
saveDisabledPlugins(disabledPlugins, false);
|
||||
}
|
||||
catch (IOException ignore) { }
|
||||
|
||||
myPlugins2Enable = null;
|
||||
myPlugins2Disable = null;
|
||||
}
|
||||
}));
|
||||
myPluginError = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isPluginInstalled(PluginId id) {
|
||||
return getPlugin(id) != null;
|
||||
}
|
||||
@@ -157,24 +168,59 @@ public class PluginManager extends PluginManagerCore {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void disableIncompatiblePlugin(final Object cause, final Throwable ex) {
|
||||
final PluginId pluginId = getPluginByClassName(cause.getClass().getName());
|
||||
if (pluginId != null && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
final boolean success = PluginManagerCore.disablePlugin(pluginId.getIdString());
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
|
||||
"Incompatible plugin detected: " + pluginId.getIdString() +
|
||||
(success ? "\nThe plugin has been disabled" : ""),
|
||||
"Plugin Manager",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
public static void handleComponentError(Throwable t, String componentClassName, ComponentConfig config) {
|
||||
if (t instanceof StartupAbortedException) {
|
||||
throw (StartupAbortedException)t;
|
||||
}
|
||||
|
||||
PluginId pluginId = config != null ? config.getPluginId() : getPluginByClassName(componentClassName);
|
||||
|
||||
if (pluginId != null && !CORE_PLUGIN_ID.equals(pluginId.getIdString())) {
|
||||
getLogger().warn(t);
|
||||
|
||||
disablePlugin(pluginId.getIdString());
|
||||
|
||||
String message =
|
||||
"Plugin '" + pluginId.getIdString() + "' failed to initialize and will be disabled\n" +
|
||||
"(reason: " + t.getMessage() + ")\n\n" +
|
||||
ApplicationNamesInfo.getInstance().getFullProductName() + " will be restarted.";
|
||||
Main.showMessage("Plugin Error", message, false);
|
||||
|
||||
throw new StartupAbortedException(t).exitCode(Main.PLUGIN_ERROR).logError(false);
|
||||
}
|
||||
else {
|
||||
// should never happen
|
||||
throw new RuntimeException(ex);
|
||||
throw new StartupAbortedException("Fatal error initializing '" + componentClassName + "'", t);
|
||||
}
|
||||
}
|
||||
|
||||
public static class StartupAbortedException extends RuntimeException {
|
||||
private int exitCode = Main.STARTUP_EXCEPTION;
|
||||
private boolean logError = true;
|
||||
|
||||
public StartupAbortedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public StartupAbortedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public int exitCode() {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
public StartupAbortedException exitCode(int exitCode) {
|
||||
this.exitCode = exitCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean logError() {
|
||||
return logError;
|
||||
}
|
||||
|
||||
public StartupAbortedException logError(boolean logError) {
|
||||
this.logError = logError;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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,8 +16,10 @@
|
||||
package com.intellij.ide.ui.laf;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.ColoredSideBorder;
|
||||
import com.intellij.ui.plaf.beg.*;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
|
||||
import com.sun.java.swing.plaf.windows.WindowsTreeUI;
|
||||
|
||||
@@ -38,7 +40,14 @@ public final class IdeaLaf extends MetalLookAndFeel {
|
||||
super.initComponentDefaults(defaults);
|
||||
LafManagerImpl.initInputMapDefaults(defaults);
|
||||
initIdeaDefaults(defaults);
|
||||
LafManagerImpl.initFontDefaults(defaults, "Tahoma", 11);
|
||||
|
||||
Pair<String, Integer> systemFont = UIUtil.getSystemFontData();
|
||||
if (systemFont != null) {
|
||||
LafManagerImpl.initFontDefaults(defaults, systemFont.first, systemFont.second);
|
||||
}
|
||||
else {
|
||||
LafManagerImpl.initFontDefaults(defaults, "Tahoma", 11);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
|
||||
@@ -23,13 +23,11 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import javax.swing.plaf.IconUIResource;
|
||||
import javax.swing.plaf.InsetsUIResource;
|
||||
import javax.swing.plaf.basic.BasicLookAndFeel;
|
||||
@@ -49,6 +47,7 @@ import java.util.Properties;
|
||||
public final class DarculaLaf extends BasicLookAndFeel {
|
||||
public static final String NAME = "Darcula";
|
||||
BasicLookAndFeel base;
|
||||
|
||||
public DarculaLaf() {
|
||||
try {
|
||||
if (SystemInfo.isWindows || SystemInfo.isLinux) {
|
||||
@@ -58,8 +57,8 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
base = (BasicLookAndFeel)Class.forName(name).newInstance();
|
||||
}
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
log(ignore);
|
||||
catch (Exception e) {
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +68,8 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
superMethod.setAccessible(true);
|
||||
superMethod.invoke(base, defaults);
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
log(ignore);
|
||||
catch (Exception e) {
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,19 +84,8 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
try {
|
||||
final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
|
||||
superMethod.setAccessible(true);
|
||||
final UIDefaults metalDefaults =
|
||||
(UIDefaults)superMethod.invoke(new MetalLookAndFeel());
|
||||
final UIDefaults metalDefaults = (UIDefaults)superMethod.invoke(new MetalLookAndFeel());
|
||||
final UIDefaults defaults = (UIDefaults)superMethod.invoke(base);
|
||||
if (SystemInfo.isLinux) {
|
||||
Font font = findFont("Ubuntu");
|
||||
if (font != null) {
|
||||
for (Object key : defaults.keySet()) {
|
||||
if (key instanceof String && ((String)key).endsWith(".font")) {
|
||||
defaults.put(key, new FontUIResource(font.deriveFont(15f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LafManagerImpl.initInputMapDefaults(defaults);
|
||||
initIdeaDefaults(defaults);
|
||||
@@ -108,21 +96,12 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
MetalLookAndFeel.setCurrentTheme(new DarculaMetalTheme());
|
||||
return defaults;
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
log(ignore);
|
||||
catch (Exception e) {
|
||||
log(e);
|
||||
}
|
||||
return super.getDefaults();
|
||||
}
|
||||
|
||||
private static Font findFont(String name) {
|
||||
for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) {
|
||||
if (font.getName().equals(name)) {
|
||||
return font;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void patchComboBox(UIDefaults metalDefaults, UIDefaults defaults) {
|
||||
defaults.remove("ComboBox.ancestorInputMap");
|
||||
defaults.remove("ComboBox.actionMap");
|
||||
@@ -294,7 +273,6 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
@@ -355,7 +333,6 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getSupportsWindowDecorations() {
|
||||
return true;
|
||||
|
||||
@@ -18,12 +18,12 @@ package com.intellij.idea;
|
||||
import com.intellij.ExtensionPoints;
|
||||
import com.intellij.Patches;
|
||||
import com.intellij.concurrency.JobScheduler;
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.AppLifecycleListener;
|
||||
import com.intellij.ide.CommandLineProcessor;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.ide.IdeRepaintManager;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.notification.NotificationDisplayType;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationType;
|
||||
@@ -36,10 +36,12 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.updateSettings.impl.UpdateChecker;
|
||||
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.impl.SystemDock;
|
||||
@@ -54,7 +56,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -79,14 +80,15 @@ public class IdeaApplication {
|
||||
myArgs = args;
|
||||
boolean isInternal = Boolean.valueOf(System.getProperty(IDEA_IS_INTERNAL_PROPERTY)).booleanValue();
|
||||
|
||||
if (Main.isCommandLine(args)) {
|
||||
boolean headless = Main.isHeadless(args);
|
||||
if (!headless) patchSystem();
|
||||
boolean headless = Main.isHeadless();
|
||||
if (!headless) {
|
||||
patchSystem();
|
||||
}
|
||||
|
||||
if (Main.isCommandLine()) {
|
||||
new CommandLineApplication(isInternal, false, headless);
|
||||
}
|
||||
else {
|
||||
patchSystem();
|
||||
|
||||
Splash splash = null;
|
||||
if (myArgs.length == 0) {
|
||||
myStarter = getStarter();
|
||||
@@ -159,15 +161,16 @@ public class IdeaApplication {
|
||||
|
||||
protected ApplicationStarter getStarter() {
|
||||
if (myArgs.length > 0) {
|
||||
PluginManager.getPlugins();
|
||||
PluginManagerCore.getPlugins();
|
||||
|
||||
ExtensionPoint<ApplicationStarter> point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.APPLICATION_STARTER);
|
||||
final ApplicationStarter[] starters = point.getExtensions();
|
||||
ApplicationStarter[] starters = point.getExtensions();
|
||||
String key = myArgs[0];
|
||||
for (ApplicationStarter o : starters) {
|
||||
if (Comparing.equal(o.getCommandName(), key)) return o;
|
||||
}
|
||||
}
|
||||
|
||||
return new IdeStarter();
|
||||
}
|
||||
|
||||
@@ -175,17 +178,9 @@ public class IdeaApplication {
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
public void run() throws Exception {
|
||||
ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
||||
try {
|
||||
app.load(PathManager.getOptionsPath());
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
app.load(PathManager.getOptionsPath());
|
||||
|
||||
myStarter.main(myArgs);
|
||||
myStarter = null; //GC it
|
||||
@@ -252,36 +247,28 @@ public class IdeaApplication {
|
||||
|
||||
@Override
|
||||
public void main(String[] args) {
|
||||
|
||||
SystemDock.updateMenu();
|
||||
|
||||
// Event queue should not be changed during initialization of application components.
|
||||
// It also cannot be changed before initialization of application components because IdeEventQueue uses other
|
||||
// application components. So it is proper to perform replacement only here.
|
||||
ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
||||
// app.setupIdeQueue(IdeEventQueue.getInstance());
|
||||
WindowManagerImpl windowManager = (WindowManagerImpl)WindowManager.getInstance();
|
||||
IdeEventQueue.getInstance().setWindowManager(windowManager);
|
||||
|
||||
try {
|
||||
IdeEventQueue.getInstance().setWindowManager(windowManager);
|
||||
Ref<Boolean> willOpenProject = new Ref<Boolean>(Boolean.FALSE);
|
||||
AppLifecycleListener lifecyclePublisher = app.getMessageBus().syncPublisher(AppLifecycleListener.TOPIC);
|
||||
lifecyclePublisher.appFrameCreated(args, willOpenProject);
|
||||
|
||||
final Ref<Boolean> willOpenProject = new Ref<Boolean>(Boolean.FALSE);
|
||||
final AppLifecycleListener lifecyclePublisher = app.getMessageBus().syncPublisher(AppLifecycleListener.TOPIC);
|
||||
lifecyclePublisher.appFrameCreated(args, willOpenProject);
|
||||
LOG.info("App initialization took " + (System.nanoTime() - PluginManager.startupStart) / 1000000 + " ms");
|
||||
PluginManager.dumpPluginClassStatistics();
|
||||
if (!willOpenProject.get()) {
|
||||
WelcomeFrame.showNow();
|
||||
lifecyclePublisher.welcomeScreenDisplayed();
|
||||
}
|
||||
else {
|
||||
windowManager.showFrame();
|
||||
}
|
||||
LOG.info("App initialization took " + (System.nanoTime() - PluginManager.startupStart) / 1000000 + " ms");
|
||||
PluginManagerCore.dumpPluginClassStatistics();
|
||||
|
||||
if (!willOpenProject.get()) {
|
||||
WelcomeFrame.showNow();
|
||||
lifecyclePublisher.welcomeScreenDisplayed();
|
||||
}
|
||||
catch (PluginException e) {
|
||||
Messages.showErrorDialog("Plugin " + e.getPluginId() + " couldn't be loaded, the IDE will now exit.\n" +
|
||||
"See the full details in the log.\n" +
|
||||
e.getMessage(), "Plugin Error");
|
||||
System.exit(-1);
|
||||
else {
|
||||
windowManager.showFrame();
|
||||
}
|
||||
|
||||
app.invokeLater(new Runnable() {
|
||||
@@ -321,7 +308,6 @@ public class IdeaApplication {
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loadProject() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -44,7 +44,6 @@ public class IdeaLogger extends Logger {
|
||||
|
||||
public static String ourLastActionId = "";
|
||||
|
||||
private final org.apache.log4j.Logger myLogger;
|
||||
/** If not null - it means that errors occurred and it is the first of them. */
|
||||
public static Exception ourErrorsOccurred;
|
||||
|
||||
@@ -59,25 +58,24 @@ public class IdeaLogger extends Logger {
|
||||
static {
|
||||
InputStream stream = Logger.class.getResourceAsStream(COMPILATION_TIMESTAMP_RESOURCE_NAME);
|
||||
if (stream != null) {
|
||||
LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream));
|
||||
try {
|
||||
String s = reader.readLine();
|
||||
if (s != null) {
|
||||
ourCompilationTimestamp = s.trim();
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
finally {
|
||||
LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream));
|
||||
try {
|
||||
stream.close();
|
||||
String s = reader.readLine();
|
||||
if (s != null) {
|
||||
ourCompilationTimestamp = s.trim();
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) { }
|
||||
}
|
||||
}
|
||||
|
||||
private final org.apache.log4j.Logger myLogger;
|
||||
|
||||
IdeaLogger(org.apache.log4j.Logger logger) {
|
||||
myLogger = logger;
|
||||
}
|
||||
@@ -134,9 +132,6 @@ public class IdeaLogger extends Logger {
|
||||
|
||||
myLogger.error(message + (!detailString.isEmpty() ? "\nDetails: " + detailString : ""), t);
|
||||
logErrorHeader();
|
||||
if (t != null && t.getCause() != null) {
|
||||
myLogger.error("Original exception: ", t.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
private void logErrorHeader() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -88,7 +88,7 @@ public class SocketLock {
|
||||
if (mySocket == null) {
|
||||
if (!myIsDialogShown) {
|
||||
final String productName = ApplicationNamesInfo.getInstance().getProductName();
|
||||
if (StartupUtil.isHeadless()) { //team server inspections
|
||||
if (Main.isHeadless()) { //team server inspections
|
||||
throw new RuntimeException("Only one instance of " + productName + " can be run at a time.");
|
||||
}
|
||||
@NonNls final String pathToLogFile = PathManager.getLogPath() + "/idea.log file".replace('/', File.separatorChar);
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
package com.intellij.idea;
|
||||
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.ide.startupWizard.StartupWizard;
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ConfigImportHelper;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
@@ -28,6 +29,7 @@ import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.win32.IdeaWin32;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.EnvironmentUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
@@ -41,7 +43,6 @@ import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -54,8 +55,6 @@ public class StartupUtil {
|
||||
|
||||
public static final boolean NO_SNAPPY = SystemProperties.getBooleanProperty("idea.no.snappy", false);
|
||||
|
||||
static boolean isHeadless;
|
||||
|
||||
private static SocketLock ourLock;
|
||||
private static String myDefaultLAF;
|
||||
|
||||
@@ -73,17 +72,55 @@ public class StartupUtil {
|
||||
return !Arrays.asList(args).contains(NO_SPLASH);
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Main#isHeadless()} (to remove in IDEA 14) */
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean isHeadless() {
|
||||
return isHeadless;
|
||||
return Main.isHeadless();
|
||||
}
|
||||
|
||||
private static void showError(final String title, final String message) {
|
||||
if (isHeadless()) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.out.println(message);
|
||||
public synchronized static void addExternalInstanceListener(Consumer<List<String>> consumer) {
|
||||
ourLock.setActivateListener(consumer);
|
||||
}
|
||||
|
||||
interface AppStarter {
|
||||
void start(boolean newConfigFolder);
|
||||
}
|
||||
|
||||
static void prepareAndStart(String[] args, AppStarter appStarter) {
|
||||
boolean newConfigFolder = false;
|
||||
|
||||
if (!Main.isHeadless()) {
|
||||
AppUIUtil.updateFrameClass();
|
||||
AppUIUtil.updateWindowIcon(JOptionPane.getRootFrame());
|
||||
AppUIUtil.registerBundledFonts();
|
||||
|
||||
newConfigFolder = PathManager.ensureConfigFolderExists(true);
|
||||
if (newConfigFolder) {
|
||||
ConfigImportHelper.importConfigsTo(PathManager.getConfigPath());
|
||||
}
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), message, title, JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
boolean canStart = checkJdkVersion() && checkSystemFolders() && lockSystemFolders(args); // note: uses config folder!
|
||||
if (!canStart) {
|
||||
System.exit(Main.STARTUP_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
Logger.setFactory(LoggerFactory.getInstance());
|
||||
Logger log = Logger.getInstance(Main.class);
|
||||
startLogging(log);
|
||||
fixProcessEnvironment(log);
|
||||
loadSystemLibraries(log);
|
||||
|
||||
appStarter.start(newConfigFolder);
|
||||
}
|
||||
|
||||
static void runStartupWizard() {
|
||||
final List<ApplicationInfoEx.PluginChooserPage> pages = ApplicationInfoImpl.getShadowInstance().getPluginChooserPages();
|
||||
if (!pages.isEmpty()) {
|
||||
final StartupWizard startupWizard = new StartupWizard(pages);
|
||||
startupWizard.setCancelText("Skip");
|
||||
startupWizard.show();
|
||||
PluginManagerCore.invalidatePlugins();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,17 +134,9 @@ public class StartupUtil {
|
||||
Class.forName("com.sun.jdi.Field");
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
showError("Error", "'tools.jar' is not in " + ApplicationNamesInfo.getInstance().getProductName() + " classpath.\n" +
|
||||
"Please ensure JAVA_HOME points to JDK rather than JRE.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!"true".equals(System.getProperty("idea.no.jdk.check"))) {
|
||||
final String version = System.getProperty("java.version");
|
||||
if (!SystemInfo.isJavaVersionAtLeast("1.6")) {
|
||||
showError("Java Version Mismatch", "The JDK version is " + version + ".\n" +
|
||||
ApplicationNamesInfo.getInstance().getProductName() + " requires JDK 1.6 or higher.");
|
||||
String message = "'tools.jar' seems to be not in " + ApplicationNamesInfo.getInstance().getProductName() + " classpath.\n" +
|
||||
"Please ensure JAVA_HOME points to JDK rather than JRE.";
|
||||
Main.showMessage("JDK Required", message, true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -117,18 +146,20 @@ public class StartupUtil {
|
||||
|
||||
private synchronized static boolean checkSystemFolders() {
|
||||
final String configPath = PathManager.getConfigPath();
|
||||
if (configPath == null || !new File(configPath).isDirectory()) {
|
||||
showError("Invalid config path", "Config path '" + configPath + "' is invalid.\n" +
|
||||
"If you have modified the 'idea.config.path' property please make sure it is correct,\n" +
|
||||
"otherwise please re-install the IDE.");
|
||||
if (!new File(configPath).isDirectory()) {
|
||||
String message = "Config path '" + configPath + "' is invalid.\n" +
|
||||
"If you have modified the 'idea.config.path' property please make sure it is correct,\n" +
|
||||
"otherwise please re-install the IDE.";
|
||||
Main.showMessage("Invalid Config Path", message, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String systemPath = PathManager.getSystemPath();
|
||||
if (systemPath == null || !new File(systemPath).isDirectory()) {
|
||||
showError("Invalid system path", "System path '" + systemPath + "' is invalid.\n" +
|
||||
"If you have modified the 'idea.system.path' property please make sure it is correct,\n" +
|
||||
"otherwise please re-install the IDE.");
|
||||
String message = "System path '" + systemPath + "' is invalid.\n" +
|
||||
"If you have modified the 'idea.system.path' property please make sure it is correct,\n" +
|
||||
"otherwise please re-install the IDE.";
|
||||
Main.showMessage("Invalid System Path", message, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,8 +177,9 @@ public class StartupUtil {
|
||||
}
|
||||
|
||||
if (activateStatus != SocketLock.ActivateStatus.NO_INSTANCE) {
|
||||
if (isHeadless() || activateStatus == SocketLock.ActivateStatus.CANNOT_ACTIVATE) {
|
||||
showError("Error", "Only one instance of " + ApplicationNamesInfo.getInstance().getFullProductName() + " can be run at a time.");
|
||||
if (Main.isHeadless() || activateStatus == SocketLock.ActivateStatus.CANNOT_ACTIVATE) {
|
||||
String message = "Only one instance of " + ApplicationNamesInfo.getInstance().getFullProductName() + " can be run at a time.";
|
||||
Main.showMessage("Too Many Instances", message, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -155,38 +187,16 @@ public class StartupUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean checkStartupPossible(String[] args) {
|
||||
return checkJdkVersion() &&
|
||||
checkSystemFolders() &&
|
||||
lockSystemFolders(args);
|
||||
}
|
||||
|
||||
static void runStartupWizard() {
|
||||
final List<ApplicationInfoEx.PluginChooserPage> pages = ApplicationInfoImpl.getShadowInstance().getPluginChooserPages();
|
||||
if (!pages.isEmpty()) {
|
||||
final StartupWizard startupWizard = new StartupWizard(pages);
|
||||
startupWizard.setCancelText("Skip");
|
||||
startupWizard.show();
|
||||
PluginManager.invalidatePlugins();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void addExternalInstanceListener(Consumer<List<String>> consumer) {
|
||||
ourLock.setActivateListener(consumer);
|
||||
}
|
||||
|
||||
|
||||
static void fixProcessEnvironment(Logger log) {
|
||||
private static void fixProcessEnvironment(Logger log) {
|
||||
boolean envReady = EnvironmentUtil.isEnvironmentReady(); // trigger environment loading
|
||||
if (!envReady) {
|
||||
log.info("initializing environment");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final String JAVA_IO_TEMP_DIR = "java.io.tmpdir";
|
||||
|
||||
static void loadSystemLibraries(final Logger log) {
|
||||
private static void loadSystemLibraries(final Logger log) {
|
||||
// load JNA and Snappy in own temp directory - to avoid collisions and work around no-exec /tmp
|
||||
final File ideaTempDir = new File(PathManager.getSystemPath(), "tmp");
|
||||
if (!(ideaTempDir.mkdirs() || ideaTempDir.exists())) {
|
||||
@@ -231,7 +241,7 @@ public class StartupUtil {
|
||||
IdeaWin32.isAvailable(); // logging is done there
|
||||
}
|
||||
|
||||
if (SystemInfo.isWin2kOrNewer && !isHeadless) {
|
||||
if (SystemInfo.isWin2kOrNewer && !Main.isHeadless()) {
|
||||
try {
|
||||
System.loadLibrary(SystemInfo.isAMD64 ? "focusKiller64" : "focusKiller");
|
||||
log.info("Using \"FocusKiller\" library to prevent focus stealing.");
|
||||
@@ -280,28 +290,25 @@ public class StartupUtil {
|
||||
loadNativeLibrary.invoke(null, loaderClass);
|
||||
}
|
||||
|
||||
public static void startLogging(final Logger log) {
|
||||
private static void startLogging(final Logger log) {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") {
|
||||
public void run() {
|
||||
log.info(
|
||||
"------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------");
|
||||
log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------");
|
||||
}
|
||||
});
|
||||
log.info(
|
||||
"------------------------------------------------------ IDE STARTED ------------------------------------------------------");
|
||||
log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------");
|
||||
|
||||
final ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance();
|
||||
final ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
|
||||
ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance();
|
||||
ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
|
||||
log.info("IDE: " + namesInfo.getFullProductName() + " (build #" + appInfo.getBuild() + ", " +
|
||||
DateFormatUtilRt.formatBuildDate(appInfo.getBuildDate()) + ")");
|
||||
log.info("OS: " + SystemInfoRt.OS_NAME + " (" + SystemInfoRt.OS_VERSION + ")");
|
||||
|
||||
log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")");
|
||||
log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.vendor", "-") + ")");
|
||||
|
||||
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
|
||||
List<String> arguments = RuntimemxBean.getInputArguments();
|
||||
|
||||
if (arguments != null) log.info("JVM Args: " + StringUtil.join(arguments, " "));
|
||||
List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
|
||||
if (arguments != null) {
|
||||
log.info("JVM Args: " + StringUtil.join(arguments, " "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-47
@@ -22,6 +22,7 @@ import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.*;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.idea.StartupUtil;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.*;
|
||||
@@ -37,7 +38,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -89,8 +89,8 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.application.impl.ApplicationImpl");
|
||||
private final ModalityState MODALITY_STATE_NONE = ModalityState.NON_MODAL;
|
||||
|
||||
// about writer preference: the way the java.util.concurrent.locks.ReentrantReadWriteLock.NonfairSync is implemented, the
|
||||
// writer thread will be always at the queue head and therefore, java.util.concurrent.locks.ReentrantReadWriteLock.NonfairSync.readerShouldBlock()
|
||||
// about writer preference: the way the j.u.c.l.ReentrantReadWriteLock.NonfairSync is implemented, the
|
||||
// writer thread will be always at the queue head and therefore, j.u.c.l.ReentrantReadWriteLock.NonfairSync.readerShouldBlock()
|
||||
// will return true if the write action is pending, exactly as we need
|
||||
private final ReentrantReadWriteLock myLock = new ReentrantReadWriteLock(false);
|
||||
|
||||
@@ -361,55 +361,25 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleInitComponentError(final Throwable ex, final boolean fatal, final String componentClassName, ComponentConfig config) {
|
||||
if (myHandlingInitComponentError) {
|
||||
return;
|
||||
}
|
||||
myHandlingInitComponentError = true;
|
||||
try {
|
||||
PluginId pluginId = config == null ? PluginManager.getPluginByClassName(componentClassName) : config.getPluginId();
|
||||
if (pluginId != null) {
|
||||
LOG.warn(ex);
|
||||
@NonNls final String errorMessage =
|
||||
"Plugin " + pluginId.getIdString() + " failed to initialize and will be disabled:\n" + ex.getMessage() +
|
||||
"\nPlease restart " + ApplicationNamesInfo.getInstance().getFullProductName() + ".";
|
||||
PluginManager.disablePlugin(pluginId.getIdString());
|
||||
if (!myHeadlessMode) {
|
||||
JOptionPane.showMessageDialog(null, errorMessage);
|
||||
}
|
||||
else if (!isUnitTestMode()) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.out.println(errorMessage);
|
||||
System.exit(1);
|
||||
}
|
||||
return; // do not call super
|
||||
protected void handleInitComponentError(Throwable t, String componentClassName, ComponentConfig config) {
|
||||
if (!myHandlingInitComponentError) {
|
||||
myHandlingInitComponentError = true;
|
||||
try {
|
||||
PluginManager.handleComponentError(t, componentClassName, config);
|
||||
}
|
||||
if (fatal) {
|
||||
LOG.error(ex);
|
||||
@NonNls final String errorMessage = "Fatal error initializing class " + componentClassName + ":\n" +
|
||||
StringUtil.trimLog(ex.toString(), 239) +
|
||||
"\nComplete error stacktrace was written to " + PathManager.getLogPath() + "/idea.log";
|
||||
if (!myHeadlessMode) {
|
||||
JOptionPane.showMessageDialog(null, errorMessage);
|
||||
}
|
||||
else {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.out.println(errorMessage);
|
||||
}
|
||||
finally {
|
||||
myHandlingInitComponentError = false;
|
||||
}
|
||||
super.handleInitComponentError(ex, fatal, componentClassName, config);
|
||||
}
|
||||
finally {
|
||||
myHandlingInitComponentError = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadApplicationComponents() {
|
||||
PluginManager.initPlugins(mySplash);
|
||||
final IdeaPluginDescriptor[] plugins = PluginManager.getPlugins();
|
||||
PluginManagerCore.initPlugins(mySplash);
|
||||
IdeaPluginDescriptor[] plugins = PluginManagerCore.getPlugins();
|
||||
for (IdeaPluginDescriptor plugin : plugins) {
|
||||
if (PluginManager.shouldSkipPlugin(plugin)) continue;
|
||||
loadComponentsConfiguration(plugin.getAppComponents(), plugin, false);
|
||||
if (!PluginManagerCore.shouldSkipPlugin(plugin)) {
|
||||
loadComponentsConfiguration(plugin.getAppComponents(), plugin, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +387,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
protected synchronized Object createComponent(Class componentInterface) {
|
||||
Object component = super.createComponent(componentInterface);
|
||||
if (mySplash != null) {
|
||||
mySplash.showProgress("", (float)(0.65f + getPercentageOfComponentsLoaded() * 0.35f));
|
||||
mySplash.showProgress("", 0.65f + getPercentageOfComponentsLoaded() * 0.35f);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
@@ -1440,7 +1410,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
public void run() {
|
||||
if (ex instanceof PluginException) {
|
||||
final PluginException pluginException = (PluginException)ex;
|
||||
PluginManager.disablePlugin(pluginException.getPluginId().getIdString());
|
||||
PluginManagerCore.disablePlugin(pluginException.getPluginId().getIdString());
|
||||
Messages.showMessageDialog("The plugin " +
|
||||
pluginException.getPluginId() +
|
||||
" failed to save settings and has been disabled. Please restart " +
|
||||
|
||||
+3
-5
@@ -149,12 +149,12 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
}
|
||||
};
|
||||
|
||||
for (final FileTypeFactory factory : Extensions.getExtensions(FileTypeFactory.FILE_TYPE_FACTORY_EP)) {
|
||||
for (FileTypeFactory factory : Extensions.getExtensions(FileTypeFactory.FILE_TYPE_FACTORY_EP)) {
|
||||
try {
|
||||
factory.createFileTypes(consumer);
|
||||
}
|
||||
catch (final Error ex) {
|
||||
PluginManager.disableIncompatiblePlugin(factory, ex);
|
||||
catch (Throwable t) {
|
||||
PluginManager.handleComponentError(t, factory.getClass().getName(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,6 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,7 +217,6 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
}
|
||||
|
||||
return new Document(root);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -319,7 +319,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
add(contentPane, BorderLayout.CENTER);
|
||||
setBorder(new InnerPanelBorder(myToolWindow));
|
||||
if (SystemInfo.isMac) {
|
||||
setBackground(Gray._200);
|
||||
setBackground(new JBColor(Gray._200, Gray._90));
|
||||
}
|
||||
|
||||
// Add listeners
|
||||
|
||||
@@ -15,77 +15,42 @@
|
||||
*/
|
||||
package com.intellij.idea;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ConfigImportHelper;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.text.DateFormatUtilRt;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.PlatformUtilsCore;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral", "UseOfSystemOutOrSystemErr", "UnusedDeclaration"})
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public class MainImpl {
|
||||
private static final String LOG_CATEGORY = "#com.intellij.idea.Main";
|
||||
|
||||
private MainImpl() { }
|
||||
|
||||
/**
|
||||
* Called from PluginManager via reflection.
|
||||
*/
|
||||
protected static void start(final String[] args) {
|
||||
System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, PlatformUtils.getPlatformPrefix(PlatformUtils.COMMUNITY_PREFIX));
|
||||
System.setProperty(PlatformUtilsCore.PLATFORM_PREFIX_KEY, PlatformUtils.getPlatformPrefix(PlatformUtils.COMMUNITY_PREFIX));
|
||||
|
||||
StartupUtil.isHeadless = Main.isHeadless(args);
|
||||
if (!StartupUtil.isHeadless) {
|
||||
AppUIUtil.updateFrameClass();
|
||||
AppUIUtil.updateWindowIcon(JOptionPane.getRootFrame());
|
||||
AppUIUtil.registerBundledFonts();
|
||||
|
||||
UIUtil.initDefaultLAF();
|
||||
|
||||
final boolean isNewConfigFolder = PathManager.ensureConfigFolderExists(true);
|
||||
if (isNewConfigFolder) {
|
||||
ConfigImportHelper.importConfigsTo(PathManager.getConfigPath());
|
||||
}
|
||||
}
|
||||
|
||||
if (!StartupUtil.checkStartupPossible(args)) { // It uses config folder!
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
Logger.setFactory(LoggerFactory.getInstance());
|
||||
|
||||
final Logger LOG = Logger.getInstance(LOG_CATEGORY);
|
||||
|
||||
StartupUtil.startLogging(LOG);
|
||||
|
||||
_main(args);
|
||||
}
|
||||
|
||||
protected static void _main(final String[] args) {
|
||||
// http://weblogs.java.net/blog/shan_man/archive/2005/06/improved_drag_g.html
|
||||
System.setProperty("sun.swing.enableImprovedDragGesture", "");
|
||||
|
||||
Logger LOG = Logger.getInstance(LOG_CATEGORY);
|
||||
StartupUtil.fixProcessEnvironment(LOG);
|
||||
StartupUtil.loadSystemLibraries(LOG);
|
||||
|
||||
startApplication(args);
|
||||
}
|
||||
|
||||
private static void startApplication(final String[] args) {
|
||||
final IdeaApplication app = new IdeaApplication(args);
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
app.run();
|
||||
StartupUtil.prepareAndStart(args, new StartupUtil.AppStarter() {
|
||||
@Override
|
||||
public void start(boolean newConfigFolder) {
|
||||
final IdeaApplication app = new IdeaApplication(args);
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
app.run();
|
||||
}
|
||||
catch (PluginManager.StartupAbortedException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
throw new PluginManager.StartupAbortedException(t);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ junit.runing.info.track.test.action.description=Select currently running test in
|
||||
junit.runing.info.collapse.test.action.name=Collapse all test suites
|
||||
junit.runing.info.expand.test.action.name=Expand all test suites
|
||||
junit.runing.info.select.first.failed.action.name=Select First Failed Test When Finished
|
||||
junit.runing.info.include.non.started.in.rerun.failed.action.name=Include Non-Started Tests into Rerun Failed
|
||||
junit.runing.info.scroll.to.stacktrace.action.name=Scroll to Stacktrace
|
||||
junit.runing.info.scroll.to.stacktrace.action.description=Scroll console to beginning of assertion or exception stacktrace
|
||||
junit.runing.info.open.source.at.exception.action.name=Open Source at Exception
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<extensionPoints>
|
||||
|
||||
<extensionPoint name="xml.startTagEndToken"
|
||||
interface="com.intellij.psi.xml.XmlChildRole$StartTagEndTokenProvider"/>
|
||||
interface="com.intellij.psi.xml.StartTagEndTokenProvider"/>
|
||||
<extensionPoint name="xml.schemaProvider"
|
||||
interface="com.intellij.xml.XmlSchemaProvider"/>
|
||||
<extensionPoint name="xml.xmlExtension"
|
||||
|
||||
+14
-9
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.testIntegration.TestLocationProvider;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -38,7 +39,6 @@ import javax.swing.*;
|
||||
* and name of test method
|
||||
*/
|
||||
public abstract class GeneralTestEventsProcessor implements Disposable {
|
||||
private boolean myDisposed = false;
|
||||
private TransferToEDTQueue<Runnable> myTransferToEDTQueue =
|
||||
new TransferToEDTQueue<Runnable>("SM queue", new Processor<Runnable>() {
|
||||
@Override
|
||||
@@ -99,16 +99,18 @@ public abstract class GeneralTestEventsProcessor implements Disposable {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myDisposed = true;
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myTransferToEDTQueue.drain();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public Condition getDisposedCondition() {
|
||||
return new Condition() {
|
||||
@Override
|
||||
public boolean value(Object o) {
|
||||
return myDisposed;
|
||||
}
|
||||
};
|
||||
return Condition.FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +121,10 @@ public abstract class GeneralTestEventsProcessor implements Disposable {
|
||||
*/
|
||||
public void addToInvokeLater(final Runnable runnable) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (application.isHeadlessEnvironment() && !application.isUnitTestMode() || SwingUtilities.isEventDispatchThread()) {
|
||||
final boolean unitTestMode = application.isUnitTestMode();
|
||||
if (unitTestMode) {
|
||||
UIUtil.invokeLaterIfNeeded(runnable);
|
||||
} else if (application.isHeadlessEnvironment() || SwingUtilities.isEventDispatchThread()) {
|
||||
runnable.run();
|
||||
}
|
||||
else {
|
||||
|
||||
+3
-15
@@ -59,14 +59,12 @@ public class ColumnDuration extends BaseColumn implements Comparator<SMTestProxy
|
||||
|
||||
@Override
|
||||
public TableCellRenderer getRenderer(final SMTestProxy proxy) {
|
||||
return new DurationCellRenderer(proxy);
|
||||
return new DurationCellRenderer();
|
||||
}
|
||||
|
||||
public static class DurationCellRenderer extends ColoredTableCellRenderer implements ColoredRenderer {
|
||||
private final SMTestProxy myProxy;
|
||||
|
||||
public DurationCellRenderer(final SMTestProxy proxy) {
|
||||
myProxy = proxy;
|
||||
public DurationCellRenderer() {
|
||||
}
|
||||
|
||||
public void customizeCellRenderer(final JTable table,
|
||||
@@ -77,17 +75,7 @@ public class ColumnDuration extends BaseColumn implements Comparator<SMTestProxy
|
||||
final int column) {
|
||||
assert value != null;
|
||||
|
||||
final String title = value.toString();
|
||||
|
||||
final SimpleTextAttributes attributes;
|
||||
if (myProxy.isSuite() && ColumnTest.TestsCellRenderer.isFirstLine(row)) {
|
||||
//Black bold for parent suite of items in statistics
|
||||
attributes = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
|
||||
} else {
|
||||
//Black, regular for other suites and tests
|
||||
attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
|
||||
}
|
||||
append(title, attributes);
|
||||
append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-28
@@ -51,19 +51,10 @@ public class ColumnTest extends BaseColumn implements Comparator<SMTestProxy>{
|
||||
|
||||
@Override
|
||||
public TableCellRenderer getRenderer(final SMTestProxy proxy) {
|
||||
return new TestsCellRenderer(proxy);
|
||||
return new TestsCellRenderer();
|
||||
}
|
||||
|
||||
public static class TestsCellRenderer extends ColoredTableCellRenderer implements ColoredRenderer {
|
||||
@NonNls private static final String TOTAL_TITLE = SMTestsRunnerBundle.message("sm.test.runner.ui.tabs.statistics.columns.test.total.title");
|
||||
@NonNls private static final String PARENT_TITLE = "..";
|
||||
|
||||
private final SMTestProxy myProxy;
|
||||
|
||||
public TestsCellRenderer(final SMTestProxy proxy) {
|
||||
myProxy = proxy;
|
||||
}
|
||||
|
||||
public void customizeCellRenderer(final JTable table,
|
||||
final Object value,
|
||||
final boolean selected,
|
||||
@@ -72,24 +63,7 @@ public class ColumnTest extends BaseColumn implements Comparator<SMTestProxy>{
|
||||
final int column) {
|
||||
assert value != null;
|
||||
|
||||
final String title = value.toString();
|
||||
//Black bold for with caption "Total" for parent suite of items in statistics
|
||||
if (myProxy.isSuite() && isFirstLine(row)) {
|
||||
if (myProxy.getParent() == null) {
|
||||
append(TOTAL_TITLE, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
}
|
||||
else {
|
||||
append(PARENT_TITLE, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
append(" (" + myProxy.getName() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//Black, regular for other suites and tests
|
||||
append(title, SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
public static boolean isFirstLine(final int row) {
|
||||
return row == 0;
|
||||
append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-13
@@ -219,19 +219,10 @@ public class StatisticsPanel implements DataProvider {
|
||||
final int i = myStatisticsTableView.getSelectedRow();
|
||||
assert i >= 0; //because something is selected
|
||||
|
||||
// If first line is selected we should go to parent suite
|
||||
if (ColumnTest.TestsCellRenderer.isFirstLine(i)) {
|
||||
final SMTestProxy parentSuite = selectedProxy.getParent();
|
||||
if (parentSuite != null) {
|
||||
// go to parent and current suit in it
|
||||
showInTableAndSelectRow(parentSuite, selectedProxy);
|
||||
}
|
||||
} else {
|
||||
// if selected element is suite - we should expand it
|
||||
if (selectedProxy.isSuite()) {
|
||||
// expand and select first (Total) row
|
||||
showInTableAndSelectRow(selectedProxy, selectedProxy);
|
||||
}
|
||||
// if selected element is suite - we should expand it
|
||||
if (selectedProxy.isSuite()) {
|
||||
// expand and select first (Total) row
|
||||
showInTableAndSelectRow(selectedProxy, selectedProxy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+1
-3
@@ -37,7 +37,7 @@ public class StatisticsTableModel extends ListTableModel<SMTestProxy> {
|
||||
|
||||
public StatisticsTableModel() {
|
||||
super(new ColumnTest(), new ColumnDuration(), new ColumnResults());
|
||||
setSortable(false); // TODO: fix me
|
||||
setSortable(true);
|
||||
}
|
||||
|
||||
public void updateModelOnProxySelected(final SMTestProxy proxy) {
|
||||
@@ -95,8 +95,6 @@ public class StatisticsTableModel extends ListTableModel<SMTestProxy> {
|
||||
}
|
||||
|
||||
final List<SMTestProxy> list = new ArrayList<SMTestProxy>();
|
||||
// suite's total statistics
|
||||
list.add(suite);
|
||||
// chiled's statistics
|
||||
list.addAll(suite.getChildren());
|
||||
|
||||
|
||||
+2
-2
@@ -258,7 +258,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
public void testTotal_TotalSuite() {
|
||||
doRender(mySuite, 0);
|
||||
assertFragmentsSize(1);
|
||||
assertEquals(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0));
|
||||
assertEquals(SimpleTextAttributes.REGULAR_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0));
|
||||
assertEquals(myColumn.valueOf(mySuite), myFragmentsContainer.getTextAt(0));
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
|
||||
public MyRenderer(final SMTestProxy proxy,
|
||||
final UITestUtil.FragmentsContainer fragmentsContainer) {
|
||||
super(proxy);
|
||||
super();
|
||||
myFragmentsContainer = fragmentsContainer;
|
||||
}
|
||||
|
||||
|
||||
+3
-8
@@ -90,18 +90,13 @@ public class ColumnTestTest extends BaseColumnRenderingTest {
|
||||
final SMTestProxy newRootSuite = createSuiteProxy("root_suite");
|
||||
mySuite.setParent(newRootSuite);
|
||||
doRender(mySuite, 0);
|
||||
assertFragmentsSize(2);
|
||||
assertEquals(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0));
|
||||
assertEquals("..", myFragmentsContainer.getTextAt(0));
|
||||
assertEquals(SimpleTextAttributes.GRAYED_ATTRIBUTES, myFragmentsContainer.getAttribsAt(1));
|
||||
assertEquals(" (suite)", myFragmentsContainer.getTextAt(1));
|
||||
assertFragmentsSize(1);
|
||||
}
|
||||
|
||||
public void testTotal_TotalRootSuite() {
|
||||
doRender(mySuite, 0);
|
||||
assertFragmentsSize(1);
|
||||
assertEquals(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0));
|
||||
assertEquals("Total:", myFragmentsContainer.getTextAt(0));
|
||||
assertEquals(SimpleTextAttributes.REGULAR_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,7 +115,7 @@ public class ColumnTestTest extends BaseColumnRenderingTest {
|
||||
|
||||
public MyRenderer(final SMTestProxy proxy,
|
||||
final UITestUtil.FragmentsContainer fragmentsContainer) {
|
||||
super(proxy);
|
||||
super();
|
||||
myFragmentsContainer = fragmentsContainer;
|
||||
}
|
||||
|
||||
|
||||
+32
-56
@@ -73,7 +73,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
// show suite in table
|
||||
myStatisticsPanel.selectProxy(suite1);
|
||||
// selects row that corresponds to test1
|
||||
myStatisticsPanel.selectRow(1);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
|
||||
// Check that necessary row is selected
|
||||
assertEquals(test1, myStatisticsPanel.getSelectedItem());
|
||||
@@ -84,7 +84,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
// Check that current suite in table wasn't changed.
|
||||
// For it let's select Total row and check selected object
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(test1, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testGotoSuite_OnSuite() {
|
||||
@@ -95,18 +95,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
// show root suite in table
|
||||
myStatisticsPanel.selectProxy(rootSuite);
|
||||
// selects row that corresponds to suite1
|
||||
myStatisticsPanel.selectRow(1);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
|
||||
// Check that necessary row is selected
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
// Perform action on suite
|
||||
myStatisticsPanel.createGotoSuiteOrParentAction().run();
|
||||
|
||||
// Check that current suite in table was changed.
|
||||
// For it let's select Total row and check selected object
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testGotoParentSuite_Total() {
|
||||
@@ -117,24 +110,14 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
// show suite in table
|
||||
myStatisticsPanel.selectProxy(suite1);
|
||||
// selects Total row
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEmpty(myStatisticsPanel.getTableItems());
|
||||
|
||||
// Check that necessary row is selected
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
// Perform action on suite
|
||||
myStatisticsPanel.createGotoSuiteOrParentAction().run();
|
||||
|
||||
// Check that current suite in table was changed.
|
||||
// For it let's select Total row and check selected object
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(rootSuite, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testGotoParentSuite_TotalRoot() {
|
||||
// create test sturcure
|
||||
final SMTestProxy rootSuite = createSuiteProxy("rootSuite");
|
||||
createSuiteProxy("suite1", rootSuite);
|
||||
final SMTestProxy suite1 = createSuiteProxy("suite1", rootSuite);
|
||||
|
||||
// show root suite in table
|
||||
myStatisticsPanel.selectProxy(rootSuite);
|
||||
@@ -142,15 +125,8 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
myStatisticsPanel.selectRow(0);
|
||||
|
||||
// Check that necessary row is selected
|
||||
assertEquals(rootSuite, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
// Perform action on suite
|
||||
myStatisticsPanel.createGotoSuiteOrParentAction().run();
|
||||
|
||||
// Check that current suite in table wasn't changed.
|
||||
// For it let's select Total row and check selected object
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(rootSuite, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testChangeSelectionListener() {
|
||||
@@ -165,7 +141,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
//suite
|
||||
myStatisticsPanel.selectProxy(suite1);
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(null, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testChangeSelectionAction() {
|
||||
@@ -190,7 +166,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
//on test
|
||||
myStatisticsPanel.selectProxy(suite1);
|
||||
myStatisticsPanel.selectRow(1);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(test1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
myStatisticsPanel.showSelectedProxyInTestsTree();
|
||||
@@ -205,7 +181,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
focusRequestedRef.set(null);
|
||||
|
||||
myStatisticsPanel.selectProxy(rootSuite);
|
||||
myStatisticsPanel.selectRow(1);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
myStatisticsPanel.showSelectedProxyInTestsTree();
|
||||
@@ -221,11 +197,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
myStatisticsPanel.selectProxy(rootSuite);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(rootSuite, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
myStatisticsPanel.showSelectedProxyInTestsTree();
|
||||
assertTrue(onSelectedHappend.isSet());
|
||||
assertEquals(rootSuite, proxyRef.get());
|
||||
assertEquals(suite1, proxyRef.get());
|
||||
assertTrue(focusRequestedRef.get());
|
||||
}
|
||||
|
||||
@@ -244,24 +220,24 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
final SMTestProxy test1 = createTestProxy("test1", suite);
|
||||
final SMTestProxy test2 = createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteStarted(suite);
|
||||
assertSameElements(getItems(), suite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSuiteStarted_Child() {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
final SMTestProxy test1 = createTestProxy("test1", suite);
|
||||
final SMTestProxy test2 = createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteStarted(test1);
|
||||
assertSameElements(getItems(), suite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSuiteStarted_Other() {
|
||||
@@ -269,12 +245,12 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy other_suite = createSuiteProxy("other_suite", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
createTestProxy("test1", suite);
|
||||
createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteStarted(other_suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
}
|
||||
|
||||
public void testOnSuiteFinished_NoCurrent() {
|
||||
@@ -292,24 +268,24 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
final SMTestProxy test1 = createTestProxy("test1", suite);
|
||||
final SMTestProxy test2 = createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteFinished(suite);
|
||||
assertSameElements(getItems(), suite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSuiteFinished_Child() {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
final SMTestProxy test1 = createTestProxy("test1", suite);
|
||||
final SMTestProxy test2 = createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteFinished(test1);
|
||||
assertSameElements(getItems(), suite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSuiteFinished_Other() {
|
||||
@@ -317,12 +293,12 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy other_suite = createSuiteProxy("other_suite", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
createTestProxy("test1", suite);
|
||||
createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteFinished(other_suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
}
|
||||
|
||||
public void testOnTestStarted_NoCurrent() {
|
||||
@@ -340,11 +316,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy test1 = createTestProxy("test1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1);
|
||||
assertSameElements(getItems(),test1);
|
||||
|
||||
final SMTestProxy test2 = createTestProxy("test2", myRootSuite);
|
||||
myTestEventsListener.onTestStarted(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnTestStarted_Other() {
|
||||
@@ -354,11 +330,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy other_test = createTestProxy("other_test", suite);
|
||||
|
||||
myStatisticsPanel.selectProxy(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1, suite);
|
||||
assertSameElements(getItems(), test1, suite);
|
||||
|
||||
createTestProxy("test2", myRootSuite);
|
||||
myTestEventsListener.onTestStarted(other_test);
|
||||
assertSameElements(getItems(), myRootSuite, test1, suite);
|
||||
assertSameElements(getItems(), test1, suite);
|
||||
}
|
||||
|
||||
public void testOnTestFinished_NoCurrent() {
|
||||
@@ -377,11 +353,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy test1 = createTestProxy("test1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1);
|
||||
assertSameElements(getItems(), test1);
|
||||
|
||||
final SMTestProxy test2 = createTestProxy("test2", myRootSuite);
|
||||
myTestEventsListener.onTestFinished(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnTestFinished_Other() {
|
||||
@@ -391,11 +367,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy other_test = createTestProxy("other_test", suite);
|
||||
|
||||
myStatisticsPanel.selectProxy(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1, suite);
|
||||
assertSameElements(getItems(), test1, suite);
|
||||
|
||||
createTestProxy("test2", myRootSuite);
|
||||
myTestEventsListener.onTestFinished(other_test);
|
||||
assertSameElements(getItems(), myRootSuite, test1, suite);
|
||||
assertSameElements(getItems(), test1, suite);
|
||||
}
|
||||
|
||||
public void testSelectionRestoring_ForTest() {
|
||||
@@ -417,7 +393,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
myTestEventsListener.onSuiteStarted(suite);
|
||||
|
||||
assertEquals(myRootSuite, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(null, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
private List<SMTestProxy> getItems() {
|
||||
|
||||
+5
-4
@@ -18,6 +18,7 @@ package com.intellij.execution.testframework.sm.runner.ui.statistics;
|
||||
import com.intellij.execution.testframework.sm.runner.BaseSMTRunnerTestCase;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -47,7 +48,7 @@ public class SMTRunnerStatisticsTableModelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy test2 = createTestProxy("test2", myRootSuite);
|
||||
myStatisticsTableModel.updateModelOnProxySelected(test1);
|
||||
|
||||
assertSameElements(getItems(), myRootSuite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSelected_Suite() {
|
||||
@@ -58,13 +59,13 @@ public class SMTRunnerStatisticsTableModelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy suite2 = createSuiteProxy("suite2", myRootSuite);
|
||||
|
||||
myStatisticsTableModel.updateModelOnProxySelected(suite1);
|
||||
assertSameElements(getItems(), suite1, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
|
||||
myStatisticsTableModel.updateModelOnProxySelected(suite2);
|
||||
assertSameElements(getItems(), suite2);
|
||||
assertSameElements(getItems());
|
||||
|
||||
myStatisticsTableModel.updateModelOnProxySelected(myRootSuite);
|
||||
assertSameElements(getItems(), myRootSuite, suite1, suite2);
|
||||
assertSameElements(getItems(), suite1, suite2);
|
||||
}
|
||||
/*
|
||||
public void testSort_ColumnTest() {
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.io.ZipUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -66,6 +67,7 @@ import java.awt.event.InvocationEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.*;
|
||||
@@ -769,4 +771,11 @@ public class PlatformTestUtil {
|
||||
public static String loadFileText(@NotNull String fileName) throws IOException {
|
||||
return StringUtil.convertLineSeparators(FileUtil.loadFile(new File(fileName)));
|
||||
}
|
||||
|
||||
public static void tryGcSoftlyReachableObjects() {
|
||||
List<Object> list = ContainerUtil.newArrayList();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
list.add(new SoftReference<byte[]>(new byte[(int)Runtime.getRuntime().freeMemory() / 2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -50,6 +50,7 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
public static final BooleanProperty OPEN_FAILURE_LINE = new BooleanProperty("openFailureLine", true);
|
||||
public static final BooleanProperty TRACK_CODE_COVERAGE = new BooleanProperty("trackCodeCoverage", false);
|
||||
public static final BooleanProperty SHOW_STATISTICS = new BooleanProperty("showStatistics", false);
|
||||
public static final BooleanProperty INCLUDE_NON_STARTED_IN_RERUN_FAILED = new BooleanProperty("includeNonStarted", true);
|
||||
|
||||
private final Project myProject;
|
||||
private final Executor myExecutor;
|
||||
|
||||
+3
@@ -150,6 +150,9 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
|
||||
|
||||
@NotNull
|
||||
protected Filter getFilter(Project project, GlobalSearchScope searchScope) {
|
||||
if (TestConsoleProperties.INCLUDE_NON_STARTED_IN_RERUN_FAILED.value(myConsoleProperties)) {
|
||||
return Filter.NOT_PASSED.or(Filter.FAILED_OR_INTERRUPTED);
|
||||
}
|
||||
return Filter.FAILED_OR_INTERRUPTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -26,17 +26,23 @@ public abstract class Logger {
|
||||
Logger getLoggerInstance(String category);
|
||||
}
|
||||
|
||||
public static Factory ourFactory = new Factory() {
|
||||
private static class DefaultFactory implements Factory {
|
||||
@Override
|
||||
public Logger getLoggerInstance(String category) {
|
||||
return new DefaultLogger(category);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Factory ourFactory = new DefaultFactory();
|
||||
|
||||
public static void setFactory(Factory factory) {
|
||||
ourFactory = factory;
|
||||
}
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return !(ourFactory instanceof DefaultFactory);
|
||||
}
|
||||
|
||||
public static Logger getInstance(@NonNls String category) {
|
||||
return ourFactory.getLoggerInstance(category);
|
||||
}
|
||||
@@ -48,9 +54,29 @@ public abstract class Logger {
|
||||
public abstract boolean isDebugEnabled();
|
||||
|
||||
public abstract void debug(@NonNls String message);
|
||||
|
||||
public abstract void debug(@Nullable Throwable t);
|
||||
|
||||
public abstract void debug(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public void info(@NotNull Throwable t) {
|
||||
info(t.getMessage(), t);
|
||||
}
|
||||
|
||||
public abstract void info(@NonNls String message);
|
||||
|
||||
public abstract void info(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public void warn(@NonNls String message) {
|
||||
warn(message, null);
|
||||
}
|
||||
|
||||
public void warn(@NotNull Throwable t) {
|
||||
warn(t.getMessage(), t);
|
||||
}
|
||||
|
||||
public abstract void warn(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public void error(@NonNls String message) {
|
||||
error(message, new Throwable(), ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
}
|
||||
@@ -70,27 +96,8 @@ public abstract class Logger {
|
||||
error(t.getMessage(), t, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
}
|
||||
|
||||
public void warn(@NonNls String message) {
|
||||
warn(message, null);
|
||||
}
|
||||
|
||||
public void warn(@NotNull Throwable t) {
|
||||
warn(t.getMessage(), t);
|
||||
}
|
||||
|
||||
|
||||
public abstract void error(@NonNls String message, @Nullable Throwable t, @NonNls @NotNull String... details);
|
||||
|
||||
public abstract void info(@NonNls String message);
|
||||
|
||||
public abstract void info(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public abstract void warn(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public void info(@NotNull Throwable t) {
|
||||
info(t.getMessage(), t);
|
||||
}
|
||||
|
||||
public boolean assertTrue(boolean value, @NonNls Object message) {
|
||||
if (!value) {
|
||||
@NonNls StringBuilder resultMessage = new StringBuilder("Assertion failed");
|
||||
@@ -107,5 +114,4 @@ public abstract class Logger {
|
||||
}
|
||||
|
||||
public abstract void setLevel(Level level);
|
||||
|
||||
}
|
||||
|
||||
@@ -220,13 +220,12 @@ public class UIUtil {
|
||||
if (ourRetina.isNull()) {
|
||||
ourRetina.set(false); // in case HiDPIScaledImage.drawIntoImage is not called for some reason
|
||||
|
||||
String vendor = SystemProperties.getJavaVmVendor();
|
||||
if (SystemInfo.isJavaVersionAtLeast("1.6.0_33") && vendor != null && StringUtil.containsIgnoreCase(vendor, "Apple")) {
|
||||
if (SystemInfo.isJavaVersionAtLeast("1.6.0_33") && SystemInfo.isAppleJvm) {
|
||||
if (!"false".equals(System.getProperty("ide.mac.retina"))) {
|
||||
ourRetina.set(IsRetina.isRetina());
|
||||
return ourRetina.get();
|
||||
}
|
||||
} else if (SystemInfo.isJavaVersionAtLeast("1.7.0_40") && vendor != null && StringUtil.containsIgnoreCase(vendor, "Oracle")) {
|
||||
} else if (SystemInfo.isJavaVersionAtLeast("1.7.0_40") && SystemInfo.isOracleJvm) {
|
||||
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
final GraphicsDevice device = env.getDefaultScreenDevice();
|
||||
try {
|
||||
@@ -1496,11 +1495,7 @@ public class UIUtil {
|
||||
|
||||
public static BufferedImage createImage(int width, int height, int type) {
|
||||
if (isRetina()) {
|
||||
if (SystemInfo.isAppleJvm) {
|
||||
return RetinaImage.create(width, height, type);
|
||||
} else if (SystemInfo.isOracleJvm) {
|
||||
//todo[kb] provide some hidpi scaled image
|
||||
}
|
||||
return RetinaImage.create(width, height, type);
|
||||
}
|
||||
//noinspection UndesirableClassUsage
|
||||
return new BufferedImage(width, height, type);
|
||||
|
||||
@@ -160,8 +160,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
DefaultActionGroup leftToolbar = new DefaultActionGroup();
|
||||
final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
|
||||
if (runner != null && env != null) {
|
||||
RestartAction restartAction = new RestartAction(executor, runner, myRunContentDescriptor.getProcessHandler(),
|
||||
myRunContentDescriptor, env);
|
||||
RestartAction restartAction = new RestartAction(executor, runner, myRunContentDescriptor, env);
|
||||
leftToolbar.add(restartAction);
|
||||
restartAction.registerShortcut(myUi.getComponent());
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.intellij.lang.xml.XmlASTFactory;
|
||||
import com.intellij.openapi.application.PluginPathManager;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.psi.xml.XmlChildRole;
|
||||
import com.intellij.psi.xml.StartTagEndTokenProvider;
|
||||
import com.intellij.testFramework.ParsingTestCase;
|
||||
|
||||
public class AntParsingTest extends ParsingTestCase {
|
||||
@@ -36,8 +36,8 @@ public class AntParsingTest extends ParsingTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
addExplicitExtension(LanguageASTFactory.INSTANCE, XMLLanguage.INSTANCE, new XmlASTFactory());
|
||||
registerExtensionPoint(new ExtensionPointName<XmlChildRole.StartTagEndTokenProvider>("com.intellij.xml.startTagEndToken"),
|
||||
XmlChildRole.StartTagEndTokenProvider.class);
|
||||
registerExtensionPoint(new ExtensionPointName<StartTagEndTokenProvider>("com.intellij.xml.startTagEndToken"),
|
||||
StartTagEndTokenProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package git4idea.branch;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
@@ -35,7 +36,6 @@ import git4idea.merge.GitMergeCommittingConflictResolver;
|
||||
import git4idea.merge.GitMerger;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.util.GitPreservingProcess;
|
||||
import git4idea.util.GitUIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
@@ -275,9 +275,9 @@ class GitMergeOperation extends GitBranchOperation {
|
||||
}
|
||||
}
|
||||
|
||||
LOG.info("for smart rollback: " + GitUIUtil.getShortNames(repositoriesForSmartRollback) +
|
||||
"; for simple rollback: " + GitUIUtil.getShortNames(repositoriesForSimpleRollback) +
|
||||
"; for merge rollback: " + GitUIUtil.getShortNames(repositoriesForMergeRollback));
|
||||
LOG.info("for smart rollback: " + DvcsUtil.getShortNames(repositoriesForSmartRollback) +
|
||||
"; for simple rollback: " + DvcsUtil.getShortNames(repositoriesForSimpleRollback) +
|
||||
"; for merge rollback: " + DvcsUtil.getShortNames(repositoriesForMergeRollback));
|
||||
|
||||
GitCompoundResult result = smartRollback(repositoriesForSmartRollback);
|
||||
for (GitRepository repository : repositoriesForSimpleRollback) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package git4idea.push;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.actionSystem.CommonShortcuts;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
@@ -34,7 +35,6 @@ import git4idea.GitBranch;
|
||||
import git4idea.GitCommit;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.util.GitUIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -362,7 +362,7 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider {
|
||||
renderer.setToolTipText(getHashString(commit) + " " + getDateString(commit));
|
||||
}
|
||||
else if (userObject instanceof GitRepository) {
|
||||
String repositoryPath = GitUIUtil.getShortRepositoryName((GitRepository)userObject);
|
||||
String repositoryPath = DvcsUtil.getShortRepositoryName((GitRepository)userObject);
|
||||
renderer.append(repositoryPath, SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
}
|
||||
else if (userObject instanceof GitPushBranchInfo) {
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellij.dvcs.DvcsUtil.joinRootsPaths;
|
||||
import static com.intellij.openapi.util.text.StringUtil.pluralize;
|
||||
import static git4idea.util.GitUIUtil.joinRootsPaths;
|
||||
|
||||
/**
|
||||
* @author Kirill Likhodedov
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package git4idea.ui;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.util.GitUIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class GitRepositoryComboboxListCellRenderer extends ListCellRendererWrapp
|
||||
|
||||
@Override
|
||||
public void customize(JList list, GitRepository value, int index, boolean selected, boolean hasFocus) {
|
||||
setText(GitUIUtil.getShortRepositoryName(value));
|
||||
setText(DvcsUtil.getShortRepositoryName(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,54 +15,44 @@
|
||||
*/
|
||||
package git4idea.ui.branch;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.dvcs.ui.BranchActionGroupPopup;
|
||||
import com.intellij.dvcs.ui.RootAction;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.ui.ErrorLabel;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.panels.OpaquePanel;
|
||||
import com.intellij.ui.popup.PopupFactoryImpl;
|
||||
import com.intellij.ui.popup.WizardPopup;
|
||||
import com.intellij.ui.popup.list.ListPopupImpl;
|
||||
import com.intellij.ui.popup.list.PopupListElementRenderer;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.branch.GitBranchUtil;
|
||||
import git4idea.config.GitVcsSettings;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryManager;
|
||||
import git4idea.util.GitUIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The popup which allows to quickly switch and control Git branches.
|
||||
* The popup which allows to quickly switch and control Git branches.
|
||||
* </p>
|
||||
* <p>
|
||||
* Use {@link #asListPopup()} to achieve the {@link ListPopup} itself.
|
||||
* Use {@link #asListPopup()} to achieve the {@link ListPopup} itself.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
class GitBranchPopup {
|
||||
class GitBranchPopup {
|
||||
|
||||
private final Project myProject;
|
||||
private final GitRepositoryManager myRepositoryManager;
|
||||
@@ -121,7 +111,7 @@ class GitBranchPopup {
|
||||
}
|
||||
};
|
||||
|
||||
myPopup = new GitBranchActionGroupPopup(title, project, preselectActionCondition);
|
||||
myPopup = new BranchActionGroupPopup(title, project, preselectActionCondition, createActions());
|
||||
|
||||
initBranchSyncPolicyIfNotInitialized();
|
||||
setCurrentBranchInfo();
|
||||
@@ -145,7 +135,7 @@ class GitBranchPopup {
|
||||
String title = "Git Branches";
|
||||
if (myRepositoryManager.moreThanOneRoot() &&
|
||||
(myMultiRootBranchConfig.diverged() || myVcsSettings.getSyncSetting() == GitBranchSyncSetting.DONT)) {
|
||||
title += " in " + GitUIUtil.getShortRepositoryName(currentRepository);
|
||||
title += " in " + DvcsUtil.getShortRepositoryName(currentRepository);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
@@ -154,7 +144,7 @@ class GitBranchPopup {
|
||||
String currentBranchText = "Current branch";
|
||||
if (myRepositoryManager.moreThanOneRoot()) {
|
||||
if (myMultiRootBranchConfig.diverged()) {
|
||||
currentBranchText += " in " + GitUIUtil.getShortRepositoryName(myCurrentRepository) + ": " +
|
||||
currentBranchText += " in " + DvcsUtil.getShortRepositoryName(myCurrentRepository) + ": " +
|
||||
GitBranchUtil.getDisplayableBranchText(myCurrentRepository);
|
||||
}
|
||||
else {
|
||||
@@ -196,7 +186,7 @@ class GitBranchPopup {
|
||||
else {
|
||||
fillPopupWithCurrentRepositoryActions(popupGroup, createRepositoriesActions());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
fillPopupWithCurrentRepositoryActions(popupGroup, null);
|
||||
}
|
||||
@@ -213,7 +203,7 @@ class GitBranchPopup {
|
||||
List<GitRepository> repositories = repositoryManager.getRepositories();
|
||||
String currentBranch = myMultiRootBranchConfig.getCurrentBranch();
|
||||
assert currentBranch != null : "Current branch can't be null if branches have not diverged";
|
||||
popupGroup.add(new GitBranchPopupActions.NewBranchAction(myProject, repositories));
|
||||
popupGroup.add(new GitBranchPopupActions.GitNewBranchAction(myProject, repositories));
|
||||
|
||||
popupGroup.addAll(createRepositoriesActions());
|
||||
|
||||
@@ -240,7 +230,10 @@ class GitBranchPopup {
|
||||
DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
|
||||
popupGroup.addSeparator("Repositories");
|
||||
for (GitRepository repository : myRepositoryManager.getRepositories()) {
|
||||
popupGroup.add(new RootAction(repository, highlightCurrentRepo() ? myCurrentRepository : null));
|
||||
popupGroup.add(new RootAction<GitRepository>(repository, highlightCurrentRepo() ? myCurrentRepository : null,
|
||||
new GitBranchPopupActions(repository.getProject(), repository).createActions(null),
|
||||
GitBranchUtil.getDisplayableBranchText(repository),
|
||||
GitBranchUtil.getBranchNameOrRev(repository)));
|
||||
}
|
||||
return popupGroup;
|
||||
}
|
||||
@@ -252,117 +245,4 @@ class GitBranchPopup {
|
||||
private void fillPopupWithCurrentRepositoryActions(@NotNull DefaultActionGroup popupGroup, @Nullable DefaultActionGroup actions) {
|
||||
popupGroup.addAll(new GitBranchPopupActions(myCurrentRepository.getProject(), myCurrentRepository).createActions(actions));
|
||||
}
|
||||
|
||||
private static class RootAction extends ActionGroup {
|
||||
|
||||
private final GitRepository myRepository;
|
||||
|
||||
/**
|
||||
* @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then.
|
||||
*/
|
||||
RootAction(@NotNull GitRepository repository, @Nullable GitRepository currentRepository) {
|
||||
super(GitUIUtil.getShortRepositoryName(repository), true);
|
||||
myRepository = repository;
|
||||
if (repository.equals(currentRepository)) {
|
||||
getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
ActionGroup group = new GitBranchPopupActions(myRepository.getProject(), myRepository).createActions(null);
|
||||
return group.getChildren(e);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getCaption() {
|
||||
return "Current branch in " + GitUIUtil.getShortRepositoryName(myRepository) + ": " +
|
||||
GitBranchUtil.getDisplayableBranchText(myRepository);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getBranch() {
|
||||
return GitBranchUtil.getBranchNameOrRev(myRepository);
|
||||
}
|
||||
}
|
||||
|
||||
private class GitBranchActionGroupPopup extends PopupFactoryImpl.ActionGroupPopup {
|
||||
public GitBranchActionGroupPopup(@NotNull String title, @NotNull Project project,
|
||||
@NotNull Condition<AnAction> preselectActionCondition) {
|
||||
super(title, GitBranchPopup.this.createActions(), SimpleDataContext.getProjectContext(project), false, false, false, true, null, -1,
|
||||
preselectActionCondition, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WizardPopup createPopup(WizardPopup parent, PopupStep step, Object parentValue) {
|
||||
WizardPopup popup = super.createPopup(parent, step, parentValue);
|
||||
RootAction rootAction = getRootAction(parentValue);
|
||||
if (rootAction != null) {
|
||||
popup.setAdText((rootAction).getCaption());
|
||||
}
|
||||
return popup;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RootAction getRootAction(Object value) {
|
||||
if (value instanceof PopupFactoryImpl.ActionItem) {
|
||||
AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction();
|
||||
if (action instanceof RootAction) {
|
||||
return (RootAction)action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListCellRenderer getListElementRenderer() {
|
||||
return new PopupListElementRenderer(this) {
|
||||
|
||||
private ErrorLabel myBranchLabel;
|
||||
|
||||
@Override
|
||||
protected void customizeComponent(JList list, Object value, boolean isSelected) {
|
||||
super.customizeComponent(list, value, isSelected);
|
||||
|
||||
RootAction rootAction = getRootAction(value);
|
||||
if (rootAction != null) {
|
||||
myBranchLabel.setVisible(true);
|
||||
myBranchLabel.setText(String.format("[%s]", rootAction.getBranch()));
|
||||
|
||||
if (isSelected) {
|
||||
setSelected(myBranchLabel);
|
||||
}
|
||||
else {
|
||||
myBranchLabel.setBackground(getBackground());
|
||||
myBranchLabel.setForeground(JBColor.GRAY); // different foreground than for other elements
|
||||
}
|
||||
|
||||
adjustOpacity(myBranchLabel, isSelected);
|
||||
}
|
||||
else {
|
||||
myBranchLabel.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createItemComponent() {
|
||||
myTextLabel = new ErrorLabel();
|
||||
myTextLabel.setOpaque(true);
|
||||
myTextLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
|
||||
|
||||
myBranchLabel = new ErrorLabel();
|
||||
myBranchLabel.setOpaque(true);
|
||||
myBranchLabel.setBorder(BorderFactory.createEmptyBorder(1, UIUtil.DEFAULT_HGAP, 1, 1));
|
||||
|
||||
JPanel compoundPanel = new OpaquePanel(new BorderLayout(), Color.white);
|
||||
compoundPanel.add(myTextLabel, BorderLayout.CENTER);
|
||||
compoundPanel.add(myBranchLabel, BorderLayout.EAST);
|
||||
|
||||
return layoutComponent(compoundPanel);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,16 +15,15 @@
|
||||
*/
|
||||
package git4idea.ui.branch;
|
||||
|
||||
import com.intellij.dvcs.ui.NewBranchAction;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.util.IconUtil;
|
||||
import git4idea.GitBranch;
|
||||
import git4idea.branch.GitBranchUtil;
|
||||
import git4idea.branch.GitBrancher;
|
||||
@@ -43,7 +42,6 @@ import java.util.List;
|
||||
*/
|
||||
class GitBranchPopupActions {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(GitBranchPopupActions.class);
|
||||
private final Project myProject;
|
||||
private final GitRepository myRepository;
|
||||
|
||||
@@ -55,7 +53,7 @@ class GitBranchPopupActions {
|
||||
ActionGroup createActions(@Nullable DefaultActionGroup toInsert) {
|
||||
DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
|
||||
|
||||
popupGroup.addAction(new NewBranchAction(myProject, Collections.singletonList(myRepository)));
|
||||
popupGroup.addAction(new GitNewBranchAction(myProject,Collections.singletonList(myRepository)));
|
||||
popupGroup.addAction(new CheckoutRevisionActions(myProject, myRepository));
|
||||
|
||||
if (toInsert != null) {
|
||||
@@ -80,15 +78,11 @@ class GitBranchPopupActions {
|
||||
|
||||
return popupGroup;
|
||||
}
|
||||
|
||||
static class NewBranchAction extends DumbAwareAction {
|
||||
private final Project myProject;
|
||||
private final List<GitRepository> myRepositories;
|
||||
|
||||
NewBranchAction(@NotNull Project project, @NotNull List<GitRepository> repositories) {
|
||||
super("New Branch", "Create and checkout new branch", IconUtil.getAddIcon());
|
||||
myProject = project;
|
||||
myRepositories = repositories;
|
||||
public static class GitNewBranchAction extends NewBranchAction<GitRepository> {
|
||||
|
||||
public GitNewBranchAction(@NotNull Project project, @NotNull List<GitRepository> repositories) {
|
||||
super(project, repositories);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,23 +93,6 @@ class GitBranchPopupActions {
|
||||
brancher.checkoutNewBranch(name, myRepositories);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
if (anyRepositoryIsFresh()) {
|
||||
e.getPresentation().setEnabled(false);
|
||||
e.getPresentation().setDescription("Checkout of a new branch is not possible before the first commit.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean anyRepositoryIsFresh() {
|
||||
for (GitRepository repository : myRepositories) {
|
||||
if (repository.isFresh()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package git4idea.ui.branch;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
@@ -22,7 +23,6 @@ import com.intellij.ui.TabbedPaneImpl;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.util.GitCommitCompareInfo;
|
||||
import git4idea.util.GitUIUtil;
|
||||
import icons.Git4ideaIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class GitCompareBranchesDialog extends DialogWrapper {
|
||||
|
||||
String rootString;
|
||||
if (compareInfo.getRepositories().size() == 1 && GitUtil.getRepositoryManager(myProject).moreThanOneRoot()) {
|
||||
rootString = " in root " + GitUIUtil.getShortRepositoryName(initialRepo);
|
||||
rootString = " in root " + DvcsUtil.getShortRepositoryName(initialRepo);
|
||||
}
|
||||
else {
|
||||
rootString = "";
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package git4idea.update;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -351,7 +352,7 @@ public class GitFetcher {
|
||||
StringBuilder info = new StringBuilder();
|
||||
if (myRepositoryManager.moreThanOneRoot()) {
|
||||
for (Map.Entry<VirtualFile, String> entry : additionalInfo.entrySet()) {
|
||||
info.append(entry.getValue()).append(" in ").append(GitUIUtil.getShortRepositoryName(myProject, entry.getKey())).append("<br/>");
|
||||
info.append(entry.getValue()).append(" in ").append(DvcsUtil.getShortRepositoryName(myProject, entry.getKey())).append("<br/>");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -23,10 +23,8 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.AbstractVcsHelper;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.util.Function;
|
||||
import git4idea.GitBranch;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.GitVcs;
|
||||
@@ -39,7 +37,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -393,43 +390,4 @@ public class GitUIUtil {
|
||||
return String.format("<%2$s>%1$s</%2$s>", s, tag);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getShortRepositoryName(@NotNull Project project, @NotNull VirtualFile root) {
|
||||
VirtualFile projectDir = project.getBaseDir();
|
||||
|
||||
String repositoryPath = root.getPresentableUrl();
|
||||
if (projectDir != null) {
|
||||
String relativePath = VfsUtilCore.getRelativePath(root, projectDir, File.separatorChar);
|
||||
if (relativePath != null) {
|
||||
repositoryPath = relativePath;
|
||||
}
|
||||
}
|
||||
|
||||
return repositoryPath.isEmpty() ? root.getName() : repositoryPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getShortRepositoryName(@NotNull GitRepository repository) {
|
||||
return getShortRepositoryName(repository.getProject(), repository.getRoot());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getShortNames(@NotNull Collection<GitRepository> repositories) {
|
||||
return StringUtil.join(repositories, new Function<GitRepository, String>() {
|
||||
@Override
|
||||
public String fun(GitRepository repository) {
|
||||
return getShortRepositoryName(repository);
|
||||
}
|
||||
}, ", ");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String joinRootsPaths(@NotNull Collection<VirtualFile> roots) {
|
||||
return StringUtil.join(roots, new Function<VirtualFile, String>() {
|
||||
@Override
|
||||
public String fun(VirtualFile virtualFile) {
|
||||
return virtualFile.getPresentableUrl();
|
||||
}
|
||||
}, ", ");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.plugins.gradle.settings;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -44,7 +45,7 @@ public class GradleExecutionSettings extends ExternalSystemExecutionSettings {
|
||||
@Nullable private String myJavaHome;
|
||||
|
||||
public GradleExecutionSettings(@Nullable String gradleHome, @Nullable String serviceDirectory, boolean wrapper) {
|
||||
this(gradleHome, serviceDirectory, wrapper, SystemProperties.getIntProperty("gradle.daemon.xmx.mb", 512));
|
||||
this(gradleHome, serviceDirectory, wrapper, SystemProperties.getIntProperty("gradle.daemon.xmx.mb", SystemInfo.is32Bit ? 512 : 1024));
|
||||
}
|
||||
|
||||
public GradleExecutionSettings(@Nullable String gradleHome, @Nullable String serviceDirectory, boolean wrapper, int daemonXmx) {
|
||||
|
||||
@@ -15,25 +15,17 @@
|
||||
*/
|
||||
package org.zmlx.hg4idea.action;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.dvcs.ui.BranchActionGroupPopup;
|
||||
import com.intellij.dvcs.ui.RootAction;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ErrorLabel;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.panels.OpaquePanel;
|
||||
import com.intellij.ui.popup.PopupFactoryImpl;
|
||||
import com.intellij.ui.popup.WizardPopup;
|
||||
import com.intellij.ui.popup.list.ListPopupImpl;
|
||||
import com.intellij.ui.popup.list.PopupListElementRenderer;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.repo.HgRepository;
|
||||
@@ -41,7 +33,6 @@ import org.zmlx.hg4idea.repo.HgRepositoryImpl;
|
||||
import org.zmlx.hg4idea.util.HgUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -82,9 +73,7 @@ public class HgBranchPopup {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
myPopup = new HgBranchActionGroupPopup(title, project, preselectActionCondition);
|
||||
|
||||
myPopup = new BranchActionGroupPopup(title, project, preselectActionCondition, createActions());
|
||||
setCurrentBranchInfo();
|
||||
}
|
||||
|
||||
@@ -92,9 +81,7 @@ public class HgBranchPopup {
|
||||
@NotNull
|
||||
private static String createPopupTitle(@NotNull HgRepository currentRepository) {
|
||||
String title = "Hg Branches";
|
||||
|
||||
title += " in " + currentRepository.getRoot().getName();
|
||||
|
||||
title += " in " + DvcsUtil.getShortRepositoryName(currentRepository);
|
||||
return title;
|
||||
}
|
||||
|
||||
@@ -119,126 +106,16 @@ public class HgBranchPopup {
|
||||
popupGroup.addSeparator("Repositories");
|
||||
for (VirtualFile repository : HgUtil.getHgRepositories(myProject)) {
|
||||
HgRepository repo = HgRepositoryImpl.getFullInstance(repository, myProject, myProject);
|
||||
popupGroup.add(new RootAction(repo, null));
|
||||
popupGroup.add(new RootAction<HgRepository>(repo, null,
|
||||
new HgBranchPopupActions(repo.getProject(), repo).createActions(null),
|
||||
HgUtil.getDisplayableBranchText(repo),
|
||||
repo.getCurrentBranch()));
|
||||
}
|
||||
return popupGroup;
|
||||
}
|
||||
|
||||
|
||||
private void fillPopupWithCurrentRepositoryActions(@NotNull DefaultActionGroup popupGroup, @Nullable DefaultActionGroup actions) {
|
||||
protected void fillPopupWithCurrentRepositoryActions(@NotNull DefaultActionGroup popupGroup, @Nullable DefaultActionGroup actions) {
|
||||
popupGroup.addAll(new HgBranchPopupActions(myProject, myCurrentRepository).createActions(actions));
|
||||
}
|
||||
|
||||
private static class RootAction extends ActionGroup {
|
||||
|
||||
private final HgRepository myRepository;
|
||||
|
||||
/**
|
||||
* @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then.
|
||||
*/
|
||||
RootAction(@NotNull HgRepository repository, @Nullable HgRepository currentRepository) {
|
||||
super(repository.getRoot().getName(), true);
|
||||
myRepository = repository;
|
||||
if (repository.equals(currentRepository)) {
|
||||
getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
ActionGroup group = new HgBranchPopupActions(myRepository.getProject(), myRepository).createActions(null);
|
||||
return group.getChildren(e);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getCaption() {
|
||||
String captionText = "Current branch in " + myRepository.getRoot().getName() + ": ";
|
||||
return captionText + HgUtil.getDisplayableBranchText(myRepository);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getBranch() {
|
||||
return myRepository.getCurrentBranch();
|
||||
}
|
||||
}
|
||||
|
||||
private class HgBranchActionGroupPopup extends PopupFactoryImpl.ActionGroupPopup {
|
||||
public HgBranchActionGroupPopup(@NotNull String title, @NotNull Project project,
|
||||
@NotNull Condition<AnAction> preselectActionCondition) {
|
||||
super(title, HgBranchPopup.this.createActions(), SimpleDataContext.getProjectContext(project), false, false, false, true, null, -1,
|
||||
preselectActionCondition, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WizardPopup createPopup(WizardPopup parent, PopupStep step, Object parentValue) {
|
||||
WizardPopup popup = super.createPopup(parent, step, parentValue);
|
||||
RootAction rootAction = getRootAction(parentValue);
|
||||
if (rootAction != null) {
|
||||
popup.setAdText((rootAction).getCaption());
|
||||
}
|
||||
return popup;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RootAction getRootAction(Object value) {
|
||||
if (value instanceof PopupFactoryImpl.ActionItem) {
|
||||
AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction();
|
||||
if (action instanceof RootAction) {
|
||||
return (RootAction)action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListCellRenderer getListElementRenderer() {
|
||||
return new PopupListElementRenderer(this) {
|
||||
|
||||
private ErrorLabel myBranchLabel;
|
||||
|
||||
@Override
|
||||
protected void customizeComponent(JList list, Object value, boolean isSelected) {
|
||||
super.customizeComponent(list, value, isSelected);
|
||||
|
||||
RootAction rootAction = getRootAction(value);
|
||||
if (rootAction != null) {
|
||||
myBranchLabel.setVisible(true);
|
||||
myBranchLabel.setText(String.format("[%s]", rootAction.getBranch()));
|
||||
|
||||
if (isSelected) {
|
||||
setSelected(myBranchLabel);
|
||||
}
|
||||
else {
|
||||
myBranchLabel.setBackground(getBackground());
|
||||
myBranchLabel.setForeground(JBColor.GRAY); // different foreground than for other elements
|
||||
}
|
||||
|
||||
adjustOpacity(myBranchLabel, isSelected);
|
||||
}
|
||||
else {
|
||||
myBranchLabel.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createItemComponent() {
|
||||
myTextLabel = new ErrorLabel();
|
||||
myTextLabel.setOpaque(true);
|
||||
myTextLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
|
||||
|
||||
myBranchLabel = new ErrorLabel();
|
||||
myBranchLabel.setOpaque(true);
|
||||
myBranchLabel.setBorder(BorderFactory.createEmptyBorder(1, UIUtil.DEFAULT_HGAP, 1, 1));
|
||||
|
||||
JPanel compoundPanel = new OpaquePanel(new BorderLayout(), Color.white);
|
||||
compoundPanel.add(myTextLabel, BorderLayout.CENTER);
|
||||
compoundPanel.add(myBranchLabel, BorderLayout.EAST);
|
||||
|
||||
return layoutComponent(compoundPanel);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.zmlx.hg4idea.action;
|
||||
|
||||
import com.intellij.dvcs.ui.NewBranchAction;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -23,7 +24,6 @@ import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.update.UpdatedFiles;
|
||||
import com.intellij.util.IconUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.HgRevisionNumber;
|
||||
@@ -59,7 +59,7 @@ public class HgBranchPopupActions {
|
||||
|
||||
ActionGroup createActions(@Nullable DefaultActionGroup toInsert) {
|
||||
DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
|
||||
popupGroup.addAction(new NewBranchAction(myProject, Collections.singletonList(myRepository)));
|
||||
popupGroup.addAction(new HgNewBranchAction(myProject, Collections.singletonList(myRepository)));
|
||||
|
||||
if (toInsert != null) {
|
||||
popupGroup.addAll(toInsert);
|
||||
@@ -76,14 +76,10 @@ public class HgBranchPopupActions {
|
||||
return popupGroup;
|
||||
}
|
||||
|
||||
static class NewBranchAction extends DumbAwareAction {
|
||||
private final Project myProject;
|
||||
private final List<HgRepository> myRepositories;
|
||||
public static class HgNewBranchAction extends NewBranchAction<HgRepository> {
|
||||
|
||||
NewBranchAction(@NotNull Project project, @NotNull List<HgRepository> repositories) {
|
||||
super("New Branch", "Create and checkout new branch", IconUtil.getAddIcon());
|
||||
myProject = project;
|
||||
myRepositories = repositories;
|
||||
HgNewBranchAction(@NotNull Project project, @NotNull List<HgRepository> repositories) {
|
||||
super(project, repositories);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,23 +102,6 @@ public class HgBranchPopupActions {
|
||||
HgAbstractGlobalAction.handleException(myProject, exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
if (anyRepositoryIsFresh()) {
|
||||
e.getPresentation().setEnabled(false);
|
||||
e.getPresentation().setDescription("Checkout of a new branch is not possible before the first commit.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean anyRepositoryIsFresh() {
|
||||
for (HgRepository repository : myRepositories) {
|
||||
if (repository.isFresh()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.execution.junit2.ui.actions;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
|
||||
import com.intellij.execution.configurations.RunnerSettings;
|
||||
@@ -27,10 +28,12 @@ import com.intellij.execution.testframework.TestFrameworkRunningModel;
|
||||
import com.intellij.execution.testframework.TestsUIUtil;
|
||||
import com.intellij.execution.testframework.ToolbarPanel;
|
||||
import com.intellij.execution.testframework.actions.ScrollToTestSourceAction;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.config.ToggleBooleanProperty;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -45,6 +48,20 @@ public class JUnitToolbarPanel extends ToolbarPanel {
|
||||
super(properties, runnerSettings, configurationSettings, parentComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendAdditionalActions(DefaultActionGroup actionGroup,
|
||||
TestConsoleProperties properties,
|
||||
RunnerSettings runnerSettings,
|
||||
ConfigurationPerRunnerSettings configurationSettings,
|
||||
JComponent parent) {
|
||||
super.appendAdditionalActions(actionGroup, properties, runnerSettings, configurationSettings, parent);
|
||||
actionGroup.addAction(new ToggleBooleanProperty(
|
||||
ExecutionBundle.message("junit.runing.info.include.non.started.in.rerun.failed.action.name"),
|
||||
null,
|
||||
null,
|
||||
properties, TestConsoleProperties.INCLUDE_NON_STARTED_IN_RERUN_FAILED)).setAsSecondary(true);
|
||||
}
|
||||
|
||||
|
||||
public void setModel(final TestFrameworkRunningModel model) {
|
||||
super.setModel(model);
|
||||
|
||||
@@ -23,11 +23,13 @@
|
||||
package com.theoryinpractice.testng.ui;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
|
||||
import com.intellij.execution.configurations.RunnerSettings;
|
||||
import com.intellij.execution.testframework.*;
|
||||
import com.intellij.execution.testframework.actions.ScrollToTestSourceAction;
|
||||
import com.intellij.execution.testframework.ui.TestResultsPanel;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.util.ColorProgressBar;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -41,6 +43,7 @@ import com.intellij.ui.DoubleClickListener;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.table.TableView;
|
||||
import com.intellij.util.OpenSourceUtil;
|
||||
import com.intellij.util.config.ToggleBooleanProperty;
|
||||
import com.theoryinpractice.testng.configuration.TestNGConfiguration;
|
||||
import com.theoryinpractice.testng.model.*;
|
||||
import com.theoryinpractice.testng.util.TestNGUtil;
|
||||
@@ -148,7 +151,21 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
|
||||
|
||||
@Override
|
||||
protected ToolbarPanel createToolbarPanel() {
|
||||
final ToolbarPanel panel = new ToolbarPanel(getProperties(), myRunnerSettings, myConfigurationSettings, this);
|
||||
final ToolbarPanel panel = new ToolbarPanel(getProperties(), myRunnerSettings, myConfigurationSettings, this){
|
||||
@Override
|
||||
protected void appendAdditionalActions(DefaultActionGroup actionGroup,
|
||||
TestConsoleProperties properties,
|
||||
RunnerSettings runnerSettings,
|
||||
ConfigurationPerRunnerSettings configurationSettings,
|
||||
JComponent parent) {
|
||||
super.appendAdditionalActions(actionGroup, properties, runnerSettings, configurationSettings, parent);
|
||||
actionGroup.addAction(new ToggleBooleanProperty(
|
||||
ExecutionBundle.message("junit.runing.info.include.non.started.in.rerun.failed.action.name"),
|
||||
null,
|
||||
null,
|
||||
properties, TestConsoleProperties.INCLUDE_NON_STARTED_IN_RERUN_FAILED)).setAsSecondary(true);
|
||||
}
|
||||
};
|
||||
panel.setModel(this);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.util.xml.impl;
|
||||
|
||||
import com.intellij.ide.highlighter.DomSupportEnabled;
|
||||
import com.intellij.ide.startup.StartupManagerEx;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -57,36 +69,44 @@ import java.util.Set;
|
||||
*/
|
||||
public final class DomManagerImpl extends DomManager {
|
||||
private static final Key<Object> MOCK = Key.create("MockElement");
|
||||
|
||||
static final Key<WeakReference<DomFileElementImpl>> CACHED_FILE_ELEMENT = Key.create("CACHED_FILE_ELEMENT");
|
||||
static final Key<DomFileDescription> MOCK_DESCRIPTION = Key.create("MockDescription");
|
||||
|
||||
static final SemKey<FileDescriptionCachedValueProvider> FILE_DESCRIPTION_KEY = SemKey.createKey("FILE_DESCRIPTION_KEY");
|
||||
public static final SemKey<DomInvocationHandler> DOM_HANDLER_KEY = SemKey.createKey("DOM_HANDLER_KEY");
|
||||
static final SemKey<DomInvocationHandler> DOM_HANDLER_KEY = SemKey.createKey("DOM_HANDLER_KEY");
|
||||
static final SemKey<IndexedElementInvocationHandler> DOM_INDEXED_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_INDEXED_HANDLER_KEY");
|
||||
static final SemKey<CollectionElementInvocationHandler> DOM_COLLECTION_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_COLLECTION_HANDLER_KEY");
|
||||
static final SemKey<CollectionElementInvocationHandler> DOM_CUSTOM_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_CUSTOM_HANDLER_KEY");
|
||||
static final SemKey<AttributeChildInvocationHandler> DOM_ATTRIBUTE_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_ATTRIBUTE_HANDLER_KEY");
|
||||
|
||||
private final EventDispatcher<DomEventListener> myListeners = EventDispatcher.create(DomEventListener.class);
|
||||
private final ConverterManagerImpl myConverterManager;
|
||||
|
||||
private final GenericValueReferenceProvider myGenericValueReferenceProvider = new GenericValueReferenceProvider();
|
||||
|
||||
private final Project myProject;
|
||||
private final SemService mySemService;
|
||||
private final ConverterManager myConverterManager;
|
||||
private final DomApplicationComponent myApplicationComponent;
|
||||
private final PsiFileFactory myFileFactory;
|
||||
private final ProjectFileIndex myFileIndex;
|
||||
|
||||
private long myModificationCount;
|
||||
private boolean myChanging;
|
||||
private final ProjectFileIndex myFileIndex;
|
||||
private final SemService mySemService;
|
||||
|
||||
public DomManagerImpl(final Project project, final XmlAspect xmlAspect) {
|
||||
public DomManagerImpl(Project project,
|
||||
final XmlAspect xmlAspect,
|
||||
SemService semService,
|
||||
ConverterManager converterManager,
|
||||
DomApplicationComponent appComponent,
|
||||
PsiFileFactory fileFactory,
|
||||
ProjectFileIndex fileIndex) {
|
||||
myProject = project;
|
||||
mySemService = SemService.getSemService(project);
|
||||
myConverterManager = (ConverterManagerImpl)ServiceManager.getService(ConverterManager.class);
|
||||
myApplicationComponent = DomApplicationComponent.getInstance();
|
||||
final PomModel pomModel = PomManager.getModel(project);
|
||||
mySemService = semService;
|
||||
myConverterManager = converterManager;
|
||||
myApplicationComponent = appComponent;
|
||||
myFileFactory = fileFactory;
|
||||
myFileIndex = fileIndex;
|
||||
|
||||
PomModel pomModel = PomManager.getModel(project);
|
||||
pomModel.addModelListener(new PomModelListener() {
|
||||
public void modelChanged(PomModelEvent event) {
|
||||
final XmlChangeSet changeSet = (XmlChangeSet)event.getChangeSet(xmlAspect);
|
||||
@@ -105,11 +125,7 @@ public final class DomManagerImpl extends DomManager {
|
||||
}
|
||||
}, project);
|
||||
|
||||
myFileFactory = PsiFileFactory.getInstance(project);
|
||||
|
||||
final PsiManager psiManager = PsiManager.getInstance(project);
|
||||
|
||||
final Runnable setupVfsListeners = new Runnable() {
|
||||
Runnable setupVfsListeners = new Runnable() {
|
||||
public void run() {
|
||||
final VirtualFileAdapter listener = new VirtualFileAdapter() {
|
||||
private final List<DomEvent> myDeletionEvents = new SmartList<DomEvent>();
|
||||
@@ -125,7 +141,7 @@ public final class DomManagerImpl extends DomManager {
|
||||
}
|
||||
|
||||
public void beforeFileDeletion(final VirtualFileEvent event) {
|
||||
if (!project.isDisposed()) {
|
||||
if (!myProject.isDisposed()) {
|
||||
beforeFileDeletion(event.getFile());
|
||||
}
|
||||
}
|
||||
@@ -148,7 +164,7 @@ public final class DomManagerImpl extends DomManager {
|
||||
|
||||
public void fileDeleted(VirtualFileEvent event) {
|
||||
if (!myDeletionEvents.isEmpty()) {
|
||||
if (!project.isDisposed()) {
|
||||
if (!myProject.isDisposed()) {
|
||||
for (DomEvent domEvent : myDeletionEvents) {
|
||||
fireEvent(domEvent);
|
||||
}
|
||||
@@ -164,18 +180,17 @@ public final class DomManagerImpl extends DomManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(listener, project);
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(listener, myProject);
|
||||
}
|
||||
};
|
||||
|
||||
final StartupManager startupManager = StartupManager.getInstance(project);
|
||||
StartupManager startupManager = StartupManager.getInstance(project);
|
||||
if (!((StartupManagerEx)startupManager).startupActivityPassed()) {
|
||||
startupManager.registerStartupActivity(setupVfsListeners);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setupVfsListeners.run();
|
||||
}
|
||||
|
||||
myFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
}
|
||||
|
||||
private void processVfsChange(final VirtualFile file) {
|
||||
@@ -507,7 +522,4 @@ public final class DomManagerImpl extends DomManager {
|
||||
public SemService getSemService() {
|
||||
return mySemService;
|
||||
}
|
||||
|
||||
|
||||
private final static Logger LOG = Logger.getInstance(DomManagerImpl.class);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
@@ -11,13 +23,14 @@ import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.xml.highlighting.*;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class DomAnnotationsTest extends DomTestCase{
|
||||
public class DomAnnotationsTest extends DomTestCase {
|
||||
|
||||
@Override
|
||||
protected <T extends DomElement> T createElement(final String xml, final Class<T> aClass) {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -11,6 +26,7 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
@@ -16,6 +28,7 @@ import com.intellij.semantic.SemService;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.Timings;
|
||||
import com.intellij.util.xml.impl.DomFileElementImpl;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import com.intellij.util.xml.reflect.DomExtender;
|
||||
import com.intellij.util.xml.reflect.DomExtenderEP;
|
||||
import com.intellij.util.xml.reflect.DomExtensionsRegistrar;
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
@@ -9,6 +21,7 @@ import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ParameterizedTypeImpl;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import com.intellij.util.xml.reflect.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
@@ -14,8 +26,8 @@ import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.psi.xml.XmlTagValue;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomApplicationComponent;
|
||||
import com.intellij.util.xml.impl.DomManagerImpl;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
@@ -22,6 +34,7 @@ import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.testFramework.MockSchemesManagerFactory;
|
||||
import com.intellij.util.xml.highlighting.*;
|
||||
import com.intellij.util.xml.impl.DefaultDomAnnotator;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
@@ -1,16 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class DomModelMergingTest extends DomTestCase{
|
||||
public class DomModelMergingTest extends DomTestCase {
|
||||
private ModelMerger myMerger;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
@@ -9,6 +20,7 @@ import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.xml.impl.DomFileElementImpl;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import com.intellij.util.xml.reflect.DomGenericInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
@@ -7,6 +22,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import com.intellij.util.xml.ui.DomUIFactory;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.util.xml;
|
||||
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class SimpleValuesIncrementalUpdateTest extends DomTestCase{
|
||||
public class SimpleValuesIncrementalUpdateTest extends DomTestCase {
|
||||
|
||||
public void testAttributeChange() throws Throwable {
|
||||
final MyElement element = createElement("<a/>");
|
||||
|
||||
+18
-6
@@ -1,4 +1,19 @@
|
||||
package com.intellij.util.xml;
|
||||
/*
|
||||
* Copyright 2000-2013 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.util.xml.impl;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
@@ -10,11 +25,8 @@ import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.*;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomApplicationComponent;
|
||||
import com.intellij.util.xml.impl.DomFileElementImpl;
|
||||
import com.intellij.util.xml.impl.DomInvocationHandler;
|
||||
import com.intellij.util.xml.impl.DomManagerImpl;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -72,7 +84,7 @@ public abstract class DomTestCase extends LightIdeaTestCase {
|
||||
return element;
|
||||
}
|
||||
|
||||
protected static <T extends DomElement> T createElement(final DomManager domManager, final String xml, final Class<T> aClass)
|
||||
public static <T extends DomElement> T createElement(final DomManager domManager, final String xml, final Class<T> aClass)
|
||||
throws IncorrectOperationException {
|
||||
final String name = "a.xml";
|
||||
final XmlFile file = (XmlFile)PsiFileFactory.getInstance(domManager.getProject()).createFileFromText(name, xml);
|
||||
@@ -1,10 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.util.xml.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.DomTestCase;
|
||||
import com.intellij.util.xml.SubTag;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
|
||||
|
||||
+16
-10
@@ -25,12 +25,12 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.impl.source.xml.TagNameReference;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.xml.XmlTagNameProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -52,15 +52,21 @@ public class TagNameReferenceCompletionProvider extends CompletionProvider<Compl
|
||||
PsiReference reference = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset());
|
||||
if (reference instanceof TagNameReference) {
|
||||
TagNameReference tagNameReference = (TagNameReference)reference;
|
||||
PsiElement element = tagNameReference.getElement();
|
||||
if (element instanceof XmlTag) {
|
||||
if (!tagNameReference.isStartTagFlag()) {
|
||||
result.addElement(createClosingTagLookupElement((XmlTag)element, false, tagNameReference.getNameElement()));
|
||||
}
|
||||
else {
|
||||
XmlTag tag = (XmlTag) element;
|
||||
LookupElement[] variants = getTagNameVariants(tag, tag.getNamespacePrefix());
|
||||
result.addAllElements(Arrays.asList(variants));
|
||||
collectCompletionVariants(tagNameReference, result);
|
||||
}
|
||||
}
|
||||
|
||||
public static void collectCompletionVariants(TagNameReference tagNameReference,
|
||||
Consumer<LookupElement> consumer) {
|
||||
PsiElement element = tagNameReference.getElement();
|
||||
if (element instanceof XmlTag) {
|
||||
if (!tagNameReference.isStartTagFlag()) {
|
||||
consumer.consume(createClosingTagLookupElement((XmlTag)element, false, tagNameReference.getNameElement()));
|
||||
}
|
||||
else {
|
||||
XmlTag tag = (XmlTag) element;
|
||||
for(LookupElement variant: getTagNameVariants(tag, tag.getNamespacePrefix())) {
|
||||
consumer.consume(variant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SwitchToHtml5Action implements LocalQuickFix, IntentionAction {
|
||||
}
|
||||
|
||||
private static void applyFix(Project project) {
|
||||
ExternalResourceManagerEx.getInstanceEx().setDefaultHtmlDoctype(Html5SchemaProvider.HTML5_SCHEMA_LOCATION, project);
|
||||
ExternalResourceManagerEx.getInstanceEx().setDefaultHtmlDoctype(Html5SchemaProvider.getHtml5SchemaLocation(), project);
|
||||
DaemonCodeAnalyzer.getInstance(project).restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class DefaultHtmlDoctypeInitialConfigurator {
|
||||
if (!propertiesComponent.getBoolean("DefaultHtmlDoctype.MigrateToHtml5", false)) {
|
||||
propertiesComponent.setValue("DefaultHtmlDoctype.MigrateToHtml5", Boolean.TRUE.toString());
|
||||
ExternalResourceManagerEx.getInstanceEx()
|
||||
.setDefaultHtmlDoctype(Html5SchemaProvider.HTML5_SCHEMA_LOCATION, projectManager.getDefaultProject());
|
||||
.setDefaultHtmlDoctype(Html5SchemaProvider.getHtml5SchemaLocation(), projectManager.getDefaultProject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple
|
||||
return XmlUtil.XHTML4_SCHEMA_LOCATION;
|
||||
}
|
||||
else if (HTML5_DOCTYPE_ELEMENT.equals(doctype)) {
|
||||
return Html5SchemaProvider.HTML5_SCHEMA_LOCATION;
|
||||
return Html5SchemaProvider.getHtml5SchemaLocation();
|
||||
}
|
||||
else {
|
||||
return doctype;
|
||||
@@ -496,7 +496,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple
|
||||
private void setDefaultHtmlDoctype(String defaultHtmlDoctype) {
|
||||
myModificationCount++;
|
||||
|
||||
if (Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(defaultHtmlDoctype)) {
|
||||
if (Html5SchemaProvider.getHtml5SchemaLocation().equals(defaultHtmlDoctype)) {
|
||||
myDefaultHtmlDoctype = HTML5_DOCTYPE_ELEMENT;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class HtmlLanguageLevelForm {
|
||||
return XmlUtil.XHTML_URI;
|
||||
}
|
||||
if (myHtml5RadioButton.isSelected()) {
|
||||
return Html5SchemaProvider.HTML5_SCHEMA_LOCATION;
|
||||
return Html5SchemaProvider.getHtml5SchemaLocation();
|
||||
}
|
||||
return myDoctypeTextField.getText();
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class HtmlLanguageLevelForm {
|
||||
myHtml4RadioButton.setSelected(true);
|
||||
myDoctypeTextField.setEnabled(false);
|
||||
}
|
||||
else if (doctype.equals(Html5SchemaProvider.HTML5_SCHEMA_LOCATION)) {
|
||||
else if (doctype.equals(Html5SchemaProvider.getHtml5SchemaLocation())) {
|
||||
myHtml5RadioButton.setSelected(true);
|
||||
myDoctypeTextField.setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ public class XmlParsingTest extends ParsingTestCase {
|
||||
addExplicitExtension(LanguageParserDefinitions.INSTANCE, DTDLanguage.INSTANCE, new DTDParserDefinition());
|
||||
addExplicitExtension(LanguageASTFactory.INSTANCE, XMLLanguage.INSTANCE, new XmlASTFactory());
|
||||
addExplicitExtension(LanguageASTFactory.INSTANCE, DTDLanguage.INSTANCE, new XmlASTFactory());
|
||||
registerExtensionPoint(new ExtensionPointName<XmlChildRole.StartTagEndTokenProvider>("com.intellij.xml.startTagEndToken"),
|
||||
XmlChildRole.StartTagEndTokenProvider.class);
|
||||
registerExtensionPoint(StartTagEndTokenProvider.EP_NAME, StartTagEndTokenProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user