diff --git a/bin/nix/idea.sh b/bin/nix/idea.sh old mode 100644 new mode 100755 index 941b392455aa..cf3b52de4e7e --- a/bin/nix/idea.sh +++ b/bin/nix/idea.sh @@ -26,7 +26,11 @@ if [ -z "$IDEA_JDK" ]; then fi if [ -z "$IDEA_JDK" ]; then echo ERROR: cannot start IntelliJ IDEA. - echo No JDK found to run IDEA. Please validate either IDEA_JDK or JDK_HOME points to valid JDK installation + echo No JDK found to run IDEA. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME points to valid JDK installation. + echo + echo Press Enter to continue. + read IGNORE + exit 1 fi fi @@ -36,7 +40,7 @@ grep 'OpenJDK' $VERSION_LOG OPEN_JDK=$? grep '64-Bit' $VERSION_LOG BITS=$? -rm /tmp/java.version.log +rm $VERSION_LOG if [ $OPEN_JDK -eq 0 ]; then echo WARNING: You are launching IDE using OpenJDK Java runtime echo @@ -84,7 +88,7 @@ fi REQUIRED_JVM_ARGS="-Xbootclasspath/a:../lib/boot.jar $IDEA_PROPERTIES_PROPERTY $REQUIRED_JVM_ARGS" JVM_ARGS=`tr '\n' ' ' < "$IDEA_VM_OPTIONS"` -JVM_ARGS="$JVM_ARGS $REQUIRED_JVM_ARGS" +JVM_ARGS=`eval echo $JVM_ARGS $REQUIRED_JVM_ARGS` CLASSPATH=../lib/bootstrap.jar CLASSPATH=$CLASSPATH:../lib/util.jar diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesCompiler.java b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesCompiler.java index 5ab1b1d9b67d..8f609405b3cc 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesCompiler.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/javaCompiler/jikes/JikesCompiler.java @@ -159,7 +159,7 @@ public class JikesCompiler extends ExternalCompiler { private void _createStartupCommand(final ModuleChunk chunk, final ArrayList commandLine, @NotNull final String outputPath) throws IOException { - myTempFile = File.createTempFile("jikes", ".tmp"); + myTempFile = FileUtil.createTempFile("jikes", ".tmp"); myTempFile.deleteOnExit(); final List files = chunk.getFilesToCompile(); diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/BuildInstructionBase.java b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/BuildInstructionBase.java index e1d89bcb482b..446dd2e37b28 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/BuildInstructionBase.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/BuildInstructionBase.java @@ -21,6 +21,7 @@ package com.intellij.compiler.impl.packagingCompiler; import com.intellij.openapi.compiler.make.BuildInstruction; import com.intellij.openapi.util.UserDataHolderBase; +import com.intellij.openapi.util.io.FileUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; @@ -64,8 +65,8 @@ public abstract class BuildInstructionBase extends UserDataHolderBase implements } protected File createTempFile(final String prefix, final String suffix) throws IOException { - final File tempFile = File.createTempFile(prefix +"___",suffix); + final File tempFile = FileUtil.createTempFile(prefix + "___", suffix); addFileToDelete(tempFile); return tempFile; } -} \ No newline at end of file +} diff --git a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java index 337381cb564f..0ba8dbf392ce 100644 --- a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java +++ b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java @@ -583,7 +583,7 @@ public class CompilerTask extends Task.Backgroundable { connection.subscribe(CompilerTopics.COMPILATION_STATUS, new CompilationStatusListener() { public void compilationFinished(boolean aborted, int errors, int warnings, final CompileContext compileContext) { connection.disconnect(); - ProjectUtil.closeProject(project); + ProjectUtil.closeAndDispose(project); } }); cancel(); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/RunHotswapDialog.java b/java/debugger/impl/src/com/intellij/debugger/ui/RunHotswapDialog.java index 9f7f8b47202c..7172f4f0bf6a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/RunHotswapDialog.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/RunHotswapDialog.java @@ -105,7 +105,7 @@ public class RunHotswapDialog extends OptionsDialog { JLabel label = new JLabel(DebuggerBundle.message("hotswap.dialog.run.prompt")); JPanel panel = new JPanel(new BorderLayout()); panel.add(label, BorderLayout.CENTER); - Icon icon = UIUtil.getOptionPanelQuestionIcon(); + Icon icon = UIUtil.getQuestionIcon(); if (icon != null) { label.setIcon(icon); label.setIconTextGap(7); diff --git a/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/EvaluateException.java b/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/EvaluateException.java index 3fbef4ddfc15..30dac08cc738 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/EvaluateException.java +++ b/java/debugger/openapi/src/com/intellij/debugger/engine/evaluation/EvaluateException.java @@ -53,4 +53,17 @@ public class EvaluateException extends Exception { public void setTargetException(final ObjectReference targetException) { myTargetException = targetException; } + + public String getMessage() { + final String errorMessage = super.getMessage(); + if (errorMessage != null) { + return errorMessage; + } + final Throwable cause = getCause(); + final String causeMessage = cause != null? cause.getMessage() : null; + if (causeMessage != null) { + return causeMessage; + } + return "unknown error"; + } } \ No newline at end of file diff --git a/java/execution/impl/src/com/intellij/execution/applet/AppletConfiguration.java b/java/execution/impl/src/com/intellij/execution/applet/AppletConfiguration.java index a1b83928a58d..d6921529547e 100644 --- a/java/execution/impl/src/com/intellij/execution/applet/AppletConfiguration.java +++ b/java/execution/impl/src/com/intellij/execution/applet/AppletConfiguration.java @@ -32,6 +32,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.DefaultJDOMExternalizer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; @@ -301,7 +302,7 @@ public class AppletConfiguration extends ModuleBasedConfiguration\n" + diff --git a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilter.java b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilter.java index 766a6bd8e9f0..157402578f4b 100644 --- a/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilter.java +++ b/java/execution/openapi/src/com/intellij/execution/filters/ExceptionFilter.java @@ -129,7 +129,7 @@ public class ExceptionFilter implements Filter, DumbAware { final OpenFileHyperlinkInfo linkInfo = new OpenFileHyperlinkInfo(myProject, virtualFile, lineNumber - 1); TextAttributes attributes = HYPERLINK_ATTRIBUTES.clone(); if (!ProjectRootManager.getInstance(myProject).getFileIndex().isInContent(virtualFile)) { - Color color = UIUtil.getTextInactiveTextColor(); + Color color = UIUtil.getInactiveTextColor(); attributes.setForegroundColor(color); attributes.setEffectColor(color); } diff --git a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java index 38821aa31838..46b163c9c780 100644 --- a/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java +++ b/java/idea-ui/src/com/intellij/ide/impl/NewProjectUtil.java @@ -197,7 +197,7 @@ public class NewProjectUtil { Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption()); } if (exitCode == 1) { // "No" option - ProjectUtil.closeProject(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1]); + ProjectUtil.closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1]); } } } diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/AbstractStepWithProgress.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/AbstractStepWithProgress.java index fe882f9c49d5..dfe7601da4f9 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/AbstractStepWithProgress.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/AbstractStepWithProgress.java @@ -75,7 +75,7 @@ public abstract class AbstractStepWithProgress extends ModuleWizardStep private JPanel createProgressPanel() { final JPanel progressPanel = new JPanel(new GridBagLayout()); myTitleLabel = new JLabel(); - myTitleLabel.setFont(UIManager.getFont("Label.font").deriveFont(Font.BOLD)); + myTitleLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD)); progressPanel.add(myTitleLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 5, 10), 0, 0)); myProgressLabel = new JLabel(); diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/NameLocationStep.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/NameLocationStep.java index a653e128a42e..3fd71a17784c 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/NameLocationStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/NameLocationStep.java @@ -81,7 +81,6 @@ public class NameLocationStep extends ModuleWizardStep { myPanel.add(myNamePathComponent, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(8, 10, 0, 10), 0, 0)); final JLabel label = new JLabel(IdeBundle.message("label.module.file.will.be.saved.in")); - //label.setFont(UIManager.getFont("Label.font").deriveFont(Font.BOLD)); myPanel.add(label, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(30, 10, 0, 10), 0, 0)); myTfModuleFilePath = new JTextField(); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java index c2f17a08ec6c..341ca35c2761 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java @@ -524,8 +524,9 @@ public class ConfigurationErrorsComponent extends JPanel implements Disposable, if (myModel.getSize() == 0) { setBorder(null); } else { - if (getBorder() == null) setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(5, 0, 5, 0, UIUtil.getPanelBackground()), - BorderFactory.createLineBorder(UIUtil.getPanelBackgound().darker()))); + if (getBorder() == null) setBorder( + BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(5, 0, 5, 0, UIUtil.getPanelBackground()), + BorderFactory.createLineBorder(UIUtil.getPanelBackground().darker()))); } final List errors = myModel.getErrors(); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java index 8af238b834d5..59e25af14f35 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java @@ -60,6 +60,7 @@ import java.util.List; @SuppressWarnings({"AssignmentToStaticFieldFromInstanceMethod"}) public abstract class ModuleEditor implements Place.Navigator, Disposable { + public static final String MODULE_TAB = "moduleTab"; private final Project myProject; private JPanel myGenericSettingsPanel; private ModifiableRootModel myModifiableRootModel; // important: in order to correctly update OrderEntries UI use corresponding proxy for the model @@ -246,12 +247,12 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { } public ActionCallback navigateTo(@Nullable final Place place, final boolean requestFocus) { - myTabbedPane.setSelectedTitle((String)place.getPath("moduleTab")); + myTabbedPane.setSelectedTitle((String)place.getPath(MODULE_TAB)); return new ActionCallback.Done(); } public void queryPlace(@NotNull final Place place) { - place.putPath("moduleTab", ourSelectedTabName); + place.putPath(MODULE_TAB, ourSelectedTabName); } public static String getSelectedTab(){ diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java index fac45969b2a7..63132c974ee3 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java @@ -359,7 +359,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se if (moduleToSelect != null) { final Module module = ModuleManager.getInstance(myProject).findModuleByName(moduleToSelect); assert module != null; - place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, module); + place = place.putPath(ModuleStructureConfigurable.TREE_OBJECT, module).putPath(ModuleEditor.MODULE_TAB, tab); } return navigateTo(place, requestFocus); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseStructureConfigurable.java index 91f15189e5d4..eb3973368615 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseStructureConfigurable.java @@ -193,7 +193,7 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i final boolean invalid = level != null; if (unused || invalid) { Color fg = unused - ? UIUtil.getTextInactiveTextColor() + ? UIUtil.getInactiveTextColor() : selected && hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeForeground(); textAttributes = new SimpleTextAttributes(invalid ? SimpleTextAttributes.STYLE_WAVED : SimpleTextAttributes.STYLE_PLAIN, fg, level == ProjectStructureProblemDescription.Severity.ERROR ? Color.RED : Color.GRAY); diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java index ec37e90cb4e1..db305fd58e56 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java @@ -40,6 +40,7 @@ import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.ex.PathUtilEx; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; @@ -250,7 +251,7 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl } try { - File sourcepathTempFile = File.createTempFile("javadoc", "args.txt"); + File sourcepathTempFile = FileUtil.createTempFile("javadoc", "args.txt"); sourcepathTempFile.deleteOnExit(); parameters.add("@" + sourcepathTempFile.getCanonicalPath()); final PrintWriter writer = new PrintWriter(new FileWriter(sourcepathTempFile)); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java index 0c4a38e000ec..276c6771dc4f 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java @@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.codeStyle.CodeStyleSettings; @@ -468,7 +469,7 @@ public class ImportHelper{ return array; } - private static PsiClass findSingleImportByShortName(@NotNull PsiJavaFile file, @NotNull String shortClassName){ + private static PsiClass findSingleImportByShortName(@NotNull final PsiJavaFile file, @NotNull String shortClassName){ PsiClass[] refs = file.getSingleClassImports(true); for (PsiClass ref : refs) { String className = ref.getQualifiedName(); @@ -482,6 +483,33 @@ public class ImportHelper{ return aClass; } } + + // there maybe a class imported implicitly from current package + String packageName = file.getPackageName(); + if (!StringUtil.isEmptyOrSpaces(packageName)) { + String fqn = packageName + "." + shortClassName; + final PsiClass aClass = JavaPsiFacade.getInstance(file.getProject()).findClass(fqn, file.getResolveScope()); + if (aClass != null) { + final boolean[] foundRef = {false}; + // check if that short name referenced in the file + file.accept(new JavaRecursiveElementWalkingVisitor() { + @Override + public void visitElement(PsiElement element) { + if (foundRef[0]) return; + super.visitElement(element); + } + + @Override + public void visitReferenceElement(PsiJavaCodeReferenceElement reference) { + if (file.getManager().areElementsEquivalent(reference.resolve(), aClass)) { + foundRef[0] = true; + } + super.visitReferenceElement(reference); + } + }); + if (foundRef[0]) return aClass; + } + } return null; } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java index b5dc13ba4f83..c8c42e8440f0 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java @@ -462,8 +462,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme final IntroduceVariableSettings settings = getSettings(project, editor, expr, occurrences, typeSelectorManager, inFinalContext, hasWriteAccess, validator, choice); if (!settings.isOK()) return; + typeSelectorManager.setAllOccurences(choice != OccurrencesChooser.ReplaceChoice.NO); final RangeMarker exprMarker = editor.getDocument().createRangeMarker(expr.getTextRange()); - final SuggestedNameInfo suggestedName = getSuggestedName(typeSelectorManager.getDefaultType(), expr); + final SuggestedNameInfo suggestedName = getSuggestedName(settings.getSelectedType(), expr); final Runnable runnable = introduce(project, expr, editor, anchorStatement, tempContainer, occurrences, anchorStatementIfAll, settings, variable); CommandProcessor.getInstance().executeCommand( @@ -501,6 +502,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme editor.getCaretModel().moveToOffset(startOffset); } editor.putUserData(ReassignVariableUtil.DECLARATION_KEY, null); + typeSelectorManager.typeSelected(ReassignVariableUtil.getVariableType(declarationStatement)); exprMarker.dispose(); } }); @@ -816,7 +818,8 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase impleme @Override public PsiType getSelectedType() { - return typeSelectorManager.getDefaultType(); + final PsiType selectedType = typeSelectorManager.getTypeSelector().getSelectedType(); + return selectedType != null ? selectedType : typeSelectorManager.getDefaultType(); } @Override diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java index 9e76662587ed..aab01479d103 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/ReassignVariableUtil.java @@ -14,6 +14,7 @@ package com.intellij.refactoring.introduceVariable; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; +import com.intellij.codeInsight.lookup.PsiTypeLookupItem; import com.intellij.codeInsight.template.Expression; import com.intellij.codeInsight.template.ExpressionContext; import com.intellij.codeInsight.template.TextResult; @@ -97,7 +98,7 @@ public class ReassignVariableUtil { } @Nullable - private static PsiType getVariableType(@Nullable PsiDeclarationStatement declaration) { + static PsiType getVariableType(@Nullable PsiDeclarationStatement declaration) { if (declaration != null) { final PsiElement[] declaredElements = declaration.getDeclaredElements(); if (declaredElements.length > 0 && declaredElements[0] instanceof PsiVariable) { @@ -167,7 +168,7 @@ public class ReassignVariableUtil { public LookupElement[] calculateLookupItems(ExpressionContext context) { LookupElement[] result = new LookupElement[types.length]; for (int i = 0, typesLength = types.length; i < typesLength; i++) { - result[i] = LookupElementBuilder.create(types[i], types[i].getPresentableText()); + result[i] = PsiTypeLookupItem.createLookupItem(types[i], null); } return result; } diff --git a/java/java-impl/src/com/intellij/refactoring/ui/InfoDialog.java b/java/java-impl/src/com/intellij/refactoring/ui/InfoDialog.java index e553bef0747f..c20ade157515 100644 --- a/java/java-impl/src/com/intellij/refactoring/ui/InfoDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/ui/InfoDialog.java @@ -65,7 +65,7 @@ public class InfoDialog extends DialogWrapper{ myTextArea = new JTextArea(myText); textPanel.add(myTextArea, BorderLayout.CENTER); myTextArea.setEditable(false); - myTextArea.setBackground(UIUtil.getPanelBackgound()); + myTextArea.setBackground(UIUtil.getPanelBackground()); Font font = myShowInFutureCheckBox.getFont(); font = new Font(font.getName(), font.getStyle(), font.getSize() + 1); myTextArea.setFont(font); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java index 865742929ad6..9570f743409f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java @@ -150,8 +150,8 @@ public class ImportHelperTest extends DaemonAnalyzerTestCase { ImportHelper importHelper = new ImportHelper(settings); PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass(fqn, GlobalSearchScope.allScope(getProject())); - boolean b = importHelper.addImport(file, psiClass); - assertTrue(b); + boolean b = importHelper.addImport(file, psiClass); + assertTrue(b); assertOrder(file, expectedOrder); } @@ -193,6 +193,22 @@ public class ImportHelperTest extends DaemonAnalyzerTestCase { String text = LoadTextUtil.loadText(vFile).toString(); assertEquals(text, getFile().getText()); } + public void testConflictingClassesFromCurrentPackage() throws Throwable { + final PsiFile file = configureByText(StdFileTypes.JAVA, "package java.util; class X{ Date d;}"); + assertEmpty(filter(doHighlighting(), HighlightSeverity.ERROR)); + + new WriteCommandAction.Simple(getProject()) { + @Override + protected void run() throws Throwable { + CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()); + ImportHelper importHelper = new ImportHelper(settings); + + PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass("java.sql.Date", GlobalSearchScope.allScope(getProject())); + boolean b = importHelper.addImport((PsiJavaFile)file, psiClass); + assertFalse(b); // must fail + } + }.execute().throwException(); + } @DoNotWrapInCommand public void testAutoImportCaretLocation() throws Throwable { diff --git a/java/java-tests/testSrc/com/intellij/psi/impl/cache/impl/SCR17650Test.java b/java/java-tests/testSrc/com/intellij/psi/impl/cache/impl/SCR17650Test.java index aaea88bb78a1..634f37e0bb2e 100644 --- a/java/java-tests/testSrc/com/intellij/psi/impl/cache/impl/SCR17650Test.java +++ b/java/java-tests/testSrc/com/intellij/psi/impl/cache/impl/SCR17650Test.java @@ -7,6 +7,7 @@ import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -27,7 +28,7 @@ public class SCR17650Test extends PsiTestCase { protected void setUp() throws Exception { super.setUp(); - final File root = File.createTempFile(getName(), ""); + final File root = FileUtil.createTempFile(getName(), ""); root.delete(); root.mkdir(); myFilesToDelete.add(root); diff --git a/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java b/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java index c5951a3c292b..52b7973ad1f8 100644 --- a/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java @@ -12,6 +12,7 @@ import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.impl.ModuleRootManagerImpl; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.ModuleTestCase; @@ -42,7 +43,7 @@ public class ModuleRootsExternalizationTest extends ModuleTestCase { } private ModuleRootManagerImpl createTempModuleRootManager() throws IOException { - File tmpModule = File.createTempFile("tst", ModuleFileType.DOT_DEFAULT_EXTENSION); + File tmpModule = FileUtil.createTempFile("tst", ModuleFileType.DOT_DEFAULT_EXTENSION); myFilesToDelete.add(tmpModule); final Module module = createModule(tmpModule); final ModuleRootManagerImpl moduleRootManager = diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java index b2d25802d9d5..4ee177217e57 100644 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java @@ -139,7 +139,7 @@ public abstract class CodeInsightTestCase extends PsiTestCase { final String extension = _extension == null ? fileType.getDefaultExtension():_extension; File dir = createTempDirectory(); - final File tempFile = File.createTempFile("aaa", "." + extension, dir); + final File tempFile = FileUtil.createTempFile(dir, "aaa", "." + extension, true); final FileTypeManager fileTypeManager = FileTypeManager.getInstance(); if (fileTypeManager.getFileTypeByExtension(extension) != fileType) { new WriteCommandAction(getProject()) { diff --git a/platform/bootstrap/src/com/intellij/idea/Main.java b/platform/bootstrap/src/com/intellij/idea/Main.java index 1a858c42dc2a..6e6e0111a3a5 100644 --- a/platform/bootstrap/src/com/intellij/idea/Main.java +++ b/platform/bootstrap/src/com/intellij/idea/Main.java @@ -18,6 +18,7 @@ package com.intellij.idea; import com.intellij.ide.Bootstrap; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.annotations.NonNls; import javax.swing.*; @@ -90,7 +91,7 @@ public class Main { List args = new ArrayList(); if (System.getProperty("os.name").toLowerCase().startsWith("windows")) { File launcherFile = new File(ideaHomeDir, "bin/vistalauncher.exe"); - File launcherCopy = File.createTempFile("vistalauncher", ".exe"); + File launcherCopy = FileUtil.createTempFile("vistalauncher", ".exe"); launcherCopy.deleteOnExit(); copyFile(launcherFile, launcherCopy); args.add(launcherCopy.getPath()); diff --git a/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java b/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java index 572f7ead1c0d..26a0944f9267 100644 --- a/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java +++ b/platform/lang-api/src/com/intellij/execution/RunnerAndConfigurationSettings.java @@ -52,4 +52,8 @@ public interface RunnerAndConfigurationSettings { void setTemporary(boolean temporary); Factory createFactory(); + + void setEditBeforeRun(boolean b); + + boolean isEditBeforeRun(); } diff --git a/platform/lang-api/src/com/intellij/facet/FacetType.java b/platform/lang-api/src/com/intellij/facet/FacetType.java index 75f17d692bb2..e1a96fcc79e7 100644 --- a/platform/lang-api/src/com/intellij/facet/FacetType.java +++ b/platform/lang-api/src/com/intellij/facet/FacetType.java @@ -47,6 +47,10 @@ public abstract class FacetType { private final @NotNull String myPresentableName; private final @Nullable FacetTypeId myUnderlyingFacetType; + public static T findInstance(Class aClass) { + return EP_NAME.findExtension(aClass); + } + /** * @param id unique instance of {@link FacetTypeId} * @param stringId unique string id of the facet type diff --git a/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java b/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java index 9b34532b148f..61e535774ca6 100644 --- a/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java +++ b/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java @@ -48,7 +48,7 @@ public class ProgramRunnerUtil { } public static void executeConfiguration(@NotNull final Project project, @NotNull final RunnerAndConfigurationSettings configuration, - @NotNull final Executor executor) { + @NotNull final Executor executor, final boolean showSettings) { ProgramRunner runner = getRunner(executor.getId(), configuration); if (runner == null) { LOG.error("Runner MUST not be null! Cannot find runner for " + executor.getId() + " and " + configuration.getConfiguration().getFactory().getName()); @@ -58,7 +58,7 @@ public class ProgramRunnerUtil { return; } - if (!RunManagerImpl.canRunConfiguration(configuration, executor)) { + if (!RunManagerImpl.canRunConfiguration(configuration, executor) || (showSettings && RunManagerImpl.isEditBeforeRun(configuration))) { final boolean result = RunDialog.editConfiguration(project, configuration, "Edit configuration", executor.getActionName(), executor.getIcon()); if (!result) { return; @@ -84,6 +84,11 @@ public class ProgramRunnerUtil { } } + public static void executeConfiguration(@NotNull final Project project, @NotNull final RunnerAndConfigurationSettings configuration, + @NotNull final Executor executor) { + executeConfiguration(project, configuration, executor, true); + } + public static Icon getConfigurationIcon(final Project project, final RunnerAndConfigurationSettings settings, final boolean invalid) { final RunManager runManager = RunManager.getInstance(project); return getConfigurationIcon(settings, invalid, runManager.isTemporary(settings.getConfiguration())); diff --git a/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java b/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java index fc6b6a24cce6..c2a9d032ae6d 100644 --- a/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java +++ b/platform/lang-impl/src/com/intellij/execution/RunManagerEx.java @@ -48,6 +48,8 @@ public abstract class RunManagerEx extends RunManager { public abstract void setTemporaryConfiguration(RunnerAndConfigurationSettings tempConfiguration); + public abstract void setEditBeforeRun(RunConfiguration settings, boolean edit); + public abstract RunManagerConfig getConfig(); @NotNull diff --git a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java index b8beb5b94ec6..95485e768ff4 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java @@ -220,7 +220,7 @@ public class ChooseRunConfigurationAction extends AnAction { PropertiesComponent.getInstance().setValue("run.configuration.edit.ad", Boolean.toString(true)); if (RunDialog.editConfiguration(project, configuration, "Edit configuration settings", executor.getActionName(), executor.getIcon())) { RunManagerEx.getInstanceEx(project).setSelectedConfiguration(configuration); - ProgramRunnerUtil.executeConfiguration(project, configuration, executor); + ProgramRunnerUtil.executeConfiguration(project, configuration, executor, false); } } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java index 53de302b4f2a..efcbd9ef4ea0 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java @@ -18,6 +18,7 @@ package com.intellij.execution.impl; import com.intellij.execution.BeforeRunTask; import com.intellij.execution.BeforeRunTaskProvider; +import com.intellij.execution.ExecutionBundle; import com.intellij.execution.RunnerAndConfigurationSettings; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.execution.configurations.UnknownRunConfiguration; @@ -55,10 +56,12 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor, BeforeRunTask> myStepsBeforeLaunch; private final Map, StepBeforeLaunchRow> myStepBeforeLaunchRows = new THashMap, StepBeforeLaunchRow>(); private boolean myStoreProjectConfiguration; + private boolean myEditBeforeRun; private final ConfigurationSettingsEditor myEditor; @@ -78,7 +81,7 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, runConfiguration.getProject()); myStepsPanel.removeAll(); - if (providers.length == 0 || runConfiguration instanceof UnknownRunConfiguration) { + if (runConfiguration instanceof UnknownRunConfiguration) { myStepsPanel.setVisible(false); } else { @@ -92,17 +95,25 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor, BeforeRunTask> getStepsBeforeLaunch() { diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index 30f57223b6d9..329392e2ed1e 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -619,6 +619,15 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, setActiveConfiguration(tempConfiguration); } + public static boolean isEditBeforeRun(@NotNull final RunnerAndConfigurationSettings configuration) { + return configuration.isEditBeforeRun(); + } + + public void setEditBeforeRun(@NotNull final RunConfiguration configuration, final boolean edit) { + final RunnerAndConfigurationSettings settings = getSettings(configuration); + if (settings != null) settings.setEditBeforeRun(edit); + } + public void setActiveConfiguration(final RunnerAndConfigurationSettings configuration) { setSelectedConfiguration(configuration); } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java index 94de17906a01..18730145d1f3 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunnerAndConfigurationSettingsImpl.java @@ -57,6 +57,9 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C protected static final String DUMMY_ELEMENT_NANE = "dummy"; @NonNls private static final String TEMPORARY_ATTRIBUTE = "temporary"; + @NonNls + private static final String EDIT_BEFORE_RUN = "editBeforeRun"; + /** for compatibility */ @NonNls @@ -73,6 +76,7 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C private List myUnloadedConfigurationPerRunnerSettings = null; private boolean myTemporary; + private boolean myEditBeforeRun; public RunnerAndConfigurationSettingsImpl(RunManagerImpl manager) { myManager = manager; @@ -122,6 +126,16 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C return myConfiguration.getName(); } + @Override + public void setEditBeforeRun(boolean b) { + myEditBeforeRun = b; + } + + @Override + public boolean isEditBeforeRun() { + return myEditBeforeRun; + } + @Nullable private ConfigurationFactory getFactory(final Element element) { final String typeName = element.getAttributeValue(CONFIGURATION_TYPE_ATTRIBUTE); @@ -130,9 +144,9 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C } public void readExternal(Element element) throws InvalidDataException { - myIsTemplate = Boolean.valueOf(element.getAttributeValue(TEMPLATE_FLAG_ATTRIBUTE)).booleanValue(); myTemporary = Boolean.valueOf(element.getAttributeValue(TEMPORARY_ATTRIBUTE)).booleanValue() || TEMP_CONFIGURATION.equals(element.getName()); + myEditBeforeRun = Boolean.valueOf(element.getAttributeValue(EDIT_BEFORE_RUN)).booleanValue(); final ConfigurationFactory factory = getFactory(element); if (factory == null) return; @@ -192,6 +206,8 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C } element.setAttribute(CONFIGURATION_TYPE_ATTRIBUTE, factory.getType().getId()); element.setAttribute(FACTORY_NAME_ATTRIBUTE, factory.getName()); + + if (isEditBeforeRun()) element.setAttribute(EDIT_BEFORE_RUN, String.valueOf(true)); if (myTemporary) { element.setAttribute(TEMPORARY_ATTRIBUTE, Boolean.toString(myTemporary)); } diff --git a/platform/lang-impl/src/com/intellij/execution/rmi/RemoteProcessSupport.java b/platform/lang-impl/src/com/intellij/execution/rmi/RemoteProcessSupport.java index 540b31f21b64..b1bcb1b50522 100644 --- a/platform/lang-impl/src/com/intellij/execution/rmi/RemoteProcessSupport.java +++ b/platform/lang-impl/src/com/intellij/execution/rmi/RemoteProcessSupport.java @@ -42,6 +42,10 @@ public abstract class RemoteProcessSupport { private final HashMap, Object> myProcMap = new HashMap, Object>(); + static { + RemoteServer.setupRMI(); + } + public RemoteProcessSupport(Class valueClass) { myValueClass = valueClass; } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java index 0fda5957f06e..4c69b3a20065 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoActionBase.java @@ -34,6 +34,17 @@ public abstract class GotoActionBase extends AnAction { protected static Class myInAction = null; + public static String getInitialText(Editor editor) { + if (editor == null) { + return ""; + } + final String selectedText = editor.getSelectionModel().getSelectedText(); + if (selectedText != null && selectedText.indexOf("\n") < 0) { + return selectedText; + } + return ""; + } + public final void actionPerformed(AnActionEvent e) { LOG.assertTrue (!getClass ().equals (myInAction)); try { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java index 6842dec2b59f..7dd49cbbf3c5 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoClassAction.java @@ -47,7 +47,8 @@ public class GotoClassAction extends GotoActionBase implements DumbAware { PsiDocumentManager.getInstance(project).commitAllDocuments(); final GotoClassModel2 model = new GotoClassModel2(project); - final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e)); + final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e), + getInitialText(e.getData(PlatformDataKeys.EDITOR))); final ChooseByNameFilter filterUI = new ChooseByNameLanguageFilter(popup, model, GotoClassSymbolConfiguration.getInstance(project), project); popup.invoke(new ChooseByNamePopupComponent.Callback() { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoFileAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoFileAction.java index a1c64f86dcc4..823b1e8a7b72 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoFileAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoFileAction.java @@ -52,7 +52,8 @@ public class GotoFileAction extends GotoActionBase implements DumbAware { FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.file"); final Project project = e.getData(PlatformDataKeys.PROJECT); final GotoFileModel gotoFileModel = new GotoFileModel(project); - final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, gotoFileModel, getPsiContext(e)); + final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, gotoFileModel, getPsiContext(e), + getInitialText(e.getData(PlatformDataKeys.EDITOR))); final ChooseByNameFilter filterUI = new GotoFileFilter(popup, gotoFileModel, project); popup.invoke(new ChooseByNamePopupComponent.Callback() { public void onClose() { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoSymbolAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoSymbolAction.java index 26a68ae23cb3..ef2d7197d441 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoSymbolAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoSymbolAction.java @@ -36,7 +36,8 @@ public class GotoSymbolAction extends GotoActionBase { PsiDocumentManager.getInstance(project).commitAllDocuments(); final GotoSymbolModel2 model = new GotoSymbolModel2(project); - final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e)); + final ChooseByNamePopup popup = ChooseByNamePopup.createPopup(project, model, getPsiContext(e), + getInitialText(e.getData(PlatformDataKeys.EDITOR))); final ChooseByNameFilter filterUI = new ChooseByNameLanguageFilter(popup, model, GotoClassSymbolConfiguration.getInstance(project), project); popup.invoke(new ChooseByNamePopupComponent.Callback() { diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java index 3cad5dedf975..2009d454eb16 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/AbstractModuleNode.java @@ -25,10 +25,11 @@ import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.pom.NavigatableWithText; import com.intellij.ui.SimpleTextAttributes; import org.jetbrains.annotations.NotNull; -public abstract class AbstractModuleNode extends ProjectViewNode { +public abstract class AbstractModuleNode extends ProjectViewNode implements NavigatableWithText { protected AbstractModuleNode(Project project, Module module, ViewSettings viewSettings) { super(project, module, viewSettings); } @@ -84,6 +85,11 @@ public abstract class AbstractModuleNode extends ProjectViewNode { ProjectSettingsService.getInstance(myProject).openModuleSettings(getValue()); } + @Override + public String getNavigateActionText(boolean focusEditor) { + return "Open Module Settings"; + } + public boolean canNavigate() { return true; } diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/NamedLibraryElementNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/NamedLibraryElementNode.java index 0ab7de8454bd..0014de0dd56c 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/NamedLibraryElementNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/NamedLibraryElementNode.java @@ -33,6 +33,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.pom.NavigatableWithText; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -40,7 +41,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -public class NamedLibraryElementNode extends ProjectViewNode{ +public class NamedLibraryElementNode extends ProjectViewNode implements NavigatableWithText { private static final Icon GENERIC_JDK_ICON = IconLoader.getIcon("/general/jdk.png"); private static final Icon LIB_ICON_OPEN = IconLoader.getIcon("/nodes/ppLibOpen.png"); private static final Icon LIB_ICON_CLOSED = IconLoader.getIcon("/nodes/ppLibClosed.png"); @@ -123,4 +124,9 @@ public class NamedLibraryElementNode extends ProjectViewNode { +public class PsiDirectoryNode extends BasePsiNode implements NavigatableWithText { public PsiDirectoryNode(Project project, PsiDirectory value, ViewSettings viewSettings) { super(project, value, viewSettings); } @@ -190,15 +191,38 @@ public class PsiDirectoryNode extends BasePsiNode { public void navigate(final boolean requestFocus) { Module module = ModuleUtil.findModuleForPsiElement(getValue()); if (module != null) { - if (ProjectRootsUtil.isModuleContentRoot(getVirtualFile(), getProject())) { + final VirtualFile file = getVirtualFile(); + final Project project = getProject(); + if (ProjectRootsUtil.isModuleContentRoot(file, project)) { ProjectSettingsService.getInstance(myProject).openModuleSettings(module); } + else if (ProjectRootsUtil.isLibraryRoot(file, project)) { + ProjectSettingsService.getInstance(myProject).openModuleLibrarySettings(module); + } else { ProjectSettingsService.getInstance(myProject).openContentEntriesSettings(module); } } } + @Override + public String getNavigateActionText(boolean focusEditor) { + VirtualFile file = getVirtualFile(); + Project project = getProject(); + + if (file != null) { + if (ProjectRootsUtil.isModuleContentRoot(file, project) || + ProjectRootsUtil.isSourceOrTestRoot(file, project)) { + return "Open Module Settings"; + } + if (ProjectRootsUtil.isLibraryRoot(file, project)) { + return "Open Library Settings"; + } + } + + return null; + } + public int getWeight() { return isFQNameShown() ? 70 : 0; } diff --git a/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextConfigurable.java b/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextConfigurable.java index 84b243c7e81e..82158e23cf03 100644 --- a/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextConfigurable.java @@ -76,7 +76,7 @@ public abstract class LangScriptingContextConfigurable implements Configurable, @Override public void reset() { - myLibManager.dropChanges(); + myLibManager.reset(); myPanel.resetTable(); } diff --git a/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextProvider.java b/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextProvider.java index d7f7c9d9c4ff..957ea71c02ad 100644 --- a/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextProvider.java +++ b/platform/lang-impl/src/com/intellij/ide/scriptingContext/LangScriptingContextProvider.java @@ -16,10 +16,9 @@ package com.intellij.ide.scriptingContext; import com.intellij.lang.Language; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.libraries.LibraryType; +import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; /** @@ -36,4 +35,6 @@ public abstract class LangScriptingContextProvider { public abstract ScriptingLibraryMappings getLibraryMappings(Project project); + public abstract boolean isCompact(VirtualFile file); + } diff --git a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ScriptingLibraryMappings.java b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ScriptingLibraryMappings.java index 777172e6141d..2f9bebde96ec 100644 --- a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ScriptingLibraryMappings.java +++ b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ScriptingLibraryMappings.java @@ -75,6 +75,7 @@ public class ScriptingLibraryMappings extends LanguagePerFileMappings getAvailableValues(VirtualFile file) { + myLibraryManager.reset(); List libraries = getSingleLibraries(); if (myCompoundLibMap.containsKey(file)) { libraries.add(myCompoundLibMap.get(file)); diff --git a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.form b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.form index c1186386820d..803ac485f05e 100644 --- a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.form +++ b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.form @@ -3,7 +3,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -70,19 +70,27 @@ - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.java b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.java index 018a01e4637d..f83dc4dfef9e 100644 --- a/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.java +++ b/platform/lang-impl/src/com/intellij/ide/scriptingContext/ui/EditLibraryDialog.java @@ -50,6 +50,7 @@ public class EditLibraryDialog extends DialogWrapper { private JButton myAddFileButton; private JButton myRemoveFileButton; private JBTable myFileTable; + private JButton myAttachFromButton; private Project myProject; private FileTableModel myFileTableModel; private VirtualFile mySelectedFile; @@ -65,6 +66,14 @@ public class EditLibraryDialog extends DialogWrapper { addFiles(); } }); + + myAttachFromButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + attachFromDirectory(); + } + }); + myFileTableModel = new FileTableModel(); myFileTable.setModel(myFileTableModel); @@ -135,14 +144,31 @@ public class EditLibraryDialog extends DialogWrapper { FileChooserDescriptor chooserDescriptor = new LibFileChooserDescriptor(); VirtualFile[] files = FileChooser.chooseFiles(myProject, chooserDescriptor); if (files.length == 1 && files[0] != null) { - myFileTableModel.addFile(files[0], false); + myFileTableModel.addFile(files[0]); + } + } + + private void attachFromDirectory() { + FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false); + chooserDescriptor.setTitle("Select a directory to attach files from"); //TODO Move to resources + VirtualFile[] files = FileChooser.chooseFiles(myProject, chooserDescriptor); + if (files.length == 1 && files[0] != null) { + VirtualFile chosenDir = files[0]; + if (chosenDir.isDirectory() && chosenDir.isValid()) { + if (myLibName.getText().isEmpty()) myLibName.setText(chosenDir.getName()); + for (VirtualFile file : chosenDir.getChildren()) { + if (file.isValid() && !file.isDirectory() && myProvider.acceptsExtension(file.getExtension())) { + myFileTableModel.addFile(file); + } + } + } } } private class LibFileChooserDescriptor extends FileChooserDescriptor { public LibFileChooserDescriptor() { super (true, false, false, true, false, false); - setTitle("Select library file"); + setTitle("Select library file"); //TODO Move to resources } @Override @@ -158,14 +184,14 @@ public class EditLibraryDialog extends DialogWrapper { } } - private static class FileTableModel extends AbstractTableModel { + private class FileTableModel extends AbstractTableModel { @Override public String getColumnName(int column) { switch(column) { case FILE_LOCATION_COL: - return "Location"; - case FILE_TYPE_COL: + return "Location"; //TODO Move to resources + case FILE_TYPE_COL: //TODO Move to resources return "Type"; } return ""; @@ -182,9 +208,9 @@ public class EditLibraryDialog extends DialogWrapper { private ArrayList myFiles = new ArrayList(); private HashSet myCompactFiles = new HashSet(); - public void addFile(VirtualFile file, boolean isCompact) { + public void addFile(VirtualFile file) { myFiles.add(file); - if (isCompact) { + if (myProvider.isCompact(file)) { myCompactFiles.add(file); } fireTableDataChanged(); @@ -286,7 +312,7 @@ public class EditLibraryDialog extends DialogWrapper { @Override protected void doOKAction() { if (!isLibNameValid(myLibName.getText())) { - Messages.showErrorDialog(myProject, "Invalid library name", "Error"); + Messages.showErrorDialog(myProject, "Invalid library name", "Error"); //TODO Move to resources return; } super.doOKAction(); diff --git a/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java b/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java index 1e68dc68ca00..8b7cdc07aad5 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java +++ b/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java @@ -300,7 +300,9 @@ public class MemberChooser extends DialogWrapper implemen final TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, new Convertor() { @Nullable public String convert(TreePath path) { - final MemberChooserObject delegate = ((ElementNode)path.getLastPathComponent()).getDelegate(); + final ElementNode lastPathComponent = (ElementNode)path.getLastPathComponent(); + if (lastPathComponent == null) return null; + final MemberChooserObject delegate = lastPathComponent.getDelegate(); return delegate.getText(); } }); diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibraryManager.java b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibraryManager.java index 77cf1187dee0..921c06a29345 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibraryManager.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/libraries/scripting/ScriptingLibraryManager.java @@ -110,7 +110,7 @@ public class ScriptingLibraryManager { } } - public void dropChanges() { + public void reset() { myLibTable = null; } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/PsiCachedValuesFactory.java b/platform/lang-impl/src/com/intellij/psi/impl/PsiCachedValuesFactory.java index d7de93f49900..00924cb57fcb 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/PsiCachedValuesFactory.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/PsiCachedValuesFactory.java @@ -44,8 +44,7 @@ public class PsiCachedValuesFactory implements CachedValuesFactory { protected Object[] getDependencies(CachedValueProvider.Result result) { return getDependenciesPlusValue(result); } - } : new PsiCachedValueImpl(myManager, provider) { - }; + } : new PsiCachedValueImpl(myManager, provider); } public ParameterizedCachedValue createParameterizedCachedValue(@NotNull ParameterizedCachedValueProvider provider, diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java index 90c00162f75e..dcdc78135e83 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java @@ -154,7 +154,8 @@ public class CodeStyleManagerImpl extends CodeStyleManager { // } // Formatter removes such white spaces, i.e. keeps only line feed symbol. But we want to preserve caret position then. // So, we check if it should be preserved and restore it after formatting if necessary - boolean fixCaretPosition = false; + int visualColumnToRestore = -1; + if (editor != null) { Document document = editor.getDocument(); int caretOffset = editor.getCaretModel().getOffset(); @@ -162,7 +163,7 @@ public class CodeStyleManagerImpl extends CodeStyleManager { CharSequence text = document.getCharsSequence(); int caretLine = document.getLineNumber(caretOffset); int lineStartOffset = document.getLineStartOffset(caretLine); - fixCaretPosition = true; + boolean fixCaretPosition = true; for (int i = caretOffset; i>= lineStartOffset; i--) { char c = text.charAt(i); if (c != ' ' && c != '\t' && c != '\n') { @@ -170,6 +171,9 @@ public class CodeStyleManagerImpl extends CodeStyleManager { break; } } + if (fixCaretPosition) { + visualColumnToRestore = editor.getCaretModel().getVisualPosition().column; + } } @@ -190,38 +194,15 @@ public class CodeStyleManagerImpl extends CodeStyleManager { formatToEnd ? file.getTextLength() : endElement.getTextRange().getEndOffset())); } - if (!fixCaretPosition) { + if (visualColumnToRestore < 0) { return; } CaretModel caretModel = editor.getCaretModel(); - String indent = getLineIndent(file, caretModel.getOffset()); - if (indent == null) { - return; - } - int tabSize = getSettings().getTabSize(file.getFileType()); - int indentColumn = indentInVisualColumns(indent, tabSize); VisualPosition position = caretModel.getVisualPosition(); - if (indentColumn != position.column) { - caretModel.moveToVisualPosition(new VisualPosition(position.line, indentColumn)); + if (visualColumnToRestore != position.column) { + caretModel.moveToVisualPosition(new VisualPosition(position.line, visualColumnToRestore)); } } - - private static int indentInVisualColumns(String indent, int tabSize) { - if (tabSize <= 1) { - return indent.length(); - } - int result = 0; - for (int i = 0; i < indent.length(); i++) { - char c = indent.charAt(i); - if (c == '\t') { - result += tabSize - result % tabSize; - } - else { - result++; - } - } - return result; - } private PsiElement reformatRangeImpl(final PsiElement element, final int startOffset, diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java index f74d49578f4d..5b103ac8fd88 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java @@ -387,13 +387,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe public void flush(StubIndexKey key) throws StorageException { final MyIndex index = myIndices.get(key); - index.getReadLock().lock(); - try { - index.flush(); - } - finally { - index.getReadLock().unlock(); - } + index.flush(); } public void updateIndex(StubIndexKey key, int fileId, final Map oldValues, Map newValues) { diff --git a/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java b/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java index ff47de5d1d0f..7b34748412d9 100644 --- a/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java @@ -27,6 +27,7 @@ import com.intellij.openapi.util.Ref; import com.intellij.util.Alarm; import com.intellij.util.Function; import com.intellij.util.ui.EmptyIcon; +import com.intellij.util.ui.UIUtil; import javax.swing.*; import javax.swing.plaf.TreeUI; @@ -47,7 +48,7 @@ public class DeferredIconImpl implements DeferredIcon { private boolean myNeedReadAction; private boolean myDone; - private Disposer myDisposer; + private IconDisposer myDisposer; public DeferredIconImpl(Icon baseIcon, T param, Function evaluator) { this(baseIcon, param, true, evaluator); @@ -139,7 +140,7 @@ public class DeferredIconImpl implements DeferredIcon { final TreeUI ui = ((JTree)actualTarget).getUI(); if (ui instanceof BasicTreeUI) { // this call is "fake" and only need to reset tree layout cache - ((BasicTreeUI)ui).setLeftChildIndent(((Integer)UIManager.get("Tree.leftChildIndent")).intValue()); + ((BasicTreeUI)ui).setLeftChildIndent(UIUtil.getTreeLeftChildIndent()); } } } @@ -276,12 +277,12 @@ public class DeferredIconImpl implements DeferredIcon { } - public DeferredIconImpl setDisposer(Disposer disposer) { + public DeferredIconImpl setDisposer(IconDisposer disposer) { myDisposer = disposer; return this; } - public interface Disposer { + public interface IconDisposer { void dispose(T key); diff --git a/platform/lang-impl/src/com/intellij/ui/IconDeferrerImpl.java b/platform/lang-impl/src/com/intellij/ui/IconDeferrerImpl.java index 884c6e6506f2..f157d521aa9c 100644 --- a/platform/lang-impl/src/com/intellij/ui/IconDeferrerImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/IconDeferrerImpl.java @@ -19,22 +19,18 @@ */ package com.intellij.ui; -import com.intellij.ProjectTopics; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.impl.ProjectLifecycleListener; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.newvfs.BulkFileListener; import com.intellij.openapi.vfs.newvfs.events.VFileEvent; -import com.intellij.psi.util.PsiModificationTracker; import com.intellij.util.Function; import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.MessageBusConnection; -import com.intellij.util.messages.MessageHandler; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -75,7 +71,7 @@ public class IconDeferrerImpl extends IconDeferrer { synchronized (LOCK) { Icon result = myIconsCache.get(param); if (result == null) { - result = new DeferredIconImpl(base, param, f).setDisposer(new DeferredIconImpl.Disposer() { + result = new DeferredIconImpl(base, param, f).setDisposer(new DeferredIconImpl.IconDisposer() { @Override public void dispose(T key) { synchronized (LOCK) { diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorSettingsTable.java b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorSettingsTable.java index 716220bbba38..66ae80271e0a 100644 --- a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorSettingsTable.java +++ b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorSettingsTable.java @@ -19,6 +19,7 @@ package com.intellij.ui.tabs; import com.intellij.ui.FileColorManager; import com.intellij.util.ui.EmptyIcon; import com.intellij.openapi.ui.StripeTable; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -243,7 +244,7 @@ public abstract class FileColorSettingsTable extends StripeTable { setBackground(isSelected ? table.getSelectionBackground() : table.getBackground()); setForeground(isSelected ? table.getSelectionForeground() : table.getForeground()); - setBorder(hasFocus ? (UIManager.getBorder("Table.focusCellHighlightBorder")) + setBorder(hasFocus ? UIUtil.getTableFocusCellHighlightBorder() : NO_FOCUS_BORDER); } } diff --git a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java index cbd70aa2db7c..9342135852d1 100644 --- a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java +++ b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java @@ -126,7 +126,7 @@ public class BrowserUtil { private static String redirectUrl(String url, @NonNls String urlString) throws IOException { if (url.indexOf('&') == -1 && (!urlString.startsWith("file:") || urlString.indexOf("#") == -1)) return urlString; - File redirect = File.createTempFile("redirect", ".html"); + File redirect = FileUtil.createTempFile("redirect", ".html"); redirect.deleteOnExit(); FileWriter writer = new FileWriter(redirect); writer.write(""); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DescriptionLabel.java b/platform/platform-api/src/com/intellij/openapi/ui/DescriptionLabel.java index 55c0e6e9e902..8bd8f5fe2fa7 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DescriptionLabel.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DescriptionLabel.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.ui; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -28,7 +29,7 @@ public class DescriptionLabel extends JLabel { @Override public void updateUI() { super.updateUI(); - setForeground(UIManager.getColor("Panel.background").darker()); + setForeground(UIUtil.getPanelBackground().darker()); int size = getFont().getSize(); if (size >= 12) { size -= 2; diff --git a/platform/platform-api/src/com/intellij/openapi/ui/FixedComboBoxEditor.java b/platform/platform-api/src/com/intellij/openapi/ui/FixedComboBoxEditor.java index c9c1592fa1ae..47a77cddeaeb 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/FixedComboBoxEditor.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/FixedComboBoxEditor.java @@ -308,7 +308,7 @@ public class FixedComboBoxEditor implements ComboBoxEditor { g.setColor(bottomColor); g.drawLine(x + 4, y + height - 4, x + width - 2, y + height - 4); - g.setColor(UIManager.getColor("Panel.background")); + g.setColor(UIUtil.getPanelBackground()); g.fillRect(x, y, width, 3); g.fillRect(x, y, 3, height); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java index c5d9f288ed25..a4012a2abedb 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/LoadingDecorator.java @@ -173,7 +173,7 @@ public class LoadingDecorator { final Graphics2D g = mySnapshot.createGraphics(); myPane.paint(g); final Component opaque = UIUtil.findNearestOpaque(this); - mySnapshotBg = opaque != null ? opaque.getBackground() : UIUtil.getPanelBackgound(); + mySnapshotBg = opaque != null ? opaque.getBackground() : UIUtil.getPanelBackground(); g.dispose(); } myProgress.resume(); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/TreeComboBox.java b/platform/platform-api/src/com/intellij/openapi/ui/TreeComboBox.java index 37251ec23a74..c52d8450478d 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/TreeComboBox.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/TreeComboBox.java @@ -34,7 +34,7 @@ import java.util.Enumeration; * User: spLeaner */ public class TreeComboBox extends JComboBox { - final static int INDENT = UIManager.getInt("Tree.leftChildIndent"); + final static int INDENT = UIUtil.getTreeLeftChildIndent(); private TreeModel myTreeModel; public TreeComboBox(@NotNull final TreeModel model) { diff --git a/platform/platform-api/src/com/intellij/openapi/wm/StatusBarWidget.java b/platform/platform-api/src/com/intellij/openapi/wm/StatusBarWidget.java index 4a8528808d5c..35dce9cd2115 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/StatusBarWidget.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/StatusBarWidget.java @@ -91,7 +91,7 @@ public interface StatusBarWidget extends Disposable { private static final Color PIXEL = LEFT1_FROM_INACTIVE; private static final Color LEFT1_TO_INACTIVE = new Color(180, 180, 180); - private static final Color SEPARATOR_COLOR = UIUtil.getPanelBackgound().darker(); + private static final Color SEPARATOR_COLOR = UIUtil.getPanelBackground().darker(); public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { final Graphics2D g2 = (Graphics2D)g.create(); diff --git a/platform/platform-api/src/com/intellij/pom/NavigatableWithText.java b/platform/platform-api/src/com/intellij/pom/NavigatableWithText.java new file mode 100644 index 000000000000..a9968e592fef --- /dev/null +++ b/platform/platform-api/src/com/intellij/pom/NavigatableWithText.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.pom; + +import org.jetbrains.annotations.Nullable; + +/** + * @author yole + */ +public interface NavigatableWithText extends Navigatable { + @Nullable + String getNavigateActionText(boolean focusEditor); +} diff --git a/platform/platform-api/src/com/intellij/ui/ColorPanel.java b/platform/platform-api/src/com/intellij/ui/ColorPanel.java index e831071af22c..b2e378f6681c 100644 --- a/platform/platform-api/src/com/intellij/ui/ColorPanel.java +++ b/platform/platform-api/src/com/intellij/ui/ColorPanel.java @@ -15,18 +15,16 @@ */ package com.intellij.ui; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import javax.swing.*; -import javax.swing.border.Border; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import com.intellij.util.ui.UIUtil; - public class ColorPanel extends JPanel { public static final Color[] fixedColors; public static final Color DARK_MAGENTA = new Color(128, 0, 128); @@ -35,7 +33,7 @@ public class ColorPanel extends JPanel { public static final Color BLUE_GREEN = new Color(0, 128, 128); public static final Color DARK_YELLOW = new Color(128, 128, 0); public static final Color DARK_RED = new Color(128, 0, 0); - public static final Color DISABLED_COLOR = UIUtil.getPanelBackgound(); + public static final Color DISABLED_COLOR = UIUtil.getPanelBackground(); private static Color[] myCustomColors; @NonNls private String myActionCommand = "colorPanelChanged"; private boolean isFiringEvent = false; diff --git a/platform/platform-api/src/com/intellij/ui/GuiUtils.java b/platform/platform-api/src/com/intellij/ui/GuiUtils.java index 96f767ef02a1..f93831c2c605 100644 --- a/platform/platform-api/src/com/intellij/ui/GuiUtils.java +++ b/platform/platform-api/src/com/intellij/ui/GuiUtils.java @@ -318,12 +318,12 @@ public class GuiUtils { if (component instanceof JPanel) { final Border border = ((JPanel)component).getBorder(); if (border instanceof TitledBorder) { - Color color = enabled ? component.getForeground() : UIUtil.getTextInactiveTextColor(); + Color color = enabled ? component.getForeground() : UIUtil.getInactiveTextColor(); ((TitledBorder)border).setTitleColor(color); } } else if (component instanceof JLabel) { - Color color = UIUtil.getTextInactiveTextColor(); + Color color = UIUtil.getInactiveTextColor(); if (color == null) color = component.getForeground(); @NonNls String changeColorString = ""; final JLabel label = (JLabel)component; diff --git a/platform/platform-api/src/com/intellij/ui/SeparatorWithText.java b/platform/platform-api/src/com/intellij/ui/SeparatorWithText.java index 5fa975b44510..763c2ff99a10 100644 --- a/platform/platform-api/src/com/intellij/ui/SeparatorWithText.java +++ b/platform/platform-api/src/com/intellij/ui/SeparatorWithText.java @@ -15,6 +15,7 @@ */ package com.intellij.ui; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import javax.swing.*; @@ -30,8 +31,7 @@ public class SeparatorWithText extends JComponent { public SeparatorWithText() { setBorder(BorderFactory.createEmptyBorder(VGAP, 0, VGAP, 0)); - @NonNls final String labelFont = "Label.font"; - setFont(UIManager.getFont(labelFont)); + setFont(UIUtil.getLabelFont()); setFont(getFont().deriveFont(Font.BOLD)); } diff --git a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java index 6b2ffa474ebc..aff4263398ee 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleColoredComponent.java @@ -278,7 +278,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible { Font font = getFont(); if (font == null) { - font = UIManager.getFont("Label.font"); + font = UIUtil.getLabelFont(); } LOG.assertTrue(font != null); @@ -429,7 +429,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible { color = getForeground(); } if (!isEnabled()) { - color = UIUtil.getTextInactiveTextColor(); + color = UIUtil.getInactiveTextColor(); } g.setColor(color); diff --git a/platform/platform-api/src/com/intellij/ui/SimpleTextAttributes.java b/platform/platform-api/src/com/intellij/ui/SimpleTextAttributes.java index b0c8596518ae..aa526016e1c2 100644 --- a/platform/platform-api/src/com/intellij/ui/SimpleTextAttributes.java +++ b/platform/platform-api/src/com/intellij/ui/SimpleTextAttributes.java @@ -45,8 +45,8 @@ public final class SimpleTextAttributes { public static final SimpleTextAttributes REGULAR_ITALIC_ATTRIBUTES = new SimpleTextAttributes(STYLE_ITALIC, null); public static final SimpleTextAttributes ERROR_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, Color.red); - public static final SimpleTextAttributes GRAYED_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, UIUtil.getTextInactiveTextColor()); - public static final SimpleTextAttributes GRAYED_BOLD_ATTRIBUTES = new SimpleTextAttributes(STYLE_BOLD, UIUtil.getTextInactiveTextColor()); + public static final SimpleTextAttributes GRAYED_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, UIUtil.getInactiveTextColor()); + public static final SimpleTextAttributes GRAYED_BOLD_ATTRIBUTES = new SimpleTextAttributes(STYLE_BOLD, UIUtil.getInactiveTextColor()); public static final SimpleTextAttributes SYNTHETIC_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, Color.BLUE); public static final SimpleTextAttributes GRAY_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, Color.GRAY); diff --git a/platform/platform-api/src/com/intellij/ui/UI.java b/platform/platform-api/src/com/intellij/ui/UI.java index 899ea86b9069..5c73cfaef3bd 100644 --- a/platform/platform-api/src/com/intellij/ui/UI.java +++ b/platform/platform-api/src/com/intellij/ui/UI.java @@ -62,7 +62,7 @@ public class UI { ourColors.put("tooltip.error", Color.red); ourColors.put("tooltip.warning", Color.yellow.darker()); - ourColors.put("toolbar.background", UIUtil.getPanelBackgound()); + ourColors.put("toolbar.background", UIUtil.getPanelBackground()); ourColors.put("toolbar.hover.background", UIUtil.getTreeSelectionBackground()); ourColors.put("toolbar.selected.background", getColor("panel.custom.background")); ourColors.put("toolbar.hover.frame.foreground", UIUtil.getTreeSelectionBackground().darker()); diff --git a/platform/platform-api/src/com/intellij/ui/components/panels/ValidatingComponent.java b/platform/platform-api/src/com/intellij/ui/components/panels/ValidatingComponent.java index 2b66b1bd0e41..33ba62c1dc6f 100644 --- a/platform/platform-api/src/com/intellij/ui/components/panels/ValidatingComponent.java +++ b/platform/platform-api/src/com/intellij/ui/components/panels/ValidatingComponent.java @@ -15,6 +15,8 @@ */ package com.intellij.ui.components.panels; +import com.intellij.util.ui.UIUtil; + import javax.swing.*; import java.awt.*; @@ -24,7 +26,7 @@ import java.awt.*; * A label with possible error text is placed under validated component. */ public abstract class ValidatingComponent extends NonOpaquePanel { - private static final Font ERROR_FONT = UIManager.getFont("Label.font").deriveFont(Font.PLAIN, 10f); + private static final Font ERROR_FONT = UIUtil.getLabelFont().deriveFont(Font.PLAIN, 10f); private JLabel myErrorLabel; private T myMainComponent; diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index 39f1cec6b902..7386a462f722 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -1502,8 +1502,8 @@ public class JBTabsImpl extends JComponent if (isPaintFocus()) { if (bgColor == null) { alpha = 150; - shapeInfo.from = UIUtil.toAlpha(UIUtil.getPanelBackgound().brighter(), alpha); - shapeInfo.to = UIUtil.toAlpha(UIUtil.getPanelBackgound(), alpha); + shapeInfo.from = UIUtil.toAlpha(UIUtil.getPanelBackground().brighter(), alpha); + shapeInfo.to = UIUtil.toAlpha(UIUtil.getPanelBackground(), alpha); } else { alpha = 255; diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleTree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleTree.java index e93d41446a57..e468d675dc50 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleTree.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleTree.java @@ -25,6 +25,7 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.TreeUIHelper; import com.intellij.util.ui.EmptyIcon; +import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; import org.jetbrains.annotations.Nullable; @@ -95,7 +96,7 @@ public class SimpleTree extends Tree implements CellEditorListener { } }); - putClientProperty("JTree.lineStyle", "Angled"); + UIUtil.setLineStyleAngled(this); if (SystemInfo.isWindowsXP) { setUI(new BasicTreeUI()); // In WindowsXP UI handles are not shown :( } @@ -584,7 +585,7 @@ public class SimpleTree extends Tree implements CellEditorListener { public Icon getExpandedHandle() { if (myExpandedHandle == null) { - myExpandedHandle = UIManager.getIcon("Tree.expandedIcon"); + myExpandedHandle = UIUtil.getTreeExpandedIcon(); } return myExpandedHandle; @@ -592,7 +593,7 @@ public class SimpleTree extends Tree implements CellEditorListener { public Icon getCollapsedHandle() { if (myCollapsedHandle == null) { - myCollapsedHandle = UIManager.getIcon("Tree.collapsedIcon"); + myCollapsedHandle = UIUtil.getTreeCollapsedIcon(); } return myCollapsedHandle; diff --git a/platform/platform-api/src/com/intellij/util/ui/AnimatedIcon.java b/platform/platform-api/src/com/intellij/util/ui/AnimatedIcon.java index 833fde1174ba..d23a8677248f 100644 --- a/platform/platform-api/src/com/intellij/util/ui/AnimatedIcon.java +++ b/platform/platform-api/src/com/intellij/util/ui/AnimatedIcon.java @@ -156,7 +156,7 @@ public abstract class AnimatedIcon extends JComponent implements Disposable { if (parent instanceof JComponent) { opaque = (JComponent)UIUtil.findNearestOpaque((JComponent)parent); } - Color bg = opaque != null ? opaque.getBackground() : UIManager.getColor("Panel.background"); + Color bg = opaque != null ? opaque.getBackground() : UIUtil.getPanelBackground(); g.setColor(bg); g.fillRect(0, 0, getWidth(), getHeight()); } diff --git a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java index 7708b63ba33b..815c3a125f78 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeTooltipManager.java @@ -32,9 +32,7 @@ import com.intellij.ui.HintHint; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.Alarm; import com.intellij.util.IJSwingUtilities; -import com.intellij.util.containers.ComparatorUtil; import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.update.ComparableObjectCheck; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -284,7 +282,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener public Color getTextForeground(boolean awtTooltip) { - return useGraphite(awtTooltip) ? Color.white : UIManager.getColor("ToolTip.foreground"); + return useGraphite(awtTooltip) ? Color.white : UIUtil.getToolTipForeground(); } public Color getLinkForeground(boolean awtTooltip) { @@ -292,7 +290,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener } public Color getTextBackground(boolean awtTooltip) { - return useGraphite(awtTooltip) ? new Color(100, 100, 100, 230) : UIManager.getColor("ToolTip.background"); + return useGraphite(awtTooltip) ? new Color(100, 100, 100, 230) : UIUtil.getToolTipBackground(); } public String getUlImg(boolean awtTooltip) { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java b/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java index e8d0a4c66eaa..14ba0980674e 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java @@ -18,6 +18,7 @@ package com.intellij.ide.actions; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.project.DumbAware; import com.intellij.pom.Navigatable; +import com.intellij.pom.NavigatableWithText; import com.intellij.util.OpenSourceUtil; import org.jetbrains.annotations.Nullable; @@ -34,25 +35,39 @@ public abstract class BaseNavigateToSourceAction extends AnAction implements Dum } - public void update(AnActionEvent event){ + public void update(AnActionEvent event) { DataContext dataContext = event.getDataContext(); - final boolean enabled = isEnabled(dataContext); + final Navigatable target = getTarget(dataContext); + boolean enabled = target != null; if (ActionPlaces.isPopupPlace(event.getPlace())) { event.getPresentation().setVisible(enabled); } else { event.getPresentation().setEnabled(enabled); } + if (target != null && target instanceof NavigatableWithText) { + final String navigateActionText = ((NavigatableWithText)target).getNavigateActionText(myFocusEditor); + if (navigateActionText != null) { + event.getPresentation().setText(navigateActionText); + } + else { + event.getPresentation().setText(getTemplatePresentation().getText()); + } + } + else { + event.getPresentation().setText(getTemplatePresentation().getText()); + } } - private boolean isEnabled(final DataContext dataContext) { + @Nullable + private Navigatable getTarget(final DataContext dataContext) { Navigatable[] navigatables = getNavigatables(dataContext); if (navigatables != null) { for (Navigatable navigatable : navigatables) { - if (navigatable.canNavigate()) return true; + if (navigatable.canNavigate()) return navigatable; } } - return false; + return null; } @Nullable diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java index cb6e09877419..7874189358ca 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ChooseComponentsToExportDialog.java @@ -68,6 +68,7 @@ public class ChooseComponentsToExportDialog extends DialogWrapper { } final Set componentElementProperties = new LinkedHashSet(componentToContainingListElement.values()); myChooser = new ElementsChooser(true); + myChooser.setColorUnmarkedElements(false); for (final ComponentElementProperties componentElementProperty : componentElementProperties) { myChooser.addElement(componentElementProperty, true, componentElementProperty); } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/CloseProjectAction.java b/platform/platform-impl/src/com/intellij/ide/actions/CloseProjectAction.java index ca3acdae635d..7800e7a6a1c2 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/CloseProjectAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/CloseProjectAction.java @@ -32,7 +32,7 @@ public class CloseProjectAction extends AnAction implements DumbAware { Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); assert project != null; - ProjectUtil.closeProject(project); + ProjectUtil.closeAndDispose(project); RecentProjectsManagerBase.getInstance().updateLastProjectPath(); } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SaveAsDirectoryBasedFormatAction.java b/platform/platform-impl/src/com/intellij/ide/actions/SaveAsDirectoryBasedFormatAction.java index 234bc5cd2c7a..51b0bd5edd4a 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SaveAsDirectoryBasedFormatAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SaveAsDirectoryBasedFormatAction.java @@ -31,7 +31,6 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import java.io.File; -import java.util.Collection; /** * @author spleaner @@ -63,7 +62,7 @@ public class SaveAsDirectoryBasedFormatAction extends AnAction implements DumbAw projectStore.setProjectFilePath(baseDir.getPath()); project.save(); - ProjectUtil.closeProject(project); + ProjectUtil.closeAndDispose(project); ProjectUtil.openProject(baseDir.getPath(), null, false); } else { diff --git a/platform/platform-impl/src/com/intellij/ide/dnd/Highlighters.java b/platform/platform-impl/src/com/intellij/ide/dnd/Highlighters.java index a7860bc205a1..e53bac7a5f2b 100644 --- a/platform/platform-impl/src/com/intellij/ide/dnd/Highlighters.java +++ b/platform/platform-impl/src/com/intellij/ide/dnd/Highlighters.java @@ -17,6 +17,7 @@ package com.intellij.ide.dnd; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.SystemInfo; +import com.intellij.util.ui.UIUtil; import javax.accessibility.Accessible; import javax.swing.*; @@ -137,7 +138,7 @@ public class Highlighters implements DnDEvent.DropTargetHighlightingType { } }; myLabel.setFont(myLabel.getFont().deriveFont(Font.BOLD)); - myLabel.setForeground(UIManager.getColor("ToolTip.foreground")); + myLabel.setForeground(UIUtil.getToolTipForeground()); setFocusable(false); @@ -179,10 +180,10 @@ public class Highlighters implements DnDEvent.DropTargetHighlightingType { Object old = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g.setColor(UIManager.getColor("ToolTip.background")); + g.setColor(UIUtil.getToolTipBackground()); g.fillRoundRect(0, 0, getSize().width - 1, getSize().height - 1, 6, 6); - g.setColor(UIManager.getColor("ToolTip.foreground")); + g.setColor(UIUtil.getToolTipForeground()); g.drawRoundRect(0, 0, getSize().width - 1, getSize().height - 1, 6, 6); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, old); } diff --git a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java index 5dda48dc6159..28ce85c2b6a1 100644 --- a/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/impl/ProjectUtil.java @@ -21,7 +21,6 @@ import com.intellij.ide.IdeBundle; import com.intellij.ide.highlighter.ModuleFileType; import com.intellij.ide.highlighter.ProjectFileType; import com.intellij.ide.highlighter.WorkspaceFileType; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.StorageScheme; import com.intellij.openapi.components.impl.stores.IProjectStore; import com.intellij.openapi.diagnostic.Logger; @@ -32,8 +31,6 @@ import com.intellij.openapi.project.ex.ProjectEx; import com.intellij.openapi.project.ex.ProjectManagerEx; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.ActionCallback; -import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.LocalFileSystem; @@ -89,14 +86,8 @@ public class ProjectUtil { /** * @param project cannot be null */ - public static boolean closeProject(@NotNull final Project project) { - return ApplicationManager.getApplication().runWriteAction(new Computable() { - public Boolean compute() { - if (!ProjectManagerEx.getInstanceEx().closeProject(project)) return false; - Disposer.dispose(project); - return true; - } - }); + public static boolean closeAndDispose(@NotNull final Project project) { + return ProjectManagerEx.getInstanceEx().closeAndDispose(project); } /** @@ -158,7 +149,7 @@ public class ProjectUtil { if (!forceOpenInNewFrame && openProjects.length > 0) { int exitCode = confirmOpenNewProject(); if (exitCode == 1) { // "No" option - if (!closeProject(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null; + if (!closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null; } else if (exitCode != 0) { // not "Yes" return null; diff --git a/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java index 2b3e1a629f13..6772bb9a34b7 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/LafManagerImpl.java @@ -601,15 +601,6 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo initIdeaDefaults(table); } - protected void initSystemColorDefaults(UIDefaults table) { - super.initSystemColorDefaults(table); - /* - table.put("control", new ColorUIResource(236, 233, 216)); - table.put("controlHighlight", new ColorUIResource(255, 255, 255)); - table.put("controlShadow", new ColorUIResource(172, 167, 153)); - */ - } - @SuppressWarnings({"HardCodedStringLiteral"}) private static void initIdeaDefaults(UIDefaults defaults) { defaults.put("Menu.maxGutterIconWidth", 18); diff --git a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsListPanel.java b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsListPanel.java index 137c858b14d0..dab6e4eab014 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsListPanel.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsListPanel.java @@ -379,7 +379,7 @@ public class NotificationsListPanel extends JPanel implements NotificationModelL } }); - setBackground(UIUtil.getPanelBackgound()); + setBackground(UIUtil.getPanelBackground()); addMouseMotionListener(new MouseMotionListener() { public void mouseMoved(MouseEvent e) { @@ -657,7 +657,7 @@ public class NotificationsListPanel extends JPanel implements NotificationModelL scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setBorder(null); - scrollPane.getViewport().setBackground(UIUtil.getPanelBackgound()); + scrollPane.getViewport().setBackground(UIUtil.getPanelBackground()); final JComponent buttonBar = buildFilterBar(list, project); model.addListDataListener(new ListDataListener() { diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionButtonWithText.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionButtonWithText.java index e693bc68991c..ffa6f65acb06 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionButtonWithText.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionButtonWithText.java @@ -56,7 +56,7 @@ public class ActionButtonWithText extends ActionButton { final int textHeight = fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent(); UIUtil.applyRenderingHints(g); - g.setColor(isButtonEnabled() ? UIUtil.getLabelForeground() : UIUtil.getTextInactiveTextColor()); + g.setColor(isButtonEnabled() ? UIUtil.getLabelForeground() : UIUtil.getInactiveTextColor()); final int iconTextDifference = (int)Math.ceil((icon.getIconHeight() - textHeight) / 2); final int textStartX = x + icon.getIconWidth() + ICON_TEXT_SPACE; g.drawString(text, textStartX, y + iconTextDifference + fontMetrics.getMaxAscent()); diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 238ad166919c..73d6008c4535 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -278,7 +278,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application try { commandProcessor.executeCommand(project, new Runnable() { public void run() { - canClose.set(ProjectUtil.closeProject(project)); + canClose.set(ProjectUtil.closeAndDispose(project)); } }, ApplicationBundle.message("command.exit"), null); } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java b/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java index 48e30c96b41b..6ad8c09a138d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/ex/DiffStatusBar.java @@ -59,7 +59,7 @@ public class DiffStatusBar extends JPanel { private void addComponent(final LegendTypeDescriptor diffType) { JComponent component = new JPanel() { public void paint(Graphics g) { - setBackground(UIUtil.getPanelBackgound()); + setBackground(UIUtil.getPanelBackground()); super.paint(g); FontMetrics metrics = getFontMetrics(getFont()); diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFiles.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFiles.java index 6497dafcfc55..aa94de49c2b1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFiles.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/external/ExtCompareFiles.java @@ -21,6 +21,7 @@ import com.intellij.openapi.diff.impl.DiffUtil; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.FileTypes; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NonNls; @@ -75,10 +76,10 @@ class ExtCompareFiles extends BaseExternalTool { if (name.length() <= 3) name = "___" + name; File tempFile; try { - tempFile = File.createTempFile(name, extension); + tempFile = FileUtil.createTempFile(name, extension); } catch (IOException e) { - tempFile = File.createTempFile(STD_PREFIX, extension); + tempFile = FileUtil.createTempFile(STD_PREFIX, extension); } FileOutputStream stream = null; try { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/CutLineEndAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/CutLineEndAction.java index d42ec92ad09f..154423330c7c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/CutLineEndAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/CutLineEndAction.java @@ -40,10 +40,16 @@ import java.awt.datatransfer.StringSelection; public class CutLineEndAction extends EditorAction { public CutLineEndAction() { - super(new Handler()); + super(new Handler(true)); } - private static class Handler extends EditorWriteActionHandler { + static class Handler extends EditorWriteActionHandler { + private final boolean myCopyToClipboard; + + Handler(boolean copyToClipboard) { + myCopyToClipboard = copyToClipboard; + } + public void executeWriteAction(Editor editor, DataContext dataContext) { final Document doc = editor.getDocument(); if (doc.getLineCount() == 0) return; @@ -56,7 +62,9 @@ public class CutLineEndAction extends EditorAction { return; } - copyToClipboard(doc, caretOffset, lineEndOffset, dataContext, editor); + if (myCopyToClipboard) { + copyToClipboard(doc, caretOffset, lineEndOffset, dataContext, editor); + } final int lineStartOffset = doc.getLineStartOffset(lineNumber); if (StringUtil.isEmptyOrSpaces(doc.getCharsSequence().subSequence(lineStartOffset, lineEndOffset).toString())) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteToLineEndAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteToLineEndAction.java new file mode 100644 index 000000000000..b178ba89728c --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/DeleteToLineEndAction.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor.actions; + +import com.intellij.openapi.editor.actionSystem.EditorAction; + +/** + * @author yole + */ +public class DeleteToLineEndAction extends EditorAction { + public DeleteToLineEndAction() { + super(new CutLineEndAction.Handler(false)); + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java index ed49a6af9560..1759c91a9a98 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java @@ -148,13 +148,13 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { VisualPosition visualCaret = editor == null ? null : editor.getCaretModel().getVisualPosition(); int caretLine = editor == null ? -1 : editor.getCaretModel().getLogicalPosition().line; + int caretOffset = editor == null ? -1 : editor.getCaretModel().getOffset(); - boolean isTestMode = ApplicationManager.getApplication().isUnitTestMode(); boolean markAsNeedsStrippingLater = false; CharSequence text = myText.getCharArray(); for (int line = 0; line < myLineSet.getLineCount(); line++) { if (inChangedLinesOnly && !myLineSet.isModified(line)) continue; - int start = -1; + int whiteSpaceStart = -1; final int lineEnd = myLineSet.getLineEnd(line) - myLineSet.getSeparatorLength(line); int lineStart = myLineSet.getLineStart(line); for (int offset = lineEnd - 1; offset >= lineStart; offset--) { @@ -162,16 +162,16 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { if (c != ' ' && c != '\t') { break; } - start = offset; + whiteSpaceStart = offset; } - if (start == -1) continue; - if (!isTestMode && !isVirtualSpaceEnabled && caretLine == line) { + if (whiteSpaceStart == -1) continue; + if (!isVirtualSpaceEnabled && caretLine == line && whiteSpaceStart < caretOffset) { // mark this as a document that needs stripping later // otherwise the caret would jump madly markAsNeedsStrippingLater = true; } else { - final int finalStart = start; + final int finalStart = whiteSpaceStart; ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(this, editor == null ? null : editor.getProject()) { public void run() { CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() { diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java index cdfb57adb762..f33ffa721877 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java @@ -57,9 +57,6 @@ import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.ex.StatusBarEx; -import com.intellij.openapi.wm.ex.WindowManagerEx; -import com.intellij.openapi.wm.impl.FrameTitleBuilder; -import com.intellij.openapi.wm.impl.IdeFrameImpl; import com.intellij.ui.docking.DockContainer; import com.intellij.ui.docking.DockManager; import com.intellij.util.containers.ContainerUtil; @@ -76,7 +73,6 @@ import javax.swing.border.Border; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.io.File; import java.util.*; import java.util.List; @@ -1430,6 +1426,8 @@ private final class MyVirtualFileListener extends VirtualFileAdapter { VirtualFile[] files = eachWindow.getFiles(); for (int i = 0; i < files.length - 1 + 1; i++) { VirtualFile eachFile = files[i]; + if (!eachFile.isValid()) continue; + VirtualFile newFile = null; for (EditorFileSwapper each : swappers) { newFile = each.getFileToSwapTo(myProject, eachFile); diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/MouseShortcutDialog.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/MouseShortcutDialog.java index 81631b536deb..bc572d63d572 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/MouseShortcutDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/MouseShortcutDialog.java @@ -79,7 +79,7 @@ class MouseShortcutDialog extends DialogWrapper{ myTarConflicts=new JTextArea(); myTarConflicts.setFocusable(false); myTarConflicts.setEditable(false); - myTarConflicts.setBackground(UIUtil.getPanelBackgound()); + myTarConflicts.setBackground(UIUtil.getPanelBackground()); myTarConflicts.setLineWrap(true); myTarConflicts.setWrapStyleWord(true); diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.java index 2860a1a094ca..1ab3b908604a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.java @@ -330,7 +330,7 @@ public class QuickListPanel { setForeground(getSelectionForeground(tree)); } else { - Color foreground = used ? UIUtil.getTextInactiveTextColor() :UIUtil.getTreeForeground(); + Color foreground = used ? UIUtil.getInactiveTextColor() :UIUtil.getTreeForeground(); setForeground(foreground); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java index 5b015306d0d5..1bd749692730 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java @@ -349,8 +349,8 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl int nestingLevel = tree.isRootVisible() ? path.getPathCount() - 1 : path.getPathCount() - 2; - final int left = UIManager.getInt("Tree.leftChildIndent"); - final int right = UIManager.getInt("Tree.rightChildIndent"); + final int left = UIUtil.getTreeLeftChildIndent(); + final int right = UIUtil.getTreeRightChildIndent(); final Insets treeInsets = tree.getInsets(); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/ex/ProjectManagerEx.java b/platform/platform-impl/src/com/intellij/openapi/project/ex/ProjectManagerEx.java index 57585d86c2d7..0ad0edc7ed59 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/ex/ProjectManagerEx.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/ex/ProjectManagerEx.java @@ -21,6 +21,7 @@ import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.vfs.VirtualFile; import org.jdom.JDOMException; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -62,4 +63,7 @@ public abstract class ProjectManagerEx extends ProjectManager { @Nullable public abstract Project loadAndOpenProject(String filePath, boolean convert) throws IOException, JDOMException, InvalidDataException; + + // returns true on success + public abstract boolean closeAndDispose(@NotNull Project project); } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java index c473abf4c7d3..04e882a6a1d9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java @@ -322,7 +322,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx { ApplicationEx application = ApplicationManagerEx.getApplicationEx(); assert application.isDispatchThread(); - // can call dispose only via com.intellij.ide.impl.ProjectUtil.closeProject() + // can call dispose only via com.intellij.ide.impl.ProjectUtil.closeAndDispose() LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || !ProjectManagerEx.getInstanceEx().isProjectOpened(this)); LOG.assertTrue(!isDisposed()); diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java index be3d0e920fa3..3fe3ab53b2f3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java @@ -389,7 +389,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt }, ProjectBundle.message("project.load.progress"), true, project); if (!ok) { - closeProject(project, false); + closeProject(project, false, false); notifyProjectOpenFailed(); return false; } @@ -850,7 +850,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt return; } - if (project[0].isDisposed() || ProjectUtil.closeProject(project[0])) { + if (project[0].isDisposed() || ProjectUtil.closeAndDispose(project[0])) { application.runWriteAction(new Runnable() { public void run() { for (final IFile originalFile : original) { @@ -874,10 +874,10 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt */ public boolean closeProject(final Project project) { - return closeProject(project, true); + return closeProject(project, true, false); } - private boolean closeProject(final Project project, final boolean save) { + private boolean closeProject(final Project project, final boolean save, final boolean dispose) { if (!isProjectOpened(project)) return true; if (!canClose(project)) return false; @@ -889,16 +889,26 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt project.save(); } - if (ensureCouldCloseIfUnableToSave(project)) { - fireProjectClosing(project); - - myOpenProjects.remove(project); - cacheOpenProjects(); - - myChangedProjectFiles.remove(project); - fireProjectClosed(project); + if (!ensureCouldCloseIfUnableToSave(project)) { + return false; } - else return false; + + fireProjectClosing(project); // somebody can start progress here, do not wrap in write action + + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + myOpenProjects.remove(project); + cacheOpenProjects(); + + myChangedProjectFiles.remove(project); + + fireProjectClosed(project); + + if (dispose) { + Disposer.dispose(project); + } + } + }); } finally { shutDownTracker.unregisterStopperThread(Thread.currentThread()); @@ -907,6 +917,11 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt return true; } + @Override + public boolean closeAndDispose(@NotNull final Project project) { + return closeProject(project, true, true); + } + private void fireProjectClosing(Project project) { if (LOG.isDebugEnabled()) { LOG.debug("enter: fireProjectClosing()"); diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java index 6732d7adf5f4..d8ee30ef372b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java @@ -208,7 +208,7 @@ public class PluginDownloader { pluginsTemp.mkdirs(); } - File file = File.createTempFile("plugin", "download", pluginsTemp); + File file = FileUtil.createTempFile(pluginsTemp, "plugin", "download", true); int responseCode = connection.getResponseCode(); switch (responseCode) { diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java index 85a52d461d70..14857fc3bd50 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java @@ -62,21 +62,14 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua if (myFile != null) { return myFile.getName(); } - else { - int index = myUrl.lastIndexOf('/'); - return index >= 0 ? myUrl.substring(index + 1) : myUrl; - } + int index = myUrl.lastIndexOf('/'); + return index >= 0 ? myUrl.substring(index + 1) : myUrl; } public VirtualFile getFile() { checkDisposed(); update(); - if (myFile != null && !myFile.isValid()) { - myUrl = myFile.getUrl(); - myFile = null; - update(); - } return myFile; } @@ -84,6 +77,10 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua public String getUrl() { //checkDisposed(); no check here since Disposer might want to compute hashcode during dispose() update(); + return getUrlNoUpdate(); + } + + private String getUrlNoUpdate() { return myUrl == null ? myFile.getUrl() : myUrl; } @@ -151,6 +148,10 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua if (myLastUpdated == fsModCount) return; myLastUpdated = fsModCount; + if (myFile != null && !myFile.isValid()) { + myUrl = myFile.getUrl(); + myFile = null; + } if (myFile == null) { LOG.assertTrue(myUrl != null, "Both file & url are null"); myFile = myVirtualFileManager.findFileByUrl(myUrl); @@ -166,7 +167,7 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua @Override public String toString() { - return myFile == null ? myUrl : myFile.getUrl(); + return getUrlNoUpdate(); } public void dispose() { @@ -177,7 +178,7 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua if (TRACE_CREATION) { putUserData(KILL_TRACE, new Throwable()); } - String url = getUrl(); + String url = getUrlNoUpdate(); disposed = true; ((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).clearPointerCaches(url, myListener); } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java index bb3cd7695d04..193665a6caba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java @@ -162,7 +162,7 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider { final Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if (openProjects.length > 1) { if (myProject != null && myProject.isOpen()) { - ProjectUtil.closeProject(myProject); + ProjectUtil.closeAndDispose(myProject); } app.getMessageBus().syncPublisher(AppLifecycleListener.TOPIC).projectFrameClosed(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/Stripe.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/Stripe.java index b293b8c60e7c..b0ac04cde7e9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/Stripe.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/Stripe.java @@ -24,6 +24,7 @@ import com.intellij.openapi.keymap.ex.KeymapManagerEx; import com.intellij.openapi.keymap.ex.WeakKeymapManagerListener; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.wm.ToolWindowAnchor; +import com.intellij.util.ui.UIUtil; import javax.swing.*; import java.awt.*; @@ -333,7 +334,7 @@ final class Stripe extends JPanel{ } public void setOverlayed(boolean overlayed) { - Color bg = UIManager.getColor("Panel.background"); + Color bg = UIUtil.getPanelBackground(); if (overlayed) { setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), 190)); } else { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java index adf6866eacf3..45a2f7b137da 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java @@ -402,7 +402,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements label.setOpaque(true); final Color treeBg = UIManager.getColor("Tree.background"); label.setBackground(new Color(treeBg.getRed(), treeBg.getGreen(), treeBg.getBlue(), 180)); - final Color treeFg = UIManager.getColor("Tree.foreground"); + final Color treeFg = UIUtil.getTreeForeground(); label.setForeground(new Color(treeFg.getRed(), treeFg.getGreen(), treeFg.getBlue(), 180)); final ToolWindowFactory factory = bean.getToolWindowFactory(); final ToolWindowImpl toolWindow = diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java index fd8a68555de8..e160f4945b3f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java @@ -112,7 +112,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di size = (aqua ? 8 : 10); } myProcessName.setFont(font.deriveFont(Font.PLAIN, size)); - myProcessName.setForeground(UIManager.getColor("Panel.background").brighter().brighter()); + myProcessName.setForeground(UIUtil.getPanelBackground().brighter().brighter()); myProcessName.setBorder(new EmptyBorder(2, 2, 2, 2)); myProcessName.setDecorate(false); @@ -346,7 +346,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di int arc = 8; - g.setColor(UIManager.getColor("Panel.background")); + g.setColor(UIUtil.getPanelBackground()); g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc); Color bg = getBackground().darker().darker(); @@ -360,7 +360,7 @@ public class InlineProgressIndicator extends ProgressIndicatorBase implements Di g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc); - g.setColor(UIManager.getColor("Panel.background")); + g.setColor(UIUtil.getPanelBackground()); g.fillRoundRect(0, getHeight() / 2, getWidth() - 1, getHeight() / 2, arc, arc); g.fillRect(0, (int)label.getMaxY() + 1, getWidth() - 1, getHeight() / 2); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusBarUI.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusBarUI.java index 1f87fd6dcc6f..dbe3f867d0ff 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusBarUI.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusBarUI.java @@ -84,7 +84,7 @@ public class StatusBarUI extends ComponentUI { public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { final Graphics2D g2d = (Graphics2D) g.create(); - final Color background = UIUtil.getPanelBackgound(); + final Color background = UIUtil.getPanelBackground(); g2d.setColor(background); g2d.fillRect(0, 0, width, height); diff --git a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java index 7c2ef3ce2d20..c65e2bac9e46 100644 --- a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java +++ b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java @@ -75,7 +75,7 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor { if (!forceOpenInNewFrame && openProjects.length > 0) { int exitCode = ProjectUtil.confirmOpenNewProject(); if (exitCode == 1) { // "No" option - if (!ProjectUtil.closeProject(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null; + if (!ProjectUtil.closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null; } else if (exitCode != 0) { // not "Yes" return null; diff --git a/platform/platform-impl/src/com/intellij/ui/HorizontalLabeledIcon.java b/platform/platform-impl/src/com/intellij/ui/HorizontalLabeledIcon.java index 76b9144d87ff..d33b6d1ddfb6 100644 --- a/platform/platform-impl/src/com/intellij/ui/HorizontalLabeledIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/HorizontalLabeledIcon.java @@ -114,7 +114,7 @@ public class HorizontalLabeledIcon implements Icon { y += fontMetrics.getHeight(); } if (myMnemonic != null) { - g.setColor(UIUtil.getTextInactiveTextColor()); + g.setColor(UIUtil.getInactiveTextColor()); int offset = fontMetrics.stringWidth(myStrings[myStrings.length-1]+" "); y -= fontMetrics.getHeight(); g.drawString(myMnemonic, x + offset, y); diff --git a/platform/platform-impl/src/com/intellij/ui/LabeledIcon.java b/platform/platform-impl/src/com/intellij/ui/LabeledIcon.java index 5ef719dfbd69..8c728c5ba13b 100644 --- a/platform/platform-impl/src/com/intellij/ui/LabeledIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/LabeledIcon.java @@ -124,7 +124,7 @@ public class LabeledIcon implements Icon { if (myMnemonic != null) { y -= fontMetrics.getHeight(); - g.setColor(UIUtil.getTextInactiveTextColor()); + g.setColor(UIUtil.getInactiveTextColor()); int offset = getTextWidth() - fontMetrics.stringWidth(myMnemonic); g.drawString(myMnemonic, x + offset, y); } diff --git a/platform/platform-impl/src/com/intellij/ui/SeparatorComponent.java b/platform/platform-impl/src/com/intellij/ui/SeparatorComponent.java index ae20a803a532..6be7f19bc486 100644 --- a/platform/platform-impl/src/com/intellij/ui/SeparatorComponent.java +++ b/platform/platform-impl/src/com/intellij/ui/SeparatorComponent.java @@ -15,6 +15,8 @@ */ package com.intellij.ui; +import com.intellij.util.ui.UIUtil; + import javax.swing.*; import java.awt.*; @@ -94,7 +96,7 @@ public class SeparatorComponent extends JComponent { */ public static JComponent createLabbeledLineSeparator(final String titleText, final Color containerBackgroungColor) { JLabel titleLabel = new JLabel(titleText); - titleLabel.setFont(UIManager.getFont("Label.font")); + titleLabel.setFont(UIUtil.getLabelFont()); titleLabel.setForeground(Colors.DARK_BLUE); SeparatorComponent separatorComponent = new SeparatorComponent(5, containerBackgroungColor.darker(), containerBackgroungColor.brighter()); diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegCellRenderer.java b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegCellRenderer.java index 146394ba3c3e..36bc9562780e 100644 --- a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegCellRenderer.java +++ b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegCellRenderer.java @@ -48,15 +48,15 @@ public class BegCellRenderer extends JLabel implements TreeCellRenderer, ListCel } public Component getTreeCellRendererComponent(JTree tree, Object obj, boolean selected, boolean expanded, boolean leaf, int i1, boolean hasFocus) { - setFont(UIManager.getFont("Label.font")); + setFont(UIUtil.getLabelFont()); setLeafIcon(UIManager.getIcon("Tree.leafIcon")); setClosedIcon(UIManager.getIcon("Tree.closedIcon")); setOpenIcon(UIManager.getIcon("Tree.openIcon")); - setSelectionForeground(UIManager.getColor("Tree.selectionForeground")); - setTextForeground(UIManager.getColor("Tree.textForeground")); - setSelectionBackground(UIManager.getColor("Tree.selectionBackground")); - setTextBackground(UIManager.getColor("Tree.textBackground")); - setSelectionBorderColor(UIManager.getColor("Tree.selectionBorderColor")); + setSelectionForeground(UIUtil.getTreeSelectionForeground()); + setTextForeground(UIUtil.getTreeTextForeground()); + setSelectionBackground(UIUtil.getTreeSelectionBackground()); + setTextBackground(UIUtil.getTreeTextBackground()); + setSelectionBorderColor(UIUtil.getTreeSelectionBorderColor()); Object obj1 = UIManager.get("Tree.drawsFocusBorderAroundIcon"); myDrawsFocusBorderAroundIcon = obj1 != null && ((Boolean)obj1).booleanValue(); @@ -80,12 +80,12 @@ public class BegCellRenderer extends JLabel implements TreeCellRenderer, ListCel } public Component getListCellRendererComponent(JList list, Object obj, int index, boolean selected, boolean hasFocus) { - setFont(UIManager.getFont("Label.font")); - setSelectionForeground(UIManager.getColor("List.selectionForeground")); - setTextForeground(UIManager.getColor("List.foreground")); + setFont(UIUtil.getLabelFont()); + setSelectionForeground(UIUtil.getListSelectionForeground()); + setTextForeground(UIUtil.getListForeground()); setSelectionBackground(UIManager.getColor("List.selectionBackground")); - setTextBackground(UIManager.getColor("List.background")); - setSelectionBorderColor(UIManager.getColor("Tree.selectionBorderColor")); + setTextBackground(UIUtil.getListBackground()); + setSelectionBorderColor(UIUtil.getTreeSelectionBorderColor()); Object obj1 = UIManager.get("Tree.drawsFocusBorderAroundIcon"); myDrawsFocusBorderAroundIcon = obj1 != null && ((Boolean)obj1).booleanValue(); diff --git a/platform/platform-impl/src/com/intellij/ui/popup/PopupComponent.java b/platform/platform-impl/src/com/intellij/ui/popup/PopupComponent.java index aaa7ebeaf936..c4eb6386647b 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/PopupComponent.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/PopupComponent.java @@ -23,8 +23,6 @@ import com.intellij.util.ui.UIUtil; import javax.swing.*; import java.awt.*; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; public interface PopupComponent { @@ -140,7 +138,7 @@ public interface PopupComponent { if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) { final Component c = (Component)ReflectionUtil.getField(Popup.class, myPopup, Component.class, "component"); - c.setBackground(UIUtil.getPanelBackgound()); + c.setBackground(UIUtil.getPanelBackground()); } } diff --git a/platform/platform-impl/src/com/intellij/util/CachedValueBase.java b/platform/platform-impl/src/com/intellij/util/CachedValueBase.java index f919f3eb21e2..80021042ac54 100644 --- a/platform/platform-impl/src/com/intellij/util/CachedValueBase.java +++ b/platform/platform-impl/src/com/intellij/util/CachedValueBase.java @@ -58,11 +58,11 @@ public abstract class CachedValueBase { return new Data(value, null, null); } - TLongArrayList timeStamps = new TLongArrayList(); - List deps = new ArrayList(); + TLongArrayList timeStamps = new TLongArrayList(dependencies.length); + List deps = new ArrayList(dependencies.length); collectDependencies(timeStamps, deps, dependencies); - return new Data(value, ArrayUtil.toObjectArray(deps), timeStamps.toNativeArray()); + return new Data(value, ArrayUtil.toObjectArray(deps), timeStamps.toNativeArray()); } protected void setValue(final T value, final CachedValueProvider.Result result) { diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties index 31c03b502121..cc8ae5dda7d5 100644 --- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties +++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties @@ -301,3 +301,4 @@ export.test.results.open.browser=O&pen exported file in browser export.test.results.dialog.title=Export Test Results export.test.results.output.path.empty=Output path is empty export.test.results.output.filename.empty=Output file name is empty +configuration.edit.before.run=Show settings diff --git a/platform/platform-resources-en/src/messages/UIBundle.properties b/platform/platform-resources-en/src/messages/UIBundle.properties index deef01709675..2557467da05b 100644 --- a/platform/platform-resources-en/src/messages/UIBundle.properties +++ b/platform/platform-resources-en/src/messages/UIBundle.properties @@ -120,7 +120,7 @@ file.chooser.create.new.folder.command.name=Create New Folder file.chooser.create.new.file.command.name=Create New File file.cache.conflict.action=Reload From Disk file.cache.conflict.message.text=Changes have been made to \"{0}\"\nin memory and on disk. -file.cache.conflict.load.fs.changes.button=&Load FS Changes +file.cache.conflict.load.fs.changes.button=&Load File System Changes file.cache.conflict.keep.memory.changes.button=&Keep Memory Changes file.cache.conflict.show.difference.button=&Show difference file.cache.conflict.for.file.dialog.title=File Cache Conflict {0} diff --git a/platform/platform-resources/src/idea/Keymap_Eclipse.xml b/platform/platform-resources/src/idea/Keymap_Eclipse.xml index 7198e1f92409..6f749a03b42b 100644 --- a/platform/platform-resources/src/idea/Keymap_Eclipse.xml +++ b/platform/platform-resources/src/idea/Keymap_Eclipse.xml @@ -59,7 +59,7 @@ - + diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 55c40538ce57..d571195faca2 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -57,6 +57,7 @@ + diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 7896c18581eb..56ddb38702ef 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -175,7 +175,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da private static void initProject(final LightProjectDescriptor descriptor) throws Exception { ourProjectDescriptor = descriptor; - final File projectFile = File.createTempFile("lighttemp", ProjectFileType.DOT_DEFAULT_EXTENSION); + final File projectFile = FileUtil.createTempFile("lighttemp", ProjectFileType.DOT_DEFAULT_EXTENSION); new WriteCommandAction.Simple(null) { @Override diff --git a/platform/testFramework/src/com/intellij/testFramework/TempFiles.java b/platform/testFramework/src/com/intellij/testFramework/TempFiles.java index cde2c052fc5b..0879bc3db3a5 100644 --- a/platform/testFramework/src/com/intellij/testFramework/TempFiles.java +++ b/platform/testFramework/src/com/intellij/testFramework/TempFiles.java @@ -47,7 +47,7 @@ public class TempFiles { } public File createTempFile(String prefix, String postfix) throws IOException { - File tempFile = File.createTempFile(prefix, postfix); + File tempFile = FileUtil.createTempFile(prefix, postfix); tempFileCreated(tempFile); return tempFile; } diff --git a/platform/testFramework/src/com/intellij/testFramework/Timings.java b/platform/testFramework/src/com/intellij/testFramework/Timings.java index d3fbb5b130b6..b1de9b99cce8 100644 --- a/platform/testFramework/src/com/intellij/testFramework/Timings.java +++ b/platform/testFramework/src/com/intellij/testFramework/Timings.java @@ -15,6 +15,8 @@ */ package com.intellij.testFramework; +import com.intellij.openapi.util.io.FileUtil; + import java.io.File; import java.io.FileReader; import java.io.FileWriter; @@ -34,7 +36,7 @@ public class Timings { } for (int i = 0; i < 42; i++) { try { - final File tempFile = File.createTempFile("test", "test" + i); + final File tempFile = FileUtil.createTempFile("test", "test" + i); final FileWriter writer = new FileWriter(tempFile); for (int j = 0; j < 15; j++) { writer.write("test" + j); diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index c72ec9ec4d86..cc940ba9a9aa 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -20,7 +20,6 @@ import com.intellij.diagnostic.PerformanceWatcher; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; @@ -62,13 +61,13 @@ import java.util.*; * @author peter */ public abstract class UsefulTestCase extends TestCase { - private static final Logger LOG = Logger.getInstance("#com.intellij.testFramework.UsefulTestCase"); - protected final Disposable myTestRootDisposable = Disposer.newDisposable(); private static final String DEFAULT_SETTINGS_EXTERNALIZED; - private static CodeStyleSettings myOldCodeStyleSettings; - private static final Random ourPRNG = new SecureRandom(); - private static final String ourOriginalTempDir = FileUtil.getTempDirectory(); - private File myTempDir; + private static final Random PRNG = new SecureRandom(); + private static final String ORIGINAL_TEMP_DIR = FileUtil.getTempDirectory(); + + protected final Disposable myTestRootDisposable = Disposer.newDisposable(); + private CodeStyleSettings myOldCodeStyleSettings; + private String myTempDir; protected static final Key CREATION_PLACE = Key.create("CREATION_PLACE"); @@ -98,11 +97,8 @@ public abstract class UsefulTestCase extends TestCase { if (shouldContainTempFiles()) { String testName = getTestName(true); if (StringUtil.isEmptyOrSpaces(testName)) testName = "unitTest"; - final String tempDirPath = ourOriginalTempDir + "/" + testName + ourPRNG.nextInt(Integer.MAX_VALUE); - setTmpDir(tempDirPath); - myTempDir = new File(tempDirPath); - assertTrue("can't setup temp directory: " + tempDirPath, - myTempDir.mkdirs()); + myTempDir = ORIGINAL_TEMP_DIR + "/" + testName + PRNG.nextInt(Integer.MAX_VALUE); + FileUtil.resetCanonicalTempPathCache(myTempDir); } } @@ -112,8 +108,8 @@ public abstract class UsefulTestCase extends TestCase { cleanupSwingDataStructures(); if (shouldContainTempFiles()) { - FileUtil.asyncDelete(myTempDir); - setTmpDir(ourOriginalTempDir); + FileUtil.resetCanonicalTempPathCache(ORIGINAL_TEMP_DIR); + FileUtil.delete(new File(myTempDir)); } super.tearDown(); @@ -680,22 +676,4 @@ public abstract class UsefulTestCase extends TestCase { } } } - - private static void setTmpDir(String path) { - System.setProperty("java.io.tmpdir", path); - FileUtil.resetCanonicalTempPathCache(); - - try { - Class ioFile = File.class; - Field field = ioFile.getDeclaredField("tmpdir"); - field.setAccessible(true); - field.set(ioFile, null); - } - catch (NoSuchFieldException ignore) { - // field was removed in JDK 1.6.0_12 - } - catch (IllegalAccessException e) { - LOG.error(e); - } - } } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index a38c02774452..2d97784f8c58 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -1090,7 +1090,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig if (prefix.length() < 3) { prefix += "___"; } - final File tempFile = File.createTempFile(prefix, "." + StringUtil.getShortName(fileName), new File(getTempDirPath())); + final File tempFile = FileUtil.createTempFile(new File(getTempDirPath()), prefix, "." + StringUtil.getShortName(fileName), true); vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempFile); } VfsUtil.saveText(vFile, text); diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java index 43be8974f7e9..079469db7331 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java @@ -135,7 +135,7 @@ class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTestFixtu new WriteCommandAction.Simple(null) { @Override protected void run() throws Throwable { - File projectFile = File.createTempFile(PROJECT_FILE_PREFIX, PROJECT_FILE_SUFFIX); + File projectFile = FileUtil.createTempFile(PROJECT_FILE_PREFIX, PROJECT_FILE_SUFFIX); myFilesToDelete.add(projectFile); LocalFileSystem.getInstance().refreshAndFindFileByIoFile(projectFile); diff --git a/platform/testRunner/src/com/intellij/execution/testframework/CompositePrintable.java b/platform/testRunner/src/com/intellij/execution/testframework/CompositePrintable.java index c4eaad143960..1792a74f40bf 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/CompositePrintable.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/CompositePrintable.java @@ -39,7 +39,7 @@ public class CompositePrintable implements Printable, Disposable { public void flush() { if (myWrapper == null) { try { - myWrapper = new PrintablesWrapper(File.createTempFile("frst", "scd")); + myWrapper = new PrintablesWrapper(FileUtil.createTempFile("frst", "scd")); } catch (IOException ignored) { } diff --git a/platform/util/src/com/intellij/execution/rmi/RemoteServer.java b/platform/util/src/com/intellij/execution/rmi/RemoteServer.java index 9f9862e605a2..9c512bbdf7dc 100644 --- a/platform/util/src/com/intellij/execution/rmi/RemoteServer.java +++ b/platform/util/src/com/intellij/execution/rmi/RemoteServer.java @@ -24,6 +24,8 @@ import java.util.Random; public class RemoteServer { protected static void start(Remote remote) throws Exception { + setupRMI(); + Registry registry; int port = 0; for (Random random = new Random(); ;) { @@ -52,4 +54,14 @@ public class RemoteServer { System.exit(1); } } + + public static void setupRMI() { + // this properties are necessary for RMI servers to work in some cases: + // if we are behind a firewall, if the network connection is lost, etc. + + // do not use domain or http address for server + System.setProperty("java.rmi.server.hostname", "localhost"); + // do not use http tunnelling + System.setProperty("java.rmi.server.disableHttp", "true"); + } } diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index f2f047e1b22d..b08884e801cd 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -28,6 +28,7 @@ import org.intellij.lang.annotations.RegExp; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import java.io.*; import java.lang.reflect.Method; @@ -53,8 +54,6 @@ public class FileUtil { private static final long CHANNELS_COPYING_LIMIT = 5L * 1024L * 1024L; private static String ourCanonicalTempPathCache = null; - //private static final byte[] BUFFER = new byte[1024 * 20]; - @Nullable public static String getRelativePath(File base, File file) { if (base == null || file == null) return null; @@ -370,6 +369,7 @@ public class FileUtil { int exceptionsCount = 0; while(true){ try{ + //noinspection SSBasedInspection return File.createTempFile(prefix, suffix, dir).getCanonicalFile(); } catch(IOException e){ // Win32 createFileExclusively access denied @@ -387,8 +387,9 @@ public class FileUtil { return ourCanonicalTempPathCache; } - public static void resetCanonicalTempPathCache() { - ourCanonicalTempPathCache = null; + @TestOnly + public static void resetCanonicalTempPathCache(final String tempPath) { + ourCanonicalTempPathCache = tempPath; } private static String calcCanonicalTempPath() { diff --git a/platform/util/src/com/intellij/ui/TitlePanel.java b/platform/util/src/com/intellij/ui/TitlePanel.java index f970ce1b3285..8c93962ad9ea 100644 --- a/platform/util/src/com/intellij/ui/TitlePanel.java +++ b/platform/util/src/com/intellij/ui/TitlePanel.java @@ -16,6 +16,8 @@ package com.intellij.ui; +import com.intellij.util.ui.UIUtil; + import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; @@ -55,7 +57,7 @@ public class TitlePanel extends CaptionPanel { public void setActive(final boolean active) { super.setActive(active); myLabel.setIcon(active ? myRegular : myInactive); - myLabel.setForeground(active ? UIManager.getColor("Label.foreground") : Color.gray); + myLabel.setForeground(active ? UIUtil.getLabelForeground() : Color.gray); } public void setText(String titleText) { diff --git a/platform/util/src/com/intellij/util/ui/MacUIUtil.java b/platform/util/src/com/intellij/util/ui/MacUIUtil.java index 481372696fc2..458da7cd41ff 100644 --- a/platform/util/src/com/intellij/util/ui/MacUIUtil.java +++ b/platform/util/src/com/intellij/util/ui/MacUIUtil.java @@ -50,7 +50,7 @@ public class MacUIUtil { final int width1 = width - 8; final int height1 = height - 6; - g.setColor(UIUtil.getPanelBackgound()); + g.setColor(UIUtil.getPanelBackground()); g.fillRect(x, y, width, height); g.setColor(c.getBackground()); diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index fe398d6afb39..d19ae46b0da8 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -111,7 +111,7 @@ public class UIUtil { public static void setEnabled(Component component, boolean enabled, boolean recursively) { component.setEnabled(enabled); if (component instanceof JLabel) { - Color color = UIManager.getColor(enabled ? "Label.foreground" : "Label.disabledForeground"); + Color color = enabled ? getLabelForeground() : UIManager.getColor("Label.disabledForeground"); if (color != null) { component.setForeground(color); } @@ -198,8 +198,11 @@ public class UIUtil { return UIManager.getIcon("OptionPane.warningIcon"); } + /** + * @deprecated use com.intellij.util.ui.UIUtil#getQuestionIcon() + */ public static Icon getOptionPanelQuestionIcon() { - return UIManager.getIcon("OptionPane.questionIcon"); + return getQuestionIcon(); } @NotNull @@ -300,8 +303,11 @@ public class UIUtil { return UIManager.getColor("textInactiveText"); } + /** + * @deprecated use com.intellij.util.ui.UIUtil#getTextFieldBackground() + */ public static Color getActiveTextFieldBackgroundColor() { - return UIManager.getColor("TextField.background"); + return getTextFieldBackground(); } public static Color getInactiveTextFieldBackgroundColor() { @@ -320,8 +326,11 @@ public class UIUtil { return UIManager.getColor("Tree.selectionForeground"); } + /** + * @deprecated use com.intellij.util.ui.UIUtil#getInactiveTextColor() + */ public static Color getTextInactiveTextColor() { - return UIManager.getColor("textInactiveText"); + return getInactiveTextColor(); } public static void installPopupMenuColorAndFonts(final JComponent contentPane) { @@ -340,12 +349,12 @@ public class UIUtil { return UIManager.getColor("Tree.selectionBorderColor"); } - public static Object getTreeRightChildIndent() { - return UIManager.get("Tree.rightChildIndent"); + public static int getTreeRightChildIndent() { + return UIManager.getInt("Tree.rightChildIndent"); } - public static Object getTreeLeftChildIndent() { - return UIManager.get("Tree.leftChildIndent"); + public static int getTreeLeftChildIndent() { + return UIManager.getInt("Tree.leftChildIndent"); } public static Color getToolTipBackground() { @@ -402,7 +411,7 @@ public class UIUtil { public static Color getListBackground() { // Fixes most of the GTK+ L&F glitches - return UIUtil.isUnderGTKLookAndFeel() ? getTreeTextBackground() : UIManager.getColor("List.background"); + return isUnderGTKLookAndFeel() ? getTreeTextBackground() : UIManager.getColor("List.background"); } public static Color getListForeground() { @@ -418,7 +427,7 @@ public class UIUtil { } public static Color getTableFocusCellBackground() { - return UIManager.getColor("Table.focusCellBackground"); + return UIManager.getColor(TABLE_FOCUS_CELL_BACKGROUND_PROPERTY); } public static Color getListSelectionBackground() { @@ -494,11 +503,14 @@ public class UIUtil { } public static Color getTableFocusCellForeground() { - return UIManager.getColor("Table.focusCellForeground"); + return UIManager.getColor("Table.focusCellForeground"); } + /** + * @deprecated use com.intellij.util.ui.UIUtil#getPanelBackground() instead + */ public static Color getPanelBackgound() { - return UIManager.getColor("Panel.background"); + return getPanelBackground(); } public static Border getTextFieldBorder() { @@ -1036,7 +1048,7 @@ public class UIUtil { URL resource = liImg != null ? SystemInfo.class.getResource(liImg) : null; String fontFamilyAndSize = "font-family:" + font.getFamily() + "; font-size:" + font.getSize() + ";"; - @Language("CSS") + //@Language("CSS") String body = "body, div, td {" + fontFamilyAndSize + " " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + "}"; if (resource != null) { body += "ul {list-style-image: " + resource.toExternalForm() +"}"; @@ -1051,8 +1063,8 @@ public class UIUtil { public static boolean isStandardMenuLAF() { return isWinLafOnVista() || - "Nimbus".equals(UIManager.getLookAndFeel().getName()) || - "GTK look and feel".equals(UIManager.getLookAndFeel().getName()); + isUnderNimbusLookAndFeel() || + isUnderGTKLookAndFeel(); } public static Color getFocusedFillColor() { @@ -1223,7 +1235,7 @@ public class UIUtil { public static HTMLEditorKit getHTMLEditorKit() { final HTMLEditorKit kit = new HTMLEditorKit(); - Font font = UIManager.getFont("Label.font"); + Font font = getLabelFont(); @NonNls String family = font != null ? font.getFamily() : "Tahoma"; int size = font != null ? font.getSize() : 11; @@ -1296,7 +1308,7 @@ public class UIUtil { @NonNls public static String toHtml(String html, final int hPadding) { html = CLOSE_TAG_PATTERN.matcher(html).replaceAll("<$1$2>"); - Font font = UIManager.getFont("Label.font"); + Font font = getLabelFont(); @NonNls String family = font != null ? font.getFamily() : "Tahoma"; int size = font != null ? font.getSize() : 11; return "