mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -25,6 +25,7 @@ import com.intellij.compiler.make.CacheCorruptedException;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.containers.SLRUCache;
|
||||
import com.intellij.util.io.PersistentEnumerator;
|
||||
import com.intellij.util.io.PersistentStringEnumerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -69,7 +70,7 @@ public class SymbolTable {
|
||||
}
|
||||
myTrie = new PersistentStringEnumerator(file);
|
||||
}
|
||||
catch (PersistentStringEnumerator.CorruptedException e) {
|
||||
catch (PersistentEnumerator.CorruptedException e) {
|
||||
throw new CacheCorruptedException(CompilerBundle.message("error.compiler.caches.corrupted"), e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
import com.intellij.util.io.KeyDescriptor;
|
||||
import com.intellij.util.io.PersistentEnumerator;
|
||||
import com.intellij.util.io.PersistentHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -49,7 +50,7 @@ public class GenericCompilerCache<Key, SourceState, OutputState> {
|
||||
myPersistentMap = new PersistentHashMap<KeyAndTargetData<Key>, PersistentStateData<SourceState,OutputState>>(myCacheFile, new SourceItemDataDescriptor(myCompiler.getItemKeyDescriptor()),
|
||||
new PersistentStateDataExternalizer(myCompiler));
|
||||
}
|
||||
catch (PersistentHashMap.CorruptedException e) {
|
||||
catch (PersistentEnumerator.CorruptedException e) {
|
||||
FileUtil.delete(myCacheFile);
|
||||
throw e;
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public abstract class AbstractBasicToClassNameDelegator extends CompletionContri
|
||||
|
||||
@Override
|
||||
public void fillCompletionVariants(final CompletionParameters parameters, final CompletionResultSet result) {
|
||||
if (parameters.getCompletionType() != CompletionType.BASIC) return;
|
||||
if (parameters.getCompletionType() != CompletionType.BASIC || parameters.getInvocationCount() == 0) return;
|
||||
|
||||
final PsiFile file = parameters.getOriginalFile();
|
||||
final PsiElement position = parameters.getPosition();
|
||||
|
||||
+7
-1
@@ -28,7 +28,13 @@ public class BasicToClassNameDelegator extends AbstractBasicToClassNameDelegator
|
||||
|
||||
@Override
|
||||
protected boolean isClassNameCompletionSupported(CompletionResultSet result, PsiFile file, PsiElement position) {
|
||||
return file.getLanguage().isKindOf(StdLanguages.XML) && JavaCompletionContributor.mayStartClassName(result, false);
|
||||
if (!JavaCompletionContributor.mayStartClassName(result, false)) return false;
|
||||
|
||||
if (file.getLanguage() == StdLanguages.JAVA) {
|
||||
return JavaCompletionContributor.isClassNamePossible(position);
|
||||
}
|
||||
|
||||
return file.getLanguage().isKindOf(StdLanguages.XML);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-4
@@ -235,7 +235,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
public static void addAllClasses(CompletionParameters parameters,
|
||||
final CompletionResultSet result,
|
||||
final InheritorsHolder inheritors) {
|
||||
if (!isClassNamePossible(parameters) || !mayStartClassName(result, parameters.isRelaxedMatching())) return;
|
||||
if (!isClassNamePossible(parameters.getPosition()) || !mayStartClassName(result, parameters.isRelaxedMatching())) return;
|
||||
|
||||
if (mayShowAllClasses(parameters)) {
|
||||
JavaClassNameCompletionContributor.addAllClasses(parameters, result, new Consumer<LookupElement>() {
|
||||
@@ -276,7 +276,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
checkAccess,
|
||||
result.getPrefixMatcher(), parameters);
|
||||
PsiClass arrays = JavaPsiFacade.getInstance(position.getProject()).findClass(CommonClassNames.JAVA_UTIL_ARRAYS, position.getResolveScope());
|
||||
if (arrays != null && filter.isAcceptable(arrays, position) && isClassNamePossible(parameters)) {
|
||||
if (arrays != null && filter.isAcceptable(arrays, position) && isClassNamePossible(parameters.getPosition())) {
|
||||
set.add(JavaClassNameCompletionContributor.createClassLookupItem(arrays, true));
|
||||
}
|
||||
for (LookupElement element : set) {
|
||||
@@ -350,8 +350,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isClassNamePossible(CompletionParameters parameters) {
|
||||
PsiElement position = parameters.getPosition();
|
||||
public static boolean isClassNamePossible(final PsiElement position) {
|
||||
final PsiElement parent = position.getParent();
|
||||
if (!(parent instanceof PsiJavaCodeReferenceElement)) return false;
|
||||
if (((PsiJavaCodeReferenceElement)parent).getQualifier() != null) return false;
|
||||
|
||||
@@ -160,19 +160,24 @@ public class SuppressFix extends SuppressIntentionAction {
|
||||
final String id) {
|
||||
|
||||
if (annotation != null) {
|
||||
if (annotation.getText().indexOf("{") == -1) {
|
||||
final String currentSuppressedId = "\"" + id + "\"";
|
||||
if (!annotation.getText().contains("{")) {
|
||||
final PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
|
||||
if (attributes.length == 1) {
|
||||
final String suppressedWarnings = attributes[0].getText();
|
||||
return JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText("@" +
|
||||
SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "({" + suppressedWarnings + ", \"" + id + "\"})", container);
|
||||
if (suppressedWarnings.contains(currentSuppressedId)) return null;
|
||||
return JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText(
|
||||
"@" + SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "({" + suppressedWarnings + ", " + currentSuppressedId + "})", container);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
final int curlyBraceIndex = annotation.getText().lastIndexOf("}");
|
||||
if (curlyBraceIndex > 0) {
|
||||
final String oldSuppressWarning = annotation.getText().substring(0, curlyBraceIndex);
|
||||
if (oldSuppressWarning.contains(currentSuppressedId)) return null;
|
||||
return JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText(
|
||||
annotation.getText().substring(0, curlyBraceIndex) + ", \"" + id + "\"})", container);
|
||||
oldSuppressWarning + ", " + currentSuppressedId + "})", container);
|
||||
}
|
||||
else if (!ApplicationManager.getApplication().isUnitTestMode() && editor != null) {
|
||||
Messages.showErrorDialog(editor.getComponent(),
|
||||
|
||||
@@ -148,28 +148,6 @@ public final class PackageViewPane extends AbstractProjectViewPSIPane {
|
||||
return super.getSelectedDirectories();
|
||||
}
|
||||
|
||||
private final class ShowModulesAction extends ToggleAction {
|
||||
private ShowModulesAction() {
|
||||
super(IdeBundle.message("action.show.modules"), IdeBundle.message("action.description.show.modules"), IconLoader.getIcon("/objectBrowser/showModules.png"));
|
||||
}
|
||||
|
||||
public boolean isSelected(AnActionEvent event) {
|
||||
return ProjectView.getInstance(myProject).isShowModules(getId());
|
||||
}
|
||||
|
||||
public void setSelected(AnActionEvent event, boolean flag) {
|
||||
final ProjectViewImpl projectView = (ProjectViewImpl)ProjectView.getInstance(myProject);
|
||||
projectView.setShowModules(flag, getId());
|
||||
}
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
final ProjectViewImpl projectView = (ProjectViewImpl)ProjectView.getInstance(myProject);
|
||||
presentation.setVisible(projectView.getCurrentProjectViewPane() == PackageViewPane.this);
|
||||
}
|
||||
}
|
||||
|
||||
private final class ShowLibraryContentsAction extends ToggleAction {
|
||||
private ShowLibraryContentsAction() {
|
||||
super(IdeBundle.message("action.show.libraries.contents"), IdeBundle.message("action.show.hide.library.contents"), IconLoader.getIcon("/objectBrowser/showLibraryContents.png"));
|
||||
@@ -193,7 +171,12 @@ public final class PackageViewPane extends AbstractProjectViewPSIPane {
|
||||
}
|
||||
|
||||
public void addToolbarActions(DefaultActionGroup actionGroup) {
|
||||
actionGroup.addAction(new ShowModulesAction()).setAsSecondary(true);
|
||||
actionGroup.addAction(new ShowModulesAction(myProject){
|
||||
@Override
|
||||
protected String getId() {
|
||||
return PackageViewPane.this.getId();
|
||||
}
|
||||
}).setAsSecondary(true);
|
||||
actionGroup.addAction(new ShowLibraryContentsAction()).setAsSecondary(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public class PackagePatternProvider extends PatternDialectProvider {
|
||||
pattern += recursively ? "..*" : ".*";
|
||||
}
|
||||
else {
|
||||
pattern = recursively ? "*..*" : ".*";
|
||||
pattern = recursively ? "*..*" : "*";
|
||||
}
|
||||
|
||||
return new PatternPackageSet(pattern, scope, getModulePattern(node));
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.file;
|
||||
|
||||
import com.intellij.ide.impl.ProjectViewSelectInTarget;
|
||||
import com.intellij.ide.projectView.impl.ProjectViewPane;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
@@ -25,7 +23,6 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.JavaDirectoryService;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.PsiManagerImpl;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -77,8 +74,4 @@ public class PsiJavaDirectoryImpl extends PsiDirectoryImpl {
|
||||
super.checkAdd(element);
|
||||
}
|
||||
}
|
||||
|
||||
public void navigate(final boolean requestFocus) {
|
||||
ProjectViewSelectInTarget.select(getProject(), this, ProjectViewPane.ID, null, getVirtualFile(), requestFocus);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-12
@@ -15,35 +15,24 @@
|
||||
*/
|
||||
package com.intellij.refactoring.introduceField;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.introduceParameter.AbstractJavaInplaceIntroducer;
|
||||
import com.intellij.refactoring.introduceParameter.VisibilityListener;
|
||||
import com.intellij.refactoring.move.moveMembers.MoveMembersImpl;
|
||||
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
|
||||
import com.intellij.refactoring.util.occurences.OccurenceManager;
|
||||
import com.intellij.ui.StateRestoringCheckBox;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
|
||||
@@ -165,7 +154,8 @@ public class InplaceIntroduceConstantPopup extends AbstractInplaceIntroduceField
|
||||
|
||||
@Override
|
||||
protected String[] suggestNames(PsiType defaultType, String propName) {
|
||||
return IntroduceConstantDialog.createNameSuggestionGenerator(propName, myExpr, JavaCodeStyleManager.getInstance(myProject), null)
|
||||
return IntroduceConstantDialog.createNameSuggestionGenerator(propName, myExpr, JavaCodeStyleManager.getInstance(myProject), null,
|
||||
myParentClass)
|
||||
.getSuggestedNameInfo(defaultType).names;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ public class InplaceIntroduceFieldPopup extends AbstractInplaceIntroduceFieldPop
|
||||
|
||||
@Override
|
||||
protected String[] suggestNames(PsiType defaultType, String propName) {
|
||||
return IntroduceFieldDialog.createGenerator(myStatic, (PsiLocalVariable)getLocalVariable(), myExpr, getLocalVariable() != null, null)
|
||||
return IntroduceFieldDialog.createGenerator(myStatic, (PsiLocalVariable)getLocalVariable(), myExpr, getLocalVariable() != null, null, myParentClass)
|
||||
.getSuggestedNameInfo(defaultType).names;
|
||||
}
|
||||
|
||||
|
||||
+13
-3
@@ -34,6 +34,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.SuggestedNameInfo;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.impl.source.PsiClassImpl;
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveUtil;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
@@ -225,7 +226,7 @@ class IntroduceConstantDialog extends DialogWrapper {
|
||||
}
|
||||
final NameSuggestionsManager nameSuggestionsManager =
|
||||
new NameSuggestionsManager(myTypeSelector, myNameField, createNameSuggestionGenerator(propertyName, myInitializerExpression,
|
||||
myCodeStyleManager, myEnteredName));
|
||||
myCodeStyleManager, myEnteredName, myParentClass));
|
||||
|
||||
nameSuggestionsManager.setLabelsFor(myTypeLabel, myNameSuggestionLabel);
|
||||
//////////
|
||||
@@ -292,11 +293,20 @@ class IntroduceConstantDialog extends DialogWrapper {
|
||||
protected static NameSuggestionsGenerator createNameSuggestionGenerator(final String propertyName,
|
||||
final PsiExpression psiExpression,
|
||||
final JavaCodeStyleManager codeStyleManager,
|
||||
final String enteredName) {
|
||||
final String enteredName, final PsiClass parentClass) {
|
||||
return new NameSuggestionsGenerator() {
|
||||
public SuggestedNameInfo getSuggestedNameInfo(PsiType type) {
|
||||
final SuggestedNameInfo nameInfo =
|
||||
SuggestedNameInfo nameInfo =
|
||||
codeStyleManager.suggestVariableName(VariableKind.STATIC_FINAL_FIELD, propertyName, psiExpression, type);
|
||||
if (psiExpression != null) {
|
||||
String[] names = nameInfo.names;
|
||||
for (int i = 0, namesLength = names.length; i < namesLength; i++) {
|
||||
String name = names[i];
|
||||
if (parentClass.findFieldByName(name, false) != null) {
|
||||
names[i] = codeStyleManager.suggestUniqueVariableName(name, psiExpression, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
final String[] strings = JavaCompletionUtil
|
||||
.completeVariableNameForRefactoring(codeStyleManager, type, VariableKind.LOCAL_VARIABLE, nameInfo);
|
||||
return new SuggestedNameInfo.Delegate(enteredName != null ? ArrayUtil.mergeArrays(new String[]{enteredName}, strings): strings, nameInfo);
|
||||
|
||||
+12
-2
@@ -177,7 +177,8 @@ class IntroduceFieldDialog extends DialogWrapper {
|
||||
namePrompt.setLabelFor(myNameField.getFocusableComponent());
|
||||
|
||||
myNameSuggestionsManager = new NameSuggestionsManager(myTypeSelector, myNameField,
|
||||
createGenerator(myWillBeDeclaredStatic, myLocalVariable, myInitializerExpression, myIsInvokedOnDeclaration, myEnteredName));
|
||||
createGenerator(myWillBeDeclaredStatic, myLocalVariable, myInitializerExpression, myIsInvokedOnDeclaration, myEnteredName,
|
||||
myParentClass));
|
||||
myNameSuggestionsManager.setLabelsFor(type, namePrompt);
|
||||
|
||||
return panel;
|
||||
@@ -200,7 +201,7 @@ class IntroduceFieldDialog extends DialogWrapper {
|
||||
static NameSuggestionsGenerator createGenerator(final boolean willBeDeclaredStatic,
|
||||
final PsiLocalVariable localVariable,
|
||||
final PsiExpression initializerExpression,
|
||||
final boolean isInvokedOnDeclaration, final String enteredName) {
|
||||
final boolean isInvokedOnDeclaration, final String enteredName, final PsiClass parentClass) {
|
||||
return new NameSuggestionsGenerator() {
|
||||
private final JavaCodeStyleManager myCodeStyleManager = JavaCodeStyleManager.getInstance(localVariable != null ? localVariable.getProject()
|
||||
: initializerExpression.getProject());
|
||||
@@ -212,6 +213,15 @@ class IntroduceFieldDialog extends DialogWrapper {
|
||||
propertyName = myCodeStyleManager.variableNameToPropertyName(localVariable.getName(), VariableKind.LOCAL_VARIABLE);
|
||||
}
|
||||
final SuggestedNameInfo nameInfo = myCodeStyleManager.suggestVariableName(variableKind, propertyName, initializerExpression, type);
|
||||
if (initializerExpression != null) {
|
||||
String[] names = nameInfo.names;
|
||||
for (int i = 0, namesLength = names.length; i < namesLength; i++) {
|
||||
String name = names[i];
|
||||
if (parentClass.findFieldByName(name, false) != null) {
|
||||
names[i] = myCodeStyleManager.suggestUniqueVariableName(name, initializerExpression, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
final String[] strings = JavaCompletionUtil.completeVariableNameForRefactoring(myCodeStyleManager, type, VariableKind.LOCAL_VARIABLE, nameInfo);
|
||||
return new SuggestedNameInfo.Delegate(enteredName != null ? ArrayUtil.mergeArrays(new String[]{enteredName}, strings) : strings, nameInfo);
|
||||
}
|
||||
|
||||
+4
-1
@@ -272,7 +272,10 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase implements R
|
||||
return new NameSuggestionsGenerator() {
|
||||
public SuggestedNameInfo getSuggestedNameInfo(PsiType type) {
|
||||
final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);
|
||||
final SuggestedNameInfo info = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, propName, expr, type);
|
||||
SuggestedNameInfo info = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, propName, expr, type);
|
||||
if (expr != null) {
|
||||
info = codeStyleManager.suggestUniqueVariableName(info, expr, true);
|
||||
}
|
||||
final String[] strings = JavaCompletionUtil
|
||||
.completeVariableNameForRefactoring(codeStyleManager, type, VariableKind.LOCAL_VARIABLE, info);
|
||||
return new SuggestedNameInfo.Delegate(enteredName != null ? ArrayUtil.mergeArrays(new String[]{enteredName}, strings): strings, info);
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
|
||||
* @author yole
|
||||
*/
|
||||
public class ThreadDumpParser {
|
||||
private static final Pattern ourThreadStartPattern = Pattern.compile("^\"(.+)\".+prio=\\d+ tid=[^\\s]+ nid=[^\\s]+ ([^\\[]+)");
|
||||
private static final Pattern ourThreadStartPattern = Pattern.compile("^\\s*\"(.+)\".+(prio=\\d+ tid=[^\\s]+ nid=[^\\s]+|Id=\\d+) ([^\\[]+)");
|
||||
private static final Pattern ourThreadStatePattern = Pattern.compile("java\\.lang\\.Thread\\.State: (.+) \\((.+)\\)");
|
||||
private static final Pattern ourThreadStatePattern2 = Pattern.compile("java\\.lang\\.Thread\\.State: (.+)");
|
||||
private static final Pattern ourWaitingForLockPattern = Pattern.compile("- waiting (on|to lock) <(.+)>");
|
||||
@@ -185,7 +185,7 @@ public class ThreadDumpParser {
|
||||
private static ThreadState tryParseThreadStart(final String line) {
|
||||
Matcher m = ourThreadStartPattern.matcher(line);
|
||||
if (m.find()) {
|
||||
final ThreadState state = new ThreadState(m.group(1), m.group(2));
|
||||
final ThreadState state = new ThreadState(m.group(1), m.group(3));
|
||||
if (line.contains(" daemon ")) {
|
||||
state.setDaemon(true);
|
||||
}
|
||||
|
||||
@@ -155,6 +155,10 @@ public class JavaUsageTypeProvider implements UsageTypeProvider {
|
||||
if (referenceList.getParent() instanceof PsiClass) return UsageType.CLASS_EXTENDS_IMPLEMENTS_LIST;
|
||||
if (referenceList.getParent() instanceof PsiMethod) return UsageType.CLASS_METHOD_THROWS_LIST;
|
||||
}
|
||||
if (PsiTreeUtil.getParentOfType(element, PsiTypeParameterList.class) != null ||
|
||||
PsiTreeUtil.getParentOfType(element, PsiReferenceParameterList.class) != null) {
|
||||
return UsageType.TYPE_PARAMETER;
|
||||
}
|
||||
|
||||
PsiTypeCastExpression castExpression = PsiTreeUtil.getParentOfType(element, PsiTypeCastExpression.class);
|
||||
if (castExpression != null) {
|
||||
@@ -203,7 +207,12 @@ public class JavaUsageTypeProvider implements UsageTypeProvider {
|
||||
final PsiNewExpression psiNewExpression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class);
|
||||
if (psiNewExpression != null) {
|
||||
final PsiJavaCodeReferenceElement classReference = psiNewExpression.getClassReference();
|
||||
if (classReference != null && PsiTreeUtil.isAncestor(classReference, element, false)) return UsageType.CLASS_NEW_OPERATOR;
|
||||
if (classReference != null && PsiTreeUtil.isAncestor(classReference, element, false)) {
|
||||
if (psiNewExpression.getArrayDimensions().length > 0) {
|
||||
return UsageType.CLASS_NEW_ARRAY;
|
||||
}
|
||||
return UsageType.CLASS_NEW_OPERATOR;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
+2
-2
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
class Test {
|
||||
private static final String FOO = "foo";
|
||||
public static final String BAR = "foo";
|
||||
public static final String FOO1 = "foo";
|
||||
|
||||
public void method(Map<Object, Object> args) {
|
||||
System.out.println(FOO);
|
||||
System.out.println(BAR);
|
||||
System.out.println(FOO1);
|
||||
}
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class Test {
|
||||
public void method(String FOO) {
|
||||
System.out.println(FOO);
|
||||
System.out.println("fo<caret>o");
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class Test {
|
||||
|
||||
public static final String FOO = "foo";
|
||||
|
||||
public void method(String FOO) {
|
||||
System.out.println(FOO);
|
||||
System.out.println(Test.FOO);
|
||||
}
|
||||
}
|
||||
+9
@@ -5,6 +5,7 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
@@ -42,6 +43,14 @@ public class HeavyNormalCompletionTest extends CompletionTestCase{
|
||||
assertTrue(JavaPsiFacade.getInstance(myProject).findPackage("foo.bar.goo").isValid());
|
||||
}
|
||||
|
||||
public void testAllClassesWhenNothingIsFound() throws Throwable {
|
||||
createClass("package foo.bar; public class AxBxCxDxEx {}");
|
||||
|
||||
configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
|
||||
((LookupImpl)LookupManager.getActiveLookup(myEditor)).finishLookup(Lookup.NORMAL_SELECT_CHAR);
|
||||
checkResultByFile("/codeInsight/completion/normal/" + getTestName(false) + "_after.java");
|
||||
}
|
||||
|
||||
public void testAllClassesOnSecondBasicCompletion() throws Throwable {
|
||||
createClass("package foo.bar; public class AxBxCxDxEx {}");
|
||||
|
||||
|
||||
@@ -700,6 +700,22 @@ class Foo {
|
||||
assert !lookup
|
||||
}
|
||||
|
||||
public void testAutoRestartAndTypingDuringCopyCommit() {
|
||||
registerLongCompletionContributor()
|
||||
|
||||
myFixture.configureByText("a.java", """ class Foo { { int iteraaa; <caret> } } """)
|
||||
type 'ite'
|
||||
assert !('iter' in myFixture.lookupElementStrings)
|
||||
myFixture.type 'r'
|
||||
joinCommit()
|
||||
myFixture.type 'a'
|
||||
joinAutopopup()
|
||||
joinCompletion()
|
||||
myFixture.type '\n'
|
||||
myFixture.checkResult(" class Foo { { int iteraaa; iteraaa<caret> } } ")
|
||||
assert !lookup
|
||||
}
|
||||
|
||||
private void joinSomething(int degree) {
|
||||
if (degree == 0) return
|
||||
joinAlarm()
|
||||
|
||||
@@ -60,7 +60,15 @@ public class InplaceIntroduceConstantTest extends AbstractInplaceIntroduceTest {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) {
|
||||
type("BAR");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testNoConflictingConstantName() throws Exception {
|
||||
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,6 +75,8 @@ public class OffsetMap {
|
||||
myModified.add(key);
|
||||
}
|
||||
|
||||
RangeMarker old = myMap.get(key);
|
||||
if (old != null) old.dispose();
|
||||
final RangeMarker marker = myDocument.createRangeMarker(offset, offset);
|
||||
marker.setGreedyToRight(key.isMoveableToRight());
|
||||
myMap.put(key, marker);
|
||||
@@ -82,6 +84,9 @@ public class OffsetMap {
|
||||
|
||||
public void removeOffset(OffsetKey key) {
|
||||
myModified.add(key);
|
||||
RangeMarker old = myMap.get(key);
|
||||
if (old != null) old.dispose();
|
||||
|
||||
myMap.remove(key);
|
||||
}
|
||||
|
||||
@@ -101,4 +106,10 @@ public class OffsetMap {
|
||||
public boolean wasModified(OffsetKey key) {
|
||||
return myModified.contains(key);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
for (RangeMarker rangeMarker : myMap.values()) {
|
||||
rangeMarker.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ExecutionUtil {
|
||||
String error = e.getMessage();
|
||||
HyperlinkListener listener = null;
|
||||
|
||||
if (error.contains("87") &&
|
||||
if ((error.contains("87") || error.contains("111") || error.contains("206")) &&
|
||||
e instanceof ProcessNotCreatedException &&
|
||||
!PropertiesComponent.getInstance(project).isTrueValue("dynamic.classpath")) {
|
||||
final String commandLineString = ((ProcessNotCreatedException)e).getCommandLine().getCommandLineString();
|
||||
|
||||
@@ -40,7 +40,7 @@ public class FoldingDescriptor {
|
||||
private final ASTNode myElement;
|
||||
private final TextRange myRange;
|
||||
@Nullable private final FoldingGroup myGroup;
|
||||
private Set<Object> myDependencies;
|
||||
private final Set<Object> myDependencies;
|
||||
private final boolean myNeverExpands;
|
||||
|
||||
/**
|
||||
@@ -150,6 +150,7 @@ public class FoldingDescriptor {
|
||||
return myNeverExpands;
|
||||
}
|
||||
|
||||
@SuppressWarnings("HardCodedStringLiteral")
|
||||
@Override
|
||||
public String toString() {
|
||||
return myRange + " for AST: " + myElement;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class LanguageFolding extends LanguageExtension<FoldingBuilder> {
|
||||
}
|
||||
}
|
||||
else {
|
||||
return (extensions.size() == 1) ? extensions.get(0) : new CompositeFoldingBuilder(extensions);
|
||||
return extensions.size() == 1 ? extensions.get(0) : new CompositeFoldingBuilder(extensions);
|
||||
}
|
||||
|
||||
l.putUserData(getLanguageCache(), result);
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.completion.impl.CompletionServiceImpl;
|
||||
import com.intellij.codeInsight.editorActions.CompletionAutoPopupHandler;
|
||||
import com.intellij.codeInsight.hint.ShowParameterInfoHandler;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
@@ -97,15 +99,18 @@ public class AutoPopupController implements Disposable {
|
||||
return;
|
||||
}
|
||||
|
||||
LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
|
||||
boolean shouldBeFast = lookup != null && lookup.isShown();
|
||||
|
||||
final CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
|
||||
if (currentCompletion != null) {
|
||||
currentCompletion.closeAndFinish(true);
|
||||
currentCompletion.closeAndFinish(false);
|
||||
}
|
||||
|
||||
final CompletionPhase.AutoPopupAlarm phase = new CompletionPhase.AutoPopupAlarm(false, editor);
|
||||
CompletionServiceImpl.setCompletionPhase(phase);
|
||||
|
||||
addRequest(new Runnable() {
|
||||
Runnable request = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CompletionAutoPopupHandler.runLaterWithCommitted(myProject, editor.getDocument(), new Runnable() {
|
||||
@@ -120,7 +125,12 @@ public class AutoPopupController implements Disposable {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, CodeInsightSettings.getInstance().AUTO_LOOKUP_DELAY);
|
||||
};
|
||||
if (shouldBeFast) {
|
||||
request.run();
|
||||
} else {
|
||||
addRequest(request, CodeInsightSettings.getInstance().AUTO_LOOKUP_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
|
||||
+27
-10
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.codeInsight.CodeInsightActionHandler;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.completion.impl.CompletionServiceImpl;
|
||||
@@ -28,6 +29,7 @@ import com.intellij.injected.editor.EditorWindow;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationAdapter;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
@@ -48,15 +50,13 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.CommitToPsiFileAction;
|
||||
import com.intellij.psi.impl.PsiFileEx;
|
||||
import com.intellij.psi.impl.PsiModificationTrackerImpl;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
@@ -260,6 +260,8 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
freezeSemaphore.down();
|
||||
final CompletionProgressIndicator indicator = new CompletionProgressIndicator(editor, parameters, this, freezeSemaphore,
|
||||
initContext.getOffsetMap(), hasModifiers);
|
||||
indicator.addMapToDispose(hostMap);
|
||||
indicator.addMapToDispose(context.getOffsetMap());
|
||||
|
||||
boolean sync =
|
||||
(invokedExplicitly || ApplicationManager.getApplication().isUnitTestMode()) && !CompletionAutoPopupHandler.ourTestingAutopopup;
|
||||
@@ -500,10 +502,19 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
|
||||
final Project project = hostFile.getProject();
|
||||
|
||||
if (autopopup) {
|
||||
if (!invokedExplicitly) {
|
||||
final CompletionPhase.AutoPopupAlarm phase = new CompletionPhase.AutoPopupAlarm(true, hostEditor);
|
||||
CompletionServiceImpl.setCompletionPhase(phase);
|
||||
|
||||
ApplicationManager.getApplication().addApplicationListener(new ApplicationAdapter() {
|
||||
@Override
|
||||
public void beforeWriteActionStart(Object action) {
|
||||
if (!(action instanceof Class) || !CommitToPsiFileAction.class.isAssignableFrom((Class)action)) {
|
||||
AutoPopupController.getInstance(project).scheduleAutoPopup(hostEditor, Condition.TRUE);
|
||||
}
|
||||
}
|
||||
}, phase);
|
||||
|
||||
CompletionAutoPopupHandler.runLaterWithCommitted(project, hostDocument, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -511,7 +522,8 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
doComplete(initContext, hasModifiers, invocationCount, hostFile, hostStartOffset, hostEditor, hostMap);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
PsiDocumentManager.getInstance(hostFile.getProject()).commitDocument(hostDocument);
|
||||
|
||||
doComplete(initContext, hasModifiers, invocationCount, hostFile, hostStartOffset, hostEditor, hostMap);
|
||||
@@ -618,13 +630,18 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
if (!context.getProject().isDisposed()) {
|
||||
runnable.run();
|
||||
}
|
||||
indicator.disposeOffsetMaps();
|
||||
}
|
||||
};
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
ApplicationManager.getApplication().invokeLater(runnable1);
|
||||
} else {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
runnable1.run();
|
||||
}
|
||||
else {
|
||||
ApplicationManager.getApplication().invokeLater(runnable1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
indicator.disposeOffsetMaps();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,7 +651,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
|
||||
public static final Key<SoftReference<Pair<PsiFile, Document>>> FILE_COPY_KEY = Key.create("CompletionFileCopy");
|
||||
|
||||
protected PsiFile createFileCopy(PsiFile file) {
|
||||
private static PsiFile createFileCopy(PsiFile file) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (file.isPhysical() && virtualFile != null && virtualFile.getFileSystem() == LocalFileSystem.getInstance()
|
||||
// must not cache injected file copy, since it does not reflect changes in host document
|
||||
|
||||
+24
-5
@@ -60,6 +60,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue;
|
||||
import com.intellij.util.ui.update.Update;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -71,6 +72,7 @@ import java.awt.event.KeyEvent;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
@@ -94,7 +96,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
private final CopyOnWriteArrayList<Pair<Integer, ElementPattern<String>>> myRestartingPrefixConditions = ContainerUtil.createEmptyCOWList();
|
||||
private final LookupAdapter myLookupListener = new LookupAdapter() {
|
||||
public void itemSelected(LookupEvent event) {
|
||||
finishCompletionProcess();
|
||||
finishCompletionProcess(false);
|
||||
|
||||
LookupElement item = event.getItem();
|
||||
if (item == null) return;
|
||||
@@ -108,13 +110,14 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
|
||||
|
||||
public void lookupCanceled(final LookupEvent event) {
|
||||
finishCompletionProcess();
|
||||
finishCompletionProcess(true);
|
||||
}
|
||||
};
|
||||
private volatile int myCount;
|
||||
private final ConcurrentHashMap<LookupElement, CompletionSorterImpl> myItemSorters = new ConcurrentHashMap<LookupElement, CompletionSorterImpl>(TObjectHashingStrategy.IDENTITY);
|
||||
private final LinkedList<Runnable> myDelayQueue = new LinkedList<Runnable>();
|
||||
private volatile boolean myProcessingDelayedActions;
|
||||
private final Set<OffsetMap> myMapsToDispose = new THashSet<OffsetMap>();
|
||||
|
||||
public CompletionProgressIndicator(final Editor editor, CompletionParameters parameters, CodeCompletionHandlerBase handler, Semaphore freezeSemaphore,
|
||||
final OffsetMap offsetMap, boolean hasModifiers) {
|
||||
@@ -134,6 +137,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
registerItself();
|
||||
addMapToDispose(offsetMap);
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
@@ -407,7 +411,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
Lookup lookup = LookupManager.getActiveLookup(myEditor);
|
||||
LOG.assertTrue(lookup == myLookup, lookup + "; " + this);
|
||||
myLookup.removeLookupListener(myLookupListener);
|
||||
finishCompletionProcess();
|
||||
finishCompletionProcess(true);
|
||||
CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());
|
||||
|
||||
if (hideLookup) {
|
||||
@@ -415,7 +419,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
}
|
||||
}
|
||||
|
||||
private void finishCompletionProcess() {
|
||||
private void finishCompletionProcess(boolean disposeOffsetMap) {
|
||||
cancel();
|
||||
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
@@ -427,13 +431,23 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
|
||||
CompletionServiceImpl.assertPhase(CompletionPhase.BgCalculation.class, CompletionPhase.ItemsCalculated.class, CompletionPhase.Synchronous.class, CompletionPhase.Restarted.class);
|
||||
CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
|
||||
if (disposeOffsetMap) {
|
||||
disposeOffsetMaps();
|
||||
}
|
||||
}
|
||||
|
||||
void disposeOffsetMaps() {
|
||||
for (OffsetMap map : myMapsToDispose) {
|
||||
map.dispose();
|
||||
}
|
||||
myMapsToDispose.clear();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static void cleanupForNextTest() {
|
||||
CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
|
||||
if (currentCompletion != null) {
|
||||
currentCompletion.finishCompletionProcess();
|
||||
currentCompletion.finishCompletionProcess(true);
|
||||
CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());
|
||||
} else {
|
||||
CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
|
||||
@@ -718,4 +732,9 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addMapToDispose(OffsetMap map) {
|
||||
myMapsToDispose.add(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-1
@@ -23,6 +23,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil;
|
||||
import com.intellij.codeInsight.problems.ProblemImpl;
|
||||
import com.intellij.codeInsight.problems.WolfTheProblemSolverImpl;
|
||||
import com.intellij.concurrency.JobUtil;
|
||||
import com.intellij.injected.editor.DocumentWindow;
|
||||
import com.intellij.lang.Language;
|
||||
@@ -49,6 +50,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -558,6 +560,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
|
||||
final Runnable action = new Runnable() {
|
||||
public void run() {
|
||||
//noinspection unchecked
|
||||
boolean failed = false;
|
||||
for (List<PsiElement> elements : new List[]{elements1, elements2}) {
|
||||
int nextLimit = chunkSize;
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
@@ -575,7 +578,24 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
|
||||
holder.clear();
|
||||
|
||||
for (final HighlightVisitor visitor : visitors) {
|
||||
visitor.visit(element, holder);
|
||||
try {
|
||||
visitor.visit(element, holder);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (WolfTheProblemSolverImpl.HaveGotErrorException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (!failed) {
|
||||
LOG.error(e);
|
||||
}
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == nextLimit) {
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -912,7 +912,9 @@ public class DocumentationManager {
|
||||
}
|
||||
|
||||
void showHint(final JBPopup hint) {
|
||||
PopupPositionManager.positionPopupInBestPosition(hint, myEditor, true);
|
||||
final Component focusOwner = IdeFocusManager.getInstance(myProject).getFocusOwner();
|
||||
DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
|
||||
PopupPositionManager.positionPopupInBestPosition(hint, null, dataContext);
|
||||
}
|
||||
|
||||
public void requestFocus() {
|
||||
|
||||
+8
-1
@@ -24,6 +24,7 @@ import com.intellij.codeInsight.completion.impl.CompletionServiceImpl;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.ide.PowerSaveMode;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
@@ -39,6 +40,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author peter
|
||||
*/
|
||||
public class CompletionAutoPopupHandler extends TypedHandlerDelegate {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.editorActions.CompletionAutoPopupHandler");
|
||||
public static volatile boolean ourTestingAutopopup = false;
|
||||
|
||||
@Override
|
||||
@@ -88,13 +90,18 @@ public class CompletionAutoPopupHandler extends TypedHandlerDelegate {
|
||||
public static void invokeCompletion(CompletionType completionType,
|
||||
boolean autopopup,
|
||||
Project project, Editor editor, int time) {
|
||||
if (editor.isDisposed()) return;
|
||||
|
||||
// retrieve the injected file from scratch since our typing might have destroyed the old one completely
|
||||
Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(topLevelEditor.getDocument());
|
||||
if (file == null) return;
|
||||
|
||||
PsiFile topLevelFile = InjectedLanguageUtil.getTopLevelFile(file);
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
if (!PsiDocumentManager.getInstance(project).isCommitted(editor.getDocument())) {
|
||||
LOG.error("Non-committed document");
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
}
|
||||
Editor newEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(topLevelEditor, topLevelFile);
|
||||
try {
|
||||
new CodeCompletionHandlerBase(completionType, false, autopopup).invokeCompletion(project, newEditor, time, false);
|
||||
|
||||
@@ -157,11 +157,11 @@ public class FoldingUpdate {
|
||||
@NotNull FoldingMap elementsToFoldMap,
|
||||
boolean quick) {
|
||||
final FileViewProvider viewProvider = file.getViewProvider();
|
||||
TextRange docRange = TextRange.from(0, document.getTextLength());
|
||||
for (final Language language : viewProvider.getLanguages()) {
|
||||
final PsiFile psi = viewProvider.getPsi(language);
|
||||
final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(language);
|
||||
if (psi != null && foldingBuilder != null) {
|
||||
TextRange docRange = TextRange.from(0, document.getTextLength());
|
||||
for (FoldingDescriptor descriptor : LanguageFolding.buildFoldingDescriptors(foldingBuilder, psi, document, quick)) {
|
||||
TextRange range = descriptor.getRange();
|
||||
if (!docRange.contains(range)) {
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import com.intellij.codeInsight.hint.ImplementationViewComponent;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.navigation.ImplementationSearcher;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
@@ -194,7 +195,7 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
|
||||
.setTitle(title)
|
||||
.createPopup();
|
||||
|
||||
PopupPositionManager.positionPopupInBestPosition(popup, editor, invokedFromEditor);
|
||||
PopupPositionManager.positionPopupInBestPosition(popup, editor, DataManager.getInstance().getDataContext());
|
||||
component.setHint(popup, title);
|
||||
|
||||
myPopupRef = new WeakReference<JBPopup>(popup);
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
|
||||
}
|
||||
}
|
||||
|
||||
private static class HaveGotErrorException extends RuntimeException {
|
||||
public static class HaveGotErrorException extends RuntimeException {
|
||||
private final HighlightInfo myHighlightInfo;
|
||||
private final boolean myHasErrorElement;
|
||||
|
||||
|
||||
@@ -619,6 +619,22 @@ public class EditTemplateDialog extends DialogWrapper {
|
||||
|
||||
}
|
||||
|
||||
boolean anyChecked = false;
|
||||
for (JCheckBox contextCheckBox : myCbContextMap.values()) {
|
||||
if (contextCheckBox.isSelected()) {
|
||||
anyChecked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!anyChecked) {
|
||||
Messages.showMessageDialog(getContentPane(),
|
||||
"Please enable at least one context checkbox. Otherwise the live template will never ber active.",
|
||||
CodeInsightBundle.message("dialog.edit.template.error.title"),
|
||||
Messages.getErrorIcon()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
super.doOKAction();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -54,10 +54,9 @@ public class LiveTemplateCompletionContributor extends CompletionContributor {
|
||||
final TemplateImpl template = findApplicableTemplate(file, offset, prefix);
|
||||
if (template != null) {
|
||||
result.addElement(new LiveTemplateLookupElement(template));
|
||||
} else {
|
||||
for (final TemplateImpl possible : listApplicableTemplates(file, offset)) {
|
||||
result.restartCompletionOnPrefixChange(possible.getKey());
|
||||
}
|
||||
}
|
||||
for (final TemplateImpl possible : listApplicableTemplates(file, offset)) {
|
||||
result.restartCompletionOnPrefixChange(possible.getKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -549,6 +549,7 @@ public class TemplateState implements Disposable {
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
offsetMap.dispose();
|
||||
|
||||
if (completionChar == '.') {
|
||||
EditorModificationUtil.insertStringAtCaret(myEditor, ".");
|
||||
|
||||
@@ -21,7 +21,9 @@ import com.intellij.codeInspection.InspectionsBundle;
|
||||
import com.intellij.codeInspection.ex.InspectionTool;
|
||||
import com.intellij.codeInspection.reference.RefElement;
|
||||
import com.intellij.codeInspection.reference.RefEntity;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.ui.ComputableIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -35,6 +37,16 @@ public class RefElementNode extends InspectionTreeNode {
|
||||
private boolean myHasDescriptorsUnder = false;
|
||||
private CommonProblemDescriptor mySingleDescriptor = null;
|
||||
protected InspectionTool myTool;
|
||||
private ComputableIcon myIcon = new ComputableIcon(new Computable<Icon>() {
|
||||
@Override
|
||||
public Icon compute() {
|
||||
final RefEntity refEntity = getElement();
|
||||
if (refEntity == null) {
|
||||
return null;
|
||||
}
|
||||
return refEntity.getIcon(false);
|
||||
}
|
||||
});
|
||||
|
||||
public RefElementNode(final Object userObject, final InspectionTool tool) {
|
||||
super(userObject);
|
||||
@@ -55,11 +67,7 @@ public class RefElementNode extends InspectionTreeNode {
|
||||
|
||||
@Nullable
|
||||
public Icon getIcon(boolean expanded) {
|
||||
final RefEntity refEntity = getElement();
|
||||
if (refEntity == null) {
|
||||
return null;
|
||||
}
|
||||
return refEntity.getIcon(expanded);
|
||||
return myIcon.getIcon();
|
||||
}
|
||||
|
||||
public int getProblemCount() {
|
||||
|
||||
@@ -36,6 +36,7 @@ public class RunContentExecutor {
|
||||
private Runnable myRerun;
|
||||
private Runnable myAfterCompletion;
|
||||
private String myTitle = "Output";
|
||||
private String myHelpId = null;
|
||||
|
||||
public RunContentExecutor(Project project, ProcessHandler process) {
|
||||
myProject = project;
|
||||
@@ -62,6 +63,11 @@ public class RunContentExecutor {
|
||||
return this;
|
||||
}
|
||||
|
||||
public RunContentExecutor withHelpId(String helpId) {
|
||||
myHelpId = helpId;
|
||||
return this;
|
||||
}
|
||||
|
||||
private ConsoleView createConsole(Project project, ProcessHandler processHandler) {
|
||||
TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
|
||||
for (Filter filter : myFilterList) {
|
||||
@@ -76,6 +82,9 @@ public class RunContentExecutor {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
|
||||
ConsoleView view = createConsole(myProject, myProcess);
|
||||
if (myHelpId != null) {
|
||||
view.setHelpId(myHelpId);
|
||||
}
|
||||
Executor executor = ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
|
||||
DefaultActionGroup actions = new DefaultActionGroup();
|
||||
|
||||
@@ -104,7 +113,7 @@ public class RunContentExecutor {
|
||||
myProcess.startNotify();
|
||||
}
|
||||
|
||||
private static JComponent createConsolePanel(ConsoleView view, ActionGroup actions) {
|
||||
private static JComponent createConsolePanel(ConsoleView view, ActionGroup actions) {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BorderLayout());
|
||||
panel.add(view.getComponent(), BorderLayout.CENTER);
|
||||
|
||||
@@ -108,8 +108,10 @@ public class FavoritesManager implements ProjectComponent, JDOMExternalizable {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<Pair<AbstractUrl, String>> getFavoritesListRootUrls(@NotNull String name) {
|
||||
return myName2FavoritesRoots.get(name);
|
||||
final LinkedHashSet<Pair<AbstractUrl, String>> pairs = myName2FavoritesRoots.get(name);
|
||||
return pairs == null ? Collections.<Pair<AbstractUrl,String>>emptyList() : pairs;
|
||||
}
|
||||
|
||||
public synchronized boolean addRoots(@NotNull String name, Module moduleContext, @NotNull Object elements) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.ide.dnd.DnDManager;
|
||||
import com.intellij.ide.dnd.DnDSource;
|
||||
import com.intellij.ide.dnd.aware.DnDAwareTree;
|
||||
import com.intellij.ide.projectView.impl.TransferableWrapper;
|
||||
import com.intellij.ide.util.scopeChooser.EditScopesDialog;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
|
||||
@@ -604,20 +605,42 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem
|
||||
protected final DefaultActionGroup createPopupActionGroup(final JComponent button) {
|
||||
final DefaultActionGroup group = new DefaultActionGroup();
|
||||
|
||||
group.add(new MenuAction(SCOPE_PROJECT));
|
||||
group.add(new MenuAction(SCOPE_TEST));
|
||||
group.add(new MenuAction(SCOPE_ALL));
|
||||
group.add(new MenuAction(SCOPE_CLASS));
|
||||
for(String name: getValidScopeNames()) {
|
||||
group.add(new MenuAction(name));
|
||||
}
|
||||
|
||||
group.add(new ConfigureScopesAction());
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
private Collection<String> getValidScopeNames() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
result.add(SCOPE_PROJECT);
|
||||
result.add(SCOPE_TEST);
|
||||
result.add(SCOPE_ALL);
|
||||
result.add(SCOPE_CLASS);
|
||||
|
||||
final NamedScopesHolder[] holders = NamedScopesHolder.getAllNamedScopeHolders(myProject);
|
||||
for (NamedScopesHolder holder : holders) {
|
||||
NamedScope[] scopes = holder.getEditableScopes(); //predefined scopes already included
|
||||
for (NamedScope scope : scopes) {
|
||||
group.add(new MenuAction(scope.getName()));
|
||||
result.add(scope.getName());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return group;
|
||||
private void selectScope(final String scopeType) {
|
||||
myType2ScopeMap.put(myCurrentViewType, scopeType);
|
||||
HierarchyBrowserManager.getInstance(myProject).getState().SCOPE = scopeType;
|
||||
|
||||
// invokeLater is called to update state of button before long tree building operation
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
doRefresh(true); // scope is kept per type so other builders doesn't need to be refreshed
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public final JComponent createCustomComponent(final Presentation presentation) {
|
||||
@@ -638,18 +661,23 @@ public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implem
|
||||
}
|
||||
|
||||
public final void actionPerformed(final AnActionEvent e) {
|
||||
myType2ScopeMap.put(myCurrentViewType, myScopeType);
|
||||
HierarchyBrowserManager.getInstance(myProject).getState().SCOPE = myScopeType;
|
||||
|
||||
// invokeLater is called to update state of button before long tree building operation
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
doRefresh(true); // scope is kept per type so other builders doesn't need to be refreshed
|
||||
}
|
||||
});
|
||||
selectScope(myScopeType);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private final class ConfigureScopesAction extends AnAction {
|
||||
private ConfigureScopesAction() {
|
||||
super("Configure...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
EditScopesDialog.editConfigurable(myProject, null);
|
||||
if (!getValidScopeNames().contains(myType2ScopeMap.get(myCurrentViewType))) {
|
||||
selectScope(SCOPE_ALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ide.macro;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDialog;
|
||||
import com.intellij.openapi.fileChooser.FileChooserFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class FilePromptMacro extends Macro implements SecondQueueExpandMacro {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "FilePrompt";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Shows a file chooser dialog";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String expand(DataContext dataContext) throws ExecutionCancelledException {
|
||||
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
|
||||
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
|
||||
final FileChooserDialog fileChooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project);
|
||||
final VirtualFile[] result = fileChooser.choose(null, project);
|
||||
if (result.length != 1) {
|
||||
throw new ExecutionCancelledException();
|
||||
}
|
||||
return FileUtil.toSystemDependentName(result [0].getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cachePreview(DataContext dataContext) {
|
||||
myCachedPreview = IdeBundle.message("macro.fileprompt.preview");
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public final class MacroManager {
|
||||
registerMacro(new FilePathRelativeToSourcepathMacro());
|
||||
registerMacro(new JdkPathMacro());
|
||||
registerMacro(new PromptMacro());
|
||||
registerMacro(new FilePromptMacro());
|
||||
registerMacro(new SourcepathEntryMacro());
|
||||
registerMacro(new ProjectFileDirMacro());
|
||||
registerMacro(new ProjectNameMacro());
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.intellij.ide.projectView.impl;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: anna
|
||||
* Date: 8/5/11
|
||||
* Time: 9:33 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public abstract class ShowModulesAction extends ToggleAction {
|
||||
private Project myProject;
|
||||
|
||||
public ShowModulesAction(Project project) {
|
||||
super(IdeBundle.message("action.show.modules"), IdeBundle.message("action.description.show.modules"), IconLoader
|
||||
.getIcon("/objectBrowser/showModules.png"));
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public boolean isSelected(AnActionEvent event) {
|
||||
return ProjectView.getInstance(myProject).isShowModules(getId());
|
||||
}
|
||||
|
||||
protected abstract String getId();
|
||||
|
||||
public void setSelected(AnActionEvent event, boolean flag) {
|
||||
final ProjectViewImpl projectView = (ProjectViewImpl)ProjectView.getInstance(myProject);
|
||||
projectView.setShowModules(flag, getId());
|
||||
}
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
final ProjectViewImpl projectView = (ProjectViewImpl)ProjectView.getInstance(myProject);
|
||||
presentation.setVisible(Comparing.strEqual(projectView.getCurrentViewId(), getId()));
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
|
||||
}
|
||||
|
||||
public void selectScope(final NamedScope scope) {
|
||||
refreshScope(scope, true);
|
||||
refreshScope(scope);
|
||||
if (scope != DefaultScopesProvider.getAllScope()) {
|
||||
CURRENT_SCOPE_NAME = scope.getName();
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
|
||||
return PsiElement.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
private void refreshScope(@Nullable NamedScope scope, boolean showProgress) {
|
||||
private void refreshScope(@Nullable NamedScope scope) {
|
||||
FileTreeModelBuilder.clearCaches(myProject);
|
||||
if (scope == null || scope.getValue() == null) { //was deleted
|
||||
scope = DefaultScopesProvider.getAllScope();
|
||||
@@ -277,6 +277,8 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
|
||||
final ProjectView projectView = ProjectView.getInstance(myProject);
|
||||
settings.UI_FLATTEN_PACKAGES = projectView.isFlattenPackages(ScopeViewPane.ID);
|
||||
settings.UI_COMPACT_EMPTY_MIDDLE_PACKAGES = projectView.isHideEmptyMiddlePackages(ScopeViewPane.ID);
|
||||
settings.UI_SHOW_MODULES = projectView.isShowModules(ScopeViewPane.ID);
|
||||
settings.UI_SHOW_MODULE_GROUPS = projectView.isShowModules(ScopeViewPane.ID);
|
||||
myBuilder = new FileTreeModelBuilder(myProject, new Marker() {
|
||||
public boolean isMarked(VirtualFile file) {
|
||||
return packageSet != null && (packageSet instanceof PackageSetBase ? ((PackageSetBase)packageSet).contains(file, holder) : packageSet.contains(PackageSetBase.getPsiFile(file, holder), holder));
|
||||
@@ -287,7 +289,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
|
||||
myTree.getEmptyText().setText("Loading...");
|
||||
myActionCallback = new ActionCallback();
|
||||
myTree.putClientProperty(TreeState.CALLBACK, new WeakReference<ActionCallback>(myActionCallback));
|
||||
myTree.setModel(myBuilder.build(myProject, showProgress, new Runnable(){
|
||||
myTree.setModel(myBuilder.build(myProject, true, new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
myTree.setPaintBusy(false);
|
||||
@@ -596,7 +598,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
|
||||
myUpdateQueue.cancelAllUpdates();
|
||||
queueUpdate(new Runnable() {
|
||||
public void run() {
|
||||
refreshScope(scope, true);
|
||||
refreshScope(scope);
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
@@ -650,7 +652,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
|
||||
myUpdateQueue.cancelAllUpdates();
|
||||
myUpdateQueue.queue(new Update("RootsChanged") {
|
||||
public void run() {
|
||||
refreshScope(getCurrentScope(), false);
|
||||
refreshScope(getCurrentScope());
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
|
||||
@@ -20,10 +20,8 @@ import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.SelectInTarget;
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.ide.projectView.impl.AbstractProjectViewPane;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.ide.projectView.impl.ShowModulesAction;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -73,8 +71,10 @@ public class ScopeViewPane extends AbstractProjectViewPane {
|
||||
refreshProjectViewAlarm.addRequest(new Runnable(){
|
||||
public void run() {
|
||||
if (myProject.isDisposed()) return;
|
||||
String subId = getSubId();
|
||||
myProjectView.removeProjectPane(ScopeViewPane.this);
|
||||
myProjectView.addProjectPane(ScopeViewPane.this);
|
||||
myProjectView.changeView(getId(), subId);
|
||||
}
|
||||
},10);
|
||||
}
|
||||
@@ -135,6 +135,12 @@ public class ScopeViewPane extends AbstractProjectViewPane {
|
||||
|
||||
public void addToolbarActions(DefaultActionGroup actionGroup) {
|
||||
actionGroup.add(ActionManager.getInstance().getAction("ScopeView.EditScopes"));
|
||||
actionGroup.addAction(new ShowModulesAction(myProject){
|
||||
@Override
|
||||
protected String getId() {
|
||||
return ScopeViewPane.this.getId();
|
||||
}
|
||||
}).setAsSecondary(true);
|
||||
}
|
||||
|
||||
public ActionCallback updateFromRoot(boolean restoreExpandedPaths) {
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.awt.*;
|
||||
*/
|
||||
public class BasePsiNode<T extends PsiElement> extends PackageDependenciesNode {
|
||||
private final SmartPsiElementPointer myPsiElementPointer;
|
||||
private Icon myIcon;
|
||||
|
||||
public BasePsiNode(final T element) {
|
||||
super(element.getProject());
|
||||
@@ -63,7 +64,10 @@ public class BasePsiNode<T extends PsiElement> extends PackageDependenciesNode {
|
||||
|
||||
private Icon getIcon() {
|
||||
final PsiElement element = getPsiElement();
|
||||
return element != null && element.isValid() ? element.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS) : null;
|
||||
if (myIcon == null) {
|
||||
myIcon = element != null && element.isValid() ? element.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS) : null;
|
||||
}
|
||||
return myIcon;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.intellij.ide.structureView.StructureViewBuilder;
|
||||
import com.intellij.ide.structureView.StructureViewModel;
|
||||
import com.intellij.ide.structureView.StructureViewTreeElement;
|
||||
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
|
||||
import com.intellij.ide.structureView.impl.common.PsiTreeElementBase;
|
||||
import com.intellij.ide.structureView.newStructureView.TreeActionsOwner;
|
||||
import com.intellij.ide.structureView.newStructureView.TreeModelWrapper;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
@@ -271,8 +270,11 @@ public class FileStructureDialog extends DialogWrapper {
|
||||
if (builder != null) {
|
||||
final AbstractTreeNode parentNode = builder.getParentNode();
|
||||
final Object value = parentNode.getValue();
|
||||
if (value instanceof PsiTreeElementBase) {
|
||||
currentParent = ((PsiTreeElementBase) value).getValue();
|
||||
if (value instanceof StructureViewTreeElement) {
|
||||
final Object elementValue = ((StructureViewTreeElement)value).getValue();
|
||||
if (elementValue instanceof PsiElement) {
|
||||
currentParent = (PsiElement) elementValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
myTreeActionsOwner.setFilterIncluded(fileStructureFilter, !chkFilter.isSelected());
|
||||
|
||||
@@ -308,7 +308,7 @@ public abstract class ChooseByNameBase {
|
||||
|
||||
public void repositionHint() {
|
||||
if (myHint == null || !myHint.isVisible()) return;
|
||||
PopupPositionManager.positionPopupInBestPosition(myHint, null, true);
|
||||
PopupPositionManager.positionPopupInBestPosition(myHint, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.PackageSet;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
@@ -76,11 +77,11 @@ public class EditScopesDialog extends SingleConfigurableEditor {
|
||||
}
|
||||
|
||||
|
||||
public static EditScopesDialog editConfigurable(final Project project, final Runnable advancedInitialization){
|
||||
public static EditScopesDialog editConfigurable(final Project project, @Nullable final Runnable advancedInitialization){
|
||||
return editConfigurable(project, advancedInitialization, false);
|
||||
}
|
||||
|
||||
public static EditScopesDialog editConfigurable(final Project project, final Runnable advancedInitialization, final boolean checkShared){
|
||||
public static EditScopesDialog editConfigurable(final Project project, @Nullable final Runnable advancedInitialization, final boolean checkShared){
|
||||
final EditScopesDialog dialog = new EditScopesDialog(project, checkShared);
|
||||
if (advancedInitialization != null) {
|
||||
advancedInitialization.run();
|
||||
|
||||
@@ -155,12 +155,14 @@
|
||||
</grid>
|
||||
</children>
|
||||
</splitpane>
|
||||
<grid id="a4d7" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="a4d7" layout-manager="GridLayoutManager" row-count="1" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="8" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<doubleBuffered value="true"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="85961" class="javax.swing.JCheckBox" binding="myShowWhiteSpacesBox">
|
||||
@@ -246,6 +248,17 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="aa136" class="javax.swing.JCheckBox" binding="myShowBlocksCheckBox">
|
||||
<constraints>
|
||||
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<label value="Show formatting blocks"/>
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<selected value="true"/>
|
||||
<text value="Show &formatting blocks"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="bd033" class="com.intellij.ui.TitledSeparatorWithMnemonic" binding="myTextSeparator">
|
||||
|
||||
@@ -119,7 +119,8 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
|
||||
private Tree myBlockTree;
|
||||
private JPanel myBlockStructurePanel;
|
||||
private JSplitPane myBlockRefSplitPane;
|
||||
private TitledSeparatorWithMnemonic myTextSeparator;
|
||||
private JCheckBox myShowBlocksCheckBox;
|
||||
private TitledSeparatorWithMnemonic myTextSeparator;
|
||||
private TitledSeparatorWithMnemonic myPsiTreeSeparator;
|
||||
private TitledSeparatorWithMnemonic myRefsSeparator;
|
||||
private TitledSeparatorWithMnemonic myBlockTreeSeparator;
|
||||
@@ -233,6 +234,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
|
||||
final Document document = EditorFactory.getInstance().createDocument("");
|
||||
editor = (EditorEx)EditorFactory.getInstance().createEditor(document, myProject);
|
||||
}
|
||||
editor.getSettings().setLineMarkerAreaShown(false);
|
||||
myEditor = editor;
|
||||
init();
|
||||
if (myCurrentFile != null) {
|
||||
@@ -423,7 +425,20 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
|
||||
psiTreeStructure.setShowWhiteSpaces(settings.showWhiteSpaces);
|
||||
myShowTreeNodesCheckBox.setSelected(settings.showTreeNodes);
|
||||
psiTreeStructure.setShowTreeNodes(settings.showTreeNodes);
|
||||
|
||||
myShowBlocksCheckBox.setSelected(settings.showBlocks);
|
||||
myBlockStructurePanel.setVisible(settings.showBlocks);
|
||||
myShowBlocksCheckBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!myShowBlocksCheckBox.isSelected()) {
|
||||
settings.blockRefDividerLocation = myBlockRefSplitPane.getDividerLocation();
|
||||
}
|
||||
else {
|
||||
myBlockRefSplitPane.setDividerLocation(settings.blockRefDividerLocation);
|
||||
}
|
||||
myBlockStructurePanel.setVisible(myShowBlocksCheckBox.isSelected());
|
||||
myBlockStructurePanel.repaint();
|
||||
}
|
||||
});
|
||||
myTextPanel.setLayout(new BorderLayout());
|
||||
myTextPanel.add(myEditor.getComponent(), BorderLayout.CENTER);
|
||||
|
||||
@@ -747,7 +762,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Block buildBlocks(@NotNull PsiElement rootElement) {
|
||||
private Block buildBlocks(@NotNull PsiElement rootElement) {
|
||||
FormattingModelBuilder formattingModelBuilder = LanguageFormatting.INSTANCE.forContext(rootElement);
|
||||
CodeStyleSettings settings = new CodeStyleSettings();
|
||||
if (formattingModelBuilder != null) {
|
||||
@@ -991,7 +1006,10 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
|
||||
settings.dialect = myDialectComboBox.isVisible() && selectedDialect != null ? selectedDialect.toString() : "";
|
||||
settings.textDividerLocation = myTextSplit.getDividerLocation();
|
||||
settings.treeDividerLocation = myTreeSplit.getDividerLocation();
|
||||
settings.blockRefDividerLocation = myBlockRefSplitPane.getDividerLocation();
|
||||
settings.showBlocks = myShowBlocksCheckBox.isSelected();
|
||||
if( myShowBlocksCheckBox.isSelected()) {
|
||||
settings.blockRefDividerLocation = myBlockRefSplitPane.getDividerLocation();
|
||||
}
|
||||
super.doCancelAction();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public class PsiViewerSettings implements PersistentStateComponent<PsiViewerSett
|
||||
public int textDividerLocation = 250;
|
||||
public int treeDividerLocation = 400;
|
||||
public int blockRefDividerLocation = 600;
|
||||
public boolean showBlocks = true;
|
||||
|
||||
public static PsiViewerSettings getSettings() {
|
||||
return ServiceManager.getService(PsiViewerSettings.class);
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class LanguagePerFileMappings<T> implements PersistentStateCompo
|
||||
}
|
||||
}
|
||||
final List<VirtualFile> files = ContainerUtil.createMaybeSingletonList(file);
|
||||
handleMappingChange(files, files, true);
|
||||
handleMappingChange(files, files, false);
|
||||
}
|
||||
|
||||
private void handleMappingChange(final Collection<VirtualFile> files, Collection<VirtualFile> oldFiles, final boolean includeOpenFiles) {
|
||||
|
||||
@@ -34,8 +34,7 @@
|
||||
<component id="6e07b" class="javax.swing.JTextField" binding="myIgnoreFilesField">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="20"/>
|
||||
<preferred-size width="-1" height="20"/>
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
|
||||
@@ -75,6 +75,10 @@ public class DirectoryNode extends PackageDependenciesNode {
|
||||
myFQName = VfsUtil.getRelativePath(myVDirectory, contentRoot, '/');
|
||||
}
|
||||
}
|
||||
|
||||
if (contentRoots.length > 1 && ProjectRootsUtil.isModuleContentRoot(myVDirectory, project)) {
|
||||
myFQName = getContentRootName(baseDir, myFQName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myFQName = FilePatternPackageSet.getLibRelativePath(myVDirectory, index);
|
||||
@@ -82,23 +86,28 @@ public class DirectoryNode extends PackageDependenciesNode {
|
||||
dirName = myFQName;
|
||||
} else {
|
||||
if (contentRoots.length > 1 && ProjectRootsUtil.isModuleContentRoot(myVDirectory, project)) {
|
||||
if (baseDir != null) {
|
||||
if (myVDirectory != baseDir) {
|
||||
if (VfsUtil.isAncestor(baseDir, myVDirectory, false)) {
|
||||
dirName = VfsUtil.getRelativePath(myVDirectory, baseDir, '/');
|
||||
} else {
|
||||
dirName = myVDirectory.getPresentableUrl();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dirName = myVDirectory.getPresentableUrl();
|
||||
}
|
||||
dirName = getContentRootName(baseDir, dirName);
|
||||
}
|
||||
}
|
||||
myDirName = dirName;
|
||||
myCompactPackages = compactPackages;
|
||||
}
|
||||
|
||||
private String getContentRootName(final VirtualFile baseDir, final String dirName) {
|
||||
if (baseDir != null) {
|
||||
if (myVDirectory != baseDir) {
|
||||
if (VfsUtil.isAncestor(baseDir, myVDirectory, false)) {
|
||||
return VfsUtil.getRelativePath(myVDirectory, baseDir, '/');
|
||||
} else {
|
||||
return myVDirectory.getPresentableUrl();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return myVDirectory.getPresentableUrl();
|
||||
}
|
||||
return dirName;
|
||||
}
|
||||
|
||||
public void fillFiles(Set<PsiFile> set, boolean recursively) {
|
||||
super.fillFiles(set, recursively);
|
||||
int count = getChildCount();
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.intellij.psi.impl.file;
|
||||
|
||||
import com.intellij.ide.impl.ProjectViewSelectInTarget;
|
||||
import com.intellij.ide.projectView.impl.ProjectViewPane;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -208,13 +210,13 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
|
||||
if (vFile.isDirectory()) {
|
||||
PsiDirectory dir = myManager.findDirectory(vFile);
|
||||
if (dir != null) {
|
||||
if(!processor.execute(dir)) return false;
|
||||
if (!processor.execute(dir)) return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PsiFile file = myManager.findFile(vFile);
|
||||
if (file != null) {
|
||||
if(!processor.execute(file)) return false;
|
||||
if (!processor.execute(file)) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,7 +314,7 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
|
||||
try {
|
||||
VirtualFile file = getVirtualFile().createChildDirectory(myManager, name);
|
||||
PsiDirectory directory = myManager.findDirectory(file);
|
||||
if (directory == null) throw new IncorrectOperationException("Cannot find directory in '"+file.getPresentableUrl()+"'");
|
||||
if (directory == null) throw new IncorrectOperationException("Cannot find directory in '" + file.getPresentableUrl() + "'");
|
||||
return directory;
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -365,15 +367,14 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
|
||||
}
|
||||
final PsiFile copyPsi = myManager.findFile(copyVFile);
|
||||
if (copyPsi == null) {
|
||||
LOG.error("Could not find file '"+copyVFile+"' after copying '"+vFile+"'");
|
||||
LOG.error("Could not find file '" + copyVFile + "' after copying '" + vFile + "'");
|
||||
}
|
||||
updateAddedFile(copyPsi);
|
||||
return copyPsi;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IncorrectOperationException(e.toString(),e);
|
||||
throw new IncorrectOperationException(e.toString(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void updateAddedFile(PsiFile copyPsi) throws IncorrectOperationException {
|
||||
@@ -420,7 +421,8 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
|
||||
if (document != null) {
|
||||
document.setText(text);
|
||||
fileDocumentManager.saveDocument(document);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
String lineSeparator = fileDocumentManager.getLineSeparator(newVFile, getProject());
|
||||
if (!lineSeparator.equals("\n")) {
|
||||
text = StringUtil.convertLineSeparators(text, lineSeparator);
|
||||
@@ -453,7 +455,7 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
|
||||
return newFile;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IncorrectOperationException(e.toString(),e);
|
||||
throw new IncorrectOperationException(e.toString(), e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -468,7 +470,7 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
|
||||
String name = ((PsiDirectory)element).getName();
|
||||
PsiDirectory[] subpackages = getSubdirectories();
|
||||
for (PsiDirectory dir : subpackages) {
|
||||
if (Comparing.strEqual(dir.getName(),name)) {
|
||||
if (Comparing.strEqual(dir.getName(), name)) {
|
||||
throw new IncorrectOperationException(VfsBundle.message("dir.already.exists.error", dir.getVirtualFile().getPresentableUrl()));
|
||||
}
|
||||
}
|
||||
@@ -477,7 +479,7 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
|
||||
String name = ((PsiFile)element).getName();
|
||||
PsiFile[] files = getFiles();
|
||||
for (PsiFile file : files) {
|
||||
if (Comparing.strEqual(file.getName(),name, SystemInfo.isFileSystemCaseSensitive)) {
|
||||
if (Comparing.strEqual(file.getName(), name, SystemInfo.isFileSystemCaseSensitive)) {
|
||||
throw new IncorrectOperationException(VfsBundle.message("file.already.exists.error", file.getVirtualFile().getPresentableUrl()));
|
||||
}
|
||||
}
|
||||
@@ -510,7 +512,7 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
|
||||
myFile.delete(myManager);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IncorrectOperationException(e.toString(),e);
|
||||
throw new IncorrectOperationException(e.toString(), e);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -552,6 +554,7 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu
|
||||
}
|
||||
|
||||
public void navigate(boolean requestFocus) {
|
||||
ProjectViewSelectInTarget.select(getProject(), this, ProjectViewPane.ID, null, getVirtualFile(), requestFocus);
|
||||
}
|
||||
|
||||
public FileStatus getFileStatus() {
|
||||
|
||||
+17
-17
@@ -308,7 +308,6 @@ public class InjectedLanguageUtil {
|
||||
}
|
||||
|
||||
private static final Key<List<DocumentWindow>> INJECTED_DOCS_KEY = Key.create("INJECTED_DOCS_KEY");
|
||||
private static final Key<List<RangeMarker>> INJECTED_REGIONS_KEY = Key.create("INJECTED_REGIONS_KEY");
|
||||
@NotNull
|
||||
public static List<DocumentWindow> getCachedInjectedDocuments(@NotNull PsiFile hostPsiFile) {
|
||||
// modification of cachedInjectedDocuments must be under PsiLock only
|
||||
@@ -323,26 +322,36 @@ public class InjectedLanguageUtil {
|
||||
}
|
||||
|
||||
public static void commitAllInjectedDocuments(Document hostDocument, Project project) {
|
||||
List<RangeMarker> injected = getCachedInjectedRegions(hostDocument);
|
||||
if (injected.isEmpty()) return;
|
||||
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
|
||||
PsiFile hostPsiFile = documentManager.getPsiFile(hostDocument);
|
||||
if (hostPsiFile == null) return;
|
||||
for (RangeMarker rangeMarker : injected) {
|
||||
|
||||
List<DocumentWindow> injected = getCachedInjectedDocuments(hostPsiFile);
|
||||
if (injected.isEmpty()) return;
|
||||
|
||||
for (int i = injected.size() - 1; i >= 0; i--) {
|
||||
DocumentWindow documentWindow = injected.get(i);
|
||||
ProgressManager.checkCanceled();
|
||||
RangeMarker rangeMarker = documentWindow.getHostRanges()[0];
|
||||
PsiElement element = rangeMarker.isValid() ? hostPsiFile.findElementAt(rangeMarker.getStartOffset()) : null;
|
||||
if (element == null) {
|
||||
injected.remove(rangeMarker);
|
||||
injected.remove(i);
|
||||
continue;
|
||||
}
|
||||
ProgressManager.checkCanceled();
|
||||
final DocumentWindow[] stillInjectedDocument = {null};
|
||||
// it is here where the reparse happens and old file contents replaced
|
||||
enumerate(element, hostPsiFile, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
|
||||
public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {
|
||||
PsiDocumentManagerImpl.checkConsistency(injectedPsi, injectedPsi.getViewProvider().getDocument());
|
||||
stillInjectedDocument[0] = (DocumentWindow)injectedPsi.getViewProvider().getDocument();
|
||||
PsiDocumentManagerImpl.checkConsistency(injectedPsi, stillInjectedDocument[0]);
|
||||
}
|
||||
}, true);
|
||||
if (stillInjectedDocument[0] == null) {
|
||||
injected.remove(i);
|
||||
}
|
||||
else if (stillInjectedDocument[0] != documentWindow) {
|
||||
injected.set(i,stillInjectedDocument[0]);
|
||||
}
|
||||
}
|
||||
EditorWindow.disposeInvalidEditors(); // in write action
|
||||
|
||||
@@ -380,15 +389,6 @@ public class InjectedLanguageUtil {
|
||||
}
|
||||
|
||||
|
||||
static List<RangeMarker> getCachedInjectedRegions(Document hostDocument) {
|
||||
List<RangeMarker> injectedRegions = hostDocument.getUserData(INJECTED_REGIONS_KEY);
|
||||
if (injectedRegions == null) {
|
||||
injectedRegions = ((UserDataHolderEx)hostDocument).putUserDataIfAbsent(INJECTED_REGIONS_KEY,
|
||||
ContainerUtil.<RangeMarker>createEmptyCOWList());
|
||||
}
|
||||
return injectedRegions;
|
||||
}
|
||||
|
||||
public static Editor openEditorFor(PsiFile file, Project project) {
|
||||
Document document = PsiDocumentManager.getInstance(project).getDocument(file);
|
||||
// may return editor injected in current selection in the host editor, not for the file passed as argument
|
||||
|
||||
-23
@@ -435,32 +435,9 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar {
|
||||
}
|
||||
injected.add(documentWindow);
|
||||
|
||||
cacheInjectedRegion(documentWindow, hostDocument);
|
||||
return injectedPsi;
|
||||
}
|
||||
|
||||
private static void cacheInjectedRegion(DocumentWindowImpl documentWindow, DocumentEx hostDocument) {
|
||||
List<RangeMarker> injectedRegions = InjectedLanguageUtil.getCachedInjectedRegions(hostDocument);
|
||||
RangeMarker newMarker = documentWindow.getHostRanges()[0];
|
||||
TextRange newRange = ProperTextRange.create(newMarker);
|
||||
for (int i = 0; i < injectedRegions.size(); i++) {
|
||||
RangeMarker stored = injectedRegions.get(i);
|
||||
if (!stored.isValid()) continue;
|
||||
TextRange storedRange = ProperTextRange.create(stored);
|
||||
if (storedRange.intersects(newRange)) {
|
||||
injectedRegions.set(i, newMarker);
|
||||
break;
|
||||
}
|
||||
if (storedRange.getStartOffset() > newRange.getEndOffset()) {
|
||||
injectedRegions.add(i, newMarker);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (injectedRegions.isEmpty() || newRange.getStartOffset() > injectedRegions.get(injectedRegions.size()-1).getEndOffset()) {
|
||||
injectedRegions.add(newMarker);
|
||||
}
|
||||
}
|
||||
|
||||
// returns lexer element types with corresponding ranges in encoded (injection host based) PSI
|
||||
private static List<Trinity<IElementType, PsiLanguageInjectionHost, TextRange>>
|
||||
obtainHighlightTokensFromLexer(Language language,
|
||||
|
||||
@@ -28,7 +28,9 @@ public class PopupPositionManager {
|
||||
private PopupPositionManager() {
|
||||
}
|
||||
|
||||
public static void positionPopupInBestPosition(final JBPopup hint, @Nullable final Editor editor, final boolean invokedFromEditor) {
|
||||
public static void positionPopupInBestPosition(final JBPopup hint,
|
||||
@Nullable final Editor editor,
|
||||
@Nullable DataContext dataContext) {
|
||||
final LookupEx lookup = LookupManager.getActiveLookup(editor);
|
||||
if (lookup != null && lookup.getCurrentItem() != null) {
|
||||
new PositionAdjuster(lookup.getComponent()).adjust(hint);
|
||||
@@ -43,38 +45,45 @@ public class PopupPositionManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (invokedFromEditor && editor != null && editor.getComponent().isShowing()) {
|
||||
final PositionAdjuster positionAdjuster = createPositionAdjuster();
|
||||
if (positionAdjuster != null) {
|
||||
positionAdjuster.adjust(hint);
|
||||
return;
|
||||
}
|
||||
|
||||
if (editor != null && editor.getComponent().isShowing()) {
|
||||
hint.showInBestPositionFor(editor);
|
||||
return;
|
||||
}
|
||||
|
||||
final PositionAdjuster positionAdjuster = createPositionAdjuster();
|
||||
if (positionAdjuster != null) positionAdjuster.adjust(hint);
|
||||
if (dataContext != null) {
|
||||
hint.showInBestPositionFor(dataContext);
|
||||
}
|
||||
}
|
||||
|
||||
private static Component discoverPopup(final DataKey<JBPopup> datakey, Component focusOwner) {
|
||||
if (focusOwner == null) {
|
||||
focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
}
|
||||
|
||||
|
||||
if (focusOwner == null) return null;
|
||||
|
||||
|
||||
final DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
|
||||
if (dataContext == null) return null;
|
||||
|
||||
|
||||
final JBPopup popup = datakey.getData(dataContext);
|
||||
if (popup != null && popup.isVisible()) {
|
||||
return popup.getContent();
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private static PositionAdjuster createPositionAdjuster() {
|
||||
final Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
if (focusOwner == null) return null;
|
||||
|
||||
|
||||
if (focusOwner instanceof JBList) {
|
||||
return new PositionAdjuster(SwingUtilities.getWindowAncestor(focusOwner));
|
||||
}
|
||||
@@ -84,10 +93,11 @@ public class PopupPositionManager {
|
||||
return new PositionAdjuster2(existing, discoverPopup(LangDataKeys.CHOOSE_BY_NAME_POPUP, focusOwner));
|
||||
}
|
||||
|
||||
final Window window = SwingUtilities.getWindowAncestor(focusOwner);
|
||||
return window == null ? null : new PositionAdjuster(window);
|
||||
//final Window window = SwingUtilities.getWindowAncestor(focusOwner);
|
||||
//return window == null ? null : new PositionAdjuster(window);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static class PositionAdjuster2 extends PositionAdjuster {
|
||||
|
||||
private Component myTopComponent;
|
||||
@@ -102,10 +112,10 @@ public class PopupPositionManager {
|
||||
return myTopComponent.getLocationOnScreen().y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class PositionAdjuster {
|
||||
private static final int GAP = 5;
|
||||
|
||||
private static final int GAP = 5;
|
||||
|
||||
private Component myRelativeTo;
|
||||
private Point myRelativeOnScreen;
|
||||
private Rectangle myScreenRect;
|
||||
@@ -115,35 +125,35 @@ public class PopupPositionManager {
|
||||
myRelativeOnScreen = relativeTo.getLocationOnScreen();
|
||||
myScreenRect = ScreenUtil.getScreenRectangle(myRelativeOnScreen);
|
||||
}
|
||||
|
||||
|
||||
protected Rectangle positionRight(final Dimension d) {
|
||||
return new Rectangle(myRelativeOnScreen.x + myRelativeTo.getWidth() + GAP, myRelativeOnScreen.y, d.width,
|
||||
return new Rectangle(myRelativeOnScreen.x + myRelativeTo.getWidth() + GAP, myRelativeOnScreen.y, d.width,
|
||||
d.height);
|
||||
}
|
||||
|
||||
|
||||
protected Rectangle positionLeft(final Dimension d) {
|
||||
return new Rectangle(myRelativeOnScreen.x - GAP - d.width, myRelativeOnScreen.y, d.width, d.height);
|
||||
}
|
||||
|
||||
|
||||
protected Rectangle positionAbove(final Dimension d) {
|
||||
return new Rectangle(myRelativeOnScreen.x, getYForTopPositioning() - GAP - d.height, d.width, d.height);
|
||||
}
|
||||
|
||||
|
||||
protected Rectangle positionUnder(final Dimension d) {
|
||||
return new Rectangle(myRelativeOnScreen.x, myRelativeOnScreen.y + GAP + myRelativeTo.getHeight(), d.width, d.height);
|
||||
}
|
||||
|
||||
|
||||
protected int getYForTopPositioning() {
|
||||
return myRelativeOnScreen.y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try to position:
|
||||
* 1. to the right
|
||||
* 2. to the left
|
||||
* 3. above
|
||||
* 4. under
|
||||
*
|
||||
*
|
||||
* @param popup
|
||||
*/
|
||||
public void adjust(final JBPopup popup) {
|
||||
@@ -153,51 +163,53 @@ public class PopupPositionManager {
|
||||
Rectangle r = positionRight(d);
|
||||
if (myScreenRect.contains(r)) {
|
||||
popupRect = r;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (popupRect == null) {
|
||||
r = positionLeft(d);
|
||||
if (myScreenRect.contains(r)) {
|
||||
popupRect = r;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (popupRect == null) {
|
||||
r = positionAbove(d);
|
||||
if (myScreenRect.contains(r)) {
|
||||
popupRect = r;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (popupRect == null) {
|
||||
r = positionUnder(d);
|
||||
if (myScreenRect.contains(r)) {
|
||||
popupRect = r;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (popupRect != null) {
|
||||
if (popup.isVisible()) {
|
||||
popup.setLocation(new Point(r.x, r.y));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
final Point p = new Point(r.x - myRelativeOnScreen.x, r.y - myRelativeOnScreen.y);
|
||||
popup.show(new RelativePoint(myRelativeTo, p));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// ok, popup does not fit, will try to resize it
|
||||
final List<Rectangle> boxes = new ArrayList<Rectangle>();
|
||||
// right
|
||||
boxes.add(crop(myScreenRect, new Rectangle(myRelativeOnScreen.x + myRelativeTo.getWidth() + GAP, myRelativeOnScreen.y,
|
||||
myScreenRect.width, myScreenRect.height)));
|
||||
|
||||
|
||||
// left
|
||||
boxes.add(crop(myScreenRect, new Rectangle(myScreenRect.x, myRelativeOnScreen.y, myRelativeOnScreen.x - myScreenRect.x - GAP,
|
||||
myScreenRect.height)));
|
||||
|
||||
|
||||
// top
|
||||
boxes.add(crop(myScreenRect, new Rectangle(myRelativeOnScreen.x, myScreenRect.y,
|
||||
myScreenRect.width, getYForTopPositioning() - myScreenRect.y - GAP)));
|
||||
|
||||
|
||||
// bottom
|
||||
boxes.add(crop(myScreenRect, new Rectangle(myRelativeOnScreen.x, myRelativeOnScreen.y + myRelativeTo.getHeight() + GAP,
|
||||
myScreenRect.width, myScreenRect.height)));
|
||||
@@ -211,44 +223,47 @@ public class PopupPositionManager {
|
||||
});
|
||||
|
||||
final Rectangle suitableBox = boxes.get(boxes.size() - 1);
|
||||
final Rectangle crop = crop(suitableBox,
|
||||
new Rectangle(suitableBox.x < myRelativeOnScreen.x ? suitableBox.x + suitableBox.width - d.width :
|
||||
suitableBox.x, suitableBox.y < myRelativeOnScreen.y ? suitableBox.y + suitableBox.height - d.height : suitableBox.y,
|
||||
final Rectangle crop = crop(suitableBox,
|
||||
new Rectangle(suitableBox.x < myRelativeOnScreen.x ? suitableBox.x + suitableBox.width - d.width :
|
||||
suitableBox.x, suitableBox.y < myRelativeOnScreen.y
|
||||
? suitableBox.y + suitableBox.height - d.height
|
||||
: suitableBox.y,
|
||||
d.width, d.height));
|
||||
|
||||
popup.setSize(crop.getSize());
|
||||
if (popup.isVisible()) {
|
||||
popup.setLocation(crop.getLocation());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
popup.show(new RelativePoint(myRelativeTo, new Point(crop.getLocation().x - myRelativeOnScreen.x,
|
||||
crop.getLocation().y - myRelativeOnScreen.y)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Rectangle crop(final Rectangle source, final Rectangle toCrop) {
|
||||
final Rectangle result = new Rectangle(toCrop);
|
||||
if (toCrop.x < source.x) {
|
||||
result.width -= source.x - toCrop.x;
|
||||
result.x = source.x;
|
||||
}
|
||||
|
||||
|
||||
if (toCrop.y < source.y) {
|
||||
result.height -= source.y - toCrop.y;
|
||||
result.y = source.y;
|
||||
}
|
||||
|
||||
|
||||
if (result.x + result.width > source.x + source.width) {
|
||||
result.width = source.x + source.width - result.x;
|
||||
result.width = source.x + source.width - result.x;
|
||||
}
|
||||
|
||||
|
||||
if (result.y + result.height > source.y + source.height) {
|
||||
result.height = source.y + source.height - result.y;
|
||||
result.height = source.y + source.height - result.y;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected static Dimension getPopupSize(final JBPopup popup) {
|
||||
Dimension size = null;
|
||||
if (popup instanceof AbstractPopup) {
|
||||
@@ -261,8 +276,8 @@ public class PopupPositionManager {
|
||||
if (size == null) {
|
||||
size = popup.getContent().getPreferredSize();
|
||||
}
|
||||
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
|
||||
@@ -130,7 +131,7 @@ public class ChangeListStorageImpl implements ChangeListStorage {
|
||||
"Local History is broken",
|
||||
message + "<br>" +
|
||||
"<br>" +
|
||||
"Please attach log files from <a href=\"file\">" +logFile + "</a><br>" +
|
||||
"Please attach log files from <a href=\"file\">" + logFile + "</a><br>" +
|
||||
"to the <a href=\"url\">YouTrack issue</a>",
|
||||
NotificationType.ERROR,
|
||||
new NotificationListener() {
|
||||
@@ -171,13 +172,15 @@ public class ChangeListStorageImpl implements ChangeListStorage {
|
||||
String message = null;
|
||||
if (prevId != 0) {
|
||||
try {
|
||||
Pair<Long, Integer> prevOS = myStorage.getOffsetAndSize(prevId);
|
||||
long prevRecordTimestamp = myStorage.getTimestamp(prevId);
|
||||
int lastRecord = myStorage.getLastRecord();
|
||||
Pair<Long, Integer> lastOS = myStorage.getOffsetAndSize(lastRecord);
|
||||
long lastRecordTimestamp = myStorage.getTimestamp(lastRecord);
|
||||
|
||||
message = "invalid record is: " + prevId
|
||||
message = "invalid record is: " + prevId + " offset: " + prevOS.first + " size: " + prevOS.second
|
||||
+ " (created " + DateFormat.getDateTimeInstance().format(prevRecordTimestamp) + ") "
|
||||
+ "last record is: " + lastRecord
|
||||
+ "last record is: " + lastRecord + " offset: " + lastOS.first + " size: " + lastOS.second
|
||||
+ " (created " + DateFormat.getDateTimeInstance().format(lastRecordTimestamp) + ")";
|
||||
}
|
||||
catch (Exception e1) {
|
||||
@@ -216,9 +219,11 @@ public class ChangeListStorageImpl implements ChangeListStorage {
|
||||
myStorage.setLastId(myLastId);
|
||||
myStorage.force();
|
||||
|
||||
LocalHistoryLog.LOG.info("Block was written: " + id);
|
||||
// todo remove this when bug is found
|
||||
Pair<Long, Integer> os = myStorage.getOffsetAndSize(id);
|
||||
LocalHistoryLog.LOG.info("Block was written: " + id + " offset: " + os.first + " size: " + os.second);
|
||||
|
||||
// todo remove this check when buf is found
|
||||
// todo remove this when bug is found
|
||||
if (ApplicationManagerEx.getApplicationEx().isInternal()) {
|
||||
try {
|
||||
doReadBlock(id);
|
||||
@@ -246,6 +251,9 @@ public class ChangeListStorageImpl implements ChangeListStorage {
|
||||
|
||||
while (eachBlockId != 0) {
|
||||
processor.consume(doReadBlock(eachBlockId).changeSet);
|
||||
// todo remove this when bug is found
|
||||
Pair<Long, Integer> os = myStorage.getOffsetAndSize(eachBlockId);
|
||||
LocalHistoryLog.LOG.info("Block was deleted: " + eachBlockId + " offset: " + os.first + " size: " + os.second);
|
||||
eachBlockId = doReadPrevSafely(eachBlockId, recursionGuard);
|
||||
}
|
||||
myStorage.deleteRecordsUpTo(firstObsoleteId);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.history.core;
|
||||
|
||||
import com.intellij.openapi.util.Clock;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.io.PagePool;
|
||||
import com.intellij.util.io.storage.AbstractRecordsTable;
|
||||
import com.intellij.util.io.storage.AbstractStorage;
|
||||
@@ -91,6 +92,13 @@ public class LocalHistoryStorage extends AbstractStorage {
|
||||
}
|
||||
}
|
||||
|
||||
public Pair<Long, Integer> getOffsetAndSize(int id) {
|
||||
synchronized (myLock) {
|
||||
return Pair.create(myRecordsTable.getAddress(id), myRecordsTable.getSize(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int createNextRecord() throws IOException {
|
||||
synchronized (myLock) {
|
||||
LocalHistoryRecordsTable table = (LocalHistoryRecordsTable)myRecordsTable;
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.options;
|
||||
|
||||
public class CancelledConfigurationException extends ConfigurationException {
|
||||
|
||||
public CancelledConfigurationException() {
|
||||
super(null);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.wm.IdeGlassPaneUtil;
|
||||
import com.intellij.openapi.wm.impl.content.GraphicsConfig;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.UIBundle;
|
||||
import com.intellij.ui.mac.DoNotAskDialogOption;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ui.AwtVisitor;
|
||||
@@ -1147,7 +1148,7 @@ public abstract class DialogWrapper {
|
||||
}
|
||||
|
||||
public boolean isOK() {
|
||||
return myExitCode == OK_EXIT_CODE;
|
||||
return getExitCode() == OK_EXIT_CODE;
|
||||
}
|
||||
|
||||
public boolean isOKActionEnabled() {
|
||||
@@ -1556,7 +1557,7 @@ public abstract class DialogWrapper {
|
||||
return myDisposable;
|
||||
}
|
||||
|
||||
public interface DoNotAskOption {
|
||||
public interface DoNotAskOption extends DoNotAskDialogOption {
|
||||
|
||||
boolean isToBeShown();
|
||||
|
||||
|
||||
@@ -20,13 +20,16 @@ import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.ui.BrowserHyperlinkListener;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.InsertPathAction;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.ui.mac.MacMessages;
|
||||
import com.intellij.util.PairFunction;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -173,10 +176,20 @@ public class Messages {
|
||||
* @see com.intellij.openapi.ui.DialogWrapper#DialogWrapper(Project,boolean)
|
||||
*/
|
||||
public static void showMessageDialog(Project project, String message, String title, @Nullable Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showOkMessageDialog(title, message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project));
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(project, message, title, new String[]{OK_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
public static void showMessageDialog(Component parent, String message, String title, @Nullable Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showOkMessageDialog(title, message, OK_BUTTON, SwingUtilities.getWindowAncestor(parent));
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(parent, message, title, new String[]{OK_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
@@ -187,23 +200,63 @@ public class Messages {
|
||||
* @see #showMessageDialog(Component, String, String, Icon)
|
||||
*/
|
||||
public static void showMessageDialog(String message, String title, @Nullable Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showOkMessageDialog(title, message, OK_BUTTON);
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(message, title, new String[]{OK_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>0</code> if user pressed "Yes" and returns <code>1</code> if user pressed "No" button.
|
||||
*/
|
||||
public static int showYesNoDialog(Project project, String message, String title, String yesText, String noText, @Nullable Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoDialog(title, message, yesText, noText, WindowManager.getInstance().suggestParentWindow(project));
|
||||
}
|
||||
|
||||
return showDialog(project, message, title, new String[]{yesText, noText}, 0, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>0</code> if user pressed "Yes" and returns <code>1</code> if user pressed "No" button.
|
||||
*/
|
||||
public static int showYesNoDialog(Project project, String message, String title, @Nullable Icon icon) {
|
||||
return showDialog(project, message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon);
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, WindowManager.getInstance().suggestParentWindow(project));
|
||||
}
|
||||
|
||||
return showYesNoDialog(project, message, title, YES_BUTTON, NO_BUTTON, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>0</code> if user pressed "Yes" and returns <code>1</code> if user pressed "No" button.
|
||||
*/
|
||||
public static int showYesNoDialog(Component parent, String message, String title, @Nullable Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, SwingUtilities.getWindowAncestor(parent));
|
||||
}
|
||||
|
||||
return showDialog(parent, message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use this method only if you do not know project or component
|
||||
*
|
||||
* @return <code>0</code> if user pressed "Yes" and returns <code>1</code> if user pressed "No" button.
|
||||
* @see #showYesNoDialog(Project, String, String, Icon)
|
||||
* @see #showYesNoDialog(Component, String, String, Icon)
|
||||
*/
|
||||
public static int showYesNoDialog(String message, String title, String yesText, String noText, @Nullable Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoDialog(title, message, yesText, noText, null);
|
||||
}
|
||||
|
||||
return showDialog(message, title, new String[]{yesText, noText}, 0, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method only if you do not know project or component
|
||||
*
|
||||
@@ -212,26 +265,27 @@ public class Messages {
|
||||
* @see #showYesNoDialog(Component, String, String, Icon)
|
||||
*/
|
||||
public static int showYesNoDialog(String message, String title, @Nullable Icon icon) {
|
||||
return showDialog(message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon);
|
||||
}
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, null);
|
||||
}
|
||||
|
||||
public static int showYesNoDialog(Component parent, String message, String title, int defaultOptionIndex, int focusedOptionIndex, Icon icon) {
|
||||
return showDialog(parent, message, title, new String[]{YES_BUTTON, NO_BUTTON}, defaultOptionIndex, focusedOptionIndex, icon);
|
||||
}
|
||||
|
||||
public static int showYesNoDialog(Project project, String message, String title, int defaultOptionIndex, int focusedOptionIndex, Icon icon) {
|
||||
return showDialog(project, message, title, new String[]{YES_BUTTON, NO_BUTTON}, defaultOptionIndex, focusedOptionIndex, icon);
|
||||
return showYesNoDialog(message, title, YES_BUTTON, NO_BUTTON, icon);
|
||||
}
|
||||
|
||||
public static int showOkCancelDialog(Project project, String message, String title, Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoDialog(title, message, OK_BUTTON, CANCEL_BUTTON, WindowManager.getInstance().suggestParentWindow(project));
|
||||
}
|
||||
|
||||
return showDialog(project, message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
public static int showOkCancelDialog(Component parent, String message, String title, int defaultOptionIndex, int focusedOptionIndex, Icon icon) {
|
||||
return showDialog(parent, message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, defaultOptionIndex, focusedOptionIndex, icon);
|
||||
}
|
||||
|
||||
public static int showOkCancelDialog(Component parent, String message, String title, Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoDialog(title, message, OK_BUTTON, CANCEL_BUTTON, SwingUtilities.getWindowAncestor(parent));
|
||||
}
|
||||
|
||||
|
||||
return showDialog(parent, message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
@@ -242,12 +296,17 @@ public class Messages {
|
||||
* @see #showOkCancelDialog(Component, String, String, Icon)
|
||||
*/
|
||||
public static int showOkCancelDialog(String message, String title, Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoDialog(title, message, OK_BUTTON, CANCEL_BUTTON, null);
|
||||
}
|
||||
|
||||
return showDialog(message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, 0, icon);
|
||||
}
|
||||
|
||||
public static int showCheckboxOkCancelDialog(String message, String title, String checkboxText, final boolean checked,
|
||||
final int defaultOptionIndex, final int focusedOptionIndex, Icon icon) {
|
||||
return showCheckboxMessageDialog(message, title, new String[] {OK_BUTTON, CANCEL_BUTTON}, checkboxText, checked, defaultOptionIndex, focusedOptionIndex, icon,
|
||||
return showCheckboxMessageDialog(message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, checkboxText, checked, defaultOptionIndex,
|
||||
focusedOptionIndex, icon,
|
||||
new PairFunction<Integer, JCheckBox, Integer>() {
|
||||
@Override
|
||||
public Integer fun(final Integer exitCode, final JCheckBox cb) {
|
||||
@@ -272,18 +331,33 @@ public class Messages {
|
||||
|
||||
|
||||
public static int showTwoStepConfirmationDialog(String message, String title, String checkboxText, Icon icon) {
|
||||
return showCheckboxMessageDialog(message, title, new String[] {OK_BUTTON, CANCEL_BUTTON}, checkboxText, true, -1, -1, icon, null);
|
||||
return showCheckboxMessageDialog(message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, checkboxText, true, -1, -1, icon, null);
|
||||
}
|
||||
|
||||
public static void showErrorDialog(Project project, @Nls String message, @Nls String title) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showErrorDialog(title, message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project));
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(project, message, title, new String[]{OK_BUTTON}, 0, getErrorIcon());
|
||||
}
|
||||
|
||||
public static void showErrorDialog(Component component, String message, @Nls String title) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showErrorDialog(title, message, OK_BUTTON, SwingUtilities.getWindowAncestor(component));
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(component, message, title, new String[]{OK_BUTTON}, 0, getErrorIcon());
|
||||
}
|
||||
|
||||
public static void showErrorDialog(Component component, String message) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showErrorDialog(CommonBundle.getErrorTitle(), message, OK_BUTTON, SwingUtilities.getWindowAncestor(component));
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(component, message, CommonBundle.getErrorTitle(), new String[]{OK_BUTTON}, 0, getErrorIcon());
|
||||
}
|
||||
|
||||
@@ -294,14 +368,29 @@ public class Messages {
|
||||
* @see #showErrorDialog(Component, String, String)
|
||||
*/
|
||||
public static void showErrorDialog(String message, String title) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showErrorDialog(CommonBundle.getErrorTitle(), message, OK_BUTTON, null);
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(message, title, new String[]{OK_BUTTON}, 0, getErrorIcon());
|
||||
}
|
||||
|
||||
public static void showWarningDialog(Project project, String message, String title) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showErrorDialog(CommonBundle.getErrorTitle(), message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project));
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(project, message, title, new String[]{OK_BUTTON}, 0, getWarningIcon());
|
||||
}
|
||||
|
||||
public static void showWarningDialog(Component component, String message, String title) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showErrorDialog(CommonBundle.getErrorTitle(), message, OK_BUTTON, SwingUtilities.getWindowAncestor(component));
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(component, message, title, new String[]{OK_BUTTON}, 0, getWarningIcon());
|
||||
}
|
||||
|
||||
@@ -312,22 +401,55 @@ public class Messages {
|
||||
* @see #showWarningDialog(Component, String, String)
|
||||
*/
|
||||
public static void showWarningDialog(String message, String title) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showErrorDialog(CommonBundle.getErrorTitle(), message, OK_BUTTON, null);
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(message, title, new String[]{OK_BUTTON}, 0, getWarningIcon());
|
||||
}
|
||||
|
||||
public static int showYesNoCancelDialog(Project project, String message, String title, Icon icon) {
|
||||
return showDialog(project, message, title, new String[]{YES_BUTTON, NO_BUTTON, CANCEL_BUTTON}, 0, icon);
|
||||
public static int showYesNoCancelDialog(Project project, String message, String title, String yes, String no, String cancel, Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoCancelDialog(title, message, yes, no, cancel,
|
||||
WindowManager.getInstance().suggestParentWindow(project), null);
|
||||
}
|
||||
|
||||
return showDialog(project, message, title, new String[]{yes, no, cancel}, 0, icon);
|
||||
}
|
||||
|
||||
public static int showYesNoCancelDialog(Project project, String message, String title, final int defaultOptionIndex,
|
||||
final int focusedOptionIndex, Icon icon) {
|
||||
return showDialog(project, message, title, new String[]{YES_BUTTON, NO_BUTTON, CANCEL_BUTTON}, defaultOptionIndex, focusedOptionIndex, icon);
|
||||
|
||||
public static int showYesNoCancelDialog(Project project, String message, String title, Icon icon) {
|
||||
return showYesNoCancelDialog(project, message, title, YES_BUTTON, NO_BUTTON, CANCEL_BUTTON, icon);
|
||||
}
|
||||
|
||||
public static int showYesNoCancelDialog(Component parent, String message, String title, String yes, String no, String cancel, Icon icon) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoCancelDialog(title, message, yes, no, cancel,
|
||||
SwingUtilities.getWindowAncestor(parent), null);
|
||||
}
|
||||
|
||||
return showDialog(parent, message, title, new String[]{yes, no, cancel}, 0, icon);
|
||||
}
|
||||
|
||||
public static int showYesNoCancelDialog(Component parent, String message, String title, Icon icon) {
|
||||
return showDialog(parent, message, title, new String[]{YES_BUTTON, NO_BUTTON, CANCEL_BUTTON}, 0, icon);
|
||||
return showYesNoCancelDialog(parent, message, title, YES_BUTTON, NO_BUTTON, CANCEL_BUTTON, icon);
|
||||
}
|
||||
|
||||
|
||||
public static int showYesNoCancelDialog(String message, String title, String yes, String no, String cancel, Icon icon,
|
||||
DialogWrapper.DoNotAskOption doNotAskOption) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
return MacMessages.showYesNoCancelDialog(title, message, yes, no, cancel, null, doNotAskOption);
|
||||
}
|
||||
|
||||
return showDialog(message, title, new String[]{yes, no, cancel}, 0, icon, doNotAskOption);
|
||||
}
|
||||
|
||||
public static int showYesNoCancelDialog(String message, String title, String yes, String no, String cancel, Icon icon) {
|
||||
return showYesNoCancelDialog(message, title, yes, no, cancel, icon, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method only if you do not know project or component
|
||||
*
|
||||
@@ -335,7 +457,7 @@ public class Messages {
|
||||
* @see #showYesNoCancelDialog(Component, String, String, Icon)
|
||||
*/
|
||||
public static int showYesNoCancelDialog(String message, String title, Icon icon) {
|
||||
return showDialog(message, title, new String[]{YES_BUTTON, NO_BUTTON, CANCEL_BUTTON}, 0, icon);
|
||||
return showYesNoCancelDialog(message, title, YES_BUTTON, NO_BUTTON, CANCEL_BUTTON, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,6 +642,11 @@ public class Messages {
|
||||
* Shows dialog with given message and title, infomation icon {@link #getInformationIcon()} and OK button
|
||||
*/
|
||||
public static void showInfoMessage(Component component, String message, String title) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showOkMessageDialog(title, message, OK_BUTTON, SwingUtilities.getWindowAncestor(component));
|
||||
return;
|
||||
}
|
||||
|
||||
showMessageDialog(component, message, title, getInformationIcon());
|
||||
}
|
||||
|
||||
@@ -527,6 +654,11 @@ public class Messages {
|
||||
* Shows dialog with given message and title, infomation icon {@link #getInformationIcon()} and OK button
|
||||
*/
|
||||
public static void showInfoMessage(Project project, @Nls String message, @Nls String title) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showOkMessageDialog(title, message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project));
|
||||
return;
|
||||
}
|
||||
|
||||
showMessageDialog(project, message, title, getInformationIcon());
|
||||
}
|
||||
|
||||
@@ -534,6 +666,12 @@ public class Messages {
|
||||
* Shows dialog with given message and title, infomation icon {@link #getInformationIcon()} and OK button
|
||||
*/
|
||||
public static void showInfoMessage(String message, String title) {
|
||||
if (SystemInfo.isMac && !isApplicationInUnitTestOrHeadless()) {
|
||||
MacMessages.showOkMessageDialog(title, message, OK_BUTTON, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
showMessageDialog(message, title, getInformationIcon());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,15 @@ import java.awt.*;
|
||||
public class ScreenUtil {
|
||||
private ScreenUtil() {
|
||||
}
|
||||
|
||||
|
||||
public static boolean isVisible(Rectangle bounds) {
|
||||
final Rectangle intersection = getScreenBounds().intersection(bounds);
|
||||
final int sq1 = intersection.width * intersection.height;
|
||||
final int sq2 = bounds.width * bounds.height;
|
||||
if (sq1 == 0 || sq2 == 0) return false;
|
||||
return (double)sq1 / (double)sq2 > 0.1;
|
||||
}
|
||||
|
||||
public static Rectangle getScreenBounds() {
|
||||
Rectangle screenBounds = new Rectangle();
|
||||
final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
}
|
||||
|
||||
if (scrollbar != null) {
|
||||
scrollbar.repaint();
|
||||
scrollbar.repaint(((ButtonlessScrollBarUI)scrollbar.getUI()).getThumbBounds());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,8 +24,10 @@ import java.awt.*;
|
||||
|
||||
/**
|
||||
* author: lesya
|
||||
*
|
||||
* @deprecated use one of {@link com.intellij.openapi.ui.Messages} methods instead.
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public abstract class OptionsDialog extends DialogWrapper {
|
||||
|
||||
protected final Project myProject;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.application.options;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
@@ -75,57 +76,54 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent,
|
||||
SYSTEM_MACROS.add(USER_HOME_MACRO_NAME);
|
||||
}
|
||||
|
||||
private static final Set<String> ourToolsMacros = new HashSet<String>();
|
||||
|
||||
static {
|
||||
ourToolsMacros.addAll(Arrays.asList(
|
||||
"ClasspathEntry",
|
||||
"Classpath",
|
||||
"ColumnNumber",
|
||||
"FileClass",
|
||||
"FileDir",
|
||||
"FileDirRelativeToProjectRoot",
|
||||
"/FileDirRelativeToProjectRoot",
|
||||
"FileDirRelativeToSourcepath",
|
||||
"/FileDirRelativeToSourcepath",
|
||||
"FileExt",
|
||||
"FileFQPackage",
|
||||
"FileName",
|
||||
"FileNameWithoutExtension",
|
||||
"FilePackage",
|
||||
"FilePath",
|
||||
"FilePathRelativeToProjectRoot",
|
||||
"/FilePathRelativeToProjectRoot",
|
||||
"FilePathRelativeToSourcepath",
|
||||
"/FilePathRelativeToSourcepath",
|
||||
"FileRelativeDir",
|
||||
"/FileRelativeDir",
|
||||
"FileRelativePath",
|
||||
"/FileRelativePath",
|
||||
"JavaDocPath",
|
||||
"JDKPath",
|
||||
"LineNumber",
|
||||
"ModuleFileDir",
|
||||
"ModuleFilePath",
|
||||
"ModuleName",
|
||||
"ModuleSourcePath",
|
||||
"OutputPath",
|
||||
"PhpExecutable",
|
||||
"ProjectFileDir",
|
||||
"ProjectFilePath",
|
||||
"ProjectName",
|
||||
"Projectpath",
|
||||
"Prompt",
|
||||
"SourcepathEntry",
|
||||
"Sourcepath",
|
||||
"SHOW_CHANGES",
|
||||
"SelectedText",
|
||||
"SelectionStartLine",
|
||||
"SelectionEndLine",
|
||||
"SelectionStartColumn",
|
||||
"SelectionEndColumn"
|
||||
));
|
||||
}
|
||||
private static final Set<String> ourToolsMacros = ImmutableSet.of(
|
||||
"ClasspathEntry",
|
||||
"Classpath",
|
||||
"ColumnNumber",
|
||||
"FileClass",
|
||||
"FileDir",
|
||||
"FileDirRelativeToProjectRoot",
|
||||
"/FileDirRelativeToProjectRoot",
|
||||
"FileDirRelativeToSourcepath",
|
||||
"/FileDirRelativeToSourcepath",
|
||||
"FileExt",
|
||||
"FileFQPackage",
|
||||
"FileName",
|
||||
"FileNameWithoutExtension",
|
||||
"FilePackage",
|
||||
"FilePath",
|
||||
"FilePathRelativeToProjectRoot",
|
||||
"/FilePathRelativeToProjectRoot",
|
||||
"FilePathRelativeToSourcepath",
|
||||
"/FilePathRelativeToSourcepath",
|
||||
"FilePrompt",
|
||||
"FileRelativeDir",
|
||||
"/FileRelativeDir",
|
||||
"FileRelativePath",
|
||||
"/FileRelativePath",
|
||||
"JavaDocPath",
|
||||
"JDKPath",
|
||||
"LineNumber",
|
||||
"ModuleFileDir",
|
||||
"ModuleFilePath",
|
||||
"ModuleName",
|
||||
"ModuleSourcePath",
|
||||
"OutputPath",
|
||||
"PhpExecutable",
|
||||
"ProjectFileDir",
|
||||
"ProjectFilePath",
|
||||
"ProjectName",
|
||||
"Projectpath",
|
||||
"Prompt",
|
||||
"SourcepathEntry",
|
||||
"Sourcepath",
|
||||
"SHOW_CHANGES",
|
||||
"SelectedText",
|
||||
"SelectionStartLine",
|
||||
"SelectionEndLine",
|
||||
"SelectionStartColumn",
|
||||
"SelectionEndColumn"
|
||||
);
|
||||
|
||||
public PathMacrosImpl() {
|
||||
//setMacro(USER_HOME_MACRO_NAME, FileUtil.toSystemIndependentName(SystemProperties.getUserHome()));
|
||||
|
||||
@@ -30,10 +30,9 @@ public class GroupedLogMessage extends AbstractMessage {
|
||||
}
|
||||
|
||||
public String getThrowableText() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
for (int i = 0; i < myMessages.size(); i++) {
|
||||
AbstractMessage each = myMessages.get(i);
|
||||
result.append(each.getThrowableText() + "\n\n\n");
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (AbstractMessage each : myMessages) {
|
||||
result.append(each.getThrowableText()).append("\n\n\n");
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -92,12 +92,13 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
static {
|
||||
TW_KEYMAP.put("Messages", 0);
|
||||
TW_KEYMAP.put("Project", 1);
|
||||
TW_KEYMAP.put("Commander", 2);
|
||||
TW_KEYMAP.put("Favorites", 2);
|
||||
TW_KEYMAP.put("Find", 3);
|
||||
TW_KEYMAP.put("Run", 4);
|
||||
TW_KEYMAP.put("Debug", 5);
|
||||
TW_KEYMAP.put("TODO", 6);
|
||||
TW_KEYMAP.put("Structure", 7);
|
||||
TW_KEYMAP.put("Hierarchy", 8);
|
||||
TW_KEYMAP.put("Changes", 9);
|
||||
|
||||
IdeEventQueue.getInstance().addPostprocessor(new IdeEventQueue.EventDispatcher() {
|
||||
|
||||
@@ -128,14 +128,12 @@ public class ProjectUtil {
|
||||
public static Project openProject(final String path, Project projectToClose, boolean forceOpenInNewFrame) {
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
Messages.showMessageDialog(IdeBundle.message("error.project.file.does.not.exist", path), CommonBundle.getErrorTitle(),
|
||||
Messages.getErrorIcon());
|
||||
Messages.showErrorDialog(IdeBundle.message("error.project.file.does.not.exist", path), CommonBundle.getErrorTitle());
|
||||
return null;
|
||||
}
|
||||
|
||||
if (file.isDirectory() && !new File(file, com.intellij.openapi.project.ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).exists()) {
|
||||
Messages.showMessageDialog(IdeBundle.message("error.project.file.does.not.exist", new File(file, com.intellij.openapi.project.ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).getPath()), CommonBundle.getErrorTitle(),
|
||||
Messages.getErrorIcon());
|
||||
Messages.showErrorDialog(IdeBundle.message("error.project.file.does.not.exist", new File(file, com.intellij.openapi.project.ProjectUtil.DIRECTORY_BASED_PROJECT_DIR).getPath()), CommonBundle.getErrorTitle());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -182,10 +180,12 @@ public class ProjectUtil {
|
||||
public static int confirmOpenNewProject() {
|
||||
final GeneralSettings settings = GeneralSettings.getInstance();
|
||||
if (settings.getConfirmOpenNewProject() == GeneralSettings.OPEN_PROJECT_ASK) {
|
||||
return Messages.showDialog(IdeBundle.message("prompt.open.project.in.new.frame"), IdeBundle.message("title.open.project"),
|
||||
new String[]{IdeBundle.message("button.newframe"), IdeBundle.message("button.existingframe"),
|
||||
CommonBundle.getCancelButtonText()}, 1, 0, Messages.getQuestionIcon(),
|
||||
new ProjectNewWindowDoNotAskOption());
|
||||
return Messages.showYesNoCancelDialog(IdeBundle.message("prompt.open.project.in.new.frame"),
|
||||
IdeBundle.message("title.open.project"),
|
||||
IdeBundle.message("button.newframe"),
|
||||
IdeBundle.message("button.existingframe"),
|
||||
CommonBundle.getCancelButtonText(), Messages.getQuestionIcon(),
|
||||
new ProjectNewWindowDoNotAskOption());
|
||||
} else {
|
||||
return settings.getConfirmOpenNewProject();
|
||||
}
|
||||
|
||||
@@ -174,13 +174,13 @@ public class PluginManagerConfigurable extends BaseConfigurable implements Searc
|
||||
private static int showShutDownIDEADialog() {
|
||||
String message = IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getProductName());
|
||||
String title = IdeBundle.message("title.plugins.changed");
|
||||
return Messages.showDialog(message, title, new String[]{"Shut Down", POSTPONE},0,0,Messages.getQuestionIcon());
|
||||
return Messages.showYesNoDialog(message, title, "Shut Down", POSTPONE,Messages.getQuestionIcon());
|
||||
}
|
||||
|
||||
public static int showRestartIDEADialog() {
|
||||
String message = IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getProductName());
|
||||
String title = IdeBundle.message("title.plugins.changed");
|
||||
return Messages.showDialog(message, title, new String[]{"Restart", POSTPONE},0,0,Messages.getQuestionIcon());
|
||||
return Messages.showYesNoDialog(message, title, "Restart", POSTPONE, Messages.getQuestionIcon());
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
|
||||
@@ -290,7 +290,7 @@
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Reload"/>
|
||||
<text value="&Reload Available Plugins"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c101a" class="javax.swing.JButton" binding="myHttpProxySettingsButton">
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.intellij.openapi.ui.SimpleToolWindowPanel;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
@@ -274,7 +275,9 @@ public class EventLog implements Notifications {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
console.doPrintNotification(notification);
|
||||
if (!ShutDownTracker.isShutdownHookRunning()) {
|
||||
console.doPrintNotification(notification);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+13
-1
@@ -18,18 +18,24 @@ package com.intellij.openapi.actionSystem.impl;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Map;
|
||||
|
||||
public class SimpleDataContext implements DataContext {
|
||||
private final Map<String, Object> myDataId2Data;
|
||||
private final DataContext myParent;
|
||||
|
||||
private WeakReference<Component> myContextComponent;
|
||||
|
||||
private SimpleDataContext(String dataId, Object data, DataContext parent) {
|
||||
myDataId2Data = new HashMap<String, Object>(1);
|
||||
myDataId2Data.put(dataId, data);
|
||||
myParent = parent;
|
||||
myContextComponent = new WeakReference<Component>(IdeFocusManager.getGlobalInstance().getFocusOwner());
|
||||
}
|
||||
|
||||
private SimpleDataContext(Map<String, Object> dataid2data, DataContext parent) {
|
||||
@@ -38,8 +44,14 @@ public class SimpleDataContext implements DataContext {
|
||||
}
|
||||
|
||||
public Object getData(String dataId) {
|
||||
return myDataId2Data.containsKey(dataId) ? myDataId2Data.get(dataId) :
|
||||
Object result = myDataId2Data.containsKey(dataId) ? myDataId2Data.get(dataId) :
|
||||
myParent == null ? null : myParent.getData(dataId);
|
||||
|
||||
if (result == null && PlatformDataKeys.CONTEXT_COMPONENT.getName().equals(dataId)) {
|
||||
result = myContextComponent.get();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static DataContext getSimpleContext(String dataId, Object data, DataContext parent) {
|
||||
|
||||
+48
-6
@@ -35,17 +35,20 @@ public class ConfigImportHelper {
|
||||
@NonNls private static final String BUILD_NUMBER_FILE = "build.txt";
|
||||
@NonNls private static final String PLUGINS_PATH = "plugins";
|
||||
@NonNls private static final String BIN_FOLDER = "bin";
|
||||
@NonNls private static final String OPTIONS_XML = "options/options.xml";
|
||||
|
||||
private ConfigImportHelper() {}
|
||||
|
||||
public static void importConfigsTo(String newConfigPath) {
|
||||
File oldConfigDir = findOldConfigDir(newConfigPath);
|
||||
|
||||
do {
|
||||
ImportOldConfigsPanel dlg;
|
||||
if (UIUtil.hasJdk6Dialogs()) {
|
||||
dlg = new ImportOldConfigsPanel();
|
||||
dlg = new ImportOldConfigsPanel(oldConfigDir);
|
||||
}
|
||||
else {
|
||||
dlg = new ImportOldConfigsPanel(JOptionPane.getRootFrame());
|
||||
dlg = new ImportOldConfigsPanel(oldConfigDir, JOptionPane.getRootFrame());
|
||||
}
|
||||
|
||||
UIUtil.setToolkitModal(dlg);
|
||||
@@ -53,7 +56,7 @@ public class ConfigImportHelper {
|
||||
dlg.setVisible(true);
|
||||
if (dlg.isImportEnabled()) {
|
||||
File instHome = dlg.getSelectedFile();
|
||||
File oldConfigDir = getOldConfigDir(instHome);
|
||||
oldConfigDir = getOldConfigDir(instHome);
|
||||
if (!validateOldConfigDir(instHome, oldConfigDir)) continue;
|
||||
|
||||
doImport(newConfigPath, oldConfigDir);
|
||||
@@ -64,6 +67,33 @@ public class ConfigImportHelper {
|
||||
while (true);
|
||||
}
|
||||
|
||||
private static File findOldConfigDir(String newConfigPath) {
|
||||
final File configDir = new File(newConfigPath);
|
||||
final File selectorDir = SystemInfo.isMac ? configDir : configDir.getParentFile();
|
||||
final File parent = selectorDir.getParentFile();
|
||||
if (parent == null || !parent.exists()) return null;
|
||||
File maxFile = null;
|
||||
long lastModified = 0;
|
||||
final String selector = PathManager.getPathsSelector() != null ? PathManager.getPathsSelector() : selectorDir.getName();
|
||||
for (File file : parent.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return name.length() == selector.length() &&
|
||||
name.startsWith(selector.replaceAll("\\d",""));
|
||||
|
||||
}
|
||||
})) {
|
||||
final File options = new File(file, OPTIONS_XML);
|
||||
if (!options.exists()) continue;
|
||||
final long modified = options.lastModified();
|
||||
if (modified > lastModified) {
|
||||
lastModified = modified;
|
||||
maxFile = file;
|
||||
}
|
||||
}
|
||||
return maxFile;
|
||||
}
|
||||
|
||||
public static void doImport(final String newConfigPath, final File oldConfigDir) {
|
||||
try {
|
||||
xcopy(oldConfigDir, new File(newConfigPath));
|
||||
@@ -77,9 +107,13 @@ public class ConfigImportHelper {
|
||||
|
||||
public static boolean validateOldConfigDir(final File instHome, final File oldConfigDir) {
|
||||
if (oldConfigDir == null) {
|
||||
final String message = !instHome.equals(oldConfigDir) ?
|
||||
ApplicationBundle.message("error.invalid.installation.home", instHome.getAbsolutePath(),
|
||||
ApplicationNamesInfo.getInstance().getFullProductName()) :
|
||||
ApplicationBundle.message("error.invalid.config.folder", instHome.getAbsolutePath(),
|
||||
ApplicationNamesInfo.getInstance().getFullProductName()) ;
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
|
||||
ApplicationBundle.message("error.invalid.installation.home", instHome.getAbsolutePath(),
|
||||
ApplicationNamesInfo.getInstance().getFullProductName()));
|
||||
message);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -113,6 +147,12 @@ public class ConfigImportHelper {
|
||||
|
||||
@Nullable
|
||||
public static File getOldConfigDir(File oldInstallHome) {
|
||||
if (oldInstallHome == null) return null;
|
||||
// check if it's already config dir
|
||||
if (new File(oldInstallHome, OPTIONS_XML).exists()) {
|
||||
return oldInstallHome;
|
||||
}
|
||||
|
||||
int oldBuildNumber = getBuildNumber(oldInstallHome);
|
||||
|
||||
if (oldBuildNumber != -1 && oldBuildNumber <= 600) { // Pandora
|
||||
@@ -252,7 +292,9 @@ public class ConfigImportHelper {
|
||||
return dir;
|
||||
}
|
||||
|
||||
public static boolean isInstallationHome(String installationHome) {
|
||||
public static boolean isInstallationHomeOrConfig(String installationHome) {
|
||||
if (new File(installationHome, OPTIONS_XML).exists()) return true;
|
||||
|
||||
String mainJarName = StringUtil.toLowerCase(ApplicationNamesInfo.getInstance().getProductName()) + ".jar";
|
||||
//noinspection HardCodedStringLiteral
|
||||
boolean quickTest = new File(new File(installationHome, "lib"), mainJarName).exists() &&
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<grid id="47e28" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
<constraints>
|
||||
<xy x="28" y="33" width="566" height="210"/>
|
||||
<xy x="28" y="33" width="566" height="272"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -41,7 +41,7 @@
|
||||
<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>
|
||||
<grid id="865b3" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="865b3" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -65,14 +65,6 @@
|
||||
<text resource-bundle="messages/ApplicationBundle" key="radio.import"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="92c19" class="javax.swing.JRadioButton" binding="myRbDoNotImport">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ApplicationBundle" key="radio.do.not.import"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="1855" layout-manager="GridLayoutManager" row-count="2" 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>
|
||||
@@ -108,6 +100,22 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</xy>
|
||||
<component id="717e6" class="javax.swing.JRadioButton" binding="myRbImportAuto">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ApplicationBundle" key="radio.import.auto"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="92c19" class="javax.swing.JRadioButton" binding="myRbDoNotImport">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ApplicationBundle" key="radio.do.not.import"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<hspacer id="9b2a0">
|
||||
|
||||
+22
-11
@@ -19,6 +19,7 @@ import com.intellij.openapi.MnemonicHelper;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -41,16 +42,19 @@ public class ImportOldConfigsPanel extends JDialog {
|
||||
private JButton myOkButton;
|
||||
private JLabel mySuggestLabel;
|
||||
private JLabel myHomeLabel;
|
||||
private JRadioButton myRbImportAuto;
|
||||
private final File myGuessedOldConfig;
|
||||
|
||||
public ImportOldConfigsPanel(final Frame owner) {
|
||||
public ImportOldConfigsPanel(final File guessedOldConfig, final Frame owner) {
|
||||
super(owner, true);
|
||||
myGuessedOldConfig = guessedOldConfig;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public ImportOldConfigsPanel() {
|
||||
public ImportOldConfigsPanel(final File guessedOldConfig) {
|
||||
super((Dialog) null, true);
|
||||
|
||||
myGuessedOldConfig = guessedOldConfig;
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -60,12 +64,19 @@ public class ImportOldConfigsPanel extends JDialog {
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(myRbDoNotImport);
|
||||
group.add(myRbImport);
|
||||
group.add(myRbImportAuto);
|
||||
myRbDoNotImport.setSelected(true);
|
||||
|
||||
final ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
|
||||
final String productName = namesInfo.getProductName().equals("IDEA") ? namesInfo.getFullProductName() : namesInfo.getProductName();
|
||||
mySuggestLabel.setText(ApplicationBundle.message("label.you.can.import", productName));
|
||||
myRbDoNotImport.setText(ApplicationBundle.message("radio.do.not.import", productName));
|
||||
if(myGuessedOldConfig != null) {
|
||||
myRbImportAuto.setText(ApplicationBundle.message("radio.import.auto", myGuessedOldConfig.getAbsolutePath().replace(SystemProperties.getUserHome(), "~")));
|
||||
myRbImportAuto.setSelected(true);
|
||||
} else {
|
||||
myRbImportAuto.setVisible(false);
|
||||
}
|
||||
myHomeLabel.setText(ApplicationBundle.message("editbox.installation.home", productName));
|
||||
|
||||
myRbImport.addChangeListener(new ChangeListener() {
|
||||
@@ -74,7 +85,9 @@ public class ImportOldConfigsPanel extends JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
if (SystemInfo.isMac) {
|
||||
if (myGuessedOldConfig != null) {
|
||||
myPrevInstallation.setText(myGuessedOldConfig.getParent());
|
||||
} if (SystemInfo.isMac) {
|
||||
myPrevInstallation.setText(findPreviousInstallationMac(productName));
|
||||
}
|
||||
else if (SystemInfo.isWindows) {
|
||||
@@ -91,9 +104,7 @@ public class ImportOldConfigsPanel extends JDialog {
|
||||
fc = new JFileChooser(myLastSelection);
|
||||
}
|
||||
|
||||
if (!SystemInfo.isMac) {
|
||||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
}
|
||||
fc.setFileSelectionMode(SystemInfo.isMac ? JFileChooser.FILES_AND_DIRECTORIES : JFileChooser.DIRECTORIES_ONLY);
|
||||
|
||||
int returnVal = fc.showOpenDialog(ImportOldConfigsPanel.this);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION){
|
||||
@@ -184,7 +195,7 @@ public class ImportOldConfigsPanel extends JDialog {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ConfigImportHelper.isInstallationHome(instHome)) {
|
||||
if (myRbImport.isSelected() && !ConfigImportHelper.isInstallationHomeOrConfig(instHome)) {
|
||||
JOptionPane.showMessageDialog(this,
|
||||
ApplicationBundle.message("error.does.not.appear.to.be.installation.home", instHome,
|
||||
productWithVendor),
|
||||
@@ -204,11 +215,11 @@ public class ImportOldConfigsPanel extends JDialog {
|
||||
}
|
||||
|
||||
public boolean isImportEnabled() {
|
||||
return myRbImport.isSelected();
|
||||
return myRbImport.isSelected() || myRbImportAuto.isSelected();
|
||||
}
|
||||
|
||||
public File getSelectedFile() {
|
||||
return new File(myPrevInstallation.getText());
|
||||
return myRbImportAuto.isSelected() ? myGuessedOldConfig : new File(myPrevInstallation.getText());
|
||||
}
|
||||
|
||||
private void update() {
|
||||
@@ -216,7 +227,7 @@ public class ImportOldConfigsPanel extends JDialog {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ImportOldConfigsPanel dlg = new ImportOldConfigsPanel();
|
||||
ImportOldConfigsPanel dlg = new ImportOldConfigsPanel(null);
|
||||
dlg.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-7
@@ -773,16 +773,17 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
|
||||
private static boolean showConfirmation() {
|
||||
final boolean hasUnsafeBgTasks = ProgressManager.getInstance().hasUnsafeProgressIndicator();
|
||||
final ConfirmExitDialog confirmExitDialog = new ConfirmExitDialog(hasUnsafeBgTasks);
|
||||
if (confirmExitDialog.isToBeShown()) {
|
||||
confirmExitDialog.show();
|
||||
if (!confirmExitDialog.isOK()) {
|
||||
if (hasUnsafeBgTasks || GeneralSettings.getInstance().isConfirmExit()) {
|
||||
String message = ApplicationBundle
|
||||
.message(hasUnsafeBgTasks ? "exit.confirm.prompt.tasks" : "exit.confirm.prompt",
|
||||
ApplicationNamesInfo.getInstance().getFullProductName());
|
||||
|
||||
if (DialogWrapper.OK_EXIT_CODE != Messages.showYesNoDialog(message, ApplicationBundle.message("exit.confirm.title"),
|
||||
ApplicationBundle.message("command.exit"), "Cancel",
|
||||
Messages.getQuestionIcon())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
confirmExitDialog.close(DialogWrapper.OK_EXIT_CODE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
-75
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* 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.openapi.application.impl;
|
||||
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.util.ui.OptionsDialog;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Jun 2, 2005
|
||||
*/
|
||||
public class ConfirmExitDialog extends OptionsDialog {
|
||||
|
||||
private final boolean myHasTasks;
|
||||
|
||||
public ConfirmExitDialog(boolean hasBgTasks) {
|
||||
super(false);
|
||||
setTitle(ApplicationBundle.message("exit.confirm.title"));
|
||||
myHasTasks = hasBgTasks;
|
||||
init();
|
||||
}
|
||||
|
||||
protected Action[] createActions() {
|
||||
setOKButtonText(ApplicationBundle.message("command.exit"));
|
||||
return new Action[] {getOKAction(), getCancelAction()};
|
||||
}
|
||||
|
||||
protected boolean isToBeShown() {
|
||||
return GeneralSettings.getInstance().isConfirmExit() || myHasTasks;
|
||||
}
|
||||
|
||||
protected void setToBeShown(boolean value, boolean onOk) {
|
||||
GeneralSettings.getInstance().setConfirmExit(value);
|
||||
}
|
||||
|
||||
protected boolean shouldSaveOptionsOnCancel() {
|
||||
return !myHasTasks;
|
||||
}
|
||||
|
||||
protected boolean canBeHidden() {
|
||||
return !myHasTasks;
|
||||
}
|
||||
|
||||
protected JComponent createCenterPanel() {
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
final String message = ApplicationBundle.message(myHasTasks ? "exit.confirm.prompt.tasks": "exit.confirm.prompt", ApplicationNamesInfo.getInstance().getFullProductName());
|
||||
|
||||
final JLabel label = new JLabel(message);
|
||||
label.setIconTextGap(10);
|
||||
label.setIcon(Messages.getQuestionIcon());
|
||||
panel.add(label, BorderLayout.CENTER);
|
||||
panel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
int startLine = myDocument.getLineNumber(start);
|
||||
int endLine = end < myDocument.getTextLength() ? myDocument.getLineNumber(end) : myDocument.getLineCount() - 1;
|
||||
repaintLines(Math.max(0, startLine - 1), Math.min(endLine + 1, getDocument().getLineCount()));
|
||||
((EditorMarkupModelImpl)getMarkupModel()).markDirtied();
|
||||
((EditorMarkupModelImpl)getMarkupModel()).repaint(start, end);
|
||||
GutterIconRenderer renderer = highlighter.getGutterIconRenderer();
|
||||
if (renderer != null) {
|
||||
@@ -2467,7 +2466,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
}
|
||||
|
||||
private void addContent(Graphics g, char[] _data, int _start, int _end, int _x, int _y, Color _color) {
|
||||
private void addContent(Graphics g, char[] _data, int _start, int _end, int _x, int _y, @Nullable Color _color) {
|
||||
final int count = myCount;
|
||||
if (count > 0) {
|
||||
final int lastCount = count - 1;
|
||||
@@ -2706,8 +2705,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
int end,
|
||||
Point position,
|
||||
Rectangle clip,
|
||||
Color effectColor,
|
||||
EffectType effectType,
|
||||
@Nullable Color effectColor,
|
||||
@Nullable EffectType effectType,
|
||||
int fontType,
|
||||
Color fontColor) {
|
||||
if (start >= end) return position.x;
|
||||
|
||||
+52
-18
@@ -42,6 +42,7 @@ import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.ProperTextRange;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.HintHint;
|
||||
import com.intellij.ui.LightweightHint;
|
||||
@@ -59,6 +60,7 @@ import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
@@ -79,6 +81,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
private int myEditorScrollbarTop = -1;
|
||||
private int myEditorTargetHeight = -1;
|
||||
private int myEditorSourceHeight = -1;
|
||||
private TextRange myDirtyRange = null;
|
||||
|
||||
@NotNull private ErrorStripTooltipRendererProvider myTooltipRendererProvider = new BasicTooltipRendererProvider();
|
||||
|
||||
@@ -283,7 +286,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
void repaint(int startOffset, int endOffset) {
|
||||
markDirtied();
|
||||
markDirtied(startOffset, endOffset);
|
||||
|
||||
ProperTextRange range = offsetToYPosition(startOffset, endOffset);
|
||||
|
||||
@@ -331,6 +334,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
private class MyErrorPanel extends ButtonlessScrollBarUI implements MouseMotionListener, MouseListener {
|
||||
private PopupHandler myHandler;
|
||||
private ErrorStripeButton myErrorStripeButton;
|
||||
private BufferedImage myCachedTrack;
|
||||
|
||||
@Override
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
@@ -376,22 +380,41 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
|
||||
@Override
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle bounds) {
|
||||
Rectangle clip = g.getClipBounds().intersection(bounds);
|
||||
if (clip.height == 0) return;
|
||||
|
||||
final Rectangle componentBounds = c.getBounds();
|
||||
if (myCachedTrack == null || myCachedTrack.getHeight() != componentBounds.getHeight()) {
|
||||
myCachedTrack = new BufferedImage(componentBounds.width, componentBounds.height, BufferedImage.TYPE_INT_ARGB);
|
||||
myDirtyRange = TextRange.create(0, getEditor().getDocument().getTextLength());
|
||||
paintTrackBasement(myCachedTrack.getGraphics(), new Rectangle(0, 0, componentBounds.width, componentBounds.height));
|
||||
}
|
||||
|
||||
if (myDirtyRange != null) {
|
||||
final Graphics2D imageGraphics = myCachedTrack.createGraphics();
|
||||
|
||||
|
||||
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
|
||||
|
||||
try {
|
||||
repaint(imageGraphics, componentBounds.width, ERROR_ICON_WIDTH - 1, myDirtyRange.getStartOffset(), myDirtyRange.getEndOffset());
|
||||
myDirtyRange = null;
|
||||
}
|
||||
finally {
|
||||
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
|
||||
}
|
||||
}
|
||||
|
||||
((Graphics2D)g).drawImage(myCachedTrack, null, 0, 0);
|
||||
}
|
||||
|
||||
private void paintTrackBasement(Graphics g, Rectangle bounds) {
|
||||
g.setColor(TRACK_BACKGROUND);
|
||||
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
||||
|
||||
g.setColor(TRACK_BORDER);
|
||||
int border = isMirrored() ? bounds.x + bounds.width - 1 : bounds.x;
|
||||
g.drawLine(border, bounds.y, border, bounds.y + bounds.height);
|
||||
|
||||
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
|
||||
|
||||
try {
|
||||
Rectangle clipBounds = g.getClipBounds();
|
||||
repaint(g, ERROR_ICON_WIDTH - 1, clipBounds);
|
||||
}
|
||||
finally {
|
||||
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -399,13 +422,16 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
return ColorUtil.withAlpha(ColorUtil.shift(super.adjustColor(c), 0.9), 0.85);
|
||||
}
|
||||
|
||||
private void repaint(final Graphics g, final int width, Rectangle clipBounds) {
|
||||
Document document = myEditor.getDocument();
|
||||
int startOffset = yPositionToOffset(clipBounds.y, true);
|
||||
int endOffset = yPositionToOffset(clipBounds.y + clipBounds.height, false);
|
||||
private void repaint(final Graphics g, int gutterWidth, final int stripeWidth, int startOffset, int endOffset) {
|
||||
final ProperTextRange yrange = offsetToYPosition(startOffset, endOffset);
|
||||
final Rectangle clip = new Rectangle(0, yrange.getStartOffset(), gutterWidth, yrange.getLength() + getMinHeight());
|
||||
paintTrackBasement(g, clip);
|
||||
|
||||
drawMarkup(g, width, startOffset, endOffset, EditorMarkupModelImpl.this);
|
||||
drawMarkup(g, width, startOffset, endOffset, (MarkupModelEx)document.getMarkupModel(myEditor.getProject()));
|
||||
Document document = myEditor.getDocument();
|
||||
endOffset = yPositionToOffset(clip.y + clip.height, false);
|
||||
|
||||
drawMarkup(g, stripeWidth, startOffset, endOffset, EditorMarkupModelImpl.this);
|
||||
drawMarkup(g, stripeWidth, startOffset, endOffset, (MarkupModelEx)document.getMarkupModel(myEditor.getProject()));
|
||||
}
|
||||
|
||||
private void drawMarkup(final Graphics g, final int width, int startOffset, int endOffset, MarkupModelEx markup) {
|
||||
@@ -684,10 +710,18 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
LOG.assertTrue(success);
|
||||
}
|
||||
|
||||
public void markDirtied() {
|
||||
public void markDirtied(int startOffset, int endOffset) {
|
||||
myEditorScrollbarTop = -1;
|
||||
myEditorSourceHeight = -1;
|
||||
myEditorTargetHeight = -1;
|
||||
|
||||
final TextRange range = TextRange.create(startOffset, endOffset);
|
||||
if (myDirtyRange == null) {
|
||||
myDirtyRange = range;
|
||||
}
|
||||
else {
|
||||
myDirtyRange = myDirtyRange.union(range);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMinMarkHeight(final int minMarkHeight) {
|
||||
|
||||
@@ -14,11 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.openapi.updateSettings.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.BuildNumber;
|
||||
@@ -31,12 +29,16 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class BuildInfo implements Comparable<BuildInfo> {
|
||||
private final BuildNumber myNumber;
|
||||
private final String myVersion;
|
||||
private final String myMessage;
|
||||
private final Date myReleaseDate;
|
||||
private final List<PatchInfo> myPatches;
|
||||
private final List<ButtonInfo> myButtons;
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.updateSettings.impl.BuildInfo");
|
||||
|
||||
@@ -60,6 +62,11 @@ public class BuildInfo implements Comparable<BuildInfo> {
|
||||
for (Object patchNode : node.getChildren("patch")) {
|
||||
myPatches.add(new PatchInfo((Element)patchNode));
|
||||
}
|
||||
|
||||
myButtons = new ArrayList<ButtonInfo>();
|
||||
for (Object buttonNode : node.getChildren("button")) {
|
||||
myButtons.add(new ButtonInfo((Element) buttonNode));
|
||||
}
|
||||
|
||||
Element messageTag = node.getChild("message");
|
||||
myMessage = messageTag != null ? messageTag.getValue() : "";
|
||||
@@ -94,6 +101,10 @@ public class BuildInfo implements Comparable<BuildInfo> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ButtonInfo> getButtons() {
|
||||
return ImmutableList.copyOf(myButtons);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BuildInfo(number=" + myNumber + ")";
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.updateSettings.impl;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class ButtonInfo {
|
||||
private final String myName;
|
||||
private final String myUrl;
|
||||
|
||||
public ButtonInfo(Element element) {
|
||||
myName = element.getAttributeValue("name");
|
||||
myUrl = element.getAttributeValue("url");
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return myUrl;
|
||||
}
|
||||
}
|
||||
+28
-8
@@ -51,7 +51,7 @@ public class PluginDownloader {
|
||||
@NonNls private static final String FILENAME = "filename=";
|
||||
|
||||
private final String myPluginId;
|
||||
private final String myPluginUrl;
|
||||
private String myPluginUrl;
|
||||
private String myPluginVersion;
|
||||
|
||||
private String myFileName;
|
||||
@@ -197,14 +197,9 @@ public class PluginDownloader {
|
||||
|
||||
pi.setText(IdeBundle.message("progress.connecting"));
|
||||
|
||||
final URLConnection connection = new URL(myPluginUrl).openConnection();
|
||||
URLConnection connection = null;
|
||||
try {
|
||||
if (connection instanceof HttpURLConnection) {
|
||||
final int responseCode = ((HttpURLConnection)connection).getResponseCode();
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
throw new IOException(IdeBundle.message("error.connection.failed.with.http.code.N", responseCode));
|
||||
}
|
||||
}
|
||||
connection = openConnection(myPluginUrl);
|
||||
|
||||
final InputStream is = UrlConnectionUtil.getConnectionInputStream(connection, pi);
|
||||
if (is == null) {
|
||||
@@ -243,6 +238,31 @@ public class PluginDownloader {
|
||||
}
|
||||
}
|
||||
|
||||
private URLConnection openConnection(String url) throws IOException {
|
||||
final URLConnection connection = new URL(url).openConnection();
|
||||
if (connection instanceof HttpURLConnection) {
|
||||
final int responseCode = ((HttpURLConnection)connection).getResponseCode();
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
String location = null;
|
||||
if (responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP) {
|
||||
location = connection.getHeaderField("Location");
|
||||
}
|
||||
if (location == null) {
|
||||
throw new IOException(IdeBundle.message("error.connection.failed.with.http.code.N", responseCode));
|
||||
} else {
|
||||
setPluginUrl(location);
|
||||
((HttpURLConnection)connection).disconnect();
|
||||
return openConnection(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
private void setPluginUrl(String location) {
|
||||
myPluginUrl = location;
|
||||
}
|
||||
|
||||
private void guessFileName(final URLConnection connection, final File file) throws IOException {
|
||||
String contentDisposition = connection.getHeaderField("Content-Disposition");
|
||||
if (contentDisposition == null || !contentDisposition.contains(FILENAME)) {
|
||||
|
||||
+57
-17
@@ -27,6 +27,7 @@ import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -49,23 +50,40 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
|
||||
|
||||
@Override
|
||||
protected Action[] createActions() {
|
||||
AbstractAction ignore = new AbstractAction("&Ignore This Update") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
UpdateSettings.getInstance().getIgnoredBuildNumbers().add(myLatestBuild.getNumber().asStringWithoutProductCode());
|
||||
doCancelAction();
|
||||
}
|
||||
};
|
||||
if (hasPatch()) {
|
||||
AbstractAction moreInfo = new AbstractAction(IdeBundle.message("updates.more.info.button")) {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
openDownloadPage();
|
||||
}
|
||||
};
|
||||
return new Action[]{getOKAction(), moreInfo, getCancelAction(), ignore };
|
||||
}
|
||||
List<Action> actions = new ArrayList<Action>();
|
||||
actions.add(getOKAction());
|
||||
|
||||
return new Action[] { getOKAction(), getCancelAction(), ignore };
|
||||
final List<ButtonInfo> buttons = myLatestBuild.getButtons();
|
||||
|
||||
if (hasPatch()) {
|
||||
if (buttons.isEmpty()) {
|
||||
actions.add(new AbstractAction(IdeBundle.message("updates.more.info.button")) {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
openDownloadPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
for (ButtonInfo info : buttons) {
|
||||
actions.add(new ButtonAction(info));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = 1; i < buttons.size(); i++) {
|
||||
actions.add(new ButtonAction(buttons.get(i)));
|
||||
}
|
||||
}
|
||||
actions.add(getCancelAction());
|
||||
actions.add(new AbstractAction("&Ignore This Update") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
UpdateSettings.getInstance().getIgnoredBuildNumbers().add(myLatestBuild.getNumber().asStringWithoutProductCode());
|
||||
doCancelAction();
|
||||
}
|
||||
});
|
||||
|
||||
return actions.toArray(new Action[buttons.size()]);
|
||||
}
|
||||
|
||||
private void openDownloadPage() {
|
||||
@@ -78,6 +96,9 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
|
||||
? IdeBundle.message("updates.download.and.install.patch.button.restart")
|
||||
: IdeBundle.message("updates.download.and.install.patch.button");
|
||||
}
|
||||
else if (myLatestBuild.getButtons().size() > 0) {
|
||||
return myLatestBuild.getButtons().get(0).getName();
|
||||
}
|
||||
else {
|
||||
return IdeBundle.message("updates.more.info.button");
|
||||
}
|
||||
@@ -100,7 +121,12 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
|
||||
return;
|
||||
}
|
||||
|
||||
openDownloadPage();
|
||||
if (myLatestBuild.getButtons().size() > 0) {
|
||||
BrowserUtil.launchBrowser(myLatestBuild.getButtons().get(0).getUrl());
|
||||
}
|
||||
else {
|
||||
openDownloadPage();
|
||||
}
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
@@ -124,6 +150,20 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
|
||||
private boolean hasPatch() {
|
||||
return myLatestBuild.findPatchForCurrentBuild() != null;
|
||||
}
|
||||
|
||||
private static class ButtonAction extends AbstractAction {
|
||||
private ButtonInfo myInfo;
|
||||
|
||||
private ButtonAction(ButtonInfo info) {
|
||||
super(info.getName());
|
||||
myInfo = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
BrowserUtil.launchBrowser(myInfo.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
private class UpdateInfoPanel {
|
||||
private JPanel myPanel;
|
||||
|
||||
@@ -218,7 +218,7 @@ public final class WindowManagerImpl extends WindowManagerEx implements Applicat
|
||||
myProject2Frame.put(null, frame);
|
||||
|
||||
if (myFrameBounds == null
|
||||
|| !ScreenUtil.getScreenBounds().contains(myFrameBounds)) { //avoid situations when IdeFrame is out of all screens
|
||||
|| !ScreenUtil.isVisible(myFrameBounds)) { //avoid situations when IdeFrame is out of all screens
|
||||
Rectangle rect = ScreenUtil.getScreenRectangle(0, 0);
|
||||
int yParts = rect.height / 6;
|
||||
int xParts = rect.width / 5;
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.mac.foundation.Foundation;
|
||||
import com.intellij.ui.mac.foundation.ID;
|
||||
import com.intellij.ui.mac.foundation.MacUtil;
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Pointer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -139,7 +140,7 @@ public class MacFileChooserDialogImpl implements MacFileChooserDialog {
|
||||
activeWindowTitle = ((JDialog)activeWindow).getTitle();
|
||||
}
|
||||
|
||||
final ID focusedWindow = MacMainFrameDecorator.findWindowForTitle(activeWindowTitle);
|
||||
final ID focusedWindow = MacUtil.findWindowForTitle(activeWindowTitle);
|
||||
if (focusedWindow != null) {
|
||||
invoke(chooser, "beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:",
|
||||
directory, file, null, focusedWindow, self, Foundation.createSelector("openPanelDidEnd:returnCode:contextInfo:"), null);
|
||||
|
||||
@@ -23,17 +23,16 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.ui.mac.foundation.Foundation;
|
||||
import com.intellij.ui.mac.foundation.ID;
|
||||
import com.intellij.ui.mac.foundation.MacUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.sun.jna.Callback;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.intellij.ui.mac.foundation.Foundation.invoke;
|
||||
import static com.intellij.ui.mac.foundation.Foundation.toStringViaUTF8;
|
||||
|
||||
/**
|
||||
* User: spLeaner
|
||||
@@ -95,7 +94,7 @@ public class MacMainFrameDecorator implements UISettingsListener, Disposable {
|
||||
private Callback myDidEnter;
|
||||
|
||||
public MacMainFrameDecorator(@NotNull final Frame frame, final boolean navBar) {
|
||||
final ID window = findWindowForTitle(frame.getTitle());
|
||||
final ID window = MacUtil.findWindowForTitle(frame.getTitle());
|
||||
if (window == null) return;
|
||||
|
||||
if (CURRENT_SETTER == null) {
|
||||
@@ -212,7 +211,7 @@ public class MacMainFrameDecorator implements UISettingsListener, Disposable {
|
||||
public static void toggleFullScreen(Frame frame) {
|
||||
if (!SystemInfo.isMacOSLion) return;
|
||||
|
||||
final ID window = findWindowForTitle(frame.getTitle());
|
||||
final ID window = MacUtil.findWindowForTitle(frame.getTitle());
|
||||
if (window == null) return;
|
||||
|
||||
invoke(window, "toggleFullScreen:", window);
|
||||
@@ -221,45 +220,11 @@ public class MacMainFrameDecorator implements UISettingsListener, Disposable {
|
||||
public static boolean isFullScreenMode(@NotNull Frame frame) {
|
||||
if (!SystemInfo.isMacOSLion) return false;
|
||||
|
||||
final ID window = findWindowForTitle(frame.getTitle());
|
||||
final ID window = MacUtil.findWindowForTitle(frame.getTitle());
|
||||
if (window == null) return false;
|
||||
|
||||
final ID mask = invoke(window, "styleMask");
|
||||
return (mask.intValue() & (1 << 14)) == (1 << 14);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ID findWindowForTitle(final String title) {
|
||||
if (title == null || title.length() == 0) return null;
|
||||
final ID pool = invoke("NSAutoreleasePool", "new");
|
||||
|
||||
ID focusedWindow = null;
|
||||
try {
|
||||
final ID sharedApplication = invoke("NSApplication", "sharedApplication");
|
||||
final ID windows = invoke(sharedApplication, "windows");
|
||||
final ID windowEnumerator = invoke(windows, "objectEnumerator");
|
||||
|
||||
while (true) {
|
||||
// dirty hack: walks through all the windows to find a cocoa window to show sheet for
|
||||
final ID window = invoke(windowEnumerator, "nextObject");
|
||||
if (0 == window.intValue()) break;
|
||||
|
||||
final ID windowTitle = invoke(window, "title");
|
||||
if (windowTitle != null && windowTitle.intValue() != 0) {
|
||||
final String titleString = toStringViaUTF8(windowTitle);
|
||||
if (titleString.equals(title)) {
|
||||
if (1 == invoke(window, "isVisible").intValue()) {
|
||||
focusedWindow = window;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
invoke(pool, "release");
|
||||
}
|
||||
|
||||
return focusedWindow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
error.invalid.installation.home=Unable to import settings. ''{0}'' doesn''t appear to be valid {1} installation home.
|
||||
error.invalid.config.folder=Unable to import settings. ''{0}'' doesn''t appear to be valid {1} config folder.
|
||||
error.no.settings.path=Unable to import settings. {0} does not exist.
|
||||
title.settings.import.failed=Settings Import Failed
|
||||
error.unable.to.import.settings=Unable to import settings. {0}
|
||||
title.complete.installation=Complete Installation
|
||||
title.installation.home.required=Installation Home Required
|
||||
error.please.select.previous.installation.home=Please select previous {0} installation home
|
||||
title.installation.home.required=Config Folder or Installation Home Required
|
||||
error.please.select.previous.installation.home=Please select previous {0} config folder or installation home
|
||||
error.selected.current.installation.home=You have selected current {0} installation home.\nPlease select previous {1} installation home
|
||||
error.does.not.appear.to.be.installation.home={0} does not appear to be {1} installation home
|
||||
error.does.not.appear.to.be.installation.home={0} does not appear to be {1} config folder or installation home
|
||||
error.no.read.permissions=You do not have read permissions to {0}
|
||||
radio.do.not.import=I do not have a previous version of {0} or I do not want to import my settings
|
||||
radio.import=I want to import my settings
|
||||
radio.import.auto=I want to import my settings from previous version ({0})
|
||||
radio.import=I want to import my settings from custom location
|
||||
label.you.can.import=You can import your settings from the previous version of {0}.
|
||||
button.ok=OK
|
||||
editbox.installation.home=Specify installation home of the previous version of {0}
|
||||
editbox.installation.home=Specify config folder or installation home of the previous version of {0}
|
||||
title.code.completion=Code Completion
|
||||
editbox.lookup.height=Lookup height (items):
|
||||
editbox.autopopup.javadoc.in.ms=Autopopup documentation in (ms):
|
||||
|
||||
@@ -146,8 +146,8 @@ junit.tests.in.progress.label=Tests in Progress
|
||||
junit.auto.scroll.to.source.action.name=Auto Scroll to Source
|
||||
junit.open.text.in.editor.action.name=Open selected test in editor
|
||||
|
||||
run.configuration.java.vm.parameters.label=&VM parameters:
|
||||
run.configuration.program.parameters=Program pa&rameters:
|
||||
run.configuration.java.vm.parameters.label=&VM options:
|
||||
run.configuration.program.parameters=Program a&rguments:
|
||||
run.configuration.working.directory.label=&Working directory:
|
||||
run.configuration.use.alternate.jre.checkbox=Use alternative &JRE:
|
||||
run.configuration.select.alternate.jre.label=Select Alternative JRE
|
||||
@@ -175,7 +175,7 @@ applet.configuration.width.label= &Width:
|
||||
applet.configuration.url.html.file.label=URL/HTML &file:
|
||||
applet.configuration.url.border=URL
|
||||
applet.configuration.use.classpath.and.jdk.of.module.label=Use classpath and JDK of m&odule:
|
||||
applet.configuration.vm.parameters.for.appletviewer.label=&VM parameters for appletviewer:
|
||||
applet.configuration.vm.parameters.for.appletviewer.label=&VM options for appletviewer:
|
||||
applet.configuration.policy.file.label=&Policy file:
|
||||
applet.configuration.parameter.name.column=Name
|
||||
applet.configuration.parameter.value.column=Value
|
||||
|
||||
@@ -218,7 +218,7 @@ select.in.project=Project
|
||||
select.in.nav.bar = Navigation Bar
|
||||
error.adding.module.to.project=Error adding module to project: {0}
|
||||
title.add.module=Add Module
|
||||
prompt.open.project.in.new.frame=<html><body>New projects can either be opened in a new window or replace the project in the existing window.<br>How would you like to open the project?</body></html>?
|
||||
prompt.open.project.in.new.frame=<html><body>New projects can either be opened in a new window or replace the project in the existing window.<br>How would you like to open the project?</body></html>
|
||||
title.new.project=New Project
|
||||
button.newframe=New &Window
|
||||
button.existingframe=&This Window
|
||||
@@ -470,6 +470,7 @@ macro.prompt=Displays a string input dialog
|
||||
prompt.enter.parameters=Enter parameters:
|
||||
title.input=Input
|
||||
macro.prompt.preview=<params>
|
||||
macro.fileprompt.preview=<filename>
|
||||
macro.sourcepath.entry=Entry in the sourcepath the element belongs to
|
||||
macro.project.sourcepath=Project's sourcepath
|
||||
error.plugins.should.not.have.cyclic.dependencies=Plugins should not have cyclic dependencies:\n
|
||||
|
||||
@@ -52,7 +52,9 @@ usage.target.xml.tag.of.file={0} of file {1}
|
||||
usage.target.package.in.directory={0} (in {1})
|
||||
usage.target.exception=Exception
|
||||
usage.type.new=New instance creation
|
||||
usage.type.new.array=New array creation
|
||||
usage.type.annotation=Annotation
|
||||
usage.type.type.parameter=Type parameter
|
||||
usage.type.read=Value read
|
||||
usage.type.write=Value write
|
||||
preview.usages.action.text=Preview Usages
|
||||
|
||||
@@ -286,7 +286,8 @@
|
||||
|
||||
<statementUpDownMover implementation="com.intellij.codeInsight.editorActions.moveUpDown.XmlMover" id="xml" order="before line"/>
|
||||
|
||||
<webBrowserUrlProvider implementation="com.intellij.ide.browsers.HtmlWebBrowserUrlProvider" id="static" order="last"/>
|
||||
<applicationService serviceInterface="com.intellij.ide.browsers.WebBrowserService"
|
||||
serviceImplementation="com.intellij.ide.browsers.impl.WebBrowserServiceImpl"/>
|
||||
|
||||
<patterns.patternClass className="com.intellij.patterns.XmlPatterns" alias="xml"/>
|
||||
|
||||
|
||||
@@ -733,6 +733,9 @@
|
||||
<action id="ActivateProjectToolWindow">
|
||||
<keyboard-shortcut first-keystroke="alt 1"/>
|
||||
</action>
|
||||
<action id="ActivateFavoritesToolWindow">
|
||||
<keyboard-shortcut first-keystroke="alt 2"/>
|
||||
</action>
|
||||
<action id="ActivateFindToolWindow">
|
||||
<keyboard-shortcut first-keystroke="alt 3"/>
|
||||
</action>
|
||||
@@ -748,7 +751,7 @@
|
||||
<action id="ActivateStructureToolWindow">
|
||||
<keyboard-shortcut first-keystroke="alt 7"/>
|
||||
</action>
|
||||
<action id="ActivateFavoritesToolWindow">
|
||||
<action id="ActivateHierarchyToolWindow">
|
||||
<keyboard-shortcut first-keystroke="alt 8"/>
|
||||
</action>
|
||||
<action id="ActivateChangesToolWindow">
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
<action id="ActivateProjectToolWindow">
|
||||
<keyboard-shortcut first-keystroke="meta 1"/>
|
||||
</action>
|
||||
<action id="ActivateCommanderToolWindow">
|
||||
<action id="ActivateFavoritesToolWindow">
|
||||
<keyboard-shortcut first-keystroke="meta 2"/>
|
||||
</action>
|
||||
<action id="ActivateFindToolWindow">
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
<action id="ActivateProjectToolWindow">
|
||||
<keyboard-shortcut first-keystroke="meta 1"/>
|
||||
</action>
|
||||
<action id="ActivateCommanderToolWindow">
|
||||
<action id="ActivateFavoritesToolWindow">
|
||||
<keyboard-shortcut first-keystroke="meta 2"/>
|
||||
</action>
|
||||
<action id="ActivateFindToolWindow">
|
||||
|
||||
@@ -344,6 +344,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
|
||||
myPresentation.getScopeText());
|
||||
|
||||
if (notFoundActions == null || notFoundActions.isEmpty()) {
|
||||
//noinspection SSBasedInspection
|
||||
ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.FIND, MessageType.INFO,
|
||||
XmlStringUtil.escapeString(message),
|
||||
IconLoader.getIcon("/actions/find.png"), null);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user