diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java index 404f77cd6cd1..99b914cceb73 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerPanelsManager.java @@ -33,11 +33,12 @@ import com.intellij.execution.configurations.RemoteState; import com.intellij.execution.configurations.RunProfileState; import com.intellij.execution.executors.DefaultDebugExecutor; import com.intellij.execution.process.ProcessHandler; -import com.intellij.execution.runners.ProgramRunner; import com.intellij.execution.runners.ExecutionEnvironment; +import com.intellij.execution.runners.ProgramRunner; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.execution.ui.RunContentListener; import com.intellij.execution.ui.RunContentManager; +import com.intellij.openapi.Disposable; import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.colors.EditorColorsListener; @@ -45,7 +46,6 @@ import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.Disposable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -121,7 +121,7 @@ public class DebuggerPanelsManager implements ProjectComponent { debugProcess.putUserData(BatchEvaluator.REMOTE_SESSION_KEY, Boolean.TRUE); } - final DebuggerSessionTab sessionTab = new DebuggerSessionTab(myProject, debuggerSession.getSessionName()); + final DebuggerSessionTab sessionTab = new DebuggerSessionTab(myProject, debuggerSession.getSessionName(), environment.getRunProfile().getIcon()); Disposer.register(myProject, sessionTab); RunContentDescriptor runContentDescriptor = sessionTab.attachToSession(debuggerSession, runner, environment); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java index 3fc61b33e3a2..1e155c23262e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java @@ -99,10 +99,12 @@ public class DebuggerSessionTab extends DebuggerLogConsoleManagerBase implements public static final String BREAKPOINT_CONDITION = "breakpoint"; private final ThreadsPanel myThreadsPanel; private static final String THREAD_DUMP_CONTENT_PREFIX = "Dump"; + private Icon myIcon; - public DebuggerSessionTab(Project project, String sessionName) { + public DebuggerSessionTab(final Project project, final String sessionName, @Nullable final Icon icon) { super(project); + myIcon = icon; myUi = RunnerLayoutUi.Factory.getInstance(project).create("JavaDebugger", DebuggerBundle.message("title.generic.debug.dialog"), sessionName, this); @@ -253,7 +255,7 @@ public class DebuggerSessionTab extends DebuggerLogConsoleManagerBase implements private RunContentDescriptor initUI(ExecutionResult executionResult) { myConsole = executionResult.getExecutionConsole(); - myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName()); + myRunContentDescriptor = new RunContentDescriptor(myConsole, executionResult.getProcessHandler(), myUi.getComponent(), getSessionName(), myIcon); if (ApplicationManager.getApplication().isUnitTestMode()) { return myRunContentDescriptor; diff --git a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java index c1b77a81db2c..493d50a78ca6 100644 --- a/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java +++ b/java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java @@ -34,6 +34,8 @@ import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; + /** * @author spleaner */ @@ -41,14 +43,14 @@ public class JavaExecutionUtil { private JavaExecutionUtil() { } - public static boolean executeRun(@NotNull final Project project, String contentName, + public static boolean executeRun(@NotNull final Project project, String contentName, Icon icon, final DataContext dataContext) throws ExecutionException { - return executeRun(project, contentName, dataContext, null); + return executeRun(project, contentName, icon, dataContext, null); } - public static boolean executeRun(@NotNull final Project project, String contentName, DataContext dataContext, Filter[] filters) throws ExecutionException { + public static boolean executeRun(@NotNull final Project project, String contentName, Icon icon, DataContext dataContext, Filter[] filters) throws ExecutionException { final JavaParameters cmdLine = JavaParameters.JAVA_PARAMETERS.getData(dataContext); - final DefaultRunProfile profile = new DefaultRunProfile(project, cmdLine, contentName, filters); + final DefaultRunProfile profile = new DefaultRunProfile(project, cmdLine, contentName, icon, filters); final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(DefaultRunExecutor.EXECUTOR_ID, profile); if (runner != null) { runner.execute(DefaultRunExecutor.getRunExecutorInstance(), new ExecutionEnvironment(profile, dataContext)); @@ -63,12 +65,18 @@ public class JavaExecutionUtil { private final String myContentName; private final Filter[] myFilters; private final Project myProject; + private Icon myIcon; - public DefaultRunProfile(final Project project, final JavaParameters parameters, String contentName, Filter[] filters) { + public DefaultRunProfile(final Project project, final JavaParameters parameters, final String contentName, final Icon icon, Filter[] filters) { myProject = project; myParameters = parameters; myContentName = contentName; myFilters = filters; + myIcon = icon; + } + + public Icon getIcon() { + return myIcon; } public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java index 29e314911328..48b579f2435b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java @@ -37,14 +37,14 @@ public class ExtendsListFix implements IntentionAction, LocalQuickFix { private final boolean myToAdd; private final PsiClassType myTypeToExtendFrom; - public ExtendsListFix(PsiClass aClass, PsiClassType typeToExtendFrom, boolean toAdd) { + public ExtendsListFix(@NotNull PsiClass aClass, @NotNull PsiClassType typeToExtendFrom, boolean toAdd) { myClass = aClass; myClassToExtendFrom = typeToExtendFrom.resolve(); myTypeToExtendFrom = typeToExtendFrom; myToAdd = toAdd; } - public ExtendsListFix(PsiClass aClass, PsiClass classToExtendFrom, boolean toAdd) { + public ExtendsListFix(@NotNull PsiClass aClass, @NotNull PsiClass classToExtendFrom, boolean toAdd) { myClass = aClass; myClassToExtendFrom = classToExtendFrom; myTypeToExtendFrom = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(classToExtendFrom); @@ -126,7 +126,7 @@ public class ExtendsListFix implements IntentionAction, LocalQuickFix { PsiJavaCodeReferenceElement[] referenceElements = extendsList.getReferenceElements(); boolean alreadyExtends = false; for (PsiJavaCodeReferenceElement referenceElement : referenceElements) { - if (referenceElement.resolve() == myClassToExtendFrom) { + if (referenceElement.getManager().areElementsEquivalent(myClassToExtendFrom, referenceElement.resolve())) { alreadyExtends = true; if (!add) { referenceElement.delete(); diff --git a/java/java-impl/src/com/intellij/ide/fileTemplates/JavaCreateFromTemplateHandler.java b/java/java-impl/src/com/intellij/ide/fileTemplates/JavaCreateFromTemplateHandler.java index 866183fdbf46..5f2018c9700c 100644 --- a/java/java-impl/src/com/intellij/ide/fileTemplates/JavaCreateFromTemplateHandler.java +++ b/java/java-impl/src/com/intellij/ide/fileTemplates/JavaCreateFromTemplateHandler.java @@ -15,12 +15,13 @@ */ package com.intellij.ide.fileTemplates; +import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx; +import com.intellij.openapi.project.Project; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx; import com.intellij.util.IncorrectOperationException; import java.util.Properties; @@ -56,6 +57,18 @@ public class JavaCreateFromTemplateHandler implements CreateFromTemplateHandler else{ JavaDirectoryService.getInstance().checkCreateClass(directory, className); } + + final LanguageLevel ll = JavaDirectoryService.getInstance().getLanguageLevel(directory); + if (ll.compareTo(LanguageLevel.JDK_1_5) < 0) { + if (createdClass.isAnnotationType()) { + throw new IncorrectOperationException("Annotations only supported at language level 1.5 and higher"); + } + + if (createdClass.isEnum()) { + throw new IncorrectOperationException("Enums only supported at language level 1.5 and higher"); + } + } + psiJavaFile = (PsiJavaFile)psiJavaFile.setName(fileName); PsiElement addedElement = directory.add(psiJavaFile); if (addedElement instanceof PsiJavaFile) { diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java index 06801b122828..aa616ec4734e 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java @@ -49,6 +49,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.io.File; import java.util.ArrayList; import java.util.Collection; @@ -117,6 +118,10 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl return new JavadocConfigurable(this); } + public Icon getIcon() { + return null; + } + @NotNull public Module[] getModules() { return Module.EMPTY_ARRAY; diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveJavaFileHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveJavaFileHandler.java index 3810b2a29d07..69264c50165a 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveJavaFileHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveJavaFileHandler.java @@ -22,6 +22,7 @@ package com.intellij.refactoring.move.moveClassesOrPackages; import com.intellij.codeInsight.ChangeContextUtil; import com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFileHandler; @@ -35,6 +36,7 @@ import java.util.List; import java.util.Map; public class MoveJavaFileHandler extends MoveFileHandler { + private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.move.moveClassesOrPackages.MoveJavaFileHandler"); @Override public boolean canProcessElement(PsiFile element) { return element instanceof PsiJavaFile && !JspPsiUtil.isInJspFile(element) && !CollectHighlightsUtil.isOutsideSourceRootJavaFile(element); @@ -69,7 +71,11 @@ public class MoveJavaFileHandler extends MoveFileHandler { final PsiElement newElement = oldToNewMap.get(oldElement); final PsiReference reference = moveRenameUsage.getReference(); if (reference != null) { - reference.bindToElement(newElement); + try { + reference.bindToElement(newElement); + } catch (IncorrectOperationException ex) { + LOG.error(ex); + } } } } diff --git a/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java b/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java index cf93fdefc5ed..9b3b6b23a435 100644 --- a/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java +++ b/java/java-impl/src/com/intellij/unscramble/UnscrambleListener.java @@ -28,15 +28,13 @@ import java.util.regex.Pattern; * @author Konstantin Bulenkov */ public class UnscrambleListener extends ApplicationAdapter { - private static final int MAX_STACKTRACE_SIZE = 15*1024; //15Kb + private static final int MAX_STACKTRACE_SIZE = 15 * 1024; //15Kb private String stacktrace = null; @Override public void applicationActivated(IdeFrame ideFrame) { final String clipboard = getClipboardContents(); - if (clipboard != null - && clipboard.length() < MAX_STACKTRACE_SIZE - && !clipboard.equals(stacktrace)) { + if (clipboard != null && clipboard.length() < MAX_STACKTRACE_SIZE && !clipboard.equals(stacktrace)) { stacktrace = clipboard; if (isStacktrace(stacktrace)) { new UnscrambleDialog(ideFrame.getProject()).doOKAction(); @@ -51,20 +49,22 @@ public class UnscrambleListener extends ApplicationAdapter { public static String getClipboardContents() { String result = ""; - final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - final Transferable contents = clipboard.getContents(null); - final boolean hasTransferableText = (contents != null) && contents.isDataFlavorSupported(DataFlavor.stringFlavor); - if (hasTransferableText) { - try { + try { + final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + final Transferable contents = clipboard.getContents(null); + final boolean hasTransferableText = (contents != null) && contents.isDataFlavorSupported(DataFlavor.stringFlavor); + if (hasTransferableText) { result = (String)contents.getTransferData(DataFlavor.stringFlavor); } - catch (Exception ex){// - } + } + catch (Exception e) {// } return result; } - private static final Pattern STACKTRACE_LINE = Pattern.compile("[\t]*at [[a-zA-Z0-9]+\\.]+[a-zA-Z$0-9]+\\.[a-zA-Z0-9_]+\\([A-Za-z0-9_]+\\.java:[\\d]+\\)"); + private static final Pattern STACKTRACE_LINE = + Pattern.compile("[\t]*at [[a-zA-Z0-9]+\\.]+[a-zA-Z$0-9]+\\.[a-zA-Z0-9_]+\\([A-Za-z0-9_]+\\.java:[\\d]+\\)"); + public static boolean isStacktrace(String stacktrace) { int linesCount = 0; for (String line : stacktrace.split("\n")) { @@ -74,7 +74,8 @@ public class UnscrambleListener extends ApplicationAdapter { } if (STACKTRACE_LINE.matcher(line).matches()) { linesCount++; - } else { + } + else { linesCount = 0; } if (linesCount > 2) return true; diff --git a/lib/commons-net-1.4.1.jar b/lib/commons-net-1.4.1.jar deleted file mode 100644 index 9666a92c8009..000000000000 Binary files a/lib/commons-net-1.4.1.jar and /dev/null differ diff --git a/lib/commons-net-2.0-patched.jar b/lib/commons-net-2.0-patched.jar new file mode 100644 index 000000000000..127306f10225 Binary files /dev/null and b/lib/commons-net-2.0-patched.jar differ diff --git a/lib/src/commons-net-1.4.1-src.zip b/lib/src/commons-net-1.4.1-src.zip deleted file mode 100644 index 14237a28d602..000000000000 Binary files a/lib/src/commons-net-1.4.1-src.zip and /dev/null differ diff --git a/lib/src/commons-net-2.0-patched-src.zip b/lib/src/commons-net-2.0-patched-src.zip new file mode 100644 index 000000000000..d9293b20b394 Binary files /dev/null and b/lib/src/commons-net-2.0-patched-src.zip differ diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java index 255ecfaa6394..fa4742cdfde1 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java @@ -27,6 +27,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.ArrayList; import java.util.List; @@ -42,11 +43,13 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements private ArrayList myPredefinedLogFiles = new ArrayList(); @NonNls private static final String LOG_FILE = "log_file"; @NonNls private static final String PREDEFINED_LOG_FILE_ELEMENT = "predefined_log_file"; + private Icon myIcon; - protected RunConfigurationBase(Project project, ConfigurationFactory factory, String name) { + protected RunConfigurationBase(final Project project, final ConfigurationFactory factory, final String name) { myProject = project; myFactory = factory; myName = name; + myIcon = factory.getIcon(); } public int getUniqueID() { @@ -70,6 +73,10 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements return myFactory.getType(); } + public Icon getIcon() { + return myIcon; + } + public final String getName() { return myName; } diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunProfile.java b/platform/lang-api/src/com/intellij/execution/configurations/RunProfile.java index ed3d4cf18a37..43c22521468a 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/RunProfile.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/RunProfile.java @@ -21,6 +21,8 @@ import com.intellij.execution.runners.ExecutionEnvironment; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; + public interface RunProfile { /** * todo - javadoc @@ -30,6 +32,9 @@ public interface RunProfile { String getName(); + @Nullable + Icon getIcon(); + void checkConfiguration() throws RuntimeConfigurationException; } diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RuntimeConfiguration.java b/platform/lang-api/src/com/intellij/execution/configurations/RuntimeConfiguration.java index ab0a5d781215..cdaa7ecd26eb 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/RuntimeConfiguration.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/RuntimeConfiguration.java @@ -24,6 +24,8 @@ import com.intellij.openapi.util.JDOMExternalizable; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import javax.swing.*; + public abstract class RuntimeConfiguration extends RunConfigurationBase implements LocatableConfiguration, Cloneable, ModuleRunConfiguration { protected RuntimeConfiguration(final String name, final Project project, final ConfigurationFactory factory) { super(project, factory, name); diff --git a/platform/lang-api/src/com/intellij/execution/configurations/UnknownRunConfiguration.java b/platform/lang-api/src/com/intellij/execution/configurations/UnknownRunConfiguration.java index 763a35ad6885..47d3c250c28e 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/UnknownRunConfiguration.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/UnknownRunConfiguration.java @@ -29,6 +29,7 @@ import com.intellij.openapi.util.WriteExternalException; import org.jdom.Attribute; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.List; @@ -55,6 +56,11 @@ public class UnknownRunConfiguration implements RunConfiguration { myDoNotStore = b; } + @Nullable + public Icon getIcon() { + return null; + } + public boolean isDoNotStore() { return myDoNotStore; } diff --git a/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java b/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java index 67365ce9179a..52a6176dc1cb 100644 --- a/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java +++ b/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java @@ -34,18 +34,21 @@ public class RunContentDescriptor { private final ProcessHandler myProcessHandler; private final JComponent myComponent; private final String myDisplayName; + private final Icon myIcon; + /** * Used to hack {@link com.intellij.execution.runners.RestartAction} */ private Content myContent; public RunContentDescriptor(final ExecutionConsole executionConsole, - final ProcessHandler processHandler, final JComponent component, final String displayName) { + final ProcessHandler processHandler, final JComponent component, final String displayName, final Icon icon) { LOG.assertTrue(executionConsole != null || ApplicationManager.getApplication().isUnitTestMode()); myExecutionConsole = executionConsole; myProcessHandler = processHandler; myComponent = component; myDisplayName = displayName; + myIcon = icon; myComponent.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, new DataProvider() { public Object getData(@NonNls final String dataId) { @@ -55,7 +58,11 @@ public class RunContentDescriptor { return null; } }); + } + public RunContentDescriptor(final ExecutionConsole executionConsole, + final ProcessHandler processHandler, final JComponent component, final String displayName) { + this(executionConsole, processHandler, component, displayName, null); } public ExecutionConsole getExecutionConsole() { @@ -66,6 +73,11 @@ public class RunContentDescriptor { Disposer.dispose(myExecutionConsole); } + @Nullable + public Icon getIcon() { + return myIcon; + } + @Nullable public ProcessHandler getProcessHandler() { return myProcessHandler; diff --git a/platform/lang-api/src/com/intellij/patterns/VirtualFilePattern.java b/platform/lang-api/src/com/intellij/patterns/VirtualFilePattern.java index 5494c73ef98e..a417c914bf28 100644 --- a/platform/lang-api/src/com/intellij/patterns/VirtualFilePattern.java +++ b/platform/lang-api/src/com/intellij/patterns/VirtualFilePattern.java @@ -65,6 +65,24 @@ public class VirtualFilePattern extends TreeElementPattern namespacePattern) { + return with(new PatternCondition("xmlWithRootTagNamespace") { + public boolean accepts(@NotNull final VirtualFile virtualFile, final ProcessingContext context) { + try { + String rootTagNamespace = NanoXmlUtil.parseHeaderWithException(virtualFile).getRootTagNamespace(); + return rootTagNamespace != null && namespacePattern.getCondition().accepts(rootTagNamespace, context); + } + catch (IOException e) { + return false; + } + } + }); + } protected VirtualFile getParent(@NotNull final VirtualFile t) { return t.getParent(); 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 29d9f868295c..a855a6b4d4c4 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationAction.java @@ -43,6 +43,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -66,7 +68,17 @@ public class ChooseRunConfigurationAction extends AnAction { final Executor executor = getDefaultExecutor(); assert executor != null; - final RunListPopup popup = new RunListPopup(project, new ConfigurationListPopupStep(this, project, String.format("%s", executor.getActionName()))); + final RunListPopup popup = new RunListPopup(project, new ConfigurationListPopupStep(this, project, String.format("%s", executor.getActionName()))) { + @Override + protected void handleShiftClick(final boolean handleFinalChoices, final InputEvent inputEvent, final RunListPopup popup) { + try { + myCurrentExecutor = getAlternateExecutor(); + popup._handleSelect(handleFinalChoices, inputEvent); + } finally { + myCurrentExecutor = null; + } + } + }; registerActions(popup); final String adText = getAdText(getAlternateExecutor()); @@ -792,7 +804,7 @@ public class ChooseRunConfigurationAction extends AnAction { } } - private static class RunListPopup extends ListPopupImpl { + private static abstract class RunListPopup extends ListPopupImpl { private Project myProject_; public RunListPopup(final Project project, ListPopupStep step) { @@ -800,6 +812,28 @@ public class ChooseRunConfigurationAction extends AnAction { myProject_ = project; } + @Override + public void handleSelect(boolean handleFinalChoices, InputEvent e) { + if (e instanceof MouseEvent && e.isShiftDown()) { + handleShiftClick(handleFinalChoices, e, this); + return; + } + + _handleSelect(handleFinalChoices, e); + } + + protected void _handleSelect(boolean handleFinalChoices, InputEvent e) { + super.handleSelect(handleFinalChoices, e); + } + + protected abstract void handleShiftClick(boolean handleFinalChoices, final InputEvent inputEvent, final RunListPopup popup); + + @Override + protected boolean isActionClick(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON2 || e.isPopupTrigger() || e.getID() != MouseEvent.MOUSE_PRESSED) return false; + return e.getButton() == MouseEvent.BUTTON1; + } + @Override protected ListCellRenderer getListElementRenderer() { return new RunListElementRenderer(this); diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java b/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java index 67acdb0c065d..c6102811bbc0 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java @@ -276,7 +276,7 @@ public class RunContentBuilder implements LogConsoleManager, Disposable { private final Disposable[] myAdditionalDisposables; public MyRunContentDescriptor(final RunProfile profile, final ExecutionResult executionResult, final boolean reuseProhibited, final JComponent component, final Disposable... additionalDisposables) { - super(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), component, profile.getName()); + super(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), component, profile.getName(), profile.getIcon()); myReuseProhibited = reuseProhibited; myAdditionalDisposables = additionalDisposables; } diff --git a/platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java index 2b4305c5aac2..0d98f59dd3d3 100644 --- a/platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java @@ -15,10 +15,7 @@ */ package com.intellij.execution.ui; -import com.intellij.execution.ExecutionBundle; -import com.intellij.execution.Executor; -import com.intellij.execution.ExecutorRegistry; -import com.intellij.execution.TerminateRemoteProcessDialog; +import com.intellij.execution.*; import com.intellij.execution.process.ProcessAdapter; import com.intellij.execution.process.ProcessEvent; import com.intellij.execution.process.ProcessHandler; @@ -39,6 +36,7 @@ import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ProjectManagerListener; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Key; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowAnchor; @@ -47,6 +45,7 @@ import com.intellij.openapi.wm.ex.ToolWindowManagerAdapter; import com.intellij.openapi.wm.ex.ToolWindowManagerEx; import com.intellij.ui.content.*; import com.intellij.util.EventDispatcher; +import com.intellij.util.IconUtil; import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.HashMap; import org.jetbrains.annotations.NotNull; @@ -249,7 +248,7 @@ public class RunContentManagerImpl implements RunContentManager, Disposable { public void showRunContent(@NotNull final Executor executor, final RunContentDescriptor descriptor) { if(ApplicationManager.getApplication().isUnitTestMode()) return; - final ContentManager contentManager = getContentManagerForRunner(executor); + final ContentManager contentManager = getContentManagerForRunner(executor); RunContentDescriptor oldDescriptor = chooseReuseContentForDescriptor(contentManager, descriptor); final Content content; @@ -261,7 +260,8 @@ public class RunContentManagerImpl implements RunContentManager, Disposable { } else { content = createNewContent(contentManager, descriptor, executor.getToolWindowId()); - content.setIcon(executor.getToolWindowIcon()); + final Icon icon = descriptor.getIcon(); + content.setIcon(icon == null ? executor.getToolWindowIcon() : icon); } content.setComponent(descriptor.getComponent()); @@ -272,7 +272,8 @@ public class RunContentManagerImpl implements RunContentManager, Disposable { public void startNotified(final ProcessEvent event) { LaterInvocator.invokeLater(new Runnable() { public void run() { - content.setIcon(executor.getToolWindowIcon()); + final Icon icon = descriptor.getIcon(); + content.setIcon(icon == null ? executor.getToolWindowIcon() : icon); } }); } @@ -280,7 +281,8 @@ public class RunContentManagerImpl implements RunContentManager, Disposable { public void processTerminated(final ProcessEvent event) { LaterInvocator.invokeLater(new Runnable() { public void run() { - content.setIcon(executor.getDisabledIcon()); + final Icon icon = descriptor.getIcon(); + content.setIcon(icon == null ? executor.getDisabledIcon() : IconLoader.getTransparentIcon(icon)); } }); } diff --git a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java index 330b51629090..884b6c418f9e 100644 --- a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java +++ b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java @@ -62,6 +62,7 @@ import com.intellij.util.Icons; import com.intellij.util.Processor; import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.ui.Table; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -334,12 +335,7 @@ public class ShowUsagesAction extends AnAction { addUsageNodes(usageView.getRoot(), usageView, new ArrayList()); - final JTable table = new Table(){ - @Override - public boolean getScrollableTracksViewportWidth() { - return true; - } - }; + final JTable table = new MyTable(); TableScrollingUtil.installActions(table); final Vector data = new Vector(); setModel(table, usages, visibleNodes, usageView, data); @@ -411,6 +407,8 @@ public class ShowUsagesAction extends AnAction { } }; + + KeyboardShortcut shortcut = getSettingsShortcut(); if (shortcut != null) { builder.registerKeyboardAction(shortcut.getFirstKeyStroke(), editSettings); @@ -635,4 +633,30 @@ public class ShowUsagesAction extends AnAction { }); } } + + static class MyTable extends Table implements DataProvider { + @Override + public boolean getScrollableTracksViewportWidth() { + return true; + } + + public Object getData(@NonNls String dataId) { + if (LangDataKeys.PSI_ELEMENT.getName().equals(dataId)) { + final int[] selected = getSelectedRows(); + if (selected.length == 1) { + final Object at = getValueAt(selected[0], 0); + if (at instanceof UsageNode) { + final Usage usage = ((UsageNode)at).getUsage(); + if (usage instanceof UsageInfo2UsageAdapter) { + final PsiElement element = ((UsageInfo2UsageAdapter)usage).getElement(); + if (element != null) { + return element.getContainingFile(); + } + } + } + } + } + return null; + } + } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryInfo.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryInfo.java index 465df0fb1a0c..9df8f6d20951 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryInfo.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryInfo.java @@ -16,15 +16,16 @@ package com.intellij.openapi.roots.impl; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.roots.OrderEntry; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.containers.OrderedSet; -import gnu.trove.TObjectHashingStrategy; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +import java.util.*; -import java.util.Collections; -import java.util.List; public class DirectoryInfo { public Module module; // module to which content it belongs or null @@ -36,11 +37,15 @@ public class DirectoryInfo { public VirtualFile sourceRoot; /** - * orderEntry to (classes of) which a directory belongs + * orderEntry to (classes of) which a directory belongs */ private List orderEntries = null; + @TestOnly + @SuppressWarnings({"unchecked"}) public boolean equals(Object o) { + assert ApplicationManager.getApplication().isUnitTestMode() : "DirectoryInfo.equals should only be used in tests"; + if (this == o) return true; if (!(o instanceof DirectoryInfo)) return false; @@ -50,7 +55,7 @@ public class DirectoryInfo { if (isInModuleSource != info.isInModuleSource) return false; if (isTestSource != info.isTestSource) return false; if (module != null ? !module.equals(info.module) : info.module != null) return false; - if (orderEntries != null ? !orderEntries.equals(info.orderEntries) : info.orderEntries != null) return false; + if (orderEntries != null ? !new HashSet(orderEntries).equals(new HashSet(info.orderEntries)) : info.orderEntries != null) return false; if (!Comparing.equal(libraryClassRoot, info.libraryClassRoot)) return false; if (!Comparing.equal(contentRoot, info.contentRoot)) return false; if (!Comparing.equal(sourceRoot, info.sourceRoot)) return false; @@ -80,20 +85,23 @@ public class DirectoryInfo { } @SuppressWarnings({"unchecked"}) - public void addOrderEntries(final List orderEntries, - final DirectoryInfo parentInfo, - final List oldParentEntries) { - if (this.orderEntries == null) { + public void addOrderEntries(List orderEntries, + @Nullable final DirectoryInfo parentInfo, + @Nullable final List oldParentEntries) { + if (orderEntries.isEmpty()) { + this.orderEntries = null; + } + else if (this.orderEntries == null) { this.orderEntries = orderEntries; } else if (parentInfo != null && oldParentEntries == this.orderEntries) { - this.orderEntries = parentInfo.getOrderEntries(); + this.orderEntries = parentInfo.orderEntries; } else { - List tmp = new OrderedSet(TObjectHashingStrategy.CANONICAL); + LinkedHashSet tmp = new LinkedHashSet(this.orderEntries.size() + orderEntries.size()); tmp.addAll(this.orderEntries); tmp.addAll(orderEntries); - this.orderEntries = tmp; + this.orderEntries = new ArrayList(tmp); } } } diff --git a/platform/lang-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java b/platform/lang-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java index 4a40f885cf6e..f2ede48b2abe 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java +++ b/platform/lang-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java @@ -151,9 +151,9 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy { final VcsRoot[] vcsRoots = plVcsManager.getAllVcsRoots(); for (VcsRoot root : vcsRoots) { - if (! root.path.equals(baseDir)) { + //if (! root.path.equals(baseDir)) { builder.addDirtyDirRecursively(root); - } + //} } } } diff --git a/platform/lang-impl/src/com/intellij/tools/ToolRunProfile.java b/platform/lang-impl/src/com/intellij/tools/ToolRunProfile.java index 1ba20a8ae7a0..f4e1b2366baa 100644 --- a/platform/lang-impl/src/com/intellij/tools/ToolRunProfile.java +++ b/platform/lang-impl/src/com/intellij/tools/ToolRunProfile.java @@ -35,6 +35,8 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; +import javax.swing.*; + /** * @author Eugene Zhuravlev * Date: Mar 30, 2005 @@ -57,6 +59,10 @@ public class ToolRunProfile implements ModuleRunProfile{ return myTool.getName(); } + public Icon getIcon() { + return null; + } + public void checkConfiguration() throws RuntimeConfigurationException { } diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java index cf80069f8176..4c7fec3ad206 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java @@ -229,7 +229,7 @@ public class AbstractTreeUi { private void initClearanceServiceIfNeeded() { if (ourClearanceService != null) return; - ourClearanceService = ConcurrencyUtil.newSingleScheduledThreadExecutor("AbstractTreeBuilder's janitor"); + ourClearanceService = ConcurrencyUtil.newSingleScheduledThreadExecutor("AbstractTreeBuilder's janitor", Thread.MIN_PRIORITY + 1); ourClearanceService.scheduleWithFixedDelay(new Runnable() { public void run() { cleanUpAll(); diff --git a/platform/platform-api/src/com/intellij/openapi/project/DumbService.java b/platform/platform-api/src/com/intellij/openapi/project/DumbService.java index 37d7522561dc..ac4b8d551428 100644 --- a/platform/platform-api/src/com/intellij/openapi/project/DumbService.java +++ b/platform/platform-api/src/com/intellij/openapi/project/DumbService.java @@ -16,13 +16,11 @@ package com.intellij.openapi.project; import com.intellij.openapi.Disposable; -import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.ui.popup.BalloonHandler; import com.intellij.openapi.util.NotNullLazyKey; -import com.intellij.util.concurrency.Semaphore; import com.intellij.util.messages.Topic; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -57,22 +55,7 @@ public abstract class DumbService { */ public abstract void runWhenSmart(Runnable runnable); - public void waitForSmartMode() { - final Application application = ApplicationManager.getApplication(); - if (!application.isUnitTestMode()) { - assert !application.isDispatchThread(); - assert !application.isReadAccessAllowed(); - } - - final Semaphore semaphore = new Semaphore(); - semaphore.down(); - runWhenSmart(new Runnable() { - public void run() { - semaphore.up(); - } - }); - semaphore.waitFor(); - } + public abstract void waitForSmartMode(); /** * Invoke the runnable later on EventDispatchThread AND when IDEA isn't in dumb mode diff --git a/platform/platform-api/src/com/intellij/openapi/util/SimpleTimer.java b/platform/platform-api/src/com/intellij/openapi/util/SimpleTimer.java index e7498b040404..4e5e9d4bcd2c 100644 --- a/platform/platform-api/src/com/intellij/openapi/util/SimpleTimer.java +++ b/platform/platform-api/src/com/intellij/openapi/util/SimpleTimer.java @@ -21,7 +21,7 @@ import java.util.*; * Simple timer that keeps order of scheduled tasks */ public class SimpleTimer { - private final Timer ourTimer = new Timer(THREAD_NAME, true); + private final Timer ourTimer; private static final SimpleTimer ourInstance = new SimpleTimer(); private static final String THREAD_NAME = "SimpleTimer"; @@ -32,6 +32,16 @@ public class SimpleTimer { private final Map> myTime2Task = new TreeMap>(); private SimpleTimer() { + final Thread thread = Thread.currentThread(); + final int currentPrio = thread.getPriority(); + try { + // need this becase the timer's thread will inherit the priority on creation + thread.setPriority(Thread.MIN_PRIORITY + 1); + ourTimer = new Timer(THREAD_NAME, true); + } + finally { + thread.setPriority(currentPrio); + } } public static SimpleTimer getInstance() { @@ -47,7 +57,7 @@ public class SimpleTimer { ArrayList tasks = myTime2Task.get(targetTime); if (tasks == null) { - tasks = new ArrayList(2); + tasks = new ArrayList(2); myTime2Task.put(targetTime, tasks); } tasks.add(result); diff --git a/platform/platform-api/src/com/intellij/util/Alarm.java b/platform/platform-api/src/com/intellij/util/Alarm.java index 8cdeae613f0f..cf7366205752 100644 --- a/platform/platform-api/src/com/intellij/util/Alarm.java +++ b/platform/platform-api/src/com/intellij/util/Alarm.java @@ -45,7 +45,7 @@ public class Alarm implements Disposable { private final ThreadPoolExecutor myExecutorService; - private static final ThreadPoolExecutor ourSharedExecutorService = ConcurrencyUtil.newSingleThreadExecutor("Alarm pool(shared)"); + private static final ThreadPoolExecutor ourSharedExecutorService = ConcurrencyUtil.newSingleThreadExecutor("Alarm pool(shared)", Thread.NORM_PRIORITY - 2); private final Object LOCK = new Object(); private final ThreadToUse myThreadToUse; @@ -84,7 +84,7 @@ public class Alarm implements Disposable { } public Alarm(@NotNull ThreadToUse threadToUse, Disposable parentDisposable) { myThreadToUse = threadToUse; - myExecutorService = threadToUse == ThreadToUse.OWN_THREAD ? ConcurrencyUtil.newSingleThreadExecutor("Alarm pool(own)") : ourSharedExecutorService; + myExecutorService = threadToUse == ThreadToUse.OWN_THREAD ? ConcurrencyUtil.newSingleThreadExecutor("Alarm pool(own)", Thread.NORM_PRIORITY - 2) : ourSharedExecutorService; if (parentDisposable != null) { Disposer.register(parentDisposable, this); diff --git a/platform/platform-impl/src/com/intellij/concurrency/JobSchedulerImpl.java b/platform/platform-impl/src/com/intellij/concurrency/JobSchedulerImpl.java index 80d781687df9..ad798b41baef 100644 --- a/platform/platform-impl/src/com/intellij/concurrency/JobSchedulerImpl.java +++ b/platform/platform-impl/src/com/intellij/concurrency/JobSchedulerImpl.java @@ -23,7 +23,10 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.application.impl.ApplicationImpl; import org.jetbrains.annotations.NonNls; -import java.util.concurrent.*; +import java.util.concurrent.PriorityBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -34,7 +37,9 @@ public class JobSchedulerImpl extends JobScheduler implements Disposable { private static final ThreadFactory WORKERS_FACTORY = new ThreadFactory() { int i; public Thread newThread(final Runnable r) { - return new Thread(r, "JobScheduler pool "+i+++"/"+CORES_COUNT); + final Thread thread = new Thread(r, "JobScheduler pool " + i++ + "/" + CORES_COUNT); + thread.setPriority(Thread.NORM_PRIORITY); + return thread; } }; diff --git a/platform/platform-impl/src/com/intellij/diagnostic/PerformanceWatcher.java b/platform/platform-impl/src/com/intellij/diagnostic/PerformanceWatcher.java index 8445c049e4a7..2b7e35a5f261 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/PerformanceWatcher.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/PerformanceWatcher.java @@ -106,6 +106,7 @@ public class PerformanceWatcher implements ApplicationComponent { checkEDTResponsiveness(); } }, "Performance watcher"); + myThread.setPriority(Thread.MIN_PRIORITY); myThread.start(); } diff --git a/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java b/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java index 56ddc6e1e16c..69a9586f4ad4 100644 --- a/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java @@ -15,9 +15,9 @@ */ package com.intellij.ide; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.application.ApplicationManager; import org.apache.xmlrpc.IdeaAwareWebServer; import org.apache.xmlrpc.IdeaAwareXmlRpcServer; import org.apache.xmlrpc.WebServer; @@ -46,8 +46,10 @@ public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent { public void initComponent() { if (ApplicationManager.getApplication().isUnitTestMode() || !checkPort()) return; - + final Thread thread = Thread.currentThread(); + final int currentPrio = thread.getPriority(); try { + thread.setPriority(Thread.NORM_PRIORITY - 2); myWebServer = new IdeaAwareWebServer(getPortNumber(), null, new IdeaAwareXmlRpcServer()); myWebServer.start(); } @@ -55,6 +57,9 @@ public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent { LOG.error(e); myWebServer = null; } + finally { + thread.setPriority(currentPrio); + } } public int getPortNumber() { diff --git a/platform/platform-impl/src/com/intellij/idea/SocketLock.java b/platform/platform-impl/src/com/intellij/idea/SocketLock.java index 54073deefed3..bd32dd33f8c1 100644 --- a/platform/platform-impl/src/com/intellij/idea/SocketLock.java +++ b/platform/platform-impl/src/com/intellij/idea/SocketLock.java @@ -162,7 +162,9 @@ public class SocketLock { } } - new Thread(new MyRunnable(), LOCK_THREAD_NAME).start(); + final Thread thread = new Thread(new MyRunnable(), LOCK_THREAD_NAME); + thread.setPriority(Thread.MIN_PRIORITY); + thread.start(); return; } 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 0e71eb79b4a3..22f605aac9e9 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 @@ -25,7 +25,6 @@ import com.intellij.ide.IdeRepaintManager; import com.intellij.ide.impl.ProjectUtil; import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.ide.plugins.PluginManager; -import com.intellij.openapi.Disposable; import com.intellij.openapi.application.*; import com.intellij.openapi.application.ex.ApplicationEx; import com.intellij.openapi.application.ex.ApplicationManagerEx; @@ -112,8 +111,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application new SynchronousQueue(), new ThreadFactory() { public Thread newThread(Runnable r) { - return new Thread(r, "ApplicationImpl pooled thread") - { + final Thread thread = new Thread(r, "ApplicationImpl pooled thread") { public void interrupt() { if (LOG.isDebugEnabled()) { LOG.debug("Interrupted worker, will remove from pool"); @@ -124,13 +122,16 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application public void run() { try { super.run(); - } catch(Throwable t) { + } + catch (Throwable t) { if (LOG.isDebugEnabled()) { LOG.debug("Worker exits due to exception", t); } } } }; + thread.setPriority(Thread.NORM_PRIORITY - 1); + return thread; } } ); 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 57537a3c73d0..0d581a715ed1 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 @@ -515,8 +515,11 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx { if (rangeMarker != null && rangeMarker.isValid()) { if (event.getOffset() <= rangeMarker.getEndOffset()) { rangeMarker.documentChanged(event); - if (!rangeMarker.isValid() && myGuardedBlocks.remove(rangeMarker)) { - LOG.error("Guarded blocks should stay valid: "+rangeMarker); + if (!rangeMarker.isValid()) { + rangeMarkerIterator.remove(); + if (myGuardedBlocks.remove(rangeMarker)) { + LOG.error("Guarded blocks should stay valid: "+rangeMarker); + } } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/HighlighterList.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/HighlighterList.java index a9b333747c82..548f983e306e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/HighlighterList.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/HighlighterList.java @@ -52,6 +52,14 @@ public abstract class HighlighterList { super.sort(delegate); } } + + @Override + public boolean remove(Object o) { + if (o instanceof RangeHighlighterImpl) { + if (!((RangeHighlighterImpl)o).isValid()) return false; + } + return super.remove(o); + } }; private boolean myIsDirtied = false; diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultBundledKeymaps.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultBundledKeymaps.java index e62e3608d01b..6530c0296bd7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultBundledKeymaps.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultBundledKeymaps.java @@ -26,6 +26,7 @@ public class DefaultBundledKeymaps implements BundledKeymapProvider { public List getKeymapFileNames() { return Arrays.asList( "Keymap_Default.xml", + "Keymap_Mac.xml", "Keymap_MacClassic.xml", "Keymap_Emacs.xml", "Keymap_VisualStudio.xml", diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultKeymap.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultKeymap.java index b0241e4c3c9b..a08e89a37b89 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultKeymap.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/DefaultKeymap.java @@ -66,7 +66,7 @@ public class DefaultKeymap { for (Element child : (List)element.getChildren()) { if (KEY_MAP.equals(child.getName())) { String keymapName = child.getAttributeValue(NAME_ATTRIBUTE); - DefaultKeymapImpl keymap = KeymapManager.MAC_OS_X_KEYMAP.equals(keymapName) ? new MacOSDefaultKeymap() : new DefaultKeymapImpl(); + DefaultKeymapImpl keymap = keymapName.startsWith(KeymapManager.MAC_OS_X_KEYMAP) ? new MacOSDefaultKeymap() : new DefaultKeymapImpl(); keymap.readExternal(child, myKeymaps.toArray(new Keymap[myKeymaps.size()])); keymap.setName(keymapName); myKeymaps.add(keymap); diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java index e49a5b47e6ff..54fd5ed11639 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java @@ -54,7 +54,7 @@ public class ProgressManagerImpl extends ProgressManager { public ProgressManagerImpl(Application application) { if (!application.isUnitTestMode() && !DISABLED) { - new Thread(NAME) { + final Thread thread = new Thread(NAME) { public void run() { while (true) { try { @@ -65,7 +65,9 @@ public class ProgressManagerImpl extends ProgressManager { ourNeedToCheckCancel = true; } } - }.start(); + }; + thread.setPriority(Thread.MIN_PRIORITY + 1); + thread.start(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index 545433b3978c..04ce9a100991 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -28,6 +28,7 @@ import com.intellij.openapi.ui.popup.BalloonHandler; import com.intellij.openapi.util.Ref; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.ex.StatusBarEx; +import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.Queue; import com.intellij.util.messages.MessageBus; import org.jetbrains.annotations.NotNull; @@ -184,7 +185,25 @@ public class DumbServiceImpl extends DumbService { } private static final Ref NULL_ACTION = new Ref(null); - + + public void waitForSmartMode() { + final Application application = ApplicationManager.getApplication(); + if (!application.isUnitTestMode()) { + assert !application.isDispatchThread(); + assert !application.isReadAccessAllowed(); + } + + final Semaphore semaphore = new Semaphore(); + semaphore.down(); + runWhenSmart(new Runnable() { + public void run() { + semaphore.up(); + } + }); + semaphore.waitFor(); + LOG.assertTrue(!isDumb()); + } + private class IndexUpdateRunnable implements Runnable { private final CacheUpdateRunner myAction; private double myProcessedItems; diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/BuildInfo.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/BuildInfo.java index eb5f4435f367..2f2e847d0310 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/BuildInfo.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/BuildInfo.java @@ -29,13 +29,13 @@ import java.util.List; public class BuildInfo implements Comparable { private final BuildNumber myNumber; - private final String myName; + private final String myVersion; private final String myMessage; private final List myPatches; public BuildInfo(Element node) { myNumber = BuildNumber.fromString(node.getAttributeValue("number")); - myName = node.getAttributeValue("name"); + myVersion = node.getAttributeValue("version"); myPatches = new ArrayList(); for (Object patchNode : node.getChildren("patch")) { @@ -54,8 +54,8 @@ public class BuildInfo implements Comparable { return myNumber; } - public String getName() { - return myName != null ? myName : ""; + public String getVersion() { + return myVersion != null ? myVersion : ""; } public String getMessage() { @@ -66,7 +66,7 @@ public class BuildInfo implements Comparable { public PatchInfo findPatchForCurrentBuild() { BuildNumber currentBuild = ApplicationInfo.getInstance().getBuild(); for (PatchInfo each : myPatches) { - if (each.getFromBuild().equals(currentBuild)) return each; + if (each.getFromBuild().asStringWithoutProductCode().equals(currentBuild.asStringWithoutProductCode())) return each; } return null; } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java index 7a14b647f943..db793ba20fca 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java @@ -383,7 +383,7 @@ public final class UpdateChecker { PatchInfo patch = newVersion.findPatchForCurrentBuild(); if (patch == null) throw new IOException("No patch is available for current version"); - String platform = System.getProperty("idea.platform.prefix", "idea"); + String productCode = ApplicationInfo.getInstance().getBuild().getProductCode(); String osSuffix = ""; if (SystemInfo.isWindows) { @@ -394,12 +394,14 @@ public final class UpdateChecker { } else if (SystemInfo.isUnix) osSuffix = "-unix"; - String fileName = platform + "-" + patch.getFromBuild().asString() + "-" + newVersion.getNumber().asString() + "-patch" + osSuffix + ".jar"; + String fromBuildNumber = patch.getFromBuild().asStringWithoutProductCode(); + String toBuildNumber = newVersion.getNumber().asStringWithoutProductCode(); + String fileName = productCode + "-" + fromBuildNumber + "-" + toBuildNumber + "-patch" + osSuffix + ".jar"; URLConnection connection = null; InputStream in = null; OutputStream out = null; - String patchFileName = "jetbrains.patch.jar." + platform; + String patchFileName = "jetbrains.patch.jar." + productCode; File patchFile = new File(FileUtil.getTempDirectory(), patchFileName); try { diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java index dcde950b9389..32269209a648 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java @@ -121,7 +121,7 @@ class UpdateInfoDialog extends AbstractUpdateDialog { public UpdateInfoPanel() { ApplicationInfo appInfo = ApplicationInfo.getInstance(); - myBuildNumber.setText(appInfo.getBuild().asString() + ")"); + myBuildNumber.setText(appInfo.getBuild().asStringWithoutProductCode() + ")"); final String majorVersion = appInfo.getMajorVersion(); final String version; if (majorVersion != null && majorVersion.trim().length() > 0) { @@ -138,8 +138,8 @@ class UpdateInfoDialog extends AbstractUpdateDialog { } myVersionNumber.setText(version); - myNewBuildNumber.setText(myLatestBuild.getNumber().asString() + ")"); - myNewVersionNumber.setText(myLatestBuild.getName()); + myNewBuildNumber.setText(myLatestBuild.getNumber().asStringWithoutProductCode() + ")"); + myNewVersionNumber.setText(myLatestBuild.getVersion()); if (myLatestBuild.getMessage() != null) { myUpdateMessageLabel.setText("
" + myLatestBuild.getMessage() + ""); } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/CommandProcessor.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/CommandProcessor.java index 01d994bbce61..ecb1b78e5ea2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/CommandProcessor.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/CommandProcessor.java @@ -15,11 +15,12 @@ */ package com.intellij.openapi.wm.impl; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Condition; import com.intellij.openapi.wm.impl.commands.FinalizableCommand; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ModalityState; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -43,7 +44,7 @@ public final class CommandProcessor implements Runnable { * commands with BlockFocusEventsCmd - UnbockFocusEventsCmd. It's required to * prevent focus handling of events which is caused by the commands to be executed. */ - public final void execute(final List commandList, Condition expired) { + public final void execute(@NotNull List commandList, @NotNull Condition expired) { synchronized (myLock) { final boolean isBusy = myCommandCount > 0; @@ -60,32 +61,28 @@ public final class CommandProcessor implements Runnable { public final void run() { synchronized (myLock) { final CommandGroup commandGroup = getNextCommandGroup(); - if (commandGroup == null) { - return; - } + if (commandGroup == null || commandGroup.isEmpty()) return; final Condition conditionForGroup = commandGroup.getExpireCondition(); - if (!commandGroup.isEmpty()) { - final FinalizableCommand command = commandGroup.takeNextCommand(); - myCommandCount--; + final FinalizableCommand command = commandGroup.takeNextCommand(); + myCommandCount--; - final Condition expire = command.getExpireCondition() != null ? command.getExpireCondition() : conditionForGroup; + final Condition expire = command.getExpireCondition() != null ? command.getExpireCondition() : conditionForGroup; - if (LOG.isDebugEnabled()) { - LOG.debug("CommandProcessor.run " + command); - } - // max. I'm not actually quite sure this should have NON_MODAL modality but it should - // definitely have some since runnables in command list may (and do) request some PSI activity - final boolean queueNext = myCommandCount > 0; - ApplicationManager.getApplication().getInvokator().invokeLater(command, ModalityState.NON_MODAL, expire == null ? Condition.FALSE : expire).doWhenDone(new Runnable() { - public void run() { - if (queueNext) { - CommandProcessor.this.run(); - } - } - }); + if (LOG.isDebugEnabled()) { + LOG.debug("CommandProcessor.run " + command); } + // max. I'm not actually quite sure this should have NON_MODAL modality but it should + // definitely have some since runnables in command list may (and do) request some PSI activity + final boolean queueNext = myCommandCount > 0; + ApplicationManager.getApplication().getInvokator().invokeLater(command, ModalityState.NON_MODAL, expire == null ? Condition.FALSE : expire).doWhenDone(new Runnable() { + public void run() { + if (queueNext) { + CommandProcessor.this.run(); + } + } + }); } } @@ -104,9 +101,9 @@ public final class CommandProcessor implements Runnable { private static class CommandGroup { private final List myList; - private final Condition myExpireCondition; + private Condition myExpireCondition; - private CommandGroup(final List list, final Condition expireCondition) { + private CommandGroup(@NotNull List list, @NotNull Condition expireCondition) { myList = list; myExpireCondition = expireCondition; } @@ -120,7 +117,12 @@ public final class CommandProcessor implements Runnable { } public FinalizableCommand takeNextCommand() { - return myList.remove(0); + FinalizableCommand command = myList.remove(0); + if (isEmpty()) { + // memory leak otherwise + myExpireCondition = Condition.TRUE; + } + return command; } } } diff --git a/platform/platform-impl/src/com/intellij/ui/EditorComboBoxEditor.java b/platform/platform-impl/src/com/intellij/ui/EditorComboBoxEditor.java index 7e5b17e0c5f3..08521183ea34 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorComboBoxEditor.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorComboBoxEditor.java @@ -34,7 +34,13 @@ public class EditorComboBoxEditor implements ComboBoxEditor{ @NonNls protected static final String NAME = "ComboBox.textField"; public EditorComboBoxEditor(Project project, FileType fileType) { - myTextField = new EditorTextField((Document)null, project, fileType); + myTextField = new EditorTextField((Document)null, project, fileType) { + @Override + protected boolean shouldHaveBorder() { + return false; + } + }; + myTextField.setName(NAME); } diff --git a/platform/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java b/platform/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java index ca27e6816cf3..67c907e66a1e 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/list/ListPopupImpl.java @@ -356,11 +356,15 @@ public class ListPopupImpl extends WizardPopup implements ListPopup { } } + protected boolean isActionClick(MouseEvent e) { + return UIUtil.isActionClick(e); + } + private class MyMouseListener extends MouseAdapter { @Override public void mousePressed(MouseEvent e) { - if (!UIUtil.isActionClick(e)) return; + if (!isActionClick(e)) return; boolean handleFinalChoices = true; final Object selectedValue = myList.getSelectedValue(); diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index ea08356de80f..760d9d8a0a3a 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -904,9 +904,9 @@ updates.download.and.install.patch.button=&Download Patch and Shutdown updates.download.and.install.patch.button.restart=&Download Patch and Restart updates.more.info.button=&More Info... updates.new.version.available=

A new version of $FULLNAME$ is available.

-updates.available.idea.version=Available $PRODUCT$ version: +updates.available.idea.version=New version: updates.build.number=(Build number: -updates.current.idea.version=Your current $PRODUCT$ version: +updates.current.idea.version=Current version: updates.press.more.info.label=
Press More Info... to open a web page where you can download $PRODUCT$ manually or learn more about its new version. updates.check.manually.label=
To check for new updates manually, use the Help | Check for Updates command. updates.settings.title=Updates diff --git a/platform/platform-resources/src/idea/Keymap_Mac.xml b/platform/platform-resources/src/idea/Keymap_Mac.xml new file mode 100644 index 000000000000..6f298280b1de --- /dev/null +++ b/platform/platform-resources/src/idea/Keymap_Mac.xml @@ -0,0 +1,412 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/usageView/src/com/intellij/usages/UsageModelTracker.java b/platform/usageView/src/com/intellij/usages/UsageModelTracker.java index cbe37b6aec9d..84ac830497e2 100644 --- a/platform/usageView/src/com/intellij/usages/UsageModelTracker.java +++ b/platform/usageView/src/com/intellij/usages/UsageModelTracker.java @@ -17,7 +17,6 @@ package com.intellij.usages; import com.intellij.openapi.Disposable; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Disposer; import com.intellij.psi.*; import com.intellij.util.containers.ContainerUtil; @@ -27,18 +26,14 @@ import java.util.List; * @author max */ public class UsageModelTracker implements Disposable { - private final PsiTreeChangeListener myPsiListener; - public interface UsageModelTrackerListener { void modelChanged(boolean isPropertyChange); } - private final Project myProject; private final List myListeners = ContainerUtil.createEmptyCOWList(); - public UsageModelTracker(Project project, Disposable parentDisposable) { - myProject = project; - myPsiListener = new PsiTreeChangeAdapter() { + public UsageModelTracker(Project project) { + final PsiTreeChangeListener myPsiListener = new PsiTreeChangeAdapter() { public void childAdded(PsiTreeChangeEvent event) { doFire(event, false); } @@ -63,8 +58,7 @@ public class UsageModelTracker implements Disposable { doFire(event, true); } }; - PsiManager.getInstance(project).addPsiTreeChangeListener(myPsiListener); - Disposer.register(parentDisposable, this); + PsiManager.getInstance(project).addPsiTreeChangeListener(myPsiListener, this); } private void doFire(final PsiTreeChangeEvent event, boolean propertyChange) { @@ -76,7 +70,6 @@ public class UsageModelTracker implements Disposable { } public void dispose() { - PsiManager.getInstance(myProject).removePsiTreeChangeListener(myPsiListener); } public void addListener(UsageModelTrackerListener listener) { diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java index 22ecc990aacb..ebc911ba5f30 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java @@ -135,7 +135,6 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra @NotNull UsageViewPresentation presentation, @NotNull UsageTarget[] targets, Factory usageSearcherFactory) { - myPresentation = presentation; myTargets = targets; myUsageSearcherFactory = usageSearcherFactory; @@ -159,7 +158,8 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra } }; myRootPanel = new MyPanel(myTree); - myModelTracker = new UsageModelTracker(project, this); + myModelTracker = new UsageModelTracker(project); + Disposer.register(this, myModelTracker); myModel = new UsageViewTreeModelBuilder(myPresentation, targets); myRoot = (GroupNode)myModel.getRoot(); diff --git a/platform/util/src/com/intellij/openapi/util/BuildNumber.java b/platform/util/src/com/intellij/openapi/util/BuildNumber.java index 1bc9cad85e6d..80808f118cc0 100644 --- a/platform/util/src/com/intellij/openapi/util/BuildNumber.java +++ b/platform/util/src/com/intellij/openapi/util/BuildNumber.java @@ -33,9 +33,19 @@ public class BuildNumber implements Comparable { } public String asString() { + return asString(true); + } + + public String asStringWithoutProductCode() { + return asString(false); + } + + private String asString(boolean includeProductCode) { StringBuilder builder = new StringBuilder(); - if (!StringUtil.isEmpty(myProductCode)) { - builder.append(myProductCode).append('-'); + if (includeProductCode) { + if (!StringUtil.isEmpty(myProductCode)) { + builder.append(myProductCode).append('-'); + } } builder.append(myBaselineVersion).append('.'); @@ -50,15 +60,10 @@ public class BuildNumber implements Comparable { return builder.toString(); } - @Override - public String toString() { - return asString(); - } - public static BuildNumber fromString(String version) { if (version == null) return null; - if ("__BUILD_NUMBER__".equals(version)) return new BuildNumber("", 92, Integer.MAX_VALUE); + if ("__BUILD_NUMBER__".equals(version)) return new BuildNumber("IU", 92, Integer.MAX_VALUE); String code = version; int productSeparator = code.indexOf('-'); @@ -114,6 +119,11 @@ public class BuildNumber implements Comparable { return new BuildNumber(productCode, baselineVersion, buildNumber); } + @Override + public String toString() { + return asString(); + } + public int compareTo(BuildNumber o) { if (myBaselineVersion == o.myBaselineVersion) return myBuildNumber - o.myBuildNumber; return myBaselineVersion - o.myBaselineVersion; diff --git a/platform/util/src/com/intellij/util/ConcurrencyUtil.java b/platform/util/src/com/intellij/util/ConcurrencyUtil.java index a21844ba5188..c24ada093846 100644 --- a/platform/util/src/com/intellij/util/ConcurrencyUtil.java +++ b/platform/util/src/com/intellij/util/ConcurrencyUtil.java @@ -16,8 +16,8 @@ package com.intellij.util; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; @@ -84,19 +84,33 @@ public class ConcurrencyUtil { V prev = map.putIfAbsent(key, defaultValue); return prev == null ? defaultValue : prev; } + public static ThreadPoolExecutor newSingleThreadExecutor(@NonNls final String threadFactoryName) { + return newSingleThreadExecutor(threadFactoryName, Thread.NORM_PRIORITY); + } + + public static ThreadPoolExecutor newSingleThreadExecutor(final String threadFactoryName, final int threadPriority) { return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() { public Thread newThread(final Runnable r) { - return new Thread(r, threadFactoryName); + final Thread thread = new Thread(r, threadFactoryName); + thread.setPriority(threadPriority); + return thread; } }); } + public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(@NonNls final String threadFactoryName) { + return newSingleScheduledThreadExecutor(threadFactoryName, Thread.NORM_PRIORITY); + } + + public static ScheduledThreadPoolExecutor newSingleScheduledThreadExecutor(final String threadFactoryName, final int threadPriority) { ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new ThreadFactory() { public Thread newThread(final Runnable r) { - return new Thread(r, threadFactoryName); + final Thread thread = new Thread(r, threadFactoryName); + thread.setPriority(threadPriority); + return thread; } }); executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); diff --git a/platform/util/src/com/intellij/util/Timed.java b/platform/util/src/com/intellij/util/Timed.java index 0393ee9801df..92ccb64ce428 100644 --- a/platform/util/src/com/intellij/util/Timed.java +++ b/platform/util/src/com/intellij/util/Timed.java @@ -74,7 +74,7 @@ abstract class Timed implements Disposable { static { - ScheduledExecutorService service = ConcurrencyUtil.newSingleScheduledThreadExecutor("timed reference disposer"); + ScheduledExecutorService service = ConcurrencyUtil.newSingleScheduledThreadExecutor("timed reference disposer", Thread.MIN_PRIORITY + 1); service.scheduleWithFixedDelay(new Runnable() { public void run() { try { diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java index 8b3ada744ac6..0e35d68c1964 100644 --- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java +++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java @@ -123,6 +123,10 @@ public class ContainerUtil { return EmptyIterator.getInstance(); } + public static Iterable emptyIterable() { + return EmptyIterable.getInstance(); + } + @Nullable public static T find(T[] array, Condition condition) { for (T element : array) { @@ -297,6 +301,42 @@ public class ContainerUtil { }; } + public static Iterable iterate(final Collection collection, final Condition condition) { + if (collection.isEmpty()) return emptyIterable(); + return new Iterable() { + public Iterator iterator() { + return new Iterator() { + Iterator impl = collection.iterator(); + T next = findNext(); + + public boolean hasNext() { + return next != null; + } + + public T next() { + T result = next; + next = findNext(); + return result; + } + + private T findNext() { + while (impl.hasNext()) { + T each = impl.next(); + if (condition.value(each)) { + return each; + } + } + return null; + } + + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; + } + public static void swapElements(final List list, final int index1, final int index2) { E e1 = list.get(index1); E e2 = list.get(index2); diff --git a/platform/util/src/com/intellij/util/containers/EmptyIterable.java b/platform/util/src/com/intellij/util/containers/EmptyIterable.java new file mode 100644 index 000000000000..a840976af1fe --- /dev/null +++ b/platform/util/src/com/intellij/util/containers/EmptyIterable.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.util.containers; + +import java.util.Iterator; +import java.util.NoSuchElementException; + +public class EmptyIterable implements Iterable { + private static final EmptyIterable INSTANCE = new EmptyIterable(); + + public static EmptyIterable getInstance() { + return INSTANCE; + } + + public Iterator iterator() { + return EmptyIterator.getInstance(); + } +} \ No newline at end of file diff --git a/platform/util/src/com/intellij/util/containers/OrderedSet.java b/platform/util/src/com/intellij/util/containers/OrderedSet.java index e3f32d7fc8e6..450c9d5cba23 100644 --- a/platform/util/src/com/intellij/util/containers/OrderedSet.java +++ b/platform/util/src/com/intellij/util/containers/OrderedSet.java @@ -29,6 +29,11 @@ public class OrderedSet extends AbstractSet implements List { myElements = new ArrayList(); } + public OrderedSet(TObjectHashingStrategy hashingStrategy, int capacity) { + myHashSet = new THashSet(capacity, hashingStrategy); + myElements = new ArrayList(capacity); + } + public OrderedSet() { myHashSet = new THashSet(); myElements = new ArrayList(); diff --git a/platform/util/src/com/intellij/util/ui/Timer.java b/platform/util/src/com/intellij/util/ui/Timer.java index f86b6623f2ba..eedce6e35886 100644 --- a/platform/util/src/com/intellij/util/ui/Timer.java +++ b/platform/util/src/com/intellij/util/ui/Timer.java @@ -62,6 +62,7 @@ public abstract class Timer implements Disposable { myDisposed = true; } }; + myThread.setPriority(Thread.MIN_PRIORITY + 1); } public void setTakeInitialDelay(final boolean take) { diff --git a/platform/util/testSrc/com/intellij/util/containers/ContainerUtilTest.java b/platform/util/testSrc/com/intellij/util/containers/ContainerUtilTest.java index c5fdd5d20e72..5dff09c904da 100644 --- a/platform/util/testSrc/com/intellij/util/containers/ContainerUtilTest.java +++ b/platform/util/testSrc/com/intellij/util/containers/ContainerUtilTest.java @@ -16,12 +16,15 @@ package com.intellij.util.containers; +import com.intellij.openapi.util.Condition; + import java.util.*; public class ContainerUtilTest extends junit.framework.TestCase { public void testFindInstanceOf() { Iterator iterator = Arrays.asList(new Object[]{new Integer(1), new ArrayList(), "1"}).iterator(); - String string = (String)com.intellij.util.containers.ContainerUtil.find(iterator, com.intellij.util.containers.FilteringIterator.instanceOf(String.class)); + String string = (String)com.intellij.util.containers.ContainerUtil + .find(iterator, com.intellij.util.containers.FilteringIterator.instanceOf(String.class)); junit.framework.Assert.assertEquals("1", string); } @@ -32,17 +35,41 @@ public class ContainerUtilTest extends junit.framework.TestCase { assertEquals(2, l.get(1)); assertEquals(3, l.get(2)); assertEquals(4, l.get(3)); - + try { l.get(-1); fail(); - } catch(IndexOutOfBoundsException ignore) { + } + catch (IndexOutOfBoundsException ignore) { } try { l.get(4); fail(); - } catch(IndexOutOfBoundsException ignore) { + } + catch (IndexOutOfBoundsException ignore) { } } + + public void testIterateWithCondition() throws Exception { + Condition cond = new Condition() { + public boolean value(Integer integer) { + return integer > 2; + } + }; + + asserIterating(Arrays.asList(1, 4, 2, 5), cond, 4, 5); + asserIterating(Arrays.asList(1, 2), cond); + asserIterating(Collections.emptyList(), cond); + asserIterating(Arrays.asList(4), cond, 4); + } + + private void asserIterating(List collection, Condition condition, Integer... expected) { + Iterable it = ContainerUtil.iterate(collection, condition); + List actual = new ArrayList(); + for (Integer each : it) { + actual.add(each); + } + assertEquals(Arrays.asList(expected), actual); + } } diff --git a/platform/vcs-impl/src/com/intellij/lifecycle/SlowlyClosingAlarm.java b/platform/vcs-impl/src/com/intellij/lifecycle/SlowlyClosingAlarm.java index 7ef8eb6bac1e..e15cab7c6fd9 100644 --- a/platform/vcs-impl/src/com/intellij/lifecycle/SlowlyClosingAlarm.java +++ b/platform/vcs-impl/src/com/intellij/lifecycle/SlowlyClosingAlarm.java @@ -50,7 +50,9 @@ public class SlowlyClosingAlarm implements AtomicSectionsAware, Disposable { private static ThreadFactory threadFactory(@NonNls final String threadsName) { return new ThreadFactory() { public Thread newThread(final Runnable r) { - return new Thread(r, threadsName); + final Thread thread = new Thread(r, threadsName); + thread.setPriority(Thread.MIN_PRIORITY); + return thread; } }; } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java index 64988d952cb0..8cffe3fcb4f2 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java @@ -34,8 +34,8 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.*; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.*; -import com.intellij.openapi.vcs.changes.ui.CommitHelper; import com.intellij.openapi.vcs.changes.conflicts.ChangelistConflictTracker; +import com.intellij.openapi.vcs.changes.ui.CommitHelper; import com.intellij.openapi.vcs.checkin.CheckinEnvironment; import com.intellij.openapi.vcs.checkin.CheckinHandler; import com.intellij.openapi.vcs.readOnlyHandler.ReadonlyStatusHandlerImpl; @@ -69,7 +69,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec private final UpdateRequestsQueue myUpdater; @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) - private static final ScheduledExecutorService ourUpdateAlarm = ConcurrencyUtil.newSingleScheduledThreadExecutor("Change List Updater"); + private static final ScheduledExecutorService ourUpdateAlarm = ConcurrencyUtil.newSingleScheduledThreadExecutor("Change List Updater", Thread.MIN_PRIORITY + 1); private final Modifier myModifier; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/CompositeCheckoutListener.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/CompositeCheckoutListener.java index be3df7b04414..4f9d718512f7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/CompositeCheckoutListener.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkout/CompositeCheckoutListener.java @@ -60,10 +60,11 @@ public class CompositeCheckoutListener implements CheckoutProvider.Listener { result.set(vDir); if (vDir != null) { final LocalFileSystem.WatchRequest watchRequest = lfs.addRootToWatch(vDir.getPath(), true); - assert watchRequest != null; ((NewVirtualFile)vDir).markDirtyRecursively(); vDir.refresh(false, true); - lfs.removeWatchedRoot(watchRequest); + if (watchRequest != null) { + lfs.removeWatchedRoot(watchRequest); + } } } }); diff --git a/plugins/IntelliLang/src/LanguageInjectionConfiguration.xml b/plugins/IntelliLang/src/LanguageInjectionConfiguration.xml index 36e0bee094f6..cd064c00a071 100644 --- a/plugins/IntelliLang/src/LanguageInjectionConfiguration.xml +++ b/plugins/IntelliLang/src/LanguageInjectionConfiguration.xml @@ -172,6 +172,10 @@ [^:]*:[\s]*([^\}]*) + + JAXB attribute node + + Pattern (java.util.regex) diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java index fd2d1e6f9ece..eb42a8a5cb17 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java @@ -27,6 +27,7 @@ import com.intellij.openapi.options.Configurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; +import com.intellij.openapi.ui.popup.PopupChooserBuilder; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.ui.popup.util.BaseListPopupStep; import com.intellij.openapi.util.Pair; @@ -36,6 +37,7 @@ import com.intellij.psi.*; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.FileContentUtil; +import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import com.intellij.util.Processor; import com.intellij.util.ui.EmptyIcon; @@ -45,7 +47,9 @@ import org.jetbrains.annotations.Nullable; import org.intellij.plugins.intelliLang.Configuration; import javax.swing.*; +import java.awt.*; import java.util.*; +import java.util.List; public class InjectLanguageAction implements IntentionAction { @NonNls protected static final String INJECT_LANGUAGE_FAMILY = "Inject Language"; @@ -108,23 +112,31 @@ public class InjectLanguageAction implements IntentionAction { final String[] langIds = InjectedLanguage.getAvailableLanguageIDs(); Arrays.sort(langIds); - final Map> map = new LinkedHashMap>(); - buildLanguageTree(langIds, map); - - final BaseListPopupStep step = new MyPopupStep(map, new ArrayList(map.keySet()), onChosen); - - final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step); - listPopup.showInBestPositionFor(DataManager.getInstance().getDataContext()); - return true; - } - - - private static void buildLanguageTree(String[] langIds, Map> map) { - for (final String id : langIds) { - if (!map.containsKey(id)) { - map.put(id, new ArrayList()); + final JList list = new JList(langIds); + list.setCellRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + final String aValue = (String)value; + final Language language = InjectedLanguage.findLanguageById(aValue); + assert language != null; + final FileType ft = language.getAssociatedFileType(); + setIcon(ft != null ? ft.getIcon() : new EmptyIcon(16)); + setText(value + (ft != null ? " (" + ft.getDescription() + ")" : "")); + return this; } - } + }); + new PopupChooserBuilder(list).setItemChoosenCallback(new Runnable() { + public void run() { + final String string = (String)list.getSelectedValue(); + onChosen.process(string); + } + }).setFilteringEnabled(new Function() { + public String fun(Object o) { + return (String)o; + } + }).createPopup().showInBestPositionFor(DataManager.getInstance().getDataContext()); + return true; } public boolean startInWriteAction() { @@ -134,50 +146,4 @@ public class InjectLanguageAction implements IntentionAction { public static boolean doEditConfigurable(final Project project, final Configurable configurable) { return true; //ShowSettingsUtil.getInstance().editConfigurable(project, configurable); } - - private static class MyPopupStep extends BaseListPopupStep { - private final Map> myMap; - private final Processor myFinalStepProcessor; - - public MyPopupStep(final Map> map, final List values, final Processor finalStepProcessor) { - super("Choose Language", values); - myMap = map; - myFinalStepProcessor = finalStepProcessor; - } - - @Override - public PopupStep onChosen(final String selectedValue, boolean finalChoice) { - if (finalChoice) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - public void run() { - myFinalStepProcessor.process(selectedValue); - } - }); - return FINAL_CHOICE; - } - return new MyPopupStep(myMap, myMap.get(selectedValue), myFinalStepProcessor); - } - - @Override - public boolean hasSubstep(String selectedValue) { - return myMap.containsKey(selectedValue) && !myMap.get(selectedValue).isEmpty(); - } - - @Override - public Icon getIconFor(String aValue) { - final Language language = InjectedLanguage.findLanguageById(aValue); - assert language != null; - final FileType ft = language.getAssociatedFileType(); - return ft != null ? ft.getIcon() : new EmptyIcon(16); - } - - @NotNull - @Override - public String getTextFor(String value) { - final Language language = InjectedLanguage.findLanguageById(value); - assert language != null; - final FileType ft = language.getAssociatedFileType(); - return value + (ft != null ? " ("+ft.getDescription()+")" : ""); - } - } } diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ExceptionUtils.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ExceptionUtils.java index 84a71d5ca512..d8fea8fc772b 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ExceptionUtils.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/exceptions/ExceptionUtils.java @@ -146,10 +146,12 @@ class ExceptionUtils{ final PsiElement[] elements = declarationStatement.getDeclaredElements(); for(PsiElement element : elements){ - final PsiVariable var = (PsiVariable) element; - final PsiExpression initializer = var.getInitializer(); - if(initializer != null){ - calculateExceptionsThrown(initializer, exceptionTypes); + if (element instanceof PsiVariable) { + final PsiVariable var = (PsiVariable) element; + final PsiExpression initializer = var.getInitializer(); + if(initializer != null){ + calculateExceptionsThrown(initializer, exceptionTypes); + } } } } @@ -511,4 +513,4 @@ class ExceptionUtils{ calculateExceptionsThrownForStatement(statement, exceptionTypes); } } -} \ No newline at end of file +} diff --git a/plugins/ant/src/com/intellij/lang/ant/config/actions/AddAntBuildFile.java b/plugins/ant/src/com/intellij/lang/ant/config/actions/AddAntBuildFile.java index 40319487f850..180f5be4adb8 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/actions/AddAntBuildFile.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/actions/AddAntBuildFile.java @@ -20,13 +20,16 @@ import com.intellij.lang.ant.config.AntBuildFile; import com.intellij.lang.ant.config.AntConfiguration; import com.intellij.lang.ant.config.AntNoFileException; import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.openapi.wm.ToolWindowManager; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiManager; +import com.intellij.psi.xml.XmlDocument; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; public class AddAntBuildFile extends AnAction { public void actionPerformed(AnActionEvent event) { @@ -48,36 +51,60 @@ public class AddAntBuildFile extends AnAction { public void update(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Presentation presentation = e.getPresentation(); - Project project = PlatformDataKeys.PROJECT.getData(dataContext); + final Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (project == null) { - presentation.setEnabled(false); - presentation.setVisible(false); - return; - } - VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext); - if (file == null) { - presentation.setEnabled(false); - presentation.setVisible(false); + disable(presentation); return; } - boolean isXml = StdFileTypes.XML.equals(FileTypeManager.getInstance().getFileTypeByFile(file)); - if (!isXml) { - presentation.setEnabled(false); - presentation.setVisible(false); + final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext); + if (file == null) { + disable(presentation); + return; + } + + final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); + if (!(psiFile instanceof XmlFile)) { + disable(presentation); + return; + } + + final XmlFile xmlFile = (XmlFile)psiFile; + final XmlDocument document = xmlFile.getDocument(); + if (document == null) { + disable(presentation); + return; + } + + final XmlTag rootTag = document.getRootTag(); + if (rootTag == null) { + disable(presentation); + return; + } + + if (!"project".equals(rootTag.getName())) { + disable(presentation); return; } for (final AntBuildFile buildFile : AntConfiguration.getInstance(project).getBuildFiles()) { if (file.equals(buildFile.getVirtualFile())) { - presentation.setEnabled(false); - presentation.setVisible(false); + disable(presentation); return; } } + enable(presentation); + } + + private static void enable(Presentation presentation) { presentation.setEnabled(true); presentation.setVisible(true); } + + private static void disable(Presentation presentation) { + presentation.setEnabled(false); + presentation.setVisible(false); + } } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/execution/AntCommandLineBuilder.java b/plugins/ant/src/com/intellij/lang/ant/config/execution/AntCommandLineBuilder.java index 6acf22eda578..56c7d5ba7e40 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/execution/AntCommandLineBuilder.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/execution/AntCommandLineBuilder.java @@ -88,7 +88,7 @@ public class AntCommandLineBuilder { } myCommandLine.setJdk(jdk); - ParametersList vmParametersList = myCommandLine.getVMParametersList(); + final ParametersList vmParametersList = myCommandLine.getVMParametersList(); vmParametersList.add("-Xmx" + AntBuildFileImpl.MAX_HEAP_SIZE.get(container) + "m"); vmParametersList.add("-Xss" + AntBuildFileImpl.MAX_STACK_SIZE.get(container) + "m"); @@ -125,7 +125,22 @@ public class AntCommandLineBuilder { myCommandLine.setMainClass(AntMain2.class.getName()); final ParametersList programParameters = myCommandLine.getProgramParametersList(); - programParameters.addParametersString(AntBuildFileImpl.ANT_COMMAND_LINE_PARAMETERS.get(container)); + + final String additionalParams = AntBuildFileImpl.ANT_COMMAND_LINE_PARAMETERS.get(container); + if (additionalParams != null) { + for (String param : ParametersList.parse(additionalParams)) { + if (param.startsWith("-J")) { + final String cutParam = param.substring("-J".length()); + if (cutParam.length() > 0) { + vmParametersList.add(cutParam); + } + } + else { + programParameters.add(param); + } + } + } + if (!(programParameters.getList().contains(LOGFILE_SHORT_PARAMETER) || programParameters.getList().contains(LOGFILE_PARAMETER)) ) { programParameters.add("-logger", IdeaAntLogger2.class.getName()); } diff --git a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java index 0363276d6933..4d35618ab477 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java @@ -47,9 +47,9 @@ import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.*; +import com.intellij.ui.treeStructure.Tree; import com.intellij.util.ArrayUtil; import com.intellij.util.StringBuilderSpinAllocator; -import com.intellij.ui.treeStructure.Tree; import com.intellij.util.ui.tree.TreeUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -95,6 +95,10 @@ public class AntExplorer extends JPanel implements DataProvider { return canExpand(); } }; + private static final Icon ICON_RUN = IconLoader.getIcon("/actions/execute.png"); + private static final Icon ICON_REMOVE = IconLoader.getIcon("/general/remove.png"); + private static final Icon ICON_ADD = IconLoader.getIcon("/general/add.png"); + private static final Icon ICON_FILTER = IconLoader.getIcon("/ant/filter.png"); public AntExplorer(final Project project) { super(new BorderLayout(0, 2)); @@ -495,8 +499,7 @@ public class AntExplorer extends JPanel implements DataProvider { private final class AddAction extends AnAction { public AddAction() { - super(AntBundle.message("add.ant.file.action.name"), AntBundle.message("add.ant.file.action.description"), - IconLoader.getIcon("/general/add.png")); + super(AntBundle.message("add.ant.file.action.name"), AntBundle.message("add.ant.file.action.description"), ICON_ADD); } public void actionPerformed(AnActionEvent e) { @@ -506,8 +509,7 @@ public class AntExplorer extends JPanel implements DataProvider { private final class RemoveAction extends AnAction { public RemoveAction() { - super(AntBundle.message("remove.ant.file.action.name"), AntBundle.message("remove.ant.file.action.description"), - IconLoader.getIcon("/general/remove.png")); + super(AntBundle.message("remove.ant.file.action.name"), AntBundle.message("remove.ant.file.action.description"), ICON_REMOVE); } public void actionPerformed(AnActionEvent e) { @@ -521,8 +523,7 @@ public class AntExplorer extends JPanel implements DataProvider { private final class RunAction extends AnAction { public RunAction() { - super(AntBundle.message("run.ant.file.or.target.action.name"), AntBundle.message("run.ant.file.or.target.action.description"), - IconLoader.getIcon("/actions/execute.png")); + super(AntBundle.message("run.ant.file.or.target.action.name"), AntBundle.message("run.ant.file.or.target.action.description"), ICON_RUN); } public void actionPerformed(AnActionEvent e) { @@ -557,8 +558,7 @@ public class AntExplorer extends JPanel implements DataProvider { private final class ShowAllTargetsAction extends ToggleAction { public ShowAllTargetsAction() { - super(AntBundle.message("filter.ant.targets.action.name"), AntBundle.message("filter.ant.targets.action.description"), - IconLoader.getIcon("/ant/filter.png")); + super(AntBundle.message("filter.ant.targets.action.name"), AntBundle.message("filter.ant.targets.action.description"), ICON_FILTER); } public boolean isSelected(AnActionEvent event) { diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/ExecutionTab.form b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/ExecutionTab.form index 33237a2805e8..467381663312 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/ExecutionTab.form +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/configuration/ExecutionTab.form @@ -1,27 +1,24 @@
- + - - + - + - - + - - + @@ -29,8 +26,7 @@ - - + @@ -38,24 +34,21 @@ - - + - + - - + - - + @@ -63,8 +56,7 @@ - - + @@ -72,27 +64,25 @@ - + - - + - - + + - - + @@ -100,26 +90,42 @@ - - + - - + - - + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/git4idea/src/git4idea/history/GitCopyHistoryRevisionNumberAction.java b/plugins/git4idea/src/git4idea/history/GitCopyHistoryRevisionNumberAction.java new file mode 100644 index 000000000000..135c158d4b99 --- /dev/null +++ b/plugins/git4idea/src/git4idea/history/GitCopyHistoryRevisionNumberAction.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package git4idea.history; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.ide.CopyPasteManager; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.vcs.VcsDataKeys; +import com.intellij.openapi.vcs.history.VcsFileRevision; +import git4idea.i18n.GitBundle; + +import java.awt.datatransfer.StringSelection; + +/** + * The action that copies a revision number text to clipboard + */ +public class GitCopyHistoryRevisionNumberAction extends AnAction implements DumbAware { + + /** + * The constructor + */ + public GitCopyHistoryRevisionNumberAction() { + super(GitBundle.getString("history.copy.revsion.number")); + } + + /** + * {@inheritDoc} + */ + @Override + public void actionPerformed(AnActionEvent e) { + VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION); + if (revision != null) { + CopyPasteManager.getInstance().setContents(new StringSelection(revision.getRevisionNumber().asString())); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void update(AnActionEvent e) { + super.update(e); + e.getPresentation().setEnabled((e.getData(VcsDataKeys.VCS_FILE_REVISION) != null)); + } +} diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java b/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java index 5209cd82599c..7e3a2ae519e9 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java @@ -62,7 +62,7 @@ public class GitHistoryProvider implements VcsHistoryProvider { * {@inheritDoc} */ public AnAction[] getAdditionalActions(FileHistoryPanel panel) { - return new AnAction[]{new GitShowAllSubmittedFilesAction()}; + return new AnAction[]{new GitShowAllSubmittedFilesAction(), new GitCopyHistoryRevisionNumberAction()}; } /** diff --git a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties index dcfac82f50e7..0475ecc2d966 100644 --- a/plugins/git4idea/src/git4idea/i18n/GitBundle.properties +++ b/plugins/git4idea/src/git4idea/i18n/GitBundle.properties @@ -138,6 +138,7 @@ git.vcs.config.ssh.mode.tooltip=Specify which version of SSH to be used wi git.vcs.config.ssh.mode=&SSH executable: git.vcs.config.test.label=Test git.vcs.config.test=&Test +history.copy.revsion.number=Copy Revision Number index.file.error=Updating file in the index failed init.add.root.message=Do you want to add this directory as vcs root? init.add.root.title=Git Init diff --git a/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java b/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java index b65796f03a31..00ae19650ae0 100644 --- a/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java +++ b/plugins/git4idea/src/git4idea/vfs/GitRootTracker.java @@ -26,9 +26,6 @@ import com.intellij.openapi.command.CommandAdapter; import com.intellij.openapi.command.CommandEvent; import com.intellij.openapi.command.CommandListener; import com.intellij.openapi.command.CommandProcessor; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModuleRootEvent; import com.intellij.openapi.roots.ModuleRootListener; @@ -43,6 +40,8 @@ import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.ex.VirtualFileManagerAdapter; import com.intellij.openapi.vfs.ex.VirtualFileManagerEx; import com.intellij.util.messages.MessageBusConnection; +import com.intellij.util.ui.update.MergingUpdateQueue; +import com.intellij.util.ui.update.Update; import git4idea.GitUtil; import git4idea.GitVcs; import git4idea.i18n.GitBundle; @@ -50,7 +49,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.event.HyperlinkEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -91,7 +93,7 @@ public class GitRootTracker implements VcsListener { */ private final AtomicBoolean myNotificationPosted = new AtomicBoolean(false); - private final Object myCheckRootsLock = new Object(); + private final MergingUpdateQueue myQueue; private Notification myNotification; @@ -129,12 +131,14 @@ public class GitRootTracker implements VcsListener { * @param multicaster the listeners to notify */ public GitRootTracker(GitVcs vcs, @NotNull Project project, @NotNull GitRootsListener multicaster) { + myMulticaster = multicaster; if (project.isDefault()) { throw new IllegalArgumentException("The project must not be default"); } myProject = project; myProjectRoots = ProjectRootManager.getInstance(myProject); + myQueue = new MergingUpdateQueue("queue", 500, true, null, project, null, false); myVcs = vcs; myVcsManager = ProjectLevelVcsManager.getInstance(project); myVcsManager.addVcsListener(this); @@ -208,12 +212,10 @@ public class GitRootTracker implements VcsListener { doCheckRoots(rootsChanged); return; } - ProgressManager.getInstance().run(new Task.Backgroundable(myProject, "Checking Git roots...") { - public void run(@NotNull ProgressIndicator indicator) { - synchronized (myCheckRootsLock) { - if (myProject.isDisposed()) return; - doCheckRoots(rootsChanged); - } + myQueue.queue(new Update("root check") { + public void run() { + if (myProject.isDisposed()) return; + doCheckRoots(rootsChanged); } }); } @@ -250,7 +252,6 @@ public class GitRootTracker implements VcsListener { return false; } }); - if (!hasInvalidRoots && rootSet.isEmpty()) { myHasGitRoots.set(false); return; @@ -306,12 +307,11 @@ public class GitRootTracker implements VcsListener { * * @param directory the content root to check * @param rootSet the mapped root set - * @return true if there are unmapped subroots */ private static boolean hasUnmappedSubroots(final VirtualFile directory, final @Nullable HashSet rootSet) { VirtualFile[] children = ApplicationManager.getApplication().runReadAction(new Computable() { public VirtualFile[] compute() { - return directory.getChildren(); + return directory.isValid() ? directory.getChildren() : VirtualFile.EMPTY_ARRAY; } }); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index 42f6fe361e85..e743e6052466 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -218,7 +218,7 @@ public class GroovyAnnotator implements Annotator { private static void checkLabeledStatement(GrLabeledStatement statement, AnnotationHolder holder) { final String name = statement.getLabelName(); if (ResolveUtil.resolveLabeledStatement(name, statement, true) != null) { - holder.createErrorAnnotation(statement.getLabel(), GroovyBundle.message("label.already.used", name)); + holder.createWarningAnnotation(statement.getLabel(), GroovyBundle.message("label.already.used", name)); } } @@ -232,20 +232,18 @@ public class GroovyAnnotator implements Annotator { } } - final PsiElement targetStatement = statement.findTargetStatement(); + final GrStatement targetStatement = statement.findTargetStatement(); if (targetStatement == null) { if (statement instanceof GrContinueStatement && label == null) { holder.createErrorAnnotation(statement, GroovyBundle.message("continue.outside.loop")); } - else if (statement instanceof GrBreakStatement) { - if (label == null) { - holder.createErrorAnnotation(statement, GroovyBundle.message("break.outside.loop.or.switch")); - } - else if (findFirstLoop(statement) == null) { - holder.createErrorAnnotation(statement, GroovyBundle.message("break.outside.loop")); - } + else if (statement instanceof GrBreakStatement && label == null) { + holder.createErrorAnnotation(statement, GroovyBundle.message("break.outside.loop.or.switch")); } } + if (statement instanceof GrBreakStatement && label != null && findFirstLoop(statement) == null) { + holder.createErrorAnnotation(statement, GroovyBundle.message("break.outside.loop")); + } } @Nullable diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java index 6449e508b9c6..d98cfc1b3557 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java @@ -19,6 +19,8 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements.arguments; import com.intellij.lang.ASTNode; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; +import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry; +import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; import com.intellij.psi.util.PropertyUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; @@ -55,7 +57,9 @@ public class GrArgumentLabelImpl extends GroovyPsiElementImpl implements GrArgum } public PsiReference getReference() { - return this; + PsiReference[] otherReferences = ReferenceProvidersRegistry.getReferencesFromProviders(this, GrArgumentLabel.class); + PsiReference[] thisReference = {this}; + return new PsiMultiReference(otherReferences.length == 0 ? thisReference : ArrayUtil.mergeArrays(thisReference, otherReferences, PsiReference.class), this); } public String getName() { @@ -166,6 +170,7 @@ public class GrArgumentLabelImpl extends GroovyPsiElementImpl implements GrArgum } + @NotNull public Object[] getVariants() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java index c0e3be47076a..a0af3e28198a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java @@ -241,8 +241,8 @@ public class ResolveUtil { do { PsiElement last = element; element = element.getParent(); - if (element == null || element instanceof GrMember || element instanceof GrClosableBlock || element instanceof GroovyFile) break; - if (element instanceof GrStatement) { + if (element == null || element instanceof GrMember || element instanceof GroovyFile) break; + if (element instanceof GrStatement && !(element instanceof GrClosableBlock)) { statement = (GrStatement)element; } PsiElement sibling = element; @@ -253,6 +253,7 @@ public class ResolveUtil { } sibling = sibling.getPrevSibling(); } + if (element instanceof GrClosableBlock) break; } while (true); return new Pair(null, null); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.java index f151918d5fca..817ebe847f69 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.java @@ -21,9 +21,11 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiReference; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.LightGroovyTestCase; import java.io.File; +import java.io.IOException; /** * @author ven @@ -39,7 +41,7 @@ public abstract class GroovyResolveTestCase extends LightGroovyTestCase { } } - protected PsiReference configureByFile(@NonNls String filePath) throws Exception{ + protected PsiReference configureByFile(@NonNls String filePath, @Nullable String newFilePath) throws IOException { filePath = StringUtil.trimStart(filePath, getTestName(true) + "/"); final VirtualFile vFile = myFixture.getTempDirFixture().getFile(filePath); assertNotNull("file " + filePath + " not found", vFile); @@ -50,11 +52,20 @@ public abstract class GroovyResolveTestCase extends LightGroovyTestCase { assertTrue(offset >= 0); fileText = fileText.substring(0, offset) + fileText.substring(offset + MARKER.length()); - myFixture.configureByText(vFile.getFileType(), fileText); + if (newFilePath == null) { + myFixture.configureByText(vFile.getName(), fileText); + } + else { + myFixture.configureByText(newFilePath, fileText); + } PsiReference ref = myFixture.getFile().findReferenceAt(offset); assertNotNull(ref); return ref; } + protected PsiReference configureByFile(@NonNls String filePath) throws Exception { + return configureByFile(filePath, null); + } + } diff --git a/plugins/groovy/testdata/highlighting/UsedLabel.groovy b/plugins/groovy/testdata/highlighting/UsedLabel.groovy index 29b8a0f7deca..cff7c5840940 100644 --- a/plugins/groovy/testdata/highlighting/UsedLabel.groovy +++ b/plugins/groovy/testdata/highlighting/UsedLabel.groovy @@ -2,7 +2,7 @@ oo: for (s in ['a', 'b']) { oo1: for (s1 in ['a', 'b']) { - oo: + oo: for (s2 in ['a', 'b']) { } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenModulePsiReference.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenModulePsiReference.java index c1e6fa2be120..d05745434751 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenModulePsiReference.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenModulePsiReference.java @@ -19,9 +19,6 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.LocalQuickFixProvider; import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.notification.Notifications; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationType; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.io.FileUtil; @@ -134,7 +131,7 @@ public class MavenModulePsiReference extends MavenPsiReference implements LocalQ myWithParent ? id : null); } catch (IOException e) { - Notifications.Bus.notify(new Notification("Maven", "Cannot create a module", e.getMessage(), NotificationType.ERROR), project); + MavenUtil.showError(project, "Cannot create a module", e); } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfiguration.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfiguration.java index 7034dee12962..a3a8c37a685e 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfiguration.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfiguration.java @@ -18,6 +18,9 @@ package org.jetbrains.idea.maven.execution; import com.intellij.execution.ExecutionException; import com.intellij.execution.Executor; import com.intellij.execution.configurations.*; +import com.intellij.execution.process.OSProcessHandler; +import com.intellij.execution.process.ProcessAdapter; +import com.intellij.execution.process.ProcessEvent; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.runners.ProgramRunner; import com.intellij.openapi.module.Module; @@ -69,6 +72,18 @@ public class MavenRunConfiguration extends RunConfigurationBase implements Locat return MavenExternalParameters .createJavaParameters(mySettings.myRunnerParameters, mySettings.myGeneralSettings, mySettings.myRunnerSettings); } + + @Override + protected OSProcessHandler startProcess() throws ExecutionException { + OSProcessHandler result = super.startProcess(); + result.addProcessListener(new ProcessAdapter() { + @Override + public void processTerminated(ProcessEvent event) { + updateProjectsFolders(); + } + }); + return result; + } }; state.setConsoleBuilder(MavenConsoleImpl.createConsoleBuilder(getProject())); return state; @@ -81,6 +96,10 @@ public class MavenRunConfiguration extends RunConfigurationBase implements Locat } } + private void updateProjectsFolders() { + MavenProjectsManager.getInstance(getProject()).updateProjectTargetFolders(); + } + @NotNull public Module[] getModules() { return Module.EMPTY_ARRAY; @@ -125,7 +144,7 @@ public class MavenRunConfiguration extends RunConfigurationBase implements Locat if (mySettings.myGeneralSettings == null) mySettings.myGeneralSettings = new MavenGeneralSettings(); if (mySettings.myRunnerSettings == null) mySettings.myRunnerSettings = new MavenRunnerSettings(); - if (mySettings.myRunnerParameters == null) mySettings.myRunnerParameters = new MavenRunnerParameters(); + if (mySettings.myRunnerParameters == null) mySettings.myRunnerParameters = new MavenRunnerParameters(); } } @@ -158,8 +177,7 @@ public class MavenRunConfiguration extends RunConfigurationBase implements Locat } public MavenSettings(Project project) { - this(MavenProjectsManager.getInstance(project).getGeneralSettings(), - MavenRunner.getInstance(project).getState(), + this(MavenProjectsManager.getInstance(project).getGeneralSettings(), MavenRunner.getInstance(project).getState(), new MavenRunnerParameters()); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationType.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationType.java index bb2dad4387f8..e894b1feaace 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationType.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunConfigurationType.java @@ -15,6 +15,7 @@ */ package org.jetbrains.idea.maven.execution; +import com.intellij.compiler.options.CompileStepBeforeRun; import com.intellij.execution.*; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationTypeUtil; @@ -31,12 +32,13 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; -import com.intellij.compiler.options.CompileStepBeforeRun; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.project.MavenGeneralSettings; import org.jetbrains.idea.maven.project.MavenProject; import org.jetbrains.idea.maven.project.MavenProjectsManager; +import org.jetbrains.idea.maven.utils.MavenUtil; import javax.swing.*; import java.util.List; @@ -143,7 +145,7 @@ public class MavenRunConfigurationType implements LocatableConfigurationType { public RunnerAndConfigurationSettings createConfigurationByLocation(Location l) { final MavenRunnerParameters params = createBuildParameters(l); if (params == null) return null; - return createRunnerAndConfigurationSettings(null, null, params, l.getProject(), false); + return createRunnerAndConfigurationSettings(null, null, params, l.getProject()); } public boolean isConfigurationByLocation(RunConfiguration configuration, Location location) { @@ -161,24 +163,42 @@ public class MavenRunConfigurationType implements LocatableConfigurationType { return new MavenRunnerParameters(true, f.getParent().getPath(), goals, profiles); } - public static void runConfiguration(Project project, MavenRunnerParameters params, DataContext dataContext) throws ExecutionException { - doRunConfiguration(dataContext, createRunnerAndConfigurationSettings(MavenProjectsManager.getInstance(project).getGeneralSettings(), - MavenRunner.getInstance(project).getState(), - params, - project, - true)); + public static void runConfiguration(Project project, + MavenRunnerParameters params, + DataContext dataContext, + @Nullable ProgramRunner.Callback callback) { + MavenGeneralSettings settings = MavenProjectsManager.getInstance(project).getGeneralSettings(); + MavenRunnerSettings runnerSettings = MavenRunner.getInstance(project).getState(); + runConfiguration(project, params, settings, runnerSettings, dataContext, callback); } - private static void doRunConfiguration(DataContext dataContext, RunnerAndConfigurationSettings settings) throws ExecutionException { + public static void runConfiguration(Project project, + MavenRunnerParameters params, + MavenGeneralSettings settings, + MavenRunnerSettings runnerSettings, + DataContext context, + @Nullable ProgramRunner.Callback callback) { + RunnerAndConfigurationSettings configSettings = createRunnerAndConfigurationSettings(settings, + runnerSettings, + params, + project); + ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(DefaultRunExecutor.EXECUTOR_ID); - runner.execute(DefaultRunExecutor.getRunExecutorInstance(), new ExecutionEnvironment(runner, settings, dataContext)); + ExecutionEnvironment env = new ExecutionEnvironment(runner, configSettings, context); + Executor executor = DefaultRunExecutor.getRunExecutorInstance(); + + try { + runner.execute(executor, env, callback); + } + catch (ExecutionException e) { + MavenUtil.showError(project, "Failed to execute Maven goal", e); + } } private static RunnerAndConfigurationSettings createRunnerAndConfigurationSettings(MavenGeneralSettings generalSettings, MavenRunnerSettings runnerSettings, MavenRunnerParameters params, - Project project, - boolean diableMakeBeforeRun) { + Project project) { MavenRunConfigurationType type = ConfigurationTypeUtil.findConfigurationType(MavenRunConfigurationType.class); final RunnerAndConfigurationSettingsImpl settings = RunManagerEx.getInstanceEx(project) @@ -188,12 +208,6 @@ public class MavenRunConfigurationType implements LocatableConfigurationType { if (generalSettings != null) runConfiguration.setGeneralSettings(generalSettings); if (runnerSettings != null) runConfiguration.setRunnerSettings(runnerSettings); - if (diableMakeBeforeRun) disableMakeBeforeRun(RunManager.getInstance(project), runConfiguration); - return settings; } - - private static void disableMakeBeforeRun(RunManager runManager, MavenRunConfiguration runConfiguration) { - //((RunManagerEx)runManager).getBeforeRunTask(runConfiguration, CompileStepBeforeRun.ID).setEnabled(false); - } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunner.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunner.java index aaabb9b6c231..94b9de4e86ba 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunner.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunner.java @@ -62,10 +62,6 @@ public class MavenRunner extends SimpleProjectComponent implements PersistentSta mySettings = settings; } - public void run(MavenRunnerParameters parameters, MavenRunnerSettings settings) { - run(parameters, settings, null); - } - public void run(final MavenRunnerParameters parameters, final MavenRunnerSettings settings, final Runnable onComplete) { FileDocumentManager.getInstance().saveAllDocuments(); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenFoldersImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenFoldersImporter.java index 27b72e0e5c7c..6e78c91bcf3a 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenFoldersImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenFoldersImporter.java @@ -21,7 +21,6 @@ import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ProjectRootManager; -import org.jetbrains.idea.maven.importing.MavenImporter; import org.jetbrains.idea.maven.project.MavenImportingSettings; import org.jetbrains.idea.maven.project.MavenProject; import org.jetbrains.idea.maven.project.MavenProjectsManager; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenOpenOrCreateFilesAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenOpenOrCreateFilesAction.java index 84d31dd4715e..1f452f214bd5 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenOpenOrCreateFilesAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/MavenOpenOrCreateFilesAction.java @@ -15,9 +15,6 @@ */ package org.jetbrains.idea.maven.project.actions; -import com.intellij.notification.Notifications; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationType; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.application.Result; @@ -84,7 +81,7 @@ public abstract class MavenOpenOrCreateFilesAction extends MavenAction { MavenUtil.runFileTemplate(project, newFile, getFileTemplate()); } catch (IOException ex) { - Notifications.Bus.notify(new Notification("Maven", "Cannot create " + file.getName(), ex.getMessage(), NotificationType.ERROR), project); + MavenUtil.showError(project, "Cannot create " + file.getName(), ex); } } }.execute(); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/RunBuildAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/RunBuildAction.java index 8bbbd4185570..435d031902e7 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/RunBuildAction.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/RunBuildAction.java @@ -15,15 +15,13 @@ */ package org.jetbrains.idea.maven.project.actions; -import com.intellij.execution.ExecutionException; import com.intellij.openapi.actionSystem.AnActionEvent; import org.jetbrains.idea.maven.execution.MavenRunConfigurationType; import org.jetbrains.idea.maven.execution.MavenRunnerParameters; +import org.jetbrains.idea.maven.project.MavenProject; +import org.jetbrains.idea.maven.utils.MavenDataKeys; import org.jetbrains.idea.maven.utils.actions.MavenAction; import org.jetbrains.idea.maven.utils.actions.MavenActionUtil; -import org.jetbrains.idea.maven.utils.MavenDataKeys; -import org.jetbrains.idea.maven.utils.MavenLog; -import org.jetbrains.idea.maven.project.MavenProject; import java.util.List; @@ -47,14 +45,9 @@ public class RunBuildAction extends MavenAction { if (!perform) return true; - try { - MavenRunnerParameters params = new MavenRunnerParameters( - true, project.getDirectory(), goals, MavenActionUtil.getProjectsManager(e).getActiveProfiles()); - MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(e), params, e.getDataContext()); - } - catch (ExecutionException ex) { - MavenLog.LOG.warn(ex); - } + MavenRunnerParameters params = new MavenRunnerParameters( + true, project.getDirectory(), goals, MavenActionUtil.getProjectsManager(e).getActiveProfiles()); + MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(e), params, e.getDataContext(), null); return true; } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenKeymapExtension.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenKeymapExtension.java index 9b95aebd93d0..976701255163 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenKeymapExtension.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/MavenKeymapExtension.java @@ -15,7 +15,6 @@ */ package org.jetbrains.idea.maven.tasks; -import com.intellij.execution.ExecutionException; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -28,17 +27,16 @@ import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.TestOnly; import org.jetbrains.idea.maven.embedder.MavenEmbedderFactory; +import org.jetbrains.idea.maven.execution.MavenRunConfigurationType; +import org.jetbrains.idea.maven.execution.MavenRunnerParameters; import org.jetbrains.idea.maven.project.MavenPlugin; import org.jetbrains.idea.maven.project.MavenProject; import org.jetbrains.idea.maven.project.MavenProjectsManager; -import org.jetbrains.idea.maven.execution.MavenRunConfigurationType; -import org.jetbrains.idea.maven.execution.MavenRunnerParameters; +import org.jetbrains.idea.maven.utils.MavenArtifactUtil; +import org.jetbrains.idea.maven.utils.MavenIcons; +import org.jetbrains.idea.maven.utils.MavenPluginInfo; import org.jetbrains.idea.maven.utils.actions.MavenAction; import org.jetbrains.idea.maven.utils.actions.MavenActionUtil; -import org.jetbrains.idea.maven.utils.MavenArtifactUtil; -import org.jetbrains.idea.maven.utils.MavenLog; -import org.jetbrains.idea.maven.utils.MavenPluginInfo; -import org.jetbrains.idea.maven.utils.MavenIcons; import java.io.File; import java.util.*; @@ -184,16 +182,11 @@ public class MavenKeymapExtension implements KeymapExtension { } public void actionPerformed(AnActionEvent e) { - try { - MavenRunnerParameters params = new MavenRunnerParameters(true, - myMavenProject.getDirectory(), - Arrays.asList(myGoal), - MavenActionUtil.getProjectsManager(e).getActiveProfiles()); - MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(e), params, e.getDataContext()); - } - catch (ExecutionException ex) { - MavenLog.LOG.warn(ex); - } + MavenRunnerParameters params = new MavenRunnerParameters(true, + myMavenProject.getDirectory(), + Arrays.asList(myGoal), + MavenActionUtil.getProjectsManager(e).getActiveProfiles()); + MavenRunConfigurationType.runConfiguration(MavenActionUtil.getProject(e), params, e.getDataContext(), null); } public MavenProject getMavenProject() { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java index 0f2ebbb8ff1c..6f5c94b39337 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java @@ -19,6 +19,9 @@ import com.intellij.codeInsight.template.TemplateManager; import com.intellij.codeInsight.template.impl.TemplateImpl; import com.intellij.ide.fileTemplates.FileTemplate; import com.intellij.ide.fileTemplates.FileTemplateManager; +import com.intellij.notification.Notification; +import com.intellij.notification.NotificationType; +import com.intellij.notification.Notifications; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.PathManager; @@ -150,6 +153,11 @@ public class MavenUtil { return LaterInvocator.isInModalContext(); } + public static void showError(Project project, String title, Throwable e) { + MavenLog.LOG.error(e); + Notifications.Bus.notify(new Notification("Maven", title, e.getMessage(), NotificationType.ERROR), project); + } + public static Properties getSystemProperties() { Properties result = (Properties)System.getProperties().clone(); for (String each : new THashSet((Set)result.keySet())) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilder.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilder.java index e36f4d5180ec..1b9f244c69f3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilder.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleBuilder.java @@ -15,14 +15,16 @@ */ package org.jetbrains.idea.maven.wizards; +import com.intellij.execution.process.ProcessAdapter; +import com.intellij.execution.process.ProcessEvent; +import com.intellij.execution.runners.ProgramRunner; +import com.intellij.execution.ui.RunContentDescriptor; +import com.intellij.ide.DataManager; import com.intellij.ide.util.EditorHelper; import com.intellij.ide.util.projectWizard.ModuleBuilder; import com.intellij.ide.util.projectWizard.ModuleWizardStep; import com.intellij.ide.util.projectWizard.SourcePathsBuilder; import com.intellij.ide.util.projectWizard.WizardContext; -import com.intellij.notification.Notifications; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationType; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; @@ -46,6 +48,7 @@ import com.intellij.psi.xml.XmlElement; import org.jetbrains.idea.maven.dom.MavenDomUtil; import org.jetbrains.idea.maven.dom.model.MavenDomModule; import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel; +import org.jetbrains.idea.maven.execution.MavenRunConfigurationType; import org.jetbrains.idea.maven.execution.MavenRunner; import org.jetbrains.idea.maven.execution.MavenRunnerParameters; import org.jetbrains.idea.maven.execution.MavenRunnerSettings; @@ -107,9 +110,7 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil result.setResult(file); } catch (IOException e) { - MavenLog.LOG.warn(e); - Notifications.Bus.notify(new Notification("Maven", "Cannot create " + MavenConstants.POM_XML + " " + root.getPath(), - e.getMessage(), NotificationType.ERROR), project); + showError(project, e); return; } @@ -185,7 +186,7 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil workingDir.deleteOnExit(); } catch (IOException e) { - MavenLog.LOG.warn("Cannot generate archetype", e); + showError(project, e); return; } @@ -208,24 +209,32 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil runner.run(params, settings, new Runnable() { public void run() { - try { - FileUtil.copyDir(new File(workingDir, myProjectId.getArtifactId()), new File(myContentRootPath)); - } - catch (IOException e) { - MavenLog.LOG.warn("Cannot generate archetype", e); - return; - } - - FileUtil.delete(workingDir); - - pom.refresh(false, false); - updateProjectPom(project, pom); - - LocalFileSystem.getInstance().refreshWithoutFileWatcher(true); + copyGeneratedFiles(workingDir, pom, project); } }); } + private void copyGeneratedFiles(File workingDir, VirtualFile pom, Project project) { + try { + FileUtil.copyDir(new File(workingDir, myProjectId.getArtifactId()), new File(myContentRootPath)); + } + catch (IOException e) { + showError(project, e); + return; + } + + FileUtil.delete(workingDir); + + pom.refresh(false, false); + updateProjectPom(project, pom); + + LocalFileSystem.getInstance().refreshWithoutFileWatcher(true); + } + + private void showError(Project project, Throwable e) { + MavenUtil.showError(project, "Failed to create a Maven project", e); + } + @Override public String getBuilderId() { return getClass().getName(); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java index 227cc81c5aee..3e226792f5bc 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java @@ -77,11 +77,15 @@ public abstract class MavenTestCase extends UsefulTestCase { MavenWorkspaceSettingsComponent.getInstance(myProject).loadState(new MavenWorkspaceSettings()); + String home = getTestMavenHome(); + if (home != null) { + getMavenGeneralSettings().setMavenHome(home); + } + restoreSettingsFile(); ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { - try { setUpInWriteAction(); } @@ -153,11 +157,20 @@ public abstract class MavenTestCase extends UsefulTestCase { @Override protected void runTest() throws Throwable { - new WriteAction() { - protected void run(Result result) throws Throwable { - MavenTestCase.super.runTest(); - } - }.executeSilently().throwException(); + if (runInWriteAction()) { + new WriteAction() { + protected void run(Result result) throws Throwable { + MavenTestCase.super.runTest(); + } + }.executeSilently().throwException(); + } + else { + MavenTestCase.super.runTest(); + } + } + + protected boolean runInWriteAction() { + return true; } protected MavenGeneralSettings getMavenGeneralSettings() { @@ -409,8 +422,12 @@ public abstract class MavenTestCase extends UsefulTestCase { } protected boolean hasMavenInstallation() { - boolean result = "true".equals(System.getProperty("idea.maven.test.has.installation")); + boolean result = getTestMavenHome() != null; if (!result) System.out.println("Ignored, because Maven installation not found: " + getClass().getSimpleName() + "." + getName()); return result; } + + private String getTestMavenHome() { + return System.getProperty("idea.maven.test.home"); + } } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutionTest.java new file mode 100644 index 000000000000..61ad7353937e --- /dev/null +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutionTest.java @@ -0,0 +1,116 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.maven.execution; + +import com.intellij.execution.process.ProcessAdapter; +import com.intellij.execution.process.ProcessEvent; +import com.intellij.execution.runners.ProgramRunner; +import com.intellij.execution.ui.RunContentDescriptor; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.application.Result; +import com.intellij.openapi.application.WriteAction; +import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.testFramework.MapDataContext; +import com.intellij.util.concurrency.Semaphore; +import org.jetbrains.idea.maven.MavenImportingTestCase; + +import java.io.File; +import java.util.Arrays; + +@SuppressWarnings({"ConstantConditions"}) +public class MavenExecutionTest extends MavenImportingTestCase { + @Override + protected boolean runInWriteAction() { + return false; + } + + public void testExternalExecutor() throws Exception { + if (!hasMavenInstallation()) return; + + VfsUtil.saveText(createProjectSubFile("src/main/java/A.java"), "public class A {}"); + + new WriteAction() { + @Override + protected void run(Result objectResult) throws Throwable { + createProjectPom("test" + + "project" + + "1"); + } + }.execute(); + + assertFalse(new File(getProjectPath(), "target").exists()); + + execute(new MavenRunnerParameters(true, getProjectPath(), Arrays.asList("compile"), null)); + + assertTrue(new File(getProjectPath(), "target").exists()); + } + + public void testUpdatingExcludedFoldersAfterExecution() throws Exception { + if (!hasMavenInstallation()) return; + + new WriteAction() { + @Override + protected void run(Result objectResult) throws Throwable { + createStdProjectFolders(); + + importProject("test" + + "project" + + "1"); + + createProjectSubDirs("target/generated-sources/foo", + "target/bar"); + } + }.execute(); + + assertModules("project"); + assertExcludes("project", "target"); + + MavenRunnerParameters params = new MavenRunnerParameters(true, getProjectPath(), Arrays.asList("compile"), null); + execute(params); + + assertSources("project", + "src/main/java", + "src/main/resources", + "target/generated-sources/foo"); + + assertExcludes("project", + "target/bar", + "target/classes", + "target/classes"); // output dirs are collected twice for exclusion and for compiler output + } + + private void execute(MavenRunnerParameters params) { + final Semaphore sema = new Semaphore(); + sema.down(); + MapDataContext context = new MapDataContext(); + context.put(PlatformDataKeys.PROJECT, myProject); + MavenRunConfigurationType.runConfiguration(myProject, params, getMavenGeneralSettings(), + new MavenRunnerSettings(), + context, new ProgramRunner.Callback() { + public void processStarted(final RunContentDescriptor descriptor) { + descriptor.getProcessHandler().addProcessListener(new ProcessAdapter() { + @Override + public void processTerminated(ProcessEvent event) { + sema.up(); + descriptor.dispose(); + } + }); + } + }); + sema.waitFor(); + } + +} diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutorsTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutorsTest.java deleted file mode 100644 index ea464ba9499c..000000000000 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenExecutorsTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.idea.maven.execution; - -import com.intellij.openapi.progress.EmptyProgressIndicator; -import com.intellij.openapi.vfs.VfsUtil; -import org.jetbrains.idea.maven.MavenTestCase; - -import java.io.File; -import java.util.Arrays; - -public class MavenExecutorsTest extends MavenTestCase { - public void testExternalExecutor() throws Exception { - if (!hasMavenInstallation()) return; - - VfsUtil.saveText(createProjectSubFile("src/main/java/A.java"), "public class A {}"); - - createProjectPom("test" + - "project" + - "1"); - - assertFalse(new File(getProjectPath(), "target").exists()); - - MavenRunnerParameters params = new MavenRunnerParameters(true, getProjectPath(), Arrays.asList("compile"), null); - MavenRunnerSettings settings = new MavenRunnerSettings(); - - MavenExecutor e; - settings.setJreName(MavenRunnerSettings.USE_INTERNAL_JAVA); - e = new MavenExternalExecutor(params, getMavenGeneralSettings(), settings, NULL_MAVEN_CONSOLE); - - assertTrue(e.execute(new EmptyProgressIndicator())); - - assertTrue(new File(getProjectPath(), "target").exists()); - } -} diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunnerTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunnerTest.java deleted file mode 100644 index 8390c21210b8..000000000000 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/execution/MavenRunnerTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.idea.maven.execution; - -import org.jetbrains.idea.maven.MavenImportingTestCase; - -import java.util.Arrays; - -public class MavenRunnerTest extends MavenImportingTestCase { - public void testUpdatingExcludedFoldersAfterRun() throws Exception { - if (!hasMavenInstallation()) return; - - createStdProjectFolders(); - - importProject("test" + - "project" + - "1"); - - assertModules("project"); - assertExcludes("project", "target"); - - createProjectSubDirs("target/generated-sources/foo", - "target/bar"); - - MavenRunner runner = new MavenRunner(myProject); - MavenRunnerParameters params = new MavenRunnerParameters(true, getProjectPath(), Arrays.asList("compile"), null); - MavenRunnerSettings settings = new MavenRunnerSettings(); - runner.run(params, settings); - - assertSources("project", - "src/main/java", - "src/main/resources", - "target/generated-sources/foo"); - - assertExcludes("project", - "target/bar", - "target/classes", - "target/classes"); // output dirs are collected twice for exclusion and for compiler output - } -} diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/PreviewFormAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/PreviewFormAction.java index a48421be7f98..c89fdb30fdbe 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/PreviewFormAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/PreviewFormAction.java @@ -321,6 +321,10 @@ public final class PreviewFormAction extends AnAction{ myStatusbarMessage = statusbarMessage; } + public Icon getIcon() { + return null; + } + public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException { final JavaCommandLineState state = new JavaCommandLineState(env) { protected JavaParameters createJavaParameters() { diff --git a/resources-en/src/messages/AntBundle.properties b/resources-en/src/messages/AntBundle.properties index ec9a1c3fccc7..d0fd2afb829c 100644 --- a/resources-en/src/messages/AntBundle.properties +++ b/resources-en/src/messages/AntBundle.properties @@ -184,3 +184,4 @@ loading.ant.config.progress=Loading ant configuration... intention.configure.highlighting.family.name=Configure highlighting intention.configure.highlighting.text=Configure highlighting build.file.properties.maximum.stack.size.label=Maximum &stack size (Mb): +run.execution.tab.ant.command.line.hint=Use "-J" prefix to specify JVM arguments