mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
Generated
+2
-1
@@ -58,7 +58,8 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/lvcs-api/lvcs-api.iml" filepath="$PROJECT_DIR$/platform/lvcs-api/lvcs-api.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/lvcs-impl/lvcs-impl.iml" filepath="$PROJECT_DIR$/platform/lvcs-impl/lvcs-impl.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/maven.iml" filepath="$PROJECT_DIR$/plugins/maven/maven.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/maven-facade.iml" filepath="$PROJECT_DIR$/plugins/maven/maven-facade.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/facade-api/maven-facade-api.iml" filepath="$PROJECT_DIR$/plugins/maven/facade-api/maven-facade-api.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/maven/facade-impl/maven-facade-impl.iml" filepath="$PROJECT_DIR$/plugins/maven/facade-impl/maven-facade-impl.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/compiler/notNull/notNull.iml" filepath="$PROJECT_DIR$/java/compiler/notNull/notNull.iml" group="java/compiler" />
|
||||
<module fileurl="file://$PROJECT_DIR$/java/openapi/openapi.iml" filepath="$PROJECT_DIR$/java/openapi/openapi.iml" group="java" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/platform-api/platform-api.iml" filepath="$PROJECT_DIR$/platform/platform-api/platform-api.iml" group="platform" />
|
||||
|
||||
@@ -174,10 +174,14 @@ def layoutFull(String home, String targetDirectory) {
|
||||
|
||||
|
||||
layoutPlugin("maven") {
|
||||
jar("maven-facade.jar") {
|
||||
module("maven-facade")
|
||||
jar("maven-facade-api.jar") {
|
||||
module("maven-facade-api")
|
||||
}
|
||||
fileset(dir: "$home/plugins/maven/lib")
|
||||
jar("maven-facade-impl.jar") {
|
||||
module("maven-facade-impl")
|
||||
}
|
||||
fileset(dir: "$home/plugins/maven/facade-impl/lib")
|
||||
fileset(dir: "$home/plugins/maven/facade-api/lib")
|
||||
}
|
||||
|
||||
|
||||
|
||||
-12
@@ -109,20 +109,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
LOG.assertTrue(element.isValid());
|
||||
}
|
||||
element.accept(this);
|
||||
|
||||
if (myRefCountHolder != null) {
|
||||
instantiateInjections(element);
|
||||
}
|
||||
}
|
||||
|
||||
private void instantiateInjections(final PsiElement element) {
|
||||
InjectedLanguageUtil.enumerate(element, myFile, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
|
||||
public void visit(@NotNull final PsiFile injectedPsi, @NotNull final List<PsiLanguageInjectionHost.Shred> places) {
|
||||
// no op
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
private void registerReferencesFromInjectedFragments(final PsiElement element) {
|
||||
InjectedLanguageUtil.enumerate(element, myFile, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
|
||||
public void visit(@NotNull final PsiFile injectedPsi, @NotNull final List<PsiLanguageInjectionHost.Shred> places) {
|
||||
|
||||
+2
-4
@@ -39,8 +39,6 @@ import java.util.*;
|
||||
public class RemoveUnusedVariableFix implements IntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableFix");
|
||||
private final PsiVariable myVariable;
|
||||
@NonNls private static final String JAVA_LANG_PCKG = "java.lang";
|
||||
@NonNls private static final String JAVA_IO_PCKG = "java.io";
|
||||
|
||||
public RemoveUnusedVariableFix(PsiVariable variable) {
|
||||
myVariable = variable;
|
||||
@@ -356,10 +354,10 @@ public class RemoveUnusedVariableFix implements IntentionAction {
|
||||
PsiFile file = aClass.getContainingFile();
|
||||
PsiDirectory directory = file.getContainingDirectory();
|
||||
PsiPackage classPackage = JavaDirectoryService.getInstance().getPackage(directory);
|
||||
String packageName = classPackage.getQualifiedName();
|
||||
String packageName = classPackage == null ? null : classPackage.getQualifiedName();
|
||||
|
||||
// all Throwable descendants from java.lang are side effects free
|
||||
if (JAVA_LANG_PCKG.equals(packageName) || JAVA_IO_PCKG.equals(packageName)) {
|
||||
if ("java.lang".equals(packageName) || "java.io".equals(packageName)) {
|
||||
PsiClass throwableClass = JavaPsiFacade.getInstance(aClass.getProject()).findClass("java.lang.Throwable", aClass.getResolveScope());
|
||||
if (throwableClass != null && InheritanceUtil.isInheritorOrSelf(aClass, throwableClass, true)) {
|
||||
return true;
|
||||
|
||||
@@ -497,7 +497,8 @@ public class PsiPackageImpl extends PsiElementBase implements PsiPackage, Querya
|
||||
NameHint nameHint = processor.getHint(NameHint.KEY);
|
||||
if (nameHint != null) {
|
||||
final String shortName = nameHint.getName(state);
|
||||
if (containsClassNamed(shortName) && processClassesByName(processor, state, place, scope, shortName)) return false;
|
||||
if ((migration != null || containsClassNamed(shortName))
|
||||
&& processClassesByName(processor, state, place, scope, shortName)) return false;
|
||||
}
|
||||
else if (prefixMatcher != null && migration == null) {
|
||||
for (String className : getClassNamesCache()) {
|
||||
|
||||
@@ -138,7 +138,9 @@ public class PsiClassReferenceType extends PsiClassType {
|
||||
return factory.createType(aClass, rawSubstitutor, getLanguageLevel(), getAnnotations());
|
||||
}
|
||||
String qualifiedName = myReference.getQualifiedName();
|
||||
LightClassReference reference = new LightClassReference(myReference.getManager(), myReference.getReferenceName(), qualifiedName, myReference.getResolveScope());
|
||||
String name = myReference.getReferenceName();
|
||||
if (name==null) name="";
|
||||
LightClassReference reference = new LightClassReference(myReference.getManager(), name, qualifiedName, myReference.getResolveScope());
|
||||
return new PsiClassReferenceType(reference, null,getAnnotations());
|
||||
}
|
||||
|
||||
|
||||
@@ -54,16 +54,17 @@ public class PropertyUtil {
|
||||
|
||||
String methodName = method.getName();
|
||||
PsiType returnType = method.getReturnType();
|
||||
if (methodName.startsWith("get") && methodName.length() > "get".length()) {
|
||||
int methodNameLength = methodName.length();
|
||||
if (methodName.startsWith("get") && methodNameLength > "get".length()) {
|
||||
if (Character.isLowerCase(methodName.charAt("get".length()))
|
||||
&& (methodName.length() == "get".length() + 1 || Character.isLowerCase(methodName.charAt("get".length() + 1)))) {
|
||||
&& (methodNameLength == "get".length() + 1 || Character.isLowerCase(methodName.charAt("get".length() + 1)))) {
|
||||
return false;
|
||||
}
|
||||
if (returnType != null && PsiType.VOID.equals(returnType)) return false;
|
||||
}
|
||||
else if (methodName.startsWith("is") && methodName.length() > "is".length()) {
|
||||
else if (methodName.startsWith("is") && methodNameLength > "is".length()) {
|
||||
if (Character.isLowerCase(methodName.charAt("is".length()))
|
||||
&& (methodName.length() == "is".length() + 1 || Character.isLowerCase(methodName.charAt("is".length() + 1)))) {
|
||||
&& (methodNameLength == "is".length() + 1 || Character.isLowerCase(methodName.charAt("is".length() + 1)))) {
|
||||
return false;
|
||||
}
|
||||
return isBoolean(returnType);
|
||||
@@ -209,7 +210,8 @@ public class PropertyUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable public static PsiMethod findPropertyGetterWithType(String propertyName, boolean isStatic, PsiType type, Iterator<PsiMethod> methods) {
|
||||
@Nullable
|
||||
public static PsiMethod findPropertyGetterWithType(String propertyName, boolean isStatic, PsiType type, Iterator<PsiMethod> methods) {
|
||||
while (methods.hasNext()) {
|
||||
PsiMethod method = methods.next();
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC) != isStatic) continue;
|
||||
@@ -252,7 +254,8 @@ public class PropertyUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable public static PsiMethod findPropertySetterWithType(String propertyName, boolean isStatic, PsiType type, Iterator<PsiMethod> methods) {
|
||||
@Nullable
|
||||
public static PsiMethod findPropertySetterWithType(String propertyName, boolean isStatic, PsiType type, Iterator<PsiMethod> methods) {
|
||||
while (methods.hasNext()) {
|
||||
PsiMethod method = methods.next();
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC) != isStatic) continue;
|
||||
@@ -500,7 +503,8 @@ public class PropertyUtil {
|
||||
/**
|
||||
* "xxx", "void setMyProperty(String pp)" -> "setXxx"
|
||||
*/
|
||||
@Nullable public static String suggestPropertyAccessor(String name, PsiMethod accessorTemplate) {
|
||||
@Nullable
|
||||
public static String suggestPropertyAccessor(String name, PsiMethod accessorTemplate) {
|
||||
if (isSimplePropertyGetter(accessorTemplate)) {
|
||||
PsiType type = accessorTemplate.getReturnType();
|
||||
return suggestGetterName(name, type, accessorTemplate.getName());
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -284,7 +284,9 @@ static int walk_tree(const char* path, watch_node* parent, array* ignores) {
|
||||
|
||||
|
||||
int watch(const char* root, array* ignores) {
|
||||
return walk_tree(root, NULL, ignores);
|
||||
char buf[PATH_MAX];
|
||||
const char* normalized = realpath(root, buf);
|
||||
return walk_tree((normalized != NULL ? normalized : root), NULL, ignores);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
#!/bin/sh
|
||||
echo "compiling 32-bit version"
|
||||
gcc -O2 -m32 -Wall -std=c99 -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -o fsnotifier main.c inotify.c util.c
|
||||
echo "compiling 64-bit version"
|
||||
gcc -O2 -m64 -Wall -std=c99 -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -o fsnotifier64 main.c inotify.c util.c
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.execution.configurations;
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.executors.DefaultRunExecutor;
|
||||
import com.intellij.execution.filters.TextConsoleBuilder;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
@@ -61,7 +60,7 @@ public abstract class CommandLineState implements RunnableState {
|
||||
return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler, executor));
|
||||
}
|
||||
|
||||
protected abstract OSProcessHandler startProcess() throws ExecutionException;
|
||||
protected abstract ProcessHandler startProcess() throws ExecutionException;
|
||||
|
||||
protected AnAction[] createActions(final ConsoleView console, final ProcessHandler processHandler) {
|
||||
return createActions(console, processHandler, null);
|
||||
|
||||
+53
-57
@@ -26,10 +26,13 @@ import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiCodeFragment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import gnu.trove.TIntStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -37,7 +40,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CollectHighlightsUtil {
|
||||
private static final ExtensionPointName<Condition<PsiElement>> EP_NAME = ExtensionPointName.create("com.intellij.elementsToHighlightFilter");
|
||||
public static final ExtensionPointName<Condition<PsiElement>> EP_NAME = ExtensionPointName.create("com.intellij.elementsToHighlightFilter");
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil");
|
||||
|
||||
@@ -76,65 +79,58 @@ public class CollectHighlightsUtil {
|
||||
final int currentOffset = commonParent.getTextRange().getStartOffset();
|
||||
final Condition<PsiElement>[] filters = Extensions.getExtensions(EP_NAME);
|
||||
|
||||
final PsiElementVisitor visitor = new PsiElementVisitor() {
|
||||
int offset = currentOffset;
|
||||
|
||||
final TIntArrayList starts = new TIntArrayList(STARTING_TREE_HEIGHT);
|
||||
final List<PsiElement> elements = new ArrayList<PsiElement>(STARTING_TREE_HEIGHT);
|
||||
final List<PsiElement> children = new ArrayList<PsiElement>(STARTING_TREE_HEIGHT);
|
||||
|
||||
@Override public void visitElement(PsiElement element) {
|
||||
children.add(PsiUtilBase.NULL_PSI_ELEMENT);
|
||||
|
||||
while (true) {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
PsiElement child = children.remove(children.size() - 1);
|
||||
int offset = currentOffset;
|
||||
|
||||
for (Condition<PsiElement> filter : filters) {
|
||||
if (!filter.value(element)) {
|
||||
assert child == PsiUtilBase.NULL_PSI_ELEMENT;
|
||||
child = null; // do not want to process children
|
||||
break;
|
||||
}
|
||||
}
|
||||
final TIntStack starts = new TIntStack(STARTING_TREE_HEIGHT);
|
||||
final Stack<PsiElement> elements = new Stack<PsiElement>(STARTING_TREE_HEIGHT);
|
||||
final Stack<PsiElement> children = new Stack<PsiElement>(STARTING_TREE_HEIGHT);
|
||||
PsiElement element = commonParent;
|
||||
|
||||
boolean startChildrenVisiting = false;
|
||||
PsiElement child = PsiUtilBase.NULL_PSI_ELEMENT;
|
||||
while (true) {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
if (child == PsiUtilBase.NULL_PSI_ELEMENT) {
|
||||
startChildrenVisiting = true;
|
||||
child = element.getFirstChild();
|
||||
}
|
||||
|
||||
if (child == null) {
|
||||
if (startChildrenVisiting) {
|
||||
// leaf element
|
||||
offset += element.getTextLength();
|
||||
}
|
||||
|
||||
if (elements.size() == 0) break;
|
||||
int start = starts.remove(starts.size() - 1);
|
||||
if (startOffset <= start && offset <= endOffset) result.add(element);
|
||||
|
||||
element = elements.remove(elements.size() - 1);
|
||||
}
|
||||
else {
|
||||
// composite element
|
||||
if (offset <= endOffset) {
|
||||
starts.add(offset);
|
||||
children.add(child.getNextSibling());
|
||||
children.add(PsiUtilBase.NULL_PSI_ELEMENT);
|
||||
elements.add(element);
|
||||
element = child;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (Condition<PsiElement> filter : filters) {
|
||||
if (!filter.value(element)) {
|
||||
assert child == PsiUtilBase.NULL_PSI_ELEMENT;
|
||||
child = null; // do not want to process children
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
commonParent.accept(visitor);
|
||||
|
||||
|
||||
boolean startChildrenVisiting;
|
||||
if (child == PsiUtilBase.NULL_PSI_ELEMENT) {
|
||||
startChildrenVisiting = true;
|
||||
child = element.getFirstChild();
|
||||
}
|
||||
else {
|
||||
startChildrenVisiting = false;
|
||||
}
|
||||
|
||||
if (child == null) {
|
||||
if (startChildrenVisiting) {
|
||||
// leaf element
|
||||
offset += element.getTextLength();
|
||||
}
|
||||
|
||||
if (elements.isEmpty()) break;
|
||||
int start = starts.pop();
|
||||
if (startOffset <= start && offset <= endOffset) result.add(element);
|
||||
|
||||
element = elements.pop();
|
||||
child = children.pop();
|
||||
}
|
||||
else {
|
||||
// composite element
|
||||
if (offset > endOffset) break;
|
||||
children.push(child.getNextSibling());
|
||||
starts.push(offset);
|
||||
elements.push(element);
|
||||
element = child;
|
||||
child = PsiUtilBase.NULL_PSI_ELEMENT;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+54
-26
@@ -16,35 +16,54 @@
|
||||
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.codeHighlighting.*;
|
||||
import com.intellij.codeHighlighting.BackgroundEditorHighlighter;
|
||||
import com.intellij.codeHighlighting.HighlightingPass;
|
||||
import com.intellij.codeHighlighting.Pass;
|
||||
import com.intellij.codeInsight.daemon.*;
|
||||
import com.intellij.codeInsight.hint.*;
|
||||
import com.intellij.codeInsight.intention.impl.*;
|
||||
import com.intellij.concurrency.*;
|
||||
import com.intellij.lang.annotation.*;
|
||||
import com.intellij.openapi.application.*;
|
||||
import com.intellij.openapi.diagnostic.*;
|
||||
import com.intellij.codeHighlighting.TextEditorHighlightingPass;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.ReferenceImporter;
|
||||
import com.intellij.codeInsight.hint.HintManager;
|
||||
import com.intellij.codeInsight.intention.impl.IntentionHintComponent;
|
||||
import com.intellij.concurrency.Job;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.ex.*;
|
||||
import com.intellij.openapi.editor.markup.*;
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import com.intellij.openapi.fileEditor.*;
|
||||
import com.intellij.openapi.fileEditor.impl.text.*;
|
||||
import com.intellij.openapi.fileTypes.*;
|
||||
import com.intellij.openapi.progress.*;
|
||||
import com.intellij.openapi.project.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorMarkupModel;
|
||||
import com.intellij.openapi.editor.markup.MarkupModel;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.packageDependencies.*;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.scope.packageSet.*;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.*;
|
||||
import gnu.trove.*;
|
||||
import org.jdom.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.psi.PsiCompiledElement;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopeManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -82,6 +101,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
@NonNls private static final String FILE_TAG = "file";
|
||||
@NonNls private static final String URL_ATT = "url";
|
||||
private DaemonListeners myDaemonListeners;
|
||||
private StatusBarUpdater myStatusBarUpdater;
|
||||
private final PassExecutorService myPassExecutorService;
|
||||
private static final Key<List<HighlightInfo>> HIGHLIGHTS_TO_REMOVE_KEY = Key.create("HIGHLIGHTS_TO_REMOVE");
|
||||
private int myModificationCount = 0;
|
||||
@@ -126,6 +146,9 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
|
||||
public void projectOpened() {
|
||||
assert !myInitialized : "Double Initializing";
|
||||
myStatusBarUpdater = new StatusBarUpdater(myProject);
|
||||
Disposer.register(myProject, myStatusBarUpdater);
|
||||
|
||||
myDaemonListeners = new DaemonListeners(myProject, this, myEditorTracker);
|
||||
Disposer.register(myProject, myDaemonListeners);
|
||||
reloadScopes();
|
||||
@@ -451,6 +474,11 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
markup.putUserData(HIGHLIGHTS_IN_EDITOR_DOCUMENT_KEY, Collections.unmodifiableList(highlightsToSet));
|
||||
|
||||
markup.putUserData(HIGHLIGHTS_TO_REMOVE_KEY, Collections.unmodifiableList(highlightsToRemove));
|
||||
|
||||
DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
|
||||
if (codeAnalyzer instanceof DaemonCodeAnalyzerImpl && ((DaemonCodeAnalyzerImpl)codeAnalyzer).myStatusBarUpdater != null) {
|
||||
((DaemonCodeAnalyzerImpl)codeAnalyzer).myStatusBarUpdater.updateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private static void stripWarningsCoveredByErrors(final Project project, List<HighlightInfo> highlights, MarkupModel markup) {
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
|
||||
/*
|
||||
* Copyright 2000-2009 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.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.event.CaretEvent;
|
||||
import com.intellij.openapi.editor.event.CaretListener;
|
||||
import com.intellij.openapi.editor.ex.DocumentEx;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.StatusBarEx;
|
||||
|
||||
public class StatusBarUpdater implements Disposable {
|
||||
private final Project myProject;
|
||||
private final UpdateStatusRunnable myUpdateStatusRunnable = new UpdateStatusRunnable();
|
||||
|
||||
public StatusBarUpdater(Project project) {
|
||||
myProject = project;
|
||||
|
||||
CaretListener caretListener = new CaretListener() {
|
||||
public void caretPositionChanged(CaretEvent e) {
|
||||
ApplicationManager.getApplication().invokeLater(myUpdateStatusRunnable);
|
||||
}
|
||||
};
|
||||
EditorFactory.getInstance().getEventMulticaster().addCaretListener(caretListener, this);
|
||||
|
||||
project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
|
||||
@Override
|
||||
public void selectionChanged(FileEditorManagerEvent event) {
|
||||
ApplicationManager.getApplication().invokeLater(myUpdateStatusRunnable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
public void updateStatus() {
|
||||
Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
|
||||
if (editor == null || !editor.getContentComponent().hasFocus()){
|
||||
return;
|
||||
}
|
||||
|
||||
final Document document = editor.getDocument();
|
||||
if (document instanceof DocumentEx && ((DocumentEx)document).isInBulkUpdate()) return;
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject);
|
||||
HighlightInfo info = ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(document, offset, false);
|
||||
String text = info != null && info.description != null ? info.description : "";
|
||||
|
||||
StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
|
||||
if (statusBar instanceof StatusBarEx) {
|
||||
StatusBarEx barEx = (StatusBarEx)statusBar;
|
||||
if (!text.equals(barEx.getInfo())){
|
||||
statusBar.setInfo(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class UpdateStatusRunnable implements DumbAwareRunnable {
|
||||
public void run() {
|
||||
if (!myProject.isDisposed()) {
|
||||
updateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-10
@@ -33,8 +33,6 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
@@ -91,14 +89,9 @@ public class SmartEnterAction extends EditorAction {
|
||||
final Language language = PsiUtilBase.getLanguageInEditor(editor, project);
|
||||
boolean processed = false;
|
||||
if (language != null) {
|
||||
final List<SmartEnterProcessor> processors = SmartEnterProcessors.INSTANCE.forKey(language);
|
||||
if (!processors.isEmpty()) {
|
||||
for (SmartEnterProcessor processor : processors) {
|
||||
if (processor.process(project, editor, psiFile)) {
|
||||
processed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final SmartEnterProcessor processor = SmartEnterProcessors.INSTANCE.forLanguage(language);
|
||||
if (processor != null && processor.process(project, editor, psiFile)) {
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
if (!processed) {
|
||||
|
||||
+22
-28
@@ -73,25 +73,6 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
|
||||
}
|
||||
};
|
||||
|
||||
private final VirtualFileListener myVirtualFileListener = new VirtualFileAdapter() {
|
||||
public void fileDeleted(final VirtualFileEvent event) {
|
||||
onDeleted(event.getFile());
|
||||
}
|
||||
|
||||
public void fileMoved(final VirtualFileMoveEvent event) {
|
||||
onDeleted(event.getFile());
|
||||
}
|
||||
|
||||
private void onDeleted(final VirtualFile file) {
|
||||
if (file.isDirectory()) {
|
||||
clearInvalidFiles();
|
||||
}
|
||||
else {
|
||||
doRemove(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void doRemove(VirtualFile problemFile) {
|
||||
ProblemFileInfo old;
|
||||
synchronized (myProblems) {
|
||||
@@ -106,8 +87,6 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
|
||||
}
|
||||
}
|
||||
|
||||
private final PsiTreeChangeListener myChangeListener;
|
||||
|
||||
private static class ProblemFileInfo {
|
||||
private final Collection<Problem> problems = new THashSet<Problem>();
|
||||
private boolean hasSyntaxErrors;
|
||||
@@ -118,10 +97,7 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
|
||||
|
||||
final ProblemFileInfo that = (ProblemFileInfo)o;
|
||||
|
||||
if (hasSyntaxErrors != that.hasSyntaxErrors) return false;
|
||||
if (!problems.equals(that.problems)) return false;
|
||||
|
||||
return true;
|
||||
return hasSyntaxErrors == that.hasSyntaxErrors && problems.equals(that.problems);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
@@ -133,7 +109,7 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
|
||||
|
||||
public WolfTheProblemSolverImpl(Project project, PsiManager psiManager, VirtualFileManager virtualFileManager) {
|
||||
myProject = project;
|
||||
myChangeListener = new PsiTreeChangeAdapter() {
|
||||
PsiTreeChangeListener changeListener = new PsiTreeChangeAdapter() {
|
||||
public void childAdded(PsiTreeChangeEvent event) {
|
||||
childrenChanged(event);
|
||||
}
|
||||
@@ -158,8 +134,26 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
|
||||
clearSyntaxErrorFlag(event);
|
||||
}
|
||||
};
|
||||
psiManager.addPsiTreeChangeListener(myChangeListener);
|
||||
virtualFileManager.addVirtualFileListener(myVirtualFileListener, myProject);
|
||||
psiManager.addPsiTreeChangeListener(changeListener);
|
||||
VirtualFileListener virtualFileListener = new VirtualFileAdapter() {
|
||||
public void fileDeleted(final VirtualFileEvent event) {
|
||||
onDeleted(event.getFile());
|
||||
}
|
||||
|
||||
public void fileMoved(final VirtualFileMoveEvent event) {
|
||||
onDeleted(event.getFile());
|
||||
}
|
||||
|
||||
private void onDeleted(final VirtualFile file) {
|
||||
if (file.isDirectory()) {
|
||||
clearInvalidFiles();
|
||||
}
|
||||
else {
|
||||
doRemove(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
virtualFileManager.addVirtualFileListener(virtualFileListener, myProject);
|
||||
FileStatusManager fileStatusManager = FileStatusManager.getInstance(myProject);
|
||||
if (fileStatusManager != null) { //tests?
|
||||
fileStatusManager.addFileStatusListener(new FileStatusListener() {
|
||||
|
||||
@@ -13,8 +13,8 @@ import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.runners.DefaultProgramRunner;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -34,20 +34,16 @@ import java.util.List;
|
||||
* @author Gregory.Shrago
|
||||
*/
|
||||
public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
|
||||
private final Project myProject;
|
||||
public static final Logger LOG = Logger.getInstance("#" + RemoteProcessSupport.class);
|
||||
|
||||
private final Class<EntryPoint> myValueClass;
|
||||
private final HashMap<Pair<Target, Parameters>, Object> myProcMap =
|
||||
new HashMap<Pair<Target, Parameters>, Object>();
|
||||
|
||||
public RemoteProcessSupport(Project project, Class<EntryPoint> valueClass) {
|
||||
myProject = project;
|
||||
public RemoteProcessSupport(Class<EntryPoint> valueClass) {
|
||||
myValueClass = valueClass;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
protected abstract void fireModificationCountChanged();
|
||||
|
||||
protected abstract String getName(Target target);
|
||||
@@ -55,7 +51,6 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
|
||||
protected void logText(Parameters configuration, ProcessEvent event, Key outputType, Object info) {
|
||||
}
|
||||
|
||||
|
||||
public void stopAll() {
|
||||
final ArrayList<ProcessHandler> allHandlers = new ArrayList<ProcessHandler>();
|
||||
synchronized (myProcMap) {
|
||||
@@ -86,17 +81,7 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
|
||||
final Ref<Info> ref = Ref.create(null);
|
||||
final Pair<Target, Parameters> key = Pair.create(target, configuration);
|
||||
if (!getExistingInfo(ref, key)) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
startProcess(target, configuration, key);
|
||||
}
|
||||
};
|
||||
if (ApplicationManager.getApplication().isDispatchThread()) {
|
||||
runnable.run();
|
||||
}
|
||||
else {
|
||||
ApplicationManager.getApplication().invokeLater(runnable);
|
||||
}
|
||||
startProcess(target, configuration, key);
|
||||
if (ref.isNull()) {
|
||||
try {
|
||||
synchronized (ref) {
|
||||
@@ -166,7 +151,8 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract RunProfileState getRunProfileState(Target target, Parameters configuration, Executor executor) throws ExecutionException;
|
||||
protected abstract RunProfileState getRunProfileState(Target target, Parameters configuration, Executor executor)
|
||||
throws ExecutionException;
|
||||
|
||||
private boolean getExistingInfo(Ref<Info> ref, final Pair<Target, Parameters> key) {
|
||||
Object info;
|
||||
@@ -214,7 +200,7 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
|
||||
}
|
||||
|
||||
private static <T> T narrowImpl(Remote remote, Class<T> to) {
|
||||
return (T) (to.isInstance(remote)? remote : PortableRemoteObject.narrow(remote, to));
|
||||
return (T)(to.isInstance(remote) ? remote : PortableRemoteObject.narrow(remote, to));
|
||||
}
|
||||
|
||||
private ProcessListener getProcessListener(final Pair<Target, Parameters> key) {
|
||||
@@ -240,6 +226,13 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
|
||||
}
|
||||
|
||||
public void onTextAvailable(ProcessEvent event, Key outputType) {
|
||||
if (outputType == ProcessOutputTypes.STDERR) {
|
||||
LOG.warn(event.getText());
|
||||
}
|
||||
else {
|
||||
LOG.info(event.getText());
|
||||
}
|
||||
|
||||
Info result = null;
|
||||
final PendingInfo info;
|
||||
synchronized (myProcMap) {
|
||||
@@ -262,7 +255,9 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
|
||||
info.stderr.append(event.getText());
|
||||
}
|
||||
}
|
||||
else info = null;
|
||||
else {
|
||||
info = null;
|
||||
}
|
||||
}
|
||||
if (result != null) {
|
||||
synchronized (info.ref) {
|
||||
@@ -280,8 +275,8 @@ public abstract class RemoteProcessSupport<Target, EntryPoint, Parameters> {
|
||||
final PendingInfo pendingInfo;
|
||||
synchronized (myProcMap) {
|
||||
o = myProcMap.remove(key);
|
||||
pendingInfo = o instanceof PendingInfo? (PendingInfo)o : null;
|
||||
if (pendingInfo != null && (pendingInfo.stderr.length() > 0 || pendingInfo.ref.isNull())) {
|
||||
pendingInfo = o instanceof PendingInfo ? (PendingInfo)o : null;
|
||||
if (pendingInfo != null && (pendingInfo.stderr.length() > 0 || pendingInfo.ref.isNull())) {
|
||||
if (errorMessage != null) pendingInfo.stderr.append(errorMessage);
|
||||
pendingInfo.ref.set(new Info(null, -1, pendingInfo.stderr.toString()));
|
||||
}
|
||||
|
||||
@@ -148,17 +148,33 @@ public abstract class ASTDelegatePsiElement extends PsiElementBase {
|
||||
return node == null ? null : node.getPsi();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected PsiElement findNotNullChildByType(IElementType type) {
|
||||
return notNullChild(findChildByType(type));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected PsiElement findChildByType(TokenSet type) {
|
||||
ASTNode node = getNode().findChildByType(type);
|
||||
return node == null ? null : node.getPsi();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected PsiElement findNotNullChildByType(TokenSet type) {
|
||||
return notNullChild(findChildByType(type));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected PsiElement findChildByFilter(TokenSet tokenSet) {
|
||||
ASTNode[] nodes = getNode().getChildren(tokenSet);
|
||||
return nodes == null || nodes.length == 0 ? null : nodes[0].getPsi();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected PsiElement findNotNullChildByFilter(TokenSet tokenSet) {
|
||||
return notNullChild(findChildByFilter(tokenSet));
|
||||
}
|
||||
|
||||
protected <T extends PsiElement> T[] findChildrenByType(IElementType elementType, Class<T> arrayClass) {
|
||||
return ContainerUtil.map2Array(SharedImplUtil.getChildrenOfType(getNode(), elementType), arrayClass, new Function<ASTNode, T>() {
|
||||
public T fun(final ASTNode s) {
|
||||
|
||||
@@ -241,7 +241,11 @@ public abstract class PsiElementBase extends ElementBase implements NavigatableP
|
||||
|
||||
@NotNull
|
||||
protected <T> T findNotNullChildByClass(Class<T> aClass) {
|
||||
final T child = findChildByClass(aClass);
|
||||
return notNullChild(findChildByClass(aClass));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected <T> T notNullChild(T child) {
|
||||
if (child == null) {
|
||||
LOG.error(getText() + "\n parent=" + getParent().getText());
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class FileTemplateUtil{
|
||||
};
|
||||
Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, emptyLogSystem);
|
||||
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "file,class");
|
||||
//todo[myakovlev] implement my oun Loader, with ability to load templates from classpath
|
||||
//todo[myakovlev] implement my own Loader, with ability to load templates from classpath
|
||||
Velocity.setProperty("file.resource.loader.class", MyFileResourceLoader.class.getName());
|
||||
Velocity.setProperty("class.resource.loader.class", MyClasspathResourceLoader.class.getName());
|
||||
Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, modifiedPatternsPath.getAbsolutePath());
|
||||
@@ -321,7 +321,7 @@ public class FileTemplateUtil{
|
||||
File modifiedPatternsPath = new File(PathManager.getConfigPath());
|
||||
modifiedPatternsPath = new File(modifiedPatternsPath, INCLUDES_PATH);
|
||||
|
||||
try{
|
||||
try {
|
||||
Field pathsField = FileResourceLoader.class.getDeclaredField("paths");
|
||||
pathsField.setAccessible(true);
|
||||
Collection<String> paths = (Collection)pathsField.get(this);
|
||||
@@ -333,12 +333,13 @@ public class FileTemplateUtil{
|
||||
paths.add(testsDir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean canCreateFromTemplate (PsiDirectory[] dirs, FileTemplate template) {
|
||||
FileType fileType = FileTypeManagerEx.getInstanceEx().getFileTypeByExtension(template.getExtension());
|
||||
if (fileType.equals(FileTypes.UNKNOWN)) return false;
|
||||
|
||||
@@ -25,24 +25,22 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Progressive;
|
||||
import com.intellij.openapi.progress.util.StatusBarProgress;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
|
||||
protected final Project myProject;
|
||||
@@ -52,10 +50,54 @@ public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
|
||||
DefaultTreeModel treeModel,
|
||||
AbstractTreeStructure treeStructure,
|
||||
Comparator<NodeDescriptor> comparator) {
|
||||
super(tree, treeModel, treeStructure, comparator);
|
||||
init(tree, treeModel, new AbstractTreeStructure.Delegate(treeStructure) {
|
||||
@Override
|
||||
public AsyncResult revalidateElement(Object element) {
|
||||
return _revalidateElement(element);
|
||||
}
|
||||
}, comparator, DEFAULT_UPDATE_INACTIVE);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
private AsyncResult _revalidateElement(Object element) {
|
||||
final AsyncResult<Object> result = new AsyncResult<Object>();
|
||||
|
||||
if (element instanceof AbstractTreeNode) {
|
||||
AbstractTreeNode node = (AbstractTreeNode)element;
|
||||
final Object value = node.getValue();
|
||||
VirtualFile vFile = null;
|
||||
if (value instanceof PsiFileSystemItem) {
|
||||
vFile = ((PsiFileSystemItem)value).getVirtualFile();
|
||||
} else if (value instanceof PsiElement) {
|
||||
PsiFile psiFile = ((PsiElement)value).getContainingFile();
|
||||
if (psiFile != null) {
|
||||
vFile = psiFile.getVirtualFile();
|
||||
}
|
||||
}
|
||||
final ActionCallback cb = new ActionCallback();
|
||||
|
||||
final VirtualFile finalVFile = vFile;
|
||||
batch(new Progressive() {
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
final Ref<Object> target = new Ref<Object>();
|
||||
_select(value, finalVFile, false, Conditions.<AbstractTreeNode>alwaysTrue(), cb, indicator, target);
|
||||
cb.doWhenDone(new Runnable() {
|
||||
public void run() {
|
||||
result.setDone(target.get());
|
||||
}
|
||||
}).doWhenRejected(new Runnable() {
|
||||
public void run() {
|
||||
result.setRejected();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
result.setRejected();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean isAlwaysShowPlus(NodeDescriptor nodeDescriptor) {
|
||||
return ((AbstractTreeNode)nodeDescriptor).isAlwaysShowPlus();
|
||||
}
|
||||
@@ -132,7 +174,7 @@ public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
|
||||
public void run() {
|
||||
batch(new Progressive() {
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
_select(element, file, requestFocus, nonStopCondition, result, indicator);
|
||||
_select(element, file, requestFocus, nonStopCondition, result, indicator, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -148,12 +190,13 @@ public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
|
||||
final boolean requestFocus,
|
||||
final Condition<AbstractTreeNode> nonStopCondition,
|
||||
final ActionCallback result,
|
||||
ProgressIndicator indicator) {
|
||||
ProgressIndicator indicator,
|
||||
@Nullable final Ref<Object> virtualSelectTarget) {
|
||||
AbstractTreeNode alreadySelected = alreadySelectedNode(element);
|
||||
|
||||
final Runnable onDone = new Runnable() {
|
||||
public void run() {
|
||||
if (requestFocus) {
|
||||
if (requestFocus && virtualSelectTarget == null) {
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(getTree(), true);
|
||||
}
|
||||
|
||||
@@ -169,15 +212,23 @@ public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
|
||||
};
|
||||
|
||||
if (alreadySelected == null) {
|
||||
expandPathTo(file, (AbstractTreeNode)getTreeStructure().getRootElement(), element, condition, indicator)
|
||||
expandPathTo(file, (AbstractTreeNode)getTreeStructure().getRootElement(), element, condition, indicator, virtualSelectTarget)
|
||||
.doWhenDone(new AsyncResult.Handler<AbstractTreeNode>() {
|
||||
public void run(AbstractTreeNode node) {
|
||||
select(node, onDone);
|
||||
if (virtualSelectTarget == null) {
|
||||
select(node, onDone);
|
||||
} else if (onDone != null) {
|
||||
onDone.run();
|
||||
}
|
||||
}
|
||||
}).notifyWhenRejected(result);
|
||||
}
|
||||
else {
|
||||
select(alreadySelected, onDone);
|
||||
if (virtualSelectTarget == null) {
|
||||
select(alreadySelected, onDone);
|
||||
} else if (onDone != null) {
|
||||
onDone.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,15 +261,21 @@ public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
|
||||
final AbstractTreeNode root,
|
||||
final Object element,
|
||||
final Condition<AbstractTreeNode> nonStopCondition,
|
||||
final ProgressIndicator indicator) {
|
||||
final ProgressIndicator indicator,
|
||||
@Nullable final Ref<Object> target) {
|
||||
final AsyncResult<AbstractTreeNode> async = new AsyncResult<AbstractTreeNode>();
|
||||
|
||||
if (root.canRepresent(element)) {
|
||||
expand(root, new Runnable() {
|
||||
public void run() {
|
||||
async.setDone(root);
|
||||
}
|
||||
});
|
||||
if (target == null) {
|
||||
expand(root, new Runnable() {
|
||||
public void run() {
|
||||
async.setDone(root);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
target.set(root);
|
||||
async.setDone(root);
|
||||
}
|
||||
return async;
|
||||
}
|
||||
|
||||
@@ -228,27 +285,50 @@ public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
|
||||
}
|
||||
|
||||
|
||||
expand(root, new Runnable() {
|
||||
public void run() {
|
||||
indicator.checkCanceled();
|
||||
if (target == null) {
|
||||
expand(root, new Runnable() {
|
||||
public void run() {
|
||||
indicator.checkCanceled();
|
||||
|
||||
final DefaultMutableTreeNode rootNode = getNodeForElement(root);
|
||||
if (rootNode != null) {
|
||||
final List<AbstractTreeNode> kids = collectChildren(rootNode);
|
||||
expandChild(kids, 0, nonStopCondition, file, element, async, indicator, target);
|
||||
}
|
||||
else {
|
||||
async.setRejected();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (indicator.isCanceled()) {
|
||||
async.setRejected();
|
||||
} else {
|
||||
final DefaultMutableTreeNode rootNode = getNodeForElement(root);
|
||||
if (rootNode != null) {
|
||||
final List<AbstractTreeNode> kids = collectChildren(rootNode);
|
||||
expandChild(kids, 0, nonStopCondition, file, element, async, indicator);
|
||||
}
|
||||
else {
|
||||
async.setRejected();
|
||||
final ArrayList<AbstractTreeNode> kids = new ArrayList<AbstractTreeNode>();
|
||||
if (rootNode != null && getTree().isExpanded(new TreePath(rootNode.getPath()))) {
|
||||
kids.addAll(collectChildren(rootNode));
|
||||
} else {
|
||||
List<Object> list = Arrays.asList(getTreeStructure().getChildElements(root));
|
||||
for (Object each : list) {
|
||||
kids.add((AbstractTreeNode)each);
|
||||
}
|
||||
}
|
||||
|
||||
yield(new Runnable() {
|
||||
public void run() {
|
||||
expandChild(kids, 0, nonStopCondition, file, element, async, indicator, target);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return async;
|
||||
}
|
||||
|
||||
private void expandChild(final List<AbstractTreeNode> kids, final int i, final Condition<AbstractTreeNode> nonStopCondition, final VirtualFile file,
|
||||
final Object element,
|
||||
final AsyncResult<AbstractTreeNode> async, final ProgressIndicator indicator) {
|
||||
final AsyncResult<AbstractTreeNode> async, final ProgressIndicator indicator, final Ref<Object> virtualSelectTarget) {
|
||||
|
||||
if (i >= kids.size()) {
|
||||
async.setRejected();
|
||||
@@ -263,7 +343,7 @@ public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
|
||||
}
|
||||
|
||||
if (nonStopCondition.value(eachKid)) {
|
||||
expandPathTo(file, eachKid, element, nonStopCondition, indicator).doWhenDone(new AsyncResult.Handler<AbstractTreeNode>() {
|
||||
expandPathTo(file, eachKid, element, nonStopCondition, indicator, virtualSelectTarget).doWhenDone(new AsyncResult.Handler<AbstractTreeNode>() {
|
||||
public void run(AbstractTreeNode abstractTreeNode) {
|
||||
indicator.checkCanceled();
|
||||
|
||||
@@ -273,10 +353,10 @@ public abstract class BaseProjectTreeBuilder extends AbstractTreeBuilder {
|
||||
public void run() {
|
||||
indicator.checkCanceled();
|
||||
|
||||
if (nodeWasCollapsed[0]) {
|
||||
if (nodeWasCollapsed[0] && virtualSelectTarget == null) {
|
||||
collapseChildren(eachKid, null);
|
||||
}
|
||||
expandChild(kids, i + 1, nonStopCondition, file, element, async, indicator);
|
||||
expandChild(kids, i + 1, nonStopCondition, file, element, async, indicator, virtualSelectTarget);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -97,7 +97,8 @@ public class GroupByTypeComparator implements Comparator<NodeDescriptor> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptor1 == null) return -1;
|
||||
if (descriptor2 == null) return 1;
|
||||
return AlphaComparator.INSTANCE.compare(descriptor1, descriptor2);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ public class TogglePopupHintsPanel implements StatusBarWidget, StatusBarWidget.I
|
||||
return "InspectionProfile";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,17 @@ public class FilterPositionUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiElement searchNonSpaceNonCommentBack(PsiElement element) {
|
||||
return searchNonSpaceNonCommentBack(element, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement searchNonSpaceNonCommentBack(PsiElement element, final boolean strict) {
|
||||
if(element == null || element.getNode() == null) return null;
|
||||
ASTNode leftNeibour = TreeUtil.prevLeaf(element.getNode());
|
||||
while (leftNeibour != null && (leftNeibour.getElementType() == TokenType.WHITE_SPACE || leftNeibour.getPsi() instanceof PsiComment)){
|
||||
leftNeibour = TreeUtil.prevLeaf(leftNeibour);
|
||||
if (!strict) {
|
||||
while (leftNeibour != null && (leftNeibour.getElementType() == TokenType.WHITE_SPACE || leftNeibour.getPsi() instanceof PsiComment)){
|
||||
leftNeibour = TreeUtil.prevLeaf(leftNeibour);
|
||||
}
|
||||
}
|
||||
return leftNeibour != null ? leftNeibour.getPsi() : null;
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.psi.filters.position;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.filters.ElementFilter;
|
||||
import com.intellij.psi.filters.FilterPositionUtil;
|
||||
|
||||
/**
|
||||
* User: spLeaner
|
||||
*/
|
||||
public class AfterElement extends PositionElementFilter {
|
||||
public AfterElement(){}
|
||||
|
||||
public AfterElement(ElementFilter filter){
|
||||
setFilter(filter);
|
||||
}
|
||||
|
||||
public boolean isAcceptable(Object element, PsiElement context){
|
||||
if (!(element instanceof PsiElement)) return false;
|
||||
final PsiElement previous = FilterPositionUtil.searchNonSpaceNonCommentBack((PsiElement) element, true);
|
||||
if(previous != null){
|
||||
return getFilter().isAcceptable(previous, context);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "after(" +getFilter()+")";
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class PsiDocumentManagerImpl extends PsiDocumentManager implements Projec
|
||||
if (!file.getViewProvider().isEventSystemEnabled()) return null;
|
||||
document = FileDocumentManager.getInstance().getDocument(file.getViewProvider().getVirtualFile());
|
||||
|
||||
if (!file.getViewProvider().isPhysical()) {
|
||||
if (document != null && !file.getViewProvider().isPhysical()) {
|
||||
cachePsi(document, file);
|
||||
}
|
||||
|
||||
|
||||
@@ -384,7 +384,6 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
}
|
||||
|
||||
final Ref<Boolean> cancelled = new Ref<Boolean>(Boolean.FALSE);
|
||||
final GlobalSearchScope finalScope = searchScope;
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (progress != null) progress.checkCanceled();
|
||||
|
||||
@@ -394,16 +393,15 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
public void run() {
|
||||
CharSequence text = psiFile.getViewProvider().getContents();
|
||||
for (int index = LowLevelSearchUtil.searchWord(text, 0, text.length(), searcher, progress); index >= 0;) {
|
||||
PsiReference referenceAt = psiFile.findReferenceAt(index);
|
||||
if (referenceAt == null || originalElement == null ||
|
||||
!PsiSearchScopeUtil.isInScope(getUseScope(originalElement).intersectWith(finalScope), psiFile)) {
|
||||
if (!processor.process(psiFile, index, index + searcher.getPattern().length())) {
|
||||
final int endOffset = index + searcher.getPattern().length();
|
||||
if (originalElement == null || !containsReferenceTo(psiFile, index, endOffset, originalElement)) {
|
||||
if (!processor.process(psiFile, index, endOffset)) {
|
||||
cancelled.set(Boolean.TRUE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
index = LowLevelSearchUtil.searchWord(text, index + searcher.getPattern().length(), text.length(), searcher, progress);
|
||||
index = LowLevelSearchUtil.searchWord(text, endOffset, text.length(), searcher, progress);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -418,6 +416,20 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean containsReferenceTo(@NotNull PsiFile psiFile, int startOffset, int endOffset, @NotNull PsiElement originalElement) {
|
||||
int index = startOffset;
|
||||
while (index < endOffset) {
|
||||
PsiReference referenceAt = psiFile.findReferenceAt(index);
|
||||
if (referenceAt == null) return false;
|
||||
if (referenceAt.isReferenceTo(originalElement)) {
|
||||
return true;
|
||||
}
|
||||
int end = referenceAt.getElement().getTextRange().getStartOffset() + referenceAt.getRangeInElement().getLength();
|
||||
index = Math.max(end, index + 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void processAllFilesWithWord(@NotNull String word, @NotNull GlobalSearchScope scope, @NotNull Processor<PsiFile> processor, final boolean caseSensitively) {
|
||||
myManager.getCacheManager().processFilesWithWord(processor,word, UsageSearchContext.IN_CODE, scope, caseSensitively);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.util.ArrayFactory;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ConcurrentWeakHashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.Arrays;
|
||||
@@ -100,6 +101,7 @@ public class ResolveCache {
|
||||
myRunnablesToRunOnDropCaches.add(r);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <TRef extends PsiReference, TResult> TResult resolve(TRef ref,
|
||||
AbstractResolver<TRef, TResult> resolver,
|
||||
Map<? super TRef,Reference<TResult>>[] maps,
|
||||
|
||||
+15
-1
@@ -383,7 +383,21 @@ public class FileReference implements FileReferenceOwner, PsiPolyVariantReferenc
|
||||
}
|
||||
}
|
||||
}
|
||||
if (root == null) return element;
|
||||
if (root == null) {
|
||||
PsiFileSystemItem _dstItem = FileReferenceHelperRegistrar.NullFileReferenceHelper.INSTANCE.getPsiFileSystemItem(project, dstVFile);
|
||||
if (_dstItem != null) {
|
||||
PsiFileSystemItem _root = FileReferenceHelperRegistrar.NullFileReferenceHelper.INSTANCE.findRoot(project, dstVFile);
|
||||
if (_root != null) {
|
||||
root = _root;
|
||||
dstItem = _dstItem;
|
||||
}
|
||||
}
|
||||
|
||||
if (root == null) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
final String relativePath = PsiFileSystemItemUtil.getRelativePath(root, dstItem);
|
||||
if (relativePath == null) {
|
||||
return element;
|
||||
|
||||
+4
-2
@@ -48,7 +48,7 @@ public class FileReferenceHelperRegistrar {
|
||||
@NotNull
|
||||
public static <T extends PsiFileSystemItem> FileReferenceHelper getNotNullHelper(@NotNull T psiFileSystemItem) {
|
||||
final FileReferenceHelper helper = getHelper(psiFileSystemItem);
|
||||
return helper == null ? new NullFileReferenceHelper() : helper;
|
||||
return helper == null ? NullFileReferenceHelper.INSTANCE : helper;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -67,7 +67,9 @@ public class FileReferenceHelperRegistrar {
|
||||
return element2.getManager().areElementsEquivalent(element1, element2);
|
||||
}
|
||||
|
||||
private static class NullFileReferenceHelper extends FileReferenceHelper {
|
||||
public static class NullFileReferenceHelper extends FileReferenceHelper {
|
||||
|
||||
public static final NullFileReferenceHelper INSTANCE = new NullFileReferenceHelper();
|
||||
|
||||
public PsiFileSystemItem findRoot(final Project project, @NotNull final VirtualFile file) {
|
||||
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class DataManager {
|
||||
|
||||
/**
|
||||
* @return {@link DataContext} constructed by the current focused component
|
||||
* @deprecated use either {@link #getDataContext(java.awt.Component)} or {@link #getDataContextFromFocus())
|
||||
* @deprecated use either {@link #getDataContext(java.awt.Component)} or {@link #getDataContextFromFocus()}
|
||||
*/
|
||||
public abstract DataContext getDataContext();
|
||||
|
||||
|
||||
@@ -492,4 +492,9 @@ public class AbstractTreeBuilder implements Disposable {
|
||||
return app != null && app.isUnitTestMode();
|
||||
}
|
||||
|
||||
public static boolean isToPaintSelection(JTree tree) {
|
||||
AbstractTreeBuilder builder = getBuilderFor(tree);
|
||||
return builder == null ? true : builder.getUi().isToPaintSelection();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.ide.util.treeView;
|
||||
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -39,4 +40,62 @@ public abstract class AbstractTreeStructure {
|
||||
return false;
|
||||
}
|
||||
|
||||
public AsyncResult<Object> revalidateElement(Object element) {
|
||||
return new AsyncResult.Done<Object>(element);
|
||||
}
|
||||
|
||||
public static class Delegate extends AbstractTreeStructure {
|
||||
private AbstractTreeStructure myDelegee;
|
||||
|
||||
public Delegate(AbstractTreeStructure delegee) {
|
||||
myDelegee = delegee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRootElement() {
|
||||
return myDelegee.getRootElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getChildElements(Object element) {
|
||||
return myDelegee.getChildElements(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParentElement(Object element) {
|
||||
return myDelegee.getParentElement(element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NodeDescriptor createDescriptor(Object element, NodeDescriptor parentDescriptor) {
|
||||
return myDelegee.createDescriptor(element, parentDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
myDelegee.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSomethingToCommit() {
|
||||
return myDelegee.hasSomethingToCommit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToBuildChildrenInBackground(Object element) {
|
||||
return myDelegee.isToBuildChildrenInBackground(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysLeaf(Object element) {
|
||||
return myDelegee.isAlwaysLeaf(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncResult revalidateElement(Object element) {
|
||||
return myDelegee.revalidateElement(element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -106,7 +106,6 @@ public class AbstractTreeUi {
|
||||
|
||||
private UpdaterTreeState myUpdaterState;
|
||||
private AbstractTreeBuilder myBuilder;
|
||||
private boolean myReleaseRequested;
|
||||
|
||||
private final Set<DefaultMutableTreeNode> myUpdatingChildren = new HashSet<DefaultMutableTreeNode>();
|
||||
private long myJanitorPollPeriod = Time.SECOND * 10;
|
||||
@@ -172,6 +171,9 @@ public class AbstractTreeUi {
|
||||
|
||||
private Map<DefaultMutableTreeNode, DefaultMutableTreeNode> myCancelledBuild = new WeakHashMap<DefaultMutableTreeNode, DefaultMutableTreeNode>();
|
||||
|
||||
private boolean mySelectionIsAdjusted;
|
||||
private boolean myReleaseRequested;
|
||||
|
||||
protected void init(AbstractTreeBuilder builder,
|
||||
JTree tree,
|
||||
DefaultTreeModel treeModel,
|
||||
@@ -213,14 +215,14 @@ public class AbstractTreeUi {
|
||||
public void showNotify() {
|
||||
myShowing = true;
|
||||
myWasEverShown = true;
|
||||
if (!isReleaseRequested()) {
|
||||
if (canInitiateNewActivity()) {
|
||||
activate(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideNotify() {
|
||||
myShowing = false;
|
||||
if (!validateReleaseRequested()) {
|
||||
if (canInitiateNewActivity()) {
|
||||
deactivate();
|
||||
}
|
||||
}
|
||||
@@ -271,6 +273,13 @@ public class AbstractTreeUi {
|
||||
}
|
||||
}
|
||||
|
||||
private void setHoldSize(boolean holdSize) {
|
||||
if (myTree instanceof com.intellij.ui.treeStructure.Tree) {
|
||||
final com.intellij.ui.treeStructure.Tree tree = (Tree)myTree;
|
||||
tree.setHoldSize(holdSize);
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanUpAll() {
|
||||
final long now = System.currentTimeMillis();
|
||||
final AbstractTreeUi[] uis = ourUi2Countdown.keySet().toArray(new AbstractTreeUi[ourUi2Countdown.size()]);
|
||||
@@ -282,7 +291,7 @@ public class AbstractTreeUi {
|
||||
ourUi2Countdown.remove(eachUi);
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
if (isReleased()) return;
|
||||
if (!canInitiateNewActivity()) return;
|
||||
|
||||
myCleanupTask = null;
|
||||
getBuilder().cleanUp();
|
||||
@@ -301,7 +310,7 @@ public class AbstractTreeUi {
|
||||
protected void doCleanUp() {
|
||||
Runnable cleanup = new Runnable() {
|
||||
public void run() {
|
||||
if (!isReleaseRequested()) {
|
||||
if (canInitiateNewActivity()) {
|
||||
cleanUpNow();
|
||||
}
|
||||
}
|
||||
@@ -363,8 +372,8 @@ public class AbstractTreeUi {
|
||||
|
||||
if (!myWasEverShown) return;
|
||||
|
||||
if (isNodeActionsPending()) {
|
||||
cancelBackgroundLoading();
|
||||
if (!isReady()) {
|
||||
cancelUpdate();
|
||||
myUpdateFromRootRequested = true;
|
||||
}
|
||||
|
||||
@@ -385,15 +394,12 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
public void requestRelease() {
|
||||
if (isReleaseRequested()) return;
|
||||
|
||||
assertIsDispatchThread();
|
||||
|
||||
myReleaseRequested = true;
|
||||
|
||||
getUpdater().requestRelease();
|
||||
|
||||
maybeReady();
|
||||
cancelUpdate().doWhenDone(new Runnable() {
|
||||
public void run() {
|
||||
releaseNow();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void releaseNow() {
|
||||
@@ -429,24 +435,6 @@ public class AbstractTreeUi {
|
||||
myYeildingDoneRunnables.clear();
|
||||
}
|
||||
|
||||
public boolean isReleaseRequested() {
|
||||
return myReleaseRequested;
|
||||
}
|
||||
|
||||
public boolean validateReleaseRequested() {
|
||||
if (isReleaseRequested()) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
maybeReady();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReleased() {
|
||||
return myBuilder == null;
|
||||
}
|
||||
@@ -455,14 +443,9 @@ public class AbstractTreeUi {
|
||||
if (!myUnbuiltNodes.contains(node)) return;
|
||||
if (isLoadedInBackground(getElementFor(node))) return;
|
||||
|
||||
if (!isReleaseRequested()) {
|
||||
getTreeStructure().commit();
|
||||
addSubtreeToUpdate(node);
|
||||
getUpdater().performUpdate();
|
||||
}
|
||||
else {
|
||||
processNodeActionsIfReady(node);
|
||||
}
|
||||
getTreeStructure().commit();
|
||||
addSubtreeToUpdate(node);
|
||||
getUpdater().performUpdate();
|
||||
}
|
||||
|
||||
public final AbstractTreeStructure getTreeStructure() {
|
||||
@@ -812,12 +795,11 @@ public class AbstractTreeUi {
|
||||
else {
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
if (!validateReleaseRequested()) {
|
||||
result.setDone(_update(nodeDescriptor));
|
||||
}
|
||||
else {
|
||||
result.setRejected();
|
||||
}
|
||||
execute(new Runnable() {
|
||||
public void run() {
|
||||
result.setDone(_update(nodeDescriptor));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -861,6 +843,8 @@ public class AbstractTreeUi {
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new ProcessCanceledException();
|
||||
} catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
} finally {
|
||||
myStateLock.readLock().release();
|
||||
}
|
||||
@@ -962,7 +946,10 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
final void updateSubtreeNow(TreeUpdatePass pass, boolean canSmartExpand) {
|
||||
|
||||
|
||||
maybeSetBusyAndScheduleWaiterForReady(true);
|
||||
setHoldSize(true);
|
||||
|
||||
boolean consumed = initRootNodeNowIfNeeded(pass);
|
||||
if (consumed) return;
|
||||
@@ -1086,13 +1073,7 @@ public class AbstractTreeUi {
|
||||
|
||||
if (processAlwaysLeaf(node)) return;
|
||||
|
||||
Pair<Boolean, LoadedChildren> unbuilt;
|
||||
try {
|
||||
unbuilt = processUnbuilt(node, descriptor, pass, wasExpanded, null);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
return;
|
||||
}
|
||||
Pair<Boolean, LoadedChildren> unbuilt = processUnbuilt(node, descriptor, pass, wasExpanded, null);
|
||||
|
||||
if (unbuilt.getFirst()) return;
|
||||
preloaded.set(unbuilt.getSecond());
|
||||
@@ -1127,6 +1108,8 @@ public class AbstractTreeUi {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (isReleased()) return;
|
||||
|
||||
processNodeActionsIfReady(node);
|
||||
}
|
||||
}
|
||||
@@ -1191,7 +1174,9 @@ public class AbstractTreeUi {
|
||||
final boolean wasExpanded,
|
||||
final boolean wasLeaf,
|
||||
final boolean forceUpdate) {
|
||||
if (!canInitiateNewActivity()) return;
|
||||
if (!canInitiateNewActivity()) {
|
||||
throw new ProcessCanceledException();
|
||||
}
|
||||
|
||||
final NodeDescriptor descriptor = getDescriptorFrom(node);
|
||||
|
||||
@@ -1533,7 +1518,7 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
private boolean isRerunNeeded(TreeUpdatePass pass) {
|
||||
if (pass.isExpired()) return false;
|
||||
if (pass.isExpired() || !canInitiateNewActivity()) return false;
|
||||
|
||||
final boolean rerunBecauseTreeIsHidden = !pass.isExpired() && !isTreeShowing() && getUpdater().isInPostponeMode();
|
||||
|
||||
@@ -1552,11 +1537,6 @@ public class AbstractTreeUi {
|
||||
pass.setCurrentNode(node);
|
||||
boolean wasRun = yieldAndRun(new Runnable() {
|
||||
public void run() {
|
||||
if (validateReleaseRequested()) {
|
||||
result.setRejected();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pass.isExpired()) {
|
||||
result.setRejected();
|
||||
return;
|
||||
@@ -1634,13 +1614,15 @@ public class AbstractTreeUi {
|
||||
if (node != null) {
|
||||
addToCancelled(node);
|
||||
}
|
||||
resetToReady();
|
||||
if (!isReleased()) {
|
||||
resetToReady();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canInitiateNewActivity() {
|
||||
return !myResettingToReadyNow.get();
|
||||
return !myResettingToReadyNow.get() && !myReleaseRequested && !isReleased();
|
||||
}
|
||||
|
||||
private ActionCallback resetToReady() {
|
||||
@@ -1652,14 +1634,13 @@ public class AbstractTreeUi {
|
||||
|
||||
invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
resetToReadyNow();
|
||||
|
||||
Progressive[] progressives = myBatchIndicators.keySet().toArray(new Progressive[myBatchIndicators.size()]);
|
||||
for (Progressive each : progressives) {
|
||||
myBatchIndicators.remove(each).cancel();
|
||||
myBatchCallbacks.remove(each).setRejected();
|
||||
}
|
||||
|
||||
resetToReadyNow();
|
||||
|
||||
myResettingToReadyNow.set(false);
|
||||
result.setDone();
|
||||
@@ -1698,6 +1679,8 @@ public class AbstractTreeUi {
|
||||
|
||||
myDeferredExpansions.clear();
|
||||
myDeferredSelections.clear();
|
||||
|
||||
maybeReady();
|
||||
}
|
||||
|
||||
public void addToCancelled(DefaultMutableTreeNode node) {
|
||||
@@ -1723,8 +1706,6 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
private boolean yieldAndRun(final Runnable runnable, final TreeUpdatePass pass) {
|
||||
if (validateReleaseRequested()) return false;
|
||||
|
||||
myYeildingPasses.add(pass);
|
||||
myYeildingNow = true;
|
||||
yield(new Runnable() {
|
||||
@@ -1745,19 +1726,39 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
private boolean hasSheduledUpdates() {
|
||||
return getUpdater().hasNodesToUpdate() || isLoadingInBackgroundNow();
|
||||
return getUpdater().hasNodesToUpdate();
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return isIdle() && !hasPendingWork() && !isNodeActionsPending();
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return "isReady=" + isReady() + "\n" +
|
||||
" isIdle=" + isIdle() + "\n" +
|
||||
" isYeildingNow=" + isYeildingNow() + "\n" +
|
||||
" isWorkerBusy=" + isWorkerBusy() + "\n" +
|
||||
" hasUpdatingNow=" + hasUpdatingNow() + "\n" +
|
||||
" isLoadingInBackgroundNow=" + isLoadingInBackgroundNow() + "\n" +
|
||||
" hasPendingWork=" + hasPendingWork() + "\n" +
|
||||
" hasNodesToUpdate=" + hasNodesToUpdate() + "\n" +
|
||||
" updaterState=" + myUpdaterState + "\n" +
|
||||
" hasScheduledUpdates=" + hasSheduledUpdates() + "\n" +
|
||||
" isPostponedMode=" + getUpdater().isInPostponeMode() + "\n" +
|
||||
" nodeActions=" + myNodeActions.keySet() + "\n" +
|
||||
"isReleased=" + isReleased() + "\n" +
|
||||
" isReleaseRequested=" + isReleaseRequested() + "\n" +
|
||||
"isCancelProcessed=" + isCancelProcessed() + "\n" +
|
||||
" isCancelRequested=" + myCancelRequest + "\n" +
|
||||
" isResettingToReadyNow=" + myResettingToReadyNow;
|
||||
}
|
||||
|
||||
public boolean hasPendingWork() {
|
||||
return hasNodesToUpdate() || (myUpdaterState != null && myUpdaterState.isProcessingNow());
|
||||
return hasNodesToUpdate() || (myUpdaterState != null && myUpdaterState.isProcessingNow()) || (hasSheduledUpdates() && !getUpdater().isInPostponeMode());
|
||||
}
|
||||
|
||||
public boolean isIdle() {
|
||||
return !isYeildingNow() && !isWorkerBusy() && (!hasSheduledUpdates() || getUpdater().isInPostponeMode());
|
||||
return !isYeildingNow() && !isWorkerBusy() && !hasUpdatingNow() && !isLoadingInBackgroundNow();
|
||||
}
|
||||
|
||||
private void executeYieldingRequest(Runnable runnable, TreeUpdatePass pass) {
|
||||
@@ -1766,7 +1767,9 @@ public class AbstractTreeUi {
|
||||
runnable.run();
|
||||
}
|
||||
finally {
|
||||
maybeYeildingFinished();
|
||||
if (!isReleased()) {
|
||||
maybeYeildingFinished();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1783,27 +1786,23 @@ public class AbstractTreeUi {
|
||||
if (isReleased()) return;
|
||||
|
||||
if (isReady()) {
|
||||
if (isReleaseRequested()) {
|
||||
releaseNow();
|
||||
return;
|
||||
}
|
||||
myInitialized.setDone();
|
||||
|
||||
if (myTree.isShowing() || myUpdateIfInactive) {
|
||||
myInitialized.setDone();
|
||||
}
|
||||
if (canInitiateNewActivity()) {
|
||||
if (myUpdaterState != null && !myUpdaterState.isProcessingNow()) {
|
||||
UpdaterTreeState oldState = myUpdaterState;
|
||||
if (!myUpdaterState.restore(null)) {
|
||||
setUpdaterState(oldState);
|
||||
}
|
||||
|
||||
|
||||
if (myUpdaterState != null && !myUpdaterState.isProcessingNow()) {
|
||||
UpdaterTreeState oldState = myUpdaterState;
|
||||
if (!myUpdaterState.restore(null)) {
|
||||
setUpdaterState(oldState);
|
||||
}
|
||||
|
||||
if (!isReady()) {
|
||||
return;
|
||||
if (!isReady()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setHoldSize(false);
|
||||
|
||||
if (myTree.isShowing()) {
|
||||
if (getBuilder().isToEnsureSelectionOnFocusGained() && Registry.is("ide.tree.ensureSelectionOnFocusGained")) {
|
||||
TreeUtil.ensureSelection(myTree);
|
||||
@@ -1813,6 +1812,19 @@ public class AbstractTreeUi {
|
||||
if (myInitialized.isDone()) {
|
||||
myBusyObject.onReady();
|
||||
}
|
||||
|
||||
if (canInitiateNewActivity()) {
|
||||
TreePath[] selection = getTree().getSelectionPaths();
|
||||
Rectangle visible = getTree().getVisibleRect();
|
||||
if (selection != null) {
|
||||
for (TreePath each : selection) {
|
||||
Rectangle bounds = getTree().getPathBounds(each);
|
||||
if (bounds != null && (visible.contains(bounds) || visible.intersects(bounds))) {
|
||||
getTree().repaint(bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2042,7 +2054,7 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
public boolean hasNodesToUpdate() {
|
||||
return getUpdater().hasNodesToUpdate() || hasUpdatingNow() || isLoadingInBackgroundNow();
|
||||
return getUpdater().hasNodesToUpdate();
|
||||
}
|
||||
|
||||
public List<Object> getExpandedElements() {
|
||||
@@ -2070,8 +2082,13 @@ public class AbstractTreeUi {
|
||||
resetToReadyNow();
|
||||
done.setDone();
|
||||
} else {
|
||||
requestCancel();
|
||||
getReady(this).notify(done);
|
||||
if (isIdle() && hasPendingWork()) {
|
||||
resetToReadyNow();
|
||||
done.setDone();
|
||||
} else {
|
||||
requestCancel();
|
||||
getReady(this).notify(done);
|
||||
}
|
||||
}
|
||||
|
||||
maybeReady();
|
||||
@@ -2108,6 +2125,8 @@ public class AbstractTreeUi {
|
||||
try {
|
||||
progressive.run(indicator);
|
||||
} finally {
|
||||
if (isReleased()) return new ActionCallback.Rejected();
|
||||
|
||||
getReady(this).doWhenDone(new Runnable() {
|
||||
public void run() {
|
||||
if (myBatchIndicators.containsKey(progressive)) {
|
||||
@@ -2136,6 +2155,14 @@ public class AbstractTreeUi {
|
||||
return myCancelRequest.get() || myResettingToReadyNow.get();
|
||||
}
|
||||
|
||||
public boolean isToPaintSelection() {
|
||||
return isReady() || !mySelectionIsAdjusted;
|
||||
}
|
||||
|
||||
public boolean isReleaseRequested() {
|
||||
return myReleaseRequested;
|
||||
}
|
||||
|
||||
static class ElementNode extends DefaultMutableTreeNode {
|
||||
|
||||
Set<Object> myElements = new HashSet<Object>();
|
||||
@@ -2220,8 +2247,6 @@ public class AbstractTreeUi {
|
||||
private boolean queueBackgroundUpdate(final UpdateInfo updateInfo, final DefaultMutableTreeNode node) {
|
||||
assertIsDispatchThread();
|
||||
|
||||
if (validateReleaseRequested()) return false;
|
||||
|
||||
final Object oldElementFromDescriptor = getElementFromDescriptor(updateInfo.getDescriptor());
|
||||
|
||||
UpdateInfo loaded = getLoadedInBackground(oldElementFromDescriptor);
|
||||
@@ -2266,7 +2291,6 @@ public class AbstractTreeUi {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!updateInfo.isDescriptorIsUpToDate()) {
|
||||
update(updateInfo.getDescriptor(), true);
|
||||
}
|
||||
@@ -2281,6 +2305,7 @@ public class AbstractTreeUi {
|
||||
elementFromDescriptor.set(element);
|
||||
|
||||
Object[] loadedElements = getChildrenFor(getBuilder().getTreeStructureElement(updateInfo.getDescriptor()));
|
||||
|
||||
LoadedChildren loaded = new LoadedChildren(loadedElements);
|
||||
for (Object each : loadedElements) {
|
||||
NodeDescriptor eachChildDescriptor = getTreeStructure().createDescriptor(each, updateInfo.getDescriptor());
|
||||
@@ -2288,6 +2313,12 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
children.set(loaded);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "runnable=" + oldElementFromDescriptor;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2396,8 +2427,10 @@ public class AbstractTreeUi {
|
||||
if (!isUpdatingParent(node) && !isWorkerBusy()) {
|
||||
final UpdaterTreeState state = myUpdaterState;
|
||||
if (myNodeActions.size() == 0 && state != null && !state.isProcessingNow()) {
|
||||
if (!state.restore(childrenReady ? node : null)) {
|
||||
setUpdaterState(state);
|
||||
if (canInitiateNewActivity()) {
|
||||
if (!state.restore(childrenReady ? node : null)) {
|
||||
setUpdaterState(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2749,6 +2782,8 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
if (toSelect != null) {
|
||||
mySelectionIsAdjusted = isAdjustedSelection;
|
||||
|
||||
myTree.addSelectionPath(toSelect);
|
||||
|
||||
if (isAdjustedSelection && myUpdaterState != null) {
|
||||
@@ -2897,7 +2932,7 @@ public class AbstractTreeUi {
|
||||
|
||||
|
||||
protected ActionCallback queueToBackground(@NotNull final Runnable bgBuildAction, @Nullable final Runnable edtPostRunnable) {
|
||||
if (validateReleaseRequested() || !canInitiateNewActivity()) return new ActionCallback.Rejected();
|
||||
if (!canInitiateNewActivity()) return new ActionCallback.Rejected();
|
||||
|
||||
final ActionCallback result = new ActionCallback();
|
||||
|
||||
@@ -2917,50 +2952,64 @@ public class AbstractTreeUi {
|
||||
|
||||
final Runnable pooledThreadWithProgressRunnable = new Runnable() {
|
||||
public void run() {
|
||||
final AbstractTreeBuilder builder = getBuilder();
|
||||
try {
|
||||
final AbstractTreeBuilder builder = getBuilder();
|
||||
|
||||
if (isReleased() || !canInitiateNewActivity()) return;
|
||||
if (!canInitiateNewActivity()) {
|
||||
throw new ProcessCanceledException();
|
||||
}
|
||||
|
||||
builder.runBackgroundLoading(new Runnable() {
|
||||
public void run() {
|
||||
assertNotDispatchThread();
|
||||
if (isReleased() || !canInitiateNewActivity()) return;
|
||||
builder.runBackgroundLoading(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
execute(bgBuildAction);
|
||||
assertNotDispatchThread();
|
||||
try {
|
||||
if (!canInitiateNewActivity()) {
|
||||
throw new ProcessCanceledException();
|
||||
}
|
||||
|
||||
if (edtPostRunnable != null) {
|
||||
builder.updateAfterLoadedInBackground(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
assertIsDispatchThread();
|
||||
if (isReleased() || !canInitiateNewActivity()) return;
|
||||
execute(bgBuildAction);
|
||||
|
||||
execute(edtPostRunnable);
|
||||
if (edtPostRunnable != null) {
|
||||
|
||||
builder.updateAfterLoadedInBackground(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
assertIsDispatchThread();
|
||||
if (!canInitiateNewActivity()) {
|
||||
throw new ProcessCanceledException();
|
||||
}
|
||||
|
||||
execute(edtPostRunnable);
|
||||
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
fail.set(true);
|
||||
}
|
||||
finally {
|
||||
unregisterWorkerTask(bgBuildAction, finalizer);
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
fail.set(true);
|
||||
}
|
||||
finally {
|
||||
unregisterWorkerTask(bgBuildAction, finalizer);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
unregisterWorkerTask(bgBuildAction, finalizer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
catch (ProcessCanceledException e) {
|
||||
fail.set(true);
|
||||
unregisterWorkerTask(bgBuildAction, finalizer);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
unregisterWorkerTask(bgBuildAction, finalizer);
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
fail.set(true);
|
||||
unregisterWorkerTask(bgBuildAction, finalizer);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
unregisterWorkerTask(bgBuildAction, finalizer);
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
unregisterWorkerTask(bgBuildAction, finalizer);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3007,6 +3056,7 @@ public class AbstractTreeUi {
|
||||
|
||||
private void unregisterWorkerTask(Runnable runnable, @Nullable Runnable finalizeRunnable) {
|
||||
boolean wasRemoved;
|
||||
|
||||
synchronized (myActiveWorkerTasks) {
|
||||
wasRemoved = myActiveWorkerTasks.remove(runnable);
|
||||
}
|
||||
@@ -3127,8 +3177,10 @@ public class AbstractTreeUi {
|
||||
}
|
||||
myTreeModel.nodeStructureChanged(parentNode);
|
||||
|
||||
while (expanded.hasMoreElements()) {
|
||||
expandSilently(expanded.nextElement());
|
||||
if (expanded != null) {
|
||||
while (expanded.hasMoreElements()) {
|
||||
expandSilently(expanded.nextElement());
|
||||
}
|
||||
}
|
||||
|
||||
if (selected != null) {
|
||||
@@ -3187,7 +3239,7 @@ public class AbstractTreeUi {
|
||||
return addSubtreeToUpdate(root, null);
|
||||
}
|
||||
|
||||
public boolean addSubtreeToUpdate(final DefaultMutableTreeNode root, Runnable runAfterUpdate) {
|
||||
public boolean addSubtreeToUpdate(final DefaultMutableTreeNode root, final Runnable runAfterUpdate) {
|
||||
Object element = getElementFor(root);
|
||||
if (getTreeStructure().isAlwaysLeaf(element)) {
|
||||
removeLoading(root, true);
|
||||
@@ -3198,13 +3250,12 @@ public class AbstractTreeUi {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isReleaseRequested()) {
|
||||
processNodeActionsIfReady(root);
|
||||
}
|
||||
else {
|
||||
getUpdater().runAfterUpdate(runAfterUpdate);
|
||||
getUpdater().addSubtreeToUpdate(root);
|
||||
}
|
||||
execute(new Runnable() {
|
||||
public void run() {
|
||||
getUpdater().runAfterUpdate(runAfterUpdate);
|
||||
getUpdater().addSubtreeToUpdate(root);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -3447,16 +3498,49 @@ public class AbstractTreeUi {
|
||||
final boolean deferred,
|
||||
final boolean canBeCentered,
|
||||
final boolean scrollToVisible,
|
||||
boolean canSmartExpand) {
|
||||
final boolean canSmartExpand) {
|
||||
final Runnable _onDone = new Runnable() {
|
||||
public void run() {
|
||||
if (!checkDeferred(deferred, onDone)) return;
|
||||
selectVisible(element, onDone, addToSelection, canBeCentered, scrollToVisible);
|
||||
|
||||
checkPathAndMaybeRevalidate(element, new Runnable() {
|
||||
public void run() {
|
||||
selectVisible(element, onDone, addToSelection, canBeCentered, scrollToVisible);
|
||||
}
|
||||
}, true, false, canSmartExpand);
|
||||
}
|
||||
};
|
||||
_expand(element, _onDone, true, false, canSmartExpand);
|
||||
}
|
||||
|
||||
private void checkPathAndMaybeRevalidate(Object element, final Runnable onDone, final boolean parentsOnly, final boolean checkIfInStructure, final boolean canSmartExpand) {
|
||||
boolean toRevalidate = getNodeForElement(element, false) == null && isInStructure(element);
|
||||
if (!toRevalidate) {
|
||||
runDone(onDone);
|
||||
return;
|
||||
}
|
||||
|
||||
AsyncResult<Object> revalidated = getTreeStructure().revalidateElement(element);
|
||||
if (revalidated == null) {
|
||||
runDone(onDone);
|
||||
return;
|
||||
}
|
||||
|
||||
revalidated.doWhenDone(new AsyncResult.Handler<Object>() {
|
||||
public void run(final Object o) {
|
||||
invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
_expand(o, onDone, parentsOnly, checkIfInStructure, canSmartExpand);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).doWhenRejected(new Runnable() {
|
||||
public void run() {
|
||||
runDone(onDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void scrollSelectionToVisible(@Nullable Runnable onDone, boolean shouldBeCentered) {
|
||||
int[] rows = myTree.getSelectionRows();
|
||||
if (rows == null || rows.length == 0) {
|
||||
@@ -3497,6 +3581,7 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
if (Registry.is("ide.tree.autoscrollToVCenter") && canBeCentered) {
|
||||
setHoldSize(false);
|
||||
runDone(new Runnable() {
|
||||
public void run() {
|
||||
TreeUtil.showRowCentered(myTree, row, false, scroll).doWhenDone(new Runnable() {
|
||||
@@ -3508,6 +3593,7 @@ public class AbstractTreeUi {
|
||||
});
|
||||
}
|
||||
else {
|
||||
setHoldSize(false);
|
||||
TreeUtil.showAndSelect(myTree, row - 2, row + 2, row, -1, addToSelection, scroll).doWhenDone(new Runnable() {
|
||||
public void run() {
|
||||
runDone(onDone);
|
||||
@@ -3764,13 +3850,12 @@ public class AbstractTreeUi {
|
||||
return;
|
||||
}
|
||||
|
||||
final DefaultMutableTreeNode nextNode = getNodeForElement(kidsToExpand.get(expandIndex - 1), false);
|
||||
if (nextNode != null) {
|
||||
processExpand(nextNode, kidsToExpand, expandIndex - 1, onDone, canSmartExpand);
|
||||
}
|
||||
else {
|
||||
runDone(onDone);
|
||||
}
|
||||
checkPathAndMaybeRevalidate(kidsToExpand.get(expandIndex - 1), new Runnable() {
|
||||
public void run() {
|
||||
final DefaultMutableTreeNode nextNode = getNodeForElement(kidsToExpand.get(expandIndex - 1), false);
|
||||
processExpand(nextNode, kidsToExpand, expandIndex - 1, onDone, canSmartExpand);
|
||||
}
|
||||
}, false, false, canSmartExpand);
|
||||
}
|
||||
}, true);
|
||||
|
||||
@@ -3838,8 +3923,6 @@ public class AbstractTreeUi {
|
||||
}
|
||||
|
||||
public final boolean isNodeBeingBuilt(Object node) {
|
||||
if (isReleaseRequested()) return false;
|
||||
|
||||
return getParentBuiltNode(node) != null;
|
||||
}
|
||||
|
||||
@@ -3900,6 +3983,7 @@ public class AbstractTreeUi {
|
||||
if (!isInnerChange()) {
|
||||
clearUpdaterState();
|
||||
myAutoExpandRoots.clear();
|
||||
mySelectionIsAdjusted = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4013,15 +4097,6 @@ public class AbstractTreeUi {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void cancelBackgroundLoading() {
|
||||
if (myWorker != null) {
|
||||
myWorker.cancelTasks();
|
||||
clearWorkerTasks();
|
||||
}
|
||||
|
||||
clearNodeActions();
|
||||
}
|
||||
|
||||
private void addNodeAction(Object element, NodeAction action, boolean shouldChildrenBeReady) {
|
||||
_addNodeAction(element, action, myNodeActions);
|
||||
if (shouldChildrenBeReady) {
|
||||
@@ -4042,7 +4117,7 @@ public class AbstractTreeUi {
|
||||
|
||||
|
||||
private void cleanUpNow() {
|
||||
if (isReleaseRequested()) return;
|
||||
if (!canInitiateNewActivity()) return;
|
||||
|
||||
final UpdaterTreeState state = new UpdaterTreeState(this);
|
||||
|
||||
|
||||
@@ -197,6 +197,8 @@ public class AbstractTreeUpdater implements Disposable, Activatable {
|
||||
}
|
||||
|
||||
private void queue(Update update) {
|
||||
if (isReleased()) return;
|
||||
|
||||
myUpdateQueue.queue(update);
|
||||
}
|
||||
|
||||
@@ -233,6 +235,8 @@ public class AbstractTreeUpdater implements Disposable, Activatable {
|
||||
});
|
||||
}
|
||||
|
||||
if (isReleased()) return;
|
||||
|
||||
myTreeBuilder.getUi().maybeReady();
|
||||
|
||||
if (myRunAfterUpdate != null) {
|
||||
@@ -257,6 +261,10 @@ public class AbstractTreeUpdater implements Disposable, Activatable {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isReleased() {
|
||||
return myTreeBuilder.getUi() == null;
|
||||
}
|
||||
|
||||
protected void invokeLater(Runnable runnable) {
|
||||
if (myTreeBuilder.getUi().isPassthroughMode()) {
|
||||
runnable.run();
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.actionSystem;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.beans.PropertyChangeListener;
|
||||
@@ -174,13 +175,14 @@ public final class Presentation implements Cloneable {
|
||||
setText(presentation.getTextWithMnemonic());
|
||||
}
|
||||
|
||||
public static String restoreTextWithMnemonic(final String text, final int mnemonic) {
|
||||
if (text != null) {
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (Character.toUpperCase(text.charAt(i)) == mnemonic) {
|
||||
return text.replaceFirst(String.valueOf(text.charAt(i)), "_" + text.charAt(i));
|
||||
}
|
||||
}
|
||||
public static String restoreTextWithMnemonic(@Nullable String text, final int mnemonic) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (Character.toUpperCase(text.charAt(i)) == mnemonic) {
|
||||
return text.substring(0, i) + "_" + text.substring(i);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.*;
|
||||
@@ -134,6 +135,9 @@ public class SimpleTimer {
|
||||
try {
|
||||
each.run();
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
@@ -33,16 +33,20 @@ public interface StatusBar extends StatusBarInfo {
|
||||
abstract class Info implements StatusBarInfo {
|
||||
public static final Topic<StatusBarInfo> TOPIC = Topic.create("IdeStatusBar.Text", StatusBarInfo.class);
|
||||
|
||||
private Info() {}
|
||||
private Info() {
|
||||
}
|
||||
|
||||
public static void set(@Nullable final String text, @Nullable final Project project) {
|
||||
if (project != null && !project.isInitialized() && !project.isDisposed()) {
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
|
||||
public void run() {
|
||||
project.getMessageBus().syncPublisher(TOPIC).setInfo(text);
|
||||
}
|
||||
});
|
||||
return;
|
||||
if (project != null) {
|
||||
if (project.isDisposed()) return;
|
||||
if (!project.isInitialized()) {
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
|
||||
public void run() {
|
||||
project.getMessageBus().syncPublisher(TOPIC).setInfo(text);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final MessageBus bus = project == null ? ApplicationManager.getApplication().getMessageBus() : project.getMessageBus();
|
||||
@@ -51,9 +55,11 @@ public interface StatusBar extends StatusBarInfo {
|
||||
}
|
||||
|
||||
void addWidget(@NotNull StatusBarWidget widget);
|
||||
|
||||
void addWidget(@NotNull StatusBarWidget widget, @NotNull String anchor);
|
||||
|
||||
|
||||
void addWidget(@NotNull StatusBarWidget widget, @NotNull Disposable parentDisposable);
|
||||
|
||||
void addWidget(@NotNull StatusBarWidget widget, @NotNull String anchor, @NotNull Disposable parentDisposable);
|
||||
|
||||
/**
|
||||
@@ -61,9 +67,11 @@ public interface StatusBar extends StatusBarInfo {
|
||||
*/
|
||||
@Deprecated
|
||||
void addCustomIndicationComponent(@NotNull JComponent c);
|
||||
|
||||
void removeCustomIndicationComponent(@NotNull JComponent c);
|
||||
|
||||
void removeWidget(@NotNull String id);
|
||||
|
||||
void updateWidget(@NotNull String id);
|
||||
|
||||
void fireNotificationPopup(@NotNull JComponent content, Color backgroundColor);
|
||||
|
||||
@@ -15,16 +15,17 @@
|
||||
*/
|
||||
package com.intellij.openapi.wm;
|
||||
|
||||
import com.intellij.openapi.*;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.util.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
/**
|
||||
* User: spLeaner
|
||||
@@ -35,7 +36,7 @@ public interface StatusBarWidget extends Disposable {
|
||||
DEFAULT, MAC
|
||||
}
|
||||
|
||||
interface Presentation {
|
||||
interface WidgetPresentation {
|
||||
@Nullable
|
||||
String getTooltipText();
|
||||
|
||||
@@ -43,12 +44,12 @@ public interface StatusBarWidget extends Disposable {
|
||||
Consumer<MouseEvent> getClickConsumer();
|
||||
}
|
||||
|
||||
interface IconPresentation extends Presentation {
|
||||
interface IconPresentation extends WidgetPresentation {
|
||||
@NotNull
|
||||
Icon getIcon();
|
||||
}
|
||||
|
||||
interface TextPresentation extends Presentation {
|
||||
interface TextPresentation extends WidgetPresentation {
|
||||
@NotNull
|
||||
String getText();
|
||||
|
||||
@@ -56,7 +57,7 @@ public interface StatusBarWidget extends Disposable {
|
||||
String getMaxPossibleText();
|
||||
}
|
||||
|
||||
interface MultipleTextValuesPresentation extends Presentation {
|
||||
interface MultipleTextValuesPresentation extends WidgetPresentation {
|
||||
@NotNull
|
||||
ListPopup getPopupStep();
|
||||
|
||||
@@ -71,7 +72,7 @@ public interface StatusBarWidget extends Disposable {
|
||||
String ID();
|
||||
|
||||
@Nullable
|
||||
Presentation getPresentation(@NotNull Type type);
|
||||
WidgetPresentation getPresentation(@NotNull Type type);
|
||||
|
||||
void install(@NotNull final StatusBar statusBar);
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.plaf.TreeUI;
|
||||
import javax.swing.plaf.basic.BasicTreeUI;
|
||||
import javax.swing.text.Position;
|
||||
@@ -47,6 +48,9 @@ public class Tree extends JTree implements ComponentWithEmptyText, Autoscroll, Q
|
||||
private boolean myBusy;
|
||||
private Rectangle myLastVisibleRec;
|
||||
|
||||
private Dimension myHoldSize;
|
||||
private MySelectionModel mySelectionModel = new MySelectionModel();
|
||||
|
||||
public Tree() {
|
||||
initTree_();
|
||||
}
|
||||
@@ -78,6 +82,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, Autoscroll, Q
|
||||
}
|
||||
|
||||
setCellRenderer(new NodeRenderer());
|
||||
|
||||
setSelectionModel(mySelectionModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,15 +165,25 @@ public class Tree extends JTree implements ComponentWithEmptyText, Autoscroll, Q
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
|
||||
Rectangle clip = g.getClipBounds();
|
||||
final Rectangle visible = getVisibleRect();
|
||||
|
||||
if (!visible.equals(myLastVisibleRec)) {
|
||||
updateBusyIconLocation();
|
||||
if (!AbstractTreeBuilder.isToPaintSelection(this)) {
|
||||
mySelectionModel.holdSelection();
|
||||
}
|
||||
|
||||
myLastVisibleRec = visible;
|
||||
try {
|
||||
super.paint(g);
|
||||
|
||||
if (!visible.equals(myLastVisibleRec)) {
|
||||
updateBusyIconLocation();
|
||||
}
|
||||
|
||||
myLastVisibleRec = visible;
|
||||
}
|
||||
finally {
|
||||
mySelectionModel.unholdSelection();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPaintBusy(boolean paintBusy) {
|
||||
@@ -184,14 +200,26 @@ public class Tree extends JTree implements ComponentWithEmptyText, Autoscroll, Q
|
||||
myBusyIcon.setOpaque(false);
|
||||
myBusyIcon.setPaintPassiveIcon(false);
|
||||
add(myBusyIcon);
|
||||
myBusyIcon.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (!UIUtil.isActionClick(e)) return;
|
||||
AbstractTreeBuilder builder = AbstractTreeBuilder.getBuilderFor(Tree.this);
|
||||
if (builder != null) {
|
||||
builder.cancelUpdate();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (myBusyIcon != null) {
|
||||
if (myBusy) {
|
||||
myBusyIcon.resume();
|
||||
myBusyIcon.setToolTipText("Update is in progress. Click to cancel");
|
||||
} else {
|
||||
myBusyIcon.suspend();
|
||||
myBusyIcon.setToolTipText(null);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (myBusyIcon != null) {
|
||||
@@ -439,6 +467,30 @@ public class Tree extends JTree implements ComponentWithEmptyText, Autoscroll, Q
|
||||
return treeNode != null ? new TreePath(treeNode.getPath()) : new TreePath(node);
|
||||
}
|
||||
|
||||
private static class MySelectionModel extends DefaultTreeSelectionModel {
|
||||
|
||||
private TreePath[] myHeldSelection;
|
||||
|
||||
@Override
|
||||
protected void fireValueChanged(TreeSelectionEvent e) {
|
||||
if (myHeldSelection == null) {
|
||||
super.fireValueChanged(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void holdSelection() {
|
||||
myHeldSelection = getSelectionPaths();
|
||||
clearSelection();
|
||||
}
|
||||
|
||||
public void unholdSelection() {
|
||||
if (myHeldSelection != null) {
|
||||
setSelectionPaths(myHeldSelection);
|
||||
myHeldSelection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MyMouseListener extends MouseAdapter {
|
||||
public void mousePressed(MouseEvent mouseevent) {
|
||||
if (!SwingUtilities.isLeftMouseButton(mouseevent) &&
|
||||
@@ -539,4 +591,24 @@ public class Tree extends JTree implements ComponentWithEmptyText, Autoscroll, Q
|
||||
public void reshape(int x, int y, int w, int h) {
|
||||
super.reshape(x, y, w, h);
|
||||
}
|
||||
|
||||
public void setHoldSize(boolean hold) {
|
||||
if (hold && myHoldSize == null) {
|
||||
myHoldSize = getPreferredSize();
|
||||
} else if (!hold && myHoldSize != null) {
|
||||
myHoldSize = null;
|
||||
revalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension size = super.getPreferredSize();
|
||||
|
||||
if (myHoldSize != null) {
|
||||
size.width = Math.max(size.width, myHoldSize.width);
|
||||
size.height = Math.max(size.height, myHoldSize.height);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
@@ -48,10 +48,8 @@ public class QueueProcessor<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanAndWait() throws InterruptedException {
|
||||
public void waitFor() throws InterruptedException {
|
||||
synchronized (myQueue) {
|
||||
myQueue.clear();
|
||||
|
||||
while (isProcessing) {
|
||||
myQueue.wait();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.intellij.util.io;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
public abstract class ReaderProcess {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.ReaderProcess");
|
||||
|
||||
private final Reader myReader;
|
||||
private final char[] myBuffer = new char[4096];
|
||||
private final Semaphore myReadSemaphore = new Semaphore();
|
||||
private boolean isClosed;
|
||||
|
||||
public ReaderProcess(Reader reader) throws IOException {
|
||||
myReader = reader;
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
doRun();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void doRun() {
|
||||
try {
|
||||
while (true) {
|
||||
while (!myReader.ready()) {
|
||||
synchronized (this) {
|
||||
myReadSemaphore.up();
|
||||
wait(300);
|
||||
if (isClosed) return;
|
||||
}
|
||||
}
|
||||
int read = myReader.read(myBuffer);
|
||||
if (read == -1) break;
|
||||
|
||||
onTextAvailable(new String(myBuffer, 0, read));
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (isClosed) return;
|
||||
LOG.warn(e);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOG.warn(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void onTextAvailable(String text);
|
||||
|
||||
public void readFully() throws InterruptedException {
|
||||
synchronized (this) {
|
||||
myReadSemaphore.down();
|
||||
notifyAll();
|
||||
}
|
||||
myReadSemaphore.waitForUnsafe();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
synchronized (this) {
|
||||
isClosed = true;
|
||||
notifyAll();
|
||||
}
|
||||
myReader.close();
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public abstract class AnimatedIcon extends JComponent implements Disposable {
|
||||
myEmptyPassiveIcon = new EmptyIcon(0);
|
||||
}
|
||||
|
||||
setOpaque(true);
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public void setPaintPassiveIcon(boolean paintPassive) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class IdeMessagePanel extends JPanel implements MessagePoolListener, Cust
|
||||
return "FatalError";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class IdeNotificationArea implements StatusBarWidget, StatusBarWidget.Ico
|
||||
public IdeNotificationArea() {
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.util.containers.WeakValueHashMap;
|
||||
import com.intellij.util.io.fs.FilePath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
|
||||
@@ -269,6 +269,8 @@ public class KeymapImpl implements Keymap, ExternalizableScheme {
|
||||
}
|
||||
|
||||
private Map<KeyStroke, List<String>> getKeystroke2ListOfIds() {
|
||||
if (myKeystroke2ListOfIds != null) return myKeystroke2ListOfIds;
|
||||
|
||||
myKeystroke2ListOfIds = new THashMap<KeyStroke, List<String>>();
|
||||
for (String id : ContainerUtil.concat(myActionId2ListOfShortcuts.keySet(), getKeymapManager().getBoundActions())) {
|
||||
addKeystrokesMap(id, myKeystroke2ListOfIds);
|
||||
|
||||
@@ -42,4 +42,7 @@ public interface StatusBarEx extends StatusBar, Disposable {
|
||||
boolean isProcessWindowOpen();
|
||||
|
||||
void setProcessWindowOpen(boolean open);
|
||||
|
||||
@Deprecated
|
||||
void removeCustomIndicationComponents();
|
||||
}
|
||||
|
||||
@@ -261,6 +261,8 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider {
|
||||
statusBar.removeWidget(positionPanel.ID());
|
||||
statusBar.removeWidget(readOnlyAttributePanel.ID());
|
||||
if (finalInsertOverwritePanel != null) statusBar.removeWidget(finalInsertOverwritePanel.ID());
|
||||
|
||||
((StatusBarEx)statusBar).removeCustomIndicationComponents();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
return c.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,9 @@ public final class TestWindowManager extends WindowManagerEx implements Applicat
|
||||
public void setProcessWindowOpen(final boolean open) {
|
||||
}
|
||||
|
||||
public void removeCustomIndicationComponents() {
|
||||
}
|
||||
|
||||
public BalloonHandler notifyProgressByBalloon(@NotNull MessageType type, @NotNull String htmlBody) {
|
||||
return new BalloonHandler() {
|
||||
public void hide() {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class EncodingPanel implements StatusBarWidget, StatusBarWidget.MultipleT
|
||||
return "Encoding";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+25
-12
@@ -53,10 +53,10 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
private JPanel myRightPanel;
|
||||
private JPanel myCenterPanel;
|
||||
|
||||
private ProcessIconWidget myProcessWidget;
|
||||
|
||||
private String myInfo;
|
||||
|
||||
private List<String> myCustomComponentIds = new ArrayList<String>();
|
||||
|
||||
private static class WidgetBean {
|
||||
JComponent component;
|
||||
Position position;
|
||||
@@ -73,10 +73,7 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
|
||||
public IdeStatusBarImpl() {
|
||||
setLayout(new BorderLayout());
|
||||
setBorder(BorderFactory.createEmptyBorder(1, 2, 0, 2));
|
||||
|
||||
myProcessWidget = new ProcessIconWidget();
|
||||
addWidget(myProcessWidget, Position.LEFT);
|
||||
setBorder(BorderFactory.createEmptyBorder(1, 4, 0, 2));
|
||||
|
||||
myInfoAndProgressPanel = new InfoAndProgressPanel();
|
||||
addWidget(myInfoAndProgressPanel, Position.CENTER);
|
||||
@@ -115,15 +112,24 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
});
|
||||
}
|
||||
|
||||
public void removeCustomIndicationComponents() {
|
||||
for (final String id : myCustomComponentIds) {
|
||||
removeWidget(id);
|
||||
}
|
||||
|
||||
myCustomComponentIds.clear();
|
||||
}
|
||||
|
||||
public void addCustomIndicationComponent(@NotNull final JComponent c) {
|
||||
final String customId = c.getClass().getName() + new Random().nextLong();
|
||||
addWidget(new CustomStatusBarWidget() {
|
||||
@NotNull
|
||||
public String ID() {
|
||||
return c.getClass().getSimpleName() + new Random().toString();
|
||||
return customId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -137,6 +143,8 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
return c;
|
||||
}
|
||||
});
|
||||
|
||||
myCustomComponentIds.add(customId);
|
||||
}
|
||||
|
||||
public void removeCustomIndicationComponent(@NotNull final JComponent c) {
|
||||
@@ -275,12 +283,12 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
}
|
||||
|
||||
public void startRefreshIndication(String tooltipText) {
|
||||
myProcessWidget.setToolTipText(tooltipText);
|
||||
myProcessWidget.setRefreshVisible(true);
|
||||
myInfoAndProgressPanel.setRefreshToolTipText(tooltipText);
|
||||
myInfoAndProgressPanel.setRefreshVisible(true);
|
||||
}
|
||||
|
||||
public void stopRefreshIndication() {
|
||||
myProcessWidget.setRefreshVisible(false);
|
||||
myInfoAndProgressPanel.setRefreshVisible(false);
|
||||
}
|
||||
|
||||
public BalloonHandler notifyProgressByBalloon(@NotNull MessageType type, @NotNull String htmlBody) {
|
||||
@@ -304,7 +312,7 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
}
|
||||
|
||||
private static JComponent wrap(@NotNull final StatusBarWidget widget) {
|
||||
final StatusBarWidget.Presentation presentation =
|
||||
final StatusBarWidget.WidgetPresentation presentation =
|
||||
widget.getPresentation(SystemInfo.isMac ? StatusBarWidget.Type.MAC : StatusBarWidget.Type.DEFAULT);
|
||||
assert presentation != null : "Presentation should not be null!";
|
||||
|
||||
@@ -431,6 +439,8 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
popup.show(new RelativePoint(e.getComponent(), at));
|
||||
}
|
||||
});
|
||||
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
@@ -485,6 +495,8 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
myMouseOver = false;
|
||||
}
|
||||
});
|
||||
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public void beforeUpdate() {
|
||||
@@ -512,6 +524,7 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
});
|
||||
|
||||
ToolTipManager.sharedInstance().registerComponent(this);
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public void beforeUpdate() {
|
||||
|
||||
+48
-10
@@ -46,6 +46,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
private final ProcessPopup myPopup;
|
||||
|
||||
private final TextPanel myInfoPanel = new TextPanel();
|
||||
private final JPanel myRefreshAndInfoPanel = new JPanel();
|
||||
private final AsyncProcessIcon myProgressIcon;
|
||||
|
||||
private final ArrayList<ProgressIndicatorEx> myOriginals = new ArrayList<ProgressIndicatorEx>();
|
||||
@@ -59,10 +60,32 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
private final Alarm myQueryAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
|
||||
|
||||
private boolean myShouldClosePopupAndOnProcessFinish;
|
||||
private AsyncProcessIcon myRefreshIcon;
|
||||
private EmptyIcon myEmptyRefreshIcon;
|
||||
|
||||
public InfoAndProgressPanel() {
|
||||
setOpaque(false);
|
||||
|
||||
myRefreshIcon = new AsyncProcessIcon("Refreshing filesystem") {
|
||||
protected Icon getPassiveIcon() {
|
||||
return myEmptyRefreshIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
if (!isRunning()) return new Dimension(0, 0);
|
||||
return super.getPreferredSize();
|
||||
}
|
||||
};
|
||||
|
||||
myRefreshIcon.setPaintPassiveIcon(false);
|
||||
myEmptyRefreshIcon = new EmptyIcon(0, myRefreshIcon.getPreferredSize().height);
|
||||
|
||||
myRefreshAndInfoPanel.setLayout(new BorderLayout());
|
||||
myRefreshAndInfoPanel.setOpaque(false);
|
||||
myRefreshAndInfoPanel.add(myRefreshIcon, BorderLayout.WEST);
|
||||
myRefreshAndInfoPanel.add(myInfoPanel, BorderLayout.CENTER);
|
||||
|
||||
myProgressIcon = new AsyncProcessIcon("Background process");
|
||||
myProgressIcon.setOpaque(false);
|
||||
|
||||
@@ -92,7 +115,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
return "InfoAndProgress";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -100,6 +123,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
setRefreshVisible(false);
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
@@ -236,7 +260,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
//myProgressIcon.setBorder(new IdeStatusBarImpl.MacStatusBarWidgetBorder());
|
||||
progressCountPanel.add(myProgressIcon, BorderLayout.WEST);
|
||||
|
||||
add(myInfoPanel, BorderLayout.CENTER);
|
||||
add(myRefreshAndInfoPanel, BorderLayout.CENTER);
|
||||
|
||||
progressCountPanel.setBorder(new EmptyBorder(0, 0, 0, 4));
|
||||
add(progressCountPanel, BorderLayout.EAST);
|
||||
@@ -248,7 +272,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
private void buildInInlineIndicator(final InlineProgressIndicator inline) {
|
||||
removeAll();
|
||||
setLayout(new InlineLayout());
|
||||
add(myInfoPanel);
|
||||
add(myRefreshAndInfoPanel);
|
||||
|
||||
final JPanel inlinePanel = new JPanel(new BorderLayout()) {
|
||||
@Override
|
||||
@@ -270,14 +294,30 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
|
||||
add(inlinePanel);
|
||||
|
||||
myInfoPanel.revalidate();
|
||||
myInfoPanel.repaint();
|
||||
myRefreshAndInfoPanel.revalidate();
|
||||
myRefreshAndInfoPanel.repaint();
|
||||
}
|
||||
|
||||
public void setText(final String text) {
|
||||
myInfoPanel.setText(text);
|
||||
}
|
||||
|
||||
public void setRefreshVisible(final boolean visible) {
|
||||
if (visible) {
|
||||
myRefreshIcon.resume();
|
||||
}
|
||||
else {
|
||||
myRefreshIcon.suspend();
|
||||
}
|
||||
|
||||
myRefreshIcon.revalidate();
|
||||
myRefreshIcon.repaint();
|
||||
}
|
||||
|
||||
public void setRefreshToolTipText(final String tooltip) {
|
||||
myRefreshIcon.setToolTipText(tooltip);
|
||||
}
|
||||
|
||||
public BalloonHandler notifyByBalloon(MessageType type, String htmlBody, Icon icon, HyperlinkListener listener) {
|
||||
final Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(
|
||||
htmlBody.replace("\n", "<br>"),
|
||||
@@ -382,9 +422,7 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
private void restoreEmptyStatus() {
|
||||
removeAll();
|
||||
setLayout(new BorderLayout());
|
||||
add(myInfoPanel, BorderLayout.CENTER);
|
||||
|
||||
//myProgressIcon.setBorder(new IdeStatusBarImpl.MacStatusBarWidgetBorder());
|
||||
add(myRefreshAndInfoPanel, BorderLayout.CENTER);
|
||||
|
||||
long wastedTime = ProgressManagerImpl.getWastedTime();
|
||||
if (ApplicationManagerEx.getApplicationEx().isInternal() && wastedTime > 10 * 60 * 1000) {
|
||||
@@ -417,8 +455,8 @@ public class InfoAndProgressPanel extends JPanel implements CustomStatusBarWidge
|
||||
}
|
||||
|
||||
myProgressIcon.suspend();
|
||||
myInfoPanel.revalidate();
|
||||
myInfoPanel.repaint();
|
||||
myRefreshAndInfoPanel.revalidate();
|
||||
myRefreshAndInfoPanel.repaint();
|
||||
}
|
||||
|
||||
private String formatTime(long t) {
|
||||
|
||||
+10
-31
@@ -46,7 +46,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
private final boolean myCompact;
|
||||
private TaskInfo myInfo;
|
||||
|
||||
private final FixedHeightLabel myProcessName = new FixedHeightLabel();
|
||||
private final TextPanel myProcessName = new TextPanel();
|
||||
private boolean myDisposed;
|
||||
|
||||
private long myLastTimeProgressWasAtZero;
|
||||
@@ -81,10 +81,10 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
textAndProgress.add(myText, BorderLayout.CENTER);
|
||||
|
||||
final NonOpaquePanel progressWrapper = new NonOpaquePanel(new GridBagLayout());
|
||||
if (!myInfo.isCancellable()) progressWrapper.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4));
|
||||
final GridBagConstraints c = new GridBagConstraints();
|
||||
c.weightx = 1;
|
||||
c.weighty = 1;
|
||||
c.insets = new Insets(0, 0, 1, myInfo.isCancellable() ? 0 : 4);
|
||||
c.fill = GridBagConstraints.HORIZONTAL;
|
||||
progressWrapper.add(myProgress, c);
|
||||
|
||||
@@ -108,6 +108,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
myProcessName.setFont(font.deriveFont(Font.PLAIN, size));
|
||||
myProcessName.setForeground(UIManager.getColor("Panel.background").brighter().brighter());
|
||||
myProcessName.setBorder(new EmptyBorder(2, 2, 2, 2));
|
||||
myProcessName.setDecorate(false);
|
||||
|
||||
final NonOpaquePanel content = new NonOpaquePanel(new BorderLayout());
|
||||
content.setBorder(new EmptyBorder(2, 2, 2, myInfo.isCancellable() ? 2 : 4));
|
||||
@@ -122,6 +123,9 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
content.add(myProgress, BorderLayout.CENTER);
|
||||
content.add(myText2, BorderLayout.SOUTH);
|
||||
|
||||
myText.setDecorate(false);
|
||||
myText2.setDecorate(false);
|
||||
|
||||
myComponent.setBorder(new EmptyBorder(2, 2, 2, 2));
|
||||
myProgress.setActive(false);
|
||||
}
|
||||
@@ -130,6 +134,8 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
|
||||
if (!myCompact) {
|
||||
myProcessName.recomputeSize();
|
||||
myText.recomputeSize();
|
||||
myText2.recomputeSize();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -274,33 +280,6 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
return myInfo;
|
||||
}
|
||||
|
||||
// TODO: use TextPanel instead
|
||||
private static class FixedHeightLabel extends JLabel {
|
||||
private Dimension myPrefSize;
|
||||
|
||||
public FixedHeightLabel() {
|
||||
setOpaque(false);
|
||||
if (SystemInfo.isMac) setFont(UIUtil.getLabelFont().deriveFont(11.0f));
|
||||
}
|
||||
|
||||
public void recomputeSize() {
|
||||
final String old = getText();
|
||||
setText("XXX");
|
||||
myPrefSize = getPreferredSize();
|
||||
setText(old);
|
||||
}
|
||||
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
final Dimension size = super.getPreferredSize();
|
||||
if (myPrefSize != null) {
|
||||
size.height = myPrefSize.height;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyProgressBar extends JProgressBar {
|
||||
|
||||
private boolean myActive = true;
|
||||
@@ -336,9 +315,9 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di
|
||||
|
||||
private class MyComponent extends JPanel {
|
||||
private final boolean myCompact;
|
||||
private final FixedHeightLabel myProcessName;
|
||||
private final JComponent myProcessName;
|
||||
|
||||
private MyComponent(final boolean compact, final FixedHeightLabel processName) {
|
||||
private MyComponent(final boolean compact, final JComponent processName) {
|
||||
myCompact = compact;
|
||||
myProcessName = processName;
|
||||
addMouseListener(new MouseAdapter() {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class InsertOverwritePanel implements StatusBarWidget, StatusBarWidget.Te
|
||||
return "InsertOverwrite";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class MemoryUsagePanel extends JButton implements CustomStatusBarWidget {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class PositionPanel implements StatusBarWidget, StatusBarWidget.TextPrese
|
||||
return "Position";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull final Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull final Type type) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.openapi.wm.impl.status;
|
||||
|
||||
import com.intellij.openapi.wm.*;
|
||||
import com.intellij.util.ui.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* User: spLeaner
|
||||
*/
|
||||
public class ProcessIconWidget implements CustomStatusBarWidget {
|
||||
private AsyncProcessIcon myRefreshIcon;
|
||||
private EmptyIcon myEmptyRefreshIcon;
|
||||
|
||||
public ProcessIconWidget() {
|
||||
myRefreshIcon = new AsyncProcessIcon("Refreshing filesystem") {
|
||||
protected Icon getPassiveIcon() {
|
||||
return myEmptyRefreshIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
if (!isRunning()) return new Dimension(4, 0);
|
||||
return super.getPreferredSize();
|
||||
}
|
||||
};
|
||||
|
||||
myRefreshIcon.setBorder(StatusBarWidget.WidgetBorder.INSTANCE);
|
||||
myRefreshIcon.setOpaque(false);
|
||||
|
||||
myEmptyRefreshIcon = new EmptyIcon(0 /*myRefreshIcon.getPreferredSize().width*/, myRefreshIcon.getPreferredSize().height);
|
||||
setRefreshVisible(false);
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
return myRefreshIcon;
|
||||
}
|
||||
|
||||
public void setRefreshVisible(final boolean visible) {
|
||||
if (visible) {
|
||||
myRefreshIcon.resume();
|
||||
}
|
||||
else {
|
||||
myRefreshIcon.suspend();
|
||||
}
|
||||
|
||||
myRefreshIcon.revalidate();
|
||||
myRefreshIcon.repaint();
|
||||
}
|
||||
|
||||
public void setToolTipText(final String tooltip) {
|
||||
myRefreshIcon.setToolTipText(tooltip);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String ID() {
|
||||
return "RefreshIcon";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void install(@NotNull StatusBar statusBar) {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
setRefreshVisible(false);
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,19 @@ import java.awt.*;
|
||||
public class TextPanel extends JComponent {
|
||||
private String myText;
|
||||
private final String myMaxPossibleString;
|
||||
private Dimension myPrefSize;
|
||||
|
||||
private boolean myDecorate = true;
|
||||
|
||||
TextPanel() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
TextPanel(final boolean decorate) {
|
||||
this(null);
|
||||
myDecorate = decorate;
|
||||
}
|
||||
|
||||
TextPanel(@Nullable final String maxPossibleString) {
|
||||
myMaxPossibleString = maxPossibleString;
|
||||
|
||||
@@ -37,6 +45,16 @@ public class TextPanel extends JComponent {
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public void recomputeSize() {
|
||||
final JLabel label = new JLabel("XXX");
|
||||
label.setFont(getFont());
|
||||
myPrefSize = label.getPreferredSize();
|
||||
}
|
||||
|
||||
public void setDecorate(boolean decorate) {
|
||||
myDecorate = decorate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
final String s = getText();
|
||||
@@ -47,14 +65,14 @@ public class TextPanel extends JComponent {
|
||||
final Graphics2D g2 = (Graphics2D)g;
|
||||
g2.setFont(getFont());
|
||||
|
||||
UIUtil.applyRenderingHints(g2);
|
||||
|
||||
final int y = UIUtil.getStringY(s, bounds, g2);
|
||||
if (SystemInfo.isMac) {
|
||||
if (SystemInfo.isMac && myDecorate) {
|
||||
g2.setColor(new Color(215, 215, 215));
|
||||
g2.drawString(s, insets.left, y+1);
|
||||
}
|
||||
|
||||
UIUtil.applyRenderingHints(g2);
|
||||
|
||||
g2.setColor(getForeground());
|
||||
g2.drawString(s, insets.left, y);
|
||||
}
|
||||
@@ -88,6 +106,11 @@ public class TextPanel extends JComponent {
|
||||
public Dimension getPreferredSize(){
|
||||
int max = 0;
|
||||
if (myMaxPossibleString != null) max = getFontMetrics(getFont()).stringWidth(myMaxPossibleString);
|
||||
|
||||
if (myPrefSize != null) {
|
||||
return new Dimension(20 + max, myPrefSize.height);
|
||||
}
|
||||
|
||||
return new Dimension(20 + max, getMinimumSize().height);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class ToggleReadOnlyAttributePanel implements StatusBarWidget, StatusBarW
|
||||
return "ReadOnlyAttribute";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,8 +130,8 @@ public abstract class AppIcon {
|
||||
@Override
|
||||
public void applicationActivated(IdeFrame ideFrame) {
|
||||
hideProgress(myCurrentProcessId);
|
||||
setOkBadge(false);
|
||||
setErrorBadge(null);
|
||||
_setOkBadge(false);
|
||||
_setTextBadge(null);
|
||||
}
|
||||
};
|
||||
app.addApplicationListener(myAppListener);
|
||||
|
||||
+24
-1
@@ -1,5 +1,6 @@
|
||||
package com.intellij.ide.util.treeView;
|
||||
|
||||
import com.intellij.openapi.util.AsyncResult;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
@@ -108,6 +109,7 @@ abstract class AbstractTreeBuilderTest extends BaseTreeTestCase<BaseTreeTestCase
|
||||
protected void tearDown() throws Exception {
|
||||
myElementUpdate.clear();
|
||||
myElementUpdateHook = null;
|
||||
myStructure.setRevalidator(null);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@@ -381,6 +383,12 @@ abstract class AbstractTreeBuilderTest extends BaseTreeTestCase<BaseTreeTestCase
|
||||
return node;
|
||||
}
|
||||
|
||||
public Node addChild(NodeElement element) {
|
||||
final Node node = new Node(this, element);
|
||||
myChildElements.add(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myElement.toString();
|
||||
@@ -438,6 +446,7 @@ abstract class AbstractTreeBuilderTest extends BaseTreeTestCase<BaseTreeTestCase
|
||||
private final Map<NodeElement, NodeElement> myChild2Parent = new HashMap<NodeElement, NodeElement>();
|
||||
private final Map<NodeElement, Node> myElement2Node = new HashMap<NodeElement, Node>();
|
||||
private final Set<NodeElement> myLeaves = new HashSet<NodeElement>();
|
||||
private Revalidator myRevalidator;
|
||||
|
||||
public Object getRootElement() {
|
||||
return myRoot.myElement;
|
||||
@@ -464,7 +473,8 @@ abstract class AbstractTreeBuilderTest extends BaseTreeTestCase<BaseTreeTestCase
|
||||
}
|
||||
|
||||
public Object getParentElement(final Object element) {
|
||||
return myChild2Parent.get((NodeElement)element);
|
||||
NodeElement nodeElement = (NodeElement)element;
|
||||
return nodeElement.getForcedParent() != null ? nodeElement.getForcedParent() : myChild2Parent.get(nodeElement);
|
||||
}
|
||||
|
||||
|
||||
@@ -514,6 +524,19 @@ abstract class AbstractTreeBuilderTest extends BaseTreeTestCase<BaseTreeTestCase
|
||||
public Node getNodeFor(NodeElement element) {
|
||||
return myElement2Node.get(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncResult<Object> revalidateElement(Object element) {
|
||||
return myRevalidator != null ? myRevalidator.revalidate((NodeElement)element) : super.revalidateElement(element);
|
||||
}
|
||||
|
||||
public void setRevalidator(Revalidator revalidator) {
|
||||
myRevalidator = revalidator;
|
||||
}
|
||||
}
|
||||
|
||||
interface Revalidator {
|
||||
AsyncResult<Object> revalidate(NodeElement element);
|
||||
}
|
||||
|
||||
class MyBuilder extends BaseTreeBuilder {
|
||||
|
||||
+19
-3
@@ -97,11 +97,12 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
}.isConditionRealized();
|
||||
|
||||
if (myCancelRequest != null) {
|
||||
Thread.dumpStack();
|
||||
throw new Exception(myCancelRequest);
|
||||
}
|
||||
|
||||
Assert.assertTrue(getBuilder().getUi().getNodeActions().isEmpty());
|
||||
if (myCancelRequest == null && !myReadyRequest) {
|
||||
Assert.assertTrue(getBuilder().getUi().getNodeActions().isEmpty());
|
||||
}
|
||||
|
||||
Assert.assertTrue(success);
|
||||
}
|
||||
@@ -226,7 +227,13 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
}
|
||||
|
||||
void _runBackgroundLoading(Runnable runnable) {
|
||||
SimpleTimer.getInstance().setUp(runnable, getChildrenLoadingDelay());
|
||||
try {
|
||||
Thread.currentThread().sleep(getChildrenLoadingDelay());
|
||||
runnable.run();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -448,6 +455,7 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
public static class NodeElement extends ComparableObject.Impl implements Comparable<NodeElement>{
|
||||
|
||||
final String myName;
|
||||
private NodeElement myForcedParent;
|
||||
|
||||
public NodeElement(String name) {
|
||||
super(name);
|
||||
@@ -461,6 +469,14 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
|
||||
public int compareTo(NodeElement o) {
|
||||
return myName.compareTo(o.myName);
|
||||
}
|
||||
|
||||
public NodeElement getForcedParent() {
|
||||
return myForcedParent;
|
||||
}
|
||||
|
||||
public void setForcedParent(NodeElement forcedParent) {
|
||||
myForcedParent = forcedParent;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ package com.intellij.ide.util.treeView;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Progressive;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.util.Time;
|
||||
import com.intellij.util.WaitFor;
|
||||
import junit.framework.TestSuite;
|
||||
@@ -1013,7 +1010,7 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
public void onElementAction(String action, Object element) {
|
||||
if (wasInterrupted[0]) {
|
||||
if (myCancelRequest == null) {
|
||||
myCancelRequest = new AssertionError("Not supposed to be update after interruption request: action=" + action + " element=" + element);
|
||||
myCancelRequest = new AssertionError("Not supposed to be update after interruption request: action=" + action + " element=" + element + " interruptAction=" + interruptAction + " interruptElement=" + interruptElement);
|
||||
}
|
||||
} else {
|
||||
if (element.equals(interruptElement) && action.equals(interruptAction)) {
|
||||
@@ -1411,6 +1408,72 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
doTestSelectionOnDelete(true);
|
||||
}
|
||||
|
||||
public void testRevalidateStructure() throws Exception {
|
||||
final NodeElement com = new NodeElement("com");
|
||||
final NodeElement actionSystem = new NodeElement("actionSystem");
|
||||
actionSystem.setForcedParent(com);
|
||||
|
||||
final NodeElement fabrique = new NodeElement("fabrique");
|
||||
final NodeElement ide = new NodeElement("ide");
|
||||
fabrique.setForcedParent(myRoot.getElement());
|
||||
|
||||
doAndWaitForBuilder(new Runnable() {
|
||||
public void run() {
|
||||
myRoot.addChild(com).addChild(actionSystem);
|
||||
myRoot.addChild(fabrique).addChild(ide);
|
||||
getBuilder().getUi().activate(true);
|
||||
}
|
||||
});
|
||||
|
||||
select(actionSystem, false);
|
||||
expand(getPath("ide"));
|
||||
|
||||
assertTree("-/\n" +
|
||||
" -com\n" +
|
||||
" [actionSystem]\n" +
|
||||
" -fabrique\n" +
|
||||
" ide\n");
|
||||
|
||||
|
||||
removeFromParentButKeepRef(actionSystem);
|
||||
removeFromParentButKeepRef(fabrique);
|
||||
|
||||
final NodeElement newActionSystem = new NodeElement("actionSystem");
|
||||
final NodeElement newFabrique = new NodeElement("fabrique");
|
||||
|
||||
myStructure.getNodeFor(com).addChild("intellij").addChild("openapi").addChild(newActionSystem);
|
||||
myRoot.addChild("jetbrains").addChild("tools").addChild(newFabrique).addChild("ide");
|
||||
|
||||
assertSame(com, myStructure.getParentElement(actionSystem));
|
||||
assertNotSame(com, newActionSystem);
|
||||
assertEquals(new NodeElement("openapi"), myStructure.getParentElement(newActionSystem));
|
||||
|
||||
assertSame(myRoot.getElement(), myStructure.getParentElement(fabrique));
|
||||
|
||||
myStructure.setRevalidator(new Revalidator() {
|
||||
public AsyncResult<Object> revalidate(NodeElement element) {
|
||||
if (element == actionSystem) {
|
||||
return new AsyncResult.Done<Object>(newActionSystem);
|
||||
} else if (element == fabrique) {
|
||||
return new AsyncResult.Done<Object>(newFabrique);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
updateFromRoot();
|
||||
|
||||
assertTree("-/\n" +
|
||||
" -com\n" +
|
||||
" -intellij\n" +
|
||||
" -openapi\n" +
|
||||
" [actionSystem]\n" +
|
||||
" -jetbrains\n" +
|
||||
" -tools\n" +
|
||||
" -fabrique\n" +
|
||||
" ide\n");
|
||||
}
|
||||
|
||||
private void doTestSelectionOnDelete(boolean keepRef) throws Exception {
|
||||
myComparator.setDelegate(new NodeDescriptor.NodeComparator<NodeDescriptor>() {
|
||||
public int compare(NodeDescriptor o1, NodeDescriptor o2) {
|
||||
@@ -1673,20 +1736,26 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
public void onElementAction(String action, Object element) {
|
||||
if (!element.toString().equals(actionElement.toString())) return;
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
myReadyRequest = true;
|
||||
Disposer.dispose(getBuilder());
|
||||
}
|
||||
};
|
||||
|
||||
if (actionAction.equals(action)) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
myReadyRequest = true;
|
||||
Disposer.dispose(getBuilder());
|
||||
}
|
||||
});
|
||||
if (getBuilder().getUi().isPassthroughMode()) {
|
||||
runnable.run();
|
||||
} else {
|
||||
SwingUtilities.invokeLater(runnable);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
buildAction.run();
|
||||
|
||||
boolean released = new WaitFor(5000) {
|
||||
boolean released = new WaitFor(15000) {
|
||||
@Override
|
||||
protected boolean condition() {
|
||||
return getBuilder().getUi() == null;
|
||||
@@ -1700,16 +1769,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
public SyncUpdate() {
|
||||
super(false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCancelUpdate() throws Exception {
|
||||
super.testCancelUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testThrowingProcessCancelledInterruptsUpdate() throws Exception {
|
||||
super.testThrowingProcessCancelledInterruptsUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Passthrough extends TreeUiTest {
|
||||
@@ -1717,11 +1776,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCancelUpdate() throws Exception {
|
||||
super.testCancelUpdate();
|
||||
}
|
||||
|
||||
public void testSelectionGoesToParentWhenOnlyChildMoved2() throws Exception {
|
||||
//todo
|
||||
}
|
||||
@@ -1762,6 +1816,11 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
|
||||
super(false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testReleaseBuilderDuringUpdate() throws Exception {
|
||||
super.testReleaseBuilderDuringUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getChildrenLoadingDelay() {
|
||||
return 300;
|
||||
|
||||
@@ -231,6 +231,7 @@
|
||||
<keyword name="static"/>
|
||||
<keyword name="struct"/>
|
||||
<keyword name="switch"/>
|
||||
<keyword name="true"/>
|
||||
<keyword name="typedef"/>
|
||||
<keyword name="union"/>
|
||||
<keyword name="unsigned"/>
|
||||
@@ -258,7 +259,6 @@
|
||||
<keyword name="static_cast"/>
|
||||
<keyword name="this"/>
|
||||
<keyword name="throw"/>
|
||||
<keyword name="true"/>
|
||||
<keyword name="try"/>
|
||||
<keyword name="typeid"/>
|
||||
<keyword name="typename"/>
|
||||
|
||||
+11
-10
@@ -104,24 +104,25 @@ public class FileUrlProvider implements TestLocationProvider {
|
||||
|
||||
final int lineCount = doc.getLineCount();
|
||||
final int lineStartOffset;
|
||||
final int endOffset;
|
||||
if (lineNum <= lineCount) {
|
||||
lineStartOffset = doc.getLineStartOffset(lineNum - 1);
|
||||
endOffset = doc.getLineEndOffset(lineNum - 1);
|
||||
} else {
|
||||
// unknown line
|
||||
lineStartOffset = 0;
|
||||
endOffset = doc.getTextLength();
|
||||
}
|
||||
|
||||
PsiElement elementAtLine = psiFile.findElementAt(lineStartOffset);
|
||||
if (elementAtLine != null) {
|
||||
// skip whitespaces
|
||||
while (elementAtLine instanceof PsiWhiteSpace) {
|
||||
elementAtLine = elementAtLine.getNextSibling();
|
||||
}
|
||||
int offset = lineStartOffset;
|
||||
PsiElement elementAtLine = null;
|
||||
while (offset <= endOffset) {
|
||||
elementAtLine = psiFile.findElementAt(offset);
|
||||
if (!(elementAtLine instanceof PsiWhiteSpace)) break;
|
||||
int length = elementAtLine.getTextLength();
|
||||
offset += length > 1 ? length - 1 : 1;
|
||||
}
|
||||
final PsiElement leafPsiElementAtLine = elementAtLine == null
|
||||
? null
|
||||
: psiFile.findElementAt(elementAtLine.getTextOffset());
|
||||
|
||||
return PsiLocation.fromPsiElement(project, leafPsiElementAtLine != null ? leafPsiElementAtLine : psiFile);
|
||||
return PsiLocation.fromPsiElement(project, elementAtLine != null ? elementAtLine : psiFile);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-30
@@ -29,39 +29,16 @@ public class FileUrlLocationTest extends SMLightFixtureTestCase {
|
||||
}
|
||||
|
||||
public void testSpecNavigation() throws Throwable {
|
||||
createAndAddFile("my_example_spec.rb",
|
||||
createAndAddFile("my_example_spec.xml",
|
||||
"\n" +
|
||||
"require \"spec\"\n" +
|
||||
"\n" +
|
||||
"describe \"Blabla\" do\n" +
|
||||
"\n" +
|
||||
" # Called before each example.\n" +
|
||||
" before(:each) do\n" +
|
||||
" # Do nothing\n" +
|
||||
" end\n" +
|
||||
"\n" +
|
||||
" # Called after each example.\n" +
|
||||
" after(:each) do\n" +
|
||||
" # Do nothing\n" +
|
||||
" end\n" +
|
||||
"\n" +
|
||||
" it \"should fail\" do\n" +
|
||||
"\n" +
|
||||
" #should pass\n" +
|
||||
" true.should == false\n" +
|
||||
" end\n" +
|
||||
"\n" +
|
||||
" it \"should pass\" do\n" +
|
||||
"\n" +
|
||||
" #should pass\n" +
|
||||
" true.should == true\n" +
|
||||
" end\n" +
|
||||
"end");
|
||||
"<describe>\n" +
|
||||
" <a></a>\n" +
|
||||
"</describe>\n" +
|
||||
"\n");
|
||||
|
||||
final String path = myFixture.getFile().getVirtualFile().getPath();
|
||||
doTest(17, "describe", path, 4);
|
||||
doTest(189, "it", path, 16);
|
||||
doTest(261, "it", path, 22);
|
||||
doTest(1, "<", path, 2);
|
||||
doTest(16, "<", path, 3);
|
||||
}
|
||||
|
||||
private void doTest(final int expectedOffset, final String expectedStartsWith,
|
||||
|
||||
+6
@@ -23,6 +23,7 @@ import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture;
|
||||
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
|
||||
@@ -37,6 +38,11 @@ import java.io.IOException;
|
||||
* @author Roman.Chernyatchik
|
||||
*/
|
||||
public abstract class SMLightFixtureTestCase extends UsefulTestCase {
|
||||
|
||||
protected SMLightFixtureTestCase() {
|
||||
PlatformTestCase.initPlatformLangPrefix();
|
||||
}
|
||||
|
||||
protected static final LightProjectDescriptor ourDescriptor = new LightProjectDescriptor() {
|
||||
public ModuleType getModuleType() {
|
||||
return ModuleType.EMPTY;
|
||||
|
||||
+5
@@ -18,6 +18,7 @@ package com.intellij.execution.testframework.sm.runner;
|
||||
import com.intellij.execution.configurations.RuntimeConfiguration;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
|
||||
/**
|
||||
* @author Roman Chernyatchik
|
||||
@@ -26,6 +27,10 @@ public abstract class BaseSMTRunnerTestCase extends LightPlatformTestCase {
|
||||
protected SMTestProxy mySuite;
|
||||
protected SMTestProxy mySimpleTest;
|
||||
|
||||
protected BaseSMTRunnerTestCase() {
|
||||
PlatformTestCase.initPlatformLangPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
@@ -1172,7 +1172,7 @@ public class StringUtil {
|
||||
}
|
||||
|
||||
@NotNull public static String replaceSubstring(@NotNull String string, @NotNull TextRange range, @NotNull String replacement) {
|
||||
return string.substring(0, range.getStartOffset()) + replacement + string.substring(range.getEndOffset());
|
||||
return range.replace(string, replacement);
|
||||
}
|
||||
|
||||
public static boolean startsWith(@NotNull CharSequence text, @NotNull CharSequence prefix) {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.vfs;
|
||||
package com.intellij.util.io.fs;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class EncodingAwareProperties extends java.util.Properties{
|
||||
propText = StringUtil.convertLineSeparators(propText);
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(propText, "\n");
|
||||
while (stringTokenizer.hasMoreElements()){
|
||||
String line = (String)stringTokenizer.nextElement();
|
||||
String line = stringTokenizer.nextElement();
|
||||
int i = line.indexOf('=');
|
||||
String propName = i == -1 ? line : line.substring(0,i);
|
||||
String propValue = i == -1 ? "" : line.substring(i+1);
|
||||
|
||||
@@ -1203,7 +1203,9 @@ public class UIUtil {
|
||||
final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
|
||||
final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0;
|
||||
|
||||
if (path != null && tree.isPathSelected(path)) {
|
||||
boolean selected = false;
|
||||
if (path != null) {
|
||||
selected = tree.isPathSelected(path);
|
||||
Graphics2D rowGraphics = (Graphics2D)g.create();
|
||||
if (clipBounds.height >= bounds.height) {
|
||||
// fill the row only if clip bounds intersects actual node bounds
|
||||
@@ -1216,14 +1218,24 @@ public class UIUtil {
|
||||
|
||||
final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
|
||||
if (sourceList != null && ((Boolean)sourceList)) {
|
||||
if (tree.hasFocus()) {
|
||||
LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
|
||||
}
|
||||
else {
|
||||
LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
|
||||
if (selected) {
|
||||
if (tree.hasFocus()) {
|
||||
LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
|
||||
}
|
||||
else {
|
||||
LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
|
||||
}
|
||||
} else {
|
||||
rowGraphics.setColor(tree.getBackground());
|
||||
rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
|
||||
}
|
||||
} else {
|
||||
rowGraphics.setColor(tree.hasFocus() ? getTreeSelectionBackground() : UNFOCUSED_SELECTION_COLOR);
|
||||
Color bg = tree.hasFocus() ? getTreeSelectionBackground() : UNFOCUSED_SELECTION_COLOR;
|
||||
if (!selected) {
|
||||
bg = tree.getBackground();
|
||||
}
|
||||
|
||||
rowGraphics.setColor(bg);
|
||||
rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height - 1);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ public class IncomingChangesIndicator implements ProjectComponent {
|
||||
return "IncomingChanges";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -72,6 +72,7 @@ public class MethodParameterPanel extends AbstractInjectionPanel<MethodParameter
|
||||
|
||||
public MethodParameterPanel(MethodParameterInjection injection, final Project project) {
|
||||
super(injection, project);
|
||||
$$$setupUI$$$();
|
||||
|
||||
myClassField = new ReferenceEditorWithBrowseButton(new BrowseClassListener(project), project, new Function<String, Document>() {
|
||||
public Document fun(String s) {
|
||||
@@ -411,4 +412,8 @@ public class MethodParameterPanel extends AbstractInjectionPanel<MethodParameter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void $$$setupUI$$$() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Settings implements SearchableConfigurable {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return getHelpTopic();
|
||||
return "IntelliLang.Configuration";
|
||||
}
|
||||
|
||||
public Runnable enableSearch(String option) {
|
||||
|
||||
+9
-24
@@ -22,13 +22,12 @@ import com.intellij.util.Consumer;
|
||||
import org.intellij.lang.regexp.RegExpLanguage;
|
||||
import org.intellij.plugins.intelliLang.inject.InjectedLanguage;
|
||||
import org.intellij.plugins.intelliLang.inject.config.AbstractTagInjection;
|
||||
import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
|
||||
import org.intellij.plugins.intelliLang.inject.config.XPathSupportProxy;
|
||||
import org.intellij.plugins.intelliLang.util.LanguageTextField;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class AdvancedXmlPanel extends AbstractInjectionPanel<BaseInjection> {
|
||||
public class AdvancedXmlPanel extends AbstractInjectionPanel<AbstractTagInjection> {
|
||||
|
||||
private JPanel myRoot;
|
||||
|
||||
@@ -37,30 +36,21 @@ public class AdvancedXmlPanel extends AbstractInjectionPanel<BaseInjection> {
|
||||
private JLabel myXPathConditionLabel;
|
||||
private JCheckBox mySingleFileCheckBox;
|
||||
|
||||
public AdvancedXmlPanel(Project project, BaseInjection injection) {
|
||||
public AdvancedXmlPanel(Project project, AbstractTagInjection injection) {
|
||||
super(injection, project);
|
||||
$$$setupUI$$$(); // see IDEA-9987
|
||||
if (!(injection instanceof AbstractTagInjection)) {
|
||||
myXPathCondition.setVisible(false);
|
||||
myXPathConditionLabel.setVisible(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void apply(BaseInjection other) {
|
||||
protected void apply(AbstractTagInjection other) {
|
||||
other.setValuePattern(myValuePattern.getText());
|
||||
other.setSingleFile(mySingleFileCheckBox.isSelected());
|
||||
if (myOrigInjection instanceof AbstractTagInjection) {
|
||||
((AbstractTagInjection)other).setXPathCondition(myXPathCondition.getText());
|
||||
}
|
||||
other.setXPathCondition(myXPathCondition.getText());
|
||||
}
|
||||
|
||||
protected void resetImpl() {
|
||||
myValuePattern.setText(myOrigInjection.getValuePattern());
|
||||
mySingleFileCheckBox.setSelected(myOrigInjection.isSingleFile());
|
||||
if (myOrigInjection instanceof AbstractTagInjection) {
|
||||
myXPathCondition.setText(((AbstractTagInjection)myOrigInjection).getXPathCondition());
|
||||
}
|
||||
myXPathCondition.setText(myOrigInjection.getXPathCondition());
|
||||
}
|
||||
|
||||
public JPanel getComponent() {
|
||||
@@ -74,11 +64,10 @@ public class AdvancedXmlPanel extends AbstractInjectionPanel<BaseInjection> {
|
||||
}
|
||||
});
|
||||
|
||||
if (myOrigInjection instanceof AbstractTagInjection) {
|
||||
// don't even bother to look up the language when xpath-evaluation isn't possible
|
||||
final XPathSupportProxy proxy = XPathSupportProxy.getInstance();
|
||||
myXPathCondition = new LanguageTextField(proxy != null ? InjectedLanguage.findLanguageById("XPath") : null, myProject,
|
||||
((AbstractTagInjection)myOrigInjection).getXPathCondition(), new Consumer<PsiFile>() {
|
||||
// don't even bother to look up the language when xpath-evaluation isn't possible
|
||||
final XPathSupportProxy proxy = XPathSupportProxy.getInstance();
|
||||
myXPathCondition = new LanguageTextField(proxy != null ? InjectedLanguage.findLanguageById("XPath") : null, myProject,
|
||||
myOrigInjection.getXPathCondition(), new Consumer<PsiFile>() {
|
||||
public void consume(PsiFile psiFile) {
|
||||
// important to get proper validation & completion for Jaxen's built-in and PSI functions
|
||||
// like lower-case(), file-type(), file-ext(), file-name(), etc.
|
||||
@@ -87,10 +76,6 @@ public class AdvancedXmlPanel extends AbstractInjectionPanel<BaseInjection> {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
myXPathCondition = new EditorTextField();
|
||||
}
|
||||
}
|
||||
|
||||
private void $$$setupUI$$$() {
|
||||
|
||||
+14
-7
@@ -26,6 +26,8 @@ import org.intellij.plugins.intelliLang.inject.config.BaseInjection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersProcessor;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint;
|
||||
|
||||
/**
|
||||
* @author Gregory.Shrago
|
||||
@@ -38,13 +40,18 @@ public class PatternEditorContextMembersProvider implements NonCodeMembersProces
|
||||
final PsiFile file = place.getContainingFile().getOriginalFile();
|
||||
final BaseInjection injection = file.getUserData(BaseInjection.INJECTION_KEY);
|
||||
if (injection == null) return true;
|
||||
return ((UserDataHolderEx)file).putUserDataIfAbsent(INJECTION_PARSED_CONTEXT, new AtomicNotNullLazyValue<PsiFile>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected PsiFile compute() {
|
||||
return parseInjectionContext(injection, file.getProject());
|
||||
}
|
||||
}).getValue().processDeclarations(processor, ResolveState.initial(), null, place);
|
||||
final PsiFile contextFile =
|
||||
((UserDataHolderEx)file).putUserDataIfAbsent(INJECTION_PARSED_CONTEXT, new AtomicNotNullLazyValue<PsiFile>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected PsiFile compute() {
|
||||
return parseInjectionContext(injection, file.getProject());
|
||||
}
|
||||
}).getValue();
|
||||
for (PsiElement cur = contextFile.getFirstChild(); cur != null; cur = cur.getNextSibling()) {
|
||||
if (cur instanceof PsiNamedElement && !ResolveUtil.processElement(processor, (PsiNamedElement)cur)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static PsiFile parseInjectionContext(@NotNull BaseInjection injection, Project project) {
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.findUsages;
|
||||
|
||||
import com.intellij.lang.cacheBuilder.WordsScanner;
|
||||
import com.intellij.lang.findUsages.FindUsagesProvider;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
@@ -35,7 +36,7 @@ public class GroovyFindUsagesProvider implements FindUsagesProvider {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GroovyWordsScanner getWordsScanner() {
|
||||
public WordsScanner getWordsScanner() {
|
||||
return new GroovyWordsScanner();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
group.hg4idea.global.menu.text=Mercurial
|
||||
group.hg4idea.global.submenu.text=Mercurial
|
||||
group.hg4idea.global.submenu.text=Mercurial Actions
|
||||
group.hg4idea.file.menu.text=Mercurial
|
||||
action.hg4idea.tag.text=Tag Repository
|
||||
action.hg4idea.tag.description=Create a tag for current revision
|
||||
@@ -21,6 +21,11 @@ hg4idea.error=Error
|
||||
hg4idea.revert=Revert
|
||||
hg4idea.commit=Commit
|
||||
|
||||
hg4idea.init.destination.directory.description=Select directory where the new Mercurial repository will be created.
|
||||
hg4idea.init.destination.directory.title=Select directory for hg init
|
||||
hg4idea.init.error.already.under.hg=The selected directory {0} is already under hg.
|
||||
hg4idea.init.error.title=hg init Error
|
||||
|
||||
hg4idea.clone.title=Clone Mercurial Repostiroy
|
||||
hg4idea.clone.button.clone=Clone
|
||||
hg4idea.clone.button.test=&Test Repository
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.zmlx.hg4idea.ui.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class HgIdeConfigurable implements ApplicationComponent, Configurable {
|
||||
public class HgIdeConfigurable implements SearchableConfigurable {
|
||||
|
||||
private final HgConfigurationIdePanel panel;
|
||||
|
||||
@@ -60,14 +60,11 @@ public class HgIdeConfigurable implements ApplicationComponent, Configurable {
|
||||
public void disposeUIResources() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return getClass().getName();
|
||||
public String getId() {
|
||||
return "Mercurial";
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
public Runnable enableSearch(String option) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.zmlx.hg4idea.ui.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class HgProjectConfigurable implements Configurable {
|
||||
public class HgProjectConfigurable implements SearchableConfigurable {
|
||||
|
||||
private final HgConfigurationProjectPanel hgConfigurationProjectPanel;
|
||||
|
||||
@@ -58,4 +58,12 @@ public class HgProjectConfigurable implements Configurable {
|
||||
public void disposeUIResources() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return "Mercurial.Project";
|
||||
}
|
||||
|
||||
public Runnable enableSearch(String option) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.vcsUtil.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -127,6 +128,7 @@ public abstract class HgUtil {
|
||||
* @return The temporary copy the specified python file, with all the necessary hooks installed
|
||||
* to make sure it is completely removed at shutdown
|
||||
*/
|
||||
@Nullable
|
||||
public static File getTemporaryPythonFile(String base) {
|
||||
try {
|
||||
final File file = copyResourceToTempFile(base, ".py");
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.List;
|
||||
|
||||
public final class HgCommandService {
|
||||
|
||||
private static final File PROMPT_HOOKS_PLUGIN = HgUtil.getTemporaryPythonFile("prompthooks");
|
||||
private static File PROMPT_HOOKS_PLUGIN;
|
||||
|
||||
static final Logger LOG = Logger.getInstance(HgCommandService.class.getName());
|
||||
|
||||
@@ -43,6 +43,9 @@ public final class HgCommandService {
|
||||
public HgCommandService(Project project, HgGlobalSettings settings) {
|
||||
this.project = project;
|
||||
this.settings = settings;
|
||||
if (PROMPT_HOOKS_PLUGIN == null) {
|
||||
PROMPT_HOOKS_PLUGIN = HgUtil.getTemporaryPythonFile("prompthooks");
|
||||
}
|
||||
}
|
||||
|
||||
public static HgCommandService getInstance(Project project) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class HgChangesetStatus extends JLabel implements CustomStatusBarWidget {
|
||||
return "HgChangeSetStatus";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<text value="&Specify executable path"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="42f2c" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="pathSelector">
|
||||
<component id="42f2c" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="pathSelector" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="100" height="-1"/>
|
||||
|
||||
@@ -12,16 +12,13 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea.ui;
|
||||
|
||||
import com.intellij.openapi.fileChooser.*;
|
||||
import com.intellij.openapi.options.*;
|
||||
import com.intellij.openapi.ui.*;
|
||||
import com.intellij.uiDesigner.core.*;
|
||||
import org.apache.commons.lang.*;
|
||||
import org.zmlx.hg4idea.*;
|
||||
import org.zmlx.hg4idea.command.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class HgConfigurationIdePanel {
|
||||
@@ -36,14 +33,6 @@ public class HgConfigurationIdePanel {
|
||||
this.globalSettings = globalSettings;
|
||||
loadSettings();
|
||||
|
||||
String title = HgVcsMessages.message("hg4idea.configuration.title");
|
||||
String description = HgVcsMessages.message("hg4idea.configuration.description");
|
||||
|
||||
pathSelector.addBrowseFolderListener(
|
||||
title, description, null,
|
||||
new FileChooserDescriptor(true, false, false, false, false, false)
|
||||
);
|
||||
|
||||
final ActionListener listener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
pathSelector.setEnabled(selectRadioButton.isSelected());
|
||||
@@ -100,54 +89,7 @@ public class HgConfigurationIdePanel {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||
// >>> IMPORTANT!! <<<
|
||||
// DO NOT EDIT OR ADD ANY CODE HERE!
|
||||
$$$setupUI$$$();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method generated by IntelliJ IDEA GUI Designer
|
||||
* >>> IMPORTANT!! <<<
|
||||
* DO NOT edit this method OR call it in your code!
|
||||
*
|
||||
* @noinspection ALL
|
||||
*/
|
||||
private void $$$setupUI$$$() {
|
||||
basePanel = new JPanel();
|
||||
basePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
final JPanel panel1 = new JPanel();
|
||||
panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
|
||||
basePanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||
panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Path to hg executable"));
|
||||
autoRadioButton = new JRadioButton();
|
||||
autoRadioButton.setSelected(true);
|
||||
autoRadioButton.setText("Autodetect hg in PATH");
|
||||
autoRadioButton.setMnemonic('A');
|
||||
autoRadioButton.setDisplayedMnemonicIndex(0);
|
||||
panel1.add(autoRadioButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
selectRadioButton = new JRadioButton();
|
||||
selectRadioButton.setEnabled(true);
|
||||
selectRadioButton.setText("Specify executable path");
|
||||
selectRadioButton.setMnemonic('S');
|
||||
selectRadioButton.setDisplayedMnemonicIndex(0);
|
||||
panel1.add(selectRadioButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
pathSelector = new TextFieldWithBrowseButton();
|
||||
pathSelector.setEnabled(false);
|
||||
panel1.add(pathSelector, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, new Dimension(100, -1), null, null, 0, false));
|
||||
final Spacer spacer1 = new Spacer();
|
||||
basePanel.add(spacer1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
ButtonGroup buttonGroup;
|
||||
buttonGroup = new ButtonGroup();
|
||||
buttonGroup.add(autoRadioButton);
|
||||
buttonGroup.add(selectRadioButton);
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
public JComponent $$$getRootComponent$$$() {
|
||||
return basePanel;
|
||||
private void createUIComponents() {
|
||||
pathSelector = new HgSetExecutablePathPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class HgCurrentBranchStatus extends JLabel implements CustomStatusBarWidg
|
||||
return "HgCurrentBranchStatus";
|
||||
}
|
||||
|
||||
public Presentation getPresentation(@NotNull Type type) {
|
||||
public WidgetPresentation getPresentation(@NotNull Type type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.zmlx.hg4idea.ui.HgSetExecutableDialog">
|
||||
<grid id="27dc6" binding="centerPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myCenterPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="564" height="400"/>
|
||||
@@ -8,7 +8,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="40fef" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="hgExecutablePath">
|
||||
<component id="2e454" class="org.zmlx.hg4idea.ui.HgSetExecutablePathPanel" binding="myHgExecutablePath" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="9" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="400" height="-1"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="a1421" class="javax.swing.JLabel" binding="infoLabel">
|
||||
<component id="a1421" class="javax.swing.JLabel" binding="myInfoLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -24,19 +24,9 @@
|
||||
<text value="Full path to hg executable or 'hg' if PATH has it:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c771f" class="javax.swing.JLabel" binding="errorLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font style="2"/>
|
||||
<foreground awt-color="red"/>
|
||||
<text resource-bundle="org/zmlx/hg4idea/HgVcsMessages" key="hg4idea.error.invalidExecutable"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="4c273">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
|
||||
@@ -12,20 +12,18 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea.ui;
|
||||
|
||||
import com.intellij.openapi.project.*;
|
||||
import com.intellij.openapi.ui.*;
|
||||
import com.intellij.uiDesigner.core.*;
|
||||
import org.zmlx.hg4idea.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import org.zmlx.hg4idea.HgVcsMessages;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class HgSetExecutableDialog extends DialogWrapper {
|
||||
private JPanel centerPanel;
|
||||
private TextFieldWithBrowseButton hgExecutablePath;
|
||||
private JLabel infoLabel;
|
||||
private JLabel errorLabel;
|
||||
private JPanel myCenterPanel;
|
||||
private HgSetExecutablePathPanel myHgExecutablePath;
|
||||
private JLabel myInfoLabel;
|
||||
|
||||
public HgSetExecutableDialog(Project project) {
|
||||
super(project, false);
|
||||
@@ -34,81 +32,24 @@ public class HgSetExecutableDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return centerPanel;
|
||||
return myCenterPanel;
|
||||
}
|
||||
|
||||
public void setBadHgPath(String hgPath) {
|
||||
hgExecutablePath.setText(hgPath);
|
||||
errorLabel.setText(HgVcsMessages.message("hg4idea.error.invalidExecutable", hgPath));
|
||||
myHgExecutablePath.setText(hgPath);
|
||||
setErrorText(HgVcsMessages.message("hg4idea.configuration.executable.error", hgPath));
|
||||
}
|
||||
|
||||
public String getNewHgPath() {
|
||||
return hgExecutablePath.getText();
|
||||
return myHgExecutablePath.getText();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||
// >>> IMPORTANT!! <<<
|
||||
// DO NOT EDIT OR ADD ANY CODE HERE!
|
||||
$$$setupUI$$$();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method generated by IntelliJ IDEA GUI Designer
|
||||
* >>> IMPORTANT!! <<<
|
||||
* DO NOT edit this method OR call it in your code!
|
||||
*
|
||||
* @noinspection ALL
|
||||
*/
|
||||
private void $$$setupUI$$$() {
|
||||
centerPanel = new JPanel();
|
||||
centerPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
hgExecutablePath = new TextFieldWithBrowseButton();
|
||||
centerPanel.add(hgExecutablePath, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(400, -1), null, 0, false));
|
||||
infoLabel = new JLabel();
|
||||
infoLabel.setText("Full path to hg executable or 'hg' if PATH has it:");
|
||||
centerPanel.add(infoLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
errorLabel = new JLabel();
|
||||
errorLabel.setFont(new Font(errorLabel.getFont().getName(), Font.ITALIC, errorLabel.getFont().getSize()));
|
||||
errorLabel.setForeground(Color.red);
|
||||
this.$$$loadLabelText$$$(errorLabel, ResourceBundle.getBundle("org/zmlx/hg4idea/HgVcsMessages").getString("hg4idea.error.invalidExecutable"));
|
||||
centerPanel.add(errorLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
final Spacer spacer1 = new Spacer();
|
||||
centerPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
private void $$$loadLabelText$$$(JLabel component, String text) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
boolean haveMnemonic = false;
|
||||
char mnemonic = '\0';
|
||||
int mnemonicIndex = -1;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.charAt(i) == '&') {
|
||||
i++;
|
||||
if (i == text.length()) break;
|
||||
if (!haveMnemonic && text.charAt(i) != '&') {
|
||||
haveMnemonic = true;
|
||||
mnemonic = text.charAt(i);
|
||||
mnemonicIndex = result.length();
|
||||
}
|
||||
private void createUIComponents() {
|
||||
myHgExecutablePath = new HgSetExecutablePathPanel();
|
||||
myHgExecutablePath.addOKListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
setErrorText("");
|
||||
}
|
||||
result.append(text.charAt(i));
|
||||
}
|
||||
component.setText(result.toString());
|
||||
if (haveMnemonic) {
|
||||
component.setDisplayedMnemonic(mnemonic);
|
||||
component.setDisplayedMnemonicIndex(mnemonicIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
public JComponent $$$getRootComponent$$$() {
|
||||
return centerPanel;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="util" exported="" />
|
||||
<orderEntry type="library" exported="" name="JDOM" level="project" />
|
||||
<orderEntry type="module-library" exported="">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/lucene-core-2.3.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.idea.maven.facade;
|
||||
|
||||
import org.jetbrains.idea.maven.model.MavenArtifactInfo;
|
||||
import org.jetbrains.idea.maven.model.MavenModel;
|
||||
import org.jetbrains.idea.maven.model.MavenRepositoryInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface MavenFacade extends Remote {
|
||||
void setLogger(MavenFacadeLogger logger) throws RemoteException;
|
||||
|
||||
MavenFacadeEmbedder createEmbedder(MavenFacadeSettings settings) throws RemoteException;
|
||||
|
||||
MavenFacadeIndexer createIndexer() throws RemoteException;
|
||||
|
||||
MavenModel interpolateAndAlignModel(MavenModel model, File basedir) throws RemoteException;
|
||||
|
||||
MavenModel assembleInheritance(MavenModel model, MavenModel parentModel) throws RemoteException;
|
||||
|
||||
ProfileApplicationResult applyProfiles(MavenModel model,
|
||||
File basedir,
|
||||
Collection<String> explicitProfiles,
|
||||
Collection<String> alwaysOnProfiles) throws RemoteException;
|
||||
|
||||
List<MavenRepositoryInfo> getRepositories(String nexusUrl) throws RemoteException;
|
||||
|
||||
List<MavenArtifactInfo> findArtifacts(MavenArtifactInfo template, String nexusUrl) throws RemoteException;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.idea.maven.facade;
|
||||
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
public interface MavenFacadeConsole extends Remote {
|
||||
// must be same as in org.codehaus.plexus.logging.Logger
|
||||
int LEVEL_DEBUG = 0;
|
||||
int LEVEL_INFO = 1;
|
||||
int LEVEL_WARN = 2;
|
||||
int LEVEL_ERROR = 3;
|
||||
int LEVEL_FATAL = 4;
|
||||
int LEVEL_DISABLED = 5;
|
||||
|
||||
void printMessage(int level, String message, Throwable throwable) throws RemoteException;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.idea.maven.facade;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.model.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MavenFacadeEmbedder extends Remote {
|
||||
void customizeForResolve(MavenFacadeConsole console, MavenFacadeProgressIndicator process) throws RemoteException;
|
||||
|
||||
void customizeForResolve(Map<MavenId, File> projectIdToFileMap,
|
||||
MavenFacadeConsole console,
|
||||
MavenFacadeProgressIndicator process) throws RemoteException;
|
||||
|
||||
void customizeForStrictResolve(Map<MavenId, File> projectIdToFileMap,
|
||||
MavenFacadeConsole console,
|
||||
MavenFacadeProgressIndicator process) throws RemoteException;
|
||||
|
||||
@NotNull
|
||||
MavenWrapperExecutionResult resolveProject(@NotNull File file,
|
||||
@NotNull Collection<String> activeProfiles) throws RemoteException,
|
||||
MavenFacadeProcessCanceledException;
|
||||
|
||||
@NotNull
|
||||
MavenArtifact resolve(@NotNull MavenArtifactInfo info,
|
||||
@NotNull List<MavenRemoteRepository> remoteRepositories) throws RemoteException,
|
||||
MavenFacadeProcessCanceledException;
|
||||
|
||||
@NotNull
|
||||
List<MavenArtifact> resolveTransitively(@NotNull List<MavenArtifactInfo> artifacts,
|
||||
@NotNull List<MavenRemoteRepository> remoteRepositories) throws RemoteException,
|
||||
MavenFacadeProcessCanceledException;
|
||||
|
||||
Collection<MavenArtifact> resolvePlugin(@NotNull MavenPlugin plugin,
|
||||
@NotNull List<MavenRemoteRepository> repositories,
|
||||
int nativeMavenProjectId,
|
||||
boolean transitive) throws RemoteException, MavenFacadeProcessCanceledException;
|
||||
|
||||
@NotNull
|
||||
MavenWrapperExecutionResult execute(@NotNull File file,
|
||||
@NotNull Collection<String> activeProfiles,
|
||||
@NotNull List<String> goals) throws RemoteException,
|
||||
MavenFacadeProcessCanceledException;
|
||||
|
||||
void reset() throws RemoteException;
|
||||
|
||||
void release() throws RemoteException;
|
||||
|
||||
void clearCaches() throws RemoteException;
|
||||
|
||||
void clearCachesFor(MavenId projectId) throws RemoteException;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.idea.maven.facade;
|
||||
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.model.MavenArchetype;
|
||||
import org.jetbrains.idea.maven.model.MavenArtifactInfo;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
|
||||
import java.io.File;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MavenFacadeIndexer extends Remote {
|
||||
String SEARCH_TERM_COORDINATES = "u"; // see org.sonatype.nexus.index.ArtifactInfo
|
||||
String SEARCH_TERM_CLASS_NAMES = "c";
|
||||
|
||||
int createIndex(@NotNull String indexId,
|
||||
@Nullable String repositoryId,
|
||||
@Nullable File file,
|
||||
@Nullable String url,
|
||||
@NotNull File indexDir) throws RemoteException, MavenFacadeIndexerException;
|
||||
|
||||
void releaseIndex(int id) throws RemoteException, MavenFacadeIndexerException;
|
||||
|
||||
int getIndexCount() throws RemoteException;
|
||||
|
||||
void updateIndex(int id, MavenFacadeSettings settings, MavenFacadeProgressIndicator indicator) throws RemoteException,
|
||||
MavenFacadeIndexerException,
|
||||
MavenFacadeProcessCanceledException;
|
||||
|
||||
List<MavenId> getAllArtifacts(int indexId) throws RemoteException, MavenFacadeIndexerException;
|
||||
|
||||
MavenId addArtifact(int indexId, File artifactFile) throws RemoteException, MavenFacadeIndexerException;
|
||||
|
||||
Set<MavenArtifactInfo> search(int indexId, Query query, int maxResult) throws RemoteException, MavenFacadeIndexerException;
|
||||
|
||||
Collection<MavenArchetype> getArchetypes() throws RemoteException;
|
||||
|
||||
void release() throws RemoteException;
|
||||
}
|
||||
+8
-9
@@ -13,15 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.maven.facade.remote;
|
||||
package org.jetbrains.idea.maven.facade;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
public class MavenFacadeIndexerException extends Exception {
|
||||
public MavenFacadeIndexerException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Gregory.Shrago
|
||||
*/
|
||||
public interface MavenFacadeManager {
|
||||
MavenFacade getMavenFacade(@NotNull final Object key) throws Exception;
|
||||
void releaseMavenFacade(@NotNull Object key);
|
||||
public MavenFacadeIndexerException(Throwable cause) {
|
||||
super(null, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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 org.jetbrains.idea.maven.facade;
|
||||
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
public interface MavenFacadeLogger extends Remote {
|
||||
void info(Throwable e) throws RemoteException;
|
||||
|
||||
void warn(Throwable e) throws RemoteException;
|
||||
|
||||
void error(Throwable e) throws RemoteException;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user