Merge branch 'master' of git.labs.intellij.net:idea/community
authorirengrig <Irina.Chernushina@jetbrains.com>
Tue, 2 Mar 2010 16:06:27 +0000 (19:06 +0300)
committerirengrig <Irina.Chernushina@jetbrains.com>
Tue, 2 Mar 2010 16:06:27 +0000 (19:06 +0300)
147 files changed:
java/debugger/impl/src/com/intellij/debugger/actions/AddToWatchActionHandler.java [moved from java/debugger/impl/src/com/intellij/debugger/actions/AddToWatchAction.java with 85% similarity]
java/debugger/impl/src/com/intellij/debugger/actions/DebuggerActions.java
java/debugger/impl/src/com/intellij/debugger/ui/DebuggerSessionTab.java
java/debugger/impl/src/com/intellij/debugger/ui/JavaDebuggerSupport.java
java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/FieldBreakpoint.java
java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java
java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/MainWatchPanel.java
java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java
java/java-impl/src/com/intellij/refactoring/convertToInstanceMethod/ConvertToInstanceMethodDialog.java
java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java
java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveDirectoryWithClassesProcessor.java
java/java-impl/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveJavaClassHandler.java
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/pack2/UsagesFromBoth.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/target/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/target/pack1/S1.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/target/pack1/test_readme.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src2/pack1/S2.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src2/pack2/UsagesFromBoth2.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/pack1/S1.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/pack1/test_readme.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/pack2/UsagesFromBoth.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/target/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src2/pack1/S2.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src2/pack2/UsagesFromBoth2.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/pack2/UsagesFromBoth.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/target/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/target/pack1/S1.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/target/pack1/US.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src2/pack1/S2.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src2/pack2/UsagesFromBoth2.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/pack1/S1.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/pack1/US.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/pack2/UsagesFromBoth.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/target/empty.txt [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src2/pack1/S2.java [new file with mode: 0644]
java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src2/pack2/UsagesFromBoth2.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/refactoring/MovePackageAsDirectoryTest.java
platform/icons/src/debugger/db_muted_breakpoint.png [new file with mode: 0644]
platform/icons/src/debugger/db_muted_exception_breakpoint.png [new file with mode: 0644]
platform/icons/src/debugger/db_muted_field_breakpoint.png [new file with mode: 0644]
platform/icons/src/debugger/db_muted_method_breakpoint.png [new file with mode: 0644]
platform/lang-impl/src/com/intellij/application/options/codeStyle/LanguageCodeStyleSettingsProvider.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTableWithPreviewPanel.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingConfigurable.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingPanel.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingSettingsProvider.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java
platform/lang-impl/src/com/intellij/codeInsight/template/TemplateEditingAdapter.java
platform/lang-impl/src/com/intellij/codeInsight/template/TemplateEditingListener.java
platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java
platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java
platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java
platform/lang-impl/src/com/intellij/find/impl/ShowRecentFindUsagesGroup.java
platform/lang-impl/src/com/intellij/ide/impl/StructureViewWrapperImpl.java
platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureTreeBuilder.java
platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java
platform/lang-impl/src/com/intellij/ide/util/treeView/smartTree/SmartTreeStructure.java
platform/lang-impl/src/com/intellij/openapi/editor/actions/SelectWordAtCaretAction.java
platform/lang-impl/src/com/intellij/openapi/projectRoots/impl/SdkConfigurationUtil.java
platform/lang-impl/src/com/intellij/refactoring/ui/RefactoringDialog.java
platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java
platform/platform-api/src/com/intellij/ide/util/treeView/AbstractTreeUi.java
platform/platform-api/src/com/intellij/openapi/actionSystem/EmptyAction.java
platform/platform-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java
platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java
platform/platform-api/src/com/intellij/openapi/ui/popup/JBPopupFactory.java
platform/platform-api/src/com/intellij/util/ui/Timer.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java
platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java
platform/platform-impl/src/com/intellij/ide/actions/ShowContentAction.java
platform/platform-impl/src/com/intellij/ide/actions/ToggleFullScreenModeAction.java [deleted file]
platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/actions/CopyAction.java
platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleShowIndentLinesAction.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java
platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/ui/playback/commands/TypeCommand.java
platform/platform-impl/src/com/intellij/ui/popup/PopupFactoryImpl.java
platform/platform-impl/testSrc/com/intellij/ide/util/treeView/BaseTreeTestCase.java
platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/platform-resources-en/src/messages/CodeInsightBundle.properties
platform/platform-resources-en/src/messages/DaemonBundle.properties
platform/platform-resources-en/src/messages/FeatureStatisticsBundle.properties
platform/platform-resources-en/src/messages/PsiBundle.properties
platform/platform-resources-en/src/misc/registry.properties
platform/platform-resources/src/idea/Keymap_Default.xml
platform/platform-resources/src/idea/Keymap_Netbeans.xml
platform/platform-resources/src/idea/Keymap_XWin.xml
platform/platform-resources/src/idea/LangActions.xml
platform/platform-resources/src/idea/PlatformActions.xml
platform/testFramework/src/com/intellij/testFramework/LexerTestCase.java
platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java
platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java
platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java
platform/util/src/com/intellij/openapi/application/PathManager.java
platform/util/src/com/intellij/util/ArrayUtil.java
platform/util/src/com/intellij/util/ui/Timer.java [deleted file]
platform/xdebugger-api/src/com/intellij/xdebugger/ui/DebuggerIcons.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/DebuggerSupport.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerSupport.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AddToWatchesAction.java [new file with mode: 0644]
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/XDebuggerActions.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XAddToWatchesFromEditorActionHandler.java [new file with mode: 0644]
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesView.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java
plugins/IntentionPowerPak/src/com/siyeh/ipp/expression/FlipExpressionIntention.java
plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/generator/GroovyToJavaGenerator.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java [new file with mode: 0644]
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/PropertyResolverProcessor.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java
plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCompletionTest.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy
plugins/groovy/testdata/groovy/completion/FirstCompletionDontShowGDKMethods.groovy [new file with mode: 0644]
plugins/groovy/testdata/groovy/completion/FirstCompletionDontShowGDKMethods_after.groovy [new file with mode: 0644]
plugins/groovy/testdata/highlighting/GrDefFieldsArePrivateInJavaCode.java [new file with mode: 0644]
plugins/groovy/testdata/resolve/method/localVariableVsGetter/A.groovy [new file with mode: 0644]
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPluginConfigurationDomExtender.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDomConvertersRegistry.java [new file with mode: 0644]
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenPluginCustomParameterValueConverter.java [new file with mode: 0644]
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomBuild.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomBuildBase.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomConfigurationParameter.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomReporting.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomResource.java
plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/plugin/MavenDomParameter.java
plugins/maven/src/main/resources/META-INF/plugin.xml
plugins/properties/resources/messages/PropertiesBundle.properties
resources-en/src/messages/JavaErrorMessages.properties
resources/src/META-INF/IdeaPlugin.xml
resources/src/idea/IdeaActions.xml
xml/dom-impl/src/com/intellij/util/xml/impl/FixedChildDescriptionImpl.java
xml/impl/src/com/intellij/codeInsight/template/XmlZenCodingTemplate.java

similarity index 85%
rename from java/debugger/impl/src/com/intellij/debugger/actions/AddToWatchAction.java
rename to java/debugger/impl/src/com/intellij/debugger/actions/AddToWatchActionHandler.java
index a94a2c09ada15b78dadc948dee4babe9e1b2f2f2..e1df811cee258c1a5977003e13dfdedf42dedfcb 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 /*
- * Class AddToWatchAction
+ * Class AddToWatchActionHandler
  * @author Jeka
  */
 package com.intellij.debugger.actions;
@@ -34,27 +34,28 @@ import com.intellij.debugger.ui.impl.WatchDebuggerTree;
 import com.intellij.debugger.ui.impl.watch.*;
 import com.intellij.ide.DataManager;
 import com.intellij.idea.ActionsBundle;
-import com.intellij.openapi.actionSystem.ActionPlaces;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
+import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
+import com.intellij.xdebugger.impl.actions.XDebuggerActions;
+import org.jetbrains.annotations.NotNull;
 
-public class AddToWatchAction extends DebuggerAction {
-
-  public void update(AnActionEvent e) {
+public class AddToWatchActionHandler extends DebuggerActionHandler {
+  @Override
+  public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
     DataContext context = DataManager.getInstance().getDataContext();
     if (context == null) {
-      e.getPresentation().setEnabled(false);
-      return;
+      return false;
     }
 
-    DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(context);
+    DebuggerTreeNodeImpl[] selectedNodes = DebuggerAction.getSelectedNodes(context);
     boolean enabled = false;
     if (selectedNodes != null && selectedNodes.length > 0) {
-      if (getPanel(context) instanceof VariablesPanel) {
+      if (DebuggerAction.getPanel(context) instanceof VariablesPanel) {
         enabled = true;
         for (DebuggerTreeNodeImpl node : selectedNodes) {
           NodeDescriptorImpl descriptor = node.getDescriptor();
@@ -66,20 +67,18 @@ public class AddToWatchAction extends DebuggerAction {
       }
     }
     else {
-      final Editor editor = e.getData(PlatformDataKeys.EDITOR);
+      final Editor editor = event.getData(PlatformDataKeys.EDITOR);
       enabled = DebuggerUtilsEx.getEditorText(editor) != null;
     }
-    e.getPresentation().setEnabled(enabled);
-    if (ActionPlaces.isPopupPlace(e.getPlace())) {
-      e.getPresentation().setVisible(enabled);
-    }
+    return enabled;
   }
 
-  public void actionPerformed(AnActionEvent e) {
+  @Override
+  public void perform(@NotNull Project project, AnActionEvent event) {
     DataContext context = DataManager.getInstance().getDataContext();
     if (context == null) return;
 
-    final DebuggerContextImpl debuggerContext = getDebuggerContext(context);
+    final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(context);
 
     if(debuggerContext == null) return;
 
@@ -93,13 +92,13 @@ public class AddToWatchAction extends DebuggerAction {
       return;
     }
 
-    final DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(context);
+    final DebuggerTreeNodeImpl[] selectedNodes = DebuggerAction.getSelectedNodes(context);
 
     if(selectedNodes != null && selectedNodes.length > 0) {
       addFromNodes(debuggerContext, watchPanel, selectedNodes);
     }
     else {
-      final Editor editor = e.getData(PlatformDataKeys.EDITOR);
+      final Editor editor = event.getData(PlatformDataKeys.EDITOR);
       if (editor != null) {
         final TextWithImports editorText = DebuggerUtilsEx.getEditorText(editor);
         if (editorText != null) {
@@ -152,7 +151,7 @@ public class AddToWatchAction extends DebuggerAction {
         catch (final EvaluateException e) {
           DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
             public void run() {
-              Messages.showErrorDialog(project, e.getMessage(), ActionsBundle.actionText(DebuggerActions.ADD_TO_WATCH));
+              Messages.showErrorDialog(project, e.getMessage(), ActionsBundle.actionText(XDebuggerActions.ADD_TO_WATCH));
             }
           });
         }
index 1220f5c9682bfe81cff036ad7dd84c1518a9008a..2a2ae16f9c618b8e1c4b7079ad2a555296860d0e 100644 (file)
@@ -36,7 +36,6 @@ public interface DebuggerActions extends XDebuggerActions {
   @Deprecated @NonNls String DEBUGGER_TREE_PANEL = DebuggerTreePanel.DATA_KEY.getName();
   @NonNls String REMOVE_WATCH = "Debugger.RemoveWatch";
   @NonNls String NEW_WATCH = "Debugger.NewWatch";
-  @NonNls String ADD_TO_WATCH = "Debugger.AddToWatch";
   @NonNls String EDIT_WATCH = "Debugger.EditWatch";
   @NonNls String MARK_OBJECT = "Debugger.MarkObject";
   @NonNls String SET_VALUE = "Debugger.SetValue";
index b6167ccb3b3ec6d4415aff44ec638ec3834f823b..49a1ce52eb90b4d10c3c5d274abc7f0ee541dec6 100644 (file)
@@ -167,7 +167,7 @@ public class DebuggerSessionTab extends DebuggerLogConsoleManagerBase implements
     watches.setAlertIcon(breakpointAlert);
     final DefaultActionGroup watchesGroup = new DefaultActionGroup();
     addAction(watchesGroup, DebuggerActions.NEW_WATCH);
-    addAction(watchesGroup, DebuggerActions.ADD_TO_WATCH);
+    addAction(watchesGroup, XDebuggerActions.ADD_TO_WATCH);
     addAction(watchesGroup, DebuggerActions.REMOVE_WATCH);
     watches.setActions(watchesGroup, ActionPlaces.DEBUGGER_TOOLBAR, myWatchPanel.getTree());
     myUi.addContent(watches, 0, PlaceInGrid.right, false);
index cea1dd02f8226c99254acccf1df1a311b448144b..76d5a6985672c755c8aef80e36b60b9c8ec94b7a 100644 (file)
@@ -45,43 +45,24 @@ import java.util.List;
  * @author nik
  */
 public class JavaDebuggerSupport extends DebuggerSupport {
-  private final JavaBreakpointPanelProvider myBreakpointPanelProvider;
-  private final StepOverActionHandler myStepOverActionHandler;
-  private final StepIntoActionHandler myStepIntoActionHandler;
-  private final StepOutActionHandler myStepOutActionHandler;
-  private final ForceStepOverActionHandler myForceStepOverActionHandler;
-  private final ForceStepIntoActionHandler myForceStepIntoActionHandler;
-  private final RunToCursorActionHandler myRunToCursorActionHandler;
-  private final ForceRunToCursorActionHandler myForceRunToCursorActionHandler;
-  private final ResumeActionHandler myResumeActionHandler;
-  private final PauseActionHandler myPauseActionHandler;
-  private final ToggleLineBreakpointActionHandler myToggleLineBreakpointActionHandler;
-  private final ShowExecutionPointActionHandler myShowExecutionPointActionHandler;
-  private final EvaluateActionHandler myEvaluateActionHandler;
-  private final QuickEvaluateActionHandler myQuickEvaluateHandler;
-  private final JavaDebuggerSettingsPanelProvider myDebuggerSettingsPanelProvider;
-  private final MuteBreakpointsActionHandler myMuteBreakpointsHandler;
-  private final DebuggerActionHandler mySmartStepIntoHandler;
-
-  public JavaDebuggerSupport() {
-    myBreakpointPanelProvider = new JavaBreakpointPanelProvider();
-    myStepOverActionHandler = new StepOverActionHandler();
-    myStepIntoActionHandler = new StepIntoActionHandler();
-    myStepOutActionHandler = new StepOutActionHandler();
-    myForceStepOverActionHandler = new ForceStepOverActionHandler();
-    myForceStepIntoActionHandler = new ForceStepIntoActionHandler();
-    myRunToCursorActionHandler = new RunToCursorActionHandler();
-    myForceRunToCursorActionHandler = new ForceRunToCursorActionHandler();
-    myResumeActionHandler = new ResumeActionHandler();
-    myPauseActionHandler = new PauseActionHandler();
-    myToggleLineBreakpointActionHandler = new ToggleLineBreakpointActionHandler();
-    myShowExecutionPointActionHandler = new ShowExecutionPointActionHandler();
-    myEvaluateActionHandler = new EvaluateActionHandler();
-    myQuickEvaluateHandler = new QuickEvaluateActionHandler();
-    myDebuggerSettingsPanelProvider = new JavaDebuggerSettingsPanelProvider();
-    myMuteBreakpointsHandler = new MuteBreakpointsActionHandler();
-    mySmartStepIntoHandler = new SmartStepIntoActionHandler();
-  }
+  private final JavaBreakpointPanelProvider myBreakpointPanelProvider = new JavaBreakpointPanelProvider();
+  private final StepOverActionHandler myStepOverActionHandler = new StepOverActionHandler();
+  private final StepIntoActionHandler myStepIntoActionHandler = new StepIntoActionHandler();
+  private final StepOutActionHandler myStepOutActionHandler = new StepOutActionHandler();
+  private final ForceStepOverActionHandler myForceStepOverActionHandler = new ForceStepOverActionHandler();
+  private final ForceStepIntoActionHandler myForceStepIntoActionHandler = new ForceStepIntoActionHandler();
+  private final RunToCursorActionHandler myRunToCursorActionHandler = new RunToCursorActionHandler();
+  private final ForceRunToCursorActionHandler myForceRunToCursorActionHandler = new ForceRunToCursorActionHandler();
+  private final ResumeActionHandler myResumeActionHandler = new ResumeActionHandler();
+  private final PauseActionHandler myPauseActionHandler = new PauseActionHandler();
+  private final ToggleLineBreakpointActionHandler myToggleLineBreakpointActionHandler = new ToggleLineBreakpointActionHandler();
+  private final ShowExecutionPointActionHandler myShowExecutionPointActionHandler = new ShowExecutionPointActionHandler();
+  private final EvaluateActionHandler myEvaluateActionHandler = new EvaluateActionHandler();
+  private final QuickEvaluateActionHandler myQuickEvaluateHandler = new QuickEvaluateActionHandler();
+  private final JavaDebuggerSettingsPanelProvider myDebuggerSettingsPanelProvider = new JavaDebuggerSettingsPanelProvider();
+  private final MuteBreakpointsActionHandler myMuteBreakpointsHandler = new MuteBreakpointsActionHandler();
+  private final DebuggerActionHandler mySmartStepIntoHandler = new SmartStepIntoActionHandler();
+  private final DebuggerActionHandler myAddToWatchedActionHandler = new AddToWatchActionHandler();
 
   @NotNull
   public BreakpointPanelProvider<?> getBreakpointPanelProvider() {
@@ -158,6 +139,12 @@ public class JavaDebuggerSupport extends DebuggerSupport {
     return myQuickEvaluateHandler;
   }
 
+  @NotNull
+  @Override
+  public DebuggerActionHandler getAddToWatchesActionHandler() {
+    return myAddToWatchedActionHandler;
+  }
+
   @NotNull
   public DebuggerToggleActionHandler getMuteBreakpointsHandler() {
     return myMuteBreakpointsHandler;
index 7b8c4d42c05486e1cccaab22e5b9760310f1e176..138f4a256f2fd2d1337c98aad789d5889193c03d 100644 (file)
@@ -85,6 +85,8 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
 
   protected abstract Icon getDisabledIcon();
 
+  protected abstract Icon getMutedIcon();
+
   protected abstract Icon getInvalidIcon();
 
   protected abstract Icon getSetIcon();
@@ -136,9 +138,12 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
   }
 
   private Icon calcIcon(DebugProcessImpl debugProcess) {
-    if (!ENABLED || (debugProcess != null && isMuted(debugProcess))) {
+    if (!ENABLED) {
       return getDisabledIcon();
     }
+    if (debugProcess != null && isMuted(debugProcess)) {
+      return getMutedIcon();
+    }
 
     myInvalidMessage = "";
 
index cbacf6f200bf6b854c0de9865067f25ef506a984..bd6e5166d24bdfad3cd9320c5ccdde00c68d0ecc 100644 (file)
@@ -63,6 +63,7 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
   private String myFieldName;
 
   public static Icon ICON = IconLoader.getIcon("/debugger/db_field_breakpoint.png");
+  public static Icon MUTED_ICON = IconLoader.getIcon("/debugger/db_muted_field_breakpoint.png");
   public static Icon DISABLED_ICON = IconLoader.getIcon("/debugger/db_disabled_field_breakpoint.png");
   public static Icon DISABLED_DEP_ICON = IconLoader.getIcon("/debugger/db_dep_field_breakpoint.png");
   private static final Icon ourInvalidIcon = IconLoader.getIcon("/debugger/db_invalid_field_breakpoint.png");
@@ -93,6 +94,10 @@ public class FieldBreakpoint extends BreakpointWithHighlighter {
     return master == null? DISABLED_ICON : DISABLED_DEP_ICON;
   }
 
+  protected Icon getMutedIcon() {
+    return MUTED_ICON;
+  }
+
   protected Icon getSetIcon() {
     return ICON;
   }
index 3449a440ffba82d854b322230927571279368650..730a66e9b07c73e49fe9e33a7b7403fbacf657eb 100644 (file)
@@ -66,6 +66,7 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
 
   // icons
   public static Icon ICON = DebuggerIcons.ENABLED_BREAKPOINT_ICON;
+  public static final Icon MUTED_ICON = DebuggerIcons.MUTED_BREAKPOINT_ICON;
   public static final Icon DISABLED_ICON = DebuggerIcons.DISABLED_BREAKPOINT_ICON;
   private static final Icon ourVerifiedWarningsIcon = IconLoader.getIcon("/debugger/db_verified_warning_breakpoint.png");
 
@@ -85,6 +86,10 @@ public class LineBreakpoint extends BreakpointWithHighlighter {
     return master == null? DISABLED_ICON : DebuggerIcons.DISABLED_DEPENDENT_BREAKPOINT_ICON;
   }
 
+  protected Icon getMutedIcon() {
+    return MUTED_ICON;
+  }
+
   protected Icon getSetIcon() {
     return ICON;
   }
index 262f394e1963a82ccbf4508eb920eeb85ca25736..9bcb471d59a1c93ad687d6aae224d1c6404dd2b8 100644 (file)
@@ -68,6 +68,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
   private boolean myIsStatic;
 
   public static Icon ICON = IconLoader.getIcon("/debugger/db_method_breakpoint.png");
+  public static Icon MUTED_ICON = IconLoader.getIcon("/debugger/db_muted_method_breakpoint.png");
   public static Icon DISABLED_ICON = IconLoader.getIcon("/debugger/db_disabled_method_breakpoint.png");
   public static Icon DISABLED_DEP_ICON = IconLoader.getIcon("/debugger/db_dep_method_breakpoint.png");
   private static final Icon ourInvalidIcon = IconLoader.getIcon("/debugger/db_invalid_method_breakpoint.png");
@@ -221,6 +222,10 @@ public class MethodBreakpoint extends BreakpointWithHighlighter {
     return master == null? DISABLED_ICON : DISABLED_DEP_ICON;
   }
 
+  protected Icon getMutedIcon() {
+    return MUTED_ICON;
+  }
+
   protected Icon getSetIcon() {
     return ICON;
   }
index 8720ea36b0d96f6a65c4f6208f3ce8a48cc910fe..e8876aee1f62f7ce664dc5be3a543bb17517e728 100644 (file)
@@ -20,7 +20,7 @@
  */
 package com.intellij.debugger.ui.impl;
 
-import com.intellij.debugger.actions.AddToWatchAction;
+import com.intellij.debugger.actions.AddToWatchActionHandler;
 import com.intellij.debugger.actions.DebuggerActions;
 import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
 import com.intellij.debugger.engine.evaluation.TextWithImports;
@@ -137,11 +137,11 @@ public class MainWatchPanel extends WatchPanel implements DataProvider {
   }
 
   private void addWatchesFrom(final DebuggerTreeNodeImpl[] nodes) {
-    AddToWatchAction.addFromNodes(getContext(), this, nodes);
+    AddToWatchActionHandler.addFromNodes(getContext(), this, nodes);
   }
 
   private void addWatchesFrom(String text) {
-    AddToWatchAction.doAddWatch(this, new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, text), null);
+    AddToWatchActionHandler.doAddWatch(this, new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, text), null);
   }
 
   protected ActionPopupMenu createPopupMenu() {
index 0382f508d83cb83f6ae3b6b5a30133f8558af909..d0ab00d727ef355524078e806c049b05c9491168 100644 (file)
@@ -38,9 +38,10 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
         return INDENT_AND_BRACES_SAMPLE;
       case SPACING_SETTINGS:
         return SPACING_SAMPLE;
-      default:
-        return GENERAL_CODE_SAMPLE;
+      case WRAPPING_SETTINGS:
+        return WRAPPING_CODE_SAMPLE;
     }
+    return GENERAL_CODE_SAMPLE;
   }
 
   private static final String GENERAL_CODE_SAMPLE = "public class Foo {\n" +
@@ -203,4 +204,40 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
                                                "    while (true);\n" +
                                                "  }\n" +
                                                "}";
+
+  private static final String WRAPPING_CODE_SAMPLE = "/*\n" +
+                                                     " * This is a sample file.\n" +
+                                                     " */\n" +
+                                                     "\n" +
+                                                     "public class ThisIsASampleClass extends C1 implements I1, I2, I3, I4, I5 {\n" +
+                                                     "  private int f1;\n" +
+                                                     "  private int f2;\n" +
+                                                     "  public void foo1(int i1, int i2, int i3, int i4, int i5, int i6, int i7) {}\n" +
+                                                     "  public static void longerMethod() throws Exception1, Exception2, Exception3 {\n" +
+                                                     "    int[] a = new int[] {1, 2, 0x0052, 0x0053, 0x0054};\n" +
+                                                     "    foo1(0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057);\n" +
+                                                     "    int x = (3 + 4 + 5 + 6) * (7 + 8 + 9 + 10) * (11 + 12 + 13 + 14 + 0xFFFFFFFF);\n" +
+                                                     "    String s1, s2, s3;\n" +
+                                                     "    s1 = s2 = s3 = \"012345678901456\";\n" +
+                                                     "    assert i + j + k + l + n+ m <= 2 : \"assert description\";" +
+                                                     "    int y = 2 > 3 ? 7 + 8 + 9 : 11 + 12 + 13;\n" +
+                                                     "    label: " +
+                                                     "    for (int i = 0; i < 0xFFFFFF; i += 2) {\n" +
+                                                     "       super.getFoo().foo().getBar().bar();\n" +
+                                                     "    }\n" +
+                                                     "  }\n" +
+                                                     "}\n" +
+                                                     "\n" +
+                                                     "enum Breed {\n" +
+                                                     "    Dalmatian(), Labrador(), Dachshund()\n" +
+                                                     "}\n" +
+                                                     "\n" +
+                                                     "@Annotation1 @Annotation2 @Annotation3(param1=\"value1\", param2=\"value2\") @Annotation4 class Foo {\n" +
+                                                     "    @Annotation1 @Annotation3(param1=\"value1\", param2=\"value2\") public static void foo(){\n" +
+                                                     "    }\n" +
+                                                     "    @Annotation1 @Annotation3(param1=\"value1\", param2=\"value2\") public static int myFoo;\n" +
+                                                     "    public void method(@Annotation1 @Annotation3(param1=\"value1\", param2=\"value2\") final int param){\n" +
+                                                     "        @Annotation1 @Annotation3(param1=\"value1\", param2=\"value2\") final int localVariable;" +
+                                                     "    }\n" +
+                                                     "}";
 }
index 2fa0f4bf01f331b036d99dc4827dffb24e63c342..d76321c40fc554055ddccbcf5d39c49f19a6540c 100644 (file)
@@ -25,6 +25,9 @@ import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.move.moveInstanceMethod.MoveInstanceMethodDialogBase;
 
 import javax.swing.*;
+import java.awt.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 
 /**
  * @author ven
@@ -63,4 +66,20 @@ public class ConvertToInstanceMethodDialog  extends MoveInstanceMethodDialogBase
     label.setText(RefactoringBundle.message("moveInstanceMethod.select.an.instance.parameter"));
     return vBox;
   }
+
+  @Override
+  protected JList createTargetVariableChooser() {
+    final JList variableChooser = super.createTargetVariableChooser();
+    variableChooser.addMouseListener(new MouseAdapter() {
+      public void mouseClicked(MouseEvent e) {
+        if (e.getClickCount() != 2) return;
+        Point point = e.getPoint();
+        int index = variableChooser.locationToIndex(point);
+        if (index == -1) return;
+        if (!variableChooser.getCellBounds(index, index).contains(point)) return;
+        doRefactorAction();
+      }
+    });
+    return variableChooser;
+  }
 }
index 3706299c6fecc25e833fa344d97e082ab9aa95f0..70e9a96f3b6375b7443f40346079cd2d1ebe8a4a 100644 (file)
@@ -139,22 +139,26 @@ public class PullUpHelper extends BaseRefactoringProcessor{
           ChangeContextUtil.clearContextInfo(method);
           RefactoringUtil.abstractizeMethod(myTargetSuperClass, methodCopy);
 
+          if (method.findDeepestSuperMethods().length == 0 || (myTargetSuperClass.isInterface() && !PsiUtil.isLanguageLevel6OrHigher(mySourceClass))) {
+            deleteOverrideAnnotationIfFound(methodCopy);
+          }
+
           myJavaDocPolicy.processCopiedJavaDoc(methodCopy.getDocComment(), method.getDocComment(), isOriginalMethodAbstract);
 
           final PsiMember movedElement = (PsiMember)myTargetSuperClass.add(methodCopy);
           CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(method.getProject());
           if (styleSettings.INSERT_OVERRIDE_ANNOTATION) {
             if (PsiUtil.isLanguageLevel5OrHigher(mySourceClass) && !myTargetSuperClass.isInterface() || PsiUtil.isLanguageLevel6OrHigher(mySourceClass)) {
-              new AddAnnotationFix("java.lang.Override", method).invoke(method.getProject(), null, mySourceClass.getContainingFile());
+              new AddAnnotationFix(Override.class.getName(), method).invoke(method.getProject(), null, mySourceClass.getContainingFile());
             }
           }
-          if (isOriginalMethodAbstract && myTargetSuperClass.isInterface() && !PsiUtil.isLanguageLevel6OrHigher(mySourceClass)) {
-            for (PsiMethod oMethod : OverridingMethodsSearch.search(method)) {
-              final PsiAnnotation annotation = AnnotationUtil.findAnnotation(oMethod, Override.class.getName());
-              if (annotation != null) {
-                annotation.delete();
+          if (!PsiUtil.isLanguageLevel6OrHigher(mySourceClass) && myTargetSuperClass.isInterface()) {
+            if (isOriginalMethodAbstract) {
+              for (PsiMethod oMethod : OverridingMethodsSearch.search(method)) {
+                deleteOverrideAnnotationIfFound(oMethod);
               }
             }
+            deleteOverrideAnnotationIfFound(method);
           }
           myMembersAfterMove.add(movedElement);
           if (isOriginalMethodAbstract) {
@@ -231,6 +235,13 @@ public class PullUpHelper extends BaseRefactoringProcessor{
     }
   }
 
+  private static void deleteOverrideAnnotationIfFound(PsiMethod oMethod) {
+    final PsiAnnotation annotation = AnnotationUtil.findAnnotation(oMethod, Override.class.getName());
+    if (annotation != null) {
+      annotation.delete();
+    }
+  }
+
   public void moveFieldInitializations() throws IncorrectOperationException {
     LOG.assertTrue(myMembersAfterMove != null);
 
index 097c6777edfe394f8f75f973a95d9ffe8995d84f..c348d27f0d7859591c019323789b15cf7f848146 100644 (file)
@@ -25,7 +25,6 @@ import com.intellij.codeInsight.ChangeContextUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.Ref;
-import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.search.searches.ReferencesSearch;
@@ -52,7 +51,7 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
   private PsiDirectory myTargetDirectory;
   private boolean mySearchInComments;
   private boolean mySearchInNonJavaFiles;
-  private Map<PsiClass, TargetDirectoryWrapper> myClassesToMove;
+  private Map<PsiFile, TargetDirectoryWrapper> myFilesToMove;
   private NonCodeUsageInfo[] myNonCodeUsages;
   private MoveCallback myMoveCallback;
 
@@ -69,16 +68,16 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
     mySearchInComments = searchInComments;
     mySearchInNonJavaFiles = searchInNonJavaFiles;
     myMoveCallback = moveCallback;
-    myClassesToMove = new HashMap<PsiClass, TargetDirectoryWrapper>();
+    myFilesToMove = new HashMap<PsiFile, TargetDirectoryWrapper>();
     for (PsiDirectory dir : directories) {
-      collectClasses(myClassesToMove, dir, includeSelf ? dir.getParentDirectory() : dir, getTargetDirectory(dir));
+      collectFiles2Move(myFilesToMove, dir, includeSelf ? dir.getParentDirectory() : dir, getTargetDirectory(dir));
     }
   }
 
   @Override
   protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usages) {
-    PsiElement[] elements = new PsiElement[myClassesToMove.size()];
-    final PsiClass[] classes = myClassesToMove.keySet().toArray(new PsiClass[myClassesToMove.keySet().size()]);
+    PsiElement[] elements = new PsiElement[myFilesToMove.size()];
+    final PsiFile[] classes = myFilesToMove.keySet().toArray(new PsiFile[myFilesToMove.keySet().size()]);
     System.arraycopy(classes, 0, elements, 0, classes.length);
     return new MoveClassesOrPackagesViewDescriptor(elements, false, false, getTargetName());
   }
@@ -92,11 +91,14 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
   public UsageInfo[] findUsages() {
     final List<UsageInfo> usages = new ArrayList<UsageInfo>();
     final Set<String> packageNames = new HashSet<String>();
-    for (PsiClass psiClass : myClassesToMove.keySet()) {
-      Collections.addAll(usages, MoveClassesOrPackagesUtil.findUsages(psiClass, mySearchInComments, mySearchInNonJavaFiles, psiClass.getName()));
-      final String fqName = psiClass.getQualifiedName();
-      assert fqName != null;
-      packageNames.add(StringUtil.getPackageName(fqName));
+    for (PsiFile psiFile : myFilesToMove.keySet()) {
+      if (psiFile instanceof PsiClassOwner) {
+        final PsiClass[] classes = ((PsiClassOwner)psiFile).getClasses();
+        for (PsiClass aClass : classes) {
+          Collections.addAll(usages, MoveClassesOrPackagesUtil.findUsages(aClass, mySearchInComments, mySearchInNonJavaFiles, aClass.getName()));
+        }
+        packageNames.add(((PsiClassOwner)psiFile).getPackageName());
+      }
     }
     final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(myProject);
     for (String packageName : packageNames) {
@@ -136,12 +138,12 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
   @Override
   protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) {
     final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
-    for (PsiClass psiClass : myClassesToMove.keySet()) {
+    for (PsiFile psiFile : myFilesToMove.keySet()) {
       try {
-        myClassesToMove.get(psiClass).checkMove(psiClass);
+        myFilesToMove.get(psiFile).checkMove(psiFile);
       }
       catch (IncorrectOperationException e) {
-        conflicts.putValue(psiClass, e.getMessage());
+        conflicts.putValue(psiFile, e.getMessage());
       }
     }
     return showConflicts(conflicts);
@@ -153,9 +155,9 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
   @Override
   public void performRefactoring(UsageInfo[] usages) {
     //try to create all directories beforehand
-    for (PsiClass psiClass : myClassesToMove.keySet()) {
+    for (PsiFile psiFile : myFilesToMove.keySet()) {
       try {
-        myClassesToMove.get(psiClass).findOrCreateTargetDirectory();
+        myFilesToMove.get(psiFile).findOrCreateTargetDirectory();
       }
       catch (IncorrectOperationException e) {
         Messages.showErrorDialog(myProject, e.getMessage(), CommonBundle.getErrorTitle());
@@ -163,16 +165,25 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
       }
     }
     final Map<PsiElement, PsiElement> oldToNewElementsMapping = new HashMap<PsiElement, PsiElement>();
-    for (PsiClass psiClass : myClassesToMove.keySet()) {
-      ChangeContextUtil.encodeContextInfo(psiClass, true);
-      final RefactoringElementListener listener = getTransaction().getElementListener(psiClass);
-      final PsiDirectory moveDestination = myClassesToMove.get(psiClass).getTargetDirectory();
-      final PsiClass newClass = MoveClassesOrPackagesUtil.doMoveClass(psiClass, moveDestination);
-      oldToNewElementsMapping.put(psiClass, newClass);
-      listener.elementMoved(newClass);
+    for (PsiFile psiFile : myFilesToMove.keySet()) {
+      ChangeContextUtil.encodeContextInfo(psiFile, true);
+      final RefactoringElementListener listener = getTransaction().getElementListener(psiFile);
+      final PsiDirectory moveDestination = myFilesToMove.get(psiFile).getTargetDirectory();
+      if (psiFile instanceof PsiClassOwner) {
+        for (PsiClass psiClass : ((PsiClassOwner)psiFile).getClasses()) {
+          final PsiClass newClass = MoveClassesOrPackagesUtil.doMoveClass(psiClass, moveDestination);
+          oldToNewElementsMapping.put(psiClass, newClass);
+          listener.elementMoved(newClass);
+        }
+      } else {
+        if (!moveDestination.equals(psiFile.getContainingDirectory())) {
+          psiFile.getManager().moveFile(psiFile, moveDestination);
+          listener.elementMoved(psiFile);
+        }
+      }
     }
-    for (PsiClass psiClass : myClassesToMove.keySet()) {
-      ChangeContextUtil.decodeContextInfo(psiClass, null, null);
+    for (PsiElement newElement : oldToNewElementsMapping.values()) {
+      ChangeContextUtil.decodeContextInfo(newElement, null, null);
     }
     myNonCodeUsages = MoveClassesOrPackagesProcessor.retargetUsages(usages, oldToNewElementsMapping);
     for (UsageInfo usage : usages) {
@@ -196,7 +207,7 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
     }
   }
 
-  private static void collectClasses(Map<PsiClass, TargetDirectoryWrapper> classesToMove,
+  private static void collectFiles2Move(Map<PsiFile, TargetDirectoryWrapper> files2Move,
                                      PsiDirectory directory,
                                      PsiDirectory rootDirectory,
                                      @NotNull TargetDirectoryWrapper targetDirectory) {
@@ -207,13 +218,11 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
                                                       ? targetDirectory
                                                       : targetDirectory.findOrCreateChild(relativePath);
     for (PsiElement child : children) {
-      if (child instanceof PsiJavaFile) {
-        for (PsiClass aClass : ((PsiJavaFile)child).getClasses()) {
-          classesToMove.put(aClass, newTargetDirectory);
-        }
+      if (child instanceof PsiFile) {
+        files2Move.put((PsiFile)child, newTargetDirectory);
       }
       else if (child instanceof PsiDirectory){
-        collectClasses(classesToMove, (PsiDirectory)child, directory, newTargetDirectory);
+        collectFiles2Move(files2Move, (PsiDirectory)child, directory, newTargetDirectory);
       }
     }
   }
@@ -281,9 +290,9 @@ public class MoveDirectoryWithClassesProcessor extends BaseRefactoringProcessor
       return new TargetDirectoryWrapper(this, relativePath);
     }
 
-    public void checkMove(PsiClass psiClass) throws IncorrectOperationException {
+    public void checkMove(PsiFile psiFile) throws IncorrectOperationException {
       if (myTargetDirectory != null) {
-        psiClass.getManager().checkMove(psiClass, myTargetDirectory);
+        psiFile.getManager().checkMove(psiFile, myTargetDirectory);
       }
     }
   }
index cf5f3a1da96fcda7392483e13156dd3c13e70cbc..60c548626a68986a44bf195af820461c9b4fee46 100644 (file)
@@ -19,16 +19,20 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.psi.*;
 import com.intellij.psi.javadoc.PsiDocComment;
+import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * @author Maxim.Medvedev
  */
 public class MoveJavaClassHandler implements MoveClassHandler {
   private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.move.moveClassesOrPackages.MoveJavaClassHandler");
 
-  public PsiClass doMoveClass(@NotNull PsiClass aClass, @NotNull PsiDirectory moveDestination) throws IncorrectOperationException {
+  public PsiClass doMoveClass(@NotNull final PsiClass aClass, @NotNull PsiDirectory moveDestination) throws IncorrectOperationException {
     PsiFile file = aClass.getContainingFile();
     final PsiPackage newPackage = JavaDirectoryService.getInstance().getPackage(moveDestination);
 
@@ -51,18 +55,26 @@ public class MoveJavaClassHandler implements MoveClassHandler {
              moveDestination.findFile(file.getName()) != null) {
       // moving second of two classes which were in the same file to a different directory (IDEADEV-3089)
       correctSelfReferences(aClass, newPackage);
-      PsiFile newFile = moveDestination.findFile(file.getName());
+      final PsiFile newFile = moveDestination.findFile(file.getName());
+      LOG.assertTrue(newFile != null);
       newClass = (PsiClass)newFile.add(aClass);
+      correctOldClassReferences(newClass, aClass);
       aClass.delete();
     }
     return newClass;
   }
 
   private static void correctOldClassReferences(final PsiClass newClass, final PsiClass oldClass) {
-    newClass.accept(new JavaRecursiveElementVisitor() {
+    final Set<PsiImportStatementBase> importsToDelete = new HashSet<PsiImportStatementBase>();
+    newClass.getContainingFile().accept(new JavaRecursiveElementVisitor() {
       @Override
       public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
         if (reference.isReferenceTo(oldClass)) {
+          final PsiImportStatementBase importStatement = PsiTreeUtil.getParentOfType(reference, PsiImportStatementBase.class);
+          if (importStatement != null) {
+            importsToDelete.add(importStatement);
+            return;
+          }
           try {
             reference.bindToElement(newClass);
           }
@@ -73,6 +85,9 @@ public class MoveJavaClassHandler implements MoveClassHandler {
         super.visitReferenceElement(reference);
       }
     });
+    for (PsiImportStatementBase importStatement : importsToDelete) {
+      importStatement.delete();
+    }
   }
 
   private static void correctSelfReferences(final PsiClass aClass, final PsiPackage newContainingPackage) {
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/pack2/UsagesFromBoth.java b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/pack2/UsagesFromBoth.java
new file mode 100644 (file)
index 0000000..6d4410f
--- /dev/null
@@ -0,0 +1,9 @@
+package pack2;
+
+import pack1.*;
+import target.pack1.S1;
+
+public class UsagesFromBoth {
+  S1 s1;
+  S2 s2;
+}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/target/empty.txt b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/target/empty.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/target/pack1/S1.java b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/target/pack1/S1.java
new file mode 100644 (file)
index 0000000..bafd60d
--- /dev/null
@@ -0,0 +1,3 @@
+package target.pack1;
+
+public class S1{}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/target/pack1/test_readme.txt b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src1/target/pack1/test_readme.txt
new file mode 100644 (file)
index 0000000..ea786ff
--- /dev/null
@@ -0,0 +1 @@
+readme
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src2/pack1/S2.java b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src2/pack1/S2.java
new file mode 100644 (file)
index 0000000..0bd2d20
--- /dev/null
@@ -0,0 +1,3 @@
+package pack1;
+
+public class S2{}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src2/pack2/UsagesFromBoth2.java b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/after/src2/pack2/UsagesFromBoth2.java
new file mode 100644 (file)
index 0000000..9b53f38
--- /dev/null
@@ -0,0 +1,9 @@
+package pack2;
+
+import pack1.*;
+import target.pack1.S1;
+
+public class UsagesFromBoth2 {
+  S1 s1;
+  S2 s2;
+}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/pack1/S1.java b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/pack1/S1.java
new file mode 100644 (file)
index 0000000..c0a5f31
--- /dev/null
@@ -0,0 +1,3 @@
+package pack1;
+
+public class S1{}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/pack1/test_readme.txt b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/pack1/test_readme.txt
new file mode 100644 (file)
index 0000000..ea786ff
--- /dev/null
@@ -0,0 +1 @@
+readme
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/pack2/UsagesFromBoth.java b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/pack2/UsagesFromBoth.java
new file mode 100644 (file)
index 0000000..906b1fe
--- /dev/null
@@ -0,0 +1,8 @@
+package pack2;
+
+import pack1.*;
+
+public class UsagesFromBoth {
+  S1 s1;
+  S2 s2;
+}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/target/empty.txt b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src1/target/empty.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src2/pack1/S2.java b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src2/pack1/S2.java
new file mode 100644 (file)
index 0000000..0bd2d20
--- /dev/null
@@ -0,0 +1,3 @@
+package pack1;
+
+public class S2{}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src2/pack2/UsagesFromBoth2.java b/java/java-tests/testData/refactoring/movePackageAsDir/movePackageWithTxtFilesInside/before/src2/pack2/UsagesFromBoth2.java
new file mode 100644 (file)
index 0000000..d8ece1c
--- /dev/null
@@ -0,0 +1,8 @@
+package pack2;
+
+import pack1.*;
+
+public class UsagesFromBoth2 {
+  S1 s1;
+  S2 s2;
+}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/pack2/UsagesFromBoth.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/pack2/UsagesFromBoth.java
new file mode 100644 (file)
index 0000000..6d4410f
--- /dev/null
@@ -0,0 +1,9 @@
+package pack2;
+
+import pack1.*;
+import target.pack1.S1;
+
+public class UsagesFromBoth {
+  S1 s1;
+  S2 s2;
+}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/target/empty.txt b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/target/empty.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/target/pack1/S1.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/target/pack1/S1.java
new file mode 100644 (file)
index 0000000..00ad41e
--- /dev/null
@@ -0,0 +1,7 @@
+package target.pack1;
+
+public class S1{
+  S11 s11;
+}
+
+class S11{}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/target/pack1/US.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src1/target/pack1/US.java
new file mode 100644 (file)
index 0000000..31b3384
--- /dev/null
@@ -0,0 +1,5 @@
+package target.pack1;
+
+class US {
+  S11 myS11WithoutImport;
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src2/pack1/S2.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src2/pack1/S2.java
new file mode 100644 (file)
index 0000000..0bd2d20
--- /dev/null
@@ -0,0 +1,3 @@
+package pack1;
+
+public class S2{}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src2/pack2/UsagesFromBoth2.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/after/src2/pack2/UsagesFromBoth2.java
new file mode 100644 (file)
index 0000000..9b53f38
--- /dev/null
@@ -0,0 +1,9 @@
+package pack2;
+
+import pack1.*;
+import target.pack1.S1;
+
+public class UsagesFromBoth2 {
+  S1 s1;
+  S2 s2;
+}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/pack1/S1.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/pack1/S1.java
new file mode 100644 (file)
index 0000000..c6942e2
--- /dev/null
@@ -0,0 +1,7 @@
+package pack1;
+
+public class S1{
+  S11 s11;
+}
+
+class S11{}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/pack1/US.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/pack1/US.java
new file mode 100644 (file)
index 0000000..b4f7dc8
--- /dev/null
@@ -0,0 +1,5 @@
+package pack1;
+
+class US {
+  S11 myS11WithoutImport;
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/pack2/UsagesFromBoth.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/pack2/UsagesFromBoth.java
new file mode 100644 (file)
index 0000000..906b1fe
--- /dev/null
@@ -0,0 +1,8 @@
+package pack2;
+
+import pack1.*;
+
+public class UsagesFromBoth {
+  S1 s1;
+  S2 s2;
+}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/target/empty.txt b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src1/target/empty.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src2/pack1/S2.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src2/pack1/S2.java
new file mode 100644 (file)
index 0000000..0bd2d20
--- /dev/null
@@ -0,0 +1,3 @@
+package pack1;
+
+public class S2{}
diff --git a/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src2/pack2/UsagesFromBoth2.java b/java/java-tests/testData/refactoring/movePackageAsDir/multipleClassesInOneFile/before/src2/pack2/UsagesFromBoth2.java
new file mode 100644 (file)
index 0000000..d8ece1c
--- /dev/null
@@ -0,0 +1,8 @@
+package pack2;
+
+import pack1.*;
+
+public class UsagesFromBoth2 {
+  S1 s1;
+  S2 s2;
+}
index fdd9074160d6062a9b65723271e40a7779e14130..a9f2a630c64f23fb3165c4a38189c13ed94f2072 100644 (file)
@@ -31,6 +31,15 @@ public class MovePackageAsDirectoryTest extends MultiFileTestCase {
     doTest(createAction("pack1", "target"));
   }
 
+  public void testMovePackageWithTxtFilesInside() throws Exception {
+    doTest(createAction("pack1", "target"));
+  }
+
+  public void testMultipleClassesInOneFile() throws Exception {
+    doTest(createAction("pack1", "target"));
+  }
+
+
   public void testRemoveUnresolvedImports() throws Exception {
     doTest(createAction("pack1", "target"));
   }
diff --git a/platform/icons/src/debugger/db_muted_breakpoint.png b/platform/icons/src/debugger/db_muted_breakpoint.png
new file mode 100644 (file)
index 0000000..4b3335e
Binary files /dev/null and b/platform/icons/src/debugger/db_muted_breakpoint.png differ
diff --git a/platform/icons/src/debugger/db_muted_exception_breakpoint.png b/platform/icons/src/debugger/db_muted_exception_breakpoint.png
new file mode 100644 (file)
index 0000000..49a9c13
Binary files /dev/null and b/platform/icons/src/debugger/db_muted_exception_breakpoint.png differ
diff --git a/platform/icons/src/debugger/db_muted_field_breakpoint.png b/platform/icons/src/debugger/db_muted_field_breakpoint.png
new file mode 100644 (file)
index 0000000..982c571
Binary files /dev/null and b/platform/icons/src/debugger/db_muted_field_breakpoint.png differ
diff --git a/platform/icons/src/debugger/db_muted_method_breakpoint.png b/platform/icons/src/debugger/db_muted_method_breakpoint.png
new file mode 100644 (file)
index 0000000..8b2d6a5
Binary files /dev/null and b/platform/icons/src/debugger/db_muted_method_breakpoint.png differ
index 3d4c8a24acfc0f0972a6b36bcf93ac677a597a9d..73ef4db5e5c8fbecdff9e6f036d72483e1ce8976 100644 (file)
@@ -31,7 +31,7 @@ import java.util.ArrayList;
  */
 public abstract class LanguageCodeStyleSettingsProvider {
   public enum SettingsType {
-    BLANK_LINE_SETTINGS, INDENT_AND_BRACES_SETTINGS, SPACING_SETTINGS
+    BLANK_LINE_SETTINGS, INDENT_AND_BRACES_SETTINGS, SPACING_SETTINGS, WRAPPING_SETTINGS
   }
   
   public static final ExtensionPointName<LanguageCodeStyleSettingsProvider> EP_NAME =
index 81033bd734561e97beea28c11fc185ba3559feca..4652052bc886ab532afdb1a3f71a4cd64463f300 100644 (file)
@@ -43,6 +43,8 @@ import com.intellij.util.LocalTimeCounter;
 import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import java.awt.*;
@@ -55,14 +57,19 @@ import java.io.File;
  */
 public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstractPanel {
 
-  private Language myLanguage;
+  private static Language myLanguage;
   private static final Logger LOG = Logger.getInstance("#com.intellij.application.options.codeStyle.MultilanguageCodeStyleAbstractPanel");
   private static Project mySettingsProject;
   private static int myInstanceCount;
   private int myLangSelectionIndex;
+  private JTabbedPane tabbedPane;
 
   protected MultilanguageCodeStyleAbstractPanel(CodeStyleSettings settings) {
     super(settings);
+    initProject();
+  }
+
+  private synchronized static void initProject() {
     createSettingsProject();
     myInstanceCount++;
   }
@@ -191,7 +198,7 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr
 
   @Override
   protected void installPreviewPanel(final JPanel previewPanel) {
-    JTabbedPane tabbedPane = new JTabbedPane();
+    tabbedPane = new JTabbedPane();
     tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
     Language[] langs = LanguageCodeStyleSettingsProvider.getLanguagesWithCodeStyleSettings();
     if (langs.length == 0) return;
@@ -200,13 +207,40 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr
     }
     tabbedPane.setComponentAt(0, getEditor().getComponent());
     myLangSelectionIndex = 0;
-    setLanguage(langs[0]);
+    if (myLanguage == null) {
+      setLanguage(langs[0]);
+    }
+    else {
+      updatePreviewEditor();
+    }
     tabbedPane.addChangeListener(new ChangeListener() {
       public void stateChanged(ChangeEvent e) {
         onTabSelection((JTabbedPane)e.getSource());        
       }
     });
     previewPanel.add(tabbedPane, BorderLayout.CENTER);
+    previewPanel.addAncestorListener(new AncestorListener(){
+      public void ancestorAdded(AncestorEvent event) {
+        selectCurrentLanguageTab();
+      }
+
+      public void ancestorRemoved(AncestorEvent event) {
+        // Do nothing
+      }
+
+      public void ancestorMoved(AncestorEvent event) {
+        // Do nothing
+      }
+    });
+  }
+
+  private void selectCurrentLanguageTab() {
+    for(int i = 0; i < tabbedPane.getTabCount(); i ++) {
+      if (myLanguage.getDisplayName().equals(tabbedPane.getTitleAt(i))) {
+        tabbedPane.setSelectedIndex(i);
+        return;
+      }
+    }
   }
 
 
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTableWithPreviewPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/OptionTableWithPreviewPanel.java
new file mode 100644 (file)
index 0000000..a3a1287
--- /dev/null
@@ -0,0 +1,578 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.application.options.codeStyle;
+
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.ui.ScrollPaneFactory;
+import com.intellij.ui.treeStructure.treetable.ListTreeTableModel;
+import com.intellij.ui.treeStructure.treetable.TreeTable;
+import com.intellij.ui.treeStructure.treetable.TreeTableCellRenderer;
+import com.intellij.ui.treeStructure.treetable.TreeTableModel;
+import com.intellij.util.containers.HashMap;
+import com.intellij.util.ui.AbstractTableCellEditor;
+import com.intellij.util.ui.ColumnInfo;
+import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NonNls;
+
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.tree.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * @author max
+ */
+public abstract class OptionTableWithPreviewPanel extends MultilanguageCodeStyleAbstractPanel {
+  private static final Logger LOG = Logger.getInstance("#com.intellij.application.options.CodeStyleSpacesPanel");
+
+  @SuppressWarnings({"HardCodedStringLiteral"})
+  public final ColumnInfo TITLE = new ColumnInfo("TITLE") {
+    public Object valueOf(Object o) {
+      if (o instanceof MyTreeNode) {
+        MyTreeNode node = (MyTreeNode)o;
+        return node.getText();
+      }
+      return o.toString();
+    }
+
+    public Class getColumnClass() {
+      return TreeTableModel.class;
+    }
+  };
+
+  @SuppressWarnings({"HardCodedStringLiteral"})
+  public final ColumnInfo VALUE = new ColumnInfo("VALUE") {
+    private final TableCellEditor myEditor = new MyValueEditor();
+    private final TableCellRenderer myRenderer = new MyValueRenderer();
+
+    public Object valueOf(Object o) {
+      if (o instanceof MyTreeNode) {
+        MyTreeNode node = (MyTreeNode)o;
+        return node.getValue();
+      }
+
+      return null;
+    }
+
+    public TableCellRenderer getRenderer(Object o) {
+      return myRenderer;
+    }
+
+    public TableCellEditor getEditor(Object item) {
+      return myEditor;
+    }
+
+    public boolean isCellEditable(Object o) {
+      return o instanceof MyTreeNode;
+    }
+
+    public void setValue(Object o, Object o1) {
+      MyTreeNode node = (MyTreeNode)o;
+      node.setValue(o1);
+    }
+  };
+
+  public final ColumnInfo[] COLUMNS = new ColumnInfo[]{TITLE, VALUE};
+
+  private final TreeCellRenderer myTitleRenderer = new TreeCellRenderer() {
+    private final JLabel myLabel = new JLabel();
+
+    public Component getTreeCellRendererComponent(JTree tree,
+                                                  Object value,
+                                                  boolean selected,
+                                                  boolean expanded,
+                                                  boolean leaf,
+                                                  int row,
+                                                  boolean hasFocus) {
+      if (value instanceof MyTreeNode) {
+        MyTreeNode node = (MyTreeNode)value;
+        myLabel.setText(node.getText());
+        myLabel.setFont(
+          myLabel.getFont().deriveFont(node.getKey() instanceof IntSelectionOptionKey ? Font.BOLD : Font.PLAIN));
+      }
+      else {
+        myLabel.setText(value.toString());
+        myLabel.setFont(myLabel.getFont().deriveFont(Font.BOLD));
+      }
+
+      Color foreground = selected
+                         ? UIUtil.getTableSelectionForeground()
+                         : UIUtil.getTableForeground();
+      myLabel.setForeground(foreground);
+
+      return myLabel;
+    }
+  };
+
+  private final TreeTable myTreeTable;
+  private final HashMap myKeyToFieldMap = new HashMap();
+  private final ArrayList myKeys = new ArrayList();
+
+  private final JPanel myPanel = new JPanel();
+
+  public OptionTableWithPreviewPanel(CodeStyleSettings settings) {
+    super(settings);
+    myPanel.setLayout(new GridBagLayout());
+
+    initTables();
+
+    myTreeTable = createOptionsTree(settings);
+    myPanel.add(ScrollPaneFactory.createScrollPane(myTreeTable),
+                new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH,
+                                       new Insets(7, 7, 3, 4), 0, 0));
+
+    final JPanel previewPanel = createPreviewPanel();
+    myPanel.add(previewPanel,
+                new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH,
+                                       new Insets(0, 0, 0, 4), 0, 0));
+
+    installPreviewPanel(previewPanel);
+    addPanelToWatch(myPanel);
+
+  }
+
+
+  protected TreeTable createOptionsTree(CodeStyleSettings settings) {
+    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
+    String groupName = "";
+    DefaultMutableTreeNode groupNode = null;
+    for (int i = 0; i < myKeys.size(); i++) {
+      if (myKeys.get(i) instanceof BooleanOptionKey) {
+        BooleanOptionKey key = (BooleanOptionKey)myKeys.get(i);
+        String newGroupName = key.groupName;
+        if (!newGroupName.equals(groupName) || groupNode == null) {
+          groupName = newGroupName;
+          groupNode = new DefaultMutableTreeNode(newGroupName);
+          rootNode.add(groupNode);
+        }
+        groupNode.add(new MyTreeNode(key, key.cbName, settings));
+      }
+      else if (myKeys.get(i) instanceof IntSelectionOptionKey) {
+        IntSelectionOptionKey key = (IntSelectionOptionKey)myKeys.get(i);
+        String newGroupName = key.groupName;
+        if (!newGroupName.equals(groupName) || groupNode == null) {
+          groupName = newGroupName;
+          groupNode = new MyTreeNode(key, key.groupName, settings);
+          rootNode.add(groupNode);
+        }
+        else {
+          LOG.assertTrue(false);
+        }
+      }
+    }
+
+    ListTreeTableModel model = new ListTreeTableModel(rootNode, COLUMNS);
+    TreeTable treeTable = new TreeTable(model) {
+      public TreeTableCellRenderer createTableRenderer(TreeTableModel treeTableModel) {
+        TreeTableCellRenderer tableRenderer = super.createTableRenderer(treeTableModel);
+        UIUtil.setLineStyleAngled(tableRenderer);
+        tableRenderer.setRootVisible(false);
+        tableRenderer.setShowsRootHandles(true);
+
+        return tableRenderer;
+      }
+
+      public TableCellRenderer getCellRenderer(int row, int column) {
+        TreePath treePath = getTree().getPathForRow(row);
+        if (treePath == null) return super.getCellRenderer(row, column);
+
+        Object node = treePath.getLastPathComponent();
+
+        TableCellRenderer renderer = COLUMNS[column].getRenderer(node);
+        return renderer == null ? super.getCellRenderer(row, column) : renderer;
+      }
+
+      public TableCellEditor getCellEditor(int row, int column) {
+        TreePath treePath = getTree().getPathForRow(row);
+        if (treePath == null) return super.getCellEditor(row, column);
+
+        Object node = treePath.getLastPathComponent();
+        TableCellEditor editor = COLUMNS[column].getEditor(node);
+        return editor == null ? super.getCellEditor(row, column) : editor;
+      }
+    };
+
+    treeTable.setRootVisible(false);
+
+    final JTree tree = treeTable.getTree();
+    tree.setCellRenderer(myTitleRenderer);
+    tree.setShowsRootHandles(true);
+    //myTreeTable.setRowHeight(new JComboBox(new String[]{"Sample Text"}).getPreferredSize().height);
+    treeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+    treeTable.setTableHeader(null);
+
+    expandTree(tree);
+
+    int maxWidth = tree.getPreferredScrollableViewportSize().width + 10;
+    final TableColumn titleColumn = treeTable.getColumnModel().getColumn(0);
+    titleColumn.setPreferredWidth(maxWidth);
+    titleColumn.setMinWidth(maxWidth);
+    titleColumn.setMaxWidth(maxWidth);
+    titleColumn.setResizable(false);
+
+    final TableColumn levelColumn = treeTable.getColumnModel().getColumn(1);
+    //TODO[max]: better preffered size...
+    JLabel value = new JLabel(ApplicationBundle.message("option.table.sizing.text"));
+    final Dimension valueSize = value.getPreferredSize();
+    levelColumn.setPreferredWidth(valueSize.width);
+    levelColumn.setMaxWidth(valueSize.width);
+    levelColumn.setMinWidth(valueSize.width);
+    levelColumn.setResizable(false);
+
+    treeTable.setPreferredScrollableViewportSize(new Dimension(maxWidth + valueSize.width + 10, 20));
+
+    return treeTable;
+  }
+
+  private void expandTree(final JTree tree) {
+    int oldRowCount = 0;
+    do {
+      int rowCount = tree.getRowCount();
+      if (rowCount == oldRowCount) break;
+      oldRowCount = rowCount;
+      for (int i = 0; i < rowCount; i++) {
+        tree.expandRow(i);
+      }
+    }
+    while (true);
+  }
+
+  protected abstract void initTables();
+
+  private void resetNode(TreeNode node, CodeStyleSettings settings) {
+    if (node instanceof MyTreeNode) {
+      ((MyTreeNode)node).reset(settings);
+    }
+    for (int j = 0; j < node.getChildCount(); j++) {
+      TreeNode child = node.getChildAt(j);
+      resetNode(child, settings);
+    }
+  }
+
+  private void applyNode(TreeNode node, final CodeStyleSettings settings) {
+    if (node instanceof MyTreeNode) {
+      ((MyTreeNode)node).apply(settings);
+    }
+    for (int j = 0; j < node.getChildCount(); j++) {
+      TreeNode child = node.getChildAt(j);
+      applyNode(child, settings);
+    }
+  }
+
+  private boolean isModified(TreeNode node, final CodeStyleSettings settings) {
+    if (node instanceof MyTreeNode) {
+      if (((MyTreeNode)node).isModified(settings)) return true;
+    }
+    for (int j = 0; j < node.getChildCount(); j++) {
+      TreeNode child = node.getChildAt(j);
+      if (isModified(child, settings)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  protected void initBooleanField(@NonNls String fieldName, String cbName, String groupName) {
+    try {
+      Class styleSettingsClass = CodeStyleSettings.class;
+      Field field = styleSettingsClass.getField(fieldName);
+      BooleanOptionKey key = new BooleanOptionKey(groupName, cbName);
+      myKeyToFieldMap.put(key, field);
+      myKeys.add(key);
+    }
+    catch (NoSuchFieldException e) {
+    }
+    catch (SecurityException e) {
+    }
+  }
+
+  protected void initRadioGroupField(@NonNls String fieldName, String groupName, String[] rbNames, int[] values) {
+    try {
+      Class styleSettingsClass = CodeStyleSettings.class;
+      Field field = styleSettingsClass.getField(fieldName);
+      IntSelectionOptionKey key = new IntSelectionOptionKey(groupName, rbNames, values);
+      myKeyToFieldMap.put(key, field);
+      myKeys.add(key);
+    }
+    catch (NoSuchFieldException e) {
+    }
+    catch (SecurityException e) {
+    }
+  }
+
+  protected void prepareForReformat(final PsiFile psiFile) {
+    //
+  }
+
+  private static class BooleanOptionKey {
+    final String groupName;
+    final String cbName;
+
+    public BooleanOptionKey(String groupName, String cbName) {
+      this.groupName = groupName;
+      this.cbName = cbName;
+    }
+
+    public boolean equals(Object obj) {
+      if (!(obj instanceof BooleanOptionKey)) return false;
+      BooleanOptionKey key = (BooleanOptionKey)obj;
+      return groupName.equals(key.groupName) && cbName.equals(key.cbName);
+    }
+
+    public int hashCode() {
+      return cbName.hashCode();
+    }
+  }
+
+  private static class IntSelectionOptionKey {
+    final String groupName;
+    final String[] rbNames;
+    final int[] values;
+
+    public IntSelectionOptionKey(String groupName, String[] rbNames, int[] values) {
+      this.groupName = groupName;
+      this.rbNames = rbNames;
+      this.values = values;
+    }
+
+    public boolean equals(Object o) {
+      if (this == o) return true;
+      if (!(o instanceof IntSelectionOptionKey)) return false;
+
+      final IntSelectionOptionKey intSelectionOptionKey = (IntSelectionOptionKey)o;
+
+      if (!groupName.equals(intSelectionOptionKey.groupName)) return false;
+      if (!Arrays.equals(rbNames, intSelectionOptionKey.rbNames)) return false;
+
+      return true;
+    }
+
+    public int hashCode() {
+      return groupName.hashCode() + rbNames[0].hashCode() * 29;
+    }
+  }
+
+  private Object getSettingsValue(Object key, final CodeStyleSettings settings) {
+    try {
+      if (key instanceof BooleanOptionKey) {
+        Field field = (Field)myKeyToFieldMap.get(key);
+        return field.getBoolean(settings) ? Boolean.TRUE : Boolean.FALSE;
+      }
+      else if (key instanceof IntSelectionOptionKey) {
+        Field field = (Field)myKeyToFieldMap.get(key);
+        IntSelectionOptionKey intKey = (IntSelectionOptionKey)key;
+        int[] values = intKey.values;
+        int value = field.getInt(settings);
+        for (int i = 0; i < values.length; i++) {
+          if (values[i] == value) return intKey.rbNames[i];
+        }
+      }
+    }
+    catch (IllegalAccessException e) {
+    }
+
+    return null;
+  }
+
+  public void setSettingsValue(Object key, Object value, final CodeStyleSettings settings) {
+    try {
+      if (key instanceof BooleanOptionKey) {
+        Field field = (Field)myKeyToFieldMap.get(key);
+        field.setBoolean(settings, ((Boolean)value).booleanValue());
+      }
+      else if (key instanceof IntSelectionOptionKey) {
+        Field field = (Field)myKeyToFieldMap.get(key);
+        IntSelectionOptionKey intKey = (IntSelectionOptionKey)key;
+        int[] values = intKey.values;
+        for (int i = 0; i < values.length; i++) {
+          if (intKey.rbNames[i].equals(value)) {
+            field.setInt(settings, values[i]);
+            return;
+          }
+        }
+      }
+    }
+    catch (IllegalAccessException e) {
+    }
+  }
+
+  private class MyTreeNode extends DefaultMutableTreeNode {
+    private final Object myKey;
+    private final String myText;
+    private Object myValue;
+
+    public MyTreeNode(Object key, String text, CodeStyleSettings settings) {
+      myKey = key;
+      myText = text;
+      myValue = getSettingsValue(key, settings);
+    }
+
+    public Object getKey() { return myKey; }
+
+    public String getText() { return myText; }
+
+    public Object getValue() { return myValue; }
+
+    public void setValue(Object value) {
+      myValue = value;
+    }
+
+    public void reset(CodeStyleSettings settings) {
+      setValue(getSettingsValue(myKey, settings));
+    }
+
+    public boolean isModified(final CodeStyleSettings settings) {
+      return !myValue.equals(getSettingsValue(myKey, settings));
+    }
+
+    public void apply(final CodeStyleSettings settings) {
+      setSettingsValue(myKey, myValue, settings);
+    }
+  }
+
+  private class MyValueRenderer implements TableCellRenderer {
+    private final JLabel myComboBox = new JLabel();
+    private final JCheckBox myCheckBox = new JCheckBox();
+    private final JPanel myEmptyLabel = new JPanel();
+
+    public Component getTableCellRendererComponent(JTable table,
+                                                   Object value,
+                                                   boolean isSelected,
+                                                   boolean hasFocus,
+                                                   int row,
+                                                   int column) {
+      Color background = table.getBackground();
+      if (value instanceof Boolean) {
+        myCheckBox.setSelected(((Boolean)value).booleanValue());
+        myCheckBox.setBackground(background);
+        return myCheckBox;
+      }
+      else if (value instanceof String) {
+        /*
+        myComboBox.removeAllItems();
+        myComboBox.addItem(value);
+        */
+        myComboBox.setText((String)value);
+        myComboBox.setBackground(background);
+        return myComboBox;
+      }
+
+      myCheckBox.putClientProperty("JComponent.sizeVariant", "small");
+      myComboBox.putClientProperty("JComponent.sizeVariant", "small");
+
+      myEmptyLabel.setBackground(background);
+      return myEmptyLabel;
+    }
+  }
+
+  private class MyValueEditor extends AbstractTableCellEditor {
+    private final JComboBox myComboBox = new JComboBox();
+    private final JCheckBox myCheckBox = new JCheckBox();
+    private Component myCurrentEditor = null;
+    private MyTreeNode myCurrentNode = null;
+
+    public MyValueEditor() {
+      ActionListener synchronizer = new ActionListener() {
+        public void actionPerformed(ActionEvent e) {
+          if (myCurrentNode != null) {
+            myCurrentNode.setValue(getCellEditorValue());
+          }
+        }
+      };
+      myComboBox.addActionListener(synchronizer);
+      myCheckBox.addActionListener(synchronizer);
+
+      myComboBox.putClientProperty("JComponent.sizeVariant", "small");
+      myCheckBox.putClientProperty("JComponent.sizeVariant", "small");
+    }
+
+    public Object getCellEditorValue() {
+      if (myCurrentEditor == myComboBox) {
+        return myComboBox.getSelectedItem();
+      }
+      else if (myCurrentEditor == myCheckBox) {
+        return myCheckBox.isSelected() ? Boolean.TRUE : Boolean.FALSE;
+      }
+
+      return null;
+    }
+
+    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+      final DefaultMutableTreeNode defaultNode = (DefaultMutableTreeNode)((TreeTable)table).getTree().
+        getPathForRow(row).getLastPathComponent();
+      myCurrentEditor = null;
+      myCurrentNode = null;
+      if (defaultNode instanceof MyTreeNode) {
+        MyTreeNode node = (MyTreeNode)defaultNode;
+        if (node.getKey() instanceof BooleanOptionKey) {
+          myCurrentEditor = myCheckBox;
+          myCheckBox.setSelected(node.getValue() == Boolean.TRUE);
+        }
+        else {
+          myCurrentEditor = myComboBox;
+          myComboBox.removeAllItems();
+          IntSelectionOptionKey key = (IntSelectionOptionKey)node.getKey();
+          String[] values = key.rbNames;
+          for (int i = 0; i < values.length; i++) {
+            myComboBox.addItem(values[i]);
+          }
+          myComboBox.setSelectedItem(node.getValue());
+        }
+        myCurrentNode = node;
+      }
+
+      myCurrentEditor.setBackground(table.getBackground());
+
+      return myCurrentEditor;
+    }
+  }
+
+  public void apply(CodeStyleSettings settings) {
+    TreeModel treeModel = myTreeTable.getTree().getModel();
+    TreeNode root = (TreeNode)treeModel.getRoot();
+    applyNode(root, settings);
+  }
+
+  public boolean isModified(CodeStyleSettings settings) {
+    TreeModel treeModel = myTreeTable.getTree().getModel();
+    TreeNode root = (TreeNode)treeModel.getRoot();
+    if (isModified(root, settings)) {
+      return true;
+    }
+    return false;
+  }
+
+  public JComponent getPanel() {
+    return myPanel;
+  }
+
+  protected void resetImpl(final CodeStyleSettings settings) {
+    TreeModel treeModel = myTreeTable.getTree().getModel();
+    TreeNode root = (TreeNode)treeModel.getRoot();
+    resetNode(root, settings);
+  }
+
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingConfigurable.java
new file mode 100644 (file)
index 0000000..406511e
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.application.options.codeStyle;
+
+import com.intellij.application.options.CodeStyleAbstractConfigurable;
+import com.intellij.application.options.CodeStyleAbstractPanel;
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.fileTypes.StdFileTypes;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+
+import javax.swing.*;
+
+public class WrappingConfigurable extends CodeStyleAbstractConfigurable {
+  public WrappingConfigurable(CodeStyleSettings settings, CodeStyleSettings cloneSettings) {
+    super(settings, cloneSettings, ApplicationBundle.message("title.wrapping"));
+  }
+
+  public Icon getIcon() {
+    return StdFileTypes.JAVA.getIcon();
+  }
+
+  protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) {
+    return new WrappingPanel(settings);
+  }
+
+  public String getHelpTopic() {
+    return "reference.settingsdialog.IDE.globalcodestyle.wrap";
+  }
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingPanel.java
new file mode 100644 (file)
index 0000000..7b0bc31
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.application.options.codeStyle;
+
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+
+/**
+ * @author max
+ */
+public class WrappingPanel extends OptionTableWithPreviewPanel {
+  private static final String METHOD_PARAMETERS_WRAPPING = ApplicationBundle.message("combobox.wrap.method.declaration.parameters");
+  private static final String CALL_PARAMETERS_WRAPPING = ApplicationBundle.message("combobox.wrap.method.call.arguments");
+  private static final String CALL_CHAIN_WRAPPING = ApplicationBundle.message("combobox.wrap.chained.method.calls");
+  private static final String FOR_STATEMENT_WRAPPING = ApplicationBundle.message("combobox.wrap.for.statement");
+  private static final String BINARY_OPERATION_WRAPPING = ApplicationBundle.message("combobox.wrap.binary.operations");
+  private static final String[] FULL_WRAP_OPTIONS = new String[] {
+    ApplicationBundle.message("combobox.codestyle.do.not.wrap"),
+    ApplicationBundle.message("combobox.codestyle.wrap.if.long"),
+    ApplicationBundle.message("combobox.codestyle.chop.down.if.long"),
+    ApplicationBundle.message("combobox.codestyle.wrap.always")
+  };
+  private static final String[] SINGLE_ITEM_WRAP_OPTIONS = new String[]{
+    ApplicationBundle.message("combobox.codestyle.do.not.wrap"),
+    ApplicationBundle.message("combobox.codestyle.wrap.if.long"),
+    ApplicationBundle.message("combobox.codestyle.wrap.always")
+  };
+  private static final int[] FULL_WRAP_VALUES = new int[]{CodeStyleSettings.DO_NOT_WRAP,
+                                                          CodeStyleSettings.WRAP_AS_NEEDED,
+                                                          CodeStyleSettings.WRAP_AS_NEEDED |
+                                                          CodeStyleSettings.WRAP_ON_EVERY_ITEM,
+                                                          CodeStyleSettings.WRAP_ALWAYS};
+  private static final int[] SINGLE_ITEM_WRAP_VALUES = new int[]{CodeStyleSettings.DO_NOT_WRAP,
+                                                                 CodeStyleSettings.WRAP_AS_NEEDED,
+                                                                 CodeStyleSettings.WRAP_ALWAYS};
+  private static final String EXTENDS_LIST_WRAPPING = ApplicationBundle.message("combobox.wrap.extends.implements.list");
+  private static final String EXTENDS_KEYWORD_WRAPPING = ApplicationBundle.message("combobox.wrap.extends.implements.keyword");
+  private static final String THROWS_LIST_WRAPPING = ApplicationBundle.message("combobox.wrap.throws.list");
+  private static final String THROWS_KEYWORD_WRAPPING = ApplicationBundle.message("combobox.wrap.throws.keyword");
+  private static final String PARENTHESIZED_EXPRESSION = ApplicationBundle.message("combobox.wrap.parenthesized.expression");
+  private static final String TERNARY_OPERATION_WRAPPING = ApplicationBundle.message("combobox.wrap.ternary.operation");
+  private static final String ASSIGNMENT_WRAPPING = ApplicationBundle.message("combobox.wrap.assignment.statement");
+  private static final String ARRAY_INITIALIZER_WRAPPING = ApplicationBundle.message("combobox.wrap.array.initializer");
+  private static final String LABELED_STATEMENT_WRAPPING = ApplicationBundle.message("combobox.wrap.label.declaration");
+  private static final String MODIFIER_LIST_WRAPPING = ApplicationBundle.message("combobox.wrap.modifier.list");
+  private static final String ASSERT_STATEMENT_WRAPPING = ApplicationBundle.message("combobox.wrap.assert.statement");
+
+  public WrappingPanel(CodeStyleSettings settings) {
+    super(settings);
+  }
+
+  @Override
+  protected LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
+    return LanguageCodeStyleSettingsProvider.SettingsType.WRAPPING_SETTINGS;
+  }
+
+  protected void initTables() {
+    initRadioGroupField("EXTENDS_LIST_WRAP", EXTENDS_LIST_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initRadioGroupField("EXTENDS_KEYWORD_WRAP", EXTENDS_KEYWORD_WRAPPING, SINGLE_ITEM_WRAP_OPTIONS,
+                        SINGLE_ITEM_WRAP_VALUES);
+
+    initRadioGroupField("METHOD_PARAMETERS_WRAP", METHOD_PARAMETERS_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initBooleanField("METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.new.line.after.lpar"), METHOD_PARAMETERS_WRAPPING);
+    initBooleanField("METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.place.rpar.on.new.line"), METHOD_PARAMETERS_WRAPPING);
+
+    initRadioGroupField("THROWS_LIST_WRAP", THROWS_LIST_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initRadioGroupField("THROWS_KEYWORD_WRAP", THROWS_KEYWORD_WRAPPING, SINGLE_ITEM_WRAP_OPTIONS,
+                        SINGLE_ITEM_WRAP_VALUES);
+
+    initRadioGroupField("CALL_PARAMETERS_WRAP", CALL_PARAMETERS_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initBooleanField("PREFER_PARAMETERS_WRAP", ApplicationBundle.message("checkbox.wrap.take.priority.over.call.chain.wrapping"), CALL_PARAMETERS_WRAPPING);
+    initBooleanField("CALL_PARAMETERS_LPAREN_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.new.line.after.lpar"), CALL_PARAMETERS_WRAPPING);
+    initBooleanField("CALL_PARAMETERS_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.place.rpar.on.new.line"), CALL_PARAMETERS_WRAPPING);
+
+    initRadioGroupField("METHOD_CALL_CHAIN_WRAP", CALL_CHAIN_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+
+    initRadioGroupField("FOR_STATEMENT_WRAP", FOR_STATEMENT_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initBooleanField("FOR_STATEMENT_LPAREN_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.new.line.after.lpar"), FOR_STATEMENT_WRAPPING);
+    initBooleanField("FOR_STATEMENT_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.place.rpar.on.new.line"), FOR_STATEMENT_WRAPPING);
+
+    initRadioGroupField("BINARY_OPERATION_WRAP", BINARY_OPERATION_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initBooleanField("BINARY_OPERATION_SIGN_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.operation.sign.on.next.line"), BINARY_OPERATION_WRAPPING);
+
+    initRadioGroupField("ASSIGNMENT_WRAP", ASSIGNMENT_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initBooleanField("PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.assignment.sign.on.next.line"), ASSIGNMENT_WRAPPING);
+
+    initRadioGroupField("TERNARY_OPERATION_WRAP", TERNARY_OPERATION_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initBooleanField("TERNARY_OPERATION_SIGNS_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.quest.and.colon.signs.on.next.line"),
+                     TERNARY_OPERATION_WRAPPING);
+
+    initBooleanField("PARENTHESES_EXPRESSION_LPAREN_WRAP", ApplicationBundle.message("checkbox.wrap.new.line.after.lpar"), PARENTHESIZED_EXPRESSION);
+    initBooleanField("PARENTHESES_EXPRESSION_RPAREN_WRAP", ApplicationBundle.message("checkbox.wrap.place.rpar.on.new.line"), PARENTHESIZED_EXPRESSION);
+
+    initRadioGroupField("ARRAY_INITIALIZER_WRAP", ARRAY_INITIALIZER_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initBooleanField("ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.new.line.after.lbrace"), ARRAY_INITIALIZER_WRAPPING);
+    initBooleanField("ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.place.rbrace.on.new.line"), ARRAY_INITIALIZER_WRAPPING);
+
+    initRadioGroupField("LABELED_STATEMENT_WRAP", LABELED_STATEMENT_WRAPPING, SINGLE_ITEM_WRAP_OPTIONS, SINGLE_ITEM_WRAP_VALUES);
+
+    initBooleanField("MODIFIER_LIST_WRAP", ApplicationBundle.message("checkbox.wrap.after.modifier.list"), MODIFIER_LIST_WRAPPING);
+
+    initRadioGroupField("ASSERT_STATEMENT_WRAP", ASSERT_STATEMENT_WRAPPING, FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initBooleanField("ASSERT_STATEMENT_COLON_ON_NEXT_LINE", ApplicationBundle.message("checkbox.wrap.colon.signs.on.next.line"), ASSERT_STATEMENT_WRAPPING);
+
+    initRadioGroupField("CLASS_ANNOTATION_WRAP", ApplicationBundle.message("checkbox.wrap.classes.annotation"), FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initRadioGroupField("METHOD_ANNOTATION_WRAP", ApplicationBundle.message("checkbox.wrap.methods.annotation"), FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initRadioGroupField("FIELD_ANNOTATION_WRAP", ApplicationBundle.message("checkbox.wrap.fields.annotation"), FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initRadioGroupField("PARAMETER_ANNOTATION_WRAP", ApplicationBundle.message("checkbox.wrap.parameters.annotation"), FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initRadioGroupField("VARIABLE_ANNOTATION_WRAP", ApplicationBundle.message("checkbox.wrap.local.variables.annotation"), FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+    initRadioGroupField("ENUM_CONSTANTS_WRAP", ApplicationBundle.message("checkbox.wrap.enum.constants"), FULL_WRAP_OPTIONS, FULL_WRAP_VALUES);
+
+  }
+
+  protected int getRightMargin() {
+    return 37;
+  }
+
+}
\ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingSettingsProvider.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingSettingsProvider.java
new file mode 100644 (file)
index 0000000..b91de3e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.application.options.codeStyle;
+
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.options.Configurable;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.codeStyle.CodeStyleSettingsProvider;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author yole
+ */
+public class WrappingSettingsProvider extends CodeStyleSettingsProvider {
+  @NotNull
+  public Configurable createSettingsPage(final CodeStyleSettings settings, final CodeStyleSettings originalSettings) {
+    return new WrappingConfigurable(settings, originalSettings);
+  }
+
+  @Override
+  public String getConfigurableDisplayName() {
+    return ApplicationBundle.message("title.wrapping");
+  }
+}
\ No newline at end of file
index bc7f6008b0a3e62bbf6452bda27b57de5a67eb0e..de599decda28dfc78ccc16d4e31a7966626c35a1 100644 (file)
@@ -30,9 +30,7 @@ import com.intellij.util.containers.HashSet;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 /**
  * @author Eugene.Kudelevsky
@@ -82,14 +80,23 @@ public class CustomTemplateCallback {
   @Nullable
   public TemplateImpl findApplicableTemplate(@NotNull String key) {
     List<TemplateImpl> templates = getMatchingTemplates(key);
-    templates = TemplateManagerImpl.filterApplicableCandidates(myFile, myStartOffset, templates);
+    templates = filterApplicableCandidates(templates);
     return templates.size() > 0 ? templates.get(0) : null;
   }
 
+  private List<TemplateImpl> filterApplicableCandidates(Collection<TemplateImpl> candidates) {
+    List<TemplateImpl> result = new ArrayList<TemplateImpl>();
+    for (TemplateImpl candidate : candidates) {
+      if (TemplateManagerImpl.isApplicable(myFile, myStartOffset, candidate)) {
+        result.add(candidate);
+      }
+    }
+    return result;
+  }
 
   public boolean templateContainsVars(@NotNull String key, String... varNames) {
     List<TemplateImpl> templates = getMatchingTemplates(key);
-    templates = TemplateManagerImpl.filterApplicableCandidates(myFile, myStartOffset, templates);
+    templates = filterApplicableCandidates(templates);
     if (templates.size() == 0) {
       return false;
     }
@@ -114,9 +121,9 @@ public class CustomTemplateCallback {
   public boolean startTemplate(@NotNull String key,
                                Map<String, String> predefinedVarValues,
                                @Nullable TemplateInvokationListener listener) {
-    int caretOffset = myEditor.getCaretModel().getOffset();
+    //int caretOffset = myEditor.getCaretModel().getOffset();
     List<TemplateImpl> templates = getMatchingTemplates(key);
-    templates = TemplateManagerImpl.filterApplicableCandidates(myFile, caretOffset, templates);
+    templates = filterApplicableCandidates(templates);
     if (templates.size() > 0) {
       TemplateImpl template = templates.get(0);
       return startTemplate(template, predefinedVarValues, listener);
@@ -144,8 +151,7 @@ public class CustomTemplateCallback {
         ApplicationManager.getApplication().runWriteAction(new Runnable() {
           public void run() {
             if (brokenOff) {
-              CodeStyleManager style = CodeStyleManager.getInstance(myProject);
-              style.reformatText(myFile, myGlobalMarker.getStartOffset(), myGlobalMarker.getEndOffset());
+              reformat();
             }
           }
         });
@@ -155,6 +161,11 @@ public class CustomTemplateCallback {
           listener.finished(true);
         }
       }
+
+      @Override
+      public void waitingForInput(Template template) {
+        reformat();
+      }
     });
     templateEnded[0] = true;
     if (templateFinished[0] && listener != null) {
@@ -163,6 +174,11 @@ public class CustomTemplateCallback {
     return templateFinished[0];
   }
 
+  private void reformat() {
+    CodeStyleManager style = CodeStyleManager.getInstance(myProject);
+    style.reformatText(myFile, myGlobalMarker.getStartOffset(), myGlobalMarker.getEndOffset());
+  }
+
   public void fixStartOfTemplate(@NotNull Object key) {
     int offset = myEditor.getCaretModel().getOffset();
     RangeMarker marker = myEditor.getDocument().createRangeMarker(offset, offset);
@@ -200,7 +216,9 @@ public class CustomTemplateCallback {
   public void finish() {
     myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
     final CodeStyleManager style = CodeStyleManager.getInstance(myProject);
-    style.reformatText(myFile, myGlobalMarker.getStartOffset(), myGlobalMarker.getEndOffset());
+    if (myGlobalMarker != null) {
+      style.reformatText(myFile, myGlobalMarker.getStartOffset(), myGlobalMarker.getEndOffset());
+    }
     gotoEndOffset();
   }
 
index 743f8eb708f76a3b7d6090e3b5fe857f1674b3a9..ef899f1c5659620da16a7908f15bf3ed56613b65 100644 (file)
@@ -35,6 +35,6 @@ public abstract class TemplateEditingAdapter implements TemplateEditingListener
   public void currentVariableChanged(TemplateState templateState, Template template, int oldIndex, int newIndex) {
   }
 
-  public void templateExpanded(Template template) {
+  public void waitingForInput(Template template) {
   }
 }
index 73478f59a7eeafd990a32e4b0e6d4c796647c959..59ff3be18f905870707b7acd372e8a993b918fc5 100644 (file)
@@ -26,5 +26,5 @@ public interface TemplateEditingListener {
   void templateFinished(Template template, boolean brokenOff);
   void templateCancelled(Template template);
   void currentVariableChanged(TemplateState templateState, Template template, int oldIndex, int newIndex);
-  void templateExpanded(Template template);
+  void waitingForInput(Template template);
 }
index aff173c2b22433993241e2aab51a0eead452878b..40bcb468401be305022c14f2d88de8f88fe1869d 100644 (file)
@@ -220,40 +220,81 @@ public class TemplateManagerImpl extends TemplateManager implements ProjectCompo
     }
   }
 
+  private static boolean containsTemplateStartingBefore(Map<TemplateImpl, String> template2argument,
+                                                        int offset,
+                                                        int caretOffset,
+                                                        CharSequence text) {
+    for (TemplateImpl template : template2argument.keySet()) {
+      String argument = template2argument.get(template);
+      int templateStart = getTemplateStart(template, argument, caretOffset, text);
+      if (templateStart <= offset) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   public boolean startTemplate(final Editor editor, char shortcutChar, final PairProcessor<String, String> processor) {
     PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, myProject);
     if (file == null) return false;
     TemplateSettings templateSettings = TemplateSettings.getInstance();
+
+    Map<TemplateImpl, String> template2argument = findMatchingTemplates(file, editor, shortcutChar, templateSettings);
+
     if (shortcutChar == templateSettings.getDefaultShortcutChar()) {
       for (final CustomLiveTemplate customLiveTemplate : CustomLiveTemplate.EP_NAME.getExtensions()) {
         final CustomTemplateCallback callback = new CustomTemplateCallback(editor, file);
+        callback.fixInitialEditorState();
         String key = customLiveTemplate.computeTemplateKey(callback);
         if (key != null) {
-          int offset = callback.getEditor().getCaretModel().getOffset();
-          callback.getEditor().getDocument().deleteString(offset - key.length(), offset);
-          callback.fixInitialEditorState();
-          customLiveTemplate.execute(key, callback, new TemplateInvokationListener() {
-            public void finished(boolean inSeparateEvent) {
-              callback.finish();
-            }
-          });
-          return true;
+          int caretOffset = editor.getCaretModel().getOffset();
+          int offsetBeforeKey = caretOffset - key.length();
+          CharSequence text = editor.getDocument().getCharsSequence();
+          if (template2argument == null || !containsTemplateStartingBefore(template2argument, offsetBeforeKey, caretOffset, text)) {
+            callback.getEditor().getDocument().deleteString(offsetBeforeKey, caretOffset);
+            customLiveTemplate.execute(key, callback, new TemplateInvokationListener() {
+              public void finished(boolean inSeparateEvent) {
+                callback.finish();
+              }
+            });
+            return true;
+          }
         }
       }
     }
-    return startNonCustomTemplate(templateSettings, file, editor, shortcutChar, processor);
+    return startNonCustomTemplates(template2argument, editor, processor);
   }
 
-  private boolean startNonCustomTemplate(TemplateSettings templateSettings,
-                                         PsiFile file,
-                                         Editor editor,
-                                         char shortcutChar,
-                                         PairProcessor<String, String> processor) {
-    final Document document = editor.getDocument();
+  private static int getArgumentOffset(int caretOffset, String argument, CharSequence text) {
+    int argumentOffset = caretOffset - argument.length();
+    if (argumentOffset > 0 && text.charAt(argumentOffset - 1) == ' ') {
+      if (argumentOffset - 2 >= 0 && Character.isJavaIdentifierPart(text.charAt(argumentOffset - 2))) {
+        argumentOffset--;
+      }
+    }
+    return argumentOffset;
+  }
 
-    CharSequence text = document.getCharsSequence();
+  private static int getTemplateStart(TemplateImpl template, String argument, int caretOffset, CharSequence text) {
+    int templateStart;
+    if (argument == null) {
+      templateStart = caretOffset - template.getKey().length();
+    }
+    else {
+      int argOffset = getArgumentOffset(caretOffset, argument, text);
+      templateStart = argOffset - template.getKey().length();
+    }
+    return templateStart;
+  }
 
+  private Map<TemplateImpl, String> findMatchingTemplates(final PsiFile file,
+                                                          Editor editor,
+                                                          char shortcutChar,
+                                                          TemplateSettings templateSettings) {
+    final Document document = editor.getDocument();
+    CharSequence text = document.getCharsSequence();
     final int caretOffset = editor.getCaretModel().getOffset();
+
     List<TemplateImpl> candidatesWithoutArgument = findMatchingTemplates(text, caretOffset, shortcutChar, templateSettings, false);
 
     int argumentOffset = passArgumentBack(text, caretOffset);
@@ -268,7 +309,9 @@ public class TemplateManagerImpl extends TemplateManager implements ProjectCompo
     }
     List<TemplateImpl> candidatesWithArgument = findMatchingTemplates(text, argumentOffset, shortcutChar, templateSettings, true);
 
-    if (candidatesWithArgument.isEmpty() && candidatesWithoutArgument.isEmpty()) return false;
+    if (candidatesWithArgument.isEmpty() && candidatesWithoutArgument.isEmpty()) {
+      return null;
+    }
 
     CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
       public void run() {
@@ -281,27 +324,31 @@ public class TemplateManagerImpl extends TemplateManager implements ProjectCompo
     Map<TemplateImpl, String> candidate2Argument = new HashMap<TemplateImpl, String>();
     addToMap(candidate2Argument, candidatesWithoutArgument, null);
     addToMap(candidate2Argument, candidatesWithArgument, argument);
+    return candidate2Argument;
+  }
 
-    if (candidate2Argument.isEmpty()) {
+  private boolean startNonCustomTemplates(Map<TemplateImpl, String> template2argument,
+                                          Editor editor,
+                                          PairProcessor<String, String> processor) {
+    final int caretOffset = editor.getCaretModel().getOffset();
+    final Document document = editor.getDocument();
+    CharSequence text = document.getCharsSequence();
+
+    if (template2argument == null || template2argument.size() == 0) {
       return false;
     }
     if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), myProject)) {
       return false;
     }
 
-    if (candidate2Argument.size() == 1) {
-      TemplateImpl template = candidate2Argument.keySet().iterator().next();
-      if (candidatesWithoutArgument.size() == 1) {
-        int templateStart = caretOffset - template.getKey().length();
-        startTemplateWithPrefix(editor, template, templateStart, processor, null);
-      }
-      else {
-        int templateStart = argumentOffset - template.getKey().length();
-        startTemplateWithPrefix(editor, template, templateStart, processor, argument);
-      }
+    if (template2argument.size() == 1) {
+      TemplateImpl template = template2argument.keySet().iterator().next();
+      String argument = template2argument.get(template);
+      int templateStart = getTemplateStart(template, argument, caretOffset, text);
+      startTemplateWithPrefix(editor, template, templateStart, processor, argument);
     }
     else {
-      ListTemplatesHandler.showTemplatesLookup(myProject, editor, candidate2Argument);
+      ListTemplatesHandler.showTemplatesLookup(myProject, editor, template2argument);
     }
     return true;
   }
@@ -417,7 +464,7 @@ public class TemplateManagerImpl extends TemplateManager implements ProjectCompo
     return templateState != null ? templateState.getTemplate() : null;
   }
 
-  static boolean isApplicable(PsiFile file, int offset, TemplateImpl template) {
+  public static boolean isApplicable(PsiFile file, int offset, TemplateImpl template) {
     TemplateManager instance = getInstance(file.getProject());
     TemplateContext context = template.getTemplateContext();
     if (context.isEnabled(instance.getContextType(file, offset))) {
index e8f033dae0cac5232f24756c786510c89436d464..c074689f6a1609ba5552bc16a41e9c2e4091d4d7 100644 (file)
@@ -319,9 +319,12 @@ public class TemplateState implements Disposable {
         calcResults(false);  //Fixed SCR #[vk500] : all variables should be recalced twice on start.
         doReformat(null);
 
-        fireTemplateExpanded();
-
         int nextVariableNumber = getNextVariableNumber(-1);
+
+        if (nextVariableNumber >= 0) {
+          fireWaitingForInput();
+        }
+
         if (nextVariableNumber == -1) {
           finishTemplateEditing(false);
         }
@@ -1022,10 +1025,10 @@ public class TemplateState implements Disposable {
     }
   }
 
-  private void fireTemplateExpanded() {
+  private void fireWaitingForInput() {
     TemplateEditingListener[] listeners = myListeners.toArray(new TemplateEditingListener[myListeners.size()]);
     for (TemplateEditingListener listener : listeners) {
-      listener.templateExpanded(myTemplate);
+      listener.waitingForInput(myTemplate);
     }
   }
 
index 737be4900bf121ed69ade075724dfd7318cc1df8..14be608e3edb1749b5d8553376c67b6a7bc0e1b8 100644 (file)
@@ -651,7 +651,9 @@ public class ShowUsagesAction extends AnAction {
             // after new editor created, some editor resizing events are still bubbling. To prevent hiding hint, invokeLater this
             IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {
               public void run() {
-                showHint(hint, newEditor, popupPosition, handler, maxUsages);
+                if (newEditor.getComponent().isShowing()) {
+                  showHint(hint, newEditor, popupPosition, handler, maxUsages);
+                }
               }
             });
           }
index 13f9ba8205c451c7180433983b30ed5bbd79b479..b87b994a937deb5be28d434427d320af17052dbe 100644 (file)
@@ -26,6 +26,7 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.search.ProjectScope;
 import com.intellij.usageView.UsageViewUtil;
 import com.intellij.usages.impl.UsageViewImpl;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
@@ -42,6 +43,7 @@ public class ShowRecentFindUsagesGroup extends ActionGroup {
     e.getPresentation().setVisible(project != null);
   }
 
+  @NotNull
   public AnAction[] getChildren(@Nullable final AnActionEvent e) {
     if (e == null) return EMPTY_ARRAY;
     Project project = e.getData(PlatformDataKeys.PROJECT);
index 90c694c2ec3ed0cd9d0403cfaf5668568d971d1b..386c9276fe35c0d563aa84fdffc287c046b45c7c 100644 (file)
@@ -32,8 +32,10 @@ import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleUtil;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.openapi.wm.ToolWindow;
@@ -43,6 +45,8 @@ import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.util.Alarm;
 import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.update.MergingUpdateQueue;
+import com.intellij.util.ui.update.Update;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.Nullable;
 
@@ -63,7 +67,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
   private ModuleStructureComponent myModuleStructureComponent;
 
   private final JPanel myPanel;
-  private final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
+  private final MergingUpdateQueue myUpdateQueue;
   private final String myKey = new String("DATA_SELECTOR");
 
   // -------------------------------------------------------------------------
@@ -75,6 +79,9 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
     myPanel = new ContentPanel();
     myPanel.setBackground(UIUtil.getTreeTextBackground());
 
+    myUpdateQueue = new MergingUpdateQueue("StructureView", Registry.intValue("structureView.coalesceTime"), false, myPanel, this, myPanel, true);
+    myUpdateQueue.setRestartTimerOnAdd(true);
+
     ActionManager.getInstance().addTimerListener(500, new TimerListener() {
       public ModalityState getModalityState() {
         return ModalityState.stateForComponent(myPanel);
@@ -98,7 +105,7 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
     if (myProject.isDisposed()) return;
 
     final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
-    if (SwingUtilities.isDescendingFrom(myPanel, owner)) return;
+    if (SwingUtilities.isDescendingFrom(myPanel, owner) || JBPopupFactory.getInstance().isPopupActive()) return;
 
     final DataContext dataContext = DataManager.getInstance().getDataContext(owner);
     if (dataContext.getData(myKey) == this) return;
@@ -147,13 +154,12 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
   }
 
   private void scheduleRebuild() {
-    myUpdateAlarm.cancelAllRequests();
-    myUpdateAlarm.addRequest(new Runnable() {
+    myUpdateQueue.queue(new Update("rebuild") {
       public void run() {
         if (myProject.isDisposed()) return;
         rebuild();
       }
-    }, 300, ModalityState.stateForComponent(myPanel));
+    });
   }
 
   public void rebuild() {
index 47d0149adf64b9c6f3a4e26b95169d5dedcd2fe5..93fb914eb4a34e9060cc21727c283a5e3d605bb8 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.ide.structureView.ModelListener;
 import com.intellij.ide.structureView.StructureViewModel;
 import com.intellij.ide.util.treeView.*;
 import com.intellij.ide.util.treeView.smartTree.SmartTreeStructure;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.ide.CopyPasteManager;
 import com.intellij.openapi.progress.ProgressIndicator;
@@ -52,7 +53,7 @@ class StructureTreeBuilder extends AbstractTreeBuilder {
     super(
       tree,
       treeModel,
-      treeStructure, null
+      treeStructure, null, false
     );
 
     myProject = project;
@@ -70,6 +71,8 @@ class StructureTreeBuilder extends AbstractTreeBuilder {
     CopyPasteManager.getInstance().addContentChangedListener(myCopyPasteListener);
     initRootNode();
     myStructureModel.addModelListener(myModelListener);
+
+    setCanYieldUpdate(!ApplicationManager.getApplication().isUnitTestMode());
   }
 
   public final void dispose() {
index f0c2a8b09cc3b0a65c66e390e5a3523a622cd7e7..a85871cbb7328f90f95af775099e4e6c347a4ab0 100644 (file)
@@ -114,13 +114,7 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre
       }
 
       public boolean isToBuildChildrenInBackground(final Object element) {
-        if (element instanceof TreeElementWrapper) {
-          final Object o = ((TreeElementWrapper)element).getElement();
-          final TreeElement root = myModel.getRoot();
-          if (o == root)
-          return true;
-        }
-        return false;
+        return getRootElement() == element;
       }
 
       protected TreeElementWrapper createTree() {
@@ -140,7 +134,6 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre
         return isValid(child);
       }
     };
-    myAbstractTreeBuilder.updateFromRoot();
     Disposer.register(this, myAbstractTreeBuilder);
     Disposer.register(myAbstractTreeBuilder, new Disposable() {
       public void dispose() {
@@ -785,6 +778,16 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre
       return super.getChildren();
     }
 
+    @Override
+    public boolean isAlwaysShowPlus() {
+      return getValue().getChildren().length > 0;
+    }
+
+    @Override
+    public boolean isAlwaysLeaf() {
+      return getValue().getChildren().length == 0;
+    }
+
     protected TreeElementWrapper createChildNode(final TreeElement child) {
       return new StructureViewTreeElementWrapper(myProject, child, myTreeModel);
     }
index 90ee15e8b981eb67a0a0335aaa3e9f3cdf271ec4..c8bde1879bce715861e69bf5d31f41b9fa9311f7 100644 (file)
@@ -64,6 +64,11 @@ public class SmartTreeStructure extends AbstractTreeStructure {
     return new TreeElementWrapper(myProject, myModel.getRoot(), myModel);
   }
 
+  @Override
+  public boolean isAlwaysLeaf(Object element) {
+    return ((AbstractTreeNode)element).isAlwaysLeaf();
+  }
+
   public boolean hasSomethingToCommit() {
     return PsiDocumentManager.getInstance(myProject).hasUncommitedDocuments();
   }
index 58dd85c853867557d6f0369f48368c7562c7a3d0..f4157b585723c18b99669222d23bc83f4e0fcfad 100644 (file)
@@ -28,6 +28,8 @@ import com.intellij.codeInsight.editorActions.SelectWordUtil;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.IndentGuideDescriptor;
+import com.intellij.openapi.editor.SelectionModel;
 import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.project.DumbAware;
@@ -37,11 +39,16 @@ import java.util.List;
 
 public class SelectWordAtCaretAction extends TextComponentEditorAction implements DumbAware {
   public SelectWordAtCaretAction() {
-    super(new Handler());
+    super(new DefaultHandler());
     setInjectedContext(true);
   }
 
-  private static class Handler extends EditorActionHandler {
+  @Override
+  public EditorActionHandler getHandler() {
+    return new Handler(super.getHandler());
+  }
+
+  private static class DefaultHandler extends EditorActionHandler {
     public void execute(Editor editor, DataContext dataContext) {
       int lineNumber = editor.getCaretModel().getLogicalPosition().line;
       int caretOffset = editor.getCaretModel().getOffset();
@@ -74,4 +81,42 @@ public class SelectWordAtCaretAction extends TextComponentEditorAction implement
       editor.getSelectionModel().setSelection(startWordOffset, endWordOffset);
     }
   }
+
+  private static class Handler extends EditorActionHandler {
+    private final EditorActionHandler myDefaultHandler;
+
+    private Handler(EditorActionHandler defaultHandler) {
+      myDefaultHandler = defaultHandler;
+    }
+
+    @Override
+    public void execute(Editor editor, DataContext dataContext) {
+      final IndentGuideDescriptor guide = editor.getCaretIndentGuide();
+      final SelectionModel selectionModel = editor.getSelectionModel();
+      if (guide != null && !selectionModel.hasSelection() && !selectionModel.hasBlockSelection() && isWhitespaceAtCaret(editor)) {
+        selectWithGuide(editor, guide);
+      }
+      else {
+        myDefaultHandler.execute(editor, dataContext);
+      }
+    }
+
+    private static boolean isWhitespaceAtCaret(Editor editor) {
+      final Document doc = editor.getDocument();
+
+      final int offset = editor.getCaretModel().getOffset();
+      if (offset >= doc.getTextLength()) return false;
+
+      final char c = doc.getCharsSequence().charAt(offset);
+      return c == ' ' || c == '\t' || c == '\n';
+    }
+
+    private static void selectWithGuide(Editor editor, IndentGuideDescriptor guide) {
+      final Document doc = editor.getDocument();
+      int startOffset = doc.getLineStartOffset(guide.startLine - 1);
+      int endOffset = Math.min(doc.getLineEndOffset(guide.endLine) + 1, doc.getTextLength());
+
+      editor.getSelectionModel().setSelection(startOffset, endOffset);
+    }
+  }
 }
index 2952d50d9ecea2e1dca0e9041779bc3d1e097dbb..0c860a3ff64b54afd85d011e92133ab04be027b4 100644 (file)
@@ -31,7 +31,9 @@ import com.intellij.openapi.projectRoots.SdkType;
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.NullableComputable;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -60,7 +62,7 @@ public class SdkConfigurationUtil {
     if (selection.length > 0) {
       for (SdkType sdkType : sdkTypes) {
         if (sdkType.isValidSdkHome(selection[0].getPath())) {
-          return setupSdk(selection[0], sdkType);
+          return setupSdk(selection[0], sdkType, false);
         }
       }
     }
@@ -100,21 +102,39 @@ public class SdkConfigurationUtil {
     });
   }
 
-
-  public static Sdk setupSdk(final VirtualFile homeDir, final SdkType sdkType) {
-    return ApplicationManager.getApplication().runWriteAction(new Computable<Sdk>() {
-        public Sdk compute(){
+  @Nullable
+  public static Sdk setupSdk(final VirtualFile homeDir, final SdkType sdkType, final boolean silent) {
+    return ApplicationManager.getApplication().runWriteAction(new NullableComputable<Sdk>() {
+        public Sdk compute() {
           final Sdk[] sdks = ProjectJdkTable.getInstance().getAllJdks();
-          final String sdkName = createUniqueSdkName(sdkType, homeDir.getPath(), Arrays.asList(sdks));
-          final ProjectJdkImpl projectJdk = new ProjectJdkImpl(sdkName, sdkType);
-          projectJdk.setHomePath(homeDir.getPath());
-          sdkType.setupSdkPaths(projectJdk);
+          ProjectJdkImpl projectJdk;
+          try {
+            final String sdkName = createUniqueSdkName(sdkType, homeDir.getPath(), Arrays.asList(sdks));
+            projectJdk = new ProjectJdkImpl(sdkName, sdkType);
+            projectJdk.setHomePath(homeDir.getPath());
+            sdkType.setupSdkPaths(projectJdk);
+          }
+          catch (Exception e) {
+            if (!silent) {
+              Messages.showErrorDialog("Error configuring SDK: " +
+                                       e.getMessage() +
+                                       ".\nPlease make sure that " +
+                                       FileUtil.toSystemDependentName(homeDir.getPath()) +
+                                       " is a valid home path for this SDK type.", "Error configuring SDK");
+            }
+            return null;
+          }
           ProjectJdkTable.getInstance().addJdk(projectJdk);
           return projectJdk;
         }
     });
   }
 
+  @Nullable
+  public static Sdk setupSdk(final VirtualFile homeDir, final SdkType sdkType) {
+    return setupSdk(homeDir, sdkType, true);
+  }
+
   public static void setDirectoryProjectSdk(final Project project, final Sdk sdk) {
     ApplicationManager.getApplication().runWriteAction(new Runnable() {
       public void run() {
@@ -167,7 +187,7 @@ public class SdkConfigurationUtil {
           }
         });
         if (sdkHome != null) {
-          return setupSdk(sdkHome, sdkType);
+          return setupSdk(sdkHome, sdkType, true);
         }
       }
     }
index 74c044fbf5e1b7e5c2132bfa468ffb19f6ff194a..a8dd723fc14d504e2c13612d61615c5d93f0aae2 100644 (file)
@@ -72,7 +72,7 @@ public abstract class RefactoringDialog extends DialogWrapper {
     doAction();
   }
 
-  private void doRefactorAction () {
+  protected void doRefactorAction () {
     myCbPreviewResults = false;
     doAction();
   }
index a154adbc794d14cd2fa01ff68be4646d6760c6f5..d18ed42417c6d85c470030dd7d6264dba1206fdd 100644 (file)
@@ -93,6 +93,10 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor impl
     return false;
   }
 
+  public boolean isAlwaysLeaf() {
+    return false;   
+  }
+
   public boolean isAlwaysExpand() {
     return false;
   }
index 4950eb96e7d30cc6a57cdcf722367041fab1e366..aa2d7465ce496e22efeb70c22db521e4238fe6db 100644 (file)
@@ -170,6 +170,16 @@ public class AbstractTreeUi {
     myNodeDescriptorComparator = comparator;
     myUpdateIfInactive = updateIfInactive;
 
+    UIUtil.invokeLaterIfNeeded(new Runnable() {
+      public void run() {
+        if (!myRootNodeWasInitialized) {
+          if (myRootNode.getChildCount() == 0) {
+            insertLoadingNode(myRootNode, true);
+          }
+        }
+      }
+    });
+
     myExpansionListener = new MyExpansionListener();
     myTree.addTreeExpansionListener(myExpansionListener);
 
index 7a566039ec74569b92cbddb5f340d89c75bd9466..c5c11412a624f56c30d994a86f7521ff80a63ecd 100644 (file)
@@ -28,6 +28,12 @@ public class EmptyAction extends AnAction {
   public void actionPerformed(AnActionEvent e) {
   }
 
+  @Override
+  public void update(AnActionEvent e) {
+    e.getPresentation().setEnabled(false);
+    e.getPresentation().setVisible(false);
+  }
+
   public static void setupAction(@NotNull AnAction action, @NotNull String id, @Nullable JComponent component) {
     final AnAction emptyAction = ActionManager.getInstance().getAction(id);
     if (action.getTemplatePresentation().getIcon() == null) {
index 9c49d6e86a487792f1978c55f559690ab335fdd7..cf087ba8a09b59c51b9d986b992f493ffca79d83 100644 (file)
@@ -23,11 +23,13 @@ public class IndentGuideDescriptor {
   public final int indentLevel;
   public final int startLine;
   public final int endLine;
+  public int indentSize;
 
-  public IndentGuideDescriptor(int indentLevel, int startLine, int endLine) {
+  public IndentGuideDescriptor(int indentLevel, int startLine, int endLine, int indentSize) {
     this.indentLevel = indentLevel;
     this.startLine = startLine;
     this.endLine = endLine;
+    this.indentSize = indentSize;
   }
 
   @Override
index e25fdd49b1cfdfb09533bc10a8a6053b4150b64c..60b33344dcefdd56ec23f9aba9cc735da677ecd7 100644 (file)
@@ -27,7 +27,7 @@ public abstract class EditorAction extends AnAction implements DumbAware {
   private EditorActionHandler myHandler;
   private boolean myHandlersLoaded;
 
-  public final EditorActionHandler getHandler() {
+  public EditorActionHandler getHandler() {
     ensureHandlersLoaded();
     return myHandler;
   }
index 4fa4afedd0f732e35bd324785d329d33693f2c15..af065cddbc2024abb485aee4e36e4840ac9ac760 100644 (file)
@@ -231,6 +231,8 @@ public abstract class JBPopupFactory {
   @Nullable
   public abstract List<JBPopup> getChildPopups(@NotNull Component parent);
 
+  public abstract boolean isPopupActive();
+
   public abstract BalloonBuilder createBalloonBuilder(@NotNull JComponent content);
 
 
diff --git a/platform/platform-api/src/com/intellij/util/ui/Timer.java b/platform/platform-api/src/com/intellij/util/ui/Timer.java
new file mode 100644 (file)
index 0000000..c7130fa
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.intellij.util.ui;
+
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.application.Application;
+import com.intellij.openapi.application.ApplicationManager;
+
+public abstract class Timer implements Disposable, Runnable  {
+
+  private final int mySpan;
+
+  private volatile boolean myRunning;
+  private volatile boolean myDisposed;
+  private volatile boolean myRestartRequest;
+
+  private final String myName;
+
+  private volatile boolean myTakeInitialDelay = true;
+  private volatile boolean myInitiallySlept = false;
+
+  private ThreadRunner myRunner;
+  private Exception myInterruptedException;
+
+  private final Object LOCK = new Object();
+
+  public Timer(String name, int span) {
+    myName = name;
+    mySpan = span;
+  }
+
+  public void setTakeInitialDelay(final boolean take) {
+    myTakeInitialDelay = take;
+  }
+
+  public final int getSpan() {
+    return mySpan;
+  }
+
+  public final void start() {
+    synchronized (LOCK) {
+      myRunning = true;
+
+      if (myRunner != null) return;
+
+      Application app = ApplicationManager.getApplication();
+      myRunner = app != null ? new AppPool() : new PlainThread();
+      myRunner.run(this);
+    }
+  }
+
+  public final void run() {
+    try {
+      while(true) {
+        synchronized (LOCK) {
+          if (!myRunning || myDisposed) {
+            myRunner = null;
+            resetToStart();
+            break;
+          }
+        }
+
+        if (myTakeInitialDelay || myInitiallySlept) {
+          Thread.currentThread().sleep(mySpan);
+        }
+        myInitiallySlept = true;
+
+        if (myRestartRequest) {
+          myRestartRequest = false;
+          continue;
+        }
+
+        onTimer();
+      }
+    }
+    catch (InterruptedException e) {
+      myInterruptedException = e;
+      resetToStart();
+    }
+  }
+
+  private void resetToStart() {
+    myRestartRequest = false;
+    myInitiallySlept = false;
+  }
+
+  protected abstract void onTimer() throws InterruptedException;
+
+  public final void suspend() {
+    synchronized (LOCK) {
+      if (myDisposed) return;
+
+      if (myRunning) {
+        myRunning = false;
+      } else {
+        resetToStart();
+      }
+    }
+  }
+
+  public final void resume() {
+    synchronized (LOCK) {
+      if (myDisposed) return;
+
+      start();
+    }
+  }
+
+  public final void dispose() {
+    synchronized (LOCK) {
+      myDisposed = true;
+      suspend();
+    }
+  }
+
+  public void restart() {
+    synchronized (LOCK) {
+      start();
+      myRestartRequest = true;
+    }
+  }
+
+  public boolean isRunning() {
+    synchronized (LOCK) {
+      return myRunning;
+    }
+  }
+
+  public boolean isDisposed() {
+    synchronized (LOCK) {
+      return myDisposed;
+    }
+  }
+
+  interface ThreadRunner{
+    void run(Runnable runnable);
+  }
+
+  public String toString() {
+    return "Timer=" + myName;
+  }
+
+  static class AppPool implements ThreadRunner {
+    public void run(Runnable runnable) {
+      ApplicationManager.getApplication().executeOnPooledThread(runnable);
+    }
+  }
+
+  static class PlainThread implements ThreadRunner {
+
+    private Thread myThread;
+
+    public void run(Runnable runnable) {
+      myThread = new Thread(runnable, "timer thread");
+      myThread.start();
+    }
+  }
+
+}
index 7336727ed6eff03dfc43301c362c2c82ca4a563f..7c8245b02cd6e2632a25ed80e6b479344b54cc91 100644 (file)
@@ -26,6 +26,7 @@ import com.intellij.openapi.editor.ex.FoldingModelEx;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.ui.LightweightHint;
 import com.intellij.ui.ScreenUtil;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import javax.swing.border.Border;
@@ -125,6 +126,7 @@ public class EditorFragmentComponent extends JPanel {
    * @param x <code>x</code> coordinate in layered pane coordinate system.
    * @param y <code>y</code> coordinate in layered pane coordinate system.
    */
+  @Nullable
   public static LightweightHint showEditorFragmentHintAt(Editor editor,
                                                          TextRange range,
                                                          int x,
@@ -168,12 +170,15 @@ public class EditorFragmentComponent extends JPanel {
     return fragmentComponent;
   }
 
+  @Nullable
   public static LightweightHint showEditorFragmentHint(Editor editor, TextRange range, boolean showFolding, boolean hideByAnyKey){
     int x = -2;
     int y = 0;
 
     JComponent editorComponent = editor.getComponent();
-    JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
+    final JRootPane rootPane = editorComponent.getRootPane();
+    if (rootPane == null) return null;
+    JLayeredPane layeredPane = rootPane.getLayeredPane();
     Point point = SwingUtilities.convertPoint(editorComponent, x, y, layeredPane);
 
     return showEditorFragmentHintAt(editor, range, point.x, point.y, true, showFolding, hideByAnyKey);
index 6f66e323ef014b00127f262169a287c6a7c7a259..1f0b844e5dc11fd1cff7e7275c5dc4a919f9bc5d 100644 (file)
@@ -774,4 +774,8 @@ public class IdeEventQueue extends EventQueue {
       });
     }
   }
+
+  public boolean isPopupActive() {
+    return myPopupManager.isPopupActive();
+  }
 }
index eee0870d2dd6c3b17342ecd6f7d09ae95843333d..ccc131cd3628eeabfaf2a26dc35fd93e7354794c 100644 (file)
@@ -32,6 +32,7 @@ import java.awt.*;
 public class ShowContentAction extends AnAction implements DumbAware {
   private ToolWindow myWindow;
 
+  @SuppressWarnings({"UnusedDeclaration"})
   public ShowContentAction() {
   }
 
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ToggleFullScreenModeAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ToggleFullScreenModeAction.java
deleted file mode 100644 (file)
index ba1b861..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.ide.actions;
-
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.actionSystem.ToggleAction;
-import com.intellij.openapi.project.DumbAware;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.SystemInfo;
-import com.intellij.openapi.wm.ToolWindow;
-import com.intellij.openapi.wm.ToolWindowManager;
-import com.intellij.openapi.wm.ToolWindowType;
-import com.intellij.openapi.wm.ex.WindowManagerEx;
-import com.intellij.openapi.wm.impl.IdeFrameImpl;
-import org.jetbrains.annotations.NonNls;
-
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * @author Vladimir Kondratyev
- */
-public final class ToggleFullScreenModeAction extends ToggleAction implements DumbAware {
-  @NonNls
-  private static final String PROP_BOUNDS_BEFORE_FULL_SCREEN="boundsBeforeFullScreen";
-
-  private static IdeFrameImpl getFrame(AnActionEvent e){
-    WindowManagerEx windowManagerEx=WindowManagerEx.getInstanceEx();
-    Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
-    return windowManagerEx.getFrame(project);
-  }
-
-  public boolean isSelected(AnActionEvent e){
-    IdeFrameImpl frame=getFrame(e);
-    return frame != null && frame.getGraphicsConfiguration().getDevice().getFullScreenWindow()==frame;
-  }
-
-  public void setSelected(AnActionEvent e,boolean state){
-    // Hide all all visible floating tool windows.
-    Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
-    if(project!=null){
-      ToolWindowManager toolWindowManager=ToolWindowManager.getInstance(project);
-      String[] ids=toolWindowManager.getToolWindowIds();
-      for (String id : ids) {
-        ToolWindow toolWindow = toolWindowManager.getToolWindow(id);
-        if (ToolWindowType.FLOATING == toolWindow.getType() && toolWindow.isVisible()) {
-          toolWindow.hide(null);
-        }
-      }
-    }
-    // Toggle full screen mode.
-    IdeFrameImpl frame=getFrame(e);
-    final Component focusedComponent=WindowManagerEx.getInstanceEx().getFocusedComponent(frame);
-    GraphicsConfiguration graphicsConfiguration=frame.getGraphicsConfiguration();
-    Rectangle bounds=graphicsConfiguration.getBounds();
-    Insets insets=Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfiguration);
-    if(state){ // toggle full screen on
-      frame.getRootPane().putClientProperty(PROP_BOUNDS_BEFORE_FULL_SCREEN,frame.getBounds());
-      frame.dispose();
-      frame.setUndecorated(true);
-      frame.setBounds(bounds);
-      frame.setVisible(true);
-      graphicsConfiguration.getDevice().setFullScreenWindow(frame);
-    }else{ // toggle full screen off
-      Rectangle boundsBeforeFullScreen=(Rectangle)frame.getRootPane().getClientProperty(PROP_BOUNDS_BEFORE_FULL_SCREEN);
-      frame.dispose();
-      graphicsConfiguration.getDevice().setFullScreenWindow(null);
-      frame.setUndecorated(false);
-      if(boundsBeforeFullScreen!=null){
-        frame.setBounds(boundsBeforeFullScreen);
-        frame.setVisible(true);
-      }else{
-        frame.setBounds(
-          bounds.x+insets.left,
-          bounds.y+insets.top,
-          bounds.width-insets.left-insets.right,
-          bounds.height-insets.top-insets.bottom
-        );
-        frame.setVisible(true);
-        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
-      }
-    }
-    if(focusedComponent!=null){
-      SwingUtilities.invokeLater(
-        new Runnable(){
-          public void run(){
-            focusedComponent.requestFocus();
-          }
-        }
-      );
-    }
-  }
-
-  public void update(AnActionEvent e){
-    super.update(e);
-    IdeFrameImpl frame = getFrame(e);
-    final boolean operational = frame != null && frame.getGraphicsConfiguration().getDevice().isFullScreenSupported() &&
-                                (!SystemInfo.isMac || SystemInfo.isMacOSSnowLeopard);
-    e.getPresentation().setVisible(operational);
-    e.getPresentation().setEnabled(operational);
-  }
-}
index 77aefc9eb471c756273bd05467bed3012d4bfa79..c68bc2655ecce363db48f9a7470565ec320aeefd 100644 (file)
@@ -375,7 +375,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
     return stub;
   }
 
-  private ResourceBundle getActionsResourceBundle(ClassLoader loader, IdeaPluginDescriptor plugin) {
+  private static ResourceBundle getActionsResourceBundle(ClassLoader loader, IdeaPluginDescriptor plugin) {
     @NonNls final String resBundleName = plugin != null && !plugin.getPluginId().getIdString().equals("com.intellij") ? plugin.getResourceBundleBaseName() : ACTIONS_BUNDLE;
     ResourceBundle bundle = null;
     if (resBundleName != null) {
@@ -625,7 +625,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
     group.addAction(action, new Constraints(anchor, relativeToActionId), this).setAsSecondary(secondary);
   }
 
-  public boolean checkRelativeToAction(final String relativeToActionId,
+  public static boolean checkRelativeToAction(final String relativeToActionId,
                                        @NotNull final Anchor anchor,
                                        @NotNull final String actionName,
                                        @Nullable final PluginId pluginId) {
@@ -637,7 +637,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
   }
 
   @Nullable
-  public Anchor parseAnchor(final String anchorStr,
+  public static Anchor parseAnchor(final String anchorStr,
                             @Nullable final String actionName,
                             @Nullable final PluginId pluginId) {
     if (anchorStr == null) {
@@ -946,13 +946,13 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
 
   public void removeActionPopup(final ActionPopupMenuImpl menu) {
     final boolean removed = myPopups.remove(menu);
-    if (removed && myPopups.size() == 0) {
+    if (removed && myPopups.isEmpty()) {
       flushActionPerformed();
     }
   }
 
   public void queueActionPerformedEvent(final AnAction action, DataContext context, AnActionEvent event) {
-    if (myPopups.size() > 0) {
+    if (!myPopups.isEmpty()) {
       myQueuedNotifications.put(action, context);
     } else {
       fireAfterActionPerformed(action, context, event);
@@ -961,7 +961,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
 
 
   public boolean isActionPopupStackEmpty() {
-    return myPopups.size() == 0;
+    return myPopups.isEmpty();
   }
 
   private void flushActionPerformed() {
@@ -1268,7 +1268,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
     });
   }
 
-  private DataContext getContextBy(Component contextComponent) {
+  private static DataContext getContextBy(Component contextComponent) {
     final DataManager dataManager = DataManager.getInstance();
     return contextComponent != null ? dataManager.getDataContext(contextComponent) : dataManager.getDataContext();
   }
index db43f3e3f90bd8280cdb9324587b78bb65207540..255dd7b794c01c1264d09f1665499759760e0ea9 100644 (file)
@@ -85,11 +85,11 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
 
   private final EventDispatcher<ApplicationListener> myDispatcher = EventDispatcher.create(ApplicationListener.class);
 
-  private boolean myTestModeFlag = false;
-  private boolean myHeadlessMode = false;
-  private boolean myCommandLineMode = false;
+  private final boolean myTestModeFlag;
+  private final boolean myHeadlessMode;
+  private final boolean myCommandLineMode;
 
-  private boolean myIsInternal = false;
+  private final boolean myIsInternal;
   private final String myName;
 
   private final ReentrantWriterPreferenceReadWriteLock myActionsLock = new ReentrantWriterPreferenceReadWriteLock();
index 6778516e3dc09c39445b979ddc12c5ea814ce672..2551da7744dc5075f62ad5839a574310125b6fd2 100644 (file)
@@ -34,7 +34,7 @@ public class CopyAction extends EditorAction {
     super(new Handler());
   }
 
-  public static class Handler extends EditorActionHandler {
+  private static class Handler extends EditorActionHandler {
     public void execute(Editor editor, DataContext dataContext) {
       if (!editor.getSelectionModel().hasSelection() && !editor.getSelectionModel().hasBlockSelection()) {
         editor.getSelectionModel().selectLineAtCaret();
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleShowIndentLinesAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ToggleShowIndentLinesAction.java
new file mode 100644 (file)
index 0000000..9571b19
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.editor.actions;
+
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.actionSystem.ToggleAction;
+import com.intellij.openapi.editor.Editor;
+import org.jetbrains.annotations.Nullable;
+
+public class ToggleShowIndentLinesAction extends ToggleAction {
+
+  public void setSelected(AnActionEvent e, boolean state) {
+    final Editor editor = getEditor(e);
+    assert editor != null;
+    editor.getSettings().setIndentGuidesShown(state);
+  }
+
+  public boolean isSelected(AnActionEvent e) {
+    final Editor editor = getEditor(e);
+    return editor != null && editor.getSettings().isIndentGuidesShown();
+  }
+
+  @Nullable
+  private static Editor getEditor(AnActionEvent e) {
+    return e.getData(PlatformDataKeys.EDITOR);
+  }
+
+  public void update(AnActionEvent e){
+    super.update(e);
+
+    if (getEditor(e) == null) {
+      e.getPresentation().setEnabled(false);
+      e.getPresentation().setVisible(false);
+    } else {
+      e.getPresentation().setEnabled(true);
+      e.getPresentation().setVisible(true);
+    }
+  }
+}
index aa0435971caaf0a4841567ccfcc795ad9dced515..ab44109454f7a25eb1405cbf6ceab67ac4946fb2 100644 (file)
@@ -218,8 +218,7 @@ public class EditorUtil {
   }
 
   public static int getTabSize(Editor editor) {
-    Project project = editor.getProject();
-    return project != null && project.isDisposed() ? 0 : editor.getSettings().getTabSize(project);
+    return editor.getSettings().getTabSize(editor.getProject());
   }
 
   public static int nextTabStop(int x, Editor editor) {
index 75abbc5d33d5634f3e6f59cfd193d7cb90853e49..156ffce5e09b392ebcdee79867a4b8f1a38c8969 100644 (file)
@@ -226,6 +226,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
   private char[] myPrefixText;
   private TextAttributes myPrefixAttributes;
   private IndentGuideDescriptor myCaretIndentGuide = null;
+  private int myIndentSize = -1;
 
   static {
     ourCaretBlinkingCommand = new RepaintCursorCommand();
@@ -442,6 +443,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
     myCharHeight = -1;
     myLineHeight = -1;
     myDescent = -1;
+    myIndentSize = -1;
     myPlainFontMetrics = null;
 
     myCaretModel.reinitSettings();
@@ -1208,7 +1210,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
     paintBackgrounds(g, clip);
     paintRectangularSelection(g);
     paintRightMargin(g, clip);
-    paintIndentGuides(g, clip);
+    paintIndentGuides((Graphics2D)g, clip);
     final MarkupModel docMarkup = myDocument.getMarkupModel(myProject);
     paintLineMarkersSeparators(g, clip, docMarkup);
     paintLineMarkersSeparators(g, clip, myMarkupModel);
@@ -1223,59 +1225,107 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
     paintComposedTextDecoration((Graphics2D)g);
   }
 
-  private void paintIndentGuides(Graphics g, Rectangle clip) {
+  private void paintIndentGuides(Graphics2D g, Rectangle clip) {
     if (mySettings.isIndentGuidesShown()) {
+      int x = 0;
       int y = clip.y;
       int line = xyToLogicalPosition(new Point(0, y)).line;
 
       final int indentSize = getIndentSize();
       int gapWidth = EditorUtil.getSpaceWidth(Font.PLAIN, this) * indentSize;
+      final CharSequence chars = myDocument.getCharsNoThreadCheck();
 
+      int prevIndent = -1;
       do {
         final int indents = getIndents(line);
+
+        /*
+        if (prevIndent > indents && isWhitespaceAt(chars, x, y)) {
+          g.setColor(myScheme.getColor(EditorColors.WHITESPACES_COLOR));
+          g.drawLine(x, y + getLineHeight() - 2, x + 7, y + getLineHeight() - 2);
+        }
+        */
+
+        y = logicalLineToY(line);
+        if (y > clip.y + clip.height) break;
+
         for (int n = 1; n < indents; n++) {
-          int x = n * gapWidth + 1;
-          UIUtil.drawDottedLine((Graphics2D)g, x, y, x, y + getLineHeight(), getBackroundColor(), myScheme.getColor(EditorColors.WHITESPACES_COLOR));
+          x = n * gapWidth + 1;
+          drawSegment(g, x, y, chars, false);
         }
 
         line++;
-        y = logicalLineToY(line);
+        prevIndent = indents;
       }
-      while (y < clip.y + clip.height);
+      while (true);
 
       if (myCaretIndentGuide != null) {
-        int x = myCaretIndentGuide.indentLevel * gapWidth + 1;
-        int y1 = logicalLineToY(myCaretIndentGuide.startLine);
-        int y2 = logicalLineToY(myCaretIndentGuide.endLine);
-        UIUtil.drawDottedLine((Graphics2D)g, x, y1, x, y2, getBackroundColor(), getForegroundColor());
+        x = myCaretIndentGuide.indentLevel * gapWidth + 1;
+        for (int i = myCaretIndentGuide.startLine; i <= myCaretIndentGuide.endLine; i++) {
+          drawSegment(g, x, logicalLineToY(i), chars, true);
+        }
+
+        /*
+        y = logicalLineToY(myCaretIndentGuide.endLine);
+        if (isWhitespaceAt(chars, x, y)) {
+          g.setColor(getForegroundColor());
+          g.drawLine(x, y + getLineHeight() - 2, x + 7, y + getLineHeight() - 2);
+        }
+        */
       }
     }
   }
 
+  private boolean isWhitespaceAt(CharSequence chars, int x, int y) {
+    LogicalPosition log = xyToLogicalPosition(new Point(x, y));
+    int offset = logicalPositionToOffset(log);
+
+    char c = chars.charAt(offset);
+    return c == ' ' || c == '\t' || c == '\n';
+  }
+
+  private void drawSegment(Graphics2D g, int x, int y, CharSequence chars, boolean selected) {
+    if (isWhitespaceAt(chars, x, y)) {
+      /*
+      UIUtil.drawDottedLine(g, x, y, x, y + getLineHeight(),
+                            getBackroundColor(),
+                            selected ? getForegroundColor() : myScheme.getColor(EditorColors.WHITESPACES_COLOR));
+      */
+
+      g.setColor(selected ? new Color(200, 200, 200) : new Color(230, 230, 230));
+      g.drawLine( x + 1, y, x + 1, y + getLineHeight());
+    }
+  }
+
   @Nullable
   public IndentGuideDescriptor getCaretIndentGuide() {
+    if (!mySettings.isIndentGuidesShown()) return null;
+    
     final int indentSize = getIndentSize();
+    if (indentSize == 0) return null;
 
     final LogicalPosition caretPosition = myCaretModel.getLogicalPosition();
     int startLine = caretPosition.line;
     int endLine = startLine;
-    int indents = caretPosition.column / indentSize;
+    final int caretIndent = caretPosition.column / indentSize;
+    final int indents = getIndents(startLine);
 
-    if (indents > 0 && caretPosition.column % indentSize == 0) {
+    if (caretIndent * indentSize != caretPosition.column) return null;
+    if (caretIndent > indents|| indents == 0) return null;
+    
+    if (caretIndent > 0 && caretPosition.column % indentSize == 0) {
       while (startLine > 0) {
-        if (getIndents(startLine - 1) <= indents) break;
+        if (getIndents(startLine - 1) <= caretIndent) break;
         startLine--;
       }
 
-      if (getIndents(endLine + 1) > indents) endLine++;
-
       while (endLine < myDocument.getLineCount() - 1) {
-        if (getIndents(endLine) <= indents) break;
+        if (getIndents(endLine + 1) <= caretIndent) break;
         endLine++;
       }
 
-      if (indents > 0 && startLine < endLine) {
-        return new IndentGuideDescriptor(indents, startLine, endLine);
+      if (startLine < endLine) {
+        return new IndentGuideDescriptor(caretIndent, startLine, endLine, indentSize);
       }
     }
 
@@ -1497,7 +1547,10 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
             }
           }
           else {
-            paintAfterFileEndBackground(iterationState, g, position, clip, lineHeight, defaultBackground);
+            paintAfterFileEndBackground(iterationState,
+                                        g,
+                                        position, clip,
+                                        lineHeight, defaultBackground);
             break;
           }
 
@@ -2231,8 +2284,11 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
   }
 
   private int getIndentSize() {
-    if (myProject == null || myProject.isDisposed() || myVirtualFile == null) return EditorUtil.getTabSize(this);
-    return CodeStyleFacade.getInstance(myProject).getIndentSize(myVirtualFile.getFileType());
+    if (myIndentSize == -1) {
+      if (myProject == null || myProject.isDisposed() || myVirtualFile == null) return EditorUtil.getTabSize(this);
+      myIndentSize = CodeStyleFacade.getInstance(myProject).getIndentSize(myVirtualFile.getFileType());
+    }
+    return myIndentSize;
   }
 
   private int getIndents(int line, boolean goUp, boolean goDown) {
@@ -2246,14 +2302,15 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
       return calcColumnNumber(nonWhitespaceOffset, line) / getIndentSize();
     }
     else {
-      int upIndent = goUp ? getIndents(line - 1, true, false) : 0;
-      int downIndent = goDown ? getIndents(line + 1, false, true) : 0;
-      return Math.max(upIndent, downIndent);
+      int upIndent = goUp ? getIndents(line - 1, true, false) : 100;
+      int downIndent = goDown ? getIndents(line + 1, false, true) : 100;
+      return Math.min(upIndent, downIndent);
     }
   }
 
   private int getIndents(int line) {
     int answer = getIndents(line, true, true);
+    if (answer == 0) return 0;
 
     int prev;
     do {
index 29336dd23642236278b3262527d4019e13edeadb..b7a82b17ec26684c3ab478fd19e49ffdb80f6119 100644 (file)
@@ -103,7 +103,11 @@ public class SettingsImpl implements EditorSettings {
   }
 
   public void setIndentGuidesShown(boolean val) {
-    myIndentGuidesShown = Boolean.valueOf(val);
+    final Boolean newValue = val ? Boolean.TRUE : Boolean.FALSE;
+    if (newValue.equals(myIndentGuidesShown)) return;
+
+    myIndentGuidesShown = newValue;
+    fireEditorRefresh();
   }
 
   public boolean isLineNumbersShown() {
@@ -195,7 +199,7 @@ public class SettingsImpl implements EditorSettings {
     if (myCachedTabSize != null) return myCachedTabSize.intValue();
 
     FileType fileType = getFileType();
-    int tabSize = CodeStyleFacade.getInstance(project).getTabSize(fileType);
+    int tabSize = project == null || project.isDisposed() ? 0 : CodeStyleFacade.getInstance(project).getTabSize(fileType);
     myCachedTabSize = Integer.valueOf(tabSize);
     return tabSize;
   }
index 3d02d028eb0f97e37486a45591fc86b11c5d47c2..a57ad910a96750272d292f47186d5ff32a2ef9e6 100644 (file)
@@ -566,9 +566,8 @@ public final class IdeKeyEventDispatcher implements Disposable {
 
     // search in main keymap
 
-    String[] actionIds;
     Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
-    actionIds = keymap.getActionIds(sc);
+    String[] actionIds = keymap.getActionIds(sc);
 
     ActionManager actionManager = ActionManager.getInstance();
     for (String actionId : actionIds) {
index e32cd0ac2d8b86015341e3ba508ab1d8cb788ad9..9694fc18a28c25cf306ae6f15020f66caebe4909 100644 (file)
@@ -58,14 +58,10 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
   private String myActiveKeymapName;
   private final Map<String, String> myBoundShortcuts = new HashMap<String, String>();
 
-  @NonNls
-  private static final String KEYMAP = "keymap";
-  @NonNls
-  private static final String KEYMAPS = "keymaps";
-  @NonNls
-  private static final String ACTIVE_KEYMAP = "active_keymap";
-  @NonNls
-  private static final String NAME_ATTRIBUTE = "name";
+  @NonNls private static final String KEYMAP = "keymap";
+  @NonNls private static final String KEYMAPS = "keymaps";
+  @NonNls private static final String ACTIVE_KEYMAP = "active_keymap";
+  @NonNls private static final String NAME_ATTRIBUTE = "name";
   private final SchemesManager<Keymap, KeymapImpl> mySchemesManager;
 
   public static boolean ourKeymapManagerInitialized = false;
index 02530d93fec4700c8b82014066c224ff29b7ae63..3e1efff3acbd8dc669c0f18210ee7f318b651371 100644 (file)
@@ -37,7 +37,7 @@ public abstract class TypeCommand extends AbstractCommand {
   protected void type(Robot robot, KeyStroke keyStroke) {
     boolean shift = (keyStroke.getModifiers() & KeyEvent.SHIFT_MASK) > 0;
     boolean alt = (keyStroke.getModifiers() & KeyEvent.ALT_MASK) > 0;
-    boolean control = (keyStroke.getModifiers() & KeyEvent.ALT_MASK) > 0;
+    boolean control = (keyStroke.getModifiers() & KeyEvent.CTRL_MASK) > 0;
     boolean meta = (keyStroke.getModifiers() & KeyEvent.META_MASK) > 0;
 
     if (shift) {
index 40abc8560c1e36816ba08f6d06c96526bca9ec11..1e9f77217e86a43b32d1a4b710c94d475029c476 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.ui.popup;
 
 import com.intellij.CommonBundle;
 import com.intellij.ide.DataManager;
+import com.intellij.ide.IdeEventQueue;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.actionSystem.ex.ActionUtil;
 import com.intellij.openapi.actionSystem.impl.ActionMenu;
@@ -532,6 +533,11 @@ public class PopupFactoryImpl extends JBPopupFactory {
     return FocusTrackback.getChildPopups(component);
   }
 
+  @Override
+  public boolean isPopupActive() {
+  return IdeEventQueue.getInstance().isPopupActive();
+  }
+
   private static class ActionStepBuilder {
     private final List<ActionItem> myListModel;
     private final DataContext myDataContext;
index 827be17f371ec2c05c82ad2a2e1707ce4a0c7d05..3742524dbc2293554f1a8c9edf5c5eec8d57fc6c 100644 (file)
@@ -408,15 +408,14 @@ abstract class BaseTreeTestCase<StructureElement> extends FlyIdeaTestCase {
   private void checkThread() {
     String message = "Wrong thread used for query structure, thread=" + Thread.currentThread();
 
-    if (myPassthroughMode) {
-      Assert.assertSame(message, myTestThread, Thread.currentThread());
-    } else {
+    if (!myPassthroughMode) {
       if (isBgStructureBuilding()) {
         Assert.assertFalse(message, EventQueue.isDispatchThread());
       } else {
         Assert.assertTrue(message, EventQueue.isDispatchThread());
       }
-    } 
+
+    }
   }
 
   protected final void invokeLaterIfNeeded(Runnable runnable) {
index 75eacac1c5c815d53e86c498a458654c592f116a..138faa087e82001088c7ea4d280ff6700f9f13ef 100644 (file)
@@ -119,6 +119,8 @@ action.EditorToggleColumnMode.text=Column _Mode
 action.EditorToggleColumnMode.description=Toggle editor column mode
 action.EditorToggleShowWhitespaces.text=Sh_ow Whitespaces
 action.EditorToggleShowWhitespaces.description=Toggle display whitespaces in current editor
+action.EditorToggleShowIndentLines.text=Sh_ow Indent Guides
+action.EditorToggleShowIndentLines.description=Toggle display indent guides in current editor
 action.EditorToggleShowLineNumbers.text=Show L_ine Numbers
 action.EditorToggleShowLineNumbers.description=Toggle display line numbers in current editor
 action.ViewImportPopups.text=Show Import Popups
@@ -305,8 +307,6 @@ action.ViewStatusBar.text=_Status Bar
 action.ViewStatusBar.description=Show/hide the status bar
 action.ViewNavigationBar.text=Na_vigation Bar
 action.ViewNavigationBar.description=Show/hide the navigation bar
-action.ToggleFullScreenMode.text=F_ull Screen
-action.ToggleFullScreenMode.description=Maximize window to full screen
 action.FileStructurePopup.text=_File Structure Popup
 action.FileStructurePopup.description=Popup structure of the current file for quick navigation
 action.ShowFilePath.text=File _Path
@@ -1115,7 +1115,7 @@ group.GoToChangeMarkerGroup.text=Change Navigation Actions
 group.CoverageMenu.text=Code Coverage Actions
 group.ToolsXmlGroup.text=XML Actions
 group.XmlGenerateToolsGroup.text=XML Generate Actions
-group.EditorPopupMenu2.text=Debug Actions
+group.EditorPopupMenuDebug.text=Debug Actions
 group.VersionControlsGroup.text=VCS/LVCS Actions
 group.EditorPopupMenu.Run.text=Compile/Run Actions
 group.ProjectViewCompileGroup.text=Compile/Debug Actions
@@ -1179,4 +1179,4 @@ group.ToolsBasicGroup.text=Tools Basic Group
 group.ToolsBasicGroup.description=Tools Basic Group
 group.ToolbarNewElement.text=Toolbar New Element Group
 action.NewElementToolbarAction.text=Create New File
-action.ShowRegistry.text=Registry
\ No newline at end of file
+action.ShowRegistry.text=Registry
index ffaace6cb16e2eb56f4a7c4be33c1eff250ab05b..6745810f357d4839bed226d46dc20b7a9ef045e1 100644 (file)
@@ -423,7 +423,7 @@ node.static.flag.tooltip=Static
 multiple.implementations.tooltip=Multiple implementations
 static.class.initializer={0}class initializer
 
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 intentions.category.ejb=EJB
 set.language.level=Set language level
 set.language.level.to.0=Set language level to {0}
index 9bfa7c5544753525a70341e18ef3c8e7462d07dc..82f9ac4ae9019a6fd00f0072dac87f97e582ab37 100644 (file)
@@ -15,9 +15,9 @@ no.syntax.highlighting.performed=No syntax highlighting performed.
 no.inspections.performed=No inspections performed.
 
 # These two aren't unused!
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 no.syntax.highlighting.performed.for=No syntax highlighting performed for {0}.
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 no.inspections.performed.for=No inspections performed {0}.
 
 pass.syntax=Syntax
index 72458a0f8541852df9ecf2a124ad650085a4a22c..dbec7256cc1b203f36c327d69d607a8bf0e5873c 100644 (file)
@@ -77,32 +77,32 @@ refactoring.copyClass=Copy Class refactoring
 ui.tree.speedsearch=Speed search in trees
 ui.scheme.quickswitch=Quick switch scheme
 
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 ui.recentchanges=Recent changes
 
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 ant.quickfix.CreateProperty=Create property tag
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 ant.quickfix.CreateTarget=Create target tag
 
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 group.navigation=Navigation
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 group.completion=Code Completion
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 group.editing=Code Editing
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 group.codeassists=Code Assistants
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 group.refactoring=Refactoring
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 group.ui=UI Usability Features
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 group.ant=Ant support features
 
 navigation.popup.action=Go to action
 navigation.goto.usages=Show usages
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 editing.completion.completeStatement=Complete Statement from Code Completion
 codeassists.highlight.implements=Highlight implementing or overriding members
 codeassists.highlight.return=Highlight method exit points
index a868ff78f101c39817a2640204fee7800eca820a..dc1b7f09915ee64438e85a8df707b01fb5666d77 100644 (file)
@@ -92,28 +92,28 @@ cannot.delete.a.read.only.file=Cannot delete a read-only file ''{0}''.
 0.expected={0} expected
 cannot.resolve.symbol=Cannot resolve symbol ''{0}''
 
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 packageLocal.visibility.presentation=package local
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 protected.visibility.presentation=protected
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 private.visibility.presentation=private
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 public.visibility.presentation=public
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 abstract.visibility.presentation=abstract
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 static.visibility.presentation=static
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 final.visibility.presentation=final
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 native.visibility.presentation=native
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 synchronized.visibility.presentation=synchronized
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 strictfp.visibility.presentation=strictfp
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 transient.visibility.presentation=transient
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 volatile.visibility.presentation=volatile
 
index e67799379ef05f9d6aad0bdf2c8279ef5c9aaa6c..fa238ac53853b7d0d6d33d8856bae17b16cd9345 100644 (file)
@@ -55,3 +55,5 @@ compiler.perform.outputs.refresh.on.start.restartRequired=false
 vcs.show.colored.annotations=true
 vcs.showConsole=true
 psi.viewer.selection.color=0,153,153
+
+structureView.coalesceTime=500
\ No newline at end of file
index 62866c57d516b2c9b1e0093369e6e3bed794f425..8a93cd070204f5ca7018b22d2395acd63b9f4dfa 100644 (file)
@@ -33,9 +33,6 @@
   <action id="CollapseTreeNode">
     <keyboard-shortcut first-keystroke="SUBTRACT"/>
   </action>
-  <action id="ToggleFullScreenMode">
-    <keyboard-shortcut first-keystroke="control alt F11"/>
-  </action>
   <action id="SwitchCoverage">
     <keyboard-shortcut first-keystroke="control alt F6"/>
   </action>
index de3d1dab3401a90b376ba5ffe690f914a65eabc2..bcfd27342513a37d5ff1c4409cdcf0cb8f7371fc 100644 (file)
     <action id="ToggleFloatingMode">
       <keyboard-shortcut first-keystroke="shift alt D" />
     </action>
-    <action id="ToggleFullScreenMode">
-      <keyboard-shortcut first-keystroke="control alt F11" />
-      <keyboard-shortcut first-keystroke="shift alt ENTER" />
-    </action>
     <action id="TypeHierarchy">
       <keyboard-shortcut first-keystroke="shift alt F12" />
     </action>
index 8ae162fa1987bc97836dc78c8a3409fdef708948..6b673310fcd7a8a468f286feb84807b57114f72b 100644 (file)
@@ -15,8 +15,5 @@
     <action id="SwitchCoverage">
       <keyboard-shortcut first-keystroke="control alt 6" />
     </action>
-    <action id="ToggleFullScreenMode">
-      <keyboard-shortcut first-keystroke="control alt MINUS" />
-    </action>
   </keymap>
 </component>
index 9ab84e9a6e758e170e324e4bb0102e02460055c0..2e6e05b93f6435aa5ba288220002609d36e7ff47 100644 (file)
 
     <!-- TODO: correct action location -->
     <action id="QuickImplementations" class="com.intellij.codeInsight.hint.actions.ShowImplementationsAction">
-      <add-to-group group-id="ViewMenu" relative-to-action="ToggleFullScreenMode" anchor="after"/>
+      <add-to-group group-id="ViewMenu" relative-to-action="QuickChangeScheme" anchor="before"/>
     </action>
 
     <action id="RecentChanges" class="com.intellij.history.integration.ui.actions.RecentChangesAction">
       <add-to-group group-id="RunMenu" anchor="last"/>
     </group>
 
+    <action id="Debugger.AddToWatch" class="com.intellij.xdebugger.impl.actions.AddToWatchesAction" icon="/debugger/addToWatch.png"/>
+
+    <group id="EditorPopupMenuDebug">
+      <separator/>
+      <reference ref="EvaluateExpression"/>
+      <reference ref="RunToCursor"/>
+      <reference ref="ForceRunToCursor"/>
+      <reference ref="Debugger.AddToWatch"/>
+      <separator/>
+
+      <add-to-group group-id="EditorLangPopupMenu" relative-to-action="EditorPopupMenu.Run" anchor="before"/>
+    </group>
+
+
     <group id="XDebugger.Actions">
       <action id="XDebugger.SetValue" class="com.intellij.xdebugger.impl.ui.tree.actions.XSetValueAction"/>
       <action id="XDebugger.CopyValue" class="com.intellij.xdebugger.impl.ui.tree.actions.XCopyValueAction"/>
index d5dddac5adc4d6dab56c4ccbc2e0ceeb8eeca9a2..a1954ea76b8d03d001b26816506bedd7ac17afef 100644 (file)
@@ -67,6 +67,8 @@
       <action id="EditorToggleColumnMode" class="com.intellij.openapi.editor.actions.ToggleColumnModeAction"/>
       <action id="EditorToggleShowWhitespaces" class="com.intellij.openapi.editor.actions.ToggleShowWhitespacesAction"/>
       <action id="EditorToggleShowLineNumbers" class="com.intellij.openapi.editor.actions.ToggleShowLineNumbersAction"/>
+      <action id="EditorToggleShowIndentLines" class="com.intellij.openapi.editor.actions.ToggleShowIndentLinesAction"/>
+
       <action id="EditorScrollToCenter" class="com.intellij.openapi.editor.actions.ScrollToCenterAction"/>
       <action id="EditorToggleCase" class="com.intellij.openapi.editor.actions.ToggleCaseAction"/>
       <action id="EditorJoinLines" class="com.intellij.openapi.editor.actions.JoinLinesAction"/>
         <action id="ViewStatusBar" class="com.intellij.ide.actions.ViewStatusBarAction"/>
         <reference ref="EditorToggleShowWhitespaces"/>
         <reference ref="EditorToggleShowLineNumbers"/>
+        <reference ref="EditorToggleShowIndentLines" />
         <separator/>
-        <action id="ToggleFullScreenMode" class="com.intellij.ide.actions.ToggleFullScreenModeAction"/>
         <action id="QuickChangeScheme" class="com.intellij.ide.actions.QuickChangeSchemesAction"/>
         <separator/>
         <action id="EditSource" class="com.intellij.ide.actions.EditSourceAction"/>
 
     <group id="EditorGutterPopupMenu">
       <reference ref="EditorToggleShowLineNumbers"/>
+      <reference ref="EditorToggleShowIndentLines" />
     </group>
 
     <group id="FileChooserToolbar">
index 3cda844c395d507ced0c027decee9cbcaa253de2..ad3c02c4593f4b81ce3605ace6a10c3cc41a71be 100644 (file)
@@ -17,10 +17,14 @@ package com.intellij.testFramework;
 
 import com.intellij.lexer.Lexer;
 import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.tree.IElementType;
 import org.jetbrains.annotations.NonNls;
 
+import java.io.File;
+import java.io.IOException;
+
 /**
  * @author peter
  */
@@ -30,7 +34,7 @@ public abstract class LexerTestCase extends UsefulTestCase {
     Lexer lexer = createLexer();
     lexer.start(text);
     String result = "";
-    for (; ;) {
+    while (true) {
       IElementType tokenType = lexer.getTokenType();
       if (tokenType == null) {
         break;
@@ -42,7 +46,18 @@ public abstract class LexerTestCase extends UsefulTestCase {
       lexer.advance();
     }
     assertSameLinesWithFile(PathManager.getHomePath() + "/" + getDirPath() + "/" + getTestName(true) + ".txt", result);
+  }
 
+  protected void doFileTest(@NonNls String fileExt) {
+    String fileName = PathManager.getHomePath() + "/" + getDirPath() + "/" + getTestName(true) + "." + fileExt;
+    String text = "";
+    try {
+      text = new String(FileUtil.loadFileText(new File(fileName))).trim();
+    }
+    catch (IOException e) {
+      fail("can't load file " + fileName + ": " + e.getMessage());
+    }
+    doTest(text);
   }
 
   private static String getTokenText(Lexer lexer) {
index 800f286f6b6f8e633fef2fdefde4eb3d214162f4..3ec6a5aa7281f472521687c0dcec3097286a5a6a 100644 (file)
  */
 package com.intellij.testFramework;
 
+import com.intellij.ide.DataManager;
 import com.intellij.ide.util.treeView.AbstractTreeNode;
 import com.intellij.ide.util.treeView.AbstractTreeStructure;
 import com.intellij.idea.Bombed;
 import com.intellij.openapi.Disposable;
+import com.intellij.openapi.actionSystem.ActionManager;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.Presentation;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.extensions.ExtensionPoint;
 import com.intellij.openapi.extensions.ExtensionPointName;
@@ -273,4 +278,15 @@ public class PlatformTestUtil {
   public static void assertTreeStructureEquals(final AbstractTreeStructure treeStructure, final String expected) {
     Assert.assertEquals(expected, print(treeStructure, treeStructure.getRootElement(), 0, null, -1, ' ').toString());
   }
+
+  public static void invokeNamedAction(final String actionId) {
+    final AnAction action = ActionManager.getInstance().getAction(actionId);
+    Assert.assertNotNull(action);
+    final Presentation presentation = new Presentation();
+    final AnActionEvent event =
+        new AnActionEvent(null, DataManager.getInstance().getDataContext(), "", presentation, ActionManager.getInstance(), 0);
+    action.update(event);
+    Assert.assertTrue(presentation.isEnabled());
+    action.actionPerformed(event);
+  }
 }
index 469ca5d8c8fa370684bd4721943714944a223a6a..9035ea177d7188b7f749c680e039cba4c308d15c 100644 (file)
@@ -33,7 +33,6 @@ import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiManager;
 import com.intellij.psi.PsiReference;
 import com.intellij.testFramework.TestDataFile;
-import com.intellij.testFramework.TestDataPath;
 import com.intellij.usageView.UsageInfo;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -173,15 +172,19 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
   PsiReference getReferenceAtCaretPositionWithAssertion(@NonNls String... filePaths) throws Exception;
 
   /**
-   * Collects available intentions in the whole file or at caret position if {@link #CARET_MARKER} presents.
+   * Collects available intentions at caret position.
    *
    * @param filePaths the first file is tested only; the others are just copied along with the first.
    * @return available intentions.
    * @throws Exception any exception.
+   * @see #CARET_MARKER
    */
   @NotNull
   List<IntentionAction> getAvailableIntentions(@NonNls String... filePaths) throws Exception;
 
+  @NotNull
+  List<IntentionAction> getAllQuickFixes(@NonNls String... filePaths) throws Exception;
+
   @NotNull
   List<IntentionAction> getAvailableIntentions() throws Exception;
 
index 84fba5db90805cadcd691912bb18900e9ca4549c..d0f5efb3aba4c0fd912f0fe39efc0982e3ff7bff 100644 (file)
@@ -393,8 +393,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
   @NotNull
   public List<IntentionAction> getAvailableIntentions(final String... filePaths) throws Exception {
 
-    final Project project = myProjectFixture.getProject();
-    return new WriteCommandAction<List<IntentionAction>>(project) {
+    return new WriteCommandAction<List<IntentionAction>>(myProjectFixture.getProject()) {
       protected void run(final Result<List<IntentionAction>> result) throws Exception {
         configureByFilesInner(filePaths);
         result.setResult(getAvailableIntentions());
@@ -402,6 +401,23 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
     }.execute().getResultObject();
   }
 
+  @NotNull
+  public List<IntentionAction> getAllQuickFixes(@NonNls final String... filePaths) {
+    return new WriteCommandAction<List<IntentionAction>>(myProjectFixture.getProject()) {
+      protected void run(final Result<List<IntentionAction>> result) throws Exception {
+        configureByFilesInner(filePaths);
+        List<HighlightInfo> infos = doHighlighting();
+        ArrayList<IntentionAction> actions = new ArrayList<IntentionAction>();
+        for (HighlightInfo info : infos) {
+          for (Pair<HighlightInfo.IntentionActionDescriptor, TextRange> pair : info.quickFixActionRanges) {
+            actions.add(pair.getFirst().getAction());
+          }
+        }
+        result.setResult(actions);
+      }
+    }.execute().getResultObject();
+  }
+
   @NotNull
   public List<IntentionAction> getAvailableIntentions() {
     doHighlighting();
index 485568e58bedf6fb212ef316fb83c6b8bcef2574..15b8a91426ff113bd6d3c0c4c0e6f5f4afcee72a 100644 (file)
@@ -870,11 +870,8 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
   private boolean checkReadonlyUsages() {
     final Set<VirtualFile> readOnlyUsages = getReadOnlyUsagesFiles();
 
-    if (!readOnlyUsages.isEmpty()) {
-      return
-        !ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(VfsUtil.toVirtualFileArray(readOnlyUsages)).hasReadonlyFiles();
-    }
-    return true;
+    return readOnlyUsages.isEmpty() ||
+           !ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(VfsUtil.toVirtualFileArray(readOnlyUsages)).hasReadonlyFiles();
   }
 
   private Set<Usage> getReadOnlyUsages() {
index dce7574f02c35d9aff0a80641a5ebef6d32ca30d..6ff4a33514c5be3d28ea01fa863531e759ef06f7 100644 (file)
@@ -229,10 +229,7 @@ public class PathManager {
       path = SystemProperties.getUserHome() + path.substring(1);
     }
 
-    File file = new File(path);
-    if (!file.exists()) return path;
-    file = file.getAbsoluteFile();
-    return file.getAbsolutePath();
+    return new File(path).getAbsolutePath();
   }
 
   @NonNls
index 444f20fe425b7b8aad62bf0f5770933803f51cf7..e1ffe9abd97701e3cd046d8fa515e76b93a39e13 100644 (file)
@@ -112,12 +112,14 @@ public class ArrayUtil {
   @NotNull
   public static Object[] toObjectArray(@NotNull Collection<?> collection) {
     if (collection.isEmpty()) return EMPTY_OBJECT_ARRAY;
+    //noinspection SSBasedInspection
     return collection.toArray(new Object[collection.size()]);
   }
 
   @NotNull
   public static String[] toStringArray(@NotNull Collection<String> collection) {
     if (collection.isEmpty()) return EMPTY_STRING_ARRAY;
+    //noinspection SSBasedInspection
     return collection.toArray(new String[collection.size()]);
   }
 
diff --git a/platform/util/src/com/intellij/util/ui/Timer.java b/platform/util/src/com/intellij/util/ui/Timer.java
deleted file mode 100644 (file)
index eedce6e..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.intellij.util.ui;
-
-import com.intellij.openapi.Disposable;
-
-public abstract class Timer implements Disposable {
-
-  private Thread myThread;
-  private final int mySpan;
-
-  private volatile boolean myRunning;
-  private volatile boolean myDisposed;
-  private volatile boolean myRestartRequest;
-
-  private final String myName;
-
-  private volatile boolean myTakeInitialDelay = true;
-  private volatile boolean myInitiallySlept = false;
-  private volatile boolean myInterruptRequest;
-
-  public Timer(String name, int span) {
-    myName = name;
-    mySpan = span;
-    myThread = new Thread(name+" timer") {
-      public void run() {
-        try {
-          while(true) {
-            if (myInterruptRequest) break;
-
-            if (myTakeInitialDelay || myInitiallySlept) {
-              sleep(mySpan);
-            }
-            myInitiallySlept = true;
-
-            if (myRestartRequest) {
-              myRestartRequest = false;
-              continue;
-            }
-
-            if (myRunning) {
-              onTimer();
-            }
-          }
-        }
-        catch (InterruptedException e) {
-        }
-        myDisposed = true;
-      }
-    };
-    myThread.setPriority(Thread.MIN_PRIORITY + 1);
-  }
-
-  public void setTakeInitialDelay(final boolean take) {
-    myTakeInitialDelay = take;
-  }
-
-  public final int getSpan() {
-    return mySpan;
-  }
-
-  public final void start() {
-    assert !myThread.isAlive();
-    myThread.start();
-  }
-
-  protected abstract void onTimer() throws InterruptedException;
-
-  public final void suspend() {
-    if (myDisposed) return;
-
-    if (myThread.isAlive()) {
-      myRunning = false;
-    }
-    myInitiallySlept = false;
-  }
-
-  public final void resume() {
-    startIfNeeded();
-    myRunning = true;
-  }
-
-  private void startIfNeeded() {
-    if (myDisposed) return;
-
-    if (!myThread.isAlive()) {
-      start();
-    }
-  }
-
-  public final void dispose() {
-    if (myThread != null) {
-      startIfNeeded();
-      myInterruptRequest = true;
-      myThread.interrupt();
-      myDisposed = true;
-      myThread = null;
-    }
-  }
-
-  public void restart() {
-    startIfNeeded();
-    myRestartRequest = true;
-  }
-
-  public String toString() {
-    return "Timer=" + myName;
-  }
-
-  public boolean isRunning() {
-    return myRunning;
-  }
-
-  public boolean isDisposed() {
-    return myDisposed;
-  }
-}
index 205fe585532fad949bd0f294126846cd6c592a43..7e68d4e2dcefc8b9f7a9c46851e09faec8dce615 100644 (file)
@@ -26,6 +26,7 @@ import javax.swing.*;
 public interface DebuggerIcons {
 
   Icon ENABLED_BREAKPOINT_ICON = IconLoader.getIcon("/debugger/db_set_breakpoint.png");
+  Icon MUTED_BREAKPOINT_ICON = IconLoader.getIcon("/debugger/db_muted_breakpoint.png");
   Icon DISABLED_BREAKPOINT_ICON = IconLoader.getIcon("/debugger/db_disabled_breakpoint.png");
   Icon INVALID_BREAKPOINT_ICON = IconLoader.getIcon("/debugger/db_invalid_breakpoint.png");
   Icon VERIFIED_BREAKPOINT_ICON = IconLoader.getIcon("/debugger/db_verified_breakpoint.png");
index 8edd16c099a5d1412eec09a5fc7eacda0f21672c..5b3394d8fa4a1cff1835e2b020a9aa202310b30e 100644 (file)
@@ -90,6 +90,9 @@ public abstract class DebuggerSupport {
   @NotNull
   public abstract QuickEvaluateHandler getQuickEvaluateHandler();
 
+  @NotNull
+  public abstract DebuggerActionHandler getAddToWatchesActionHandler();
+
   @NotNull
   public abstract DebuggerToggleActionHandler getMuteBreakpointsHandler();
 
index 56e027d696f33e30543c0f0f6c02122f252e36a9..0626bc48fd7ef4f03948b80497060a45f513e0cb 100644 (file)
@@ -50,12 +50,14 @@ public class XDebuggerSupport extends DebuggerSupport {
   private final XDebuggerEvaluateActionHandler myEvaluateHandler;
   private final XQuickEvaluateHandler myQuickEvaluateHandler;
   private final XDebuggerSettingsPanelProviderImpl mySettingsPanelProvider;
+  private final XAddToWatchesFromEditorActionHandler myAddToWatchesActionHandler;
   private final DebuggerToggleActionHandler myMuteBreakpointsHandler;
   private final DebuggerActionHandler mySmartStepIntoHandler;
 
   public XDebuggerSupport() {
     myBreakpointPanelProvider = new XBreakpointPanelProvider();
     myToggleLineBreakpointActionHandler = new XToggleLineBreakpointActionHandler();
+    myAddToWatchesActionHandler = new XAddToWatchesFromEditorActionHandler();
     myStepOverHandler = new XDebuggerSuspendedActionHandler() {
       protected void perform(@NotNull final XDebugSession session, final DataContext dataContext) {
         session.stepOver(false);
@@ -180,6 +182,12 @@ public class XDebuggerSupport extends DebuggerSupport {
     return myQuickEvaluateHandler;
   }
 
+  @NotNull
+  @Override
+  public DebuggerActionHandler getAddToWatchesActionHandler() {
+    return myAddToWatchesActionHandler;
+  }
+
   @NotNull
   public DebuggerToggleActionHandler getMuteBreakpointsHandler() {
     return myMuteBreakpointsHandler;
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AddToWatchesAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AddToWatchesAction.java
new file mode 100644 (file)
index 0000000..33bfc5a
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.xdebugger.impl.actions;
+
+import com.intellij.xdebugger.impl.DebuggerSupport;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author nik
+ */
+public class AddToWatchesAction extends XDebuggerActionBase {
+  public AddToWatchesAction() {
+    super(true);
+  }
+
+  @NotNull
+  @Override
+  protected DebuggerActionHandler getHandler(@NotNull DebuggerSupport debuggerSupport) {
+    return debuggerSupport.getAddToWatchesActionHandler();
+  }
+}
index a906f73af2b587235f262b8eeecf539b2c55b6b5..ce1621ff2213832305583d277808f44e584e6112 100644 (file)
@@ -45,6 +45,8 @@ public interface XDebuggerActions {
   @NonNls String WATCHES_TREE_POPUP_GROUP = "XDebugger.Watches.Tree.Popup";
   @NonNls String WATCHES_TREE_TOOLBAR_GROUP = "XDebugger.Watches.Tree.Toolbar";
 
+  @NonNls String ADD_TO_WATCH = "Debugger.AddToWatch";
+
   @NonNls String XNEW_WATCH = "XDebugger.NewWatch";
   @NonNls String XREMOVE_WATCH = "XDebugger.RemoveWatch";
   @NonNls String XEDIT_WATCH = "XDebugger.EditWatch";
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XAddToWatchesFromEditorActionHandler.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XAddToWatchesFromEditorActionHandler.java
new file mode 100644 (file)
index 0000000..f154bae
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.xdebugger.impl.actions.handlers;
+
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.xdebugger.XDebugSession;
+import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
+import com.intellij.xdebugger.frame.XStackFrame;
+import com.intellij.xdebugger.impl.XDebugSessionImpl;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author nik
+ */
+public class XAddToWatchesFromEditorActionHandler extends XDebuggerActionHandler {
+  @Override
+  protected boolean isEnabled(@NotNull XDebugSession session, DataContext dataContext) {
+    return getTextToEvaluate(dataContext, session) != null;
+  }
+
+  @Nullable
+  private static String getTextToEvaluate(DataContext dataContext, XDebugSession session) {
+    final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
+    if (editor == null) {
+      return null;
+    }
+
+    String text = editor.getSelectionModel().getSelectedText();
+    if (text == null && session.isSuspended()) {
+      final XStackFrame stackFrame = session.getCurrentStackFrame();
+      if (stackFrame != null) {
+        final XDebuggerEvaluator evaluator = stackFrame.getEvaluator();
+        if (evaluator != null) {
+          final int offset = editor.getCaretModel().getOffset();
+          final Document document = editor.getDocument();
+          final TextRange textRange = evaluator.getExpressionRangeAtOffset(session.getProject(), document, offset);
+          if (textRange != null) {
+            text = textRange.substring(document.getText());
+          }
+        }
+      }
+    }
+
+    return StringUtil.isEmptyOrSpaces(text) ? null : text;
+  }
+
+  @Override
+  protected void perform(@NotNull XDebugSession session, DataContext dataContext) {
+    final String text = getTextToEvaluate(dataContext, session);
+    if (text == null) return;
+
+    ((XDebugSessionImpl)session).getSessionTab().getWatchesView().addWatchExpression(text, -1);
+  }
+}
index 8b76c7d74ad560b9b24a0b7b19f0fe229687a037..e47faa4155a30805cb6b64a6b8c9830b89570695 100644 (file)
@@ -76,13 +76,12 @@ public class XWatchesView extends XDebugViewBase implements DnDNativeTarget {
   }
 
   public void addWatchExpression(@NotNull String expression, int index) {
+    XDebuggerEvaluator evaluator = null;
     XStackFrame stackFrame = mySession.getCurrentStackFrame();
     if (stackFrame != null) {
-      XDebuggerEvaluator evaluator = stackFrame.getEvaluator();
-      if (evaluator != null) {
-        myRootNode.addWatchExpression(evaluator, expression, index);
-      }
+      evaluator = stackFrame.getEvaluator();
     }
+    myRootNode.addWatchExpression(evaluator, expression, index);
   }
 
   protected void rebuildView(final SessionEvent event) {
index 2ca705576cdd69aba8225272aa3545821c70af6e..b5065519c4e1536b35ea8c15472fd885dc994b25 100644 (file)
@@ -111,15 +111,17 @@ public class WatchesRootNode extends XDebuggerTreeNode {
     }
   }
 
-  public void addWatchExpression(final @NotNull XDebuggerEvaluator evaluator, final @NotNull String expression, int index) {
-    WatchNode message = WatchMessageNode.createEvaluatingNode(myTree, this, expression);
+  public void addWatchExpression(final @Nullable XDebuggerEvaluator evaluator, final @NotNull String expression, int index) {
+    WatchNode message = evaluator != null ? WatchMessageNode.createEvaluatingNode(myTree, this, expression) : WatchMessageNode.createMessageNode(myTree, this, expression);
     if (index == -1) {
       myChildren.add(message);
     }
     else {
       myChildren.add(index, message);
     }
-    evaluator.evaluate(expression, new MyEvaluationCallback(message), null);
+    if (evaluator != null) {
+      evaluator.evaluate(expression, new MyEvaluationCallback(message), null);
+    }
     fireNodeChildrenChanged();
   }
 
index f60c2dea5a20152a1df1d35c90dbbcfdc080288a..e8774a46507919cabcb03d01fe0971908986be1b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2007-2010 Dave Griffith, Bas Leijdekkers
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,14 +20,14 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiExpression;
 import com.intellij.psi.PsiJavaToken;
 import com.intellij.util.IncorrectOperationException;
+import com.siyeh.IntentionPowerPackBundle;
 import com.siyeh.ipp.base.MutablyNamedIntention;
 import com.siyeh.ipp.base.PsiElementPredicate;
-import com.siyeh.ipp.psiutils.ComparisonUtils;
-import com.siyeh.IntentionPowerPackBundle;
 import org.jetbrains.annotations.NotNull;
 
 public class FlipExpressionIntention extends MutablyNamedIntention {
 
+    @Override
     public String getTextForElement(PsiElement element) {
         final PsiBinaryExpression expression = (PsiBinaryExpression)element;
         final PsiJavaToken sign = expression.getOperationSign();
@@ -36,19 +36,31 @@ public class FlipExpressionIntention extends MutablyNamedIntention {
                 operatorText);
     }
 
+    @Override
     @NotNull
     public PsiElementPredicate getElementPredicate() {
         return new ExpressionPredicate();
     }
 
+    @Override
     public void processIntention(@NotNull PsiElement element)
             throws IncorrectOperationException {
         final PsiBinaryExpression expression = (PsiBinaryExpression)element;
         final PsiExpression lhs = expression.getLOperand();
         final PsiExpression rhs = expression.getROperand();
         final PsiJavaToken sign = expression.getOperationSign();
-        assert rhs != null;
-        final String expString = rhs.getText() + sign.getText() + lhs.getText();
-        replaceExpression(expString, expression);
+        if (rhs == null) {
+            return;
+        }
+        final String signText = sign.getText();
+        final String lhsText = lhs.getText();
+        final String rhsText = rhs.getText();
+        final StringBuilder newExpression = new StringBuilder(rhsText);
+        newExpression.append(signText);
+        if (lhsText.startsWith(signText)) {
+            newExpression.append(' ');
+        }
+        newExpression.append(lhsText);
+        replaceExpression(newExpression.toString(), expression);
     }
 }
\ No newline at end of file
index d24e5dcfe238e7ec1004d12b31f4586612726db2..5be2ca2b278624f41c63d2fb768c547ad907cdac 100644 (file)
@@ -47,7 +47,6 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrConstructorInvocation;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
@@ -644,7 +643,7 @@ public class GroovyToJavaGenerator {
       }
 
       text.append("\n  ");
-      writeFieldModifiers(text, modifierList, JAVA_MODIFIERS, variable);
+      writeFieldModifiers(text, modifierList, JAVA_MODIFIERS);
 
       //type
       text.append(type).append(" ").append(name).append(" = ").append(initializer).append(";\n");
@@ -673,7 +672,7 @@ public class GroovyToJavaGenerator {
     PsiType retType;
     if (method instanceof GrMethod) {
       retType = ((GrMethod) method).getDeclaredReturnType();
-      if (retType == null) retType = TypesUtil.getJavaLangObject((GrMethod) method);
+      if (retType == null) retType = TypesUtil.getJavaLangObject(method);
     } else retType = method.getReturnType();
 
     text.append(getTypeText(retType, false));
@@ -731,17 +730,8 @@ public class GroovyToJavaGenerator {
     return wasAddedModifiers;
   }
 
-  private static void writeFieldModifiers(StringBuffer text, GrModifierList modifierList, String[] modifiers, GrVariable variable) {
-    final boolean isProperty = variable instanceof GrField && !modifierList.hasExplicitVisibilityModifiers() && !(((GrField)variable).getContainingClass().isInterface());
-    if (isProperty) {
-      text.append("private ");
-    }
-
+  private static void writeFieldModifiers(StringBuffer text, GrModifierList modifierList, String[] modifiers) {
     for (String modifierType : modifiers) {
-      if (isProperty && modifierType.equals(PsiModifier.PUBLIC)) {
-        continue;
-      }
-
       if (modifierList.hasModifierProperty(modifierType)) {
         text.append(modifierType);
         text.append(" ");
index 6dd6f33c6bed6918c7d1a203a21a1073bf68b9a3..475a4f6a4b3aeb0f542a1bc39f5afc314977711f 100644 (file)
@@ -49,6 +49,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExp
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
 
 import java.util.ArrayList;
@@ -111,9 +112,11 @@ public class GroovyCompletionContributor extends CompletionContributor {
 
         }
         else if (reference instanceof GrReferenceElement) {
+          final boolean addGDKMethods = parameters.getInvocationCount() > 1;
           ((GrReferenceElement)reference).processVariants(new Consumer<Object>() {
             public void consume(Object element) {
               LookupElement lookupElement = LookupItemUtil.objectToLookupItem(element);
+              if (lookupElement.getObject() instanceof GrGdkMethod && !addGDKMethods) return;
               if (lookupElement instanceof LookupItem) {
                 lookupElement = ((LookupItem)lookupElement).setInsertHandler(new GroovyInsertHandlerAdapter());
               }
index d00322776531f84c4388fcd34e988a8b68da81d3..b573c33c0433c503af6428eb69c28866cba8da18 100644 (file)
@@ -121,9 +121,9 @@ public class GrModifierListImpl extends GroovyBaseElementImpl<GrModifierListStub
         !hasExplicitVisibilityModifiers()) { //properties are backed by private fields
       PsiElement pParent = parent.getParent().getParent();
       if (!(pParent instanceof PsiClass) || !((PsiClass)pParent).isInterface()) {
-        if (modifier.equals(GrModifier.PUBLIC)) return true;
+        if (modifier.equals(GrModifier.PRIVATE)) return true;
         if (modifier.equals(GrModifier.PROTECTED)) return false;
-        if (modifier.equals(GrModifier.PRIVATE)) return false;
+        if (modifier.equals(GrModifier.PUBLIC)) return false;
       }
       else {
         if (modifier.equals(GrModifier.STATIC)) return true;
index fce06d1b78d4176d4a436cadcf0e4a129c2817c1..2d8e8f3d93765db24840227887a10e05ed9c9603 100644 (file)
@@ -67,7 +67,10 @@ import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
 import org.jetbrains.plugins.groovy.lang.resolve.processors.*;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.EnumSet;
+import java.util.List;
 
 /**
  * @author ilyas
@@ -388,17 +391,70 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements
   private static class OurResolver implements ResolveCache.PolyVariantResolver<GrReferenceExpressionImpl> {
     public GroovyResolveResult[] resolve(GrReferenceExpressionImpl refExpr, boolean incompleteCode) {
       String name = refExpr.getReferenceName();
-      if (name == null) return null;
-      ResolverProcessor processor = getMethodOrPropertyResolveProcessor(refExpr, name, incompleteCode);
+      if (name == null) return GroovyResolveResult.EMPTY_ARRAY;
+
+      Kind kind = refExpr.getKind();
+      if (incompleteCode) {
+        ResolverProcessor processor = CompletionProcessor.createRefSameNameProcessor(refExpr, name);
+        resolveImpl(refExpr, processor);
+        GroovyResolveResult[] propertyCandidates = processor.getCandidates();
+        if (propertyCandidates.length > 0) return propertyCandidates;
+      }
+
+      if (kind == Kind.METHOD_OR_PROPERTY) {
+        final PsiType[] argTypes = PsiUtil.getArgumentTypes(refExpr, false, false);
+        PsiType thisType = getThisType(refExpr);
+
+        MethodResolverProcessor methodResolver =
+          new MethodResolverProcessor(name, refExpr, false, thisType, argTypes, refExpr.getTypeArguments());
+        resolveImpl(refExpr, methodResolver);
+        if (methodResolver.hasApplicableCandidates()) return methodResolver.getCandidates();
+
+        PropertyResolverProcessor propertyResolver = new PropertyResolverProcessor(name, refExpr);
+        resolveImpl(refExpr, propertyResolver);
+        if (propertyResolver.hasCandidates()) return propertyResolver.getCandidates();
+
+        final String[] names = GroovyPropertyUtils.suggestGettersName(name);
+        List<GroovyResolveResult> list = new ArrayList<GroovyResolveResult>();
+        for (String getterName : names) {
+          AccessorResolverProcessor getterResolver = new AccessorResolverProcessor(getterName, refExpr, true);
+          resolveImpl(refExpr, getterResolver);
+          list.addAll(Arrays.asList(getterResolver.getCandidates()));
+        }
+        if (list.size() > 0) return list.toArray(new GroovyResolveResult[list.size()]);
+        return methodResolver.getCandidates();
+      }
+      else if (kind == Kind.TYPE_OR_PROPERTY) {
+        ResolverProcessor processor = new PropertyResolverProcessor(name, refExpr);
+        resolveImpl(refExpr, processor);
+        final GroovyResolveResult[] fieldCandidates = processor.getCandidates();
+
+        //if reference expression is in class we need to return field instead of accessor method
+        for (GroovyResolveResult candidate : fieldCandidates) {
+          final PsiElement element = candidate.getElement();
+          if (element instanceof PsiField) {
+            final PsiClass containingClass = ((PsiField)element).getContainingClass();
+            if (containingClass != null && PsiTreeUtil.isAncestor(containingClass, refExpr, true)) return fieldCandidates;
+          } else {
+            return fieldCandidates;
+          }
+        }
 
-      resolveImpl(refExpr, processor);
+        final boolean isLValue = PsiUtil.isLValue(refExpr);
+        String[] names;
+        names = isLValue ? GroovyPropertyUtils.suggestSettersName(name) : GroovyPropertyUtils.suggestGettersName(name);
+        List<GroovyResolveResult> list = new ArrayList<GroovyResolveResult>();
+        for (String getterName : names) {
+          AccessorResolverProcessor accessorResolver = new AccessorResolverProcessor(getterName, refExpr, !isLValue);
+          resolveImpl(refExpr, accessorResolver);
+          list.addAll(Arrays.asList(accessorResolver.getCandidates()));
+        }
+        if (list.size() > 0) return list.toArray(new GroovyResolveResult[list.size()]);
+        if (fieldCandidates.length > 0) return fieldCandidates;
 
-      GroovyResolveResult[] propertyCandidates = processor.getCandidates();
-      if (propertyCandidates.length > 0) return propertyCandidates;
-      if (refExpr.getKind() == Kind.TYPE_OR_PROPERTY) {
-        EnumSet<ClassHint.ResolveKind> kinds = refExpr.getParent() instanceof GrReferenceExpression ?
-                EnumSet.of(ClassHint.ResolveKind.CLASS, ClassHint.ResolveKind.PACKAGE) :
-                EnumSet.of(ClassHint.ResolveKind.CLASS);
+        EnumSet<ClassHint.ResolveKind> kinds = refExpr.getParent() instanceof GrReferenceExpression
+                                               ? EnumSet.of(ClassHint.ResolveKind.CLASS, ClassHint.ResolveKind.PACKAGE)
+                                               : EnumSet.of(ClassHint.ResolveKind.CLASS);
         ResolverProcessor classProcessor = new ClassResolverProcessor(refExpr.getReferenceName(), refExpr, kinds);
         resolveImpl(refExpr, classProcessor);
         return classProcessor.getCandidates();
@@ -518,22 +574,6 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements
     }
   }
 
-  private static ResolverProcessor getMethodOrPropertyResolveProcessor(GrReferenceExpression refExpr, String name, boolean incomplete) {
-    if (incomplete) return CompletionProcessor.createRefSameNameProcessor(refExpr, name);
-
-    Kind kind = ((GrReferenceExpressionImpl) refExpr).getKind();
-    ResolverProcessor processor;
-    if (kind == Kind.METHOD_OR_PROPERTY) {
-      final PsiType[] argTypes = PsiUtil.getArgumentTypes(refExpr, false, false);
-      PsiType thisType = getThisType(refExpr);
-      processor = new MethodResolverProcessor(name, refExpr, false, thisType, argTypes, refExpr.getTypeArguments());
-    } else {
-      processor = new PropertyResolverProcessor(name, refExpr);
-    }
-
-    return processor;
-  }
-
   private static PsiType getThisType(GrReferenceExpression refExpr) {
     GrExpression qualifier = refExpr.getQualifierExpression();
     if (qualifier != null) {
index d7e6183e48572713fdeb5671ac0f20769e248aa7..e8ede41cdbda824f499d5c699cb3daaeac02a05d 100644 (file)
@@ -168,6 +168,14 @@ public class GroovyPropertyUtils {
     return false;
   }
 
+  public static String[] suggestGettersName(@NotNull String name) {
+    return new String[]{"get"+capitalize(name), "is"+capitalize(name)};
+  }
+
+  public static String[] suggestSettersName(@NotNull String name) {
+    return new String[]{"set"+capitalize(name)};
+  }
+
   public static boolean isSetterName(String name) {
     return name != null && name.startsWith("set") && name.length() > 3 && isUpperCase(name.charAt(3));
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java
new file mode 100644 (file)
index 0000000..4c440c1
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.resolve.processors;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.PsiType;
+import com.intellij.psi.ResolveState;
+import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
+
+import java.util.EnumSet;
+
+/**
+ * @author Maxim.Medvedev
+ */
+public class AccessorResolverProcessor extends ResolverProcessor {
+  private boolean mySearchForGetter;
+
+  public AccessorResolverProcessor(String name, PsiElement place, boolean searchForGetter) {
+    super(name, EnumSet.of(ResolveKind.METHOD), place, PsiType.EMPTY_ARRAY);
+    mySearchForGetter = searchForGetter;
+  }
+
+  public boolean execute(PsiElement element, ResolveState state) {
+    if (mySearchForGetter) {
+      if (element instanceof PsiMethod && GroovyPropertyUtils.isSimplePropertyGetter((PsiMethod)element)) {
+        return super.execute(element, state);
+      }
+    }
+    else {
+      if (element instanceof PsiMethod && GroovyPropertyUtils.isSimplePropertySetter((PsiMethod)element)) {
+        return super.execute(element, state);
+      }
+    }
+    return true;
+  }
+}
\ No newline at end of file
index b24d3fef81d5ef9a9ae654e50c95ea16557fe4a5..32d18ea2af0f44b37552496227516e5ea14f578e 100644 (file)
@@ -26,15 +26,12 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
-import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
@@ -72,6 +69,7 @@ public class MethodResolverProcessor extends ResolverProcessor {
     PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
     if (element instanceof PsiMethod) {
       PsiMethod method = (PsiMethod) element;
+      
       if (method.isConstructor() != myIsConstructor) return true;
       if (substitutor == null) substitutor = PsiSubstitutor.EMPTY;
       substitutor = obtainSubstitutor(substitutor, method);
@@ -85,17 +83,6 @@ public class MethodResolverProcessor extends ResolverProcessor {
 
       return true;
     }
-    else if (element instanceof PsiVariable) {
-      if (isApplicableClosure((PsiVariable)element)) {
-        myCandidates.add(new GroovyResolveResultImpl(element, myCurrentFileResolveContext, substitutor, isAccessible((PsiVariable)element),
-                                                     isStaticsOK((PsiVariable)element)));
-      }
-      else {
-        myInapplicableCandidates.add(
-          new GroovyResolveResultImpl(element, myCurrentFileResolveContext, substitutor, isAccessible((PsiVariable)element),
-                                      isStaticsOK((PsiVariable)element)));
-      }
-    }
 
     return true;
   }
@@ -130,18 +117,6 @@ public class MethodResolverProcessor extends ResolverProcessor {
     return substitutor;
   }
 
-  private boolean isApplicableClosure(PsiVariable variable) {
-    if (variable instanceof GrVariable) {
-      final PsiType type = ((GrVariable)variable).getTypeGroovy();
-      if (type == null) return false;
-      if (type instanceof GrClosureType) {
-        return PsiUtil.isApplicable(myArgumentTypes, (GrClosureType)type, variable.getManager());
-      }
-      if (type.equalsToText(GrClosableBlock.GROOVY_LANG_CLOSURE)) return true;
-    }
-    return variable.getType().equalsToText(GrClosableBlock.GROOVY_LANG_CLOSURE);
-  }
-
   private PsiSubstitutor inferMethodTypeParameters(PsiMethod method, PsiSubstitutor partialSubstitutor, final PsiTypeParameter[] typeParameters, final PsiType[] argTypes) {
     if (typeParameters.length == 0) return partialSubstitutor;
 
@@ -237,13 +212,10 @@ public class MethodResolverProcessor extends ResolverProcessor {
     PsiManager manager = myPlace.getManager();
     GlobalSearchScope scope = myPlace.getResolveScope();
 
-    boolean methodsPresent = array[0].getElement() instanceof PsiMethod;
-    boolean propertiesPresent = !methodsPresent;
     Outer:
     for (int i = 1; i < array.length; i++) {
       PsiElement currentElement = array[i].getElement();
       if (currentElement instanceof PsiMethod) {
-        methodsPresent = true;
         PsiMethod currentMethod = (PsiMethod) currentElement;
         for (Iterator<GroovyResolveResult> iterator = result.iterator(); iterator.hasNext();) {
           final GroovyResolveResult otherResolveResult = iterator.next();
@@ -258,20 +230,11 @@ public class MethodResolverProcessor extends ResolverProcessor {
             }
           }
         }
-      } else {
-        propertiesPresent = true;
       }
 
       result.add(array[i]);
     }
 
-    if (methodsPresent && propertiesPresent) {
-      for (Iterator<GroovyResolveResult> iterator = result.iterator(); iterator.hasNext();) {
-        GroovyResolveResult resolveResult = iterator.next();
-        if (!(resolveResult.getElement() instanceof PsiMethod)) iterator.remove();
-      }
-    }
-
     return result.toArray(new GroovyResolveResult[result.size()]);
   }
 
@@ -320,6 +283,10 @@ public class MethodResolverProcessor extends ResolverProcessor {
     return super.hasCandidates() || !myInapplicableCandidates.isEmpty();
   }
 
+  public boolean hasApplicableCandidates() {
+    return !myCandidates.isEmpty();
+  }
+
   @Nullable
   public PsiType[] getArgumentTypes() {
     return myArgumentTypes;
index 2974c45b0f728ab27a2455c69ddb7abf2dca2c0a..f534236f053f3e2cb7f1595a94c99f3c3e1b5a46 100644 (file)
 
 package org.jetbrains.plugins.groovy.lang.resolve.processors;
 
-import com.intellij.openapi.util.Key;
-import com.intellij.psi.*;
-import com.intellij.psi.scope.NameHint;
-import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import com.intellij.psi.ResolveState;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrThisReferenceExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
-import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl;
-import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
-import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
 import java.util.EnumSet;
 
@@ -42,60 +32,14 @@ public class PropertyResolverProcessor extends ResolverProcessor {
   private GroovyResolveResult myProperty = null;
 
   public PropertyResolverProcessor(String name, PsiElement place) {
-    super(name, EnumSet.of(ResolveKind.METHOD, ResolveKind.PROPERTY), place, PsiType.EMPTY_ARRAY);
+    super(name, EnumSet.of(ResolveKind.PROPERTY), place, PsiType.EMPTY_ARRAY);
   }
 
   public boolean execute(PsiElement element, ResolveState state) {
-    if (myName != null && element instanceof PsiMethod && !(element instanceof GrAccessorMethod)) {
-      PsiMethod method = (PsiMethod)element;
-      boolean lValue = myPlace instanceof GroovyPsiElement && PsiUtil.isLValue((GroovyPsiElement)myPlace);
-      if (!lValue && GroovyPropertyUtils.isSimplePropertyGetter(method, myName) ||
-          lValue && GroovyPropertyUtils.isSimplePropertySetter(method, myName)) {
-        if (method instanceof GrMethod && isFieldReferenceInSameClass(method, myName)) {
-          return true;
-        }
-
-        myCandidates.clear();
-        super.execute(element, state);
-        return false;
-      }
-    }
-    else if (myName == null || myName.equals(((PsiNamedElement)element).getName())) {
-      if (element instanceof GrField && ((GrField)element).isProperty()) {
-        if (myProperty == null) {
-          boolean isAccessible = isAccessible((PsiNamedElement)element);
-          boolean isStaticsOK = isStaticsOK((PsiNamedElement)element);
-
-          PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
-          substitutor = substitutor == null ? PsiSubstitutor.EMPTY : substitutor;
-          myProperty = new GroovyResolveResultImpl(element, myCurrentFileResolveContext, substitutor, isAccessible, isStaticsOK);
-        }
-        return true;
-      }
-      else if (element instanceof GrReferenceExpression) {
-        if (((GrReferenceExpression)element).getQualifier() != null) {
-          return true;
-        }
-      }
-      return super.execute(element, state);
-    }
-
-    return true;
-  }
-
-  private boolean isFieldReferenceInSameClass(final PsiMethod method, final String fieldName) {
-    if (!(myPlace instanceof GrReferenceExpression)) {
-      return false;
-    }
-
-    final PsiClass containingClass = method.getContainingClass();
-    if (containingClass == null || !PsiTreeUtil.isAncestor(containingClass, myPlace, true)) return false;
-    final GrExpression qualifier = ((GrReferenceExpression)myPlace).getQualifierExpression();
-    if (qualifier != null && !(qualifier instanceof GrThisReferenceExpression)) {
-      return false;
+    if (element instanceof GrReferenceExpression && ((GrReferenceExpression)element).getQualifier() != null) {
+      return true;
     }
-
-    return containingClass.findFieldByName(fieldName, false) != null;
+    return super.execute(element, state);
   }
 
   @NotNull
@@ -111,13 +55,8 @@ public class PropertyResolverProcessor extends ResolverProcessor {
     return super.getCandidates();
   }
 
-  public <T> T getHint(Key<T> hintKey) {
-    if (NameHint.KEY == hintKey) {
-      //we cannot provide name hint here
-      return null;
-    }
-
-    return super.getHint(hintKey);
+  @Override
+  public boolean hasCandidates() {
+    return myProperty != null || super.hasCandidates();
   }
-
 }
index ce2ca46b45e549cdef0b15dbc32da625cbf13260..426b710047bcbcc78674ac584510ffdadf1d7645 100644 (file)
@@ -179,5 +179,4 @@ public class ResolverProcessor implements PsiScopeProcessor, NameHint, ClassHint
     //todo[DIANA] implement me!
     return myName;
   }
-
 }
index 419fa4733123b83af8961c134e1b6aed5124e612..e333b651c0b188fbc33581eabcb6597a8653b449 100644 (file)
@@ -78,7 +78,7 @@ public class GroovyCompletionTest extends LightCodeInsightFixtureTestCase {
     doBasicTest();
   }
 
-  private void doBasicTest() throws Throwable {
+  private void doBasicTest() throws Exception {
     myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + "_after.groovy");
   }
 
@@ -293,4 +293,8 @@ public class GroovyCompletionTest extends LightCodeInsightFixtureTestCase {
   public void testIncSmartCompletion() throws Exception {
     doSmartCompletion("a", "b");
   }
+
+  public void testFirstCompletionDontShowGDKMethods() throws Exception {
+    doBasicTest();
+  }
 }
index 4d65aedae35e0908d927daee73de2c031b80c305..eff21bf699a3e3978bdd953d8d67c7375a6a2687 100644 (file)
@@ -212,4 +212,9 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
   public void testSetInitializing() throws Exception {doTest();}
 
   public void testEmptyTupleAssignability() throws Exception {doTest();}
+
+  public void testGrDefFieldsArePrivateInJavaCode() throws Exception {
+    myFixture.configureByText("X.groovy", "public class X{def x=5}");
+    myFixture.testHighlighting(true, false, false, getTestName(false) + ".java");
+  }
 }
\ No newline at end of file
index 2303bf5f7d4cf86abbfb471a8518b7b9343e226c..18ffadc51ad50eb899e3f07ba628ced91ba96766 100644 (file)
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.resolve;
 
 import com.intellij.psi.*;
 import com.intellij.psi.util.PropertyUtil;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
@@ -552,4 +553,10 @@ public class ResolveMethodTest extends GroovyResolveTestCase {
     final PsiElement element = ref.resolve();
     assertInstanceOf(element, PsiMethod.class);
   }
+
+  public void testLocalVariableVsGetter() throws Exception {
+    final PsiReference ref = configureByFile("localVariableVsGetter/A.groovy");
+    final PsiElement element = ref.resolve();
+    assertInstanceOf(element, GrVariable.class);
+  }
 }
index 1c09dda2d964ab3244dae860b01766b613874f99..e5d66008a7137bd21fdea51e714e985883ca6e66 100644 (file)
@@ -290,6 +290,21 @@ class Foo {
     assertFalse ref.isReferenceTo(target.setter)
   }
 
+  public void testAliasedStaticImport() throws Exception {
+    myFixture.addClass """ class Main {
+  static def foo=4
+"""
+
+    myFixture.configureByText "a.groovy", """
+import static Main.foo as bar
+print ba<caret>r
+}
+"""
+    def ref = findReference()
+    def target = assertInstanceOf(ref.resolve(), PsiField)
+    assertEquals target.getName(), "foo"
+  }
+
   private void doTest(String fileName) throws Exception {
     PsiReference ref = configureByFile(fileName);
     PsiElement resolved = ref.resolve();
diff --git a/plugins/groovy/testdata/groovy/completion/FirstCompletionDontShowGDKMethods.groovy b/plugins/groovy/testdata/groovy/completion/FirstCompletionDontShowGDKMethods.groovy
new file mode 100644 (file)
index 0000000..997cf43
--- /dev/null
@@ -0,0 +1,13 @@
+class Foo {
+  def bar = 2
+
+  def bar() { 3 }
+
+  public static void main(String[] args) {
+    def f = new Foo()
+    println f.bar
+    println f.bar()
+
+    pr<caret>
+  }
+}
diff --git a/plugins/groovy/testdata/groovy/completion/FirstCompletionDontShowGDKMethods_after.groovy b/plugins/groovy/testdata/groovy/completion/FirstCompletionDontShowGDKMethods_after.groovy
new file mode 100644 (file)
index 0000000..f09856d
--- /dev/null
@@ -0,0 +1,13 @@
+class Foo {
+  def bar = 2
+
+  def bar() { 3 }
+
+  public static void main(String[] args) {
+    def f = new Foo()
+    println f.bar
+    println f.bar()
+
+    properties<caret>
+  }
+}
diff --git a/plugins/groovy/testdata/highlighting/GrDefFieldsArePrivateInJavaCode.java b/plugins/groovy/testdata/highlighting/GrDefFieldsArePrivateInJavaCode.java
new file mode 100644 (file)
index 0000000..c4961d7
--- /dev/null
@@ -0,0 +1,5 @@
+public class GrDefFieldsArePrivateInJavaCode {
+  public static void main(String[] args) {
+    System.out.println(new X().<error descr="'x' has private access in 'null'">x</error>);
+  }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/resolve/method/localVariableVsGetter/A.groovy b/plugins/groovy/testdata/resolve/method/localVariableVsGetter/A.groovy
new file mode 100644 (file)
index 0000000..46abb13
--- /dev/null
@@ -0,0 +1,11 @@
+class W {
+  def getFoo() {
+    return 4;
+  }
+
+  def a() {
+    def foo = 5;
+
+    print f<ref>oo;
+  }
+}
index e4ae08474bc3e048da79827bdb52df0e7268ebca..4c9657666fd550c475891763407b35e4c36a2944 100644 (file)
@@ -20,12 +20,15 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.codeStyle.NameUtil;
 import com.intellij.util.xml.DomElement;
 import com.intellij.util.xml.GenericDomValue;
+import com.intellij.util.xml.Required;
 import com.intellij.util.xml.XmlName;
 import com.intellij.util.xml.reflect.DomExtender;
 import com.intellij.util.xml.reflect.DomExtension;
 import com.intellij.util.xml.reflect.DomExtensionsRegistrar;
 import gnu.trove.THashMap;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.idea.maven.dom.converters.MavenDomConvertersRegistry;
+import org.jetbrains.idea.maven.dom.converters.MavenPluginCustomParameterValueConverter;
 import org.jetbrains.idea.maven.dom.model.MavenDomConfiguration;
 import org.jetbrains.idea.maven.dom.model.MavenDomConfigurationParameter;
 import org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution;
@@ -33,6 +36,7 @@ import org.jetbrains.idea.maven.dom.plugin.MavenDomMojo;
 import org.jetbrains.idea.maven.dom.plugin.MavenDomParameter;
 import org.jetbrains.idea.maven.dom.plugin.MavenDomPluginModel;
 
+import java.lang.annotation.Annotation;
 import java.util.*;
 
 public class MavenPluginConfigurationDomExtender extends DomExtender<MavenDomConfiguration> {
@@ -51,7 +55,7 @@ public class MavenPluginConfigurationDomExtender extends DomExtender<MavenDomCon
     }
   }
 
-  private Collection<MavenDomParameter> collectParameters(MavenDomPluginModel pluginModel, MavenDomConfiguration config) {
+  private static Collection<MavenDomParameter> collectParameters(MavenDomPluginModel pluginModel, MavenDomConfiguration config) {
     List<String> selectedGoals = null;
 
     MavenDomPluginExecution executionElement = config.getParentOfType(MavenDomPluginExecution.class, false);
@@ -84,7 +88,7 @@ public class MavenPluginConfigurationDomExtender extends DomExtender<MavenDomCon
     return namesWithParameters.values();
   }
 
-  private void registerPluginParameter(DomExtensionsRegistrar r, final MavenDomParameter parameter) {
+  private static void registerPluginParameter(DomExtensionsRegistrar r, final MavenDomParameter parameter) {
     String paramName = parameter.getName().getStringValue();
     String alias = parameter.getAlias().getStringValue();
 
@@ -92,7 +96,7 @@ public class MavenPluginConfigurationDomExtender extends DomExtender<MavenDomCon
     if (alias != null) registerPluginParameter(r, parameter, alias);
   }
 
-  private void registerPluginParameter(DomExtensionsRegistrar r, final MavenDomParameter parameter, final String parameterName) {
+  private static void registerPluginParameter(DomExtensionsRegistrar r, final MavenDomParameter parameter, final String parameterName) {
     DomExtension e;
     if (isCollection(parameter)) {
       e = r.registerFixedNumberChildExtension(new XmlName(parameterName), MavenDomConfigurationParameter.class);
@@ -107,13 +111,31 @@ public class MavenPluginConfigurationDomExtender extends DomExtender<MavenDomCon
     }
     else {
       e = r.registerFixedNumberChildExtension(new XmlName(parameterName), MavenDomConfigurationParameter.class);
+
+      addValueConverter(e, parameter);
+      addRequiredAnnotation(e, parameter);
     }
+
     e.putUserData(DomExtension.KEY_DECLARATION, parameter);
 
     parameter.getXmlElement().putUserData(PLUGIN_PARAMETER_KEY, parameter);
   }
 
-  public List<String> collectPossibleNameForCollectionParameter(String parameterName) {
+  private static void addValueConverter(DomExtension e, MavenDomParameter parameter) {
+    String type = parameter.getType().getStringValue();
+    if (!StringUtil.isEmptyOrSpaces(type) ) {
+        e.setConverter(new MavenPluginCustomParameterValueConverter(type), MavenDomConvertersRegistry.getInstance().isSoft(type));
+    }
+  }
+
+  private static void addRequiredAnnotation(DomExtension e, MavenDomParameter parameter) {
+    final String required = parameter.getRequired().getStringValue();
+    if (!StringUtil.isEmptyOrSpaces(required) ) {
+        e.addCustomAnnotation(new MyRequired(required));
+    }
+  }
+
+  public static List<String> collectPossibleNameForCollectionParameter(String parameterName) {
     String singularName = StringUtil.unpluralize(parameterName);
     if (singularName == null) singularName = parameterName;
 
@@ -125,7 +147,7 @@ public class MavenPluginConfigurationDomExtender extends DomExtender<MavenDomCon
     return result;
   }
 
-  private boolean isCollection(MavenDomParameter parameter) {
+  private static boolean isCollection(MavenDomParameter parameter) {
     String type = parameter.getType().getStringValue();
     if (type.endsWith("[]")) return true;
 
@@ -134,4 +156,28 @@ public class MavenPluginConfigurationDomExtender extends DomExtender<MavenDomCon
                                                    "java.util.Collection");
     return collectionClasses.contains(type);
   }
+
+  private static class MyRequired implements Required {
+    private final String myRequired;
+
+    public MyRequired(String required) {
+      myRequired = required;
+    }
+
+    public boolean value() {
+      return Boolean.valueOf(myRequired);
+    }
+
+    public boolean nonEmpty() {
+      return false;
+    }
+
+    public boolean identifier() {
+      return false;
+    }
+
+    public Class<? extends Annotation> annotationType() {
+      return Required.class;
+    }
+  }
 }
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDomConvertersRegistry.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDomConvertersRegistry.java
new file mode 100644 (file)
index 0000000..dfd23e2
--- /dev/null
@@ -0,0 +1,44 @@
+package org.jetbrains.idea.maven.dom.converters;
+
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.util.containers.hash.HashSet;
+import com.intellij.util.xml.converters.PathReferenceConverter;
+import com.intellij.util.xml.converters.values.GenericDomValueConvertersRegistry;
+
+import java.io.File;
+import java.util.Set;
+
+public class MavenDomConvertersRegistry {
+  protected GenericDomValueConvertersRegistry myConvertersRegistry;
+
+  private Set<String> mySoftConverterTypes = new HashSet<String>();
+
+  public static MavenDomConvertersRegistry getInstance() {
+    return ServiceManager.getService(MavenDomConvertersRegistry.class);
+  }
+
+  public MavenDomConvertersRegistry() {
+    myConvertersRegistry = new GenericDomValueConvertersRegistry();
+
+    initConverters();
+    initSoftConverterTypes();
+  }
+
+  private void initSoftConverterTypes() {
+    mySoftConverterTypes.add(File.class.getCanonicalName());
+  }
+
+  private void initConverters() {
+    myConvertersRegistry.registerDefaultConverters();
+
+    myConvertersRegistry.registerConverter(PathReferenceConverter.INSTANCE, File.class);
+  }
+
+  public GenericDomValueConvertersRegistry getConvertersRegistry() {
+    return myConvertersRegistry;
+  }
+
+  public boolean isSoft(String type) {
+    return mySoftConverterTypes.contains(type);
+  }
+}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenPluginCustomParameterValueConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenPluginCustomParameterValueConverter.java
new file mode 100644 (file)
index 0000000..1453e3c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.idea.maven.dom.converters;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.util.PsiTypesUtil;
+import com.intellij.util.xml.Converter;
+import com.intellij.util.xml.GenericDomValue;
+import com.intellij.util.xml.WrappingConverter;
+import com.intellij.util.xml.converters.values.GenericDomValueConvertersRegistry;
+import org.jetbrains.annotations.NotNull;
+
+public class MavenPluginCustomParameterValueConverter extends WrappingConverter {
+  private final String myType;
+
+  public MavenPluginCustomParameterValueConverter(@NotNull String type) {
+    myType = PsiTypesUtil.boxIfPossible(type);
+  }
+
+
+  @Override
+  public Converter getConverter(@NotNull GenericDomValue domElement) {
+    Project project = domElement.getManager().getProject();
+
+    JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
+    PsiClass psiClass = psiFacade.findClass(myType, GlobalSearchScope.allScope(project));
+    if (psiClass != null) {
+      GenericDomValueConvertersRegistry convertersRegistry = MavenDomConvertersRegistry.getInstance().getConvertersRegistry();
+      return convertersRegistry.getConverter(domElement, psiFacade.getElementFactory().createType(psiClass));
+    }
+
+    return null;
+  }
+
+}
\ No newline at end of file
index 07f2f894d4593b250f9b92004f97a38cddac6809..a15a8986e68ec31f9f9ac427f385edf5e9a6bc6d 100644 (file)
 
 package org.jetbrains.idea.maven.dom.model;
 
+import com.intellij.openapi.paths.PathReference;
+import com.intellij.util.xml.Convert;
 import com.intellij.util.xml.GenericDomValue;
 import com.intellij.util.xml.Required;
+import com.intellij.util.xml.converters.PathReferenceConverter;
 import org.jetbrains.annotations.NotNull;
 
 /**
@@ -43,7 +46,8 @@ public interface MavenDomBuild extends MavenDomBuildBase {
    */
   @NotNull
   @Required(value = false, nonEmpty = true)
-  GenericDomValue<String> getSourceDirectory();
+  @Convert(value = PathReferenceConverter.class, soft = true)
+  GenericDomValue<PathReference> getSourceDirectory();
 
   /**
    * Returns the value of the scriptSourceDirectory child.
@@ -56,7 +60,8 @@ public interface MavenDomBuild extends MavenDomBuildBase {
    */
   @NotNull
   @Required(value = false, nonEmpty = true)
-  GenericDomValue<String> getScriptSourceDirectory();
+  @Convert(value = PathReferenceConverter.class, soft = true)
+  GenericDomValue<PathReference> getScriptSourceDirectory();
 
   /**
    * Returns the value of the testSourceDirectory child.
@@ -69,7 +74,8 @@ public interface MavenDomBuild extends MavenDomBuildBase {
    */
   @NotNull
   @Required(value = false, nonEmpty = true)
-  GenericDomValue<String> getTestSourceDirectory();
+  @Convert(value = PathReferenceConverter.class, soft = true)
+  GenericDomValue<PathReference> getTestSourceDirectory();
 
   /**
    * Returns the value of the outputDirectory child.
@@ -82,7 +88,8 @@ public interface MavenDomBuild extends MavenDomBuildBase {
    */
   @NotNull
   @Required(value = false, nonEmpty = true)
-  GenericDomValue<String> getOutputDirectory();
+  @Convert(value = PathReferenceConverter.class, soft = true)
+  GenericDomValue<PathReference> getOutputDirectory();
 
   /**
    * Returns the value of the testOutputDirectory child.
@@ -95,7 +102,8 @@ public interface MavenDomBuild extends MavenDomBuildBase {
    */
   @NotNull
   @Required(value = false, nonEmpty = true)
-  GenericDomValue<String> getTestOutputDirectory();
+  @Convert(value = PathReferenceConverter.class, soft = true)
+  GenericDomValue<PathReference> getTestOutputDirectory();
 
   /**
    * Returns the value of the extensions child.
index 9145f6ef6f5e465ea63dc96220d23c956b619575..1f939be555dc4da33099488cfdb66e420492baf8 100644 (file)
 
 package org.jetbrains.idea.maven.dom.model;
 
+import com.intellij.openapi.paths.PathReference;
+import com.intellij.util.xml.Convert;
 import com.intellij.util.xml.GenericDomValue;
 import com.intellij.util.xml.Required;
+import com.intellij.util.xml.converters.PathReferenceConverter;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.idea.maven.dom.MavenDomElement;
 
@@ -81,7 +84,8 @@ public interface MavenDomBuildBase extends MavenDomElement {
    */
   @NotNull
   @Required(value = false, nonEmpty = true)
-  GenericDomValue<String> getDirectory();
+  @Convert(value = PathReferenceConverter.class, soft = true)
+  GenericDomValue<PathReference> getDirectory();
 
   /**
    * Returns the value of the finalName child.
index 0f0d5d955486b138d97971ab21c661550ce7de4f..10dc8085a445946e56a47e26bf3ccd8cc1953b1b 100644 (file)
 package org.jetbrains.idea.maven.dom.model;
 
 import com.intellij.util.xml.CustomChildren;
+import com.intellij.util.xml.GenericDomValue;
 import org.jetbrains.idea.maven.dom.MavenDomElement;
 
 import java.util.List;
 
-public interface MavenDomConfigurationParameter extends MavenDomElement {
+public interface MavenDomConfigurationParameter extends MavenDomElement, GenericDomValue<Object> {
   @CustomChildren
   List<MavenDomConfigurationParameter> getChildren();
 }
index fddd2eddcbfc218bebf40a0e4e347dc0a5d335f1..d0047db4309ab6e68fad085ac4f8ae5a38e786bb 100644 (file)
 
 package org.jetbrains.idea.maven.dom.model;
 
+import com.intellij.openapi.paths.PathReference;
+import com.intellij.util.xml.Convert;
 import com.intellij.util.xml.GenericDomValue;
+import com.intellij.util.xml.converters.PathReferenceConverter;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.idea.maven.dom.MavenDomElement;
 
@@ -54,7 +57,8 @@ public interface MavenDomReporting extends MavenDomElement {
    * @return the value of the outputDirectory child.
    */
   @NotNull
-  GenericDomValue<String> getOutputDirectory();
+  @Convert(value = PathReferenceConverter.class, soft = true)
+  GenericDomValue<PathReference> getOutputDirectory();
 
   /**
    * Returns the value of the plugins child.
index d124a8bcb3df35861a3b7dfbc545c33c3dfd06bd..91a5742ce81d5abe63ab100238ef6d4c5e2a80e1 100644 (file)
 
 package org.jetbrains.idea.maven.dom.model;
 
+import com.intellij.openapi.paths.PathReference;
+import com.intellij.util.xml.Convert;
 import com.intellij.util.xml.GenericDomValue;
 import com.intellij.util.xml.Required;
+import com.intellij.util.xml.converters.PathReferenceConverter;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.idea.maven.dom.MavenDomElement;
 
@@ -44,7 +47,8 @@ public interface MavenDomResource extends MavenDomElement {
    */
   @NotNull
   @Required(value = false, nonEmpty = true)
-  GenericDomValue<String> getTargetPath();
+  @Convert(value = PathReferenceConverter.class, soft = true)
+  GenericDomValue<PathReference> getTargetPath();
 
   /**
    * Returns the value of the filtering child.
@@ -70,7 +74,8 @@ public interface MavenDomResource extends MavenDomElement {
    */
   @NotNull
   @Required(value = false, nonEmpty = true)
-  GenericDomValue<String> getDirectory();
+  @Convert(value = PathReferenceConverter.class, soft = true)
+  GenericDomValue<PathReference> getDirectory();
 
   /**
    * Returns the value of the includes child.
index 80e3caf157b8ccea962c540e7e718fc565721dc2..4f38daade1293963ab54478cd9e5635821e8c84d 100644 (file)
@@ -34,4 +34,6 @@ public interface MavenDomParameter extends MavenDomElement {
 
   @NotNull
   GenericDomValue<String> getDescription();
+
+  GenericDomValue<Boolean> getRequired();
 }
index b72eac68511c5c53aa25c8c1542cfa4986511c12..82cab0e506a396701463ff856f9005bbd8b6c358 100644 (file)
@@ -70,6 +70,9 @@
     <projectService serviceInterface="org.jetbrains.idea.maven.dom.MavenDomElementDescriptorHolder"
                     serviceImplementation="org.jetbrains.idea.maven.dom.MavenDomElementDescriptorHolder"/>
 
+    <applicationService serviceInterface="org.jetbrains.idea.maven.dom.converters.MavenDomConvertersRegistry"
+                    serviceImplementation="org.jetbrains.idea.maven.dom.converters.MavenDomConvertersRegistry"/>
+
     <applicationService serviceInterface="org.jetbrains.idea.maven.dom.converters.repositories.MavenRepositoriesProvider"
                     serviceImplementation="org.jetbrains.idea.maven.dom.converters.repositories.MavenRepositoriesProvider"/>
 
index a182d9881b9f9e670cb01eeff06e4fd32cffc121..76c998626cf81531e38c19da120b92d2102c2e52 100644 (file)
@@ -25,9 +25,9 @@ unused.message.format.parameter.problem.descriptor=Using parameter {0} without u
 unresolved.property.key=Cannot resolve property key
 unused.property.suppress.for.property=Suppress for this property
 unused.property.suppress.for.file=Suppress for whole file
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 action.I18nize.text=Internationali_ze...
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 action.I18nize.description=Replace Java string literal or JSP text with internationalized expression
 create.property.quickfix.text=Create Property
 unescape=Unescape
index 1c905d8329e1acdbe39922b53cbf8d8c63fff579..29e83d684e07db11e46826d89f09da3623630e2a 100644 (file)
@@ -16,25 +16,25 @@ annotation.may.not.have.extends.list=@interface may not have extends list
 annotation.name.is.missing=Annotation attribute must be of the form 'name=value'
 
 # These aren't unused.
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.ANNOTATION_TYPE=annotation type
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.TYPE=type
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.TYPE_USE=type use
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.TYPE_PARAMETER=type parameter
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.CONSTRUCTOR=constructor
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.METHOD=method
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.FIELD=field
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.PARAMETER=parameter
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.LOCAL_VARIABLE=local variable
-# suppress inspection "unused property"
+# suppress inspection "UnusedProperty"
 annotation.target.PACKAGE=package
 
 # generics related messages
index 44949004be2d3140745d9249d5bf88c9d9b4ef91..3624617973e91e89cfcf61ea47e0182296b95194 100644 (file)
 
     <codeStyleSettingsProvider implementation="com.intellij.application.options.GenerationSettingsProvider"/>
     <codeStyleSettingsProvider implementation="com.intellij.application.options.codeStyle.IndentAndBracesSettingsProvider"/>
-    <codeStyleSettingsProvider implementation="com.intellij.application.options.WrappingSettingsProvider"/>
+    <codeStyleSettingsProvider implementation="com.intellij.application.options.codeStyle.WrappingSettingsProvider"/>
     <codeStyleSettingsProvider implementation="com.intellij.application.options.codeStyle.BlankLinesSettingsProvider"/>
     <codeStyleSettingsProvider implementation="com.intellij.application.options.codeStyle.SpacesSettingsProvider"/>
     <codeStyleSettingsProvider implementation="com.intellij.application.options.ImportsSettingsProvider"/>
index db07ec7af1aca530872c20f6af1e28fe9c741871..cc1541b0cab0a255657e63655a37d2f412a9d6c5 100644 (file)
       <action id="Debugger.ShowFrame" class="com.intellij.debugger.actions.ShowFrameAction"/>
       <action id="Debugger.ResumeThread" class="com.intellij.debugger.actions.ResumeThreadAction"/>
       <action id="Debugger.FreezeThread" class="com.intellij.debugger.actions.FreezeThreadAction"/>
-      <action id="Debugger.AddToWatch" class="com.intellij.debugger.actions.AddToWatchAction" icon="/debugger/addToWatch.png"/>
       <action id="Debugger.FocusOnBreakpoint" class="com.intellij.debugger.ui.breakpoints.actions.FocusOnBreakpointAction"/>
 
     </group>
 
     <action id="AnalyzeStacktraceOnError" class="com.intellij.unscramble.AnalyzeStacktraceOnErrorAction" text="Analyze Stacktrace"/>
 
-    <group id="EditorPopupMenu2">
-      <separator/>
-      <reference ref="EvaluateExpression"/>
-      <reference ref="RunToCursor"/>
-      <reference ref="ForceRunToCursor"/>
-      <reference ref="Debugger.AddToWatch"/>
+    <group id="EditorPopupMenuDebugJava">
       <separator/>
       <reference ref="ToggleFieldBreakpoint"/>
       <separator/>
 
-      <add-to-group group-id="EditorLangPopupMenu" relative-to-action="EditorPopupMenu.Run" anchor="before"/>
+      <add-to-group group-id="EditorPopupMenuDebug" anchor="last"/>
     </group>
 
     <reference ref="Compile">
index 787d93d9d8add486a21d4e11c76c30a420e94a65..8fe2d86da40534d30413aaf8008335051533d3c2 100644 (file)
@@ -53,11 +53,11 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl implement
 
     final Type elemType = getType();
     if (elemType instanceof AnnotatedElement) {
-      return ((AnnotatedElement)elemType).getAnnotation(annotationClass);
-    }
-    else {
-      return super.getAnnotation(annotationClass);
+      T annotation = ((AnnotatedElement)elemType).getAnnotation(annotationClass);
+      if (annotation != null) return annotation;
     }
+
+    return super.getAnnotation(annotationClass);
   }
 
   public int getCount() {
@@ -73,10 +73,11 @@ public class FixedChildDescriptionImpl extends DomChildDescriptionImpl&nbs