diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java index 8bd7f5477eea..e729aeadff4b 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java @@ -27,14 +27,13 @@ import com.intellij.ide.util.projectWizard.ModuleBuilder; import com.intellij.ide.util.projectWizard.ModuleWizardStep; import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.openapi.application.ApplicationNamesInfo; +import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.roots.ui.configuration.ModulesProvider; -import com.intellij.openapi.module.ModuleType; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.util.HashMap; import java.util.Map; @@ -49,7 +48,7 @@ public class CreateFromScratchMode extends WizardMode { @NotNull public String getDescription(final WizardContext context) { - return ProjectBundle.message("project.new.wizard.from.scratch.description", ApplicationNamesInfo.getInstance().getProductName(), context.getPresentationName()); + return ProjectBundle.message("project.new.wizard.from.scratch.description", ApplicationNamesInfo.getInstance().getFullProductName(), context.getPresentationName()); } @Nullable diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromSourcesMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromSourcesMode.java index f4571186789c..d514b0067edc 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromSourcesMode.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromSourcesMode.java @@ -52,7 +52,7 @@ public abstract class CreateFromSourcesMode extends WizardMode { @NotNull public String getDescription(final WizardContext context) { return ProjectBundle.message("project.new.wizard.from.existent.sources.description", - ApplicationNamesInfo.getInstance().getProductName(), context.getPresentationName()); + ApplicationNamesInfo.getInstance().getFullProductName(), context.getPresentationName()); } @Nullable diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportImlMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportImlMode.java index 34716c72a9b3..e8311c223944 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportImlMode.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportImlMode.java @@ -52,7 +52,7 @@ public class ImportImlMode extends WizardMode { @NotNull public String getDescription(final WizardContext context) { - return IdeBundle.message("prompt.select.module.file.to.import", ApplicationNamesInfo.getInstance().getProductName()); + return IdeBundle.message("prompt.select.module.file.to.import", ApplicationNamesInfo.getInstance().getFullProductName()); } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportMode.java index bb7b40aec703..e00eef20309c 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportMode.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/ImportMode.java @@ -48,7 +48,7 @@ public class ImportMode extends WizardMode { @NotNull public String getDescription(final WizardContext context) { - final String productName = ApplicationNamesInfo.getInstance().getProductName(); + final String productName = ApplicationNamesInfo.getInstance().getFullProductName(); return ProjectBundle.message("project.new.wizard.import.description", productName, context.getPresentationName(), StringUtil.join( Arrays.asList(Extensions.getExtensions(ProjectImportProvider.PROJECT_IMPORT_PROVIDER)), new Function() { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/LibraryProjectStructureElement.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/LibraryProjectStructureElement.java index 200e95e3d30d..1efe1a27247b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/LibraryProjectStructureElement.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/LibraryProjectStructureElement.java @@ -72,7 +72,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement { private static String createInvalidRootsDescription(List invalidClasses, String rootName, String libraryName) { StringBuilder buffer = new StringBuilder(); buffer.append(""); - buffer.append("Library '").append(libraryName).append("' has broken " + rootName + " " + StringUtil.pluralize("path", invalidClasses.size()) + ":"); + buffer.append("Library '").append(StringUtil.escapeXml(libraryName)).append("' has broken " + rootName + " " + StringUtil.pluralize("path", invalidClasses.size()) + ":"); for (String url : invalidClasses) { buffer.append("
  "); buffer.append(PathUtil.toPresentableUrl(url)); @@ -129,7 +129,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement { @Override public ProjectStructureProblemDescription createUnusedElementWarning() { final List fixes = Arrays.asList(new AddLibraryToDependenciesFix(), new RemoveLibraryFix()); - return new ProjectStructureProblemDescription(getPresentableName() + " is not used", null, createPlace(), + return new ProjectStructureProblemDescription("Library '" + StringUtil.escapeXml(myLibrary.getName()) + "'" + " is not used", null, createPlace(), ProjectStructureProblemType.unused("unused-library"), ProjectStructureProblemDescription.ProblemLevel.PROJECT, fixes, false); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java index 22f4752597c5..6f3b39a5893c 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ModuleProjectStructureElement.java @@ -10,6 +10,7 @@ import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.ui.configuration.ModuleEditor; import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable; import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; @@ -57,7 +58,7 @@ public class ModuleProjectStructureElement extends ProjectStructureElement { null); } else { - problemsHolder.registerProblem(ProjectBundle.message("project.roots.library.problem.message", entry.getPresentableName()), null, + problemsHolder.registerProblem(ProjectBundle.message("project.roots.library.problem.message", StringUtil.escapeXml(entry.getPresentableName())), null, ProjectStructureProblemType.error("invalid-module-dependency"), createPlace(entry), null); } diff --git a/java/java-impl/src/com/intellij/openapi/roots/impl/LanguageLevelUsagesCollector.java b/java/java-impl/src/com/intellij/openapi/roots/impl/LanguageLevelUsagesCollector.java new file mode 100644 index 000000000000..a022b701ff6c --- /dev/null +++ b/java/java-impl/src/com/intellij/openapi/roots/impl/LanguageLevelUsagesCollector.java @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.roots.impl; + +import com.intellij.internal.statistic.AbstractApplicationUsagesCollector; +import com.intellij.internal.statistic.beans.GroupDescriptor; +import com.intellij.internal.statistic.beans.UsageDescriptor; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.LanguageLevelModuleExtension; +import com.intellij.openapi.roots.LanguageLevelProjectExtension; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.HashSet; +import org.jetbrains.annotations.NotNull; + +import java.util.Set; + +public class LanguageLevelUsagesCollector extends AbstractApplicationUsagesCollector { + public static final String GROUP_ID = "language-level"; + + @NotNull + @Override + public GroupDescriptor getGroupId() { + return GroupDescriptor.create(GROUP_ID, GroupDescriptor.HIGHER_PRIORITY); + } + + + @NotNull + public Set getProjectUsages(@NotNull Project project) { + + final Set languageLevels = new HashSet(); + for (Module module : ModuleManager.getInstance(project).getModules()) { + final LanguageLevelModuleExtension instance = LanguageLevelModuleExtension.getInstance(module); + final LanguageLevel languageLevel = instance.getLanguageLevel(); + if (languageLevel != null) { + languageLevels.add(languageLevel.getPresentableText()); + } + } + languageLevels.add(LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().getPresentableText()); + + return ContainerUtil.map2Set(languageLevels, new Function() { + @Override + public UsageDescriptor fun(String languageLevel) { + return new UsageDescriptor(languageLevel, 1); + } + }); + } +} diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java index 417883814970..8b4723334984 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java @@ -1179,7 +1179,7 @@ public class ExtractMethodProcessor implements MatchProvider { private boolean applyChosenClassAndExtract(List inputVariables, @Nullable Pass extractPass) throws PrepareFailedException { myStatic = shouldBeStatic(); - if (myTargetClass.getContainingClass() == null || myTargetClass.hasModifierProperty(PsiModifier.STATIC)) { + if (!PsiUtil.isLocalOrAnonymousClass(myTargetClass) && (myTargetClass.getContainingClass() == null || myTargetClass.hasModifierProperty(PsiModifier.STATIC))) { ElementNeedsThis needsThis = new ElementNeedsThis(myTargetClass); for (int i = 0; i < myElements.length && !needsThis.usesMembers(); i++) { PsiElement element = myElements[i]; diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java index ff5921437afc..8ce18260c8af 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterHandler.java @@ -396,12 +396,10 @@ public class IntroduceParameterHandler extends IntroduceHandlerBase { } boolean mustBeFinal = false; - if (myLocalVar != null) { - for(PsiExpression occurrence: occurences) { - if (PsiTreeUtil.getParentOfType(occurrence, PsiClass.class, PsiMethod.class) != method) { - mustBeFinal = true; - break; - } + for (PsiExpression occurrence : occurences) { + if (PsiTreeUtil.getParentOfType(occurrence, PsiClass.class, PsiMethod.class) != method) { + mustBeFinal = true; + break; } } diff --git a/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java b/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java index 0324b445af37..9a86dff9062c 100644 --- a/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java +++ b/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java @@ -191,7 +191,7 @@ public class ThreadDumpPanel extends JPanel { final int s1 = getThreadStateCode(o1).ordinal(); final int s2 = getThreadStateCode(o2).ordinal(); if (s1 == s2) { - return o1.getName().compareTo(o2.getName()); + return o1.getName().compareToIgnoreCase(o2.getName()); } else { return s1 < s2 ? - 1 : 1; } diff --git a/lib/eawtstub.jar b/lib/eawtstub.jar index 089e5487aad3..62903c29ab5b 100644 Binary files a/lib/eawtstub.jar and b/lib/eawtstub.jar differ diff --git a/lib/src/eawtstub_src.zip b/lib/src/eawtstub_src.zip index 95878b1b65fc..06842049bd49 100644 Binary files a/lib/src/eawtstub_src.zip and b/lib/src/eawtstub_src.zip differ diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java index 396f22337928..2d8d5ec100a3 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java @@ -57,7 +57,7 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem private Map myIgnoredElements; private HashMap myOldProblemElements = null; - private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.DescriptorProviderInspection"); + protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.DescriptorProviderInspection"); public void addProblemElement(RefEntity refElement, CommonProblemDescriptor... descriptions){ addProblemElement(refElement, true, descriptions); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java index 6800577f73a4..4123e2f6736b 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java @@ -52,6 +52,7 @@ public abstract class InspectionToolWrapper extends L private final FileType myFileType; public TypeColumn(Project project, FileType fileType) { - super(RefactoringBundle.message("column.name.type")); + this(project, fileType, RefactoringBundle.message("column.name.type")); + } + + public TypeColumn(Project project, FileType fileType, String title) { + super(title); myProject = project; myFileType = fileType; } @@ -157,7 +161,11 @@ public abstract class ParameterTableModelBase

extends L private final Project myProject; public NameColumn(Project project) { - super(RefactoringBundle.message("column.name.name")); + this(project, RefactoringBundle.message("column.name.name")); + } + + public NameColumn(Project project, String title) { + super(title); myProject = project; } diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java index 37e3f6dc0c90..7bb4ac18757f 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java @@ -165,6 +165,7 @@ public class FileBasedIndex implements ApplicationComponent { synchronized (myTransactionMap) { myTransactionMap.remove(doc); } + incTransactionCount(doc); } }); @@ -1234,7 +1235,8 @@ public class FileBasedIndex implements ApplicationComponent { content = new AuthenticContent(document); } - final long currentDocStamp = content.getModificationStamp(); + final long currentDocStamp = content.getModificationStamp() + + getTransactionCount(document); // we add transaction count in order to deal with committed status if (currentDocStamp != myLastIndexedDocStamps.getAndSet(document, requestedIndexId, currentDocStamp)) { final Ref exRef = new Ref(null); ProgressManager.getInstance().executeNonCancelableSection(new Runnable() { @@ -1280,6 +1282,18 @@ public class FileBasedIndex implements ApplicationComponent { return true; } + public static final Key TRANSACTION_COUNT = new Key("Transaction count"); + + private long getTransactionCount(@NotNull Document document) { + Integer data = document.getUserData(TRANSACTION_COUNT); + return data != null ? data : 0; + } + + private void incTransactionCount(@NotNull Document document) { + Integer data = document.getUserData(TRANSACTION_COUNT); + document.putUserData(TRANSACTION_COUNT, (data != null ? data : 0) + 1); + } + public static final Key EDITOR_HIGHLIGHTER = new Key("Editor"); @Nullable diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/ActionUninstallPlugin.java b/platform/platform-impl/src/com/intellij/ide/plugins/ActionUninstallPlugin.java index 64a563a7ee2c..827b8116362b 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/ActionUninstallPlugin.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/ActionUninstallPlugin.java @@ -62,7 +62,8 @@ public class ActionUninstallPlugin extends AnAction implements DumbAware { } } if (descriptor instanceof PluginNode) { - enabled &= PluginManagerColumnInfo.getRealNodeState((PluginNode)descriptor) == PluginNode.STATUS_DOWNLOADED; + enabled = false; + break; } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MacGestureAdapter.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MacGestureAdapter.java new file mode 100644 index 000000000000..32538508f7a0 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MacGestureAdapter.java @@ -0,0 +1,75 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.actionSystem.impl; + +import com.apple.eawt.event.*; +import com.intellij.openapi.wm.IdeFrame; + +import javax.swing.*; + +/** +* User: anna +* Date: 11/29/11 +*/ +class MacGestureAdapter extends GestureAdapter { + double magnification; + private final IdeFrame myFrame; + private MouseGestureManager myManager; + + public MacGestureAdapter(MouseGestureManager manager, IdeFrame frame) { + myFrame = frame; + magnification = 0; + myManager = manager; + GestureUtilities.addGestureListenerTo(frame.getComponent(), this); + } + + @Override + public void gestureBegan(GesturePhaseEvent event) { + myManager.activateTrackpad(); + magnification = 0; + } + + @Override + public void gestureEnded(GesturePhaseEvent event) { + myManager.activateTrackpad(); + if (magnification != 0) { + MouseGestureManager.processMagnification(myFrame, magnification); + magnification = 0; + } + } + + @Override + public void swipedLeft(SwipeEvent event) { + myManager.activateTrackpad(); + myManager.processLeftSwipe(myFrame); + } + + @Override + public void swipedRight(SwipeEvent event) { + myManager.activateTrackpad(); + myManager.processRightSwipe(myFrame); + } + + @Override + public void magnify(MagnificationEvent event) { + myManager.activateTrackpad(); + magnification += event.getMagnification(); + } + + public void remove(JComponent cmp) { + GestureUtilities.removeGestureListenerFrom(cmp, this); + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MouseGestureManager.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MouseGestureManager.java index 678a9b9d8b61..7e4ae8bb03fd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MouseGestureManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/MouseGestureManager.java @@ -15,22 +15,24 @@ */ package com.intellij.openapi.actionSystem.impl; +import com.intellij.ide.DataManager; import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.IdeFrame; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; import java.util.HashMap; import java.util.Map; @@ -40,6 +42,8 @@ public class MouseGestureManager implements ApplicationComponent { private ActionManagerImpl myActionManager; private Map myListeners = new HashMap(); + private boolean HAS_TRACKPAD = false; + public MouseGestureManager(ActionManagerImpl actionManager) { myActionManager = actionManager; @@ -54,47 +58,53 @@ public class MouseGestureManager implements ApplicationComponent { remove(frame); } - Class gestureListenerClass = Class.forName("com.apple.eawt.event.GestureListener"); - Class swipeListenerClass = Class.forName("com.apple.eawt.event.SwipeListener"); - Object listener = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{swipeListenerClass}, new InvocationHandler() { - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if ("swipedRight".equals(method.getName())) { - processRightSwipe(frame); - } else if ("swipedLeft".equals(method.getName())) { - processLeftSwipe(frame); - } - return null; - } - }); - - Class utilsClass = Class.forName("com.apple.eawt.event.GestureUtilities"); - Method addMethod = utilsClass.getDeclaredMethod("addGestureListenerTo", JComponent.class, gestureListenerClass); - addMethod.invoke(null, frame.getComponent(), listener); + Object listener = new MacGestureAdapter(this, frame); myListeners.put(frame, listener); } - catch (Exception e) { + catch (Throwable e) { LOG.debug(e); } } } - private void processLeftSwipe(IdeFrame frame) { + protected void activateTrackpad() { + HAS_TRACKPAD = true; + } + + public boolean hasTrackpad() { + return HAS_TRACKPAD; + } + + protected static void processMagnification(IdeFrame frame, double magnification) { + Point mouse = MouseInfo.getPointerInfo().getLocation(); + SwingUtilities.convertPointFromScreen(mouse, frame.getComponent()); + Component componentAt = SwingUtilities.getDeepestComponentAt(frame.getComponent(), mouse.x, mouse.y); + if (componentAt != null) { + Editor editor = PlatformDataKeys.EDITOR.getData(DataManager.getInstance().getDataContext(componentAt)); + if (editor != null) { + double currentSize = editor.getColorsScheme().getEditorFontSize(); + int defaultFontSize = EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize(); + ((EditorEx)editor).setFontSize((int)(Math.max(currentSize + magnification * 3, defaultFontSize))); + } + } + } + + protected void processLeftSwipe(IdeFrame frame) { AnAction forward = myActionManager.getAction("Forward"); if (forward == null) return; myActionManager.tryToExecute(forward, createMouseEventWrapper(frame), null, null, false); } - private void processRightSwipe(IdeFrame frame) { + protected void processRightSwipe(IdeFrame frame) { AnAction back = myActionManager.getAction("Back"); if (back == null) return; myActionManager.tryToExecute(back, createMouseEventWrapper(frame), null, null, false); } - private MouseEvent createMouseEventWrapper(IdeFrame frame) { + private static MouseEvent createMouseEventWrapper(IdeFrame frame) { return new MouseEvent(frame.getComponent(), ActionEvent.ACTION_PERFORMED, System.currentTimeMillis(), 0, 0, 0, 0, false, 0); } @@ -107,13 +117,10 @@ public class MouseGestureManager implements ApplicationComponent { JComponent cmp = frame.getComponent(); myListeners.remove(frame); if (listener != null && cmp != null && cmp.isShowing()) { - Class gestureListenerClass = Class.forName("com.apple.eawt.event.GestureListener"); - Class utilsClass = Class.forName("com.apple.eawt.event.GestureUtilities"); - Method addMethod = utilsClass.getDeclaredMethod("removeGestureListenerFrom", JComponent.class, gestureListenerClass); - addMethod.invoke(null, cmp, listener); + ((MacGestureAdapter)listener).remove(cmp); } } - catch (Exception e) { + catch (Throwable e) { LOG.debug(e); } } 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 8408e01bdaf6..bd88f4e29259 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 @@ -355,7 +355,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application LOG.error(ex); @NonNls final String errorMessage = "Fatal error initializing class " + componentClassName + ":\n" + ex.toString() + - "\nComplete error stacktrace was written to idea.log"; + "\nComplete error stacktrace was written to " + PathManager.getLogPath() + "/idea.log"; if (!myHeadlessMode) { JOptionPane.showMessageDialog(null, errorMessage); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 459f84dc8bc1..eca9c747af4d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -29,6 +29,7 @@ import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.actionSystem.ex.ActionManagerEx; +import com.intellij.openapi.actionSystem.impl.MouseGestureManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.ex.ApplicationManagerEx; @@ -6096,7 +6097,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi @Override protected void processMouseWheelEvent(MouseWheelEvent e) { - if (mySettings.isWheelFontChangeEnabled()) { + if (mySettings.isWheelFontChangeEnabled() && !MouseGestureManager.getInstance().hasTrackpad()) { if (EditorUtil.isChangeFontSize(e)) { setFontSize(myScheme.getEditorFontSize() - e.getWheelRotation()); return; diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index defbbf58363a..3c9022834161 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -162,3 +162,6 @@ navbar.is.decorated=true navbar.is.decorated.description=NavBar with decorations show.anonymous.in.structure.view=false show.anonymous.in.structure.view.description=Enables Java anonymous classes in Structure View + +enable.groovy.hotswap=true +enable.groovy.hotswap.description=Whether IDEA should add a special java agent to the debugged process which allows to hot-swap Groovy changes in some cases diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index 6e61a80398c2..e11978e3d91e 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -438,7 +438,9 @@ public class XDebugSessionImpl implements XDebugSession { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { - mySessionTab.getUi().clearAttractionBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION); + if (mySessionTab != null) { + mySessionTab.getUi().clearAttractionBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION); + } } }); myDispatcher.getMulticaster().sessionResumed(); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java index 2ab581ed0b9a..396b11f9b948 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java @@ -31,6 +31,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; import com.intellij.openapi.ui.Messages; @@ -643,12 +644,17 @@ public class AndroidCompileUtil { public static void collectAllResources(@NotNull final AndroidFacet facet, final Set resourceSet) { final LocalResourceManager manager = facet.getLocalResourceManager(); + final Project project = facet.getModule().getProject(); + final DumbService dumbService = DumbService.getInstance(project); + for (final String resType : ResourceType.getNames()) { for (final ResourceElement element : manager.getValueResources(resType)) { + dumbService.waitForSmartMode(); + ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { - if (!element.isValid() || facet.getModule().isDisposed() || facet.getModule().getProject().isDisposed()) { + if (!element.isValid() || facet.getModule().isDisposed() || project.isDisposed()) { return; } final String name = element.getName().getValue(); @@ -662,10 +668,12 @@ public class AndroidCompileUtil { } for (final Resources resources : manager.getResourceElements()) { + dumbService.waitForSmartMode(); + ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { - if (!resources.isValid() || facet.getModule().isDisposed() || facet.getModule().getProject().isDisposed()) { + if (!resources.isValid() || facet.getModule().isDisposed() || project.isDisposed()) { return; } @@ -688,10 +696,12 @@ public class AndroidCompileUtil { }); } + dumbService.waitForSmartMode(); + ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { - if (facet.getModule().isDisposed() || facet.getModule().getProject().isDisposed()) { + if (facet.getModule().isDisposed() || project.isDisposed()) { return; } diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/CvsBundle.properties b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/CvsBundle.properties index 6ff67698f0ae..34267dfc644a 100644 --- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/CvsBundle.properties +++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/CvsBundle.properties @@ -360,10 +360,12 @@ action.Cvs.Import.description=Put files into a CVS repository action.Cvs.BrowseCVSRepository.text=_Browse CVS Repository... action.Cvs.BrowseCVSRepository.description=Browse a CVS repository group.CvsGlobalGroup.text=_CVS -action.GlobalSettings.text=Global Settings... +action.GlobalSettings.text=Global CVS Settings... action.GlobalSettings.description=Configure global CVS settings action.ConfigureCvsRoots.text=Configure CVS _Roots... -action.ConfigureCvsRoots.description=Configure CVSroots +action.ConfigureCvsRoots.description=Configure CVS Roots +action.MigrateCvsRoot.text=_Migrate CVS Root... +action.MigrateCvsRoot.description=Change CVS root for selected directory and all directories below it group.CvsFilePopupGroup.text=_CVS action.Cvs.GetFromRepository.text=Get action.Cvs.GetFromRepository.description=Get from cvs repository @@ -461,4 +463,9 @@ switched.revision.format=revision {0} changelist.column.branch=Branch annotation.tooltip=Revision: {0} Date: {1}\nAuthor: {2}\n\n{3} message.password.file.does.not.exist=Password file {0} does not exist. Do you want to create it? -title.password.file.does.not.exist=Missing Password File \ No newline at end of file +title.password.file.does.not.exist=Missing Password File +migrate.cvs.root.directory.label=Migrate CVS Root under &directory: +error.message.directory.is.not.under.cvs=Directory is not under CVS +migrate.replace.if.root.equals.label=Replace if CVS root &equals {0} +migrate.replace.all.roots.label=Replace &all CVS roots +migrate.target.root.label=To the following &CVS root: \ No newline at end of file diff --git a/plugins/cvs/cvs-plugin/src/META-INF/plugin.xml b/plugins/cvs/cvs-plugin/src/META-INF/plugin.xml index ef9ac9a368ed..4861b89cee9a 100644 --- a/plugins/cvs/cvs-plugin/src/META-INF/plugin.xml +++ b/plugins/cvs/cvs-plugin/src/META-INF/plugin.xml @@ -1,7 +1,7 @@ CVS Integration CVS - 0.1 + 11 JetBrains com.intellij.cvsSupport2.CvsBundle VCS Integration @@ -57,6 +57,7 @@ + diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/MigrateCvsRootAction.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/MigrateCvsRootAction.java new file mode 100644 index 000000000000..c0ae4033ad4b --- /dev/null +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/MigrateCvsRootAction.java @@ -0,0 +1,141 @@ +/* + * Copyright 2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.cvsSupport2.actions; + +import com.intellij.cvsSupport2.CvsUtil; +import com.intellij.cvsSupport2.actions.actionVisibility.CvsActionVisibility; +import com.intellij.cvsSupport2.actions.cvsContext.CvsContextWrapper; +import com.intellij.cvsSupport2.config.CvsRootConfiguration; +import com.intellij.cvsSupport2.ui.MigrateRootDialog; +import com.intellij.cvsSupport2.util.CvsVfsUtil; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.application.AccessToken; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.vcs.actions.VcsContext; +import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager; +import com.intellij.openapi.vfs.VirtualFile; +import org.netbeans.lib.cvsclient.file.FileUtils; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class MigrateCvsRootAction extends AnAction { + private static final Logger LOG = Logger.getInstance("#com.intellij.cvsSupport2.actions.MigrateCvsRootAction"); + private final CvsActionVisibility myVisibility = new CvsActionVisibility(); + + public MigrateCvsRootAction() { + super(); + myVisibility.shouldNotBePerformedOnFile(); + } + + @Override + public void update(AnActionEvent e) { + myVisibility.applyToEvent(e); + } + + @Override + public void actionPerformed(AnActionEvent event) { + final VcsContext context = CvsContextWrapper.createInstance(event); + final VirtualFile selectedFile = context.getSelectedFile(); + final MigrateRootDialog dialog = new MigrateRootDialog(context.getProject(), selectedFile); + dialog.show(); + if (!dialog.isOK()) return; + final File directory = dialog.getSelectedDirectory(); + final boolean shouldReplaceAllRoots = dialog.shouldReplaceAllRoots(); + final List rootFiles = new ArrayList(); + try { + if (shouldReplaceAllRoots) { + collectRootFiles(directory, null, rootFiles); + } else { + collectRootFiles(directory, dialog.getCvsRoot(), rootFiles); + } + } catch (IOException e) { + LOG.error(e); + return; + } + final CvsRootConfiguration cvsConfiguration = dialog.getSelectedCvsConfiguration(); + final String cvsRoot = cvsConfiguration.getCvsRootAsString(); + for (final File file : rootFiles) { + try { + FileUtils.writeLine(file, cvsRoot); + } + catch (IOException e) { + LOG.error(e); + break; + } + } + final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock(); + try { + final VcsDirtyScopeManager dirty = VcsDirtyScopeManager.getInstance(context.getProject()); + for (File file : rootFiles) { + dirty.fileDirty(CvsVfsUtil.findFileByIoFile(file)); + } + CvsVfsUtil.findFileByIoFile(directory).refresh(false, true); + } finally { + token.finish(); + } + } + + + + private static void collectRootFiles(File directory, final String root, final List rootFiles) throws IOException { + final File rootFile = getRootFile(directory); + if (rootFile != null) { + rootFiles.add(rootFile); + } + try { + final File[] files = directory.listFiles(new FileFilter() { + @Override + public boolean accept(File file) { + if (!file.isDirectory()) { + return false; + } + final File rootFile = getRootFile(file); + if (!rootFile.exists()) { + return false; + } + if (root == null) { + return true; + } + try { + final String cvsRoot = FileUtils.readLineFromFile(rootFile).trim(); + return root.equals(cvsRoot); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + }); + for (File file : files) { + collectRootFiles(file, root, rootFiles); + } + } catch (RuntimeException e) { + final Throwable cause = e.getCause(); + if (cause instanceof IOException) { + throw (IOException) cause; + } + } + } + + private static File getRootFile(File directory) { + return new File(directory, CvsUtil.CVS + '/' + CvsUtil.CVS_ROOT_FILE); + } +} diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java index e79044eae769..034575f4c939 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java @@ -19,10 +19,10 @@ import com.intellij.CvsBundle; import com.intellij.cvsSupport2.CvsUtil; import com.intellij.cvsSupport2.application.CvsEntriesManager; import com.intellij.cvsSupport2.connections.CvsEnvironment; -import com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor; -import com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutorCallback; -import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler; +import com.intellij.cvsSupport2.connections.CvsRootOnFileSystem; +import com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException; import com.intellij.cvsSupport2.history.CvsRevisionNumber; +import com.intellij.cvsSupport2.util.CvsVfsUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.cvsIntegration.CvsResult; import com.intellij.openapi.diagnostic.Logger; @@ -42,7 +42,6 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.AsynchConsumer; import com.intellij.util.Consumer; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.netbeans.lib.cvsclient.admin.Entry; @@ -50,7 +49,6 @@ import org.netbeans.lib.cvsclient.command.log.Revision; import java.io.DataInput; import java.io.DataOutput; -import java.io.File; import java.io.IOException; import java.util.*; @@ -63,8 +61,6 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi private final Project myProject; private final MyZipper myZipper; - @NonNls private static final String INVALID_OPTION_S = "invalid option -- S"; - public CvsCommittedChangesProvider(Project project) { myProject = project; myZipper = new MyZipper(); @@ -137,8 +133,7 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi @Nullable @Override public Pair getOneList(VirtualFile file, final VcsRevisionNumber number) throws VcsException { - final File ioFile = new File(file.getPath()); - final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(ioFile); + final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file); final VirtualFile vcsRoot = ProjectLevelVcsManager.getInstance(myProject).getVcsRootFor(filePath); final CvsRepositoryLocation cvsLocation = getLocationFor(filePath); if (cvsLocation == null) return null; @@ -158,7 +153,7 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi result[0] = builder.addRevision(revision); } }, cvsLocation.getModuleName(), number.asString()); - final CvsResult executionResult = runRLogOperation(operation); + final CvsResult executionResult = operation.run(myProject); if (executionResult.isCanceled()) { throw new ProcessCanceledException(); @@ -191,7 +186,7 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi } } }); - final CvsResult cvsResult = runRLogOperation(operation2); + final CvsResult cvsResult = operation2.run(myProject); if (cvsResult.hasErrors()) { throw cvsResult.composeError(); } @@ -243,7 +238,7 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi } } }); - final CvsResult executionResult = runRLogOperation(operation); + final CvsResult executionResult = operation.run(myProject); if (executionResult.isCanceled()) { throw new ProcessCanceledException(); @@ -259,11 +254,17 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi private List loadCommittedChanges(final ChangeBrowserSettings settings, final String module, - final CvsEnvironment connectionSettings, + CvsEnvironment connectionSettings, final VirtualFile rootFile) throws VcsException { if (connectionSettings.isOffline()) { return Collections.emptyList(); } + try { + // refresh cvs connection settings from file system + connectionSettings = CvsRootOnFileSystem.createMeOn(CvsVfsUtil.getFileFor(rootFile)); + } + catch (CannotFindCvsRootException ignore) { + } final CvsChangeListsBuilder builder = new CvsChangeListsBuilder(module, connectionSettings, myProject, rootFile); Date dateTo = settings.getDateBeforeFilter(); Date dateFrom = settings.getDateAfterFilter(); @@ -280,7 +281,7 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi log.add(logInformationWrapper); } }); - final CvsResult executionResult = runRLogOperation(operation); + final CvsResult executionResult = operation.run(myProject); if (executionResult.isCanceled()) { throw new ProcessCanceledException(); @@ -296,28 +297,6 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi } } - private CvsResult runRLogOperation(final LoadHistoryOperation operation) { - final CvsResult executionResult = runRLogOperationImpl(operation); - - for (VcsException error : executionResult.getErrors()) { - for (String message : error.getMessages()) { - if (message.contains(INVALID_OPTION_S)) { - operation.disableSuppressEmptyHeadersForCurrentCvsRoot(); - // try only once - return runRLogOperationImpl(operation); - } - } - } - return executionResult; - } - - private CvsResult runRLogOperationImpl(final LoadHistoryOperation operation) { - final CvsOperationExecutor executor = new CvsOperationExecutor(myProject); - executor.performActionSync(new CommandCvsHandler(CvsBundle.message("browse.changes.load.history.progress.title"), operation), - CvsOperationExecutorCallback.EMPTY); - return executor.getResult(); - } - public int getFormatVersion() { return 3; } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/LoadHistoryOperation.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/LoadHistoryOperation.java index bcf677ab7add..bef7e0f96ef6 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/LoadHistoryOperation.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/LoadHistoryOperation.java @@ -15,11 +15,18 @@ */ package com.intellij.cvsSupport2.changeBrowser; +import com.intellij.CvsBundle; import com.intellij.cvsSupport2.connections.CvsEnvironment; import com.intellij.cvsSupport2.connections.CvsRootProvider; +import com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor; +import com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutorCallback; +import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler; import com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment; import com.intellij.cvsSupport2.cvsoperations.common.LocalPathIndifferentOperation; import com.intellij.cvsSupport2.cvsoperations.cvsLog.RlogCommand; +import com.intellij.openapi.cvsIntegration.CvsResult; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.VcsException; import com.intellij.util.Consumer; import com.intellij.util.text.SyncDateFormat; import org.jetbrains.annotations.NonNls; @@ -36,6 +43,7 @@ import java.util.Locale; public class LoadHistoryOperation extends LocalPathIndifferentOperation { + @NonNls private static final String INVALID_OPTION_S = "invalid option -- S"; @NonNls private static final SyncDateFormat DATE_FORMAT = new SyncDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ", Locale.US)); private static final Collection ourDoNotSupportingSOptionServers = new HashSet(); @@ -46,7 +54,8 @@ public class LoadHistoryOperation extends LocalPathIndifferentOperation { private final String[] myRevisions; private final boolean myNoTags; - public LoadHistoryOperation(CvsEnvironment environment, String module, + public LoadHistoryOperation(CvsEnvironment environment, + String module, @Nullable Date dateFrom, @Nullable Date dateTo, @NotNull final Consumer consumer) { @@ -93,7 +102,7 @@ public class LoadHistoryOperation extends LocalPathIndifferentOperation { return command; } - public void disableSuppressEmptyHeadersForCurrentCvsRoot() { + private void disableSuppressEmptyHeadersForCurrentCvsRoot() { ourDoNotSupportingSOptionServers.add(myEnvironment.getCvsRootAsString()); } @@ -122,4 +131,26 @@ public class LoadHistoryOperation extends LocalPathIndifferentOperation { protected boolean runInExclusiveLock() { return false; } + + public CvsResult run(Project project) { + final CvsResult executionResult = internalRun(project); + + for (VcsException error : executionResult.getErrors()) { + for (String message : error.getMessages()) { + if (message.contains(INVALID_OPTION_S)) { + disableSuppressEmptyHeadersForCurrentCvsRoot(); + // try only once + return internalRun(project); + } + } + } + return executionResult; + } + + private CvsResult internalRun(Project project) { + final CvsOperationExecutor executor = new CvsOperationExecutor(project); + executor.performActionSync(new CommandCvsHandler(CvsBundle.message("browse.changes.load.history.progress.title"), this), + CvsOperationExecutorCallback.EMPTY); + return executor.getResult(); + } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsCheckOut/CheckoutProjectOperation.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsCheckOut/CheckoutProjectOperation.java index d35ba5783311..d4bd50541bbd 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsCheckOut/CheckoutProjectOperation.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsCheckOut/CheckoutProjectOperation.java @@ -48,10 +48,8 @@ public class CheckoutProjectOperation extends CvsCommandOperation { private final boolean myPruneEmptyDirectories; private final KeywordSubstitution myKeywordSubstitution; - public static CheckoutProjectOperation createTestInstance(CvsEnvironment env, String moduleName, File targetLocation - ) { - return CheckoutProjectOperation.create(env, new String[]{moduleName}, targetLocation, false, - false); + public static CheckoutProjectOperation createTestInstance(CvsEnvironment env, String moduleName, File targetLocation) { + return create(env, new String[]{moduleName}, targetLocation, false, false); } public CheckoutProjectOperation(String[] moduleNames, @@ -74,22 +72,20 @@ public class CheckoutProjectOperation extends CvsCommandOperation { } public static CheckoutProjectOperation create(CvsEnvironment env, - String[] moduleName, - File targetLocation, - boolean useAlternativecheckoutDir, - boolean makeNewFilesReadOnly) { + String[] moduleName, + File targetLocation, + boolean useAlternativeCheckoutDir, + boolean makeNewFilesReadOnly) { + final CvsApplicationLevelConfiguration config = CvsApplicationLevelConfiguration.getInstance(); + final KeywordSubstitutionWrapper substitution = KeywordSubstitutionWrapper.getValue(config.CHECKOUT_KEYWORD_SUBSTITUTION); - CvsApplicationLevelConfiguration config = CvsApplicationLevelConfiguration.getInstance(); - KeywordSubstitutionWrapper substitution = KeywordSubstitutionWrapper.getValue(config.CHECKOUT_KEYWORD_SUBSTITUTION); - - File root; - String directory; - - if (useAlternativecheckoutDir && targetLocation.getParentFile() == null) { + final File root; + final String directory; + if (useAlternativeCheckoutDir && targetLocation.getParentFile() == null) { root = targetLocation; directory = getModuleRootName(moduleName); } - else if (useAlternativecheckoutDir) { + else if (useAlternativeCheckoutDir) { root = targetLocation.getParentFile(); directory = targetLocation.getName(); } @@ -107,7 +103,6 @@ public class CheckoutProjectOperation extends CvsCommandOperation { substitution == null ? null : substitution.getSubstitution()); } - private static String getModuleRootName(String[] moduleNames) { File current = new File(moduleNames[0]); while (current.getParentFile() != null) current = current.getParentFile(); @@ -119,7 +114,7 @@ public class CheckoutProjectOperation extends CvsCommandOperation { } protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) { - CheckoutCommand command = new CheckoutCommand(new ThrowableRunnable() { + final CheckoutCommand command = new CheckoutCommand(new ThrowableRunnable() { public void run() throws IOCommandException { ((CheckoutAdminWriter) myAdminWriter).finish(); } @@ -155,4 +150,9 @@ public class CheckoutProjectOperation extends CvsCommandOperation { super.modifyOptions(options); options.setCheckedOutFilesReadOnly(myMakeNewFilesReadOnly); } + + @Override + public boolean runInReadThread() { + return false; + } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/MigrateRootDialog.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/MigrateRootDialog.java new file mode 100644 index 000000000000..5836be3db99f --- /dev/null +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/MigrateRootDialog.java @@ -0,0 +1,193 @@ +/* + * Copyright 2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.cvsSupport2.ui; + +import com.intellij.CvsBundle; +import com.intellij.cvsSupport2.CvsUtil; +import com.intellij.cvsSupport2.config.CvsRootConfiguration; +import com.intellij.cvsSupport2.config.ui.SelectCvsConfigurationPanel; +import com.intellij.cvsSupport2.util.CvsVfsUtil; +import com.intellij.openapi.fileChooser.FileChooserDescriptor; +import com.intellij.openapi.fileChooser.FileChooserFactory; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.ui.TextFieldWithBrowseButton; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.vfs.VirtualFile; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.*; +import java.io.File; + +public class MigrateRootDialog extends DialogWrapper { + + private final JRadioButton myRadioButton1; + private final JRadioButton myRadioButton2 = new JRadioButton(CvsBundle.message("migrate.replace.all.roots.label")); + private final TextFieldWithBrowseButton myDirectoryField = new TextFieldWithBrowseButton(); + private final SelectCvsConfigurationPanel myCvsConfigurationPanel; + private ListSelectionListener myListener; + private String myCvsRoot; + + public MigrateRootDialog(Project project, VirtualFile directory) { + super(project); + setTitle("Migrate CVS Root"); + final File file = CvsVfsUtil.getFileFor(directory); + final String root = CvsUtil.loadRootFrom(file); + myRadioButton1 = new JRadioButton(CvsBundle.message("migrate.replace.if.root.equals.label", root)); + myRadioButton1.setSelected(true); + final ButtonGroup group = new ButtonGroup(); + group.add(myRadioButton1); + group.add(myRadioButton2); + myDirectoryField.setText(directory.getPath()); + final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) { + @Override + public void validateSelectedFiles(VirtualFile[] files) throws Exception { + for (VirtualFile vFile : files) { + final File file = CvsVfsUtil.getFileFor(vFile); + final String root = CvsUtil.loadRootFrom(file); + if (root == null) { + throw new Exception(CvsBundle.message("error.message.directory.is.not.under.cvs")); + } + } + } + }; + final VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRootsFromAllModules(); + for (VirtualFile vFile : roots) { + descriptor.addRoot(vFile); + } + myDirectoryField.addBrowseFolderListener("Select directory to migrate to a new CVS root", "", project, descriptor); + FileChooserFactory.getInstance().installFileCompletion(myDirectoryField.getChildComponent(), descriptor, true, getDisposable()); + myDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + enableOKActionConditionally(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + enableOKActionConditionally(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + enableOKActionConditionally(); + } + }); + myCvsConfigurationPanel = new SelectCvsConfigurationPanel(project); + if (SystemInfo.isMac) { + myCvsConfigurationPanel.setBorder(new EmptyBorder(2, 3, 2, 0)); + } + myListener = new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + enableOKActionConditionally(); + } + }; + myCvsConfigurationPanel.addListSelectionListener(myListener); + setOKButtonText("Migrate"); + init(); + } + + @Override + protected JComponent createCenterPanel() { + final JPanel panel = new JPanel(new GridBagLayout()); + final GridBagConstraints constraints = new GridBagConstraints(); + constraints.gridx = 0; + constraints.gridy = 0; + constraints.insets.bottom = 2; + constraints.weightx = 1.0; + constraints.fill = GridBagConstraints.HORIZONTAL; + constraints.anchor = GridBagConstraints.LINE_START; + final JLabel label1 = new JLabel(CvsBundle.message("migrate.cvs.root.directory.label")); + label1.setLabelFor(myDirectoryField); + panel.add(label1, constraints); + constraints.gridy = 1; + panel.add(myDirectoryField, constraints); + + constraints.gridy = 2; + constraints.insets.left = 5; + panel.add(myRadioButton1, constraints); + constraints.gridy = 3; + panel.add(myRadioButton2, constraints); + + constraints.gridy = 4; + constraints.insets.top = 8; + constraints.insets.left = 0; + final JLabel label2 = new JLabel(CvsBundle.message("migrate.target.root.label")); + panel.add(label2, constraints); + + final JComponent component = myCvsConfigurationPanel.getPreferredFocusedComponent(); + label2.setLabelFor(component); + constraints.insets.top = 0; + constraints.gridy = 5; + panel.add(myCvsConfigurationPanel, constraints); + return panel; + } + + private boolean check() { + final String text = myDirectoryField.getText(); + final File file = new File(text); + if (!file.exists() || !file.isDirectory()) { + return false; + } + myCvsRoot = CvsUtil.loadRootFrom(file); + if (myCvsRoot == null) { + return false; + } + myRadioButton1.setText(CvsBundle.message("migrate.replace.if.root.equals.label", myCvsRoot)); + if (getSelectedCvsConfiguration() == null) { + return false; + } + return true; + } + + @Override + protected void dispose() { + myCvsConfigurationPanel.removeListSelectionListener(myListener); + super.dispose(); + } + + private void enableOKActionConditionally() { + setOKActionEnabled(check()); + } + + public String getCvsRoot() { + return myCvsRoot; + } + + @Override + public JComponent getPreferredFocusedComponent() { + return myCvsConfigurationPanel; + } + + public CvsRootConfiguration getSelectedCvsConfiguration() { + return myCvsConfigurationPanel.getSelectedConfiguration(); + } + + public File getSelectedDirectory() { + return new File(myDirectoryField.getText()); + } + + public boolean shouldReplaceAllRoots() { + return myRadioButton2.isSelected(); + } +} diff --git a/plugins/git4idea/src/git4idea/push/GitManualPushToBranch.java b/plugins/git4idea/src/git4idea/push/GitManualPushToBranch.java index 94c34a73f4a9..66665daa7174 100644 --- a/plugins/git4idea/src/git4idea/push/GitManualPushToBranch.java +++ b/plugins/git4idea/src/git4idea/push/GitManualPushToBranch.java @@ -140,7 +140,7 @@ class GitManualPushToBranch extends JPanel { } @NotNull - private static Collection getRemotesWithCommonNames(@NotNull Collection repositories) { + public static Collection getRemotesWithCommonNames(@NotNull Collection repositories) { if (repositories.isEmpty()) { return Collections.emptyList(); } diff --git a/plugins/git4idea/src/git4idea/push/GitPushDialog.java b/plugins/git4idea/src/git4idea/push/GitPushDialog.java index 301ef503987b..03f26a58b440 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushDialog.java +++ b/plugins/git4idea/src/git4idea/push/GitPushDialog.java @@ -61,6 +61,8 @@ public class GitPushDialog extends DialogWrapper { private final Object COMMITS_LOADING_LOCK = new Object(); private final GitManualPushToBranch myRefspecPanel; private final AtomicReference myDestBranchInfoOnRefresh = new AtomicReference(); + + private final boolean myPushPossible; public GitPushDialog(@NotNull Project project) { super(project); @@ -84,10 +86,20 @@ public class GitPushDialog extends DialogWrapper { myListPanel = new GitPushLog(myProject, myRepositories, new RepositoryCheckboxListener()); myRefspecPanel = new GitManualPushToBranch(myRepositories, new RefreshButtonListener()); - + + if (GitManualPushToBranch.getRemotesWithCommonNames(myRepositories).isEmpty()) { + myRefspecPanel.setVisible(false); + setErrorText("Can't push, because no remotes are defined"); + setOKActionEnabled(false); + myPushPossible = false; + } else { + myPushPossible = true; + } + init(); setOKButtonText("Push"); setTitle("Git Push"); + } @Override @@ -105,7 +117,12 @@ public class GitPushDialog extends DialogWrapper { private JComponent createCommitListPanel() { myLoadingPanel.add(myListPanel, BorderLayout.CENTER); - loadCommitsInBackground(); + if (myPushPossible) { + loadCommitsInBackground(); + } else { + myLoadingPanel.startLoading(); + myLoadingPanel.stopLoading(); + } JPanel commitListPanel = new JPanel(new BorderLayout()); commitListPanel.add(myLoadingPanel, BorderLayout.CENTER); diff --git a/plugins/git4idea/src/git4idea/push/GitPushLog.java b/plugins/git4idea/src/git4idea/push/GitPushLog.java index 35be8eab1f66..94486217b1b0 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushLog.java +++ b/plugins/git4idea/src/git4idea/push/GitPushLog.java @@ -19,8 +19,6 @@ import com.intellij.openapi.actionSystem.CommonShortcuts; import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.actionSystem.DataSink; import com.intellij.openapi.actionSystem.TypeSafeDataProvider; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.colors.EditorFontType; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.vcs.VcsDataKeys; @@ -45,6 +43,7 @@ import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.*; import java.awt.*; +import java.awt.event.MouseEvent; import java.io.File; import java.util.*; import java.util.List; @@ -85,8 +84,21 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { } @Override - public boolean getScrollableTracksViewportWidth() { - return false; + public String getToolTipText(MouseEvent event) { + final TreePath path = myTree.getPathForLocation(event.getX(), event.getY()); + if (path == null) { + return ""; + } + Object node = path.getLastPathComponent(); + if (node == null || (!(node instanceof DefaultMutableTreeNode))) { + return ""; + } + Object userObject = ((DefaultMutableTreeNode)node).getUserObject(); + if (userObject instanceof GitCommit) { + GitCommit commit = (GitCommit)userObject; + return getHashString(commit) + " " + getDateString(commit) + " by " + commit.getAuthor() + "\n\n" + commit.getDescription(); + } + return ""; } }; myTree.setRootVisible(false); @@ -109,7 +121,7 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { myChangesBrowser.setChangesToDisplay(Collections.emptyList()); } }); - + ToolTipManager.sharedInstance().registerComponent(myTree); myChangesBrowser = new ChangesBrowser(project, null, Collections.emptyList(), null, false, true, null, ChangesBrowser.MyUseCase.LOCAL_CHANGES, null); myChangesBrowser.getDiffAction().registerCustomShortcutSet(CommonShortcuts.getDiff(), myTree); @@ -154,7 +166,6 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { createNodes(commits); myTreeModel.nodeStructureChanged(myRootNode); myTree.setModel(myTreeModel); // TODO: why doesn't it repaint otherwise? - myTreeCellRenderer.recalculateWidth(commits.getAllCommits()); TreeUtil.expandAll(myTree); selectFirstCommit(); } @@ -273,22 +284,17 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { } } - private static class MyTreeCellRenderer extends CheckboxTree.CheckboxTreeCellRenderer { - - private int myDateMaxWidth; - - void recalculateWidth(@NotNull Collection commits) { - for (GitCommit commit : commits) { - int len = getDateString(commit).length(); - if (len > myDateMaxWidth) { - myDateMaxWidth = len; - } - } - } + @NotNull + private static String getDateString(@NotNull GitCommit commit) { + return DateFormatUtil.formatPrettyDateTime(commit.getAuthorTime()) + " "; + } - private static String getDateString(GitCommit commit) { - return DateFormatUtil.formatPrettyDateTime(commit.getAuthorTime()); - } + @NotNull + private static String getHashString(@NotNull GitCommit commit) { + return commit.getShortHash().toString(); + } + + private static class MyTreeCellRenderer extends CheckboxTree.CheckboxTreeCellRenderer { @Override public void customizeRenderer(final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { @@ -302,16 +308,10 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { } ColoredTreeCellRenderer renderer = getTextRenderer(); - Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN); // using probable monospace font to emulate table - renderer.setFont(font); - - SimpleTextAttributes smallGrey = new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, UIUtil.getInactiveTextColor()); if (userObject instanceof GitCommit) { GitCommit commit = (GitCommit)userObject; - SimpleTextAttributes small = new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, renderer.getForeground()); - renderer.append(commit.getShortHash().toString(), smallGrey); - renderer.append(String.format(" %" + myDateMaxWidth + "s ", getDateString(commit)), smallGrey); - renderer.append(commit.getSubject(), small); + renderer.append(commit.getSubject(), new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, getTextRenderer().getForeground())); + renderer.setToolTipText(getHashString(commit) + " " + getDateString(commit)); } else if (userObject instanceof GitRepository) { String repositoryPath = calcRootPath((GitRepository)userObject); @@ -345,7 +345,7 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { break; } renderer.append(text, attrs); - renderer.append(additionalText, smallGrey); + renderer.append(additionalText, new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, UIUtil.getInactiveTextColor())); } else if (userObject instanceof FakeCommit) { int spaces = 6 + 15 + 3 + 30; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties index ab7d8f55f8d3..8b7b70e6c566 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties @@ -253,29 +253,18 @@ Inner.methods.are.not.supported=Inner methods are not supported final.class.cannot.be.extended=Final class cannot be extended #Override and implement -goto.override.method.declaration=go to override method declaration -interface.expected.here=Interface is expected here -overrides.method.from.super=Overrides method in ''{0}'' -implements.method.from.super=Implements method in ''{0}'' -implement.methods=Implement methods -implement.methods.fix=Implement methods method.is.not.implemented=Method ''{0}'' is not implemented -interface.is.not.expected.here=Interface is not expected here change.implements.and.extends.classes=Normalize extends and implements lists -unsafe.dereference=Unsafe dereference -type.definition.can.extend.just.one.super.type=Type definition must extends not more than one class class.is.not.expected.here=Class is not expected here -interface.cannot.contain.implements.clause=Interface cannot contain implements clause fix.package.name=Fix package name #dynamic properties add.dynamic.property=Add dynamic property ''{0}'' duplicate.element.in.the.map=Duplicate element in the map -message.nothing.to.show.in.structure.view=There are no dynamic properties dynamic.toolwindow.search.elements=Search dynamic element -dynamic.toolwindow.property.fiter=Property Filter -dynamic.tool.window.id=Dynamic properties +dynamic.toolwindow.property.filter=Property Filter +dynamic.tool.window.id=Dynamic Properties create.from.usage.family.name=Create From Usage create.field.from.usage=Create Field ''{0}'' diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicChangeListener.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicChangeListener.java deleted file mode 100644 index 0f91df3ea3bb..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicChangeListener.java +++ /dev/null @@ -1,29 +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.plugins.groovy.annotator.intentions.dynamic; - -import java.util.EventListener; - -/** - * User: Dmitry.Krasilschikov - * Date: 11.01.2008 - */ -public interface DynamicChangeListener extends EventListener { - /* - * Change property - */ - public void dynamicPropertyChange(); -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicManager.java index 459373344ac9..06296cd5eae4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicManager.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicManager.java @@ -63,16 +63,6 @@ public abstract class DynamicManager implements ProjectComponent, PersistentStat public abstract void replaceClassName(final DClassElement oldClassElement, String newClassName); - /* - * Adds dynamicPropertyChange listener - */ - public abstract void addDynamicChangeListener(DynamicChangeListener listener); - - /* - * Removes dynamicPropertyChange listener - */ - public abstract void removeDynamicChangeListener(DynamicChangeListener listener); - public abstract void addProperty(DynamicElementSettings settings); public abstract void addMethod(DynamicElementSettings settings); @@ -85,9 +75,6 @@ public abstract class DynamicManager implements ProjectComponent, PersistentStat @NotNull public abstract Collection findDynamicPropertiesOfClass(final String conatainingClassName); - @NotNull - public abstract String[] getPropertiesNamesOfClass(final String conatainingClassName); - @Nullable public abstract String getPropertyType(String className, String propertyName); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicManagerImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicManagerImpl.java index 0d472320a8fb..5750b5ede6f1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicManagerImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicManagerImpl.java @@ -19,7 +19,6 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.components.StorageScheme; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; @@ -27,7 +26,6 @@ import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.wm.ToolWindow; import com.intellij.psi.*; import com.intellij.ui.treeStructure.treetable.ListTreeTableModelOnColumns; -import com.intellij.util.ArrayUtil; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.tree.TreeUtil; @@ -39,7 +37,10 @@ import org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicEleme import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager; import javax.swing.tree.DefaultMutableTreeNode; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; /** * User: Dmitry.Krasilschikov @@ -53,10 +54,7 @@ import java.util.*; }) public class DynamicManagerImpl extends DynamicManager { - private static final Logger LOG = Logger.getInstance("org.jetbrains.plugins.groovy.annotator.intentions.dynamic.DynamicManagerImpl"); - private final Project myProject; - private final List myListeners = new ArrayList(); private DRootElement myRootElement = new DRootElement(); public DynamicManagerImpl(final Project project) { @@ -111,7 +109,7 @@ public class DynamicManagerImpl extends DynamicManager { doRemove(wrapper, node, parent); } - private void doRemove(DynamicToolWindowWrapper wrapper, DefaultMutableTreeNode node, DefaultMutableTreeNode parent) { + private static void doRemove(DynamicToolWindowWrapper wrapper, DefaultMutableTreeNode node, DefaultMutableTreeNode parent) { DefaultMutableTreeNode toSelect = (parent.getChildAfter(node) != null || parent.getChildCount() == 1 ? node.getNextNode() : node.getPreviousNode()); @@ -166,7 +164,7 @@ public class DynamicManagerImpl extends DynamicManager { }, true); } - private int getIndexToInsert(DefaultMutableTreeNode parent, DNamedElement namedElement) { + private static int getIndexToInsert(DefaultMutableTreeNode parent, DNamedElement namedElement) { if (parent.getChildCount() == 0) return 0; int res = 0; @@ -220,19 +218,6 @@ public class DynamicManagerImpl extends DynamicManager { return new ArrayList(); } - @NotNull - public String[] getPropertiesNamesOfClass(String conatainingClassName) { - final DClassElement classElement = findClassElement(getRootElement(), conatainingClassName); - - Set result = new HashSet(); - if (classElement != null) { - for (DPropertyElement propertyElement : classElement.getProperties()) { - result.add(propertyElement.getName()); - } - } - return ArrayUtil.toStringArray(result); - } - @Nullable public String getPropertyType(String className, String propertyName) { final DPropertyElement dynamicProperty = findConcreteDynamicProperty(getRootElement(), className, propertyName); @@ -253,24 +238,6 @@ public class DynamicManagerImpl extends DynamicManager { return myRootElement; } - /* - * Adds dynamicPropertyChange listener - */ - public void addDynamicChangeListener(DynamicChangeListener listener) { - myListeners.add(listener); - } - - /* - * Removes dynamicPropertyChange listener - */ - public void removeDynamicChangeListener(DynamicChangeListener listener) { - myListeners.remove(listener); - } - - /* - * Changes dynamic property - */ - public String replaceDynamicPropertyName(String className, String oldPropertyName, String newPropertyName) { final DClassElement classElement = findClassElement(getRootElement(), className); if (classElement == null) return null; @@ -403,10 +370,6 @@ public class DynamicManagerImpl extends DynamicManager { } public void fireChange() { - for (DynamicChangeListener listener : myListeners) { - listener.dynamicPropertyChange(); - } - fireChangeCodeAnalyze(); } @@ -427,7 +390,7 @@ public class DynamicManagerImpl extends DynamicManager { } @Nullable - public DPropertyElement findConcreteDynamicProperty(DRootElement rootElement, final String conatainingClassName, final String propertyName) { + private static DPropertyElement findConcreteDynamicProperty(DRootElement rootElement, final String conatainingClassName, final String propertyName) { final DClassElement classElement = rootElement.getClassElement(conatainingClassName); if (classElement == null) return null; @@ -436,7 +399,7 @@ public class DynamicManagerImpl extends DynamicManager { } @Nullable - private DClassElement findClassElement(DRootElement rootElement, final String conatainingClassName) { + private static DClassElement findClassElement(DRootElement rootElement, final String conatainingClassName) { return rootElement.getClassElement(conatainingClassName); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicToolWindowWrapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicToolWindowWrapper.java index 6c849843cd12..46d8dd4b7372 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicToolWindowWrapper.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicToolWindowWrapper.java @@ -15,8 +15,8 @@ */ package org.jetbrains.plugins.groovy.annotator.intentions.dynamic; -import com.intellij.openapi.actionSystem.DataProvider; -import com.intellij.openapi.actionSystem.LangDataKeys; +import com.intellij.ide.DeleteProvider; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; @@ -96,7 +96,7 @@ public class DynamicToolWindowWrapper { private static final int CLASS_OR_ELEMENT_NAME_COLUMN = 0; private static final int TYPE_COLUMN = 1; - private static final String[] myColumnNames = {"Dynamic element", "Type"}; + private static final String[] myColumnNames = {"Dynamic Element", "Type"}; private MyTreeTable myTreeTable; @@ -129,7 +129,7 @@ public class DynamicToolWindowWrapper { myBigPanel = new JPanel(new BorderLayout()); myBigPanel.setBackground(UIUtil.getFieldForegroundColor()); - final DynamicFilterComponent filter = new DynamicFilterComponent(GroovyBundle.message("dynamic.toolwindow.property.fiter"), 10); + final DynamicFilterComponent filter = new DynamicFilterComponent(GroovyBundle.message("dynamic.toolwindow.property.filter"), 10); filter.setBackground(UIUtil.getLabelBackground()); myBigPanel.add(new JLabel(GroovyBundle.message("dynamic.toolwindow.search.elements")), BorderLayout.NORTH); @@ -212,6 +212,10 @@ public class DynamicToolWindowWrapper { myTreeTable = new MyTreeTable(myTreeTableModel); + DefaultActionGroup group = new DefaultActionGroup(); + group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_DELETE)); + PopupHandler.installUnknownPopupHandler(myTreeTable, group, ActionManager.getInstance()); + final MyColoredTreeCellRenderer treeCellRenderer = new MyColoredTreeCellRenderer(); myTreeTable.setDefaultRenderer(String.class, new TableCellRenderer() { @@ -342,12 +346,6 @@ public class DynamicToolWindowWrapper { myTreeTable.setDefaultEditor(String.class, typeCellEditor); - myTreeTable.registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent event) { - deleteRow(); - } - }, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_FOCUSED); - myTreeTable.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent event) { final int selectionRow = myTreeTable.getTree().getLeadSelectionRow(); @@ -743,6 +741,18 @@ public class DynamicToolWindowWrapper { if (element == null) return null; return element.getContainingFile(); + } else if (LangDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) { + return new DeleteProvider() { + @Override + public void deleteElement(DataContext dataContext) { + deleteRow(); + } + + @Override + public boolean canDeleteElement(DataContext dataContext) { + return myTreeTable.getTree().getSelectionPaths() != null; + } + }; } return null; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java index e848a11816cd..8b38ae20f06e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java @@ -17,6 +17,7 @@ import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.LanguageLevelModuleExtension; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.registry.Registry; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.search.FilenameIndex; import com.intellij.psi.search.GlobalSearchScope; @@ -67,10 +68,11 @@ public class GroovyHotSwapper extends JavaProgramPatcher { if (!executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) { return; } - if ("false".equals(System.getProperty("enable.groovy.hotswap", "true"))) { + + if (!Registry.is("enable.groovy.hotswap")) { return; } - + if (!(configuration instanceof RunConfiguration)) { return; } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java index 092efb15b5b9..c9e2636c0e0d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java @@ -58,6 +58,7 @@ public class HgPullDialog extends DialogWrapper { }; sourceTxt.getDocument().addDocumentListener(documentListener); setTitle("Pull"); + setOKButtonText("Pull"); init(); } @@ -106,4 +107,9 @@ public class HgPullDialog extends DialogWrapper { setOKActionEnabled(StringUtils.isNotBlank(sourceTxt.getText())); } + @Override + protected String getDimensionServiceKey() { + return HgPullDialog.class.getName(); + } + } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomElementDescriptorHolder.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomElementDescriptorHolder.java index 996a480488f7..5f4cf19f3724 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomElementDescriptorHolder.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomElementDescriptorHolder.java @@ -24,6 +24,10 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; +import com.intellij.psi.util.CachedValue; +import com.intellij.psi.util.CachedValueProvider; +import com.intellij.psi.util.CachedValuesManager; +import com.intellij.psi.util.PsiModificationTracker; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; import com.intellij.xml.XmlElementDescriptor; @@ -38,6 +42,7 @@ import java.util.Map; public class MavenDomElementDescriptorHolder { private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.maven.dom.MavenDomElementDescriptorHolder"); + private enum FileKind { PROJECT_FILE { public String getSchemaUrl() { @@ -59,7 +64,8 @@ public class MavenDomElementDescriptorHolder { } private final Project myProject; - private final Map myDescriptorsMap = new THashMap(); + private final Map> myDescriptorsMap = + new THashMap>(); public MavenDomElementDescriptorHolder(Project project) { myProject = project; @@ -80,14 +86,27 @@ public class MavenDomElementDescriptorHolder { if (desc == null) return null; } LOG.assertTrue(tag.isValid()); + LOG.assertTrue(desc.isValid()); return desc.getElementDescriptor(tag.getName(), desc.getDefaultNamespace()); } @Nullable - private XmlNSDescriptorImpl tryGetOrCreateDescriptor(FileKind kind) { - XmlNSDescriptorImpl result = myDescriptorsMap.get(kind); - if (result != null && result.isValid()) return result; + private XmlNSDescriptorImpl tryGetOrCreateDescriptor(final FileKind kind) { + CachedValue result = myDescriptorsMap.get(kind); + if (result == null) { + result = CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider() { + @Override + public Result compute() { + return Result.create(doCreateDescriptor(kind), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT); + } + }, false); + myDescriptorsMap.put(kind, result); + } + return result.getValue(); + } + @Nullable + private XmlNSDescriptorImpl doCreateDescriptor(FileKind kind) { String schemaUrl = kind.getSchemaUrl(); String location = ExternalResourceManager.getInstance().getResourceLocation(schemaUrl); if (schemaUrl.equals(location)) return null; @@ -105,14 +124,12 @@ public class MavenDomElementDescriptorHolder { PsiFile psiFile = PsiManager.getInstance(myProject).findFile(schema); if (!(psiFile instanceof XmlFile)) return null; - result = new XmlNSDescriptorImpl(); - + XmlNSDescriptorImpl result = new XmlNSDescriptorImpl(); result.init(psiFile); - myDescriptorsMap.put(kind, result); - return result; } + @Nullable private FileKind getFileKind(PsiFile file) { if (MavenDomUtil.isProjectFile(file)) return FileKind.PROJECT_FILE; if (MavenDomUtil.isProfilesFile(file)) return FileKind.PROFILES_FILE; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java index 6190c8934524..2414a8852270 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java @@ -84,7 +84,7 @@ public class MavenPluginConfigurationDomExtender extends DomExtender1"); final VirtualFile p2 = createModulePom("project2", - "test" + - "project2" + - "1"); + "test" + + "project2" + + "1"); importProjects(p1, p2); assertEquals(2, myProjectsTree.getRootProjects().size()); @@ -127,9 +128,9 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase { "1"); final VirtualFile p2 = createModulePom("project2", - "test" + - "project2" + - "1"); + "test" + + "project2" + + "1"); importProjects(p1, p2); final VirtualFile oldDir = p2.getParent(); @@ -165,9 +166,9 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase { ""); final VirtualFile m = createModulePom("m1", - "test" + - "m" + - "1"); + "test" + + "m" + + "1"); importProject(); final VirtualFile oldDir = m.getParent(); @@ -726,9 +727,9 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase { ""); final VirtualFile m = createModulePom("m", - "test" + - "m" + - "1"); + "test" + + "m" + + "1"); importProject(); myProjectsManager.performScheduledImportInTests(); // ensure no pending requests assertModules("project", "m"); @@ -822,16 +823,16 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase { ""); final VirtualFile m2 = createModulePom("m2", "test" + - "m2" + - "1" + + "m2" + + "1" + - "" + - " " + - " junit" + - " junit" + - " 4.0" + - " " + - ""); + "" + + " " + + " junit" + + " junit" + + " 4.0" + + " " + + ""); importProject(); @@ -1077,4 +1078,31 @@ public class MavenProjectsManagerTest extends MavenImportingTestCase { assertNull(ModuleManager.getInstance(myProject).findModuleByName("m")); assertTrue(myProjectsManager.isIgnored(myProjectsManager.findProject(m))); } + + public void testDoNotRemoveMavenProjectsOnReparse() throws Exception { + // this pom file doesn't belong to any of the modules, this is won't be processed + // by MavenProjectProjectsManager and won't occur in its projects list. + importProject("test" + + "project" + + "1"); + + final StringBuilder log = new StringBuilder(); + myProjectsManager.performScheduledImportInTests(); + myProjectsManager.addProjectsTreeListener(new MavenProjectsTree.ListenerAdapter() { + @Override + public void projectsUpdated(List> updated, List deleted) { + for (Pair each : updated) { + log.append("updated: " + each.first.getDisplayName() + " "); + } + for (MavenProject each : deleted) { + log.append("deleted: " + each.getDisplayName() + " "); + } + } + }); + + FileContentUtil.reparseFiles(myProject, myProjectsManager.getProjectsFiles(), true); + myProjectsManager.waitForReadingCompletion(); + + assertTrue(log.toString(), log.length() == 0); + } } diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltCommandLineState.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltCommandLineState.java index 7e9e88d549c9..f1994c65e9ca 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltCommandLineState.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltCommandLineState.java @@ -54,7 +54,7 @@ import java.util.List; import static org.intellij.lang.xpath.xslt.run.XsltRunConfiguration.isEmpty; -class XsltCommandLineState extends CommandLineState { +public class XsltCommandLineState extends CommandLineState { private static final Logger LOG = Logger.getInstance(XsltCommandLineState.class.getName()); public static final Key STATE = Key.create("STATE"); @@ -145,7 +145,8 @@ class XsltCommandLineState extends CommandLineState { assert descriptor != null; pluginPath = descriptor.getPath(); } else { - pluginPath = new File(System.getProperty("xslt.plugin.path")); + // -Dxslt.plugin.path=C:\work\java\intellij/ultimate\out\classes\production\xslt-rt + pluginPath = new File(System.getProperty("xslt.plugin.path")); } LOG.debug("Plugin Path = " + pluginPath.getAbsolutePath()); @@ -187,7 +188,11 @@ class XsltCommandLineState extends CommandLineState { return myPort; } - private class MyProcessAdapter extends ProcessAdapter { + public UserDataHolder getExtensionData() { + return myExtensionData; + } + + private class MyProcessAdapter extends ProcessAdapter { public void processTerminated(final ProcessEvent event) { diff --git a/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java b/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java index dc9df67055c6..0fae411e2944 100644 --- a/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java +++ b/plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java @@ -22,10 +22,7 @@ import net.sf.saxon.expr.StackFrame; import net.sf.saxon.expr.XPathContext; import net.sf.saxon.expr.instruct.GlobalVariable; import net.sf.saxon.expr.instruct.SlotManager; -import net.sf.saxon.om.Item; -import net.sf.saxon.om.NodeInfo; -import net.sf.saxon.om.StructuredQName; -import net.sf.saxon.om.ValueRepresentation; +import net.sf.saxon.om.*; import net.sf.saxon.style.StyleElement; import net.sf.saxon.trans.XPathException; import net.sf.saxon.type.ItemType; @@ -65,22 +62,22 @@ class Saxon9StyleFrame extends AbstractSaxon9Frame extends AbstractSaxon9Frame"); } - if (instructionInfo instanceof StyleElement) { + if (instructionInfo instanceof StyleElement || instructionInfo instanceof InstructionDetails) { myDebugger.leave(); } } @@ -89,4 +98,58 @@ public class Saxon9TraceListener implements TraceListener { myDebugger.popSource(); } } + + private static class VirtualFrame extends AbstractSaxon9Frame implements Debugger.StyleFrame { + + public VirtualFrame(Debugger.StyleFrame previous, InstructionDetails instr) { + super(previous, new MySource(instr)); + } + + @Override + public String getInstruction() { + return getPrevious().getInstruction(); + } + + @Override + public Value eval(String expr) throws Debugger.EvaluationException { + return getPrevious().eval(expr); + } + + @Override + public List getVariables() { + return getPrevious().getVariables(); + } + + private static class MySource implements Source, SourceLocator { + private final InstructionDetails myInstruction; + + public MySource(InstructionDetails instr) { + myInstruction = instr; + } + + @Override + public void setSystemId(String systemId) { + } + + @Override + public String getPublicId() { + return null; + } + + @Override + public String getSystemId() { + return myInstruction.getSystemId(); + } + + @Override + public int getLineNumber() { + return myInstruction.getLineNumber(); + } + + @Override + public int getColumnNumber() { + return myInstruction.getColumnNumber(); + } + } + } } \ No newline at end of file diff --git a/plugins/xslt-debugger/src/META-INF/plugin.xml b/plugins/xslt-debugger/src/META-INF/plugin.xml index 2670f2b5e4bf..c02c972de3da 100644 --- a/plugins/xslt-debugger/src/META-INF/plugin.xml +++ b/plugins/xslt-debugger/src/META-INF/plugin.xml @@ -20,7 +20,8 @@ - + + diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/DebuggerConnector.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/DebuggerConnector.java index 3d7831798c3c..7ce6a6b32c75 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/DebuggerConnector.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/DebuggerConnector.java @@ -93,6 +93,8 @@ class DebuggerConnector implements Runnable { private Debugger connect() { Throwable lastException = null; for (int i = 0; i < 10; i++) { + if (myProcess.isProcessTerminated()) return null; + try { final Debugger realClient = EDTGuard.create(new RemoteDebuggerClient(myPort), myProcess); myProcess.notifyTextAvailable("Connected to XSLT debugger on port " + myPort + "\n", ProcessOutputTypes.SYSTEM); diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/VMPausedException.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/VMPausedException.java index 90c6ed935d3a..8a1bd37a61d0 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/VMPausedException.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/VMPausedException.java @@ -20,4 +20,5 @@ package org.intellij.plugins.xsltDebugger; * Thrown by the EDTGuard when some method cannot be completed due to the target VM being paused. */ public class VMPausedException extends RuntimeException { + public static final String MESSAGE = "Target VM is not responding"; } diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java index dbfb1b09581e..65fa36c0ee2b 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltBreakpointType.java @@ -13,6 +13,7 @@ import com.intellij.xdebugger.breakpoints.XLineBreakpointType; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.ui.DebuggerIcons; import org.intellij.lang.xpath.xslt.XsltSupport; +import org.intellij.lang.xpath.xslt.impl.XsltChecker; import org.intellij.plugins.xsltDebugger.impl.XsltDebuggerEditorsProvider; import org.jetbrains.annotations.NotNull; @@ -23,12 +24,12 @@ import javax.swing.*; * User: sweinreuter * Date: 03.03.11 */ -public final class XsltBreakpointType extends XLineBreakpointType { +public abstract class XsltBreakpointType extends XLineBreakpointType { - private final XsltDebuggerEditorsProvider myMyEditorsProvider = new XsltDebuggerEditorsProvider(); + private final XsltDebuggerEditorsProvider myMyEditorsProvider = new XsltDebuggerEditorsProvider(getLanguageLevel()); - public XsltBreakpointType() { - super("xslt", "XSLT Breakpoints"); + protected XsltBreakpointType(final String id) { + super(id, "XSLT Breakpoints"); } @Override @@ -44,9 +45,11 @@ public final class XsltBreakpointType extends XLineBreakpointType VERSION = Key.create("VERSION"); private static final Key PORT = Key.create("PORT"); private static final Key MANIFEST = Key.create("MANIFEST"); @@ -133,6 +134,7 @@ public class XsltDebuggerExtension extends XsltRunnerExtension { assert descriptor != null; pluginPath = descriptor.getPath(); } else { + // -Dxslt-debugger.plugin.path=C:\work\java\intellij/ultimate\out\classes\production\xslt-debugger-engine pluginPath = new File(System.getProperty("xslt-debugger.plugin.path")); } @@ -192,12 +194,20 @@ public class XsltDebuggerExtension extends XsltRunnerExtension { parameters.getVMParametersList().defineProperty("xslt.transformer.type", "xalan"); } } + + final VirtualFile xsltFile = configuration.findXsltFile(); + final PsiManager psiManager = PsiManager.getInstance(configuration.getProject()); + final XsltChecker.LanguageLevel level; + if (xsltFile != null) { + level = XsltSupport.getXsltLanguageLevel(psiManager.findFile(xsltFile)); + } else { + level = XsltChecker.LanguageLevel.V1; + } + extensionData.putUserData(VERSION, level); + if (!parameters.getVMParametersList().hasProperty("xslt.transformer.type")) { // add saxon for backward-compatibility - final VirtualFile xsltFile = configuration.findXsltFile(); - final PsiManager psiManager = PsiManager.getInstance(configuration.getProject()); - if (xsltFile != null && XsltSupport.getXsltLanguageLevel(psiManager.findFile(xsltFile)) == XsltChecker.LanguageLevel.V2) - { + if (level == XsltChecker.LanguageLevel.V2) { parameters.getVMParametersList().defineProperty("xslt.transformer.type", "saxon9"); addSaxon(parameters, pluginPath, SAXON_9_JAR); } else { diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerRunner.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerRunner.java index 0aa7e9b17c83..b0b1939d56e3 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerRunner.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerRunner.java @@ -14,6 +14,7 @@ import com.intellij.xdebugger.XDebugProcess; import com.intellij.xdebugger.XDebugProcessStarter; import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.XDebuggerManager; +import org.intellij.lang.xpath.xslt.run.XsltCommandLineState; import org.intellij.lang.xpath.xslt.run.XsltRunConfiguration; import org.intellij.plugins.xsltDebugger.impl.XsltDebugProcess; import org.jetbrains.annotations.NonNls; @@ -63,8 +64,9 @@ public class XsltDebuggerRunner extends DefaultProgramRunner { public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException { ACTIVE.set(Boolean.TRUE); try { + final XsltCommandLineState c = (XsltCommandLineState)runProfileState; final ExecutionResult result = runProfileState.execute(executor, XsltDebuggerRunner.this); - return new XsltDebugProcess(session, result); + return new XsltDebugProcess(session, result, c.getExtensionData().getUserData(XsltDebuggerExtension.VERSION)); } finally { ACTIVE.remove(); } diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerSession.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerSession.java index 97ec8374b013..1c20129a774f 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerSession.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerSession.java @@ -26,7 +26,6 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.pom.Navigatable; import com.intellij.psi.PsiFile; import com.intellij.util.EventDispatcher; import com.intellij.xdebugger.XSourcePosition; @@ -153,14 +152,14 @@ public class XsltDebuggerSession implements Disposable { myClient.stepInto(); } - public boolean canRunTo(final PsiFile file, final int offset) { - return XsltBreakpointHandler.getActualLineNumber(myProject, new MyXSourcePosition(file, offset)) != -1; + public boolean canRunTo(final XSourcePosition position) { + return XsltBreakpointHandler.getActualLineNumber(myProject, position) != -1; } - public void runTo(final PsiFile file, final int offset) { + public void runTo(final PsiFile file, final XSourcePosition position) { assert myTempBreakpoint == null; - final int lineNumber = XsltBreakpointHandler.getActualLineNumber(myProject, new MyXSourcePosition(file, offset)); + final int lineNumber = XsltBreakpointHandler.getActualLineNumber(myProject, position); final String uri = XsltBreakpointHandler.getFileURL(file.getVirtualFile()); myTempBreakpoint = myClient.getBreakpointManager().setBreakpoint(uri, lineNumber); @@ -224,36 +223,4 @@ public class XsltDebuggerSession implements Disposable { void debuggerStopped(); } - - private static class MyXSourcePosition implements XSourcePosition { - private final PsiFile myFile; - private final int myOffset; - - public MyXSourcePosition(PsiFile file, int offset) { - myFile = file; - myOffset = offset; - } - - @Override - public int getLine() { - return -1; - } - - @Override - public int getOffset() { - return myOffset; - } - - @NotNull - @Override - public VirtualFile getFile() { - return myFile.getVirtualFile(); - } - - @NotNull - @Override - public Navigatable createNavigatable(@NotNull Project project) { - throw new UnsupportedOperationException(); - } - } } diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltBreakpointHandler.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltBreakpointHandler.java index af00a57d6461..a54fe614017b 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltBreakpointHandler.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltBreakpointHandler.java @@ -23,14 +23,15 @@ import org.intellij.plugins.xsltDebugger.VMPausedException; import org.intellij.plugins.xsltDebugger.XsltBreakpointType; import org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint; import org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager; +import org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class XsltBreakpointHandler extends XBreakpointHandler> { private XsltDebugProcess myXsltDebugProcess; - public XsltBreakpointHandler(XsltDebugProcess xsltDebugProcess) { - super(XsltBreakpointType.class); + public XsltBreakpointHandler(XsltDebugProcess xsltDebugProcess, final Class typeClass) { + super(typeClass); myXsltDebugProcess = xsltDebugProcess; } @@ -61,6 +62,7 @@ public class XsltBreakpointHandler extends XBreakpointHandler position.getLine()) { + if (document != null && document.getLineCount() > position.getLine() && position.getLine() >= 0) { offset = document.getLineStartOffset(position.getLine()); } if (offset < 0) { diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebugProcess.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebugProcess.java index 498c28e93734..c1ed79d8a064 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebugProcess.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebugProcess.java @@ -17,12 +17,11 @@ import com.intellij.xdebugger.breakpoints.XBreakpointHandler; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.frame.XExecutionStack; import com.intellij.xdebugger.frame.XSuspendContext; +import org.intellij.lang.xpath.xslt.impl.XsltChecker; import org.intellij.plugins.xsltDebugger.VMPausedException; +import org.intellij.plugins.xsltDebugger.XsltBreakpointType; import org.intellij.plugins.xsltDebugger.XsltDebuggerSession; -import org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint; -import org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager; -import org.intellij.plugins.xsltDebugger.rt.engine.Debugger; -import org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManagerImpl; +import org.intellij.plugins.xsltDebugger.rt.engine.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,16 +37,17 @@ public class XsltDebugProcess extends XDebugProcess implements Disposable { private BreakpointManager myBreakpointManager = new BreakpointManagerImpl(); private final XBreakpointHandler[] myXBreakpointHandlers = new XBreakpointHandler[]{ - new XsltBreakpointHandler(this) + new XsltBreakpointHandler(this, XsltBreakpointType.V1.class), + new XsltBreakpointHandler(this, XsltBreakpointType.V2.class) }; private XsltDebuggerSession myDebuggerSession; - public XsltDebugProcess(XDebugSession session, ExecutionResult executionResult) { + public XsltDebugProcess(XDebugSession session, ExecutionResult executionResult, XsltChecker.LanguageLevel data) { super(session); myProcessHandler = executionResult.getProcessHandler(); myProcessHandler.putUserData(KEY, this); myExecutionConsole = executionResult.getExecutionConsole(); - myEditorsProvider = new XsltDebuggerEditorsProvider(); + myEditorsProvider = new XsltDebuggerEditorsProvider(data); Disposer.register(myExecutionConsole, this); } @@ -77,6 +77,7 @@ public class XsltDebugProcess extends XDebugProcess implements Disposable { @Override public void debuggerStopped() { + myBreakpointManager = new BreakpointManagerImpl(); } }); @@ -129,6 +130,7 @@ public class XsltDebugProcess extends XDebugProcess implements Disposable { @Override public void startStepOut() { + myDebuggerSession.stepOver(); } @Override @@ -145,7 +147,7 @@ public class XsltDebugProcess extends XDebugProcess implements Disposable { try { return myDebuggerSession.getClient().ping(); } catch (VMPausedException e) { - getSession().reportMessage("Target VM is not responding", MessageType.WARNING); + getSession().reportMessage(VMPausedException.MESSAGE, MessageType.WARNING); return false; } } @@ -163,8 +165,8 @@ public class XsltDebugProcess extends XDebugProcess implements Disposable { public void runToPosition(@NotNull XSourcePosition position) { final PsiFile psiFile = PsiManager.getInstance(getSession().getProject()).findFile(position.getFile()); assert psiFile != null; - if (myDebuggerSession.canRunTo(psiFile, position.getOffset())) { - myDebuggerSession.runTo(psiFile, position.getOffset()); + if (myDebuggerSession.canRunTo(position)) { + myDebuggerSession.runTo(psiFile, position); } else { StatusBar.Info.set("Not a valid position in file '" + psiFile.getName() + "'", psiFile.getProject()); final Debugger c = myDebuggerSession.getClient(); diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebuggerEditorsProvider.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebuggerEditorsProvider.java index 8872caf1f3c5..d1fec61805b3 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebuggerEditorsProvider.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebuggerEditorsProvider.java @@ -12,16 +12,24 @@ import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.evaluation.EvaluationMode; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import org.intellij.lang.xpath.XPathFileType; +import org.intellij.lang.xpath.xslt.impl.XsltChecker; import org.intellij.plugins.xsltDebugger.BreakpointContext; import org.intellij.plugins.xsltDebugger.rt.engine.Debugger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class XsltDebuggerEditorsProvider extends XDebuggerEditorsProvider { + + private final XPathFileType myFileType; + + public XsltDebuggerEditorsProvider(XsltChecker.LanguageLevel level) { + myFileType = level == XsltChecker.LanguageLevel.V2 ? XPathFileType.XPATH2 : XPathFileType.XPATH; + } + @NotNull @Override public FileType getFileType() { - return XPathFileType.XPATH; + return myFileType; } @NotNull @@ -31,7 +39,7 @@ public class XsltDebuggerEditorsProvider extends XDebuggerEditorsProvider { @Nullable XSourcePosition sourcePosition, @NotNull EvaluationMode mode) { final PsiFile psiFile = PsiFileFactory.getInstance(project) - .createFileFromText("XPathExpr.xpath", XPathFileType.XPATH, text, LocalTimeCounter.currentTime(), true); + .createFileFromText("XPathExpr." + myFileType.getDefaultExtension(), myFileType, text, LocalTimeCounter.currentTime(), true); if (sourcePosition instanceof XsltSourcePosition && ((XsltSourcePosition)sourcePosition).getLocation() instanceof Debugger.StyleFrame) { final Debugger.Locatable location = ((XsltSourcePosition)sourcePosition).getLocation(); diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltExecutionStack.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltExecutionStack.java index b8e2a8b302cf..3f57574e175c 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltExecutionStack.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltExecutionStack.java @@ -44,7 +44,7 @@ public class XsltExecutionStack extends XExecutionStack { } } } catch (VMPausedException e) { - container.errorOccurred("VM is paused"); + container.errorOccurred(VMPausedException.MESSAGE); } } } diff --git a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltStackFrame.java b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltStackFrame.java index 187a31c6373b..4867c1b25173 100644 --- a/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltStackFrame.java +++ b/plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltStackFrame.java @@ -97,7 +97,7 @@ public class XsltStackFrame extends XStackFrame { super.computeChildren(node); } } catch (VMPausedException e) { - node.setErrorMessage("Target VM is not responding"); + node.setErrorMessage(VMPausedException.MESSAGE); } } @@ -200,6 +200,8 @@ public class XsltStackFrame extends XStackFrame { try { final Value eval = myFrame.eval(expression); callback.evaluated(new MyValue(new ExpressionResult(eval))); + } catch (VMPausedException e) { + callback.errorOccurred(VMPausedException.MESSAGE); } catch (Debugger.EvaluationException e) { callback.errorOccurred(e.getMessage() != null ? e.getMessage() : e.toString()); } diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 35a81ac95aa2..c2f291d22407 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -917,6 +917,7 @@ +