summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-08-20 17:01:23 -0700
committerTor Norbye <tnorbye@google.com>2014-08-20 17:01:23 -0700
commit1aa2e09bdbd413eacb677e9fa4b50630530d0656 (patch)
tree2f4cc6d69645bd460aa253fdecb606d764fbd25d /platform
parent02cf98d65c798d368fcec43ed64a001d513bdd4f (diff)
downloadidea-1aa2e09bdbd413eacb677e9fa4b50630530d0656.tar.gz
Snapshot idea/138.1696 from git://git.jetbrains.org/idea/community.git
Change-Id: I50c97b83a815ce635e49a38380ba5b8765e4b16a
Diffstat (limited to 'platform')
-rw-r--r--platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java12
-rw-r--r--platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java3
-rw-r--r--platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolsRegistrarCore.java29
-rw-r--r--platform/analysis-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java4
-rw-r--r--platform/analysis-api/src/com/intellij/psi/search/scope/ProjectProductionScope.java6
-rw-r--r--platform/annotations/src/org/intellij/lang/annotations/Flow.java6
-rw-r--r--platform/bootstrap/src/com/intellij/ide/startup/StartupActionScriptManager.java22
-rw-r--r--platform/core-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java (renamed from platform/lang-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java)2
-rw-r--r--platform/core-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java23
-rw-r--r--platform/core-api/src/com/intellij/codeInsight/controlflow/Instruction.java (renamed from platform/lang-api/src/com/intellij/codeInsight/controlflow/Instruction.java)2
-rw-r--r--platform/core-api/src/com/intellij/concurrency/JobScheduler.java3
-rw-r--r--platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java14
-rw-r--r--platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java8
-rw-r--r--platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java47
-rw-r--r--platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java3
-rw-r--r--platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java15
-rw-r--r--platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java1
-rw-r--r--platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java2
-rw-r--r--platform/core-api/src/com/intellij/psi/PsiFileFactory.java4
-rw-r--r--platform/core-api/src/com/intellij/psi/PsiWalkingState.java7
-rw-r--r--platform/core-api/src/com/intellij/psi/ReferenceRange.java15
-rw-r--r--platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java7
-rw-r--r--platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java1
-rw-r--r--platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java4
-rw-r--r--platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java14
-rw-r--r--platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java18
-rw-r--r--platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationInfoEx.java4
-rw-r--r--platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java6
-rw-r--r--platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java14
-rw-r--r--platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java14
-rw-r--r--platform/core-impl/src/com/intellij/psi/impl/source/tree/PsiCommentImpl.java (renamed from platform/lang-impl/src/com/intellij/psi/impl/source/tree/PsiCommentImpl.java)2
-rw-r--r--platform/core-impl/src/com/intellij/psi/impl/source/tree/injected/CommentLiteralEscaper.java (renamed from platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/CommentLiteralEscaper.java)2
-rw-r--r--platform/duplicates-analysis/src/com/intellij/dupLocator/index/DuplicatesIndex.java2
-rw-r--r--platform/dvcs-api/dvcs-api.iml18
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/CommitLoader.java20
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingCommitsProvider.java35
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java41
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java26
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/PushSpec.java43
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/PushSupport.java88
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/PushTarget.java (renamed from platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudLoggingHandler.java)14
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/Pusher.java39
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/TreeNodeLinkListener.java24
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/VcsError.java43
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/VcsErrorHandler.java22
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionValue.java19
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionsPanel.java29
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushReferenceStrategy.java26
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/repo/Repository.java (renamed from platform/dvcs/src/com/intellij/dvcs/repo/Repository.java)4
-rw-r--r--platform/dvcs-api/src/com/intellij/dvcs/repo/RepositoryManager.java (renamed from platform/dvcs/src/com/intellij/dvcs/repo/RepositoryManager.java)0
-rw-r--r--platform/dvcs-impl/dvcs-impl.iml (renamed from platform/dvcs/dvcs.iml)3
-rw-r--r--platform/dvcs-impl/resources/icons/Loading@2x.gifbin0 -> 3233 bytes
-rw-r--r--platform/dvcs-impl/resources/icons/Loading@2x_dark.gifbin0 -> 3332 bytes
-rw-r--r--platform/dvcs-impl/resources/icons/loading.gifbin0 -> 1460 bytes
-rw-r--r--platform/dvcs-impl/resources/icons/loading_dark.gifbin0 -> 1496 bytes
-rw-r--r--platform/dvcs-impl/src/META-INF/dvcs.xml12
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/DvcsCommitAdditionalComponent.java (renamed from platform/dvcs/src/com/intellij/dvcs/DvcsCommitAdditionalComponent.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/DvcsPlatformFacade.java (renamed from platform/dvcs/src/com/intellij/dvcs/DvcsPlatformFacade.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/DvcsPlatformFacadeImpl.java (renamed from platform/dvcs/src/com/intellij/dvcs/DvcsPlatformFacadeImpl.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/DvcsRememberedInputs.java (renamed from platform/dvcs/src/com/intellij/dvcs/DvcsRememberedInputs.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/DvcsUtil.java (renamed from platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java)19
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java445
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/RepositoryNodeListener.java23
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/CustomRenderedTreeNode.java24
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/DvcsStrategyPanel.java43
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/EditableTreeNode.java33
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/LoadingTreeNode.java51
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/NodeImageObserver.java46
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java289
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLogTreeUtil.java52
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java97
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java185
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/SingleRepositoryNode.java52
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/TextWithLinkNode.java52
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/TooltipNode.java21
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsBranchEditorListener.java61
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsFullCommitDetailsNode.java54
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsLinkListener.java24
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsLinkedText.java70
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java144
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/repo/AbstractRepositoryManager.java (renamed from platform/dvcs/src/com/intellij/dvcs/repo/AbstractRepositoryManager.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/repo/RepoStateException.java (renamed from platform/dvcs/src/com/intellij/dvcs/repo/RepoStateException.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryImpl.java (renamed from platform/dvcs/src/com/intellij/dvcs/repo/RepositoryImpl.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryUtil.java (renamed from platform/dvcs/src/com/intellij/dvcs/repo/RepositoryUtil.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java (renamed from platform/dvcs/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java)5
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/CloneDvcsDialog.form (renamed from platform/dvcs/src/com/intellij/dvcs/ui/CloneDvcsDialog.form)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/CloneDvcsDialog.java (renamed from platform/dvcs/src/com/intellij/dvcs/ui/CloneDvcsDialog.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.java (renamed from platform/dvcs/src/com/intellij/dvcs/ui/DvcsBundle.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.properties (renamed from platform/dvcs/src/com/intellij/dvcs/ui/DvcsBundle.properties)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/NewBranchAction.java (renamed from platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java)5
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/RootAction.java (renamed from platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/VcsLogAction.java (renamed from platform/dvcs/src/com/intellij/dvcs/ui/VcsLogAction.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/VcsLogOneCommitPerRepoAction.java (renamed from platform/dvcs/src/com/intellij/dvcs/ui/VcsLogOneCommitPerRepoAction.java)0
-rw-r--r--platform/dvcs-impl/src/com/intellij/dvcs/ui/VcsLogSingleCommitAction.java (renamed from platform/dvcs/src/com/intellij/dvcs/ui/VcsLogSingleCommitAction.java)0
-rw-r--r--platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockProject.java (renamed from platform/dvcs/testFramework/com/intellij/dvcs/test/MockProject.java)8
-rw-r--r--platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockProjectRootManager.java (renamed from platform/dvcs/testFramework/com/intellij/dvcs/test/MockProjectRootManager.java)0
-rw-r--r--platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockVcsHelper.java (renamed from platform/dvcs/testFramework/com/intellij/dvcs/test/MockVcsHelper.java)0
-rw-r--r--platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockVirtualFile.java (renamed from platform/dvcs/testFramework/com/intellij/dvcs/test/MockVirtualFile.java)0
-rw-r--r--platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java28
-rw-r--r--platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsListener.java4
-rw-r--r--platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java6
-rw-r--r--platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java37
-rw-r--r--platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java12
-rw-r--r--platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContextWrapper.java51
-rw-r--r--platform/editor-ui-api/src/com/intellij/openapi/actionSystem/RightAlignedToolbarAction.java22
-rw-r--r--platform/editor-ui-api/src/com/intellij/ui/switcher/QuickActionProvider.java1
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskDebugRunner.java13
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskRunner.java8
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java2
-rw-r--r--platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/AbstractExternalSystemToolWindowFactory.java4
-rw-r--r--platform/icons/src/actions/GroupByClass.pngbin0 -> 494 bytes
-rw-r--r--platform/icons/src/actions/GroupByClass@2x.pngbin0 -> 1218 bytes
-rw-r--r--platform/icons/src/actions/GroupByClass@2x_dark.pngbin0 -> 1216 bytes
-rw-r--r--platform/icons/src/actions/GroupByClass_dark.pngbin0 -> 507 bytes
-rw-r--r--platform/icons/src/gutter/extAnnotation.pngbin144 -> 322 bytes
-rw-r--r--platform/icons/src/gutter/extAnnotation@2x.pngbin192 -> 724 bytes
-rw-r--r--platform/icons/src/gutter/extAnnotation@2x_dark.pngbin269 -> 730 bytes
-rw-r--r--platform/icons/src/gutter/extAnnotation_dark.pngbin216 -> 321 bytes
-rw-r--r--platform/indexing-api/src/com/intellij/psi/RefResolveService.java50
-rw-r--r--platform/indexing-api/src/com/intellij/psi/search/PsiSearchHelper.java6
-rw-r--r--platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java4
-rw-r--r--platform/indexing-impl/src/com/intellij/psi/impl/PersistentIntList.java386
-rw-r--r--platform/indexing-impl/src/com/intellij/psi/impl/file/impl/ResolveScopeManagerImpl.java51
-rw-r--r--platform/lang-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java8
-rw-r--r--platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java2
-rw-r--r--platform/lang-api/src/com/intellij/execution/ExecutionManager.java41
-rw-r--r--platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java9
-rw-r--r--platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java9
-rw-r--r--platform/lang-api/src/com/intellij/execution/RunnerRegistry.java2
-rw-r--r--platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java7
-rw-r--r--platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java80
-rw-r--r--platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java179
-rw-r--r--platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java74
-rw-r--r--platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java3
-rw-r--r--platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java71
-rw-r--r--platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java59
-rw-r--r--platform/lang-api/src/com/intellij/execution/ui/RunContentWithExecutorListener.java (renamed from platform/lang-impl/src/com/intellij/execution/ui/RunContentWithExecutorListener.java)6
-rw-r--r--platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java3
-rw-r--r--platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java27
-rw-r--r--platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java6
-rw-r--r--platform/lang-api/src/com/intellij/ide/IdeView.java4
-rw-r--r--platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java9
-rw-r--r--platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java18
-rw-r--r--platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java40
-rw-r--r--platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java20
-rw-r--r--platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java14
-rw-r--r--platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java8
-rw-r--r--platform/lang-impl/src/com/intellij/application/options/OtherTabsAndIndentsPanel.java2
-rw-r--r--platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java8
-rw-r--r--platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java4
-rw-r--r--platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form54
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/actions/FormatChangedTextUtil.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java2
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndAction.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndWithSelectionAction.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartAction.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartWithSelectionAction.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java2
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordHandler.java7
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java9
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/editorActions/smartEnter/SmartEnterAction.java30
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java2
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/folding/impl/PsiNamesElementSignatureProvider.java47
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditAction.java7
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java76
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java140
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/NextVariableAction.java19
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/PreviousVariableAction.java18
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/EnterHandler.java5
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/ExpandLiveTemplateByTabAction.java4
-rw-r--r--platform/lang-impl/src/com/intellij/codeInsight/template/postfix/settings/PostfixTemplatesCheckboxTree.java15
-rw-r--r--platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java10
-rw-r--r--platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java4
-rw-r--r--platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleManagerBase.java6
-rw-r--r--platform/lang-impl/src/com/intellij/diagnostic/logging/LogFilesManager.java16
-rw-r--r--platform/lang-impl/src/com/intellij/diagnostic/logging/OutputFileUtil.java61
-rw-r--r--platform/lang-impl/src/com/intellij/execution/ExecutionHelper.java54
-rw-r--r--platform/lang-impl/src/com/intellij/execution/ExecutionTargetManagerImpl.java62
-rw-r--r--platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java65
-rw-r--r--platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java138
-rw-r--r--platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java57
-rw-r--r--platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java20
-rw-r--r--platform/lang-impl/src/com/intellij/execution/actions/StopAction.java72
-rw-r--r--platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java2
-rw-r--r--platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java12
-rw-r--r--platform/lang-impl/src/com/intellij/execution/impl/ExecutionManagerImpl.java410
-rw-r--r--platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationManager.java4
-rw-r--r--platform/lang-impl/src/com/intellij/execution/impl/RunConfigurationBeforeRunProvider.java22
-rw-r--r--platform/lang-impl/src/com/intellij/execution/impl/RunDialog.java5
-rw-r--r--platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java23
-rw-r--r--platform/lang-impl/src/com/intellij/execution/impl/RunnerRegistryImpl.java10
-rw-r--r--platform/lang-impl/src/com/intellij/execution/impl/SingleConfigurationConfigurable.java10
-rw-r--r--platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java2
-rw-r--r--platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java8
-rw-r--r--platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java116
-rw-r--r--platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java71
-rw-r--r--platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java124
-rw-r--r--platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java186
-rw-r--r--platform/lang-impl/src/com/intellij/execution/runners/RunTab.java94
-rw-r--r--platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java307
-rw-r--r--platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java11
-rw-r--r--platform/lang-impl/src/com/intellij/execution/ui/layout/impl/JBRunnerTabs.java4
-rw-r--r--platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java73
-rw-r--r--platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java41
-rw-r--r--platform/lang-impl/src/com/intellij/find/FindSettings.java3
-rw-r--r--platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java2
-rw-r--r--platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java11
-rw-r--r--platform/lang-impl/src/com/intellij/find/impl/FindDialog.java34
-rw-r--r--platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java1
-rw-r--r--platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java3
-rw-r--r--platform/lang-impl/src/com/intellij/find/impl/FindSettingsImpl.java11
-rw-r--r--platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java5
-rw-r--r--platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java39
-rw-r--r--platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java43
-rw-r--r--platform/lang-impl/src/com/intellij/ide/actions/SelectInAction.java8
-rw-r--r--platform/lang-impl/src/com/intellij/ide/commander/CommanderPanel.java3
-rw-r--r--platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java3
-rw-r--r--platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java3
-rw-r--r--platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInGroupTarget.java4
-rw-r--r--platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInTarget.java18
-rw-r--r--platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarIdeView.java4
-rw-r--r--platform/lang-impl/src/com/intellij/ide/projectView/ProjectView.java24
-rw-r--r--platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java4
-rw-r--r--platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java4
-rw-r--r--platform/lang-impl/src/com/intellij/ide/projectView/impl/FavoritesViewToolWindowFactory.java5
-rw-r--r--platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java178
-rw-r--r--platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewToolWindowFactory.java5
-rw-r--r--platform/lang-impl/src/com/intellij/ide/projectView/impl/ShowModulesAction.java2
-rw-r--r--platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java9
-rw-r--r--platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java7
-rw-r--r--platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewToolWindowFactory.java5
-rw-r--r--platform/lang-impl/src/com/intellij/ide/todo/TodoToolWindowFactory.java5
-rw-r--r--platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java32
-rw-r--r--platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java4
-rw-r--r--platform/lang-impl/src/com/intellij/openapi/editor/actions/SelectWordAtCaretAction.java17
-rw-r--r--platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorPsiDataProvider.java98
-rw-r--r--platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java100
-rw-r--r--platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentRootPanel.java4
-rw-r--r--platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java3
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/ScopesOrderDialog.java2
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java6
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java4
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ScopesAndSeveritiesTable.java32
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ThreeStateCheckBoxRenderer.java7
-rw-r--r--platform/lang-impl/src/com/intellij/psi/impl/DocumentCommitThread.java95
-rw-r--r--platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java18
-rw-r--r--platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java5
-rw-r--r--platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java2
-rw-r--r--platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedFileViewProvider.java2
-rw-r--r--platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java53
-rw-r--r--platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java2
-rw-r--r--platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/Place.java6
-rw-r--r--platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java1
-rw-r--r--platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java2
-rw-r--r--platform/lang-impl/src/com/intellij/refactoring/changeSignature/MethodNodeBase.java10
-rw-r--r--platform/lang-impl/src/com/intellij/refactoring/inline/GenericInlineHandler.java2
-rw-r--r--platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java6
-rw-r--r--platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java8
-rw-r--r--platform/lang-impl/src/com/intellij/tools/BaseToolManager.java6
-rw-r--r--platform/lang-impl/src/com/intellij/tools/ScanSourceCommentsAction.java31
-rw-r--r--platform/lang-impl/src/com/intellij/tools/Tool.java15
-rw-r--r--platform/lang-impl/src/com/intellij/ui/DuplicateNodeRenderer.java7
-rw-r--r--platform/lang-impl/src/com/intellij/ui/popup/PopupPositionManager.java2
-rw-r--r--platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java20
-rw-r--r--platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java41
-rw-r--r--platform/lang-impl/src/com/intellij/usageView/UsageViewUtil.java16
-rw-r--r--platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java3
-rw-r--r--platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java42
-rw-r--r--platform/platform-api/src/com/intellij/execution/process/AnsiEscapeDecoder.java101
-rw-r--r--platform/platform-api/src/com/intellij/execution/process/CapturingAnsiEscapesAwareProcessHandler.java3
-rw-r--r--platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java2
-rw-r--r--platform/platform-api/src/com/intellij/ide/CompositeSelectInTarget.java4
-rw-r--r--platform/platform-api/src/com/intellij/ide/SelectInTarget.java3
-rw-r--r--platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java9
-rw-r--r--platform/platform-api/src/com/intellij/openapi/editor/actionSystem/CaretSpecificDataContext.java47
-rw-r--r--platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java18
-rw-r--r--platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorActionHandler.java128
-rw-r--r--platform/platform-api/src/com/intellij/openapi/fileEditor/EditorDataProvider.java6
-rw-r--r--platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java10
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java2
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/ComponentWithActions.java18
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java8
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/PanelWithText.java4
-rw-r--r--platform/platform-api/src/com/intellij/openapi/ui/popup/ListItemDescriptorAdapter.java44
-rw-r--r--platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java12
-rw-r--r--platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java6
-rw-r--r--platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java5
-rw-r--r--platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java5
-rw-r--r--platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java25
-rw-r--r--platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java8
-rw-r--r--platform/platform-api/src/com/intellij/ui/content/ContentManagerEvent.java12
-rw-r--r--platform/platform-api/src/com/intellij/ui/table/JBTable.java43
-rw-r--r--platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java2
-rw-r--r--platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java62
-rw-r--r--platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java19
-rw-r--r--platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java12
-rw-r--r--platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java8
-rw-r--r--platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java8
-rw-r--r--platform/platform-api/src/com/intellij/util/ui/AsyncProcessIcon.java11
-rw-r--r--platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java22
-rw-r--r--platform/platform-api/src/com/intellij/util/ui/JTableCellEditorHelper.java76
-rw-r--r--platform/platform-impl/src/com/intellij/errorreport/itn/ITNProxy.java2
-rw-r--r--platform/platform-impl/src/com/intellij/help/impl/HelpManagerImpl.java11
-rw-r--r--platform/platform-impl/src/com/intellij/help/impl/MacHelpUtil.java12
-rw-r--r--platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java7
-rw-r--r--platform/platform-impl/src/com/intellij/ide/SwingCleanuper.java5
-rw-r--r--platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java3
-rw-r--r--platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java8
-rw-r--r--platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java27
-rw-r--r--platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardStepsProvider.java25
-rw-r--r--platform/platform-impl/src/com/intellij/ide/customize/CustomizeKeyboardSchemeStepPanel.java2
-rw-r--r--platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java39
-rw-r--r--platform/platform-impl/src/com/intellij/ide/customize/CustomizeUIThemeStepPanel.java56
-rw-r--r--platform/platform-impl/src/com/intellij/ide/customize/IdSet.java6
-rw-r--r--platform/platform-impl/src/com/intellij/ide/customize/PluginGroups.java116
-rw-r--r--platform/platform-impl/src/com/intellij/ide/passwordSafe/PasswordSafeException.java29
-rw-r--r--platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/BasePasswordSafeProvider.java1
-rw-r--r--platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/EncryptionUtil.java12
-rw-r--r--platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java172
-rw-r--r--platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/memory/MemoryPasswordSafe.java1
-rw-r--r--platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java6
-rw-r--r--platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java28
-rw-r--r--platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurable.java18
-rw-r--r--platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java4
-rw-r--r--platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerUISettings.java4
-rw-r--r--platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java8
-rw-r--r--platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java6
-rw-r--r--platform/platform-impl/src/com/intellij/ide/util/TipDialog.java10
-rw-r--r--platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java5
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java31
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java7
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java64
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java7
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityInvokatorImpl.java14
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/EditorLinePainter.java32
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/LineExtensionInfo.java71
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/actions/EnterAction.java6
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/actions/IndentSelectionAction.java2
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/actions/SplitLineAction.java14
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineAction.java10
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineBeforeAction.java4
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/actions/UnselectWordAtCaretAction.java6
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorMarkupModel.java4
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHeaderComponent.java7
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java30
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java2
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java6
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/fileEditor/ex/FileEditorManagerEx.java7
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java1
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java6
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/HistoryEntry.java13
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java3
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java4
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java42
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java7
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java26
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/ex/NodeConfigurable.java71
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java103
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java129
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsTreeView.java864
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java24
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorUtils.java79
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java22
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java17
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java32
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java34
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java6
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerEx.java4
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java3
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.java23
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java15
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java49
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java33
-rw-r--r--platform/platform-impl/src/com/intellij/remote/RemoteSdkAdditionalData.java3
-rw-r--r--platform/platform-impl/src/com/intellij/remote/RemoteSdkCredentialsHolder.java10
-rw-r--r--platform/platform-impl/src/com/intellij/remote/RemoteSdkProperties.java10
-rw-r--r--platform/platform-impl/src/com/intellij/remote/RemoteSdkPropertiesHolder.java18
-rw-r--r--platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java57
-rw-r--r--platform/platform-impl/src/com/intellij/ui/BalloonImpl.java2
-rw-r--r--platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java8
-rw-r--r--platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java8
-rw-r--r--platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java4
-rw-r--r--platform/platform-impl/src/com/intellij/ui/TableSpeedSearch.java23
-rw-r--r--platform/platform-impl/src/com/intellij/ui/content/impl/ContentImpl.java6
-rw-r--r--platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java145
-rw-r--r--platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java36
-rw-r--r--platform/platform-impl/src/com/intellij/ui/popup/list/PopupListElementRenderer.java9
-rw-r--r--platform/platform-impl/src/icons/PlatformImplIcons.java28
-rw-r--r--platform/platform-impl/src/icons/plugins/Android.pngbin0 -> 1610 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/Android@2x.pngbin0 -> 3137 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/ApplicationServers.pngbin0 -> 429 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/ApplicationServers@2x.pngbin0 -> 908 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/BuildTools.pngbin0 -> 1086 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/BuildTools@2x.pngbin0 -> 2744 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/Clouds.pngbin0 -> 2100 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/Clouds@2x.pngbin0 -> 4545 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/DatabaseTools.pngbin0 -> 1936 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/DatabaseTools@2x.pngbin0 -> 3661 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/JavaFrameworks.pngbin0 -> 2155 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/JavaFrameworks@2x.pngbin0 -> 4711 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/OtherTools.pngbin0 -> 2343 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/OtherTools@2x.pngbin0 -> 5449 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/PluginDevelopment.pngbin0 -> 1633 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/PluginDevelopment@2x.pngbin0 -> 3271 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/Swing.pngbin0 -> 711 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/Swing@2x.pngbin0 -> 1226 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/TestTools.pngbin0 -> 711 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/TestTools@2x.pngbin0 -> 1503 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/VersionControls.pngbin0 -> 967 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/VersionControls@2x.pngbin0 -> 2013 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/WebDevelopment.pngbin0 -> 2247 bytes
-rw-r--r--platform/platform-impl/src/icons/plugins/WebDevelopment@2x.pngbin0 -> 5416 bytes
-rw-r--r--platform/platform-resources-en/src/messages/ActionsBundle.properties1
-rw-r--r--platform/platform-resources-en/src/messages/ApplicationBundle.properties2
-rw-r--r--platform/platform-resources-en/src/messages/ExecutionBundle.properties1
-rw-r--r--platform/platform-resources-en/src/messages/FindBundle.properties3
-rw-r--r--platform/platform-resources-en/src/messages/InspectionsBundle.properties2
-rw-r--r--platform/platform-resources-en/src/messages/OptionsBundle.properties2
-rw-r--r--platform/platform-resources-en/src/messages/RefactoringBundle.properties1
-rw-r--r--platform/platform-resources/src/META-INF/LangExtensions.xml10
-rw-r--r--platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml2
-rw-r--r--platform/platform-resources/src/META-INF/PlatformExtensions.xml4
-rw-r--r--platform/platform-resources/src/META-INF/PlatformLangPlugin.xml3
-rw-r--r--platform/platform-resources/src/META-INF/PlatformPlugin.xml3
-rw-r--r--platform/platform-resources/src/META-INF/xdebugger.xml1
-rw-r--r--platform/platform-resources/src/brokenPlugins.txt11
-rw-r--r--platform/platform-resources/src/componentSets/Execution.xml12
-rw-r--r--platform/platform-resources/src/componentSets/UICore.xml4
-rw-r--r--platform/platform-resources/src/idea/LangActions.xml2
-rw-r--r--platform/platform-resources/src/idea/PlatformActions.xml3
-rw-r--r--platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java55
-rw-r--r--platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java10
-rw-r--r--platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java19
-rw-r--r--platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java19
-rw-r--r--platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java (renamed from platform/platform-tests/testSrc/com/intellij/psi/PsiDocumentManagerImplTest.java)33
-rw-r--r--platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java5
-rw-r--r--platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java20
-rw-r--r--platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndex.java9
-rw-r--r--platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java104
-rw-r--r--platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java24
-rw-r--r--platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java24
-rw-r--r--platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentLoggingHandler.java4
-rw-r--r--platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentWithDeployment.java5
-rw-r--r--platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgent.java2
-rw-r--r--platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogListener.java4
-rw-r--r--platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogPipe.java6
-rw-r--r--platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudGitApplicationRuntime.java6
-rw-r--r--platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java6
-rw-r--r--platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSilentLoggingHandlerImpl.java4
-rw-r--r--platform/script-debugger/backend/src/org/jetbrains/rpc/MessageManager.java5
-rw-r--r--platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java10
-rw-r--r--platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfile.java6
-rw-r--r--platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfileBase.java6
-rw-r--r--platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/CompiledPattern.java4
-rw-r--r--platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/CompileContext.java4
-rw-r--r--platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/FindInFilesOptimizingSearchHelper.java2
-rw-r--r--platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java47
-rw-r--r--platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java31
-rw-r--r--platform/testFramework/src/com/intellij/mock/Mock.java43
-rw-r--r--platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java2
-rw-r--r--platform/testFramework/src/com/intellij/projectView/TestProjectViewPSIPane.java57
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java45
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java29
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java5
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java4
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java1
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/ProjectViewTestUtil.java28
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java14
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java3
-rw-r--r--platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java3
-rw-r--r--platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java32
-rw-r--r--platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java34
-rw-r--r--platform/testRunner/src/com/intellij/execution/testframework/autotest/ToggleAutoTestAction.java8
-rw-r--r--platform/usageView/src/com/intellij/usages/UsageViewPresentation.java9
-rw-r--r--platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java2
-rw-r--r--platform/util/resources/misc/registry.properties4
-rw-r--r--platform/util/src/com/intellij/icons/AllIcons.java1
-rw-r--r--platform/util/src/com/intellij/openapi/diagnostic/Log.java8
-rw-r--r--platform/util/src/com/intellij/openapi/progress/ProcessCanceledException.java5
-rw-r--r--platform/util/src/com/intellij/openapi/util/TextRange.java10
-rw-r--r--platform/util/src/com/intellij/openapi/util/io/FileUtil.java6
-rw-r--r--platform/util/src/com/intellij/openapi/util/registry/Registry.java45
-rw-r--r--platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java47
-rw-r--r--platform/util/src/com/intellij/openapi/util/text/StringUtil.java3
-rw-r--r--platform/util/src/com/intellij/util/ReflectionUtil.java14
-rw-r--r--platform/util/src/com/intellij/util/containers/ClassMap.java10
-rw-r--r--platform/util/src/com/intellij/util/containers/ContainerUtil.java4
-rw-r--r--platform/util/src/com/intellij/util/containers/TransferToEDTQueue.java8
-rw-r--r--platform/util/src/com/intellij/util/containers/WeakStringInterner.java15
-rw-r--r--platform/util/src/com/intellij/util/io/IntToIntBtree.java85
-rw-r--r--platform/util/src/com/intellij/util/io/PagedFileStorage.java23
-rw-r--r--platform/util/src/com/intellij/util/io/RandomAccessDataFile.java29
-rw-r--r--platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java46
-rw-r--r--platform/util/src/com/intellij/util/text/StringSearcher.java6
-rw-r--r--platform/util/src/com/intellij/util/xmlb/MapBinding.java33
-rw-r--r--platform/util/testSrc/com/intellij/openapi/util/io/FileUtilLightTest.java9
-rw-r--r--platform/util/testSrc/com/intellij/util/text/StringUtilTest.java12
-rw-r--r--platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java3
-rw-r--r--platform/vcs-api/src/com/intellij/openapi/vcs/update/FileGroup.java3
-rw-r--r--platform/vcs-api/src/com/intellij/openapi/vcs/update/UpdatedFiles.java4
-rw-r--r--platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java12
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/lifecycle/PeriodicalTasksCloser.java (renamed from platform/vcs-api/src/com/intellij/lifecycle/PeriodicalTasksCloser.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/FilePath.java (renamed from platform/vcs-api/src/com/intellij/openapi/vcs/FilePath.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/VcsException.java (renamed from platform/vcs-api/src/com/intellij/openapi/vcs/VcsException.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/VcsKey.java (renamed from platform/vcs-api/src/com/intellij/openapi/vcs/VcsKey.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/Change.java (renamed from platform/vcs-api/src/com/intellij/openapi/vcs/changes/Change.java)7
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/ContentRevision.java (renamed from platform/vcs-api/src/com/intellij/openapi/vcs/changes/ContentRevision.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/MergeTexts.java (renamed from platform/vcs-api/src/com/intellij/openapi/vcs/changes/MergeTexts.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/history/LongRevisionNumber.java (renamed from platform/vcs-api/src/com/intellij/openapi/vcs/history/LongRevisionNumber.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/history/VcsRevisionNumber.java (renamed from platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsRevisionNumber.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/impl/VcsPathPresenter.java (renamed from platform/vcs-api/src/com/intellij/openapi/vcs/impl/VcsPathPresenter.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/Rethrow.java (renamed from platform/vcs-api/src/com/intellij/vcsUtil/Rethrow.java)2
-rw-r--r--platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/VcsFilePathUtil.java32
-rw-r--r--platform/vcs-api/vcs-api-core/vcs-api-core.iml15
-rw-r--r--platform/vcs-api/vcs-api.iml1
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinFilesAction.java6
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java2
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java2
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FragmentedDiffRequestFromChange.java4
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java25
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java2
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.java6
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurable.java77
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.java26
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationConfigurable.java111
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java27
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java33
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/CopyLineStatusRangeAction.java2
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java701
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java6
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/Range.java84
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RangesBuilder.java10
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java41
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusRangeAction.java2
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/SegmentTree.java116
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java18
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java3
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleVcsPathPresenter.java9
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java2
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/UpToDateLineNumberProviderImpl.java12
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java2
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java2
-rw-r--r--platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java23
-rw-r--r--platform/vcs-impl/src/com/intellij/vcsUtil/AuthDialog.java3
-rw-r--r--platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogSettings.java18
-rw-r--r--platform/vcs-log/api/vcs-log-api.iml3
-rw-r--r--platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java2
-rw-r--r--platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java14
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java87
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java47
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerWatchesManager.java13
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java4
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionImpl.java5
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionState.java7
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java75
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java1
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XValueCompactPresentation.java28
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java3
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/DebuggerFramesList.java8
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugView.java58
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugViewSessionListener.java10
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java3
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java128
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XStandaloneVariablesView.java8
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java50
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java11
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java58
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java3
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java41
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java204
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XValueTextProvider.java23
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/TreeInplaceEditor.java24
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java43
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesAction.java2
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XFetchValueActionBase.java10
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java11
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerTreeNode.java5
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java33
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java4
581 files changed, 10626 insertions, 4557 deletions
diff --git a/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java b/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java
index b18bb042c183..893a7f3d30da 100644
--- a/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java
+++ b/platform/analysis-api/src/com/intellij/analysis/AnalysisScope.java
@@ -80,6 +80,7 @@ public class AnalysisScope {
private boolean mySearchInLibraries = false;
@Type protected int myType;
+ private Set<VirtualFile> myVFiles;
protected Set<VirtualFile> myFilesSet;
protected boolean myIncludeTestSource = true;
@@ -145,7 +146,7 @@ public class AnalysisScope {
myModule = null;
myModules = null;
myScope = null;
- myFilesSet = new HashSet<VirtualFile>(virtualFiles);
+ myVFiles = new HashSet<VirtualFile>(virtualFiles);
myType = VIRTUAL_FILES;
}
@@ -241,9 +242,9 @@ public class AnalysisScope {
accept(createFileSearcher());
}
else if (myType == VIRTUAL_FILES) {
- final HashSet<VirtualFile> files = new HashSet<VirtualFile>();
+ myFilesSet = new HashSet<VirtualFile>();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
- for (Iterator<VirtualFile> iterator = myFilesSet.iterator(); iterator.hasNext(); ) {
+ for (Iterator<VirtualFile> iterator = myVFiles.iterator(); iterator.hasNext(); ) {
final VirtualFile vFile = iterator.next();
VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
@NotNull
@@ -251,7 +252,7 @@ public class AnalysisScope {
public Result visitFileEx(@NotNull VirtualFile file) {
boolean ignored = fileIndex.isExcluded(file);
if (!ignored && !file.isDirectory()) {
- files.add(file);
+ myFilesSet.add(file);
}
return ignored ? SKIP_CHILDREN : CONTINUE;
}
@@ -261,7 +262,6 @@ public class AnalysisScope {
iterator.remove();
}
}
- myFilesSet.addAll(files);
}
}
@@ -592,7 +592,7 @@ public class AnalysisScope {
if (myType != VIRTUAL_FILES) {
myFilesSet = null;
} else {
- for (Iterator<VirtualFile> i = myFilesSet.iterator(); i.hasNext();) {
+ for (Iterator<VirtualFile> i = myVFiles.iterator(); i.hasNext();) {
final VirtualFile virtualFile = i.next();
if (virtualFile == null || !virtualFile.isValid()) {
i.remove();
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
index 8d0f1da9d024..43d80faad886 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java
@@ -119,7 +119,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
return alternativeId != null && !alternativeId.equals(toolId) && suppressor.isSuppressedFor(element, alternativeId);
}
- private static Set<InspectionSuppressor> getSuppressors(@NotNull PsiElement element) {
+ public static Set<InspectionSuppressor> getSuppressors(@NotNull PsiElement element) {
FileViewProvider viewProvider = element.getContainingFile().getViewProvider();
if (viewProvider instanceof TemplateLanguageFileViewProvider) {
LinkedHashSet<InspectionSuppressor> suppressors = new LinkedHashSet<InspectionSuppressor>();
@@ -127,6 +127,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
for (Language language : viewProvider.getLanguages()) {
ContainerUtil.addIfNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.forLanguage(language));
}
+ ContainerUtil.addIfNotNull(suppressors, LanguageInspectionSuppressors.INSTANCE.forLanguage(element.getLanguage()));
return suppressors;
}
return Collections.singleton(LanguageInspectionSuppressors.INSTANCE.forLanguage(element.getLanguage()));
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolsRegistrarCore.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolsRegistrarCore.java
index 7d2ffb7ce405..eb99cc4d1594 100644
--- a/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolsRegistrarCore.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/InspectionToolsRegistrarCore.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -17,36 +17,17 @@ package com.intellij.codeInspection.ex;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.ReflectionUtil;
import org.jetbrains.annotations.NotNull;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
public class InspectionToolsRegistrarCore {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionToolsRegistrarCore");
static Object instantiateTool(@NotNull Class<?> toolClass) {
try {
- Constructor<?> constructor = toolClass.getDeclaredConstructor(ArrayUtil.EMPTY_CLASS_ARRAY);
- constructor.setAccessible(true);
- return constructor.newInstance(ArrayUtil.EMPTY_OBJECT_ARRAY);
- }
- catch (SecurityException e) {
- LOG.error(e);
- }
- catch (NoSuchMethodException e) {
- LOG.error(e);
- }
- catch (InstantiationException e) {
- LOG.error(e);
- }
- catch (IllegalAccessException e) {
- LOG.error(e);
- }
- catch (IllegalArgumentException e) {
- LOG.error(e);
+ return ReflectionUtil.newInstance(toolClass, ArrayUtil.EMPTY_CLASS_ARRAY);
}
- catch (InvocationTargetException e) {
- LOG.error(e);
+ catch (RuntimeException e) {
+ LOG.error(e.getCause());
}
return null;
diff --git a/platform/analysis-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java b/platform/analysis-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java
index 63fe1c8d28e5..ca229a64bebc 100644
--- a/platform/analysis-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java
+++ b/platform/analysis-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java
@@ -17,6 +17,7 @@ package com.intellij.psi.search.scope;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.vfs.NonPhysicalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.search.ProjectScope;
import com.intellij.psi.search.scope.packageSet.AbstractPackageSet;
@@ -43,7 +44,8 @@ public class NonProjectFilesScope extends NamedScope {
@Override
public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) {
- if (file == null) return true;
+ // do not include fake-files e.g. fragment-editors, database consoles, etc.
+ if (file == null || file.getFileSystem() instanceof NonPhysicalFileSystem) return false;
if (!file.isInLocalFileSystem()) return true;
if (isInsideProjectContent(project, file)) return false;
return !ProjectScope.getProjectScope(project).contains(file);
diff --git a/platform/analysis-api/src/com/intellij/psi/search/scope/ProjectProductionScope.java b/platform/analysis-api/src/com/intellij/psi/search/scope/ProjectProductionScope.java
index 7d44b0f91450..19788a0bd3d7 100644
--- a/platform/analysis-api/src/com/intellij/psi/search/scope/ProjectProductionScope.java
+++ b/platform/analysis-api/src/com/intellij/psi/search/scope/ProjectProductionScope.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -30,8 +30,10 @@ import org.jetbrains.annotations.Nullable;
* @author Konstantin Bulenkov
*/
public class ProjectProductionScope extends NamedScope {
+ public static final String NAME = IdeBundle.message("predefined.scope.production.name");
+
public ProjectProductionScope() {
- super(IdeBundle.message("predefined.scope.production.name"), new AbstractPackageSet("src:*..*") {
+ super(NAME, new AbstractPackageSet("src:*..*") {
@Override
public boolean contains(VirtualFile file, NamedScopesHolder holder) {
return contains(file, holder.getProject(), holder);
diff --git a/platform/annotations/src/org/intellij/lang/annotations/Flow.java b/platform/annotations/src/org/intellij/lang/annotations/Flow.java
index a6ea57837336..c73fa57bf9f4 100644
--- a/platform/annotations/src/org/intellij/lang/annotations/Flow.java
+++ b/platform/annotations/src/org/intellij/lang/annotations/Flow.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -59,7 +59,7 @@ public @interface Flow {
* </li>
* </ul>
*/
- String source() default DEFAULT_SOURCE;
+ String source() default org.intellij.lang.annotations.Flow.DEFAULT_SOURCE;
@NonNls String DEFAULT_SOURCE = "The method argument (if parameter was annotated) or this container (if instance method was annotated)";
@NonNls String THIS_SOURCE = "this";
@@ -108,7 +108,7 @@ public @interface Flow {
* </li>
* </ul>
*/
- String target() default DEFAULT_TARGET;
+ String target() default org.intellij.lang.annotations.Flow.DEFAULT_TARGET;
@NonNls String DEFAULT_TARGET = "This container (if the parameter was annotated) or the return value (if instance method was annotated)";
@NonNls String RETURN_METHOD_TARGET = "The return value of this method";
@NonNls String THIS_TARGET = "this";
diff --git a/platform/bootstrap/src/com/intellij/ide/startup/StartupActionScriptManager.java b/platform/bootstrap/src/com/intellij/ide/startup/StartupActionScriptManager.java
index fd2882dfb40b..2cf84526471a 100644
--- a/platform/bootstrap/src/com/intellij/ide/startup/StartupActionScriptManager.java
+++ b/platform/bootstrap/src/com/intellij/ide/startup/StartupActionScriptManager.java
@@ -17,6 +17,7 @@ package com.intellij.ide.startup;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.io.ZipUtil;
import org.jetbrains.annotations.NonNls;
@@ -71,21 +72,26 @@ public class StartupActionScriptManager {
private static List<ActionCommand> loadActionScript() throws IOException {
File file = new File(getActionScriptPath());
if (file.exists()) {
+ boolean fileCorrupted = false;
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
try {
//noinspection unchecked
return (List<ActionCommand>)ois.readObject();
}
- catch (ClassNotFoundException e) {
- // problem with scrambled code
- // fas fixed, but still appear because corrupted file still exists
- // return empty list.
+ catch (Throwable e) { // ClassNotFoundException / IOException
+ fileCorrupted = true;
LOG.error("Internal file was corrupted. Problem is fixed.\nIf some plugins has been installed/uninstalled, please re-install/-uninstall them.", e);
+ //noinspection InstanceofCatchParameter
+ if (e instanceof IOException) throw (IOException)e;
return new ArrayList<ActionCommand>();
}
finally {
- ois.close();
+ try {
+ ois.close();
+ } finally {
+ if (fileCorrupted) FileUtil.delete(file); // do not need corrupted file anymore
+ }
}
}
else {
@@ -189,7 +195,8 @@ public class StartupActionScriptManager {
public void execute() throws IOException {
if (!mySource.exists()) {
- //noinspection HardCodedStringLiteral
+ // Note, that we can not use LOG at this moment because it throws AssertionError
+ //noinspection HardCodedStringLiteral,UseOfSystemOutOrSystemErr
System.err.println("Source file " + mySource.getAbsolutePath() + " does not exist for action " + this);
}
else if (!canCreateFile(myDestination)) {
@@ -203,6 +210,7 @@ public class StartupActionScriptManager {
ZipUtil.extract(mySource, myDestination, myFilenameFilter);
}
catch(Exception ex) {
+ //noinspection CallToPrintStackTrace
ex.printStackTrace();
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
MessageFormat.format("<html>Failed to extract ZIP file {0}<br>to<br>{1}<br>You may need to re-download the plugin you tried to install.",
@@ -228,7 +236,7 @@ public class StartupActionScriptManager {
public void execute() throws IOException {
if (mySource != null && mySource.exists() && !FileUtilRt.delete(mySource)) {
- //noinspection HardCodedStringLiteral
+ //noinspection HardCodedStringLiteral,UseOfSystemOutOrSystemErr
System.err.println("Action " + this + " failed.");
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
MessageFormat.format("<html>Cannot delete {0}<br>Please, check your access rights on folder <br>{1}",
diff --git a/platform/lang-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java b/platform/core-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java
index daea33cd1e9a..3bb44937de4a 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java
+++ b/platform/core-api/src/com/intellij/codeInsight/controlflow/ConditionalInstruction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/core-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java b/platform/core-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java
new file mode 100644
index 000000000000..bf72d011c6ea
--- /dev/null
+++ b/platform/core-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2014 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.codeInsight.controlflow;
+
+/**
+ * @author oleg
+ */
+public interface ControlFlow {
+ Instruction[] getInstructions();
+}
diff --git a/platform/lang-api/src/com/intellij/codeInsight/controlflow/Instruction.java b/platform/core-api/src/com/intellij/codeInsight/controlflow/Instruction.java
index 26ecfcca2a5d..8b0dda01d226 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/controlflow/Instruction.java
+++ b/platform/core-api/src/com/intellij/codeInsight/controlflow/Instruction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/core-api/src/com/intellij/concurrency/JobScheduler.java b/platform/core-api/src/com/intellij/concurrency/JobScheduler.java
index a7e16644363c..30d668088824 100644
--- a/platform/core-api/src/com/intellij/concurrency/JobScheduler.java
+++ b/platform/core-api/src/com/intellij/concurrency/JobScheduler.java
@@ -81,8 +81,7 @@ public abstract class JobScheduler {
private static void enableRemoveOnCancelPolicy(ScheduledThreadPoolExecutor executor) {
if (Patches.USE_REFLECTION_TO_ACCESS_JDK7) {
try {
- Method setRemoveOnCancelPolicy = ScheduledThreadPoolExecutor.class.getDeclaredMethod("setRemoveOnCancelPolicy", boolean.class);
- setRemoveOnCancelPolicy.setAccessible(true);
+ Method setRemoveOnCancelPolicy = ReflectionUtil.getDeclaredMethod(ScheduledThreadPoolExecutor.class, "setRemoveOnCancelPolicy", boolean.class);
setRemoveOnCancelPolicy.invoke(executor, true);
}
catch (Exception ignored) {
diff --git a/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java b/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java
index 4dda4a664174..4a72e09dcd8e 100644
--- a/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java
+++ b/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -31,9 +31,11 @@ public interface ModalityInvokator {
*
* @param runnable the runnable to execute.
*/
- ActionCallback invokeLater(Runnable runnable);
+ @NotNull
+ ActionCallback invokeLater(@NotNull Runnable runnable);
- ActionCallback invokeLater(Runnable runnable, @NotNull Condition expired);
+ @NotNull
+ ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull Condition expired);
/**
* Causes <i>runnable.run()</i> to be executed asynchronously on the
@@ -43,7 +45,9 @@ public interface ModalityInvokator {
* @param runnable the runnable to execute.
* @param state the state in which the runnable will be executed.
*/
- ActionCallback invokeLater(Runnable runnable, @NotNull ModalityState state);
+ @NotNull
+ ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState state);
- ActionCallback invokeLater(Runnable runnable, @NotNull ModalityState state, @NotNull Condition expired);
+ @NotNull
+ ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState state, @NotNull Condition expired);
} \ No newline at end of file
diff --git a/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java b/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java
index 0f50f8d05ecf..afe440b8588f 100644
--- a/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java
+++ b/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -25,7 +25,6 @@ public abstract class ProgressIndicatorProvider {
@Nullable
public static ProgressIndicatorProvider ourInstance;
- @Nullable
public static ProgressIndicatorProvider getInstance() {
return ourInstance;
}
@@ -39,6 +38,7 @@ public abstract class ProgressIndicatorProvider {
return ourInstance != null ? ourInstance.getProgressIndicator() : null;
}
+ @NotNull
public abstract NonCancelableSection startNonCancelableSection();
@NotNull
@@ -46,12 +46,12 @@ public abstract class ProgressIndicatorProvider {
return ourInstance != null ? ourInstance.startNonCancelableSection() : NonCancelableSection.EMPTY;
}
- public static volatile boolean ourNeedToCheckCancel = false;
+ protected static volatile boolean ourNeedToCheckCancel = false;
public static void checkCanceled() throws ProcessCanceledException {
// smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
if (ourNeedToCheckCancel && ourInstance != null) {
+ ourNeedToCheckCancel = false; // doCheckCanceled() may flip it back to true
ourInstance.doCheckCanceled();
- ourNeedToCheckCancel = false;
}
}
}
diff --git a/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java b/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java
index e99b8e6bebf0..4b4ace28cd37 100644
--- a/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java
+++ b/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java
@@ -25,38 +25,17 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-public abstract class ProgressManager {
- static {
- ProgressIndicatorProvider.ourInstance = new ProgressIndicatorProvider() {
- @Override
- public ProgressIndicator getProgressIndicator() {
- ProgressManager manager = ProgressManager.getInstance();
- return manager != null ? manager.getProgressIndicator() : null;
- }
-
- @Override
- protected void doCheckCanceled() throws ProcessCanceledException {
- ProgressManager manager = ProgressManager.getInstance();
- if (manager != null) {
- manager.doCheckCanceled();
- }
- }
-
- @Override
- public NonCancelableSection startNonCancelableSection() {
- ProgressManager manager = ProgressManager.getInstance();
- return manager != null ? manager.startNonCancelableSection() : NonCancelableSection.EMPTY;
- }
- };
+public abstract class ProgressManager extends ProgressIndicatorProvider {
+ public ProgressManager() {
+ ProgressIndicatorProvider.ourInstance = this;
}
- private static ProgressManager ourInstance;
+ private static class ProgressManagerHolder {
+ private static final ProgressManager ourInstance = ServiceManager.getService(ProgressManager.class);
+ }
public static ProgressManager getInstance() {
- if (ourInstance == null) {
- ourInstance = ServiceManager.getService(ProgressManager.class);
- }
- return ourInstance;
+ return ProgressManagerHolder.ourInstance;
}
public abstract boolean hasProgressIndicator();
@@ -66,17 +45,13 @@ public abstract class ProgressManager {
public abstract void runProcess(@NotNull Runnable process, ProgressIndicator progress) throws ProcessCanceledException;
public abstract <T> T runProcess(@NotNull Computable<T> process, ProgressIndicator progress) throws ProcessCanceledException;
+ @Override
public ProgressIndicator getProgressIndicator() {
return myThreadIndicator.get();
}
- protected static volatile boolean ourNeedToCheckCancel = false;
public static void checkCanceled() throws ProcessCanceledException {
- // smart optimization! There's a thread started in ProgressManagerImpl, that set's this flag up once in 10 milliseconds
- if (ourNeedToCheckCancel) {
- getInstance().doCheckCanceled();
- ourNeedToCheckCancel = false;
- }
+ ProgressIndicatorProvider.checkCanceled();
}
public static void progress(@NotNull String text) throws ProcessCanceledException {
@@ -100,11 +75,7 @@ public abstract class ProgressManager {
}
}
- protected abstract void doCheckCanceled() throws ProcessCanceledException;
-
public abstract void executeNonCancelableSection(@NotNull Runnable runnable);
- @NotNull
- public abstract NonCancelableSection startNonCancelableSection();
public abstract void setCancelButtonText(String cancelButtonText);
diff --git a/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java b/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java
index 5232dc439b90..9b74576176fb 100644
--- a/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java
+++ b/platform/core-api/src/com/intellij/openapi/util/SimpleModificationTracker.java
@@ -16,6 +16,7 @@
package com.intellij.openapi.util;
import com.intellij.Patches;
+import com.intellij.util.xmlb.annotations.Transient;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
@@ -28,6 +29,8 @@ public class SimpleModificationTracker implements ModificationTracker {
// fixed in JDK8
assert Patches.JDK_BUG_ID_7103570;
}
+
+ @Transient
public volatile int myCounter;
@Override
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
index 9e8c37880589..b3fc7550adfa 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VfsUtilCore.java
@@ -46,6 +46,8 @@ public class VfsUtilCore {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.VfsUtilCore");
public static final String LOCALHOST_URI_PATH_PREFIX = "localhost/";
+ public static final char VFS_SEPARATOR_CHAR = '/';
+
private static final String PROTOCOL_DELIMITER = ":";
/**
@@ -118,6 +120,11 @@ public class VfsUtilCore {
return false;
}
+ @Nullable
+ public static String getRelativePath(@NotNull VirtualFile file, @NotNull VirtualFile ancestor) {
+ return getRelativePath(file, ancestor, VFS_SEPARATOR_CHAR);
+ }
+
/**
* Gets the relative path of <code>file</code> to its <code>ancestor</code>. Uses <code>separator</code> for
* separating files.
@@ -129,12 +136,10 @@ public class VfsUtilCore {
*/
@Nullable
public static String getRelativePath(@NotNull VirtualFile file, @NotNull VirtualFile ancestor, char separator) {
- if (!file.getFileSystem().equals(ancestor.getFileSystem())) return null;
-
- return doGetRelative(file, ancestor, separator);
- }
+ if (!file.getFileSystem().equals(ancestor.getFileSystem())) {
+ return null;
+ }
- public static String doGetRelative(VirtualFile file, VirtualFile ancestor, char separator) {
int length = 0;
VirtualFile parent = file;
while (true) {
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
index e4c3e5c502f5..d265d5a8cd2e 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java
@@ -717,6 +717,7 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
putUserData(BOM_KEY, BOM);
}
+ @Override
@NonNls
public String toString() {
return "VirtualFile: " + getPresentableUrl();
diff --git a/platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java b/platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java
index 205bf27fe1c0..4a2343ce2983 100644
--- a/platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java
+++ b/platform/core-api/src/com/intellij/psi/PsiElementResolveResult.java
@@ -87,7 +87,7 @@ public class PsiElementResolveResult implements ResolveResult{
}
@NotNull
- public static ResolveResult[] createResults(@Nullable PsiElement[] elements) {
+ public static ResolveResult[] createResults(@Nullable PsiElement... elements) {
if (elements == null || elements.length == 0) return EMPTY_ARRAY;
final ResolveResult[] results = new ResolveResult[elements.length];
diff --git a/platform/core-api/src/com/intellij/psi/PsiFileFactory.java b/platform/core-api/src/com/intellij/psi/PsiFileFactory.java
index b31c03b6640a..e77ed1c3a4fb 100644
--- a/platform/core-api/src/com/intellij/psi/PsiFileFactory.java
+++ b/platform/core-api/src/com/intellij/psi/PsiFileFactory.java
@@ -63,6 +63,10 @@ public abstract class PsiFileFactory {
public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text);
+ public PsiFile createFileFromText(@NotNull Language language, @NotNull CharSequence text) {
+ return createFileFromText("foo.bar", language, text);
+ }
+
public abstract PsiFile createFileFromText(@NotNull String name, @NotNull Language language, @NotNull CharSequence text,
boolean eventSystemEnabled, boolean markAsCopy);
diff --git a/platform/core-api/src/com/intellij/psi/PsiWalkingState.java b/platform/core-api/src/com/intellij/psi/PsiWalkingState.java
index b6207e8bf364..6418a0b60804 100644
--- a/platform/core-api/src/com/intellij/psi/PsiWalkingState.java
+++ b/platform/core-api/src/com/intellij/psi/PsiWalkingState.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -52,7 +52,10 @@ public abstract class PsiWalkingState extends WalkingState<PsiElement> {
}
protected PsiWalkingState(@NotNull PsiElementVisitor delegate) {
- super(PsiTreeGuide.instance);
+ this(delegate, PsiTreeGuide.instance);
+ }
+ protected PsiWalkingState(@NotNull PsiElementVisitor delegate, @NotNull TreeGuide<PsiElement> guide) {
+ super(guide);
myVisitor = delegate;
}
diff --git a/platform/core-api/src/com/intellij/psi/ReferenceRange.java b/platform/core-api/src/com/intellij/psi/ReferenceRange.java
index cfb1f49a71e7..1ac18336abcb 100644
--- a/platform/core-api/src/com/intellij/psi/ReferenceRange.java
+++ b/platform/core-api/src/com/intellij/psi/ReferenceRange.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -20,6 +20,7 @@
package com.intellij.psi;
import com.intellij.openapi.util.TextRange;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,14 +30,16 @@ public class ReferenceRange {
private ReferenceRange() {
}
- public static List<TextRange> getRanges(PsiReference ref) {
+ @NotNull
+ public static List<TextRange> getRanges(@NotNull PsiReference ref) {
if (ref instanceof MultiRangeReference) {
return ((MultiRangeReference)ref).getRanges();
}
return Collections.singletonList(ref.getRangeInElement());
}
- public static List<TextRange> getAbsoluteRanges(PsiReference ref) {
+ @NotNull
+ public static List<TextRange> getAbsoluteRanges(@NotNull PsiReference ref) {
final PsiElement elt = ref.getElement();
final List<TextRange> relativeRanges = getRanges(ref);
final List<TextRange> answer = new ArrayList<TextRange>(relativeRanges.size());
@@ -47,7 +50,7 @@ public class ReferenceRange {
return answer;
}
- public static TextRange getRange(PsiReference ref) {
+ public static TextRange getRange(@NotNull PsiReference ref) {
if (ref instanceof MultiRangeReference) {
final List<TextRange> ranges = ((MultiRangeReference)ref).getRanges();
return new TextRange(ranges.get(0).getStartOffset(), ranges.get(ranges.size() - 1).getEndOffset());
@@ -56,7 +59,7 @@ public class ReferenceRange {
return ref.getRangeInElement();
}
- public static boolean containsOffsetInElement(PsiReference ref, int offset) {
+ public static boolean containsOffsetInElement(@NotNull PsiReference ref, int offset) {
if (ref instanceof MultiRangeReference) {
for (TextRange range : ((MultiRangeReference)ref).getRanges()) {
if (range.containsOffset(offset)) return true;
@@ -68,7 +71,7 @@ public class ReferenceRange {
return rangeInElement != null && rangeInElement.containsOffset(offset);
}
- public static boolean containsRangeInElement(PsiReference ref, TextRange rangeInElement) {
+ public static boolean containsRangeInElement(@NotNull PsiReference ref, @NotNull TextRange rangeInElement) {
if (ref instanceof MultiRangeReference) {
for (TextRange range : ((MultiRangeReference)ref).getRanges()) {
if (range.contains(rangeInElement)) return true;
diff --git a/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java b/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java
index bc518e1b66a3..982d921b9e97 100644
--- a/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java
+++ b/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java
@@ -19,10 +19,7 @@ import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.CharsetUtil;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
-import com.intellij.openapi.vfs.DeprecatedVirtualFileSystem;
-import com.intellij.openapi.vfs.VfsUtilCore;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.openapi.vfs.VirtualFileSystem;
+import com.intellij.openapi.vfs.*;
import com.intellij.util.LocalTimeCounter;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -113,7 +110,7 @@ public class LightVirtualFile extends VirtualFile {
myOriginalFile = originalFile;
}
- private static class MyVirtualFileSystem extends DeprecatedVirtualFileSystem {
+ private static class MyVirtualFileSystem extends DeprecatedVirtualFileSystem implements NonPhysicalFileSystem{
@NonNls private static final String PROTOCOL = "mock";
private MyVirtualFileSystem() {
diff --git a/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java b/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java
index 633c25a0145a..f82e7a80d5fb 100644
--- a/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java
+++ b/platform/core-impl/src/com/intellij/core/CoreApplicationEnvironment.java
@@ -234,6 +234,7 @@ public class CoreApplicationEnvironment {
protected void doCheckCanceled() throws ProcessCanceledException {
}
+ @NotNull
@Override
public NonCancelableSection startNonCancelableSection() {
return NonCancelableSection.EMPTY;
diff --git a/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java b/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java
index 24e12524dc97..72d290e61e25 100644
--- a/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java
+++ b/platform/core-impl/src/com/intellij/ide/plugins/IdeaPluginDescriptorImpl.java
@@ -121,9 +121,7 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
@NotNull
public static String intern(@NotNull String s) {
- synchronized (ourInterner) {
- return ourInterner.intern(s);
- }
+ return ourInterner.intern(s);
}
public static void internJDOMElement(@NotNull Element rootElement) {
diff --git a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
index e834e33f0f42..d80d36822eb1 100644
--- a/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
+++ b/platform/core-impl/src/com/intellij/ide/plugins/PluginManagerCore.java
@@ -322,15 +322,8 @@ public class PluginManagerCore {
Extensions.registerAreaClass(ExtensionAreas.IDEA_MODULE, ExtensionAreas.IDEA_PROJECT);
}
- @SuppressWarnings({"HardCodedStringLiteral"})
- static Method getAddUrlMethod(final ClassLoader loader) throws NoSuchMethodException {
- if (loader instanceof URLClassLoader) {
- final Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
- addUrlMethod.setAccessible(true);
- return addUrlMethod;
- }
-
- return loader.getClass().getDeclaredMethod("addURL", URL.class);
+ private static Method getAddUrlMethod(final ClassLoader loader) {
+ return ReflectionUtil.getDeclaredMethod(loader instanceof URLClassLoader ? URLClassLoader.class : loader.getClass(), "addURL", URL.class);
}
@Nullable
@@ -351,9 +344,6 @@ public class PluginManagerCore {
return loader;
}
- catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
catch (IOException e) {
e.printStackTrace();
}
diff --git a/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java
index b68fa936af23..d67ae891d3bf 100644
--- a/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java
+++ b/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java
@@ -1113,7 +1113,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
if (curDepth > maxDepth) maxDepth = curDepth;
}
else if (item instanceof DoneMarker) {
- if (((DoneMarker)item).myStart != curNode) LOG.error(UNBALANCED_MESSAGE);
+ assertMarkersBalanced(((DoneMarker)item).myStart == curNode, item);
curNode = nodes.pop();
curDepth--;
}
@@ -1143,7 +1143,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
myLexStarts[myCurrentLexeme + 1] = 0;
myLexTypes[myCurrentLexeme] = null;
- LOG.assertTrue(curNode == rootMarker, UNBALANCED_MESSAGE);
+ assertMarkersBalanced(curNode == rootMarker, curNode);
checkTreeDepth(maxDepth, rootMarker.getTokenType() instanceof IFileElementType);
@@ -1151,6 +1151,16 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
return rootMarker;
}
+ private void assertMarkersBalanced(boolean condition, @Nullable ProductionMarker marker) {
+ if (condition) return;
+
+ int index = marker != null ? marker.getStartIndex() + 1 : myLexStarts.length;
+ CharSequence context =
+ index < myLexStarts.length ? myText.subSequence(Math.max(0, myLexStarts[index] - 1000), myLexStarts[index]) : "<none>";
+ String language = myFile != null ? myFile.getLanguage() + ", " : "";
+ LOG.error(UNBALANCED_MESSAGE + "\n" + language + context);
+ }
+
private void balanceWhiteSpaces() {
RelativeTokenTypesView wsTokens = new RelativeTokenTypesView();
RelativeTokenTextView tokenTextGetter = new RelativeTokenTextView();
@@ -1158,8 +1168,8 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
for (int i = 1, size = myProduction.size() - 1; i < size; i++) {
ProductionMarker item = myProduction.get(i);
- if (item instanceof StartMarker && ((StartMarker)item).myDoneMarker == null) {
- LOG.error(UNBALANCED_MESSAGE);
+ if (item instanceof StartMarker) {
+ assertMarkersBalanced(((StartMarker)item).myDoneMarker != null, item);
}
int prevProductionLexIndex = myProduction.get(i - 1).myLexemeIndex;
diff --git a/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationInfoEx.java b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationInfoEx.java
index 4282eb20ff26..d1251c9c9ad0 100644
--- a/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationInfoEx.java
+++ b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationInfoEx.java
@@ -16,6 +16,7 @@
package com.intellij.openapi.application.ex;
import com.intellij.openapi.application.ApplicationInfo;
+import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.util.Calendar;
@@ -117,4 +118,7 @@ public abstract class ApplicationInfoEx extends ApplicationInfo {
/** @deprecated to remove in IDEA 14 */
@SuppressWarnings("UnusedDeclaration")
public abstract String getWelcomeScreenDeveloperSloganUrl();
+
+ @Nullable
+ public abstract String getCustomizeIDEWizardStepsProvider();
}
diff --git a/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java
index 663cd6f9e0b3..1d7de90e5f61 100644
--- a/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java
+++ b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java
@@ -35,6 +35,12 @@ public class ApplicationUtil {
throw new CannotRunReadActionException();
}
+ public static void tryRunReadAction(@NotNull final Runnable computable) throws CannotRunReadActionException {
+ if (!((ApplicationEx)ApplicationManager.getApplication()).tryRunReadAction(computable)) {
+ throw new CannotRunReadActionException();
+ }
+ }
+
public static class CannotRunReadActionException extends RuntimeException{
@Override
public Throwable fillInStackTrace() {
diff --git a/platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java b/platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java
index 62fbfa502c79..13d580ef0834 100644
--- a/platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java
+++ b/platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java
@@ -75,6 +75,7 @@ public class ApplicationInfoImpl extends ApplicationInfoEx implements JDOMExtern
private boolean myShowLicensee = true;
private String myWelcomeScreenCaptionUrl;
private String myWelcomeScreenDeveloperSloganUrl;
+ private String myCustomizeIDEWizardStepsProvider;
private UpdateUrls myUpdateUrls;
private String myDocumentationUrl;
private String mySupportUrl;
@@ -171,6 +172,8 @@ public class ApplicationInfoImpl extends ApplicationInfoEx implements JDOMExtern
@NonNls private static final String ELEMENT_THIRD_PARTY = "third-party";
+ @NonNls private static final String CUSTOMIZE_IDE_WIZARD_STEPS = "customize-ide-wizard";
+ @NonNls private static final String STEPS_PROVIDER = "provider";
public void initComponent() { }
@@ -311,6 +314,12 @@ public class ApplicationInfoImpl extends ApplicationInfoEx implements JDOMExtern
return myWelcomeScreenLogoUrl;
}
+ @Nullable
+ @Override
+ public String getCustomizeIDEWizardStepsProvider() {
+ return myCustomizeIDEWizardStepsProvider;
+ }
+
@Override
public String getEditorBackgroundImageUrl() {
return myEditorBackgroundImageUrl;
@@ -598,6 +607,11 @@ public class ApplicationInfoImpl extends ApplicationInfoEx implements JDOMExtern
myWelcomeScreenDeveloperSloganUrl = welcomeScreen.getAttributeValue(SLOGAN_URL_ATTR);
}
+ Element wizardSteps = parentNode.getChild(CUSTOMIZE_IDE_WIZARD_STEPS);
+ if (wizardSteps != null) {
+ myCustomizeIDEWizardStepsProvider = wizardSteps.getAttributeValue(STEPS_PROVIDER);
+ }
+
Element editor = parentNode.getChild(ELEMENT_EDITOR);
if (editor != null) {
myEditorBackgroundImageUrl = editor.getAttributeValue(BACKGROUND_URL_ATTR);
diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java
index a42d7a1944f0..670aaf1d8493 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java
@@ -51,20 +51,20 @@ public abstract class DocumentCommitProcessor {
public abstract void commitAsynchronously(@NotNull final Project project, @NotNull final Document document, @NonNls @NotNull Object reason);
protected static class CommitTask {
- public final Document document;
- public final Project project;
+ @NotNull public final Document document;
+ @NotNull public final Project project;
// when queued it's not started
// when dequeued it's started
// when failed it's canceled
- public final ProgressIndicator indicator; // progress to commit this doc under.
- public final Object reason;
+ @NotNull public final ProgressIndicator indicator; // progress to commit this doc under.
+ @NotNull public final Object reason;
public boolean removed; // task marked as removed, should be ignored.
public CommitTask(@NotNull Document document,
- @NotNull Project project,
- @NotNull ProgressIndicator indicator,
- @NotNull Object reason) {
+ @NotNull Project project,
+ @NotNull ProgressIndicator indicator,
+ @NotNull Object reason) {
this.document = document;
this.project = project;
this.indicator = indicator;
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/PsiCommentImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/PsiCommentImpl.java
index d4e1b0d52f53..70bc987a91f8 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/PsiCommentImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/PsiCommentImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/CommentLiteralEscaper.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/injected/CommentLiteralEscaper.java
index c6399e30b5f6..3374a2b59f87 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/CommentLiteralEscaper.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/injected/CommentLiteralEscaper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/duplicates-analysis/src/com/intellij/dupLocator/index/DuplicatesIndex.java b/platform/duplicates-analysis/src/com/intellij/dupLocator/index/DuplicatesIndex.java
index cacbcf89aca0..1255a7fec9e3 100644
--- a/platform/duplicates-analysis/src/com/intellij/dupLocator/index/DuplicatesIndex.java
+++ b/platform/duplicates-analysis/src/com/intellij/dupLocator/index/DuplicatesIndex.java
@@ -58,7 +58,7 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
}
@NonNls public static final ID<Integer, TIntArrayList> NAME = ID.create("DuplicatesIndex");
- private static final int myBaseVersion = 9;
+ private static final int myBaseVersion = 10;
private final FileBasedIndex.InputFilter myInputFilter = new FileBasedIndex.InputFilter() {
@Override
diff --git a/platform/dvcs-api/dvcs-api.iml b/platform/dvcs-api/dvcs-api.iml
new file mode 100644
index 000000000000..f425c986a066
--- /dev/null
+++ b/platform/dvcs-api/dvcs-api.iml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="util-rt" />
+ <orderEntry type="module" module-name="vcs-log-graph-api" exported="" />
+ <orderEntry type="module" module-name="core-api" />
+ <orderEntry type="module" module-name="vcs-api" />
+ <orderEntry type="module" module-name="extensions" />
+ <orderEntry type="module" module-name="vcs-log-api" />
+ </component>
+</module>
+
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/CommitLoader.java b/platform/dvcs-api/src/com/intellij/dvcs/push/CommitLoader.java
new file mode 100644
index 000000000000..71ffa32d93e2
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/CommitLoader.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+public interface CommitLoader {
+ void reloadCommits();
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingCommitsProvider.java b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingCommitsProvider.java
new file mode 100644
index 000000000000..4532146f9b4a
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingCommitsProvider.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import com.intellij.dvcs.repo.Repository;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Provider for outgoing commits
+ */
+public abstract class OutgoingCommitsProvider {
+
+ /**
+ * Collect outgoing commits or errors for selected repo for specified {@link PushSpec} and store to {@link OutgoingResult}
+ *
+ * @param initial true for first commits loading, which identify that all inside actions should be silent
+ * and do not ask user about smth, a.e authorization request
+ */
+ @NotNull
+ public abstract OutgoingResult getOutgoingCommits(@NotNull Repository repository,
+ @NotNull PushSpec pushSpec, boolean initial);
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java
new file mode 100644
index 000000000000..7b4b0a7b4a81
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import com.intellij.vcs.log.VcsFullCommitDetails;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+public class OutgoingResult {
+ @NotNull private final List<VcsError> myErrors;
+ @NotNull private final List<? extends VcsFullCommitDetails> myCommits;
+
+ public OutgoingResult(@NotNull List<? extends VcsFullCommitDetails> commits, @NotNull List<VcsError> errors) {
+ myCommits = commits;
+ myErrors = errors;
+ }
+
+ @NotNull
+ public List<VcsError> getErrors() {
+ return myErrors;
+ }
+
+ @NotNull
+ public List<? extends VcsFullCommitDetails> getCommits() {
+ return myCommits;
+ }
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java
new file mode 100644
index 000000000000..7ae7a33dd6e2
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Source to push from. For example, local branch for git or branch/bookmark for mercurial.
+ */
+public interface PushSource {
+ @NotNull
+ String getPresentation();
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSpec.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSpec.java
new file mode 100644
index 000000000000..81ff874979bd
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSpec.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Specified a push from-to settings for one repository
+ */
+public class PushSpec {
+
+ @NotNull private PushSource mySource;
+ @Nullable private PushTarget myTarget;
+
+ public PushSpec(@NotNull PushSource source, @Nullable PushTarget target) {
+ mySource = source;
+ myTarget = target;
+ }
+
+ @NotNull
+ public PushSource getSource() {
+ return mySource;
+ }
+
+ @Nullable
+ public PushTarget getTarget() {
+ return myTarget;
+ }
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSupport.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSupport.java
new file mode 100644
index 000000000000..d6af8eec1088
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSupport.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import com.intellij.dvcs.repo.Repository;
+import com.intellij.dvcs.repo.RepositoryManager;
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.vcs.AbstractVcs;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+/**
+ * Base class to provide vcs-specific info
+ */
+
+public abstract class PushSupport<Repo extends Repository> {
+
+ public static final ExtensionPointName<PushSupport<? extends Repository>> PUSH_SUPPORT_EP =
+ ExtensionPointName.create("com.intellij.pushSupport");
+
+ @NotNull
+ public abstract AbstractVcs getVcs();
+
+ @NotNull
+ public abstract Pusher getPusher();
+
+ @NotNull
+ public abstract OutgoingCommitsProvider getOutgoingCommitsProvider();
+
+ /**
+ * @return Default push destination
+ */
+ @Nullable
+ public abstract PushTarget getDefaultTarget(@NotNull Repo repository);
+
+ /**
+ * @return All remembered remote destinations used for completion
+ */
+ @NotNull
+ public abstract Collection<String> getTargetNames(@NotNull Repo repository);
+
+ /**
+ * @return current source(branch) for repository
+ */
+ @NotNull
+ public abstract PushSource getSource(@NotNull Repo repository);
+
+ /**
+ * Parse user input string, and create the valid target for push,
+ * or return <code><b>null</b></code> if the target name is not valid.
+ *
+ * @see #validateSpec(Repository, PushSpec)
+ */
+ @Nullable
+ public abstract PushTarget createTarget(@NotNull Repo repository, @NotNull String targetName);
+
+ /**
+ * @return RepositoryManager for vcs
+ */
+ @NotNull
+ public abstract RepositoryManager<Repo> getRepositoryManager();
+
+ @Nullable
+ public VcsPushOptionsPanel getVcsPushOptionsPanel() {
+ return null;
+ }
+
+ /**
+ * @return null if target is valid for selected repository
+ */
+ @Nullable
+ public abstract VcsError validate(@NotNull Repository repository, @Nullable String targetToValidate);
+}
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudLoggingHandler.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushTarget.java
index 9fad3190e865..87c7244bd77c 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudLoggingHandler.java
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushTarget.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.remoteServer.agent.util;
+package com.intellij.dvcs.push;
+
+import org.jetbrains.annotations.NotNull;
-import com.intellij.remoteServer.agent.util.log.LogListener;
/**
- * @author michael.golubev
+ * Destination for push action. (Remote for git or push-path for mercurial).
*/
-public interface CloudLoggingHandler extends CloudAgentLoggingHandler {
+public interface PushTarget {
- LogListener getOrCreateLogListener(String pipeName);
+ @NotNull
+ String getPresentation();
}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/Pusher.java b/platform/dvcs-api/src/com/intellij/dvcs/push/Pusher.java
new file mode 100644
index 000000000000..6d5fc1611030
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/Pusher.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import com.intellij.dvcs.repo.Repository;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Map;
+
+/**
+ * Base class to execute push command.
+ */
+public abstract class Pusher {
+ /**
+ * Perform push command for all repositories belonged to one vcs.
+ *
+ * @param pushSpecs specify push from and to params
+ * @param vcsPushOptionValue specify additional options to push, null if not supported
+ * @param force if true then execute force push
+ */
+ public abstract void push(@NotNull Map<Repository, PushSpec> pushSpecs,
+ @Nullable VcsPushOptionValue vcsPushOptionValue,
+ boolean force);
+}
+
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/TreeNodeLinkListener.java b/platform/dvcs-api/src/com/intellij/dvcs/push/TreeNodeLinkListener.java
new file mode 100644
index 000000000000..8ce03d299b29
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/TreeNodeLinkListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public interface TreeNodeLinkListener {
+ void onClick(@NotNull DefaultMutableTreeNode source);
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsError.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsError.java
new file mode 100644
index 000000000000..de2c640d12b1
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsError.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class VcsError {
+ @NotNull String myErrorText;
+ @Nullable private final VcsErrorHandler myErrorHandleListener;
+
+ public VcsError(@NotNull String text) {
+ this(text, null);
+ }
+
+ public VcsError(@NotNull String text, @Nullable VcsErrorHandler listener) {
+ myErrorText = text;
+ myErrorHandleListener = listener;
+ }
+
+ public String getText() {
+ return myErrorText;
+ }
+
+ public void handleError(@NotNull CommitLoader loader) {
+ if (myErrorHandleListener != null) {
+ myErrorHandleListener.handleError(loader);
+ }
+ }
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsErrorHandler.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsErrorHandler.java
new file mode 100644
index 000000000000..c27e4c7e99d9
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsErrorHandler.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import org.jetbrains.annotations.NotNull;
+
+public interface VcsErrorHandler {
+ void handleError(@NotNull CommitLoader loader);
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionValue.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionValue.java
new file mode 100644
index 000000000000..61a50eb09d73
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionValue.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+public interface VcsPushOptionValue {
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionsPanel.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionsPanel.java
new file mode 100644
index 000000000000..5ecd9af0d182
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionsPanel.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import javax.swing.*;
+import java.awt.event.ActionListener;
+
+public abstract class VcsPushOptionsPanel extends JPanel {
+
+ public abstract VcsPushOptionValue getValue();
+
+ /**
+ * @param listener handle valueChange event
+ */
+ public abstract void addValueChangeListener(ActionListener listener);
+}
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushReferenceStrategy.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushReferenceStrategy.java
new file mode 100644
index 000000000000..7e4cbecb796b
--- /dev/null
+++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushReferenceStrategy.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+/**
+ * Specify which references(tags) should be pushed
+ */
+
+public enum VcsPushReferenceStrategy {
+ none, // do not push references/tags
+ follow, // push references only for selected sources
+ all // push all references for all repositories
+}
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/Repository.java b/platform/dvcs-api/src/com/intellij/dvcs/repo/Repository.java
index c12cf4ff0407..47cc17866c08 100644
--- a/platform/dvcs/src/com/intellij/dvcs/repo/Repository.java
+++ b/platform/dvcs-api/src/com/intellij/dvcs/repo/Repository.java
@@ -17,6 +17,7 @@ package com.intellij.dvcs.repo;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -97,6 +98,9 @@ public interface Repository extends Disposable {
@NotNull
State getState();
+ @Nullable
+ AbstractVcs getVcs();
+
/**
* Returns the hash of the revision, which HEAD currently points to.
* Returns null only in the case of a fresh repository, when no commit have been made.
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryManager.java b/platform/dvcs-api/src/com/intellij/dvcs/repo/RepositoryManager.java
index d27694cd05d0..d27694cd05d0 100644
--- a/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryManager.java
+++ b/platform/dvcs-api/src/com/intellij/dvcs/repo/RepositoryManager.java
diff --git a/platform/dvcs/dvcs.iml b/platform/dvcs-impl/dvcs-impl.iml
index 145ad6363140..43dd32b785b4 100644
--- a/platform/dvcs/dvcs.iml
+++ b/platform/dvcs-impl/dvcs-impl.iml
@@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/testFramework" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
@@ -17,6 +18,8 @@
<orderEntry type="module" module-name="vcs-log-api" />
<orderEntry type="module" module-name="vcs-log-impl" />
<orderEntry type="module" module-name="images" />
+ <orderEntry type="module" module-name="lang-impl" />
+ <orderEntry type="module" module-name="dvcs-api" />
</component>
</module>
diff --git a/platform/dvcs-impl/resources/icons/Loading@2x.gif b/platform/dvcs-impl/resources/icons/Loading@2x.gif
new file mode 100644
index 000000000000..77c756d99cb1
--- /dev/null
+++ b/platform/dvcs-impl/resources/icons/Loading@2x.gif
Binary files differ
diff --git a/platform/dvcs-impl/resources/icons/Loading@2x_dark.gif b/platform/dvcs-impl/resources/icons/Loading@2x_dark.gif
new file mode 100644
index 000000000000..f95c9287108f
--- /dev/null
+++ b/platform/dvcs-impl/resources/icons/Loading@2x_dark.gif
Binary files differ
diff --git a/platform/dvcs-impl/resources/icons/loading.gif b/platform/dvcs-impl/resources/icons/loading.gif
new file mode 100644
index 000000000000..bfd4da223753
--- /dev/null
+++ b/platform/dvcs-impl/resources/icons/loading.gif
Binary files differ
diff --git a/platform/dvcs-impl/resources/icons/loading_dark.gif b/platform/dvcs-impl/resources/icons/loading_dark.gif
new file mode 100644
index 000000000000..e41778b2c6e7
--- /dev/null
+++ b/platform/dvcs-impl/resources/icons/loading_dark.gif
Binary files differ
diff --git a/platform/dvcs-impl/src/META-INF/dvcs.xml b/platform/dvcs-impl/src/META-INF/dvcs.xml
new file mode 100644
index 000000000000..aa81616f24f6
--- /dev/null
+++ b/platform/dvcs-impl/src/META-INF/dvcs.xml
@@ -0,0 +1,12 @@
+<idea-plugin>
+ <extensionPoints>
+ <extensionPoint name="pushSupport"
+ interface="com.intellij.dvcs.push.PushSupport" area="IDEA_PROJECT"/>
+ </extensionPoints>
+ <actions>
+ <!--<action id="Vcs.Push" class="">-->
+ <!--<keyboard-shortcut first-keystroke="control shift K" keymap="$default"/>-->
+ <!--</action>-->
+ </actions>
+</idea-plugin>
+
diff --git a/platform/dvcs/src/com/intellij/dvcs/DvcsCommitAdditionalComponent.java b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsCommitAdditionalComponent.java
index 26c87c7de627..26c87c7de627 100644
--- a/platform/dvcs/src/com/intellij/dvcs/DvcsCommitAdditionalComponent.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsCommitAdditionalComponent.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/DvcsPlatformFacade.java b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsPlatformFacade.java
index 91adfa23dd92..91adfa23dd92 100644
--- a/platform/dvcs/src/com/intellij/dvcs/DvcsPlatformFacade.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsPlatformFacade.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/DvcsPlatformFacadeImpl.java b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsPlatformFacadeImpl.java
index 9f10311f68d3..9f10311f68d3 100644
--- a/platform/dvcs/src/com/intellij/dvcs/DvcsPlatformFacadeImpl.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsPlatformFacadeImpl.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/DvcsRememberedInputs.java b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsRememberedInputs.java
index 58292aa17f91..58292aa17f91 100644
--- a/platform/dvcs/src/com/intellij/dvcs/DvcsRememberedInputs.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsRememberedInputs.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsUtil.java
index c2aef0502db5..1fba1827084c 100644
--- a/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/DvcsUtil.java
@@ -39,6 +39,8 @@ import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.impl.status.StatusBarUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.text.DateFormatUtil;
+import com.intellij.vcs.log.TimedVcsCommit;
import com.intellij.vcs.log.VcsLog;
import com.intellij.vcs.log.VcsLogProvider;
import org.intellij.images.editor.ImageFileEditor;
@@ -55,6 +57,8 @@ import java.util.List;
*/
public class DvcsUtil {
+ private static final int SHORT_HASH_LENGTH = 8;
+
public static void installStatusBarWidget(@NotNull Project project, @NotNull StatusBarWidget widget) {
StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
if (statusBar != null) {
@@ -183,4 +187,19 @@ public class DvcsUtil {
return result;
}
+ @NotNull
+ public static String getShortHash(@NotNull String hash) {
+ if (hash.length() == 0) return "";
+ if (hash.length() == 40) return hash.substring(0, SHORT_HASH_LENGTH);
+ if (hash.length() > 40) // revision string encoded with date too
+ {
+ return hash.substring(hash.indexOf("[") + 1, SHORT_HASH_LENGTH);
+ }
+ return hash;
+ }
+
+ @NotNull
+ public static String getDateString(@NotNull TimedVcsCommit commit) {
+ return DateFormatUtil.formatPrettyDateTime(commit.getTimestamp()) + " ";
+ }
}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java
new file mode 100644
index 000000000000..2a409e12c854
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java
@@ -0,0 +1,445 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+import com.intellij.dvcs.DvcsUtil;
+import com.intellij.dvcs.push.ui.*;
+import com.intellij.dvcs.repo.Repository;
+import com.intellij.dvcs.repo.RepositoryManager;
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.application.ModalityState;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.progress.Task;
+import com.intellij.openapi.progress.impl.ProgressManagerImpl;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.ValidationInfo;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.vcs.AbstractVcs;
+import com.intellij.ui.CheckedTreeNode;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.hash.HashMap;
+import com.intellij.vcs.log.VcsFullCommitDetails;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.tree.DefaultMutableTreeNode;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class PushController implements Disposable {
+
+ @NotNull private final Project myProject;
+ @NotNull private final List<PushSupport<? extends Repository>> myPushSupports;
+ @NotNull private final PushLog myPushLog;
+ @NotNull private final VcsPushDialog myDialog;
+ private boolean mySingleRepoProject;
+ private static final int DEFAULT_CHILDREN_PRESENTATION_NUMBER = 20;
+ private final Map<PushSupport, MyPushOptionValueModel> myAdditionalValuesMap;
+
+ private final Map<RepositoryNode, MyRepoModel> myView2Model = new HashMap<RepositoryNode, MyRepoModel>();
+
+
+ public PushController(@NotNull Project project,
+ @NotNull VcsPushDialog dialog,
+ @NotNull List<? extends Repository> preselectedRepositories) {
+ myProject = project;
+ //todo what would be in case of null
+ myPushSupports = Arrays.asList(Extensions.getExtensions(PushSupport.PUSH_SUPPORT_EP, myProject));
+ CheckedTreeNode rootNode = new CheckedTreeNode(null);
+ mySingleRepoProject = createTreeModel(rootNode, preselectedRepositories);
+ myPushLog = new PushLog(myProject, rootNode);
+ myAdditionalValuesMap = new HashMap<PushSupport, MyPushOptionValueModel>();
+ myDialog = dialog;
+ myDialog.updateButtons();
+ startLoadingCommits();
+ Disposer.register(dialog.getDisposable(), this);
+ }
+
+ @Nullable
+ public ValidationInfo validate() {
+ ValidationInfo validInfo = new ValidationInfo("There are no selected repository to push!");
+ for (Map.Entry<RepositoryNode, MyRepoModel> entry : myView2Model.entrySet()) {
+ MyRepoModel model = entry.getValue();
+ if (model.isSelected()) {
+ //has one or more selected roots
+ validInfo = null;
+ RepositoryNode node = entry.getKey();
+ PushTarget target = model.getSpec().getTarget();
+ //todo add validation for model -> hasErrors, too
+ if (target == null) {
+ JComponent editingComponent = myPushLog.startEditNode(node);
+ return new ValidationInfo("Invalid remote for repository " + DvcsUtil.getShortRepositoryName(model.getRepository()),
+ editingComponent);
+ }
+ }
+ }
+ return validInfo;
+ }
+
+ private void startLoadingCommits() {
+ //todo should be reworked
+ Map<RepositoryNode, MyRepoModel> priorityLoading = new HashMap<RepositoryNode, MyRepoModel>();
+ Map<RepositoryNode, MyRepoModel> others = new HashMap<RepositoryNode, MyRepoModel>();
+ for (Map.Entry<RepositoryNode, MyRepoModel> entry : myView2Model.entrySet()) {
+ MyRepoModel model = entry.getValue();
+ if (model.isSelected()) {
+ priorityLoading.put(entry.getKey(), model);
+ }
+ else {
+ others.put(entry.getKey(), model);
+ }
+ }
+ loadCommitsFromMap(priorityLoading);
+ loadCommitsFromMap(others);
+ }
+
+ private void loadCommitsFromMap(@NotNull Map<RepositoryNode, MyRepoModel> items) {
+ for (Map.Entry<RepositoryNode, MyRepoModel> entry : items.entrySet()) {
+ RepositoryNode node = entry.getKey();
+ loadCommits(entry.getValue(), node, true);
+ }
+ }
+
+ //return is single repository project or not
+ private boolean createTreeModel(@NotNull CheckedTreeNode rootNode, @NotNull List<? extends Repository> preselectedRepositories) {
+ if (myPushSupports.isEmpty()) return true;
+ int repoCount = 0;
+ for (PushSupport<? extends Repository> support : myPushSupports) {
+ repoCount += createNodesForVcs(support, rootNode, preselectedRepositories);
+ }
+ return repoCount == 1;
+ }
+
+ private <T extends Repository> int createNodesForVcs(@NotNull PushSupport<T> pushSupport,
+ @NotNull CheckedTreeNode rootNode,
+ @NotNull List<? extends Repository> preselectedRepositories) {
+ RepositoryManager<T> repositoryManager = pushSupport.getRepositoryManager();
+ List<T> repositories = repositoryManager.getRepositories();
+ for (T repository : repositories) {
+ createRepoNode(pushSupport, repository, rootNode, preselectedRepositories.contains(repository), repositories.size() == 1);
+ }
+ return repositories.size();
+ }
+
+ private <T extends Repository> void createRepoNode(@NotNull final PushSupport<T> support,
+ @NotNull final T repository,
+ @NotNull CheckedTreeNode rootNode,
+ boolean isSelected,
+ boolean isSingleRepositoryProject) {
+ PushTarget target = support.getDefaultTarget(repository);
+ final MyRepoModel model = new MyRepoModel(repository, support, isSelected, new PushSpec(support.getSource(repository), target),
+ DEFAULT_CHILDREN_PRESENTATION_NUMBER);
+ RepositoryWithBranchPanel repoPanel = new RepositoryWithBranchPanel(myProject, DvcsUtil.getShortRepositoryName(repository),
+ support.getSource(repository).getPresentation(),
+ target == null ? "" : target.getPresentation(),
+ support.getTargetNames(repository));
+ final RepositoryNode repoNode = isSingleRepositoryProject ? new SingleRepositoryNode(repoPanel) : new RepositoryNode(repoPanel);
+ myView2Model.put(repoNode, model);
+ repoNode.setChecked(model.isSelected());
+ repoPanel.addRepoNodeListener(new RepositoryNodeListener() {
+ @Override
+ public void onTargetChanged(String newValue) {
+ VcsError validationError = support.validate(model.getRepository(), newValue);
+ if (validationError == null) {
+ myView2Model.get(repoNode).setSpec(new PushSpec(model.getSpec().getSource(), support.createTarget(repository, newValue)));
+ loadCommits(model, repoNode, false);
+ }
+ else {
+ //todo may be should store validation errors in model and get errors during dialog validation
+ myView2Model.get(repoNode).setSpec(new PushSpec(model.getSpec().getSource(), null));
+ }
+ myDialog.updateButtons();
+ }
+
+ @Override
+ public void onSelectionChanged(boolean isSelected) {
+ myView2Model.get(repoNode).setSelected(isSelected);
+ repoNode.setChecked(isSelected);
+ myDialog.updateButtons();
+ }
+ });
+ rootNode.add(repoNode);
+ }
+
+ private void loadCommits(@NotNull final MyRepoModel model,
+ @NotNull final RepositoryNode node,
+ final boolean initial) {
+ node.stopLoading();
+ myPushLog.startLoading(node);
+ final ProgressIndicator indicator = node.startLoading();
+ final PushSupport support = model.getSupport();
+ final AtomicReference<OutgoingResult> result = new AtomicReference<OutgoingResult>();
+ Task.Backgroundable task = new Task.Backgroundable(myProject, "Loading Commits", true) {
+
+ @Override
+ public void onCancel() {
+ node.stopLoading();
+ }
+
+ @Override
+ public void onSuccess() {
+ OutgoingResult outgoing = result.get();
+ List<VcsError> errors = outgoing.getErrors();
+ if (!errors.isEmpty()) {
+ myPushLog.setChildren(node, ContainerUtil.map(errors, new Function<VcsError, DefaultMutableTreeNode>() {
+ @Override
+ public DefaultMutableTreeNode fun(final VcsError error) {
+ VcsLinkedText errorLinkText = new VcsLinkedText(error.getText(), new VcsLinkListener() {
+ @Override
+ public void hyperlinkActivated(@NotNull DefaultMutableTreeNode sourceNode) {
+ error.handleError(new CommitLoader() {
+ @Override
+ public void reloadCommits() {
+ loadCommits(model, node, false);
+ }
+ });
+ }
+ });
+ return new TextWithLinkNode(errorLinkText);
+ }
+ }), model.isSelected());
+ }
+ else {
+ model.setLoadedCommits(outgoing.getCommits());
+ myPushLog.setChildren(node,
+ getPresentationForCommits(PushController.this.myProject, model.getLoadedCommits(),
+ model.getNumberOfShownCommits()), model.isSelected());
+ }
+ }
+
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ OutgoingResult outgoing = support.getOutgoingCommitsProvider()
+ .getOutgoingCommits(model.getRepository(), model.getSpec(), initial);
+ result.compareAndSet(null, outgoing);
+ }
+ };
+
+ ProgressManagerImpl.runProcessWithProgressAsynchronously(task, indicator, null, ModalityState.any());
+ }
+
+
+ public PushLog getPushPanelInfo() {
+ return myPushLog;
+ }
+
+ public void push(final boolean force) {
+ Task.Backgroundable task = new Task.Backgroundable(myProject, "Pushing...", false) {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ for (PushSupport support : myPushSupports) {
+ MyPushOptionValueModel additionalOptionsModel = myAdditionalValuesMap.get(support);
+ support.getPusher()
+ .push(collectPushInfoForVcs(support), additionalOptionsModel == null ? null : additionalOptionsModel.getCurrentValue(), force);
+ }
+ }
+ };
+ task.queue();
+ }
+
+ @NotNull
+ private Map<Repository, PushSpec> collectPushInfoForVcs(@NotNull final PushSupport pushSupport) {
+ Map<Repository, PushSpec> pushSpecs = new HashMap<Repository, PushSpec>();
+ Collection<MyRepoModel> repositoriesInformation = getSelectedRepoNode();
+ for (MyRepoModel repoModel : repositoriesInformation) {
+ if (pushSupport.equals(repoModel.getSupport())) {
+ pushSpecs.put(repoModel.getRepository(), repoModel.getSpec());
+ }
+ }
+ return pushSpecs;
+ }
+
+ public Collection<MyRepoModel> getSelectedRepoNode() {
+ if (mySingleRepoProject) {
+ return myView2Model.values();
+ }
+ return ContainerUtil.filter(myView2Model.values(), new Condition<MyRepoModel>() {
+ @Override
+ public boolean value(MyRepoModel model) {
+ return model.isSelected();
+ }
+ });
+ }
+
+ @Override
+ public void dispose() {
+ for (RepositoryNode node : myView2Model.keySet()) {
+ node.stopLoading();
+ }
+ }
+
+ private void addMoreCommits(RepositoryNode repositoryNode) {
+ MyRepoModel repoModel = myView2Model.get(repositoryNode);
+ repoModel.increaseShownCommits();
+ myPushLog.setChildren(repositoryNode,
+ getPresentationForCommits(
+ myProject,
+ repoModel.getLoadedCommits(),
+ repoModel.getNumberOfShownCommits()
+ ));
+ }
+
+
+ @NotNull
+ public List<DefaultMutableTreeNode> getPresentationForCommits(@NotNull final Project project,
+ @NotNull List<? extends VcsFullCommitDetails> commits,
+ int commitsNum) {
+ Function<VcsFullCommitDetails, DefaultMutableTreeNode> commitToNode = new Function<VcsFullCommitDetails, DefaultMutableTreeNode>() {
+ @Override
+ public DefaultMutableTreeNode fun(VcsFullCommitDetails commit) {
+ return new VcsFullCommitDetailsNode(project, commit);
+ }
+ };
+ List<DefaultMutableTreeNode> childrenToShown = new ArrayList<DefaultMutableTreeNode>();
+ for (int i = 0; i < commits.size(); ++i) {
+ if (i >= commitsNum) {
+ final VcsLinkedText moreCommitsLink = new VcsLinkedText("<a href='loadMore'>...</a>", new VcsLinkListener() {
+ @Override
+ public void hyperlinkActivated(@NotNull DefaultMutableTreeNode sourceNode) {
+ addMoreCommits((RepositoryNode)sourceNode);
+ }
+ });
+ childrenToShown.add(new TextWithLinkNode(moreCommitsLink));
+ break;
+ }
+ childrenToShown.add(commitToNode.fun(commits.get(i)));
+ }
+ return childrenToShown;
+ }
+
+ @NotNull
+ public List<VcsPushOptionsPanel> getAdditionalPanels() {
+ List<VcsPushOptionsPanel> additionalPanels = new ArrayList<VcsPushOptionsPanel>();
+ for (final PushSupport support : myPushSupports) {
+ if (hasRepoForPushSupport(support)) {
+ final VcsPushOptionsPanel panel = support.getVcsPushOptionsPanel();
+ if (panel != null) {
+ additionalPanels.add(panel);
+ myAdditionalValuesMap.put(support, new MyPushOptionValueModel(panel.getValue()));
+ panel.addValueChangeListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ myAdditionalValuesMap.get(support).setCurrentValue(panel.getValue());
+ }
+ });
+ }
+ }
+ }
+ return additionalPanels;
+ }
+
+ private boolean hasRepoForPushSupport(@NotNull final PushSupport support) {
+ return ContainerUtil.exists(myView2Model.values(), new Condition<MyRepoModel>() {
+ @Override
+ public boolean value(MyRepoModel model) {
+ return support.equals(model.getSupport());
+ }
+ });
+ }
+
+ private static class MyRepoModel {
+ @NotNull final Repository myRepository;
+ @NotNull private PushSupport mySupport;
+
+ @NotNull PushSpec mySpec;
+ int myNumberOfShownCommits;
+
+ List<? extends VcsFullCommitDetails> myLoadedCommits;
+ boolean myIsSelected;
+
+ public MyRepoModel(@NotNull Repository repository,
+ @NotNull PushSupport supportForRepo,
+ boolean isSelected,
+ @NotNull PushSpec spec,
+ int num) {
+ myRepository = repository;
+ mySupport = supportForRepo;
+ myIsSelected = isSelected;
+ mySpec = spec;
+ myNumberOfShownCommits = num;
+ }
+
+ @NotNull
+ public Repository getRepository() {
+ return myRepository;
+ }
+
+ @NotNull
+ public PushSupport getSupport() {
+ return mySupport;
+ }
+
+ public boolean isSelected() {
+ return myIsSelected;
+ }
+
+ public AbstractVcs<?> getVcs() {
+ return myRepository.getVcs();
+ }
+
+ @NotNull
+ public PushSpec getSpec() {
+ return mySpec;
+ }
+
+ public void setSpec(@NotNull PushSpec spec) {
+ mySpec = spec;
+ }
+
+ public void setSelected(boolean isSelected) {
+ myIsSelected = isSelected;
+ }
+
+ public int getNumberOfShownCommits() {
+ return myNumberOfShownCommits;
+ }
+
+ public void increaseShownCommits() {
+ myNumberOfShownCommits *= 2;
+ }
+
+ public List<? extends VcsFullCommitDetails> getLoadedCommits() {
+ return myLoadedCommits;
+ }
+
+ public void setLoadedCommits(List<? extends VcsFullCommitDetails> loadedCommits) {
+ myLoadedCommits = loadedCommits;
+ }
+ }
+
+ private static class MyPushOptionValueModel {
+ @NotNull private VcsPushOptionValue myCurrentValue;
+
+ public MyPushOptionValueModel(@NotNull VcsPushOptionValue currentValue) {
+ myCurrentValue = currentValue;
+ }
+
+ public void setCurrentValue(@NotNull VcsPushOptionValue currentValue) {
+ myCurrentValue = currentValue;
+ }
+
+ @NotNull
+ public VcsPushOptionValue getCurrentValue() {
+ return myCurrentValue;
+ }
+ }
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/RepositoryNodeListener.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/RepositoryNodeListener.java
new file mode 100644
index 000000000000..7ca285fc95aa
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/RepositoryNodeListener.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push;
+
+public interface RepositoryNodeListener {
+
+ void onTargetChanged(String newValue);
+
+ void onSelectionChanged(boolean isSelected);
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/CustomRenderedTreeNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/CustomRenderedTreeNode.java
new file mode 100644
index 000000000000..18a69bae53be
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/CustomRenderedTreeNode.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.ui.ColoredTreeCellRenderer;
+import org.jetbrains.annotations.NotNull;
+
+interface CustomRenderedTreeNode {
+
+ void render(@NotNull ColoredTreeCellRenderer renderer);
+} \ No newline at end of file
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/DvcsStrategyPanel.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/DvcsStrategyPanel.java
new file mode 100644
index 000000000000..5b3aa4b153ed
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/DvcsStrategyPanel.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.dvcs.push.VcsPushReferenceStrategy;
+import com.intellij.openapi.ui.ComboBox;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class DvcsStrategyPanel extends JPanel {
+
+ private ComboBox myReferenceStrategyCombobox;
+
+ public DvcsStrategyPanel() {
+ setLayout(new BorderLayout());
+ myReferenceStrategyCombobox = new ComboBox();
+ DefaultComboBoxModel comboModel = new DefaultComboBoxModel(VcsPushReferenceStrategy.values());
+ myReferenceStrategyCombobox.setModel(comboModel);
+ JPanel bottomPanel = new JPanel(new FlowLayout());
+ JLabel referenceStrategyLabel = new JLabel("Push Reference Strategy: ");
+ bottomPanel.add(referenceStrategyLabel, FlowLayout.LEFT);
+ bottomPanel.add(myReferenceStrategyCombobox);
+ add(bottomPanel, BorderLayout.WEST);
+ }
+
+ public VcsPushReferenceStrategy getStrategy() {
+ return (VcsPushReferenceStrategy)myReferenceStrategyCombobox.getSelectedItem();
+ }
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/EditableTreeNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/EditableTreeNode.java
new file mode 100644
index 000000000000..5d0d20cdc4c0
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/EditableTreeNode.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.openapi.progress.ProgressIndicator;
+import org.jetbrains.annotations.NotNull;
+
+public interface EditableTreeNode extends CustomRenderedTreeNode {
+
+ void fireOnChange(@NotNull String value);
+
+ void fireOnSelectionChange(boolean isSelected);
+
+ void stopLoading();
+
+ @NotNull
+ ProgressIndicator startLoading();
+
+ String getValue();
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/LoadingTreeNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/LoadingTreeNode.java
new file mode 100644
index 000000000000..dc424df43b81
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/LoadingTreeNode.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.ui.ColoredTreeCellRenderer;
+import com.intellij.ui.JBColor;
+import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.util.ImageLoader;
+import com.intellij.util.ui.JBImageIcon;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import javax.swing.tree.DefaultMutableTreeNode;
+import java.awt.*;
+import java.net.URL;
+
+public class LoadingTreeNode extends DefaultMutableTreeNode implements CustomRenderedTreeNode {
+ @NotNull protected ImageIcon myLoadingIcon;
+ private static final String LOADING_ICON = "/icons/loading.gif";
+
+ @NotNull
+ public ImageIcon getIcon() {
+ return myLoadingIcon;
+ }
+
+ public LoadingTreeNode() {
+ super(null, false);
+ URL loadingIconUrl = getClass().getResource(LOADING_ICON);
+ Image image = ImageLoader.loadFromUrl(loadingIconUrl);
+ myLoadingIcon = new JBImageIcon(image);
+ }
+
+ @Override
+ public void render(@NotNull ColoredTreeCellRenderer renderer) {
+ renderer.setIcon(myLoadingIcon);
+ renderer.append("Loading Commits...", new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, JBColor.GRAY));
+ }
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/NodeImageObserver.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/NodeImageObserver.java
new file mode 100644
index 000000000000..1e3d82015afe
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/NodeImageObserver.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import javax.swing.*;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
+import java.awt.*;
+import java.awt.image.ImageObserver;
+
+class NodeImageObserver implements ImageObserver {
+ JTree tree;
+ DefaultTreeModel model;
+ TreeNode node;
+
+ NodeImageObserver(JTree tree, TreeNode node) {
+ this.tree = tree;
+ this.model = (DefaultTreeModel)tree.getModel();
+ this.node = node;
+ }
+
+ public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) {
+ if ((flags & (FRAMEBITS | ALLBITS)) != 0) {
+ TreePath path = new TreePath(model.getPathToRoot(node));
+ Rectangle rect = tree.getPathBounds(path);
+ if (rect != null) {
+ tree.repaint(rect);
+ }
+ }
+ return (flags & (ALLBITS | ABORT)) == 0;
+ }
+} \ No newline at end of file
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java
new file mode 100644
index 000000000000..b07bf9243f8a
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLog.java
@@ -0,0 +1,289 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.openapi.actionSystem.CommonShortcuts;
+import com.intellij.openapi.actionSystem.DataKey;
+import com.intellij.openapi.actionSystem.DataSink;
+import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Splitter;
+import com.intellij.openapi.vcs.VcsDataKeys;
+import com.intellij.openapi.vcs.changes.Change;
+import com.intellij.openapi.vcs.changes.committed.CommittedChangesTreeBrowser;
+import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
+import com.intellij.ui.*;
+import com.intellij.ui.components.JBTextField;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.ui.tree.TreeUtil;
+import com.intellij.vcs.log.VcsFullCommitDetails;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.event.CellEditorListener;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+public class PushLog extends JPanel implements TypeSafeDataProvider {
+
+ private final ReentrantReadWriteLock TREE_CONSTRUCTION_LOCK = new ReentrantReadWriteLock();
+
+ private static final String START_EDITING = "startEditing";
+ private final ChangesBrowser myChangesBrowser;
+ private final CheckboxTree myTree;
+ private final MyTreeCellRenderer myTreeCellRenderer;
+
+ public PushLog(Project project, CheckedTreeNode root) {
+ DefaultTreeModel treeModel = new DefaultTreeModel(root);
+ treeModel.nodeStructureChanged(root);
+ myTreeCellRenderer = new MyTreeCellRenderer();
+ myTree = new CheckboxTree(myTreeCellRenderer, root) {
+
+ public boolean isPathEditable(TreePath path) {
+ return isEditable() && path.getLastPathComponent() instanceof DefaultMutableTreeNode;
+ }
+
+ @Override
+ protected void onNodeStateChanged(CheckedTreeNode node) {
+ if (node instanceof EditableTreeNode) {
+ ((EditableTreeNode)node).fireOnSelectionChange(node.isChecked());
+ }
+ }
+
+ @Override
+ public String getToolTipText(MouseEvent event) {
+ final TreePath path = myTree.getPathForLocation(event.getX(), event.getY());
+ if (path == null) {
+ return "";
+ }
+ Object node = path.getLastPathComponent();
+ if (node == null || (!(node instanceof DefaultMutableTreeNode))) {
+ return "";
+ }
+ if (node instanceof TooltipNode) {
+ return ((TooltipNode)node).getTooltip();
+ }
+ return "";
+ }
+ };
+ myTree.setEditable(true);
+ MyTreeCellEditor treeCellEditor = new MyTreeCellEditor(new JBTextField());
+ myTree.setCellEditor(treeCellEditor);
+ treeCellEditor.addCellEditorListener(new CellEditorListener() {
+ @Override
+ public void editingStopped(ChangeEvent e) {
+ }
+
+ @Override
+ public void editingCanceled(ChangeEvent e) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)myTree.getLastSelectedPathComponent();
+ if (node != null && node instanceof EditableTreeNode) {
+ //todo restore from appropriate editor
+ ((EditableTreeNode)node).fireOnChange(((EditableTreeNode)node).getValue());
+ }
+ }
+ });
+ myTree.setRootVisible(false);
+ TreeUtil.expandAll(myTree);
+ final VcsBranchEditorListener linkMouseListener = new VcsBranchEditorListener(myTreeCellRenderer);
+ linkMouseListener.installOn(myTree);
+
+ myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+ myTree.addTreeSelectionListener(new TreeSelectionListener() {
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ TreePath[] nodes = myTree.getSelectionPaths();
+ if (nodes != null) {
+ ArrayList<Change> changes = new ArrayList<Change>();
+ for (TreePath node : nodes) {
+ Object nodeInfo = ((DefaultMutableTreeNode)node.getLastPathComponent()).getUserObject();
+ if (nodeInfo instanceof VcsFullCommitDetails) {
+ changes.addAll(((VcsFullCommitDetails)nodeInfo).getChanges());
+ }
+ }
+ myChangesBrowser.getViewer().setEmptyText("No differences");
+ myChangesBrowser.setChangesToDisplay(CommittedChangesTreeBrowser.zipChanges(changes));
+ return;
+ }
+ setDefaultEmptyText();
+ myChangesBrowser.setChangesToDisplay(Collections.<Change>emptyList());
+ }
+ });
+ myTree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), START_EDITING);
+ myTree.setRowHeight(0);
+ ToolTipManager.sharedInstance().registerComponent(myTree);
+
+ myChangesBrowser =
+ new ChangesBrowser(project, null, Collections.<Change>emptyList(), null, false, true, null, ChangesBrowser.MyUseCase.LOCAL_CHANGES,
+ null);
+ myChangesBrowser.getDiffAction().registerCustomShortcutSet(CommonShortcuts.getDiff(), myTree);
+ setDefaultEmptyText();
+
+ Splitter splitter = new Splitter(false, 0.7f);
+ splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree));
+ splitter.setSecondComponent(myChangesBrowser);
+
+ setLayout(new BorderLayout());
+ add(splitter);
+ }
+
+ private void setDefaultEmptyText() {
+ myChangesBrowser.getViewer().setEmptyText("No commits selected");
+ }
+
+ // Make changes available for diff action
+ @Override
+ public void calcData(DataKey key, DataSink sink) {
+ if (VcsDataKeys.CHANGES.equals(key)) {
+ DefaultMutableTreeNode[] selectedNodes = myTree.getSelectedNodes(DefaultMutableTreeNode.class, null);
+ if (selectedNodes.length == 0) {
+ return;
+ }
+ Object object = selectedNodes[0].getUserObject();
+ if (object instanceof VcsFullCommitDetails) {
+ sink.put(key, ArrayUtil.toObjectArray(((VcsFullCommitDetails)object).getChanges(), Change.class));
+ }
+ }
+ }
+
+ @Override
+ protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER && myTree.isEditing()) {
+ myTree.cancelEditing();
+ return true;
+ }
+ return super.processKeyBinding(ks, e, condition, pressed);
+ }
+
+ public void startLoading(DefaultMutableTreeNode parentNode) {
+ LoadingTreeNode loading = new LoadingTreeNode();
+ loading.getIcon().setImageObserver(new NodeImageObserver(myTree, loading));
+ setChildren(parentNode, Collections.singleton(loading));
+ }
+
+ private class MyTreeCellEditor extends DefaultCellEditor {
+
+ public MyTreeCellEditor(JTextField field) {
+ super(field);
+ setClickCountToStart(1);
+ }
+
+ @Override
+ public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
+ final Object node = ((DefaultMutableTreeNode)value).getUserObject();
+ editorComponent =
+ (JComponent)((RepositoryWithBranchPanel)node).getTreeCellRendererComponent(tree, value, isSelected, expanded, leaf, row, true);
+ return editorComponent;
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject anEvent) {
+ if (anEvent instanceof MouseEvent) {
+ MouseEvent me = ((MouseEvent)anEvent);
+ final TreePath path = myTree.getClosestPathForLocation(me.getX(), me.getY());
+ final int row = myTree.getRowForLocation(me.getX(), me.getY());
+ myTree.getCellRenderer().getTreeCellRendererComponent(myTree, path.getLastPathComponent(), false, false, true, row, true);
+ Object tag = me.getClickCount() >= clickCountToStart
+ ? PushLogTreeUtil.getTagAtForRenderer(myTreeCellRenderer, me)
+ : null;
+ return tag instanceof EditorTextField;
+ }
+ //if keyboard event - then anEvent will be null =( See BasicTreeUi
+ TreePath treePath = myTree.getAnchorSelectionPath();
+ //there is no selection path if we start editing during initial validation//
+ if (treePath == null) return true;
+ Object treeNode = treePath.getLastPathComponent();
+ return treeNode instanceof EditableTreeNode;
+ }
+
+ //Implement the one CellEditor method that AbstractCellEditor doesn't.
+ public Object getCellEditorValue() {
+ return ((RepositoryWithBranchPanel)editorComponent).getRemoteTargetName();
+ }
+ }
+
+ private static class MyTreeCellRenderer extends CheckboxTree.CheckboxTreeCellRenderer {
+
+ @Override
+ public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+ if (!(value instanceof DefaultMutableTreeNode)) {
+ return;
+ }
+ if (value instanceof RepositoryNode) {
+ //todo simplify, remove instance of
+ myCheckbox.setVisible(((RepositoryNode)value).isCheckboxVisible());
+ }
+ Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
+ ColoredTreeCellRenderer renderer = getTextRenderer();
+ renderer.setBorder(null);
+ if (value instanceof CustomRenderedTreeNode) {
+ ((CustomRenderedTreeNode)value).render(renderer);
+ }
+ else {
+ renderer.append(userObject == null ? "" : userObject.toString());
+ }
+ }
+ }
+
+ public void setChildren(DefaultMutableTreeNode parentNode, @NotNull Collection<? extends DefaultMutableTreeNode> childrenNodes) {
+ setChildren(parentNode, childrenNodes, true);
+ }
+
+ public void setChildren(DefaultMutableTreeNode parentNode,
+ @NotNull Collection<? extends DefaultMutableTreeNode> childrenNodes,
+ boolean shouldExpand) {
+ try {
+ TREE_CONSTRUCTION_LOCK.writeLock().lock();
+ parentNode.removeAllChildren();
+ for (DefaultMutableTreeNode child : childrenNodes) {
+ parentNode.add(child);
+ }
+ final DefaultTreeModel model = ((DefaultTreeModel)myTree.getModel());
+ model.nodeStructureChanged(parentNode);
+ TreePath path = TreeUtil.getPathFromRoot(parentNode);
+ if (shouldExpand) {
+ myTree.expandPath(path);
+ }
+ else {
+ myTree.collapsePath(path);
+ }
+ }
+ finally {
+ TREE_CONSTRUCTION_LOCK.writeLock().unlock();
+ }
+ }
+
+ @Nullable
+ public JComponent startEditNode(@NotNull TreeNode node) {
+ TreePath path = TreeUtil.getPathFromRoot(node);
+ if (!myTree.isEditing()) {
+ myTree.startEditingAtPath(path);
+ }
+ return (JComponent)myTree.getCellEditor()
+ .getTreeCellEditorComponent(myTree, node, false, false, false, myTree.getRowForPath(path));
+ }
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLogTreeUtil.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLogTreeUtil.java
new file mode 100644
index 000000000000..c7da9247ae74
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/PushLogTreeUtil.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.ui.CheckboxTree;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
+import java.awt.*;
+import java.awt.event.MouseEvent;
+
+public class PushLogTreeUtil {
+
+ @Nullable
+ public static Object getTagAtForRenderer(CheckboxTree.CheckboxTreeCellRenderer renderer, MouseEvent e) {
+ JTree tree = (JTree)e.getSource();
+ Object tag = null;
+ final TreePath path = tree.getPathForLocation(e.getX(), e.getY());
+ if (path != null) {
+ final Rectangle rectangle = tree.getPathBounds(path);
+ assert rectangle != null;
+ int dx = e.getX() - rectangle.x;
+ final TreeNode treeNode = (TreeNode)path.getLastPathComponent();
+ final int row = tree.getRowForLocation(e.getX(), e.getY());
+ tree.getCellRenderer().getTreeCellRendererComponent(tree, treeNode, false, false, true, row, true);
+ if (treeNode instanceof RepositoryNode) {
+ RepositoryNode repositoryNode = (RepositoryNode)treeNode;
+ int checkBoxWidth = repositoryNode.isCheckboxVisible() ? renderer.getCheckbox().getWidth() : 0;
+ tag = renderer.getTextRenderer().getFragmentTagAt(dx - checkBoxWidth);
+ }
+ else {
+ tag = renderer.getTextRenderer().getFragmentTagAt(dx);
+ }
+ }
+ return tag;
+ }
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java
new file mode 100644
index 000000000000..24a26ece96d9
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryNode.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.openapi.progress.EmptyProgressIndicator;
+import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.ui.CheckedTreeNode;
+import com.intellij.ui.ColoredTreeCellRenderer;
+import com.intellij.ui.EditorTextField;
+import com.intellij.ui.SimpleTextAttributes;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import java.awt.*;
+
+public class RepositoryNode extends CheckedTreeNode implements EditableTreeNode {
+ protected final static String ENTER_REMOTE = "Enter Remote";
+ @NotNull private final RepositoryWithBranchPanel myRepositoryPanel;
+
+ private ProgressIndicator myCurrentIndicator;
+
+ public RepositoryNode(@NotNull RepositoryWithBranchPanel repositoryPanel) {
+ super(repositoryPanel);
+ myRepositoryPanel = repositoryPanel;
+ }
+
+ public boolean isCheckboxVisible() {
+ return true;
+ }
+
+ @Override
+ public void render(@NotNull ColoredTreeCellRenderer renderer) {
+ String repositoryPath = myRepositoryPanel.getRepositoryName();
+ renderer.append(repositoryPath, SimpleTextAttributes.GRAY_ATTRIBUTES);
+ renderer.appendFixedTextFragmentWidth(120);
+ renderer.append(myRepositoryPanel.getSourceName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ renderer.append(myRepositoryPanel.getArrow(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ EditorTextField textField = myRepositoryPanel.getRemoteTextFiled();
+ renderTargetName(renderer, textField, myRepositoryPanel.getRemoteTargetName());
+ Insets insets = BorderFactory.createEmptyBorder().getBorderInsets(textField);
+ renderer.setBorder(new EmptyBorder(insets));
+ }
+
+ protected void renderTargetName(@NotNull ColoredTreeCellRenderer renderer, @NotNull EditorTextField textField,
+ @NotNull String targetName) {
+ if (StringUtil.isEmptyOrSpaces(targetName)) {
+ renderer.append(ENTER_REMOTE, SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES, textField);
+ }
+ else {
+ renderer.append(targetName, SimpleTextAttributes.SYNTHETIC_ATTRIBUTES, textField);
+ }
+ }
+
+ @Override
+ @NotNull
+ public String getValue() {
+ return myRepositoryPanel.getRemoteTargetName();
+ }
+
+ @Override
+ public void fireOnChange(@NotNull String value) {
+ myRepositoryPanel.fireOnChange(value);
+ }
+
+ @Override
+ public void fireOnSelectionChange(boolean isSelected) {
+ myRepositoryPanel.fireOnSelectionChange(isSelected);
+ }
+
+ @Override
+ public void stopLoading() {
+ if (myCurrentIndicator != null && myCurrentIndicator.isRunning()) {
+ myCurrentIndicator.cancel();
+ }
+ }
+
+ @Override
+ @NotNull
+ public ProgressIndicator startLoading() {
+ return myCurrentIndicator = new EmptyProgressIndicator();
+ }
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java
new file mode 100644
index 000000000000..c1afcdd52839
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/RepositoryWithBranchPanel.java
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.dvcs.push.RepositoryNodeListener;
+import com.intellij.openapi.editor.ex.EditorEx;
+import com.intellij.openapi.project.Project;
+import com.intellij.ui.ColoredTreeCellRenderer;
+import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.ui.TextFieldWithAutoCompletion;
+import com.intellij.ui.TextFieldWithAutoCompletionListProvider;
+import com.intellij.ui.components.JBCheckBox;
+import com.intellij.ui.components.JBLabel;
+import com.intellij.ui.components.panels.NonOpaquePanel;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import javax.swing.tree.TreeCellRenderer;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.util.Collection;
+import java.util.List;
+
+public class RepositoryWithBranchPanel extends NonOpaquePanel implements TreeCellRenderer {
+
+ private final JBCheckBox myRepositoryCheckbox;
+ private final TextFieldWithAutoCompletion myDestBranchTextField;
+ private final JBLabel myLocalBranch;
+ private final JLabel myArrowLabel;
+ private final JLabel myRepositoryLabel;
+ private final ColoredTreeCellRenderer myTextRenderer;
+ @NotNull private final List<RepositoryNodeListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
+
+ public RepositoryWithBranchPanel(Project project, @NotNull String repoName,
+ @NotNull String sourceName, String targetName, @NotNull Collection<String> targetVariants) {
+ super();
+ setLayout(new BorderLayout());
+ myRepositoryCheckbox = new JBCheckBox();
+ myRepositoryCheckbox.setOpaque(false);
+ myRepositoryCheckbox.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ fireOnSelectionChange(myRepositoryCheckbox.isSelected());
+ }
+ });
+ myRepositoryLabel = new JLabel(repoName);
+ myLocalBranch = new JBLabel(sourceName);
+ myArrowLabel = new JLabel(" -> ");
+ TextFieldWithAutoCompletionListProvider<String> provider =
+ new TextFieldWithAutoCompletion.StringsCompletionProvider(targetVariants, null);
+ myDestBranchTextField = new TextFieldWithAutoCompletion<String>(project, provider, true, targetName) {
+
+ @Override
+ public boolean shouldHaveBorder() {
+ return false;
+ }
+
+ @Override
+ protected void updateBorder(@NotNull final EditorEx editor) {
+ }
+ };
+ myDestBranchTextField.setBorder(UIUtil.getTableFocusCellHighlightBorder());//getTextFieldBorder());
+ myDestBranchTextField.setOneLineMode(true);
+ myDestBranchTextField.setOpaque(true);
+ myDestBranchTextField.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ myDestBranchTextField.selectAll();
+ }
+ });
+
+ myTextRenderer = new ColoredTreeCellRenderer() {
+ public void customizeCellRenderer(@NotNull JTree tree,
+ Object value,
+ boolean selected,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus) {
+
+ }
+ };
+ myTextRenderer.setOpaque(false);
+ layoutComponents();
+ }
+
+ private void layoutComponents() {
+ add(myRepositoryCheckbox, BorderLayout.WEST);
+ JPanel panel = new NonOpaquePanel(new BorderLayout());
+ panel.add(myTextRenderer, BorderLayout.WEST);
+ panel.add(myDestBranchTextField, BorderLayout.CENTER);
+ add(panel, BorderLayout.CENTER);
+ }
+
+ @NotNull
+ public String getRepositoryName() {
+ return myRepositoryLabel.getText();
+ }
+
+ public String getSourceName() {
+ return myLocalBranch.getText();
+ }
+
+ public String getArrow() {
+ return myArrowLabel.getText();
+ }
+
+ public TextFieldWithAutoCompletion getRemoteTextFiled() {
+ return myDestBranchTextField;
+ }
+
+ @NotNull
+ public String getRemoteTargetName() {
+ return myDestBranchTextField.getText();
+ }
+
+ @Override
+ public Component getTreeCellRendererComponent(JTree tree,
+ Object value,
+ boolean selected,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus) {
+ Rectangle bounds = tree.getPathBounds(tree.getPathForRow(row));
+ invalidate();
+ if (!(value instanceof SingleRepositoryNode)) {
+ RepositoryNode node = (RepositoryNode)value;
+ myRepositoryCheckbox.setSelected(node.isChecked());
+ myRepositoryCheckbox.setVisible(true);
+ myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
+ myTextRenderer.append(getRepositoryName(), SimpleTextAttributes.GRAY_ATTRIBUTES);
+ myTextRenderer.appendFixedTextFragmentWidth(120);
+ }
+ else {
+ myTextRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
+ myRepositoryCheckbox.setVisible(false);
+ }
+ myTextRenderer.append(getSourceName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ myTextRenderer.append(getArrow(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ if (bounds != null) {
+ setPreferredSize(new Dimension(tree.getWidth() - bounds.x, bounds.height));
+ }
+ myDestBranchTextField.grabFocus();
+ myDestBranchTextField.requestFocus();
+ revalidate();
+ return this;
+ }
+
+ public void addRepoNodeListener(@NotNull RepositoryNodeListener listener) {
+ myListeners.add(listener);
+ }
+
+ public void fireOnChange(@NotNull String newValue) {
+ for (RepositoryNodeListener listener : myListeners) {
+ listener.onTargetChanged(newValue);
+ }
+ }
+
+ public void fireOnSelectionChange(boolean isSelected) {
+ for (RepositoryNodeListener listener : myListeners) {
+ listener.onSelectionChanged(isSelected);
+ }
+ }
+}
+
+
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/SingleRepositoryNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/SingleRepositoryNode.java
new file mode 100644
index 000000000000..c566dd6f2867
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/SingleRepositoryNode.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.ui.ColoredTreeCellRenderer;
+import com.intellij.ui.EditorTextField;
+import com.intellij.ui.SimpleTextAttributes;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import java.awt.*;
+
+public class SingleRepositoryNode extends RepositoryNode {
+
+ @NotNull private final RepositoryWithBranchPanel myRepositoryPanel;
+
+ public SingleRepositoryNode(@NotNull RepositoryWithBranchPanel repositoryPanel) {
+ super(repositoryPanel);
+ myRepositoryPanel = repositoryPanel;
+ }
+
+ @Override
+ public boolean isCheckboxVisible() {
+ return false;
+ }
+
+ @Override
+ public void render(@NotNull ColoredTreeCellRenderer renderer) {
+ renderer.append(myRepositoryPanel.getSourceName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ renderer.append(myRepositoryPanel.getArrow(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ EditorTextField textField = myRepositoryPanel.getRemoteTextFiled();
+ String targetName = myRepositoryPanel.getRemoteTargetName();
+ renderTargetName(renderer, textField, targetName);
+ Insets insets = BorderFactory.createEmptyBorder().getBorderInsets(textField);
+ renderer.setBorder(new EmptyBorder(insets));
+ }
+
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/TextWithLinkNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/TextWithLinkNode.java
new file mode 100644
index 000000000000..685fcb81fd05
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/TextWithLinkNode.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.ui.ColoredTreeCellRenderer;
+import com.intellij.ui.SimpleTextAttributes;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+
+public class TextWithLinkNode extends DefaultMutableTreeNode implements CustomRenderedTreeNode {
+
+ @NotNull protected VcsLinkedText myLinkedText;
+
+ public TextWithLinkNode(@NotNull VcsLinkedText linkedText) {
+ myLinkedText = linkedText;
+ }
+
+ public void fireOnClick(@NotNull TextWithLinkNode relatedNode) {
+ TreeNode parent = relatedNode.getParent();
+ if (parent instanceof RepositoryNode) {
+ myLinkedText.hyperLinkActivate((RepositoryNode)parent);
+ }
+ }
+
+ @Override
+ public void render(@NotNull ColoredTreeCellRenderer renderer) {
+ renderer.append(myLinkedText.getTextBefore(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ String linkedText = myLinkedText.getLinkText();
+ if (!StringUtil.isEmptyOrSpaces(linkedText)) {
+ renderer.append(" ");
+ renderer.append(myLinkedText.getLinkText(), SimpleTextAttributes.SYNTHETIC_ATTRIBUTES, this);
+ }
+ renderer.append(myLinkedText.getTextAfter(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
+ }
+} \ No newline at end of file
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/TooltipNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/TooltipNode.java
new file mode 100644
index 000000000000..fef83cc12f63
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/TooltipNode.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+public interface TooltipNode {
+
+ String getTooltip();
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsBranchEditorListener.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsBranchEditorListener.java
new file mode 100644
index 000000000000..d8e35fd25d53
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsBranchEditorListener.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.openapi.vcs.changes.issueLinks.LinkMouseListenerBase;
+import com.intellij.ui.CheckboxTree;
+import com.intellij.ui.EditorTextField;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+import java.awt.event.MouseEvent;
+
+public class VcsBranchEditorListener extends LinkMouseListenerBase {
+ private final CheckboxTree.CheckboxTreeCellRenderer myRenderer;
+
+ public VcsBranchEditorListener(final CheckboxTree.CheckboxTreeCellRenderer renderer) {
+ myRenderer = renderer;
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ Component component = (Component)e.getSource();
+ Object tag = getTagAt(e);
+ if (tag != null && tag instanceof EditorTextField) {
+ component.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
+ }
+ else if (tag != null && tag instanceof TextWithLinkNode) {
+ component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ }
+ else {
+ component.setCursor(Cursor.getDefaultCursor());
+ }
+ }
+
+ @Nullable
+ @Override
+ protected Object getTagAt(@NotNull final MouseEvent e) {
+ return PushLogTreeUtil.getTagAtForRenderer(myRenderer, e);
+ }
+
+ protected void handleTagClick(@Nullable Object tag, @NotNull MouseEvent event) {
+ if (tag instanceof TextWithLinkNode) {
+ TextWithLinkNode textWithLink = (TextWithLinkNode)tag;
+ textWithLink.fireOnClick(textWithLink);
+ }
+ }
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsFullCommitDetailsNode.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsFullCommitDetailsNode.java
new file mode 100644
index 000000000000..0df7af05d496
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsFullCommitDetailsNode.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.dvcs.DvcsUtil;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkHtmlRenderer;
+import com.intellij.ui.ColoredTreeCellRenderer;
+import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.vcs.log.VcsFullCommitDetails;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public class VcsFullCommitDetailsNode extends DefaultMutableTreeNode implements CustomRenderedTreeNode, TooltipNode {
+
+ @NotNull private final Project myProject;
+ private final VcsFullCommitDetails myCommit;
+
+ public VcsFullCommitDetailsNode(@NotNull Project project, VcsFullCommitDetails commit) {
+ super(commit, false);
+ myProject = project;
+ myCommit = commit;
+ }
+
+ @Override
+ public void render(@NotNull ColoredTreeCellRenderer renderer) {
+ renderer
+ .append(myCommit.getSubject(), new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, renderer.getForeground()));
+ }
+
+ public String getTooltip() {
+ return DvcsUtil.getShortHash(myCommit.getId().toString()) +
+ " " +
+ DvcsUtil.getDateString(myCommit) +
+ " by " +
+ myCommit.getAuthor().getName() +
+ "\n\n" +
+ IssueLinkHtmlRenderer.formatTextWithLinks(myProject, myCommit.getFullMessage());
+ }
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsLinkListener.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsLinkListener.java
new file mode 100644
index 000000000000..76578165b37c
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsLinkListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+public interface VcsLinkListener {
+ void hyperlinkActivated(@NotNull DefaultMutableTreeNode sourceNode);
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsLinkedText.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsLinkedText.java
new file mode 100644
index 000000000000..35c4989f160e
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsLinkedText.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class VcsLinkedText {
+
+ private static final Pattern HREF_PATTERN = Pattern.compile("<a(?:\\s+href\\s*=\\s*[\"']([^\"']*)[\"'])?\\s*>([^<]*)</a>");
+
+ @NotNull private String myTextBefore;
+ @NotNull private String myTextAfter;
+ @NotNull private String myHandledLink;
+
+ @Nullable private final VcsLinkListener myLinkListener;
+
+ public VcsLinkedText(@NotNull String text, @Nullable VcsLinkListener listener) {
+ Matcher aMatcher = HREF_PATTERN.matcher(text);
+ if (aMatcher.find()) {
+ myTextBefore = text.substring(0, aMatcher.start());
+ myHandledLink = aMatcher.group(2);
+ myTextAfter = text.substring(aMatcher.end(), text.length());
+ }
+ else {
+ myTextBefore = text;
+ myHandledLink = "";
+ myTextAfter = "";
+ }
+ myLinkListener = listener;
+ }
+
+ @NotNull
+ public String getTextBefore() {
+ return myTextBefore;
+ }
+
+ @NotNull
+ public String getTextAfter() {
+ return myTextAfter;
+ }
+
+ @NotNull
+ public String getLinkText() {
+ return myHandledLink;
+ }
+
+ public void hyperLinkActivate(@NotNull DefaultMutableTreeNode relatedNode) {
+ if (myLinkListener != null) {
+ myLinkListener.hyperlinkActivated(relatedNode);
+ }
+ }
+}
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java
new file mode 100644
index 000000000000..b441952f7a43
--- /dev/null
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2000-2014 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.dvcs.push.ui;
+
+import com.intellij.dvcs.push.PushController;
+import com.intellij.dvcs.push.VcsPushOptionsPanel;
+import com.intellij.dvcs.repo.Repository;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.OptionAction;
+import com.intellij.openapi.ui.ValidationInfo;
+import net.miginfocom.swing.MigLayout;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.List;
+
+public class VcsPushDialog extends DialogWrapper {
+
+ private final PushLog myListPanel;
+ private final PushController myController;
+ private final Action[] myExecutorActions = {new DvcsPushAction("&Force Push", true)};
+ @NotNull private final JPanel myAdditionalOptionsFromVcsPanel;
+
+ private DvcsPushAction myPushAction;
+
+ public VcsPushDialog(@NotNull Project project, @NotNull List<? extends Repository> selectedRepositories) {
+ super(project);
+ myController = new PushController(project, this, selectedRepositories);
+ myListPanel = myController.getPushPanelInfo();
+ myAdditionalOptionsFromVcsPanel = new JPanel(new MigLayout("ins 0 0, flowx"));
+ init();
+ setOKButtonText("Push");
+ setOKButtonMnemonic('P');
+ setTitle("Push Dialog");
+ }
+
+ @Override
+ protected JComponent createCenterPanel() {
+
+ JComponent rootPanel = new JPanel(new BorderLayout(0, 15));
+ rootPanel.add(myListPanel, BorderLayout.CENTER);
+ for (VcsPushOptionsPanel panel : myController.getAdditionalPanels()) {
+ myAdditionalOptionsFromVcsPanel.add(panel);
+ }
+ rootPanel.add(myAdditionalOptionsFromVcsPanel, BorderLayout.SOUTH);
+ return rootPanel;
+ }
+
+ @Override
+ protected String getDimensionServiceKey() {
+ return VcsPushDialog.class.getName();
+ }
+
+ @Override
+ @NotNull
+ protected Action[] createActions() {
+ final List<Action> actions = new ArrayList<Action>();
+ myPushAction = new DvcsPushAction("&Push", false);
+ myPushAction.putValue(DEFAULT_ACTION, Boolean.TRUE);
+ actions.add(myPushAction);
+ myPushAction.setOptions(myExecutorActions);
+ actions.add(getCancelAction());
+ actions.add(getHelpAction());
+ return actions.toArray(new Action[actions.size()]);
+ }
+
+ @NotNull
+ @Override
+ protected Action getOKAction() {
+ return myPushAction;
+ }
+
+ @Nullable
+ @Override
+ protected ValidationInfo doValidate() {
+ return myController.validate();
+ }
+
+ @Override
+ protected String getHelpId() {
+ return "reference.mercurial.push.dialog";
+ }
+
+ public void updateButtons() {
+ initValidation();
+ }
+
+ @Override
+ protected boolean postponeValidation() {
+ return false;
+ }
+
+ private class DvcsPushAction extends AbstractAction implements OptionAction {
+ private Action[] myOptions = new Action[0];
+ private final boolean myForce;
+
+ private DvcsPushAction(String title, boolean force) {
+ super(title);
+ myForce = force;
+ }
+
+ @Override
+ public void setEnabled(boolean isEnabled) {
+ super.setEnabled(isEnabled);
+ for (Action optionAction : myOptions) {
+ optionAction.setEnabled(isEnabled);
+ }
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ myController.push(myForce);
+ close(OK_EXIT_CODE);
+ }
+
+ @NotNull
+ @Override
+ public Action[] getOptions() {
+ return myOptions;
+ }
+
+ public void setOptions(Action[] actions) {
+ myOptions = actions;
+ }
+ }
+}
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/AbstractRepositoryManager.java b/platform/dvcs-impl/src/com/intellij/dvcs/repo/AbstractRepositoryManager.java
index 992654248e83..992654248e83 100644
--- a/platform/dvcs/src/com/intellij/dvcs/repo/AbstractRepositoryManager.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/repo/AbstractRepositoryManager.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/RepoStateException.java b/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepoStateException.java
index cfe1f0e5c014..cfe1f0e5c014 100644
--- a/platform/dvcs/src/com/intellij/dvcs/repo/RepoStateException.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepoStateException.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryImpl.java b/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryImpl.java
index 5a605c566710..5a605c566710 100644
--- a/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryImpl.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryImpl.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryUtil.java b/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryUtil.java
index 5a5a555768ba..5a5a555768ba 100644
--- a/platform/dvcs/src/com/intellij/dvcs/repo/RepositoryUtil.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/repo/RepositoryUtil.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java
index 3b935745a212..44b4c8c5c3f0 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java
@@ -34,13 +34,10 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
-/**
- * @author Nadya Zabrodina
- */
public class BranchActionGroupPopup extends PopupFactoryImpl.ActionGroupPopup {
public BranchActionGroupPopup(@NotNull String title, @NotNull Project project,
@NotNull Condition<AnAction> preselectActionCondition, @NotNull ActionGroup actions) {
- super(title, actions, SimpleDataContext.getProjectContext(project), false, false, false, false, null, -1,
+ super(title, actions, SimpleDataContext.getProjectContext(project), false, false, true, false, null, -1,
preselectActionCondition, null);
}
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/CloneDvcsDialog.form b/platform/dvcs-impl/src/com/intellij/dvcs/ui/CloneDvcsDialog.form
index 53d957676c8b..53d957676c8b 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/CloneDvcsDialog.form
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/CloneDvcsDialog.form
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/CloneDvcsDialog.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/CloneDvcsDialog.java
index 8e06c99775e2..8e06c99775e2 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/CloneDvcsDialog.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/CloneDvcsDialog.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/DvcsBundle.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.java
index 879def5e1802..879def5e1802 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/DvcsBundle.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/DvcsBundle.properties b/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.properties
index 14822049588d..14822049588d 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/DvcsBundle.properties
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.properties
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/NewBranchAction.java
index 29481e236c2a..92ba9515b5d6 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/NewBranchAction.java
@@ -25,9 +25,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
-/**
- * @author Nadya Zabrodina
- */
public abstract class NewBranchAction<T extends Repository> extends DumbAwareAction {
protected final List<T> myRepositories;
protected Project myProject;
@@ -43,7 +40,7 @@ public abstract class NewBranchAction<T extends Repository> extends DumbAwareAct
public void update(AnActionEvent e) {
if (DvcsUtil.anyRepositoryIsFresh(myRepositories)) {
e.getPresentation().setEnabled(false);
- e.getPresentation().setDescription("Checkout of a new branch is not possible before the first commit.");
+ e.getPresentation().setDescription("Checkout of a new branch is not possible before the first commit");
}
}
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/RootAction.java
index 93e49042648c..93e49042648c 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/RootAction.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/VcsLogAction.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/VcsLogAction.java
index bb7f64f9b24c..bb7f64f9b24c 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/VcsLogAction.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/VcsLogAction.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/VcsLogOneCommitPerRepoAction.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/VcsLogOneCommitPerRepoAction.java
index 1b4be918a3e1..1b4be918a3e1 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/VcsLogOneCommitPerRepoAction.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/VcsLogOneCommitPerRepoAction.java
diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/VcsLogSingleCommitAction.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/VcsLogSingleCommitAction.java
index 4b43380ea9eb..4b43380ea9eb 100644
--- a/platform/dvcs/src/com/intellij/dvcs/ui/VcsLogSingleCommitAction.java
+++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/VcsLogSingleCommitAction.java
diff --git a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockProject.java b/platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockProject.java
index 6ca5f302607c..a8dc262d7be1 100644
--- a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockProject.java
+++ b/platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockProject.java
@@ -15,15 +15,15 @@
*/
package com.intellij.dvcs.test;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.components.BaseComponent;
-import org.picocontainer.PicoContainer;
-import com.intellij.util.messages.MessageBus;
import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Key;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.messages.MessageBus;
import org.jetbrains.annotations.NotNull;
+import org.picocontainer.PicoContainer;
/**
*
diff --git a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockProjectRootManager.java b/platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockProjectRootManager.java
index d89b92878f54..d89b92878f54 100644
--- a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockProjectRootManager.java
+++ b/platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockProjectRootManager.java
diff --git a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockVcsHelper.java b/platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockVcsHelper.java
index 55e0a0e68b17..55e0a0e68b17 100644
--- a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockVcsHelper.java
+++ b/platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockVcsHelper.java
diff --git a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockVirtualFile.java b/platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockVirtualFile.java
index 3b36381dcf85..3b36381dcf85 100644
--- a/platform/dvcs/testFramework/com/intellij/dvcs/test/MockVirtualFile.java
+++ b/platform/dvcs-impl/testFramework/com/intellij/dvcs/test/MockVirtualFile.java
diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java
index e6b2553085a8..aff6216c3dba 100644
--- a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java
+++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java
@@ -21,9 +21,10 @@ import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.*;
-import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.SimpleModificationTracker;
import com.intellij.openapi.util.SystemInfo;
+import com.intellij.util.EventDispatcher;
import com.intellij.util.PlatformUtilsCore;
import com.intellij.util.SystemProperties;
import com.intellij.util.ui.UIUtil;
@@ -36,7 +37,6 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
-import javax.swing.event.EventListenerList;
import java.awt.*;
import java.io.File;
import java.util.Map;
@@ -50,7 +50,7 @@ import static com.intellij.util.ui.UIUtil.isValidFont;
file = StoragePathMacros.APP_CONFIG + "/ui.lnf.xml"
)}
)
-public class UISettings implements PersistentStateComponent<UISettings>, ExportableApplicationComponent {
+public class UISettings extends SimpleModificationTracker implements PersistentStateComponent<UISettings>, ExportableApplicationComponent {
/** Not tabbed pane. */
public static final int TABS_NONE = 0;
@@ -121,10 +121,9 @@ public class UISettings implements PersistentStateComponent<UISettings>, Exporta
public boolean SHOW_TABS_TOOLTIPS = true;
public boolean SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true;
- private final EventListenerList myListenerList;
+ private final EventDispatcher<UISettingsListener> myDispatcher = EventDispatcher.create(UISettingsListener.class);
public UISettings() {
- myListenerList = new EventListenerList();
tweakPlatformDefaults();
setSystemFontFaceAndSize();
}
@@ -142,31 +141,24 @@ public class UISettings implements PersistentStateComponent<UISettings>, Exporta
* @deprecated use {@link UISettings#addUISettingsListener(com.intellij.ide.ui.UISettingsListener, Disposable disposable)} instead.
*/
public void addUISettingsListener(UISettingsListener listener) {
- myListenerList.add(UISettingsListener.class, listener);
+ myDispatcher.addListener(listener);
}
public void addUISettingsListener(@NotNull final UISettingsListener listener, @NotNull Disposable parentDisposable) {
- myListenerList.add(UISettingsListener.class, listener);
- Disposer.register(parentDisposable, new Disposable() {
- @Override
- public void dispose() {
- removeUISettingsListener(listener);
- }
- });
+ myDispatcher.addListener(listener, parentDisposable);
}
/**
* Notifies all registered listeners that UI settings has been changed.
*/
public void fireUISettingsChanged() {
- UISettingsListener[] listeners = myListenerList.getListeners(UISettingsListener.class);
- for (UISettingsListener listener : listeners) {
- listener.uiSettingsChanged(this);
- }
+ incModificationCount();
+ myDispatcher.getMulticaster().uiSettingsChanged(this);
+ ApplicationManager.getApplication().getMessageBus().syncPublisher(UISettingsListener.TOPIC).uiSettingsChanged(this);
}
public void removeUISettingsListener(UISettingsListener listener) {
- myListenerList.remove(UISettingsListener.class, listener);
+ myDispatcher.removeListener(listener);
}
private void setSystemFontFaceAndSize() {
diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsListener.java b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsListener.java
index 035fb700e481..1dcce2c076a3 100644
--- a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsListener.java
+++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsListener.java
@@ -19,8 +19,12 @@
*/
package com.intellij.ide.ui;
+import com.intellij.util.messages.Topic;
+
import java.util.EventListener;
public interface UISettingsListener extends EventListener{
+ Topic<UISettingsListener> TOPIC = Topic.create("UI settings", UISettingsListener.class);
+
void uiSettingsChanged(UISettings source);
}
diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java
index 1d1540910539..42da54a61d72 100644
--- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java
+++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -297,6 +297,10 @@ public abstract class AnAction implements PossiblyDumbAware {
return myIsDefaultIcon;
}
+ /**
+ * Enables automatic detection of injected fragments in editor. Values in DataContext, passed to the action, like EDITOR, PSI_FILE
+ * will refer to an injected fragment, if caret is currently positioned on it.
+ */
public void setInjectedContext(boolean worksInInjected) {
myWorksInInjected = worksInInjected;
}
diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java
index 5202aa291224..94dcccb71778 100644
--- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java
+++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java
@@ -37,7 +37,7 @@ import java.util.Map;
public class AnActionEvent implements PlaceProvider<String> {
private final InputEvent myInputEvent;
- private final ActionManager myActionManager;
+ @NotNull private final ActionManager myActionManager;
@NotNull private final DataContext myDataContext;
@NotNull private final String myPlace;
@NotNull private final Presentation myPresentation;
@@ -49,12 +49,14 @@ public class AnActionEvent implements PlaceProvider<String> {
/**
* @throws IllegalArgumentException if <code>dataContext</code> is <code>null</code> or
* <code>place</code> is <code>null</code> or <code>presentation</code> is <code>null</code>
+ *
+ * @see ActionManager#getInstance()
*/
public AnActionEvent(InputEvent inputEvent,
@NotNull DataContext dataContext,
@NotNull @NonNls String place,
@NotNull Presentation presentation,
- ActionManager actionManager,
+ @NotNull ActionManager actionManager,
@JdkConstants.InputEventMask int modifiers) {
// TODO[vova,anton] make this constructor package local. No one is allowed to create AnActionEvents
myInputEvent = inputEvent;
@@ -69,7 +71,7 @@ public class AnActionEvent implements PlaceProvider<String> {
public static AnActionEvent createFromInputEvent(@NotNull AnAction action, InputEvent event, @NotNull String place) {
DataContext context = event == null ? DataManager.getInstance().getDataContext() : DataManager.getInstance().getDataContext(event.getComponent());
int modifiers = event == null ? 0 : event.getModifiers();
- return new AnActionEvent(
+ AnActionEvent anActionEvent = new AnActionEvent(
event,
context,
place,
@@ -77,6 +79,8 @@ public class AnActionEvent implements PlaceProvider<String> {
ActionManager.getInstance(),
modifiers
);
+ anActionEvent.setInjectedContext(action.isInInjectedContext());
+ return anActionEvent;
}
/**
@@ -113,6 +117,18 @@ public class AnActionEvent implements PlaceProvider<String> {
return StringUtil.trimStart(dataId, ourInjectedPrefix);
}
+ public static DataContext getInjectedDataContext(final DataContext context) {
+ return new DataContextWrapper(context) {
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ Object injected = super.getData(injectedId(dataId));
+ if (injected != null) return injected;
+ return super.getData(dataId);
+ }
+ };
+ }
+
/**
* Returns the context which allows to retrieve information about the state of IDEA related to
* the action invocation (active editor, selection and so on).
@@ -121,18 +137,7 @@ public class AnActionEvent implements PlaceProvider<String> {
*/
@NotNull
public DataContext getDataContext() {
- if (!myWorksInInjected) {
- return myDataContext;
- }
- return new DataContext() {
- @Override
- @Nullable
- public Object getData(@NonNls String dataId) {
- Object injected = myDataContext.getData(injectedId(dataId));
- if (injected != null) return injected;
- return myDataContext.getData(dataId);
- }
- };
+ return myWorksInInjected ? getInjectedDataContext(myDataContext) : myDataContext;
}
@Nullable
@@ -203,9 +208,11 @@ public class AnActionEvent implements PlaceProvider<String> {
return myModifiers;
}
+ @NotNull
public ActionManager getActionManager() {
return myActionManager;
}
+
public void setInjectedContext(boolean worksInInjected) {
myWorksInInjected = worksInInjected;
}
diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java
index cb7449a2c914..edde5ca34f8c 100644
--- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java
+++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.actionSystem;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
@@ -25,7 +26,14 @@ import com.intellij.psi.PsiFile;
public class CommonDataKeys {
public static final DataKey<Project> PROJECT = DataKey.create("project");
public static final DataKey<Editor> EDITOR = DataKey.create("editor");
-
+ /**
+ * This key can be used to obtain reference to host editor instance, in case {@link #EDITOR} key is referring to an injected editor.
+ */
+ public static final DataKey<Editor> HOST_EDITOR = DataKey.create("host.editor");
+ /**
+ * A key to retrieve caret instance (in host or injected editor, depending on context).
+ */
+ public static final DataKey<Caret> CARET = DataKey.create("caret");
/**
* Returns com.intellij.openapi.editor.Editor even if focus currently is in find bar
*/
diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContextWrapper.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContextWrapper.java
new file mode 100644
index 000000000000..091153d67cc5
--- /dev/null
+++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContextWrapper.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.actionSystem;
+
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.UserDataHolder;
+import com.intellij.openapi.util.UserDataHolderBase;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+// We implement UserDataHolder to support DataManager.saveInDataContext/loadFromDataContext methods
+public class DataContextWrapper implements DataContext, UserDataHolder {
+ private final DataContext myDelegate;
+ private final UserDataHolder myDataHolder;
+
+ public DataContextWrapper(@NotNull DataContext delegate) {
+ myDelegate = delegate;
+ myDataHolder = delegate instanceof UserDataHolder ? (UserDataHolder) delegate : new UserDataHolderBase();
+ }
+
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ return myDelegate.getData(dataId);
+ }
+
+ @Nullable
+ @Override
+ public <T> T getUserData(@NotNull Key<T> key) {
+ return myDataHolder.getUserData(key);
+ }
+
+ @Override
+ public <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
+ myDataHolder.putUserData(key, value);
+ }
+}
diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/RightAlignedToolbarAction.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/RightAlignedToolbarAction.java
new file mode 100644
index 000000000000..d977bfa1e1f9
--- /dev/null
+++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/RightAlignedToolbarAction.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.actionSystem;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public interface RightAlignedToolbarAction {
+}
diff --git a/platform/editor-ui-api/src/com/intellij/ui/switcher/QuickActionProvider.java b/platform/editor-ui-api/src/com/intellij/ui/switcher/QuickActionProvider.java
index 7de29e05f281..a41abe4bc1ca 100644
--- a/platform/editor-ui-api/src/com/intellij/ui/switcher/QuickActionProvider.java
+++ b/platform/editor-ui-api/src/com/intellij/ui/switcher/QuickActionProvider.java
@@ -18,7 +18,6 @@ package com.intellij.ui.switcher;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DataKey;
-import javax.swing.*;
import java.util.List;
public interface QuickActionProvider extends QuickAccessProvider {
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskDebugRunner.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskDebugRunner.java
index 71b74f6e2272..86d1b6138f0d 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskDebugRunner.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskDebugRunner.java
@@ -17,7 +17,6 @@ package com.intellij.openapi.externalSystem.service.execution;
import com.intellij.debugger.impl.GenericDebuggerRunner;
import com.intellij.execution.ExecutionException;
-import com.intellij.execution.Executor;
import com.intellij.execution.configurations.RemoteConnection;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.configurations.RunProfileState;
@@ -26,7 +25,6 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
-import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -35,8 +33,7 @@ import org.jetbrains.annotations.Nullable;
* @since 6/7/13 11:18 AM
*/
public class ExternalSystemTaskDebugRunner extends GenericDebuggerRunner {
-
- private static final Logger LOG = Logger.getInstance("#" + ExternalSystemTaskDebugRunner.class.getName());
+ private static final Logger LOG = Logger.getInstance(ExternalSystemTaskDebugRunner.class);
@NotNull
@Override
@@ -51,16 +48,12 @@ public class ExternalSystemTaskDebugRunner extends GenericDebuggerRunner {
@Nullable
@Override
- protected RunContentDescriptor createContentDescriptor(Project project,
- RunProfileState state,
- RunContentDescriptor contentToReuse,
- ExecutionEnvironment env) throws ExecutionException
- {
+ protected RunContentDescriptor createContentDescriptor(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
if (state instanceof ExternalSystemRunConfiguration.MyRunnableState) {
int port = ((ExternalSystemRunConfiguration.MyRunnableState)state).getDebugPort();
if (port > 0) {
RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", String.valueOf(port), true);
- return attachVirtualMachine(project, state, contentToReuse, env, connection, true);
+ return attachVirtualMachine(state, environment, connection, true);
}
else {
LOG.warn("Can't attach debugger to external system task execution. Reason: target debug port is unknown");
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskRunner.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskRunner.java
index 90ca62f1bd54..d45be42bbbd9 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskRunner.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemTaskRunner.java
@@ -51,12 +51,8 @@ public class ExternalSystemTaskRunner extends GenericProgramRunner {
protected RunContentDescriptor doExecute(@NotNull Project project,
@NotNull RunProfileState state,
RunContentDescriptor contentToReuse,
- @NotNull ExecutionEnvironment env) throws ExecutionException
- {
+ @NotNull ExecutionEnvironment env) throws ExecutionException {
ExecutionResult executionResult = state.execute(env.getExecutor(), this);
- if (executionResult == null) return null;
-
- final RunContentBuilder contentBuilder = new RunContentBuilder(this, executionResult, env);
- return contentBuilder.showRunContent(contentToReuse);
+ return executionResult == null ? null : new RunContentBuilder(executionResult, env).showRunContent(contentToReuse);
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java
index 59b1e5f0dc74..5a933ab18e42 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/settings/AbstractExternalSystemConfigurable.java
@@ -166,7 +166,6 @@ public abstract class AbstractExternalSystemConfigurable<
if (!myProjectsModel.isEmpty()) {
- addTitle(ExternalSystemBundle.message("settings.title.system.settings", myExternalSystemId.getReadableName()));
myProjectsList.setSelectedIndex(0);
}
}
@@ -196,6 +195,7 @@ public abstract class AbstractExternalSystemConfigurable<
private void prepareSystemSettings(@NotNull SystemSettings s) {
mySystemSettingsControl = createSystemSettingsControl(s);
if (mySystemSettingsControl != null) {
+ addTitle(ExternalSystemBundle.message("settings.title.system.settings", myExternalSystemId.getReadableName()));
mySystemSettingsControl.fillUi(myComponent, 1);
}
}
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/AbstractExternalSystemToolWindowFactory.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/AbstractExternalSystemToolWindowFactory.java
index 8c3ef0099e0d..1e08045faeea 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/AbstractExternalSystemToolWindowFactory.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/task/ui/AbstractExternalSystemToolWindowFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -45,7 +45,7 @@ public abstract class AbstractExternalSystemToolWindowFactory implements ToolWin
}
@Override
- public void createToolWindowContent(final Project project, final ToolWindow toolWindow) {
+ public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
toolWindow.setTitle(myExternalSystemId.getReadableName());
ContentManager contentManager = toolWindow.getContentManager();
String tasksTitle = ExternalSystemBundle.message("tool.window.title.tasks");
diff --git a/platform/icons/src/actions/GroupByClass.png b/platform/icons/src/actions/GroupByClass.png
new file mode 100644
index 000000000000..dddca942c295
--- /dev/null
+++ b/platform/icons/src/actions/GroupByClass.png
Binary files differ
diff --git a/platform/icons/src/actions/GroupByClass@2x.png b/platform/icons/src/actions/GroupByClass@2x.png
new file mode 100644
index 000000000000..25f262ea99ff
--- /dev/null
+++ b/platform/icons/src/actions/GroupByClass@2x.png
Binary files differ
diff --git a/platform/icons/src/actions/GroupByClass@2x_dark.png b/platform/icons/src/actions/GroupByClass@2x_dark.png
new file mode 100644
index 000000000000..8b8c42ceb33b
--- /dev/null
+++ b/platform/icons/src/actions/GroupByClass@2x_dark.png
Binary files differ
diff --git a/platform/icons/src/actions/GroupByClass_dark.png b/platform/icons/src/actions/GroupByClass_dark.png
new file mode 100644
index 000000000000..4ff7bde4a984
--- /dev/null
+++ b/platform/icons/src/actions/GroupByClass_dark.png
Binary files differ
diff --git a/platform/icons/src/gutter/extAnnotation.png b/platform/icons/src/gutter/extAnnotation.png
index 68fcd67c54ca..83bfdd350f5c 100644
--- a/platform/icons/src/gutter/extAnnotation.png
+++ b/platform/icons/src/gutter/extAnnotation.png
Binary files differ
diff --git a/platform/icons/src/gutter/extAnnotation@2x.png b/platform/icons/src/gutter/extAnnotation@2x.png
index 91b7e88e5864..a09a1571711f 100644
--- a/platform/icons/src/gutter/extAnnotation@2x.png
+++ b/platform/icons/src/gutter/extAnnotation@2x.png
Binary files differ
diff --git a/platform/icons/src/gutter/extAnnotation@2x_dark.png b/platform/icons/src/gutter/extAnnotation@2x_dark.png
index d84a71dbeba1..2793ff7fa8cc 100644
--- a/platform/icons/src/gutter/extAnnotation@2x_dark.png
+++ b/platform/icons/src/gutter/extAnnotation@2x_dark.png
Binary files differ
diff --git a/platform/icons/src/gutter/extAnnotation_dark.png b/platform/icons/src/gutter/extAnnotation_dark.png
index a0cc10b27be8..7303f547addc 100644
--- a/platform/icons/src/gutter/extAnnotation_dark.png
+++ b/platform/icons/src/gutter/extAnnotation_dark.png
Binary files differ
diff --git a/platform/indexing-api/src/com/intellij/psi/RefResolveService.java b/platform/indexing-api/src/com/intellij/psi/RefResolveService.java
new file mode 100644
index 000000000000..f53316506e78
--- /dev/null
+++ b/platform/indexing-api/src/com/intellij/psi/RefResolveService.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2014 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.psi;
+
+import com.intellij.openapi.components.AbstractProjectComponent;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileWithId;
+import com.intellij.psi.search.GlobalSearchScope;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+public abstract class RefResolveService extends AbstractProjectComponent {
+ public RefResolveService(Project project) {
+ super(project);
+ }
+
+ public static RefResolveService getInstance(Project project) {
+ return project.getComponent(RefResolveService.class);
+ }
+
+ @Nullable("null means the service has not resolved all files and is not ready yet")
+ public abstract int[] getBackwardIds(@NotNull VirtualFileWithId file);
+
+ /**
+ * @return subset of scope containing only files which reference the virtualFile
+ */
+ @NotNull
+ public abstract GlobalSearchScope restrictByBackwardIds(@NotNull VirtualFile virtualFile, @NotNull GlobalSearchScope scope);
+
+ /**
+ * @return add files to the resolve queue. until all files from there are resolved, the service is in incomplete state and returns null from getBackwardIds()
+ */
+ public abstract boolean queue(@NotNull Collection<VirtualFile> files, Object reason);
+}
diff --git a/platform/indexing-api/src/com/intellij/psi/search/PsiSearchHelper.java b/platform/indexing-api/src/com/intellij/psi/search/PsiSearchHelper.java
index cc283d0bb2b7..bef3d0350563 100644
--- a/platform/indexing-api/src/com/intellij/psi/search/PsiSearchHelper.java
+++ b/platform/indexing-api/src/com/intellij/psi/search/PsiSearchHelper.java
@@ -86,7 +86,7 @@ public interface PsiSearchHelper {
@NotNull GlobalSearchScope searchScope);
/**
- * Passes all occurrences of the specified full-qualified class name in plain text context in the
+ * Passes all occurrences of the specified fully qualified class name in plain text context in the
* use scope of the specified element to the specified processor.
*
* @param originalElement the element whose use scope is used to restrict the search scope,
@@ -126,7 +126,7 @@ public interface PsiSearchHelper {
final boolean caseSensitively);
/**
- * Passes all files containing the specified word in {@link UsageSearchContext#IN_PLAIN_TEXT code}
+ * Passes all files containing the specified word in {@link UsageSearchContext#IN_PLAIN_TEXT plain text}
* context to the specified processor.
*
* @param word the word to search.
@@ -189,7 +189,7 @@ public interface PsiSearchHelper {
@NotNull
SearchCostResult isCheapEnoughToSearch(@NotNull String name,
@NotNull GlobalSearchScope scope,
- @Nullable PsiFile fileToIgnoreOccurencesIn,
+ @Nullable PsiFile fileToIgnoreOccurrencesIn,
@Nullable ProgressIndicator progress);
enum SearchCostResult {
diff --git a/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java b/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java
index 11074f83781f..d9bbf9ee58a9 100644
--- a/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java
+++ b/platform/indexing-api/src/com/intellij/psi/stubs/StubIndex.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -162,5 +162,5 @@ public abstract class StubIndex {
protected <Psi extends PsiElement> void reportStubPsiMismatch(Psi psi, VirtualFile file, Class<Psi> requiredClass) {
LOG.error("Invalid stub element type in index: " + file + ". found: " + psi + ". expected: " + requiredClass);
}
-
+ public abstract void forceRebuild(@NotNull Throwable e);
}
diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/PersistentIntList.java b/platform/indexing-impl/src/com/intellij/psi/impl/PersistentIntList.java
new file mode 100644
index 000000000000..aa5998364db4
--- /dev/null
+++ b/platform/indexing-impl/src/com/intellij/psi/impl/PersistentIntList.java
@@ -0,0 +1,386 @@
+/*
+ * Copyright 2000-2014 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.psi.impl;
+
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.io.Bits;
+import com.intellij.util.io.IntToIntBtree;
+import com.intellij.util.io.PagedFileStorage;
+import com.intellij.util.io.RandomAccessDataFile;
+import gnu.trove.TIntHashSet;
+import gnu.trove.TIntIntHashMap;
+import gnu.trove.TIntIntProcedure;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+/**
+ * the (int -> int[]) map which is persisted to the specified file.
+ */
+public class PersistentIntList implements Disposable {
+ public static final int MAX_DATA_BYTES = 500000000;
+ public static final int MAX_LIST_LENGTH = 100000;
+ private final IntToIntBtree index;
+ private RandomAccessDataFile data;
+ public int gap; // bytes lost due to fragmentation
+ private final int dataStart; // offset of real data; the bytes before are reserved for 'index' meta information, see persistsVarsTo()
+
+ public PersistentIntList(@NotNull File indexFile, @NotNull File dataFile, boolean initial) throws IOException {
+ if (initial) {
+ FileUtil.writeToFile(dataFile, ArrayUtil.EMPTY_BYTE_ARRAY);
+ }
+ PagedFileStorage.StorageLockContext context = new PagedFileStorage.StorageLockContext(true);
+ context.lock();
+ try {
+ data = new RandomAccessDataFile(dataFile);
+ index = new IntToIntBtree(4096, indexFile, context, initial);
+ dataStart = persistsVarsTo(data, initial);
+ }
+ finally {
+ context.unlock();
+ }
+ }
+
+ private int persistsVarsTo(@NotNull final RandomAccessDataFile data, boolean toDisk) {
+ return index.persistVars(new IntToIntBtree.BtreeDataStorage() {
+ @Override
+ public int persistInt(int offset, int value, boolean toDisk) {
+ if (toDisk) {
+ data.putInt(offset, value);
+ return value;
+ }
+ else {
+ return data.getInt(offset);
+ }
+ }
+ }, toDisk);
+ }
+
+ @Override
+ public void dispose() {
+ index.withStorageLock(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ persistsVarsTo(data, true);
+ index.doClose();
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ data.dispose();
+ }
+ });
+ }
+
+ @NotNull
+ public int[] get(final int id) {
+ final Ref<int[]> res = new Ref<int[]>();
+
+ index.withStorageLock(new Runnable() {
+ @Override
+ public void run() {
+ final int[] ptrPtr = new int[1];
+ boolean exists = index.get(id, ptrPtr);
+ if (!exists) {
+ ptrPtr[0] = 0;
+ }
+ int pointer = ptrPtr[0];
+ if (pointer == 0) {
+ res.set(ArrayUtil.EMPTY_INT_ARRAY);
+ }
+ else {
+ assertPointer(pointer);
+ int listLength = data.getInt(pointer);
+ int capacity = data.getInt(pointer + 4);
+ assertListLength(listLength, capacity);
+ int[] result = new int[listLength];
+ byte[] bytes = new byte[listLength * 4];
+ data.get(pointer + 8, bytes, 0, bytes.length);
+ for (int i = 0; i < listLength; i++) {
+ result[i] = Bits.getInt(bytes, i*4);
+ }
+ res.set(result);
+ }
+ }
+ });
+ return res.get();
+ }
+
+ // return true if was added
+ public boolean add(final int id, final int value) {
+ assert value > 0;
+ assert id > 0;
+ final boolean[] added = new boolean[1];
+ index.withStorageLock(new Runnable() {
+ @Override
+ public void run() {
+ int[] ptrPtr = new int[1];
+ index.get(id, ptrPtr);
+ final int pointer = ptrPtr[0];
+ int[] stored;
+ int capacity;
+ final int listLength;
+ if (pointer == 0) {
+ stored = ArrayUtil.EMPTY_INT_ARRAY;
+ listLength = 0;
+ capacity = 2;
+ }
+ else {
+ assertPointer(pointer);
+ listLength = data.getInt(pointer);
+ capacity = data.getInt(pointer+4);
+ assertListLength(listLength,capacity);
+ stored = new int[listLength];
+ for (int i = 0; i < listLength; i++) {
+ int v = data.getInt(pointer + (i + 2) * 4);
+ stored[i] = v;
+ if (v == value) return;
+ }
+ // append
+ if (capacity > listLength /*|| data.length() == pointer + 4 + 4 + 4*capacity*/) {
+ data.putInt(pointer + (listLength + 2) * 4, value);
+ data.putInt(pointer, listLength + 1);
+ if (capacity <= listLength) {
+ data.putInt(pointer+4, capacity + 1);
+ }
+ added[0] = true;
+ return;
+ }
+ // reallocate
+ gap += 4 + 4 + 4 * capacity;
+ }
+
+ int storePointer = (int)data.length();
+ data.putInt(storePointer, stored.length + 1);
+ int newCapacity = capacity < 10 ? capacity * 2 : (int)(capacity * 1.5);
+ assert newCapacity > stored.length + 1;
+ data.putInt(storePointer+4, newCapacity);
+ for (int i = 0; i < stored.length; i++) {
+ int v = stored[i];
+ data.putInt(storePointer + (i+2)*4, v);
+ }
+ data.putInt(storePointer + (stored.length+2)*4, value);
+ for (int i = stored.length + 1; i < newCapacity; i++) {
+ data.putInt(storePointer + (i+2)*4, 0); // gap
+ }
+ index.put(id, storePointer);
+ if (storePointer > 10000000) {
+ int i = 0;
+ }
+ added[0] = true;
+ }
+ });
+
+ return added[0];
+ }
+
+ private static void assertListLength(int listLength, int capacity) {
+ assert 0 < listLength && listLength <= MAX_LIST_LENGTH : listLength;
+ assert 0 < capacity && capacity <= MAX_LIST_LENGTH : capacity;
+ assert capacity >= listLength : listLength + ", " + capacity;
+ assert capacity <= (listLength+1)*2 : listLength + ", " + capacity;
+ }
+
+ public void addAll(final int id, @NotNull final int[] values) {
+ assertListLength(values.length, values.length);
+ assert id > 0;
+ Arrays.sort(values);
+
+ index.withStorageLock(new Runnable() {
+ @Override
+ public void run() {
+ int[] ptrPtr = new int[1];
+ index.get(id, ptrPtr);
+ final int pointer = ptrPtr[0];
+ int capacity;
+ final int newListLength;
+ byte[] mergedBytes;
+
+ if (pointer == 0) {
+ mergedBytes = toBytes(values);
+ newListLength = values.length;
+ capacity = 0;
+ }
+ else {
+ int[] oldIds = get(id);
+ checkSorted(oldIds);
+
+ assertPointer(pointer);
+ int storedListLength = data.getInt(pointer);
+ capacity = data.getInt(pointer + 4);
+ assertListLength(storedListLength, capacity);
+ // try to merge inplace and if failed, reallocate at the end
+ byte[] storedBytes = new byte[storedListLength * 4];
+ data.get(pointer + 8, storedBytes, 0, storedListLength * 4);
+
+ mergedBytes = new byte[storedBytes.length + values.length * 4];
+ int outPtr = 0;
+ int i = 0;
+ int j = 0;
+ while (i < storedListLength || j < values.length) {
+ int stored = i < storedListLength ? Bits.getInt(storedBytes, i * 4) : Integer.MAX_VALUE;
+ int value = j < values.length ? values[j] : Integer.MAX_VALUE;
+ if (stored < value) {
+ Bits.putInt(mergedBytes, outPtr, stored);
+ outPtr += 4;
+ i++;
+ }
+ else if (stored > value) {
+ Bits.putInt(mergedBytes, outPtr, value);
+ outPtr += 4;
+ j++;
+ }
+ else {
+ Bits.putInt(mergedBytes, outPtr, value);
+ outPtr += 4;
+ j++;
+ i++;
+ }
+ }
+ int[] mergedInts = fromBytes(mergedBytes, outPtr);
+ checkSorted(mergedInts);
+
+ newListLength = outPtr / 4;
+ assertListLength(newListLength, newListLength);
+ if (newListLength <= capacity) {
+ storeArray(data, pointer, newListLength, capacity, mergedBytes);
+ return;
+ }
+ gap += capacity * 4 + 8;
+ }
+ // reallocate at the end
+
+ int storePointer = (int)data.length();
+ assertPointer(storePointer);
+ int oldCapacity = Math.max(capacity, newListLength);
+ int newCapacity = oldCapacity < 10 ? (oldCapacity + 1) * 2 : (int)(oldCapacity * 1.5);
+ assert newCapacity > newListLength + 1;
+ storeArray(data, storePointer, newListLength, newCapacity, mergedBytes);
+ index.put(id, storePointer);
+ }
+ });
+
+ int[] ids = get(id);
+ checkSorted(ids);
+ TIntHashSet set = new TIntHashSet(ids);
+ assert set.containsAll(values): "ids: "+Arrays.toString(ids)+";\n values:"+Arrays.toString(values);
+ }
+
+ private static void checkSorted(int[] oldIds) {
+ for (int i = 1; i < oldIds.length; i++) {
+ assert oldIds[i - 1] < oldIds[i] : oldIds[i-1] + ", " + oldIds[i];
+ }
+ }
+
+ private static byte[] toBytes(@NotNull int[] values) {
+ byte[] mergedBytes = new byte[4 * values.length];
+ for (int i = 0; i < values.length; i++) {
+ int value = values[i];
+ Bits.putInt(mergedBytes, i * 4, value);
+ }
+ return mergedBytes;
+ }
+
+ private static int[] fromBytes(@NotNull byte[] bytes, int length) {
+ assert length % 4 == 0;
+ int[] ints = new int[length/4];
+ for (int i = 0; i < length; i+=4) {
+ int value = Bits.getInt(bytes, i);
+ ints[i/4] = value;
+ }
+ return ints;
+ }
+
+ private static void storeArray(@NotNull RandomAccessDataFile data,
+ int storePointer,
+ int newListLength,
+ int newCapacity,
+ @NotNull byte[] mergedBytes) {
+ assertListLength(newListLength, newCapacity);
+ data.putInt(storePointer, newListLength);
+ data.putInt(storePointer + 4, newCapacity);
+ data.put(storePointer + 8, mergedBytes, 0, newListLength * 4);
+ byte[] fill = new byte[(newCapacity - newListLength) * 4];
+ Arrays.fill(fill, (byte)-1);
+ data.put(storePointer + 8 + newListLength * 4, fill, 0, fill.length);
+ }
+
+ private static void assertPointer(int pointer) {
+ assert 0 < pointer && pointer <= MAX_DATA_BYTES : pointer;
+ }
+
+ public void flush() {
+ index.withStorageLock(new Runnable() {
+ @Override
+ public void run() {
+ persistsVarsTo(data, true);
+ index.doFlush();
+ data.sync();
+ //data.force();
+ }
+ });
+ }
+
+ private void compactIfNecessary() {
+ if (gap < data.length() / 2) return;
+ index.withStorageLock(new Runnable() {
+ @Override
+ public void run() {
+ persistsVarsTo(data, true);
+ index.doFlush();
+ data.sync();
+
+ try {
+ final RandomAccessDataFile newData = new RandomAccessDataFile(new File(data.getFile().getParentFile(), "newData"));
+ persistsVarsTo(newData, true);
+ final TIntIntHashMap map = new TIntIntHashMap();
+ index.processMappings(new IntToIntBtree.KeyValueProcessor() {
+ @Override
+ public boolean process(int key, int value) throws IOException {
+ map.put(key, value);
+ return true;
+ }
+ });
+ map.forEachEntry(new TIntIntProcedure() {
+ @Override
+ public boolean execute(int key, int value) {
+ int[] ids = get(key);
+ int pointer = (int)newData.length();
+ byte[] bytes = toBytes(ids);
+ storeArray(newData, pointer, ids.length, (int)(ids.length * 1.3), bytes);
+ index.put(key, pointer);
+ return true;
+ }
+ });
+
+ data.dispose();
+ data = newData;
+ gap = 0;
+ flush();
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ }
+}
diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/file/impl/ResolveScopeManagerImpl.java b/platform/indexing-impl/src/com/intellij/psi/impl/file/impl/ResolveScopeManagerImpl.java
index b89042b68257..15112d3a100e 100644
--- a/platform/indexing-impl/src/com/intellij/psi/impl/file/impl/ResolveScopeManagerImpl.java
+++ b/platform/indexing-impl/src/com/intellij/psi/impl/file/impl/ResolveScopeManagerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.impl.LibraryScopeCache;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileWithId;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.psi.impl.ResolveScopeManager;
@@ -37,14 +38,17 @@ import java.util.List;
import java.util.Map;
public class ResolveScopeManagerImpl extends ResolveScopeManager {
-
+ /**
+ * if true then getUseScope() returns scope restricted to only relevant files which are stored in {@link RefResolveService}
+ */
+ public static final boolean ENABLED_REF_BACK = /*ApplicationManager.getApplication().isUnitTestMode() ||*/ Boolean.getBoolean("ref.back");
private final Project myProject;
private final ProjectRootManager myProjectRootManager;
private final PsiManager myManager;
private final Map<VirtualFile, GlobalSearchScope> myDefaultResolveScopesCache = new ConcurrentFactoryMap<VirtualFile, GlobalSearchScope>() {
@Override
- protected GlobalSearchScope create(VirtualFile key) {
+ protected GlobalSearchScope create(@NotNull VirtualFile key) {
GlobalSearchScope scope = null;
for(ResolveScopeProvider resolveScopeProvider: ResolveScopeProvider.EP_NAME.getExtensions()) {
scope = resolveScopeProvider.getResolveScope(key, myProject);
@@ -180,34 +184,37 @@ public class ResolveScopeManagerImpl extends ResolveScopeManager {
@Override
@NotNull
public GlobalSearchScope getUseScope(@NotNull PsiElement element) {
- VirtualFile vFile;
+ VirtualFile vDirectory;
+ final VirtualFile virtualFile;
+ final PsiFile containingFile;
final GlobalSearchScope allScope = GlobalSearchScope.allScope(myManager.getProject());
if (element instanceof PsiDirectory) {
- vFile = ((PsiDirectory)element).getVirtualFile();
+ vDirectory = ((PsiDirectory)element).getVirtualFile();
+ virtualFile = null;
+ containingFile = null;
}
else {
- final PsiFile containingFile = element.getContainingFile();
+ containingFile = element.getContainingFile();
if (containingFile == null) return allScope;
- final VirtualFile virtualFile = containingFile.getVirtualFile();
+ virtualFile = containingFile.getVirtualFile();
if (virtualFile == null) return allScope;
- vFile = virtualFile.getParent();
+ vDirectory = virtualFile.getParent();
}
- if (vFile == null) return allScope;
- ProjectFileIndex projectFileIndex = myProjectRootManager.getFileIndex();
- Module module = projectFileIndex.getModuleForFile(vFile);
- if (module != null) {
- boolean isTest = projectFileIndex.isInTestSourceContent(vFile);
- return isTest
- ? GlobalSearchScope.moduleTestsWithDependentsScope(module)
- : GlobalSearchScope.moduleWithDependentsScope(module);
+ if (vDirectory == null) return allScope;
+ final ProjectFileIndex projectFileIndex = myProjectRootManager.getFileIndex();
+ final Module module = projectFileIndex.getModuleForFile(vDirectory);
+ if (module == null) {
+ return containingFile == null || virtualFile.isDirectory() || allScope.contains(virtualFile)
+ ? allScope : GlobalSearchScope.fileScope(containingFile).uniteWith(allScope);
}
- else {
- final PsiFile f = element.getContainingFile();
- final VirtualFile vf = f == null ? null : f.getVirtualFile();
-
- return f == null || vf == null || vf.isDirectory() || allScope.contains(vf)
- ? allScope : GlobalSearchScope.fileScope(f).uniteWith(allScope);
+ boolean isTest = projectFileIndex.isInTestSourceContent(vDirectory);
+ GlobalSearchScope scope = isTest
+ ? GlobalSearchScope.moduleTestsWithDependentsScope(module)
+ : GlobalSearchScope.moduleWithDependentsScope(module);
+ if (virtualFile instanceof VirtualFileWithId && ENABLED_REF_BACK) {
+ return RefResolveService.getInstance(myProject).restrictByBackwardIds(virtualFile, scope);
}
+ return scope;
}
}
diff --git a/platform/lang-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java b/platform/lang-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java
deleted file mode 100644
index 99e7c2887d01..000000000000
--- a/platform/lang-api/src/com/intellij/codeInsight/controlflow/ControlFlow.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.intellij.codeInsight.controlflow;
-
-/**
- * @author oleg
- */
-public interface ControlFlow {
- Instruction[] getInstructions();
-}
diff --git a/platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java b/platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java
index f3331f899ff1..6799cfd7e6da 100644
--- a/platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java
+++ b/platform/lang-api/src/com/intellij/execution/BeforeRunTaskProvider.java
@@ -80,7 +80,7 @@ public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
@Nullable
public static <T extends BeforeRunTask> BeforeRunTaskProvider<T> getProvider(Project project, Key<T> key) {
- BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, project);
+ BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(EXTENSION_POINT_NAME, project);
for (BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
if (provider.getId() == key)
return (BeforeRunTaskProvider<T>)provider;
diff --git a/platform/lang-api/src/com/intellij/execution/ExecutionManager.java b/platform/lang-api/src/com/intellij/execution/ExecutionManager.java
index 5e9029ebf93f..183d6ada5ad2 100644
--- a/platform/lang-api/src/com/intellij/execution/ExecutionManager.java
+++ b/platform/lang-api/src/com/intellij/execution/ExecutionManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -21,6 +21,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunContentManager;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
@@ -30,11 +31,11 @@ import org.jetbrains.annotations.Nullable;
* Manages the execution of run configurations and the relationship between running processes and Run/Debug toolwindow tabs.
*/
public abstract class ExecutionManager {
- public static final Topic<ExecutionListener> EXECUTION_TOPIC
- = new Topic<ExecutionListener>("configuration executed", ExecutionListener.class, Topic.BroadcastDirection.TO_PARENT);
+ public static final Topic<ExecutionListener> EXECUTION_TOPIC =
+ Topic.create("configuration executed", ExecutionListener.class, Topic.BroadcastDirection.TO_PARENT);
- public static ExecutionManager getInstance(final Project project) {
- return project.getComponent(ExecutionManager.class);
+ public static ExecutionManager getInstance(@NotNull Project project) {
+ return ServiceManager.getService(project, ExecutionManager.class);
}
/**
@@ -49,12 +50,12 @@ public abstract class ExecutionManager {
* Executes the before launch tasks for a run configuration.
*
* @param startRunnable the runnable to actually start the process for the run configuration.
- * @param env the execution environment describing the process to be started.
+ * @param environment the execution environment describing the process to be started.
* @param state the ready-to-start process
* @param onCancelRunnable the callback to call if one of the before launch tasks cancels the process execution.
*/
public abstract void compileAndRun(@NotNull Runnable startRunnable,
- @NotNull ExecutionEnvironment env,
+ @NotNull ExecutionEnvironment environment,
@Nullable RunProfileState state,
@Nullable Runnable onCancelRunnable);
@@ -63,27 +64,19 @@ public abstract class ExecutionManager {
*
* @return the list of processes.
*/
+ @NotNull
public abstract ProcessHandler[] getRunningProcesses();
/**
- * @deprecated use {@link #startRunProfile(RunProfileStarter, com.intellij.execution.configurations.RunProfileState, com.intellij.execution.runners.ExecutionEnvironment)}
- */
- public abstract void startRunProfile(@NotNull RunProfileStarter starter,
- @NotNull RunProfileState state,
- @NotNull Project project,
- @NotNull Executor executor,
- @NotNull ExecutionEnvironment env);
-
- /**
* Prepares the run or debug tab for running the specified process and calls a callback to start it.
*
* @param starter the callback to start the process execution.
* @param state the ready-to-start process
- * @param env the execution environment describing the process to be started.
+ * @param environment the execution environment describing the process to be started.
*/
public abstract void startRunProfile(@NotNull RunProfileStarter starter,
@NotNull RunProfileState state,
- @NotNull ExecutionEnvironment env);
+ @NotNull ExecutionEnvironment environment);
public abstract void restartRunProfile(@NotNull Project project,
@NotNull Executor executor,
@@ -91,9 +84,10 @@ public abstract class ExecutionManager {
@Nullable RunnerAndConfigurationSettings configuration,
@Nullable ProcessHandler processHandler);
- //currentDescriptor is null for toolbar/popup action and not null for actions in run/debug toolwindows
/**
- * @deprecated use {@link #restartRunProfile(com.intellij.execution.runners.ProgramRunner, com.intellij.execution.runners.ExecutionEnvironment, com.intellij.execution.ui.RunContentDescriptor)}
+ * currentDescriptor is null for toolbar/popup action and not null for actions in run/debug toolwindows
+ * @deprecated use {@link #restartRunProfile(com.intellij.execution.runners.ExecutionEnvironment)}
+ * to remove in IDEA 15
*/
public abstract void restartRunProfile(@NotNull Project project,
@NotNull Executor executor,
@@ -101,7 +95,14 @@ public abstract class ExecutionManager {
@Nullable RunnerAndConfigurationSettings configuration,
@Nullable RunContentDescriptor currentDescriptor);
+ /**
+ * currentDescriptor is null for toolbar/popup action and not null for actions in run/debug toolwindows
+ * @deprecated use {@link #restartRunProfile(com.intellij.execution.runners.ExecutionEnvironment)}
+ * to remove in IDEA 15
+ */
public abstract void restartRunProfile(@Nullable ProgramRunner runner,
@NotNull ExecutionEnvironment environment,
@Nullable RunContentDescriptor currentDescriptor);
+
+ public abstract void restartRunProfile(@NotNull ExecutionEnvironment environment);
}
diff --git a/platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java b/platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java
index b48a2e8919fb..612c9c1c80ea 100644
--- a/platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java
+++ b/platform/lang-api/src/com/intellij/execution/ExecutionTargetManager.java
@@ -15,6 +15,8 @@
*/
package com.intellij.execution;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
@@ -26,10 +28,9 @@ import java.util.List;
public abstract class ExecutionTargetManager {
public static final Topic<ExecutionTargetListener> TOPIC = Topic.create("ExecutionTarget topic", ExecutionTargetListener.class);
-
@NotNull
public static ExecutionTargetManager getInstance(@NotNull Project project) {
- return project.getComponent(ExecutionTargetManager.class);
+ return ServiceManager.getService(project, ExecutionTargetManager.class);
}
@NotNull
@@ -57,6 +58,10 @@ public abstract class ExecutionTargetManager {
return settings != null && target != null && settings.canRunOn(target) && target.canRun(settings);
}
+ public static boolean canRun(@NotNull ExecutionEnvironment environment) {
+ return canRun(environment.getRunnerAndConfigurationSettings(), environment.getExecutionTarget());
+ }
+
public static void update(@NotNull Project project) {
getInstance(project).update();
}
diff --git a/platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java b/platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java
index 49139be54e58..31d39087d1f1 100644
--- a/platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java
+++ b/platform/lang-api/src/com/intellij/execution/ExecutorRegistry.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -16,6 +16,7 @@
package com.intellij.execution;
+import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.project.Project;
@@ -25,7 +26,6 @@ import org.jetbrains.annotations.NotNull;
* @author spleaner
*/
public abstract class ExecutorRegistry implements ApplicationComponent {
-
public static ExecutorRegistry getInstance() {
return ApplicationManager.getApplication().getComponent(ExecutorRegistry.class);
}
@@ -35,5 +35,10 @@ public abstract class ExecutorRegistry implements ApplicationComponent {
public abstract Executor getExecutorById(final String executorId);
+ /**
+ * Consider to use {@link #isStarting(com.intellij.execution.runners.ExecutionEnvironment)}
+ */
public abstract boolean isStarting(Project project, String executorId, String runnerId);
+
+ public abstract boolean isStarting(@NotNull ExecutionEnvironment environment);
}
diff --git a/platform/lang-api/src/com/intellij/execution/RunnerRegistry.java b/platform/lang-api/src/com/intellij/execution/RunnerRegistry.java
index 39eb47de921d..fec7223b1721 100644
--- a/platform/lang-api/src/com/intellij/execution/RunnerRegistry.java
+++ b/platform/lang-api/src/com/intellij/execution/RunnerRegistry.java
@@ -30,7 +30,7 @@ public abstract class RunnerRegistry implements ApplicationComponent {
public abstract boolean hasRunner(@NotNull final String executorId, @NotNull final RunProfile settings);
@Nullable
- public abstract ProgramRunner getRunner(@NotNull final String executorId, final RunProfile settings);
+ public abstract ProgramRunner getRunner(@NotNull String executorId, @Nullable RunProfile settings);
public abstract ProgramRunner[] getRegisteredRunners();
diff --git a/platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java b/platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java
index d159fa03ac3a..6f23831c9e3a 100644
--- a/platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java
+++ b/platform/lang-api/src/com/intellij/execution/configurations/LogFileOptions.java
@@ -123,11 +123,8 @@ public class LogFileOptions implements JDOMExternalizable {
final File[] dirs = root.listFiles();
if (dirs == null) return;
for (File dir : dirs) {
- if (dir.isFile()) {
- final String path = FileUtil.toSystemIndependentName(FileUtil.getRelativePath(root, dir));
- if (pattern.matcher(path).matches()) {
- files.add(dir);
- }
+ if (pattern.matcher(dir.getName()).matches() && dir.isFile()) {
+ files.add(dir);
}
}
}
diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
index 6acc467249e3..e85e36669f2c 100644
--- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
+++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironment.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.execution.runners;
import com.intellij.execution.*;
@@ -39,9 +38,7 @@ import java.util.concurrent.atomic.AtomicLong;
import static com.intellij.openapi.actionSystem.LangDataKeys.*;
-
-public class ExecutionEnvironment extends UserDataHolderBase {
-
+public class ExecutionEnvironment extends UserDataHolderBase implements Disposable {
private static final AtomicLong myIdHolder = new AtomicLong(1L);
@NotNull private final Project myProject;
@@ -54,7 +51,7 @@ public class ExecutionEnvironment extends UserDataHolderBase {
@Nullable private ConfigurationPerRunnerSettings myConfigurationSettings;
@Nullable private final RunnerAndConfigurationSettings myRunnerAndConfigurationSettings;
@Nullable private RunContentDescriptor myContentToReuse;
- @Nullable private String myRunnerId;
+ private final ProgramRunner<?> myRunner;
private long myExecutionId = 0;
@Nullable private DataContext myDataContext;
@@ -64,11 +61,12 @@ public class ExecutionEnvironment extends UserDataHolderBase {
myContentToReuse = null;
myRunnerAndConfigurationSettings = null;
myExecutor = null;
+ myRunner = null;
}
public ExecutionEnvironment(@NotNull Executor executor,
- @NotNull final ProgramRunner runner,
- @NotNull final RunnerAndConfigurationSettings configuration,
+ @NotNull ProgramRunner runner,
+ @NotNull RunnerAndConfigurationSettings configuration,
@NotNull Project project) {
this(configuration.getConfiguration(),
executor,
@@ -78,11 +76,12 @@ public class ExecutionEnvironment extends UserDataHolderBase {
configuration.getConfigurationSettings(runner),
null,
null,
- runner.getRunnerId());
+ runner);
}
/**
* @deprecated, use {@link com.intellij.execution.runners.ExecutionEnvironmentBuilder} instead
+ * to remove in IDEA 14
*/
@TestOnly
public ExecutionEnvironment(@NotNull Executor executor,
@@ -97,45 +96,46 @@ public class ExecutionEnvironment extends UserDataHolderBase {
configuration.getRunnerSettings(runner),
configuration.getConfigurationSettings(runner),
null,
- configuration, runner.getRunnerId());
+ configuration,
+ runner);
}
/**
* @deprecated, use {@link com.intellij.execution.runners.ExecutionEnvironmentBuilder} instead
+ * to remove in IDEA 15
*/
public ExecutionEnvironment(@NotNull RunProfile runProfile,
@NotNull Executor executor,
@NotNull Project project,
@Nullable RunnerSettings runnerSettings) {
- this(runProfile, executor, DefaultExecutionTarget.INSTANCE, project, runnerSettings, null, null, null, null);
+ //noinspection ConstantConditions
+ this(runProfile, executor, DefaultExecutionTarget.INSTANCE, project, runnerSettings, null, null, null, RunnerRegistry.getInstance().getRunner(executor.getId(), runProfile));
}
- public ExecutionEnvironment(@NotNull RunProfile runProfile,
- @NotNull Executor executor,
- @NotNull ExecutionTarget target,
- @NotNull Project project,
- @Nullable RunnerSettings runnerSettings,
- @Nullable ConfigurationPerRunnerSettings configurationSettings,
- @Nullable RunContentDescriptor contentToReuse,
- @Nullable RunnerAndConfigurationSettings settings,
- @Nullable String runnerId) {
+ ExecutionEnvironment(@NotNull RunProfile runProfile,
+ @NotNull Executor executor,
+ @NotNull ExecutionTarget target,
+ @NotNull Project project,
+ @Nullable RunnerSettings runnerSettings,
+ @Nullable ConfigurationPerRunnerSettings configurationSettings,
+ @Nullable RunContentDescriptor contentToReuse,
+ @Nullable RunnerAndConfigurationSettings settings,
+ @NotNull ProgramRunner<?> runner) {
myExecutor = executor;
myTarget = target;
myRunProfile = runProfile;
myRunnerSettings = runnerSettings;
myConfigurationSettings = configurationSettings;
myProject = project;
- myContentToReuse = contentToReuse;
+ setContentToReuse(contentToReuse);
myRunnerAndConfigurationSettings = settings;
- myRunnerId = runnerId;
- if (myContentToReuse != null) {
- Disposer.register(myContentToReuse, new Disposable() {
- @Override
- public void dispose() {
- myContentToReuse = null;
- }
- });
- }
+
+ myRunner = runner;
+ }
+
+ @Override
+ public void dispose() {
+ myContentToReuse = null;
}
@NotNull
@@ -163,9 +163,27 @@ public class ExecutionEnvironment extends UserDataHolderBase {
return myContentToReuse;
}
+ public void setContentToReuse(@Nullable RunContentDescriptor contentToReuse) {
+ myContentToReuse = contentToReuse;
+
+ if (contentToReuse != null) {
+ Disposer.register(contentToReuse, this);
+ }
+ }
+
@Nullable
+ @Deprecated
+ /**
+ * Use {@link #getRunner()} instead
+ * to remove in IDEA 15
+ */
public String getRunnerId() {
- return myRunnerId;
+ return myRunner.getRunnerId();
+ }
+
+ @NotNull
+ public ProgramRunner<?> getRunner() {
+ return myRunner;
}
@Nullable
diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java
index cb5891a0040e..6bdb1942171e 100644
--- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java
+++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionEnvironmentBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,16 +15,13 @@
*/
package com.intellij.execution.runners;
-import com.intellij.execution.DefaultExecutionTarget;
-import com.intellij.execution.ExecutionTarget;
-import com.intellij.execution.Executor;
-import com.intellij.execution.RunnerAndConfigurationSettings;
+import com.intellij.execution.*;
import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
+import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.configurations.RunnerSettings;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,7 +30,6 @@ import org.jetbrains.annotations.Nullable;
* User: Vassiliy.Kudryashov
*/
public final class ExecutionEnvironmentBuilder {
- private static final Logger LOG = Logger.getInstance("#com.intellij.execution.runners.ExecutionEnvironmentBuilder");
@NotNull private RunProfile myRunProfile;
@NotNull private ExecutionTarget myTarget = DefaultExecutionTarget.INSTANCE;
@@ -44,6 +40,7 @@ public final class ExecutionEnvironmentBuilder {
@Nullable private RunContentDescriptor myContentToReuse;
@Nullable private RunnerAndConfigurationSettings myRunnerAndConfigurationSettings;
@Nullable private String myRunnerId;
+ private ProgramRunner<?> myRunner;
private boolean myAssignNewId;
@NotNull private Executor myExecutor;
@Nullable private DataContext myDataContext;
@@ -53,83 +50,224 @@ public final class ExecutionEnvironmentBuilder {
myExecutor = executor;
}
+ @NotNull
+ public static ExecutionEnvironmentBuilder create(@NotNull Project project, @NotNull Executor executor, @NotNull RunProfile runProfile) throws ExecutionException {
+ ExecutionEnvironmentBuilder builder = createOrNull(project, executor, runProfile);
+ if (builder == null) {
+ throw new ExecutionException("Cannot find runner for " + runProfile.getName());
+ }
+ return builder;
+ }
+
+ @Nullable
+ public static ExecutionEnvironmentBuilder createOrNull(@NotNull Project project, @NotNull Executor executor, @NotNull RunProfile runProfile) {
+ ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), runProfile);
+ if (runner == null) {
+ return null;
+ }
+ return new ExecutionEnvironmentBuilder(project, executor).runner(runner).runProfile(runProfile);
+ }
+
+ @Nullable
+ public static ExecutionEnvironmentBuilder createOrNull(@NotNull Executor executor, @NotNull RunnerAndConfigurationSettings settings) {
+ ExecutionEnvironmentBuilder builder = createOrNull(settings.getConfiguration().getProject(), executor, settings.getConfiguration());
+ return builder == null ? null : builder.runnerAndSettings(builder.myRunner, settings);
+ }
+
+ @NotNull
+ public static ExecutionEnvironmentBuilder create(@NotNull Executor executor, @NotNull RunnerAndConfigurationSettings settings) throws ExecutionException {
+ ExecutionEnvironmentBuilder builder = create(settings.getConfiguration().getProject(), executor, settings.getConfiguration());
+ return builder.runnerAndSettings(builder.myRunner, settings);
+ }
+
+ @NotNull
+ public static ExecutionEnvironmentBuilder create(@NotNull Executor executor, @NotNull RunConfiguration configuration) {
+ return new ExecutionEnvironmentBuilder(configuration.getProject(), executor).runProfile(configuration);
+ }
+
+ @NotNull
+ Executor getExecutor() {
+ return myExecutor;
+ }
+
/**
* Creates an execution environment builder initialized with a copy of the specified environment.
*
* @param copySource the environment to copy from.
*/
public ExecutionEnvironmentBuilder(@NotNull ExecutionEnvironment copySource) {
- setTarget(copySource.getExecutionTarget());
+ myTarget = copySource.getExecutionTarget();
myProject = copySource.getProject();
myRunnerAndConfigurationSettings = copySource.getRunnerAndConfigurationSettings();
myRunProfile = copySource.getRunProfile();
myRunnerSettings = copySource.getRunnerSettings();
myConfigurationSettings = copySource.getConfigurationSettings();
- myRunnerId = copySource.getRunnerId();
- setContentToReuse(copySource.getContentToReuse());
+ //noinspection deprecation
+ myRunner = copySource.getRunner();
+ myContentToReuse = copySource.getContentToReuse();
myExecutor = copySource.getExecutor();
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setTarget(@NotNull ExecutionTarget target) {
- myTarget = target;
+ return target(target);
+ }
+
+ public ExecutionEnvironmentBuilder target(@Nullable ExecutionTarget target) {
+ if (target != null) {
+ myTarget = target;
+ }
+ return this;
+ }
+
+ public ExecutionEnvironmentBuilder activeTarget() {
+ myTarget = ExecutionTargetManager.getActiveTarget(myProject);
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setRunnerAndSettings(@NotNull ProgramRunner programRunner,
@NotNull RunnerAndConfigurationSettings settings) {
+ return runnerAndSettings(programRunner, settings);
+ }
+
+ public ExecutionEnvironmentBuilder runnerAndSettings(@NotNull ProgramRunner runner,
+ @NotNull RunnerAndConfigurationSettings settings) {
myRunnerAndConfigurationSettings = settings;
- setRunProfile(settings.getConfiguration());
- setRunnerSettings(settings.getRunnerSettings(programRunner));
- setConfigurationSettings(settings.getConfigurationSettings(programRunner));
- setRunnerId(programRunner.getRunnerId());
+ myRunProfile = settings.getConfiguration();
+ myRunnerSettings = settings.getRunnerSettings(runner);
+ myConfigurationSettings = settings.getConfigurationSettings(runner);
+ myRunner = runner;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setRunnerSettings(@Nullable RunnerSettings runnerSettings) {
myRunnerSettings = runnerSettings;
return this;
}
+ public ExecutionEnvironmentBuilder runnerSettings(@Nullable RunnerSettings runnerSettings) {
+ myRunnerSettings = runnerSettings;
+ return this;
+ }
+
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setConfigurationSettings(@Nullable ConfigurationPerRunnerSettings configurationSettings) {
myConfigurationSettings = configurationSettings;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setContentToReuse(@Nullable RunContentDescriptor contentToReuse) {
+ contentToReuse(contentToReuse);
+ return this;
+ }
+
+ public ExecutionEnvironmentBuilder contentToReuse(@Nullable RunContentDescriptor contentToReuse) {
myContentToReuse = contentToReuse;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setRunProfile(@NotNull RunProfile runProfile) {
+ return runProfile(runProfile);
+ }
+
+ public ExecutionEnvironmentBuilder runProfile(@NotNull RunProfile runProfile) {
myRunProfile = runProfile;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setRunnerId(@Nullable String runnerId) {
myRunnerId = runnerId;
return this;
}
+ public ExecutionEnvironmentBuilder runner(@NotNull ProgramRunner<?> runner) {
+ myRunner = runner;
+ return this;
+ }
+
public ExecutionEnvironmentBuilder assignNewId() {
myAssignNewId = true;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setDataContext(@Nullable DataContext dataContext) {
+ return dataContext(dataContext);
+ }
+
+ public ExecutionEnvironmentBuilder dataContext(@Nullable DataContext dataContext) {
myDataContext = dataContext;
return this;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * to remove in IDEA 15
+ */
public ExecutionEnvironmentBuilder setExecutor(@NotNull Executor executor) {
+ return executor(executor);
+ }
+
+ public ExecutionEnvironmentBuilder executor(@NotNull Executor executor) {
myExecutor = executor;
return this;
}
@NotNull
public ExecutionEnvironment build() {
- ExecutionEnvironment environment =
- new ExecutionEnvironment(myRunProfile, myExecutor, myTarget, myProject, myRunnerSettings, myConfigurationSettings, myContentToReuse,
- myRunnerAndConfigurationSettings, myRunnerId);
+ if (myRunner == null) {
+ if (myRunnerId == null) {
+ myRunner = RunnerRegistry.getInstance().getRunner(myExecutor.getId(), myRunProfile);
+ }
+ else {
+ myRunner = RunnerRegistry.getInstance().findRunnerById(myRunnerId);
+ }
+ }
+
+ if (myRunner == null) {
+ throw new IllegalStateException("Runner must be specified");
+ }
+
+ ExecutionEnvironment environment = new ExecutionEnvironment(myRunProfile, myExecutor, myTarget, myProject, myRunnerSettings, myConfigurationSettings, myContentToReuse,
+ myRunnerAndConfigurationSettings, myRunner);
if (myAssignNewId) {
environment.assignNewExecutionId();
}
@@ -138,4 +276,9 @@ public final class ExecutionEnvironmentBuilder {
}
return environment;
}
+
+ public void buildAndExecute() throws ExecutionException {
+ ExecutionEnvironment environment = build();
+ myRunner.execute(environment);
+ }
}
diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java
index f0d67274d61a..0d15a272498c 100644
--- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java
+++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java
@@ -16,24 +16,29 @@
package com.intellij.execution.runners;
-import com.intellij.execution.ExecutionBundle;
-import com.intellij.execution.ExecutionException;
-import com.intellij.execution.RunCanceledByUserException;
+import com.intellij.execution.*;
import com.intellij.execution.configurations.RunProfile;
+import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.process.ProcessNotCreatedException;
+import com.intellij.execution.ui.RunContentDescriptor;
+import com.intellij.ide.DataManager;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.wm.ToolWindowManager;
+import com.intellij.ui.content.Content;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
@@ -52,6 +57,10 @@ public class ExecutionUtil {
handleExecutionError(project, toolWindowId, runProfile.getName(), e);
}
+ public static void handleExecutionError(@NotNull ExecutionEnvironment environment, @NotNull ExecutionException e) {
+ handleExecutionError(environment.getProject(), environment.getExecutor().getToolWindowId(), environment.getRunProfile().getName(), e);
+ }
+
public static void handleExecutionError(@NotNull final Project project,
@NotNull final String toolWindowId,
@NotNull String taskName,
@@ -59,15 +68,15 @@ public class ExecutionUtil {
if (e instanceof RunCanceledByUserException) return;
LOG.debug(e);
-
+
String description = e.getMessage();
HyperlinkListener listener = null;
-
+
if (description == null) {
LOG.warn("Execution error without description", e);
description = "Unknown error";
}
-
+
if ((description.contains("87") || description.contains("111") || description.contains("206")) &&
e instanceof ProcessNotCreatedException &&
!PropertiesComponent.getInstance(project).isTrueValue("dynamic.classpath")) {
@@ -107,4 +116,57 @@ public class ExecutionUtil {
}
});
}
+
+ public static void restartIfActive(@NotNull RunContentDescriptor descriptor) {
+ ProcessHandler processHandler = descriptor.getProcessHandler();
+ if (processHandler != null
+ && processHandler.isStartNotified()
+ && !processHandler.isProcessTerminating()
+ && !processHandler.isProcessTerminated()) {
+ restart(descriptor);
+ }
+ }
+
+ public static void restart(@NotNull RunContentDescriptor descriptor) {
+ restart(descriptor.getComponent());
+ }
+
+ public static void restart(@NotNull Content content) {
+ restart(content.getComponent());
+ }
+
+ private static void restart(@Nullable JComponent component) {
+ if (component != null) {
+ ExecutionEnvironment environment = LangDataKeys.EXECUTION_ENVIRONMENT.getData(DataManager.getInstance().getDataContext(component));
+ if (environment != null) {
+ restart(environment);
+ }
+ }
+ }
+
+ public static void restart(@NotNull ExecutionEnvironment environment) {
+ if (!ExecutorRegistry.getInstance().isStarting(environment)) {
+ ExecutionManager.getInstance(environment.getProject()).restartRunProfile(environment);
+ }
+ }
+
+ public static void runConfiguration(@NotNull RunnerAndConfigurationSettings configuration, @NotNull Executor executor) {
+ ExecutionEnvironmentBuilder builder = createEnvironment(executor, configuration);
+ if (builder != null) {
+ ExecutionManager.getInstance(configuration.getConfiguration().getProject()).restartRunProfile(builder
+ .activeTarget()
+ .build());
+ }
+ }
+
+ @Nullable
+ public static ExecutionEnvironmentBuilder createEnvironment(@NotNull Executor executor, @NotNull RunnerAndConfigurationSettings settings) {
+ try {
+ return ExecutionEnvironmentBuilder.create(executor, settings);
+ }
+ catch (ExecutionException e) {
+ handleExecutionError(settings.getConfiguration().getProject(), executor.getToolWindowId(), settings.getConfiguration().getName(), e);
+ return null;
+ }
+ }
}
diff --git a/platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java b/platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java
index ec8ec49a790b..adbd04e822e6 100644
--- a/platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java
+++ b/platform/lang-api/src/com/intellij/execution/runners/GenericProgramRunner.java
@@ -51,7 +51,8 @@ public abstract class GenericProgramRunner<Settings extends RunnerSettings> exte
}
@Nullable
- protected abstract RunContentDescriptor doExecute(@NotNull Project project, @NotNull RunProfileState state,
+ protected abstract RunContentDescriptor doExecute(@NotNull Project project,
+ @NotNull RunProfileState state,
@Nullable RunContentDescriptor contentToReuse,
@NotNull ExecutionEnvironment environment) throws ExecutionException;
diff --git a/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java b/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java
index 8d4d3b29b088..60e7f03d54db 100644
--- a/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/RunContentDescriptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,23 +15,20 @@
*/
package com.intellij.execution.ui;
+import com.intellij.execution.ExecutionResult;
+import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.process.ProcessHandler;
-import com.intellij.ide.DataManager;
import com.intellij.ide.HelpIdProvider;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.DataProvider;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Disposer;
import com.intellij.ui.content.Content;
-import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class RunContentDescriptor implements Disposable {
- private static final Logger LOG = Logger.getInstance("#com.intellij.execution.ui.RunContentDescriptor");
-
private ExecutionConsole myExecutionConsole;
private ProcessHandler myProcessHandler;
private JComponent myComponent;
@@ -45,37 +42,33 @@ public class RunContentDescriptor implements Disposable {
private Computable<JComponent> myFocusComputable = null;
private boolean myAutoFocusContent = false;
- /**
- * Used to hack {@link com.intellij.execution.runners.RestartAction}
- */
private Content myContent;
private Runnable myRestarter;
- public RunContentDescriptor(final ExecutionConsole executionConsole,
- final ProcessHandler processHandler, final JComponent component, final String displayName, final Icon icon) {
+ public RunContentDescriptor(@Nullable ExecutionConsole executionConsole,
+ @Nullable ProcessHandler processHandler,
+ @NotNull JComponent component,
+ String displayName,
+ @Nullable Icon icon) {
myExecutionConsole = executionConsole;
myProcessHandler = processHandler;
myComponent = component;
myDisplayName = displayName;
myIcon = icon;
myHelpId = myExecutionConsole instanceof HelpIdProvider ? ((HelpIdProvider)myExecutionConsole).getHelpId() : null;
- DataManager.registerDataProvider(myComponent, new DataProvider() {
-
- @Override
- public Object getData(@NonNls final String dataId) {
- if (RunContentManager.RUN_CONTENT_DESCRIPTOR.is(dataId)) {
- return RunContentDescriptor.this;
- }
- return null;
- }
- });
}
- public RunContentDescriptor(final ExecutionConsole executionConsole,
- final ProcessHandler processHandler, final JComponent component, final String displayName) {
+ public RunContentDescriptor(@Nullable ExecutionConsole executionConsole,
+ @Nullable ProcessHandler processHandler,
+ @NotNull JComponent component,
+ String displayName) {
this(executionConsole, processHandler, component, displayName, null);
}
+ public RunContentDescriptor(@NotNull RunProfile profile, @NotNull ExecutionResult executionResult, @NotNull RunnerLayoutUi ui) {
+ this(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), ui.getComponent(), profile.getName(), profile.getIcon());
+ }
+
public ExecutionConsole getExecutionConsole() {
return myExecutionConsole;
}
@@ -86,10 +79,7 @@ public class RunContentDescriptor implements Disposable {
Disposer.dispose(myExecutionConsole);
myExecutionConsole = null;
}
- if (myComponent != null) {
- DataManager.removeDataProvider(myComponent);
- myComponent = null;
- }
+ myComponent = null;
myRestarter = null;
}
@@ -128,25 +118,30 @@ public class RunContentDescriptor implements Disposable {
return myHelpId;
}
- /**
- * @see #myContent
- */
- public void setAttachedContent(final Content content) {
- myContent = content;
- }
-
- /**
- * @see #myContent
- */
+ @Nullable
public Content getAttachedContent() {
return myContent;
}
+ public void setAttachedContent(@NotNull Content content) {
+ myContent = content;
+ }
+
@Nullable
+ @Deprecated
+ /**
+ * @deprecated Use {@link com.intellij.execution.runners.ExecutionUtil#restart(RunContentDescriptor)} instead
+ * to remove in IDEA 15
+ */
public Runnable getRestarter() {
return myRestarter;
}
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated to remove in IDEA 15
+ */
public void setRestarter(@Nullable Runnable runnable) {
myRestarter = runnable;
}
diff --git a/platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java b/platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java
index 4f192197b0f9..5a2b53c97bc8 100644
--- a/platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/RunContentManager.java
@@ -20,15 +20,24 @@ import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataKey;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.wm.ToolWindow;
+import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public interface RunContentManager {
+ Topic<RunContentWithExecutorListener> TOPIC =
+ Topic.create("Run Content", RunContentWithExecutorListener.class);
- DataKey<RunContentDescriptor> RUN_CONTENT_DESCRIPTOR = DataKey.create("RUN_CONTENT_DESCRIPTOR");
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated Use {@link LangDataKeys#RUN_CONTENT_DESCRIPTOR} instead
+ */
+ DataKey<RunContentDescriptor> RUN_CONTENT_DESCRIPTOR = LangDataKeys.RUN_CONTENT_DESCRIPTOR;
@Nullable
RunContentDescriptor getSelectedContent();
@@ -38,28 +47,35 @@ public interface RunContentManager {
@NotNull
List<RunContentDescriptor> getAllDescriptors();
+
/**
- * to reduce number of open contents RunContentManager reuses
- * some of them during showRunContent (for ex. if a process was stopped)
- * @return content that will be reused by showRunContent
- * @deprecated use {@link #getReuseContent(com.intellij.execution.Executor, ExecutionEnvironment)}
+ * @deprecated use {@link #getReuseContent(ExecutionEnvironment)}
+ * to remove in IDEA 15
*/
+ @Deprecated
@Nullable
RunContentDescriptor getReuseContent(Executor requestor, @Nullable RunContentDescriptor contentToReuse);
/**
* @deprecated use {@link #getReuseContent(ExecutionEnvironment)}
+ * to remove in IDEA 15
*/
@Deprecated
@Nullable
RunContentDescriptor getReuseContent(Executor requestor, @NotNull ExecutionEnvironment executionEnvironment);
@Nullable
+ /**
+ * To reduce number of open contents RunContentManager reuses
+ * some of them during showRunContent (for ex. if a process was stopped)
+ */
RunContentDescriptor getReuseContent(@NotNull ExecutionEnvironment executionEnvironment);
/**
* @deprecated use {@link #getReuseContent(ExecutionEnvironment)}
+ * to remove in IDEA 15
*/
+ @SuppressWarnings("UnusedDeclaration")
@Deprecated
@Nullable
RunContentDescriptor getReuseContent(Executor requestor, DataContext dataContext);
@@ -67,19 +83,42 @@ public interface RunContentManager {
@Nullable
RunContentDescriptor findContentDescriptor(Executor requestor, ProcessHandler handler);
- void showRunContent(@NotNull Executor executor, RunContentDescriptor descriptor, RunContentDescriptor contentToReuse);
- void showRunContent(@NotNull Executor executor, RunContentDescriptor descriptor);
+ void showRunContent(@NotNull Executor executor, @NotNull RunContentDescriptor descriptor, @Nullable RunContentDescriptor contentToReuse);
+
+ void showRunContent(@NotNull Executor executor, @NotNull RunContentDescriptor descriptor);
+
void hideRunContent(@NotNull Executor executor, RunContentDescriptor descriptor);
+
boolean removeRunContent(@NotNull Executor executor, RunContentDescriptor descriptor);
void toFrontRunContent(Executor requestor, RunContentDescriptor descriptor);
+
void toFrontRunContent(Executor requestor, ProcessHandler handler);
- void addRunContentListener(RunContentListener listener);
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated Use {@link RunContentManager#TOPIC} instead
+ * to remove in IDEA 15
+ */
+ void addRunContentListener(@NotNull RunContentListener listener);
+
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated Use {@link RunContentManager#TOPIC} instead
+ * to remove in IDEA 15
+ */
void removeRunContentListener(RunContentListener listener);
- void addRunContentListener(RunContentListener myContentListener, Executor executor);
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
+ /**
+ * @deprecated Use {@link RunContentManager#TOPIC} instead
+ * to remove in IDEA 15
+ */
+ void addRunContentListener(@NotNull RunContentListener myContentListener, Executor executor);
@Nullable
ToolWindow getToolWindowByDescriptor(@NotNull RunContentDescriptor descriptor);
-} \ No newline at end of file
+}
diff --git a/platform/lang-impl/src/com/intellij/execution/ui/RunContentWithExecutorListener.java b/platform/lang-api/src/com/intellij/execution/ui/RunContentWithExecutorListener.java
index 8231f0d1d1d8..ef18d75ab699 100644
--- a/platform/lang-impl/src/com/intellij/execution/ui/RunContentWithExecutorListener.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/RunContentWithExecutorListener.java
@@ -17,11 +17,13 @@ package com.intellij.execution.ui;
import com.intellij.execution.Executor;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public interface RunContentWithExecutorListener {
- void contentSelected(RunContentDescriptor descriptor, @NotNull Executor executor);
- void contentRemoved(RunContentDescriptor descriptor, @NotNull Executor executor);
+ void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor);
+
+ void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor);
}
diff --git a/platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java b/platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java
index 90dfad98dbbc..7fdb851514fe 100644
--- a/platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java
+++ b/platform/lang-api/src/com/intellij/execution/ui/layout/ViewContext.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -53,6 +53,7 @@ public interface ViewContext extends Disposable {
ContentManager getContentManager();
+ @NotNull
ActionManager getActionManager();
IdeFocusManager getFocusManager();
diff --git a/platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java b/platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java
index e896c9f14246..cb3518834423 100644
--- a/platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java
+++ b/platform/lang-api/src/com/intellij/facet/frameworks/SettingsConnectionService.java
@@ -17,10 +17,12 @@ package com.intellij.facet.frameworks;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.JDOMUtil;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.containers.hash.HashMap;
+import com.intellij.util.containers.ContainerUtil;
import org.jdom.Document;
import org.jdom.Element;
+import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -65,18 +67,23 @@ public abstract class SettingsConnectionService {
@Nullable
private Map<String, String> readSettings(String... attributes) {
- Map<String, String> settings = new HashMap<String, String>();
+ Map<String, String> settings = ContainerUtil.newLinkedHashMap();
try {
- final URL url = new URL(getSettingsUrl());
- final InputStream is = getStream(url);
- final Document document = JDOMUtil.loadDocument(is);
- final Element root = document.getRootElement();
- for (String s : attributes) {
- final String attributeValue = root.getAttributeValue(s);
- if (StringUtil.isNotEmpty(attributeValue)) {
- settings.put(s, attributeValue);
+ URL url = new URL(getSettingsUrl());
+ String text = FileUtil.loadTextAndClose(getStream(url));
+ try {
+ Document document = JDOMUtil.loadDocument(text);
+ Element root = document.getRootElement();
+ for (String s : attributes) {
+ String attributeValue = root.getAttributeValue(s);
+ if (StringUtil.isNotEmpty(attributeValue)) {
+ settings.put(s, attributeValue);
+ }
}
}
+ catch (JDOMException e) {
+ LOG.error("", e, text);
+ }
}
catch (MalformedURLException e) {
LOG.error(e);
diff --git a/platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java b/platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java
index f3a6d087da35..c04efa50ba33 100644
--- a/platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java
+++ b/platform/lang-api/src/com/intellij/facet/ui/FacetEditorValidator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,12 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.facet.ui;
+import org.jetbrains.annotations.NotNull;
+
/**
* @author nik
*/
public abstract class FacetEditorValidator {
+ @NotNull
public abstract ValidationResult check();
}
diff --git a/platform/lang-api/src/com/intellij/ide/IdeView.java b/platform/lang-api/src/com/intellij/ide/IdeView.java
index 7ee910f0925f..8f2dc5ce51a8 100644
--- a/platform/lang-api/src/com/intellij/ide/IdeView.java
+++ b/platform/lang-api/src/com/intellij/ide/IdeView.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,6 +18,7 @@ package com.intellij.ide;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -41,6 +42,7 @@ public interface IdeView {
*
* @return the list of directories, or an empty array if nothing is selected.
*/
+ @NotNull
PsiDirectory[] getDirectories();
/**
diff --git a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java
index c3f1bc3cb2fd..0dd1683899f4 100644
--- a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java
+++ b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java
@@ -16,7 +16,10 @@
package com.intellij.openapi.actionSystem;
+import com.intellij.execution.configurations.RunProfile;
+import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.ConsoleView;
+import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.ide.IdeView;
import com.intellij.lang.Language;
import com.intellij.openapi.module.ModifiableModuleModel;
@@ -54,10 +57,14 @@ public class LangDataKeys extends PlatformDataKeys {
public static final DataKey<PsiElement> PASTE_TARGET_PSI_ELEMENT = DataKey.create("psi.pasteTargetElement");
public static final DataKey<ConsoleView> CONSOLE_VIEW = DataKey.create("consoleView");
-
+
public static final DataKey<JBPopup> POSITION_ADJUSTER_POPUP = DataKey.create("chooseByNameDropDown");
public static final DataKey<JBPopup> PARENT_POPUP = DataKey.create("chooseByNamePopup");
public static final DataKey<Library> LIBRARY = DataKey.create("project.model.library");
+
+ public static final DataKey<RunProfile> RUN_PROFILE = DataKey.create("runProfile");
+ public static final DataKey<ExecutionEnvironment> EXECUTION_ENVIRONMENT = DataKey.create("executionEnvironment");
+ public static final DataKey<RunContentDescriptor> RUN_CONTENT_DESCRIPTOR = DataKey.create("RUN_CONTENT_DESCRIPTOR");
}
diff --git a/platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java b/platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java
index 2c38cd057b2b..11bf87e7a2cd 100644
--- a/platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java
+++ b/platform/lang-api/src/com/intellij/psi/WeigherExtensionPoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,11 +18,10 @@ package com.intellij.psi;
import com.intellij.openapi.extensions.AbstractExtensionPointBean;
import com.intellij.openapi.util.NotNullLazyValue;
import com.intellij.util.KeyedLazyInstance;
+import com.intellij.util.ReflectionUtil;
import com.intellij.util.xmlb.annotations.Attribute;
import org.jetbrains.annotations.NotNull;
-import java.lang.reflect.Constructor;
-
/**
* @author peter
*/
@@ -44,24 +43,13 @@ public class WeigherExtensionPoint extends AbstractExtensionPointBean implements
protected final Weigher compute() {
try {
Class<Weigher> tClass = findClass(implementationClass);
- Constructor<Weigher> constructor = tClass.getConstructor();
- constructor.setAccessible(true);
- final Weigher weigher = tClass.newInstance();
+ final Weigher weigher = ReflectionUtil.newInstance(tClass);
weigher.setDebugName(id);
return weigher;
}
- catch (InstantiationException e) {
- throw new RuntimeException(e);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
- catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
}
};
diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
index d858bfc01fcb..2683db2a846d 100644
--- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
+++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java
@@ -113,7 +113,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
}
}
- public <T extends CustomCodeStyleSettings> T getCustomSettings(Class<T> aClass) {
+ public <T extends CustomCodeStyleSettings> T getCustomSettings(@NotNull Class<T> aClass) {
synchronized (myCustomSettings) {
return (T)myCustomSettings.get(aClass);
}
@@ -127,7 +127,9 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
}
private void copyCustomSettingsFrom(@NotNull CodeStyleSettings from) {
- myCustomSettings.clear();
+ synchronized (myCustomSettings) {
+ myCustomSettings.clear();
+ }
for (final CustomCodeStyleSettings settings : from.getCustomSettingsValues()) {
addCustomSettings((CustomCodeStyleSettings) settings.clone());
}
@@ -247,6 +249,10 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
public int INNER_CLASSES_ORDER_WEIGHT = 7;
//----------------- WRAPPING ---------------------------
+ /**
+ * @deprecated Use get/setRightMargin() methods instead.
+ */
+ @Deprecated
public int RIGHT_MARGIN = 120;
public boolean WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = false;
@@ -435,6 +441,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
private CodeStyleSettings myParentSettings;
private boolean myLoadedAdditionalIndentOptions;
+ @NotNull
private Collection<CustomCodeStyleSettings> getCustomSettingsValues() {
synchronized (myCustomSettings) {
return Collections.unmodifiableCollection(myCustomSettings.values());
@@ -524,7 +531,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
@NonNls Element option = (Element)option1;
@NonNls final String name = option.getAttributeValue("name");
if ("TAB_SIZE".equals(name)) {
- final int value = Integer.valueOf(option.getAttributeValue("value")).intValue();
+ final int value = Integer.parseInt(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.TAB_SIZE = value;
JSP_INDENT_OPTIONS.TAB_SIZE = value;
XML_INDENT_OPTIONS.TAB_SIZE = value;
@@ -532,7 +539,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
optionsImported = true;
}
else if ("INDENT_SIZE".equals(name)) {
- final int value = Integer.valueOf(option.getAttributeValue("value")).intValue();
+ final int value = Integer.parseInt(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.INDENT_SIZE = value;
JSP_INDENT_OPTIONS.INDENT_SIZE = value;
XML_INDENT_OPTIONS.INDENT_SIZE = value;
@@ -540,7 +547,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
optionsImported = true;
}
else if ("CONTINUATION_INDENT_SIZE".equals(name)) {
- final int value = Integer.valueOf(option.getAttributeValue("value")).intValue();
+ final int value = Integer.parseInt(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.CONTINUATION_INDENT_SIZE = value;
JSP_INDENT_OPTIONS.CONTINUATION_INDENT_SIZE = value;
XML_INDENT_OPTIONS.CONTINUATION_INDENT_SIZE = value;
@@ -548,7 +555,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
optionsImported = true;
}
else if ("USE_TAB_CHARACTER".equals(name)) {
- final boolean value = Boolean.valueOf(option.getAttributeValue("value")).booleanValue();
+ final boolean value = Boolean.parseBoolean(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.USE_TAB_CHARACTER = value;
JSP_INDENT_OPTIONS.USE_TAB_CHARACTER = value;
XML_INDENT_OPTIONS.USE_TAB_CHARACTER = value;
@@ -556,14 +563,15 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
optionsImported = true;
}
else if ("SMART_TABS".equals(name)) {
- final boolean value = Boolean.valueOf(option.getAttributeValue("value")).booleanValue();
+ final boolean value = Boolean.parseBoolean(option.getAttributeValue("value"));
JAVA_INDENT_OPTIONS.SMART_TABS = value;
JSP_INDENT_OPTIONS.SMART_TABS = value;
XML_INDENT_OPTIONS.SMART_TABS = value;
OTHER_INDENT_OPTIONS.SMART_TABS = value;
optionsImported = true;
- } else if ("SPACE_AFTER_UNARY_OPERATOR".equals(name)) {
- SPACE_AROUND_UNARY_OPERATOR = Boolean.valueOf(option.getAttributeValue("value")).booleanValue();
+ }
+ else if ("SPACE_AFTER_UNARY_OPERATOR".equals(name)) {
+ SPACE_AROUND_UNARY_OPERATOR = Boolean.parseBoolean(option.getAttributeValue("value"));
optionsImported = true;
}
}
@@ -751,6 +759,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
myNames.addAll(from.myNames);
}
+ @Override
public boolean equals(Object other) {
if (other instanceof TypeToNameMap) {
TypeToNameMap otherMap = (TypeToNameMap)other;
@@ -759,6 +768,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
return false;
}
+ @Override
public int hashCode() {
int code = 0;
for (String myPattern : myPatterns) {
@@ -900,7 +910,7 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
if (langSettings.RIGHT_MARGIN >= 0) return langSettings.RIGHT_MARGIN;
}
}
- return RIGHT_MARGIN;
+ return getDefaultRightMargin();
}
/**
@@ -917,6 +927,16 @@ public class CodeStyleSettings extends CommonCodeStyleSettings implements Clonea
return;
}
}
+ setDefaultRightMargin(rightMargin);
+ }
+
+ @SuppressWarnings("deprecation")
+ public int getDefaultRightMargin() {
+ return RIGHT_MARGIN;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setDefaultRightMargin(int rightMargin) {
RIGHT_MARGIN = rightMargin;
}
}
diff --git a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
index 56fe91a0dc28..13f84cb1dc4f 100644
--- a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
+++ b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
@@ -32,6 +32,7 @@ import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.AsyncResult;
import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.vfs.NonPhysicalFileSystem;
import com.intellij.openapi.vfs.VFileProperty;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
@@ -221,12 +222,13 @@ public class PsiUtilBase extends PsiUtilCore implements PsiEditorUtil {
* Tries to find editor for the given element.
* <p/>
* There are at least two approaches to achieve the target. Current method is intended to encapsulate both of them:
- * <pre>
* <ul>
* <li>target editor works with a real file that remains at file system;</li>
* <li>target editor works with a virtual file;</li>
* </ul>
- * </pre>
+ * <p/>
+ * Please don't use this method for finding an editor for quick fix.
+ * @see {@link com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement}
*
* @param element target element
* @return editor that works with a given element if the one is found; <code>null</code> otherwise
@@ -234,30 +236,28 @@ public class PsiUtilBase extends PsiUtilCore implements PsiEditorUtil {
@Nullable
public static Editor findEditor(@NotNull PsiElement element) {
PsiFile psiFile = element.getContainingFile();
- if (psiFile == null) {
- return null;
- }
- VirtualFile virtualFile = psiFile.getOriginalFile().getVirtualFile();
+ VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
if (virtualFile == null) {
return null;
}
- if (virtualFile.isInLocalFileSystem()) {
+ Project project = psiFile.getProject();
+ if (virtualFile.isInLocalFileSystem() || virtualFile.getFileSystem() instanceof NonPhysicalFileSystem) {
// Try to find editor for the real file.
- final FileEditor[] editors = FileEditorManager.getInstance(psiFile.getProject()).getEditors(virtualFile);
+ final FileEditor[] editors = FileEditorManager.getInstance(project).getEditors(virtualFile);
for (FileEditor editor : editors) {
if (editor instanceof TextEditor) {
return ((TextEditor)editor).getEditor();
}
}
}
- else if (SwingUtilities.isEventDispatchThread()) {
+ if (SwingUtilities.isEventDispatchThread()) {
// We assume that data context from focus-based retrieval should success if performed from EDT.
AsyncResult<DataContext> asyncResult = DataManager.getInstance().getDataContextFromFocus();
if (asyncResult.isDone()) {
Editor editor = CommonDataKeys.EDITOR.getData(asyncResult.getResult());
if (editor != null) {
- Document cachedDocument = PsiDocumentManager.getInstance(psiFile.getProject()).getCachedDocument(psiFile);
+ Document cachedDocument = PsiDocumentManager.getInstance(project).getCachedDocument(psiFile);
// Ensure that target editor is found by checking its document against the one from given PSI element.
if (cachedDocument == editor.getDocument()) {
return editor;
diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java
index 9f38c6605f11..b07c7a62bc47 100644
--- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java
@@ -23,6 +23,7 @@ import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.codeStyle.CodeStyleScheme;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider;
@@ -55,6 +56,9 @@ public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent.
public JComponent createComponent() {
myModel = ensureModel();
+ if (Registry.is("ide.file.settings.order.new")) {
+ return myPanels == null || myPanels.isEmpty() ? null : myPanels.get(0).createComponent();
+ }
return myRootSchemesPanel.getPanel();
}
@@ -232,6 +236,14 @@ public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent.
}
}
+ if (Registry.is("ide.file.settings.order.new")) {
+ int size = myPanels.size();
+ Configurable[] result = new Configurable[size > 0 ? size - 1 : 0];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = myPanels.get(i + 1);
+ }
+ return result;
+ }
return myPanels.toArray(new Configurable[myPanels.size()]);
}
@@ -255,7 +267,7 @@ public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent.
@Override
public void currentSettingsChanged() {
-
+
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java b/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java
index d51ddbd827d5..e3dabad85b21 100644
--- a/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java
@@ -111,7 +111,7 @@ public class GeneralCodeStylePanel extends CodeStyleAbstractPanel {
myLineSeparatorCombo.addItem(MACINTOSH_STRING);
addPanelToWatch(myPanel);
- myRightMarginSpinner.setModel(new SpinnerNumberModel(settings.RIGHT_MARGIN, 1, 1000000, 1));
+ myRightMarginSpinner.setModel(new SpinnerNumberModel(settings.getDefaultRightMargin(), 1, 1000000, 1));
myIndentOptionsEditor = new SmartIndentOptionsEditor();
myDefaultIndentOptionsPanel.add(myIndentOptionsEditor.createPanel(), BorderLayout.CENTER);
@@ -165,7 +165,7 @@ public class GeneralCodeStylePanel extends CodeStyleAbstractPanel {
public void apply(CodeStyleSettings settings) {
settings.LINE_SEPARATOR = getSelectedLineSeparator();
- settings.RIGHT_MARGIN = ((Number) myRightMarginSpinner.getValue()).intValue();
+ settings.setDefaultRightMargin(((Number) myRightMarginSpinner.getValue()).intValue());
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myCbWrapWhenTypingReachesRightMargin.isSelected();
myIndentOptionsEditor.setEnabled(true);
myIndentOptionsEditor.apply(settings, settings.OTHER_INDENT_OPTIONS);
@@ -226,7 +226,7 @@ public class GeneralCodeStylePanel extends CodeStyleAbstractPanel {
return true;
}
- if (!Comparing.equal(myRightMarginSpinner.getValue(), settings.RIGHT_MARGIN)) return true;
+ if (!Comparing.equal(myRightMarginSpinner.getValue(), settings.getDefaultRightMargin())) return true;
myIndentOptionsEditor.setEnabled(true);
if (myEnableFormatterTags.isSelected()) {
@@ -265,7 +265,7 @@ public class GeneralCodeStylePanel extends CodeStyleAbstractPanel {
myLineSeparatorCombo.setSelectedItem(SYSTEM_DEPENDANT_STRING);
}
- myRightMarginSpinner.setValue(settings.RIGHT_MARGIN);
+ myRightMarginSpinner.setValue(settings.getDefaultRightMargin());
myCbWrapWhenTypingReachesRightMargin.setSelected(settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN);
myIndentOptionsEditor.reset(settings, settings.OTHER_INDENT_OPTIONS);
myIndentOptionsEditor.setEnabled(true);
diff --git a/platform/lang-impl/src/com/intellij/application/options/OtherTabsAndIndentsPanel.java b/platform/lang-impl/src/com/intellij/application/options/OtherTabsAndIndentsPanel.java
index cf118835aa0e..aadc34a0ac1f 100644
--- a/platform/lang-impl/src/com/intellij/application/options/OtherTabsAndIndentsPanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/OtherTabsAndIndentsPanel.java
@@ -91,7 +91,7 @@ public class OtherTabsAndIndentsPanel extends CodeStyleAbstractPanel {
installPreviewPanel(myPreviewPanel);
addPanelToWatch(myPanel);
- myRightMargin = settings.RIGHT_MARGIN;
+ myRightMargin = settings.getDefaultRightMargin();
}
diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java
index 70c747dc11ca..0759052ee623 100644
--- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java
+++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/RightMarginForm.java
@@ -48,7 +48,7 @@ public class RightMarginForm {
public RightMarginForm(@NotNull Language language, @NotNull CodeStyleSettings settings) {
myLanguage = language;
- myDefaultRightMargin = settings.RIGHT_MARGIN;
+ myDefaultRightMargin = settings.getDefaultRightMargin();
myDefaultGeneralCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
@@ -71,7 +71,7 @@ public class RightMarginForm {
}
else {
myDefaultGeneralCheckBox.setSelected(true);
- myRightMarginField.setText(Integer.toString(settings.RIGHT_MARGIN));
+ myRightMarginField.setText(Integer.toString(settings.getDefaultRightMargin()));
if (langSettings == settings) {
myDefaultGeneralCheckBox.setEnabled(false);
myRightMarginField.setEnabled(false);
@@ -86,7 +86,7 @@ public class RightMarginForm {
langSettings.RIGHT_MARGIN = -1;
}
else {
- langSettings.RIGHT_MARGIN = getFieldRightMargin(settings.RIGHT_MARGIN);
+ langSettings.RIGHT_MARGIN = getFieldRightMargin(settings.getDefaultRightMargin());
}
}
}
@@ -97,7 +97,7 @@ public class RightMarginForm {
return langSettings.RIGHT_MARGIN >= 0;
}
else {
- return langSettings.RIGHT_MARGIN != getFieldRightMargin(settings.RIGHT_MARGIN);
+ return langSettings.RIGHT_MARGIN != getFieldRightMargin(settings.getDefaultRightMargin());
}
}
diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java
index 5e3017206132..ce2a00d3d671 100644
--- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java
+++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java
@@ -81,6 +81,8 @@ import java.util.*;
import java.util.List;
public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract implements EditorOptionsProvider {
+ public static final String ID = "reference.settingsdialog.IDE.editor.colors";
+
private HashMap<String,MyColorScheme> mySchemes;
private MyColorScheme mySelectedScheme;
public static final String DIFF_GROUP = ApplicationBundle.message("title.diff");
@@ -999,7 +1001,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
@Override
@NotNull
public String getHelpTopic() {
- return "reference.settingsdialog.IDE.editor.colors";
+ return ID;
}
private static class MyColorScheme extends EditorColorsSchemeImpl {
diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form
index db23ce17b2c3..edb9fcdb9e18 100644
--- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form
+++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form
@@ -3,12 +3,12 @@
<grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <xy x="20" y="20" width="500" height="585"/>
+ <xy x="20" y="20" width="500" height="614"/>
</constraints>
<properties/>
<border type="none"/>
<children>
- <grid id="ed507" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="ed507" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="9" fill="3" indent="0" use-parent-layout="false"/>
@@ -101,6 +101,35 @@
<text resource-bundle="messages/ApplicationBundle" key="checkbox.show.tabs.tooltips"/>
</properties>
</component>
+ <grid id="e3283" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <margin top="0" left="0" bottom="0" right="0"/>
+ <constraints>
+ <grid row="7" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties/>
+ <border type="none"/>
+ <children>
+ <component id="2479d" class="javax.swing.JLabel">
+ <constraints>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <text resource-bundle="messages/ApplicationBundle" key="editbox.tab.title.limit"/>
+ </properties>
+ </component>
+ <component id="3499c" class="javax.swing.JTextField" binding="myTabTitleLimitField">
+ <constraints>
+ <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false">
+ <preferred-size width="30" height="27"/>
+ </grid>
+ </constraints>
+ <properties>
+ <columns value="2"/>
+ <text value="30"/>
+ </properties>
+ </component>
+ </children>
+ </grid>
</children>
</grid>
<vspacer id="651b4">
@@ -119,7 +148,7 @@
</clientProperties>
<border type="none" title-resource-bundle="messages/ApplicationBundle" title-key="group.tab.closing.policy"/>
<children>
- <grid id="5a5a7" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="5a5a7" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -147,25 +176,6 @@
<text value="15"/>
</properties>
</component>
- <component id="2479d" class="javax.swing.JLabel">
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <text resource-bundle="messages/ApplicationBundle" key="editbox.tab.title.limit"/>
- </properties>
- </component>
- <component id="3499c" class="javax.swing.JTextField" binding="myTabTitleLimitField">
- <constraints>
- <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false">
- <preferred-size width="30" height="27"/>
- </grid>
- </constraints>
- <properties>
- <columns value="2"/>
- <text value="30"/>
- </properties>
- </component>
</children>
</grid>
<grid id="9b723" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="2">
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/FormatChangedTextUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/FormatChangedTextUtil.java
index af6bbdc931ca..0bc36c17325d 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/actions/FormatChangedTextUtil.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/FormatChangedTextUtil.java
@@ -312,8 +312,8 @@ public class FormatChangedTextUtil {
List<TextRange> ranges = ContainerUtil.newArrayList();
for (Range range : changedRanges) {
if (range.getType() != Range.DELETED) {
- int changeStartLine = range.getOffset1();
- int changeEndLine = range.getOffset2();
+ int changeStartLine = range.getLine1();
+ int changeEndLine = range.getLine2();
int lineStartOffset = document.getLineStartOffset(changeStartLine);
int lineEndOffset = document.getLineEndOffset(changeEndLine - 1);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
index 75a4fd410959..c8d5ec4b8ddb 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java
@@ -104,7 +104,7 @@ public class DaemonListeners implements Disposable {
private final ProjectLevelVcsManager myProjectLevelVcsManager;
private final VcsDirtyScopeManager myVcsDirtyScopeManager;
private final FileStatusManager myFileStatusManager;
- private final ActionManager myActionManager;
+ @NotNull private final ActionManager myActionManager;
private final TooltipController myTooltipController;
private boolean myEscPressed;
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java
index 0483d5a05027..825e72bc98e6 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -91,7 +91,7 @@ public class HectorComponent extends JPanel {
Collections.sort(languages, PsiUtilBase.LANGUAGE_COMPARATOR);
for (Language language : languages) {
@SuppressWarnings("UseOfObsoleteCollectionType")
- final Hashtable<Integer, JLabel> sliderLabels = new Hashtable<Integer, JLabel>();
+ final Hashtable<Integer, JComponent> sliderLabels = new Hashtable<Integer, JComponent>();
sliderLabels.put(1, new JLabel(EditorBundle.message("hector.none.slider.label")));
sliderLabels.put(2, new JLabel(EditorBundle.message("hector.syntax.slider.label")));
if (notInLibrary) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndAction.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndAction.java
index e7c723c17f8b..28b733cb1d5c 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndAction.java
@@ -26,10 +26,12 @@ package com.intellij.codeInsight.editorActions;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.Nullable;
public class CodeBlockEndAction extends EditorAction {
public CodeBlockEndAction() {
@@ -43,7 +45,7 @@ public class CodeBlockEndAction extends EditorAction {
}
@Override
- public void execute(Editor editor, DataContext dataContext) {
+ public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project != null) {
CodeBlockUtil.moveCaretToCodeBlockEnd(project, editor, false);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndWithSelectionAction.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndWithSelectionAction.java
index 9431da1fc4d7..10a71a5edc86 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndWithSelectionAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockEndWithSelectionAction.java
@@ -26,10 +26,12 @@ package com.intellij.codeInsight.editorActions;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.Nullable;
public class CodeBlockEndWithSelectionAction extends EditorAction {
public CodeBlockEndWithSelectionAction() {
@@ -43,7 +45,7 @@ public class CodeBlockEndWithSelectionAction extends EditorAction {
}
@Override
- public void execute(Editor editor, DataContext dataContext) {
+ public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project != null) {
CodeBlockUtil.moveCaretToCodeBlockEnd(project, editor, true);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartAction.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartAction.java
index 690efff63d16..fc8ac9cf119a 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartAction.java
@@ -26,10 +26,12 @@ package com.intellij.codeInsight.editorActions;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.Nullable;
public class CodeBlockStartAction extends EditorAction {
public CodeBlockStartAction() {
@@ -43,7 +45,7 @@ public class CodeBlockStartAction extends EditorAction {
}
@Override
- public void execute(Editor editor, DataContext dataContext) {
+ public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project != null) {
CodeBlockUtil.moveCaretToCodeBlockStart(project, editor, false);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartWithSelectionAction.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartWithSelectionAction.java
index 9819efcdc439..fcae25ac1a2b 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartWithSelectionAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/CodeBlockStartWithSelectionAction.java
@@ -26,10 +26,12 @@ package com.intellij.codeInsight.editorActions;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.Nullable;
public class CodeBlockStartWithSelectionAction extends EditorAction {
public CodeBlockStartWithSelectionAction() {
@@ -43,7 +45,7 @@ public class CodeBlockStartWithSelectionAction extends EditorAction {
}
@Override
- public void execute(Editor editor, DataContext dataContext) {
+ public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project != null) {
CodeBlockUtil.moveCaretToCodeBlockStart(project, editor, true);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java
index c8a1ab3b7730..5db0a1a7e93b 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/EnterHandler.java
@@ -61,8 +61,8 @@ public class EnterHandler extends BaseEnterHandler {
}
@Override
- public boolean isEnabled(Editor editor, DataContext dataContext) {
- return myOriginalHandler.isEnabled(editor, dataContext);
+ public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
+ return myOriginalHandler.isEnabled(editor, caret, dataContext);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java
index eebdb50ea2ee..5f416dd307c4 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/JoinLinesHandler.java
@@ -239,7 +239,7 @@ public class JoinLinesHandler extends EditorWriteActionHandler {
docManager.commitDocument(doc);
try {
- CodeStyleManager.getInstance(project).reformatText(psiFile, start + 1, end);
+ CodeStyleManager.getInstance(project).reformatRange(psiFile, start + 1, end, true);
}
catch (IncorrectOperationException e) {
LOG.error(e);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordHandler.java
index 8edbb3f5f11d..bfddf17054b5 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordHandler.java
@@ -25,6 +25,7 @@ import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
@@ -51,14 +52,14 @@ public class SelectWordHandler extends EditorActionHandler {
}
@Override
- public void execute(@NotNull Editor editor, DataContext dataContext) {
+ public void doExecute(@NotNull Editor editor, @Nullable Caret caret, DataContext dataContext) {
if (LOG.isDebugEnabled()) {
LOG.debug("enter: execute(editor='" + editor + "')");
}
Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(editor.getComponent()));
if (project == null) {
if (myOriginalHandler != null) {
- myOriginalHandler.execute(editor, dataContext);
+ myOriginalHandler.execute(editor, caret, dataContext);
}
return;
}
@@ -74,7 +75,7 @@ public class SelectWordHandler extends EditorActionHandler {
}
if (range == null) {
if (myOriginalHandler != null) {
- myOriginalHandler.execute(editor, dataContext);
+ myOriginalHandler.execute(editor, caret, dataContext);
}
}
else {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java
index cb1d0a6f2be9..de59e9e8fa6b 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java
@@ -19,6 +19,7 @@ package com.intellij.codeInsight.editorActions;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.FoldRegion;
@@ -28,6 +29,7 @@ import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.util.Processor;
+import org.jetbrains.annotations.Nullable;
public class UnSelectWordHandler extends EditorActionHandler {
private final EditorActionHandler myOriginalHandler;
@@ -38,14 +40,17 @@ public class UnSelectWordHandler extends EditorActionHandler {
}
@Override
- public void execute(Editor editor, DataContext dataContext) {
+ public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(editor.getComponent()));
+ if (project == null) {
+ return;
+ }
Document document = editor.getDocument();
final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
if (file == null) {
if (myOriginalHandler != null) {
- myOriginalHandler.execute(editor, dataContext);
+ myOriginalHandler.execute(editor, caret, dataContext);
}
return;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/smartEnter/SmartEnterAction.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/smartEnter/SmartEnterAction.java
index bbb1e163729e..19fb28086099 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/smartEnter/SmartEnterAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/smartEnter/SmartEnterAction.java
@@ -16,13 +16,13 @@
package com.intellij.codeInsight.editorActions.smartEnter;
-import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.codeInsight.editorActions.enter.EnterAfterUnmatchedBraceHandler;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.lang.Language;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.IdeActions;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
@@ -41,15 +41,7 @@ import java.util.List;
public class SmartEnterAction extends EditorAction {
public SmartEnterAction() {
super(new Handler());
- }
-
- @Override
- protected Editor getEditor(@NotNull final DataContext dataContext) {
- final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
- if (editor == null) return null;
- Project project = editor.getProject();
- if (project == null) project = CommonDataKeys.PROJECT.getData(dataContext);
- return project == null ? null : BaseCodeInsightAction.getInjectedEditor(project, editor);
+ setInjectedContext(true);
}
private static class Handler extends EditorWriteActionHandler {
@@ -58,15 +50,15 @@ public class SmartEnterAction extends EditorAction {
}
@Override
- public boolean isEnabled(Editor editor, DataContext dataContext) {
- return getEnterHandler().isEnabled(editor, dataContext);
+ public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
+ return getEnterHandler().isEnabled(editor, caret, dataContext);
}
@Override
- public void executeWriteAction(Editor editor, DataContext dataContext) {
+ public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null || editor.isOneLineMode()) {
- plainEnter(editor, dataContext);
+ plainEnter(editor, caret, dataContext);
return;
}
@@ -76,13 +68,13 @@ public class SmartEnterAction extends EditorAction {
PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
if (psiFile == null) {
- plainEnter(editor, dataContext);
+ plainEnter(editor, caret, dataContext);
return;
}
if (EnterAfterUnmatchedBraceHandler.isAfterUnmatchedLBrace(editor, caretOffset, psiFile.getFileType())) {
EditorActionHandler enterHandler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
- enterHandler.execute(editor, dataContext);
+ enterHandler.execute(editor, caret, dataContext);
return;
}
@@ -100,13 +92,13 @@ public class SmartEnterAction extends EditorAction {
}
}
if (!processed) {
- plainEnter(editor, dataContext);
+ plainEnter(editor, caret, dataContext);
}
}
}
- public static void plainEnter(Editor editor, DataContext dataContext) {
- getEnterHandler().execute(editor, dataContext);
+ public static void plainEnter(Editor editor, Caret caret, DataContext dataContext) {
+ getEnterHandler().execute(editor, caret, dataContext);
}
private static EditorActionHandler getEnterHandler() {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java
index 7d0b4453c517..4c137f8d2a37 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/FoldingUpdate.java
@@ -174,7 +174,7 @@ public class FoldingUpdate {
injectedFiles.add(injectedFile);
final FoldingMap map = new FoldingMap();
maps.add(map);
- getFoldingsFor(injectedFile, injectedDocument, map, false);
+ getFoldingsFor(injectedFile, injectedEditor.getDocument(), map, false);
}
});
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/PsiNamesElementSignatureProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/PsiNamesElementSignatureProvider.java
index 17a85304d4a1..3409d3f93fc8 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/PsiNamesElementSignatureProvider.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/PsiNamesElementSignatureProvider.java
@@ -89,11 +89,23 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
return candidate instanceof PsiComment ? candidate : null;
}
else if (CODE_BLOCK_MARKER.equals(elementMarker)) {
+ int index = 0;
+ if (tokenizer.hasMoreTokens()) {
+ String indexStr = tokenizer.nextToken();
+ try {
+ index = Integer.parseInt(indexStr);
+ }
+ catch (NumberFormatException e) {
+ if (processingInfoStorage != null) {
+ processingInfoStorage.append("Invalid block index: ").append(indexStr).append("\n");
+ }
+ }
+ }
for (PsiElement child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- PsiElement firstChild = child.getFirstChild();
- PsiElement lastChild = child.getLastChild();
- if (firstChild != null && lastChild != null && "{".equals(firstChild.getText()) && "}".equals(lastChild.getText())) {
- return child;
+ if (isBlockElement(child)) {
+ if (--index < 0) {
+ return child;
+ }
}
}
return null;
@@ -212,18 +224,39 @@ public class PsiNamesElementSignatureProvider extends AbstractElementSignaturePr
PsiElement parent = element.getParent();
if (parent instanceof PsiNamedElement && !(parent instanceof PsiFile)) {
- PsiElement firstChild = element.getFirstChild();
- PsiElement lastChild = element.getLastChild();
- if (firstChild != null && "{".equals(firstChild.getText()) && lastChild != null && "}".equals(lastChild.getText())) {
+ if (isBlockElement(element)) {
+ int index = getBlockElementIndex(element);
StringBuilder bufferToUse = buffer;
if (bufferToUse == null) {
bufferToUse = new StringBuilder();
}
bufferToUse.append(TYPE_MARKER).append(ELEMENT_TOKENS_SEPARATOR).append(CODE_BLOCK_MARKER);
+ if (index > 0) {
+ bufferToUse.append(ELEMENT_TOKENS_SEPARATOR).append(index);
+ }
return bufferToUse;
}
}
return null;
}
+
+ private static boolean isBlockElement(@NotNull PsiElement element) {
+ PsiElement firstChild = element.getFirstChild();
+ PsiElement lastChild = element.getLastChild();
+ return firstChild != null && "{".equals(firstChild.getText()) && lastChild != null && "}".equals(lastChild.getText());
+ }
+
+ private static int getBlockElementIndex(@NotNull PsiElement element) {
+ int i = 0;
+ for (PsiElement sibling : element.getParent().getChildren()) {
+ if (element.equals(sibling)) {
+ return i;
+ }
+ if (isBlockElement(sibling)) {
+ i++;
+ }
+ }
+ throw new RuntimeException("Malformed PSI");
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditAction.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditAction.java
index ee4c91972046..62e3bcba3a22 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditAction.java
@@ -25,7 +25,10 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.Balloon;
-import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
@@ -138,7 +141,7 @@ public class QuickEditAction implements IntentionAction, LowPriorityAction {
}
@Nullable
- protected JComponent createBalloonComponent(PsiFile file, Ref<Balloon> ref) {
+ protected JComponent createBalloonComponent(@NotNull PsiFile file) {
return null;
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java
index 2f4aa4198f85..2c5d8642e46d 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/intention/impl/QuickEditHandler.java
@@ -55,6 +55,7 @@ import com.intellij.psi.impl.source.PostprocessReformattingAspect;
import com.intellij.psi.impl.source.resolve.FileContextUtil;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.impl.source.tree.injected.Place;
+import com.intellij.psi.util.PsiUtilCore;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.DocumentUtil;
@@ -108,18 +109,19 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
myEditor = editor;
myAction = action;
myOrigDocument = editor.getDocument();
- final Place shreds = InjectedLanguageUtil.getShreds(injectedFile);
- final FileType fileType = injectedFile.getFileType();
- final Language language = injectedFile.getLanguage();
-
- final PsiFileFactory factory = PsiFileFactory.getInstance(project);
- final String text = InjectedLanguageManager.getInstance(project).getUnescapedText(injectedFile);
- final String newFileName =
+ Place shreds = InjectedLanguageUtil.getShreds(injectedFile);
+ FileType fileType = injectedFile.getFileType();
+ Language language = injectedFile.getLanguage();
+ PsiLanguageInjectionHost.Shred firstShred = ContainerUtil.getFirstItem(shreds);
+
+ PsiFileFactory factory = PsiFileFactory.getInstance(project);
+ String text = InjectedLanguageManager.getInstance(project).getUnescapedText(injectedFile);
+ String newFileName =
StringUtil.notNullize(language.getDisplayName(), "Injected") + " Fragment " + "(" +
- origFile.getName() + ":" + shreds.get(0).getHost().getTextRange().getStartOffset() + ")" + "." + fileType.getDefaultExtension();
+ origFile.getName() + ":" + firstShred.getHost().getTextRange().getStartOffset() + ")" + "." + fileType.getDefaultExtension();
// preserve \r\n as it is done in MultiHostRegistrarImpl
- myNewFile = factory.createFileFromText(newFileName, language, text, true, true);
+ myNewFile = factory.createFileFromText(newFileName, language, text, true, false);
myNewVirtualFile = ObjectUtils.assertNotNull((LightVirtualFile)myNewFile.getVirtualFile());
myNewVirtualFile.setOriginalFile(origFile.getVirtualFile());
@@ -130,8 +132,7 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
// suppress possible errors as in injected mode
myNewFile.putUserData(InjectedLanguageUtil.FRANKENSTEIN_INJECTION,
injectedFile.getUserData(InjectedLanguageUtil.FRANKENSTEIN_INJECTION));
- final SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(project);
- myNewFile.putUserData(FileContextUtil.INJECTED_IN_ELEMENT, smartPointerManager.createSmartPsiElementPointer(origFile));
+ myNewFile.putUserData(FileContextUtil.INJECTED_IN_ELEMENT, shreds.getHostPointer());
myNewDocument = PsiDocumentManager.getInstance(project).getDocument(myNewFile);
assert myNewDocument != null;
EditorActionManager.getInstance().setReadonlyFragmentModificationHandler(myNewDocument, new MyQuietHandler());
@@ -149,22 +150,23 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
if (event.getEditor().getDocument() != myNewDocument) return;
myEditorCount ++;
final EditorActionHandler editorEscape = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ESCAPE);
- new AnAction() {
- @Override
- public void update(AnActionEvent e) {
- Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
- e.getPresentation().setEnabled(
- !myAction.isShowInBalloon() &&
- editor != null && LookupManager.getActiveLookup(editor) == null &&
- TemplateManager.getInstance(myProject).getActiveTemplate(editor) == null &&
- (editorEscape == null || !editorEscape.isEnabled(editor, e.getDataContext())));
- }
+ if (!myAction.isShowInBalloon()) {
+ new AnAction() {
+ @Override
+ public void update(AnActionEvent e) {
+ Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
+ e.getPresentation().setEnabled(
+ editor != null && LookupManager.getActiveLookup(editor) == null &&
+ TemplateManager.getInstance(myProject).getActiveTemplate(editor) == null &&
+ (editorEscape == null || !editorEscape.isEnabled(editor, e.getDataContext())));
+ }
- @Override
- public void actionPerformed(AnActionEvent e) {
- closeEditor();
- }
- }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, event.getEditor().getContentComponent());
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ closeEditor();
+ }
+ }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, event.getEditor().getContentComponent());
+ }
}
@Override
@@ -178,10 +180,11 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
}
}, this);
- if ("JAVA".equals(shreds.get(0).getHost().getLanguage().getID())) {
+ if ("JAVA".equals(firstShred.getHost().getLanguage().getID())) {
+ PsiLanguageInjectionHost.Shred lastShred = ContainerUtil.getLastItem(shreds);
myAltFullRange = myOrigDocument.createRangeMarker(
- shreds.get(0).getHostRangeMarker().getStartOffset(),
- shreds.get(shreds.size() - 1).getHostRangeMarker().getEndOffset());
+ firstShred.getHostRangeMarker().getStartOffset(),
+ lastShred.getHostRangeMarker().getEndOffset());
myAltFullRange.setGreedyToLeft(true);
myAltFullRange.setGreedyToRight(true);
@@ -201,8 +204,7 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
public void navigate(int injectedOffset) {
if (myAction.isShowInBalloon()) {
- Ref<Balloon> ref = Ref.create(null);
- final JComponent component = myAction.createBalloonComponent(myNewFile, ref);
+ final JComponent component = myAction.createBalloonComponent(myNewFile);
if (component != null) {
final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(component)
.setShadow(true)
@@ -212,7 +214,12 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
.setHideOnAction(false)
.setFillColor(UIUtil.getControlColor())
.createBalloon();
- ref.set(balloon);
+ new AnAction() {
+ @Override
+ public void actionPerformed(AnActionEvent e) {
+ balloon.hide();
+ }
+ }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, component);
Disposer.register(myNewFile.getProject(), balloon);
final Balloon.Position position = QuickEditAction.getBalloonPosition(myEditor);
RelativePoint point = JBPopupFactory.getInstance().guessBestPopupLocation(myEditor);
@@ -353,11 +360,10 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
private void commitToOriginal() {
if (!isValid()) return;
- final PsiFile origFile = (PsiFile)myNewFile.getUserData(FileContextUtil.INJECTED_IN_ELEMENT).getElement();
- VirtualFile origFileVirtualFile = origFile != null? origFile.getVirtualFile() : null;
+ VirtualFile origVirtualFile = PsiUtilCore.getVirtualFile(ObjectUtils.assertNotNull(myNewFile.getContext()));
myCommittingToOriginal = true;
try {
- if (origFileVirtualFile == null || !ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(origFileVirtualFile).hasReadonlyFiles()) {
+ if (origVirtualFile == null || !ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(origVirtualFile).hasReadonlyFiles()) {
PostprocessReformattingAspect.getInstance(myProject).disablePostprocessFormattingInside(new Runnable() {
@Override
public void run() {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
index 3666b4642efd..2f56d3714943 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java
@@ -19,6 +19,7 @@ package com.intellij.codeInsight.navigation;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.codeInsight.documentation.DocumentationManager;
+import com.intellij.codeInsight.documentation.DocumentationManagerProtocol;
import com.intellij.codeInsight.hint.HintManager;
import com.intellij.codeInsight.hint.HintManagerImpl;
import com.intellij.codeInsight.hint.HintUtil;
@@ -34,9 +35,7 @@ import com.intellij.openapi.actionSystem.MouseShortcut;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.actionSystem.impl.ActionButton;
import com.intellij.openapi.actionSystem.impl.PresentationFactory;
-import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
@@ -66,7 +65,7 @@ import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Comparing;
-import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
@@ -104,16 +103,14 @@ import java.util.List;
public class CtrlMouseHandler extends AbstractProjectComponent {
private static final AbstractDocumentationTooltipAction[] ourTooltipActions = {new ShowQuickDocAtPinnedWindowFromTooltipAction()};
- private static Key<?> ourDebuggerHighlighterKey;
- private static Key<?> ourXDebuggerHighlighterKey;
private final EditorColorsManager myEditorColorsManager;
- private HighlightersSet myHighlighter;
- @JdkConstants.InputEventMask private int myStoredModifiers = 0;
- private TooltipProvider myTooltipProvider = null;
- private final FileEditorManager myFileEditorManager;
- private final DocumentationManager myDocumentationManager;
- @Nullable private Point myPrevMouseLocation;
+ private HighlightersSet myHighlighter;
+ @JdkConstants.InputEventMask private int myStoredModifiers = 0;
+ private TooltipProvider myTooltipProvider = null;
+ private final FileEditorManager myFileEditorManager;
+ private final DocumentationManager myDocumentationManager;
+ @Nullable private Point myPrevMouseLocation;
private LightweightHint myHint;
private enum BrowseMode {None, Declaration, TypeDeclaration, Implementation}
@@ -137,7 +134,11 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
BrowseMode browseMode = getBrowseMode(modifiers);
- if (browseMode != BrowseMode.None) {
+ if (browseMode == BrowseMode.None) {
+ disposeHighlighter();
+ cancelPreviousTooltip();
+ }
+ else {
TooltipProvider tooltipProvider = myTooltipProvider;
if (tooltipProvider != null) {
if (browseMode != tooltipProvider.getBrowseMode()) {
@@ -149,10 +150,6 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
myTooltipProvider.execute(browseMode);
}
}
- else {
- disposeHighlighter();
- cancelPreviousTooltip();
- }
}
};
@@ -240,8 +237,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
EditorColorsManager colorsManager,
FileEditorManager fileEditorManager,
@NotNull DocumentationManager documentationManager,
- @NotNull final EditorFactory editorFactory)
- {
+ @NotNull final EditorFactory editorFactory) {
super(project);
myEditorColorsManager = colorsManager;
startupManager.registerPostStartupActivity(new DumbAwareRunnable() {
@@ -289,6 +285,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
return new Rectangle(hintComponent.getLocationOnScreen(), hintComponent.getSize());
}
+ @NotNull
private static BrowseMode getBrowseMode(@JdkConstants.InputEventMask int modifiers) {
if (modifiers != 0) {
final Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
@@ -375,9 +372,9 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
private abstract static class Info {
@NotNull protected final PsiElement myElementAtPointer;
- private final List<TextRange> myRanges;
+ @NotNull private final List<TextRange> myRanges;
- public Info(@NotNull PsiElement elementAtPointer, List<TextRange> ranges) {
+ public Info(@NotNull PsiElement elementAtPointer, @NotNull List<TextRange> ranges) {
myElementAtPointer = elementAtPointer;
myRanges = ranges;
}
@@ -387,10 +384,11 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
elementAtPointer.getTextOffset() + elementAtPointer.getTextLength())));
}
- boolean isSimilarTo(final Info that) {
+ boolean isSimilarTo(@NotNull Info that) {
return Comparing.equal(myElementAtPointer, that.myElementAtPointer) && myRanges.equals(that.myRanges);
}
+ @NotNull
public List<TextRange> getRanges() {
return myRanges;
}
@@ -398,11 +396,11 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
@NotNull
public abstract DocInfo getInfo();
- public abstract boolean isValid(Document document);
+ public abstract boolean isValid(@NotNull Document document);
public abstract void showDocInfo(@NotNull DocumentationManager docManager);
- protected boolean rangesAreCorrect(Document document) {
+ protected boolean rangesAreCorrect(@NotNull Document document) {
final TextRange docRange = new TextRange(0, document.getTextLength());
for (TextRange range : getRanges()) {
if (!docRange.contains(range)) return false;
@@ -412,7 +410,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
}
- private static void showDumbModeNotification(final Project project) {
+ private static void showDumbModeNotification(@NotNull Project project) {
DumbService.getInstance(project).showDumbModeNotification("Element information is not available during index update");
}
@@ -424,7 +422,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
myTargetElement = targetElement;
}
- public InfoSingle(final PsiReference ref, @NotNull final PsiElement targetElement) {
+ public InfoSingle(@NotNull PsiReference ref, @NotNull final PsiElement targetElement) {
super(ref.getElement(), ReferenceRange.getAbsoluteRanges(ref));
myTargetElement = targetElement;
}
@@ -432,21 +430,22 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
@Override
@NotNull
public DocInfo getInfo() {
- AccessToken token = ReadAction.start();
- try {
- return generateInfo(myTargetElement, myElementAtPointer);
- }
- catch (IndexNotReadyException e) {
- showDumbModeNotification(myTargetElement.getProject());
- return DocInfo.EMPTY;
- }
- finally {
- token.finish();
- }
+ return ApplicationManager.getApplication().runReadAction(new Computable<DocInfo>() {
+ @Override
+ public DocInfo compute() {
+ try {
+ return generateInfo(myTargetElement, myElementAtPointer);
+ }
+ catch (IndexNotReadyException e) {
+ showDumbModeNotification(myTargetElement.getProject());
+ return DocInfo.EMPTY;
+ }
+ }
+ });
}
@Override
- public boolean isValid(Document document) {
+ public boolean isValid(@NotNull Document document) {
if (!myTargetElement.isValid()) return false;
if (!myElementAtPointer.isValid()) return false;
if (myTargetElement == myElementAtPointer) return false;
@@ -462,7 +461,6 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
private static class InfoMultiple extends Info {
-
public InfoMultiple(@NotNull final PsiElement elementAtPointer) {
super(elementAtPointer);
}
@@ -478,7 +476,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
@Override
- public boolean isValid(Document document) {
+ public boolean isValid(@NotNull Document document) {
return rangesAreCorrect(document);
}
@@ -489,7 +487,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
@Nullable
- private Info getInfoAt(@NotNull Editor editor, PsiFile file, int offset, BrowseMode browseMode) {
+ private Info getInfoAt(@NotNull Editor editor, @NotNull PsiFile file, int offset, @NotNull BrowseMode browseMode) {
PsiElement targetElement = null;
if (browseMode == BrowseMode.TypeDeclaration) {
@@ -502,7 +500,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
else if (browseMode == BrowseMode.Declaration) {
final PsiReference ref = TargetElementUtilBase.findReference(editor, offset);
- final List<PsiElement> resolvedElements = ref != null ? resolve(ref) : Collections.<PsiElement>emptyList();
+ final List<PsiElement> resolvedElements = ref == null ? Collections.<PsiElement>emptyList() : resolve(ref);
final PsiElement resolvedElement = resolvedElements.size() == 1 ? resolvedElements.get(0) : null;
final PsiElement[] targetElements = GotoDeclarationAction.findTargetElementsNoVS(myProject, editor, offset, false);
@@ -572,7 +570,8 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
return null;
}
- private static List<PsiElement> resolve(final PsiReference ref) {
+ @NotNull
+ private static List<PsiElement> resolve(@NotNull PsiReference ref) {
// IDEA-56727 try resolve first as in GotoDeclarationAction
PsiElement resolvedElement = ref.resolve();
@@ -734,13 +733,13 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
private class TooltipProvider {
- private final Editor myEditor;
- private final LogicalPosition myPosition;
+ @NotNull private final Editor myEditor;
+ @NotNull private final LogicalPosition myPosition;
private BrowseMode myBrowseMode;
private boolean myDisposed;
private final ProgressIndicator myProgress = new ProgressIndicatorBase();
- TooltipProvider(Editor editor, LogicalPosition pos) {
+ TooltipProvider(@NotNull Editor editor, @NotNull LogicalPosition pos) {
myEditor = editor;
myPosition = pos;
}
@@ -754,7 +753,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
return myBrowseMode;
}
- void execute(BrowseMode browseMode) {
+ void execute(@NotNull BrowseMode browseMode) {
myBrowseMode = browseMode;
Document document = myEditor.getDocument();
@@ -785,16 +784,16 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
});
}
- private void doExecute(PsiFile file, int offset) {
+ private void doExecute(@NotNull PsiFile file, int offset) {
final Info info;
try {
info = getInfoAt(myEditor, file, offset, myBrowseMode);
+ if (info == null) return;
}
catch (IndexNotReadyException e) {
showDumbModeNotification(myProject);
return;
}
- if (info == null) return;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
@@ -805,7 +804,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
});
}
- private void showHint(Info info) {
+ private void showHint(@NotNull Info info) {
if (myDisposed || myEditor.isDisposed()) return;
Component internalComponent = myEditor.getContentComponent();
if (myHighlighter != null) {
@@ -856,10 +855,6 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
@Override
public void mouseClicked(MouseEvent e) {
- QuickDocInfoPane pane = quickDocPaneRef.get();
- if (pane != null) {
- pane.mouseClicked(e);
- }
}
};
Ref<Consumer<String>> newTextConsumerRef = new Ref<Consumer<String>>();
@@ -889,7 +884,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
showHint(hint);
}
- public void showHint(LightweightHint hint) {
+ public void showHint(@NotNull LightweightHint hint) {
final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
Point p = HintManagerImpl.getHintPosition(hint, myEditor, myPosition, HintManager.ABOVE);
hintManager.showEditorHint(hint, myEditor, p,
@@ -898,7 +893,8 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
}
- private HighlightersSet installHighlighterSet(Info info, Editor editor) {
+ @NotNull
+ private HighlightersSet installHighlighterSet(@NotNull Info info, @NotNull Editor editor) {
final JComponent internalComponent = editor.getContentComponent();
internalComponent.addKeyListener(myEditorKeyListener);
editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
@@ -922,12 +918,15 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
private class HighlightersSet {
- private final List<RangeHighlighter> myHighlighters;
- private final Editor myHighlighterView;
- private final Cursor myStoredCursor;
- private final Info myStoredInfo;
-
- private HighlightersSet(List<RangeHighlighter> highlighters, Editor highlighterView, Cursor storedCursor, Info storedInfo) {
+ @NotNull private final List<RangeHighlighter> myHighlighters;
+ @NotNull private final Editor myHighlighterView;
+ @NotNull private final Cursor myStoredCursor;
+ @NotNull private final Info myStoredInfo;
+
+ private HighlightersSet(@NotNull List<RangeHighlighter> highlighters,
+ @NotNull Editor highlighterView,
+ @NotNull Cursor storedCursor,
+ @NotNull Info storedInfo) {
myHighlighters = highlighters;
myHighlighterView = highlighterView;
myStoredCursor = storedCursor;
@@ -946,18 +945,18 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
myFileEditorManager.removeFileEditorManagerListener(myFileEditorManagerListener);
}
+ @NotNull
public Info getStoredInfo() {
return myStoredInfo;
}
}
private static class DocInfo {
-
public static final DocInfo EMPTY = new DocInfo(null, null, null);
- @Nullable public final String text;
+ @Nullable public final String text;
@Nullable public final DocumentationProvider docProvider;
- @Nullable public final PsiElement documentationAnchor;
+ @Nullable public final PsiElement documentationAnchor;
DocInfo(@Nullable String text, @Nullable DocumentationProvider provider, @Nullable PsiElement documentationAnchor) {
this.text = text;
@@ -967,7 +966,6 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
private class QuickDocInfoPane extends JBLayeredPane {
-
private static final int BUTTON_HGAP = 5;
@NotNull private final List<JComponent> myButtons = new ArrayList<JComponent>();
@@ -1073,11 +1071,6 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
processStateChangeIfNecessary(e.getLocationOnScreen(), false);
}
- public void mouseClicked(@NotNull MouseEvent e) {
- // TODO den check the processing.
- int i = 1;
- }
-
private void processStateChangeIfNecessary(@NotNull Point mouseScreenLocation, boolean mouseEntered) {
// Don't show 'view quick doc' buttons if docked quick doc control is already active.
if (myDocumentationManager.hasActiveDockedDocWindow()) {
@@ -1095,9 +1088,8 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
private class QuickDocHyperlinkListener implements HyperlinkListener {
-
@NotNull private final DocumentationProvider myProvider;
- @NotNull private final PsiElement myContext;
+ @NotNull private final PsiElement myContext;
QuickDocHyperlinkListener(@NotNull DocumentationProvider provider, @NotNull PsiElement context) {
myProvider = provider;
@@ -1111,11 +1103,11 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
}
String description = e.getDescription();
- if (StringUtil.isEmpty(description) || !description.startsWith(DocumentationManager.PSI_ELEMENT_PROTOCOL)) {
+ if (StringUtil.isEmpty(description) || !description.startsWith(DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL)) {
return;
}
- String elementName = e.getDescription().substring(DocumentationManager.PSI_ELEMENT_PROTOCOL.length());
+ String elementName = e.getDescription().substring(DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL.length());
final PsiElement targetElement = myProvider.getDocumentationElementForLink(PsiManager.getInstance(myProject), elementName, myContext);
if (targetElement != null) {
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/NextVariableAction.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/NextVariableAction.java
index 6605dacbc209..102626785a24 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/NextVariableAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/NextVariableAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -28,11 +28,13 @@ import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.codeInsight.template.impl.TemplateState;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class NextVariableAction extends EditorAction {
public NextVariableAction() {
@@ -42,16 +44,17 @@ public class NextVariableAction extends EditorAction {
private static class Handler extends EditorWriteActionHandler {
@Override
- public void executeWriteAction(Editor editor, DataContext dataContext) {
+ public void executeWriteAction(Editor editor, @Nullable Caret caret, DataContext dataContext) {
TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
+ assert templateState != null;
CommandProcessor.getInstance().setCurrentCommandName(CodeInsightBundle.message("template.next.variable.command"));
templateState.nextTab();
}
- }
- @Override
- public void update(Editor editor, Presentation presentation, DataContext dataContext) {
- TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
- presentation.setEnabled(templateState != null && !templateState.isFinished() && templateState.isToProcessTab());
+ @Override
+ protected boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
+ TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
+ return templateState != null && !templateState.isFinished() && templateState.isToProcessTab();
+ }
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/PreviousVariableAction.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/PreviousVariableAction.java
index bbb1f6a2bdf7..04a19bdd9b65 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/PreviousVariableAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/PreviousVariableAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -28,11 +28,12 @@ import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.codeInsight.template.impl.TemplateState;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
+import org.jetbrains.annotations.NotNull;
public class PreviousVariableAction extends EditorAction {
public PreviousVariableAction() {
@@ -42,16 +43,17 @@ public class PreviousVariableAction extends EditorAction {
private static class Handler extends EditorWriteActionHandler {
@Override
- public void executeWriteAction(Editor editor, DataContext dataContext) {
+ public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
final TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
+ assert templateState != null;
CommandProcessor.getInstance().setCurrentCommandName(CodeInsightBundle.message("template.previous.variable.command"));
templateState.previousTab();
}
- }
- @Override
- public void update(Editor editor, Presentation presentation, DataContext dataContext) {
- final TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
- presentation.setEnabled(templateState != null && !templateState.isFinished());
+ @Override
+ protected boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
+ final TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
+ return templateState != null && !templateState.isFinished();
+ }
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/EnterHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/EnterHandler.java
index d071b24416b3..de503d125f30 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/EnterHandler.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/EnterHandler.java
@@ -26,6 +26,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
+import org.jetbrains.annotations.NotNull;
public class EnterHandler extends BaseEnterHandler {
private final EditorActionHandler myOriginalHandler;
@@ -36,8 +37,8 @@ public class EnterHandler extends BaseEnterHandler {
}
@Override
- public boolean isEnabled(Editor editor, DataContext dataContext) {
- return myOriginalHandler.isEnabled(editor, dataContext);
+ public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
+ return myOriginalHandler.isEnabled(editor, caret, dataContext);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/ExpandLiveTemplateByTabAction.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/ExpandLiveTemplateByTabAction.java
index 13798639227f..326daba46e1e 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/ExpandLiveTemplateByTabAction.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/editorActions/ExpandLiveTemplateByTabAction.java
@@ -19,11 +19,13 @@ import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.codeInsight.template.impl.TemplateSettings;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
+import org.jetbrains.annotations.Nullable;
/**
* @author peter
@@ -32,7 +34,7 @@ public class ExpandLiveTemplateByTabAction extends EditorAction {
public ExpandLiveTemplateByTabAction() {
super(new EditorWriteActionHandler(true) {
@Override
- public void executeWriteAction(Editor editor, DataContext dataContext) {
+ public void executeWriteAction(Editor editor, @Nullable Caret caret, DataContext dataContext) {
Project project = editor.getProject();
assert project != null;
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/postfix/settings/PostfixTemplatesCheckboxTree.java b/platform/lang-impl/src/com/intellij/codeInsight/template/postfix/settings/PostfixTemplatesCheckboxTree.java
index b6a507ec67a2..68d5e7417d2a 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/postfix/settings/PostfixTemplatesCheckboxTree.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/postfix/settings/PostfixTemplatesCheckboxTree.java
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.template.postfix.settings;
import com.intellij.codeInsight.template.postfix.templates.PostfixTemplate;
import com.intellij.ide.util.treeView.TreeState;
+import com.intellij.lang.Language;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.CheckboxTree;
import com.intellij.ui.CheckedTreeNode;
@@ -35,7 +36,10 @@ import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
-import java.util.*;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Set;
public class PostfixTemplatesCheckboxTree extends CheckboxTree {
@@ -102,7 +106,7 @@ public class PostfixTemplatesCheckboxTree extends CheckboxTree {
getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
- public void valueChanged(TreeSelectionEvent event) {
+ public void valueChanged(@NotNull TreeSelectionEvent event) {
selectionChanged();
}
});
@@ -117,10 +121,13 @@ public class PostfixTemplatesCheckboxTree extends CheckboxTree {
public void initTree(@NotNull MultiMap<String, PostfixTemplate> langToTemplates) {
myRoot.removeAllChildren();
for (Map.Entry<String, Collection<PostfixTemplate>> entry : langToTemplates.entrySet()) {
- CheckedTreeNode langNode = new CheckedTreeNode(entry.getKey());
+ String id = entry.getKey();
+ Language language = Language.findLanguageByID(id);
+ String langName = language != null ? language.getDisplayName() : id;
+ CheckedTreeNode langNode = new CheckedTreeNode(langName);
myRoot.add(langNode);
for (PostfixTemplate template : entry.getValue()) {
- CheckedTreeNode templateNode = new PostfixTemplateCheckedTreeNode(template, entry.getKey());
+ CheckedTreeNode templateNode = new PostfixTemplateCheckedTreeNode(template, langName);
langNode.add(templateNode);
}
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
index f109d0dfe8dd..090d83389b6c 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
@@ -58,6 +58,7 @@ import com.intellij.psi.*;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.content.*;
import com.intellij.util.Processor;
import com.intellij.util.SequentialModalProgressTask;
@@ -354,7 +355,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
final FileViewProvider viewProvider = psiManager.findViewProvider(virtualFile);
final com.intellij.openapi.editor.Document document = viewProvider == null ? null : viewProvider.getDocument();
- if (document == null || virtualFile.getFileType().isBinary()) return; //do not inspect binary files
+ if (document == null || isBinary(file)) return; //do not inspect binary files
final LocalInspectionsPass pass = new LocalInspectionsPass(file, document, 0,
file.getTextLength(), LocalInspectionsPass.EMPTY_PRIORITY_RANGE, true,
HighlightInfoProcessor.getEmpty());
@@ -656,8 +657,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
scope.accept(new PsiElementVisitor() {
@Override
public void visitFile(PsiFile file) {
- final VirtualFile virtualFile = file.getVirtualFile();
- if (virtualFile == null || virtualFile.getFileType().isBinary()) return;
+ if (isBinary(file)) return;
for (final Tools tools : profile.getAllEnabledInspectionTools(project)) {
if (tools.getTool().getTool() instanceof CleanupLocalInspectionTool) {
final InspectionToolWrapper tool = tools.getEnabledTool(file);
@@ -724,4 +724,8 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
ApplicationManager.getApplication().invokeLater(runnable);
}
}
+
+ private static boolean isBinary(PsiFile file) {
+ return file instanceof PsiBinaryFile || file.getFileType().isBinary();
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java
index 527235b5166c..e239678af0ad 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/SeverityEditorDialog.java
@@ -37,6 +37,7 @@ import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.options.ShowSettingsUtil;
+import com.intellij.openapi.options.ex.ConfigurableWrapper;
import com.intellij.openapi.options.newEditor.OptionsEditor;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.InputValidator;
@@ -231,7 +232,8 @@ public class SeverityEditorDialog extends DialogWrapper {
final DataContext dataContext = DataManager.getInstance().getDataContext(myPanel);
final OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
if (optionsEditor != null) {
- final ColorAndFontOptions colorAndFontOptions = optionsEditor.findConfigurable(ColorAndFontOptions.class);
+ final ColorAndFontOptions colorAndFontOptions =
+ (ColorAndFontOptions)((ConfigurableWrapper)optionsEditor.findConfigurableById(ColorAndFontOptions.ID)).getConfigurable();
assert colorAndFontOptions != null;
final SearchableConfigurable javaPage = colorAndFontOptions.findSubConfigurable(InspectionColorSettingsPage.class);
LOG.assertTrue(javaPage != null);
diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleManagerBase.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleManagerBase.java
index 026de56c9491..cb034daeaf5a 100644
--- a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleManagerBase.java
+++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleManagerBase.java
@@ -52,7 +52,9 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos
/**
* @deprecated use {@link #LogConsoleManagerBase(com.intellij.openapi.project.Project, com.intellij.psi.search.GlobalSearchScope)}
+ * to remove in IDEA 15
*/
+ @SuppressWarnings("UnusedDeclaration")
protected LogConsoleManagerBase(@NotNull Project project) {
this(project, GlobalSearchScope.allScope(project));
}
@@ -66,8 +68,8 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos
return myProject;
}
- public void setEnvironment(@NotNull final ExecutionEnvironment env) {
- myEnvironment = env;
+ public void setEnvironment(@NotNull ExecutionEnvironment environment) {
+ myEnvironment = environment;
}
protected final ExecutionEnvironment getEnvironment() {
diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogFilesManager.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogFilesManager.java
index 05abeb4b7790..a581a15ed6b8 100644
--- a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogFilesManager.java
+++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogFilesManager.java
@@ -23,9 +23,11 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Conditions;
import com.intellij.openapi.util.Disposer;
import com.intellij.util.Alarm;
import gnu.trove.THashSet;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.io.File;
@@ -36,18 +38,17 @@ import java.util.*;
* Date: 01-Feb-2006
*/
public class LogFilesManager implements Disposable {
- public static final Logger LOG = Logger.getInstance("#" + LogFilesManager.class.getName());
+ public static final Logger LOG = Logger.getInstance(LogFilesManager.class);
private static final int UPDATE_INTERVAL = 500;
private final Map<LogFileOptions, Set<String>> myLogFileManagerMap = new LinkedHashMap<LogFileOptions, Set<String>>();
- private final Map<LogFileOptions, RunConfigurationBase> myLogFileToConfiguration = new HashMap<LogFileOptions, RunConfigurationBase>();
private final Runnable myUpdateRequest;
private final LogConsoleManager myManager;
private final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this);
private boolean myDisposed;
- public LogFilesManager(final Project project, LogConsoleManager manager, Disposable parentDisposable) {
+ public LogFilesManager(@NotNull final Project project, LogConsoleManager manager, Disposable parentDisposable) {
myManager = manager;
Disposer.register(parentDisposable, this);
@@ -86,12 +87,11 @@ public class LogFilesManager implements Disposable {
};
}
- public void registerFileMatcher(final RunConfigurationBase runConfiguration) {
+ public void registerFileMatcher(@NotNull RunConfigurationBase runConfiguration) {
final ArrayList<LogFileOptions> logFiles = runConfiguration.getAllLogFiles();
for (LogFileOptions logFile : logFiles) {
if (logFile.isEnabled()) {
myLogFileManagerMap.put(logFile, logFile.getPaths());
- myLogFileToConfiguration.put(logFile, runConfiguration);
}
}
Alarm updateAlarm = myUpdateAlarm;
@@ -108,11 +108,11 @@ public class LogFilesManager implements Disposable {
}
}
- public void initLogConsoles(RunConfigurationBase base, ProcessHandler startedProcess) {
- final ArrayList<LogFileOptions> logFiles = base.getAllLogFiles();
+ public void initLogConsoles(@NotNull RunConfigurationBase base, ProcessHandler startedProcess) {
+ List<LogFileOptions> logFiles = base.getAllLogFiles();
for (LogFileOptions logFile : logFiles) {
if (logFile.isEnabled()) {
- addConfigurationConsoles(logFile, Condition.TRUE, logFile.getPaths());
+ addConfigurationConsoles(logFile, Conditions.<String>alwaysTrue(), logFile.getPaths());
}
}
base.createAdditionalTabComponents(myManager, startedProcess);
diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/OutputFileUtil.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/OutputFileUtil.java
index fc7e6a342406..1f82f25307a3 100644
--- a/platform/lang-impl/src/com/intellij/diagnostic/logging/OutputFileUtil.java
+++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/OutputFileUtil.java
@@ -34,6 +34,7 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -51,41 +52,43 @@ public class OutputFileUtil {
private OutputFileUtil() {
}
- public static void attachDumpListener(final RunConfigurationBase base, final ProcessHandler startedProcess, ExecutionConsole console) {
- if (base.isSaveOutputToFile()) {
- final String outputFilePath = base.getOutputFilePath();
- if (outputFilePath != null) {
- final String filePath = FileUtil.toSystemDependentName(outputFilePath);
- startedProcess.addProcessListener(new ProcessAdapter() {
- private PrintStream myOutput;
- @Override
- public void onTextAvailable(ProcessEvent event, Key outputType) {
- if (base.collectOutputFromProcessHandler() && myOutput != null && outputType != ProcessOutputTypes.SYSTEM) {
- myOutput.print(event.getText());
- }
+ public static void attachDumpListener(@NotNull final RunConfigurationBase configuration, @NotNull final ProcessHandler startedProcess, @Nullable ExecutionConsole console) {
+ if (!configuration.isSaveOutputToFile()) {
+ return;
+ }
+
+ String outputFilePath = configuration.getOutputFilePath();
+ if (outputFilePath != null) {
+ final String filePath = FileUtil.toSystemDependentName(outputFilePath);
+ startedProcess.addProcessListener(new ProcessAdapter() {
+ private PrintStream myOutput;
+ @Override
+ public void onTextAvailable(ProcessEvent event, Key outputType) {
+ if (configuration.collectOutputFromProcessHandler() && myOutput != null && outputType != ProcessOutputTypes.SYSTEM) {
+ myOutput.print(event.getText());
}
+ }
- @Override
- public void startNotified(ProcessEvent event) {
- try {
- myOutput = new PrintStream(new FileOutputStream(new File(filePath)));
- }
- catch (FileNotFoundException ignored) {
- }
- startedProcess.notifyTextAvailable(CONSOLE_OUTPUT_FILE_MESSAGE + filePath + "\n", ProcessOutputTypes.SYSTEM);
+ @Override
+ public void startNotified(ProcessEvent event) {
+ try {
+ myOutput = new PrintStream(new FileOutputStream(new File(filePath)));
+ }
+ catch (FileNotFoundException ignored) {
}
+ startedProcess.notifyTextAvailable(CONSOLE_OUTPUT_FILE_MESSAGE + filePath + "\n", ProcessOutputTypes.SYSTEM);
+ }
- @Override
- public void processTerminated(ProcessEvent event) {
- startedProcess.removeProcessListener(this);
- if (myOutput != null) {
- myOutput.close();
- }
+ @Override
+ public void processTerminated(ProcessEvent event) {
+ startedProcess.removeProcessListener(this);
+ if (myOutput != null) {
+ myOutput.close();
}
- });
- if (console instanceof ConsoleView) {
- ((ConsoleView)console).addMessageFilter(new ShowOutputFileFilter());
}
+ });
+ if (console instanceof ConsoleView) {
+ ((ConsoleView)console).addMessageFilter(new ShowOutputFileFilter());
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/ExecutionHelper.java b/platform/lang-impl/src/com/intellij/execution/ExecutionHelper.java
index c4b5eaf71daf..cce4fc571abb 100644
--- a/platform/lang-impl/src/com/intellij/execution/ExecutionHelper.java
+++ b/platform/lang-impl/src/com/intellij/execution/ExecutionHelper.java
@@ -21,6 +21,7 @@ import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.process.ProcessOutput;
import com.intellij.execution.ui.RunContentDescriptor;
+import com.intellij.execution.ui.RunContentManager;
import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.ApplicationManager;
@@ -44,12 +45,8 @@ import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.components.JBList;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
-import com.intellij.ui.content.ContentManager;
import com.intellij.ui.content.MessageView;
-import com.intellij.util.ArrayUtil;
-import com.intellij.util.Consumer;
-import com.intellij.util.Function;
-import com.intellij.util.NotNullFunction;
+import com.intellij.util.*;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.ErrorTreeView;
@@ -170,10 +167,8 @@ public class ExecutionHelper {
openMessagesView(errorTreeView, myProject, tabDisplayName);
}
catch (NullPointerException e) {
- final StringBuilder builder = new StringBuilder();
- builder.append(stdOutTitle).append("\n").append(stdout != null ? stdout : "<empty>").append("\n");
- builder.append(stderrTitle).append("\n").append(stderr != null ? stderr : "<empty>");
- Messages.showErrorDialog(builder.toString(), "Process Output");
+ Messages.showErrorDialog(stdOutTitle + "\n" + (stdout != null ? stdout : "<empty>") + "\n" + stderrTitle + "\n"
+ + (stderr != null ? stderr : "<empty>"), "Process Output");
return;
}
@@ -267,13 +262,12 @@ public class ExecutionHelper {
});
}
- public static Collection<RunContentDescriptor> findRunningConsole(final Project project,
- @NotNull final NotNullFunction<RunContentDescriptor, Boolean> descriptorMatcher) {
- final ExecutionManager executionManager = ExecutionManager.getInstance(project);
-
- final RunContentDescriptor selectedContent = executionManager.getContentManager().getSelectedContent();
+ public static Collection<RunContentDescriptor> findRunningConsole(@NotNull Project project,
+ @NotNull NotNullFunction<RunContentDescriptor, Boolean> descriptorMatcher) {
+ RunContentManager contentManager = ExecutionManager.getInstance(project).getContentManager();
+ final RunContentDescriptor selectedContent = contentManager.getSelectedContent();
if (selectedContent != null) {
- final ToolWindow toolWindow = ExecutionManager.getInstance(project).getContentManager().getToolWindowByDescriptor(selectedContent);
+ final ToolWindow toolWindow = contentManager.getToolWindowByDescriptor(selectedContent);
if (toolWindow != null && toolWindow.isVisible()) {
if (descriptorMatcher.fun(selectedContent)) {
return Collections.singletonList(selectedContent);
@@ -282,7 +276,7 @@ public class ExecutionHelper {
}
final ArrayList<RunContentDescriptor> result = ContainerUtil.newArrayList();
- for (RunContentDescriptor runContentDescriptor : executionManager.getContentManager().getAllDescriptors()) {
+ for (RunContentDescriptor runContentDescriptor : contentManager.getAllDescriptors()) {
if (descriptorMatcher.fun(runContentDescriptor)) {
result.add(runContentDescriptor);
}
@@ -290,11 +284,10 @@ public class ExecutionHelper {
return result;
}
- public static List<RunContentDescriptor> collectConsolesByDisplayName(final Project project,
+ public static List<RunContentDescriptor> collectConsolesByDisplayName(@NotNull Project project,
@NotNull NotNullFunction<String, Boolean> titleMatcher) {
- List<RunContentDescriptor> result = ContainerUtil.newArrayList();
- final ExecutionManager executionManager = ExecutionManager.getInstance(project);
- for (RunContentDescriptor runContentDescriptor : executionManager.getContentManager().getAllDescriptors()) {
+ List<RunContentDescriptor> result = new SmartList<RunContentDescriptor>();
+ for (RunContentDescriptor runContentDescriptor : ExecutionManager.getInstance(project).getContentManager().getAllDescriptors()) {
if (titleMatcher.fun(runContentDescriptor.getDisplayName())) {
result.add(runContentDescriptor);
}
@@ -343,21 +336,18 @@ public class ExecutionHelper {
}
}
- private static void descriptorToFront(final Project project, final RunContentDescriptor descriptor) {
+ private static void descriptorToFront(@NotNull final Project project, @NotNull final RunContentDescriptor descriptor) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- final ToolWindow toolWindow = ExecutionManager.getInstance(project).getContentManager().getToolWindowByDescriptor(descriptor);
-
+ ToolWindow toolWindow = ExecutionManager.getInstance(project).getContentManager().getToolWindowByDescriptor(descriptor);
if (toolWindow != null) {
toolWindow.show(null);
-
- final ContentManager contentManager = toolWindow.getContentManager();
-
- contentManager.setSelectedContent(descriptor.getAttachedContent());
+ //noinspection ConstantConditions
+ toolWindow.getContentManager().setSelectedContent(descriptor.getAttachedContent());
}
}
- });
+ }, project.getDisposed());
}
public static class ErrorViewPanel extends NewErrorTreeViewPanel {
@@ -384,8 +374,6 @@ public class ExecutionHelper {
@NotNull final ExecutionMode mode,
@NotNull final String presentableCmdline) {
final String title = mode.getTitle() != null ? mode.getTitle() : "Please wait...";
- assert title != null;
-
final Runnable process;
if (mode.cancelable()) {
process = createCancelableExecutionProcess(processHandler, mode.shouldCancelFun());
@@ -400,7 +388,7 @@ public class ExecutionHelper {
};
}
else {
- process = createTimelimitedExecutionProcess(processHandler, mode.getTimeout(), presentableCmdline);
+ process = createTimeLimitedExecutionProcess(processHandler, mode.getTimeout(), presentableCmdline);
}
}
if (mode.withModalProgress()) {
@@ -447,7 +435,7 @@ public class ExecutionHelper {
private final Runnable myCancelListener = new Runnable() {
@Override
public void run() {
- for (; ; ) {
+ while (true) {
if ((myProgressIndicator != null && (myProgressIndicator.isCanceled()
|| !myProgressIndicator.isRunning()))
|| (cancelableFun != null && cancelableFun.fun(null).booleanValue())
@@ -493,7 +481,7 @@ public class ExecutionHelper {
};
}
- private static Runnable createTimelimitedExecutionProcess(final ProcessHandler processHandler,
+ private static Runnable createTimeLimitedExecutionProcess(final ProcessHandler processHandler,
final int timeout,
@NotNull final String presentableCmdline) {
return new Runnable() {
diff --git a/platform/lang-impl/src/com/intellij/execution/ExecutionTargetManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/ExecutionTargetManagerImpl.java
index d0170430613e..e4d7b9cff49e 100644
--- a/platform/lang-impl/src/com/intellij/execution/ExecutionTargetManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/ExecutionTargetManagerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,9 +15,11 @@
*/
package com.intellij.execution;
-import com.intellij.execution.impl.RunManagerImpl;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.components.*;
+import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.util.containers.ContainerUtil;
@@ -29,25 +31,30 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
-@State(name = "ExecutionTargetManager", storages = {@Storage(file = StoragePathMacros.WORKSPACE_FILE, scheme = StorageScheme.DEFAULT)})
-public class ExecutionTargetManagerImpl extends ExecutionTargetManager implements ProjectComponent, PersistentStateComponent<Element> {
+@State(name = "ExecutionTargetManager", storages = {@Storage(file = StoragePathMacros.WORKSPACE_FILE)})
+public class ExecutionTargetManagerImpl extends ExecutionTargetManager implements PersistentStateComponent<Element> {
@NotNull private final Project myProject;
@NotNull private final Object myActiveTargetLock = new Object();
@Nullable private ExecutionTarget myActiveTarget;
@Nullable private String mySavedActiveTargetId;
- public ExecutionTargetManagerImpl(@NotNull Project project) {
+ public ExecutionTargetManagerImpl(@NotNull Project project, @NotNull RunManager runManager) {
myProject = project;
- }
- @Override
- public void projectOpened() {
- }
+ ((RunManagerEx)runManager).addRunManagerListener(new RunManagerAdapter() {
+ @Override
+ public void runConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
+ if (settings == RunManager.getInstance(myProject).getSelectedConfiguration()) {
+ updateActiveTarget(settings);
+ }
+ }
- @Override
- public void projectClosed() {
+ @Override
+ public void runConfigurationSelected() {
+ updateActiveTarget();
+ }
+ });
}
@Override
@@ -70,33 +77,6 @@ public class ExecutionTargetManagerImpl extends ExecutionTargetManager implement
}
}
- @Override
- public void initComponent() {
- RunManagerImpl.getInstanceImpl(myProject).addRunManagerListener(new RunManagerAdapter() {
- @Override
- public void runConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
- if (settings == RunManager.getInstance(myProject).getSelectedConfiguration()) {
- updateActiveTarget(settings);
- }
- }
-
- @Override
- public void runConfigurationSelected() {
- updateActiveTarget();
- }
- });
- }
-
- @Override
- public void disposeComponent() {
- }
-
- @NotNull
- @Override
- public String getComponentName() {
- return ExecutionTargetManager.class.getName();
- }
-
@NotNull
@Override
public ExecutionTarget getActiveTarget() {
@@ -128,7 +108,7 @@ public class ExecutionTargetManagerImpl extends ExecutionTargetManager implement
private void updateActiveTarget(@Nullable RunnerAndConfigurationSettings settings, @Nullable ExecutionTarget toSelect) {
List<ExecutionTarget> suitable = settings == null ? Collections.singletonList(DefaultExecutionTarget.INSTANCE)
: getTargetsFor(settings);
- ExecutionTarget toNotify = null;
+ ExecutionTarget toNotify;
synchronized (myActiveTargetLock) {
if (toSelect == null) toSelect = myActiveTarget;
diff --git a/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java b/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java
index bd9f5014fabb..44af49d36cdd 100644
--- a/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/ExecutorRegistryImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.execution;
import com.intellij.execution.actions.RunContextAction;
@@ -35,12 +34,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
-/**
- * @author spleaner
- */
public class ExecutorRegistryImpl extends ExecutorRegistry {
- private static final Logger LOG = Logger.getInstance("#com.intellij.execution.ExecutorRegistryImpl");
-
+ private static final Logger LOG = Logger.getInstance(ExecutorRegistryImpl.class);
@NonNls public static final String RUNNERS_GROUP = "RunnerActions";
@NonNls public static final String RUN_CONTEXT_GROUP = "RunContextGroup";
@@ -84,8 +79,7 @@ public class ExecutorRegistryImpl extends ExecutorRegistry {
action = anAction;
}
- final DefaultActionGroup group = (DefaultActionGroup) myActionManager.getAction(groupId);
- group.add(action);
+ ((DefaultActionGroup)myActionManager.getAction(groupId)).add(action);
}
synchronized void deinitExecutor(@NotNull final Executor executor) {
@@ -135,18 +129,18 @@ public class ExecutorRegistryImpl extends ExecutorRegistry {
final MessageBusConnection connect = project.getMessageBus().connect(project);
connect.subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionAdapter(){
@Override
- public void processStartScheduled(String executorId, ExecutionEnvironment env) {
- myInProgress.add(createExecutionId(executorId, env, project));
+ public void processStartScheduled(String executorId, ExecutionEnvironment environment) {
+ myInProgress.add(createExecutionId(executorId, environment));
}
@Override
- public void processNotStarted(String executorId, @NotNull ExecutionEnvironment env) {
- myInProgress.remove(createExecutionId(executorId, env, project));
+ public void processNotStarted(String executorId, @NotNull ExecutionEnvironment environment) {
+ myInProgress.remove(createExecutionId(executorId, environment));
}
@Override
- public void processStarted(String executorId, @NotNull ExecutionEnvironment env, @NotNull ProcessHandler handler) {
- myInProgress.remove(createExecutionId(executorId, env, project));
+ public void processStarted(String executorId, @NotNull ExecutionEnvironment environment, @NotNull ProcessHandler handler) {
+ myInProgress.remove(createExecutionId(executorId, environment));
}
});
}
@@ -172,26 +166,29 @@ public class ExecutorRegistryImpl extends ExecutorRegistry {
}
}
- private static Trinity<Project, String, String> createExecutionId(String executorId, ExecutionEnvironment env, Project project) {
- return new Trinity<Project, String, String>(project, executorId, env.getRunnerId());
+ @NotNull
+ private static Trinity<Project, String, String> createExecutionId(String executorId, @NotNull ExecutionEnvironment environment) {
+ return Trinity.create(environment.getProject(), executorId, environment.getRunner().getRunnerId());
}
@Override
public boolean isStarting(Project project, final String executorId, final String runnerId) {
- return myInProgress.contains(new Trinity<Project, String, String>(project, executorId, runnerId));
+ return myInProgress.contains(Trinity.create(project, executorId, runnerId));
+ }
+
+ @Override
+ public boolean isStarting(@NotNull ExecutionEnvironment environment) {
+ return isStarting(environment.getProject(), environment.getExecutor().getId(), environment.getRunner().getRunnerId());
}
@Override
public synchronized void disposeComponent() {
- if (myExecutors.size() > 0) {
- List<Executor> executors = new ArrayList<Executor>(myExecutors);
- for (Executor executor : executors) {
+ if (!myExecutors.isEmpty()) {
+ for (Executor executor : new ArrayList<Executor>(myExecutors)) {
deinitExecutor(executor);
}
-
- myExecutors = null;
}
-
+ myExecutors = null;
myActionManager = null;
}
@@ -206,7 +203,7 @@ public class ExecutorRegistryImpl extends ExecutorRegistry {
@Override
public void update(final AnActionEvent e) {
final Presentation presentation = e.getPresentation();
- final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
+ final Project project = e.getProject();
if (project == null || !project.isInitialized() || project.isDisposed() || DumbService.getInstance(project).isDumb()) {
presentation.setEnabled(false);
@@ -222,7 +219,7 @@ public class ExecutorRegistryImpl extends ExecutorRegistry {
ExecutionTarget target = ExecutionTargetManager.getActiveTarget(project);
enabled = ExecutionTargetManager.canRun(selectedConfiguration, target)
- && runner != null && !isStarting(project, myExecutor.getId(), runner.getRunnerId());
+ && runner != null && !isStarting(project, myExecutor.getId(), runner.getRunnerId());
if (enabled) {
presentation.setDescription(myExecutor.getDescription());
@@ -244,25 +241,17 @@ public class ExecutorRegistryImpl extends ExecutorRegistry {
@Override
public void actionPerformed(final AnActionEvent e) {
- final DataContext dataContext = e.getDataContext();
final Project project = e.getProject();
if (project == null || project.isDisposed()) {
return;
}
- final RunnerAndConfigurationSettings configuration = getConfiguration(project);
- if (configuration == null) {
- return;
- }
- ExecutionTarget target = ExecutionTargetManager.getActiveTarget(project);
- ExecutionEnvironmentBuilder builder = new ExecutionEnvironmentBuilder(project, myExecutor);
- ProgramRunner runner = ProgramRunnerUtil.getRunner(myExecutor.getId(), configuration);
- if (runner == null) {
+ RunnerAndConfigurationSettings configuration = getConfiguration(project);
+ ExecutionEnvironmentBuilder builder = configuration == null ? null : ExecutionEnvironmentBuilder.createOrNull(myExecutor, configuration);
+ if (builder == null) {
return;
}
-
- builder.setDataContext(dataContext).setTarget(target).setRunnerAndSettings(runner, configuration);
- ExecutionManager.getInstance(project).restartRunProfile(runner, builder.build(), null);
+ ExecutionManager.getInstance(project).restartRunProfile(builder.activeTarget().dataContext(e.getDataContext()).build());
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java b/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java
index b27a939dd57c..5ad5f73b954a 100644
--- a/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java
+++ b/platform/lang-impl/src/com/intellij/execution/ProgramRunnerUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,23 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.execution;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.configurations.RunConfiguration;
-import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.impl.RunDialog;
import com.intellij.execution.impl.RunManagerImpl;
+import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.icons.AllIcons;
import com.intellij.internal.statistic.UsageTrigger;
import com.intellij.internal.statistic.beans.ConvertUsagesUtil;
-import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
@@ -41,11 +38,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-/**
- * @author spleaner
- */
public class ProgramRunnerUtil {
- private static final Logger LOG = Logger.getInstance("#com.intellij.execution.ProgramRunnerUtil");
+ private static final Logger LOG = Logger.getInstance(ProgramRunnerUtil.class);
private ProgramRunnerUtil() {
}
@@ -55,102 +49,82 @@ public class ProgramRunnerUtil {
return configuration == null ? null : RunnerRegistry.getInstance().getRunner(executorId, configuration.getConfiguration());
}
- public static void executeConfiguration(@NotNull final Project project,
- @Nullable final DataContext context,
- @NotNull final RunnerAndConfigurationSettings configuration,
- @NotNull final Executor executor,
- @NotNull final ExecutionTarget target,
- @Nullable RunContentDescriptor contentToReuse,
- final boolean showSettings) {
- ProgramRunner runner = getRunner(executor.getId(), configuration);
- if (runner == null) {
- LOG.error("Runner MUST not be null! Cannot find runner for " +
- executor.getId() +
- " and " +
- configuration.getConfiguration().getFactory().getName());
- return;
- }
- executeConfiguration(project, context, configuration, executor, target, contentToReuse, showSettings, runner, null, true);
- }
-
- public static void executeConfiguration(Project project,
- @Nullable DataContext context,
- @Nullable RunnerAndConfigurationSettings configuration,
- Executor executor,
- ExecutionTarget target,
- RunContentDescriptor contentToReuse,
- boolean showSettings,
- @NotNull ProgramRunner runner,
- @Nullable RunProfile runProfile,
- boolean assignNewId) {
- if (ExecutorRegistry.getInstance().isStarting(project, executor.getId(), runner.getRunnerId())) {
- return;
- }
-
- if (configuration != null && !ExecutionTargetManager.canRun(configuration, target)) {
- ExecutionUtil.handleExecutionError(
- project, executor.getToolWindowId(), configuration.getConfiguration(),
- new ExecutionException(StringUtil.escapeXml("Cannot run '" + configuration.getName() + "' on '" + target.getDisplayName() + "'")));
+ public static void executeConfiguration(@NotNull ExecutionEnvironment environment, boolean showSettings, boolean assignNewId) {
+ if (ExecutorRegistry.getInstance().isStarting(environment)) {
return;
}
- if (configuration != null &&
- (!RunManagerImpl.canRunConfiguration(configuration, executor) || (showSettings && configuration.isEditBeforeRun()))) {
- if (!RunDialog.editConfiguration(project, configuration, "Edit configuration", executor)) {
+ RunnerAndConfigurationSettings runnerAndConfigurationSettings = environment.getRunnerAndConfigurationSettings();
+ if (runnerAndConfigurationSettings != null) {
+ if (!ExecutionTargetManager.canRun(environment)) {
+ ExecutionUtil.handleExecutionError(environment, new ExecutionException(
+ StringUtil.escapeXml("Cannot run '" + environment.getRunProfile().getName() + "' on '" + environment.getExecutionTarget().getDisplayName() + "'")));
return;
}
- while (!RunManagerImpl.canRunConfiguration(configuration, executor)) {
- if (Messages.YES == Messages
- .showYesNoDialog(project, "Configuration is still incorrect. Do you want to edit it again?", "Change Configuration Settings",
- "Edit", "Continue Anyway", Messages.getErrorIcon())) {
- if (!RunDialog.editConfiguration(project, configuration, "Edit configuration", executor)) {
- return;
- }
+ if (!RunManagerImpl.canRunConfiguration(environment) || (showSettings && runnerAndConfigurationSettings.isEditBeforeRun())) {
+ if (!RunDialog.editConfiguration(environment, "Edit configuration")) {
+ return;
}
- else {
- break;
+
+ while (!RunManagerImpl.canRunConfiguration(environment)) {
+ if (Messages.YES == Messages
+ .showYesNoDialog(environment.getProject(), "Configuration is still incorrect. Do you want to edit it again?", "Change Configuration Settings",
+ "Edit", "Continue Anyway", Messages.getErrorIcon())) {
+ if (!RunDialog.editConfiguration(environment, "Edit configuration")) {
+ return;
+ }
+ }
+ else {
+ break;
+ }
}
}
- }
- final ConfigurationType configurationType = configuration != null ? configuration.getType() : null;
- if (configurationType != null) {
- UsageTrigger.trigger("execute." + ConvertUsagesUtil.ensureProperKey(configurationType.getId()) + "." + executor.getId());
+ ConfigurationType configurationType = runnerAndConfigurationSettings.getType();
+ if (configurationType != null) {
+ UsageTrigger.trigger("execute." + ConvertUsagesUtil.ensureProperKey(configurationType.getId()) + "." + environment.getExecutor().getId());
+ }
}
try {
- ExecutionEnvironmentBuilder builder =
- new ExecutionEnvironmentBuilder(project, executor);
- if (configuration != null) {
- builder.setRunnerAndSettings(runner, configuration);
- }
- else {
- builder.setRunnerId(runner.getRunnerId());
- }
- builder.setTarget(target).setContentToReuse(contentToReuse).setDataContext(context);
if (assignNewId) {
- builder.assignNewId();
- }
- if (runProfile != null) {
- builder.setRunProfile(runProfile);
+ environment.assignNewExecutionId();
}
- runner.execute(builder.build());
+ environment.getRunner().execute(environment);
}
catch (ExecutionException e) {
- String name = configuration != null ? configuration.getName() : null;
- if (name == null && runProfile != null) name = runProfile.getName();
- if (name == null && contentToReuse != null) name = contentToReuse.getDisplayName();
- if (name == null) name = "<Unknown>";
- ExecutionUtil.handleExecutionError(project, executor.getToolWindowId(), name, e);
+ String name = runnerAndConfigurationSettings != null ? runnerAndConfigurationSettings.getName() : null;
+ if (name == null) {
+ name = environment.getRunProfile().getName();
+ }
+ if (name == null && environment.getContentToReuse() != null) {
+ name = environment.getContentToReuse().getDisplayName();
+ }
+ if (name == null) {
+ name = "<Unknown>";
+ }
+ ExecutionUtil.handleExecutionError(environment.getProject(), environment.getExecutor().getToolWindowId(), name, e);
}
}
-
public static void executeConfiguration(@NotNull Project project,
@NotNull RunnerAndConfigurationSettings configuration,
@NotNull Executor executor) {
- executeConfiguration(project, null, configuration, executor, ExecutionTargetManager.getActiveTarget(project), null, true);
+ ExecutionEnvironmentBuilder builder;
+ try {
+ builder = ExecutionEnvironmentBuilder.create(executor, configuration);
+ }
+ catch (ExecutionException e) {
+ LOG.error(e);
+ return;
+ }
+
+ executeConfiguration(builder
+ .contentToReuse(null)
+ .dataContext(null)
+ .activeTarget()
+ .build(), true, true);
}
public static Icon getConfigurationIcon(final RunnerAndConfigurationSettings settings,
diff --git a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java
index 1a0235ac9d46..a4764dae0036 100644
--- a/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java
+++ b/platform/lang-impl/src/com/intellij/execution/actions/ChooseRunConfigurationPopup.java
@@ -22,8 +22,8 @@ import com.intellij.execution.configurations.UnknownConfigurationType;
import com.intellij.execution.impl.EditConfigurationsDialog;
import com.intellij.execution.impl.RunDialog;
import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
+import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
import com.intellij.ide.util.PropertiesComponent;
@@ -193,10 +193,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
}
private void updatePresentation() {
- final Executor executor = getExecutor();
- if (executor != null) {
- myPopup.setCaption(executor.getActionName());
- }
+ myPopup.setCaption(getExecutor().getActionName());
}
static void execute(final ItemWrapper itemWrapper, final Executor executor) {
@@ -218,12 +215,10 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
void editConfiguration(@NotNull final Project project, @NotNull final RunnerAndConfigurationSettings configuration) {
final Executor executor = getExecutor();
- assert executor != null;
-
PropertiesComponent.getInstance().setValue("run.configuration.edit.ad", Boolean.toString(true));
if (RunDialog.editConfiguration(project, configuration, "Edit configuration settings", executor)) {
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(configuration);
- doRunConfiguration(configuration, executor, project);
+ ExecutionUtil.runConfiguration(configuration, executor);
}
}
@@ -379,7 +374,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
public void perform(@NotNull Project project, @NotNull Executor executor, @NotNull DataContext context) {
RunnerAndConfigurationSettings config = getValue();
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(config);
- doRunConfiguration(config, executor, project);
+ ExecutionUtil.runConfiguration(config, executor);
}
@Override
@@ -404,7 +399,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
@Override
public boolean available(Executor executor) {
- return null != ProgramRunnerUtil.getRunner(executor.getId(), getValue());
+ return ProgramRunnerUtil.getRunner(executor.getId(), getValue()) != null;
}
@Override
@@ -462,7 +457,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
final List<ItemWrapper> configurations = getValues();
final int index = configurations.indexOf(value);
if (index > 0 && index <= configurations.size() - 1) {
- final ItemWrapper aboveConfiguration = index == 0 ? null : configurations.get(index - 1);
+ final ItemWrapper aboveConfiguration = configurations.get(index - 1);
if (aboveConfiguration != null && aboveConfiguration.isDynamic() != value.isDynamic()) {
return new ListSeparator();
@@ -508,18 +503,15 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
}
}
- final Executor executor = myAction.getExecutor();
- assert executor != null;
-
- if (finalChoice && wrapper.available(executor)) {
+ if (finalChoice && wrapper.available(myAction.getExecutor())) {
return doFinalStep(new Runnable() {
@Override
public void run() {
- if (executor == myAction.myAlternativeExecutor) {
+ if (myAction.getExecutor() == myAction.myAlternativeExecutor) {
PropertiesComponent.getInstance().setValue(myAction.myAddKey, Boolean.toString(true));
}
- wrapper.perform(myProject, executor, DataManager.getInstance().getDataContext());
+ wrapper.perform(myProject, myAction.getExecutor(), DataManager.getInstance().getDataContext());
}
});
}
@@ -545,14 +537,6 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
}
}
- private static void doRunConfiguration(RunnerAndConfigurationSettings configuration, Executor executor, Project project) {
- ExecutionManager.getInstance(project).restartRunProfile(project,
- executor,
- ExecutionTargetManager.getActiveTarget(project),
- configuration,
- (RunContentDescriptor)null);
- }
-
private static final class ConfigurationActionsStep extends BaseListPopupStep<ActionWrapper> {
@NotNull private final RunnerAndConfigurationSettings mySettings;
@@ -600,11 +584,13 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
@Override
public void perform() {
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
- if (dynamic) manager.setTemporaryConfiguration(settings);
+ if (dynamic) {
+ manager.setTemporaryConfiguration(settings);
+ }
manager.setSelectedConfiguration(settings);
ExecutionTargetManager.setActiveTarget(project, eachTarget);
- doRunConfiguration(settings, action.getExecutor(), project);
+ ExecutionUtil.runConfiguration(settings, action.getExecutor());
}
});
}
@@ -617,9 +603,11 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
@Override
public void perform() {
final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
- if (dynamic) manager.setTemporaryConfiguration(settings);
+ if (dynamic) {
+ manager.setTemporaryConfiguration(settings);
+ }
manager.setSelectedConfiguration(settings);
- doRunConfiguration(settings, executor, project);
+ ExecutionUtil.runConfiguration(settings, executor);
}
});
isFirst = false;
@@ -857,7 +845,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
RunnerAndConfigurationSettings selectedConfiguration = RunManagerEx.getInstanceEx(project).getSelectedConfiguration();
if (myConfigurations.contains(selectedConfiguration)) {
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(selectedConfiguration);
- doRunConfiguration(selectedConfiguration, myExecutorProvider.getExecutor(), project);
+ ExecutionUtil.runConfiguration(selectedConfiguration, myExecutorProvider.getExecutor());
}
}
@@ -906,8 +894,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
public void run() {
RunnerAndConfigurationSettings settings = selectedValue.getSettings();
RunManagerEx.getInstanceEx(myProject).setSelectedConfiguration(settings);
- doRunConfiguration(settings, myExecutorProvider.getExecutor(), myProject);
-
+ ExecutionUtil.runConfiguration(settings, myExecutorProvider.getExecutor());
}
});
} else {
@@ -961,7 +948,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
ExecutionTargetManager.setActiveTarget(project, eachTarget);
- doRunConfiguration(selectedConfiguration, executor, project);
+ ExecutionUtil.runConfiguration(selectedConfiguration, executor);
}
@Override
@@ -1035,7 +1022,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- doRunConfiguration(RunManager.getInstance(project).getSelectedConfiguration(), executor, project);
+ ExecutionUtil.runConfiguration(RunManager.getInstance(project).getSelectedConfiguration(), executor);
}
});
}
@@ -1116,7 +1103,7 @@ public class ChooseRunConfigurationPopup implements ExecutorProvider {
public void perform(@NotNull Project project, @NotNull Executor executor, @NotNull DataContext context) {
manager.setTemporaryConfiguration(configuration);
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(configuration);
- doRunConfiguration(configuration, executor, project);
+ ExecutionUtil.runConfiguration(configuration, executor);
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java b/platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java
index f5741242089d..0a467c7cec23 100644
--- a/platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/actions/RunContextAction.java
@@ -18,10 +18,9 @@ package com.intellij.execution.actions;
import com.intellij.execution.*;
import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.actionSystem.Presentation;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -47,12 +46,8 @@ public class RunContextAction extends BaseRunConfigurationAction {
runManager.setTemporaryConfiguration(configuration);
}
runManager.setSelectedConfiguration(configuration);
- Project project = context.getProject();
- ExecutionManager.getInstance(project).restartRunProfile(project,
- myExecutor,
- ExecutionTargetManager.getActiveTarget(project),
- configuration,
- (RunContentDescriptor)null);
+
+ ExecutionUtil.runConfiguration(configuration, myExecutor);
}
@Override
@@ -81,11 +76,10 @@ public class RunContextAction extends BaseRunConfigurationAction {
configuration = context.getConfiguration();
}
- if (configuration == null) return Pair.create(false, false);
-
- final ProgramRunner runner = getRunner(configuration.getConfiguration());
- if (runner == null) return Pair.create(false, false);
-
+ ProgramRunner runner = configuration == null ? null : getRunner(configuration.getConfiguration());
+ if (runner == null) {
+ return Pair.create(false, false);
+ }
return Pair.create(!ExecutorRegistry.getInstance().isStarting(context.getProject(), myExecutor.getId(), runner.getRunnerId()), true);
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/actions/StopAction.java b/platform/lang-impl/src/com/intellij/execution/actions/StopAction.java
index 618a4b1c65c5..75466528ae2f 100644
--- a/platform/lang-impl/src/com/intellij/execution/actions/StopAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/actions/StopAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.execution.actions;
+import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.ExecutionManager;
import com.intellij.execution.KillableProcess;
+import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
-import com.intellij.execution.ui.RunContentManager;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -29,7 +29,7 @@ import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
-import com.intellij.openapi.ui.popup.ListItemDescriptor;
+import com.intellij.openapi.ui.popup.ListItemDescriptorAdapter;
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
@@ -49,19 +49,20 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-public class StopAction extends DumbAwareAction implements AnAction.TransparentUpdate {
+class StopAction extends DumbAwareAction implements AnAction.TransparentUpdate {
@Override
public void update(final AnActionEvent e) {
boolean enable = false;
Icon icon = getTemplatePresentation().getIcon();
String description = getTemplatePresentation().getDescription();
- final Presentation presentation = e.getPresentation();
-
+ Presentation presentation = e.getPresentation();
if (ActionPlaces.MAIN_MENU.equals(e.getPlace())) {
enable = !getCancellableProcesses(e.getProject()).isEmpty() || !getActiveDescriptors(e.getDataContext()).isEmpty();
+ presentation.setText(getTemplatePresentation().getText());
}
else {
- final ProcessHandler processHandler = getHandler(e.getDataContext());
+ RunContentDescriptor contentDescriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
+ ProcessHandler processHandler = contentDescriptor == null ? null : contentDescriptor.getProcessHandler();
if (processHandler != null && !processHandler.isProcessTerminated()) {
if (!processHandler.isProcessTerminating()) {
enable = true;
@@ -72,6 +73,14 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
description = "Kill process";
}
}
+
+ RunProfile runProfile = e.getData(LangDataKeys.RUN_PROFILE);
+ if (runProfile == null && contentDescriptor == null) {
+ presentation.setText(getTemplatePresentation().getText());
+ }
+ else {
+ presentation.setText(ExecutionBundle.message("stop.configuration.action.name", runProfile == null ? contentDescriptor.getDisplayName() : runProfile.getName()));
+ }
}
presentation.setEnabled(enable);
@@ -84,7 +93,8 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
final DataContext dataContext = e.getDataContext();
ProcessHandler activeProcessHandler = getHandler(dataContext);
- List<Pair<TaskInfo, ProgressIndicator>> backgroundTasks = getCancellableProcesses(e.getProject());
+ Project project = e.getProject();
+ List<Pair<TaskInfo, ProgressIndicator>> backgroundTasks = getCancellableProcesses(project);
if (ActionPlaces.MAIN_MENU.equals(e.getPlace())) {
if (activeProcessHandler != null && !activeProcessHandler.isProcessTerminating() && !activeProcessHandler.isProcessTerminated()
&& backgroundTasks.isEmpty()) {
@@ -94,12 +104,14 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
Pair<List<HandlerItem>, HandlerItem>
handlerItems = getItemsList(backgroundTasks, getActiveDescriptors(dataContext), activeProcessHandler);
- if (handlerItems.first.isEmpty()) return;
+ if (handlerItems == null || handlerItems.first.isEmpty()) {
+ return;
+ }
final JBList list = new JBList(handlerItems.first);
if (handlerItems.second != null) list.setSelectedValue(handlerItems.second, true);
- list.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptor() {
+ list.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptorAdapter() {
@Nullable
@Override
public String getTextFor(Object value) {
@@ -108,12 +120,6 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
@Nullable
@Override
- public String getTooltipFor(Object value) {
- return null;
- }
-
- @Nullable
- @Override
public Icon getIconFor(Object value) {
return value instanceof HandlerItem ? ((HandlerItem)value).icon : null;
}
@@ -122,12 +128,6 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
public boolean hasSeparatorAboveOf(Object value) {
return value instanceof HandlerItem && ((HandlerItem)value).hasSeparator;
}
-
- @Nullable
- @Override
- public String getCaptionAboveOf(Object value) {
- return null;
- }
}));
final PopupChooserBuilder builder = JBPopupFactory.getInstance().createListPopupBuilder(list);
@@ -148,7 +148,8 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
}
}).setRequestFocus(true).createPopup();
- popup.showCenteredInCurrentWindow(e.getProject());
+ assert project != null;
+ popup.showCenteredInCurrentWindow(project);
}
else {
if (activeProcessHandler != null) {
@@ -171,12 +172,15 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
});
}
+ @Nullable
private static Pair<List<HandlerItem>, HandlerItem> getItemsList(List<Pair<TaskInfo, ProgressIndicator>> tasks,
List<RunContentDescriptor> descriptors,
ProcessHandler activeProcessHandler) {
- if (tasks.isEmpty() && descriptors.isEmpty()) return Pair.create(Collections.<HandlerItem>emptyList(), null);
+ if (tasks.isEmpty() && descriptors.isEmpty()) {
+ return null;
+ }
- ArrayList<HandlerItem> items = new ArrayList<HandlerItem>(tasks.size() + descriptors.size());
+ List<HandlerItem> items = new ArrayList<HandlerItem>(tasks.size() + descriptors.size());
HandlerItem selected = null;
for (RunContentDescriptor descriptor : descriptors) {
final ProcessHandler handler = descriptor.getProcessHandler();
@@ -188,7 +192,9 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
}
};
items.add(item);
- if (handler == activeProcessHandler) selected = item;
+ if (handler == activeProcessHandler) {
+ selected = item;
+ }
}
}
@@ -202,7 +208,7 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
});
hasSeparator = false;
}
- return Pair.<List<HandlerItem>, HandlerItem>create(items, selected);
+ return Pair.create(items, selected);
}
private static void stopProcess(ProcessHandler processHandler) {
@@ -220,21 +226,19 @@ public class StopAction extends DumbAwareAction implements AnAction.TransparentU
}
@Nullable
- static ProcessHandler getHandler(final DataContext dataContext) {
- final RunContentDescriptor contentDescriptor = RunContentManager.RUN_CONTENT_DESCRIPTOR.getData(dataContext);
- final ProcessHandler processHandler;
+ static ProcessHandler getHandler(@NotNull DataContext dataContext) {
+ final RunContentDescriptor contentDescriptor = LangDataKeys.RUN_CONTENT_DESCRIPTOR.getData(dataContext);
if (contentDescriptor != null) {
// toolwindow case
- processHandler = contentDescriptor.getProcessHandler();
+ return contentDescriptor.getProcessHandler();
}
else {
// main menu toolbar
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final RunContentDescriptor selectedContent =
project == null ? null : ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
- processHandler = selectedContent == null ? null : selectedContent.getProcessHandler();
+ return selectedContent == null ? null : selectedContent.getProcessHandler();
}
- return processHandler;
}
@NotNull
diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
index 1a9afd1e25e5..d7f40f35a219 100644
--- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
@@ -616,7 +616,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
sink.put(OpenFileDescriptor.NAVIGATE_IN_EDITOR, myConsoleEditor);
}
else if (getProject().isInitialized()) {
- sink.put(key, FileEditorManagerEx.getInstanceEx(getProject()).getData(key.getName(), myConsoleEditor, myVirtualFile));
+ sink.put(key, FileEditorManagerEx.getInstanceEx(getProject()).getData(key.getName(), myConsoleEditor, myConsoleEditor.getCaretModel().getCurrentCaret()));
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java
index bdae21f781ea..7bae2105014a 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditor.java
@@ -75,16 +75,14 @@ class ConfigurationSettingsEditor extends CompositeSettingsEditor<RunnerAndConfi
myRunnersComponent = new RunnersEditorComponent();
- ProgramRunner[] runners = RunnerRegistry.getInstance().getRegisteredRunners();
final Executor[] executors = ExecutorRegistry.getInstance().getRegisteredExecutors();
for (final Executor executor : executors) {
- for (ProgramRunner runner : runners) {
- if (runner.canRun(executor.getId(), myConfiguration)) {
- JComponent perRunnerSettings = createCompositePerRunnerSettings(executor, runner);
- if (perRunnerSettings != null) {
- myRunnersComponent.addExecutorComponent(executor, perRunnerSettings);
- }
+ ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), myConfiguration);
+ if (runner != null) {
+ JComponent perRunnerSettings = createCompositePerRunnerSettings(executor, runner);
+ if (perRunnerSettings != null) {
+ myRunnersComponent.addExecutorComponent(executor, perRunnerSettings);
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ExecutionManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ExecutionManagerImpl.java
index c017284f8e11..29808af0845d 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/ExecutionManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/ExecutionManagerImpl.java
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.execution.impl;
import com.intellij.CommonBundle;
import com.intellij.execution.*;
import com.intellij.execution.configuration.CompatibilityAwareRunProfile;
-import com.intellij.execution.configurations.*;
+import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.execution.configurations.RunProfile;
+import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
@@ -34,12 +35,12 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Trinity;
@@ -47,21 +48,20 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.ui.docking.DockManager;
import com.intellij.util.Alarm;
+import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.Predicate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-/**
- * @author dyoma
- */
-public class ExecutionManagerImpl extends ExecutionManager implements ProjectComponent {
+public class ExecutionManagerImpl extends ExecutionManager implements Disposable {
public static final Key<Object> EXECUTION_SESSION_ID_KEY = Key.create("EXECUTION_SESSION_ID_KEY");
- private static final Logger LOG = Logger.getInstance("com.intellij.execution.impl.ExecutionManagerImpl");
+
+ private static final Logger LOG = Logger.getInstance(ExecutionManagerImpl.class);
+ private static final ProcessHandler[] EMPTY_PROCESS_HANDLERS = new ProcessHandler[0];
private final Project myProject;
@@ -70,28 +70,12 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
private final List<Trinity<RunContentDescriptor, RunnerAndConfigurationSettings, Executor>> myRunningConfigurations =
ContainerUtil.createLockFreeCopyOnWriteList();
- /**
- * reflection
- */
- ExecutionManagerImpl(final Project project) {
+ ExecutionManagerImpl(@NotNull Project project) {
myProject = project;
}
@Override
- public void projectOpened() {
- ((RunContentManagerImpl)getContentManager()).init();
- }
-
- @Override
- public void projectClosed() {
- }
-
- @Override
- public void initComponent() {
- }
-
- @Override
- public void disposeComponent() {
+ public void dispose() {
for (Trinity<RunContentDescriptor, RunnerAndConfigurationSettings, Executor> trinity : myRunningConfigurations) {
Disposer.dispose(trinity.first);
}
@@ -108,112 +92,118 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
return myContentManager;
}
+ @NotNull
@Override
public ProcessHandler[] getRunningProcesses() {
- final List<ProcessHandler> handlers = new ArrayList<ProcessHandler>();
+ if (myContentManager == null) return EMPTY_PROCESS_HANDLERS;
+ List<ProcessHandler> handlers = null;
for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) {
- final ProcessHandler processHandler = descriptor.getProcessHandler();
+ ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null) {
+ if (handlers == null) {
+ handlers = new SmartList<ProcessHandler>();
+ }
handlers.add(processHandler);
}
}
- return handlers.toArray(new ProcessHandler[handlers.size()]);
+ return handlers == null ? EMPTY_PROCESS_HANDLERS : handlers.toArray(new ProcessHandler[handlers.size()]);
}
@Override
public void compileAndRun(@NotNull final Runnable startRunnable,
- @NotNull final ExecutionEnvironment env,
+ @NotNull final ExecutionEnvironment environment,
@Nullable final RunProfileState state,
@Nullable final Runnable onCancelRunnable) {
- long id = env.getExecutionId();
+ long id = environment.getExecutionId();
if (id == 0) {
- id = env.assignNewExecutionId();
+ id = environment.assignNewExecutionId();
}
- RunProfile profile = env.getRunProfile();
-
- if (profile instanceof RunConfiguration) {
- final RunConfiguration runConfiguration = (RunConfiguration)profile;
- final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myProject);
- final List<BeforeRunTask> activeTasks = new ArrayList<BeforeRunTask>();
- activeTasks.addAll(runManager.getBeforeRunTasks(runConfiguration));
+ RunProfile profile = environment.getRunProfile();
+ if (!(profile instanceof RunConfiguration)) {
+ startRunnable.run();
+ return;
+ }
- DataContext context = env.getDataContext();
+ final RunConfiguration runConfiguration = (RunConfiguration)profile;
+ final List<BeforeRunTask> beforeRunTasks = RunManagerEx.getInstanceEx(myProject).getBeforeRunTasks(runConfiguration);
+ if (beforeRunTasks.isEmpty()) {
+ startRunnable.run();
+ }
+ else {
+ DataContext context = environment.getDataContext();
final DataContext projectContext = context != null ? context : SimpleDataContext.getProjectContext(myProject);
-
- if (!activeTasks.isEmpty()) {
- final long finalId = id;
- final Long executionSessionId = new Long(id);
- ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
- /** @noinspection SSBasedInspection*/
- @Override
- public void run() {
- for (BeforeRunTask task : activeTasks) {
- if (myProject.isDisposed()) {
- return;
- }
- BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myProject, task.getProviderId());
- if (provider == null) {
- LOG.warn("Cannot find BeforeRunTaskProvider for id='" + task.getProviderId() + "'");
- continue;
- }
- ExecutionEnvironment taskEnvironment = new ExecutionEnvironmentBuilder(env).setContentToReuse(null).build();
- taskEnvironment.setExecutionId(finalId);
- EXECUTION_SESSION_ID_KEY.set(taskEnvironment, executionSessionId);
- if (!provider.executeTask(projectContext, runConfiguration, taskEnvironment, task)) {
- if (onCancelRunnable != null) {
- SwingUtilities.invokeLater(onCancelRunnable);
- }
- return;
- }
+ final long finalId = id;
+ final Long executionSessionId = new Long(id);
+ ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+ /** @noinspection SSBasedInspection*/
+ @Override
+ public void run() {
+ for (BeforeRunTask task : beforeRunTasks) {
+ if (myProject.isDisposed()) {
+ return;
}
- // important! Do not use DumbService.smartInvokelater here because it depends on modality state
- // and execution of startRunnable could be skipped if modality state check fails
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if (!myProject.isDisposed()) {
- DumbService.getInstance(myProject).runWhenSmart(startRunnable);
- }
+ @SuppressWarnings("unchecked")
+ BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myProject, task.getProviderId());
+ if (provider == null) {
+ LOG.warn("Cannot find BeforeRunTaskProvider for id='" + task.getProviderId() + "'");
+ continue;
+ }
+ ExecutionEnvironment taskEnvironment = new ExecutionEnvironmentBuilder(environment).contentToReuse(null).build();
+ taskEnvironment.setExecutionId(finalId);
+ EXECUTION_SESSION_ID_KEY.set(taskEnvironment, executionSessionId);
+ if (!provider.executeTask(projectContext, runConfiguration, taskEnvironment, task)) {
+ if (onCancelRunnable != null) {
+ SwingUtilities.invokeLater(onCancelRunnable);
}
- });
+ return;
+ }
}
- });
- }
- else {
- startRunnable.run();
- }
- }
- else {
- startRunnable.run();
+ // important! Do not use DumbService.smartInvokeLater here because it depends on modality state
+ // and execution of startRunnable could be skipped if modality state check fails
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ if (!myProject.isDisposed()) {
+ DumbService.getInstance(myProject).runWhenSmart(startRunnable);
+ }
+ }
+ });
+ }
+ });
}
}
@Override
- public void startRunProfile(@NotNull final RunProfileStarter starter, @NotNull final RunProfileState state,
- @NotNull final Project project, @NotNull final Executor executor, @NotNull final ExecutionEnvironment env) {
- final RunContentDescriptor reuseContent =
- ExecutionManager.getInstance(project).getContentManager().getReuseContent(env);
+ public void startRunProfile(@NotNull final RunProfileStarter starter,
+ @NotNull final RunProfileState state,
+ @NotNull final ExecutionEnvironment environment) {
+ final Project project = environment.getProject();
+ final RunContentDescriptor reuseContent = getContentManager().getReuseContent(environment);
if (reuseContent != null) {
- reuseContent.setExecutionId(env.getExecutionId());
+ reuseContent.setExecutionId(environment.getExecutionId());
}
- final RunProfile profile = env.getRunProfile();
- project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStartScheduled(executor.getId(), env);
+ final Executor executor = environment.getExecutor();
+ project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStartScheduled(executor.getId(), environment);
Runnable startRunnable = new Runnable() {
@Override
public void run() {
- if (project.isDisposed()) return;
+ if (project.isDisposed()) {
+ return;
+ }
+
+ RunProfile profile = environment.getRunProfile();
boolean started = false;
try {
- project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStarting(executor.getId(), env);
-
- final RunContentDescriptor descriptor = starter.execute(project, executor, state, reuseContent, env);
+ project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStarting(executor.getId(), environment);
+ final RunContentDescriptor descriptor = starter.execute(project, executor, state, reuseContent, environment);
if (descriptor != null) {
+ environment.setContentToReuse(descriptor);
final Trinity<RunContentDescriptor, RunnerAndConfigurationSettings, Executor> trinity =
- Trinity.create(descriptor, env.getRunnerAndConfigurationSettings(), executor);
+ Trinity.create(descriptor, environment.getRunnerAndConfigurationSettings(), executor);
myRunningConfigurations.add(trinity);
Disposer.register(descriptor, new Disposable() {
@Override
@@ -221,13 +211,13 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
myRunningConfigurations.remove(trinity);
}
});
- ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor, reuseContent);
+ getContentManager().showRunContent(executor, descriptor, reuseContent);
final ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null) {
if (!processHandler.isStartNotified()) {
processHandler.startNotify();
}
- project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStarted(executor.getId(), env, processHandler);
+ project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processStarted(executor.getId(), environment, processHandler);
started = true;
processHandler.addProcessListener(new ProcessExecutionListener(project, profile, processHandler));
}
@@ -239,7 +229,7 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
}
finally {
if (!started) {
- project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processNotStarted(executor.getId(), env);
+ project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processNotStarted(executor.getId(), environment);
}
}
}
@@ -249,11 +239,11 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
startRunnable.run();
}
else {
- compileAndRun(startRunnable, env, state, new Runnable() {
+ compileAndRun(startRunnable, environment, state, new Runnable() {
@Override
public void run() {
if (!project.isDisposed()) {
- project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processNotStarted(executor.getId(), env);
+ project.getMessageBus().syncPublisher(EXECUTION_TOPIC).processNotStarted(executor.getId(), environment);
}
}
});
@@ -261,26 +251,36 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
}
@Override
- public void startRunProfile(@NotNull RunProfileStarter starter, @NotNull RunProfileState state, @NotNull ExecutionEnvironment env) {
- startRunProfile(starter, state, env.getProject(), env.getExecutor(), env);
- }
-
- @Override
- public void restartRunProfile(@NotNull final Project project,
- @NotNull final Executor executor,
- @NotNull final ExecutionTarget target,
- @Nullable final RunnerAndConfigurationSettings configuration,
- @Nullable final ProcessHandler processHandler) {
+ public void restartRunProfile(@NotNull Project project,
+ @NotNull Executor executor,
+ @NotNull ExecutionTarget target,
+ @Nullable RunnerAndConfigurationSettings configuration,
+ @Nullable ProcessHandler processHandler) {
+ ExecutionEnvironmentBuilder builder = createEnvironmentBuilder(project, executor, configuration);
if (processHandler != null) {
for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) {
- final ProcessHandler handler = descriptor.getProcessHandler();
- if (handler == processHandler) {
- restartRunProfile(project, null, null, null, null, null, executor, target, configuration, descriptor);
- return;
+ if (descriptor.getProcessHandler() == processHandler) {
+ builder.contentToReuse(descriptor);
+ break;
}
}
}
- restartRunProfile(project, null, null, null, null, null, executor, target, configuration, null);
+ restartRunProfile(builder.target(target).build());
+ }
+
+ @NotNull
+ private static ExecutionEnvironmentBuilder createEnvironmentBuilder(@NotNull Project project, @NotNull Executor executor, @Nullable RunnerAndConfigurationSettings configuration) {
+ ExecutionEnvironmentBuilder builder = new ExecutionEnvironmentBuilder(project, executor);
+
+ ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), configuration != null ? configuration.getConfiguration() : null);
+ if (runner == null && configuration != null) {
+ LOG.error("Cannot find runner for " + configuration.getName());
+ }
+ else if (runner != null) {
+ assert configuration != null;
+ builder.runnerAndSettings(runner, configuration);
+ }
+ return builder;
}
@Override
@@ -289,123 +289,89 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
@NotNull ExecutionTarget target,
@Nullable RunnerAndConfigurationSettings configuration,
@Nullable RunContentDescriptor currentDescriptor) {
- restartRunProfile(project, null, null, null, null, null, executor, target, configuration, currentDescriptor);
+ ExecutionEnvironmentBuilder builder = createEnvironmentBuilder(project, executor, configuration);
+ restartRunProfile(builder.target(target).contentToReuse(currentDescriptor).build());
}
@Override
public void restartRunProfile(@Nullable ProgramRunner runner,
@NotNull ExecutionEnvironment environment,
@Nullable RunContentDescriptor currentDescriptor) {
- restartRunProfile(environment.getProject(),
- environment.getDataContext(),
- runner,
- environment.getRunProfile(),
- environment.getRunnerSettings(),
- environment.getConfigurationSettings(),
- environment.getExecutor(),
- environment.getExecutionTarget(),
- environment.getRunnerAndConfigurationSettings(), currentDescriptor);
+ ExecutionEnvironmentBuilder builder = new ExecutionEnvironmentBuilder(environment).contentToReuse(currentDescriptor);
+ if (runner != null) {
+ builder.runner(runner);
+ }
+ restartRunProfile(builder.build());
}
+ public static boolean isProcessRunning(@Nullable RunContentDescriptor descriptor) {
+ ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
+ return processHandler != null && !processHandler.isProcessTerminated();
+ }
- private void restartRunProfile(@NotNull final Project project,
- @Nullable final DataContext context,
- @Nullable ProgramRunner r,
- @Nullable final RunProfile runProfile,
- @Nullable final RunnerSettings runnerSettings,
- @Nullable final ConfigurationPerRunnerSettings configurationPerRunnerSettings,
- @NotNull final Executor executor,
- @NotNull final ExecutionTarget target,
- @Nullable final RunnerAndConfigurationSettings configuration,
- @Nullable final RunContentDescriptor currentDescriptor) {
- final ProgramRunner runner = r != null ?
- r :
- RunnerRegistry.getInstance().getRunner(executor.getId(),
- configuration != null && configuration.getConfiguration() != null
- ? configuration.getConfiguration()
- : runProfile
- );
- if (configuration != null && runner == null) {
- LOG.error("Cannot find runner for " + configuration.getName());
- return;
- }
-
- final List<RunContentDescriptor> runningConfigurationsOfTheSameType = new ArrayList<RunContentDescriptor>();
- final List<RunContentDescriptor> runningIncompatibleConfigurations = new ArrayList<RunContentDescriptor>();
+ @Override
+ public void restartRunProfile(@NotNull final ExecutionEnvironment environment) {
+ RunnerAndConfigurationSettings configuration = environment.getRunnerAndConfigurationSettings();
- if (configuration != null) {
- runningIncompatibleConfigurations.addAll(getIncompatibleRunningDescriptors(configuration));
+ List<RunContentDescriptor> runningIncompatible;
+ if (configuration == null) {
+ runningIncompatible = Collections.emptyList();
}
+ else {
+ runningIncompatible = getIncompatibleRunningDescriptors(configuration);
+ }
+
+ RunContentDescriptor contentToReuse = environment.getContentToReuse();
+ final List<RunContentDescriptor> runningOfTheSameType = new SmartList<RunContentDescriptor>();
if (configuration != null && configuration.isSingleton()) {
- runningConfigurationsOfTheSameType.addAll(getRunningDescriptorsOfTheSameConfigType(configuration));
+ runningOfTheSameType.addAll(getRunningDescriptorsOfTheSameConfigType(configuration));
}
- else if (currentDescriptor != null) {
- runningConfigurationsOfTheSameType.add(currentDescriptor);
+ else if (isProcessRunning(contentToReuse)) {
+ runningOfTheSameType.add(contentToReuse);
}
- final List<RunContentDescriptor> runningConfigurationsToStop = ContainerUtil.concat(runningConfigurationsOfTheSameType,
- runningIncompatibleConfigurations);
- if (!runningConfigurationsToStop.isEmpty()) {
+ List<RunContentDescriptor> runningToStop = ContainerUtil.concat(runningOfTheSameType, runningIncompatible);
+ if (!runningToStop.isEmpty()) {
if (configuration != null) {
- if (!runningConfigurationsOfTheSameType.isEmpty()
- && (runningConfigurationsOfTheSameType.size() > 1 ||
- currentDescriptor == null ||
- runningConfigurationsOfTheSameType.get(0) != currentDescriptor) &&
- !userApprovesStopForSameTypeConfigurations(project, configuration.getName(), runningConfigurationsOfTheSameType.size())) {
+ if (!runningOfTheSameType.isEmpty()
+ && (runningOfTheSameType.size() > 1 || contentToReuse == null || runningOfTheSameType.get(0) != contentToReuse) &&
+ !userApprovesStopForSameTypeConfigurations(environment.getProject(), configuration.getName(), runningOfTheSameType.size())) {
return;
}
- if (!runningIncompatibleConfigurations.isEmpty()
- && !userApprovesStopForIncompatibleConfigurations(myProject, configuration.getName(), runningIncompatibleConfigurations)) {
+ if (!runningIncompatible.isEmpty()
+ && !userApprovesStopForIncompatibleConfigurations(myProject, configuration.getName(), runningIncompatible)) {
return;
}
}
- for (RunContentDescriptor descriptor : runningConfigurationsToStop) {
+
+ for (RunContentDescriptor descriptor : runningToStop) {
stop(descriptor);
}
}
- Runnable runnable = new Runnable() {
+ awaitingTerminationAlarm.addRequest(new Runnable() {
@Override
public void run() {
- if (runner != null && ExecutorRegistry.getInstance().isStarting(project, executor.getId(), runner.getRunnerId())) {
+ if (ExecutorRegistry.getInstance().isStarting(environment)) {
awaitingTerminationAlarm.addRequest(this, 100);
return;
}
- for (RunContentDescriptor descriptor : runningConfigurationsOfTheSameType) {
+
+ for (RunContentDescriptor descriptor : runningOfTheSameType) {
ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler != null && !processHandler.isProcessTerminated()) {
awaitingTerminationAlarm.addRequest(this, 100);
return;
}
}
- start(project, context, runner, runProfile, runnerSettings, configurationPerRunnerSettings, configuration, executor, target,
- currentDescriptor);
+ start(environment);
}
- };
- awaitingTerminationAlarm.addRequest(runnable, 50);
+ }, 50);
}
- private static void start(@NotNull Project project,
- @Nullable DataContext context,
- @Nullable ProgramRunner runner,
- @Nullable RunProfile runProfile,
- @Nullable RunnerSettings runnerSettings,
- @Nullable ConfigurationPerRunnerSettings configurationPerRunnerSettings,
- @Nullable RunnerAndConfigurationSettings configuration,
- @NotNull Executor executor,
- @NotNull ExecutionTarget target,
- @Nullable RunContentDescriptor descriptor) {
- Runnable restarter = descriptor != null ? descriptor.getRestarter() : null;
- if (runner != null && runProfile != null) {
- ProgramRunnerUtil.executeConfiguration(project, context, configuration, executor, target, descriptor,
- configuration != null && configuration.isEditBeforeRun(), runner, runProfile, false);
- }
- else if (configuration != null) {
- ProgramRunnerUtil.executeConfiguration(project, context, configuration, executor, target, descriptor, true);
- }
- else if (restarter != null) {
- restarter.run();
- }
+ private static void start(@NotNull ExecutionEnvironment environment) {
+ RunnerAndConfigurationSettings settings = environment.getRunnerAndConfigurationSettings();
+ ProgramRunnerUtil.executeConfiguration(environment, settings != null && settings.isEditBeforeRun(), true);
}
private static boolean userApprovesStopForSameTypeConfigurations(Project project, String configName, int instancesCount) {
@@ -505,35 +471,36 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
Messages.getQuestionIcon(), option) == Messages.OK;
}
- private List<RunContentDescriptor> getRunningDescriptorsOfTheSameConfigType(
- @NotNull final RunnerAndConfigurationSettings configurationAndSettings) {
- return getRunningDescriptors(new Predicate<RunnerAndConfigurationSettings>() {
+ @NotNull
+ private List<RunContentDescriptor> getRunningDescriptorsOfTheSameConfigType(@NotNull final RunnerAndConfigurationSettings configurationAndSettings) {
+ return getRunningDescriptors(new Condition<RunnerAndConfigurationSettings>() {
@Override
- public boolean apply(@Nullable RunnerAndConfigurationSettings runningConfigurationAndSettings) {
+ public boolean value(@Nullable RunnerAndConfigurationSettings runningConfigurationAndSettings) {
return configurationAndSettings == runningConfigurationAndSettings;
}
});
}
- private List<RunContentDescriptor> getIncompatibleRunningDescriptors(
- @NotNull final RunnerAndConfigurationSettings configurationAndSettings) {
+ @NotNull
+ private List<RunContentDescriptor> getIncompatibleRunningDescriptors(@NotNull RunnerAndConfigurationSettings configurationAndSettings) {
final RunConfiguration configurationToCheckCompatibility = configurationAndSettings.getConfiguration();
- return getRunningDescriptors(new Predicate<RunnerAndConfigurationSettings>() {
+ return getRunningDescriptors(new Condition<RunnerAndConfigurationSettings>() {
@Override
- public boolean apply(@Nullable RunnerAndConfigurationSettings runningConfigurationAndSettings) {
- if (runningConfigurationAndSettings == null) return false;
- RunConfiguration runningConfiguration = runningConfigurationAndSettings.getConfiguration();
- if (runningConfiguration == null || !(runningConfiguration instanceof CompatibilityAwareRunProfile)) return false;
+ public boolean value(@Nullable RunnerAndConfigurationSettings runningConfigurationAndSettings) {
+ RunConfiguration runningConfiguration = runningConfigurationAndSettings == null ? null : runningConfigurationAndSettings.getConfiguration();
+ if (runningConfiguration == null || !(runningConfiguration instanceof CompatibilityAwareRunProfile)) {
+ return false;
+ }
return ((CompatibilityAwareRunProfile)runningConfiguration).mustBeStoppedToRun(configurationToCheckCompatibility);
}
});
}
- private List<RunContentDescriptor> getRunningDescriptors(
- Predicate<RunnerAndConfigurationSettings> condition) {
- List<RunContentDescriptor> result = new ArrayList<RunContentDescriptor>();
+ @NotNull
+ private List<RunContentDescriptor> getRunningDescriptors(@NotNull Condition<RunnerAndConfigurationSettings> condition) {
+ List<RunContentDescriptor> result = new SmartList<RunContentDescriptor>();
for (Trinity<RunContentDescriptor, RunnerAndConfigurationSettings, Executor> trinity : myRunningConfigurations) {
- if (condition.apply(trinity.getSecond())) {
+ if (condition.value(trinity.getSecond())) {
ProcessHandler processHandler = trinity.getFirst().getProcessHandler();
if (processHandler != null && !processHandler.isProcessTerminating() && !processHandler.isProcessTerminated()) {
result.add(trinity.getFirst());
@@ -543,30 +510,27 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
return result;
}
- private static void stop(RunContentDescriptor runContentDescriptor) {
- ProcessHandler processHandler = runContentDescriptor != null ? runContentDescriptor.getProcessHandler() : null;
+ private static void stop(@Nullable RunContentDescriptor descriptor) {
+ ProcessHandler processHandler = descriptor != null ? descriptor.getProcessHandler() : null;
if (processHandler == null) {
return;
}
+
if (processHandler instanceof KillableProcess && processHandler.isProcessTerminating()) {
((KillableProcess)processHandler).killProcess();
return;
}
- if (processHandler.detachIsDefault()) {
- processHandler.detachProcess();
- }
- else {
- processHandler.destroyProcess();
+ if (!processHandler.isProcessTerminated()) {
+ if (processHandler.detachIsDefault()) {
+ processHandler.detachProcess();
+ }
+ else {
+ processHandler.destroyProcess();
+ }
}
}
- @Override
- @NotNull
- public String getComponentName() {
- return "ExecutionManager";
- }
-
private static class ProcessExecutionListener extends ProcessAdapter {
private final Project myProject;
private final RunProfile myProfile;
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationManager.java b/platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationManager.java
index deadaad0a0d1..42b9be79890e 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationManager.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationManager.java
@@ -50,7 +50,7 @@ import java.util.Set;
}
)
public class ProjectRunConfigurationManager implements ProjectComponent, PersistentStateComponent<Element> {
- private static final Logger LOG = Logger.getInstance("#com.intellij.execution.impl.ProjectRunConfigurationManager");
+ private static final Logger LOG = Logger.getInstance(ProjectRunConfigurationManager.class);
private final RunManagerImpl myManager;
private List<Element> myUnloadedElements = null;
@@ -150,7 +150,7 @@ public class ProjectRunConfigurationManager implements ProjectComponent, Persist
}
if (myUnloadedElements != null) {
for (Element unloadedElement : myUnloadedElements) {
- element.addContent((Element)unloadedElement.clone());
+ element.addContent(unloadedElement.clone());
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurationBeforeRunProvider.java b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurationBeforeRunProvider.java
index edf1352a760c..97f36a8fd2b4 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurationBeforeRunProvider.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/RunConfigurationBeforeRunProvider.java
@@ -23,6 +23,7 @@ import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.Disposable;
@@ -137,7 +138,7 @@ extends BeforeRunTaskProvider<RunConfigurationBeforeRunProvider.RunConfigurableB
}
@NotNull
- private List<RunnerAndConfigurationSettings> getAvailableConfigurations(RunConfiguration runConfiguration) {
+ private static List<RunnerAndConfigurationSettings> getAvailableConfigurations(RunConfiguration runConfiguration) {
Project project = runConfiguration.getProject();
if (project == null || !project.isInitialized())
return Collections.emptyList();
@@ -164,9 +165,7 @@ extends BeforeRunTaskProvider<RunConfigurationBeforeRunProvider.RunConfigurableB
}
String executorId = DefaultRunExecutor.getRunExecutorInstance().getId();
final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
- if (runner == null)
- return false;
- return runner.canRun(executorId, settings.getConfiguration());
+ return runner != null && runner.canRun(executorId, settings.getConfiguration());
}
@Override
@@ -180,16 +179,17 @@ extends BeforeRunTaskProvider<RunConfigurationBeforeRunProvider.RunConfigurableB
}
final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
final String executorId = executor.getId();
- final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
- if (runner == null)
+ ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.createOrNull(executor, settings);
+ if (builder == null) {
return false;
- final ExecutionEnvironment environment = new ExecutionEnvironment(executor, runner, settings, myProject);
+ }
+ final ExecutionEnvironment environment = builder.build();
environment.setExecutionId(env.getExecutionId());
if (!ExecutionTargetManager.canRun(settings, env.getExecutionTarget())) {
return false;
}
- if (!runner.canRun(executorId, environment.getRunProfile())) {
+ if (!environment.getRunner().canRun(executorId, environment.getRunProfile())) {
return false;
}
else {
@@ -198,23 +198,27 @@ extends BeforeRunTaskProvider<RunConfigurationBeforeRunProvider.RunConfigurableB
final Disposable disposable = Disposer.newDisposable();
myProject.getMessageBus().connect(disposable).subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionAdapter() {
+ @Override
public void processStartScheduled(final String executorIdLocal, final ExecutionEnvironment environmentLocal) {
if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) {
targetDone.down();
}
}
+ @Override
public void processNotStarted(final String executorIdLocal, @NotNull final ExecutionEnvironment environmentLocal) {
if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) {
targetDone.up();
}
}
+ @Override
public void processStarted(final String executorIdLocal,
@NotNull final ExecutionEnvironment environmentLocal,
@NotNull final ProcessHandler handler) {
if (executorId.equals(executorIdLocal) && environment.equals(environmentLocal)) {
handler.addProcessListener(new ProcessAdapter() {
+ @Override
public void processTerminated(ProcessEvent event) {
result.set(event.getExitCode() == 0);
targetDone.up();
@@ -229,7 +233,7 @@ extends BeforeRunTaskProvider<RunConfigurationBeforeRunProvider.RunConfigurableB
@Override
public void run() {
try {
- runner.execute(environment);
+ environment.getRunner().execute(environment);
}
catch (ExecutionException e) {
targetDone.up();
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunDialog.java b/platform/lang-impl/src/com/intellij/execution/impl/RunDialog.java
index 71e205c3f22c..139eb0c4e25b 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/RunDialog.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/RunDialog.java
@@ -20,6 +20,7 @@ import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.Executor;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.configurations.RunConfiguration;
+import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
@@ -111,6 +112,10 @@ public class RunDialog extends DialogWrapper implements RunConfigurable.RunDialo
return editConfiguration(project, configuration, title, null);
}
+ public static boolean editConfiguration(@NotNull ExecutionEnvironment environment, @NotNull String title) {
+ return editConfiguration(environment.getProject(), environment.getRunnerAndConfigurationSettings(), title, environment.getExecutor());
+ }
+
public static boolean editConfiguration(final Project project, final RunnerAndConfigurationSettings configuration, final String title, @Nullable final Executor executor) {
final SingleConfigurationConfigurable<RunConfiguration> configurable = SingleConfigurationConfigurable.editSettings(configuration, executor);
final SingleConfigurableEditor dialog = new SingleConfigurableEditor(project, configurable, IdeModalityType.PROJECT) {
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java
index d3a1e1cb0574..7b54f21503df 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java
@@ -19,6 +19,7 @@ package com.intellij.execution.impl;
import com.intellij.ProjectTopics;
import com.intellij.execution.*;
import com.intellij.execution.configurations.*;
+import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.NamedComponent;
@@ -106,7 +107,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
public final void initializeConfigurationTypes(@NotNull final ConfigurationType[] factories) {
Arrays.sort(factories, new Comparator<ConfigurationType>() {
@Override
- public int compare(final ConfigurationType o1, final ConfigurationType o2) {
+ public int compare(@NotNull final ConfigurationType o1, @NotNull final ConfigurationType o2) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
});
@@ -461,7 +462,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
// IDEA-63663 Sort run configurations alphabetically if clean checkout
Collections.sort(order, new Comparator<Pair<String, RunnerAndConfigurationSettings>>() {
@Override
- public int compare(Pair<String, RunnerAndConfigurationSettings> o1, Pair<String, RunnerAndConfigurationSettings> o2) {
+ public int compare(@NotNull Pair<String, RunnerAndConfigurationSettings> o1, @NotNull Pair<String, RunnerAndConfigurationSettings> o2) {
boolean temporary1 = o1.getSecond().isTemporary();
boolean temporary2 = o2.getSecond().isTemporary();
if (temporary1 == temporary2) {
@@ -475,7 +476,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
else {
Collections.sort(order, new Comparator<Pair<String, RunnerAndConfigurationSettings>>() {
@Override
- public int compare(Pair<String, RunnerAndConfigurationSettings> o1, Pair<String, RunnerAndConfigurationSettings> o2) {
+ public int compare(@NotNull Pair<String, RunnerAndConfigurationSettings> o1, @NotNull Pair<String, RunnerAndConfigurationSettings> o2) {
int i1 = folderNames.indexOf(o1.getSecond().getFolderName());
int i2 = folderNames.indexOf(o2.getSecond().getFolderName());
if (i1 != i2) {
@@ -507,8 +508,12 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
return myConfigurations.values();
}
- public static boolean canRunConfiguration(@NotNull final RunnerAndConfigurationSettings configuration,
- @NotNull final Executor executor) {
+ public static boolean canRunConfiguration(@NotNull ExecutionEnvironment environment) {
+ RunnerAndConfigurationSettings runnerAndConfigurationSettings = environment.getRunnerAndConfigurationSettings();
+ return runnerAndConfigurationSettings != null && canRunConfiguration(runnerAndConfigurationSettings, environment.getExecutor());
+ }
+
+ public static boolean canRunConfiguration(@NotNull RunnerAndConfigurationSettings configuration, @NotNull Executor executor) {
try {
configuration.checkSettings(executor);
}
@@ -567,7 +572,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
if (myUnknownElements != null) {
for (Element unloadedElement : myUnknownElements) {
- parentNode.addContent((Element)unloadedElement.clone());
+ parentNode.addContent(unloadedElement.clone());
}
}
}
@@ -647,7 +652,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
final Comparator<Element> comparator = new Comparator<Element>() {
@Override
- public int compare(Element a, Element b) {
+ public int compare(@NotNull Element a, @NotNull Element b) {
final boolean aDefault = Boolean.valueOf(a.getAttributeValue("default", "false"));
final boolean bDefault = Boolean.valueOf(b.getAttributeValue("default", "false"));
return aDefault == bDefault ? 0 : aDefault ? -1 : 1;
@@ -666,7 +671,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
Collections.sort(sortedElements, comparator); // ensure templates are loaded first!
for (final Element element : sortedElements) {
- RunnerAndConfigurationSettings configurationSettings = null;
+ RunnerAndConfigurationSettings configurationSettings;
try {
configurationSettings = loadConfiguration(element, false);
}
@@ -915,6 +920,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
public List<RunnerAndConfigurationSettings> getTempConfigurationsList() {
List<RunnerAndConfigurationSettings> configurations =
ContainerUtil.filter(myConfigurations.values(), new Condition<RunnerAndConfigurationSettings>() {
+ @Override
public boolean value(RunnerAndConfigurationSettings settings) {
return settings.isTemporary();
}
@@ -933,6 +939,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
return result;
}
+ @Override
public void makeStable(@NotNull RunnerAndConfigurationSettings settings) {
settings.setTemporary(false);
myRecentlyUsedTemporaries.remove(settings.getConfiguration());
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunnerRegistryImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunnerRegistryImpl.java
index 08e9541c265f..cefeaf958f0d 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/RunnerRegistryImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/RunnerRegistryImpl.java
@@ -51,10 +51,12 @@ public class RunnerRegistryImpl extends RunnerRegistry {
}
@Override
- public ProgramRunner getRunner(@NotNull final String executorId, final RunProfile settings) {
- if (settings == null) return null;
- final ProgramRunner[] runners = getRegisteredRunners();
- for (final ProgramRunner runner : runners) {
+ public ProgramRunner getRunner(@NotNull String executorId, @Nullable RunProfile settings) {
+ if (settings == null) {
+ return null;
+ }
+
+ for (ProgramRunner runner : getRegisteredRunners()) {
if (runner.canRun(executorId, settings)) {
return runner;
}
diff --git a/platform/lang-impl/src/com/intellij/execution/impl/SingleConfigurationConfigurable.java b/platform/lang-impl/src/com/intellij/execution/impl/SingleConfigurationConfigurable.java
index 4c58ab7029b3..4a750f22a15d 100644
--- a/platform/lang-impl/src/com/intellij/execution/impl/SingleConfigurationConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/execution/impl/SingleConfigurationConfigurable.java
@@ -151,12 +151,10 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
if (snapshot != null) {
snapshot.setName(getNameText());
snapshot.checkSettings(myExecutor);
- for (ProgramRunner runner : RunnerRegistry.getInstance().getRegisteredRunners()) {
- for (Executor executor : ExecutorRegistry.getInstance().getRegisteredExecutors()) {
- if (runner.canRun(executor.getId(), snapshot.getConfiguration())) {
- checkConfiguration(runner, snapshot);
- break;
- }
+ for (Executor executor : ExecutorRegistry.getInstance().getRegisteredExecutors()) {
+ ProgramRunner runner = RunnerRegistry.getInstance().getRunner(executor.getId(), snapshot.getConfiguration());
+ if (runner != null) {
+ checkConfiguration(runner, snapshot);
}
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java b/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java
index b4b3cd919ec4..7bcabebf256a 100644
--- a/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java
+++ b/platform/lang-impl/src/com/intellij/execution/runners/AbstractConsoleRunnerWithHistory.java
@@ -173,7 +173,7 @@ public abstract class AbstractConsoleRunnerWithHistory<T extends LanguageConsole
return false;
}
- protected void showConsole(Executor defaultExecutor, RunContentDescriptor contentDescriptor) {
+ protected void showConsole(Executor defaultExecutor, @NotNull RunContentDescriptor contentDescriptor) {
// Show in run toolwindow
ExecutionManager.getInstance(myProject).getContentManager().showRunContent(defaultExecutor, contentDescriptor);
}
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java b/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java
index e2f8a5a717fe..5f7321aa8068 100644
--- a/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java
+++ b/platform/lang-impl/src/com/intellij/execution/runners/DefaultProgramRunner.java
@@ -36,10 +36,10 @@ public abstract class DefaultProgramRunner extends GenericProgramRunner {
@NotNull final ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
ExecutionResult executionResult = state.execute(env.getExecutor(), this);
- if (executionResult == null) return null;
-
- final RunContentBuilder contentBuilder = new RunContentBuilder(this, executionResult, env);
- return contentBuilder.showRunContent(contentToReuse);
+ if (executionResult == null) {
+ return null;
+ }
+ return new RunContentBuilder(executionResult, env).showRunContent(contentToReuse);
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java b/platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java
index 45393c328e69..ecc8fa553121 100644
--- a/platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/runners/FakeRerunAction.java
@@ -15,33 +15,127 @@
*/
package com.intellij.execution.runners;
+import com.intellij.execution.ExecutionBundle;
+import com.intellij.execution.ExecutorRegistry;
+import com.intellij.execution.impl.ExecutionManagerImpl;
+import com.intellij.execution.process.ProcessHandler;
+import com.intellij.execution.ui.RunContentDescriptor;
+import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.project.DumbAware;
import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
/**
* @author Roman.Chernyatchik
*/
-public class FakeRerunAction extends AnAction implements DumbAware {
- protected static final List<RestartAction> registry = ContainerUtil.createLockFreeCopyOnWriteList();
+class FakeRerunAction extends AnAction implements DumbAware {
+ @SuppressWarnings("deprecation")
+ static final List<RestartAction> registry = ContainerUtil.createLockFreeCopyOnWriteList();
@Override
- public void actionPerformed(AnActionEvent e) {
- RestartAction action = RestartAction.findActualAction();
- if (action != null && action.isEnabled()) {
- action.actionPerformed(e);
+ public void update(AnActionEvent event) {
+ Presentation presentation = event.getPresentation();
+ ExecutionEnvironment environment = getEnvironment(event);
+ if (environment != null) {
+ presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", environment.getRunProfile().getName()));
+ presentation.setIcon(ExecutionManagerImpl.isProcessRunning(getDescriptor(event)) ? AllIcons.Actions.Restart : environment.getExecutor().getIcon());
+ presentation.setEnabledAndVisible(isEnabled(event));
+ return;
}
+
+ FakeRerunAction action = findActualAction(event);
+ presentation.setEnabled(action != null && action.isEnabled(event));
+ presentation.setVisible(false);
}
@Override
- public void update(AnActionEvent e) {
- final Presentation presentation = e.getPresentation();
- RestartAction action = RestartAction.findActualAction();
- presentation.setEnabled(action != null && action.isEnabled());
- presentation.setVisible(false);
+ public void actionPerformed(AnActionEvent event) {
+ ExecutionEnvironment environment = getEnvironment(event);
+ if (environment != null) {
+ ExecutionUtil.restart(environment);
+ return;
+ }
+
+ FakeRerunAction action = findActualAction(event);
+ if (action != null && action.isEnabled(event)) {
+ action.actionPerformed(event);
+ }
+ }
+
+ @Nullable
+ protected RunContentDescriptor getDescriptor(AnActionEvent event) {
+ return event.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
+ }
+
+ @Nullable
+ protected ExecutionEnvironment getEnvironment(AnActionEvent event) {
+ return event.getData(LangDataKeys.EXECUTION_ENVIRONMENT);
+ }
+
+ protected boolean isEnabled(AnActionEvent event) {
+ RunContentDescriptor descriptor = getDescriptor(event);
+ ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
+ ExecutionEnvironment environment = getEnvironment(event);
+ return environment != null &&
+ !ExecutorRegistry.getInstance().isStarting(environment) &&
+ !(processHandler != null && processHandler.isProcessTerminating());
+ }
+
+ @Nullable
+ private JComponent getRunComponent(@NotNull AnActionEvent event) {
+ RunContentDescriptor descriptor = getDescriptor(event);
+ return descriptor == null ? null : descriptor.getComponent();
+ }
+
+ @Nullable
+ private static FakeRerunAction findActualAction(@NotNull final AnActionEvent event) {
+ if (registry.isEmpty()) {
+ return null;
+ }
+
+ List<FakeRerunAction> candidates = new ArrayList<FakeRerunAction>(registry);
+ Collections.sort(candidates, new Comparator<FakeRerunAction>() {
+ @Override
+ public int compare(@NotNull FakeRerunAction action1, @NotNull FakeRerunAction action2) {
+ boolean isActive1 = action1.isEnabled(event);
+ if (isActive1 != action2.isEnabled(event)) {
+ return isActive1 ? -1 : 1;
+ }
+
+ JComponent component1 = action1.getRunComponent(event);
+ JComponent component2 = action2.getRunComponent(event);
+ Window window1 = component1 == null ? null : SwingUtilities.windowForComponent(component1);
+ Window window2 = component2 == null ? null : SwingUtilities.windowForComponent(component2);
+ if (window1 == null) {
+ return 1;
+ }
+ if (window2 == null) {
+ return -1;
+ }
+
+ boolean showing1 = component1.isShowing();
+ boolean showing2 = component2.isShowing();
+ if (showing1 && !showing2) {
+ return -1;
+ }
+ if (showing2 && !showing1) {
+ return 1;
+ }
+ return (window1.isActive() ? -1 : 1);
+ }
+ });
+ return candidates.get(0);
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java b/platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java
index c4e8fd0a3e0d..8d3bf8663598 100644
--- a/platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/runners/RerunTestsAction.java
@@ -1,13 +1,11 @@
package com.intellij.execution.runners;
-import com.intellij.execution.ExecutionManager;
-import com.intellij.execution.ExecutorRegistry;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -25,41 +23,27 @@ import java.util.List;
* @author Sergey Simonchik
*/
public class RerunTestsAction extends DumbAwareAction implements AnAction.TransparentUpdate {
-
public static final String ID = "RerunTests";
- private static final List<RerunInfo> REGISTRY = ContainerUtil.createLockFreeCopyOnWriteList();
+ private static final List<ExecutionEnvironment> REGISTRY = ContainerUtil.createLockFreeCopyOnWriteList();
- public static void register(@NotNull RunContentDescriptor descriptor,
- @NotNull ExecutionEnvironment env,
- @NotNull ProgramRunner runner) {
- final RerunInfo rerunInfo = new RerunInfo(descriptor, env, runner);
- REGISTRY.add(rerunInfo);
- Disposer.register(descriptor, new Disposable() {
+ public static void register(@NotNull final ExecutionEnvironment environment) {
+ REGISTRY.add(environment);
+ Disposer.register(environment, new Disposable() {
@Override
public void dispose() {
- REGISTRY.remove(rerunInfo);
+ REGISTRY.remove(environment);
}
});
}
@Override
public void actionPerformed(AnActionEvent e) {
- DataContext dataContext = e.getDataContext();
- Project project = CommonDataKeys.PROJECT.getData(dataContext);
- if (project == null) {
- return;
- }
- ExecutionManager executionManager = ExecutionManager.getInstance(project);
- for (RerunInfo rerunInfo : REGISTRY) {
- RunContentDescriptor descriptor = rerunInfo.getDescriptor();
- if (!Disposer.isDisposed(descriptor)) {
- ExecutionEnvironment env = rerunInfo.getEnv();
- ProgramRunner runner = rerunInfo.getRunner();
- ProcessHandler processHandler = descriptor.getProcessHandler();
+ for (ExecutionEnvironment environment : REGISTRY) {
+ if (!Disposer.isDisposed(environment)) {
+ RunContentDescriptor descriptor = environment.getContentToReuse();
+ ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
if (processHandler != null && processHandler.isProcessTerminated()) {
- if (!ExecutorRegistry.getInstance().isStarting(project, env.getExecutor().getId(), runner.getRunnerId())) {
- executionManager.restartRunProfile(runner, env, descriptor);
- }
+ ExecutionUtil.restart(environment);
}
}
}
@@ -67,35 +51,6 @@ public class RerunTestsAction extends DumbAwareAction implements AnAction.Transp
@Override
public void update(AnActionEvent e) {
- Presentation presentation = e.getPresentation();
- presentation.setEnabled(true);
- }
-
- private static class RerunInfo {
-
- private final RunContentDescriptor myDescriptor;
- private final ExecutionEnvironment myEnv;
- private final ProgramRunner myRunner;
-
- public RerunInfo(@NotNull RunContentDescriptor descriptor,
- @NotNull ExecutionEnvironment env,
- @NotNull ProgramRunner runner) {
- myDescriptor = descriptor;
- myEnv = env;
- myRunner = runner;
- }
-
- private RunContentDescriptor getDescriptor() {
- return myDescriptor;
- }
-
- private ExecutionEnvironment getEnv() {
- return myEnv;
- }
-
- private ProgramRunner getRunner() {
- return myRunner;
- }
+ e.getPresentation().setEnabled(true);
}
-
}
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java
index 20b29c2de994..1ab3cee3c8cb 100644
--- a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java
+++ b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,129 +15,69 @@
*/
package com.intellij.execution.runners;
-import com.intellij.execution.ExecutionBundle;
-import com.intellij.execution.ExecutionManager;
import com.intellij.execution.Executor;
-import com.intellij.execution.ExecutorRegistry;
-import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.RunContentDescriptor;
-import com.intellij.icons.AllIcons;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.CustomShortcutSet;
+import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.DumbAware;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
+@Deprecated
/**
- * @author dyoma
+ * to remove in IDEA 15
*/
public class RestartAction extends FakeRerunAction implements DumbAware, AnAction.TransparentUpdate, Disposable {
-
- private final ProgramRunner myRunner;
- @NotNull private final RunContentDescriptor myDescriptor;
- @NotNull private final Executor myExecutor;
+ private final RunContentDescriptor myDescriptor;
private final ExecutionEnvironment myEnvironment;
- public RestartAction(@NotNull final Executor executor,
- final ProgramRunner runner,
- @NotNull final RunContentDescriptor descriptor,
- @NotNull final ExecutionEnvironment env) {
+ public RestartAction(@NotNull RunContentDescriptor descriptor, @NotNull ExecutionEnvironment environment) {
+ //noinspection deprecation
+ this(environment.getExecutor(), null, descriptor, environment);
+ }
+
+ @Deprecated
+ /**
+ * @deprecated environment must provide runner id
+ * to remove in IDEA 15
+ */
+ public RestartAction(@SuppressWarnings("UnusedParameters") @NotNull Executor executor,
+ @Nullable ProgramRunner runner,
+ @NotNull RunContentDescriptor descriptor,
+ @NotNull ExecutionEnvironment environment) {
Disposer.register(descriptor, this);
- registry.add(this);
+ FakeRerunAction.registry.add(this);
- myEnvironment = env;
+ myEnvironment = runner == null ? environment : RunContentBuilder.fix(environment, runner);
getTemplatePresentation().setEnabled(false);
- myRunner = runner;
myDescriptor = descriptor;
- myExecutor = executor;
- // see IDEADEV-698
-
- if (descriptor.getRestarter() == null) {
- descriptor.setRestarter(new Runnable() {
- @Override
- public void run() {
- restart();
- }
- });
- }
}
@Override
public void dispose() {
- registry.remove(this);
- }
-
- @Nullable
- static RestartAction findActualAction() {
- if (registry.isEmpty())
- return null;
- List<RestartAction> candidates = new ArrayList<RestartAction>(registry);
- Collections.sort(candidates, new Comparator<RestartAction>() {
- @Override
- public int compare(RestartAction action1, RestartAction action2) {
- boolean isActive1 = action1.isEnabled();
- boolean isActive2 = action2.isEnabled();
- if (isActive1 != isActive2)
- return isActive1? - 1 : 1;
- Window window1 = SwingUtilities.windowForComponent(action1.myDescriptor.getComponent());
- Window window2 = SwingUtilities.windowForComponent(action2.myDescriptor.getComponent());
- if (window1 == null)
- return 1;
- if (window2 == null)
- return -1;
- boolean showing1 = action1.myDescriptor.getComponent().isShowing();
- boolean showing2 = action2.myDescriptor.getComponent().isShowing();
- if (showing1 && !showing2)
- return -1;
- if (showing2 && !showing1)
- return 1;
- return (window1.isActive() ? -1 : 1);
- }
- });
- return candidates.get(0);
+ FakeRerunAction.registry.remove(this);
}
@Override
- public void actionPerformed(final AnActionEvent e) {
- restart();
- }
-
- public void restart() {
- Project project = myEnvironment.getProject();
- if (!ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), myRunner.getRunnerId()))
- ExecutionManager.getInstance(project).restartRunProfile(myRunner, myEnvironment, myDescriptor);
+ @NotNull
+ protected RunContentDescriptor getDescriptor(AnActionEvent event) {
+ return myDescriptor;
}
@Override
- public void update(final AnActionEvent event) {
- final Presentation presentation = event.getPresentation();
- String name = myEnvironment.getRunProfile().getName();
- ProcessHandler processHandler = myDescriptor.getProcessHandler();
- final boolean isRunning = processHandler != null && !processHandler.isProcessTerminated();
-
- presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", name));
- presentation.setIcon(isRunning ? AllIcons.Actions.Restart : myExecutor.getIcon());
- presentation.setEnabled(isEnabled());
- }
-
- boolean isEnabled() {
- ProcessHandler processHandler = myDescriptor.getProcessHandler();
- boolean isTerminating = processHandler != null && processHandler.isProcessTerminating();
- boolean isStarting = ExecutorRegistry.getInstance().isStarting(myEnvironment.getProject(), myExecutor.getId(), myRunner.getRunnerId());
- return !isStarting && !isTerminating;
+ @NotNull
+ protected ExecutionEnvironment getEnvironment(AnActionEvent event) {
+ return myEnvironment;
}
- public void registerShortcut(final JComponent component) {
+ public void registerShortcut(JComponent component) {
registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_RERUN)),
component);
}
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java b/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java
index bb6d206f1eb9..f16f8dadfb45 100644
--- a/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java
+++ b/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,9 +15,6 @@
*/
package com.intellij.execution.runners;
-import com.intellij.diagnostic.logging.LogConsoleManagerBase;
-import com.intellij.diagnostic.logging.LogFilesManager;
-import com.intellij.diagnostic.logging.OutputFileUtil;
import com.intellij.execution.DefaultExecutionResult;
import com.intellij.execution.ExecutionManager;
import com.intellij.execution.ExecutionResult;
@@ -32,7 +29,6 @@ import com.intellij.execution.ui.actions.CloseAction;
import com.intellij.execution.ui.layout.PlaceInGrid;
import com.intellij.icons.AllIcons;
import com.intellij.ide.actions.ContextHelpAction;
-import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
@@ -40,115 +36,91 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.tabs.PinToolwindowTabAction;
+import com.intellij.util.SmartList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
-/**
- * @author dyoma
- */
-public class RunContentBuilder extends LogConsoleManagerBase {
+public class RunContentBuilder extends RunTab {
@NonNls private static final String JAVA_RUNNER = "JavaRunner";
- private final ProgramRunner myRunner;
- private final ArrayList<AnAction> myRunnerActions = new ArrayList<AnAction>();
- private ExecutionResult myExecutionResult;
-
- private final LogFilesManager myManager;
-
- private RunnerLayoutUi myUi;
- private final Executor myExecutor;
+ private final List<AnAction> myRunnerActions = new SmartList<AnAction>();
+ private final ExecutionResult myExecutionResult;
/**
- * @deprecated use {@link #RunContentBuilder(ProgramRunner, com.intellij.execution.ExecutionResult, ExecutionEnvironment)}
+ * @deprecated use {@link #RunContentBuilder(com.intellij.execution.ExecutionResult, ExecutionEnvironment)}
+ * to remove in IDEA 14
*/
+ @SuppressWarnings("UnusedParameters")
public RunContentBuilder(@NotNull Project project,
ProgramRunner runner,
Executor executor,
ExecutionResult executionResult,
@NotNull ExecutionEnvironment environment) {
+ //noinspection deprecation
this(runner, executionResult, environment);
}
+ /**
+ * @deprecated use {@link #RunContentBuilder(com.intellij.execution.ExecutionResult, ExecutionEnvironment)}
+ * to remove in IDEA 15
+ */
public RunContentBuilder(ProgramRunner runner,
ExecutionResult executionResult,
@NotNull ExecutionEnvironment environment) {
- super(environment.getProject(), SearchScopeProvider.createSearchScope(environment.getProject(), environment.getRunProfile()));
- myRunner = runner;
- myExecutor = environment.getExecutor();
- myManager = new LogFilesManager(environment.getProject(), this, this);
+ this(executionResult, fix(environment, runner));
+ }
+
+ public RunContentBuilder(@NotNull ExecutionResult executionResult, @NotNull ExecutionEnvironment environment) {
+ super(environment, getRunnerType(executionResult.getExecutionConsole()));
+
myExecutionResult = executionResult;
- setEnvironment(environment);
+ myUi.getOptions().setMoveToGridActionEnabled(false).setMinimizeActionEnabled(false);
}
- /**
- * @deprecated use {@link #RunContentBuilder(com.intellij.openapi.project.Project, ProgramRunner, com.intellij.execution.Executor, com.intellij.execution.ExecutionResult, ExecutionEnvironment)}
- */
- public RunContentBuilder(final Project project, final ProgramRunner runner, Executor executor) {
- super(project);
- myRunner = runner;
- myExecutor = executor;
- myManager = new LogFilesManager(project, this, this);
+ @NotNull
+ public static ExecutionEnvironment fix(@NotNull ExecutionEnvironment environment, @Nullable ProgramRunner runner) {
+ if (runner == null || runner.equals(environment.getRunner())) {
+ return environment;
+ }
+ else {
+ return new ExecutionEnvironmentBuilder(environment).runner(runner).build();
+ }
}
+ @SuppressWarnings("UnusedDeclaration")
@Deprecated
@NotNull
+ /**
+ * @deprecated to remove in IDEA 15
+ */
public static GlobalSearchScope createSearchScope(Project project, RunProfile runProfile) {
return SearchScopeProvider.createSearchScope(project, runProfile);
}
+ @NotNull
public ExecutionResult getExecutionResult() {
return myExecutionResult;
}
- @Deprecated
- public void setExecutionResult(final ExecutionResult executionResult) {
- myExecutionResult = executionResult;
- }
-
- @Override
- public void setEnvironment(@NotNull final ExecutionEnvironment env) {
- super.setEnvironment(env);
- final RunProfile profile = env.getRunProfile();
- if (profile instanceof RunConfigurationBase) {
- myManager.registerFileMatcher((RunConfigurationBase)profile);
- }
- }
-
public void addAction(@NotNull final AnAction action) {
myRunnerActions.add(action);
}
+ @NotNull
private RunContentDescriptor createDescriptor() {
- if (myExecutionResult == null) {
- throw new IllegalStateException("Missing ExecutionResult");
- }
-
- ExecutionEnvironment environment = getEnvironment();
- if (environment == null) {
- throw new IllegalStateException("Missing ExecutionEnvironment");
- }
-
- final RunProfile profile = environment.getRunProfile();
-
- final ExecutionConsole console = myExecutionResult.getExecutionConsole();
- String runnerType = JAVA_RUNNER;
- if (console instanceof ExecutionConsoleEx) {
- final String id = ((ExecutionConsoleEx)console).getExecutionConsoleId();
- if (id != null) {
- runnerType = JAVA_RUNNER + "." + id;
- }
- }
- myUi = RunnerLayoutUi.Factory.getInstance(getProject()).create(runnerType, myExecutor.getId(), profile.getName(), this);
- myUi.getOptions().setMoveToGridActionEnabled(false).setMinimizeActionEnabled(false);
-
+ final RunProfile profile = getEnvironment().getRunProfile();
if (ApplicationManager.getApplication().isUnitTestMode()) {
- return new MyRunContentDescriptor(profile, myExecutionResult, myUi.getComponent(), this);
+ RunContentDescriptor contentDescriptor = new RunContentDescriptor(profile, myExecutionResult, myUi);
+ Disposer.register(contentDescriptor, this);
+ return contentDescriptor;
}
+ final ExecutionConsole console = myExecutionResult.getExecutionConsole();
if (console != null) {
if (console instanceof ExecutionConsoleEx) {
((ExecutionConsoleEx)console).buildUi(myUi);
@@ -156,19 +128,17 @@ public class RunContentBuilder extends LogConsoleManagerBase {
else {
buildConsoleUiDefault(myUi, console);
}
- if (profile instanceof RunConfigurationBase) {
- myManager.initLogConsoles((RunConfigurationBase)profile, myExecutionResult.getProcessHandler());
- OutputFileUtil.attachDumpListener((RunConfigurationBase)profile, myExecutionResult.getProcessHandler(), console);
- }
+ initLogConsoles(profile, myExecutionResult.getProcessHandler(), console);
}
- MyRunContentDescriptor contentDescriptor = new MyRunContentDescriptor(profile, myExecutionResult, myUi.getComponent(), this);
- myUi.getOptions().setLeftToolbar(createActionToolbar(contentDescriptor, myUi.getComponent()), ActionPlaces.UNKNOWN);
+ RunContentDescriptor contentDescriptor = new RunContentDescriptor(profile, myExecutionResult, myUi);
+ Disposer.register(contentDescriptor, this);
+ myUi.getOptions().setLeftToolbar(createActionToolbar(contentDescriptor), ActionPlaces.UNKNOWN);
if (profile instanceof RunConfigurationBase) {
if (console instanceof ObservableConsoleView && !ApplicationManager.getApplication().isUnitTestMode()) {
((ObservableConsoleView)console).addChangeListener(new ConsoleToFrontListener((RunConfigurationBase)profile,
getProject(),
- myExecutor,
+ getEnvironment().getExecutor(),
contentDescriptor,
myUi),
this);
@@ -178,10 +148,22 @@ public class RunContentBuilder extends LogConsoleManagerBase {
return contentDescriptor;
}
+ @NotNull
+ private static String getRunnerType(@Nullable ExecutionConsole console) {
+ String runnerType = JAVA_RUNNER;
+ if (console instanceof ExecutionConsoleEx) {
+ String id = ((ExecutionConsoleEx)console).getExecutionConsoleId();
+ if (id != null) {
+ return JAVA_RUNNER + '.' + id;
+ }
+ }
+ return runnerType;
+ }
+
public static void buildConsoleUiDefault(RunnerLayoutUi ui, final ExecutionConsole console) {
final Content consoleContent = ui.createContent(ExecutionConsole.CONSOLE_CONTENT_ID, console.getComponent(), "Console",
AllIcons.Debugger.Console,
- console.getPreferredFocusableComponent());
+ console.getPreferredFocusableComponent());
consoleContent.setCloseable(false);
addAdditionalConsoleEditorActions(console, consoleContent);
@@ -191,22 +173,18 @@ public class RunContentBuilder extends LogConsoleManagerBase {
public static void addAdditionalConsoleEditorActions(final ExecutionConsole console, final Content consoleContent) {
final DefaultActionGroup consoleActions = new DefaultActionGroup();
if (console instanceof ConsoleView) {
- AnAction[] actions = ((ConsoleView)console).createConsoleActions();
- for (AnAction goaction: actions) {
- consoleActions.add(goaction);
+ for (AnAction action : ((ConsoleView)console).createConsoleActions()) {
+ consoleActions.add(action);
}
}
consoleContent.setActions(consoleActions, ActionPlaces.UNKNOWN, console.getComponent());
}
- private ActionGroup createActionToolbar(final RunContentDescriptor contentDescriptor, final JComponent component) {
+ @NotNull
+ private ActionGroup createActionToolbar(@NotNull RunContentDescriptor contentDescriptor) {
final DefaultActionGroup actionGroup = new DefaultActionGroup();
-
- final RestartAction restartAction = new RestartAction(myExecutor, myRunner, contentDescriptor, getEnvironment());
- restartAction.registerShortcut(component);
- actionGroup.add(restartAction);
-
+ actionGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_RERUN));
if (myExecutionResult instanceof DefaultExecutionResult) {
final AnAction[] actions = ((DefaultExecutionResult)myExecutionResult).getRestartActions();
if (actions != null) {
@@ -217,15 +195,14 @@ public class RunContentBuilder extends LogConsoleManagerBase {
}
}
- final AnAction stopAction = ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM);
- actionGroup.add(stopAction);
+ actionGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_STOP_PROGRAM));
if (myExecutionResult instanceof DefaultExecutionResult) {
actionGroup.addAll(((DefaultExecutionResult)myExecutionResult).getAdditionalStopActions());
}
actionGroup.addAll(myExecutionResult.getActions());
- for (final AnAction anAction : myRunnerActions) {
+ for (AnAction anAction : myRunnerActions) {
if (anAction != null) {
actionGroup.add(anAction);
}
@@ -238,9 +215,9 @@ public class RunContentBuilder extends LogConsoleManagerBase {
actionGroup.add(myUi.getOptions().getLayoutActions());
actionGroup.addSeparator();
actionGroup.add(PinToolwindowTabAction.getPinAction());
- actionGroup.add(new CloseAction(myExecutor, contentDescriptor, getProject()));
+ actionGroup.add(new CloseAction(getEnvironment().getExecutor(), contentDescriptor, getProject()));
final String helpId = contentDescriptor.getHelpId();
- actionGroup.add(new ContextHelpAction(helpId != null ? helpId : myExecutor.getHelpId()));
+ actionGroup.add(new ContextHelpAction(helpId != null ? helpId : getEnvironment().getExecutor().getHelpId()));
return actionGroup;
}
@@ -252,14 +229,10 @@ public class RunContentBuilder extends LogConsoleManagerBase {
/**
* @param reuseContent see {@link RunContentDescriptor#myContent}
*/
- public RunContentDescriptor showRunContent(final RunContentDescriptor reuseContent) {
- final RunContentDescriptor descriptor = createDescriptor();
- if (reuseContent != null) {
- descriptor.setAttachedContent(reuseContent.getAttachedContent());
- if (reuseContent.isReuseToolWindowActivation()) {
- descriptor.setActivateToolWindowWhenAdded(reuseContent.isActivateToolWindowWhenAdded());
- }
- }
+ public RunContentDescriptor showRunContent(@Nullable RunContentDescriptor reuseContent) {
+ RunContentDescriptor descriptor = createDescriptor();
+ RunContentManagerImpl.copyContentAndBehavior(descriptor, reuseContent);
+ myRunContentDescriptor = descriptor;
return descriptor;
}
@@ -273,21 +246,6 @@ public class RunContentBuilder extends LogConsoleManagerBase {
return AllIcons.Debugger.Console;
}
- private static class MyRunContentDescriptor extends RunContentDescriptor {
- private final Disposable myAdditionalDisposable;
-
- public MyRunContentDescriptor(final RunProfile profile, final ExecutionResult executionResult, final JComponent component, @NotNull Disposable additionalDisposable) {
- super(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), component, profile.getName(), profile.getIcon());
- myAdditionalDisposable = additionalDisposable;
- }
-
- @Override
- public void dispose() {
- Disposer.dispose(myAdditionalDisposable);
- super.dispose();
- }
- }
-
public static class ConsoleToFrontListener implements ConsoleViewImpl.ChangeListener {
@NotNull private final RunConfigurationBase myRunConfigurationBase;
@NotNull private final Project myProject;
diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java b/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java
new file mode 100644
index 000000000000..2edc2098ce15
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/execution/runners/RunTab.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2000-2014 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.execution.runners;
+
+import com.intellij.diagnostic.logging.LogConsoleManagerBase;
+import com.intellij.diagnostic.logging.LogFilesManager;
+import com.intellij.diagnostic.logging.OutputFileUtil;
+import com.intellij.execution.configurations.RunConfigurationBase;
+import com.intellij.execution.configurations.RunProfile;
+import com.intellij.execution.configurations.SearchScopeProvider;
+import com.intellij.execution.process.ProcessHandler;
+import com.intellij.execution.ui.ExecutionConsole;
+import com.intellij.execution.ui.RunContentDescriptor;
+import com.intellij.execution.ui.RunnerLayoutUi;
+import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.search.GlobalSearchScope;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public abstract class RunTab extends LogConsoleManagerBase implements DataProvider {
+ @NotNull
+ protected final RunnerLayoutUi myUi;
+ protected final LogFilesManager myManager;
+ protected RunContentDescriptor myRunContentDescriptor;
+
+ protected RunTab(@NotNull ExecutionEnvironment environment, @NotNull String runnerType) {
+ this(environment.getProject(),
+ SearchScopeProvider.createSearchScope(environment.getProject(), environment.getRunProfile()),
+ runnerType,
+ environment.getExecutor().getId(),
+ environment.getRunProfile().getName());
+
+ setEnvironment(environment);
+ }
+
+ protected RunTab(@NotNull Project project, @NotNull GlobalSearchScope searchScope, @NotNull String runnerType, @NotNull String runnerTitle, @NotNull String sessionName) {
+ super(project, searchScope);
+
+ myManager = new LogFilesManager(project, this, this);
+
+ myUi = RunnerLayoutUi.Factory.getInstance(getProject()).create(runnerType, runnerTitle, sessionName, this);
+ myUi.getContentManager().addDataProvider(this);
+ }
+
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ if (LangDataKeys.RUN_PROFILE.is(dataId)) {
+ ExecutionEnvironment environment = getEnvironment();
+ return environment == null ? null : environment.getRunProfile();
+ }
+ else if (LangDataKeys.EXECUTION_ENVIRONMENT.is(dataId)) {
+ return getEnvironment();
+ }
+ else if (LangDataKeys.RUN_CONTENT_DESCRIPTOR.is(dataId)) {
+ return myRunContentDescriptor;
+ }
+ return null;
+ }
+
+ @Override
+ public final void setEnvironment(@NotNull ExecutionEnvironment environment) {
+ super.setEnvironment(environment);
+
+ RunProfile profile = environment.getRunProfile();
+ if (profile instanceof RunConfigurationBase) {
+ myManager.registerFileMatcher((RunConfigurationBase)profile);
+ }
+ }
+
+ protected final void initLogConsoles(@NotNull RunProfile runConfiguration, @Nullable ProcessHandler processHandler, @Nullable ExecutionConsole console) {
+ if (runConfiguration instanceof RunConfigurationBase && processHandler != null) {
+ RunConfigurationBase configuration = (RunConfigurationBase)runConfiguration;
+ myManager.initLogConsoles(configuration, processHandler);
+ OutputFileUtil.attachDumpListener(configuration, processHandler, console);
+ }
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java
index 73ec463954cd..c9dae095522c 100644
--- a/platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/ui/RunContentManagerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -46,12 +46,14 @@ import com.intellij.openapi.wm.ToolWindowAnchor;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.ex.ToolWindowManagerAdapter;
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
+import com.intellij.ui.AppUIUtil;
import com.intellij.ui.content.*;
import com.intellij.ui.docking.DockManager;
+import com.intellij.util.SmartList;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.HashMap;
-import com.intellij.util.messages.Topic;
+import gnu.trove.THashMap;
+import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -59,60 +61,59 @@ import javax.swing.*;
import java.util.*;
public class RunContentManagerImpl implements RunContentManager, Disposable {
- public static final Topic<RunContentWithExecutorListener> RUN_CONTENT_TOPIC =
- Topic.create("Run Content", RunContentWithExecutorListener.class);
public static final Key<Boolean> ALWAYS_USE_DEFAULT_STOPPING_BEHAVIOUR_KEY = Key.create("ALWAYS_USE_DEFAULT_STOPPING_BEHAVIOUR_KEY");
- private static final Logger LOG = Logger.getInstance("#com.intellij.execution.ui.RunContentManagerImpl");
- private static final Key<RunContentDescriptor> DESCRIPTOR_KEY = new Key<RunContentDescriptor>("Descriptor");
+ private static final Logger LOG = Logger.getInstance(RunContentManagerImpl.class);
+ private static final Key<RunContentDescriptor> DESCRIPTOR_KEY = Key.create("Descriptor");
private final Project myProject;
- private DockableGridContainerFactory myContentFactory;
- private final Map<String, ContentManager> myToolwindowIdToContentManagerMap = new HashMap<String, ContentManager>();
+ private final Map<String, ContentManager> myToolwindowIdToContentManagerMap = new THashMap<String, ContentManager>();
- private final Map<RunContentListener, Disposable> myListeners = new HashMap<RunContentListener, Disposable>();
- private final LinkedList<String> myToolwindowIdZbuffer = new LinkedList<String>();
+ private final Map<RunContentListener, Disposable> myListeners = new THashMap<RunContentListener, Disposable>();
+ private final LinkedList<String> myToolwindowIdZBuffer = new LinkedList<String>();
- public RunContentManagerImpl(Project project, DockManager dockManager) {
+ public RunContentManagerImpl(@NotNull Project project, @NotNull DockManager dockManager) {
myProject = project;
- myContentFactory = new DockableGridContainerFactory();
- dockManager.register(DockableGridContainerFactory.TYPE, myContentFactory);
- Disposer.register(myProject, myContentFactory);
+ DockableGridContainerFactory containerFactory = new DockableGridContainerFactory();
+ dockManager.register(DockableGridContainerFactory.TYPE, containerFactory);
+ Disposer.register(myProject, containerFactory);
+
+ AppUIUtil.invokeOnEdt(new Runnable() {
+ @Override
+ public void run() {
+ init();
+ }
+ }, myProject.getDisposed());
}
- public void init() {
- final Executor[] executors = ExecutorRegistry.getInstance().getRegisteredExecutors();
- for (Executor executor : executors) {
- registerToolwindow(executor);
+ // must be called on EDT
+ private void init() {
+ ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(myProject);
+ if (toolWindowManager == null) {
+ return;
}
- if (ToolWindowManager.getInstance(myProject) == null) return;
+ for (Executor executor : ExecutorRegistry.getInstance().getRegisteredExecutors()) {
+ registerToolwindow(executor, toolWindowManager);
+ }
- // To ensure ToolwindowManager had already initialized in its projectOpened.
- SwingUtilities.invokeLater(new Runnable() {
+ toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter() {
@Override
- public void run() {
- if (myProject.isDisposed()) return;
- ((ToolWindowManagerEx)ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {
- @Override
- public void stateChanged() {
- if (myProject.isDisposed()) return;
-
- ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
-
- Set<String> currentWindows = new HashSet<String>();
- String[] toolWindowIds = toolWindowManager.getToolWindowIds();
+ public void stateChanged() {
+ if (myProject.isDisposed()) {
+ return;
+ }
- ContainerUtil.addAll(currentWindows, toolWindowIds);
- myToolwindowIdZbuffer.retainAll(currentWindows);
+ ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
+ Set<String> currentWindows = new THashSet<String>();
+ ContainerUtil.addAll(currentWindows, toolWindowManager.getToolWindowIds());
+ myToolwindowIdZBuffer.retainAll(currentWindows);
- final String activeToolWindowId = toolWindowManager.getActiveToolWindowId();
- if (activeToolWindowId != null) {
- if (myToolwindowIdZbuffer.remove(activeToolWindowId)) {
- myToolwindowIdZbuffer.addFirst(activeToolWindowId);
- }
- }
+ final String activeToolWindowId = toolWindowManager.getActiveToolWindowId();
+ if (activeToolWindowId != null) {
+ if (myToolwindowIdZBuffer.remove(activeToolWindowId)) {
+ myToolwindowIdZBuffer.addFirst(activeToolWindowId);
}
- });
+ }
}
});
}
@@ -121,25 +122,15 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
public void dispose() {
}
- private void unregisterToolwindow(final String id) {
- final ContentManager manager = myToolwindowIdToContentManagerMap.get(id);
- manager.removeAllContents(true);
- myToolwindowIdToContentManagerMap.remove(id);
- myToolwindowIdZbuffer.remove(id);
- }
-
- private void registerToolwindow(@NotNull final Executor executor) {
+ private void registerToolwindow(@NotNull final Executor executor, @NotNull ToolWindowManagerEx toolWindowManager) {
final String toolWindowId = executor.getToolWindowId();
- final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
- if (toolWindowManager == null) return; //headless environment
if (toolWindowManager.getToolWindow(toolWindowId) != null) {
return;
}
- final ToolWindow toolWindow = toolWindowManager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM, this, true);
-
+ ToolWindow toolWindow = toolWindowManager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM, this, true);
final ContentManager contentManager = toolWindow.getContentManager();
- class MyDataProvider implements DataProvider {
+ contentManager.addDataProvider(new DataProvider() {
private int myInsideGetData = 0;
@Override
@@ -157,31 +148,30 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
myInsideGetData--;
}
}
- }
- contentManager.addDataProvider(new MyDataProvider());
+ });
toolWindow.setIcon(executor.getToolWindowIcon());
new ContentManagerWatcher(toolWindow, contentManager);
contentManager.addContentManagerListener(new ContentManagerAdapter() {
@Override
public void selectionChanged(final ContentManagerEvent event) {
- final Content content = event.getContent();
- final RunContentDescriptor descriptor = content != null ? getRunContentDescriptorByContent(content) : null;
- getSyncPublisher().contentSelected(descriptor, executor);
+ Content content = event.getContent();
+ getSyncPublisher().contentSelected(content == null ? null : getRunContentDescriptorByContent(content), executor);
}
});
myToolwindowIdToContentManagerMap.put(toolWindowId, contentManager);
Disposer.register(contentManager, new Disposable() {
@Override
public void dispose() {
- unregisterToolwindow(toolWindowId);
+ myToolwindowIdToContentManagerMap.remove(toolWindowId).removeAllContents(true);
+ myToolwindowIdZBuffer.remove(toolWindowId);
}
});
- myToolwindowIdZbuffer.addLast(toolWindowId);
+ myToolwindowIdZBuffer.addLast(toolWindowId);
}
private RunContentWithExecutorListener getSyncPublisher() {
- return myProject.getMessageBus().syncPublisher(RUN_CONTENT_TOPIC);
+ return myProject.getMessageBus().syncPublisher(TOPIC);
}
@Override
@@ -193,24 +183,19 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
toFrontRunContent(requestor, descriptor);
}
-
@Override
public void toFrontRunContent(final Executor requestor, final RunContentDescriptor descriptor) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- final ContentManager contentManager = getContentManagerForRunner(requestor);
-
- final Content content = getRunContentByDescriptor(contentManager, descriptor);
-
- if (contentManager != null && content != null) {
+ ContentManager contentManager = getContentManagerForRunner(requestor);
+ Content content = getRunContentByDescriptor(contentManager, descriptor);
+ if (content != null) {
contentManager.setSelectedContent(content);
-
- final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(requestor.getToolWindowId());
- toolWindow.show(null);
+ ToolWindowManager.getInstance(myProject).getToolWindow(requestor.getToolWindowId()).show(null);
}
}
- });
+ }, myProject.getDisposed());
}
@Override
@@ -218,37 +203,25 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- if (!myProject.isDisposed()) {
- final String toolWindowId = executor.getToolWindowId();
- final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(toolWindowId);
- if (toolWindow != null) {
- toolWindow.hide(null);
- }
+ ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(executor.getToolWindowId());
+ if (toolWindow != null) {
+ toolWindow.hide(null);
}
}
- });
+ }, myProject.getDisposed());
}
@Override
@Nullable
public RunContentDescriptor getSelectedContent(final Executor executor) {
- final ContentManager contentManager = getContentManagerForRunner(executor);
- if (contentManager != null) {
- final Content selectedContent = contentManager.getSelectedContent();
- if (selectedContent != null) {
- final RunContentDescriptor runContentDescriptorByContent = getRunContentDescriptorByContent(selectedContent);
- if (runContentDescriptorByContent != null) {
- return runContentDescriptorByContent;
- }
- }
- }
- return null;
+ final Content selectedContent = getContentManagerForRunner(executor).getSelectedContent();
+ return selectedContent != null ? getRunContentDescriptorByContent(selectedContent) : null;
}
@Override
@Nullable
public RunContentDescriptor getSelectedContent() {
- for (String activeWindow : myToolwindowIdZbuffer) {
+ for (String activeWindow : myToolwindowIdZBuffer) {
final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(activeWindow);
if (contentManager == null) {
continue;
@@ -280,32 +253,30 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
@Override
- public void showRunContent(@NotNull final Executor executor, final RunContentDescriptor descriptor) {
- showRunContent(executor, descriptor, descriptor != null ? descriptor.getExecutionId() : 0L);
+ public void showRunContent(@NotNull Executor executor, @NotNull RunContentDescriptor descriptor) {
+ showRunContent(executor, descriptor, descriptor.getExecutionId());
}
- public void showRunContent(@NotNull final Executor executor, final RunContentDescriptor descriptor, long executionId) {
- if (ApplicationManager.getApplication().isUnitTestMode()) return;
+ public void showRunContent(@NotNull final Executor executor, @NotNull final RunContentDescriptor descriptor, long executionId) {
+ if (ApplicationManager.getApplication().isUnitTestMode()) {
+ return;
+ }
final ContentManager contentManager = getContentManagerForRunner(executor);
- RunContentDescriptor oldDescriptor =
- chooseReuseContentForDescriptor(contentManager, descriptor, executionId, descriptor != null ? descriptor.getDisplayName() : null);
-
+ RunContentDescriptor oldDescriptor = chooseReuseContentForDescriptor(contentManager, descriptor, executionId, descriptor.getDisplayName());
final Content content;
-
- Content oldAttachedContent = oldDescriptor != null ? oldDescriptor.getAttachedContent() : null;
- if (oldDescriptor != null) {
- content = oldAttachedContent;
- getSyncPublisher().contentRemoved(oldDescriptor, executor);
- Disposer.dispose(oldDescriptor); // is of the same category, can be reused
- }
- else if (oldAttachedContent == null || !oldAttachedContent.isValid() /*|| oldAttachedContent.getUserData(MARKED_TO_BE_REUSED) != null */) {
+ if (oldDescriptor == null) {
content = createNewContent(contentManager, descriptor, executor);
- final Icon icon = descriptor.getIcon();
+ Icon icon = descriptor.getIcon();
content.setIcon(icon == null ? executor.getToolWindowIcon() : icon);
- } else {
- content = oldAttachedContent;
}
+ else {
+ content = oldDescriptor.getAttachedContent();
+ LOG.assertTrue(content != null);
+ getSyncPublisher().contentRemoved(oldDescriptor, executor);
+ Disposer.dispose(oldDescriptor); // is of the same category, can be reused
+ }
+
content.setExecutionId(executionId);
content.setComponent(descriptor.getComponent());
content.setPreferredFocusedComponent(descriptor.getPreferredFocusComputable());
@@ -353,10 +324,10 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
if (!descriptor.isActivateToolWindowWhenAdded()) {
return;
}
+
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- if (myProject.isDisposed()) return;
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(executor.getToolWindowId());
// let's activate tool window, but don't move focus
//
@@ -367,14 +338,17 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
descriptor.getPreferredFocusComputable();
window.activate(null, descriptor.isAutoFocusContent(), descriptor.isAutoFocusContent());
}
- });
+ }, myProject.getDisposed());
}
@Override
@Nullable
@Deprecated
public RunContentDescriptor getReuseContent(final Executor requestor, DataContext dataContext) {
- if (ApplicationManager.getApplication().isUnitTestMode()) return null;
+ if (ApplicationManager.getApplication().isUnitTestMode()) {
+ return null;
+ }
+ //noinspection deprecation
return getReuseContent(requestor, GenericProgramRunner.CONTENT_TO_REUSE_DATA_KEY.getData(dataContext));
}
@@ -382,11 +356,13 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
@Nullable
@Deprecated
public RunContentDescriptor getReuseContent(Executor requestor, @Nullable RunContentDescriptor contentToReuse) {
- if (ApplicationManager.getApplication().isUnitTestMode()) return null;
- if (contentToReuse != null) return contentToReuse;
-
- final ContentManager contentManager = getContentManagerForRunner(requestor);
- return chooseReuseContentForDescriptor(contentManager, contentToReuse, 0L, null);
+ if (ApplicationManager.getApplication().isUnitTestMode()) {
+ return null;
+ }
+ if (contentToReuse != null) {
+ return contentToReuse;
+ }
+ return chooseReuseContentForDescriptor(getContentManagerForRunner(requestor), null, 0L, null);
}
@Nullable
@@ -400,10 +376,12 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
public RunContentDescriptor getReuseContent(@NotNull ExecutionEnvironment executionEnvironment) {
if (ApplicationManager.getApplication().isUnitTestMode()) return null;
RunContentDescriptor contentToReuse = executionEnvironment.getContentToReuse();
- if (contentToReuse != null) return contentToReuse;
+ if (contentToReuse != null) {
+ return contentToReuse;
+ }
final ContentManager contentManager = getContentManagerForRunner(executionEnvironment.getExecutor());
- return chooseReuseContentForDescriptor(contentManager, contentToReuse, executionEnvironment.getExecutionId(),
+ return chooseReuseContentForDescriptor(contentManager, null, executionEnvironment.getExecutionId(),
executionEnvironment.toString());
}
@@ -413,14 +391,21 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
@Override
- public void showRunContent(@NotNull final Executor info, RunContentDescriptor descriptor, RunContentDescriptor contentToReuse) {
+ public void showRunContent(@NotNull Executor info, @NotNull RunContentDescriptor descriptor, @Nullable RunContentDescriptor contentToReuse) {
+ copyContentAndBehavior(descriptor, contentToReuse);
+ showRunContent(info, descriptor, descriptor.getExecutionId());
+ }
+
+ public static void copyContentAndBehavior(@NotNull RunContentDescriptor descriptor, @Nullable RunContentDescriptor contentToReuse) {
if (contentToReuse != null) {
- final Content attachedContent = contentToReuse.getAttachedContent();
- if (attachedContent.getManager() != null) {
+ Content attachedContent = contentToReuse.getAttachedContent();
+ if (attachedContent != null && attachedContent.isValid()) {
descriptor.setAttachedContent(attachedContent);
}
+ if (contentToReuse.isReuseToolWindowActivation()) {
+ descriptor.setActivateToolWindowWhenAdded(contentToReuse.isActivateToolWindowWhenAdded());
+ }
}
- showRunContent(info, descriptor, descriptor != null ? descriptor.getExecutionId(): 0L);
}
@Nullable
@@ -436,7 +421,9 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
//Stage two: try to get content from descriptor itself
final Content attachedContent = descriptor.getAttachedContent();
- if (attachedContent != null && attachedContent.isValid() && contentManager.getIndexOfContent(attachedContent) != -1) content = attachedContent;
+ if (attachedContent != null && attachedContent.isValid() && contentManager.getIndexOfContent(attachedContent) != -1) {
+ content = attachedContent;
+ }
}
//Stage three: choose the content with name we prefer
if (content == null) {
@@ -486,6 +473,7 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
if (contentManager == null) {
LOG.error("Runner " + executor.getId() + " is not registered");
}
+ //noinspection ConstantConditions
return contentManager;
}
@@ -499,26 +487,20 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
return content;
}
- private static boolean isTerminated(@NotNull final Content content) {
- final RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
- if (descriptor == null) {
- return true;
- }
- else {
- final ProcessHandler processHandler = descriptor.getProcessHandler();
- return processHandler == null || processHandler.isProcessTerminated();
- }
+ private static boolean isTerminated(@NotNull Content content) {
+ RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
+ ProcessHandler processHandler = descriptor == null ? null : descriptor.getProcessHandler();
+ return processHandler == null || processHandler.isProcessTerminated();
}
@Nullable
- public static RunContentDescriptor getRunContentDescriptorByContent(@NotNull final Content content) {
+ private static RunContentDescriptor getRunContentDescriptorByContent(@NotNull Content content) {
return content.getUserData(DESCRIPTOR_KEY);
}
-
@Override
@Nullable
- public ToolWindow getToolWindowByDescriptor(@NotNull final RunContentDescriptor descriptor) {
+ public ToolWindow getToolWindowByDescriptor(@NotNull RunContentDescriptor descriptor) {
for (Map.Entry<String, ContentManager> entry : myToolwindowIdToContentManagerMap.entrySet()) {
if (getRunContentByDescriptor(entry.getValue(), descriptor) != null) {
return ToolWindowManager.getInstance(myProject).getToolWindow(entry.getKey());
@@ -528,9 +510,8 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
@Nullable
- private static Content getRunContentByDescriptor(final ContentManager contentManager, final RunContentDescriptor descriptor) {
- final Content[] contents = contentManager.getContents();
- for (final Content content : contents) {
+ private static Content getRunContentByDescriptor(@NotNull ContentManager contentManager, @NotNull RunContentDescriptor descriptor) {
+ for (Content content : contentManager.getContents()) {
if (descriptor.equals(content.getUserData(DESCRIPTOR_KEY))) {
return content;
}
@@ -539,18 +520,18 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
@Override
- public void addRunContentListener(final RunContentListener listener, final Executor executor) {
+ public void addRunContentListener(@NotNull final RunContentListener listener, final Executor executor) {
final Disposable disposable = Disposer.newDisposable();
- myProject.getMessageBus().connect(disposable).subscribe(RUN_CONTENT_TOPIC, new RunContentWithExecutorListener() {
+ myProject.getMessageBus().connect(disposable).subscribe(TOPIC, new RunContentWithExecutorListener() {
@Override
- public void contentSelected(RunContentDescriptor descriptor, @NotNull Executor executor2) {
+ public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor2) {
if (executor2.equals(executor)) {
listener.contentSelected(descriptor);
}
}
@Override
- public void contentRemoved(RunContentDescriptor descriptor, @NotNull Executor executor2) {
+ public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor2) {
if (executor2.equals(executor)) {
listener.contentRemoved(descriptor);
}
@@ -560,16 +541,16 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
}
@Override
- public void addRunContentListener(final RunContentListener listener) {
+ public void addRunContentListener(@NotNull final RunContentListener listener) {
final Disposable disposable = Disposer.newDisposable();
- myProject.getMessageBus().connect(disposable).subscribe(RUN_CONTENT_TOPIC, new RunContentWithExecutorListener() {
+ myProject.getMessageBus().connect(disposable).subscribe(TOPIC, new RunContentWithExecutorListener() {
@Override
- public void contentSelected(RunContentDescriptor descriptor, @NotNull Executor executor) {
+ public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
listener.contentSelected(descriptor);
}
@Override
- public void contentRemoved(RunContentDescriptor descriptor, @NotNull Executor executor) {
+ public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
listener.contentRemoved(descriptor);
}
});
@@ -582,18 +563,16 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
if (myToolwindowIdToContentManagerMap.isEmpty()) {
return Collections.emptyList();
}
- final String[] ids = myToolwindowIdToContentManagerMap.keySet().toArray(new String[myToolwindowIdToContentManagerMap.size()]);
- final List<RunContentDescriptor> descriptors = new ArrayList<RunContentDescriptor>();
- for (String id : ids) {
- final ContentManager contentManager = myToolwindowIdToContentManagerMap.get(id);
- for (final Content content : contentManager.getContents()) {
- final RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
+
+ List<RunContentDescriptor> descriptors = new SmartList<RunContentDescriptor>();
+ for (String id : myToolwindowIdToContentManagerMap.keySet()) {
+ for (Content content : myToolwindowIdToContentManagerMap.get(id).getContents()) {
+ RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
if (descriptor != null) {
descriptors.add(descriptor);
}
}
}
-
return descriptors;
}
@@ -607,10 +586,9 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
@Nullable
private RunContentDescriptor getDescriptorBy(ProcessHandler handler, Executor runnerInfo) {
- ContentManager contentManager = getContentManagerForRunner(runnerInfo);
- Content[] contents = contentManager.getContents();
- for (Content content : contents) {
- RunContentDescriptor runContentDescriptor = content.getUserData(DESCRIPTOR_KEY);
+ for (Content content : getContentManagerForRunner(runnerInfo).getContents()) {
+ RunContentDescriptor runContentDescriptor = getRunContentDescriptorByContent(content);
+ assert runContentDescriptor != null;
if (runContentDescriptor.getProcessHandler() == handler) {
return runContentDescriptor;
}
@@ -642,12 +620,11 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
final Content content = myContent;
try {
- final RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
-
+ RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
getSyncPublisher().contentRemoved(descriptor, myExecutor);
-
- if (descriptor != null)
+ if (descriptor != null) {
Disposer.dispose(descriptor);
+ }
}
finally {
content.getManager().removeContentManagerListener(this);
@@ -699,7 +676,6 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
private boolean closeQuery(boolean modal) {
final RunContentDescriptor descriptor = getRunContentDescriptorByContent(myContent);
-
if (descriptor == null) {
return true;
}
@@ -709,6 +685,7 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
return true;
}
final boolean destroyProcess;
+ //noinspection deprecation
if (processHandler.isSilentlyDestroyOnClose() || Boolean.TRUE.equals(processHandler.getUserData(ProcessHandler.SILENTLY_DESTROY_ON_CLOSE))) {
destroyProcess = true;
}
@@ -786,7 +763,9 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
break;
}
try {
+ //noinspection SynchronizeOnThis
synchronized (this) {
+ //noinspection SynchronizeOnThis
wait(2000L);
}
}
diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java
index b70d37a79e41..301cceee7e19 100644
--- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java
@@ -70,6 +70,7 @@ public class GridCellImpl implements GridCell {
myPlaceInGrid = placeInGrid;
myPlaceholder = placeholder;
myTabs = new JBTabsImpl(myContext.getProject(), myContext.getActionManager(), myContext.getFocusManager(), container) {
+ @SuppressWarnings("UseJBColor")
@Override
protected Color getFocusedTopFillColor() {
return UIUtil.isUnderDarcula() ? ColorUtil.toAlpha(new Color(0x1E2533), 100) : new Color(202, 211, 227);
@@ -88,11 +89,13 @@ public class GridCellImpl implements GridCell {
super.paintBorder(g2d, shape, borderColor);
}
+ @SuppressWarnings("UseJBColor")
@Override
protected Color getFocusedBottomFillColor() {
return UIUtil.isUnderDarcula() ? new Color(0x1E2533) : new Color(0xc2cbdb);
}
+ @SuppressWarnings("UseJBColor")
@Override
public Color getBackground() {
return UIUtil.isUnderDarcula() ? new Color(0x27292A) : super.getBackground();
@@ -239,8 +242,6 @@ public class GridCellImpl implements GridCell {
}
private TabInfo createTabInfoFor(Content content) {
- final JComponent c = content.getComponent();
-
final TabInfo tabInfo = updatePresentation(new TabInfo(new ProviderWrapper(content, myContext)), content)
.setObject(content)
.setPreferredFocusableComponent(content.getPreferredFocusableComponent())
@@ -257,7 +258,10 @@ public class GridCellImpl implements GridCell {
@Nullable
private static TabInfo updatePresentation(TabInfo info, Content content) {
- if (info == null) return info;
+ if (info == null) {
+ return null;
+ }
+
return info.
setIcon(content.getIcon()).
setText(content.getDisplayName()).
@@ -309,7 +313,6 @@ public class GridCellImpl implements GridCell {
}
private static class ProviderWrapper extends NonOpaquePanel implements DataProvider {
-
Content myContent;
ViewContext myContext;
diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/JBRunnerTabs.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/JBRunnerTabs.java
index 8ca416bd5427..d680e8a7e173 100644
--- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/JBRunnerTabs.java
+++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/JBRunnerTabs.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -43,7 +43,7 @@ import java.util.Map;
*/
public class
JBRunnerTabs extends JBTabsImpl {
- public JBRunnerTabs(@Nullable Project project, ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
+ public JBRunnerTabs(@Nullable Project project, @NotNull ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
super(project, actionManager, focusManager, parent);
}
diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java
index 821d9dbd6bc3..b8225b0c238b 100644
--- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java
+++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -89,7 +89,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
private ContentManager myManager;
private final RunnerLayout myLayoutSettings;
- private final ActionManager myActionManager;
+ @NotNull private final ActionManager myActionManager;
private final String mySessionName;
private final MyComponent myComponent = new MyComponent();
@@ -99,7 +99,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
JBRunnerTabs myTabs;
private final Comparator<TabInfo> myTabsComparator = new Comparator<TabInfo>() {
@Override
- public int compare(final TabInfo o1, final TabInfo o2) {
+ public int compare(@NotNull final TabInfo o1, @NotNull final TabInfo o2) {
//noinspection ConstantConditions
TabImpl tab1 = getTabFor(o1);
TabImpl tab2 = getTabFor(o2);
@@ -132,7 +132,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
private final Map<String, LayoutAttractionPolicy> myConditionAttractions = new HashMap<String, LayoutAttractionPolicy>();
private ActionGroup myTabPopupActions;
- private ActionGroup myAdditonalFocusActions;
+ private ActionGroup myAdditionalFocusActions;
private final ActionCallback myInitialized = new ActionCallback();
private boolean myToDisposeRemovedContent = true;
@@ -149,7 +149,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
private final CopyOnWriteArraySet<Listener> myDockingListeners = new CopyOnWriteArraySet<Listener>();
private final Set<RunnerContentUi> myChildren = new TreeSet<RunnerContentUi>(new Comparator<RunnerContentUi>() {
@Override
- public int compare(RunnerContentUi o1, RunnerContentUi o2) {
+ public int compare(@NotNull RunnerContentUi o1, @NotNull RunnerContentUi o2) {
return o1.myWindow - o2.myWindow;
}
});
@@ -164,7 +164,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
@NotNull String sessionName) {
myProject = project;
myRunnerUi = ui;
- myLayoutSettings = settings;
+ myLayoutSettings = settings;
myActionManager = actionManager;
mySessionName = sessionName;
myFocusManager = focusManager;
@@ -190,7 +190,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
public void setAdditionalFocusActions(final ActionGroup group) {
- myAdditonalFocusActions = group;
+ myAdditionalFocusActions = group;
rebuildTabPopup();
}
@@ -269,7 +269,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
});
myTabs.addTabMouseListener(new MouseAdapter() {
@Override
- public void mousePressed(MouseEvent e) {
+ public void mousePressed(@NotNull MouseEvent e) {
if (UIUtil.isCloseClick(e)) {
final TabInfo tabInfo = myTabs.findInfo(e);
final GridImpl grid = tabInfo == null? null : getGridFor(tabInfo);
@@ -299,10 +299,11 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
private void rebuildTabPopup() {
+ initUi();
+
myTabs.setPopupGroup(getCellPopupGroup(TAB_POPUP_PLACE), TAB_POPUP_PLACE, true);
- final ArrayList<GridImpl> grids = getGrids();
- for (GridImpl each : grids) {
+ for (GridImpl each : getGrids()) {
each.rebuildTabPopup();
}
}
@@ -325,10 +326,9 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
for (AnAction eachFocus : focusActions) {
group.add(eachFocus);
}
- if (myAdditonalFocusActions != null) {
- final AnAction[] addins = myAdditonalFocusActions.getChildren(event);
- for (AnAction eachAddin : addins) {
- group.add(eachAddin);
+ if (myAdditionalFocusActions != null) {
+ for (AnAction action : myAdditionalFocusActions.getChildren(event)) {
+ group.add(action);
}
}
}
@@ -350,7 +350,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
@Override
- public void propertyChange(final PropertyChangeEvent evt) {
+ public void propertyChange(@NotNull final PropertyChangeEvent evt) {
Content content = (Content)evt.getSource();
final GridImpl grid = getGridFor(content, false);
if (grid == null) return;
@@ -436,8 +436,8 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
return new ActionCallback.Done();
}
- private void storeDefaultIndices(Content[] contents) {
- int i = 0;
+ private void storeDefaultIndices(@NotNull Content[] contents) {
+ //int i = 0;
for (Content content : contents) {
content.putUserData(RunnerLayout.DEFAULT_INDEX, getStateFor(content).getTab().getDefaultIndex());
//content.putUserData(CONTENT_NUMBER, i++);
@@ -637,8 +637,9 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
myManager.addContentManagerListener(new ContentManagerListener() {
@Override
public void contentAdded(final ContentManagerEvent event) {
- final GridImpl grid = getGridFor(event.getContent(), true);
+ initUi();
+ GridImpl grid = getGridFor(event.getContent(), true);
if (grid == null) {
return;
}
@@ -795,10 +796,12 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
private static void moveFollowingTabs(int index, final JBRunnerTabs tabs) {
for (TabInfo info : tabs.getTabs()) {
- final TabImpl tab = getTabFor(info);
- final int tabIndex = tab != null ? tab.getIndex() : -1;
- if (tabIndex >= index) {
- tab.setIndex(tabIndex + 1);
+ TabImpl tab = getTabFor(info);
+ if (tab != null) {
+ int tabIndex = tab.getIndex();
+ if (tabIndex >= index) {
+ tab.setIndex(tabIndex + 1);
+ }
}
}
}
@@ -1147,7 +1150,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
myOriginal = null;
myTopActions = null;
- myAdditonalFocusActions = null;
+ myAdditionalFocusActions = null;
myLeftToolbarActions = null;
}
@@ -1166,7 +1169,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
Content[] all = contents.toArray(new Content[contents.size()]);
Arrays.sort(all, new Comparator<Content>() {
@Override
- public int compare(Content content, Content content1) {
+ public int compare(@NotNull Content content, @NotNull Content content1) {
final int i = getStateFor(content).getTab().getDefaultIndex();
final int i1 = getStateFor(content1).getTab().getDefaultIndex();
return i - i1;
@@ -1222,6 +1225,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
myMinimizeActionEnabled = enabled;
}
+ @SuppressWarnings("SpellCheckingInspection")
public void setMovetoGridActionEnabled(final boolean enabled) {
myMoveToGridActionEnabled = enabled;
}
@@ -1271,7 +1275,6 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
return null;
}
- @Nullable
public void restoreContent(final String key) {
for (AnAction action : myMinimizedViewActions.getChildren(null)) {
Content content = ((RestoreViewAction)action).getContent();
@@ -1293,7 +1296,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
private static class MyDropAreaPainter extends AbstractPainter {
private Shape myBoundingBox;
- private Color myColor = ColorUtil.mix(JBColor.BLUE, JBColor.WHITE, .3);
+ private final Color myColor = ColorUtil.mix(JBColor.BLUE, JBColor.WHITE, .3);
@Override
public boolean needsRepaint() {
@@ -1390,6 +1393,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
}
+ @SuppressWarnings("NullableProblems")
@Override
public String getName() {
return RunnerContentUi.this.getName();
@@ -1575,6 +1579,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
return myManager;
}
+ @NotNull
@Override
public ActionManager getActionManager() {
return myActionManager;
@@ -1617,7 +1622,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
@Override
- public void validate(final Content content, final ActiveRunnable toRestore) {
+ public void validate(Content content, final ActiveRunnable toRestore) {
final TabInfo current = myTabs.getSelectedInfo();
myTabs.getPresentation().setPaintBlocked(true, true);
@@ -1628,6 +1633,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
toRestore.run().doWhenDone(new Runnable() {
@Override
public void run() {
+ assert current != null;
myTabs.select(current, true);
myTabs.getPresentation().setPaintBlocked(false, true);
}
@@ -1654,7 +1660,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
@Override
- public Dimension preferredLayoutSize(final Container parent) {
+ public Dimension preferredLayoutSize(@NotNull final Container parent) {
Dimension size = new Dimension();
Dimension leftSize = myLeft.getPreferredSize();
@@ -1667,7 +1673,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
}
@Override
- public void layoutContainer(final Container parent) {
+ public void layoutContainer(@NotNull final Container parent) {
Dimension size = parent.getSize();
Dimension prefSize = parent.getPreferredSize();
if (prefSize.width <= size.width) {
@@ -1806,10 +1812,9 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
@Override
public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) {
- final JComponent component = info.getComponent();
- final Content[] data = CONTENT_KEY.getData((DataProvider)component);
- final List<Content> contents = Arrays.asList(data);
-
+ JComponent component = info.getComponent();
+ Content[] data = CONTENT_KEY.getData((DataProvider)component);
+ assert data != null;
storeDefaultIndices(data);
final Dimension size = info.getComponent().getSize();
@@ -1822,7 +1827,7 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
presentation.setIcon(info.getIcon());
mySession = getDockManager().createDragSession(mouseEvent, new DockableGrid(image, presentation,
size,
- contents, 0));
+ Arrays.asList(data), 0));
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java
index 70d6a3f92819..7475adbcab21 100644
--- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerLayoutUiImpl.java
@@ -21,7 +21,6 @@ import com.intellij.execution.ui.layout.LayoutAttractionPolicy;
import com.intellij.execution.ui.layout.LayoutStateDefaults;
import com.intellij.execution.ui.layout.LayoutViewOptions;
import com.intellij.execution.ui.layout.PlaceInGrid;
-import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.ActionManager;
@@ -46,9 +45,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
-public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, LayoutStateDefaults, LayoutViewOptions {
+public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, LayoutStateDefaults, LayoutViewOptions, DataProvider {
private final RunnerLayout myLayout;
- private final JPanel myContentPanel;
private final RunnerContentUi myContentUI;
private final ContentManager myViewsContentManager;
@@ -63,14 +61,12 @@ public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, La
Disposer.register(parent, this);
myContentUI = new RunnerContentUi(project, this, ActionManager.getInstance(), IdeFocusManager.getInstance(project), myLayout,
- runnerTitle + " - " + sessionName);
+ runnerTitle + " - " + sessionName);
Disposer.register(this, myContentUI);
- myContentPanel = new MyContent();
myViewsContentManager = getContentFactory().createContentManager(myContentUI.getContentUI(), false, project);
+ myViewsContentManager.addDataProvider(this);
Disposer.register(this, myViewsContentManager);
-
- myContentPanel.add(myViewsContentManager.getComponent(), BorderLayout.CENTER);
}
@Override
@@ -80,7 +76,6 @@ public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, La
return this;
}
-
@NotNull
@Override
public LayoutStateDefaults initTabDefaults(int id, String text, Icon icon) {
@@ -156,7 +151,7 @@ public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, La
@Override
@NotNull
public JComponent getComponent() {
- return myContentPanel;
+ return myViewsContentManager.getComponent();
}
private static ContentFactory getContentFactory() {
@@ -380,28 +375,12 @@ public class RunnerLayoutUiImpl implements Disposable.Parent, RunnerLayoutUi, La
return contents;
}
- private class MyContent extends JPanel implements DataProvider {
- public MyContent() {
- super(new BorderLayout());
- }
-
- @Override
- public Object getData(@NonNls String dataId) {
- if (SwitchProvider.KEY.getName().equals(dataId)) {
- return myContentUI;
- }
-
- if (QuickActionProvider.KEY.getName().equals(dataId)) {
- return myContentUI;
- }
-
- if (RunnerContentUi.KEY.getName().equals(dataId)) {
- return myContentUI;
- }
-
- final DataProvider provider = DataManager.getDataProvider(this);
- return provider != null ? provider.getData(dataId) : null;
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ if (SwitchProvider.KEY.is(dataId) || QuickActionProvider.KEY.is(dataId) || RunnerContentUi.KEY.is(dataId)) {
+ return myContentUI;
}
+ return null;
}
-
}
diff --git a/platform/lang-impl/src/com/intellij/find/FindSettings.java b/platform/lang-impl/src/com/intellij/find/FindSettings.java
index d61fd395eadd..d8c6d73461a1 100644
--- a/platform/lang-impl/src/com/intellij/find/FindSettings.java
+++ b/platform/lang-impl/src/com/intellij/find/FindSettings.java
@@ -128,4 +128,7 @@ public abstract class FindSettings{
public abstract boolean isExceptCommentsAndLiterals();
public abstract void setExceptCommentsAndLiterals(boolean selected);
+
+ public abstract boolean isShowResultsInSeparateView();
+ public abstract void setShowResultsInSeparateView(boolean selected);
}
diff --git a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java
index d9848fdec4b0..c4445c4ab5d2 100644
--- a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java
+++ b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesTableCellRenderer.java
@@ -77,7 +77,7 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
textChunks.setBorder(null);
if (usage == null || usageNode instanceof ShowUsagesAction.StringNode) {
- textChunks.append(value.toString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
+ textChunks.append(value != null ? value.toString() : "", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
return textComponentSpanningWholeRow(textChunks, panelBackground, panelForeground, column, list, row);
}
if (usage == ShowUsagesAction.MORE_USAGES_SEPARATOR) {
diff --git a/platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java b/platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java
index d7f7665a9299..b78ce2c7ead7 100644
--- a/platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java
+++ b/platform/lang-impl/src/com/intellij/find/findInProject/FindInProjectManager.java
@@ -40,7 +40,6 @@ import org.jetbrains.annotations.NotNull;
public class FindInProjectManager {
private final Project myProject;
- private boolean myToOpenInNewTab = false;
private volatile boolean myIsFindInProgress = false;
public static FindInProjectManager getInstance(Project project) {
@@ -60,12 +59,12 @@ public class FindInProjectManager {
isOpenInNewTabEnabled = false;
}
else {
- toOpenInNewTab[0] = myToOpenInNewTab;
+ toOpenInNewTab[0] = FindSettings.getInstance().isShowResultsInSeparateView();
isOpenInNewTabEnabled = UsageViewManager.getInstance(myProject).getReusableContentsCount() > 0;
}
final FindManager findManager = FindManager.getInstance(myProject);
- final FindModel findModel = (FindModel) findManager.getFindInProjectModel().clone();
+ final FindModel findModel = findManager.getFindInProjectModel().clone();
findModel.setReplaceState(false);
findModel.setOpenInNewTabVisible(true);
findModel.setOpenInNewTabEnabled(isOpenInNewTabEnabled);
@@ -86,7 +85,7 @@ public class FindInProjectManager {
public void run() {
findModel.setOpenInNewTabVisible(false);
if (isOpenInNewTabEnabled) {
- myToOpenInNewTab = toOpenInNewTab[0] = findModel.isOpenInNewTab();
+ FindSettings.getInstance().setShowResultsInSeparateView(toOpenInNewTab[0] = findModel.isOpenInNewTab());
}
startFindInProject(findModel);
@@ -107,8 +106,8 @@ public class FindInProjectManager {
if (manager == null) return;
final FindManager findManager = FindManager.getInstance(myProject);
findManager.getFindInProjectModel().copyFrom(findModel);
- final FindModel findModelCopy = (FindModel)findModel.clone();
- final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(myToOpenInNewTab, findModelCopy);
+ final FindModel findModelCopy = findModel.clone();
+ final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(FindSettings.getInstance().isShowResultsInSeparateView(), findModelCopy);
final boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();
final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, showPanelIfOnlyOneUsage, presentation);
diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
index c25456da1988..b268e455a67c 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java
@@ -45,10 +45,7 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiFileFactory;
import com.intellij.psi.search.SearchScope;
-import com.intellij.ui.EditorComboBoxRenderer;
-import com.intellij.ui.EditorTextField;
-import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.StateRestoringCheckBox;
+import com.intellij.ui.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Consumer;
import com.intellij.util.ui.UIUtil;
@@ -340,6 +337,9 @@ public class FindDialog extends DialogWrapper {
topOptionsPanel.setLayout(new GridLayout(1, 2, UIUtil.DEFAULT_HGAP, 0));
topOptionsPanel.add(createFindOptionsPanel());
optionsPanel.add(topOptionsPanel, gbConstraints);
+
+ JPanel resultsOptionPanel = null;
+
if (myModel.isMultipleFiles()) {
optionsPanel.add(createGlobalScopePanel(), gbConstraints);
gbConstraints.weightx = 1;
@@ -350,7 +350,9 @@ public class FindDialog extends DialogWrapper {
optionsPanel.add(createFilterPanel(),gbConstraints);
myCbToSkipResultsWhenOneUsage = createCheckbox(FindSettings.getInstance().isSkipResultsWithOneUsage(), FindBundle.message("find.options.skip.results.tab.with.one.occurrence.checkbox"));
- optionsPanel.add(myCbToSkipResultsWhenOneUsage, gbConstraints);
+ resultsOptionPanel = createResultsOptionPanel(optionsPanel, gbConstraints);
+ resultsOptionPanel.add(myCbToSkipResultsWhenOneUsage);
+
myCbToSkipResultsWhenOneUsage.setVisible(!myModel.isReplaceState());
}
else {
@@ -374,18 +376,26 @@ public class FindDialog extends DialogWrapper {
}
if (myModel.isOpenInNewTabVisible()){
- JPanel openInNewTabWindowPanel = new JPanel(new BorderLayout());
myCbToOpenInNewTab = new JCheckBox(FindBundle.message("find.open.in.new.tab.checkbox"));
myCbToOpenInNewTab.setFocusable(false);
myCbToOpenInNewTab.setSelected(myModel.isOpenInNewTab());
myCbToOpenInNewTab.setEnabled(myModel.isOpenInNewTabEnabled());
- openInNewTabWindowPanel.add(myCbToOpenInNewTab, BorderLayout.EAST);
- optionsPanel.add(openInNewTabWindowPanel, gbConstraints);
+
+ if (resultsOptionPanel == null) resultsOptionPanel = createResultsOptionPanel(optionsPanel, gbConstraints);
+ resultsOptionPanel.add(myCbToOpenInNewTab);
}
return optionsPanel;
}
+ private static JPanel createResultsOptionPanel(JPanel optionsPanel, GridBagConstraints gbConstraints) {
+ JPanel resultsOptionPanel = new JPanel();
+ resultsOptionPanel.setLayout(new BoxLayout(resultsOptionPanel, BoxLayout.Y_AXIS));
+
+ optionsPanel.add(new HideableTitledPanel(FindBundle.message("results.options.group"), resultsOptionPanel, false), gbConstraints);
+ return resultsOptionPanel;
+ }
+
@NotNull
private JComponent createFilterPanel() {
JPanel filterPanel = new JPanel();
@@ -615,9 +625,11 @@ public class FindDialog extends DialogWrapper {
JLabel searchContextLabel = new JLabel(FindBundle.message("find.context.combo.label"));
searchContextLabel.setLabelFor(mySearchContext);
- searchContextPanel.add(searchContextLabel, BorderLayout.WEST);
-
- searchContextPanel.add(mySearchContext, BorderLayout.CENTER);
+ JPanel panel = new JPanel();
+ panel.setAlignmentX(Component.LEFT_ALIGNMENT);
+ panel.add(searchContextLabel);
+ panel.add(mySearchContext);
+ searchContextPanel.add(panel, BorderLayout.WEST);
if (FindManagerImpl.ourHasSearchInCommentsAndLiterals) {
findOptionsPanel.add(searchContextPanel);
diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java
index 23f14c5eb0b4..db82791478f0 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/FindInProjectUtil.java
@@ -301,6 +301,7 @@ public class FindInProjectUtil {
}
presentation.setOpenInNewTab(toOpenInNewTab);
presentation.setCodeUsages(false);
+ presentation.setUsageTypeFilteringAvailable(true);
return presentation;
}
diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java b/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java
index 27e2b7215f25..b7d58e926e30 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java
@@ -387,7 +387,8 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
if (input == null || !input.isStringFound()) return true;
NavigableMap<Integer, Integer> map = mySkipRangesSet.headMap(input.getStartOffset(), true);
for(Map.Entry<Integer, Integer> e:map.descendingMap().entrySet()) {
- if (e.getKey() <= input.getStartOffset() && e.getValue() >= input.getEndOffset()) return false;
+ // [e.key, e.value] intersect with [input.start, input.end]
+ if (e.getKey() <= input.getStartOffset() && (input.getStartOffset() <= e.getValue() || e.getValue() >= input.getEndOffset())) return false;
if (e.getValue() <= input.getStartOffset()) break;
}
return true;
diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindSettingsImpl.java b/platform/lang-impl/src/com/intellij/find/impl/FindSettingsImpl.java
index c9c8e3492834..ffe3555ea059 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/FindSettingsImpl.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/FindSettingsImpl.java
@@ -110,6 +110,7 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
@SuppressWarnings({"WeakerAccess"}) public boolean REGULAR_EXPRESSIONS = false;
@SuppressWarnings({"WeakerAccess"}) public boolean LOCAL_REGULAR_EXPRESSIONS = false;
@SuppressWarnings({"WeakerAccess"}) public boolean WITH_SUBDIRECTORIES = true;
+ @SuppressWarnings({"WeakerAccess"}) public boolean SHOW_RESULTS_IN_SEPARATE_VIEW = false;
@SuppressWarnings({"WeakerAccess"}) public String SEARCH_SCOPE = DEFAULT_SEARCH_SCOPE;
@SuppressWarnings({"WeakerAccess"}) public String FILE_MASK;
@@ -409,6 +410,16 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
}
@Override
+ public boolean isShowResultsInSeparateView() {
+ return SHOW_RESULTS_IN_SEPARATE_VIEW;
+ }
+
+ @Override
+ public void setShowResultsInSeparateView(boolean optionValue) {
+ SHOW_RESULTS_IN_SEPARATE_VIEW = optionValue;
+ }
+
+ @Override
public boolean isExceptCommentsAndLiterals() {
return EXCEPT_COMMENTS_AND_STRING_LITERALS;
}
diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java
index 7d3c7c649fd2..73358455bdcd 100644
--- a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java
+++ b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java
@@ -180,6 +180,7 @@ class FormatProcessor {
}
private int getRightMargin(Block rootBlock) {
+ Language language = null;
if (rootBlock instanceof ASTBlock) {
ASTNode node = ((ASTBlock)rootBlock).getNode();
if (node != null) {
@@ -187,12 +188,12 @@ class FormatProcessor {
if (psiElement.isValid()) {
PsiFile psiFile = psiElement.getContainingFile();
if (psiFile != null) {
- return mySettings.getRightMargin(psiFile.getViewProvider().getBaseLanguage());
+ language = psiFile.getViewProvider().getBaseLanguage();
}
}
}
}
- return mySettings.RIGHT_MARGIN;
+ return mySettings.getRightMargin(language);
}
private LeafBlockWrapper getLastBlock() {
diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java b/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java
index 7b40b786ff7a..5b32caed587d 100644
--- a/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java
+++ b/platform/lang-impl/src/com/intellij/formatting/FormatterImpl.java
@@ -112,26 +112,27 @@ public class FormatterImpl extends FormatterEx
@Override
public int getSpacingForBlockAtOffset(FormattingModel model, int offset) {
Couple<Block> blockWithParent = getBlockAtOffset(null, model.getRootBlock(), offset);
- if (blockWithParent == null) {
- return 0;
- }
- Block parentBlock = blockWithParent.first;
- Block targetBlock = blockWithParent.second;
- if (parentBlock == null || targetBlock == null) {
- return 0;
- }
- Block prevBlock = findPreviousSibling(parentBlock, targetBlock);
- if (prevBlock == null) {
- return 0;
- }
- SpacingImpl spacing = (SpacingImpl)parentBlock.getSpacing(prevBlock, targetBlock);
- if (spacing == null) {
- return 0;
+ if (blockWithParent != null) {
+ Block parentBlock = blockWithParent.first;
+ Block targetBlock = blockWithParent.second;
+ if (parentBlock != null && targetBlock != null) {
+ Block prevBlock = findPreviousSibling(parentBlock, targetBlock);
+ if (prevBlock != null) {
+ SpacingImpl spacing = (SpacingImpl)parentBlock.getSpacing(prevBlock, targetBlock);
+ if (spacing != null) {
+ int minSpaces = spacing.getMinSpaces();
+ if (minSpaces > 0) {
+ return minSpaces;
+ }
+ }
+ }
+ }
}
- return Math.max(spacing.getMinSpaces(), 0);
+ return 0;
}
- private static Couple<Block> getBlockAtOffset(Block parent, Block block, int offset) {
+ @Nullable
+ private static Couple<Block> getBlockAtOffset(@Nullable Block parent, @NotNull Block block, int offset) {
TextRange textRange = block.getTextRange();
int startOffset = textRange.getStartOffset();
int endOffset = textRange.getEndOffset();
@@ -150,7 +151,8 @@ public class FormatterImpl extends FormatterEx
return null;
}
- private static Block findPreviousSibling(Block parent, Block block) {
+ @Nullable
+ private static Block findPreviousSibling(@NotNull Block parent, Block block) {
Block result = null;
for (Block subBlock : parent.getSubBlocks()) {
if (subBlock == block) {
@@ -568,6 +570,7 @@ public class FormatterImpl extends FormatterEx
final TextRange affectedRange) {
final FormattingDocumentModel documentModel = model.getDocumentModel();
final Block block = model.getRootBlock();
+ if (block.getTextRange().isEmpty()) return null; // handing empty document case
final FormatProcessor processor = buildProcessorAndWrapBlocks(
documentModel, block, settings, indentOptions, new FormatTextRanges(affectedRange, true), offset
);
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
index d704e738efa3..bfd00da9107d 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
@@ -18,9 +18,11 @@ package com.intellij.ide.actions;
import com.intellij.codeInsight.navigation.NavigationUtil;
import com.intellij.execution.Executor;
import com.intellij.execution.ExecutorRegistry;
+import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.actions.ChooseRunConfigurationPopup;
import com.intellij.execution.actions.ExecutorProvider;
import com.intellij.execution.executors.DefaultRunExecutor;
+import com.intellij.execution.impl.RunDialog;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
@@ -116,7 +118,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @author Konstantin Bulenkov
*/
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
-public class SearchEverywhereAction extends AnAction implements CustomComponentAction, DumbAware{
+public class SearchEverywhereAction extends AnAction implements CustomComponentAction, DumbAware, DataProvider, RightAlignedToolbarAction {
public static final String SE_HISTORY_KEY = "SearchEverywhereHistoryKey";
public static final int SEARCH_FIELD_COLUMNS = 25;
private static final int MAX_CLASSES = 6;
@@ -321,6 +323,12 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
}
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ return null;
+ }
+
private static String getShortcut() {
String shortcutText;
final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SEARCH_EVERYWHERE);
@@ -673,6 +681,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
panel.add(myPopupField, BorderLayout.CENTER);
panel.add(topPanel, BorderLayout.NORTH);
panel.setBorder(IdeBorderFactory.createEmptyBorder(3, 5, 4, 5));
+ DataManager.registerDataProvider(panel, this);
final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, editor);
myBalloon = builder
.setCancelOnClickOutside(true)
@@ -695,7 +704,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
});
Component parent = UIUtil.findUltimateParent(window);
- registerDataProvider(panel);
+ registerDataProvider(panel, e.getProject());
final RelativePoint showPoint;
if (me != null) {
final Component label = me.getComponent();
@@ -773,7 +782,12 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
storage.setValues(SE_HISTORY_KEY, newValues);
}
- private void registerDataProvider(JPanel panel) {
+ public Executor getExecutor() {
+ return ourShiftIsPressed.get() ? DefaultRunExecutor.getRunExecutorInstance()
+ : ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);
+ }
+
+ private void registerDataProvider(JPanel panel, final Project project) {
DataManager.registerDataProvider(panel, new DataProvider() {
@Nullable
@Override
@@ -783,6 +797,29 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
return value;
} else if (CommonDataKeys.VIRTUAL_FILE.is(dataId) && value instanceof VirtualFile) {
return value;
+ } else if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
+ if (value instanceof Navigatable) return value;
+ if (value instanceof ChooseRunConfigurationPopup.ItemWrapper) {
+ final Object config = ((ChooseRunConfigurationPopup.ItemWrapper)value).getValue();
+ if (config instanceof RunnerAndConfigurationSettings) {
+ return new Navigatable() {
+ @Override
+ public void navigate(boolean requestFocus) {
+ RunDialog.editConfiguration(project, (RunnerAndConfigurationSettings)config, "Edit Configuration", getExecutor());
+ }
+
+ @Override
+ public boolean canNavigate() {
+ return true;
+ }
+
+ @Override
+ public boolean canNavigateToSource() {
+ return true;
+ }
+ };
+ }
+ }
}
return null;
}
diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SelectInAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SelectInAction.java
index 7efdfb14249f..55d532106a56 100644
--- a/platform/lang-impl/src/com/intellij/ide/actions/SelectInAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/actions/SelectInAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -54,7 +54,7 @@ public class SelectInAction extends AnAction implements DumbAware {
}
}
- private static void invoke(DataContext dataContext, SelectInContext context) {
+ private static void invoke(@NotNull DataContext dataContext, @NotNull SelectInContext context) {
final List<SelectInTarget> targetVector = Arrays.asList(getSelectInManager(context.getProject()).getTargets());
ListPopup popup;
if (targetVector.isEmpty()) {
@@ -71,10 +71,10 @@ public class SelectInAction extends AnAction implements DumbAware {
}
private static class SelectInActionsStep extends BaseListPopupStep<SelectInTarget> {
- private final SelectInContext mySelectInContext;
+ @NotNull private final SelectInContext mySelectInContext;
private final List<SelectInTarget> myVisibleTargets;
- public SelectInActionsStep(@NotNull final Collection<SelectInTarget> targetVector, SelectInContext selectInContext) {
+ public SelectInActionsStep(@NotNull final Collection<SelectInTarget> targetVector, @NotNull SelectInContext selectInContext) {
mySelectInContext = selectInContext;
myVisibleTargets = new ArrayList<SelectInTarget>();
for (SelectInTarget target : targetVector) {
diff --git a/platform/lang-impl/src/com/intellij/ide/commander/CommanderPanel.java b/platform/lang-impl/src/com/intellij/ide/commander/CommanderPanel.java
index b5af4621705d..03a5a7fd806a 100644
--- a/platform/lang-impl/src/com/intellij/ide/commander/CommanderPanel.java
+++ b/platform/lang-impl/src/com/intellij/ide/commander/CommanderPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -607,6 +607,7 @@ public class CommanderPanel extends JPanel {
}
}
+ @NotNull
@Override
public PsiDirectory[] getDirectories() {
PsiDirectory directory = getDirectory();
diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java
index c76416e5a4b1..df2a1bf83962 100644
--- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java
+++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesProjectViewPane.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -131,6 +131,7 @@ public class FavoritesProjectViewPane extends AbstractProjectViewPane {
return subId;
}
+ @NotNull
@Override
public ActionCallback updateFromRoot(boolean restoreExpandedPaths) {
return ((FavoritesViewTreeBuilder)getTreeBuilder()).updateFromRootCB();
diff --git a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java
index f97eb9e2a8df..4d72b483a39c 100644
--- a/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java
+++ b/platform/lang-impl/src/com/intellij/ide/favoritesTreeView/FavoritesTreeViewPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -777,6 +777,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider, Dock
return selectedNodeElements[0] instanceof PsiDirectory ? new PsiDirectory[]{(PsiDirectory)selectedNodeElements[0]} : null;
}
+ @NotNull
@Override
public PsiDirectory[] getDirectories() {
final PsiDirectory[] directories = getSelectedDirectories();
diff --git a/platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInGroupTarget.java b/platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInGroupTarget.java
index 8b96157234d8..a0fb4f5d389d 100644
--- a/platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInGroupTarget.java
+++ b/platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInGroupTarget.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -37,7 +37,7 @@ import java.util.LinkedHashSet;
public class ProjectViewSelectInGroupTarget implements CompositeSelectInTarget, DumbAware {
@Override
@NotNull
- public Collection<SelectInTarget> getSubTargets(SelectInContext context) {
+ public Collection<SelectInTarget> getSubTargets(@NotNull SelectInContext context) {
return ProjectView.getInstance(context.getProject()).getSelectInTargets();
}
diff --git a/platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInTarget.java b/platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInTarget.java
index 8902939c1de5..b510dc98bf1f 100644
--- a/platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInTarget.java
+++ b/platform/lang-impl/src/com/intellij/ide/impl/ProjectViewSelectInTarget.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -55,12 +55,13 @@ public abstract class ProjectViewSelectInTarget extends SelectInTargetPsiWrapper
select(myProject, selector, getMinorViewId(), mySubId, virtualFile, requestFocus);
}
+ @NotNull
public static ActionCallback select(@NotNull Project project,
- final Object toSelect,
- @Nullable final String viewId,
- @Nullable final String subviewId,
- final VirtualFile virtualFile,
- final boolean requestFocus) {
+ final Object toSelect,
+ @Nullable final String viewId,
+ @Nullable final String subviewId,
+ final VirtualFile virtualFile,
+ final boolean requestFocus) {
final ActionCallback result = new ActionCallback();
@@ -86,7 +87,8 @@ public abstract class ProjectViewSelectInTarget extends SelectInTargetPsiWrapper
if (requestFocus) {
projectViewToolWindow.activate(runnable, false);
- } else {
+ }
+ else {
projectViewToolWindow.show(runnable);
}
@@ -96,7 +98,7 @@ public abstract class ProjectViewSelectInTarget extends SelectInTargetPsiWrapper
@Override
@NotNull
- public Collection<SelectInTarget> getSubTargets(SelectInContext context) {
+ public Collection<SelectInTarget> getSubTargets(@NotNull SelectInContext context) {
List<SelectInTarget> result = new ArrayList<SelectInTarget>();
AbstractProjectViewPane pane = ProjectView.getInstance(myProject).getProjectViewPaneById(getMinorViewId());
int index = 0;
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarIdeView.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarIdeView.java
index 13ab984a7620..5a32f4d0531b 100644
--- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarIdeView.java
+++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarIdeView.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -22,6 +22,7 @@ import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.Navigatable;
import com.intellij.psi.*;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@@ -48,6 +49,7 @@ public final class NavBarIdeView implements IdeView {
myPanel.hideHint();
}
+ @NotNull
@Override
public PsiDirectory[] getDirectories() {
final PsiDirectory dir = myPanel.getSelectedElement(PsiDirectory.class);
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/ProjectView.java b/platform/lang-impl/src/com/intellij/ide/projectView/ProjectView.java
index cad0cf728c9a..d82a7c0a9b4b 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/ProjectView.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/ProjectView.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
@@ -34,14 +35,15 @@ public abstract class ProjectView {
public abstract void select(Object element, VirtualFile file, boolean requestFocus);
+ @NotNull
public abstract ActionCallback selectCB(Object element, VirtualFile file, boolean requestFocus);
@Nullable
public abstract PsiElement getParentOfCurrentSelection();
// show pane identified by id using default(or currently selected) subId
- public abstract void changeView(String viewId);
- public abstract void changeView(String viewId, String subId);
+ public abstract void changeView(@NotNull String viewId);
+ public abstract void changeView(@NotNull String viewId, String subId);
public abstract void changeView();
@@ -55,19 +57,19 @@ public abstract class ProjectView {
public abstract boolean isHideEmptyMiddlePackages(String paneId);
- public abstract void setHideEmptyPackages(boolean hideEmptyPackages, String paneId);
+ public abstract void setHideEmptyPackages(boolean hideEmptyPackages, @NotNull String paneId);
public abstract boolean isShowLibraryContents(String paneId);
- public abstract void setShowLibraryContents(boolean showLibraryContents, String paneId);
+ public abstract void setShowLibraryContents(boolean showLibraryContents, @NotNull String paneId);
public abstract boolean isShowModules(String paneId);
- public abstract void setShowModules(boolean showModules, String paneId);
+ public abstract void setShowModules(boolean showModules, @NotNull String paneId);
- public abstract void addProjectPane(final AbstractProjectViewPane pane);
+ public abstract void addProjectPane(@NotNull AbstractProjectViewPane pane);
- public abstract void removeProjectPane(AbstractProjectViewPane instance);
+ public abstract void removeProjectPane(@NotNull AbstractProjectViewPane pane);
public abstract AbstractProjectViewPane getProjectViewPaneById(String id);
@@ -75,7 +77,7 @@ public abstract class ProjectView {
public abstract boolean isAbbreviatePackageNames(String paneId);
- public abstract void setAbbreviatePackageNames(boolean abbreviatePackageNames, String paneId);
+ public abstract void setAbbreviatePackageNames(boolean abbreviatePackageNames, @NotNull String paneId);
/**
* e.g. {@link com.intellij.ide.projectView.impl.ProjectViewPane#ID}
@@ -86,11 +88,13 @@ public abstract class ProjectView {
public abstract void selectPsiElement(PsiElement element, boolean requestFocus);
public abstract boolean isSortByType(String paneId);
- public abstract void setSortByType(String paneId, final boolean sortByType);
+ public abstract void setSortByType(@NotNull String paneId, final boolean sortByType);
public abstract AbstractProjectViewPane getCurrentProjectViewPane();
+ @NotNull
public abstract Collection<String> getPaneIds();
+ @NotNull
public abstract Collection<SelectInTarget> getSelectInTargets();
}
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java
index d8bab8db9224..593d2576f370 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPSIPane.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -156,6 +156,7 @@ public abstract class AbstractProjectViewPSIPane extends AbstractProjectViewPane
CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
+ @NotNull
@Override
public final ActionCallback updateFromRoot(boolean restoreExpandedPaths) {
final ArrayList<Object> pathsToExpand = new ArrayList<Object>();
@@ -190,6 +191,7 @@ public abstract class AbstractProjectViewPSIPane extends AbstractProjectViewPane
selectCB(element, file, requestFocus);
}
+ @NotNull
public ActionCallback selectCB(Object element, VirtualFile file, boolean requestFocus) {
if (file != null) {
return ((BaseProjectTreeBuilder)getTreeBuilder()).select(element, file, requestFocus);
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java
index c4708c48d19f..636824bd4896 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/AbstractProjectViewPane.java
@@ -204,9 +204,11 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl
myTreeStructure = null;
}
+ @NotNull
public abstract ActionCallback updateFromRoot(boolean restoreExpandedPaths);
public abstract void select(Object element, VirtualFile file, boolean requestFocus);
+
public void selectModule(final Module module, final boolean requestFocus) {
doSelectModuleOrGroup(module, requestFocus);
}
@@ -482,6 +484,7 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl
return myTree;
}
+ @NotNull
public PsiDirectory[] getSelectedDirectories() {
List<PsiDirectory> directories = ContainerUtil.newArrayList();
for (PsiDirectoryNode node : getSelectedNodes(PsiDirectoryNode.class)) {
@@ -541,6 +544,7 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl
return PsiDirectory.EMPTY_ARRAY;
}
+ @NotNull
protected PsiDirectory[] getSelectedDirectoriesInAmbiguousCase(@NotNull final DefaultMutableTreeNode node) {
final Object userObject = node.getUserObject();
if (userObject instanceof AbstractModuleNode) {
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/FavoritesViewToolWindowFactory.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/FavoritesViewToolWindowFactory.java
index 17aa1b673f0c..451ae64b0bbb 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/FavoritesViewToolWindowFactory.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/FavoritesViewToolWindowFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -24,13 +24,14 @@ import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.openapi.wm.ex.ToolWindowEx;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManager;
+import org.jetbrains.annotations.NotNull;
/**
* @author Konstantin Bulenkov
*/
public class FavoritesViewToolWindowFactory implements ToolWindowFactory, DumbAware {
@Override
- public void createToolWindowContent(Project project, ToolWindow toolWindow) {
+ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
if (toolWindow != null) {
final ContentManager contentManager = toolWindow.getContentManager();
final FavoritesTreeViewPanel panel = new FavoritesPanel(project).getPanel();
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
index a8c7c0aa98a0..4172abdb1798 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java
@@ -40,7 +40,10 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
-import com.intellij.openapi.components.*;
+import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.openapi.components.State;
+import com.intellij.openapi.components.Storage;
+import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.Extensions;
@@ -49,7 +52,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
@@ -70,13 +73,15 @@ import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
import com.intellij.openapi.wm.impl.content.ToolWindowContentUi;
import com.intellij.psi.*;
import com.intellij.psi.impl.file.PsiDirectoryFactory;
-import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.AutoScrollFromSourceHandler;
import com.intellij.ui.AutoScrollToSourceHandler;
import com.intellij.ui.GuiUtils;
import com.intellij.ui.components.JBList;
-import com.intellij.ui.content.*;
+import com.intellij.ui.content.Content;
+import com.intellij.ui.content.ContentManager;
+import com.intellij.ui.content.ContentManagerAdapter;
+import com.intellij.ui.content.ContentManagerEvent;
import com.intellij.ui.switcher.QuickActionProvider;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IJSwingUtilities;
@@ -114,7 +119,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private final CopyPasteDelegator myCopyPasteDelegator;
private boolean isInitialized;
private boolean myExtensionsLoaded = false;
- private final Project myProject;
+ @NotNull private final Project myProject;
// + options
private final Map<String, Boolean> myFlattenPackages = new THashMap<String, Boolean>();
@@ -134,7 +139,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private final Map<String, Boolean> myAutoscrollToSource = new THashMap<String, Boolean>();
private final Map<String, Boolean> myAutoscrollFromSource = new THashMap<String, Boolean>();
private static final boolean ourAutoscrollFromSourceDefaults = false;
- private static final boolean ourShowStructureDefaults = false;
private String myCurrentViewId;
private String myCurrentViewSubId;
@@ -172,7 +176,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
@NonNls private static final String ELEMENT_AUTOSCROLL_TO_SOURCE = "autoscrollToSource";
@NonNls private static final String ELEMENT_AUTOSCROLL_FROM_SOURCE = "autoscrollFromSource";
@NonNls private static final String ELEMENT_SORT_BY_TYPE = "sortByType";
- @NonNls private static final String ELEMENT_FOLDERS_ALWAYS_ON_TOP = "foldersAlwaysOnTop";
private static final String ATTRIBUTE_ID = "id";
private JPanel myViewContentPanel;
@@ -191,7 +194,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private ContentManager myContentManager;
private boolean myFoldersAlwaysOnTop = true;
- public ProjectViewImpl(Project project, final FileEditorManager fileEditorManager, final ToolWindowManagerEx toolWindowManager) {
+ public ProjectViewImpl(@NotNull Project project, final FileEditorManager fileEditorManager, final ToolWindowManagerEx toolWindowManager) {
myProject = project;
constructUi();
@@ -221,16 +224,16 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
};
myAutoScrollToSourceHandler = new AutoScrollToSourceHandler() {
- @Override
- protected boolean isAutoScrollMode() {
- return isAutoscrollToSource(myCurrentViewId);
- }
+ @Override
+ protected boolean isAutoScrollMode() {
+ return isAutoscrollToSource(myCurrentViewId);
+ }
- @Override
- protected void setAutoScrollMode(boolean state) {
- setAutoscrollToSource(state, myCurrentViewId);
- }
- };
+ @Override
+ protected void setAutoScrollMode(boolean state) {
+ setAutoscrollToSource(state, myCurrentViewId);
+ }
+ };
toolWindowManager.addToolWindowManagerListener(new ToolWindowManagerAdapter(){
private boolean toolWindowVisible;
@@ -268,16 +271,15 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
@Override
+ @NotNull
public List<AnAction> getActions(boolean originalProvider) {
ArrayList<AnAction> result = new ArrayList<AnAction>();
DefaultActionGroup views = new DefaultActionGroup("Change View", true);
- boolean lastWasHeader = false;
boolean lastHeaderHadKids = false;
for (int i = 0; i < myContentManager.getContentCount(); i++) {
Content each = myContentManager.getContent(i);
if (each != null) {
-
if (each.getUserData(SUB_ID_KEY) == null) {
if (lastHeaderHadKids) {
views.add(new Separator());
@@ -291,12 +293,11 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
}
- } else {
+ }
+ else {
lastHeaderHadKids = true;
}
- lastWasHeader = each.getUserData(SUB_ID_KEY) == null;
-
views.add(new ChangeViewAction(each.getUserData(ID_KEY), each.getUserData(SUB_ID_KEY)));
}
}
@@ -304,13 +305,14 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
result.add(new Separator());
- ArrayList<AnAction> secondary = new ArrayList<AnAction>();
+ List<AnAction> secondary = new ArrayList<AnAction>();
if (myActionGroup != null) {
AnAction[] kids = myActionGroup.getChildren(null);
for (AnAction each : kids) {
if (myActionGroup.isPrimary(each)) {
result.add(each);
- } else {
+ }
+ else {
secondary.add(each);
}
}
@@ -325,7 +327,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private final String myId;
private final String mySubId;
- private ChangeViewAction(String id, String subId) {
+ private ChangeViewAction(@NotNull String id, String subId) {
myId = id;
mySubId = subId;
}
@@ -348,7 +350,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
@Override
- public synchronized void addProjectPane(final AbstractProjectViewPane pane) {
+ public synchronized void addProjectPane(@NotNull final AbstractProjectViewPane pane) {
myUninitializedPanes.add(pane);
SelectInTarget selectInTarget = pane.createSelectInTarget();
if (selectInTarget != null) {
@@ -360,7 +362,8 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
@Override
- public synchronized void removeProjectPane(AbstractProjectViewPane pane) {
+ public synchronized void removeProjectPane(@NotNull AbstractProjectViewPane pane) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
myUninitializedPanes.remove(pane);
//assume we are completely initialized here
String idToRemove = pane.getId();
@@ -425,7 +428,8 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
myUninitializedPanes.clear();
}
- private void doAddPane(final AbstractProjectViewPane newPane) {
+ private void doAddPane(@NotNull final AbstractProjectViewPane newPane) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
int index;
final ContentManager manager = myContentManager;
for (index = 0; index < manager.getContentCount(); index++) {
@@ -473,7 +477,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
Disposer.register(this, newPane);
}
- private void showPane(AbstractProjectViewPane newPane) {
+ private void showPane(@NotNull AbstractProjectViewPane newPane) {
AbstractProjectViewPane currentPane = getCurrentProjectViewPane();
PsiElement selectedPsiElement = null;
if (currentPane != null) {
@@ -550,30 +554,26 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
myActionGroup.remove(collapseAction);
}
}
- ((ToolWindowEx)window).setTitleActions(new AnAction[] {scrollAction, collapseAction});
+ ((ToolWindowEx)window).setTitleActions(scrollAction, collapseAction);
}
// public for tests
- public synchronized void setupImpl(final ToolWindow toolWindow) {
+ public synchronized void setupImpl(@NotNull ToolWindow toolWindow) {
setupImpl(toolWindow, true);
}
// public for tests
- public synchronized void setupImpl(final ToolWindow toolWindow, final boolean loadPaneExtensions) {
+ public synchronized void setupImpl(@NotNull ToolWindow toolWindow, final boolean loadPaneExtensions) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
myActionGroup = new DefaultActionGroup();
myAutoScrollFromSourceHandler.install();
- if (toolWindow != null) {
- myContentManager = toolWindow.getContentManager();
- if (!ApplicationManager.getApplication().isUnitTestMode()) {
- toolWindow.setContentUiType(ToolWindowContentUiType.COMBO, null);
- ((ToolWindowEx)toolWindow).setAdditionalGearActions(myActionGroup);
- toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
- }
- } else {
- final ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class);
- myContentManager = contentFactory.createContentManager(false, myProject);
+ myContentManager = toolWindow.getContentManager();
+ if (!ApplicationManager.getApplication().isUnitTestMode()) {
+ toolWindow.setContentUiType(ToolWindowContentUiType.COMBO, null);
+ ((ToolWindowEx)toolWindow).setAdditionalGearActions(myActionGroup);
+ toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
}
GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel);
@@ -655,11 +655,11 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
class FlattenPackagesDependableAction extends PaneOptionAction {
- FlattenPackagesDependableAction(Map<String, Boolean> optionsMap,
- final String text,
- final String description,
- final Icon icon,
- boolean optionDefaultValue) {
+ FlattenPackagesDependableAction(@NotNull Map<String, Boolean> optionsMap,
+ @NotNull String text,
+ @NotNull String description,
+ @NotNull Icon icon,
+ boolean optionDefaultValue) {
super(optionsMap, text, description, icon, optionDefaultValue);
}
@@ -782,15 +782,15 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
+ @NotNull
@Override
public ActionCallback selectCB(Object element, VirtualFile file, boolean requestFocus) {
final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
if (viewPane != null && viewPane instanceof AbstractProjectViewPSIPane) {
- return ((AbstractProjectViewPSIPane) viewPane).selectCB(element, file, requestFocus);
- } else {
- select(element, file, requestFocus);
- return new ActionCallback.Done();
+ return ((AbstractProjectViewPSIPane)viewPane).selectCB(element, file, requestFocus);
}
+ select(element, file, requestFocus);
+ return new ActionCallback.Done();
}
@Override
@@ -844,10 +844,10 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private final Map<String, Boolean> myOptionsMap;
private final boolean myOptionDefaultValue;
- PaneOptionAction(Map<String, Boolean> optionsMap,
- final String text,
- final String description,
- final Icon icon,
+ PaneOptionAction(@NotNull Map<String, Boolean> optionsMap,
+ @NotNull String text,
+ @NotNull String description,
+ Icon icon,
boolean optionDefaultValue) {
super(text, description, icon);
myOptionsMap = optionsMap;
@@ -946,6 +946,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
+ @NotNull
private PsiElement[] getElementsToDelete() {
final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
PsiElement[] elements = viewPane.getSelectedPSIElements();
@@ -1038,7 +1039,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
if (virtualFiles == null || virtualFiles.length <= 1) return null;
final Set<Module> modules = new HashSet<Module>();
for (VirtualFile virtualFile : virtualFiles) {
- modules.add(ModuleUtil.findModuleForFile(virtualFile, myProject));
+ modules.add(ModuleUtilCore.findModuleForFile(virtualFile, myProject));
}
return modules.size() == 1 ? modules.iterator().next() : null;
}
@@ -1157,7 +1158,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
return null;
}
- private void detachLibrary(final LibraryOrderEntry orderEntry, final Project project) {
+ private void detachLibrary(@NotNull final LibraryOrderEntry orderEntry, @NotNull Project project) {
final Module module = orderEntry.getOwnerModule();
String message = IdeBundle.message("detach.library.from.module", orderEntry.getPresentableName(), module.getName());
String title = IdeBundle.message("detach.library");
@@ -1230,7 +1231,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
* otherwise VirtualFileArrayRule will return all module's content roots when just one of them is selected
*/
@Nullable
- private Module moduleBySingleContentRoot(VirtualFile file) {
+ private Module moduleBySingleContentRoot(@NotNull VirtualFile file) {
if (ProjectRootsUtil.isModuleContentRoot(file, myProject)) {
Module module = ProjectRootManager.getInstance(myProject).getFileIndex().getModuleForFile(file);
if (module != null && !module.isDisposed() && ModuleRootManager.getInstance(module).getContentRoots().length == 1) {
@@ -1241,8 +1242,9 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
return null;
}
- private <T> List<T> getSelectedElements(Class<T> klass) {
- ArrayList<T> result = new ArrayList<T>();
+ @NotNull
+ private <T> List<T> getSelectedElements(@NotNull Class<T> klass) {
+ List<T> result = new ArrayList<T>();
final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
if (viewPane == null) return result;
final Object[] elements = viewPane.getSelectedElements();
@@ -1276,6 +1278,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
+ @NotNull
@Override
public PsiDirectory[] getDirectories() {
final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
@@ -1295,12 +1298,12 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
@Override
public void selectPsiElement(PsiElement element, boolean requestFocus) {
if (element == null) return;
- VirtualFile virtualFile = PsiUtilBase.getVirtualFile(element);
+ VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
select(element, virtualFile, requestFocus);
}
- private static void readOption(Element node, Map<String, Boolean> options) {
+ private static void readOption(Element node, @NotNull Map<String, Boolean> options) {
if (node == null) return;
List attributes = node.getAttributes();
for (final Object attribute1 : attributes) {
@@ -1309,7 +1312,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
- private static void writeOption(Element parentNode, Map<String, Boolean> optionsForPanes, String optionName) {
+ private static void writeOption(@NotNull Element parentNode, @NotNull Map<String, Boolean> optionsForPanes, @NotNull String optionName) {
Element e = new Element(optionName);
for (Map.Entry<String, Boolean> entry : optionsForPanes.entrySet()) {
final String key = entry.getKey();
@@ -1354,7 +1357,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
- private void readPaneState(Element panesElement) {
+ private void readPaneState(@NotNull Element panesElement) {
@SuppressWarnings({"unchecked"})
final List<Element> paneElements = panesElement.getChildren(ELEMENT_PANE);
@@ -1412,7 +1415,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
return parentNode;
}
- private void writePaneState(Element panesElement) {
+ private void writePaneState(@NotNull Element panesElement) {
for (AbstractProjectViewPane pane : myId2Pane.values()) {
Element paneElement = new Element(ELEMENT_PANE);
paneElement.setAttribute(ATTRIBUTE_ID, pane.getId());
@@ -1425,7 +1428,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
panesElement.addContent(paneElement);
}
for (Element element : myUninitializedPaneState.values()) {
- panesElement.addContent((Element) element.clone());
+ panesElement.addContent(element.clone());
}
}
@@ -1496,10 +1499,11 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
@Override
- public void setShowLibraryContents(boolean showLibraryContents, String paneId) {
+ public void setShowLibraryContents(boolean showLibraryContents, @NotNull String paneId) {
setPaneOption(myShowLibraryContents, showLibraryContents, paneId, true);
}
+ @NotNull
public ActionCallback setShowLibraryContentsCB(boolean showLibraryContents, String paneId) {
return setPaneOption(myShowLibraryContents, showLibraryContents, paneId, true);
}
@@ -1510,21 +1514,22 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
@Override
- public void setShowModules(boolean showModules, String paneId) {
+ public void setShowModules(boolean showModules, @NotNull String paneId) {
setPaneOption(myShowModules, showModules, paneId, true);
}
@Override
- public void setHideEmptyPackages(boolean hideEmptyPackages, String paneId) {
+ public void setHideEmptyPackages(boolean hideEmptyPackages, @NotNull String paneId) {
setPaneOption(myHideEmptyPackages, hideEmptyPackages, paneId, true);
}
@Override
- public void setAbbreviatePackageNames(boolean abbreviatePackageNames, String paneId) {
+ public void setAbbreviatePackageNames(boolean abbreviatePackageNames, @NotNull String paneId) {
setPaneOption(myAbbreviatePackageNames, abbreviatePackageNames, paneId, true);
}
- private ActionCallback setPaneOption(Map<String, Boolean> optionsMap, boolean value, String paneId, final boolean updatePane) {
+ @NotNull
+ private ActionCallback setPaneOption(@NotNull Map<String, Boolean> optionsMap, boolean value, String paneId, final boolean updatePane) {
optionsMap.put(paneId, value ? Boolean.TRUE : Boolean.FALSE);
if (updatePane) {
final AbstractProjectViewPane pane = getProjectViewPaneById(paneId);
@@ -1535,7 +1540,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
return new ActionCallback.Done();
}
- private static boolean getPaneOptionValue(Map<String, Boolean> optionsMap, String paneId, boolean defaultValue) {
+ private static boolean getPaneOptionValue(@NotNull Map<String, Boolean> optionsMap, String paneId, boolean defaultValue) {
final Boolean value = optionsMap.get(paneId);
return value == null ? defaultValue : value.booleanValue();
}
@@ -1573,7 +1578,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private static class SelectionInfo {
private final Object[] myElements;
- private SelectionInfo(Object[] elements) {
+ private SelectionInfo(@NotNull Object[] elements) {
myElements = elements;
}
@@ -1600,6 +1605,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
+ @NotNull
public static SelectionInfo create(final AbstractProjectViewPane viewPane) {
List<Object> selectedElements = Collections.emptyList();
if (viewPane != null) {
@@ -1621,7 +1627,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private class MyAutoScrollFromSourceHandler extends AutoScrollFromSourceHandler {
private MyAutoScrollFromSourceHandler() {
- super(ProjectViewImpl.this.myProject,ProjectViewImpl.this.myViewContentPanel, ProjectViewImpl.this);
+ super(ProjectViewImpl.this.myProject, myViewContentPanel, ProjectViewImpl.this);
}
@Override
@@ -1631,7 +1637,8 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
if (fileEditor instanceof TextEditor) {
Editor editor = ((TextEditor)fileEditor).getEditor();
selectElementAtCaretNotLosingFocus(editor);
- } else {
+ }
+ else {
final VirtualFile file = FileEditorManagerEx.getInstanceEx(myProject).getFile(fileEditor);
if (file != null) {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
@@ -1679,19 +1686,19 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
- private void selectElementAtCaretNotLosingFocus(final Editor editor) {
+ private void selectElementAtCaretNotLosingFocus(@NotNull Editor editor) {
if (IJSwingUtilities.hasFocus(getCurrentProjectViewPane().getComponentToFocus())) return;
selectElementAtCaret(editor);
}
- private void selectElementAtCaret(Editor editor) {
+ private void selectElementAtCaret(@NotNull Editor editor) {
final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
if (file == null) return;
scrollFromFile(file, editor);
}
- private void scrollFromFile(PsiFile file, @Nullable Editor editor) {
+ private void scrollFromFile(@NotNull PsiFile file, @Nullable Editor editor) {
final MySelectInContext selectInContext = new MySelectInContext(file, editor);
final SelectInTarget target = mySelectInTargets.get(getCurrentViewId());
@@ -1719,10 +1726,10 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
private class MySelectInContext implements SelectInContext {
- private final PsiFile myPsiFile;
+ @NotNull private final PsiFile myPsiFile;
@Nullable private final Editor myEditor;
- private MySelectInContext(final PsiFile psiFile, @Nullable Editor editor) {
+ private MySelectInContext(@NotNull PsiFile psiFile, @Nullable Editor editor) {
myPsiFile = psiFile;
myEditor = editor;
}
@@ -1733,13 +1740,14 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
return myProject;
}
+ @NotNull
private PsiFile getPsiFile() {
return myPsiFile;
}
@Override
+ @NotNull
public FileEditorProvider getFileEditorProvider() {
- if (myPsiFile == null) return null;
return new FileEditorProvider() {
@Override
public FileEditor openFileEditor() {
@@ -1748,6 +1756,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
};
}
+ @NotNull
private PsiElement getPsiElement() {
PsiElement e = null;
if (myEditor != null) {
@@ -1780,7 +1789,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
@Override
- public void setSortByType(String paneId, final boolean sortByType) {
+ public void setSortByType(@NotNull String paneId, final boolean sortByType) {
setPaneOption(mySortByType, sortByType, paneId, false);
final AbstractProjectViewPane pane = getProjectViewPaneById(paneId);
pane.installComparator();
@@ -1788,8 +1797,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private class SortByTypeAction extends ToggleAction {
private SortByTypeAction() {
- super(IdeBundle.message("action.sort.by.type"), IdeBundle.message("action.sort.by.type"),
- AllIcons.ObjectBrowser.SortByType);
+ super(IdeBundle.message("action.sort.by.type"), IdeBundle.message("action.sort.by.type"), AllIcons.ObjectBrowser.SortByType);
}
@Override
@@ -1845,11 +1853,13 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
}
+ @NotNull
@Override
public Collection<String> getPaneIds() {
return myId2Pane.keySet();
}
+ @NotNull
@Override
public Collection<SelectInTarget> getSelectInTargets() {
ensurePanesLoaded();
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewToolWindowFactory.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewToolWindowFactory.java
index 192f5966c489..f4b3803a63d0 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewToolWindowFactory.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewToolWindowFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -23,13 +23,14 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactoryEx;
+import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class ProjectViewToolWindowFactory implements ToolWindowFactoryEx, DumbAware {
@Override
- public void createToolWindowContent(Project project, ToolWindow toolWindow) {
+ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
((ProjectViewImpl) ProjectView.getInstance(project)).setupImpl(toolWindow);
}
diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ShowModulesAction.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ShowModulesAction.java
index 6e53e96725b5..370b7a335bf4 100644
--- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ShowModulesAction.java
+++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ShowModulesAction.java
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.util.PlatformUtils;
+import org.jetbrains.annotations.NotNull;
/**
* @author anna
@@ -43,6 +44,7 @@ public abstract class ShowModulesAction extends ToggleAction {
return ProjectView.getInstance(myProject).isShowModules(getId());
}
+ @NotNull
protected abstract String getId();
@Override
diff --git a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java
index 2fbbdc7ea348..9daf15441dbf 100644
--- a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java
+++ b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -252,7 +252,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
public void selectScope(final NamedScope scope) {
refreshScope(scope);
- if (scope != DefaultScopesProvider.getAllScope() && scope != null) {
+ if (scope != CustomScopesProviderEx.getAllScope() && scope != null) {
CURRENT_SCOPE_NAME = scope.getName();
}
}
@@ -323,7 +323,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
public void refreshScope(@Nullable NamedScope scope) {
FileTreeModelBuilder.clearCaches(myProject);
if (scope == null) { //was deleted
- scope = DefaultScopesProvider.getAllScope();
+ scope = CustomScopesProviderEx.getAllScope();
}
LOG.assertTrue(scope != null);
final NamedScopesHolder holder = NamedScopesHolder.getHolder(myProject, scope.getName(), myDependencyValidationManager);
@@ -364,7 +364,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
protected NamedScope getCurrentScope() {
NamedScope scope = NamedScopesHolder.getScope(myProject, CURRENT_SCOPE_NAME);
if (scope == null) {
- scope = DefaultScopesProvider.getAllScope();
+ scope = CustomScopesProviderEx.getAllScope();
}
LOG.assertTrue(scope != null);
return scope;
@@ -888,6 +888,7 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
return null;
}
+ @NotNull
@Override
public PsiDirectory[] getDirectories() {
PsiDirectory directory = getDirectory();
diff --git a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java
index 5c929e99b736..dc47793401e0 100644
--- a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java
+++ b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java
@@ -162,6 +162,7 @@ public class ScopeViewPane extends AbstractProjectViewPane {
public void addToolbarActions(DefaultActionGroup actionGroup) {
actionGroup.add(ActionManager.getInstance().getAction("ScopeView.EditScopes"));
actionGroup.addAction(new ShowModulesAction(myProject){
+ @NotNull
@Override
protected String getId() {
return ScopeViewPane.this.getId();
@@ -169,6 +170,7 @@ public class ScopeViewPane extends AbstractProjectViewPane {
}).setAsSecondary(true);
}
+ @NotNull
@Override
public ActionCallback updateFromRoot(boolean restoreExpandedPaths) {
saveExpandedPaths();
@@ -249,14 +251,13 @@ public class ScopeViewPane extends AbstractProjectViewPane {
if (data != null) {
return data;
}
- return myViewPanel != null ? myViewPanel.getData(dataId) : null;
+ return myViewPanel == null ? null : myViewPanel.getData(dataId);
}
@NotNull
@Override
public ActionCallback getReady(@NotNull Object requestor) {
final ActionCallback callback = myViewPanel.getActionCallback();
- return myViewPanel == null ? new ActionCallback.Rejected() :
- callback != null ? callback : new ActionCallback.Done();
+ return callback == null ? new ActionCallback.Done() : callback;
}
}
diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewToolWindowFactory.java b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewToolWindowFactory.java
index b05193bf858a..c06cd2cb5d59 100644
--- a/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewToolWindowFactory.java
+++ b/platform/lang-impl/src/com/intellij/ide/structureView/impl/StructureViewToolWindowFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -22,13 +22,14 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.openapi.wm.ex.ToolWindowEx;
+import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class StructureViewToolWindowFactory implements ToolWindowFactory, DumbAware {
@Override
- public void createToolWindowContent(Project project, ToolWindow toolWindow) {
+ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
StructureViewFactoryImpl factory = (StructureViewFactoryImpl)StructureViewFactory.getInstance(project);
factory.initToolWindow((ToolWindowEx)toolWindow);
}
diff --git a/platform/lang-impl/src/com/intellij/ide/todo/TodoToolWindowFactory.java b/platform/lang-impl/src/com/intellij/ide/todo/TodoToolWindowFactory.java
index ad5368672fec..4217f5ace393 100644
--- a/platform/lang-impl/src/com/intellij/ide/todo/TodoToolWindowFactory.java
+++ b/platform/lang-impl/src/com/intellij/ide/todo/TodoToolWindowFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -20,13 +20,14 @@ import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.components.ServiceManager;
+import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class TodoToolWindowFactory implements ToolWindowFactory {
@Override
- public void createToolWindowContent(Project project, ToolWindow toolWindow) {
+ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
TodoView todoView = ServiceManager.getService(project, TodoView.class);
todoView.initToolWindow(toolWindow);
}
diff --git a/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java b/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java
index 80099b35c3d8..54ae97d446b5 100644
--- a/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java
+++ b/platform/lang-impl/src/com/intellij/ide/util/MemberChooser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -47,8 +47,6 @@ import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.*;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.*;
import java.util.List;
@@ -536,9 +534,9 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
protected void doSort() {
Pair<ElementNode, List<ElementNode>> pair = storeSelection();
- Enumeration<ParentNode> children = getRootNodeChildren();
+ Enumeration<TreeNode> children = getRootNodeChildren();
while (children.hasMoreElements()) {
- ParentNode classNode = children.nextElement();
+ ParentNode classNode = (ParentNode)children.nextElement();
sortNode(classNode, myComparator);
myTreeModel.nodeStructureChanged(classNode);
}
@@ -547,10 +545,10 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
}
private static void sortNode(ParentNode node, final Comparator<ElementNode> sortComparator) {
- ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>();
- Enumeration<MemberNode> children = node.children();
+ ArrayList<ElementNode> arrayList = new ArrayList<ElementNode>();
+ Enumeration<TreeNode> children = node.children();
while (children.hasMoreElements()) {
- arrayList.add(children.nextElement());
+ arrayList.add((ElementNode)children.nextElement());
}
Collections.sort(arrayList, sortComparator);
@@ -571,16 +569,16 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
DefaultMutableTreeNode root = getRootNode();
if (!myShowClasses || myContainerNodes.isEmpty()) {
List<ParentNode> otherObjects = new ArrayList<ParentNode>();
- Enumeration<ParentNode> children = getRootNodeChildren();
+ Enumeration<TreeNode> children = getRootNodeChildren();
ParentNode newRoot = new ParentNode(null, new MemberChooserObjectBase(getAllContainersNodeName()), new Ref<Integer>(0));
while (children.hasMoreElements()) {
- final ParentNode nextElement = children.nextElement();
+ final ParentNode nextElement = (ParentNode)children.nextElement();
if (nextElement instanceof ContainerNode) {
final ContainerNode containerNode = (ContainerNode)nextElement;
- Enumeration<MemberNode> memberNodes = containerNode.children();
+ Enumeration<TreeNode> memberNodes = containerNode.children();
List<MemberNode> memberNodesList = new ArrayList<MemberNode>();
while (memberNodes.hasMoreElements()) {
- memberNodesList.add(memberNodes.nextElement());
+ memberNodesList.add((MemberNode)memberNodes.nextElement());
}
for (MemberNode memberNode : memberNodesList) {
newRoot.add(memberNode);
@@ -595,13 +593,13 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
if (newRoot.children().hasMoreElements()) root.add(newRoot);
}
else {
- Enumeration<ParentNode> children = getRootNodeChildren();
+ Enumeration<TreeNode> children = getRootNodeChildren();
while (children.hasMoreElements()) {
- ParentNode allClassesNode = children.nextElement();
- Enumeration<MemberNode> memberNodes = allClassesNode.children();
+ ParentNode allClassesNode = (ParentNode)children.nextElement();
+ Enumeration<TreeNode> memberNodes = allClassesNode.children();
ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>();
while (memberNodes.hasMoreElements()) {
- arrayList.add(memberNodes.nextElement());
+ arrayList.add((MemberNode)memberNodes.nextElement());
}
Collections.sort(arrayList, myComparator);
for (MemberNode memberNode : arrayList) {
@@ -626,7 +624,7 @@ public class MemberChooser<T extends ClassMember> extends DialogWrapper implemen
return IdeBundle.message("node.memberchooser.all.classes");
}
- private Enumeration<ParentNode> getRootNodeChildren() {
+ private Enumeration<TreeNode> getRootNodeChildren() {
return getRootNode().children();
}
diff --git a/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java b/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java
index ccf63a429346..267333399dbd 100644
--- a/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java
+++ b/platform/lang-impl/src/com/intellij/lang/parser/GeneratedParserUtilBase.java
@@ -933,7 +933,8 @@ public class GeneratedParserUtilBase {
for (Pair<PsiBuilder.Marker, Integer> pair : siblingList) {
if (pair.second != rating || parenPair != null && pair.first == parenPair.second) break main;
if (++count >= MAX_CHILDREN_IN_TREE) {
- final PsiBuilder.Marker parentMarker = pair.first.precede();
+ PsiBuilder.Marker parentMarker = pair.first.precede();
+ parentMarker.setCustomEdgeTokenBinders(WhitespacesBinders.GREEDY_LEFT_BINDER, null);
while (count-- > 0) {
siblingList.removeFirst();
}
@@ -986,6 +987,7 @@ public class GeneratedParserUtilBase {
else {
if (marker == null) {
marker = builder_.mark();
+ marker.setCustomEdgeTokenBinders(WhitespacesBinders.GREEDY_LEFT_BINDER, null);
}
final boolean result = (!parenList.isEmpty() || eatMoreCondition.parse(builder_, level + 1)) && parser.parse(builder_, level + 1);
if (result) {
diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/actions/SelectWordAtCaretAction.java b/platform/lang-impl/src/com/intellij/openapi/editor/actions/SelectWordAtCaretAction.java
index b70189f5140a..0cf8e9e984d0 100644
--- a/platform/lang-impl/src/com/intellij/openapi/editor/actions/SelectWordAtCaretAction.java
+++ b/platform/lang-impl/src/com/intellij/openapi/editor/actions/SelectWordAtCaretAction.java
@@ -35,6 +35,7 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.text.CharArrayUtil;
+import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -45,18 +46,13 @@ public class SelectWordAtCaretAction extends TextComponentEditorAction implement
setInjectedContext(true);
}
- @Override
- public EditorActionHandler getHandler() {
- return new Handler(super.getHandler());
- }
-
private static class DefaultHandler extends EditorActionHandler {
private DefaultHandler() {
super(true);
}
@Override
- public void execute(Editor editor, DataContext dataContext) {
+ public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
int lineNumber = editor.getCaretModel().getLogicalPosition().line;
int caretOffset = editor.getCaretModel().getOffset();
Document document = editor.getDocument();
@@ -94,23 +90,24 @@ public class SelectWordAtCaretAction extends TextComponentEditorAction implement
}
}
- private static class Handler extends EditorActionHandler {
+ public static class Handler extends EditorActionHandler {
private final EditorActionHandler myDefaultHandler;
- private Handler(EditorActionHandler defaultHandler) {
+ public Handler(EditorActionHandler defaultHandler) {
super(true);
myDefaultHandler = defaultHandler;
+
}
@Override
- public void execute(Editor editor, DataContext dataContext) {
+ public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
final IndentGuideDescriptor guide = editor.getIndentsModel().getCaretIndentGuide();
final SelectionModel selectionModel = editor.getSelectionModel();
if (guide != null && !selectionModel.hasSelection() && !selectionModel.hasBlockSelection() && isWhitespaceAtCaret(editor)) {
selectWithGuide(editor, guide);
}
else {
- myDefaultHandler.execute(editor, dataContext);
+ myDefaultHandler.execute(editor, caret, dataContext);
}
}
diff --git a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorPsiDataProvider.java b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorPsiDataProvider.java
index 1f911936637a..7400e982b5a0 100644
--- a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorPsiDataProvider.java
+++ b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorPsiDataProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -19,9 +19,12 @@ package com.intellij.openapi.fileEditor.impl.text;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.ide.IdeView;
import com.intellij.ide.util.EditorHelper;
+import com.intellij.injected.editor.EditorWindow;
+import com.intellij.injected.editor.InjectedCaret;
import com.intellij.lang.Language;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.SelectionModel;
+import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.fileEditor.EditorDataProvider;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.Project;
@@ -42,45 +45,64 @@ import static com.intellij.util.containers.ContainerUtil.addIfNotNull;
public class TextEditorPsiDataProvider implements EditorDataProvider {
@Override
@Nullable
- public Object getData(@NotNull final String dataId, @NotNull final Editor e, @NotNull final VirtualFile file) {
- if (!file.isValid()) return null;
+ public Object getData(@NotNull final String dataId, @NotNull final Editor e, @NotNull final Caret caret) {
+ if (!(e instanceof EditorEx)) {
+ return null;
+ }
+ VirtualFile file = ((EditorEx)e).getVirtualFile();
+ if (file == null || !file.isValid()) return null;
+ Project project = e.getProject();
if (dataId.equals(injectedId(EDITOR.getName()))) {
- if (PsiDocumentManager.getInstance(e.getProject()).isUncommited(e.getDocument())) {
+ if (project == null || PsiDocumentManager.getInstance(project).isUncommited(e.getDocument())) {
return e;
}
else {
- return InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(e, getPsiFile(e, file));
+ return InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(e, caret, getPsiFile(e, file));
}
}
+ if (HOST_EDITOR.is(dataId)) {
+ return e instanceof EditorWindow ? ((EditorWindow)e).getDelegate() : e;
+ }
+ if (CARET.is(dataId)) {
+ return caret;
+ }
+ if (dataId.equals(injectedId(CARET.getName()))) {
+ Editor editor = (Editor)getData(injectedId(EDITOR.getName()), e, caret);
+ assert editor != null;
+ return getInjectedCaret(editor, caret);
+ }
if (dataId.equals(injectedId(PSI_ELEMENT.getName()))) {
- return getPsiElementIn((Editor)getData(injectedId(EDITOR.getName()), e, file), file);
+ Editor editor = (Editor)getData(injectedId(EDITOR.getName()), e, caret);
+ assert editor != null;
+ Caret injectedCaret = getInjectedCaret(editor, caret);
+ return getPsiElementIn(editor, injectedCaret, file);
}
if (PSI_ELEMENT.is(dataId)){
- return getPsiElementIn(e, file);
+ return getPsiElementIn(e, caret, file);
}
if (dataId.equals(injectedId(LANGUAGE.getName()))) {
- PsiFile psiFile = (PsiFile)getData(injectedId(PSI_FILE.getName()), e, file);
- Editor editor = (Editor)getData(injectedId(EDITOR.getName()), e, file);
+ PsiFile psiFile = (PsiFile)getData(injectedId(PSI_FILE.getName()), e, caret);
+ Editor editor = (Editor)getData(injectedId(EDITOR.getName()), e, caret);
if (psiFile == null || editor == null) return null;
- return getLanguageAtCurrentPositionInEditor(editor, psiFile);
+ Caret injectedCaret = getInjectedCaret(editor, caret);
+ return getLanguageAtCurrentPositionInEditor(injectedCaret, psiFile);
}
if (LANGUAGE.is(dataId)) {
final PsiFile psiFile = getPsiFile(e, file);
if (psiFile == null) return null;
- return getLanguageAtCurrentPositionInEditor(e, psiFile);
+ return getLanguageAtCurrentPositionInEditor(caret, psiFile);
}
if (dataId.equals(injectedId(VIRTUAL_FILE.getName()))) {
- PsiFile psiFile = (PsiFile)getData(injectedId(PSI_FILE.getName()), e, file);
+ PsiFile psiFile = (PsiFile)getData(injectedId(PSI_FILE.getName()), e, caret);
if (psiFile == null) return null;
return psiFile.getVirtualFile();
}
if (dataId.equals(injectedId(PSI_FILE.getName()))) {
- Editor editor = (Editor)getData(injectedId(EDITOR.getName()), e, file);
+ Editor editor = (Editor)getData(injectedId(EDITOR.getName()), e, caret);
if (editor == null) {
return null;
}
- final Project project = editor.getProject();
if (project == null) {
return null;
}
@@ -90,7 +112,7 @@ public class TextEditorPsiDataProvider implements EditorDataProvider {
return getPsiFile(e, file);
}
if (IDE_VIEW.is(dataId)) {
- final PsiFile psiFile = PsiManager.getInstance(e.getProject()).findFile(file);
+ final PsiFile psiFile = project == null ? null : PsiManager.getInstance(project).findFile(file);
final PsiDirectory psiDirectory = psiFile != null ? psiFile.getParent() : null;
if (psiDirectory != null && psiDirectory.isPhysical()) {
return new IdeView() {
@@ -103,6 +125,7 @@ public class TextEditorPsiDataProvider implements EditorDataProvider {
}
}
+ @NotNull
@Override
public PsiDirectory[] getDirectories() {
return new PsiDirectory[]{psiDirectory};
@@ -116,20 +139,32 @@ public class TextEditorPsiDataProvider implements EditorDataProvider {
}
}
if (CONTEXT_LANGUAGES.is(dataId)) {
- return computeLanguages(e, file);
+ return computeLanguages(e, caret);
}
return null;
}
- private static Language getLanguageAtCurrentPositionInEditor(final Editor editor, final PsiFile psiFile) {
- final SelectionModel selectionModel = editor.getSelectionModel();
- int caretOffset = editor.getCaretModel().getOffset();
- int mostProbablyCorrectLanguageOffset = caretOffset == selectionModel.getSelectionStart() ||
- caretOffset == selectionModel.getSelectionEnd()
- ? selectionModel.getSelectionStart()
+ @NotNull
+ private static Caret getInjectedCaret(@NotNull Editor editor, @NotNull Caret hostCaret) {
+ if (!(editor instanceof EditorWindow) || hostCaret instanceof InjectedCaret) {
+ return hostCaret;
+ }
+ for (Caret caret : editor.getCaretModel().getAllCarets()) {
+ if (((InjectedCaret)caret).getDelegate() == hostCaret) {
+ return caret;
+ }
+ }
+ throw new IllegalArgumentException("Cannot find injected caret corresponding to " + hostCaret);
+ }
+
+ private static Language getLanguageAtCurrentPositionInEditor(Caret caret, final PsiFile psiFile) {
+ int caretOffset = caret.getOffset();
+ int mostProbablyCorrectLanguageOffset = caretOffset == caret.getSelectionStart() ||
+ caretOffset == caret.getSelectionEnd()
+ ? caret.getSelectionStart()
: caretOffset;
- if (selectionModel.hasSelection()) {
- return getLanguageAtOffset(psiFile, mostProbablyCorrectLanguageOffset, selectionModel.getSelectionEnd());
+ if (caret.hasSelection()) {
+ return getLanguageAtOffset(psiFile, mostProbablyCorrectLanguageOffset, caret.getSelectionEnd());
}
return PsiUtilCore.getLanguageAtOffset(psiFile, mostProbablyCorrectLanguageOffset);
@@ -148,12 +183,13 @@ public class TextEditorPsiDataProvider implements EditorDataProvider {
}
@Nullable
- private static PsiElement getPsiElementIn(@NotNull Editor editor, @NotNull VirtualFile file) {
+ private static PsiElement getPsiElementIn(@NotNull Editor editor, @NotNull Caret caret, @NotNull VirtualFile file) {
final PsiFile psiFile = getPsiFile(editor, file);
if (psiFile == null) return null;
try {
- return TargetElementUtilBase.findTargetElement(editor, TargetElementUtilBase.getInstance().getReferenceSearchFlags());
+ TargetElementUtilBase util = TargetElementUtilBase.getInstance();
+ return util.findTargetElement(editor, util.getReferenceSearchFlags(), caret.getOffset());
}
catch (IndexNotReadyException e) {
return null;
@@ -173,13 +209,13 @@ public class TextEditorPsiDataProvider implements EditorDataProvider {
return psiFile != null && psiFile.isValid() ? psiFile : null;
}
- private Language[] computeLanguages(@NotNull Editor editor, @NotNull VirtualFile file) {
+ private Language[] computeLanguages(@NotNull Editor editor, @NotNull Caret caret) {
LinkedHashSet<Language> set = new LinkedHashSet<Language>(4);
- Language injectedLanguage = (Language)getData(injectedId(LANGUAGE.getName()), editor, file);
+ Language injectedLanguage = (Language)getData(injectedId(LANGUAGE.getName()), editor, caret);
addIfNotNull(injectedLanguage, set);
- Language language = (Language)getData(LANGUAGE.getName(), editor, file);
+ Language language = (Language)getData(LANGUAGE.getName(), editor, caret);
addIfNotNull(language, set);
- PsiFile psiFile = (PsiFile)getData(PSI_FILE.getName(), editor, file);
+ PsiFile psiFile = (PsiFile)getData(PSI_FILE.getName(), editor, caret);
if (psiFile != null) {
addIfNotNull(psiFile.getViewProvider().getBaseLanguage(), set);
}
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java
index 09e489b3d1df..c753efb145e8 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java
@@ -25,14 +25,16 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.*;
+import com.intellij.openapi.roots.ModuleRootAdapter;
+import com.intellij.openapi.roots.ModuleRootEvent;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
-import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Query;
import com.intellij.util.containers.ConcurrentIntObjectMap;
import com.intellij.util.containers.StripedLockIntObjectConcurrentHashMap;
@@ -42,8 +44,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
public class DirectoryIndexImpl extends DirectoryIndex {
@@ -206,96 +206,4 @@ public class DirectoryIndexImpl extends DirectoryIndex {
LOG.error("Directory index is already disposed for " + myProject);
}
}
-
- @NotNull
- private static OrderEntry createFakeOrderEntry(@NotNull final Module ownerModule) {
- return new OrderEntry() {
- @NotNull
- @Override
- public VirtualFile[] getFiles(OrderRootType type) {
- throw new IncorrectOperationException();
- }
-
- @NotNull
- @Override
- public String[] getUrls(OrderRootType rootType) {
- throw new IncorrectOperationException();
- }
-
- @NotNull
- @Override
- public String getPresentableName() {
- throw new IncorrectOperationException();
- }
-
- @Override
- public boolean isValid() {
- throw new IncorrectOperationException();
- }
-
- @NotNull
- @Override
- public Module getOwnerModule() {
- return ownerModule;
- }
-
- @Override
- public <R> R accept(RootPolicy<R> policy, @Nullable R initialValue) {
- throw new IncorrectOperationException();
- }
-
- @Override
- public int compareTo(@NotNull OrderEntry o) {
- throw new IncorrectOperationException();
- }
-
- @Override
- public boolean isSynthetic() {
- throw new IncorrectOperationException();
- }
- };
- }
-
- @Override
- @Nullable
- OrderEntry findOrderEntryWithOwnerModule(@NotNull DirectoryInfo info, @NotNull Module ownerModule) {
- OrderEntry[] entries = getOrderEntries(info);
- if (entries.length < 10) {
- for (OrderEntry entry : entries) {
- if (entry.getOwnerModule() == ownerModule) return entry;
- }
- return null;
- }
- int index = Arrays.binarySearch(entries, createFakeOrderEntry(ownerModule), RootIndex.BY_OWNER_MODULE);
- return index < 0 ? null : entries[index];
- }
-
- @Override
- @NotNull
- List<OrderEntry> findAllOrderEntriesWithOwnerModule(@NotNull DirectoryInfo info, @NotNull Module ownerModule) {
- OrderEntry[] entries = getOrderEntries(info);
- if (entries.length == 0) return Collections.emptyList();
-
- if (entries.length == 1) {
- OrderEntry entry = entries[0];
- return entry.getOwnerModule() == ownerModule ? Arrays.asList(entries) : Collections.<OrderEntry>emptyList();
- }
- int index = Arrays.binarySearch(entries, createFakeOrderEntry(ownerModule), RootIndex.BY_OWNER_MODULE);
- if (index < 0) {
- return Collections.emptyList();
- }
- int firstIndex = index;
- while (firstIndex - 1 >= 0 && entries[firstIndex - 1].getOwnerModule() == ownerModule) {
- firstIndex--;
- }
- int lastIndex = index + 1;
- while (lastIndex < entries.length && entries[lastIndex].getOwnerModule() == ownerModule) {
- lastIndex++;
- }
-
- OrderEntry[] subArray = new OrderEntry[lastIndex - firstIndex];
- System.arraycopy(entries, firstIndex, subArray, 0, lastIndex - firstIndex);
-
- return Arrays.asList(subArray);
- }
}
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentRootPanel.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentRootPanel.java
index bc10302c9c43..71b9ebcd205d 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentRootPanel.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/ContentRootPanel.java
@@ -45,6 +45,7 @@ import org.jetbrains.jps.model.JpsElement;
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
import javax.swing.*;
+import javax.swing.border.EmptyBorder;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.*;
@@ -102,6 +103,7 @@ public abstract class ContentRootPanel extends JPanel {
public void initUI() {
myHeader = createHeader();
+ myHeader.setBorder(new EmptyBorder(0, 8, 0, 0));
this.add(myHeader, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 8, 0), 0, 0));
addFolderGroupComponents();
@@ -198,7 +200,7 @@ public abstract class ContentRootPanel extends JPanel {
final Font labelFont = UIUtil.getLabelFont();
titleLabel.setFont(labelFont.deriveFont(Font.BOLD));
titleLabel.setOpaque(false);
- titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
+ titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
registerTextComponent(titleLabel, foregroundColor);
final JPanel groupPanel = new JPanel(new BorderLayout());
diff --git a/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java b/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java
index e4889af6a591..bbffc7c98ba4 100644
--- a/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java
+++ b/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java
@@ -176,9 +176,6 @@ public class DownloadUtil {
URLConnection urlConnection = HttpConfigurable.getInstance().openConnection(location);
HttpURLConnection httpURLConnection = ObjectUtils.tryCast(urlConnection, HttpURLConnection.class);
try {
- int timeout = (int) TimeUnit.MINUTES.toMillis(2);
- urlConnection.setConnectTimeout(timeout);
- urlConnection.setReadTimeout(timeout);
urlConnection.connect();
InputStream in = urlConnection.getInputStream();
int contentLength = urlConnection.getContentLength();
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/ScopesOrderDialog.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/ScopesOrderDialog.java
index c69a3e5566a2..602de3c8dba5 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/ScopesOrderDialog.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/ScopesOrderDialog.java
@@ -64,7 +64,7 @@ public class ScopesOrderDialog extends DialogWrapper {
ListUtil.moveSelectedItemsUp(myOptionsList);
}
}).disableRemoveAction().disableAddAction().createPanel();
- final JLabel descr = new JLabel("<html><p>If file appears in two or more scopes, it will be" +
+ final JLabel descr = new JLabel("<html><p>If file appears in two or more scopes, it will be " +
"inspected with settings of the topmost scope in list above.</p><p/>" +
"<p>Scope order is set globally for all inspections in the profile.</p></html>");
descr.setPreferredSize(new Dimension(300, 100));
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java
index 2da5c80a758b..81d0bf651688 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java
@@ -16,7 +16,6 @@
package com.intellij.profile.codeInspection.ui;
-import com.intellij.CommonBundle;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
@@ -62,7 +61,6 @@ import com.intellij.profile.codeInspection.ui.table.ScopesAndSeveritiesTable;
import com.intellij.psi.search.scope.packageSet.NamedScope;
import com.intellij.ui.*;
import com.intellij.ui.components.JBLabel;
-import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.Alarm;
import com.intellij.util.Function;
import com.intellij.util.config.StorageAccessors;
@@ -85,8 +83,6 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
import java.io.IOException;
import java.io.StringReader;
import java.util.*;
@@ -811,7 +807,7 @@ public class SingleInspectionProfilePanel extends JPanel {
}
}
final JTable scopesAndScopesAndSeveritiesTable =
- new ScopesAndSeveritiesTable(new ScopesAndSeveritiesTable.TableSettings(nodes, mySelectedProfile, myTreeTable, project) {
+ new ScopesAndSeveritiesTable(new ScopesAndSeveritiesTable.TableSettings(nodes, mySelectedProfile, project) {
@Override
protected void onScopeChosen(@NotNull final ScopeToolState state) {
setConfigPanel(configPanelAnchor, state);
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java
index 92cb62f0f800..5607816ad13c 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java
@@ -64,8 +64,8 @@ public class InspectionsConfigTreeTable extends TreeTable {
final TableColumn isEnabledColumn = getColumnModel().getColumn(IS_ENABLED_COLUMN);
isEnabledColumn.setMaxWidth(20);
- isEnabledColumn.setCellRenderer(new ThreeStateCheckBoxRenderer(false));
- isEnabledColumn.setCellEditor(new ThreeStateCheckBoxRenderer(true));
+ isEnabledColumn.setCellRenderer(new ThreeStateCheckBoxRenderer());
+ isEnabledColumn.setCellEditor(new ThreeStateCheckBoxRenderer());
addMouseMotionListener(new MouseAdapter() {
@Override
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ScopesAndSeveritiesTable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ScopesAndSeveritiesTable.java
index 3b2c36bf7d34..385b764af027 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ScopesAndSeveritiesTable.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ScopesAndSeveritiesTable.java
@@ -20,11 +20,9 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.ex.Descriptor;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.codeInspection.ex.ScopeToolState;
-import com.intellij.icons.AllIcons;
import com.intellij.ide.DataManager;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopupFactory;
@@ -36,12 +34,12 @@ import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTr
import com.intellij.psi.search.scope.packageSet.NamedScope;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.table.JBTable;
-import com.intellij.ui.treeStructure.treetable.TreeTable;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.EditableModel;
+import com.intellij.util.ui.EmptyIcon;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -63,7 +61,7 @@ public class ScopesAndSeveritiesTable extends JBTable {
public static final HighlightSeverity MIXED_FAKE_SEVERITY = new HighlightSeverity("Mixed", -1);
@SuppressWarnings("UnusedDeclaration")
- public static final HighlightDisplayLevel MIXED_FAKE_LEVEL = new HighlightDisplayLevel(MIXED_FAKE_SEVERITY, AllIcons.Actions.Help);
+ public static final HighlightDisplayLevel MIXED_FAKE_LEVEL = new HighlightDisplayLevel(MIXED_FAKE_SEVERITY, EmptyIcon.create(12));
private final static int SCOPE_ENABLED_COLUMN = 0;
private final static int SCOPE_NAME_COLUMN = 1;
@@ -76,8 +74,8 @@ public class ScopesAndSeveritiesTable extends JBTable {
final TableColumn scopeEnabledColumn = columnModel.getColumn(SCOPE_ENABLED_COLUMN);
scopeEnabledColumn.setMaxWidth(30);
- scopeEnabledColumn.setCellRenderer(new ThreeStateCheckBoxRenderer(false));
- scopeEnabledColumn.setCellEditor(new ThreeStateCheckBoxRenderer(true));
+ scopeEnabledColumn.setCellRenderer(new ThreeStateCheckBoxRenderer());
+ scopeEnabledColumn.setCellEditor(new ThreeStateCheckBoxRenderer());
final TableColumn severityColumn = columnModel.getColumn(SEVERITY_COLUMN);
severityColumn.setCellRenderer(SeverityRenderer.create(tableSettings.getInspectionProfile()));
@@ -113,12 +111,10 @@ public class ScopesAndSeveritiesTable extends JBTable {
private final List<String> myKeyNames;
private final List<HighlightDisplayKey> myKeys;
private final InspectionProfileImpl myInspectionProfile;
- private final TreeTable myTreeTable;
private final Project myProject;
protected TableSettings(final List<InspectionConfigTreeNode> nodes,
final InspectionProfileImpl inspectionProfile,
- final TreeTable treeTable,
final Project project) {
myNodes = nodes;
myKeys = new ArrayList<HighlightDisplayKey>(myNodes.size());
@@ -130,7 +126,6 @@ public class ScopesAndSeveritiesTable extends JBTable {
}
myInspectionProfile = inspectionProfile;
- myTreeTable = treeTable;
myProject = project;
}
@@ -150,10 +145,6 @@ public class ScopesAndSeveritiesTable extends JBTable {
return myInspectionProfile;
}
- public TreeTable getTreeTable() {
- return myTreeTable;
- }
-
public Project getProject() {
return myProject;
}
@@ -186,8 +177,6 @@ public class ScopesAndSeveritiesTable extends JBTable {
private static class MyTableModel extends AbstractTableModel implements EditableModel {
private final InspectionProfileImpl myInspectionProfile;
private final List<String> myKeyNames;
- private final List<InspectionConfigTreeNode> myNodes;
- private final TreeTable myTreeTable;
private final Project myProject;
private final TableSettings myTableSettings;
private final List<HighlightDisplayKey> myKeys;
@@ -202,8 +191,6 @@ public class ScopesAndSeveritiesTable extends JBTable {
myInspectionProfile = tableSettings.getInspectionProfile();
myKeys = tableSettings.getKeys();
myKeyNames = tableSettings.getKeyNames();
- myNodes = tableSettings.getNodes();
- myTreeTable = tableSettings.getTreeTable();
myScopeComparator = new ScopeOrderComparator(myInspectionProfile);
refreshAggregatedScopes();
}
@@ -263,7 +250,7 @@ public class ScopesAndSeveritiesTable extends JBTable {
case SCOPE_ENABLED_COLUMN:
return isEnabled(rowIndex);
case SCOPE_NAME_COLUMN:
- return rowIndex == lastRowIndex() ? "Everywhere else" : getScope(rowIndex).getName();
+ return rowIndex == lastRowIndex() ? "Everywhere else" : getScopeName(rowIndex);
case SEVERITY_COLUMN:
return getSeverityState(rowIndex);
default:
@@ -275,13 +262,17 @@ public class ScopesAndSeveritiesTable extends JBTable {
return getScopeToolState(rowIndex).getExistedStates().get(0).getScope(myProject);
}
+ private String getScopeName(final int rowIndex) {
+ return getScopeToolState(rowIndex).getExistedStates().get(0).getScopeName();
+ }
+
@NotNull
private SeverityState getSeverityState(final int rowIndex) {
final ExistedScopesStatesAndNonExistNames existedScopesStatesAndNonExistNames = getScopeToolState(rowIndex);
if (!existedScopesStatesAndNonExistNames.getNonExistNames().isEmpty()) {
return new SeverityState(MIXED_FAKE_SEVERITY, false);
}
- return new SeverityState(ScopesAndSeveritiesTable.getSeverity(existedScopesStatesAndNonExistNames.getExistedStates()), true);
+ return new SeverityState(getSeverity(existedScopesStatesAndNonExistNames.getExistedStates()), true);
}
@Nullable
@@ -361,7 +352,7 @@ public class ScopesAndSeveritiesTable extends JBTable {
LOG.error("no display level found for name " + severityState.getSeverity().getName());
return;
}
- final String scopeName = rowIndex == lastRowIndex() ? null : getScope(rowIndex).getName();
+ final String scopeName = rowIndex == lastRowIndex() ? null : getScopeName(rowIndex);
myInspectionProfile.setErrorLevel(myKeys, level, scopeName, myProject);
}
else if (columnIndex == SCOPE_ENABLED_COLUMN) {
@@ -417,7 +408,6 @@ public class ScopesAndSeveritiesTable extends JBTable {
}
};
DataContext dataContext = DataManager.getInstance().getDataContext(myTable);
- final JComponent component = (JComponent)PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
final ListPopup popup = JBPopupFactory.getInstance()
.createActionGroupPopup(ScopesChooser.TITLE, scopesChooser.createPopupActionGroup(myTable), dataContext,
JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ThreeStateCheckBoxRenderer.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ThreeStateCheckBoxRenderer.java
index 455e2a60cd19..9e2a4ead10f1 100644
--- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ThreeStateCheckBoxRenderer.java
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/table/ThreeStateCheckBoxRenderer.java
@@ -27,6 +27,7 @@ import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.*;
+import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
@@ -37,7 +38,7 @@ public class ThreeStateCheckBoxRenderer extends ThreeStateCheckBox implements Ta
private final List<CellEditorListener> myListeners = new SmartList<CellEditorListener>();
- public ThreeStateCheckBoxRenderer(final boolean isEditor) {
+ public ThreeStateCheckBoxRenderer() {
setThirdStateEnabled(false);
setHorizontalAlignment(CENTER);
setVerticalAlignment(CENTER);
@@ -95,7 +96,7 @@ public class ThreeStateCheckBoxRenderer extends ThreeStateCheckBox implements Ta
@Override
public boolean stopCellEditing() {
final ChangeEvent e = new ChangeEvent(this);
- for (final CellEditorListener listener : myListeners) {
+ for (final CellEditorListener listener : new ArrayList<CellEditorListener>(myListeners)) {
listener.editingStopped(e);
}
return true;
@@ -104,7 +105,7 @@ public class ThreeStateCheckBoxRenderer extends ThreeStateCheckBox implements Ta
@Override
public void cancelCellEditing() {
final ChangeEvent e = new ChangeEvent(this);
- for (final CellEditorListener listener : myListeners) {
+ for (final CellEditorListener listener : new ArrayList<CellEditorListener>(myListeners)) {
listener.editingCanceled(e);
}
}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/DocumentCommitThread.java b/platform/lang-impl/src/com/intellij/psi/impl/DocumentCommitThread.java
index c8793c085a58..32a2e38384d9 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/DocumentCommitThread.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/DocumentCommitThread.java
@@ -18,8 +18,8 @@ package com.intellij.psi.impl;
import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
import com.intellij.ide.startup.impl.StartupManagerImpl;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ex.ApplicationManagerEx;
+import com.intellij.openapi.application.ApplicationAdapter;
+import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
@@ -54,17 +54,44 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
private final Queue<CommitTask> documentsToCommit = new Queue<CommitTask>(10);
private final List<CommitTask> documentsToApplyInEDT = new ArrayList<CommitTask>(10); // guarded by documentsToCommit
+ private final ApplicationEx myApplication;
private volatile boolean isDisposed;
private CommitTask currentTask; // guarded by documentsToCommit
private volatile boolean threadFinished;
- private volatile boolean myEnabled = true; // true if we can do commits. set to false temporarily during the write action.
+ private volatile boolean myEnabled; // true if we can do commits. set to false temporarily during the write action.
public static DocumentCommitThread getInstance() {
return ServiceManager.getService(DocumentCommitThread.class);
}
- public DocumentCommitThread() {
- log("Starting thread",null, false);
+ public DocumentCommitThread(final ApplicationEx application) {
+ myApplication = application;
+ // install listener in EDT to avoid missing events in case we are inside write action right now
+ application.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ application.addApplicationListener(new ApplicationAdapter() {
+ private int runningWriteActions;
+
+ @Override
+ public void beforeWriteActionStart(Object action) {
+ if (runningWriteActions++ == 0) {
+ disable("Write action started: " + action);
+ }
+ }
+
+ @Override
+ public void writeActionFinished(Object action) {
+ if (--runningWriteActions == 0) {
+ enable("Write action finished: " + action);
+ }
+ }
+ }, DocumentCommitThread.this);
+
+ enable("Listener installed, started");
+ }
+ });
+ log("Starting thread", null, false);
new Thread(this, "Document commit thread").start();
}
@@ -88,14 +115,14 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
}
}
- public void disable(@NonNls Object reason) {
+ private void disable(@NonNls Object reason) {
// write action has just started, all commits are useless
cancel(reason);
myEnabled = false;
log("Disabled", null, false, reason);
}
- public void enable(Object reason) {
+ private void enable(@NonNls Object reason) {
myEnabled = true;
wakeUpQueue();
log("Enabled", null, false, reason);
@@ -107,7 +134,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
}
}
- private void cancel(@NonNls Object reason) {
+ private void cancel(@NonNls @NotNull Object reason) {
startNewTask(null, reason);
}
@@ -126,7 +153,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
doQueue(project, document, reason);
}
- private void doQueue(Project project, Document document, Object reason) {
+ private void doQueue(@NotNull Project project, @NotNull Document document, @NotNull Object reason) {
synchronized (documentsToCommit) {
ProgressIndicator indicator = new DaemonProgressIndicator();
CommitTask newTask = new CommitTask(document, project, indicator, reason);
@@ -193,7 +220,6 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
public void clearQueue() {
cancelAll();
log.setLength(0);
- disable("end of test");
wakeUpQueue();
}
@@ -303,9 +329,9 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
}
if (success) {
- assert !ApplicationManager.getApplication().isDispatchThread();
+ assert !myApplication.isDispatchThread();
UIUtil.invokeLaterIfNeeded(finishRunnable);
- log("Invoked later finishRunnable", task, false, success, finishRunnable, indicator);
+ log("Invoked later finishRunnable", task, false, finishRunnable, indicator);
}
}
catch (ProcessCanceledException e) {
@@ -334,7 +360,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
@Override
public void commitSynchronously(@NotNull Document document, @NotNull Project project) {
assert !isDisposed;
- ApplicationManager.getApplication().assertWriteAccessAllowed();
+ myApplication.assertWriteAccessAllowed();
if (!project.isInitialized() && !project.isDefault()) {
@NonNls String s = project + "; Disposed: "+project.isDisposed()+"; Open: "+project.isOpen();
@@ -380,7 +406,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
return new ProgressIndicatorBase();
}
- private void startNewTask(CommitTask task, Object reason) {
+ private void startNewTask(@Nullable CommitTask task, @NotNull Object reason) {
synchronized (documentsToCommit) { // sync to prevent overwriting
CommitTask cur = currentTask;
if (cur != null) {
@@ -388,19 +414,19 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
}
currentTask = task;
}
+ log("new task started", task, false, reason);
}
// returns finish commit Runnable (to be invoked later in EDT), or null on failure
@Nullable
- private Runnable commitUnderProgress(@NotNull final CommitTask task,
- final boolean synchronously) {
+ private Runnable commitUnderProgress(@NotNull final CommitTask task, final boolean synchronously) {
final Project project = task.project;
final Document document = task.document;
final List<Processor<Document>> finishProcessors = new SmartList<Processor<Document>>();
Runnable runnable = new Runnable() {
@Override
public void run() {
- ApplicationManager.getApplication().assertReadAccessAllowed();
+ myApplication.assertReadAccessAllowed();
if (project.isDisposed()) return;
final PsiDocumentManagerImpl documentManager = (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(project);
@@ -424,14 +450,12 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
}
};
if (synchronously) {
- ApplicationManager.getApplication().assertWriteAccessAllowed();
+ myApplication.assertWriteAccessAllowed();
runnable.run();
}
- else {
- if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(runnable)) {
- log("Could not start read action", task, synchronously, ApplicationManager.getApplication().isReadAccessAllowed(), Thread.currentThread());
- return null;
- }
+ else if (!myApplication.tryRunReadAction(runnable)) {
+ log("Could not start read action", task, synchronously, myApplication.isReadAccessAllowed(), Thread.currentThread());
+ return null;
}
boolean canceled = task.indicator.isCanceled();
@@ -443,7 +467,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
Runnable finishRunnable = new Runnable() {
@Override
public void run() {
- ApplicationManager.getApplication().assertIsDispatchThread();
+ myApplication.assertIsDispatchThread();
Project project = task.project;
if (project.isDisposed()) return;
@@ -525,4 +549,27 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
}
return result[0];
}
+
+ @TestOnly
+ boolean isEnabled() {
+ return myEnabled;
+ }
+
+ @TestOnly
+ public void waitUntilAllCommitted(long timeout) throws InterruptedException {
+ if (!myEnabled) {
+ throw new IllegalStateException("DocumentCommitThread is disabled");
+ }
+ int attempts = 0;
+ int delay = 100;
+ synchronized (documentsToCommit) {
+ while(!documentsToCommit.isEmpty() || currentTask != null) {
+ documentsToCommit.wait(delay);
+ if (delay * attempts > timeout) {
+ throw new RuntimeException("timeout");
+ }
+ attempts++;
+ }
+ }
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java
index 63b8a6af86e1..16926b18b834 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java
@@ -19,7 +19,6 @@ package com.intellij.psi.impl;
import com.intellij.AppTopics;
import com.intellij.injected.editor.DocumentWindow;
import com.intellij.injected.editor.EditorWindowImpl;
-import com.intellij.openapi.application.ApplicationAdapter;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.SettingsSavingComponent;
import com.intellij.openapi.editor.Document;
@@ -33,7 +32,10 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectLocator;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.*;
+import com.intellij.psi.FileViewProvider;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiManager;
+import com.intellij.psi.SmartPointerManager;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
import com.intellij.util.FileContentUtil;
import com.intellij.util.Processor;
@@ -79,18 +81,6 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase implements Se
documentCommitThread.queueCommit(project, doc, "Bulk update finished");
}
});
- ApplicationManager.getApplication().addApplicationListener(new ApplicationAdapter() {
- @Override
- public void beforeWriteActionStart(Object action) {
- documentCommitThread.disable("Write action started: " + action);
- }
-
- @Override
- public void writeActionFinished(Object action) {
- documentCommitThread.enable("Write action finished: " + action);
- }
- }, project);
- documentCommitThread.enable("project open");
}
@Nullable
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
index fa1dd9e86b4a..c7b9bf3a3adf 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java
@@ -391,14 +391,15 @@ public class CodeFormatterFacade {
/**
- * Inspects all lines of the given document and wraps all of them that exceed {@link CodeStyleSettings#RIGHT_MARGIN right margin}.
+ * Inspects all lines of the given document and wraps all of them that exceed {@link CodeStyleSettings#getRightMargin(com.intellij.lang.Language)}
+ * right margin}.
* <p/>
* I.e. the algorithm is to do the following for every line:
* <p/>
* <pre>
* <ol>
* <li>
- * Check if the line exceeds {@link CodeStyleSettings#RIGHT_MARGIN right margin}. Go to the next line in the case of
+ * Check if the line exceeds {@link CodeStyleSettings#getRightMargin(com.intellij.lang.Language)} right margin}. Go to the next line in the case of
* negative answer;
* </li>
* <li>Determine line wrap position; </li>
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java
index 767152fc1e2b..d51ef1216a59 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java
@@ -181,7 +181,7 @@ public class CodeStyleManagerImpl extends CodeStyleManager {
transformAllChildren(treeElement);
final CodeFormatterFacade codeFormatter = new CodeFormatterFacade(getSettings(), file.getLanguage());
- LOG.assertTrue(file.isValid());
+ LOG.assertTrue(file.isValid(), "File name: " + file.getName() + " , class: " + file.getClass().getSimpleName());
if (editor == null) {
editor = PsiUtilBase.findEditor(file);
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedFileViewProvider.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedFileViewProvider.java
index f4a6d576e6b8..58a9463b755d 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedFileViewProvider.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedFileViewProvider.java
@@ -61,7 +61,7 @@ public class InjectedFileViewProvider extends SingleRootFileViewProvider impleme
@NotNull Language language) {
super(psiManager, (VirtualFile)virtualFile, true, language);
myDocumentWindow = documentWindow;
- myProject = documentWindow.getShreds().get(0).getHost().getProject();
+ myProject = documentWindow.getShreds().getHostPointer().getProject();
}
@Override
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
index fdc434d8d11a..647ace567d5d 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageUtil.java
@@ -24,7 +24,6 @@ import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.editor.impl.EditorImpl;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
@@ -38,6 +37,7 @@ import com.intellij.psi.impl.PsiParameterizedCachedValue;
import com.intellij.psi.impl.source.DummyHolder;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.*;
+import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.containers.ConcurrentList;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -93,7 +93,12 @@ public class InjectedLanguageUtil {
public static Place getShreds(@NotNull FileViewProvider viewProvider) {
if (!(viewProvider instanceof InjectedFileViewProvider)) return null;
InjectedFileViewProvider myFileViewProvider = (InjectedFileViewProvider)viewProvider;
- return ((DocumentWindowImpl)myFileViewProvider.getDocument()).getShreds();
+ return getShreds(myFileViewProvider.getDocument());
+ }
+
+ @NotNull
+ public static Place getShreds(@NotNull DocumentWindow document) {
+ return ((DocumentWindowImpl)document).getShreds();
}
public static void enumerate(@NotNull DocumentWindow documentWindow,
@@ -162,6 +167,13 @@ public class InjectedLanguageUtil {
return getEditorForInjectedLanguageNoCommit(editor, file, offset);
}
+ public static Editor getEditorForInjectedLanguageNoCommit(@Nullable Editor editor, @Nullable Caret caret, @Nullable PsiFile file) {
+ if (editor == null || file == null || editor instanceof EditorWindow || caret == null) return editor;
+
+ PsiFile injectedFile = findInjectedPsiNoCommit(file, caret.getOffset());
+ return getInjectedEditorForInjectedFile(editor, caret, injectedFile);
+ }
+
public static Caret getCaretForInjectedLanguageNoCommit(@Nullable Caret caret, @Nullable PsiFile file) {
if (caret == null || file == null || caret instanceof InjectedCaret) return caret;
@@ -212,17 +224,21 @@ public class InjectedLanguageUtil {
@NotNull
public static Editor getInjectedEditorForInjectedFile(@NotNull Editor hostEditor, @Nullable final PsiFile injectedFile) {
+ return getInjectedEditorForInjectedFile(hostEditor, hostEditor.getCaretModel().getCurrentCaret(), injectedFile);
+ }
+
+ @NotNull
+ public static Editor getInjectedEditorForInjectedFile(@NotNull Editor hostEditor, @NotNull Caret hostCaret, @Nullable final PsiFile injectedFile) {
if (injectedFile == null || hostEditor instanceof EditorWindow || hostEditor.isDisposed()) return hostEditor;
Project project = hostEditor.getProject();
if (project == null) project = injectedFile.getProject();
Document document = PsiDocumentManager.getInstance(project).getDocument(injectedFile);
if (!(document instanceof DocumentWindowImpl)) return hostEditor;
DocumentWindowImpl documentWindow = (DocumentWindowImpl)document;
- SelectionModel selectionModel = hostEditor.getSelectionModel();
- if (selectionModel.hasSelection()) {
- int selstart = selectionModel.getSelectionStart();
+ if (hostCaret.hasSelection()) {
+ int selstart = hostCaret.getSelectionStart();
if (selstart != -1) {
- int selend = Math.max(selstart, selectionModel.getSelectionEnd());
+ int selend = Math.max(selstart, hostCaret.getSelectionEnd());
if (!documentWindow.containsRange(selstart, selend)) {
// selection spreads out the injected editor range
return hostEditor;
@@ -573,4 +589,29 @@ public class InjectedLanguageUtil {
});
return ref.get();
}
+
+ @Nullable
+ public static PsiLanguageInjectionHost findInjectionHost(@Nullable PsiElement psi) {
+ if (psi == null) return null;
+ PsiFile containingFile = psi.getContainingFile().getOriginalFile(); // * formatting
+ PsiElement fileContext = containingFile.getContext(); // * quick-edit-handler
+ if (fileContext instanceof PsiLanguageInjectionHost) return (PsiLanguageInjectionHost)fileContext;
+ Place shreds = getShreds(containingFile.getViewProvider()); // * injection-registrar
+ if (shreds == null) {
+ VirtualFile virtualFile = PsiUtilCore.getVirtualFile(containingFile);
+ if (virtualFile instanceof LightVirtualFile) {
+ virtualFile = ((LightVirtualFile)virtualFile).getOriginalFile(); // * dynamic files-from-text
+ }
+ if (virtualFile instanceof VirtualFileWindow) {
+ shreds = getShreds(((VirtualFileWindow)virtualFile).getDocumentWindow());
+ }
+ }
+ return shreds != null ? shreds.getHostPointer().getElement() : null;
+ }
+
+ @Nullable
+ public static PsiLanguageInjectionHost findInjectionHost(@Nullable VirtualFile virtualFile) {
+ return virtualFile instanceof VirtualFileWindow ?
+ getShreds(((VirtualFileWindow)virtualFile).getDocumentWindow()).getHostPointer().getElement() : null;
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java
index 183af7374072..e520eea741be 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/MultiHostRegistrarImpl.java
@@ -389,7 +389,7 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar, ModificationT
"\nLeaf texts concatenated:'"+ patcher.catLeafs +"';" +
"\nFile root: "+parsedNode+
"\nLanguage: "+parsedNode.getPsi().getLanguage()+
- "\nHost file: "+ shreds.get(0).getHost().getContainingFile().getVirtualFile()
+ "\nHost file: "+ shreds.getHostPointer().getVirtualFile()
;
DebugUtil.startPsiModification("injection leaf patching");
try {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/Place.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/Place.java
index afaf499b9bb9..f6be385077c2 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/Place.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/Place.java
@@ -17,6 +17,7 @@
package com.intellij.psi.impl.source.tree.injected;
import com.intellij.psi.PsiLanguageInjectionHost;
+import com.intellij.psi.SmartPsiElementPointer;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
@@ -30,6 +31,11 @@ public class Place extends SmartList<PsiLanguageInjectionHost.Shred> {
super(shreds);
}
+ @NotNull
+ public SmartPsiElementPointer<PsiLanguageInjectionHost> getHostPointer() {
+ return ((ShredImpl)get(0)).getSmartPointer();
+ }
+
public boolean isValid() {
for (PsiLanguageInjectionHost.Shred shred : this) {
if (!shred.isValid()) {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java
index aea41ab16f72..5c60a1c2254f 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/ShredImpl.java
@@ -45,6 +45,7 @@ class ShredImpl implements PsiLanguageInjectionHost.Shred {
assert relevantRangeInHost.isValid();
}
+ @NotNull
public SmartPsiElementPointer<PsiLanguageInjectionHost> getSmartPointer() {
return hostElementPointer;
}
diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java
index d791f14aa841..493d1d6cd519 100644
--- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java
+++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java
@@ -302,7 +302,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
return true;
}
- private static void forceRebuild(@NotNull Throwable e) {
+ public void forceRebuild(@NotNull Throwable e) {
LOG.info(e);
FileBasedIndex.getInstance().scheduleRebuild(StubUpdatingIndex.INDEX_ID, e);
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MethodNodeBase.java b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MethodNodeBase.java
index 36e5352e0f8e..782ff452fbf4 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MethodNodeBase.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MethodNodeBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.refactoring.changeSignature;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Iconable;
@@ -88,7 +89,12 @@ public abstract class MethodNodeBase<M extends PsiElement> extends CheckedTreeNo
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
- callers.set(computeCallers());
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ callers.set(computeCallers());
+ }
+ });
}
}, RefactoringBundle.message("caller.chooser.looking.for.callers"), true, myProject)) {
myCancelCallback.run();
diff --git a/platform/lang-impl/src/com/intellij/refactoring/inline/GenericInlineHandler.java b/platform/lang-impl/src/com/intellij/refactoring/inline/GenericInlineHandler.java
index dd5d9a42ed91..cbeefc786612 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/inline/GenericInlineHandler.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/inline/GenericInlineHandler.java
@@ -184,7 +184,7 @@ public class GenericInlineHandler {
}
}
else {
- conflicts.putValue(referenceElement, "Cannot inline reference from " + language.getID());
+ conflicts.putValue(referenceElement, "Cannot inline reference from " + language.getDisplayName());
}
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java
index 7e8ec09f3e23..a34d30dc5401 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java
@@ -320,11 +320,7 @@ public class RenameProcessor extends BaseRefactoringProcessor {
protected boolean isPreviewUsages(UsageInfo[] usages) {
if (myForceShowPreview) return true;
if (super.isPreviewUsages(usages)) return true;
- if (UsageViewUtil.hasNonCodeUsages(usages)) {
- WindowManager.getInstance().getStatusBar(myProject)
- .setInfo(RefactoringBundle.message("occurrences.found.in.comments.strings.and.non.java.files"));
- return true;
- }
+ if (UsageViewUtil.reportNonRegularUsages(usages, myProject)) return true;
return false;
}
diff --git a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java
index e6acbaa4adda..b8f069d5f142 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/safeDelete/SafeDeleteProcessor.java
@@ -26,7 +26,6 @@ import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Ref;
-import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
@@ -40,7 +39,9 @@ import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteCustomUsageInfo;
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDeleteUsageInfo;
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceUsageInfo;
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteUsageInfo;
-import com.intellij.refactoring.util.*;
+import com.intellij.refactoring.util.NonCodeSearchDescriptionLocation;
+import com.intellij.refactoring.util.RefactoringUIUtil;
+import com.intellij.refactoring.util.TextOccurrencesUtil;
import com.intellij.usageView.UsageInfo;
import com.intellij.usageView.UsageViewDescriptor;
import com.intellij.usageView.UsageViewUtil;
@@ -352,8 +353,7 @@ public class SafeDeleteProcessor extends BaseRefactoringProcessor {
@Override
protected boolean isPreviewUsages(UsageInfo[] usages) {
- if(myPreviewNonCodeUsages && (UsageViewUtil.hasNonCodeUsages(usages) || UsageViewUtil.hasUsagesInGeneratedCode(usages, myProject))) {
- WindowManager.getInstance().getStatusBar(myProject).setInfo(RefactoringBundle.message("occurrences.found.in.comments.strings.non.java.files.and.generated.code"));
+ if(myPreviewNonCodeUsages && UsageViewUtil.reportNonRegularUsages(usages, myProject)) {
return true;
}
diff --git a/platform/lang-impl/src/com/intellij/tools/BaseToolManager.java b/platform/lang-impl/src/com/intellij/tools/BaseToolManager.java
index c848939cf398..478f60eed51a 100644
--- a/platform/lang-impl/src/com/intellij/tools/BaseToolManager.java
+++ b/platform/lang-impl/src/com/intellij/tools/BaseToolManager.java
@@ -1,6 +1,6 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -33,10 +33,10 @@ import java.util.List;
public abstract class BaseToolManager<T extends Tool> implements ExportableApplicationComponent {
- private final ActionManagerEx myActionManager;
+ @NotNull private final ActionManagerEx myActionManager;
private final SchemesManager<ToolsGroup<T>, ToolsGroup<T>> mySchemesManager;
- public BaseToolManager(ActionManagerEx actionManagerEx, SchemesManagerFactory factory) {
+ public BaseToolManager(@NotNull ActionManagerEx actionManagerEx, SchemesManagerFactory factory) {
myActionManager = actionManagerEx;
mySchemesManager = factory.createSchemesManager(
diff --git a/platform/lang-impl/src/com/intellij/tools/ScanSourceCommentsAction.java b/platform/lang-impl/src/com/intellij/tools/ScanSourceCommentsAction.java
index be3fa32182de..53d15d581927 100644
--- a/platform/lang-impl/src/com/intellij/tools/ScanSourceCommentsAction.java
+++ b/platform/lang-impl/src/com/intellij/tools/ScanSourceCommentsAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -22,7 +22,7 @@ package com.intellij.tools;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -107,19 +107,24 @@ public class ScanSourceCommentsAction extends AnAction {
descriptor.addFile(file);
}
- private void scanCommentsInFile(Project project, final VirtualFile vFile) {
+ private void scanCommentsInFile(final Project project, final VirtualFile vFile) {
if (!vFile.isDirectory() && vFile.getFileType() instanceof LanguageFileType) {
- PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
- if (psiFile == null) return;
-
- for (PsiFile root : psiFile.getViewProvider().getAllFiles()) {
- root.accept(new PsiRecursiveElementWalkingVisitor() {
- @Override
- public void visitComment(PsiComment comment) {
- commentFound(vFile, comment.getText());
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
+ if (psiFile == null) return;
+
+ for (PsiFile root : psiFile.getViewProvider().getAllFiles()) {
+ root.accept(new PsiRecursiveElementWalkingVisitor() {
+ @Override
+ public void visitComment(PsiComment comment) {
+ commentFound(vFile, comment.getText());
+ }
+ });
}
- });
- }
+ }
+ });
}
}
diff --git a/platform/lang-impl/src/com/intellij/tools/Tool.java b/platform/lang-impl/src/com/intellij/tools/Tool.java
index 760fb5901e65..8077bf530e37 100644
--- a/platform/lang-impl/src/com/intellij/tools/Tool.java
+++ b/platform/lang-impl/src/com/intellij/tools/Tool.java
@@ -17,7 +17,6 @@
package com.intellij.tools;
import com.intellij.execution.ExecutionException;
-import com.intellij.execution.RunnerRegistry;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.PathEnvironmentVariableUtil;
import com.intellij.execution.executors.DefaultRunExecutor;
@@ -274,15 +273,11 @@ public class Tool implements SchemeElement {
FileDocumentManager.getInstance().saveAllDocuments();
try {
if (isUseConsole()) {
- final ToolRunProfile profile = new ToolRunProfile(this, dataContext);
- final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(DefaultRunExecutor.EXECUTOR_ID, profile);
- assert runner != null;
-
- ExecutionEnvironment executionEnvironment = new ExecutionEnvironmentBuilder(project, DefaultRunExecutor.getRunExecutorInstance())
- .setRunProfile(profile)
- .build();
- executionEnvironment.setExecutionId(executionId);
- runner.execute(executionEnvironment, new ProgramRunner.Callback() {
+ ExecutionEnvironment environment = ExecutionEnvironmentBuilder.create(project,
+ DefaultRunExecutor.getRunExecutorInstance(),
+ new ToolRunProfile(this, dataContext)).build();
+ environment.setExecutionId(executionId);
+ environment.getRunner().execute(environment, new ProgramRunner.Callback() {
@Override
public void processStarted(RunContentDescriptor descriptor) {
ProcessHandler processHandler = descriptor.getProcessHandler();
diff --git a/platform/lang-impl/src/com/intellij/ui/DuplicateNodeRenderer.java b/platform/lang-impl/src/com/intellij/ui/DuplicateNodeRenderer.java
index 3083ffed6de9..663dccce5ed8 100644
--- a/platform/lang-impl/src/com/intellij/ui/DuplicateNodeRenderer.java
+++ b/platform/lang-impl/src/com/intellij/ui/DuplicateNodeRenderer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.util.Enumeration;
@@ -84,9 +85,9 @@ public class DuplicateNodeRenderer {
private static Rectangle getExpandedNodesRect(JTree tree, DefaultMutableTreeNode node, TreePath path) {
Rectangle rect = tree.getRowBounds(tree.getRowForPath(path));
if (tree.isExpanded(path)) {
- Enumeration<DefaultMutableTreeNode> children = node.children();
+ Enumeration<TreeNode> children = node.children();
while (children.hasMoreElements()) {
- DefaultMutableTreeNode child = children.nextElement();
+ DefaultMutableTreeNode child = (DefaultMutableTreeNode)children.nextElement();
TreePath childPath = path.pathByAddingChild(child);
assert !path.equals(childPath) : path+";"+child;
rect = union(rect, getExpandedNodesRect(tree, child, childPath));
diff --git a/platform/lang-impl/src/com/intellij/ui/popup/PopupPositionManager.java b/platform/lang-impl/src/com/intellij/ui/popup/PopupPositionManager.java
index ea9a263d5713..81d09d7886f8 100644
--- a/platform/lang-impl/src/com/intellij/ui/popup/PopupPositionManager.java
+++ b/platform/lang-impl/src/com/intellij/ui/popup/PopupPositionManager.java
@@ -53,7 +53,7 @@ public class PopupPositionManager {
@Nullable final Editor editor,
@Nullable DataContext dataContext) {
final LookupEx lookup = LookupManager.getActiveLookup(editor);
- if (lookup != null && lookup.getCurrentItem() != null) {
+ if (lookup != null && lookup.getCurrentItem() != null && lookup.getComponent().isShowing()) {
new PositionAdjuster(lookup.getComponent()).adjust(hint);
lookup.addLookupListener(new LookupAdapter() {
@Override
diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java b/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java
index a7721a8b826f..bfa1e14ec88e 100644
--- a/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java
+++ b/platform/lang-impl/src/com/intellij/ui/tabs/ColorSelectionComponent.java
@@ -96,24 +96,24 @@ public class ColorSelectionComponent extends JPanel {
}
@Nullable
- private ColorButton getSelectedButtonInner() {
+ public String getSelectedColorName() {
for (String name : myColorToButtonMap.keySet()) {
ColorButton button = myColorToButtonMap.get(name);
- if (button.isSelected()) return button;
+ if (!button.isSelected()) continue;
+ if (button instanceof CustomColorButton) return ColorUtil.toHex(button.getColor());
+ return name;
}
return null;
}
@Nullable
- public String getSelectedColorName() {
- ColorButton button = getSelectedButtonInner();
- return button == null? null : button instanceof CustomColorButton ? ColorUtil.toHex(button.getColor()) : button.getText();
- }
-
- @Nullable
public Color getSelectedColor() {
- ColorButton button = getSelectedButtonInner();
- return button == null? null : button.getColor();
+ for (String name : myColorToButtonMap.keySet()) {
+ ColorButton button = myColorToButtonMap.get(name);
+ if (!button.isSelected()) continue;
+ return button.getColor();
+ }
+ return null;
}
public void initDefault(@NotNull FileColorManager manager, @Nullable String selectedColorName) {
diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java
index a60889bb9f93..c65af1ecdb4f 100644
--- a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java
@@ -18,24 +18,25 @@ package com.intellij.ui.tabs;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.components.*;
-import com.intellij.openapi.components.StoragePathMacros;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiManager;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.FileColorManager;
+import com.intellij.ui.JBColor;
import com.intellij.ui.LightColors;
-import com.intellij.util.containers.hash.LinkedHashMap;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
/**
* @author spleaner
@@ -52,25 +53,14 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent
private final FileColorsModel myModel;
private FileColorSharedConfigurationManager mySharedConfigurationManager;
- private static final Map<String, Color> ourDefaultColors;
- private static final Map<String, Color> ourDefaultDarkColors;
-
- static {
- ourDefaultColors = new LinkedHashMap<String, Color>();
- ourDefaultColors.put("Blue", new Color(0xdcf0ff));
- ourDefaultColors.put("Green", new Color(231, 250, 219));
- ourDefaultColors.put("Orange", new Color(246, 224, 202));
- ourDefaultColors.put("Rose", new Color(242, 206, 202));
- ourDefaultColors.put("Violet", new Color(222, 213, 241));
- ourDefaultColors.put("Yellow", new Color(255, 255, 228));
- ourDefaultDarkColors = new LinkedHashMap<String, Color>();
- ourDefaultDarkColors.put("Blue", new Color(0x2B3557));
- ourDefaultDarkColors.put("Green", new Color(0x2A3B2C));
- ourDefaultDarkColors.put("Orange", new Color(0x823B1C));
- ourDefaultDarkColors.put("Rose", new Color(0x542F3A));
- ourDefaultDarkColors.put("Violet", new Color(0x4f4056));
- ourDefaultDarkColors.put("Yellow", new Color(0x494539));
- }
+ private static final Map<String, Color> ourDefaultColors = ContainerUtil.<String, Color>immutableMapBuilder()
+ .put("Blue", new JBColor(new Color(0xdcf0ff), new Color(0x2B3557)))
+ .put("Green", new JBColor(new Color(231, 250, 219), new Color(0x2A3B2C)))
+ .put("Orange", new JBColor(new Color(246, 224, 202), new Color(0x823B1C)))
+ .put("Rose", new JBColor(new Color(242, 206, 202), new Color(0x542F3A)))
+ .put("Violet", new JBColor(new Color(222, 213, 241), new Color(0x4f4056)))
+ .put("Yellow", new JBColor(new Color(255, 255, 228), new Color(0x494539)))
+ .build();
public FileColorManagerImpl(@NotNull final Project project) {
myProject = project;
@@ -133,7 +123,7 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent
@SuppressWarnings({"MethodMayBeStatic"})
@Nullable
public Color getColor(@NotNull final String name) {
- final Color color = UIUtil.isUnderDarcula() ? ourDefaultDarkColors.get(name) : ourDefaultColors.get(name);
+ Color color = ourDefaultColors.get(name);
return color == null ? ColorUtil.fromHex(name, null) : color;
}
@@ -151,8 +141,7 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent
@Override
@SuppressWarnings({"MethodMayBeStatic"})
public Collection<String> getColorNames() {
- final Set<String> names = ourDefaultColors.keySet();
- final List<String> sorted = new ArrayList<String>(names);
+ List<String> sorted = ContainerUtil.newArrayList(ourDefaultColors.keySet());
Collections.sort(sorted);
return sorted;
}
diff --git a/platform/lang-impl/src/com/intellij/usageView/UsageViewUtil.java b/platform/lang-impl/src/com/intellij/usageView/UsageViewUtil.java
index ca230c790e65..4dee56707ae0 100644
--- a/platform/lang-impl/src/com/intellij/usageView/UsageViewUtil.java
+++ b/platform/lang-impl/src/com/intellij/usageView/UsageViewUtil.java
@@ -24,10 +24,13 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.GeneratedSourcesFilter;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.wm.StatusBar;
+import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.ElementDescriptionUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
+import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.util.MoveRenameUsageInfo;
import com.intellij.refactoring.util.NonCodeUsageInfo;
import com.intellij.usages.Usage;
@@ -179,4 +182,17 @@ public class UsageViewUtil {
}
return usageInfos;
}
+
+ public static boolean reportNonRegularUsages(UsageInfo[] usages, final Project project) {
+ boolean inGeneratedCode = hasUsagesInGeneratedCode(usages, project);
+ if (hasNonCodeUsages(usages) || inGeneratedCode) {
+ StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
+ if (statusBar != null) {
+ statusBar.setInfo(inGeneratedCode ? RefactoringBundle.message("occurrences.found.in.comments.strings.non.java.files.and.generated.code")
+ : RefactoringBundle.message("occurrences.found.in.comments.strings.and.non.java.files"));
+ }
+ return true;
+ }
+ return false;
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
index 85077380ea6e..da85132806e5 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
@@ -531,7 +531,8 @@ public class FileBasedIndexImpl extends FileBasedIndex {
extension.hasSnapshotMapping() && IdIndex.ourSnapshotMappingsEnabled
? createInputsIndexExternalizer(extension, indexId, extension.getKeyDescriptor())
: null;
- index = new MapReduceIndex<K, V, FileContent>(indexId, extension.getIndexer(), storage, externalizer, extension.getValueExternalizer());
+ index = new MapReduceIndex<K, V, FileContent>(
+ indexId, extension.getIndexer(), storage, externalizer, extension.getValueExternalizer(), extension instanceof PsiDependentIndex);
}
index.setInputIdToDataKeysIndex(new Factory<PersistentHashMap<Integer, Collection<K>>>() {
@Override
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
index 6427765295c5..0060cb2fb159 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
@@ -17,10 +17,14 @@
package com.intellij.util.indexing;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
import com.intellij.openapi.util.io.ByteSequence;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.*;
import com.intellij.util.io.*;
@@ -50,6 +54,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
private final DataExternalizer<Value> myValueExternalizer;
private final DataExternalizer<Collection<Key>> mySnapshotIndexExternalizer;
+ private final boolean myIsPsiBackedIndex;
private PersistentHashMap<Integer, Collection<Key>> myInputsIndex;
private PersistentHashMap<Integer, ByteSequence> myContents;
@@ -75,14 +80,16 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
public MapReduceIndex(@Nullable final ID<Key, Value> indexId,
DataIndexer<Key, Value, Input> indexer,
@NotNull IndexStorage<Key, Value> storage) throws IOException {
- this(indexId, indexer, storage, null, null);
+ this(indexId, indexer, storage, null, null, false);
}
public MapReduceIndex(@Nullable final ID<Key, Value> indexId,
DataIndexer<Key, Value, Input> indexer,
@NotNull IndexStorage<Key, Value> storage,
DataExternalizer<Collection<Key>> snapshotIndexExternalizer,
- DataExternalizer<Value> valueDataExternalizer) throws IOException {
+ DataExternalizer<Value> valueDataExternalizer,
+ boolean psiBasedIndex
+ ) throws IOException {
myIndexId = indexId;
myIndexer = indexer;
myStorage = storage;
@@ -91,6 +98,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
mySnapshotIndexExternalizer = snapshotIndexExternalizer;
myValueExternalizer = valueDataExternalizer;
myContents = createContentsIndex();
+ myIsPsiBackedIndex = psiBasedIndex;
}
private PersistentHashMap<Integer, ByteSequence> createContentsIndex() throws IOException {
@@ -557,7 +565,34 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
return result;
}
- private static Integer getHashOfContent(FileContent content) throws IOException {
+ private Integer getHashOfContent(FileContent content) throws IOException {
+ if (myIsPsiBackedIndex && myHasSnapshotMapping && content instanceof FileContentImpl) {
+ // psi backed index should use existing psi to build index value (FileContentImpl.getPsiFileAccountingForUnsavedDocument())
+ // so we should use different bytes to calculate hash(Id)
+ Integer previouslyCalculatedUncommittedHashId = content.getUserData(ourSavedUncommittedHashIdKey);
+
+ if (previouslyCalculatedUncommittedHashId == null) {
+ Document document = FileDocumentManager.getInstance().getCachedDocument(content.getFile());
+
+ if (document != null) { // if document is not committed
+ PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(content.getProject());
+
+ if (psiDocumentManager.isUncommited(document)) {
+ PsiFile file = psiDocumentManager.getCachedPsiFile(document);
+ Charset charset = ((FileContentImpl)content).getCharset();
+
+ if (file != null) {
+ previouslyCalculatedUncommittedHashId = ContentHashesSupport
+ .calcContentHashIdWithFileType(file.getText().getBytes(charset), charset,
+ content.getFileType());
+ content.putUserData(ourSavedUncommittedHashIdKey, previouslyCalculatedUncommittedHashId);
+ }
+ }
+ }
+ }
+ if (previouslyCalculatedUncommittedHashId != null) return previouslyCalculatedUncommittedHashId;
+ }
+
Integer previouslyCalculatedContentHashId = content.getUserData(ourSavedContentHashIdKey);
if (previouslyCalculatedContentHashId == null) {
byte[] hash = content instanceof FileContentImpl ? ((FileContentImpl)content).getHash():null;
@@ -616,6 +651,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
}
private static final com.intellij.openapi.util.Key<Integer> ourSavedContentHashIdKey = com.intellij.openapi.util.Key.create("saved.content.hash.id");
+ private static final com.intellij.openapi.util.Key<Integer> ourSavedUncommittedHashIdKey = com.intellij.openapi.util.Key.create("saved.uncommitted.hash.id");
protected void updateWithMap(final int inputId,
int savedInputId, @NotNull Map<Key, Value> newData,
diff --git a/platform/platform-api/src/com/intellij/execution/process/AnsiEscapeDecoder.java b/platform/platform-api/src/com/intellij/execution/process/AnsiEscapeDecoder.java
index 0ecf7c8a6dd0..58a8e40db2d6 100644
--- a/platform/platform-api/src/com/intellij/execution/process/AnsiEscapeDecoder.java
+++ b/platform/platform-api/src/com/intellij/execution/process/AnsiEscapeDecoder.java
@@ -19,80 +19,105 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
+import java.util.regex.Pattern;
/**
+ * See <a href="http://en.wikipedia.org/wiki/ANSI_escape_code">ANSI escape code</a>.
+ *
* @author traff
*/
public class AnsiEscapeDecoder {
- private static final char TEXT_ATTRS_PREFIX_CH = '\u001B';
- private static final String TEXT_ATTRS_PREFIX = Character.toString(TEXT_ATTRS_PREFIX_CH) + "[";
- private static final String TEXT_ATTRS_PATTERN = "m" + TEXT_ATTRS_PREFIX_CH + "\\[";
+ private static final char ESC_CHAR = '\u001B'; // Escape sequence start character
+ private static final String CSI = ESC_CHAR + "["; // "Control Sequence Initiator"
+ private static final Pattern INNER_PATTERN = Pattern.compile(Pattern.quote("m" + CSI));
- private Key myCurrentColor;
+ private Key myCurrentTextAttributes;
/**
* Parses ansi-color codes from text and sends text fragments with color attributes to textAcceptor
*
- * @param text
- * @param outputType
- * @param textAcceptor if implements ColoredTextAcceptor then it will receive text fragments with color attributes
- * if implements ColoredChunksAcceptor then it will receive list of pairs <text, attribute>
+ * @param text a string with ANSI escape sequences
+ * @param outputType stdout/stderr/system (from {@link ProcessOutputTypes})
+ * @param textAcceptor receives text fragments with color attributes.
+ * It can implement ColoredChunksAcceptor to receive list of pairs (text, attribute).
*/
- public void escapeText(String text, Key outputType, ColoredTextAcceptor textAcceptor) {
- final List<Pair<String, Key>> textChunks = ContainerUtil.newArrayList();
+ public void escapeText(@NotNull String text, @NotNull Key outputType, @NotNull ColoredTextAcceptor textAcceptor) {
+ List<Pair<String, Key>> chunks = null;
int pos = 0;
while (true) {
- int macroPos = text.indexOf(TEXT_ATTRS_PREFIX, pos);
- if (macroPos < 0) break;
- if (pos != macroPos) {
- textChunks.add(Pair.create(text.substring(pos, macroPos), getCurrentOutputAttributes(outputType)));
+ int escSeqBeginInd = text.indexOf(CSI, pos);
+ if (escSeqBeginInd < 0) {
+ break;
}
- final int macroEndPos = getEndMacroPos(text, macroPos);
- if (macroEndPos < 0) {
+ if (pos < escSeqBeginInd) {
+ chunks = processTextChunk(chunks, text.substring(pos, escSeqBeginInd), outputType, textAcceptor);
+ }
+ final int escSeqEndInd = findEscSeqEndIndex(text, escSeqBeginInd);
+ if (escSeqEndInd < 0) {
break;
}
+ String escSeq = text.substring(escSeqBeginInd, escSeqEndInd);
// this is a simple fix for RUBY-8996:
// we replace several consecutive escape sequences with one which contains all these sequences
- final String colorAttribute = text.substring(macroPos, macroEndPos).replaceAll(TEXT_ATTRS_PATTERN, ";");
- myCurrentColor = ColoredOutputTypeRegistry.getInstance().getOutputKey(colorAttribute);
- pos = macroEndPos;
+ String colorAttribute = INNER_PATTERN.matcher(escSeq).replaceAll(";");
+ myCurrentTextAttributes = ColoredOutputTypeRegistry.getInstance().getOutputKey(colorAttribute);
+ pos = escSeqEndInd;
}
if (pos < text.length()) {
- textChunks.add(Pair.create(text.substring(pos), getCurrentOutputAttributes(outputType)));
+ chunks = processTextChunk(chunks, text.substring(pos), outputType, textAcceptor);
}
- if (textAcceptor instanceof ColoredChunksAcceptor) {
- ((ColoredChunksAcceptor)textAcceptor).coloredChunksAvailable(textChunks);
- }
- else {
- coloredTextAvailable(textChunks, textAcceptor);
+ if (chunks != null && textAcceptor instanceof ColoredChunksAcceptor) {
+ ((ColoredChunksAcceptor)textAcceptor).coloredChunksAvailable(chunks);
}
}
- // selects all consecutive escape sequences
- private static int getEndMacroPos(final String text, int macroPos) {
- int endMacroPos = text.indexOf('m', macroPos);
- while (endMacroPos >= 0) {
- endMacroPos += 1;
- macroPos = text.indexOf(TEXT_ATTRS_PREFIX, endMacroPos);
- if (macroPos != endMacroPos) {
+ /*
+ * Selects all consecutive escape sequences and returns escape sequence end index (exclusive).
+ * If the escape sequence isn't finished, returns -1.
+ */
+ private static int findEscSeqEndIndex(@NotNull String text, int escSeqBeginInd) {
+ escSeqBeginInd = text.indexOf('m', escSeqBeginInd);
+ while (escSeqBeginInd >= 0) {
+ escSeqBeginInd++;
+ if (!text.regionMatches(escSeqBeginInd, CSI, 0, CSI.length())) {
break;
}
- endMacroPos = text.indexOf('m', macroPos);
+ escSeqBeginInd = text.indexOf('m', escSeqBeginInd);
+ }
+ return escSeqBeginInd;
+ }
+
+ @Nullable
+ private List<Pair<String, Key>> processTextChunk(@Nullable List<Pair<String, Key>> buffer,
+ @NotNull String text,
+ @NotNull Key outputType,
+ @NotNull ColoredTextAcceptor textAcceptor) {
+ Key attributes = getCurrentOutputAttributes(outputType);
+ if (textAcceptor instanceof ColoredChunksAcceptor) {
+ if (buffer == null) {
+ buffer = ContainerUtil.newArrayListWithCapacity(1);
+ }
+ buffer.add(Pair.create(text, attributes));
+ }
+ else {
+ textAcceptor.coloredTextAvailable(text, attributes);
}
- return endMacroPos;
+ return buffer;
}
- protected Key getCurrentOutputAttributes(final Key outputType) {
+ @NotNull
+ protected Key getCurrentOutputAttributes(@NotNull Key outputType) {
if (outputType == ProcessOutputTypes.STDERR || outputType == ProcessOutputTypes.SYSTEM) {
return outputType;
}
- return myCurrentColor != null ? myCurrentColor : outputType;
+ return myCurrentTextAttributes != null ? myCurrentTextAttributes : outputType;
}
- public void coloredTextAvailable(@NotNull final List<Pair<String, Key>> textChunks, ColoredTextAcceptor textAcceptor) {
- for (final Pair<String, Key> textChunk : textChunks) {
+ public void coloredTextAvailable(@NotNull List<Pair<String, Key>> textChunks, ColoredTextAcceptor textAcceptor) {
+ for (Pair<String, Key> textChunk : textChunks) {
textAcceptor.coloredTextAvailable(textChunk.getFirst(), textChunk.getSecond());
}
}
diff --git a/platform/platform-api/src/com/intellij/execution/process/CapturingAnsiEscapesAwareProcessHandler.java b/platform/platform-api/src/com/intellij/execution/process/CapturingAnsiEscapesAwareProcessHandler.java
index c76e79a0bfd6..96544b8ba83c 100644
--- a/platform/platform-api/src/com/intellij/execution/process/CapturingAnsiEscapesAwareProcessHandler.java
+++ b/platform/platform-api/src/com/intellij/execution/process/CapturingAnsiEscapesAwareProcessHandler.java
@@ -44,7 +44,8 @@ public class CapturingAnsiEscapesAwareProcessHandler extends CapturingProcessHan
private static class AnsiEscapesAwareAdapter extends CapturingProcessAdapter implements AnsiEscapeDecoder.ColoredTextAcceptor {
private final AnsiEscapeDecoder myAnsiEscapeDecoder = new AnsiEscapeDecoder() {
@Override
- protected Key getCurrentOutputAttributes(Key outputType) {
+ @NotNull
+ protected Key getCurrentOutputAttributes(@NotNull Key outputType) {
return outputType; //we don't need color information - only stdout and stderr keys are added to output in CapturingProcessAdapter
}
};
diff --git a/platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java b/platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java
index 7fff03827fb4..be9dccb0dbca 100644
--- a/platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java
+++ b/platform/platform-api/src/com/intellij/execution/process/ColoredOutputTypeRegistry.java
@@ -8,6 +8,7 @@ import com.intellij.openapi.editor.markup.EffectType;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.HashMap;
@@ -73,6 +74,7 @@ public class ColoredOutputTypeRegistry {
see full doc at http://en.wikipedia.org/wiki/ANSI_escape_code
*/
+ @NotNull
public Key getOutputKey(@NonNls String attribute) {
final Key key = myRegisteredKeys.get(attribute);
if (key != null) {
diff --git a/platform/platform-api/src/com/intellij/ide/CompositeSelectInTarget.java b/platform/platform-api/src/com/intellij/ide/CompositeSelectInTarget.java
index 7facb6f990f8..e493770d6605 100644
--- a/platform/platform-api/src/com/intellij/ide/CompositeSelectInTarget.java
+++ b/platform/platform-api/src/com/intellij/ide/CompositeSelectInTarget.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -25,5 +25,5 @@ import java.util.Collection;
*/
public interface CompositeSelectInTarget extends SelectInTarget{
@NotNull
- Collection<SelectInTarget> getSubTargets(SelectInContext context);
+ Collection<SelectInTarget> getSubTargets(@NotNull SelectInContext context);
}
diff --git a/platform/platform-api/src/com/intellij/ide/SelectInTarget.java b/platform/platform-api/src/com/intellij/ide/SelectInTarget.java
index 3e5f9d0e87bd..e7d834ac2268 100644
--- a/platform/platform-api/src/com/intellij/ide/SelectInTarget.java
+++ b/platform/platform-api/src/com/intellij/ide/SelectInTarget.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
public interface SelectInTarget {
ExtensionPointName<SelectInTarget> EP_NAME = new ExtensionPointName<SelectInTarget>("com.intellij.selectInTarget");
+ @Override
String toString();
/**
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java
index 78db7cf0ed5c..1e03a3482ad4 100644
--- a/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java
+++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java
@@ -15,7 +15,7 @@
*/
package com.intellij.openapi.actionSystem;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.components.ServiceManager;
import java.util.List;
import java.util.Set;
@@ -26,11 +26,16 @@ import java.util.Set;
*/
public abstract class AbbreviationManager {
public static AbbreviationManager getInstance() {
- return ApplicationManager.getApplication().getComponent(AbbreviationManager.class);
+ return ServiceManager.getService(AbbreviationManager.class);
}
+
public abstract Set<String> getAbbreviations();
+
public abstract Set<String> getAbbreviations(String actionId);
+
public abstract List<String> findActions(String abbreviation);
+
public abstract void register(String abbreviation, String actionId);
+
public abstract void remove(String abbreviation, String actionId);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/CaretSpecificDataContext.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/CaretSpecificDataContext.java
new file mode 100644
index 000000000000..e53cc48e4d5a
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/CaretSpecificDataContext.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2014 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.actionSystem;
+
+import com.intellij.openapi.actionSystem.CommonDataKeys;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.DataContextWrapper;
+import com.intellij.openapi.editor.Caret;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class CaretSpecificDataContext extends DataContextWrapper {
+ private final Caret myCaret;
+
+ public CaretSpecificDataContext(@NotNull DataContext delegate, @NotNull Caret caret) {
+ super(delegate);
+ myCaret = caret;
+ }
+
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ Project project = (Project)super.getData(CommonDataKeys.PROJECT.getName());
+ if (project == null) {
+ return null;
+ }
+ FileEditorManager fm = FileEditorManager.getInstance(project);
+ Object data = fm == null ? null : fm.getData(dataId, myCaret.getEditor(), myCaret);
+ return data == null ? super.getData(dataId) : data;
+ }
+}
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java
index 945c52022984..d93a508f97bd 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java
@@ -26,13 +26,14 @@ import org.jetbrains.annotations.Nullable;
import java.awt.event.KeyEvent;
+import static com.intellij.openapi.actionSystem.CommonDataKeys.EDITOR;
import static com.intellij.openapi.actionSystem.CommonDataKeys.PROJECT;
public abstract class EditorAction extends AnAction implements DumbAware {
private EditorActionHandler myHandler;
private boolean myHandlersLoaded;
- public EditorActionHandler getHandler() {
+ public final EditorActionHandler getHandler() {
ensureHandlersLoaded();
return myHandler;
}
@@ -46,6 +47,7 @@ public abstract class EditorAction extends AnAction implements DumbAware {
ensureHandlersLoaded();
EditorActionHandler tmp = myHandler;
myHandler = newHandler;
+ myHandler.setWorksInInjected(isInInjectedContext());
return tmp;
}
@@ -58,12 +60,22 @@ public abstract class EditorAction extends AnAction implements DumbAware {
final EditorActionHandlerBean handlerBean = extensions[i];
if (handlerBean.action.equals(id)) {
myHandler = handlerBean.getHandler(myHandler);
+ myHandler.setWorksInInjected(isInInjectedContext());
}
}
}
}
@Override
+ public void setInjectedContext(boolean worksInInjected) {
+ super.setInjectedContext(worksInInjected);
+ // we assume that this method is called in constructor at the point
+ // where the chain of handlers is not initialized yet
+ // and it's enough to pass the flag to the default handler only
+ myHandler.setWorksInInjected(isInInjectedContext());
+ }
+
+ @Override
public final void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Editor editor = getEditor(dataContext);
@@ -72,7 +84,7 @@ public abstract class EditorAction extends AnAction implements DumbAware {
@Nullable
protected Editor getEditor(@NotNull DataContext dataContext) {
- return CommonDataKeys.EDITOR.getData(dataContext);
+ return EDITOR.getData(dataContext);
}
public final void actionPerformed(final Editor editor, @NotNull final DataContext dataContext) {
@@ -102,7 +114,7 @@ public abstract class EditorAction extends AnAction implements DumbAware {
}
public void update(Editor editor, Presentation presentation, DataContext dataContext) {
- presentation.setEnabled(getHandler().isEnabled(editor, dataContext));
+ presentation.setEnabled(getHandler().isEnabled(editor, null, dataContext));
}
public void updateForKeyboardAccess(Editor editor, Presentation presentation, DataContext dataContext) {
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorActionHandler.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorActionHandler.java
index c43fd13d8bef..294622ce1916 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorActionHandler.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorActionHandler.java
@@ -15,7 +15,7 @@
*/
package com.intellij.openapi.editor.actionSystem;
-import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.CaretAction;
import com.intellij.openapi.editor.Editor;
@@ -35,7 +35,9 @@ import org.jetbrains.annotations.Nullable;
*/
public abstract class EditorActionHandler {
private final boolean myRunForEachCaret;
+ private boolean myWorksInInjected;
private boolean inExecution;
+ private boolean inCheck;
protected EditorActionHandler() {
this(false);
@@ -46,17 +48,92 @@ public abstract class EditorActionHandler {
}
/**
- * Checks if the action handler is currently enabled.
- *
- * @param editor the editor in which the action is invoked.
- * @param dataContext the data context for the action.
- * @return true if the action is enabled, false otherwise
+ * @deprecated Implementations should override
+ * {@link #isEnabledForCaret(com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.Caret, com.intellij.openapi.actionSystem.DataContext)}
+ * instead,
+ * client code should invoke
+ * {@link #isEnabled(com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.Caret, com.intellij.openapi.actionSystem.DataContext)}
+ * instead.
*/
- public boolean isEnabled(Editor editor, DataContext dataContext) {
- return true;
+ public boolean isEnabled(Editor editor, final DataContext dataContext) {
+ if (inCheck) {
+ return true;
+ }
+ inCheck = true;
+ try {
+ if (editor == null) {
+ return false;
+ }
+ Editor hostEditor = dataContext == null ? null : CommonDataKeys.HOST_EDITOR.getData(dataContext);
+ if (hostEditor == null) {
+ hostEditor = editor;
+ }
+ final boolean[] result = new boolean[1];
+ final CaretTask check = new CaretTask() {
+ @Override
+ public void perform(@NotNull Caret caret, @Nullable DataContext dataContext) {
+ result[0] = true;
+ }
+ };
+ if (myRunForEachCaret) {
+ hostEditor.getCaretModel().runForEachCaret(new CaretAction() {
+ @Override
+ public void perform(Caret caret) {
+ doIfEnabled(caret, dataContext, check);
+ }
+ });
+ }
+ else {
+ doIfEnabled(hostEditor.getCaretModel().getCurrentCaret(), dataContext, check);
+ }
+ return result[0];
+ }
+ finally {
+ inCheck = false;
+ }
+ }
+
+ private void doIfEnabled(@NotNull Caret hostCaret, @Nullable DataContext context, @NotNull CaretTask task) {
+ DataContext caretContext = context == null ? null : new CaretSpecificDataContext(context, hostCaret);
+ if (myWorksInInjected && caretContext != null) {
+ DataContext injectedCaretContext = AnActionEvent.getInjectedDataContext(caretContext);
+ Caret injectedCaret = CommonDataKeys.CARET.getData(injectedCaretContext);
+ if (injectedCaret != null && injectedCaret != hostCaret && isEnabledForCaret(injectedCaret.getEditor(), injectedCaret, injectedCaretContext)) {
+ task.perform(injectedCaret, injectedCaretContext);
+ return;
+ }
+ }
+ if (isEnabledForCaret(hostCaret.getEditor(), hostCaret, caretContext)) {
+ task.perform(hostCaret, caretContext);
+ }
}
/**
+ * Implementations can override this method to define whether handler is enabled for a specific caret in a given editor.
+ */
+ protected boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
+ if (inCheck) {
+ return true;
+ }
+ inCheck = true;
+ try {
+ //noinspection deprecation
+ return isEnabled(editor, dataContext);
+ }
+ finally {
+ inCheck = false;
+ }
+ }
+
+ /**
+ * If <code>caret</code> is <code>null</code>, checks whether handler is enabled in general (i.e. enabled for at least one caret in editor),
+ * if <code>caret</code> is not <code>null</code>, checks whether it's enabled for specified caret.
+ */
+ public final boolean isEnabled(@NotNull Editor editor, @Nullable Caret caret, DataContext dataContext) {
+ //noinspection deprecation
+ return caret == null ? isEnabled(editor, dataContext) : isEnabledForCaret(editor, caret, dataContext);
+ }
+ /**
* @deprecated To implement action logic, override
* {@link #doExecute(com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.Caret, com.intellij.openapi.actionSystem.DataContext)},
* to invoke the handler, call
@@ -112,22 +189,49 @@ public abstract class EditorActionHandler {
* @param editor the editor in which the action is invoked.
* @param dataContext the data context for the action.
*/
- public final void execute(@NotNull final Editor editor, @Nullable Caret contextCaret, final DataContext dataContext) {
+ public final void execute(@NotNull Editor editor, @Nullable final Caret contextCaret, final DataContext dataContext) {
+ Editor hostEditor = dataContext == null ? null : CommonDataKeys.HOST_EDITOR.getData(dataContext);
+ if (hostEditor == null) {
+ hostEditor = editor;
+ }
if (contextCaret == null && runForAllCarets()) {
- editor.getCaretModel().runForEachCaret(new CaretAction() {
+ hostEditor.getCaretModel().runForEachCaret(new CaretAction() {
@Override
public void perform(Caret caret) {
- doExecute(editor, caret, dataContext);
+ doIfEnabled(caret, dataContext, new CaretTask() {
+ @Override
+ public void perform(@NotNull Caret caret, @Nullable DataContext dataContext) {
+ doExecute(caret.getEditor(), caret, dataContext);
+ }
+ });
}
}, true);
}
else {
- doExecute(editor, contextCaret, dataContext);
+ if (contextCaret == null) {
+ doIfEnabled(hostEditor.getCaretModel().getCurrentCaret(), dataContext, new CaretTask() {
+ @Override
+ public void perform(@NotNull Caret caret, @Nullable DataContext dataContext) {
+ doExecute(caret.getEditor(), null, dataContext);
+ }
+ });
+ }
+ else {
+ doExecute(editor, contextCaret, dataContext);
+ }
}
}
+ void setWorksInInjected(boolean worksInInjected) {
+ myWorksInInjected = worksInInjected;
+ }
+
public DocCommandGroupId getCommandGroupId(Editor editor) {
// by default avoid merging two consequential commands, and, in the same time, pass along the Document
return DocCommandGroupId.noneGroupId(editor.getDocument());
}
+
+ private interface CaretTask {
+ void perform(@NotNull Caret caret, @Nullable DataContext dataContext);
+ }
}
diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/EditorDataProvider.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/EditorDataProvider.java
index 7dfec0240c1f..90d05360be0e 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileEditor/EditorDataProvider.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/EditorDataProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,14 +15,14 @@
*/
package com.intellij.openapi.fileEditor;
+import com.intellij.openapi.editor.Caret;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.vfs.VirtualFile;
/**
* @author peter
*/
public interface EditorDataProvider {
- @Nullable Object getData(@NotNull String dataId, @NotNull Editor e, @NotNull VirtualFile file);
+ @Nullable Object getData(@NotNull String dataId, @NotNull Editor e, @NotNull Caret caret);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java
index b9589574059d..86e719eef48d 100644
--- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java
+++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -16,6 +16,7 @@
package com.intellij.openapi.fileEditor;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
@@ -184,6 +185,13 @@ public abstract class FileEditorManager {
public abstract void registerExtraEditorDataProvider(@NotNull EditorDataProvider provider, Disposable parentDisposable);
/**
+ * Returns data associated with given editor/caret context. Data providers are registered via
+ * {@link #registerExtraEditorDataProvider(EditorDataProvider, com.intellij.openapi.Disposable)} method.
+ */
+ @Nullable
+ public abstract Object getData(@NotNull String dataId, @NotNull Editor editor, @NotNull Caret caret);
+
+ /**
* Selects a specified file editor tab for the specified editor.
* @param file a file to switch the file editor tab for. The function does nothing if the file is not currently open in the editor.
* @param fileEditorProviderId the ID of the file editor to open; matches the return value of
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java
index c02f27af5d4b..f35d76fff51c 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java
@@ -117,7 +117,7 @@ public class ComboBoxTableRenderer<T> extends JLabel implements TableCellRendere
public Component getTableCellEditorComponent(JTable table, final Object value, boolean isSelected, final int row, final int column) {
@SuppressWarnings("unchecked") final T t = (T)value;
myValue = t;
- customizeComponent(t, table, isSelected);
+ customizeComponent(t, table, true);
//noinspection SSBasedInspection
SwingUtilities.invokeLater(new Runnable() {
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithActions.java b/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithActions.java
index d6310f508ed0..889fb2786188 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithActions.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithActions.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -41,11 +41,11 @@ public interface ComponentWithActions {
boolean isContentBuiltIn();
class Impl implements ComponentWithActions {
- private ActionGroup myToolbar;
- private String myToolbarPlace;
- private JComponent myToolbarContext;
- private JComponent mySearchComponent;
- private JComponent myComponent;
+ private final ActionGroup myToolbar;
+ private final String myToolbarPlace;
+ private final JComponent myToolbarContext;
+ private final JComponent mySearchComponent;
+ private final JComponent myComponent;
public Impl(final ActionGroup toolbar, final String toolbarPlace, final JComponent toolbarContext,
final JComponent searchComponent,
@@ -57,6 +57,7 @@ public interface ComponentWithActions {
myComponent = component;
}
+ @Override
public boolean isContentBuiltIn() {
return false;
}
@@ -65,22 +66,27 @@ public interface ComponentWithActions {
this(null, null, null, null, component);
}
+ @Override
public ActionGroup getToolbarActions() {
return myToolbar;
}
+ @Override
public JComponent getSearchComponent() {
return mySearchComponent;
}
+ @Override
public String getToolbarPlace() {
return myToolbarPlace;
}
+ @Override
public JComponent getToolbarContextComponent() {
return myToolbarContext;
}
+ @Override
@NotNull
public JComponent getComponent() {
return myComponent;
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
index 6c13964d5789..a262ea0a3b85 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
@@ -122,7 +122,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
private boolean myHasDeletedItems;
protected AutoScrollToSourceHandler myAutoScrollHandler;
- private boolean myToReInitWholePanel = true;
+ protected boolean myToReInitWholePanel = true;
protected MasterDetailsComponent() {
this(new MasterDetailsState());
@@ -139,7 +139,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
reInitWholePanelIfNeeded();
}
- private void reInitWholePanelIfNeeded() {
+ protected void reInitWholePanelIfNeeded() {
if (!myToReInitWholePanel) return;
myWholePanel = new JPanel(new BorderLayout()) {
@@ -177,7 +177,8 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
decorator.setActionGroup(group);
}
//left.add(myNorthPanel, BorderLayout.NORTH);
- myMaster = decorator.setPanelBorder(new EmptyBorder(0, 0, 0, 0)).createPanel();
+ myMaster = decorator.setAsUsualTopToolbar().setPanelBorder(new EmptyBorder(0, 0, 0, 0)).createPanel();
+ myNorthPanel.setVisible(false);
} else {
left.add(myNorthPanel, BorderLayout.NORTH);
myMaster = ScrollPaneFactory.createScrollPane(myTree);
@@ -280,6 +281,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
}
private void initToolbar() {
+ if (Registry.is("ide.new.project.settings")) return;
DefaultActionGroup group = createToolbarActionGroup();
if (group != null) {
final JComponent component = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent();
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/PanelWithText.java b/platform/platform-api/src/com/intellij/openapi/ui/PanelWithText.java
index 172772139ccf..fc6c3c6686cd 100644
--- a/platform/platform-api/src/com/intellij/openapi/ui/PanelWithText.java
+++ b/platform/platform-api/src/com/intellij/openapi/ui/PanelWithText.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -36,7 +36,7 @@ public class PanelWithText extends JPanel {
public PanelWithText(String text) {
super(new GridBagLayout());
- setBorder(BorderFactory.createEtchedBorder());
+ //setBorder(BorderFactory.createEtchedBorder());
myLabel.setText(XmlStringUtil.wrapInHtml(text));
add(myLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(8,8,8,8), 0, 0));
}
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/ListItemDescriptorAdapter.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/ListItemDescriptorAdapter.java
new file mode 100644
index 000000000000..e11e70c74b98
--- /dev/null
+++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/ListItemDescriptorAdapter.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.ui.popup;
+
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+public abstract class ListItemDescriptorAdapter<T> implements ListItemDescriptor<T> {
+ @Nullable
+ @Override
+ public String getCaptionAboveOf(T value) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public String getTooltipFor(T value) {
+ return null;
+ }
+
+ @Override
+ public Icon getIconFor(T value) {
+ return null;
+ }
+
+ @Override
+ public boolean hasSeparatorAboveOf(T value) {
+ return false;
+ }
+} \ No newline at end of file
diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java
index 3cd467048e98..254f7749fb25 100644
--- a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java
+++ b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java
@@ -51,7 +51,9 @@ import java.util.*;
public class VfsUtil extends VfsUtilCore {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.VfsUtil");
- public static final char VFS_PATH_SEPARATOR = '/';
+
+ /** @deprecated incorrect name, use {@link #VFS_SEPARATOR_CHAR} (to be removed in IDEA 15) */
+ public static final char VFS_PATH_SEPARATOR = VFS_SEPARATOR_CHAR;
public static void saveText(@NotNull VirtualFile file, @NotNull String text) throws IOException {
Charset charset = file.getCharset();
@@ -585,7 +587,7 @@ public class VfsUtil extends VfsUtilCore {
if (url == null) {
return null;
}
- final int index = url.lastIndexOf(VFS_PATH_SEPARATOR);
+ final int index = url.lastIndexOf(VfsUtil.VFS_SEPARATOR_CHAR);
return index < 0 ? null : url.substring(0, index);
}
@@ -598,12 +600,12 @@ public class VfsUtil extends VfsUtilCore {
if (urlOrPath == null) {
return null;
}
- final int index = urlOrPath.lastIndexOf(VFS_PATH_SEPARATOR);
+ final int index = urlOrPath.lastIndexOf(VfsUtil.VFS_SEPARATOR_CHAR);
return index < 0 ? null : urlOrPath.substring(index+1);
}
@NotNull
- public static List<VirtualFile> markDirty(boolean recursive, boolean reloadChildren, VirtualFile... files) {
+ public static List<VirtualFile> markDirty(boolean recursive, boolean reloadChildren, @NotNull VirtualFile... files) {
List<VirtualFile> list = ContainerUtil.filter(Condition.NOT_NULL, files);
if (list.isEmpty()) {
return Collections.emptyList();
@@ -626,7 +628,7 @@ public class VfsUtil extends VfsUtilCore {
return list;
}
- public static void markDirtyAndRefresh(boolean async, boolean recursive, boolean reloadChildren, VirtualFile... files) {
+ public static void markDirtyAndRefresh(boolean async, boolean recursive, boolean reloadChildren, @NotNull VirtualFile... files) {
List<VirtualFile> list = markDirty(recursive, reloadChildren, files);
if (list.isEmpty()) return;
LocalFileSystem.getInstance().refreshFiles(list, async, recursive, null);
diff --git a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java
index 6c40a04f5831..38dcb877e030 100644
--- a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java
+++ b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java
@@ -192,7 +192,7 @@ public abstract class FocusCommand extends ActiveRunnable implements Expirable {
LOG.info("We could not request focus in window on " + myToFocus.getClass().getName());
LOG.info(myAllocation);
}
- if (!SystemInfo.isMac || isForced() ) {
+ if (isForced()) {
myToFocus.requestFocus();
if (shouldLogFocuses) {
LOG.info("Force request focus on " + myToFocus.getClass().getName());
@@ -217,10 +217,6 @@ public abstract class FocusCommand extends ActiveRunnable implements Expirable {
if (myToFocus == null) {
return true;
}
- if (SwingUtilities.getWindowAncestor(myToFocus) == null) {
- clear();
- return true;
- }
return false;
}
diff --git a/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java b/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java
index d8f7e86d4b9e..6b4852319899 100644
--- a/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java
+++ b/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -163,9 +163,8 @@ public abstract class IdeFocusManager implements FocusRequestor {
public abstract void toFront(JComponent c);
public static IdeFocusManager getInstance(@Nullable Project project) {
- if (project == null) return getGlobalInstance();
+ if (project == null || project.isDisposed() || !project.isInitialized()) return getGlobalInstance();
- if (project.isDisposed() || !project.isInitialized()) return getGlobalInstance();
return project.getComponent(IdeFocusManager.class);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java
index 477ff28baef6..cc198e18a140 100644
--- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java
+++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -17,6 +17,7 @@
package com.intellij.openapi.wm;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
/**
* Performs lazy initialization of a toolwindow registered in plugin.xml.
@@ -25,5 +26,5 @@ import com.intellij.openapi.project.Project;
* @see ToolWindowEP
*/
public interface ToolWindowFactory {
- void createToolWindowContent(Project project, ToolWindow toolWindow);
+ void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow);
}
diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java
index 0e7ddb332151..b616429a11c8 100644
--- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java
+++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -47,16 +47,25 @@ public abstract class ToolWindowManager {
* @return tool window
* @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)}
*/
- public abstract ToolWindow registerToolWindow(@NotNull String id,@NotNull JComponent component,@NotNull ToolWindowAnchor anchor);
+ @Deprecated
+ @NotNull
+ public abstract ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor);
/**
* @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)}
*/
- public abstract ToolWindow registerToolWindow(@NotNull String id,@NotNull JComponent component,@NotNull ToolWindowAnchor anchor, Disposable parentDisposable);
+ @Deprecated
+ @NotNull
+ public abstract ToolWindow registerToolWindow(@NotNull String id,
+ @NotNull JComponent component,
+ @NotNull ToolWindowAnchor anchor,
+ @NotNull Disposable parentDisposable);
/**
* @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)}
*/
+ @Deprecated
+ @NotNull
public abstract ToolWindow registerToolWindow(@NotNull String id,
@NotNull JComponent component,
@NotNull ToolWindowAnchor anchor,
@@ -65,6 +74,8 @@ public abstract class ToolWindowManager {
/**
* @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)}
*/
+ @Deprecated
+ @NotNull
public abstract ToolWindow registerToolWindow(@NotNull String id,
@NotNull JComponent component,
@NotNull ToolWindowAnchor anchor,
@@ -72,12 +83,16 @@ public abstract class ToolWindowManager {
boolean canWorkInDumbMode,
boolean canCloseContents);
+ @NotNull
public abstract ToolWindow registerToolWindow(@NotNull String id, boolean canCloseContent, @NotNull ToolWindowAnchor anchor);
+ @NotNull
public abstract ToolWindow registerToolWindow(@NotNull String id, boolean canCloseContent, @NotNull ToolWindowAnchor anchor, boolean secondary);
+ @NotNull
public abstract ToolWindow registerToolWindow(@NotNull String id, boolean canCloseContent, @NotNull ToolWindowAnchor anchor, Disposable parentDisposable, boolean canWorkInDumbMode);
+ @NotNull
public ToolWindow registerToolWindow(@NotNull final String id,
final boolean canCloseContent,
@NotNull final ToolWindowAnchor anchor,
@@ -102,6 +117,7 @@ public abstract class ToolWindowManager {
/**
* @return array of <code>id</code>s of all registered tool windows.
*/
+ @NotNull
public abstract String[] getToolWindowIds();
/**
@@ -120,11 +136,12 @@ public abstract class ToolWindowManager {
/**
* Puts specified runnable to the tail of current command queue.
*/
- public abstract void invokeLater(Runnable runnable);
+ public abstract void invokeLater(@NotNull Runnable runnable);
/**
* Utility method for quick access to the focus manager
*/
+ @NotNull
public abstract IdeFocusManager getFocusManager();
public abstract void notifyByBalloon(@NotNull final String toolWindowId, @NotNull final MessageType type, @NotNull final String htmlBody);
diff --git a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java
index 83944a51755d..97a42176a25b 100644
--- a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java
+++ b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,6 +18,7 @@ package com.intellij.ui.components;
import com.intellij.openapi.wm.IdeGlassPane;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.ReflectionUtil;
import com.intellij.util.ui.ButtonlessScrollBarUI;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,7 +30,6 @@ import javax.swing.plaf.ScrollPaneUI;
import javax.swing.plaf.basic.BasicScrollBarUI;
import java.awt.*;
import java.awt.event.MouseEvent;
-import java.lang.reflect.Method;
public class JBScrollPane extends JScrollPane {
private int myViewportBorderWidth = -1;
@@ -302,9 +302,7 @@ public class JBScrollPane extends JScrollPane {
if (ui instanceof BasicScrollBarUI) {
BasicScrollBarUI bui = (BasicScrollBarUI)ui;
try {
- Method m = BasicScrollBarUI.class.getDeclaredMethod("getThumbBounds", ArrayUtil.EMPTY_CLASS_ARRAY);
- m.setAccessible(true);
- Rectangle rect = (Rectangle)m.invoke(bui);
+ Rectangle rect = (Rectangle)ReflectionUtil.getDeclaredMethod(BasicScrollBarUI.class, "getThumbBounds", ArrayUtil.EMPTY_CLASS_ARRAY).invoke(bui);
Point point = SwingUtilities.convertPoint(e.getComponent(), e.getX(), e.getY(), bar);
return !rect.contains(point);
}
diff --git a/platform/platform-api/src/com/intellij/ui/content/ContentManagerEvent.java b/platform/platform-api/src/com/intellij/ui/content/ContentManagerEvent.java
index 9aae91aaba42..31fe871d0a05 100644
--- a/platform/platform-api/src/com/intellij/ui/content/ContentManagerEvent.java
+++ b/platform/platform-api/src/com/intellij/ui/content/ContentManagerEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,10 +18,10 @@ package com.intellij.ui.content;
import java.util.EventObject;
public class ContentManagerEvent extends EventObject {
- private Content myContent;
- private int myIndex;
+ private final Content myContent;
+ private final int myIndex;
private boolean myConsumed;
- private ContentOperation myOperation;
+ private final ContentOperation myOperation;
public ContentManagerEvent(Object source, Content content, int index, ContentOperation operation) {
super(source);
@@ -54,7 +54,7 @@ public class ContentManagerEvent extends EventObject {
return myOperation;
}
- public static enum ContentOperation {
+ public enum ContentOperation {
add, remove, undefined
}
-} \ No newline at end of file
+}
diff --git a/platform/platform-api/src/com/intellij/ui/table/JBTable.java b/platform/platform-api/src/com/intellij/ui/table/JBTable.java
index 435c4358959f..bda230eb767e 100644
--- a/platform/platform-api/src/com/intellij/ui/table/JBTable.java
+++ b/platform/platform-api/src/com/intellij/ui/table/JBTable.java
@@ -52,7 +52,6 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
private Integer myMinRowHeight;
private boolean myStriped;
- private boolean isTypeAhead = true;
private AsyncProcessIcon myBusyIcon;
private boolean myBusy;
@@ -69,6 +68,8 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
public JBTable(final TableModel model, final TableColumnModel columnModel) {
super(model, columnModel);
+ setSurrendersFocusOnKeystroke(true);
+
myEmptyText = new StatusText(this) {
@Override
protected boolean isStatusVisible() {
@@ -421,7 +422,10 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
return false;
}
- if (e instanceof KeyEvent && UIUtil.isReallyTypedEvent((KeyEvent)e)) {
+ if (e instanceof KeyEvent) {
+ // do not start editing in autoStartsEdit mode on Ctrl-Z and other non-typed events
+ if (!UIUtil.isReallyTypedEvent((KeyEvent)e)) return false;
+
SpeedSearchSupply supply = SpeedSearchSupply.getSupply(this);
if (supply != null && supply.isPopupActive()) {
return false;
@@ -449,20 +453,43 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
add(editorComp);
editorComp.validate();
- IdeFocusManager.findInstanceByComponent(this).requestFocus(editorComp, false);
+ if (surrendersFocusOnKeyStroke()) {
+ // this replaces focus request in JTable.processKeyBinding
+ final IdeFocusManager focusManager = IdeFocusManager.findInstanceByComponent(this);
+ focusManager.setTypeaheadEnabled(false);
+ focusManager.requestFocus(editorComp, true).doWhenProcessed(new Runnable() {
+ @Override
+ public void run() {
+ focusManager.setTypeaheadEnabled(true);
+ }
+ });
+ }
setCellEditor(editor);
setEditingRow(row);
setEditingColumn(column);
editor.addCellEditorListener(this);
- if (isTypeAhead) {
- JTableCellEditorHelper.typeAhead(this, e, row, column);
- }
+
return true;
}
return false;
}
+ /**
+ * Always returns false.
+ * If you're interested in value of JTable.surrendersFocusOnKeystroke property, call JBTable.surrendersFocusOnKeyStroke()
+ * @return false
+ * @see #surrendersFocusOnKeyStroke
+ */
+ @Override
+ public boolean getSurrendersFocusOnKeystroke() {
+ return false; // prevents JTable.processKeyBinding from requesting editor component to be focused
+ }
+
+ public boolean surrendersFocusOnKeyStroke() {
+ return super.getSurrendersFocusOnKeystroke();
+ }
+
private static boolean isTableDecorationSupported() {
return UIUtil.isUnderAlloyLookAndFeel()
|| UIUtil.isUnderNativeMacLookAndFeel()
@@ -472,10 +499,6 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|| UIUtil.isUnderWindowsLookAndFeel();
}
- public void disableTypeAheadInCellEditors() {
- isTypeAhead = false;
- }
-
@NotNull
@Override
public Component prepareRenderer(@NotNull TableCellRenderer renderer, int row, int column) {
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java
index a842f623ac45..43f06bff2850 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBEditorTabs.java
@@ -49,7 +49,7 @@ public class JBEditorTabs extends JBTabsImpl {
private JBEditorTabsPainter myDefaultPainter = new DefaultEditorTabsPainter();
- public JBEditorTabs(@Nullable Project project, ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
+ public JBEditorTabs(@Nullable Project project, @NotNull ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
super(project, actionManager, focusManager, parent);
}
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
index 60898a6e9bd8..326192072c4b 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java
@@ -28,6 +28,7 @@ import com.intellij.openapi.wm.*;
import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.awt.RelativeRectangle;
+import com.intellij.ui.components.OrphanGuardian;
import com.intellij.ui.switcher.QuickActionProvider;
import com.intellij.ui.switcher.SwitchProvider;
import com.intellij.ui.switcher.SwitchTarget;
@@ -36,6 +37,7 @@ import com.intellij.ui.tabs.impl.singleRow.SingleRowLayout;
import com.intellij.ui.tabs.impl.singleRow.SingleRowPassInfo;
import com.intellij.ui.tabs.impl.table.TableLayout;
import com.intellij.ui.tabs.impl.table.TablePassInfo;
+import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.Animator;
@@ -69,7 +71,7 @@ public class JBTabsImpl extends JComponent
public static final Color MAC_AQUA_BG_COLOR = Gray._200;
- final ActionManager myActionManager;
+ @NotNull final ActionManager myActionManager;
private final List<TabInfo> myVisibleInfos = new ArrayList<TabInfo>();
private final Map<TabInfo, Integer> myHiddenInfos = new HashMap<TabInfo, Integer>();
@@ -153,8 +155,8 @@ public class JBTabsImpl extends JComponent
private JBTabsPosition myPosition = JBTabsPosition.top;
private final TabsBorder myBorder = new TabsBorder(this);
- private BaseNavigationAction myNextAction;
- private BaseNavigationAction myPrevAction;
+ private final BaseNavigationAction myNextAction;
+ private final BaseNavigationAction myPrevAction;
private boolean myTabDraggingEnabled;
private DragHelper myDragHelper;
@@ -172,6 +174,7 @@ public class JBTabsImpl extends JComponent
private Runnable myDeferredFocusRequest;
private boolean myAlwaysPaintSelectedTab;
+ private int myFirstTabOffset;
public JBTabsImpl(@NotNull Project project) {
this(project, project);
@@ -185,7 +188,7 @@ public class JBTabsImpl extends JComponent
this(project, ActionManager.getInstance(), focusManager, parent);
}
- public JBTabsImpl(@Nullable Project project, ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
+ public JBTabsImpl(@Nullable Project project, @NotNull ActionManager actionManager, IdeFocusManager focusManager, @NotNull Disposable parent) {
myProject = project;
myActionManager = actionManager;
myFocusManager = focusManager != null ? focusManager : IdeFocusManager.getGlobalInstance();
@@ -197,13 +200,11 @@ public class JBTabsImpl extends JComponent
myNavigationActions = new DefaultActionGroup();
- if (myActionManager != null) {
- myNextAction = new SelectNextAction(this, myActionManager);
- myPrevAction = new SelectPreviousAction(this, myActionManager);
+ myNextAction = new SelectNextAction(this, myActionManager);
+ myPrevAction = new SelectPreviousAction(this, myActionManager);
- myNavigationActions.add(myNextAction);
- myNavigationActions.add(myPrevAction);
- }
+ myNavigationActions.add(myNextAction);
+ myNavigationActions.add(myPrevAction);
setUiDecorator(null);
@@ -315,6 +316,16 @@ public class JBTabsImpl extends JComponent
}
}
};
+ putClientProperty(OrphanGuardian.CLIENT_PROPERTY_KEY, new OrphanGuardian() {
+
+ @Override
+ public void iterateOrphans(Consumer<JComponent> consumer) {
+ for (TabInfo info : getVisibleInfos()) {
+ if (info == mySelectedInfo) continue;
+ consumer.consume(info.getComponent());
+ }
+ }
+ });
}
protected SingleRowLayout createSingleRowLayout() {
@@ -451,14 +462,14 @@ public class JBTabsImpl extends JComponent
}
private void addTimerUpdate() {
- if (myActionManager != null && !myListenerAdded) {
+ if (!myListenerAdded) {
myActionManager.addTimerListener(500, this);
myListenerAdded = true;
}
}
private void removeTimerUpdate() {
- if (myActionManager != null && myListenerAdded) {
+ if (myListenerAdded) {
myActionManager.removeTimerListener(this);
myListenerAdded = false;
}
@@ -492,6 +503,14 @@ public class JBTabsImpl extends JComponent
myDropInfoIndex = dropInfoIndex;
}
+ public int getFirstTabOffset() {
+ return myFirstTabOffset;
+ }
+
+ public void setFirstTabOffset(int firstTabOffset) {
+ myFirstTabOffset = firstTabOffset;
+ }
+
class TabActionsAutoHideListener extends MouseMotionAdapter implements Weighted {
private TabLabel myCurrentOverLabel;
@@ -1399,7 +1418,7 @@ public class JBTabsImpl extends JComponent
final ActionGroup group = info.getGroup();
final JComponent side = info.getSideComponent();
- if (group != null && myTabs.myActionManager != null) {
+ if (group != null) {
final String place = info.getPlace();
ActionToolbar toolbar =
myTabs.myActionManager.createActionToolbar(place != null ? place : ActionPlaces.UNKNOWN, group, myTabs.myHorizontalSide);
@@ -1604,7 +1623,7 @@ public class JBTabsImpl extends JComponent
return 3;
}
- public static int getGhostTabLength() {
+ public int getGhostTabLength() {
return 15;
}
@@ -2561,6 +2580,7 @@ public class JBTabsImpl extends JComponent
}
private void updateContainer(boolean forced, final boolean layoutNow) {
+ if (myProject != null && !myProject.isOpen()) return;
for (TabInfo each : new ArrayList<TabInfo>(myVisibleInfos)) {
final JComponent eachComponent = each.getComponent();
if (getSelectedInfo() == each && getSelectedInfo() != null) {
@@ -2746,8 +2766,7 @@ public class JBTabsImpl extends JComponent
}
private static boolean isChanged(Object oldObject, Object newObject) {
- if (oldObject == null && newObject == null) return false;
- return oldObject != null && !oldObject.equals(newObject) || newObject != null && !newObject.equals(oldObject);
+ return !Comparing.equal(oldObject, newObject);
}
@Override
@@ -2785,12 +2804,11 @@ public class JBTabsImpl extends JComponent
}
private abstract static class BaseNavigationAction extends AnAction {
-
private final ShadowAction myShadow;
- private final ActionManager myActionManager;
+ @NotNull private final ActionManager myActionManager;
private final JBTabsImpl myTabs;
- protected BaseNavigationAction(final String copyFromID, JBTabsImpl tabs, ActionManager mgr) {
+ protected BaseNavigationAction(@NotNull String copyFromID, @NotNull JBTabsImpl tabs, @NotNull ActionManager mgr) {
myActionManager = mgr;
myTabs = tabs;
myShadow = new ShadowAction(this, myActionManager.getAction(copyFromID), tabs);
@@ -2858,7 +2876,7 @@ public class JBTabsImpl extends JComponent
private static class SelectNextAction extends BaseNavigationAction {
- private SelectNextAction(JBTabsImpl tabs, ActionManager mgr) {
+ private SelectNextAction(JBTabsImpl tabs, @NotNull ActionManager mgr) {
super(IdeActions.ACTION_NEXT_TAB, tabs, mgr);
}
@@ -2874,7 +2892,7 @@ public class JBTabsImpl extends JComponent
}
private static class SelectPreviousAction extends BaseNavigationAction {
- private SelectPreviousAction(JBTabsImpl tabs, ActionManager mgr) {
+ private SelectPreviousAction(JBTabsImpl tabs, @NotNull ActionManager mgr) {
super(IdeActions.ACTION_PREVIOUS_TAB, tabs, mgr);
}
@@ -3351,7 +3369,7 @@ public class JBTabsImpl extends JComponent
return myVisibleInfos.isEmpty();
}
- public static int getInterTabSpaceLength() {
+ public int getInterTabSpaceLength() {
return 1;
}
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java
index 4e5925d2a2ee..6bd2e1aa52bf 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java
@@ -209,6 +209,7 @@ public class SingleRowLayout extends TabLayout {
protected void prepareLayoutPassInfo(SingleRowPassInfo data, TabInfo selected) {
data.insets = myTabs.getLayoutInsets();
+ data.insets.left += myTabs.getFirstTabOffset();
final JBTabsImpl.Toolbar selectedToolbar = myTabs.myInfo2Toolbar.get(selected);
data.hToolbar = selectedToolbar != null && myTabs.myHorizontalSide && !selectedToolbar.isEmpty() ? selectedToolbar : null;
@@ -216,7 +217,7 @@ public class SingleRowLayout extends TabLayout {
data.toFitLength = getStrategy().getToFitLength(data);
if (myTabs.isGhostsAlwaysVisible()) {
- data.toFitLength -= JBTabsImpl.getGhostTabLength() * 2 + (JBTabsImpl.getInterTabSpaceLength() * 2);
+ data.toFitLength -= myTabs.getGhostTabLength() * 2 + (myTabs.getInterTabSpaceLength() * 2);
}
}
@@ -236,9 +237,9 @@ public class SingleRowLayout extends TabLayout {
private void layoutLabelsAndGhosts(final SingleRowPassInfo data) {
if (data.firstGhostVisible || myTabs.isGhostsAlwaysVisible()) {
- data.firstGhost = getStrategy().getLayoutRect(data, data.position, JBTabsImpl.getGhostTabLength());
+ data.firstGhost = getStrategy().getLayoutRect(data, data.position, myTabs.getGhostTabLength());
myTabs.layout(myLeftGhost, data.firstGhost);
- data.position += getStrategy().getLengthIncrement(data.firstGhost.getSize()) + JBTabsImpl.getInterTabSpaceLength();
+ data.position += getStrategy().getLengthIncrement(data.firstGhost.getSize()) + myTabs.getInterTabSpaceLength();
}
int deltaToFit = 0;
@@ -275,9 +276,9 @@ public class SingleRowLayout extends TabLayout {
boolean continueLayout = applyTabLayout(data, label, length, deltaToFit);
data.position = getStrategy().getMaxPosition(label.getBounds());
- data.position += JBTabsImpl.getInterTabSpaceLength();
+ data.position += myTabs.getInterTabSpaceLength();
- totalLength = getStrategy().getMaxPosition(label.getBounds()) - positionStart + JBTabsImpl.getInterTabSpaceLength();
+ totalLength = getStrategy().getMaxPosition(label.getBounds()) - positionStart + myTabs.getInterTabSpaceLength();
if (!continueLayout) {
layoutStopped = true;
}
@@ -288,7 +289,7 @@ public class SingleRowLayout extends TabLayout {
}
if (data.lastGhostVisible || myTabs.isGhostsAlwaysVisible()) {
- data.lastGhost = getStrategy().getLayoutRect(data, data.position, JBTabsImpl.getGhostTabLength());
+ data.lastGhost = getStrategy().getLayoutRect(data, data.position, myTabs.getGhostTabLength());
myTabs.layout(myRightGhost, data.lastGhost);
}
}
@@ -366,7 +367,7 @@ public class SingleRowLayout extends TabLayout {
protected int getRequiredLength(TabInfo eachInfo) {
TabLabel label = myTabs.myInfo2Label.get(eachInfo);
return getStrategy().getLengthIncrement(label != null ? label.getPreferredSize() : new Dimension())
- + (myTabs.isEditorTabs() ? JBTabsImpl.getInterTabSpaceLength() : 0);
+ + (myTabs.isEditorTabs() ? myTabs.getInterTabSpaceLength() : 0);
}
@@ -417,13 +418,13 @@ public class SingleRowLayout extends TabLayout {
if (!data.firstGhostVisible && isFirstSide) {
data.firstGhostVisible = !myTabs.isEditorTabs();
if (!myTabs.isGhostsAlwaysVisible() && !myTabs.isEditorTabs()) {
- data.toFitLength -= JBTabsImpl.getGhostTabLength();
+ data.toFitLength -= myTabs.getGhostTabLength();
}
}
else if (!data.lastGhostVisible && !isFirstSide) {
data.lastGhostVisible = !myTabs.isEditorTabs();
if (!myTabs.isGhostsAlwaysVisible() && !myTabs.isEditorTabs()) {
- data.toFitLength -= JBTabsImpl.getGhostTabLength();
+ data.toFitLength -= myTabs.getGhostTabLength();
}
}
}
diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java
index 1326531e2465..9b313783dea7 100644
--- a/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java
+++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -56,8 +56,8 @@ public class TableLayout extends TabLayout {
eachX = data.toFitRec.x;
}
myTabs.layout(eachLabel, eachX, 0, size.width, 1);
- eachX += size.width + JBTabsImpl.getInterTabSpaceLength();
- data.requiredWidth += size.width + JBTabsImpl.getInterTabSpaceLength();
+ eachX += size.width + myTabs.getInterTabSpaceLength();
+ data.requiredWidth += size.width + myTabs.getInterTabSpaceLength();
}
int selectedRow = -1;
@@ -84,7 +84,7 @@ public class TableLayout extends TabLayout {
if (myTabs.getSelectedInfo() == eachInfo) {
selectedRow = eachRow;
}
- eachX += size.width + JBTabsImpl.getInterTabSpaceLength();
+ eachX += size.width + myTabs.getInterTabSpaceLength();
}
else {
eachTableRow = new TableRow(data);
@@ -161,9 +161,9 @@ public class TableLayout extends TabLayout {
label.setAlignmentToCenter(deltaToFit > 0);
boolean lastCell = i == eachRow.myColumns.size() - 1;
- eachX += width + (lastCell ? 0 : JBTabsImpl.getInterTabSpaceLength());
+ eachX += width + (lastCell ? 0 : myTabs.getInterTabSpaceLength());
}
- eachY += myTabs.myHeaderFitSize.height - 1 + JBTabsImpl.getInterTabSpaceLength() - (row < data.table.size() - 1 ? tabUnderlineFix : 0);
+ eachY += myTabs.myHeaderFitSize.height - 1 + myTabs.getInterTabSpaceLength() - (row < data.table.size() - 1 ? tabUnderlineFix : 0);
row++;
}
diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
index 0975876055b2..c8c50bc94680 100644
--- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
+++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
@@ -283,7 +283,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
if (myBusyIcon != null) {
if (myBusy) {
- if (hasFocus()) {
+ if (shouldShowBusyIconIfNeeded()) {
myBusyIcon.resume();
myBusyIcon.setToolTipText("Update is in progress. Click to cancel");
}
@@ -305,6 +305,11 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
}
}
+ protected boolean shouldShowBusyIconIfNeeded() {
+ // http://youtrack.jetbrains.com/issue/IDEA-101422 "Rotating wait symbol in Project list whenever typing"
+ return hasFocus();
+ }
+
protected boolean paintNodes() {
return false;
}
@@ -429,7 +434,6 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
}
final Method method = ReflectionUtil.getDeclaredMethod(aClass, "isLocationInExpandControl", TreePath.class, int.class, int.class);
if (method != null) {
- method.setAccessible(true);
return (Boolean)method.invoke(ui, path, x, y);
}
}
diff --git a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java
index 0bcb416c7334..d51891a8ffe4 100644
--- a/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java
+++ b/platform/platform-api/src/com/intellij/util/net/HttpConfigurable.java
@@ -65,7 +65,7 @@ import java.util.*;
)
public class HttpConfigurable implements PersistentStateComponent<HttpConfigurable>, ApplicationComponent,
ExportableApplicationComponent {
- public static final int CONNECTION_TIMEOUT = SystemProperties.getIntProperty("connection.timeout", 10000);
+ public static final int CONNECTION_TIMEOUT = SystemProperties.getIntProperty("idea.connection.timeout", 10000);
private static final Logger LOG = Logger.getInstance("#com.intellij.util.net.HttpConfigurable");
public boolean PROXY_TYPE_IS_SOCKS = false;
public boolean USE_HTTP_PROXY = false;
@@ -350,8 +350,6 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
final URLConnection connection = openConnection(url);
try {
- connection.setConnectTimeout(CONNECTION_TIMEOUT);
- connection.setReadTimeout(CONNECTION_TIMEOUT);
connection.connect();
connection.getInputStream();
}
@@ -387,6 +385,10 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
throw ioe;
}
}
+ if (urlConnection != null) {
+ urlConnection.setReadTimeout(CONNECTION_TIMEOUT);
+ urlConnection.setConnectTimeout(CONNECTION_TIMEOUT);
+ }
return urlConnection;
}
diff --git a/platform/platform-api/src/com/intellij/util/ui/AsyncProcessIcon.java b/platform/platform-api/src/com/intellij/util/ui/AsyncProcessIcon.java
index 3c3b42721b58..3d467232b3e3 100644
--- a/platform/platform-api/src/com/intellij/util/ui/AsyncProcessIcon.java
+++ b/platform/platform-api/src/com/intellij/util/ui/AsyncProcessIcon.java
@@ -71,7 +71,7 @@ public class AsyncProcessIcon extends AnimatedIcon {
return icons;
}
- public void updateLocation(JComponent container) {
+ public void updateLocation(final JComponent container) {
final Rectangle rec = container.getVisibleRect();
final Dimension iconSize = getPreferredSize();
@@ -79,7 +79,14 @@ public class AsyncProcessIcon extends AnimatedIcon {
final Rectangle newBounds = new Rectangle(rec.x + rec.width - iconSize.width, rec.y, iconSize.width, iconSize.height);
if (!newBounds.equals(getBounds())) {
setBounds(newBounds);
- container.repaint();
+ // painting problems with scrollpane
+ // repaint shouldn't be called from paint method
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ container.repaint();
+ }
+ });
}
}
diff --git a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java
index 57f9cfca8a54..d73e21e8dc3a 100644
--- a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java
+++ b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java
@@ -23,6 +23,7 @@ import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.ui.LightColors;
import com.intellij.ui.components.JBScrollPane;
+import com.intellij.util.ReflectionUtil;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@@ -316,28 +317,21 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
resetMacScrollbarFadeout();
}
+ private static final Method setValueFrom = ReflectionUtil.getDeclaredMethod(TrackListener.class, "setValueFrom", MouseEvent.class);
+ static {
+ LOG.assertTrue(setValueFrom != null, "Cannot get TrackListener.setValueFrom method");
+ }
+
@Override
protected TrackListener createTrackListener() {
return new TrackListener() {
- private Method mySetValueFrom;
-
- {
- try {
- mySetValueFrom = TrackListener.class.getDeclaredMethod("setValueFrom", MouseEvent.class);
- mySetValueFrom.setAccessible(true);
- }
- catch (Exception e) {
- LOG.error("Cannot get TrackListener.setValueFrom method", e);
- }
- }
-
@Override
public void mousePressed(MouseEvent e) {
if (scrollbar.isEnabled()
&& SwingUtilities.isLeftMouseButton(e)
&& !getThumbBounds().contains(e.getPoint())
&& NSScrollerHelper.getClickBehavior() == NSScrollerHelper.ClickBehavior.JumpToSpot
- && mySetValueFrom != null) {
+ && setValueFrom != null) {
switch (scrollbar.getOrientation()) {
case Adjustable.VERTICAL:
@@ -349,7 +343,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
}
isDragging = true;
try {
- mySetValueFrom.invoke(this, e);
+ setValueFrom.invoke(this, e);
}
catch (Exception ex) {
LOG.error(ex);
diff --git a/platform/platform-api/src/com/intellij/util/ui/JTableCellEditorHelper.java b/platform/platform-api/src/com/intellij/util/ui/JTableCellEditorHelper.java
deleted file mode 100644
index 733fec87e0b6..000000000000
--- a/platform/platform-api/src/com/intellij/util/ui/JTableCellEditorHelper.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2000-2011 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.util.ui;
-
-import com.intellij.ide.DataManager;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.editor.Editor;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.KeyEvent;
-import java.util.EventObject;
-
-/**
- * @author Konstantin Bulenkov
- */
-public class JTableCellEditorHelper {
- private JTableCellEditorHelper() {}
-
- public static void typeAhead(final JTable table, final EventObject e, final int row, final int column) {
- if (e instanceof KeyEvent) {
- final Runnable r = new Runnable() {
- @Override
- public void run() {
- if (table.getEditingColumn() != column && table.getEditingRow() != row) return;
-
- Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
- if (focusOwner == null || !SwingUtilities.isDescendingFrom(focusOwner, table)) return;
-
- KeyEvent keyEvent = (KeyEvent)e;
- if (Character.isDefined(keyEvent.getKeyChar())) {
- try {
- selectAll(focusOwner);
-
- Robot r = new Robot();
- r.keyPress(keyEvent.getKeyCode());
- r.keyRelease(keyEvent.getKeyCode());
- }
- catch (AWTException e1) {
- return;
- }
- } else {
- selectAll(focusOwner);
- }
- }
- };
-
- SwingUtilities.invokeLater(r);
- }
- }
-
- private static void selectAll(Component component) {
- if (component instanceof TextComponent) {
- ((TextComponent)component).selectAll();
- } else {
- Editor editor = CommonDataKeys.EDITOR.getData(DataManager.getInstance().getDataContext(component));
- if (editor != null) {
- editor.getSelectionModel().setSelection(0, editor.getDocument().getTextLength());
- }
- }
- }
-}
diff --git a/platform/platform-impl/src/com/intellij/errorreport/itn/ITNProxy.java b/platform/platform-impl/src/com/intellij/errorreport/itn/ITNProxy.java
index 142b3924f96a..ec112437520b 100644
--- a/platform/platform-impl/src/com/intellij/errorreport/itn/ITNProxy.java
+++ b/platform/platform-impl/src/com/intellij/errorreport/itn/ITNProxy.java
@@ -181,8 +181,6 @@ public class ITNProxy {
private static HttpURLConnection post(URL url, byte[] bytes) throws IOException {
HttpURLConnection connection = (HttpURLConnection)HttpConfigurable.getInstance().openConnection(url.toString());
- connection.setReadTimeout(10 * 1000);
- connection.setConnectTimeout(10 * 1000);
connection.setRequestMethod(HTTP_POST);
connection.setDoInput(true);
connection.setDoOutput(true);
diff --git a/platform/platform-impl/src/com/intellij/help/impl/HelpManagerImpl.java b/platform/platform-impl/src/com/intellij/help/impl/HelpManagerImpl.java
index ac197b192284..340fbb9ae186 100644
--- a/platform/platform-impl/src/com/intellij/help/impl/HelpManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/help/impl/HelpManagerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -49,18 +49,17 @@ public class HelpManagerImpl extends HelpManager {
private Object myFXHelpBrowser = null;
public void invokeHelp(@Nullable String id) {
-
if (myHelpSet == null) {
myHelpSet = createHelpSet();
}
- if (SystemInfo.isJavaVersionAtLeast("1.7.0.40") && Registry.is("ide.help.fxbrowser")) {
- showHelpInFXBrowser(id);
+ if (MacHelpUtil.isApplicable() && MacHelpUtil.invokeHelp(id)) {
return;
}
- if (MacHelpUtil.isApplicable()) {
- if (MacHelpUtil.invokeHelp(id)) return;
+ if (SystemInfo.isJavaVersionAtLeast("1.7.0.40") && Registry.is("ide.help.fxbrowser")) {
+ showHelpInFXBrowser(id);
+ return;
}
if (myHelpSet == null) {
diff --git a/platform/platform-impl/src/com/intellij/help/impl/MacHelpUtil.java b/platform/platform-impl/src/com/intellij/help/impl/MacHelpUtil.java
index a73295c90f74..27fd6f52e4a6 100644
--- a/platform/platform-impl/src/com/intellij/help/impl/MacHelpUtil.java
+++ b/platform/platform-impl/src/com/intellij/help/impl/MacHelpUtil.java
@@ -28,20 +28,20 @@ import org.jetbrains.annotations.Nullable;
*/
public class MacHelpUtil {
static boolean invokeHelp(@NonNls @Nullable String id) {
- id = id == null || "top".equals(id) ? "startpage" : id;
+ if (id == null || "top".equals(id)) id = "startpage";
- final ID mainBundle = Foundation.invoke("NSBundle", "mainBundle");
- final ID helpBundle = Foundation.invoke(mainBundle, "objectForInfoDictionaryKey:", Foundation.nsString("CFBundleHelpBookName"));
+ ID mainBundle = Foundation.invoke("NSBundle", "mainBundle");
+ ID helpBundle = Foundation.invoke(mainBundle, "objectForInfoDictionaryKey:", Foundation.nsString("CFBundleHelpBookName"));
if (helpBundle.equals(ID.NIL)) {
return false;
}
- final ID helpManager = Foundation.invoke("NSHelpManager", "sharedHelpManager");
+
+ ID helpManager = Foundation.invoke("NSHelpManager", "sharedHelpManager");
Foundation.invoke(helpManager, "openHelpAnchor:inBook:", Foundation.nsString(id), helpBundle);
return true;
}
static boolean isApplicable() {
- return SystemInfo.isMac && Registry.is("ide.mac.show.native.help") && !PlatformUtils.isCidr() && !PlatformUtils
- .isIdeaCommunity();
+ return SystemInfo.isMac && Registry.is("ide.mac.show.native.help") && !PlatformUtils.isCidr() && !PlatformUtils.isIdeaCommunity();
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java
index c8699c083ef4..a7d07c9fa1e8 100644
--- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java
+++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java
@@ -590,7 +590,6 @@ public class IdeEventQueue extends EventQueue {
final Method setActive = ReflectionUtil.findMethod(ReflectionUtil.getClassDeclaredMethods(KeyboardFocusManager.class, false), resetMethod, Window.class);
if (setActive != null) {
try {
- setActive.setAccessible(true);
setActive.invoke(mgr, (Window)showingWindow);
}
catch (Exception exc) {
@@ -630,7 +629,6 @@ public class IdeEventQueue extends EventQueue {
if (showingWindow == null) {
Method getNativeFocusOwner = ReflectionUtil.getDeclaredMethod(KeyboardFocusManager.class, "getNativeFocusOwner");
if (getNativeFocusOwner != null) {
- getNativeFocusOwner.setAccessible(true);
try {
Object owner = getNativeFocusOwner.invoke(mgr);
if (owner instanceof Component) {
@@ -744,10 +742,7 @@ public class IdeEventQueue extends EventQueue {
&& !(e instanceof KeyEvent && ((KeyEvent)e).getKeyCode() == KeyEvent.VK_ALT)) {
try {
if (stickyAltField == null) {
- stickyAltField = Class
- .forName("com.sun.java.swing.plaf.windows.WindowsRootPaneUI$AltProcessor")
- .getDeclaredField("menuCanceledOnPress");
- stickyAltField.setAccessible(true);
+ stickyAltField = ReflectionUtil.getDeclaredField(Class.forName("com.sun.java.swing.plaf.windows.WindowsRootPaneUI$AltProcessor"), "menuCanceledOnPress");
}
stickyAltField.set(null, true);
}
diff --git a/platform/platform-impl/src/com/intellij/ide/SwingCleanuper.java b/platform/platform-impl/src/com/intellij/ide/SwingCleanuper.java
index dd969f32ac04..baefe3db672d 100644
--- a/platform/platform-impl/src/com/intellij/ide/SwingCleanuper.java
+++ b/platform/platform-impl/src/com/intellij/ide/SwingCleanuper.java
@@ -139,8 +139,7 @@ public final class SwingCleanuper implements ApplicationComponent{
focusManager.setGlobalCurrentFocusCycleRoot(null); //Remove focus leaks
try {
- final Method m = KeyboardFocusManager.class.getDeclaredMethod("setGlobalFocusOwner", Component.class);
- m.setAccessible(true);
+ final Method m = ReflectionUtil.getDeclaredMethod(KeyboardFocusManager.class,"setGlobalFocusOwner", Component.class);
m.invoke(focusManager, new Object[]{null});
}
catch (Exception e) {
@@ -169,7 +168,6 @@ public final class SwingCleanuper implements ApplicationComponent{
if (SystemInfo.isMac) {
try {
field = ReflectionUtil.findField(AccessibleContext.class, Object.class, "nativeAXResource");
- field.setAccessible(true);
}
catch (NoSuchFieldException ignored) {
}
@@ -228,7 +226,6 @@ public final class SwingCleanuper implements ApplicationComponent{
Object resource = myNativeAXResourceField.get(ac);
if (resource != null && resource.getClass().getName().equals("apple.awt.CAccessible")) {
Field accessible = ReflectionUtil.findField(resource.getClass(), Accessible.class, "accessible");
- accessible.setAccessible(true);
accessible.set(resource, null);
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java b/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java
index b76839fbffe4..411f2d9d93bb 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/CreateLauncherScriptAction.java
@@ -45,6 +45,7 @@ import static java.util.Arrays.asList;
*/
public class CreateLauncherScriptAction extends DumbAwareAction {
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.CreateLauncherScriptAction");
+ private static final String CONTENTS = "/Contents";
public static boolean isAvailable() {
return SystemInfo.isUnix;
@@ -137,6 +138,8 @@ public class CreateLauncherScriptAction extends DumbAwareAction {
// for Macs just use "*.app"
final String productName = ApplicationNamesInfo.getInstance().getProductName().toLowerCase();
runPath += "/bin/" + productName + ".sh";
+ } else if (runPath.endsWith(CONTENTS)) {
+ runPath = runPath.substring(0, runPath.length() - CONTENTS.length());
}
String launcherContents = ExecUtil.loadTemplate(CreateLauncherScriptAction.class.getClassLoader(), "launcher.py",
newHashMap(asList("$CONFIG_PATH$", "$RUN_PATH$"),
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java
index c7c729c89424..786a5825e783 100644
--- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java
+++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java
@@ -50,7 +50,7 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt
public final AtomicBoolean myCanceled = new AtomicBoolean(false);
- public CustomizeFeaturedPluginsStepPanel() throws OfflineException {
+ public CustomizeFeaturedPluginsStepPanel(PluginGroups pluginGroups) throws OfflineException {
setLayout(new GridLayout(1, 1));
JPanel gridPanel = new JPanel(new GridLayout(0, 3));
JBScrollPane scrollPane =
@@ -58,9 +58,9 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt
scrollPane.getVerticalScrollBar().setUnitIncrement(10);
scrollPane.setBorder(null);
- Map<String, String> config = PluginGroups.getInstance().getFeaturedPlugins();
+ Map<String, String> config = pluginGroups.getFeaturedPlugins();
boolean isEmptyOrOffline = true;
- List<IdeaPluginDescriptor> pluginsFromRepository = PluginGroups.getInstance().getPluginsFromRepository();
+ List<IdeaPluginDescriptor> pluginsFromRepository = pluginGroups.getPluginsFromRepository();
for (Map.Entry<String, String> entry : config.entrySet()) {
JPanel groupPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
@@ -263,5 +263,5 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt
return "New plugins can also be downloaded in " + CommonBundle.settingsTitle() + " | Plugins";
}
- static class OfflineException extends Exception {};
+ public static class OfflineException extends Exception {};
}
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java
index 1b0644a3a20f..be37f9d9d7f6 100644
--- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java
+++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardDialog.java
@@ -16,6 +16,7 @@
package com.intellij.ide.customize;
import com.intellij.ide.startup.StartupActionScriptManager;
+import com.intellij.idea.Main;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.SystemInfo;
@@ -62,6 +63,26 @@ public class CustomizeIDEWizardDialog extends DialogWrapper implements ActionLis
System.setProperty(StartupActionScriptManager.STARTUP_WIZARD_MODE, "true");
}
+ public static void showCustomSteps(String stepsProviderName) {
+ final CustomizeIDEWizardStepsProvider provider;
+
+ try {
+ Class<CustomizeIDEWizardStepsProvider> providerClass = (Class<CustomizeIDEWizardStepsProvider>)Class.forName(stepsProviderName);
+ provider = providerClass.newInstance();
+ }
+ catch (Throwable e) {
+ Main.showMessage("Start Failed", e);
+ return;
+ }
+
+ new CustomizeIDEWizardDialog() {
+ @Override
+ protected void initSteps() {
+ provider.initSteps(this, mySteps);
+ }
+ }.show();
+ }
+
@Override
protected void dispose() {
System.clearProperty(StartupActionScriptManager.STARTUP_WIZARD_MODE);
@@ -73,9 +94,11 @@ public class CustomizeIDEWizardDialog extends DialogWrapper implements ActionLis
if (SystemInfo.isMac) {
mySteps.add(new CustomizeKeyboardSchemeStepPanel());
}
- mySteps.add(new CustomizePluginsStepPanel());
+
+ PluginGroups pluginGroups = new PluginGroups();
+ mySteps.add(new CustomizePluginsStepPanel(pluginGroups));
try {
- mySteps.add(new CustomizeFeaturedPluginsStepPanel());
+ mySteps.add(new CustomizeFeaturedPluginsStepPanel(pluginGroups));
}
catch (CustomizeFeaturedPluginsStepPanel.OfflineException e) {
//skip featured step if we're offline
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardStepsProvider.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardStepsProvider.java
new file mode 100644
index 000000000000..ceea34db05fd
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeIDEWizardStepsProvider.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2014 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.customize;
+
+import java.util.List;
+
+/**
+ * @author Alexander Lobas
+ */
+public interface CustomizeIDEWizardStepsProvider {
+ void initSteps(CustomizeIDEWizardDialog wizardDialog, List<AbstractCustomizeWizardStep> steps);
+} \ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeKeyboardSchemeStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeKeyboardSchemeStepPanel.java
index 2b35ebe7a6fc..53b215516c09 100644
--- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeKeyboardSchemeStepPanel.java
+++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeKeyboardSchemeStepPanel.java
@@ -94,6 +94,6 @@ public class CustomizeKeyboardSchemeStepPanel extends AbstractCustomizeWizardSte
@Override
public String getHTMLFooter() {
- return "Keymap scheme can be later changed in " + CommonBundle.settingsTitle() + " | Keymap";
+ return "Keymap scheme can be changed later in " + CommonBundle.settingsTitle() + " | Keymap";
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java
index 9bd14b69cb47..8924c09780dd 100644
--- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java
+++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizePluginsStepPanel.java
@@ -19,7 +19,6 @@ import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.VerticalFlowLayout;
-import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.Pair;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.JBCardLayout;
@@ -52,9 +51,11 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
private static final String CUSTOMIZE_COMMAND = "Customize";
private final JBCardLayout myCardLayout;
private final IdSetPanel myCustomizePanel;
+ private final PluginGroups myPluginGroups;
- public CustomizePluginsStepPanel() {
+ public CustomizePluginsStepPanel(PluginGroups pluginGroups) {
+ myPluginGroups = pluginGroups;
myCardLayout = new JBCardLayout();
setLayout(myCardLayout);
JPanel gridPanel = new JPanel(new GridLayout(0, COLS));
@@ -66,8 +67,8 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
add(scrollPane, MAIN);
add(myCustomizePanel, CUSTOMIZE);
- Map<String, Pair<String, List<String>>> groups = PluginGroups.getInstance().getTree();
- for (final Map.Entry<String, Pair<String, List<String>>> entry : groups.entrySet()) {
+ Map<String, Pair<Icon, List<String>>> groups = pluginGroups.getTree();
+ for (final Map.Entry<String, Pair<Icon, List<String>>> entry : groups.entrySet()) {
final String group = entry.getKey();
if (PluginGroups.CORE.equals(group)) continue;
@@ -89,10 +90,10 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
return isGroupEnabled(group);
}
};
- groupPanel.add(new JLabel(IconLoader.getIcon(entry.getValue().getFirst())), gbc);
+ groupPanel.add(new JLabel(entry.getValue().getFirst()), gbc);
//gbc.insets.bottom = 5;
groupPanel.add(titleLabel, gbc);
- JLabel descriptionLabel = new JLabel(PluginGroups.getInstance().getDescription(group), SwingConstants.CENTER) {
+ JLabel descriptionLabel = new JLabel(pluginGroups.getDescription(group), SwingConstants.CENTER) {
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
@@ -116,7 +117,7 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
gbc.weighty = 0;
JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 5));
buttonsPanel.setOpaque(false);
- if (PluginGroups.getInstance().getSets(group).size() == 1) {
+ if (pluginGroups.getSets(group).size() == 1) {
buttonsPanel.add(createLink(SWITCH_COMMAND + ":" + group, getGroupSwitchTextProvider(group)));
}
else {
@@ -152,11 +153,11 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
if (SWITCH_COMMAND.equals(command)) {
boolean enabled = isGroupEnabled(group);
- List<IdSet> sets = PluginGroups.getInstance().getSets(group);
+ List<IdSet> sets = myPluginGroups.getSets(group);
for (IdSet idSet : sets) {
String[] ids = idSet.getIds();
for (String id : ids) {
- PluginGroups.getInstance().setPluginEnabledWithDependencies(id, !enabled);
+ myPluginGroups.setPluginEnabledWithDependencies(id, !enabled);
}
}
repaint();
@@ -190,17 +191,17 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
@Override
public String getText() {
return (isGroupEnabled(group) ? "Disable" : "Enable") +
- (PluginGroups.getInstance().getSets(group).size() > 1 ? " All" : "");
+ (myPluginGroups.getSets(group).size() > 1 ? " All" : "");
}
};
}
private boolean isGroupEnabled(String group) {
- List<IdSet> sets = PluginGroups.getInstance().getSets(group);
+ List<IdSet> sets = myPluginGroups.getSets(group);
for (IdSet idSet : sets) {
String[] ids = idSet.getIds();
for (String id : ids) {
- if (PluginGroups.getInstance().isPluginEnabled(id)) return true;
+ if (myPluginGroups.isPluginEnabled(id)) return true;
}
}
return false;
@@ -229,7 +230,7 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
@Override
public boolean beforeOkAction() {
try {
- PluginManager.saveDisabledPlugins(PluginGroups.getInstance().getDisabledPluginIds(), false);
+ PluginManager.saveDisabledPlugins(myPluginGroups.getDisabledPluginIds(), false);
}
catch (IOException ignored) {
}
@@ -269,9 +270,9 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
public void linkSelected(LinkLabel aSource, String command) {
if (myGroup == null) return;
boolean enable = "enable".equals(command);
- List<IdSet> idSets = PluginGroups.getInstance().getSets(myGroup);
+ List<IdSet> idSets = myPluginGroups.getSets(myGroup);
for (IdSet set : idSets) {
- PluginGroups.getInstance().setIdSetEnabled(set, enable);
+ myPluginGroups.setIdSetEnabled(set, enable);
}
CustomizePluginsStepPanel.this.repaint();
}
@@ -280,19 +281,19 @@ public class CustomizePluginsStepPanel extends AbstractCustomizeWizardStep imple
myGroup = group;
myTitleLabel.setText("<html><body><h2 style=\"text-align:left;\">" + group + "</h2></body></html>");
myContentPanel.removeAll();
- List<IdSet> idSets = PluginGroups.getInstance().getSets(group);
+ List<IdSet> idSets = myPluginGroups.getSets(group);
for (final IdSet set : idSets) {
- final JCheckBox checkBox = new JCheckBox(set.getTitle(), PluginGroups.getInstance().isIdSetAllEnabled(set));
+ final JCheckBox checkBox = new JCheckBox(set.getTitle(), myPluginGroups.isIdSetAllEnabled(set));
checkBox.setModel(new JToggleButton.ToggleButtonModel() {
@Override
public boolean isSelected() {
- return PluginGroups.getInstance().isIdSetAllEnabled(set);
+ return myPluginGroups.isIdSetAllEnabled(set);
}
});
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- PluginGroups.getInstance().setIdSetEnabled(set, !checkBox.isSelected());
+ myPluginGroups.setIdSetEnabled(set, !checkBox.isSelected());
CustomizePluginsStepPanel.this.repaint();
}
});
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeUIThemeStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeUIThemeStepPanel.java
index 1af2fb883efb..b369e49f8bca 100644
--- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeUIThemeStepPanel.java
+++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeUIThemeStepPanel.java
@@ -34,12 +34,12 @@ import java.util.LinkedHashMap;
import java.util.Map;
public class CustomizeUIThemeStepPanel extends AbstractCustomizeWizardStep {
+ protected static final String DEFAULT = "Default";
+ protected static final String DARCULA = "Darcula";
+ protected static final String INTELLIJ = "IntelliJ";
+ protected static final String ALLOY = "Alloy. IDEA Theme";
+ protected static final String GTK = "GTK+";
- private static final String DEFAULT = "Default";
- private static final String DARCULA = "Darcula";
- private static final String INTELLIJ = "IntelliJ";
- private static final String ALLOY = "Alloy. IDEA Theme";
- private static final String GTK = "GTK+";
private boolean myInitial = true;
private boolean myColumnMode;
private JLabel myPreviewLabel;
@@ -49,24 +49,8 @@ public class CustomizeUIThemeStepPanel extends AbstractCustomizeWizardStep {
setLayout(new BorderLayout(10, 10));
IconLoader.activate();
- if (SystemInfo.isMac) {
- myLafNames.put(DEFAULT, IconLoader.getIcon("/lafs/OSXAqua.png"));
- myLafNames.put(DARCULA, IconLoader.getIcon("/lafs/OSXDarcula.png"));
- }
- else if (SystemInfo.isWindows) {
- //if (PlatformUtils.isIdeaCommunity()) {
- myLafNames.put(INTELLIJ, IconLoader.getIcon("/lafs/WindowsIntelliJ.png"));
- //}
- //else {
- // myLafNames.put(ALLOY, IconLoader.getIcon("/lafs/WindowsAlloy.png"));
- //}
- myLafNames.put(DARCULA, IconLoader.getIcon("/lafs/WindowsDarcula.png"));
- }
- else {
- myLafNames.put(INTELLIJ, IconLoader.getIcon("/lafs/LinuxIntelliJ.png"));
- myLafNames.put(DARCULA, IconLoader.getIcon("/lafs/LinuxDarcula.png"));
- myLafNames.put(GTK, IconLoader.getIcon("/lafs/LinuxGTK.png"));
- }
+ initLafs();
+
myColumnMode = myLafNames.size() > 2;
JPanel buttonsPanel = new JPanel(new GridLayout(myColumnMode ? myLafNames.size() : 1, myColumnMode ? 1 : myLafNames.size(), 5, 5));
ButtonGroup group = new ButtonGroup();
@@ -111,6 +95,31 @@ public class CustomizeUIThemeStepPanel extends AbstractCustomizeWizardStep {
myInitial = false;
}
+ protected void initLafs() {
+ if (SystemInfo.isMac) {
+ addLaf(DEFAULT, "/lafs/OSXAqua.png");
+ addLaf(DARCULA, "/lafs/OSXDarcula.png");
+ }
+ else if (SystemInfo.isWindows) {
+ //if (PlatformUtils.isIdeaCommunity()) {
+ addLaf(INTELLIJ,"/lafs/WindowsIntelliJ.png");
+ //}
+ //else {
+ // addLaf(ALLOY, "/lafs/WindowsAlloy.png");
+ //}
+ addLaf(DARCULA, "/lafs/WindowsDarcula.png");
+ }
+ else {
+ addLaf(INTELLIJ, "/lafs/LinuxIntelliJ.png");
+ addLaf(DARCULA, "/lafs/LinuxDarcula.png");
+ addLaf(GTK, "/lafs/LinuxGTK.png");
+ }
+ }
+
+ protected final void addLaf(String name, String icon) {
+ myLafNames.put(name, IconLoader.getIcon(icon));
+ }
+
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
@@ -118,7 +127,6 @@ public class CustomizeUIThemeStepPanel extends AbstractCustomizeWizardStep {
return size;
}
-
@Override
public String getTitle() {
return "UI Themes";
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/IdSet.java b/platform/platform-impl/src/com/intellij/ide/customize/IdSet.java
index 47f8863b9ceb..fb406d21359a 100644
--- a/platform/platform-impl/src/com/intellij/ide/customize/IdSet.java
+++ b/platform/platform-impl/src/com/intellij/ide/customize/IdSet.java
@@ -28,7 +28,7 @@ class IdSet {
String myTitle;
String[] myIds;
- IdSet(String description) {
+ IdSet(final PluginGroups pluginGroups, String description) {
int i = description.indexOf(":");
if (i > 0) {
myTitle = description.substring(0, i);
@@ -38,7 +38,7 @@ class IdSet {
myIds = ContainerUtil.filter(myIds, new Condition<String>() {
@Override
public boolean value(String id) {
- return PluginGroups.getInstance().findPlugin(id) != null;
+ return pluginGroups.findPlugin(id) != null;
}
}).toArray(new String[]{});
@@ -47,7 +47,7 @@ class IdSet {
}
if (myTitle == null && myIds.length>0) {
//noinspection ConstantConditions
- myTitle = PluginGroups.getInstance().findPlugin(myIds[0]).getName();
+ myTitle = pluginGroups.findPlugin(myIds[0]).getName();
}
if (myTitle != null) {
for (String skipWord : BLACK_LIST) {
diff --git a/platform/platform-impl/src/com/intellij/ide/customize/PluginGroups.java b/platform/platform-impl/src/com/intellij/ide/customize/PluginGroups.java
index 930901d55105..b17805579869 100644
--- a/platform/platform-impl/src/com/intellij/ide/customize/PluginGroups.java
+++ b/platform/platform-impl/src/com/intellij/ide/customize/PluginGroups.java
@@ -16,7 +16,6 @@
package com.intellij.ide.customize;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
-import com.intellij.ide.plugins.PluginManager;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.plugins.RepositoryHelper;
import com.intellij.idea.StartupUtil;
@@ -27,19 +26,18 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
+import icons.PlatformImplIcons;
import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
import java.io.File;
import java.util.*;
-class PluginGroups {
+public class PluginGroups {
static final String CORE = "Core";
private static final int MAX_DESCR_LENGTH = 55;
-
- private static PluginGroups instance = null;
-
- final Map<String, Pair<String, List<String>>> myTree = new LinkedHashMap<String, Pair<String, List<String>>>();
+ final Map<String, Pair<Icon, List<String>>> myTree = new LinkedHashMap<String, Pair<Icon, List<String>>>();
final Map<String, String> myFeaturedPlugins = new LinkedHashMap<String, String>();
private final Map<String, List<IdSet>> myGroups = new LinkedHashMap<String, List<IdSet>>();
@@ -50,15 +48,7 @@ class PluginGroups {
private boolean myInitialized = false;
private Set<String> myFeaturedIds = new HashSet<String>();
-
- static synchronized PluginGroups getInstance() {
- if (instance == null) {
- instance = new PluginGroups();
- }
- return instance;
- }
-
- private PluginGroups() {
+ public PluginGroups() {
myAllPlugins = PluginManagerCore.loadDescriptors(null);
try {
myPluginsFromRepository.addAll(RepositoryHelper.loadPluginsFromRepository(null));
@@ -68,8 +58,12 @@ class PluginGroups {
}
PluginManagerCore.loadDisabledPlugins(new File(PathManager.getConfigPath()).getPath(), myDisabledPluginIds);
+ initGroups(myTree, myFeaturedPlugins);
+ }
- myTree.put(CORE, Pair.create((String)null, Arrays.asList(
+ protected void
+ initGroups(Map<String, Pair<Icon, List<String>>> tree, Map<String, String> featuredPlugins) {
+ tree.put(CORE, Pair.create((Icon)null, Arrays.asList(
"com.intellij.copyright",
"com.intellij.java-i18n",
"org.intellij.intelliLang",
@@ -78,7 +72,7 @@ class PluginGroups {
"Type Migration",
"ZKM"
)));
- myTree.put("Java Frameworks", Pair.create("/plugins/JavaFrameworks.png", Arrays.asList(
+ tree.put("Java Frameworks", Pair.create(PlatformImplIcons.JavaFrameworks, Arrays.asList(
"com.intellij.appengine",
"org.intellij.grails",
"com.intellij.gwt",
@@ -113,12 +107,12 @@ class PluginGroups {
"com.intellij.aspectj",
"Osmorc"
)));
- myTree.put("Build Tools", Pair.create("/plugins/BuildTools.png", Arrays.asList(
+ tree.put("Build Tools", Pair.create(PlatformImplIcons.BuildTools, Arrays.asList(
"AntSupport",
"Maven:org.jetbrains.idea.maven,org.jetbrains.idea.maven.ext",
"org.jetbrains.plugins.gradle"
)));
- myTree.put("Web Development", Pair.create("/plugins/WebDevelopment.png", Arrays.asList(
+ tree.put("Web Development", Pair.create(PlatformImplIcons.WebDevelopment, Arrays.asList(
"HTML:HtmlTools,QuirksMode,W3Validators",
"org.jetbrains.plugins.haml",
"com.jetbrains.plugins.jade",
@@ -132,24 +126,17 @@ class PluginGroups {
"com.intellij.plugins.html.instantEditing",
"com.jetbrains.restClient"
)));
- myTree.put("Version Controls", Pair.create("/plugins/VersionControls.png", Arrays.asList(
- "ClearcasePlugin",
- "CVS",
- "Git4Idea",
- "org.jetbrains.plugins.github",
- "hg4idea",
- "PerforceDirectPlugin",
- "Subversion",
- "TFS"
- )));
- myTree.put("Test Tools", Pair.create("/plugins/TestTools.png", Arrays.asList(
+
+ addVcsGroup(tree);
+
+ tree.put("Test Tools", Pair.create(PlatformImplIcons.TestTools, Arrays.asList(
"JUnit",
"TestNG-J",
"cucumber-java",
"cucumber",
"Coverage:Coverage,Emma"
)));
- myTree.put("Application Servers", Pair.create("/plugins/ApplicationServers.png", Arrays.asList(
+ tree.put("Application Servers", Pair.create(PlatformImplIcons.ApplicationServers, Arrays.asList(
"com.intellij.javaee.view",
"Geronimo",
"GlassFish",
@@ -162,7 +149,7 @@ class PluginGroups {
"com.intellij.dmserver",
"JSR45Plugin"
)));
- myTree.put("Clouds", Pair.create("/plugins/Clouds.png", Arrays.asList(
+ tree.put("Clouds", Pair.create(PlatformImplIcons.Clouds, Arrays.asList(
"CloudFoundry",
"CloudBees",
"Heroku",
@@ -170,16 +157,16 @@ class PluginGroups {
)));
//myTree.put("Groovy", Arrays.asList("org.intellij.grails"));
//TODO Scala -> Play 2.x (Play 2.0 Support)
- myTree.put("Swing", Pair.create("/plugins/Swing.png", Arrays.asList(
+ tree.put("Swing", Pair.create(PlatformImplIcons.Swing, Arrays.asList(
"com.intellij.uiDesigner"//TODO JavaFX?
)));
- myTree.put("Android", Pair.create("/plugins/Android.png", Arrays.asList(
+ tree.put("Android", Pair.create(PlatformImplIcons.Android, Arrays.asList(
"org.jetbrains.android",
"com.intellij.android-designer")));
- myTree.put("Database Tools", Pair.create("/plugins/DatabaseTools.png", Arrays.asList(
+ tree.put("Database Tools", Pair.create(PlatformImplIcons.DatabaseTools, Arrays.asList(
"com.intellij.database"
)));
- myTree.put("Other Tools", Pair.create("/plugins/OtherTools.png", Arrays.asList(
+ tree.put("Other Tools", Pair.create(PlatformImplIcons.OtherTools, Arrays.asList(
"ByteCodeViewer",
"com.intellij.dsm",
"org.jetbrains.idea.eclipse",
@@ -190,27 +177,63 @@ class PluginGroups {
"org.jetbrains.plugins.yaml",
"XSLT and XPath:XPathView,XSLT-Debugger"
)));
- myTree.put("Plugin Development", Pair.create("/plugins/PluginDevelopment.png", Arrays.asList("DevKit")));
+ tree.put("Plugin Development", Pair.create(PlatformImplIcons.PluginDevelopment, Arrays.asList("DevKit")));
+
+ featuredPlugins.put("Scala", "Custom Languages:Plugin for Scala language support:org.intellij.scala");
+ featuredPlugins.put("Live Edit Tool",
+ "Web Development:Provides live edit HTML/CSS/JavaScript:com.intellij.plugins.html.instantEditing");
+ addVimPlugin(featuredPlugins);
+ featuredPlugins.put("NodeJS", "JavaScript:Node.js integration:NodeJS");
+ featuredPlugins.put("Atlassian Connector",
+ "Tools Integration:Integration for Atlassian JIRA, Bamboo, Cricible, FishEye:atlassian-idea-plugin");
+ }
- myFeaturedPlugins.put("Scala", "Custom Languages:Plugin for Scala language support:org.intellij.scala");
- myFeaturedPlugins.put("Live Edit Tool", "Web Development:Provides live edit HTML/CSS/JavaScript:com.intellij.plugins.html.instantEditing");
- myFeaturedPlugins.put("IdeaVIM", "Editor:Vim emulation plug-in for IDEs based on the IntelliJ platform:IdeaVIM");
- myFeaturedPlugins.put("NodeJS", "JavaScript:Node.js integration:NodeJS");
- myFeaturedPlugins.put("Atlassian Connector", "Tools Integration:Integration for Atlassian JIRA, Bamboo, Cricible, FishEye:atlassian-idea-plugin");
+ protected static void addVcsGroup(Map<String, Pair<Icon, List<String>>> tree) {
+ tree.put("Version Controls", Pair.create(PlatformImplIcons.VersionControls, Arrays.asList(
+ "ClearcasePlugin",
+ "CVS",
+ "Git4Idea",
+ "org.jetbrains.plugins.github",
+ "hg4idea",
+ "PerforceDirectPlugin",
+ "Subversion",
+ "TFS"
+ )));
+ }
+ protected static void addVimPlugin(Map<String, String> featuredPlugins) {
+ featuredPlugins.put("IdeaVIM", "Editor:Vim emulation plug-in for IDEs based on the IntelliJ platform:IdeaVIM");
+ }
+
+ protected static void addLuaPlugin(Map<String, String> featuredPlugins) {
+ featuredPlugins.put("Lua", "Custom Languages:Lua language integration:Lua");
+ }
+
+ protected static void addMarkdownPlugin(Map<String, String> featuredPlugins) {
+ featuredPlugins.put("Markdown", "Custom Languages:Markdown language integration:net.nicoulaj.idea.markdown");
+ }
+
+ protected static void addConfigurationServerPlugin(Map<String, String> featuredPlugins) {
+ featuredPlugins.put("Configuration Server",
+ "Team Work:Supports sharing settings between installations of IntelliJ Platform based products used by the same developer on different computers:IdeaServerPlugin");
+ }
+
+ protected static void addTeamCityPlugin(Map<String, String> featuredPlugins) {
+ featuredPlugins.put("TeamCity Integration",
+ "Tools Integration:Integration with JetBrains TeamCity - innovative solution for continuous integration and build management:Jetbrains TeamCity Plugin");
}
private void initIfNeed() {
if (myInitialized) return;
myInitialized = true;
- for (Map.Entry<String, Pair<String, List<String>>> entry : myTree.entrySet()) {
+ for (Map.Entry<String, Pair<Icon, List<String>>> entry : myTree.entrySet()) {
final String group = entry.getKey();
if (CORE.equals(group)) continue;
List<IdSet> idSets = new ArrayList<IdSet>();
StringBuilder description = new StringBuilder();
for (String idDescription : entry.getValue().getSecond()) {
- IdSet idSet = new IdSet(idDescription);
+ IdSet idSet = new IdSet(this, idDescription);
String idSetTitle = idSet.getTitle();
if (idSetTitle == null) continue;
idSets.add(idSet);
@@ -230,7 +253,7 @@ class PluginGroups {
}
}
- Map<String, Pair<String, List<String>>> getTree() {
+ Map<String, Pair<Icon, List<String>>> getTree() {
initIfNeed();
return myTree;
}
@@ -302,7 +325,8 @@ class PluginGroups {
void setFeaturedPluginEnabled(String pluginId, boolean enabled) {
if (enabled) {
myFeaturedIds.add(pluginId);
- } else {
+ }
+ else {
myFeaturedIds.remove(pluginId);
}
StartupUtil.setFeaturedPluginsToInstall(myFeaturedIds);
diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/PasswordSafeException.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/PasswordSafeException.java
index 00b529933f68..20d7d5188efb 100644
--- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/PasswordSafeException.java
+++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/PasswordSafeException.java
@@ -19,22 +19,29 @@ package com.intellij.ide.passwordSafe;
* The exception that is thrown when password safe is not available (unable to ask for master password)
*/
public class PasswordSafeException extends Exception {
- /**
- * The constructor
- *
- * @param message the message
- * @param cause the cause
- */
+
+ private static final long MIN_INTERVAL = 1000L;
+
+ private long myTimeMillis = System.currentTimeMillis();
+
public PasswordSafeException(String message, Throwable cause) {
super(message, cause);
}
- /**
- * The constructor
- *
- * @param message the message
- */
public PasswordSafeException(String message) {
super(message);
}
+
+ public long getTimeMillis() {
+ return myTimeMillis;
+ }
+
+ public boolean justHappened() {
+ long timeMillis = System.currentTimeMillis();
+ if (timeMillis - myTimeMillis < MIN_INTERVAL) {
+ myTimeMillis = timeMillis;
+ return true;
+ }
+ return false;
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/BasePasswordSafeProvider.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/BasePasswordSafeProvider.java
index a0b001824d90..8bfa859d5ceb 100644
--- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/BasePasswordSafeProvider.java
+++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/BasePasswordSafeProvider.java
@@ -43,6 +43,7 @@ public abstract class BasePasswordSafeProvider extends PasswordSafeProvider {
* @throws PasswordSafeException in case of problems with access to the password database.
* @throws IllegalStateException if the method is called from the read action.
*/
+ @NotNull
protected abstract byte[] key(@Nullable Project project, @NotNull Class requestor) throws PasswordSafeException;
@Nullable
diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/EncryptionUtil.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/EncryptionUtil.java
index 01fef01cecb1..7bbb8bc80789 100644
--- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/EncryptionUtil.java
+++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/EncryptionUtil.java
@@ -15,6 +15,8 @@
*/
package com.intellij.ide.passwordSafe.impl.providers;
+import org.jetbrains.annotations.NotNull;
+
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
@@ -115,7 +117,7 @@ public class EncryptionUtil {
* @param rawKey the raw key to encrypt
* @return the encrypted key
*/
- public static byte[] encryptKey(byte[] password, byte[] rawKey) {
+ public static byte[] encryptKey(@NotNull byte[] password, byte[] rawKey) {
try {
Cipher c = Cipher.getInstance(ENCRYPT_KEY_ALGORITHM);
c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(password, SECRET_KEY_ALGORITHM), CBC_SALT_KEY);
@@ -130,12 +132,12 @@ public class EncryptionUtil {
* Create encrypted db key
*
* @param password the password to protect the key
- * @param requester the requester for the key
- * @param key the key within requester
+ * @param requestor the requestor for the key
+ * @param key the key within requestor
* @return the key to use in the database
*/
- public static byte[] dbKey(byte[] password, Class requester, String key) {
- return encryptKey(password, rawKey(requester, key));
+ public static byte[] dbKey(@NotNull byte[] password, Class requestor, String key) {
+ return encryptKey(password, rawKey(requestor, key));
}
diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java
index 840159270a8d..6b0b9814698b 100644
--- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java
+++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafe.java
@@ -22,12 +22,14 @@ import com.intellij.ide.passwordSafe.impl.providers.BasePasswordSafeProvider;
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper;
import com.intellij.ide.passwordSafe.impl.providers.EncryptionUtil;
import com.intellij.ide.passwordSafe.impl.providers.masterKey.windows.WindowsCryptUtils;
-import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
+import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
@@ -36,7 +38,6 @@ import org.jetbrains.annotations.Nullable;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
/**
* The password safe that stores information in configuration file encrypted by master password
@@ -44,13 +45,11 @@ import java.util.concurrent.atomic.AtomicReference;
public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
private static final String TEST_PASSWORD_KEY = "TEST_PASSWORD:";
private static final String TEST_PASSWORD_VALUE = "test password";
- final PasswordDatabase database;
- /**
- * The key to use to encrypt data
- */
- private transient final PasswordSafeTimed<AtomicReference<byte[]>> key = new PasswordSafeTimed<AtomicReference<byte[]>>() {
- protected AtomicReference<byte[]> compute() {
- return new AtomicReference<byte[]>();
+
+ private final PasswordDatabase myDatabase;
+ private transient final PasswordSafeTimed<Ref<Object>> myKey = new PasswordSafeTimed<Ref<Object>>() {
+ protected Ref<Object> compute() {
+ return Ref.create();
}
@Override
@@ -60,11 +59,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
};
public MasterKeyPasswordSafe(PasswordDatabase database) {
- this.database = database;
- }
-
- protected boolean isTestMode() {
- return false;
+ this.myDatabase = database;
}
/**
@@ -74,15 +69,15 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
* @param encrypt if the password should be encrypted an stored is master database
*/
void resetMasterPassword(String password, boolean encrypt) {
- key.get().set(EncryptionUtil.genPasswordKey(password));
- database.clear();
+ myKey.get().set(EncryptionUtil.genPasswordKey(password));
+ myDatabase.clear();
try {
storePassword(null, MasterKeyPasswordSafe.class, testKey(password), TEST_PASSWORD_VALUE);
if (encrypt) {
- database.setPasswordInfo(encryptPassword(password));
+ myDatabase.setPasswordInfo(encryptPassword(password));
}
else {
- database.setPasswordInfo(ArrayUtil.EMPTY_BYTE_ARRAY);
+ myDatabase.setPasswordInfo(ArrayUtil.EMPTY_BYTE_ARRAY);
}
}
catch (PasswordSafeException e) {
@@ -97,8 +92,8 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
* @return true, if password is a correct one
*/
boolean setMasterPassword(String password) {
- byte[] savedKey = key.get().get();
- key.get().set(EncryptionUtil.genPasswordKey(password));
+ Object savedKey = myKey.get().get();
+ myKey.get().set(EncryptionUtil.genPasswordKey(password));
String rc;
try {
rc = getPassword(null, MasterKeyPasswordSafe.class, testKey(password));
@@ -107,7 +102,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
throw new IllegalStateException("There should be no problem with password at this point", e);
}
if (!TEST_PASSWORD_VALUE.equals(rc)) {
- key.get().set(savedKey);
+ myKey.get().set(savedKey);
return false;
}
else {
@@ -127,11 +122,11 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
if (!setMasterPassword(oldPassword)) {
return false;
}
- byte[] oldKey = key.get().get(); // set right in the previous call
+ byte[] oldKey = (byte[])myKey.get().get(); // set right in the previous call
byte[] newKey = EncryptionUtil.genPasswordKey(newPassword);
ByteArrayWrapper testKey = new ByteArrayWrapper(EncryptionUtil.dbKey(oldKey, MasterKeyPasswordSafe.class, testKey(oldPassword)));
HashMap<ByteArrayWrapper, byte[]> oldDb = new HashMap<ByteArrayWrapper, byte[]>();
- database.copyTo(oldDb);
+ myDatabase.copyTo(oldDb);
HashMap<ByteArrayWrapper, byte[]> newDb = new HashMap<ByteArrayWrapper, byte[]>();
for (Map.Entry<ByteArrayWrapper, byte[]> e : oldDb.entrySet()) {
if (testKey.equals(e.getKey())) {
@@ -141,9 +136,9 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
String decryptedText = EncryptionUtil.decryptText(oldKey, e.getValue());
newDb.put(new ByteArrayWrapper(EncryptionUtil.encryptKey(newKey, decryptedKey)), EncryptionUtil.encryptText(newKey, decryptedText));
}
- synchronized (database.getDbLock()) {
+ synchronized (myDatabase.getDbLock()) {
resetMasterPassword(newPassword, encrypt);
- database.putAll(newDb);
+ myDatabase.putAll(newDb);
}
return true;
}
@@ -153,65 +148,92 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
return TEST_PASSWORD_KEY + password;
}
+ @NotNull
@Override
protected byte[] key(@Nullable final Project project, @NotNull final Class requestor) throws PasswordSafeException {
- Application application = ApplicationManager.getApplication();
- if (!isTestMode() && application.isHeadlessEnvironment()) {
+ Object key = myKey.get().get();
+ if (key instanceof byte[]) return (byte[])key;
+ if (key instanceof PasswordSafeException && ((PasswordSafeException)key).justHappened()) throw (PasswordSafeException)key;
+
+ if (isPasswordEncrypted()) {
+ try {
+ setMasterPassword(decryptPassword(myDatabase.getPasswordInfo()));
+ key = myKey.get().get();
+ if (key instanceof byte[]) return (byte[])key;
+ }
+ catch (PasswordSafeException e) {
+ // ignore exception and ask password
+ }
+ }
+
+ if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
throw new MasterPasswordUnavailableException("The provider is not available in headless environment");
}
- final Ref<byte[]> result = Ref.create(key.get().get());
- if (result.isNull()) {
- if (isPasswordEncrypted()) {
+
+ if (myDatabase.isEmpty()) {
+ if (!MasterPasswordDialog.resetMasterPasswordDialog(project, this, requestor).showAndGet()) {
+ throw new MasterPasswordUnavailableException("Master password is required to store passwords in the database.");
+ }
+ }
+
+ key = invokeAndWait(new ThrowableComputable<Object, PasswordSafeException>() {
+ @Override
+ public Object compute() throws PasswordSafeException {
+ Object key = myKey.get().get();
+ if (key instanceof byte[] || key instanceof PasswordSafeException && ((PasswordSafeException)key).justHappened()) {
+ return key;
+ }
try {
- setMasterPassword(decryptPassword(database.getPasswordInfo()));
- result.set(key.get().get());
+ MasterPasswordDialog.askPassword(project, MasterKeyPasswordSafe.this, requestor);
}
catch (PasswordSafeException e) {
- // ignore exception and ask password
+ myKey.get().set(e);
+ throw e;
}
+ return myKey.get().get();
+ }
+ }, project == null ? Condition.FALSE : project.getDisposed());
+ if (key instanceof byte[]) return (byte[])key;
+ if (key instanceof PasswordSafeException) throw (PasswordSafeException)key;
+
+ throw new AssertionError();
+ }
+
+ private static final Object ourEDTLock = new Object();
+ public <T, E extends Throwable> T invokeAndWait(@NotNull final ThrowableComputable<T, E> computable, @NotNull final Condition expired) throws E {
+ if (ApplicationManager.getApplication().isDispatchThread()) {
+ return computable.compute();
+ }
+ final Ref<Throwable> exRef = Ref.create();
+ final Ref<T> ref = Ref.create();
+ synchronized (ourEDTLock) {
+ if (expired.value(null)) {
+ throw new ProcessCanceledException();
}
- if (result.isNull()) {
- final Ref<PasswordSafeException> ex = new Ref<PasswordSafeException>();
- application.invokeAndWait(new Runnable() {
- public void run() {
- result.set(key.get().get());
- if (result.isNull()) {
- try {
- if (isTestMode()) {
- throw new MasterPasswordUnavailableException("Master password must be specified in test mode.");
- }
- if (database.isEmpty()) {
- if (!MasterPasswordDialog.resetMasterPasswordDialog(project, MasterKeyPasswordSafe.this, requestor).showAndGet()) {
- throw new MasterPasswordUnavailableException("Master password is required to store passwords in the database.");
- }
- }
- else {
- MasterPasswordDialog.askPassword(project, MasterKeyPasswordSafe.this, requestor);
- }
- result.set(key.get().get());
- }
- catch (PasswordSafeException e) {
- ex.set(e);
- }
- catch (Exception e) {
- //noinspection ThrowableInstanceNeverThrown
- ex.set(new MasterPasswordUnavailableException("The problem with retrieving the password", e));
- }
- }
+ ApplicationManager.getApplication().invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ if (expired.value(null)) {
+ exRef.set(new ProcessCanceledException());
+ return;
+ }
+
+ try {
+ ref.set(computable.compute());
+ }
+ catch (Throwable e) {
+ exRef.set(e);
}
- }, ModalityState.any());
- //noinspection ThrowableResultOfMethodCallIgnored
- if (ex.get() != null) {
- throw ex.get();
}
- }
+ }, ModalityState.any());
}
- return result.get();
+ if (!exRef.isNull()) throw (E)exRef.get();
+ return ref.get();
}
@Override
public String getPassword(@Nullable Project project, @NotNull Class requestor, String key) throws PasswordSafeException {
- if (database.isEmpty()) {
+ if (myDatabase.isEmpty()) {
return null;
}
return super.getPassword(project, requestor, key);
@@ -219,7 +241,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
@Override
public void removePassword(@Nullable Project project, @NotNull Class requester, String key) throws PasswordSafeException {
- if (database.isEmpty()) {
+ if (myDatabase.isEmpty()) {
return;
}
super.removePassword(project, requester, key);
@@ -227,17 +249,17 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
@Override
protected byte[] getEncryptedPassword(byte[] key) {
- return database.get(key);
+ return myDatabase.get(key);
}
@Override
protected void removeEncryptedPassword(byte[] key) {
- database.remove(key);
+ myDatabase.remove(key);
}
@Override
protected void storeEncryptedPassword(byte[] key, byte[] encryptedPassword) {
- database.put(key, encryptedPassword);
+ myDatabase.put(key, encryptedPassword);
}
@Override
@@ -303,11 +325,11 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
public boolean isPasswordEncrypted() {
if (!isOsProtectedPasswordSupported()) return false;
- byte[] i = database.getPasswordInfo();
- return i != null && i.length > 0;
+ byte[] info = myDatabase.getPasswordInfo();
+ return info != null && info.length > 0;
}
public boolean isEmpty() {
- return database.isEmpty();
+ return myDatabase.isEmpty();
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/memory/MemoryPasswordSafe.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/memory/MemoryPasswordSafe.java
index 4989789b4ec0..5057b0ee48d6 100644
--- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/memory/MemoryPasswordSafe.java
+++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/memory/MemoryPasswordSafe.java
@@ -57,6 +57,7 @@ public class MemoryPasswordSafe extends BasePasswordSafeProvider {
return Registry.intValue("passwordSafe.memorySafe.ttl");
}
+ @NotNull
@Override
protected byte[] key(Project project, @NotNull Class requestor) {
if (key.get() == null) {
diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java
index 6ea43344bda4..b31599816435 100644
--- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java
+++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/ui/PasswordPromptComponent.java
@@ -18,6 +18,7 @@ package com.intellij.ide.passwordSafe.ui;
import com.intellij.ide.passwordSafe.config.PasswordSafeSettings;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.util.ui.DialogUtil;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
@@ -49,7 +50,10 @@ public class PasswordPromptComponent {
setTargetProviderType(type);
setUserInputVisible(showUserName);
if (passwordPrompt != null) myPasswordLabel.setText(passwordPrompt);
- if (rememberPrompt != null) myRememberCheckBox.setText(rememberPrompt);
+ if (rememberPrompt != null) {
+ myRememberCheckBox.setText(rememberPrompt);
+ DialogUtil.registerMnemonic(myRememberCheckBox);
+ }
}
public JComponent getComponent() {
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java
index b093773bc0fb..366e4e1cf4ef 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginInstaller.java
@@ -30,10 +30,7 @@ import com.intellij.ui.GuiUtils;
import com.intellij.util.ArrayUtil;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* @author stathik
@@ -45,6 +42,19 @@ public class PluginInstaller {
private PluginInstaller() { }
public static boolean prepareToInstall(List<PluginNode> pluginsToInstall, List<IdeaPluginDescriptor> allPlugins) {
+ HashSet<PluginNode> dependant = new HashSet<PluginNode>();
+ boolean install = prepareToInstall(pluginsToInstall, allPlugins, dependant);
+ for (PluginNode node : dependant) {
+ if (!pluginsToInstall.contains(node)) {
+ pluginsToInstall.add(node);
+ }
+ }
+ return install;
+ }
+
+ private static boolean prepareToInstall(List<PluginNode> pluginsToInstall,
+ List<IdeaPluginDescriptor> allPlugins,
+ Set<PluginNode> installedDependant) {
ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
final List<PluginId> pluginIds = new ArrayList<PluginId>();
@@ -58,7 +68,7 @@ public class PluginInstaller {
if (pi != null) pi.setText(pluginNode.getName());
try {
- result |= prepareToInstall(pluginNode, pluginIds, allPlugins);
+ result |= prepareToInstall(pluginNode, pluginIds, allPlugins, installedDependant);
}
catch (IOException e) {
String title = IdeBundle.message("title.plugin.error");
@@ -72,7 +82,9 @@ public class PluginInstaller {
private static boolean prepareToInstall(final PluginNode pluginNode,
final List<PluginId> pluginIds,
- List<IdeaPluginDescriptor> allPlugins) throws IOException {
+ List<IdeaPluginDescriptor> allPlugins,
+ Set<PluginNode> installedDependant) throws IOException {
+ installedDependant.add(pluginNode);
// check for dependent plugins at first.
if (pluginNode.getDepends() != null && pluginNode.getDepends().size() > 0) {
// prepare plugins list for install
@@ -122,7 +134,7 @@ public class PluginInstaller {
return false;
}
if (proceed[0]) {
- if (!prepareToInstall(depends, allPlugins)) {
+ if (!prepareToInstall(depends, allPlugins, installedDependant)) {
return false;
}
}
@@ -152,7 +164,7 @@ public class PluginInstaller {
return false;
}
if (proceed[0]) {
- if (!prepareToInstall(optionalDeps, allPlugins)) {
+ if (!prepareToInstall(optionalDeps, allPlugins, installedDependant)) {
return false;
}
}
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurable.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurable.java
index 1fcf23e79614..cc683ecb7075 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurable.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerConfigurable.java
@@ -34,15 +34,7 @@ import javax.swing.*;
import javax.swing.table.TableModel;
import java.util.List;
-/**
- * Created by IntelliJ IDEA.
- * User: stathik
- * Date: Oct 26, 2003
- * Time: 9:30:44 PM
- * To change this template use Options | File Templates.
- */
public class PluginManagerConfigurable extends BaseConfigurable implements SearchableConfigurable, Configurable.NoScroll {
-
@NonNls private static final String POSTPONE = "&Postpone";
public static final String ID = "preferences.pluginManager";
public static final String DISPLAY_NAME = IdeBundle.message("title.plugins");
@@ -68,10 +60,12 @@ public class PluginManagerConfigurable extends BaseConfigurable implements Searc
return myPluginManagerMain.getPluginTable();
}
+ @Override
public String getDisplayName() {
return DISPLAY_NAME;
}
+ @Override
public void reset() {
myPluginManagerMain.reset();
//if (myAvailable) {
@@ -92,10 +86,12 @@ public class PluginManagerConfigurable extends BaseConfigurable implements Searc
getSplitterProportions().restoreSplitterProportions(myPluginManagerMain.getMainPanel());
}
+ @Override
public String getHelpTopic() {
return ID;
}
+ @Override
public void disposeUIResources() {
if (myPluginManagerMain != null) {
getSplitterProportions().saveSplitterProportions(myPluginManagerMain.getMainPanel());
@@ -124,6 +120,7 @@ public class PluginManagerConfigurable extends BaseConfigurable implements Searc
return myAvailable ? myUISettings.getAvailableSplitterProportionsData() : myUISettings.getSplitterProportionsData();
}
+ @Override
public JComponent createComponent() {
return getOrCreatePanel().getMainPanel();
}
@@ -132,6 +129,7 @@ public class PluginManagerConfigurable extends BaseConfigurable implements Searc
return new InstalledPluginsManagerMain(myUISettings);
}
+ @Override
public void apply() throws ConfigurationException {
final String applyMessage = myPluginManagerMain.apply();
if (applyMessage != null) {
@@ -186,18 +184,22 @@ public class PluginManagerConfigurable extends BaseConfigurable implements Searc
if (response == Messages.YES) app.restart(true);
}
+ @Override
public boolean isModified() {
return myPluginManagerMain != null && myPluginManagerMain.isModified();
}
+ @Override
@NotNull
public String getId() {
return getHelpTopic();
}
+ @Override
@Nullable
public Runnable enableSearch(final String option) {
return new Runnable(){
+ @Override
public void run() {
if (myPluginManagerMain == null) return;
myPluginManagerMain.filter(option);
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java
index 931458ff8bc0..e7601a6b0fc0 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerMain.java
@@ -85,6 +85,8 @@ import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces;
*/
public abstract class PluginManagerMain implements Disposable {
public static final String JETBRAINS_VENDOR = "JetBrains";
+ public static final NotificationGroup PLUGIN_LIFECYCLE_NOTIFICATION_GROUP =
+ new NotificationGroup("Plugins Lifecycle Group", NotificationDisplayType.STICKY_BALLOON, true);
public static Logger LOG = Logger.getInstance("#com.intellij.ide.plugins.PluginManagerMain");
@NonNls private static final String TEXT_PREFIX = "<html><head>" +
@@ -652,7 +654,7 @@ public abstract class PluginManagerMain implements Disposable {
message += "<br><a href=";
message += restartCapable ? "\"restart\">Restart now" : "\"shutdown\">Shutdown";
message += "</a>";
- new NotificationGroup("Plugins Lifecycle Group", NotificationDisplayType.STICKY_BALLOON, true)
+ PLUGIN_LIFECYCLE_NOTIFICATION_GROUP
.createNotification(title,
XmlStringUtil.wrapInHtml(message), NotificationType.INFORMATION,
new NotificationListener() {
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerUISettings.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerUISettings.java
index d5e320a77837..0f0b5189a7f7 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerUISettings.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerUISettings.java
@@ -17,7 +17,6 @@ package com.intellij.ide.plugins;
import com.intellij.ide.ui.SplitterProportionsDataImpl;
import com.intellij.openapi.components.*;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.ui.SplitterProportionsData;
import com.intellij.openapi.util.JDOMExternalizableStringList;
@@ -39,7 +38,6 @@ import javax.swing.*;
}
)
public class PluginManagerUISettings implements PersistentStateComponent<Element>, PerformInBackgroundOption {
- private static final Logger LOG = Logger.getInstance("#com.intellij.ide.plugins.PluginManagerUISettings");
private static final SkipDefaultValuesSerializationFilters FILTERS = new SkipDefaultValuesSerializationFilters();
public int AVAILABLE_SORT_COLUMN_ORDER = SortOrder.ASCENDING.ordinal();
@@ -65,6 +63,7 @@ public class PluginManagerUISettings implements PersistentStateComponent<Element
return ServiceManager.getService(PluginManagerUISettings.class);
}
+ @Override
public Element getState() {
Element element = new Element("state");
XmlSerializer.serializeInto(this, element, FILTERS);
@@ -76,6 +75,7 @@ public class PluginManagerUISettings implements PersistentStateComponent<Element
return element;
}
+ @Override
public void loadState(final Element element) {
XmlSerializer.deserializeInto(this, element);
XmlSerializer.deserializeInto(mySplitterProportionsData, element);
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java b/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java
index ec763a8d5a76..c03eca88ade3 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/RepositoryHelper.java
@@ -23,6 +23,7 @@ import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.util.BuildNumber;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.PathUtil;
import com.intellij.util.net.HttpConfigurable;
@@ -45,9 +46,14 @@ public class RepositoryHelper {
@NonNls public static final String PLUGIN_LIST_FILE = "availables.xml";
public static List<IdeaPluginDescriptor> loadPluginsFromRepository(@Nullable ProgressIndicator indicator) throws Exception {
+ return loadPluginsFromRepository(indicator, null);
+ }
+
+ public static List<IdeaPluginDescriptor> loadPluginsFromRepository(@Nullable ProgressIndicator indicator,
+ BuildNumber buildnumber) throws Exception {
ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
- String url = appInfo.getPluginsListUrl() + "?build=" + appInfo.getApiVersion();
+ String url = appInfo.getPluginsListUrl() + "?build=" + (buildnumber != null ? buildnumber.asString() : appInfo.getApiVersion());
if (indicator != null) {
indicator.setText2(IdeBundle.message("progress.connecting.to.plugin.manager", appInfo.getPluginManagerUrl()));
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
index c60ddc44748d..cc6e16aba6c2 100644
--- a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
+++ b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -70,7 +70,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
myComponent.myLafComboBox.setModel(new DefaultComboBoxModel(LafManager.getInstance().getInstalledLookAndFeels()));
myComponent.myLafComboBox.setRenderer(new LafComboBoxRenderer());
- Dictionary<Integer, JLabel> delayDictionary = new Hashtable<Integer, JLabel>();
+ Dictionary<Integer, JComponent> delayDictionary = new Hashtable<Integer, JComponent>();
delayDictionary.put(new Integer(0), new JLabel("0"));
delayDictionary.put(new Integer(1200), new JLabel("1200"));
//delayDictionary.put(new Integer(2400), new JLabel("2400"));
@@ -94,7 +94,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
myComponent.myAlphaModeRatioSlider.setSize(100, 50);
@SuppressWarnings({"UseOfObsoleteCollectionType"})
- Dictionary<Integer, JLabel> dictionary = new Hashtable<Integer, JLabel>();
+ Dictionary<Integer, JComponent> dictionary = new Hashtable<Integer, JComponent>();
dictionary.put(new Integer(0), new JLabel("0%"));
dictionary.put(new Integer(50), new JLabel("50%"));
dictionary.put(new Integer(100), new JLabel("100%"));
diff --git a/platform/platform-impl/src/com/intellij/ide/util/TipDialog.java b/platform/platform-impl/src/com/intellij/ide/util/TipDialog.java
index 0744e377e6c5..3d84e6d7431c 100644
--- a/platform/platform-impl/src/com/intellij/ide/util/TipDialog.java
+++ b/platform/platform-impl/src/com/intellij/ide/util/TipDialog.java
@@ -1,4 +1,3 @@
-
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
@@ -33,6 +32,12 @@ import java.awt.event.ActionEvent;
public class TipDialog extends DialogWrapper{
private TipPanel myTipPanel;
+ @Nullable
+ @Override
+ protected String getDimensionServiceKey() {
+ return getClass().getName();
+ }
+
public TipDialog(){
super(WindowManagerEx.getInstanceEx().findVisibleFrame(), true);
initialize();
@@ -52,9 +57,6 @@ public class TipDialog extends DialogWrapper{
setHorizontalStretch(1.33f);
setVerticalStretch(1.25f);
init();
- if (getPeer() instanceof DialogWrapperPeerImpl) {
- ((DialogWrapperPeerImpl)getPeer()).setAutoRequestFocus(false);
- }
}
@NotNull
diff --git a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
index 1fd6c340d073..32b03f3deb2b 100644
--- a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
+++ b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -36,6 +36,7 @@ import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import com.intellij.ui.content.ContentManager;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import javax.swing.event.AncestorEvent;
@@ -44,7 +45,7 @@ import javax.swing.event.AncestorEvent;
*/
public class EventLogToolWindowFactory implements ToolWindowFactory, DumbAware {
@Override
- public void createToolWindowContent(final Project project, ToolWindow toolWindow) {
+ public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow toolWindow) {
EventLog.getProjectComponent(project).initDefaultContent();
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java
index a7b2e7bc9d02..0d116c7a927f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/AbbreviationManagerImpl.java
@@ -38,40 +38,33 @@ import java.util.*;
)}
)
public class AbbreviationManagerImpl extends AbbreviationManager implements
- ExportableApplicationComponent, PersistentStateComponent<Element> {
+ ExportableComponent, PersistentStateComponent<Element> {
private final Map<String, List<String>> myAbbreviation2ActionId = new THashMap<String, List<String>>();
private final Map<String, LinkedHashSet<String>> myActionId2Abbreviations = new THashMap<String, LinkedHashSet<String>>();
private final Map<String, LinkedHashSet<String>> myPluginsActionId2Abbreviations = new THashMap<String, LinkedHashSet<String>>();
- @Override
- public void initComponent() {
-
- }
-
- @Override
- public void disposeComponent() {
-
- }
-
- @NotNull
- @Override
- public String getComponentName() {
- return "AbbreviationManager";
- }
-
@Nullable
@Override
public Element getState() {
final Element actions = new Element("actions");
- final Element abbreviations = new Element("abbreviations");
- actions.addContent(abbreviations);
+ if (myActionId2Abbreviations.isEmpty()) {
+ return actions;
+ }
+
+ Element abbreviations = null;
for (String key : myActionId2Abbreviations.keySet()) {
final LinkedHashSet<String> abbrs = myActionId2Abbreviations.get(key);
final LinkedHashSet<String> pluginAbbrs = myPluginsActionId2Abbreviations.get(key);
if (abbrs == pluginAbbrs || (abbrs != null && abbrs.equals(pluginAbbrs))) {
continue;
}
+
if (abbrs != null) {
+ if (abbreviations == null) {
+ abbreviations = new Element("abbreviations");
+ actions.addContent(abbreviations);
+ }
+
final Element action = new Element("action");
action.setAttribute("id", key);
abbreviations.addContent(action);
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
index 78043075b166..723956ef9daa 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
@@ -49,6 +49,7 @@ import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.IdeFrame;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ObjectUtils;
+import com.intellij.util.ReflectionUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.messages.MessageBusConnection;
@@ -66,7 +67,6 @@ import javax.swing.*;
import javax.swing.Timer;
import java.awt.*;
import java.awt.event.*;
-import java.lang.reflect.Constructor;
import java.util.*;
import java.util.List;
@@ -259,9 +259,8 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
Object obj;
String className = stub.getClassName();
try {
- Constructor<?> constructor = Class.forName(className, true, stub.getLoader()).getDeclaredConstructor();
- constructor.setAccessible(true);
- obj = constructor.newInstance();
+ Class<?> aClass = Class.forName(className, true, stub.getLoader());
+ obj = ReflectionUtil.newInstance(aClass);
}
catch (ClassNotFoundException e) {
PluginId pluginId = stub.getPluginId();
diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
index a0b495726f30..529d5ba1c62f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -65,6 +65,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.actionSystem.impl.ActionToolbarImpl");
private static final List<ActionToolbarImpl> ourToolbars = new LinkedList<ActionToolbarImpl>();
+ private static final String RIGHT_ALIGN_KEY = "RIGHT_ALIGN";
+
public static void updateAllToolbarsImmediately() {
for (ActionToolbarImpl toolbar : new ArrayList<ActionToolbarImpl>(ourToolbars)) {
toolbar.updateActionsImmediately();
@@ -107,7 +109,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
private final ActionButtonLook myButtonLook = null;
private final ActionButtonLook myMinimalButtonLook = new InplaceActionButtonLook();
private final DataManager myDataManager;
- protected final ActionManagerEx myActionManager;
+ @NotNull protected final ActionManagerEx myActionManager;
private Rectangle myAutoPopupRec;
@@ -135,7 +137,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
@NotNull final ActionGroup actionGroup,
final boolean horizontal,
DataManager dataManager,
- ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
KeymapManagerEx keymapManager) {
this(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, false);
}
@@ -144,7 +146,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final boolean horizontal,
final boolean decorateButtons,
DataManager dataManager,
- ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
KeymapManagerEx keymapManager) {
this(place, actionGroup, horizontal, decorateButtons, dataManager, actionManager, keymapManager, false);
}
@@ -154,7 +156,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final boolean horizontal,
final boolean decorateButtons,
DataManager dataManager,
- ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
KeymapManagerEx keymapManager,
boolean updateActionsNow) {
super(null);
@@ -272,11 +274,16 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
}
private void fillToolBar(final List<AnAction> actions, boolean layoutSecondaries) {
+ final List<AnAction> rightAligned = new ArrayList<AnAction>();
if (myAddSeparatorFirst) {
add(new MySeparator());
}
for (int i = 0; i < actions.size(); i++) {
final AnAction action = actions.get(i);
+ if (action instanceof RightAlignedToolbarAction) {
+ rightAligned.add(action);
+ continue;
+ }
// if (action instanceof Separator && isNavBar()) {
// continue;
// }
@@ -311,18 +318,23 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
add(mySecondaryActionsButton);
}
- if ((ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || ActionPlaces.NAVIGATION_BAR_TOOLBAR.equals(myPlace))) {
- final AnAction searchEverywhereAction = ActionManager.getInstance().getAction("SearchEverywhere");
- if (searchEverywhereAction != null) {
- try {
- final CustomComponentAction searchEveryWhereAction = (CustomComponentAction)searchEverywhereAction;
- final JComponent searchEverywhere = searchEveryWhereAction.createCustomComponent(searchEverywhereAction.getTemplatePresentation());
- searchEverywhere.putClientProperty("SEARCH_EVERYWHERE", Boolean.TRUE);
- add(searchEverywhere);
- }
- catch (Exception ignore) {}
- }
- }
+ for (AnAction action : rightAligned) {
+ JComponent button = action instanceof CustomComponentAction ? getCustomComponent(action) : createToolbarButton(action);
+ button.putClientProperty(RIGHT_ALIGN_KEY, Boolean.TRUE);
+ add(button);
+ }
+ //if ((ActionPlaces.MAIN_TOOLBAR.equals(myPlace) || ActionPlaces.NAVIGATION_BAR_TOOLBAR.equals(myPlace))) {
+ // final AnAction searchEverywhereAction = ActionManager.getInstance().getAction("SearchEverywhere");
+ // if (searchEverywhereAction != null) {
+ // try {
+ // final CustomComponentAction searchEveryWhereAction = (CustomComponentAction)searchEverywhereAction;
+ // final JComponent searchEverywhere = searchEveryWhereAction.createCustomComponent(searchEverywhereAction.getTemplatePresentation());
+ // searchEverywhere.putClientProperty("SEARCH_EVERYWHERE", Boolean.TRUE);
+ // add(searchEverywhere);
+ // }
+ // catch (Exception ignore) {}
+ // }
+ //}
}
private JComponent getCustomComponent(AnAction action) {
@@ -730,14 +742,18 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
throw new IllegalStateException("unknown layoutPolicy: " + myLayoutPolicy);
}
+
if (getComponentCount() > 0 && size2Fit.width < Integer.MAX_VALUE) {
- final Component component = getComponent(getComponentCount() - 1);
- if (component instanceof JComponent && ((JComponent)component).getClientProperty("SEARCH_EVERYWHERE") == Boolean.TRUE) {
- int max = 0;
- for (int i = 0; i < bounds.size() - 2; i++) {
- max = Math.max(max, bounds.get(i).height);
+ int maxHeight = 0;
+ for (int i = 0; i < bounds.size() - 2; i++) {
+ maxHeight = Math.max(maxHeight, bounds.get(i).height);
+ }
+
+ for (int i = getComponentCount() - 1, j = 1; i > 0; i--, j++) {
+ final Component component = getComponent(i);
+ if (component instanceof JComponent && ((JComponent)component).getClientProperty(RIGHT_ALIGN_KEY) == Boolean.TRUE) {
+ bounds.set(bounds.size() - j, new Rectangle(size2Fit.width - j * 25, 0, 25, maxHeight));
}
- bounds.set(bounds.size() - 1, new Rectangle(size2Fit.width - 25, 0, 25, max));
}
}
}
@@ -1185,7 +1201,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
final ActionGroup actionGroup,
final boolean horizontal,
final DataManager dataManager,
- final ActionManagerEx actionManager,
+ @NotNull ActionManagerEx actionManager,
final KeymapManagerEx keymapManager,
JComponent parent) {
super(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, true);
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
index 7c8acbc4c25c..46fae517170d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
@@ -781,7 +781,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
}
@Override
- public void restart(boolean exitConfirmed) {
+ public void restart(final boolean exitConfirmed) {
exit(false, exitConfirmed, true, true);
}
@@ -801,7 +801,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
exiting = true;
try {
- if (!force && getDefaultModalityState() != ModalityState.NON_MODAL) {
+ if (!force && !exitConfirmed && getDefaultModalityState() != ModalityState.NON_MODAL) {
return;
}
@@ -1067,8 +1067,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
private static Thread getEventQueueThread() {
EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
try {
- Method method = EventQueue.class.getDeclaredMethod("getDispatchThread");
- method.setAccessible(true);
+ Method method = ReflectionUtil.getDeclaredMethod(EventQueue.class, "getDispatchThread");
return (Thread)method.invoke(eventQueue);
}
catch (Exception e) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityInvokatorImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityInvokatorImpl.java
index ab2be68b70bd..de7a7e76aa70 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityInvokatorImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityInvokatorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -27,23 +27,27 @@ import com.intellij.openapi.util.Condition;
import org.jetbrains.annotations.NotNull;
public class ModalityInvokatorImpl implements ModalityInvokator {
+ @NotNull
@Override
- public ActionCallback invokeLater(Runnable runnable) {
+ public ActionCallback invokeLater(@NotNull Runnable runnable) {
return invokeLater(runnable, ApplicationManager.getApplication().getDisposed());
}
+ @NotNull
@Override
- public ActionCallback invokeLater(final Runnable runnable, @NotNull final Condition expired) {
+ public ActionCallback invokeLater(@NotNull final Runnable runnable, @NotNull final Condition expired) {
return LaterInvocator.invokeLater(runnable, expired);
}
+ @NotNull
@Override
- public ActionCallback invokeLater(final Runnable runnable, @NotNull final ModalityState state, @NotNull final Condition expired) {
+ public ActionCallback invokeLater(@NotNull final Runnable runnable, @NotNull final ModalityState state, @NotNull final Condition expired) {
return LaterInvocator.invokeLater(runnable, state, expired);
}
+ @NotNull
@Override
- public ActionCallback invokeLater(Runnable runnable, @NotNull ModalityState state) {
+ public ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState state) {
return invokeLater(runnable, state, ApplicationManager.getApplication().getDisposed());
}
} \ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/EditorLinePainter.java b/platform/platform-impl/src/com/intellij/openapi/editor/EditorLinePainter.java
new file mode 100644
index 000000000000..420a0fdf23a7
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/EditorLinePainter.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2014 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;
+
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public abstract class EditorLinePainter {
+ public static final ExtensionPointName<EditorLinePainter> EP_NAME = ExtensionPointName.create("com.intellij.editor.linePainter");
+
+ public abstract Collection<LineExtensionInfo> getLineExtensions(@NotNull Project project, @NotNull VirtualFile file, int lineNumber);
+}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/LineExtensionInfo.java b/platform/platform-impl/src/com/intellij/openapi/editor/LineExtensionInfo.java
new file mode 100644
index 000000000000..f84502097b10
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/LineExtensionInfo.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2000-2014 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;
+
+import com.intellij.openapi.editor.markup.EffectType;
+import org.intellij.lang.annotations.JdkConstants;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public class LineExtensionInfo {
+ @NotNull private final String myText;
+ @Nullable private final Color myColor;
+ @Nullable private final EffectType myEffectType;
+ @Nullable private final Color myEffectColor;
+ @JdkConstants.FontStyle private final int myFontType;
+
+ public LineExtensionInfo(@NotNull String text,
+ @Nullable Color color,
+ @Nullable EffectType effectType,
+ @Nullable Color effectColor,
+ @JdkConstants.FontStyle int fontType) {
+ myText = text;
+ myColor = color;
+ myEffectType = effectType;
+ myEffectColor = effectColor;
+ myFontType = fontType;
+ }
+
+ @NotNull
+ public String getText() {
+ return myText;
+ }
+
+ @Nullable
+ public Color getColor() {
+ return myColor;
+ }
+
+ @Nullable
+ public EffectType getEffectType() {
+ return myEffectType;
+ }
+
+ @Nullable
+ public Color getEffectColor() {
+ return myEffectColor;
+ }
+
+ @JdkConstants.FontStyle
+ public int getFontType() {
+ return myFontType;
+ }
+}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/EnterAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/EnterAction.java
index cc7b2177cd91..ea2107632122 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/EnterAction.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/EnterAction.java
@@ -30,6 +30,8 @@ import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
import com.intellij.util.ui.MacUIUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class EnterAction extends EditorAction {
public EnterAction() {
@@ -43,13 +45,13 @@ public class EnterAction extends EditorAction {
}
@Override
- public void executeWriteAction(Editor editor, DataContext dataContext) {
+ public void executeWriteAction(Editor editor, @Nullable Caret caret, DataContext dataContext) {
CommandProcessor.getInstance().setCurrentCommandName(EditorBundle.message("typing.command.name"));
insertNewLineAtCaret(editor);
}
@Override
- public boolean isEnabled(Editor editor, DataContext dataContext) {
+ public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
return !editor.isOneLineMode();
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/IndentSelectionAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/IndentSelectionAction.java
index 92f025685891..76eff2bd7a54 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/IndentSelectionAction.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/IndentSelectionAction.java
@@ -57,7 +57,7 @@ public class IndentSelectionAction extends EditorAction {
@Override
public void executeWriteAction(Editor editor, @Nullable Caret caret, DataContext dataContext) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
- if (isEnabled(editor, dataContext)) {
+ if (isEnabled(editor, caret, dataContext)) {
indentSelection(editor, project);
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/SplitLineAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/SplitLineAction.java
index 7716a9001b7e..1583bd423ff7 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/SplitLineAction.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/SplitLineAction.java
@@ -18,10 +18,7 @@ package com.intellij.openapi.editor.actions;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.IdeActions;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.RangeMarker;
-import com.intellij.openapi.editor.ScrollType;
+import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
@@ -30,6 +27,7 @@ import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.util.Key;
import com.intellij.util.text.CharArrayUtil;
+import org.jetbrains.annotations.NotNull;
/**
* @author max
@@ -48,13 +46,13 @@ public class SplitLineAction extends EditorAction {
}
@Override
- public boolean isEnabled(Editor editor, DataContext dataContext) {
- return getEnterHandler().isEnabled(editor, dataContext) &&
+ public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
+ return getEnterHandler().isEnabled(editor, caret, dataContext) &&
!((EditorEx)editor).isEmbeddedIntoDialogWrapper();
}
@Override
- public void executeWriteAction(Editor editor, DataContext dataContext) {
+ public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
CopyPasteManager.getInstance().stopKillRings();
final Document document = editor.getDocument();
final RangeMarker rangeMarker =
@@ -77,7 +75,7 @@ public class SplitLineAction extends EditorAction {
} else {
DataManager.getInstance().saveInDataContext(dataContext, SPLIT_LINE_KEY, true);
try {
- getEnterHandler().execute(editor, dataContext);
+ getEnterHandler().execute(editor, caret, dataContext);
}
finally {
DataManager.getInstance().saveInDataContext(dataContext, SPLIT_LINE_KEY, null);
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineAction.java
index 0302e484d00d..b2f43bf4458f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineAction.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineAction.java
@@ -17,6 +17,7 @@ package com.intellij.openapi.editor.actions;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.IdeActions;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.editor.actionSystem.EditorAction;
@@ -24,6 +25,7 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
import com.intellij.openapi.ide.CopyPasteManager;
+import org.jetbrains.annotations.NotNull;
/**
* @author max
@@ -39,12 +41,12 @@ public class StartNewLineAction extends EditorAction {
}
@Override
- public boolean isEnabled(Editor editor, DataContext dataContext) {
- return getEnterHandler().isEnabled(editor, dataContext);
+ public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
+ return getEnterHandler().isEnabled(editor, caret, dataContext);
}
@Override
- public void executeWriteAction(Editor editor, DataContext dataContext) {
+ public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
CopyPasteManager.getInstance().stopKillRings();
if (editor.getDocument().getLineCount() != 0) {
editor.getSelectionModel().removeSelection();
@@ -53,7 +55,7 @@ public class StartNewLineAction extends EditorAction {
editor.getCaretModel().moveToOffset(lineEndOffset);
}
- getEnterHandler().execute(editor, dataContext);
+ getEnterHandler().execute(editor, caret, dataContext);
}
private static EditorActionHandler getEnterHandler() {
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineBeforeAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineBeforeAction.java
index fc2ae4031ca3..4d8c6ff2f465 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineBeforeAction.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/StartNewLineBeforeAction.java
@@ -42,8 +42,8 @@ public class StartNewLineBeforeAction extends EditorAction {
}
@Override
- public boolean isEnabled(Editor editor, DataContext dataContext) {
- return getHandler(IdeActions.ACTION_EDITOR_ENTER).isEnabled(editor, dataContext);
+ public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
+ return getHandler(IdeActions.ACTION_EDITOR_ENTER).isEnabled(editor, caret, dataContext);
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/UnselectWordAtCaretAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/UnselectWordAtCaretAction.java
index a1ae088a89e2..2d7e3945ee6e 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/UnselectWordAtCaretAction.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/UnselectWordAtCaretAction.java
@@ -24,11 +24,13 @@
*/
package com.intellij.openapi.editor.actions;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorAction;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
-import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.project.DumbAware;
+import org.jetbrains.annotations.Nullable;
public class UnselectWordAtCaretAction extends EditorAction implements DumbAware {
public UnselectWordAtCaretAction() {
@@ -42,7 +44,7 @@ public class UnselectWordAtCaretAction extends EditorAction implements DumbAware
}
@Override
- public void execute(Editor editor, DataContext dataContext) {
+ public void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) {
}
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorMarkupModel.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorMarkupModel.java
index 5da1077baf5c..71dee99c3514 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorMarkupModel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorMarkupModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -28,7 +28,7 @@ public interface EditorMarkupModel extends MarkupModel {
void setErrorStripeVisible(boolean val);
- void setErrorStripeRenderer(ErrorStripeRenderer renderer);
+ void setErrorStripeRenderer(@NotNull ErrorStripeRenderer renderer);
ErrorStripeRenderer getErrorStripeRenderer();
void addErrorMarkerListener(@NotNull ErrorStripeListener listener, @NotNull Disposable parent);
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHeaderComponent.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHeaderComponent.java
index fc1f9048d31f..31b3a56d2317 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHeaderComponent.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorHeaderComponent.java
@@ -46,13 +46,8 @@ public class EditorHeaderComponent extends JPanel {
paintGradient(g, this);
}
- @NotNull
- protected JBColor getBaseBackgroundColor() {
- return new JBColor(getBackground(), JBColor.background());
- }
-
private void paintGradient(Graphics g, JComponent c) {
- Color GRADIENT_C1 = getBaseBackgroundColor();
+ Color GRADIENT_C1 = isBackgroundSet() ? getBackground() : new JBColor(getBackground(), JBColor.background());
Color GRADIENT_C2 = new JBColor(new Color(Math.max(0, GRADIENT_C1.getRed() - 0x18), Math.max(0, GRADIENT_C1.getGreen() - 0x18),
Math.max(0, GRADIENT_C1.getBlue() - 0x18)), Gray._75);
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
index c0ffbd10aca4..6160ea58dcdf 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
@@ -2765,8 +2765,25 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
if (hEnd >= lEnd) {
FoldRegion collapsedFolderAt = myFoldingModel.getCollapsedRegionAtOffset(start);
if (collapsedFolderAt == null) {
- drawStringWithSoftWraps(g, chars, start, lEnd - lIterator.getSeparatorLength(), position, clip, effectColor,
- effectType, fontType, currentColor, logicalPosition);
+ int i = drawStringWithSoftWraps(g, chars, start, lEnd - lIterator.getSeparatorLength(), position, clip, effectColor,
+ effectType, fontType, currentColor, logicalPosition);
+ final VirtualFile file = getVirtualFile();
+ if (myProject != null && file != null && !isOneLineMode()) {
+ for (EditorLinePainter painter : EditorLinePainter.EP_NAME.getExtensions()) {
+ Collection<LineExtensionInfo> extensions = painter.getLineExtensions(myProject, file, lIterator.getLineNumber());
+ if (extensions != null && !extensions.isEmpty()) {
+ for (LineExtensionInfo info : extensions) {
+ drawStringWithSoftWraps(g, info.getText(), 0, info.getText().length(), position, clip,
+ info.getEffectColor() == null ? effectColor : info.getEffectColor(),
+ info.getEffectType() == null ? effectType : info.getEffectType(),
+ info.getFontType(),
+ info.getColor() == null ? currentColor : info.getColor(),
+ logicalPosition);
+ }
+ }
+ }
+ }
+
position.x = 0;
if (position.y > clip.y + clip.height) {
break;
@@ -6749,10 +6766,17 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
public Insets getBorderInsets(Component c) {
Container splitters = SwingUtilities.getAncestorOfClass(EditorsSplitters.class, c);
boolean thereIsSomethingAbove = !SystemInfo.isMac || UISettings.getInstance().SHOW_MAIN_TOOLBAR || UISettings.getInstance().SHOW_NAVIGATION_BAR ||
- myProject != null && !ToolWindowManagerEx.getInstanceEx(myProject).getIdsOn(ToolWindowAnchor.TOP).isEmpty();
+ toolWindowIsNotEmpty();
return splitters == null ? super.getBorderInsets(c) : new Insets(thereIsSomethingAbove ? 1 : 0, 0, 0, 0);
}
+ public boolean toolWindowIsNotEmpty() {
+ if (myProject == null) return false;
+ ToolWindowManagerEx m = ToolWindowManagerEx.getInstanceEx(myProject);
+ if (m == null) return false;
+ return !m.getIdsOn(ToolWindowAnchor.TOP).isEmpty();
+ }
+
@Override
public boolean isBorderOpaque() {
return true;
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java
index 6ec29e58dc0b..20c08ec4ec99 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java
@@ -368,7 +368,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
}
@Override
- public void setErrorStripeRenderer(ErrorStripeRenderer renderer) {
+ public void setErrorStripeRenderer(@NotNull ErrorStripeRenderer renderer) {
assertIsDispatchThread();
if (myErrorStripeRenderer instanceof Disposable) {
Disposer.dispose((Disposable)myErrorStripeRenderer);
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java
index 63843a932076..64f56eb750eb 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileTextFieldImpl.java
@@ -285,7 +285,7 @@ public abstract class FileTextFieldImpl implements FileLookup, Disposable, FileT
myList = new JBList();
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- myList.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptor() {
+ myList.setCellRenderer(new GroupedItemsListRenderer(new ListItemDescriptorAdapter() {
public String getTextFor(final Object value) {
final LookupFile file = (LookupFile)value;
@@ -298,10 +298,6 @@ public abstract class FileTextFieldImpl implements FileLookup, Disposable, FileT
}
- public String getTooltipFor(final Object value) {
- return null;
- }
-
public Icon getIconFor(final Object value) {
final LookupFile file = (LookupFile)value;
return file.getIcon();
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/ex/FileEditorManagerEx.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/ex/FileEditorManagerEx.java
index 9520834b4518..30eb78cf706f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/ex/FileEditorManagerEx.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/ex/FileEditorManagerEx.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -16,6 +16,7 @@
package com.intellij.openapi.fileEditor.ex;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.EditorDataProvider;
import com.intellij.openapi.fileEditor.FileEditor;
@@ -164,9 +165,9 @@ public abstract class FileEditorManagerEx extends FileEditorManager implements B
public abstract boolean isInsideChange();
@Nullable
- public final Object getData(@NotNull String dataId, @NotNull Editor editor, @NotNull VirtualFile file) {
+ public final Object getData(@NotNull String dataId, @NotNull Editor editor, @NotNull Caret caret) {
for (final EditorDataProvider dataProvider : myDataProviders) {
- final Object o = dataProvider.getData(dataId, editor, file);
+ final Object o = dataProvider.getData(dataId, editor, caret);
if (o != null) return o;
}
return null;
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java
index 091ff1171157..cce6de27545d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java
@@ -621,6 +621,7 @@ public class FileDocumentManagerImpl extends FileDocumentManager implements Virt
DocumentEx documentEx = (DocumentEx)document;
documentEx.setReadOnly(false);
LoadTextUtil.setCharsetWasDetectedFromBytes(file, null);
+ file.setBOM(null); // reset BOM in case we had one and the external change stripped it away
documentEx.replaceText(LoadTextUtil.loadText(file), file.getModificationStamp());
documentEx.setReadOnly(!wasWritable);
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java
index c7fa51f770d1..bab6d2b2fa4f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java
@@ -1636,7 +1636,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
*/
private final class MyVirtualFileListener extends VirtualFileAdapter {
@Override
- public void beforeFileDeletion(VirtualFileEvent e) {
+ public void beforeFileDeletion(@NotNull VirtualFileEvent e) {
assertDispatchThread();
boolean moveFocus = moveFocusOnDelete();
@@ -1651,7 +1651,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
@Override
- public void propertyChanged(VirtualFilePropertyEvent e) {
+ public void propertyChanged(@NotNull VirtualFilePropertyEvent e) {
if (VirtualFile.PROP_NAME.equals(e.getPropertyName())) {
assertDispatchThread();
final VirtualFile file = e.getFile();
@@ -1681,7 +1681,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
@Override
- public void fileMoved(VirtualFileMoveEvent e) {
+ public void fileMoved(@NotNull VirtualFileMoveEvent e) {
final VirtualFile file = e.getFile();
final VirtualFile[] openFiles = getOpenFiles();
for (final VirtualFile openFile : openFiles) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/HistoryEntry.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/HistoryEntry.java
index 5f3dd9adad22..51d044866717 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/HistoryEntry.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/HistoryEntry.java
@@ -24,18 +24,19 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.util.containers.HashMap;
import org.jdom.Element;
+import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Map;
final class HistoryEntry{
- static final String TAG = "entry";
+ @NonNls static final String TAG = "entry";
private static final String FILE_ATTR = "file";
- private static final String PROVIDER_ELEMENT = "provider";
- private static final String EDITOR_TYPE_ID_ATTR = "editor-type-id";
- private static final String SELECTED_ATTR_VALUE = "selected";
- private static final String STATE_ELEMENT = "state";
+ @NonNls private static final String PROVIDER_ELEMENT = "provider";
+ @NonNls private static final String EDITOR_TYPE_ID_ATTR = "editor-type-id";
+ @NonNls private static final String SELECTED_ATTR_VALUE = "selected";
+ @NonNls private static final String STATE_ELEMENT = "state";
public final VirtualFile myFile;
/**
@@ -53,7 +54,7 @@ final class HistoryEntry{
}
}
- public HistoryEntry(Project project, Element e) throws InvalidDataException {
+ public HistoryEntry(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
myFile = getVirtualFile(e);
myProvider2State = new HashMap<FileEditorProvider, FileEditorState>();
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java
index 288227eb51bd..de11bd5b9a12 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorComponent.java
@@ -36,7 +36,6 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.impl.EditorHistoryManager;
-import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
import com.intellij.openapi.fileTypes.FileTypeEvent;
import com.intellij.openapi.fileTypes.FileTypeListener;
import com.intellij.openapi.fileTypes.FileTypeManager;
@@ -278,7 +277,7 @@ class TextEditorComponent extends JBLoadingPanel implements DataProvider {
if (e == null) return null;
if (!myProject.isDisposed()) {
- final Object o = ((FileEditorManagerImpl)FileEditorManager.getInstance(myProject)).getData(dataId, e, myFile);
+ final Object o = FileEditorManager.getInstance(myProject).getData(dataId, e, e.getCaretModel().getCurrentCaret());
if (o != null) return o;
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java
index 13a8aaecb724..8a9031986ef8 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ModifierKeyDoubleClickHandler.java
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.util.Clock;
import com.intellij.openapi.util.Couple;
+import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.util.containers.ConcurrentHashMap;
import gnu.trove.TIntIntHashMap;
@@ -63,6 +64,9 @@ public class ModifierKeyDoubleClickHandler {
public void registerAction(@NotNull String actionId,
int modifierKeyCode,
int actionKeyCode) {
+ if (SystemInfo.isMac && modifierKeyCode == KeyEvent.VK_CONTROL) {
+ modifierKeyCode = KeyEvent.VK_META;
+ }
final MyDispatcher dispatcher = new MyDispatcher(actionId, modifierKeyCode, actionKeyCode);
IdeEventQueue.EventDispatcher oldDispatcher = myDispatchers.put(actionId, dispatcher);
IdeEventQueue.getInstance().addDispatcher(dispatcher, null);
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java
index 1b0c17f3ab4e..44ec15003de9 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/ActionsTree.java
@@ -21,6 +21,7 @@ import com.intellij.ide.ui.UISettings;
import com.intellij.ide.ui.search.SearchUtil;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.QuickList;
+import com.intellij.openapi.actionSystem.impl.ActionMenu;
import com.intellij.openapi.keymap.KeyMapBundle;
import com.intellij.openapi.keymap.Keymap;
import com.intellij.openapi.keymap.KeymapUtil;
@@ -40,12 +41,15 @@ import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.util.ui.tree.WideSelectionTreeUI;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.*;
import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionAdapter;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Set;
@@ -91,7 +95,7 @@ public class ActionsTree {
}
}
}
-
+
}
};
myTree.setRootVisible(false);
@@ -99,6 +103,36 @@ public class ActionsTree {
myTree.putClientProperty(WideSelectionTreeUI.STRIPED_CLIENT_PROPERTY, Boolean.TRUE);
myTree.setCellRenderer(new KeymapsRenderer());
+ myTree.addMouseMotionListener(new MouseMotionAdapter() {
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ String description = getDescription(e);
+ if (description != null) {
+ ActionMenu.showDescriptionInStatusBar(true, myTree, description);
+ }
+ else {
+ ActionMenu.showDescriptionInStatusBar(false, myTree, null);
+ }
+ }
+
+ @Nullable
+ private String getDescription(@NotNull MouseEvent e) {
+ TreePath path = myTree.getPathForLocation(e.getX(), e.getY());
+ if (path == null) return null;
+
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
+ if (node == null) return null;
+
+ Object userObject = node.getUserObject();
+ if (!(userObject instanceof String)) return null;
+
+ String actionId = (String)userObject;
+ AnAction action = ActionManager.getInstance().getActionOrStub(actionId);
+ if (action == null) return null;
+
+ return action.getTemplatePresentation().getDescription();
+ }
+ });
myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
@@ -447,6 +481,7 @@ public class ActionsTree {
Icon icon = null;
String text;
boolean bound = false;
+ setToolTipText(null);
if (value instanceof DefaultMutableTreeNode) {
Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
@@ -474,6 +509,7 @@ public class ActionsTree {
if (actionIcon != null) {
icon = actionIcon;
}
+ setToolTipText(action.getTemplatePresentation().getDescription());
}
else {
text = actionId;
@@ -521,7 +557,7 @@ public class ActionsTree {
}
}
}
-
+
private void paintRowData(Tree tree, Object data, Rectangle bounds, Graphics2D g) {
Shortcut[] shortcuts = null;
Set<String> abbreviations = null;
@@ -552,7 +588,7 @@ public class ActionsTree {
Color c2 = new Color(208, 200, 66);
g.translate(0, bounds.y - 1);
-
+
for (Shortcut shortcut : shortcuts) {
int width = metrics.stringWidth(KeymapUtil.getShortcutText(shortcut));
UIUtil.drawSearchMatch(g, x, x + width, bounds.height, c1, c2);
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java
index c06dbee44c1a..429a55b2b809 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java
@@ -71,7 +71,7 @@ public class ConfigurableExtensionPointUtil {
idToConfigurable.put(parentId, parent.addChild(wrapper));
}
else {
- LOG.error("Can't find parent for " + parentId + " (" + wrapper + ")");
+ LOG.debug("Can't find parent for " + parentId + " (" + wrapper + ")");
}
}
}
@@ -79,8 +79,9 @@ public class ConfigurableExtensionPointUtil {
for (final Iterator<String> iterator = idToConfigurable.keySet().iterator(); iterator.hasNext(); ) {
final String key = iterator.next();
final ConfigurableWrapper wrapper = idToConfigurable.get(key);
- if (wrapper.getParentId() != null) {
- iterator.remove();
+ final String parentId = wrapper.getParentId();
+ if (parentId != null && idToConfigurable.containsKey(parentId)) {
+ iterator.remove(); // remove only processed parents
}
}
ContainerUtil.addAll(result, idToConfigurable.values());
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java
index f465e2d0fecb..f1411cf3551d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java
@@ -18,9 +18,11 @@ package com.intellij.openapi.options.ex;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurableGroup;
import com.intellij.openapi.options.OptionsBundle;
+import com.intellij.openapi.options.SearchableConfigurable;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map.Entry;
public final class MixedConfigurableGroup implements ConfigurableGroup {
@@ -66,6 +68,16 @@ public final class MixedConfigurableGroup implements ConfigurableGroup {
}
list.add(configurable);
}
+ ArrayList<Configurable> buildList = map.get("build");
+ if (buildList != null) {
+ NodeConfigurable buildTools = new NodeConfigurable("build.tools");
+ buildTools.add(find("MavenSettings", buildList.iterator()));
+ buildTools.add(find("reference.settingsdialog.project.gradle", buildList.iterator()));
+ buildTools.add(find("reference.settingsdialog.project.gant", buildList.iterator()));
+ if (buildTools.getConfigurables() != null) {
+ buildList.add(0, buildTools);
+ }
+ }
ArrayList<ConfigurableGroup> groups = new ArrayList<ConfigurableGroup>(map.size());
groups.add(new MixedConfigurableGroup("appearance", map));
groups.add(new MixedConfigurableGroup("editor", map));
@@ -80,4 +92,18 @@ public final class MixedConfigurableGroup implements ConfigurableGroup {
groups.add(other);
return groups.toArray(new ConfigurableGroup[groups.size()]);
}
+
+ private static Configurable find(String id, Iterator<Configurable> iterator) {
+ while (iterator.hasNext()) {
+ Configurable configurable = iterator.next();
+ if (configurable instanceof SearchableConfigurable) {
+ SearchableConfigurable sc = (SearchableConfigurable)configurable;
+ if (id.equals(sc.getId())) {
+ iterator.remove();
+ return configurable;
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ex/NodeConfigurable.java b/platform/platform-impl/src/com/intellij/openapi/options/ex/NodeConfigurable.java
new file mode 100644
index 000000000000..6571c7a63746
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/openapi/options/ex/NodeConfigurable.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.options.ex;
+
+import com.intellij.openapi.options.Configurable;
+import com.intellij.openapi.options.OptionsBundle;
+import com.intellij.openapi.options.SearchableConfigurable;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+
+public final class NodeConfigurable extends SearchableConfigurable.Parent.Abstract {
+ private final ArrayList<Configurable> myConfigurables = new ArrayList<Configurable>();
+ private final String myId;
+
+ public NodeConfigurable(@NotNull String id) {
+ myId = id;
+ }
+
+ public void add(Configurable configurable) {
+ if (configurable != null) {
+ super.disposeUIResources();
+ myConfigurables.add(configurable);
+ }
+ }
+
+ @Override
+ public void disposeUIResources() {
+ super.disposeUIResources();
+ myConfigurables.clear();
+ }
+
+ @NotNull
+ @Override
+ public String getId() {
+ return myId;
+ }
+
+ @Nullable
+ @Override
+ public String getHelpTopic() {
+ return myId;
+ }
+
+ @Nls
+ @Override
+ public String getDisplayName() {
+ return OptionsBundle.message("node.configurable." + myId + ".display.name");
+ }
+
+ @Override
+ protected Configurable[] buildConfigurables() {
+ int size = myConfigurables.size();
+ return size == 0 ? null : myConfigurables.toArray(new Configurable[size]);
+ }
+}
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java
index 07e5a93670e6..271539f038a0 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java
@@ -49,6 +49,7 @@ import com.intellij.ui.navigation.History;
import com.intellij.ui.navigation.Place;
import com.intellij.ui.speedSearch.ElementFilter;
import com.intellij.ui.treeStructure.SimpleNode;
+import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.update.Activatable;
import com.intellij.util.ui.update.MergingUpdateQueue;
@@ -87,6 +88,7 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
private final History myHistory = new History(this);
private final OptionsTree myTree;
+ private final SettingsTreeView myTreeView;
private final MySearchField mySearch;
private final Splitter myMainSplitter;
//[back/forward] JComponent myToolbarComponent;
@@ -126,7 +128,12 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
mySearch = new MySearchField() {
@Override
protected void onTextKeyEvent(final KeyEvent e) {
- myTree.processTextEvent(e);
+ if (myTreeView != null) {
+ myTreeView.myTree.processKeyEvent(e);
+ }
+ else {
+ myTree.processTextEvent(e);
+ }
}
};
@@ -144,12 +151,12 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
}
});
- myTree = new OptionsTree(myProject, groups, getContext()) {
+ final KeyListener listener = new KeyListener() {
@Override
- protected void onTreeKeyEvent(final KeyEvent e) {
+ public void keyTyped(KeyEvent event) {
myFilterDocumentWasChanged = false;
try {
- mySearch.keyEventToTextField(e);
+ mySearch.keyEventToTextField(event);
}
finally {
if (myFilterDocumentWasChanged && !isFilterFieldVisible()) {
@@ -157,10 +164,33 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
}
}
}
+
+ @Override
+ public void keyPressed(KeyEvent event) {
+ keyTyped(event);
+ }
+
+ @Override
+ public void keyReleased(KeyEvent event) {
+ keyTyped(event);
+ }
};
+ if (Registry.is("ide.file.settings.tree.new")) {
+ myTreeView = new SettingsTreeView(listener, getContext(), groups);
+ myTree = null;
+ }
+ else {
+ myTreeView = null;
+ myTree = new OptionsTree(myProject, groups, getContext()) {
+ @Override
+ protected void onTreeKeyEvent(final KeyEvent e) {
+ listener.keyTyped(e);
+ }
+ };
+ }
- getContext().addColleague(myTree);
- Disposer.register(this, myTree);
+ getContext().addColleague(myTreeView != null ? myTreeView : myTree);
+ Disposer.register(this, myTreeView != null ? myTreeView : myTree);
mySearch.addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
@@ -198,7 +228,8 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
@Override
public Dimension getMinimumSize() {
Dimension dimension = super.getMinimumSize();
- dimension.width = Math.max(myTree.getMinimumSize().width, mySearchWrapper.getPreferredSize().width);
+ JComponent component = myTreeView != null ? myTreeView : myTree;
+ dimension.width = Math.max(component.getMinimumSize().width, mySearchWrapper.getPreferredSize().width);
return dimension;
}
};
@@ -211,7 +242,7 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
*/
myLeftSide.add(mySearchWrapper, BorderLayout.NORTH);
- myLeftSide.add(myTree, BorderLayout.CENTER);
+ myLeftSide.add(myTreeView != null ? myTreeView : myTree, BorderLayout.CENTER);
setLayout(new BorderLayout());
@@ -233,9 +264,19 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
mySpotlightUpdate = new MergingUpdateQueue("OptionsSpotlight", 200, false, this, this, this);
if (preselectedConfigurable != null) {
- myTree.select(preselectedConfigurable);
+ if (myTreeView != null) {
+ myTreeView.select(preselectedConfigurable);
+ }
+ else {
+ myTree.select(preselectedConfigurable);
+ }
} else {
- myTree.selectFirst();
+ if (myTreeView != null) {
+ myTreeView.selectFirst();
+ }
+ else {
+ myTree.selectFirst();
+ }
}
Toolkit.getDefaultToolkit().addAWTEventListener(this,
@@ -295,12 +336,16 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
@Deprecated
@Nullable
public <T extends Configurable> T findConfigurable(Class<T> configurableClass) {
- return myTree.findConfigurable(configurableClass);
+ return myTreeView != null
+ ? myTreeView.findConfigurable(configurableClass)
+ : myTree.findConfigurable(configurableClass);
}
@Nullable
public SearchableConfigurable findConfigurableById(@NotNull String configurableId) {
- return myTree.findConfigurableById(configurableId);
+ return myTreeView != null
+ ? myTreeView.findConfigurableById(configurableId)
+ : myTree.findConfigurableById(configurableId);
}
public ActionCallback clearSearchAndSelect(Configurable configurable) {
@@ -318,7 +363,9 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
public ActionCallback select(Configurable configurable, final String text) {
myFilter.refilterFor(text, false, true);
- return myTree.select(configurable);
+ return myTreeView != null
+ ? myTreeView.select(configurable)
+ : myTree.select(configurable);
}
private float readProportion(final float defaultValue, final String propertyName) {
@@ -367,7 +414,10 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
myOwnDetails.setContent(myContentWrapper);
myOwnDetails.setBannerMinHeight(mySearchWrapper.getHeight());
myOwnDetails.setText(getBannerText(configurable));
- if (Registry.is("ide.file.settings.order.new")) {
+ if (myTreeView != null) {
+ myOwnDetails.forProject(myTreeView.findConfigurableProject(configurable));
+ }
+ else if (Registry.is("ide.file.settings.order.new")) {
myOwnDetails.forProject(myTree.getConfigurableProject(configurable));
}
@@ -385,7 +435,8 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
checkModified(oldConfigurable);
checkModified(configurable);
- if (myTree.myBuilder.getSelectedElements().size() == 0) {
+ FilteringTreeBuilder builder = myTreeView != null ? myTreeView.myBuilder : myTree.myBuilder;
+ if (builder.getSelectedElements().size() == 0) {
select(configurable).notify(result);
} else {
result.setDone();
@@ -507,6 +558,9 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
}
private String[] getBannerText(Configurable configurable) {
+ if (myTreeView != null) {
+ return myTreeView.getPathNames(configurable);
+ }
final List<Configurable> list = myTree.getPathToRoot(configurable);
final String[] result = new String[list.size()];
int add = 0;
@@ -795,7 +849,12 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
getContext().fireErrorsChanged(errors, null);
if (!errors.isEmpty()) {
- myTree.select(errors.keySet().iterator().next());
+ if (myTreeView != null) {
+ myTreeView.select(errors.keySet().iterator().next());
+ }
+ else {
+ myTree.select(errors.keySet().iterator().next());
+ }
}
}
@@ -835,7 +894,7 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
return myFiltered.contains(node.getConfigurable()) || isChildOfNameHit(node);
}
- return true;
+ return SettingsTreeView.isFiltered(myFiltered, myHits, value);
}
private boolean isChildOfNameHit(OptionsTree.EditorNode node) {
@@ -929,7 +988,8 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
myLastSelected = current;
}
- final ActionCallback callback = fireUpdate(adjustSelection ? myTree.findNodeFor(toSelect) : null, adjustSelection, now);
+ SimpleNode node = !adjustSelection ? null : myTreeView != null ? myTreeView.findNode(toSelect) : myTree.findNodeFor(toSelect);
+ final ActionCallback callback = fireUpdate(node, adjustSelection, now);
myFilterDocumentWasChanged = true;
@@ -965,7 +1025,12 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
myFilter.refilterFor(filter, false, true).doWhenDone(new Runnable() {
@Override
public void run() {
- myTree.select(config).notifyWhenDone(result);
+ if (myTreeView != null) {
+ myTreeView.select(config).notifyWhenDone(result);
+ }
+ else {
+ myTree.select(config).notifyWhenDone(result);
+ }
}
});
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java
index e0ab24815ece..175b994122ef 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java
@@ -23,6 +23,7 @@ import com.intellij.openapi.options.ConfigurableGroup;
import com.intellij.openapi.options.OptionsBundle;
import com.intellij.openapi.options.SearchableConfigurable;
import com.intellij.openapi.options.ex.ConfigurableWrapper;
+import com.intellij.openapi.options.ex.NodeConfigurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Disposer;
@@ -116,10 +117,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
}
});
- final JScrollPane scrolls = ScrollPaneFactory.createScrollPane(myTree);
- scrolls.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
-
- add(scrolls, BorderLayout.CENTER);
+ add(new StickySeparator(myTree), BorderLayout.CENTER);
mySelection = new MergingUpdateQueue("OptionsTree", 150, false, this, this, this).setRestartTimerOnAdd(true);
myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@@ -290,7 +288,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
}
class Renderer extends GroupedElementsRenderer.Tree {
-
+ private GroupSeparator mySeparator;
private JLabel myProjectIcon;
private JLabel myHandle;
@@ -298,7 +296,8 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
protected void layout() {
myRendererComponent.setOpaqueActive(false);
- myRendererComponent.add(mySeparatorComponent, BorderLayout.NORTH);
+ mySeparator = new GroupSeparator();
+ myRendererComponent.add(Registry.is("ide.file.settings.order.new") ? mySeparator : mySeparatorComponent, BorderLayout.NORTH);
final NonOpaquePanel content = new NonOpaquePanel(new BorderLayout());
myHandle = new JLabel("", SwingConstants.CENTER);
@@ -325,7 +324,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
JComponent result;
Color fg = UIUtil.getTreeTextForeground();
-
+ mySeparator.configure(null, false);
final Base base = extractNode(value);
if (base instanceof EditorNode) {
@@ -335,6 +334,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
final DefaultMutableTreeNode prevValue = ((DefaultMutableTreeNode)value).getPreviousSibling();
if (prevValue == null || prevValue instanceof LoadingNode) {
group = editor.getGroup();
+ mySeparator.configure(group, false);
}
else {
final Base prevBase = extractNode(prevValue);
@@ -342,6 +342,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
final EditorNode prevEditor = (EditorNode)prevBase;
if (prevEditor.getGroup() != editor.getGroup()) {
group = editor.getGroup();
+ mySeparator.configure(group, true);
}
}
}
@@ -404,8 +405,25 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
myTextLabel.setBorder(new EmptyBorder(1,2,1,0));
}
- Project project = getConfigurableProject(base);
- if (project != null && Registry.is("ide.file.settings.order.new")) {
+ Project project = null;
+ if (base != null && Registry.is("ide.file.settings.order.new")) {
+ SimpleNode parent = base.getParent();
+ if (parent == myRoot) {
+ project = getConfigurableProject(base); // show icon for top-level nodes
+ if (base.getConfigurable() instanceof NodeConfigurable) { // special case for custom subgroups (build.tools)
+ Configurable[] configurables = ((NodeConfigurable)base.getConfigurable()).getConfigurables();
+ if (configurables != null) { // assume that all configurables have the same project
+ project = getConfigurableProject(configurables[0]);
+ }
+ }
+ }
+ else if (parent instanceof Base && ((Base)parent).getConfigurable() instanceof NodeConfigurable) {
+ if (((Base)base.getParent()).getConfigurable() instanceof NodeConfigurable) {
+ project = getConfigurableProject(base); // special case for custom subgroups
+ }
+ }
+ }
+ if (project != null) {
myProjectIcon.setBackground(selected ? getSelectionBackground() : getBackground());
myProjectIcon.setIcon(selected ? AllIcons.General.ProjectConfigurableSelected : AllIcons.General.ProjectConfigurable);
myProjectIcon.setVisible(true);
@@ -903,4 +921,97 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
}
return getConfigurableProject(node.getParent());
}
+
+ private static final class GroupSeparator extends JLabel {
+ public static final int SPACE = 10;
+
+ public GroupSeparator() {
+ setFont(UIUtil.getLabelFont());
+ setFont(getFont().deriveFont(Font.BOLD));
+ }
+
+ public void configure(ConfigurableGroup group, boolean isSpaceNeeded) {
+ if (group == null) {
+ setVisible(false);
+ }
+ else {
+ setVisible(true);
+ int bottom = UIUtil.isUnderNativeMacLookAndFeel() ? 1 : 3;
+ int top = isSpaceNeeded
+ ? bottom + SPACE
+ : bottom;
+ setBorder(BorderFactory.createEmptyBorder(top, 3, bottom, 3));
+ setText(group.getDisplayName());
+ }
+ }
+ }
+
+ private static final class StickySeparator extends JComponent {
+ private final SimpleTree myTree;
+ private final JScrollPane myScroller;
+ private final GroupSeparator mySeparator;
+
+ public StickySeparator(SimpleTree tree) {
+ myTree = tree;
+ myScroller = ScrollPaneFactory.createScrollPane(myTree);
+ myScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ mySeparator = new GroupSeparator();
+ add(myScroller);
+ }
+
+ @Override
+ public void doLayout() {
+ myScroller.setBounds(0, 0, getWidth(), getHeight());
+ }
+
+ @Override
+ public void paint(Graphics g) {
+ super.paint(g);
+
+ if (Registry.is("ide.file.settings.order.new")) {
+ ConfigurableGroup group = getGroup(GroupSeparator.SPACE + mySeparator.getFont().getSize());
+ if (group != null && group == getGroup(-GroupSeparator.SPACE)) {
+ mySeparator.configure(group, false);
+
+ Rectangle bounds = myScroller.getViewport().getBounds();
+ int height = mySeparator.getPreferredSize().height;
+ if (bounds.height > height) {
+ bounds.height = height;
+ }
+ g.setColor(myTree.getBackground());
+ if (g instanceof Graphics2D) {
+ int h = bounds.height / 3;
+ int y = bounds.y + bounds.height - h;
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height - h);
+ ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(
+ 0, y, g.getColor(),
+ 0, y + h, ColorUtil.toAlpha(g.getColor(), 0)));
+ g.fillRect(bounds.x, y, bounds.width, h);
+ }
+ else {
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ }
+ mySeparator.setSize(bounds.width - 1, bounds.height);
+ mySeparator.paint(g.create(bounds.x + 1, bounds.y, bounds.width - 1, bounds.height));
+ }
+ }
+ }
+
+ private ConfigurableGroup getGroup(int offset) {
+ TreePath path = myTree.getClosestPathForLocation(-myTree.getX(), -myTree.getY() + offset);
+ SimpleNode node = myTree.getNodeFor(path);
+ if (node instanceof FilteringTreeStructure.FilteringNode) {
+ Object delegate = ((FilteringTreeStructure.FilteringNode)node).getDelegate();
+ while (delegate instanceof EditorNode) {
+ EditorNode editor = (EditorNode)delegate;
+ ConfigurableGroup group = editor.getGroup();
+ if (group != null) {
+ return group;
+ }
+ delegate = editor.getParent();
+ }
+ }
+ return null;
+ }
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsTreeView.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsTreeView.java
new file mode 100644
index 000000000000..9269da7ab967
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsTreeView.java
@@ -0,0 +1,864 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.options.newEditor;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.ide.ui.search.ConfigurableHit;
+import com.intellij.ide.util.treeView.NodeDescriptor;
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.options.*;
+import com.intellij.openapi.options.ex.ConfigurableWrapper;
+import com.intellij.openapi.options.ex.NodeConfigurable;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.ActionCallback;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.ui.*;
+import com.intellij.ui.treeStructure.*;
+import com.intellij.ui.treeStructure.filtered.FilteringTreeBuilder;
+import com.intellij.ui.treeStructure.filtered.FilteringTreeStructure;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.ui.GraphicsUtil;
+import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.tree.TreeUtil;
+import com.intellij.util.ui.update.MergingUpdateQueue;
+import com.intellij.util.ui.update.Update;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.util.List;
+import javax.swing.*;
+import javax.swing.event.TreeExpansionEvent;
+import javax.swing.event.TreeExpansionListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.plaf.TreeUI;
+import javax.swing.plaf.basic.BasicTreeUI;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
+
+/**
+ * @author Sergey.Malenkov
+ */
+final class SettingsTreeView extends JComponent implements Disposable, OptionsEditorColleague {
+ final SimpleTree myTree;
+ final FilteringTreeBuilder myBuilder;
+
+ private final OptionsEditorContext myContext;
+ private final MyRoot myRoot;
+ private final JScrollPane myScroller;
+ private JLabel mySeparator;
+ private final MyRenderer myRenderer = new MyRenderer();
+ private final IdentityHashMap<Configurable, MyNode> myConfigurableToNodeMap = new IdentityHashMap<Configurable, MyNode>();
+ private final MergingUpdateQueue myQueue = new MergingUpdateQueue("OptionsTree", 150, false, this, this, this).setRestartTimerOnAdd(true);
+
+ private Configurable myQueuedConfigurable;
+
+ SettingsTreeView(final KeyListener listener, OptionsEditorContext context, ConfigurableGroup... groups) {
+ myContext = context;
+ myRoot = new MyRoot(groups);
+
+ myTree = new MyTree();
+ myTree.getInputMap().clear();
+ TreeUtil.installActions(myTree);
+
+ myTree.setOpaque(true);
+ myTree.setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 0));
+
+ myTree.setRowHeight(-1);
+ myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+
+ myTree.setCellRenderer(myRenderer);
+ myTree.setRootVisible(false);
+ myTree.setShowsRootHandles(false);
+
+ myScroller = ScrollPaneFactory.createScrollPane(myTree);
+ myScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ add(myScroller);
+
+ myTree.addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ myBuilder.revalidateTree();
+ }
+
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ myBuilder.revalidateTree();
+ }
+
+ @Override
+ public void componentShown(ComponentEvent e) {
+ myBuilder.revalidateTree();
+ }
+ });
+
+ myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
+ public void valueChanged(TreeSelectionEvent event) {
+ MyNode node = extractNode(event.getNewLeadSelectionPath());
+ select(node == null ? null : node.myConfigurable);
+ }
+ });
+
+ myTree.addKeyListener(new KeyListener() {
+ public void keyTyped(KeyEvent event) {
+ if (listener != null && isValid(event)) {
+ listener.keyTyped(event);
+ }
+ }
+
+ public void keyPressed(KeyEvent event) {
+ if (listener != null && isValid(event)) {
+ listener.keyPressed(event);
+ }
+ }
+
+ public void keyReleased(KeyEvent event) {
+ if (listener != null && isValid(event)) {
+ listener.keyReleased(event);
+ }
+ }
+
+ private boolean isValid(KeyEvent event) {
+ return null == myTree.getInputMap().get(KeyStroke.getKeyStrokeForEvent(event));
+ }
+ });
+ myBuilder = new MyBuilder(new SimpleTreeStructure.Impl(myRoot));
+ myBuilder.setFilteringMerge(300, null);
+ Disposer.register(this, myBuilder);
+ }
+
+ @NotNull
+ String[] getPathNames(Configurable configurable) {
+ ArrayDeque<String> path = new ArrayDeque<String>();
+ MyNode node = myConfigurableToNodeMap.get(configurable);
+ while (node != null) {
+ path.push(node.myDisplayName);
+ SimpleNode parent = node.getParent();
+ node = parent instanceof MyNode
+ ? (MyNode)parent
+ : null;
+ }
+ return ArrayUtil.toStringArray(path);
+ }
+
+ @Nullable
+ SimpleNode findNode(Configurable toSelect) {
+ return myConfigurableToNodeMap.get(toSelect);
+ }
+
+ @Nullable
+ SearchableConfigurable findConfigurableById(@NotNull String id) {
+ for (Configurable configurable : myConfigurableToNodeMap.keySet()) {
+ if (configurable instanceof SearchableConfigurable) {
+ SearchableConfigurable searchable = (SearchableConfigurable)configurable;
+ if (id.equals(searchable.getId())) {
+ return searchable;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Nullable
+ <T extends UnnamedConfigurable> T findConfigurable(@NotNull Class<T> type) {
+ for (UnnamedConfigurable configurable : myConfigurableToNodeMap.keySet()) {
+ if (configurable instanceof ConfigurableWrapper) {
+ ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable;
+ configurable = wrapper.getConfigurable();
+ }
+ if (type.isInstance(configurable)) {
+ return type.cast(configurable);
+ }
+ }
+ return null;
+ }
+
+ @Nullable
+ Project findConfigurableProject(@Nullable Configurable configurable) {
+ if (configurable instanceof ConfigurableWrapper) {
+ ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable;
+ return wrapper.getExtensionPoint().getProject();
+ }
+ return findConfigurableProject(myConfigurableToNodeMap.get(configurable));
+ }
+
+ @Nullable
+ private static Project findConfigurableProject(@Nullable MyNode node) {
+ if (node != null) {
+ Configurable configurable = node.myConfigurable;
+ if (configurable instanceof ConfigurableWrapper) {
+ ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable;
+ return wrapper.getExtensionPoint().getProject();
+ }
+ SimpleNode parent = node.getParent();
+ if (parent instanceof MyNode) {
+ return findConfigurableProject((MyNode)parent);
+ }
+ }
+ return null;
+ }
+
+ @Nullable
+ private ConfigurableGroup findConfigurableGroupAt(int x, int y) {
+ TreePath path = myTree.getClosestPathForLocation(x - myTree.getX(), y - myTree.getY());
+ while (path != null) {
+ MyNode node = extractNode(path);
+ if (node == null) {
+ return null;
+ }
+ if (node.myComposite instanceof ConfigurableGroup) {
+ return (ConfigurableGroup)node.myComposite;
+ }
+ path = path.getParentPath();
+ }
+ return null;
+ }
+
+ @Nullable
+ private static MyNode extractNode(@Nullable Object object) {
+ if (object instanceof TreePath) {
+ TreePath path = (TreePath)object;
+ object = path.getLastPathComponent();
+ }
+ if (object instanceof DefaultMutableTreeNode) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)object;
+ object = node.getUserObject();
+ }
+ if (object instanceof FilteringTreeStructure.FilteringNode) {
+ FilteringTreeStructure.FilteringNode node = (FilteringTreeStructure.FilteringNode)object;
+ object = node.getDelegate();
+ }
+ return object instanceof MyNode
+ ? (MyNode)object
+ : null;
+ }
+
+ static boolean isFiltered(Set<Configurable> configurables, ConfigurableHit hits, SimpleNode value) {
+ if (value instanceof MyNode && !configurables.contains(((MyNode)value).myConfigurable)) {
+ if (hits != null) {
+ configurables = hits.getNameFullHits();
+ while (value != null) {
+ if (value instanceof MyNode) {
+ if (configurables.contains(((MyNode)value).myConfigurable)) {
+ return true;
+ }
+ }
+ value = value.getParent();
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void doLayout() {
+ myScroller.setBounds(0, 0, getWidth(), getHeight());
+ }
+
+ @Override
+ public void paint(Graphics g) {
+ super.paint(g);
+
+ if (mySeparator == null) {
+ mySeparator = new JLabel();
+ mySeparator.setFont(UIUtil.getLabelFont());
+ mySeparator.setFont(getFont().deriveFont(Font.BOLD));
+ }
+ ConfigurableGroup group = findConfigurableGroupAt(0, 5 + mySeparator.getFont().getSize());
+ if (group != null && group == findConfigurableGroupAt(0, -5)) {
+ int offset = UIUtil.isUnderNativeMacLookAndFeel() ? 1 : 3;
+ mySeparator.setBorder(BorderFactory.createEmptyBorder(offset, 18, offset, 3));
+ mySeparator.setText(group.getDisplayName());
+
+ Rectangle bounds = myScroller.getViewport().getBounds();
+ int height = mySeparator.getPreferredSize().height;
+ if (bounds.height > height) {
+ bounds.height = height;
+ }
+ g.setColor(myTree.getBackground());
+ if (g instanceof Graphics2D) {
+ int h = bounds.height / 4;
+ int y = bounds.y + bounds.height - h;
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height - h);
+ ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(
+ 0, y, g.getColor(),
+ 0, y + h, ColorUtil.toAlpha(g.getColor(), 0)));
+ g.fillRect(bounds.x, y, bounds.width, h + h);
+ }
+ else {
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ }
+ mySeparator.setSize(bounds.width - 1, bounds.height);
+ mySeparator.paint(g.create(bounds.x + 1, bounds.y, bounds.width - 1, bounds.height));
+ }
+ }
+
+ void selectFirst() {
+ for (ConfigurableGroup eachGroup : myRoot.myGroups) {
+ Configurable[] kids = eachGroup.getConfigurables();
+ if (kids.length > 0) {
+ select(kids[0]);
+ return;
+ }
+ }
+ }
+
+ ActionCallback select(@Nullable final Configurable configurable) {
+ if (myBuilder.isSelectionBeingAdjusted()) {
+ return new ActionCallback.Rejected();
+ }
+ final ActionCallback callback = new ActionCallback();
+ myQueuedConfigurable = configurable;
+ myQueue.queue(new Update(this) {
+ public void run() {
+ if (configurable == myQueuedConfigurable) {
+ if (configurable == null) {
+ fireSelected(null, callback);
+ }
+ else {
+ myBuilder.getReady(this).doWhenDone(new Runnable() {
+ @Override
+ public void run() {
+ if (configurable != myQueuedConfigurable) return;
+
+ MyNode editorNode = myConfigurableToNodeMap.get(configurable);
+ FilteringTreeStructure.FilteringNode editorUiNode = myBuilder.getVisibleNodeFor(editorNode);
+ if (editorUiNode == null) return;
+
+ if (!myBuilder.getSelectedElements().contains(editorUiNode)) {
+ myBuilder.select(editorUiNode, new Runnable() {
+ public void run() {
+ fireSelected(configurable, callback);
+ }
+ });
+ }
+ else {
+ myBuilder.scrollSelectionToVisible(new Runnable() {
+ public void run() {
+ fireSelected(configurable, callback);
+ }
+ }, false);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ @Override
+ public void setRejected() {
+ super.setRejected();
+ callback.setRejected();
+ }
+ });
+ return callback;
+ }
+
+ private void fireSelected(Configurable configurable, ActionCallback callback) {
+ myContext.fireSelected(configurable, this).doWhenProcessed(callback.createSetDoneRunnable());
+ }
+
+ @Override
+ public void dispose() {
+ myQueuedConfigurable = null;
+ }
+
+ @Override
+ public ActionCallback onSelected(@Nullable Configurable configurable, Configurable oldConfigurable) {
+ return select(configurable);
+ }
+
+ @Override
+ public ActionCallback onModifiedAdded(Configurable configurable) {
+ myTree.repaint();
+ return new ActionCallback.Done();
+ }
+
+ @Override
+ public ActionCallback onModifiedRemoved(Configurable configurable) {
+ myTree.repaint();
+ return new ActionCallback.Done();
+ }
+
+ @Override
+ public ActionCallback onErrorsChanged() {
+ return new ActionCallback.Done();
+ }
+
+ private final class MyRoot extends CachingSimpleNode {
+ private final ConfigurableGroup[] myGroups;
+
+ private MyRoot(ConfigurableGroup[] groups) {
+ super(null);
+ myGroups = groups;
+ }
+
+ @Override
+ protected SimpleNode[] buildChildren() {
+ if (myGroups == null || myGroups.length == 0) {
+ return NO_CHILDREN;
+ }
+ SimpleNode[] result = new SimpleNode[myGroups.length];
+ for (int i = 0; i < myGroups.length; i++) {
+ result[i] = new MyNode(this, myGroups[i]);
+ }
+ return result;
+ }
+ }
+
+ private final class MyNode extends CachingSimpleNode {
+ private final Configurable.Composite myComposite;
+ private final Configurable myConfigurable;
+ private final String myDisplayName;
+
+ private MyNode(CachingSimpleNode parent, Configurable configurable) {
+ super(parent);
+ myComposite = configurable instanceof Configurable.Composite ? (Configurable.Composite)configurable : null;
+ myConfigurable = configurable;
+ String name = configurable.getDisplayName();
+ myDisplayName = name != null ? name.replace("\n", " ") : "{ " + configurable.getClass().getSimpleName() + " }";
+
+ myConfigurableToNodeMap.put(configurable, this);
+ }
+
+ private MyNode(CachingSimpleNode parent, ConfigurableGroup group) {
+ super(parent);
+ myComposite = group;
+ myConfigurable = null;
+ String name = group.getDisplayName();
+ myDisplayName = name != null ? name.replace("\n", " ") : "{ " + group.getClass().getSimpleName() + " }";
+ }
+
+ @Override
+ protected SimpleNode[] buildChildren() {
+ if (myComposite == null) {
+ return NO_CHILDREN;
+ }
+ Configurable[] configurables = myComposite.getConfigurables();
+ if (configurables == null || configurables.length == 0) {
+ return NO_CHILDREN;
+ }
+ SimpleNode[] result = new SimpleNode[configurables.length];
+ for (int i = 0; i < configurables.length; i++) {
+ result[i] = new MyNode(this, configurables[i]);
+ if (myConfigurable != null) {
+ myContext.registerKid(myConfigurable, configurables[i]);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isAlwaysLeaf() {
+ return myComposite == null;
+ }
+
+ @Override
+ public int getWeight() {
+ return WeightBasedComparator.UNDEFINED_WEIGHT;
+ }
+ }
+
+ private final class MyRenderer extends GroupedElementsRenderer.Tree {
+ private JLabel myNodeIcon;
+ private JLabel myProjectIcon;
+
+ protected JComponent createItemComponent() {
+ myTextLabel = new ErrorLabel();
+ return myTextLabel;
+ }
+
+ @Override
+ protected void layout() {
+ myNodeIcon = new JLabel(" ", SwingConstants.RIGHT);
+ myProjectIcon = new JLabel(" ", SwingConstants.LEFT);
+ myProjectIcon.setOpaque(true);
+ myRendererComponent.add(BorderLayout.NORTH, mySeparatorComponent);
+ myRendererComponent.add(BorderLayout.CENTER, myComponent);
+ myRendererComponent.add(BorderLayout.WEST, myNodeIcon);
+ myRendererComponent.add(BorderLayout.EAST, myProjectIcon);
+ }
+
+ public Component getTreeCellRendererComponent(JTree tree,
+ Object value,
+ boolean selected,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean focused) {
+ myTextLabel.setOpaque(selected);
+ myTextLabel.setFont(UIUtil.getLabelFont());
+
+ String text;
+ boolean hasSeparatorAbove = false;
+ int preferredForcedWidth = -1;
+
+ MyNode node = extractNode(value);
+ if (node == null) {
+ text = value.toString();
+ }
+ else {
+ text = node.myDisplayName;
+ // show groups in bold
+ if (myRoot == node.getParent()) {
+ hasSeparatorAbove = node != myRoot.getChildAt(0);
+ myTextLabel.setFont(myTextLabel.getFont().deriveFont(Font.BOLD));
+ }
+ TreePath path = tree.getPathForRow(row);
+ if (path == null) {
+ if (value instanceof DefaultMutableTreeNode) {
+ path = new TreePath(((DefaultMutableTreeNode)value).getPath());
+ }
+ }
+ int forcedWidth = 2000;
+ if (path != null && tree.isVisible()) {
+ Rectangle visibleRect = tree.getVisibleRect();
+
+ int nestingLevel = tree.isRootVisible() ? path.getPathCount() - 1 : path.getPathCount() - 2;
+
+ int left = UIUtil.getTreeLeftChildIndent();
+ int right = UIUtil.getTreeRightChildIndent();
+
+ Insets treeInsets = tree.getInsets();
+
+ int indent = (left + right) * nestingLevel + (treeInsets != null ? treeInsets.left + treeInsets.right : 0);
+
+ forcedWidth = visibleRect.width > 0 ? visibleRect.width - indent : forcedWidth;
+ }
+ preferredForcedWidth = forcedWidth - 4;
+ }
+ Component result = configureComponent(text, null, null, null, selected, hasSeparatorAbove, null, preferredForcedWidth);
+ // update font color for modified configurables
+ if (!selected && node != null) {
+ Configurable configurable = node.myConfigurable;
+ if (configurable != null) {
+ if (myContext.getErrors().containsKey(configurable)) {
+ myTextLabel.setForeground(JBColor.RED);
+ }
+ else if (myContext.getModified().contains(configurable)) {
+ myTextLabel.setForeground(JBColor.BLUE);
+ }
+ }
+ }
+ // configure project icon
+ Project project = null;
+ if (node != null) {
+ SimpleNode parent = node.getParent();
+ if (parent instanceof MyNode) {
+ if (myRoot == parent.getParent()) {
+ project = findConfigurableProject(node); // show icon for top-level nodes
+ if (node.myConfigurable instanceof NodeConfigurable) { // special case for custom subgroups (build.tools)
+ Configurable[] configurables = ((NodeConfigurable)node.myConfigurable).getConfigurables();
+ if (configurables != null) { // assume that all configurables have the same project
+ project = findConfigurableProject(configurables[0]);
+ }
+ }
+ }
+ else if (((MyNode)parent).myConfigurable instanceof NodeConfigurable) {
+ if (((MyNode)node.getParent()).myConfigurable instanceof NodeConfigurable) {
+ project = findConfigurableProject(node); // special case for custom subgroups
+ }
+ }
+ }
+ }
+ if (project != null) {
+ myProjectIcon.setIcon(selected
+ ? AllIcons.General.ProjectConfigurableSelected
+ : AllIcons.General.ProjectConfigurable);
+ myProjectIcon.setToolTipText(OptionsBundle.message(project.isDefault()
+ ? "configurable.default.project.tooltip"
+ : "configurable.current.project.tooltip"));
+ myProjectIcon.setBackground(myTextLabel.getBackground());
+ myProjectIcon.setVisible(true);
+ }
+ else {
+ myProjectIcon.setVisible(false);
+ }
+ // configure node icon
+ if (value instanceof DefaultMutableTreeNode) {
+ DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value;
+ TreePath treePath = new TreePath(treeNode.getPath());
+ myNodeIcon.setIcon(myTree.getHandleIcon(treeNode, treePath));
+ }
+ else {
+ myNodeIcon.setIcon(null);
+ }
+ return result;
+ }
+
+
+ public boolean isUnderHandle(Point point) {
+ Point handlePoint = SwingUtilities.convertPoint(myRendererComponent, point, myNodeIcon);
+ Rectangle bounds = myNodeIcon.getBounds();
+ return bounds.x < handlePoint.x && bounds.getMaxX() >= handlePoint.x;
+ }
+ }
+
+ private final class MyTree extends SimpleTree {
+ @Override
+ public String getToolTipText(MouseEvent event) {
+ if (event != null) {
+ Component component = getDeepestRendererComponentAt(event.getX(), event.getY());
+ if (component instanceof JLabel) {
+ JLabel label = (JLabel)component;
+ if (label.getIcon() != null) {
+ String text = label.getToolTipText();
+ if (text != null) {
+ return text;
+ }
+ }
+ }
+ }
+ return super.getToolTipText(event);
+ }
+
+ @Override
+ protected boolean paintNodes() {
+ return false;
+ }
+
+ @Override
+ protected boolean highlightSingleNode() {
+ return false;
+ }
+
+ @Override
+ public void setUI(TreeUI ui) {
+ TreeUI actualUI = ui;
+ if (!(ui instanceof MyTreeUi)) {
+ actualUI = new MyTreeUi();
+ }
+ super.setUI(actualUI);
+ }
+
+ @Override
+ protected boolean isCustomUI() {
+ return true;
+ }
+
+ @Override
+ protected void configureUiHelper(TreeUIHelper helper) {
+ }
+
+ @Override
+ public boolean getScrollableTracksViewportWidth() {
+ return true;
+ }
+
+
+ @Override
+ public void processKeyEvent(KeyEvent e) {
+ TreePath path = myTree.getSelectionPath();
+ if (path != null) {
+ if (e.getKeyCode() == KeyEvent.VK_LEFT) {
+ if (isExpanded(path)) {
+ collapsePath(path);
+ return;
+ }
+ }
+ else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
+ if (isCollapsed(path)) {
+ expandPath(path);
+ return;
+ }
+ }
+ }
+ super.processKeyEvent(e);
+ }
+
+ @Override
+ protected void processMouseEvent(MouseEvent e) {
+ MyTreeUi ui = (MyTreeUi)myTree.getUI();
+ boolean toggleNow = MouseEvent.MOUSE_RELEASED == e.getID()
+ && UIUtil.isActionClick(e, MouseEvent.MOUSE_RELEASED)
+ && !ui.isToggleEvent(e);
+
+ if (toggleNow || MouseEvent.MOUSE_PRESSED == e.getID()) {
+ TreePath path = getPathForLocation(e.getX(), e.getY());
+ if (path != null) {
+ Rectangle bounds = getPathBounds(path);
+ if (bounds != null && path.getLastPathComponent() instanceof DefaultMutableTreeNode) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
+ boolean selected = isPathSelected(path);
+ boolean expanded = isExpanded(path);
+ Component comp =
+ myRenderer.getTreeCellRendererComponent(this, node, selected, expanded, node.isLeaf(), getRowForPath(path), isFocusOwner());
+
+ comp.setBounds(bounds);
+ comp.validate();
+
+ Point point = new Point(e.getX() - bounds.x, e.getY() - bounds.y);
+ if (myRenderer.isUnderHandle(point)) {
+ if (toggleNow) {
+ ui.toggleExpandState(path);
+ }
+ e.consume();
+ return;
+ }
+ }
+ }
+ }
+
+ super.processMouseEvent(e);
+ }
+
+ private final class MyTreeUi extends BasicTreeUI {
+
+ @Override
+ public void toggleExpandState(TreePath path) {
+ super.toggleExpandState(path);
+ }
+
+ @Override
+ public boolean isToggleEvent(MouseEvent event) {
+ return super.isToggleEvent(event);
+ }
+
+ @Override
+ protected boolean shouldPaintExpandControl(TreePath path,
+ int row,
+ boolean isExpanded,
+ boolean hasBeenExpanded,
+ boolean isLeaf) {
+ return false;
+ }
+
+ @Override
+ protected void paintHorizontalPartOfLeg(Graphics g,
+ Rectangle clipBounds,
+ Insets insets,
+ Rectangle bounds,
+ TreePath path,
+ int row,
+ boolean isExpanded,
+ boolean hasBeenExpanded,
+ boolean isLeaf) {
+
+ }
+
+ @Override
+ protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path) {
+ }
+
+ @Override
+ public void paint(Graphics g, JComponent c) {
+ GraphicsUtil.setupAntialiasing(g);
+ super.paint(g, c);
+ }
+ }
+ }
+
+ private final class MyBuilder extends FilteringTreeBuilder {
+
+ List<Object> myToExpandOnResetFilter;
+ boolean myRefilteringNow;
+ boolean myWasHoldingFilter;
+
+ public MyBuilder(SimpleTreeStructure structure) {
+ super(myTree, myContext.getFilter(), structure, new WeightBasedComparator(false));
+ myTree.addTreeExpansionListener(new TreeExpansionListener() {
+ public void treeExpanded(TreeExpansionEvent event) {
+ invalidateExpansions();
+ }
+
+ public void treeCollapsed(TreeExpansionEvent event) {
+ invalidateExpansions();
+ }
+ });
+ }
+
+ private void invalidateExpansions() {
+ if (!myRefilteringNow) {
+ myToExpandOnResetFilter = null;
+ }
+ }
+
+ @Override
+ protected boolean isSelectable(Object object) {
+ return object instanceof MyNode;
+ }
+
+ @Override
+ public boolean isAutoExpandNode(NodeDescriptor nodeDescriptor) {
+ return myContext.isHoldingFilter();
+ }
+
+ @Override
+ public boolean isToEnsureSelectionOnFocusGained() {
+ return false;
+ }
+
+ @Override
+ protected ActionCallback refilterNow(Object preferredSelection, boolean adjustSelection) {
+ final List<Object> toRestore = new ArrayList<Object>();
+ if (myContext.isHoldingFilter() && !myWasHoldingFilter && myToExpandOnResetFilter == null) {
+ myToExpandOnResetFilter = myBuilder.getUi().getExpandedElements();
+ }
+ else if (!myContext.isHoldingFilter() && myWasHoldingFilter && myToExpandOnResetFilter != null) {
+ toRestore.addAll(myToExpandOnResetFilter);
+ myToExpandOnResetFilter = null;
+ }
+
+ myWasHoldingFilter = myContext.isHoldingFilter();
+
+ ActionCallback result = super.refilterNow(preferredSelection, adjustSelection);
+ myRefilteringNow = true;
+ return result.doWhenDone(new Runnable() {
+ public void run() {
+ myRefilteringNow = false;
+ if (!myContext.isHoldingFilter() && getSelectedElements().isEmpty()) {
+ restoreExpandedState(toRestore);
+ }
+ }
+ });
+ }
+
+ private void restoreExpandedState(List<Object> toRestore) {
+ TreePath[] selected = myTree.getSelectionPaths();
+ if (selected == null) {
+ selected = new TreePath[0];
+ }
+
+ List<TreePath> toCollapse = new ArrayList<TreePath>();
+
+ for (int eachRow = 0; eachRow < myTree.getRowCount(); eachRow++) {
+ if (!myTree.isExpanded(eachRow)) continue;
+
+ TreePath eachVisiblePath = myTree.getPathForRow(eachRow);
+ if (eachVisiblePath == null) continue;
+
+ Object eachElement = myBuilder.getElementFor(eachVisiblePath.getLastPathComponent());
+ if (toRestore.contains(eachElement)) continue;
+
+
+ for (TreePath eachSelected : selected) {
+ if (!eachVisiblePath.isDescendant(eachSelected)) {
+ toCollapse.add(eachVisiblePath);
+ }
+ }
+ }
+
+ for (TreePath each : toCollapse) {
+ myTree.collapsePath(each);
+ }
+ }
+ }
+}
diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java
index 27bb8eb5f245..6a37bb2fb69e 100644
--- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java
@@ -17,7 +17,6 @@ package com.intellij.openapi.progress.impl;
import com.intellij.concurrency.JobScheduler;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ex.ApplicationEx;
@@ -46,7 +45,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-public class ProgressManagerImpl extends ProgressManager implements Disposable{
+public class ProgressManagerImpl extends ProgressManager implements Disposable {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.impl.ProgressManagerImpl");
private final AtomicInteger myCurrentUnsafeProgressCount = new AtomicInteger(0);
private final AtomicInteger myCurrentModalProgressCount = new AtomicInteger(0);
@@ -55,7 +54,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
private static final boolean DISABLED = "disabled".equals(System.getProperty("idea.ProcessCanceledException"));
private final ScheduledFuture<?> myCheckCancelledFuture;
- public ProgressManagerImpl(Application application) {
+ public ProgressManagerImpl() {
if (DISABLED) {
myCheckCancelledFuture = null;
}
@@ -64,7 +63,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
@Override
public void run() {
ourNeedToCheckCancel = true;
- ProgressIndicatorProvider.ourNeedToCheckCancel = true;
}
}, 0, 10, TimeUnit.MILLISECONDS);
}
@@ -86,7 +84,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
if (ourLockedCheckCounter > 10) {
ourLockedCheckCounter = 0;
ourNeedToCheckCancel = true;
- ProgressIndicatorProvider.ourNeedToCheckCancel = true;
}
}
else {
@@ -99,7 +96,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
public static void canceled() {
ourNeedToCheckCancel = true;
- ProgressIndicatorProvider.ourNeedToCheckCancel = true;
}
private static class NonCancelableIndicator extends EmptyProgressIndicator implements NonCancelableSection {
@@ -371,6 +367,14 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
public static Future<?> runProcessWithProgressAsynchronously(@NotNull final Task.Backgroundable task,
@NotNull final ProgressIndicator progressIndicator,
@Nullable final Runnable continuation) {
+ return runProcessWithProgressAsynchronously(task, progressIndicator, continuation, ModalityState.NON_MODAL);
+ }
+
+ @NotNull
+ public static Future<?> runProcessWithProgressAsynchronously(@NotNull final Task.Backgroundable task,
+ @NotNull final ProgressIndicator progressIndicator,
+ @Nullable final Runnable continuation,
+ @NotNull final ModalityState modalityState) {
if (progressIndicator instanceof Disposable) {
Disposer.register(ApplicationManager.getApplication(), (Disposable)progressIndicator);
}
@@ -397,7 +401,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
public void run() {
task.onCancel();
}
- }, ModalityState.NON_MODAL);
+ }, modalityState);
}
else {
final Task.NotificationInfo notificationInfo = task.notifyFinished();
@@ -412,7 +416,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
public void run() {
task.onSuccess();
}
- }, ModalityState.NON_MODAL);
+ }, modalityState);
}
}
};
@@ -493,10 +497,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable{
@Override
public void dispose() {
- stopCheckCanceled();
- }
-
- private void stopCheckCanceled() {
if (myCheckCancelledFuture != null) myCheckCancelledFuture.cancel(false);
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorUtils.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorUtils.java
index b98f19b25d17..0c18cb7706d9 100644
--- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorUtils.java
+++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorUtils.java
@@ -61,7 +61,7 @@ public class ProgressIndicatorUtils {
runWithWriteActionPriority(new ProgressIndicatorBase(), task);
}
- public static void runWithWriteActionPriority(final ProgressIndicator progressIndicator, final ReadTask task) {
+ private static void surroundWithListener(@NotNull final ProgressIndicator progressIndicator, @NotNull Runnable runnable) {
final ApplicationAdapter listener = new ApplicationAdapter() {
@Override
public void beforeWriteActionStart(Object action) {
@@ -69,45 +69,70 @@ public class ProgressIndicatorUtils {
}
};
final Application application = ApplicationManager.getApplication();
+ application.addApplicationListener(listener);
try {
- application.addApplicationListener(listener);
- ProgressManager.getInstance().runProcess(new Runnable(){
- @Override
- public void run() {
- // This read action can possible last for a long time, we want it to stop immediately on the first write access.
- // For this purpose we launch it under empty progress and invoke progressIndicator#cancel on write access to avoid possible write lock delays.
- try {
- application.runReadAction(new Runnable() {
- @Override
- public void run() {
- task.computeInReadAction(progressIndicator);
- }
- });
- }
- catch (ProcessCanceledException ignore) {
- }
- finally {
- if (progressIndicator.isCanceled()) {
- task.onCanceled(progressIndicator);
- }
- }
- }
- }, progressIndicator);
+ runnable.run();
}
finally {
application.removeApplicationListener(listener);
}
}
+
+ public static void runWithWriteActionPriority(@NotNull final ProgressIndicator progressIndicator, @NotNull final ReadTask task) {
+ surroundWithListener(progressIndicator, new Runnable() {
+ @Override
+ public void run() {
+ runUnderProgress(progressIndicator, task);
+ }
+ });
+ }
+
+ private static void runUnderProgress(@NotNull final ProgressIndicator progressIndicator, @NotNull final ReadTask task) {
+ ProgressManager.getInstance().runProcess(new Runnable() {
+ @Override
+ public void run() {
+ // This read action can possible last for a long time, we want it to stop immediately on the first write access.
+ // For this purpose we launch it under empty progress and invoke progressIndicator#cancel on write access to avoid possible write lock delays.
+ try {
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ task.computeInReadAction(progressIndicator);
+ }
+ });
+ }
+ catch (ProcessCanceledException ignore) {
+ }
+ finally {
+ if (progressIndicator.isCanceled()) {
+ task.onCanceled(progressIndicator);
+ }
+ }
+ }
+ }, progressIndicator);
+ }
+
public static void scheduleWithWriteActionPriority(@NotNull final ReadTask task) {
scheduleWithWriteActionPriority(new ProgressIndicatorBase(), task);
}
- public static void scheduleWithWriteActionPriority(final ProgressIndicator indicator, final ReadTask task) {
- ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+ public static void scheduleWithWriteActionPriority(@NotNull final ProgressIndicator indicator, @NotNull final ReadTask task) {
+ // we have to attach listeners in EDT to avoid "fire write action started while attach listeners from another thread" race condition
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- runWithWriteActionPriority(indicator, task);
+ surroundWithListener(indicator, new Runnable() {
+ @Override
+ public void run() {
+ ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+ @Override
+ public void run() {
+ runUnderProgress(indicator, task);
+ }
+ });
+ }
+ });
}
});
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java
index a20df87718cc..308edb2d81a6 100644
--- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java
@@ -392,7 +392,7 @@ public class DumbServiceImpl extends DumbService implements Disposable {
}
private class AppIconProgress extends ProgressIndicatorBase {
- double lastFraction;
+ private double lastFraction;
@Override
public void setFraction(final double fraction) {
@@ -408,16 +408,18 @@ public class DumbServiceImpl extends DumbService implements Disposable {
@Override
public void finish(@NotNull TaskInfo task) {
- UIUtil.invokeLaterIfNeeded(new Runnable() {
- @Override
- public void run() {
- AppIcon appIcon = AppIcon.getInstance();
- if (appIcon.hideProgress(myProject, "indexUpdate")) {
- appIcon.requestAttention(myProject, false);
- appIcon.setOkBadge(myProject, true);
+ if (lastFraction != 0) { // we should call setProgress at least once before
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ AppIcon appIcon = AppIcon.getInstance();
+ if (appIcon.hideProgress(myProject, "indexUpdate")) {
+ appIcon.requestAttention(myProject, false);
+ appIcon.setOkBadge(myProject, true);
+ }
}
- }
- });
+ });
+ }
}
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
index d1abc0816845..d1573e2adc7f 100644
--- a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java
@@ -745,16 +745,6 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
@Override
public void windowOpened(WindowEvent e) {
- if (!isModal()) {
- DialogWrapper wrapper = getDialogWrapper();
- if (wrapper != null) {
- JComponent component = wrapper.getPreferredFocusedComponent();
- if (component != null) {
- // request focus for non-modal dialog (i.e. TipDialog)
- IdeFocusManager.findInstance().requestFocus(component, true);
- }
- }
- }
if (!SystemInfo.isMacOSLion) return;
Window window = e.getWindow();
if (window instanceof Dialog) {
@@ -774,14 +764,9 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
queue.getKeyEventDispatcher().resetState();
}
- // if (myProject != null) {
- // Project project = myProject.get();
- //if (project != null && !project.isDisposed() && project.isInitialized()) {
- // // IdeFocusManager.findInstanceByComponent(this).requestFocus(new MyFocusCommand(dialogWrapper), true);
- //}
- // }
}
+ // Workaround for switching workspaces on dialog show
if (SystemInfo.isMac && myProject != null && Registry.is("ide.mac.fix.dialog.showing") && !dialogWrapper.isModalProgress()) {
final IdeFrame frame = WindowManager.getInstance().getIdeFrame(myProject.get());
AppIcon.getInstance().requestFocus(frame);
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java
index 9739d75be7e7..c93e69438766 100644
--- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java
+++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/PluginDownloader.java
@@ -61,6 +61,7 @@ public class PluginDownloader {
private String myFileName;
private String myPluginName;
+ private BuildNumber myBuildNumber;
private File myFile;
private File myOldFile;
@@ -74,12 +75,18 @@ public class PluginDownloader {
myPluginVersion = pluginVersion;
}
- public PluginDownloader(String pluginId, String pluginUrl, String pluginVersion, String fileName, String pluginName) {
+ public PluginDownloader(String pluginId,
+ String pluginUrl,
+ String pluginVersion,
+ String fileName,
+ String pluginName,
+ BuildNumber buildNumber) {
myPluginId = pluginId;
myPluginUrl = pluginUrl;
myPluginVersion = pluginVersion;
myFileName = fileName;
myPluginName = pluginName;
+ myBuildNumber = buildNumber;
}
@SuppressWarnings("UnusedDeclaration")
@@ -89,7 +96,7 @@ public class PluginDownloader {
}
public boolean prepareToInstall(ProgressIndicator pi) throws IOException {
- return prepareToInstall(pi, null);
+ return prepareToInstall(pi, myBuildNumber);
}
public boolean prepareToInstall(@Nullable ProgressIndicator pi, @Nullable BuildNumber forBuildNumber) throws IOException {
@@ -289,9 +296,15 @@ public class PluginDownloader {
}
private URLConnection openConnection(final String url) throws IOException {
- final URLConnection connection = ApplicationManager.getApplication() != null
- ? HttpConfigurable.getInstance().openConnection(url)
- : new URL(url).openConnection();
+ final URLConnection connection;
+ if (ApplicationManager.getApplication() != null) {
+ connection = HttpConfigurable.getInstance().openConnection(url);
+ }
+ else {
+ connection = new URL(url).openConnection();
+ connection.setConnectTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
+ connection.setReadTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
+ }
if (connection instanceof HttpURLConnection) {
final int responseCode = ((HttpURLConnection)connection).getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
@@ -385,9 +398,14 @@ public class PluginDownloader {
}
public static PluginDownloader createDownloader(IdeaPluginDescriptor descriptor) throws UnsupportedEncodingException {
+ return createDownloader(descriptor, null);
+ }
+
+ public static PluginDownloader createDownloader(IdeaPluginDescriptor descriptor,
+ BuildNumber buildNumber) throws UnsupportedEncodingException {
PluginDownloader downloader = new PluginDownloader(descriptor.getPluginId().getIdString(),
- UpdateChecker.getDownloadUrl(descriptor),
- descriptor.getVersion(), null, descriptor.getName());
+ UpdateChecker.getDownloadUrl(descriptor, buildNumber),
+ descriptor.getVersion(), null, descriptor.getName(), buildNumber);
downloader.setDescriptor(descriptor);
return downloader;
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java
index 354f89c22820..83858cc4fb40 100644
--- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java
+++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java
@@ -239,13 +239,13 @@ public final class UpdateChecker {
updateSettings.myOutdatedPlugins.clear();
if (!toUpdate.isEmpty()) {
try {
- final List<IdeaPluginDescriptor> process = RepositoryHelper.loadPluginsFromRepository(indicator);
+ final List<IdeaPluginDescriptor> process = RepositoryHelper.loadPluginsFromRepository(indicator, buildNumber);
for (IdeaPluginDescriptor loadedPlugin : process) {
final PluginId pluginId = loadedPlugin.getPluginId();
final String idString = pluginId.getIdString();
if (!toUpdate.containsKey(idString)) continue;
if (!downloaded.containsKey(pluginId)) {
- prepareToInstall(PluginDownloader.createDownloader(loadedPlugin), buildNumber, downloaded, incompatiblePlugins, true, indicator);
+ prepareToInstall(PluginDownloader.createDownloader(loadedPlugin, buildNumber), buildNumber, downloaded, incompatiblePlugins, true, indicator);
}
}
}
@@ -376,7 +376,7 @@ public final class UpdateChecker {
final List<IdeaPluginDescriptor> descriptors = RepositoryHelper.loadPluginsFromDescription(inputStream, indicator);
for (IdeaPluginDescriptor descriptor : descriptors) {
((PluginNode)descriptor).setRepositoryName(host);
- prepareToInstall(PluginDownloader.createDownloader(descriptor), buildNumber, downloaded, incompatiblePlugins, collectToUpdate,
+ prepareToInstall(PluginDownloader.createDownloader(descriptor, buildNumber), buildNumber, downloaded, incompatiblePlugins, collectToUpdate,
indicator);
}
@@ -424,7 +424,7 @@ public final class UpdateChecker {
if (progressIndicator != null) {
progressIndicator.setText2(finalPluginUrl);
}
- final PluginDownloader downloader = new PluginDownloader(pluginId, finalPluginUrl, pluginVersion, null, null);
+ final PluginDownloader downloader = new PluginDownloader(pluginId, finalPluginUrl, pluginVersion, null, null, buildNumber);
prepareToInstall(downloader, buildNumber, downloaded, incompatiblePlugins, collectToUpdate, indicator);
}
catch (IOException e) {
@@ -624,11 +624,15 @@ public final class UpdateChecker {
urlToCheck = url;
}
- HttpURLConnection connection = ApplicationManager.getApplication() != null ?
- HttpConfigurable.getInstance().openHttpConnection(urlToCheck) :
- (HttpURLConnection)new URL(urlToCheck).openConnection();
- connection.setReadTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
- connection.setConnectTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
+ HttpURLConnection connection;
+ if (ApplicationManager.getApplication() != null) {
+ connection = HttpConfigurable.getInstance().openHttpConnection(urlToCheck);
+ }
+ else {
+ connection = (HttpURLConnection)new URL(urlToCheck).openConnection();
+ connection.setReadTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
+ connection.setConnectTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
+ }
connection.connect();
inputStreams[0] = connection.getInputStream();
@@ -862,7 +866,7 @@ public final class UpdateChecker {
}
}
- static String getDownloadUrl(IdeaPluginDescriptor descriptor) throws UnsupportedEncodingException {
+ static String getDownloadUrl(IdeaPluginDescriptor descriptor, @Nullable BuildNumber buildNumber) throws UnsupportedEncodingException {
String url = null;
if (descriptor instanceof PluginNode) {
url = ((PluginNode)descriptor).getDownloadUrl();
@@ -881,11 +885,13 @@ public final class UpdateChecker {
String uuid = ApplicationManager.getApplication() == null ?
UUID.randomUUID().toString() :
getInstallationUID(PropertiesComponent.getInstance());
- String buildNumber = ApplicationManager.getApplication() != null
- ? ApplicationInfo.getInstance().getApiVersion()
- : ApplicationInfoImpl.getShadowInstance().getBuild().asString();
+ String buildNumberAsString = buildNumber != null
+ ? buildNumber.asString()
+ : ApplicationManager.getApplication() != null
+ ? ApplicationInfo.getInstance().getApiVersion()
+ : ApplicationInfoImpl.getShadowInstance().getBuild().asString();
url = RepositoryHelper.getDownloadUrl() + URLEncoder.encode(descriptor.getPluginId().getIdString(), "UTF8") +
- "&build=" + buildNumber + "&uuid=" + URLEncoder.encode(uuid, "UTF8");
+ "&build=" + buildNumberAsString + "&uuid=" + URLEncoder.encode(uuid, "UTF8");
}
return url;
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java
index d1010f52e1b1..9c6c6a2020e5 100644
--- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java
+++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesXmlLoader.java
@@ -32,6 +32,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
+import java.net.URLConnection;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
@@ -67,7 +68,10 @@ public class UpdatesXmlLoader {
URL requestUrl = prepareRequestUrl(updateUrl);
- final InputStream inputStream = requestUrl.openStream();
+ URLConnection connection = requestUrl.openConnection();
+ connection.setConnectTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
+ connection.setReadTimeout(HttpConfigurable.CONNECTION_TIMEOUT);
+ final InputStream inputStream = connection.getInputStream();
Reader reader = new InputStreamReader(inputStream);
try {
return new UpdatesInfo(JDOMUtil.loadDocument(inputStream).getRootElement());
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerEx.java b/platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerEx.java
index fbe213f20bb0..2bff2a10d5cd 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerEx.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/ex/ToolWindowManagerEx.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -28,7 +28,7 @@ import javax.swing.*;
import java.util.List;
public abstract class ToolWindowManagerEx extends ToolWindowManager {
- public abstract void initToolWindow(ToolWindowEP bean);
+ public abstract void initToolWindow(@NotNull ToolWindowEP bean);
public static ToolWindowManagerEx getInstanceEx(final Project project){
return (ToolWindowManagerEx)getInstance(project);
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java
index c302cce7572e..867c404073d3 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/FocusManagerImpl.java
@@ -203,9 +203,6 @@ public class FocusManagerImpl extends IdeFocusManager implements Disposable {
public ActionCallback requestFocus(@NotNull final FocusCommand command, final boolean forced) {
assertDispatchThread();
- if (!forced && !command.canFocusChangeFrom(getFocusOwner())) {
- return ActionCallback.REJECTED;
- }
if (isInternalMode) {
recordCommand(command, new Throwable(), forced);
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.java
index 71f964504102..1613953287b6 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.java
@@ -24,8 +24,6 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.Divider;
import com.intellij.openapi.ui.Painter;
import com.intellij.openapi.ui.impl.GlassPaneDialogWrapperPeer;
-import com.intellij.openapi.ui.popup.Balloon;
-import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Weighted;
import com.intellij.openapi.wm.IdeGlassPane;
@@ -287,8 +285,6 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
return false;
}
- private MouseEvent myLastRedispatchedEvent = null;
-
private boolean preprocess(final MouseEvent e, final boolean motion, JRootPane eventRootPane) {
try {
final MouseEvent event = convertEvent(e, eventRootPane);
@@ -297,25 +293,6 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
return false;
}
- Component c = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
- Balloon balloon = JBPopupFactory.getInstance().getParentBalloonFor(c);
- if (balloon != null && myLastRedispatchedEvent != e) {
- if (e.getID() == MouseEvent.MOUSE_PRESSED
- && IdeTooltipManager.getInstance().hasCurrent()
- && IdeTooltipManager.getInstance().hideCurrent(event, null, null, false)) {
- //noinspection SSBasedInspection
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- myLastRedispatchedEvent = e;
- IdeEventQueue.getInstance().dispatchEvent(e);
- }
- });
- }
- return false;
- }
- myLastRedispatchedEvent = null;
-
for (EventListener each : mySortedMouseListeners) {
if (motion && each instanceof MouseMotionListener) {
fireMouseMotion((MouseMotionListener)each, event);
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java
index 8b78b1632f79..7b9a7494c640 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowHeadlessManagerImpl.java
@@ -87,6 +87,7 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
return tw;
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull String id,
@NotNull JComponent component,
@@ -96,11 +97,13 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
return doRegisterToolWindow(id, parentDisposable);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor) {
return doRegisterToolWindow(id, null);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull String id,
@NotNull JComponent component,
@@ -111,19 +114,22 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
return doRegisterToolWindow(id, parentDisposable);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull String id,
@NotNull JComponent component,
@NotNull ToolWindowAnchor anchor,
- Disposable parentDisposable) {
+ @NotNull Disposable parentDisposable) {
return doRegisterToolWindow(id, parentDisposable);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id, final boolean canCloseContent, @NotNull final ToolWindowAnchor anchor) {
return doRegisterToolWindow(id, null);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id,
final boolean canCloseContent,
@@ -132,6 +138,7 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
return doRegisterToolWindow(id, null);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id, final boolean canCloseContent, @NotNull final ToolWindowAnchor anchor,
final Disposable parentDisposable, final boolean dumbAware) {
@@ -152,6 +159,7 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
return false;
}
+ @NotNull
@Override
public String[] getToolWindowIds() {
return ArrayUtil.EMPTY_STRING_ARRAY;
@@ -168,9 +176,10 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
}
@Override
- public void invokeLater(Runnable runnable) {
+ public void invokeLater(@NotNull Runnable runnable) {
}
+ @NotNull
@Override
public IdeFocusManager getFocusManager() {
return IdeFocusManagerHeadless.INSTANCE;
@@ -190,7 +199,7 @@ public class ToolWindowHeadlessManagerImpl extends ToolWindowManagerEx {
}
@Override
- public void initToolWindow(ToolWindowEP bean) {
+ public void initToolWindow(@NotNull ToolWindowEP bean) {
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java
index efcdd148d57b..1fa2bd95defe 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowImpl.java
@@ -72,6 +72,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
private boolean myPlaceholderMode;
private ToolWindowFactory myContentFactory;
+ @NotNull
private ActionCallback myActivation = new ActionCallback.Done();
private final BusyObject.Impl myShowing = new BusyObject.Impl() {
@Override
@@ -115,18 +116,22 @@ public final class ToolWindowImpl implements ToolWindowEx {
myChangeSupport.addPropertyChangeListener(l);
}
+ @Override
public final void removePropertyChangeListener(final PropertyChangeListener l) {
myChangeSupport.removePropertyChangeListener(l);
}
+ @Override
public final void activate(final Runnable runnable) {
activate(runnable, true);
}
+ @Override
public void activate(@Nullable final Runnable runnable, final boolean autoFocusContents) {
activate(runnable, autoFocusContents, true);
}
+ @Override
public void activate(@Nullable final Runnable runnable, boolean autoFocusContents, boolean forced) {
ApplicationManager.getApplication().assertIsDispatchThread();
@@ -136,6 +141,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
myToolWindowManager.activateToolWindow(myId, forced, autoFocusContents);
getActivation().doWhenDone(new Runnable() {
+ @Override
public void run() {
myToolWindowManager.invokeLater(new Runnable() {
@Override
@@ -150,6 +156,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
});
}
+ @Override
public final boolean isActive() {
ApplicationManager.getApplication().assertIsDispatchThread();
if (myToolWindowManager.isEditorComponentActive()) return false;
@@ -182,11 +189,13 @@ public final class ToolWindowImpl implements ToolWindowEx {
return result;
}
+ @Override
public final void show(final Runnable runnable) {
ApplicationManager.getApplication().assertIsDispatchThread();
myToolWindowManager.showToolWindow(myId);
if (runnable != null) {
getActivation().doWhenDone(new Runnable() {
+ @Override
public void run() {
myToolWindowManager.invokeLater(runnable);
}
@@ -194,6 +203,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
}
}
+ @Override
public final void hide(@Nullable final Runnable runnable) {
ApplicationManager.getApplication().assertIsDispatchThread();
myToolWindowManager.hideToolWindow(myId, false);
@@ -202,14 +212,17 @@ public final class ToolWindowImpl implements ToolWindowEx {
}
}
+ @Override
public final boolean isVisible() {
return myToolWindowManager.isToolWindowVisible(myId);
}
+ @Override
public final ToolWindowAnchor getAnchor() {
return myToolWindowManager.getToolWindowAnchor(myId);
}
+ @Override
public final void setAnchor(final ToolWindowAnchor anchor, @Nullable final Runnable runnable) {
ApplicationManager.getApplication().assertIsDispatchThread();
myToolWindowManager.setToolWindowAnchor(myId, anchor);
@@ -218,11 +231,13 @@ public final class ToolWindowImpl implements ToolWindowEx {
}
}
+ @Override
public boolean isSplitMode() {
ApplicationManager.getApplication().assertIsDispatchThread();
return myToolWindowManager.isSplitMode(myId);
}
+ @Override
public void setContentUiType(ToolWindowContentUiType type, @Nullable Runnable runnable) {
ApplicationManager.getApplication().assertIsDispatchThread();
myToolWindowManager.setContentUiType(myId, type);
@@ -231,15 +246,18 @@ public final class ToolWindowImpl implements ToolWindowEx {
}
}
+ @Override
public void setDefaultContentUiType(@NotNull ToolWindowContentUiType type) {
myToolWindowManager.setDefaultContentUiType(this, type);
}
+ @Override
public ToolWindowContentUiType getContentUiType() {
ApplicationManager.getApplication().assertIsDispatchThread();
return myToolWindowManager.getContentUiType(myId);
}
+ @Override
public void setSplitMode(final boolean isSideTool, @Nullable final Runnable runnable) {
ApplicationManager.getApplication().assertIsDispatchThread();
myToolWindowManager.setSideTool(myId, isSideTool);
@@ -248,20 +266,24 @@ public final class ToolWindowImpl implements ToolWindowEx {
}
}
+ @Override
public final void setAutoHide(final boolean state) {
ApplicationManager.getApplication().assertIsDispatchThread();
myToolWindowManager.setToolWindowAutoHide(myId, state);
}
+ @Override
public final boolean isAutoHide() {
ApplicationManager.getApplication().assertIsDispatchThread();
return myToolWindowManager.isToolWindowAutoHide(myId);
}
+ @Override
public final ToolWindowType getType() {
return myToolWindowManager.getToolWindowType(myId);
}
+ @Override
public final void setType(final ToolWindowType type, @Nullable final Runnable runnable) {
ApplicationManager.getApplication().assertIsDispatchThread();
myToolWindowManager.setToolWindowType(myId, type);
@@ -270,19 +292,23 @@ public final class ToolWindowImpl implements ToolWindowEx {
}
}
+ @Override
public final ToolWindowType getInternalType() {
ApplicationManager.getApplication().assertIsDispatchThread();
return myToolWindowManager.getToolWindowInternalType(myId);
}
+ @Override
public void stretchWidth(int value) {
myToolWindowManager.stretchWidth(this, value);
}
+ @Override
public void stretchHeight(int value) {
myToolWindowManager.stretchHeight(this, value);
}
+ @Override
public InternalDecorator getDecorator() {
return myDecorator;
}
@@ -297,6 +323,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
getDecorator().setTitleActions(actions);
}
+ @Override
public final void setAvailable(final boolean available, final Runnable runnable) {
ApplicationManager.getApplication().assertIsDispatchThread();
final Boolean oldAvailable = myAvailable ? Boolean.TRUE : Boolean.FALSE;
@@ -307,6 +334,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
}
}
+ @Override
public void installWatcher(ContentManager contentManager) {
new ContentManagerWatcher(this, contentManager);
}
@@ -316,14 +344,17 @@ public final class ToolWindowImpl implements ToolWindowEx {
* <code>ContentManager</code> class. Otherwise it delegates the functionality to the
* passed content manager.
*/
+ @Override
public final boolean isAvailable() {
return myAvailable && myComponent != null;
}
+ @Override
public final JComponent getComponent() {
return myComponent;
}
+ @Override
public ContentManager getContentManager() {
return myContentManager;
}
@@ -332,6 +363,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
return myContentUI;
}
+ @Override
public final Icon getIcon() {
ApplicationManager.getApplication().assertIsDispatchThread();
return myIcon;
@@ -342,17 +374,20 @@ public final class ToolWindowImpl implements ToolWindowEx {
return myId;
}
+ @Override
public final String getTitle() {
ApplicationManager.getApplication().assertIsDispatchThread();
return getSelectedContent().getDisplayName();
}
+ @Override
@NotNull
public final String getStripeTitle() {
ApplicationManager.getApplication().assertIsDispatchThread();
return ObjectUtils.notNull(myStripeTitle, myId);
}
+ @Override
public final void setIcon(final Icon icon) {
ApplicationManager.getApplication().assertIsDispatchThread();
final Icon oldIcon = getIcon();
@@ -364,6 +399,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
myChangeSupport.firePropertyChange(PROP_ICON, oldIcon, icon);
}
+ @Override
public final void setTitle(String title) {
ApplicationManager.getApplication().assertIsDispatchThread();
String oldTitle = getTitle();
@@ -371,6 +407,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
myChangeSupport.firePropertyChange(PROP_TITLE, oldTitle, title);
}
+ @Override
public final void setStripeTitle(@NotNull String stripeTitle) {
ApplicationManager.getApplication().assertIsDispatchThread();
String oldTitle = myStripeTitle;
@@ -415,18 +452,22 @@ public final class ToolWindowImpl implements ToolWindowEx {
return myDecorator != null ? myDecorator.createPopupGroup() : null;
}
+ @Override
public void setDefaultState(@Nullable final ToolWindowAnchor anchor, @Nullable final ToolWindowType type, @Nullable final Rectangle floatingBounds) {
myToolWindowManager.setDefaultState(this, anchor, type, floatingBounds);
}
+ @Override
public void setToHideOnEmptyContent(final boolean hideOnEmpty) {
myHideOnEmptyContent = hideOnEmpty;
}
+ @Override
public boolean isToHideOnEmptyContent() {
return myHideOnEmptyContent;
}
+ @Override
public boolean isDisposed() {
return myContentManager.isDisposed();
}
@@ -439,12 +480,15 @@ public final class ToolWindowImpl implements ToolWindowEx {
myPlaceholderMode = placeholderMode;
}
+ @Override
+ @NotNull
public ActionCallback getActivation() {
return myActivation;
}
- public ActionCallback setActivation(ActionCallback activation) {
- if (myActivation != null && !myActivation.isProcessed() && !myActivation.equals(activation)) {
+ @NotNull
+ public ActionCallback setActivation(@NotNull ActionCallback activation) {
+ if (!myActivation.isProcessed() && !myActivation.equals(activation)) {
myActivation.setRejected();
}
@@ -467,6 +511,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
}
}
+ @Override
public void showContentPopup(InputEvent inputEvent) {
myContentUI.toggleContentPopup();
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
index 555e0666f72e..95b3d54f8030 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
@@ -363,6 +363,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return IdeFocusManager.getInstance(project);
}
+ @NotNull
public Project getProject() {
return myProject;
}
@@ -482,21 +483,14 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
@Override
- public void initToolWindow(ToolWindowEP bean) {
- ToolWindowAnchor toolWindowAnchor;
- try {
- toolWindowAnchor = ToolWindowAnchor.fromText(bean.anchor);
- }
- catch (Exception e) {
- LOG.error(e);
- return;
- }
+ public void initToolWindow(@NotNull ToolWindowEP bean) {
JLabel label = new JLabel("Initializing...", SwingConstants.CENTER);
label.setOpaque(true);
final Color treeBg = UIManager.getColor("Tree.background");
label.setBackground(ColorUtil.toAlpha(treeBg, 180));
final Color treeFg = UIUtil.getTreeForeground();
label.setForeground(ColorUtil.toAlpha(treeFg, 180));
+ ToolWindowAnchor toolWindowAnchor = ToolWindowAnchor.fromText(bean.anchor);
final ToolWindowFactory factory = bean.getToolWindowFactory();
final ToolWindowImpl toolWindow =
(ToolWindowImpl)registerToolWindow(bean.id, label, toolWindowAnchor, myProject, DumbService.isDumbAware(factory),
@@ -747,7 +741,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
myActiveStack.push(id);
}
- if (autoFocusContents) {
+ if (autoFocusContents && ApplicationManager.getApplication().isActive()) {
appendRequestFocusInToolWindowCmd(id, commandsList, forcedFocusRequest);
}
}
@@ -826,6 +820,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
appendApplyWindowInfoCmd(info, commandsList);
}
+ @NotNull
@Override
public String[] getToolWindowIds() {
final WindowInfoImpl[] infos = myLayout.getInfos();
@@ -1087,6 +1082,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
appendApplyWindowInfoCmd(toBeShownInfo, commandsList);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id,
@NotNull final JComponent component,
@@ -1094,6 +1090,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return registerToolWindow(id, component, anchor, false);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id,
@NotNull JComponent component,
@@ -1102,6 +1099,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return registerToolWindow(id, component, anchor, parentDisposable, false, false);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull String id,
@NotNull JComponent component,
@@ -1111,6 +1109,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return registerToolWindow(id, component, anchor, parentDisposable, canWorkInDumbMode, false);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id,
@NotNull JComponent component,
@@ -1120,6 +1119,7 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return registerDisposable(id, parentDisposable, registerToolWindow(id, component, anchor, false, canCloseContents, canWorkInDumbMode));
}
+ @NotNull
private ToolWindow registerToolWindow(@NotNull final String id,
@NotNull final JComponent component,
@NotNull final ToolWindowAnchor anchor,
@@ -1127,11 +1127,13 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return registerToolWindow(id, component, anchor, false, false, canWorkInDumbMode);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id, final boolean canCloseContent, @NotNull final ToolWindowAnchor anchor) {
return registerToolWindow(id, null, anchor, false, canCloseContent, false);
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id,
final boolean canCloseContent,
@@ -1141,15 +1143,18 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id,
final boolean canCloseContent,
@NotNull final ToolWindowAnchor anchor,
@NotNull final Disposable parentDisposable,
final boolean canWorkInDumbMode) {
- return registerDisposable(id, parentDisposable, registerToolWindow(id, null, anchor, false, canCloseContent, canWorkInDumbMode));
+ ToolWindow window = registerToolWindow(id, null, anchor, false, canCloseContent, canWorkInDumbMode);
+ return registerDisposable(id, parentDisposable, window);
}
+ @NotNull
private ToolWindow registerToolWindow(@NotNull final String id,
@Nullable final JComponent component,
@NotNull final ToolWindowAnchor anchor,
@@ -1216,7 +1221,8 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
return toolWindow;
}
- private ToolWindow registerDisposable(final String id, @NotNull final Disposable parentDisposable, final ToolWindow window) {
+ @NotNull
+ private ToolWindow registerDisposable(@NotNull final String id, @NotNull final Disposable parentDisposable, @NotNull ToolWindow window) {
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
@@ -1353,12 +1359,13 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
@Override
- public void invokeLater(final Runnable runnable) {
+ public void invokeLater(@NotNull final Runnable runnable) {
List<FinalizableCommand> commandList = new ArrayList<FinalizableCommand>();
commandList.add(new InvokeLaterCmd(runnable, myWindowManager.getCommandProcessor()));
execute(commandList);
}
+ @NotNull
@Override
public IdeFocusManager getFocusManager() {
return IdeFocusManager.getInstance(myProject);
diff --git a/platform/platform-impl/src/com/intellij/remote/RemoteSdkAdditionalData.java b/platform/platform-impl/src/com/intellij/remote/RemoteSdkAdditionalData.java
index b51c85bc2c18..2da812614b88 100644
--- a/platform/platform-impl/src/com/intellij/remote/RemoteSdkAdditionalData.java
+++ b/platform/platform-impl/src/com/intellij/remote/RemoteSdkAdditionalData.java
@@ -25,8 +25,9 @@ public interface RemoteSdkAdditionalData<T extends RemoteSdkCredentials>
extends SdkAdditionalData, RemoteSdkCredentialsProducer<T>, RemoteSdkProperties {
void completeInitialization();
+ @Deprecated
boolean isInitialized();
-
+ @Deprecated
void setInitialized(boolean initialized);
void setVagrantConnectionType(@NotNull VagrantBasedCredentialsHolder vagrantBasedCredentials);
diff --git a/platform/platform-impl/src/com/intellij/remote/RemoteSdkCredentialsHolder.java b/platform/platform-impl/src/com/intellij/remote/RemoteSdkCredentialsHolder.java
index d92839e212b8..ae84919ac9ce 100644
--- a/platform/platform-impl/src/com/intellij/remote/RemoteSdkCredentialsHolder.java
+++ b/platform/platform-impl/src/com/intellij/remote/RemoteSdkCredentialsHolder.java
@@ -144,6 +144,16 @@ public class RemoteSdkCredentialsHolder extends RemoteCredentialsHolder implemen
myRemoteSdkProperties.setInitialized(initialized);
}
+ @Override
+ public boolean isValid() {
+ return myRemoteSdkProperties.isValid();
+ }
+
+ @Override
+ public void setValid(boolean valid) {
+ myRemoteSdkProperties.setValid(valid);
+ }
+
public static boolean isRemoteSdk(@Nullable String path) {
if (path != null) {
return path.startsWith(SSH_PREFIX) || path.startsWith(RemoteConnectionCredentialsWrapper.VAGRANT_PREFIX) ||
diff --git a/platform/platform-impl/src/com/intellij/remote/RemoteSdkProperties.java b/platform/platform-impl/src/com/intellij/remote/RemoteSdkProperties.java
index a690afd96afc..d9cca99cce14 100644
--- a/platform/platform-impl/src/com/intellij/remote/RemoteSdkProperties.java
+++ b/platform/platform-impl/src/com/intellij/remote/RemoteSdkProperties.java
@@ -84,9 +84,19 @@ public interface RemoteSdkProperties {
String getSdkId();
+ /**
+ * isValid() is used now
+ * To be removed in IDEA 15
+ *
+ * @deprecated
+ */
@Deprecated
boolean isInitialized();
@Deprecated
void setInitialized(boolean initialized);
+
+ boolean isValid();
+
+ void setValid(boolean valid);
}
diff --git a/platform/platform-impl/src/com/intellij/remote/RemoteSdkPropertiesHolder.java b/platform/platform-impl/src/com/intellij/remote/RemoteSdkPropertiesHolder.java
index a0407d27f7e9..68e22f79c7fc 100644
--- a/platform/platform-impl/src/com/intellij/remote/RemoteSdkPropertiesHolder.java
+++ b/platform/platform-impl/src/com/intellij/remote/RemoteSdkPropertiesHolder.java
@@ -36,6 +36,7 @@ public class RemoteSdkPropertiesHolder implements RemoteSdkProperties {
private static final String REMOTE_ROOTS = "REMOTE_ROOTS";
private static final String REMOTE_PATH = "REMOTE_PATH";
private static final String INITIALIZED = "INITIALIZED";
+ private static final String VALID = "VALID";
private static final String PATH_MAPPINGS = "PATH_MAPPINGS";
private String mySdkId;
@@ -51,6 +52,8 @@ public class RemoteSdkPropertiesHolder implements RemoteSdkProperties {
private boolean myInitialized = false;
+ private boolean myValid = true;
+
@NotNull
private PathMappingSettings myPathMappings = new PathMappingSettings();
@@ -144,6 +147,16 @@ public class RemoteSdkPropertiesHolder implements RemoteSdkProperties {
myInitialized = initialized;
}
+ @Override
+ public boolean isValid() {
+ return myValid;
+ }
+
+ @Override
+ public void setValid(boolean valid) {
+ myValid = valid;
+ }
+
public void copyTo(RemoteSdkProperties copy) {
copy.setInterpreterPath(getInterpreterPath());
copy.setHelpersPath(getHelpersPath());
@@ -152,6 +165,8 @@ public class RemoteSdkPropertiesHolder implements RemoteSdkProperties {
copy.setRemoteRoots(getRemoteRoots());
copy.setInitialized(isInitialized());
+
+ copy.setValid(isValid());
}
public void save(Element rootElement) {
@@ -159,6 +174,7 @@ public class RemoteSdkPropertiesHolder implements RemoteSdkProperties {
rootElement.setAttribute(HELPERS_PATH, StringUtil.notNullize(getHelpersPath()));
rootElement.setAttribute(INITIALIZED, Boolean.toString(isInitialized()));
+ rootElement.setAttribute(VALID, Boolean.toString(isValid()));
PathMappingSettings.writeExternal(rootElement, myPathMappings);
@@ -177,6 +193,8 @@ public class RemoteSdkPropertiesHolder implements RemoteSdkProperties {
setInitialized(StringUtil.parseBoolean(element.getAttributeValue(INITIALIZED), true));
+ setValid(StringUtil.parseBoolean(element.getAttributeValue(VALID), true));
+
setPathMappings(PathMappingSettings.readExternal(element));
}
}
diff --git a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java
index d8b204cfd76c..1fc23e5f4055 100644
--- a/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java
+++ b/platform/platform-impl/src/com/intellij/ui/AbstractExpandableItemsHandler.java
@@ -54,7 +54,7 @@ public abstract class AbstractExpandableItemsHandler<KeyType, ComponentType exte
myTipComponent = new TipComponent();
- myTipComponent.addMouseListener(new MouseAdapter() {
+ MouseAdapter tipMouseAdapter = new MouseAdapter() {
@Override
public void mouseExited(MouseEvent e) {
// don't hide the hint if mouse exited to myComponent
@@ -62,7 +62,60 @@ public abstract class AbstractExpandableItemsHandler<KeyType, ComponentType exte
hideHint();
}
}
- });
+
+ @Override
+ public void mouseWheelMoved(MouseWheelEvent e) {
+ Point p = e.getLocationOnScreen();
+ SwingUtilities.convertPointFromScreen(p, myComponent);
+ myComponent.dispatchEvent(new MouseWheelEvent(myComponent,
+ e.getID(),
+ e.getWhen(),
+ e.getModifiers(),
+ p.x, p.y,
+ e.getClickCount(),
+ e.isPopupTrigger(),
+ e.getScrollType(),
+ e.getScrollAmount(),
+ e.getWheelRotation()));
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ Point p = e.getLocationOnScreen();
+ SwingUtilities.convertPointFromScreen(p, myComponent);
+ myComponent.dispatchEvent(new MouseEvent(myComponent,
+ e.getID(),
+ e.getWhen(),
+ e.getModifiers(),
+ p.x, p.y,
+ e.getClickCount(),
+ e.isPopupTrigger(),
+ e.getButton()));
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ mouseClicked(e);
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ mouseClicked(e);
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ mouseClicked(e);
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ mouseClicked(e);
+ }
+ };
+ myTipComponent.addMouseListener(tipMouseAdapter);
+ myTipComponent.addMouseWheelListener(tipMouseAdapter);
+ myTipComponent.addMouseMotionListener(tipMouseAdapter);
myComponent.addMouseListener(
new MouseListener() {
diff --git a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java
index 513d5cedb2ab..d41d0bb5ef18 100644
--- a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java
@@ -331,7 +331,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
Integer result = JLayeredPane.DEFAULT_LAYER;
switch (myLayer) {
case normal:
- result = JLayeredPane.DEFAULT_LAYER;
+ result = JLayeredPane.POPUP_LAYER;
break;
case top:
result = JLayeredPane.DRAG_LAYER;
diff --git a/platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java b/platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java
index d5fc8dcca1ba..fe041c5ea02b 100644
--- a/platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/JBTabsPaneImpl.java
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.ui.tabs.*;
import com.intellij.ui.tabs.impl.JBEditorTabs;
+import com.intellij.ui.tabs.impl.JBTabsImpl;
import com.intellij.ui.tabs.impl.TabLabel;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
@@ -34,8 +35,7 @@ import java.awt.event.MouseListener;
import java.util.concurrent.CopyOnWriteArraySet;
public class JBTabsPaneImpl implements TabbedPane, SwingConstants {
-
- private final JBTabs myTabs;
+ private final JBTabsImpl myTabs;
private final CopyOnWriteArraySet<ChangeListener> myListeners = new CopyOnWriteArraySet<ChangeListener>();
public JBTabsPaneImpl(@Nullable Project project, int tabPlacement, @NotNull Disposable parent) {
@@ -64,6 +64,9 @@ public class JBTabsPaneImpl implements TabbedPane, SwingConstants {
maxOffset++;
g2d.setPaint(UIUtil.getPanelBackground());
+ if (getFirstTabOffset() > 0) {
+ g2d.fillRect(clip.x, clip.y, clip.x + getFirstTabOffset() - 1, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT);
+ }
g2d.fillRect(clip.x + maxOffset, clip.y, clip.width - maxOffset, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT);
g2d.setPaint(new JBColor(Gray._181, UIUtil.getPanelBackground()));
g2d.drawLine(clip.x + maxOffset, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT, clip.x + clip.width, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT);
@@ -77,6 +80,7 @@ public class JBTabsPaneImpl implements TabbedPane, SwingConstants {
super.paintSelectionAndBorder(g2d);
}
};
+ myTabs.setFirstTabOffset(10);
myTabs.addListener(new TabsListener.Adapter() {
@Override
diff --git a/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java b/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java
index aac2e77982ba..e8c6f49f8088 100644
--- a/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java
+++ b/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java
@@ -49,6 +49,7 @@ class LibNotifyWrapper implements SystemNotificationsImpl.Notifier {
}
private final LibNotify myLibNotify;
+ private final String myIcon;
private LibNotifyWrapper() {
myLibNotify = (LibNotify)Native.loadLibrary("libnotify.so.4", LibNotify.class);
@@ -58,6 +59,9 @@ class LibNotifyWrapper implements SystemNotificationsImpl.Notifier {
throw new IllegalStateException("notify_init failed");
}
+ String icon = AppUIUtil.findIcon(PathManager.getBinPath());
+ myIcon = icon != null ? icon : "dialog-information";
+
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
@Override
@@ -69,9 +73,7 @@ class LibNotifyWrapper implements SystemNotificationsImpl.Notifier {
@Override
public void notify(@NotNull Set<String> allNames, @NotNull String name, @NotNull String title, @NotNull String description) {
- String icon = AppUIUtil.findIcon(PathManager.getBinPath());
- if (icon == null) icon = "dialog-information";
- Pointer notification = myLibNotify.notify_notification_new(title, description, icon);
+ Pointer notification = myLibNotify.notify_notification_new(title, description, myIcon);
myLibNotify.notify_notification_show(notification, null);
}
}
diff --git a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
index c738995059dc..cbcde2d36418 100644
--- a/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
+++ b/platform/platform-impl/src/com/intellij/ui/SpeedSearchBase.java
@@ -288,6 +288,10 @@ public abstract class SpeedSearchBase<Comp extends JComponent> extends SpeedSear
return null;
}
+ public void showPopup() {
+ manageSearchPopup(new SearchPopup(""));
+ }
+
public void hidePopup() {
manageSearchPopup(null);
}
diff --git a/platform/platform-impl/src/com/intellij/ui/TableSpeedSearch.java b/platform/platform-impl/src/com/intellij/ui/TableSpeedSearch.java
index b596204e6ad2..eeeb90dc7ae7 100644
--- a/platform/platform-impl/src/com/intellij/ui/TableSpeedSearch.java
+++ b/platform/platform-impl/src/com/intellij/ui/TableSpeedSearch.java
@@ -20,7 +20,6 @@ import com.intellij.util.PairFunction;
import com.intellij.util.containers.Convertor;
import javax.swing.*;
-import javax.swing.table.TableModel;
import java.util.ListIterator;
public class TableSpeedSearch extends SpeedSearchBase<JTable> {
@@ -55,9 +54,8 @@ public class TableSpeedSearch extends SpeedSearchBase<JTable> {
@Override
protected boolean isSpeedSearchEnabled() {
- JTable table = getComponent();
- boolean tableIsNotEmpty = table.getRowCount() != 0 && table.getColumnCount() != 0;
- return tableIsNotEmpty && !table.isEditing() && super.isSpeedSearchEnabled();
+ boolean tableIsNotEmpty = myComponent.getRowCount() != 0 && myComponent.getColumnCount() != 0;
+ return tableIsNotEmpty && !myComponent.isEditing() && super.isSpeedSearchEnabled();
}
@Override
@@ -67,16 +65,14 @@ public class TableSpeedSearch extends SpeedSearchBase<JTable> {
@Override
protected int getElementCount() {
- final TableModel tableModel = myComponent.getModel();
- return tableModel.getRowCount() * tableModel.getColumnCount();
+ return myComponent.getRowCount() * myComponent.getColumnCount();
}
@Override
protected void selectElement(Object element, String selectedText) {
final int index = ((Integer)element).intValue();
- final TableModel model = myComponent.getModel();
- final int row = index / model.getColumnCount();
- final int col = index % model.getColumnCount();
+ final int row = index / myComponent.getColumnCount();
+ final int col = index % myComponent.getColumnCount();
myComponent.getSelectionModel().setSelectionInterval(row, row);
myComponent.getColumnModel().getSelectionModel().setSelectionInterval(col, col);
TableUtil.scrollSelectionToVisible(myComponent);
@@ -87,7 +83,7 @@ public class TableSpeedSearch extends SpeedSearchBase<JTable> {
final int row = myComponent.getSelectedRow();
final int col = myComponent.getSelectedColumn();
// selected row is not enough as we want to select specific cell in a large multi-column table
- return row > -1 && col > -1 ? row * myComponent.getModel().getColumnCount() + col : -1;
+ return row > -1 && col > -1 ? row * myComponent.getColumnCount() + col : -1;
}
@Override
@@ -98,10 +94,9 @@ public class TableSpeedSearch extends SpeedSearchBase<JTable> {
@Override
protected String getElementText(Object element) {
final int index = ((Integer)element).intValue();
- final TableModel model = myComponent.getModel();
- int row = myComponent.convertRowIndexToModel(index / model.getColumnCount());
- int col = myComponent.convertColumnIndexToModel(index % model.getColumnCount());
- Object value = model.getValueAt(row, col);
+ int row = index / myComponent.getColumnCount();
+ int col = index % myComponent.getColumnCount();
+ Object value = myComponent.getValueAt(row, col);
return myToStringConvertor.fun(value, new Cell(row, col));
}
diff --git a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentImpl.java b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentImpl.java
index 82dd6ff085fd..595a93db592f 100644
--- a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentImpl.java
@@ -1,6 +1,5 @@
-
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -45,7 +44,7 @@ public class ContentImpl extends UserDataHolderBase implements Content {
private JComponent myComponent;
private Icon myIcon;
private final PropertyChangeSupport myChangeSupport = new PropertyChangeSupport(this);
- private ContentManager myManager = null;
+ private ContentManager myManager;
private boolean myIsLocked = false;
private boolean myPinnable = true;
private Icon myLayeredIcon = new LayeredIcon(2);
@@ -294,6 +293,7 @@ public class ContentImpl extends UserDataHolderBase implements Content {
return myPlace;
}
+ @Override
@NonNls
public String toString() {
StringBuilder sb = new StringBuilder("Content name=").append(myDisplayName);
diff --git a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java
index b6e739692ede..d0b110f083bf 100644
--- a/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/content/impl/ContentManagerImpl.java
@@ -15,6 +15,7 @@
*/
package com.intellij.ui.content.impl;
+import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DataProvider;
@@ -32,13 +33,15 @@ import com.intellij.ui.components.panels.Wrapper;
import com.intellij.ui.content.*;
import com.intellij.ui.switcher.SwitchProvider;
import com.intellij.ui.switcher.SwitchTarget;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.SmartList;
+
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import javax.swing.event.EventListenerList;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -55,21 +58,21 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
private static final Logger LOG = Logger.getInstance("#com.intellij.ui.content.impl.ContentManagerImpl");
private ContentUI myUI;
- private final ArrayList<Content> myContents;
- private EventListenerList myListeners;
- private List<Content> mySelection = new ArrayList<Content>();
+ private final List<Content> myContents = new ArrayList<Content>();
+ private final List<ContentManagerListener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
+ private final List<Content> mySelection = new ArrayList<Content>();
private final boolean myCanCloseContents;
- private MyContentComponent myContentComponent;
- private MyFocusProxy myFocusProxy;
- private JPanel myComponent;
-
+ private Wrapper.FocusHolder myFocusProxy;
+ private MyNonOpaquePanel myComponent;
private final Set<Content> myContentWithChangedComponent = new HashSet<Content>();
private boolean myDisposed;
private final Project myProject;
+ private final List<DataProvider> dataProviders = new SmartList<DataProvider>();
+
/**
* WARNING: as this class adds listener to the ProjectManager which is removed on projectClosed event, all instances of this class
* must be created on already OPENED projects, otherwise there will be memory leak!
@@ -77,8 +80,6 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
public ContentManagerImpl(@NotNull ContentUI contentUI, boolean canCloseContents, @NotNull Project project) {
myProject = project;
myCanCloseContents = canCloseContents;
- myContents = new ArrayList<Content>();
- myListeners = new EventListenerList();
myUI = contentUI;
myUI.setManager(this);
@@ -95,15 +96,18 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
@Override
public JComponent getComponent() {
if (myComponent == null) {
- myComponent = new NonOpaquePanel(new BorderLayout());
+ myComponent = new MyNonOpaquePanel();
+
+ myFocusProxy = new Wrapper.FocusHolder();
+ myFocusProxy.setOpaque(false);
+ myFocusProxy.setPreferredSize(new Dimension(0, 0));
- myFocusProxy = new MyFocusProxy();
- myContentComponent = new MyContentComponent();
- myContentComponent.setContent(myUI.getComponent());
- myContentComponent.setFocusCycleRoot(true);
+ MyContentComponent contentComponent = new MyContentComponent();
+ contentComponent.setContent(myUI.getComponent());
+ contentComponent.setFocusCycleRoot(true);
myComponent.add(myFocusProxy, BorderLayout.NORTH);
- myComponent.add(myContentComponent, BorderLayout.CENTER);
+ myComponent.add(contentComponent, BorderLayout.CENTER);
}
return myComponent;
}
@@ -117,58 +121,51 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
return busyObject != null ? busyObject.getReady(requestor) : new ActionCallback.Done();
}
- private class MyContentComponent extends NonOpaquePanel implements DataProvider, SwitchProvider {
-
- private final List<DataProvider> myProviders = new ArrayList<DataProvider>();
-
- public void addProvider(final DataProvider provider) {
- myProviders.add(provider);
+ private class MyNonOpaquePanel extends NonOpaquePanel implements DataProvider {
+ public MyNonOpaquePanel() {
+ super(new BorderLayout());
}
@Override
@Nullable
- public Object getData(@NonNls final String dataId) {
- if (PlatformDataKeys.CONTENT_MANAGER.is(dataId)) return ContentManagerImpl.this;
- if (PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.is(dataId) && getContentCount() > 1) {
+ public Object getData(@NonNls String dataId) {
+ if (PlatformDataKeys.CONTENT_MANAGER.is(dataId) || PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.is(dataId) && getContentCount() > 1) {
return ContentManagerImpl.this;
}
- for (DataProvider each : myProviders) {
- final Object data = each.getData(dataId);
- if (data != null) return data;
+ for (DataProvider dataProvider : dataProviders) {
+ Object data = dataProvider.getData(dataId);
+ if (data != null) {
+ return data;
+ }
}
if (myUI instanceof DataProvider) {
return ((DataProvider)myUI).getData(dataId);
}
- return null;
+ DataProvider provider = DataManager.getDataProvider(this);
+ return provider == null ? null : provider.getData(dataId);
}
+ }
+ private class MyContentComponent extends NonOpaquePanel implements SwitchProvider {
@Override
public List<SwitchTarget> getTargets(boolean onlyVisible, boolean originalProvider) {
if (myUI instanceof SwitchProvider) {
return ((SwitchProvider)myUI).getTargets(onlyVisible, false);
}
- return new ArrayList<SwitchTarget>();
+ return new SmartList<SwitchTarget>();
}
@Override
public SwitchTarget getCurrentTarget() {
- if (myUI instanceof SwitchProvider) {
- return ((SwitchProvider)myUI).getCurrentTarget();
- }
-
- return null;
+ return myUI instanceof SwitchProvider ? ((SwitchProvider)myUI).getCurrentTarget() : null;
}
@Override
public JComponent getComponent() {
- if (myUI instanceof SwitchProvider) {
- return myUI.getComponent();
- }
-
- return this;
+ return myUI instanceof SwitchProvider ? myUI.getComponent() : this;
}
@Override
@@ -177,35 +174,23 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
}
}
- private class MyFocusProxy extends Wrapper.FocusHolder implements DataProvider {
- private MyFocusProxy() {
- setOpaque(false);
- setPreferredSize(new Dimension(0, 0));
- }
-
- @Override
- @Nullable
- public Object getData(@NonNls final String dataId) {
- return myContentComponent.getData(dataId);
- }
- }
-
@Override
public void addContent(@NotNull Content content, final int order) {
- addContent(content, null, order);
+ doAddContent(content, order);
}
@Override
public void addContent(@NotNull Content content) {
- addContent(content, null, -1);
+ doAddContent(content, -1);
}
@Override
public void addContent(@NotNull final Content content, final Object constraints) {
- addContent(content, constraints, -1);
+ doAddContent(content, -1);
}
- private void addContent(@NotNull final Content content, final Object constraints, final int index) {
+ private void doAddContent(@NotNull final Content content, final int index) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
if (myContents.contains(content)) return;
((ContentImpl)content).setManager(this);
@@ -227,24 +212,26 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
@Override
public boolean removeContent(@NotNull Content content, final boolean dispose) {
- return removeContent(content, true, dispose);
+ return removeContent(content, true, dispose).isDone();
}
@NotNull
@Override
public ActionCallback removeContent(@NotNull Content content, boolean dispose, final boolean trackFocus, final boolean forcedFocus) {
final ActionCallback result = new ActionCallback();
- _removeContent(content, true, dispose).doWhenDone(new Runnable() {
+ removeContent(content, true, dispose).doWhenDone(new Runnable() {
@Override
public void run() {
if (trackFocus) {
Content current = getSelectedContent();
if (current != null) {
setSelectedContent(current, true, true, !forcedFocus);
- } else {
+ }
+ else {
result.setDone();
}
- } else {
+ }
+ else {
result.setDone();
}
}
@@ -253,11 +240,9 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
return result;
}
- private boolean removeContent(final Content content, boolean trackSelection, boolean dispose) {
- return _removeContent(content, trackSelection, dispose).isDone();
- }
-
- private ActionCallback _removeContent(Content content, boolean trackSelection, boolean dispose) {
+ @NotNull
+ private ActionCallback removeContent(@NotNull Content content, boolean trackSelection, boolean dispose) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
int indexToBeRemoved = getIndexOfContent(content);
if (indexToBeRemoved == -1) return new ActionCallback.Rejected();
@@ -604,43 +589,39 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
@Override
public void addContentManagerListener(@NotNull ContentManagerListener l) {
- myListeners.add(ContentManagerListener.class, l);
+ myListeners.add(0,l);
}
@Override
public void removeContentManagerListener(@NotNull ContentManagerListener l) {
- myListeners.remove(ContentManagerListener.class, l);
+ myListeners.remove(l);
}
private void fireContentAdded(Content content, int newIndex, ContentManagerEvent.ContentOperation operation) {
ContentManagerEvent event = new ContentManagerEvent(this, content, newIndex, operation);
- ContentManagerListener[] listeners = myListeners.getListeners(ContentManagerListener.class);
- for (ContentManagerListener listener : listeners) {
+ for (ContentManagerListener listener : myListeners) {
listener.contentAdded(event);
}
}
private void fireContentRemoved(Content content, int oldIndex, ContentManagerEvent.ContentOperation operation) {
ContentManagerEvent event = new ContentManagerEvent(this, content, oldIndex, operation);
- ContentManagerListener[] listeners = myListeners.getListeners(ContentManagerListener.class);
- for (ContentManagerListener listener : listeners) {
+ for (ContentManagerListener listener : myListeners) {
listener.contentRemoved(event);
}
}
private void fireSelectionChanged(Content content, ContentManagerEvent.ContentOperation operation) {
ContentManagerEvent event = new ContentManagerEvent(this, content, myContents.indexOf(content), operation);
- ContentManagerListener[] listeners = myListeners.getListeners(ContentManagerListener.class);
- for (ContentManagerListener listener : listeners) {
+ for (ContentManagerListener listener : myListeners) {
listener.selectionChanged(event);
}
}
private boolean fireContentRemoveQuery(Content content, int oldIndex, ContentManagerEvent.ContentOperation operation) {
ContentManagerEvent event = new ContentManagerEvent(this, content, oldIndex, operation);
- ContentManagerListener[] listeners = myListeners.getListeners(ContentManagerListener.class);
- for (ContentManagerListener listener : listeners) {
+ for (ContentManagerListener listener : myListeners) {
listener.contentRemoveQuery(event);
if (event.isConsumed()) {
return false;
@@ -692,13 +673,13 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
@Override
public void addDataProvider(@NotNull final DataProvider provider) {
- myContentComponent.addProvider(provider);
+ dataProviders.add(provider);
}
@Override
- public void propertyChange(final PropertyChangeEvent evt) {
- if (Content.PROP_COMPONENT.equals(evt.getPropertyName())) {
- myContentWithChangedComponent.add((Content)evt.getSource());
+ public void propertyChange(@NotNull PropertyChangeEvent event) {
+ if (Content.PROP_COMPONENT.equals(event.getPropertyName())) {
+ myContentWithChangedComponent.add((Content)event.getSource());
}
}
@@ -718,10 +699,10 @@ public class ContentManagerImpl implements ContentManager, PropertyChangeListene
myDisposed = true;
myContents.clear();
- mySelection = null;
+ mySelection.clear();
myContentWithChangedComponent.clear();
myUI = null;
- myListeners = null;
+ myListeners.clear();
}
@Override
diff --git a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java
index e50403abef45..a967245c9224 100644
--- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java
+++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java
@@ -487,22 +487,24 @@ public class AbstractPopup implements JBPopup {
if (dominantArea != null) {
final Component focusedComponent = getWndManager().getFocusedComponent(myProject);
- Window window = SwingUtilities.windowForComponent(focusedComponent);
- JLayeredPane layeredPane;
- if (window instanceof JFrame) {
- layeredPane = ((JFrame)window).getLayeredPane();
- }
- else if (window instanceof JDialog) {
- layeredPane = ((JDialog)window).getLayeredPane();
- }
- else if (window instanceof JWindow) {
- layeredPane = ((JWindow)window).getLayeredPane();
- }
- else {
- throw new IllegalStateException("cannot find parent window: project=" + myProject + "; window=" + window);
- }
+ if (focusedComponent != null) {
+ Window window = SwingUtilities.windowForComponent(focusedComponent);
+ JLayeredPane layeredPane;
+ if (window instanceof JFrame) {
+ layeredPane = ((JFrame)window).getLayeredPane();
+ }
+ else if (window instanceof JDialog) {
+ layeredPane = ((JDialog)window).getLayeredPane();
+ }
+ else if (window instanceof JWindow) {
+ layeredPane = ((JWindow)window).getLayeredPane();
+ }
+ else {
+ throw new IllegalStateException("cannot find parent window: project=" + myProject + "; window=" + window);
+ }
- return relativePointWithDominantRectangle(layeredPane, dominantArea);
+ return relativePointWithDominantRectangle(layeredPane, dominantArea);
+ }
}
return JBPopupFactory.getInstance().guessBestPopupLocation(dataContext);
@@ -777,7 +779,9 @@ public class AbstractPopup implements JBPopup {
Rectangle original = new Rectangle(targetBounds);
if (myLocateWithinScreen) {
- ScreenUtil.moveRectangleToFitTheScreen(targetBounds);
+ if (myMovable) {
+ ScreenUtil.moveRectangleToFitTheScreen(targetBounds);
+ }
}
if (myMouseOutCanceller != null) {
diff --git a/platform/platform-impl/src/com/intellij/ui/popup/list/PopupListElementRenderer.java b/platform/platform-impl/src/com/intellij/ui/popup/list/PopupListElementRenderer.java
index 5d657487f6a5..1428ffc9b29d 100644
--- a/platform/platform-impl/src/com/intellij/ui/popup/list/PopupListElementRenderer.java
+++ b/platform/platform-impl/src/com/intellij/ui/popup/list/PopupListElementRenderer.java
@@ -16,7 +16,7 @@
package com.intellij.ui.popup.list;
import com.intellij.icons.AllIcons;
-import com.intellij.openapi.ui.popup.ListItemDescriptor;
+import com.intellij.openapi.ui.popup.ListItemDescriptorAdapter;
import com.intellij.openapi.ui.popup.ListPopupStep;
import com.intellij.ui.ColorUtil;
import com.intellij.util.ui.UIUtil;
@@ -27,18 +27,13 @@ public class PopupListElementRenderer extends GroupedItemsListRenderer {
private final ListPopupImpl myPopup;
public PopupListElementRenderer(final ListPopupImpl aPopup) {
- super(new ListItemDescriptor() {
+ super(new ListItemDescriptorAdapter() {
@Override
public String getTextFor(Object value) {
return aPopup.getListStep().getTextFor(value);
}
@Override
- public String getTooltipFor(Object value) {
- return null;
- }
-
- @Override
public Icon getIconFor(Object value) {
return aPopup.getListStep().getIconFor(value);
}
diff --git a/platform/platform-impl/src/icons/PlatformImplIcons.java b/platform/platform-impl/src/icons/PlatformImplIcons.java
new file mode 100644
index 000000000000..87dd75428d01
--- /dev/null
+++ b/platform/platform-impl/src/icons/PlatformImplIcons.java
@@ -0,0 +1,28 @@
+package icons;
+
+import com.intellij.openapi.util.IconLoader;
+
+import javax.swing.*;
+
+/**
+ * NOTE THIS FILE IS AUTO-GENERATED
+ * DO NOT EDIT IT BY HAND, run build/scripts/icons.gant instead
+ */
+public class PlatformImplIcons {
+ private static Icon load(String path) {
+ return IconLoader.getIcon(path, PlatformImplIcons.class);
+ }
+
+ public static final Icon Android = load("/icons/plugins/Android.png"); // 48x48
+ public static final Icon ApplicationServers = load("/icons/plugins/ApplicationServers.png"); // 48x48
+ public static final Icon BuildTools = load("/icons/plugins/BuildTools.png"); // 48x48
+ public static final Icon Clouds = load("/icons/plugins/Clouds.png"); // 48x48
+ public static final Icon DatabaseTools = load("/icons/plugins/DatabaseTools.png"); // 48x48
+ public static final Icon JavaFrameworks = load("/icons/plugins/JavaFrameworks.png"); // 48x48
+ public static final Icon OtherTools = load("/icons/plugins/OtherTools.png"); // 48x48
+ public static final Icon PluginDevelopment = load("/icons/plugins/PluginDevelopment.png"); // 48x48
+ public static final Icon Swing = load("/icons/plugins/Swing.png"); // 48x48
+ public static final Icon TestTools = load("/icons/plugins/TestTools.png"); // 48x48
+ public static final Icon VersionControls = load("/icons/plugins/VersionControls.png"); // 48x48
+ public static final Icon WebDevelopment = load("/icons/plugins/WebDevelopment.png"); // 48x48
+}
diff --git a/platform/platform-impl/src/icons/plugins/Android.png b/platform/platform-impl/src/icons/plugins/Android.png
new file mode 100644
index 000000000000..9d55c0e3409c
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/Android.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/Android@2x.png b/platform/platform-impl/src/icons/plugins/Android@2x.png
new file mode 100644
index 000000000000..e3d989db2b55
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/Android@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/ApplicationServers.png b/platform/platform-impl/src/icons/plugins/ApplicationServers.png
new file mode 100644
index 000000000000..a6195b804f61
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/ApplicationServers.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/ApplicationServers@2x.png b/platform/platform-impl/src/icons/plugins/ApplicationServers@2x.png
new file mode 100644
index 000000000000..d6901f88646d
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/ApplicationServers@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/BuildTools.png b/platform/platform-impl/src/icons/plugins/BuildTools.png
new file mode 100644
index 000000000000..c16226fb628f
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/BuildTools.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/BuildTools@2x.png b/platform/platform-impl/src/icons/plugins/BuildTools@2x.png
new file mode 100644
index 000000000000..ecd58cfeab83
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/BuildTools@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/Clouds.png b/platform/platform-impl/src/icons/plugins/Clouds.png
new file mode 100644
index 000000000000..9da8c7f39dea
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/Clouds.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/Clouds@2x.png b/platform/platform-impl/src/icons/plugins/Clouds@2x.png
new file mode 100644
index 000000000000..5338f618e25d
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/Clouds@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/DatabaseTools.png b/platform/platform-impl/src/icons/plugins/DatabaseTools.png
new file mode 100644
index 000000000000..459b90ed30bd
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/DatabaseTools.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/DatabaseTools@2x.png b/platform/platform-impl/src/icons/plugins/DatabaseTools@2x.png
new file mode 100644
index 000000000000..8b7fbbf33005
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/DatabaseTools@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/JavaFrameworks.png b/platform/platform-impl/src/icons/plugins/JavaFrameworks.png
new file mode 100644
index 000000000000..1ba077ca27ca
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/JavaFrameworks.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/JavaFrameworks@2x.png b/platform/platform-impl/src/icons/plugins/JavaFrameworks@2x.png
new file mode 100644
index 000000000000..1b9e872bd758
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/JavaFrameworks@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/OtherTools.png b/platform/platform-impl/src/icons/plugins/OtherTools.png
new file mode 100644
index 000000000000..eabbc4bc32d5
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/OtherTools.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/OtherTools@2x.png b/platform/platform-impl/src/icons/plugins/OtherTools@2x.png
new file mode 100644
index 000000000000..fa3b2021761a
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/OtherTools@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/PluginDevelopment.png b/platform/platform-impl/src/icons/plugins/PluginDevelopment.png
new file mode 100644
index 000000000000..68a4a9ccf205
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/PluginDevelopment.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/PluginDevelopment@2x.png b/platform/platform-impl/src/icons/plugins/PluginDevelopment@2x.png
new file mode 100644
index 000000000000..f02ae30b598d
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/PluginDevelopment@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/Swing.png b/platform/platform-impl/src/icons/plugins/Swing.png
new file mode 100644
index 000000000000..f0b032a73105
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/Swing.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/Swing@2x.png b/platform/platform-impl/src/icons/plugins/Swing@2x.png
new file mode 100644
index 000000000000..a0712688ac8c
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/Swing@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/TestTools.png b/platform/platform-impl/src/icons/plugins/TestTools.png
new file mode 100644
index 000000000000..9d79fa47ea6b
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/TestTools.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/TestTools@2x.png b/platform/platform-impl/src/icons/plugins/TestTools@2x.png
new file mode 100644
index 000000000000..95af9f268ef4
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/TestTools@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/VersionControls.png b/platform/platform-impl/src/icons/plugins/VersionControls.png
new file mode 100644
index 000000000000..be676163e539
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/VersionControls.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/VersionControls@2x.png b/platform/platform-impl/src/icons/plugins/VersionControls@2x.png
new file mode 100644
index 000000000000..427637d7848b
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/VersionControls@2x.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/WebDevelopment.png b/platform/platform-impl/src/icons/plugins/WebDevelopment.png
new file mode 100644
index 000000000000..d9e7430921de
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/WebDevelopment.png
Binary files differ
diff --git a/platform/platform-impl/src/icons/plugins/WebDevelopment@2x.png b/platform/platform-impl/src/icons/plugins/WebDevelopment@2x.png
new file mode 100644
index 000000000000..52f6be48c8a5
--- /dev/null
+++ b/platform/platform-impl/src/icons/plugins/WebDevelopment@2x.png
Binary files differ
diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties
index 47c4cef92207..50500e895c48 100644
--- a/platform/platform-resources-en/src/messages/ActionsBundle.properties
+++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties
@@ -939,6 +939,7 @@ action.Debugger.Inspect.text=Inspect
action.Debugger.CopyValue.text=Copy Value
action.Debugger.ViewText.text=View Text
action.Debugger.ViewText.description=View text value of selected node in a separate pane
+action.Debugger.ShowReferring.text=Show Referring Objects
action.Debugger.CompareValueWithClipboard.text=Compare Value with Clipboard
action.Debugger.CompareValueWithClipboard.description=Compare value of selected node with clipboard text
action.Debugger.CustomizeContextView.text=Customize Data Views...
diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties
index 5d539357ca3d..75d0f242e38c 100644
--- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties
+++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties
@@ -360,7 +360,7 @@ label.collapse.by.default=Collapse by default:
checkbox.show.code.folding.outline=Show code folding outline
group.tab.appearance=Tab Appearance
editbox.tab.limit=Tab limit:
-editbox.tab.title.limit=Tab title limit:
+editbox.tab.title.limit=Tab title limit (characters):
combobox.editor.tab.placement=Placement:
checkbox.editor.tabs.in.single.row=Show tabs in single row
checkbox.editor.tabs.show.close.button=Show "close" button on editor tabs
diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties
index 155e2b6c6d74..183dda3d52b8 100644
--- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties
+++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties
@@ -171,6 +171,7 @@ terminating.process.progress.kill=Kill process
waiting.for.vm.detach.progress.text=Waiting for process detach
restart.error.message.title=Restart Error
rerun.configuration.action.name=Rerun ''{0}''
+stop.configuration.action.name=Stop ''{0}''
rerun.singleton.confirmation.message=''{0}'' is single-instance run configuration.\nAre you sure you want to stop {1, choice, 1#the running one|2#{1, number} running instances}?
rerun.confirmation.button.text=Stop and Rerun
rerun.confirmation.checkbox=Confirm rerun with process termination
diff --git a/platform/platform-resources-en/src/messages/FindBundle.properties b/platform/platform-resources-en/src/messages/FindBundle.properties
index 8a857db74fd0..067ef38e17f6 100644
--- a/platform/platform-resources-en/src/messages/FindBundle.properties
+++ b/platform/platform-resources-en/src/messages/FindBundle.properties
@@ -134,4 +134,5 @@ find.scope.custom.radio=Cu&stom:
find.usages.ambiguous.title=Find Usages Of {0}
0.occurrences.replaced={0,choice,0#No|1#{0}} {0,choice,0#occurrences|1#occurrence|2#occurrences} replaced
found.occurrences=Found Occurrences
-occurrence=occurrence \ No newline at end of file
+occurrence=occurrence
+results.options.group=Result options \ No newline at end of file
diff --git a/platform/platform-resources-en/src/messages/InspectionsBundle.properties b/platform/platform-resources-en/src/messages/InspectionsBundle.properties
index 40940d687471..a339716f031e 100644
--- a/platform/platform-resources-en/src/messages/InspectionsBundle.properties
+++ b/platform/platform-resources-en/src/messages/InspectionsBundle.properties
@@ -667,7 +667,7 @@ unused.library.roots.problem.descriptor=Unused roots {0} from library ''{1}''
unused.library.backward.analysis.job.description=Perform backward analysis
inspection.duplicates.option.report.propertykey.expressions=&Ignore @PropertyKey expressions
inspection.same.parameter.fix.name=Inline value ''{1}'' for parameter ''{0}''
-fix.all.inspection.problems.in.file=Fix all ''{0}'' problems
+fix.all.inspection.problems.in.file=Fix all ''{0}'' problems in file
cleanup.in.file=Cleanup code
cleanup.in.scope=Cleanup code on...
severities.default.settings.message=Edit Settings|Colors \\& Fonts
diff --git a/platform/platform-resources-en/src/messages/OptionsBundle.properties b/platform/platform-resources-en/src/messages/OptionsBundle.properties
index aa2d1047c66e..2a78c19bdd82 100644
--- a/platform/platform-resources-en/src/messages/OptionsBundle.properties
+++ b/platform/platform-resources-en/src/messages/OptionsBundle.properties
@@ -198,6 +198,8 @@ options.xml.display.name=XML
settings.panel.title=Settings
+node.configurable.build.tools.display.name=Build Tools
+
configurable.group.appearance.settings.display.name=Appearance and Behavior
configurable.group.editor.settings.display.name=Editor
configurable.group.project.settings.display.name=Current Project
diff --git a/platform/platform-resources-en/src/messages/RefactoringBundle.properties b/platform/platform-resources-en/src/messages/RefactoringBundle.properties
index 080dce748805..48d0e63d60c0 100644
--- a/platform/platform-resources-en/src/messages/RefactoringBundle.properties
+++ b/platform/platform-resources-en/src/messages/RefactoringBundle.properties
@@ -438,6 +438,7 @@ inline.command=Inline {0}
inline.local.variable.prompt=Inline local variable ''{0}''?
inline.local.variable.definition.prompt=Inline local variable ''{0}'' definition?
occurences.string=({0,choice,1#1 occurrence|2#{0,number} occurrences})
+occurrences.string=({0,choice,1#1 occurrence|2#{0,number} occurrences})
inline.method.title=Inline Method
inline.method.method.label=Method {0}
inline.method.border.title=Inline
diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml
index aaae5ddfab28..c338dac9848b 100644
--- a/platform/platform-resources/src/META-INF/LangExtensions.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensions.xml
@@ -166,8 +166,7 @@
<applicationService serviceInterface="com.intellij.util.download.DownloadableFileService"
serviceImplementation="com.intellij.util.download.impl.DownloadableFileServiceImpl"/>
- <applicationService serviceInterface="com.intellij.psi.impl.DocumentCommitThread"
- serviceImplementation="com.intellij.psi.impl.DocumentCommitThread"/>
+ <applicationService serviceImplementation="com.intellij.psi.impl.DocumentCommitThread"/>
<applicationService serviceInterface="com.intellij.psi.stubs.StubTreeLoader"
serviceImplementation="com.intellij.psi.stubs.StubTreeLoaderImpl"/>
@@ -614,7 +613,7 @@
<editorCustomization implementation="com.intellij.ui.RightMarginEditorCustomization"/>
<!-- Colors & Fonts-->
- <editorOptionsProvider instance="com.intellij.application.options.colors.ColorAndFontOptions"
+ <applicationConfigurable groupId="editor" dynamic="true" instance="com.intellij.application.options.colors.ColorAndFontOptions"
id="reference.settingsdialog.IDE.editor.colors"/>
<editorOptionsProvider instance="com.intellij.application.options.editor.EditorTabsConfigurable" id="editor.preferences.tabs"
displayName="Editor Tabs"/>
@@ -652,6 +651,7 @@
<editorActionHandler action="EditorEnter" implementationClass="com.intellij.codeInsight.editorActions.EnterHandler" id="editorEnter"/>
<editorActionHandler action="EditorLineEnd" implementationClass="com.intellij.codeInsight.editorActions.EndHandler"/>
<editorActionHandler action="EditorSelectWord" implementationClass="com.intellij.codeInsight.editorActions.SelectWordHandler"/>
+ <editorActionHandler action="EditorSelectWord" implementationClass="com.intellij.openapi.editor.actions.SelectWordAtCaretAction$Handler" order="first"/>
<editorActionHandler action="EditorUnSelectWord" implementationClass="com.intellij.codeInsight.editorActions.UnSelectWordHandler"/>
<editorActionHandler action="EditorPaste" implementationClass="com.intellij.codeInsight.editorActions.PasteHandler"/>
<editorActionHandler action="EditorCopy" implementationClass="com.intellij.codeInsight.editorActions.CopyHandler"/>
@@ -825,7 +825,7 @@
<defaultHighlightingSettingProvider implementation="com.intellij.codeInsight.daemon.impl.analysis.GeneratedSourcesHighlightingSettingProvider"/>
<editorNotificationProvider implementation="com.intellij.ide.GeneratedFileEditingNotificationProvider"/>
- <editorTabTitleProvider implementation="com.intellij.openapi.fileEditor.impl.UniqueNameEditorTabTitleProvider"/>
+ <editorTabTitleProvider implementation="com.intellij.openapi.fileEditor.impl.UniqueNameEditorTabTitleProvider" order="last"/>
<projectService serviceInterface="com.intellij.psi.util.PsiModificationTracker"
serviceImplementation="com.intellij.psi.impl.PsiModificationTrackerImpl"/>
@@ -889,6 +889,8 @@
<editorOptionsProvider id="editing.postfixCompletion" instance="com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesConfigurable"/>
<completion.contributor language="any" implementationClass="com.intellij.codeInsight.template.postfix.completion.PostfixTemplateCompletionContributor"/>
+ <projectService serviceInterface="com.intellij.execution.ExecutionManager" serviceImplementation="com.intellij.execution.impl.ExecutionManagerImpl"/>
+ <projectService serviceInterface="com.intellij.execution.ExecutionTargetManager" serviceImplementation="com.intellij.execution.ExecutionTargetManagerImpl"/>
</extensions>
</idea-plugin>
diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml
index e8a45edbf138..a4dfd49a71a8 100644
--- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml
+++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml
@@ -230,6 +230,8 @@
<with attribute="implementationClass" implements="com.intellij.codeInsight.template.postfix.templates.PostfixTemplateProvider"/>
</extensionPoint>
+ <extensionPoint name="editor.linePainter" interface="com.intellij.openapi.editor.EditorLinePainter"/>
+
<extensionPoint name="actionFromOptionDescriptorProvider" interface="com.intellij.ide.ui.search.ActionFromOptionDescriptorProvider"/>
</extensionPoints>
</idea-plugin>
diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml
index 7aa76abcd4f8..467ef8233919 100644
--- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml
+++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml
@@ -239,6 +239,10 @@
<applicationService serviceInterface="com.intellij.ui.ColorChooserService"
serviceImplementation="com.intellij.ui.ColorChooserServiceImpl"/>
+ <applicationService serviceInterface="com.intellij.openapi.actionSystem.AbbreviationManager"
+ serviceImplementation="com.intellij.openapi.actionSystem.impl.AbbreviationManagerImpl"/>
+ <exportable serviceInterface="com.intellij.openapi.actionSystem.AbbreviationManager"/>
+
<scopeParserExtension implementation="com.intellij.psi.search.scope.packageSet.FilePackageSetParserExtension"/>
<applicationService serviceInterface="com.intellij.openapi.ui.popup.StackingPopupDispatcher" serviceImplementation="com.intellij.ui.popup.StackingPopupDispatcherImpl"/>
diff --git a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml
index b7a11c39ecae..ea14882e5ae6 100644
--- a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml
+++ b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml
@@ -101,5 +101,8 @@
<xi:include href="/META-INF/vcs-log-graph.xml" xpointer="xpointer(/idea-plugin/*)">
<xi:fallback/>
</xi:include>
+ <xi:include href="/META-INF/dvcs.xml" xpointer="xpointer(/idea-plugin/*)">
+ <xi:fallback/>
+ </xi:include>
</idea-plugin>
diff --git a/platform/platform-resources/src/META-INF/PlatformPlugin.xml b/platform/platform-resources/src/META-INF/PlatformPlugin.xml
index db1cae3e76aa..773b00c2b9f2 100644
--- a/platform/platform-resources/src/META-INF/PlatformPlugin.xml
+++ b/platform/platform-resources/src/META-INF/PlatformPlugin.xml
@@ -10,6 +10,9 @@
<xi:include href="/META-INF/vcs-log-graph.xml" xpointer="xpointer(/idea-plugin/*)">
<xi:fallback/>
</xi:include>
+ <xi:include href="/META-INF/dvcs.xml" xpointer="xpointer(/idea-plugin/*)">
+ <xi:fallback/>
+ </xi:include>
<extensionPoints>
<xi:include href="/META-INF/PlatformExtensionPoints.xml" xpointer="xpointer(/idea-plugin/extensionPoints/*)"/>
diff --git a/platform/platform-resources/src/META-INF/xdebugger.xml b/platform/platform-resources/src/META-INF/xdebugger.xml
index 4b03978f9473..4dde33287f0c 100644
--- a/platform/platform-resources/src/META-INF/xdebugger.xml
+++ b/platform/platform-resources/src/META-INF/xdebugger.xml
@@ -36,6 +36,7 @@
<xdebugger.debuggerSupport implementation="com.intellij.xdebugger.impl.XDebuggerSupport" order="first"/>
<xdebugger.configurableProvider implementation="com.intellij.xdebugger.impl.settings.XDebuggerConfigurableProvider" order="first"/>
+ <editor.linePainter implementation="com.intellij.xdebugger.impl.evaluate.XDebuggerEditorLinePainter"/>
<executor implementation="com.intellij.execution.executors.DefaultDebugExecutor" order="first,after run"/>
</extensions>
diff --git a/platform/platform-resources/src/brokenPlugins.txt b/platform/platform-resources/src/brokenPlugins.txt
index 57b863fb916b..7b0830e86b02 100644
--- a/platform/platform-resources/src/brokenPlugins.txt
+++ b/platform/platform-resources/src/brokenPlugins.txt
@@ -1,18 +1,19 @@
// This file contains list of broken plugins.
// Each line contains plugin ID and list of versions that are broken.
// If plugin name or version contains a space you can quote it like in command line.
-NodeJS 138.937 138.1013 138.921 138.447 138.172 138.317 138.21 138.35 138.96 138.85 136.1205 134.1276 134.1163 134.1145 134.1081 134.1039 134.985 134.680 134.31 134.307 134.262 134.198 134.125 136.1141
-com.jetbrains.php 138.826 136.1768 136.1672 134.1456 133.982 133.679 133.51 133.326 131.98 131.374 131.332 131.235 131.205 130.1639 130.1481 130.1176 129.91 129.814 129.672 129.362 127.67 127.100 126.334 123.66 122.875 121.62 121.390 121.215 121.12
+NodeJS 138.1189 138.1145 138.937 138.1013 138.921 138.447 138.172 138.317 138.21 138.35 138.96 138.85 136.1205 134.1276 134.1163 134.1145 134.1081 134.1039 134.985 134.680 134.31 134.307 134.262 134.198 134.125 136.1141
+com.jetbrains.php 138.1161 138.826 136.1768 136.1672 134.1456 133.982 133.679 133.51 133.326 131.98 131.374 131.332 131.235 131.205 130.1639 130.1481 130.1176 129.91 129.814 129.672 129.362 127.67 127.100 126.334 123.66 122.875 121.62 121.390 121.215 121.12
com.jetbrains.lang.ejs 131.17 131.12
com.jetbrains.twig 133.51 130.1639
-org.jetbrains.plugins.ruby 6.0.0.20140207 6.5.2.20140512 7.0.0.20140704 7.0.0.20140707
+org.jetbrains.plugins.ruby 6.0.0.20140207 6.5.2.20140512 7.0.0.20140704 7.0.0.20140707 7.0.0.20140724
Pythonid 3.1 4.0.25
Karma 138.21 134.1163 134.1039 134.686 134.31
-org.intellij.scala 0.40.20 0.40.18 0.40.16 0.32.593 0.32.562 0.32.558 0.32.550 0.32.520 0.32.512
+org.intellij.scala 0.42.23 0.40.20 0.40.18 0.40.16 0.32.593 0.32.562 0.32.558 0.32.550 0.32.520 0.32.512
org.jetbrains.kannotator 0.2.420
org.jetbrains.kotlin 0.7.1360 0.7.1376 0.8.7
SBT 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.4.0 1.5.0
"JSTestDriver Plugin" 138.21 136.1141 134.1163 134.686 134.31 134.307 134.1039
AngularJS 134.1094 0.1.8 0.1.9
org.jetbrains.plugins.vagrant 0.1 0.2
-org.intellij.clojure 0.2.1.178 \ No newline at end of file
+org.intellij.clojure 0.2.1.178
+net.nicoulaj.idea.markdown 0.9.6 0.9.5 0.9.4 0.9.3 0.9.2 0.9.1 0.8.3 0.8.2 0.8.1 0.8 0.7 0.6.1 0.6 0.5.1 0.5 0.4 0.3 0.2 0.1
diff --git a/platform/platform-resources/src/componentSets/Execution.xml b/platform/platform-resources/src/componentSets/Execution.xml
index 829135bbb0b2..6f548daa692b 100644
--- a/platform/platform-resources/src/componentSets/Execution.xml
+++ b/platform/platform-resources/src/componentSets/Execution.xml
@@ -18,17 +18,7 @@
<loadForDefaultProject/>
</component>
<component>
- <interface-class>com.intellij.execution.ExecutionTargetManager</interface-class>
- <implementation-class>com.intellij.execution.ExecutionTargetManagerImpl</implementation-class>
- <option name="workspace" value="true"/>
- <loadForDefaultProject/>
- </component>
- <component>
<implementation-class>com.intellij.execution.impl.ProjectRunConfigurationManager</implementation-class>
</component>
- <component>
- <interface-class>com.intellij.execution.ExecutionManager</interface-class>
- <implementation-class>com.intellij.execution.impl.ExecutionManagerImpl</implementation-class>
- </component>
</project-components>
-</components> \ No newline at end of file
+</components>
diff --git a/platform/platform-resources/src/componentSets/UICore.xml b/platform/platform-resources/src/componentSets/UICore.xml
index 8d7d5d63e055..6d2b09835c8c 100644
--- a/platform/platform-resources/src/componentSets/UICore.xml
+++ b/platform/platform-resources/src/componentSets/UICore.xml
@@ -14,10 +14,6 @@
<headless-implementation-class>com.intellij.idea.CommandLineApplication$MyDataManagerImpl</headless-implementation-class>
</component>
<component>
- <interface-class>com.intellij.openapi.actionSystem.AbbreviationManager</interface-class>
- <implementation-class>com.intellij.openapi.actionSystem.impl.AbbreviationManagerImpl</implementation-class>
- </component>
- <component>
<interface-class>com.intellij.openapi.actionSystem.ActionManager</interface-class>
<implementation-class>com.intellij.openapi.actionSystem.impl.ActionManagerImpl</implementation-class>
</component>
diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml
index 65fa309fe3b9..3b0289f12433 100644
--- a/platform/platform-resources/src/idea/LangActions.xml
+++ b/platform/platform-resources/src/idea/LangActions.xml
@@ -364,6 +364,7 @@
<separator/>
<reference id="NavBarToolBarOthers"/>
<separator/>
+ <reference ref="SearchEverywhere"/>
</group>
<group id="Bookmarks">
@@ -697,6 +698,7 @@
</group>
<group id="XDebugger.ToolWindow.LeftToolbar">
+ <reference ref="Rerun"/>
<reference ref="Resume"/>
<reference ref="Pause"/>
<reference ref="Stop"/>
diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml
index 869a8a754886..7773a2b00e49 100644
--- a/platform/platform-resources/src/idea/PlatformActions.xml
+++ b/platform/platform-resources/src/idea/PlatformActions.xml
@@ -457,6 +457,7 @@
</group>
<separator/>
<reference ref="HelpTopics"/>
+ <reference ref="SearchEverywhere"/>
</group>
<group id="NavBarVcsGroup"/>
@@ -580,8 +581,8 @@
<action id="MaintenanceAction" class="com.intellij.ide.actions.MaintenanceAction"/>
<group id="MaintenanceGroup">
- <action id="UiDebugger" class="com.intellij.ui.debugger.ShowUiDebuggerAction"/>
<action id="ShowRegistry" class="com.intellij.openapi.util.registry.ShowRegistryAction"/>
+ <action id="UiDebugger" class="com.intellij.ui.debugger.ShowUiDebuggerAction"/>
</group>
<action id="Console.Execute" class="com.intellij.openapi.actionSystem.EmptyAction"/>
diff --git a/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java b/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java
new file mode 100644
index 000000000000..32ec00d1a733
--- /dev/null
+++ b/platform/platform-tests/testSrc/com/intellij/execution/process/AnsiEscapeDecoderTest.java
@@ -0,0 +1,55 @@
+package com.intellij.execution.process;
+
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pair;
+import com.intellij.testFramework.PlatformTestCase;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Assert;
+
+import java.util.List;
+
+public class AnsiEscapeDecoderTest extends PlatformTestCase {
+
+ public void testTextWithoutColors() throws Exception {
+ AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
+ decoder.escapeText("", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
+ Pair.create("", ProcessOutputTypes.STDOUT)
+ )));
+ decoder.escapeText("simple text", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
+ Pair.create("simple text", ProcessOutputTypes.STDOUT)
+ )));
+ }
+
+ public void testSingleColoredChunk() throws Exception {
+ AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
+ decoder.escapeText("Chrome 35.0.1916 (Linux): Executed 0 of 1\u001B[32m SUCCESS\u001B[39m (0 secs / 0 secs)\n", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
+ Pair.create("Chrome 35.0.1916 (Linux): Executed 0 of 1", ProcessOutputTypes.STDOUT),
+ Pair.create(" SUCCESS", ColoredOutputTypeRegistry.getInstance().getOutputKey("\u001B[32m")),
+ Pair.create(" (0 secs / 0 secs)\n", ColoredOutputTypeRegistry.getInstance().getOutputKey("\u001B[39m"))
+ )));
+ }
+
+ public void testCompoundEscSeq() throws Exception {
+ AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
+ decoder.escapeText("E\u001B[41m\u001B[37mE\u001B[0mE", ProcessOutputTypes.STDOUT, createExpectedAcceptor(ContainerUtil.newArrayList(
+ Pair.create("E", ProcessOutputTypes.STDOUT),
+ Pair.create("E", ColoredOutputTypeRegistry.getInstance().getOutputKey("\u001B[41;37m")),
+ Pair.create("E", ProcessOutputTypes.STDOUT)
+ )));
+ }
+
+ private static AnsiEscapeDecoder.ColoredChunksAcceptor createExpectedAcceptor(@NotNull final List<Pair<String, Key>> expected) {
+ return new AnsiEscapeDecoder.ColoredChunksAcceptor() {
+ @Override
+ public void coloredChunksAvailable(List<Pair<String, Key>> chunks) {
+ Assert.assertEquals(expected, chunks);
+ }
+
+ @Override
+ public void coloredTextAvailable(String text, Key attributes) {
+ throw new RuntimeException(); // shouldn't be called
+ }
+ };
+ }
+}
diff --git a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java
index 6ba1e4aa12de..bbcbe9b4c2f2 100644
--- a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/LocalHistoryActionsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -20,11 +20,7 @@ import com.intellij.history.integration.TestVirtualFile;
import com.intellij.history.integration.ui.actions.LocalHistoryAction;
import com.intellij.history.integration.ui.actions.ShowHistoryAction;
import com.intellij.history.integration.ui.actions.ShowSelectionHistoryAction;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
@@ -135,6 +131,6 @@ public class LocalHistoryActionsTest extends LocalHistoryUITestCase {
return null;
}
};
- return new AnActionEvent(null, dc, "", a.getTemplatePresentation(), null, -1);
+ return new AnActionEvent(null, dc, "", a.getTemplatePresentation(), ActionManager.getInstance(), -1);
}
}
diff --git a/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java b/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java
index 0e2355f5c3c1..a84497a8f083 100644
--- a/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/ide/passwordSafe/impl/providers/masterKey/MasterKeyPasswordSafeTest.java
@@ -28,13 +28,13 @@ public class MasterKeyPasswordSafeTest {
@Test
public void testMasterKey() throws PasswordSafeException {
PasswordDatabase db = new PasswordDatabase();
- MasterKeyPasswordSafe s1 = testProvider(db);
+ MasterKeyPasswordSafe s1 = new MasterKeyPasswordSafe(db);
s1.resetMasterPassword("pass1", false);
s1.storePassword(null, MasterKeyPasswordSafeTest.class, "TEST", "test");
assertEquals("test", s1.getPassword(null, MasterKeyPasswordSafeTest.class, "TEST"));
assertTrue(s1.changeMasterPassword("pass1", "pass2", false));
assertEquals("test", s1.getPassword(null, MasterKeyPasswordSafeTest.class, "TEST"));
- MasterKeyPasswordSafe s2 = testProvider(db);
+ MasterKeyPasswordSafe s2 = new MasterKeyPasswordSafe(db);
assertFalse(s2.setMasterPassword("pass1"));
assertTrue(s2.setMasterPassword("pass2"));
assertEquals("test", s2.getPassword(null, MasterKeyPasswordSafeTest.class, "TEST"));
@@ -45,19 +45,4 @@ public class MasterKeyPasswordSafeTest {
s2.resetMasterPassword("fail", false);
assertNull(s2.getPassword(null, MasterKeyPasswordSafeTest.class, "TEST"));
}
-
- /**
- * Get test instance of the provider
- * @param db the database to use
- * @return a instance of the provider
- */
- private static MasterKeyPasswordSafe testProvider(final PasswordDatabase db) {
- return new MasterKeyPasswordSafe(db) {
- @Override
- protected boolean isTestMode() {
- return true;
- }
- };
- }
-
}
diff --git a/platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java b/platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java
index 92b2ebad945c..99c6f5b5d25a 100644
--- a/platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/ide/util/treeView/TreeUiTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,7 +15,6 @@
*/
package com.intellij.ide.util.treeView;
-import com.intellij.openapi.diagnostic.Log;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Progressive;
@@ -2753,22 +2752,6 @@ public class TreeUiTest extends AbstractTreeBuilderTest {
return suite;
}
- @Override
- protected void tearDown() throws Exception {
- AbstractTreeUi ui = getBuilder().getUi();
- if (ui != null) {
- ui.getReady(this).doWhenProcessed(new Runnable() {
- @Override
- public void run() {
- Log.flush();
- }
- });
- } else {
- Log.flush();
- }
- super.tearDown();
- }
-
private abstract static class MyRunnable implements Runnable {
@Override
public final void run() {
diff --git a/platform/platform-tests/testSrc/com/intellij/psi/PsiDocumentManagerImplTest.java b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java
index 2ab0446e86a4..b1ab5117dba9 100644
--- a/platform/platform-tests/testSrc/com/intellij/psi/PsiDocumentManagerImplTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/psi/impl/PsiDocumentManagerImplTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.psi;
+package com.intellij.psi.impl;
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.mock.MockDocument;
@@ -27,8 +27,9 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.impl.DebugUtil;
-import com.intellij.psi.impl.PsiDocumentManagerImpl;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.testFramework.LeakHunter;
import com.intellij.testFramework.LightVirtualFile;
@@ -46,6 +47,13 @@ public class PsiDocumentManagerImplTest extends PlatformLangTestCase {
return (PsiDocumentManagerImpl)PsiDocumentManager.getInstance(getProject());
}
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ DocumentCommitThread.getInstance();
+ UIUtil.dispatchAllInvocationEvents();
+ }
+
public void testGetCachedPsiFile_NoFile() throws Exception {
final PsiFile file = getPsiDocumentManager().getCachedPsiFile(new MockDocument());
assertNull(file);
@@ -367,4 +375,23 @@ public class PsiDocumentManagerImplTest extends PlatformLangTestCase {
ProjectUtil.closeAndDispose(alienProject);
}
}
+
+ public void testCommitThreadGetSuspendedDuringWriteActions() {
+ final DocumentCommitThread commitThread = DocumentCommitThread.getInstance();
+ assertTrue(commitThread.isEnabled());
+ WriteCommandAction.runWriteCommandAction(null, new Runnable() {
+ @Override
+ public void run() {
+ assertFalse(commitThread.isEnabled());
+ WriteCommandAction.runWriteCommandAction(null, new Runnable() {
+ @Override
+ public void run() {
+ assertFalse(commitThread.isEnabled());
+ }
+ });
+ assertFalse(commitThread.isEnabled());
+ }
+ });
+ assertTrue(commitThread.isEnabled());
+ }
}
diff --git a/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java b/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java
index 4544a7e547f1..1f3f1a8a248d 100644
--- a/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java
+++ b/platform/platform-tests/testSrc/com/intellij/ui/tabs/impl/JBTabsDemo.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -16,6 +16,7 @@
package com.intellij.ui.tabs.impl;
import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.IconLoader;
@@ -46,7 +47,7 @@ public class JBTabsDemo {
final JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout(0, 0));
final int[] count = new int[1];
- final JBTabsImpl tabs = new JBTabsImpl(null, null, null, Disposer.newDisposable());
+ final JBTabsImpl tabs = new JBTabsImpl(null, ActionManager.getInstance(), null, Disposer.newDisposable());
tabs.setTestMode(true);
diff --git a/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java b/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java
index 17a7abc2a694..fdae3317e74e 100644
--- a/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java
+++ b/platform/projectModel-api/src/com/intellij/openapi/roots/ProjectFileIndex.java
@@ -49,6 +49,16 @@ public interface ProjectFileIndex extends FileIndex {
Module getModuleForFile(@NotNull VirtualFile file);
/**
+ * Returns module to which the specified file belongs.
+ *
+ * @param file the file for which the module is requested.
+ * @param honorExclusion if {@code false} the containing module will be returned even if the file is located under a folder marked as excluded
+ * @return the module instance or null if the file does not belong to content of any module.
+ */
+ @Nullable
+ Module getModuleForFile(@NotNull VirtualFile file, boolean honorExclusion);
+
+ /**
* Returns the order entries which contain the specified file (either in CLASSES or SOURCES).
*
* @param file the file for which the order entries are requested.
@@ -88,6 +98,16 @@ public interface ProjectFileIndex extends FileIndex {
VirtualFile getContentRootForFile(@NotNull VirtualFile file);
/**
+ * Returns the module content root to which the specified file or directory belongs.
+ *
+ * @param file the file or directory for which the information is requested.
+ * @param honorExclusion if {@code false} the containing content root will be returned even if the file is located under a folder marked as excluded
+ * @return the file for the content root, or null if the file does not belong to this project.
+ */
+ @Nullable
+ VirtualFile getContentRootForFile(@NotNull VirtualFile file, final boolean honorExclusion);
+
+ /**
* Returns the name of the package corresponding to the specified directory.
*
* @param dir the directory for which the package name is requested.
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndex.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndex.java
index e87d3c749b10..70eb213d86c8 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndex.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndex.java
@@ -17,7 +17,6 @@
package com.intellij.openapi.roots.impl;
import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.vfs.VirtualFile;
@@ -26,8 +25,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
-import java.util.List;
-
public abstract class DirectoryIndex {
public static DirectoryIndex getInstance(Project project) {
assert !project.isDefault() : "Must not call DirectoryIndex for default project";
@@ -65,10 +62,4 @@ public abstract class DirectoryIndex {
@NotNull
public abstract OrderEntry[] getOrderEntries(@NotNull DirectoryInfo info);
-
- @Nullable
- abstract OrderEntry findOrderEntryWithOwnerModule(@NotNull DirectoryInfo info, @NotNull Module ownerModule);
-
- @NotNull
- abstract List<OrderEntry> findAllOrderEntriesWithOwnerModule(@NotNull DirectoryInfo info, @NotNull Module ownerModule);
}
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java
index 8140a3c15211..eb8a9ddf5587 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java
@@ -18,17 +18,18 @@ package com.intellij.openapi.roots.impl;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.roots.ContentIterator;
-import com.intellij.openapi.roots.ModuleFileIndex;
-import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.roots.OrderEntry;
+import com.intellij.openapi.roots.*;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileFilter;
+import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -79,12 +80,12 @@ public class ModuleFileIndexImpl extends FileIndexBase implements ModuleFileInde
@Override
@NotNull
public List<OrderEntry> getOrderEntriesForFile(@NotNull VirtualFile fileOrDir) {
- return myDirectoryIndex.findAllOrderEntriesWithOwnerModule(getInfoForFileOrDirectory(fileOrDir), myModule);
+ return findAllOrderEntriesWithOwnerModule(myModule, myDirectoryIndex.getOrderEntries(getInfoForFileOrDirectory(fileOrDir)));
}
@Override
public OrderEntry getOrderEntryForFile(@NotNull VirtualFile fileOrDir) {
- return myDirectoryIndex.findOrderEntryWithOwnerModule(getInfoForFileOrDirectory(fileOrDir), myModule);
+ return findOrderEntryWithOwnerModule(myModule, myDirectoryIndex.getOrderEntries(getInfoForFileOrDirectory(fileOrDir)));
}
@Override
@@ -100,6 +101,97 @@ public class ModuleFileIndexImpl extends FileIndexBase implements ModuleFileInde
return info.isInModuleSource() && myModule.equals(info.getModule()) && rootTypes.contains(myDirectoryIndex.getSourceRootType(info));
}
+ @Nullable
+ static OrderEntry findOrderEntryWithOwnerModule(@NotNull Module ownerModule, @NotNull OrderEntry[] orderEntries) {
+ if (orderEntries.length < 10) {
+ for (OrderEntry entry : orderEntries) {
+ if (entry.getOwnerModule() == ownerModule) return entry;
+ }
+ return null;
+ }
+ int index = Arrays.binarySearch(orderEntries, new FakeOrderEntry(ownerModule), RootIndex.BY_OWNER_MODULE);
+ return index < 0 ? null : orderEntries[index];
+ }
+
+ @NotNull
+ private static List<OrderEntry> findAllOrderEntriesWithOwnerModule(@NotNull Module ownerModule, @NotNull OrderEntry[] entries) {
+ if (entries.length == 0) return Collections.emptyList();
+
+ if (entries.length == 1) {
+ OrderEntry entry = entries[0];
+ return entry.getOwnerModule() == ownerModule ? Arrays.asList(entries) : Collections.<OrderEntry>emptyList();
+ }
+ int index = Arrays.binarySearch(entries, new FakeOrderEntry(ownerModule), RootIndex.BY_OWNER_MODULE);
+ if (index < 0) {
+ return Collections.emptyList();
+ }
+ int firstIndex = index;
+ while (firstIndex - 1 >= 0 && entries[firstIndex - 1].getOwnerModule() == ownerModule) {
+ firstIndex--;
+ }
+ int lastIndex = index + 1;
+ while (lastIndex < entries.length && entries[lastIndex].getOwnerModule() == ownerModule) {
+ lastIndex++;
+ }
+
+ OrderEntry[] subArray = new OrderEntry[lastIndex - firstIndex];
+ System.arraycopy(entries, firstIndex, subArray, 0, lastIndex - firstIndex);
+
+ return Arrays.asList(subArray);
+ }
+
+ private static class FakeOrderEntry implements OrderEntry {
+ private final Module myOwnerModule;
+
+ public FakeOrderEntry(Module ownerModule) {
+ myOwnerModule = ownerModule;
+ }
+
+ @NotNull
+ @Override
+ public VirtualFile[] getFiles(OrderRootType type) {
+ throw new IncorrectOperationException();
+ }
+
+ @NotNull
+ @Override
+ public String[] getUrls(OrderRootType rootType) {
+ throw new IncorrectOperationException();
+ }
+
+ @NotNull
+ @Override
+ public String getPresentableName() {
+ throw new IncorrectOperationException();
+ }
+
+ @Override
+ public boolean isValid() {
+ throw new IncorrectOperationException();
+ }
+
+ @NotNull
+ @Override
+ public Module getOwnerModule() {
+ return myOwnerModule;
+ }
+
+ @Override
+ public <R> R accept(RootPolicy<R> policy, @Nullable R initialValue) {
+ throw new IncorrectOperationException();
+ }
+
+ @Override
+ public int compareTo(@NotNull OrderEntry o) {
+ throw new IncorrectOperationException();
+ }
+
+ @Override
+ public boolean isSynthetic() {
+ throw new IncorrectOperationException();
+ }
+ }
+
private class ContentFilter implements VirtualFileFilter {
@Override
public boolean accept(@NotNull VirtualFile file) {
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java
index e2417193149e..aec6e11a6d15 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java
@@ -30,6 +30,7 @@ import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileFilter;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
@@ -91,10 +92,18 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn
@Override
public Module getModuleForFile(@NotNull VirtualFile file) {
+ return getModuleForFile(file, true);
+ }
+
+ @Nullable
+ @Override
+ public Module getModuleForFile(@NotNull VirtualFile file, boolean honorExclusion) {
if (file instanceof VirtualFileWindow) file = ((VirtualFileWindow)file).getDelegate();
DirectoryInfo info = getInfoForFileOrDirectory(file);
- if (!info.isInProject()) return null;
- return info.getModule();
+ if (info.isInProject() || !honorExclusion && info.isExcluded()) {
+ return info.getModule();
+ }
+ return null;
}
@Override
@@ -119,9 +128,16 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn
@Override
public VirtualFile getContentRootForFile(@NotNull VirtualFile file) {
+ return getContentRootForFile(file, true);
+ }
+
+ @Override
+ public VirtualFile getContentRootForFile(@NotNull VirtualFile file, final boolean honorExclusion) {
final DirectoryInfo info = getInfoForFileOrDirectory(file);
- if (!info.isInProject()) return null;
- return info.getContentRoot();
+ if (info.isInProject() || !honorExclusion && info.isExcluded()) {
+ return info.getContentRoot();
+ }
+ return null;
}
@Override
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java
index eb04fb6c103e..bc85dabc9aec 100644
--- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java
+++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootIndex.java
@@ -497,10 +497,11 @@ public class RootIndex {
}
@Nullable
- private Module findParentModuleForExcluded(@NotNull List<VirtualFile> hierarchy) {
+ private VirtualFile findNearestContentRootForExcluded(@NotNull List<VirtualFile> hierarchy) {
for (VirtualFile root : hierarchy) {
- Module module = contentRootOf.get(root);
- if (module != null) return module;
+ if (contentRootOf.containsKey(root)) {
+ return root;
+ }
}
return null;
}
@@ -604,10 +605,14 @@ public class RootIndex {
VirtualFile moduleContentRoot = info.findModuleRootInfo(hierarchy);
VirtualFile libraryClassRoot = info.findLibraryRootInfo(hierarchy, false);
VirtualFile librarySourceRoot = info.findLibraryRootInfo(hierarchy, true);
- Module parentModuleForExcluded = null;
- if (moduleContentRoot == null && libraryClassRoot == null && librarySourceRoot == null) {
- parentModuleForExcluded = info.findParentModuleForExcluded(hierarchy);
- if (parentModuleForExcluded == null) {
+ boolean inProject = moduleContentRoot != null || libraryClassRoot != null || librarySourceRoot != null;
+ VirtualFile nearestContentRoot;
+ if (inProject) {
+ nearestContentRoot = moduleContentRoot;
+ }
+ else {
+ nearestContentRoot = info.findNearestContentRootForExcluded(hierarchy);
+ if (nearestContentRoot == null) {
return new Pair<DirectoryInfo, String>(NonProjectDirectoryInfo.EXCLUDED, null);
}
}
@@ -619,10 +624,9 @@ public class RootIndex {
boolean inLibrarySource = librarySourceRoot != null;
int typeId = moduleSourceRoot != null ? info.rootTypeId.get(moduleSourceRoot) : 0;
- Module module = parentModuleForExcluded != null ? parentModuleForExcluded : info.contentRootOf.get(moduleContentRoot);
+ Module module = info.contentRootOf.get(nearestContentRoot);
DirectoryInfo directoryInfo =
- new DirectoryInfoImpl(root, module, moduleContentRoot, sourceRoot, libraryClassRoot, inModuleSources, inLibrarySource,
- parentModuleForExcluded != null, typeId);
+ new DirectoryInfoImpl(root, module, nearestContentRoot, sourceRoot, libraryClassRoot, inModuleSources, inLibrarySource, !inProject, typeId);
String packagePrefix = info.calcPackagePrefix(root, hierarchy, moduleContentRoot, libraryClassRoot, librarySourceRoot);
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentLoggingHandler.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentLoggingHandler.java
index 3dae58e59bb9..7055bace613b 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentLoggingHandler.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentLoggingHandler.java
@@ -15,10 +15,14 @@
*/
package com.intellij.remoteServer.agent.util;
+import com.intellij.remoteServer.agent.util.log.LogListener;
+
/**
* @author michael.golubev
*/
public interface CloudAgentLoggingHandler {
void println(String message);
+
+ LogListener getOrCreateLogListener(String pipeName);
}
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentWithDeployment.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentWithDeployment.java
index 27533ffd1bb8..cf76eaa5216a 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentWithDeployment.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudAgentWithDeployment.java
@@ -21,10 +21,9 @@ import com.intellij.remoteServer.agent.annotation.ChildCall;
* @author michael.golubev
*/
public interface CloudAgentWithDeployment<Config extends CloudAgentConfig,
- DeploymentConfig extends CloudAgentDeploymentConfig,
- LoggingHandler extends CloudAgentLoggingHandler>
+ DeploymentConfig extends CloudAgentDeploymentConfig>
extends CloudAgentBase<Config> {
@ChildCall
- CloudAgentDeployment createDeployment(DeploymentConfig config, LoggingHandler loggingHandler);
+ CloudAgentDeployment createDeployment(DeploymentConfig config, CloudAgentLoggingHandler loggingHandler);
}
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgent.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgent.java
index cc9867477c7e..bc30b0bce2c8 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgent.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/CloudGitAgent.java
@@ -29,5 +29,5 @@ public interface CloudGitAgent<C extends CloudAgentConfigBase, D extends CloudGi
void disconnect();
@ChildCall
- D createDeployment(String deploymentName, CloudLoggingHandler loggingHandler);
+ D createDeployment(String deploymentName, CloudAgentLoggingHandler loggingHandler);
}
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogListener.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogListener.java
index 564402b19797..06e2896e7867 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogListener.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogListener.java
@@ -20,11 +20,11 @@ package com.intellij.remoteServer.agent.util.log;
*/
public interface LogListener {
- void lineLogged(String line, String deploymentName, String kind);
+ void lineLogged(String line);
LogListener NULL = new LogListener() {
- public void lineLogged(String line, String deploymentName, String kind) {
+ public void lineLogged(String line) {
}
};
diff --git a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogPipe.java b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogPipe.java
index 0b7bb1cf77a3..f56fe0940e65 100644
--- a/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogPipe.java
+++ b/platform/remote-servers/agent-rt/src/com/intellij/remoteServer/agent/util/log/LogPipe.java
@@ -30,16 +30,14 @@ public abstract class LogPipe {
private final ILogger myLog;
private final String myDeploymentName;
- private final String myKind;
private boolean myClosed;
private int myTotalLines;
private int myLines2Skip;
- public LogPipe(String deploymentName, String logKind, ILogger log) {
+ public LogPipe(String deploymentName, ILogger log) {
myDeploymentName = deploymentName;
- myKind = logKind;
myLog = log;
myClosed = false;
}
@@ -73,7 +71,7 @@ public abstract class LogPipe {
}
if (myLines2Skip == 0) {
- getLogListener().lineLogged(line, myDeploymentName, myKind);
+ getLogListener().lineLogged(line);
myTotalLines++;
}
else {
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudGitApplicationRuntime.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudGitApplicationRuntime.java
index 990167d951e4..5f40b5ac4257 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudGitApplicationRuntime.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudGitApplicationRuntime.java
@@ -20,8 +20,8 @@ import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
+import com.intellij.remoteServer.agent.util.CloudAgentLoggingHandler;
import com.intellij.remoteServer.agent.util.CloudGitAgentDeployment;
-import com.intellij.remoteServer.agent.util.CloudLoggingHandler;
import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager;
import com.intellij.util.ThrowableRunnable;
import org.jetbrains.annotations.NotNull;
@@ -31,7 +31,7 @@ public class CloudGitApplicationRuntime extends CloudApplicationRuntime {
private final CloudMultiSourceServerRuntimeInstance myServerRuntime;
private final DeploymentLogManager myLogManager;
- private final CloudLoggingHandler myLoggingHandler;
+ private final CloudAgentLoggingHandler myLoggingHandler;
private final CloudGitAgentDeployment myDeployment;
@@ -53,7 +53,7 @@ public class CloudGitApplicationRuntime extends CloudApplicationRuntime {
return myLogManager;
}
- protected CloudLoggingHandler getLoggingHandler() {
+ protected CloudAgentLoggingHandler getLoggingHandler() {
return myLoggingHandler;
}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java
index c816daceb859..346bd0af3046 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudLoggingHandlerImpl.java
@@ -15,7 +15,7 @@
*/
package com.intellij.remoteServer.util;
-import com.intellij.remoteServer.agent.util.CloudLoggingHandler;
+import com.intellij.remoteServer.agent.util.CloudAgentLoggingHandler;
import com.intellij.remoteServer.agent.util.log.LogListener;
import com.intellij.remoteServer.runtime.deployment.DeploymentLogManager;
import com.intellij.remoteServer.runtime.log.LoggingHandler;
@@ -25,7 +25,7 @@ import java.util.HashMap;
/**
* @author michael.golubev
*/
-public class CloudLoggingHandlerImpl implements CloudLoggingHandler {
+public class CloudLoggingHandlerImpl implements CloudAgentLoggingHandler {
private final HashMap<String, LogListener> myPipeName2LogListener;
@@ -52,7 +52,7 @@ public class CloudLoggingHandlerImpl implements CloudLoggingHandler {
logListener = new LogListener() {
@Override
- public void lineLogged(String line, String deploymentName, String kind) {
+ public void lineLogged(String line) {
loggingHandler.print(line + "\n");
}
};
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSilentLoggingHandlerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSilentLoggingHandlerImpl.java
index 69bcbdadfb7c..49321fdfc398 100644
--- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSilentLoggingHandlerImpl.java
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudSilentLoggingHandlerImpl.java
@@ -1,13 +1,13 @@
package com.intellij.remoteServer.util;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.remoteServer.agent.util.CloudLoggingHandler;
+import com.intellij.remoteServer.agent.util.CloudAgentLoggingHandler;
import com.intellij.remoteServer.agent.util.log.LogListener;
/**
* @author michael.golubev
*/
-public class CloudSilentLoggingHandlerImpl implements CloudLoggingHandler {
+public class CloudSilentLoggingHandlerImpl implements CloudAgentLoggingHandler {
private static final Logger LOG = Logger.getInstance("#" + CloudSilentLoggingHandlerImpl.class.getName());
diff --git a/platform/script-debugger/backend/src/org/jetbrains/rpc/MessageManager.java b/platform/script-debugger/backend/src/org/jetbrains/rpc/MessageManager.java
index 54fd4c023bd1..f7a29497e1c2 100644
--- a/platform/script-debugger/backend/src/org/jetbrains/rpc/MessageManager.java
+++ b/platform/script-debugger/backend/src/org/jetbrains/rpc/MessageManager.java
@@ -124,7 +124,10 @@ public final class MessageManager<OUTGOING, INCOMING, INCOMING_WITH_SEQ, SUCCESS
Arrays.sort(keys);
for (int key : keys) {
try {
- map.get(key).onError("Connection closed", null);
+ AsyncResultCallback<SUCCESS, ERROR_DETAILS> callback = map.get(key);
+ if (callback != null) {
+ callback.onError("Connection closed", null);
+ }
}
catch (Throwable e) {
LOG.error("Failed to reject callback on connection closed", e);
diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java
index 632be05a09b5..d0850c9eef85 100644
--- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java
+++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java
@@ -23,6 +23,7 @@ import com.intellij.execution.testframework.sm.runner.states.*;
import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.ide.util.EditSourceUtil;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
@@ -30,6 +31,7 @@ import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.pom.Navigatable;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testIntegration.TestLocationProvider;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.ContainerUtilRt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -202,9 +204,10 @@ public class SMTestProxy extends AbstractTestProxy {
myState.getMagnitude() == TestStateInfo.Magnitude.PASSED_INDEX;
}
- public void addChild(final SMTestProxy child) {
+ public void addChild(@NotNull SMTestProxy child) {
+ ApplicationManager.getApplication().assertIsDispatchThread();
if (myChildren == null) {
- myChildren = new ArrayList<SMTestProxy>();
+ myChildren = ContainerUtil.newArrayListWithCapacity(4);
}
myChildren.add(child);
@@ -641,8 +644,7 @@ public class SMTestProxy extends AbstractTestProxy {
// test - no matter what we will return
myIsEmpty = true;
myIsEmptyIsCached = true;
-
- return myIsEmpty;
+ return true;
}
myIsEmpty = true;
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfile.java b/platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfile.java
index e40683dce04e..bd3d773f26f5 100644
--- a/platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfile.java
+++ b/platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfile.java
@@ -184,9 +184,13 @@ public abstract class StructuralSearchProfile {
return element.getClass();
}
+ @NotNull
public String getTypedVarString(PsiElement element) {
if (element instanceof PsiNamedElement) {
- return ((PsiNamedElement)element).getName();
+ final String name = ((PsiNamedElement)element).getName();
+ if (name != null) {
+ return name;
+ }
}
return element.getText();
}
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfileBase.java b/platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfileBase.java
index 9e9496115809..47222f932714 100644
--- a/platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfileBase.java
+++ b/platform/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfileBase.java
@@ -176,6 +176,7 @@ public abstract class StructuralSearchProfileBase extends StructuralSearchProfil
return false;
}
+ @NotNull
@Override
public String getTypedVarString(PsiElement element) {
final PsiElement initialElement = element;
@@ -480,10 +481,7 @@ public abstract class StructuralSearchProfileBase extends StructuralSearchProfil
private void visitLiteral(PsiElement literal) {
String value = literal.getText();
- if (value.length() > 2 &&
- (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') ||
- (value.charAt(0) == '\'' && value.charAt(value.length() - 1) == '\'')) {
-
+ if (StringUtil.isQuotedString(value)) {
if (mySubstitutionPatterns == null) {
final String[] prefixes = myGlobalVisitor.getContext().getPattern().getTypedVarPrefixes();
mySubstitutionPatterns = createPatterns(prefixes);
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/CompiledPattern.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/CompiledPattern.java
index 70c1cdccd03e..55aa79bfcf0b 100644
--- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/CompiledPattern.java
+++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/CompiledPattern.java
@@ -12,6 +12,7 @@ import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler;
import com.intellij.structuralsearch.impl.matcher.handlers.SimpleHandler;
import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler;
import com.intellij.structuralsearch.impl.matcher.strategies.MatchingStrategy;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
@@ -82,7 +83,7 @@ public abstract class CompiledPattern {
public boolean isRealTypedVar(PsiElement element) {
if (element!=null && element.getTextLength()>0) {
String str = getTypedVarString(element);
- if (str == null || str.length()==0) {
+ if (str.length() == 0) {
return false;
}
return isTypedVar( str );
@@ -91,6 +92,7 @@ public abstract class CompiledPattern {
}
}
+ @NotNull
public String getTypedVarString(PsiElement element) {
final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(element);
if (profile == null) {
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/CompileContext.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/CompileContext.java
index 09758a5e2191..f28e83b7ad1c 100644
--- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/CompileContext.java
+++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/CompileContext.java
@@ -41,10 +41,6 @@ public class CompileContext {
return searchHelper;
}
- void setSearchHelper(OptimizingSearchHelper searchHelper) {
- this.searchHelper = searchHelper;
- }
-
public CompiledPattern getPattern() {
return pattern;
}
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/FindInFilesOptimizingSearchHelper.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/FindInFilesOptimizingSearchHelper.java
index ff7f06a36d5b..c2fa05fef149 100644
--- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/FindInFilesOptimizingSearchHelper.java
+++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/FindInFilesOptimizingSearchHelper.java
@@ -3,7 +3,6 @@ package com.intellij.structuralsearch.impl.matcher.compiler;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageNamesValidation;
import com.intellij.lang.refactoring.NamesValidator;
-import com.intellij.lexer.Lexer;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.project.Project;
@@ -22,7 +21,6 @@ class FindInFilesOptimizingSearchHelper extends OptimizingSearchHelperBase {
private PsiSearchHelper helper;
private THashMap<PsiFile,PsiFile> filesToScan;
private THashMap<PsiFile,PsiFile> filesToScan2;
- private Lexer javaLexer;
private final boolean findMatchingFiles;
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java
index 6dba855121cb..07808d33c003 100644
--- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java
+++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java
@@ -10,10 +10,7 @@ import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiErrorElement;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
+import com.intellij.psi.*;
import com.intellij.psi.impl.source.PsiFileImpl;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.search.GlobalSearchScope;
@@ -26,6 +23,7 @@ import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil;
import com.intellij.structuralsearch.impl.matcher.PatternTreeContext;
import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter;
import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate;
+import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler;
import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler;
import com.intellij.structuralsearch.impl.matcher.predicates.*;
import com.intellij.structuralsearch.plugin.ui.Configuration;
@@ -73,7 +71,9 @@ public class PatternCompiler {
List<PsiElement> elements = compileByAllPrefixes(project, options, result, context, prefixes);
- context.getPattern().setNodes(elements);
+ final CompiledPattern pattern = context.getPattern();
+ checkForUnknownVariables(pattern, elements);
+ pattern.setNodes(elements);
if (context.getSearchHelper().doOptimizing() && context.getSearchHelper().isScannedSomething()) {
final Set<PsiFile> set = context.getSearchHelper().getFilesSetToScan();
@@ -105,6 +105,28 @@ public class PatternCompiler {
return result;
}
+ private static void checkForUnknownVariables(final CompiledPattern pattern, List<PsiElement> elements) {
+ for (PsiElement element : elements) {
+ element.accept(new PsiRecursiveElementWalkingVisitor() {
+ @Override
+ public void visitElement(PsiElement element) {
+ if (element instanceof PsiComment) {
+ return;
+ }
+ super.visitElement(element);
+
+ if (!(element instanceof LeafElement) || !pattern.isTypedVar(element)) {
+ return;
+ }
+ final MatchingHandler handler = pattern.getHandler(pattern.getTypedVarString(element));
+ if (handler == null) {
+ throw new MalformedPatternException();
+ }
+ }
+ });
+ }
+ }
+
public static String getLastFindPlan() {
return ((TestModeOptimizingSearchHelper)lastTestingContext.getSearchHelper()).getSearchPlan();
}
@@ -322,11 +344,8 @@ public class PatternCompiler {
@Override
public String getPrefix(int varIndex) {
- try {
- return myPrefixes[varIndex];
- } catch (ArrayIndexOutOfBoundsException e) {
- return null;
- }
+ if (varIndex >= myPrefixes.length) return null;
+ return myPrefixes[varIndex];
}
}
@@ -462,10 +481,9 @@ public class PatternCompiler {
PsiElement[] matchStatements;
try {
- final String pattern = buf.toString();
- matchStatements = MatcherImplUtil.createTreeFromText(pattern, PatternTreeContext.Block, options.getFileType(),
+ matchStatements = MatcherImplUtil.createTreeFromText(buf.toString(), PatternTreeContext.Block, options.getFileType(),
options.getDialect(), options.getPatternContext(), project, false);
- if (matchStatements.length==0) throw new MalformedPatternException(pattern);
+ if (matchStatements.length==0) throw new MalformedPatternException();
} catch (IncorrectOperationException e) {
throw new MalformedPatternException(e.getMessage());
}
@@ -487,12 +505,11 @@ public class PatternCompiler {
}
private static void addScriptConstraint(String name, MatchVariableConstraint constraint, SubstitutionHandler handler) {
- MatchPredicate predicate;
if (constraint.getScriptCodeConstraint()!= null && constraint.getScriptCodeConstraint().length() > 2) {
final String script = StringUtil.stripQuotesAroundValue(constraint.getScriptCodeConstraint());
final String s = ScriptSupport.checkValidScript(script);
if (s != null) throw new MalformedPatternException("Script constraint for " + constraint.getName() + " has problem "+s);
- predicate = new ScriptPredicate(name, script);
+ MatchPredicate predicate = new ScriptPredicate(name, script);
addPredicate(handler,predicate);
}
}
diff --git a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
index da479a70f93c..735147b85bfb 100644
--- a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
+++ b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
@@ -2943,4 +2943,35 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
String pattern3 = "'_a::'_b";
assertEquals("should find all method references", 3, findMatchesCount(source, pattern3));
}
+
+ public void testNoUnexpectedException() {
+ String source = "{}";
+
+ String pattern1 = "/*$A$a*/";
+ MalformedPatternException ex = null;
+ try {
+ findMatchesCount(source, pattern1);
+ } catch (MalformedPatternException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ String pattern2 = "class $A$Visitor {}";
+ try {
+ findMatchesCount(source, pattern2);
+ } catch (MalformedPatternException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+
+ String pattern3 = "class $Class$ { \n" +
+ " class $n$$FieldType$ $FieldName$ = $Init$;\n" +
+ "}";
+ try {
+ findMatchesCount(source, pattern3);
+ } catch (MalformedPatternException e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+ }
}
diff --git a/platform/testFramework/src/com/intellij/mock/Mock.java b/platform/testFramework/src/com/intellij/mock/Mock.java
index 575bc0991c3e..73d6538c52b9 100644
--- a/platform/testFramework/src/com/intellij/mock/Mock.java
+++ b/platform/testFramework/src/com/intellij/mock/Mock.java
@@ -321,10 +321,6 @@ public class Mock {
public void closeAllFiles() {
}
- public Editor openTextEditorEnsureNoFocus(@NotNull OpenFileDescriptor descriptor) {
- return null;
- }
-
@Override
@NotNull
public Pair<FileEditor[], FileEditorProvider[]> openFileWithProviders(@NotNull VirtualFile file,
@@ -558,52 +554,55 @@ public class Mock {
return false;
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor) {
- return null;
+ throw new RuntimeException();
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull String id,
@NotNull JComponent component,
@NotNull ToolWindowAnchor anchor,
Disposable parentDisposable,
boolean canWorkInDumbMode, boolean canCloseContents) {
- return null;
+ throw new RuntimeException();
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull String id,
@NotNull JComponent component,
@NotNull ToolWindowAnchor anchor,
Disposable parentDisposable,
boolean canWorkInDumbMode) {
- return null;
+ throw new RuntimeException();
}
+ @NotNull
@Override
- public ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor, Disposable parentDisposable) {
- return null;
+ public ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor, @NotNull Disposable parentDisposable) {
+ throw new RuntimeException();
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id, final boolean canCloseContent, @NotNull final ToolWindowAnchor anchor) {
- return null;
+ throw new RuntimeException();
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id, final boolean canCloseContent, @NotNull final ToolWindowAnchor anchor,
final Disposable parentDisposable, final boolean dumbAware) {
- return null;
+ throw new RuntimeException();
}
+ @NotNull
@Override
public ToolWindow registerToolWindow(@NotNull final String id, final boolean canCloseContent, @NotNull final ToolWindowAnchor anchor, final boolean secondary) {
- return null;
- }
-
- public JComponent getFocusTargetFor(final JComponent comp) {
- return null;
+ throw new RuntimeException();
}
@Override
@@ -614,19 +613,12 @@ public class Mock {
public void activateEditorComponent() {
}
- public ActionCallback requestFocus(final Component c, final boolean forced) {
- return new ActionCallback.Done();
- }
-
- public ActionCallback requestFocus(final ActiveRunnable command, final boolean forced) {
- return new ActionCallback.Done();
- }
-
@Override
public boolean isEditorComponentActive() {
return false;
}
+ @NotNull
@Override
public String[] getToolWindowIds() {
return ArrayUtil.EMPTY_STRING_ARRAY;
@@ -643,9 +635,10 @@ public class Mock {
}
@Override
- public void invokeLater(Runnable runnable) {
+ public void invokeLater(@NotNull Runnable runnable) {
}
+ @NotNull
@Override
public IdeFocusManager getFocusManager() {
return IdeFocusManagerHeadless.INSTANCE;
diff --git a/platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java b/platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java
index 95a7b8b6b9e9..400744bcc9e0 100644
--- a/platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java
+++ b/platform/testFramework/src/com/intellij/projectView/TestProjectTreeStructure.java
@@ -46,7 +46,7 @@ public class TestProjectTreeStructure extends AbstractProjectTreeStructure imple
}
public AbstractProjectViewPSIPane createPane() {
- final AbstractProjectViewPSIPane pane = new TestProjectViewPSIPane(myProject, this);
+ final AbstractProjectViewPSIPane pane = new TestProjectViewPSIPane(myProject, this, 9);
pane.createComponent();
Disposer.register(this, pane);
return pane;
diff --git a/platform/testFramework/src/com/intellij/projectView/TestProjectViewPSIPane.java b/platform/testFramework/src/com/intellij/projectView/TestProjectViewPSIPane.java
index 9add34347b86..9f85f3b977f9 100644
--- a/platform/testFramework/src/com/intellij/projectView/TestProjectViewPSIPane.java
+++ b/platform/testFramework/src/com/intellij/projectView/TestProjectViewPSIPane.java
@@ -1,8 +1,22 @@
+/*
+ * Copyright 2000-2014 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.projectView;
import com.intellij.ide.SelectInTarget;
import com.intellij.ide.projectView.BaseProjectTreeBuilder;
-import com.intellij.ide.projectView.ProjectView;
import com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane;
import com.intellij.ide.projectView.impl.ProjectAbstractTreeStructureBase;
import com.intellij.ide.projectView.impl.ProjectTreeBuilder;
@@ -10,10 +24,7 @@ import com.intellij.ide.projectView.impl.ProjectViewTree;
import com.intellij.ide.util.treeView.AbstractTreeBuilder;
import com.intellij.ide.util.treeView.AbstractTreeUpdater;
import com.intellij.ide.util.treeView.AlphaComparator;
-import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.startup.StartupManager;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -24,11 +35,13 @@ import javax.swing.tree.DefaultTreeModel;
* @author yole
*/
class TestProjectViewPSIPane extends AbstractProjectViewPSIPane {
- private TestProjectTreeStructure myTestTreeStructure;
+ private final TestProjectTreeStructure myTestTreeStructure;
+ private final int myWeight;
- public TestProjectViewPSIPane(Project project, TestProjectTreeStructure treeStructure) {
+ public TestProjectViewPSIPane(Project project, TestProjectTreeStructure treeStructure, int weight) {
super(project);
myTestTreeStructure = treeStructure;
+ myWeight = weight;
}
@Override
@@ -36,11 +49,6 @@ class TestProjectViewPSIPane extends AbstractProjectViewPSIPane {
return null;
}
- @NonNls
- public String getComponentName() {
- return "comp name";
- }
-
@Override
protected AbstractTreeUpdater createTreeUpdater(AbstractTreeBuilder treeBuilder) {
return new AbstractTreeUpdater(treeBuilder);
@@ -55,11 +63,6 @@ class TestProjectViewPSIPane extends AbstractProjectViewPSIPane {
protected AbstractTreeUpdater createUpdater() {
return createTreeUpdater(this);
}
-
- protected void addTaskToWorker(final Runnable runnable, boolean first, final Runnable postRunnable) {
- runnable.run();
- postRunnable.run();
- }
};
}
@@ -96,26 +99,6 @@ class TestProjectViewPSIPane extends AbstractProjectViewPSIPane {
@Override
public int getWeight() {
- return 0;
- }
-
- public void projectOpened() {
- final Runnable runnable = new DumbAwareRunnable() {
- @Override
- public void run() {
- final ProjectView projectView = ProjectView.getInstance(myProject);
- projectView.addProjectPane(TestProjectViewPSIPane.this);
- }
- };
- StartupManager.getInstance(myProject).registerPostStartupActivity(runnable);
- }
-
- public void projectClosed() {
- }
-
- public void initComponent() { }
-
- public void disposeComponent() {
-
+ return myWeight;
}
}
diff --git a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
index 870d6d53b998..a86c1c1440dc 100644
--- a/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
+++ b/platform/testFramework/src/com/intellij/testFramework/EditorTestUtil.java
@@ -23,7 +23,6 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.*;
-import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.editor.actionSystem.TypedAction;
import com.intellij.openapi.editor.ex.EditorEx;
@@ -46,7 +45,6 @@ import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
-import org.junit.Assert;
import java.awt.*;
import java.util.ArrayList;
@@ -73,40 +71,45 @@ public class EditorTestUtil {
public static void performTypingAction(Editor editor, char c) {
EditorActionManager actionManager = EditorActionManager.getInstance();
if (c == BACKSPACE_FAKE_CHAR) {
- EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE);
- actionHandler.execute(editor, DataManager.getInstance().getDataContext());
+ executeAction(editor, IdeActions.ACTION_EDITOR_BACKSPACE);
} else if (c == SMART_ENTER_FAKE_CHAR) {
- EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT);
- actionHandler.execute(editor, DataManager.getInstance().getDataContext());
+ executeAction(editor, IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT);
} else if (c == SMART_LINE_SPLIT_CHAR) {
- EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_SPLIT);
- actionHandler.execute(editor, DataManager.getInstance().getDataContext());
+ executeAction(editor, IdeActions.ACTION_EDITOR_SPLIT);
}
else if (c == '\n') {
- EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
- actionHandler.execute(editor, DataManager.getInstance().getDataContext());
+ executeAction(editor, IdeActions.ACTION_EDITOR_ENTER);
}
else {
TypedAction action = actionManager.getTypedAction();
- action.actionPerformed(editor, c, DataManager.getInstance().getDataContext());
+ action.actionPerformed(editor, c, DataManager.getInstance().getDataContext(editor.getContentComponent()));
}
}
- public static void performReferenceCopy(DataContext dataContext) {
+ public static void executeAction(Editor editor, String actionId) {
+ executeAction(editor, actionId, false);
+ }
+
+ public static void executeAction(Editor editor, String actionId, boolean assertActionIsEnabled) {
ActionManager actionManager = ActionManager.getInstance();
- AnAction action = actionManager.getAction(IdeActions.ACTION_COPY_REFERENCE);
- AnActionEvent
- event = new AnActionEvent(null, dataContext, "", action.getTemplatePresentation(),
- ActionManager.getInstance(), 0);
- action.update(event);
- Assert.assertTrue(event.getPresentation().isEnabled());
+ AnAction action = actionManager.getAction(actionId);
+ assertNotNull(action);
+ DataContext dataContext = DataManager.getInstance().getDataContext(editor.getContentComponent());
+ AnActionEvent event = new AnActionEvent(null, dataContext, "", action.getTemplatePresentation(), actionManager, 0);
+ action.beforeActionPerformedUpdate(event);
+ if (!event.getPresentation().isEnabled()) {
+ assertFalse("Action " + actionId + " is disabled", assertActionIsEnabled);
+ return;
+ }
action.actionPerformed(event);
}
+ public static void performReferenceCopy(Editor editor) {
+ executeAction(editor, IdeActions.ACTION_COPY_REFERENCE, true);
+ }
+
public static void performPaste(Editor editor) {
- EditorActionManager actionManager = EditorActionManager.getInstance();
- EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_PASTE);
- actionHandler.execute(editor, null, DataManager.getInstance().getDataContext());
+ executeAction(editor, IdeActions.ACTION_EDITOR_PASTE, true);
}
public static List<IElementType> getAllTokens(EditorHighlighter highlighter) {
diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
index 3c1f96113532..9dedcc6d47a8 100644
--- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java
@@ -19,10 +19,7 @@ import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction;
import com.intellij.ide.DataManager;
import com.intellij.injected.editor.DocumentWindow;
import com.intellij.injected.editor.EditorWindow;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.IdeActions;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.ex.PathManagerEx;
@@ -145,7 +142,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
* @throws java.io.IOException
*/
@NotNull
- protected static Document configureFromFileText(@NonNls @NotNull final String fileName, @NonNls @NotNull final String fileText) throws IOException {
+ protected static Document configureFromFileText(@NonNls @NotNull final String fileName, @NonNls @NotNull final String fileText) {
return new WriteCommandAction<Document>(null) {
@Override
protected void run(@NotNull Result<Document> result) throws Throwable {
@@ -353,24 +350,6 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
return userMessage + " [" + engineMessage + "]";
}
- @Override
- public Object getData(String dataId) {
- if (CommonDataKeys.EDITOR.is(dataId)) {
- return myEditor;
- }
- if (dataId.equals(AnActionEvent.injectedId(CommonDataKeys.EDITOR.getName()))) {
- return InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
- }
- if (CommonDataKeys.PSI_FILE.is(dataId)) {
- return myFile;
- }
- if (dataId.equals(AnActionEvent.injectedId(CommonDataKeys.PSI_FILE.getName()))) {
- Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
- return editor instanceof EditorWindow ? ((EditorWindow)editor).getInjectedFile() : getFile();
- }
- return super.getData(dataId);
- }
-
/**
* @return Editor used in test.
*/
@@ -508,9 +487,7 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
@Override
public void run() {
- EditorActionManager actionManager = EditorActionManager.getInstance();
- EditorActionHandler actionHandler = actionManager.getActionHandler(actionId);
- actionHandler.execute(getEditor(), null, DataManager.getInstance().getDataContext());
+ EditorTestUtil.executeAction(getEditor(), actionId);
}
}, "", null);
}
diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
index 33051b471049..268eb6d0831e 100644
--- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
@@ -722,10 +722,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
@Override
public Object getData(String dataId) {
- if (CommonDataKeys.PROJECT.is(dataId)) {
- return ourProject;
- }
- return null;
+ return ourProject == null || ourProject.isDisposed() ? null : new TestDataProvider(ourProject).getData(dataId);
}
protected Sdk getProjectJDK() {
diff --git a/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java b/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java
index f000733e8881..46b3adca7557 100644
--- a/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -89,7 +89,7 @@ public abstract class ParsingTestCase extends PlatformLiteFixture {
getApplication().getPicoContainer().registerComponent(new AbstractComponentAdapter(ProgressManager.class.getName(), Object.class) {
@Override
public Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException {
- return new ProgressManagerImpl(getApplication());
+ return new ProgressManagerImpl();
}
@Override
diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java
index 347661846e2a..d9b32080f458 100644
--- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java
@@ -198,6 +198,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
}
DocumentCommitThread.getInstance().clearQueue();
+ UIUtil.dispatchAllInvocationEvents();
}
public Project getProject() {
diff --git a/platform/testFramework/src/com/intellij/testFramework/ProjectViewTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/ProjectViewTestUtil.java
index 66b59d06d200..548c312614d4 100644
--- a/platform/testFramework/src/com/intellij/testFramework/ProjectViewTestUtil.java
+++ b/platform/testFramework/src/com/intellij/testFramework/ProjectViewTestUtil.java
@@ -15,17 +15,27 @@
*/
package com.intellij.testFramework;
+import com.intellij.ide.projectView.ProjectView;
import com.intellij.ide.projectView.ProjectViewNode;
import com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane;
+import com.intellij.ide.projectView.impl.ProjectViewImpl;
import com.intellij.ide.projectView.impl.nodes.BasePsiNode;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.ide.util.treeView.AbstractTreeStructure;
+import com.intellij.openapi.extensions.Extensions;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Queryable;
import com.intellij.openapi.util.MultiValuesMap;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.wm.ToolWindow;
+import com.intellij.openapi.wm.ToolWindowAnchor;
+import com.intellij.openapi.wm.ToolWindowEP;
+import com.intellij.openapi.wm.ToolWindowId;
+import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.Function;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
@@ -151,4 +161,22 @@ public class ProjectViewTestUtil {
DefaultMutableTreeNode nodeForElement = getNodeForElement(element, pane);
return nodeForElement != null && isExpanded((DefaultMutableTreeNode)nodeForElement.getParent(), pane);
}
+
+ public static void setupImpl(@NotNull Project project, boolean loadPaneExtensions) {
+ ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
+ ToolWindow toolWindow = toolWindowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
+
+ if (toolWindow == null) {
+ ToolWindowEP[] beans = Extensions.getExtensions(ToolWindowEP.EP_NAME);
+ for (final ToolWindowEP bean : beans) {
+ if (bean.id.equals(ToolWindowId.PROJECT_VIEW)) {
+ toolWindow = toolWindowManager.registerToolWindow(bean.id, new JLabel(), ToolWindowAnchor.fromText(bean.anchor), project,
+ false, bean.canCloseContents);
+ break;
+ }
+ }
+ }
+
+ ((ProjectViewImpl)ProjectView.getInstance(project)).setupImpl(toolWindow, loadPaneExtensions);
+ }
}
diff --git a/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java b/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java
index cc8376832e36..1ed87bbcb0fa 100644
--- a/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java
+++ b/platform/testFramework/src/com/intellij/testFramework/TestDataProvider.java
@@ -20,7 +20,6 @@ import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.impl.EditorComponentImpl;
-import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
@@ -50,18 +49,21 @@ public class TestDataProvider implements DataProvider {
if (CommonDataKeys.PROJECT.is(dataId)) {
return myProject;
}
- else if (CommonDataKeys.EDITOR.is(dataId) || OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
- return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
+ FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
+ if (manager == null) {
+ return null;
+ }
+ if (CommonDataKeys.EDITOR.is(dataId) || OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
+ return manager.getSelectedTextEditor();
}
else if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
- Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
+ Editor editor = manager.getSelectedTextEditor();
return editor == null ? null : TextEditorProvider.getInstance().getTextEditor(editor);
}
else {
Editor editor = (Editor)getData(CommonDataKeys.EDITOR.getName());
if (editor != null) {
- FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
- Object managerData = manager.getData(dataId, editor, manager.getSelectedFiles()[0]);
+ Object managerData = manager.getData(dataId, editor, editor.getCaretModel().getCurrentCaret());
if (managerData != null) {
return managerData;
}
diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java
index a309f9acda8f..581ca54b6baa 100644
--- a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java
+++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java
@@ -350,7 +350,8 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
* hint text. Throws an assertion if no such intentions are found or if multiple intentions match the hint text.
*
* @param hint the text that the intention text should begin with.
- * @return the list of matching intentions
+ * @return the matching intention
+ * @throws java.lang.AssertionError if no intentions are found or if multiple intentions match the hint text.
*/
IntentionAction findSingleIntention(@NotNull String hint);
diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java
index 27a45cbfe99e..72bbff443dfa 100644
--- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java
+++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java
@@ -205,7 +205,7 @@ class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTestFixtu
Editor editor = (Editor)getData(CommonDataKeys.EDITOR.getName());
if (editor != null) {
FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
- return manager.getData(dataId, editor, manager.getSelectedFiles()[0]);
+ return manager.getData(dataId, editor, editor.getCaretModel().getCurrentCaret());
}
else if (LangDataKeys.IDE_VIEW.is(dataId)) {
VirtualFile[] contentRoots = ProjectRootManager.getInstance(myProject).getContentRoots();
@@ -217,6 +217,7 @@ class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTestFixtu
}
+ @NotNull
@Override
public PsiDirectory[] getDirectories() {
return new PsiDirectory[] {psiDirectory};
diff --git a/platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java b/platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java
index 9be02ae51271..30f8599e2aaf 100644
--- a/platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java
+++ b/platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java
@@ -69,7 +69,7 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
protected ExecutionEnvironment myEnvironment;
private final JComponent myParent;
-
+ @SuppressWarnings("UnusedDeclaration")
public AbstractRerunFailedTestsAction() {
//We call this constructor with a little help from reflection.
myParent = null;
@@ -83,6 +83,7 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
registerCustomShortcutSet(getShortcutSet(), myParent);
}
+ @Override
public void dispose() {
registry.remove(this);
}
@@ -127,6 +128,7 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
return candidates.get(0);
}
+ @Override
public final void update(AnActionEvent e) {
AbstractRerunFailedTestsAction action = findActualAction();
e.getPresentation().setEnabled(action.isActive(e));
@@ -167,6 +169,7 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
return Filter.FAILED_OR_INTERRUPTED;
}
+ @Override
public void actionPerformed(AnActionEvent e) {
findActualAction().showPopup(e);
}
@@ -225,6 +228,7 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
.setResizable(false)
.setRequestFocus(true)
.setItemChoosenCallback(new Runnable() {
+ @Override
public void run() {
final Object value = list.getSelectedValue();
if (value instanceof Executor) {
@@ -237,12 +241,11 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
private void performAction(ProgramRunner runner, MyRunProfile profile, Executor executor) {
try {
- final ExecutionEnvironment environment =
- new ExecutionEnvironmentBuilder(myEnvironment).setRunnerId(runner.getRunnerId())
- .setExecutor(executor)
- .setRunProfile(profile)
- .build();
- runner.execute(environment);
+ new ExecutionEnvironmentBuilder(myEnvironment)
+ .runner(runner)
+ .executor(executor)
+ .runProfile(profile)
+ .buildAndExecute();
}
catch (ExecutionException e1) {
LOG.error(e1);
@@ -291,58 +294,71 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction
}
+ @Override
public void checkConfiguration() throws RuntimeConfigurationException {
}
///////////////////////////////////Delegates
+ @Override
public void readExternal(final Element element) throws InvalidDataException {
myConfiguration.readExternal(element);
}
+ @Override
public void writeExternal(final Element element) throws WriteExternalException {
myConfiguration.writeExternal(element);
}
+ @Override
@NotNull
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
return myConfiguration.getConfigurationEditor();
}
+ @Override
@NotNull
public ConfigurationType getType() {
return myConfiguration.getType();
}
+ @Override
public ConfigurationPerRunnerSettings createRunnerSettings(final ConfigurationInfoProvider provider) {
return myConfiguration.createRunnerSettings(provider);
}
+ @Override
public SettingsEditor<ConfigurationPerRunnerSettings> getRunnerSettingsEditor(final ProgramRunner runner) {
return myConfiguration.getRunnerSettingsEditor(runner);
}
+ @Override
public RunConfiguration clone() {
return myConfiguration.clone();
}
+ @Override
public int getUniqueID() {
return myConfiguration.getUniqueID();
}
+ @Override
public LogFileOptions getOptionsForPredefinedLogFile(PredefinedLogFile predefinedLogFile) {
return myConfiguration.getOptionsForPredefinedLogFile(predefinedLogFile);
}
+ @Override
public ArrayList<PredefinedLogFile> getPredefinedLogFiles() {
return myConfiguration.getPredefinedLogFiles();
}
+ @Override
public ArrayList<LogFileOptions> getAllLogFiles() {
return myConfiguration.getAllLogFiles();
}
+ @Override
public ArrayList<LogFileOptions> getLogFiles() {
return myConfiguration.getLogFiles();
}
}
-} \ No newline at end of file
+}
diff --git a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java
index fb433b23ec56..3f15ee3f6de3 100644
--- a/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java
+++ b/platform/testRunner/src/com/intellij/execution/testframework/autotest/AutoTestManager.java
@@ -2,9 +2,12 @@ package com.intellij.execution.testframework.autotest;
import com.intellij.execution.DelayedDocumentWatcher;
import com.intellij.execution.process.ProcessHandler;
+import com.intellij.execution.runners.ExecutionUtil;
import com.intellij.execution.ui.RunContentDescriptor;
-import com.intellij.execution.ui.RunContentManagerImpl;
+import com.intellij.ide.DataManager;
import com.intellij.ide.util.PropertiesComponent;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
@@ -15,6 +18,7 @@ import com.intellij.ui.content.Content;
import com.intellij.util.Consumer;
import com.intellij.util.containers.WeakHashMap;
+import javax.swing.*;
import java.util.Collections;
import java.util.Set;
@@ -79,21 +83,21 @@ public class AutoTestManager {
}
private static void runAutoTest(Content content) {
- RunContentDescriptor descriptor = RunContentManagerImpl.getRunContentDescriptorByContent(content);
- if (descriptor == null) {
- return;
- }
- Runnable restarter = descriptor.getRestarter();
- if (restarter == null) {
- return;
- }
- final ProcessHandler processHandler = descriptor.getProcessHandler();
- if (processHandler != null && !processHandler.isProcessTerminated()) {
- return;
+ JComponent component = content.getComponent();
+ if (component != null) {
+ DataContext dataContext = DataManager.getInstance().getDataContext(component);
+ RunContentDescriptor descriptor = LangDataKeys.RUN_CONTENT_DESCRIPTOR.getData(dataContext);
+ if (descriptor != null) {
+ ProcessHandler processHandler = descriptor.getProcessHandler();
+ if (processHandler != null && !processHandler.isProcessTerminated()) {
+ return;
+ }
+
+ descriptor.setActivateToolWindowWhenAdded(false);
+ descriptor.setReuseToolWindowActivation(true);
+ ExecutionUtil.restart(content);
+ }
}
- descriptor.setActivateToolWindowWhenAdded(false);
- descriptor.setReuseToolWindowActivation(true);
- restarter.run();
}
int getDelay() {
diff --git a/platform/testRunner/src/com/intellij/execution/testframework/autotest/ToggleAutoTestAction.java b/platform/testRunner/src/com/intellij/execution/testframework/autotest/ToggleAutoTestAction.java
index 893ddb320aab..256ff0277c83 100644
--- a/platform/testRunner/src/com/intellij/execution/testframework/autotest/ToggleAutoTestAction.java
+++ b/platform/testRunner/src/com/intellij/execution/testframework/autotest/ToggleAutoTestAction.java
@@ -2,10 +2,10 @@ package com.intellij.execution.testframework.autotest;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.RunContentDescriptor;
-import com.intellij.execution.ui.RunContentManager;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.Project;
@@ -21,15 +21,15 @@ public class ToggleAutoTestAction extends ToggleAction {
@Override
public boolean isSelected(AnActionEvent e) {
- Project project = e.getData(CommonDataKeys.PROJECT);
- RunContentDescriptor descriptor = e.getData(RunContentManager.RUN_CONTENT_DESCRIPTOR);
+ Project project = e.getProject();
+ RunContentDescriptor descriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
return !(project == null || descriptor == null) && AutoTestManager.getInstance(project).isAutoTestEnabled(descriptor);
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
Project project = e.getData(CommonDataKeys.PROJECT);
- RunContentDescriptor descriptor = e.getData(RunContentManager.RUN_CONTENT_DESCRIPTOR);
+ RunContentDescriptor descriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
if (project != null && descriptor != null) {
AutoTestManager.getInstance(project).setAutoTestEnabled(descriptor, state);
}
diff --git a/platform/usageView/src/com/intellij/usages/UsageViewPresentation.java b/platform/usageView/src/com/intellij/usages/UsageViewPresentation.java
index c715c6a169c6..c597eea48db0 100644
--- a/platform/usageView/src/com/intellij/usages/UsageViewPresentation.java
+++ b/platform/usageView/src/com/intellij/usages/UsageViewPresentation.java
@@ -38,6 +38,7 @@ public class UsageViewPresentation {
private boolean myShowCancelButton = false;
private boolean myOpenInNewTab = true;
private boolean myCodeUsages = true;
+ private boolean myUsageTypeFilteringAvailable;
private String myUsagesWord = UsageViewBundle.message("usage.name");
private String myTabName;
@@ -198,5 +199,13 @@ public class UsageViewPresentation {
public void setMergeDupLinesAvailable(boolean mergeDupLinesAvailable) {
myMergeDupLinesAvailable = mergeDupLinesAvailable;
}
+
+ public boolean isUsageTypeFilteringAvailable() {
+ return myCodeUsages || myUsageTypeFilteringAvailable;
+ }
+
+ public void setUsageTypeFilteringAvailable(boolean usageTypeFilteringAvailable) {
+ myUsageTypeFilteringAvailable = usageTypeFilteringAvailable;
+ }
}
diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
index 175257143ffb..11713b812523 100644
--- a/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
+++ b/platform/usageView/src/com/intellij/usages/impl/UsageGroupingRuleProviderImpl.java
@@ -104,7 +104,7 @@ public class UsageGroupingRuleProviderImpl implements UsageGroupingRuleProvider
ArrayList<AnAction> result = ContainerUtil.newArrayList();
- if (view.getPresentation().isCodeUsages()) {
+ if (view.getPresentation().isUsageTypeFilteringAvailable()) {
GroupByUsageTypeAction groupByUsageTypeAction = new GroupByUsageTypeAction(impl);
groupByUsageTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)), component, impl);
diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties
index bbda04a2461a..e9802f2321ae 100644
--- a/platform/util/resources/misc/registry.properties
+++ b/platform/util/resources/misc/registry.properties
@@ -43,6 +43,8 @@ actionSystem.enableAbbreviations=true
ide.firstStartup=true
ide.debugMode=false
+ide.debugger.inline=false
+ide.debugger.inline.description=Enables variables view in editor
ide.debugMode.description=Record additional information to make bug reports more informative.
ide.debug.minProgressTime=0
ide.forcedShowTooltip=alt
@@ -313,6 +315,7 @@ testng_sm_runner=false
show.flex.debug.design.view=false
git.new.log=true
diff.patience.alg=false
+diff.status.tracker.skip.spaces=true
svn.use.terminal=false
svn.use.incoming.optimization=false
@@ -391,6 +394,7 @@ console.too.much.text.buffer.ratio.description=Used for disabling of console pro
when there is too much of text to process.\n\
The ratio is used against the console cycle buffer size (idea.cycle.buffer.size/theRatio=maxTextLength).
ide.file.settings.order.new=false
+ide.file.settings.tree.new=false
ide.new.project.settings=true
ide.new.project.settings.description=Temporary key for new project settings dialog UI
diff --git a/platform/util/src/com/intellij/icons/AllIcons.java b/platform/util/src/com/intellij/icons/AllIcons.java
index be3f4f212072..318895db57f1 100644
--- a/platform/util/src/com/intellij/icons/AllIcons.java
+++ b/platform/util/src/com/intellij/icons/AllIcons.java
@@ -76,6 +76,7 @@ public class AllIcons {
public static final Icon Get = IconLoader.getIcon("/actions/get.png"); // 16x16
public static final Icon GroupByFile = IconLoader.getIcon("/actions/GroupByFile.png"); // 16x16
public static final Icon GroupByMethod = IconLoader.getIcon("/actions/groupByMethod.png"); // 16x16
+ public static final Icon GroupByClass = IconLoader.getIcon("/actions/GroupByClass.png"); // 16x16
public static final Icon GroupByModule = IconLoader.getIcon("/actions/GroupByModule.png"); // 16x16
public static final Icon GroupByModuleGroup = IconLoader.getIcon("/actions/GroupByModuleGroup.png"); // 16x16
public static final Icon GroupByPackage = IconLoader.getIcon("/actions/GroupByPackage.png"); // 16x16
diff --git a/platform/util/src/com/intellij/openapi/diagnostic/Log.java b/platform/util/src/com/intellij/openapi/diagnostic/Log.java
index dfc00ae9b4c6..842a8356f591 100644
--- a/platform/util/src/com/intellij/openapi/diagnostic/Log.java
+++ b/platform/util/src/com/intellij/openapi/diagnostic/Log.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,13 +15,11 @@
*/
package com.intellij.openapi.diagnostic;
-
import java.util.ArrayList;
import java.util.List;
-/**
- * This is a very primitive fast logging class, primary for race-conditions debugging.
- */
+/** @deprecated use {@link com.intellij.openapi.diagnostic.Logger} (to be removed in IDEA 15) */
+@SuppressWarnings("unused")
public class Log {
private static final List<String> myStrings = new ArrayList<String>();
private static final List<Throwable> myThrowables = new ArrayList<Throwable>();
diff --git a/platform/util/src/com/intellij/openapi/progress/ProcessCanceledException.java b/platform/util/src/com/intellij/openapi/progress/ProcessCanceledException.java
index e3029934b2e5..e6133b255411 100644
--- a/platform/util/src/com/intellij/openapi/progress/ProcessCanceledException.java
+++ b/platform/util/src/com/intellij/openapi/progress/ProcessCanceledException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,10 +18,9 @@ package com.intellij.openapi.progress;
import com.intellij.util.SystemProperties;
public class ProcessCanceledException extends RuntimeException {
- private static boolean ourHasStackTraces = SystemProperties.getBooleanProperty("idea.is.internal", false);
+ private static final boolean ourHasStackTraces = SystemProperties.getBooleanProperty("idea.is.internal", false);
public ProcessCanceledException() {
- int i = 0;
}
public ProcessCanceledException(Throwable cause) {
diff --git a/platform/util/src/com/intellij/openapi/util/TextRange.java b/platform/util/src/com/intellij/openapi/util/TextRange.java
index 797bc23ee747..4c09b969a570 100644
--- a/platform/util/src/com/intellij/openapi/util/TextRange.java
+++ b/platform/util/src/com/intellij/openapi/util/TextRange.java
@@ -99,6 +99,16 @@ public class TextRange implements Segment, Serializable {
}
@NotNull
+ public CharSequence subSequence(@NotNull CharSequence str) {
+ try {
+ return str.subSequence(myStartOffset, myEndOffset);
+ }
+ catch (IndexOutOfBoundsException e) {
+ throw new IndexOutOfBoundsException("Can't extract " + this + " range from " + str);
+ }
+ }
+
+ @NotNull
public TextRange cutOut(@NotNull TextRange subRange) {
assert subRange.getStartOffset() <= getLength() : subRange + "; this="+this;
assert subRange.getEndOffset() <= getLength() : subRange + "; this="+this;
diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
index cfcbe7967d35..adec13d20412 100644
--- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java
@@ -1264,10 +1264,10 @@ public class FileUtil extends FileUtilRt {
if (path == null) return null;
if (SystemInfo.isUnix || !unixOnly) {
- final File projectDir = new File(path);
- final File userHomeDir = new File(SystemProperties.getUserHome());
+ File projectDir = new File(path);
+ File userHomeDir = new File(SystemProperties.getUserHome());
if (isAncestor(userHomeDir, projectDir, true)) {
- return "~/" + getRelativePath(userHomeDir, projectDir);
+ return '~' + File.separator + getRelativePath(userHomeDir, projectDir);
}
}
diff --git a/platform/util/src/com/intellij/openapi/util/registry/Registry.java b/platform/util/src/com/intellij/openapi/util/registry/Registry.java
index e418e553fb6b..d41ea08161b3 100644
--- a/platform/util/src/com/intellij/openapi/util/registry/Registry.java
+++ b/platform/util/src/com/intellij/openapi/util/registry/Registry.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,6 +18,7 @@ package com.intellij.openapi.util.registry;
import com.intellij.util.containers.HashMap;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;
import java.awt.*;
@@ -33,30 +34,29 @@ public class Registry {
@NonNls
private static final String REGISTRY_BUNDLE = "misc.registry";
- private final LinkedHashMap<String, String> myUserProperties = new LinkedHashMap<String, String>();
+ private final Map<String, String> myUserProperties = new LinkedHashMap<String, String>();
private final Map<String, String> myLoadedUserProperties = new HashMap<String, String>();
private final Map<String, RegistryValue> myValues = new ConcurrentHashMap<String, RegistryValue>();
private static final Registry ourInstance = new Registry();
- public static RegistryValue get(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ @NotNull
+ public static RegistryValue get(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) {
final Registry registry = getInstance();
- if (registry.myValues.containsKey(key)) {
- return registry.myValues.get(key);
- }
- else {
- final RegistryValue value = new RegistryValue(registry, key);
+ RegistryValue value = registry.myValues.get(key);
+ if (value == null) {
+ value = new RegistryValue(registry, key);
registry.myValues.put(key, value);
- return value;
}
+ return value;
}
- public static boolean is(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ public static boolean is(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) throws MissingResourceException {
return get(key).asBoolean();
}
- public static boolean is(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key, boolean defaultValue) {
+ public static boolean is(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key, boolean defaultValue) {
try {
return get(key).asBoolean();
}
@@ -65,11 +65,11 @@ public class Registry {
}
}
- public static int intValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ public static int intValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) throws MissingResourceException {
return get(key).asInteger();
}
- public static int intValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key, int defaultValue) {
+ public static int intValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key, int defaultValue) {
try {
return get(key).asInteger();
}
@@ -78,18 +78,20 @@ public class Registry {
}
}
- public static double doubleValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ public static double doubleValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) throws MissingResourceException {
return get(key).asDouble();
}
- public static String stringValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key) {
+ @NotNull
+ public static String stringValue(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key) throws MissingResourceException {
return get(key).asString();
}
- public static Color getColor(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) String key, Color defaultValue) {
+ public static Color getColor(@PropertyKey(resourceBundle = REGISTRY_BUNDLE) @NotNull String key, Color defaultValue) throws MissingResourceException {
return get(key).asColor(defaultValue);
}
+ @NotNull
static ResourceBundle getBundle() {
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
@@ -104,6 +106,7 @@ public class Registry {
return ourInstance;
}
+ @NotNull
public Element getState() {
final Element state = new Element("registry");
for (String eachKey : myUserProperties.keySet()) {
@@ -115,7 +118,7 @@ public class Registry {
return state;
}
- public void loadState(Element state) {
+ public void loadState(@NotNull Element state) {
final List entries = state.getChildren("entry");
for (Object each : entries) {
final Element eachEntry = (Element) each;
@@ -132,15 +135,17 @@ public class Registry {
}
}
+ @NotNull
Map<String, String> getUserProperties() {
return myUserProperties;
}
+ @NotNull
public static List<RegistryValue> getAll() {
final ResourceBundle bundle = getBundle();
final Enumeration<String> keys = bundle.getKeys();
- final ArrayList<RegistryValue> result = new ArrayList<RegistryValue>();
+ List<RegistryValue> result = new ArrayList<RegistryValue>();
while (keys.hasMoreElements()) {
final String each = keys.nextElement();
@@ -152,7 +157,7 @@ public class Registry {
}
public void restoreDefaults() {
- final HashMap<String, String> old = new HashMap<String, String>();
+ Map<String, String> old = new HashMap<String, String>();
old.putAll(myUserProperties);
for (String each : old.keySet()) {
get(each).resetToDefault();
@@ -167,7 +172,7 @@ public class Registry {
return isRestartNeeded(myUserProperties) || isRestartNeeded(myLoadedUserProperties);
}
- private static boolean isRestartNeeded(Map<String, String> map) {
+ private static boolean isRestartNeeded(@NotNull Map<String, String> map) {
for (String s : map.keySet()) {
final RegistryValue eachValue = get(s);
if (eachValue.isRestartRequired() && eachValue.isChangedSinceAppStart()) return true;
diff --git a/platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java b/platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java
index 6c89311457f4..ae3873b8744f 100644
--- a/platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java
+++ b/platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -42,16 +42,18 @@ public class RegistryValue {
private Double myDoubleCachedValue;
private Boolean myBooleanCachedValue;
- RegistryValue(Registry registry, String key) {
+ RegistryValue(@NotNull Registry registry, @NotNull String key) {
myRegistry = registry;
myKey = key;
}
+ @NotNull
public String getKey() {
return myKey;
}
+ @NotNull
public String asString() {
final String value = get(myKey, null, true);
assert value != null : myKey;
@@ -97,6 +99,7 @@ public class RegistryValue {
return defaultValue;
}
+ @NotNull
public String getDescription() {
return get(myKey + ".description", "", false);
}
@@ -109,42 +112,36 @@ public class RegistryValue {
return !asString().equals(getBundleValue(myKey, false));
}
- private String get(String key, String defaultValue, boolean isValue) {
+ private String get(@NotNull String key, String defaultValue, boolean isValue) throws MissingResourceException {
if (isValue) {
if (myStringCachedValue == null) {
myStringCachedValue = _get(key, defaultValue, isValue);
- }
- if (isBoolean()) {
- myStringCachedValue = Boolean.valueOf(myStringCachedValue).toString();
+ if (isBoolean()) {
+ myStringCachedValue = Boolean.valueOf(myStringCachedValue).toString();
+ }
}
return myStringCachedValue;
}
- else {
- return _get(key, defaultValue, isValue);
- }
+ return _get(key, defaultValue, isValue);
}
- private String _get(String key, String defaultValue, boolean mustExistInBundle) {
+ private String _get(@NotNull String key, String defaultValue, boolean mustExistInBundle) throws MissingResourceException {
final String userValue = myRegistry.getUserProperties().get(key);
- if (userValue == null) {
- String systemProperty = System.getProperty(key);
- if (systemProperty != null) {
- return systemProperty;
- }
- final String bundleValue = getBundleValue(key, mustExistInBundle);
- if (bundleValue != null) {
- return bundleValue;
- }
- else {
- return defaultValue;
- }
- }
- else {
+ if (userValue != null) {
return userValue;
}
+ String systemProperty = System.getProperty(key);
+ if (systemProperty != null) {
+ return systemProperty;
+ }
+ final String bundleValue = getBundleValue(key, mustExistInBundle);
+ if (bundleValue != null) {
+ return bundleValue;
+ }
+ return defaultValue;
}
- private String getBundleValue(String key, boolean mustExist) {
+ private static String getBundleValue(@NotNull String key, boolean mustExist) throws MissingResourceException {
try {
return Registry.getBundle().getString(key);
}
diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java
index bc37f673bb03..e364a8568fda 100644
--- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java
@@ -1331,6 +1331,7 @@ public class StringUtil extends StringUtilRt {
}
public static boolean isQuotedString(@NotNull String text) {
+ if (text.length() < 2) return false;
return startsWithChar(text, '\"') && endsWithChar(text, '\"')
|| startsWithChar(text, '\'') && endsWithChar(text, '\'');
}
@@ -2678,7 +2679,7 @@ public class StringUtil extends StringUtilRt {
continue;
}
- if (i > 0 && (ch == '/' || ch == '\\' || ch == '.' || Character.isUpperCase(ch))) {
+ if (i > 0 && (ch == '/' || ch == '\\' || ch == '.' || ch == '-' || Character.isUpperCase(ch))) {
words.add(builder.toString());
builder.delete(0, builder.length());
}
diff --git a/platform/util/src/com/intellij/util/ReflectionUtil.java b/platform/util/src/com/intellij/util/ReflectionUtil.java
index df33a80d4cba..d5f6a58dc951 100644
--- a/platform/util/src/com/intellij/util/ReflectionUtil.java
+++ b/platform/util/src/com/intellij/util/ReflectionUtil.java
@@ -95,6 +95,7 @@ public class ReflectionUtil {
+ " loaded by " + ((Class)anInterface).getClassLoader();
}
+ @NotNull
public static Class<?> getRawType(@NotNull Type type) {
if (type instanceof Class) {
return (Class)type;
@@ -288,15 +289,18 @@ public class ReflectionUtil {
});
}
+ @NotNull
public static List<Method> getClassPublicMethods(@NotNull Class aClass) {
return getClassPublicMethods(aClass, false);
}
-
+
+ @NotNull
public static List<Method> getClassPublicMethods(@NotNull Class aClass, boolean includeSynthetic) {
Method[] methods = aClass.getMethods();
return includeSynthetic ? Arrays.asList(methods) : filterRealMethods(methods);
}
+ @NotNull
public static List<Method> getClassDeclaredMethods(@NotNull Class aClass) {
return getClassDeclaredMethods(aClass, false);
}
@@ -306,13 +310,15 @@ public class ReflectionUtil {
Method[] methods = aClass.getDeclaredMethods();
return includeSynthetic ? Arrays.asList(methods) : filterRealMethods(methods);
}
+
@NotNull
public static List<Field> getClassDeclaredFields(@NotNull Class aClass) {
Field[] fields = aClass.getDeclaredFields();
return Arrays.asList(fields);
}
- private static List<Method> filterRealMethods(Method[] methods) {
+ @NotNull
+ private static List<Method> filterRealMethods(@NotNull Method[] methods) {
List<Method> result = ContainerUtil.newArrayList();
for (Method method : methods) {
if (!method.isSynthetic()) {
@@ -323,8 +329,8 @@ public class ReflectionUtil {
}
@Nullable
- public static Class getMethodDeclaringClass(@NotNull Class<?> instanceClass, @NonNls @NotNull String name, @NotNull Class... parameters) {
- Method method = getMethod(instanceClass, name, parameters);
+ public static Class getMethodDeclaringClass(@NotNull Class<?> instanceClass, @NonNls @NotNull String methodName, @NotNull Class... parameters) {
+ Method method = getMethod(instanceClass, methodName, parameters);
return method == null ? null : method.getDeclaringClass();
}
diff --git a/platform/util/src/com/intellij/util/containers/ClassMap.java b/platform/util/src/com/intellij/util/containers/ClassMap.java
index 078dfd693e63..d2d3bbb3e6dc 100644
--- a/platform/util/src/com/intellij/util/containers/ClassMap.java
+++ b/platform/util/src/com/intellij/util/containers/ClassMap.java
@@ -16,6 +16,7 @@
package com.intellij.util.containers;
import gnu.trove.THashMap;
+import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Map;
@@ -29,18 +30,18 @@ public class ClassMap<T> {
public ClassMap() {
this(new THashMap<Class, T>());
}
- protected ClassMap(Map<Class, T> map) {
+ protected ClassMap(@NotNull Map<Class, T> map) {
myMap = map;
}
- public void put(Class aClass, T value) {
+ public void put(@NotNull Class aClass, T value) {
myMap.put(aClass, value);
}
- public void remove(Class aClass) {
+ public void remove(@NotNull Class aClass) {
myMap.remove(aClass);
}
- public T get(Class aClass) {
+ public T get(@NotNull Class aClass) {
T t = myMap.get(aClass);
if (t != null) {
return t;
@@ -63,6 +64,7 @@ public class ClassMap<T> {
return null;
}
+ @NotNull
public final Collection<T> values() {
return myMap.values();
}
diff --git a/platform/util/src/com/intellij/util/containers/ContainerUtil.java b/platform/util/src/com/intellij/util/containers/ContainerUtil.java
index 171cfababfa9..dca7a0e6b30d 100644
--- a/platform/util/src/com/intellij/util/containers/ContainerUtil.java
+++ b/platform/util/src/com/intellij/util/containers/ContainerUtil.java
@@ -1113,6 +1113,10 @@ public class ContainerUtil extends ContainerUtilRt {
*/
@NotNull
public static <T> List<T> concat(@NotNull final List<? extends T> list1, @NotNull final List<? extends T> list2) {
+ if (list1.isEmpty() && list2.isEmpty()) {
+ return Collections.emptyList();
+ }
+
final int size1 = list1.size();
final int size = size1 + list2.size();
diff --git a/platform/util/src/com/intellij/util/containers/TransferToEDTQueue.java b/platform/util/src/com/intellij/util/containers/TransferToEDTQueue.java
index 787ebc320490..5db4de22b401 100644
--- a/platform/util/src/com/intellij/util/containers/TransferToEDTQueue.java
+++ b/platform/util/src/com/intellij/util/containers/TransferToEDTQueue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -147,6 +147,12 @@ public class TransferToEDTQueue<T> {
}
}
+ public int size() {
+ synchronized (myQueue) {
+ return myQueue.size();
+ }
+ }
+
// process all queue in current thread
public void drain() {
int processed = 0;
diff --git a/platform/util/src/com/intellij/util/containers/WeakStringInterner.java b/platform/util/src/com/intellij/util/containers/WeakStringInterner.java
index ec223a8c6880..eb1c7b329f76 100644
--- a/platform/util/src/com/intellij/util/containers/WeakStringInterner.java
+++ b/platform/util/src/com/intellij/util/containers/WeakStringInterner.java
@@ -16,26 +16,27 @@
package com.intellij.util.containers;
import com.intellij.reference.SoftReference;
+import com.intellij.util.ConcurrencyUtil;
import org.jetbrains.annotations.NotNull;
import java.lang.ref.WeakReference;
-import java.util.*;
import java.util.HashSet;
+import java.util.Set;
/**
* @author peter
*/
public class WeakStringInterner extends StringInterner {
- private final WeakHashMap<String, WeakReference<String>> myMap = new WeakHashMap<String, WeakReference<String>>();
+ private final ConcurrentWeakHashMap<String, WeakReference<String>> myMap = new ConcurrentWeakHashMap<String, WeakReference<String>>();
@NotNull
@Override
public String intern(@NotNull String name) {
- String interned = SoftReference.dereference(myMap.get(name));
- if (interned != null) {
- return interned;
- }
- myMap.put(name, new WeakReference<String>(name));
+ WeakReference<String> key = new WeakReference<String>(name);
+ String interned = SoftReference.dereference(ConcurrencyUtil.cacheOrGet(myMap, name, key));
+ if (interned != null) return interned;
+
+ myMap.put(name, key);
return name;
}
diff --git a/platform/util/src/com/intellij/util/io/IntToIntBtree.java b/platform/util/src/com/intellij/util/io/IntToIntBtree.java
index b17fc6cc5c6c..475f3cb67a94 100644
--- a/platform/util/src/com/intellij/util/io/IntToIntBtree.java
+++ b/platform/util/src/com/intellij/util/io/IntToIntBtree.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -30,7 +30,7 @@ import java.util.Arrays;
* Date: 7/12/11
* Time: 1:34 PM
*/
-class IntToIntBtree {
+public class IntToIntBtree {
public static int version() {
return 4 + (IOUtil.ourByteBuffersUseNativeByteOrder ? 0xFF : 0);
}
@@ -55,10 +55,10 @@ class IntToIntBtree {
private boolean hasZeroKey;
private int zeroKeyValue;
- private boolean isLarge = true;
+ private final boolean isLarge = true;
private final ResizeableMappedFile storage;
private final boolean offloadToSiblingsBeforeSplit = false;
- private boolean indexNodeIsHashTable = true;
+ private final boolean indexNodeIsHashTable = true;
final int metaDataLeafPageLength;
final int hashPageCapacity;
@@ -66,8 +66,8 @@ class IntToIntBtree {
private TIntIntHashMap myCachedMappings;
private final int myCachedMappingsSize;
- public IntToIntBtree(int _pageSize, File file, PagedFileStorage.StorageLockContext storageLockContext, boolean initial) throws IOException {
- pageSize = _pageSize;
+ public IntToIntBtree(int pageSize, @NotNull File file, @NotNull PagedFileStorage.StorageLockContext storageLockContext, boolean initial) throws IOException {
+ this.pageSize = pageSize;
if (initial) {
FileUtil.delete(file);
@@ -82,13 +82,12 @@ class IntToIntBtree {
root.setIndexLeaf(true);
}
- int i = (pageSize - BtreePage.RESERVED_META_PAGE_LEN) / BtreeIndexNodeView.INTERIOR_SIZE - 1;
+ int i = (this.pageSize - BtreePage.RESERVED_META_PAGE_LEN) / BtreeIndexNodeView.INTERIOR_SIZE - 1;
assert i < Short.MAX_VALUE && i % 2 == 0;
maxInteriorNodes = (short)i;
maxLeafNodes = (short)i;
- int metaPageLen = BtreePage.RESERVED_META_PAGE_LEN;
-
+ int metaPageLen;
if (indexNodeIsHashTable) {
++i;
while(!isPrime(i)) i -= 2;
@@ -97,8 +96,10 @@ class IntToIntBtree {
metaPageLen = BtreePage.RESERVED_META_PAGE_LEN;
i = (int)(hashPageCapacity * 0.9);
if ((i & 1) == 1) ++i;
- } else {
+ }
+ else {
hashPageCapacity = -1;
+ metaPageLen = BtreePage.RESERVED_META_PAGE_LEN;
}
metaDataLeafPageLength = metaPageLen;
@@ -108,20 +109,18 @@ class IntToIntBtree {
if (hasCachedMappings) {
myCachedMappings = new TIntIntHashMap(myCachedMappingsSize = 4 * maxLeafNodes);
- } else {
+ }
+ else {
myCachedMappings = null;
myCachedMappingsSize = -1;
}
}
- public void persistVars(BtreeDataStorage storage, boolean toDisk) {
- if (toDisk) {
- storage.persistInt(0, height | (hasZeroKey ? HAS_ZERO_KEY_MASK :0), true);
- } else {
- int i = storage.persistInt(0, 0, false);
- hasZeroKey = (i & HAS_ZERO_KEY_MASK) != 0;
- height = i & ~HAS_ZERO_KEY_MASK;
- }
+ // return total number of bytes needed for storing information
+ public int persistVars(@NotNull BtreeDataStorage storage, boolean toDisk) {
+ int i = storage.persistInt(0, height | (hasZeroKey ? HAS_ZERO_KEY_MASK :0), toDisk);
+ hasZeroKey = (i & HAS_ZERO_KEY_MASK) != 0;
+ height = i & ~HAS_ZERO_KEY_MASK;
pagesCount = storage.persistInt(4, pagesCount, toDisk);
movedMembersCount = storage.persistInt(8, movedMembersCount, toDisk);
@@ -132,9 +131,10 @@ class IntToIntBtree {
hashedPagesCount = storage.persistInt(28, hashedPagesCount, toDisk);
root.setAddress(storage.persistInt(32, root.address, toDisk));
zeroKeyValue = storage.persistInt(36, zeroKeyValue, toDisk);
+ return 40;
}
- interface BtreeDataStorage {
+ public interface BtreeDataStorage {
int persistInt(int offset, int value, boolean toDisk);
}
@@ -155,10 +155,11 @@ class IntToIntBtree {
}
private BtreeIndexNodeView myAccessNodeView;
- private int myLastGetKey, myOptimizedInserts;
+ private int myLastGetKey;
+ private int myOptimizedInserts;
private boolean myCanUseLastKey;
- public boolean get(int key, int[] result) {
+ public boolean get(int key, @NotNull int[] result) {
if (key == 0) {
if (hasZeroKey) {
result[0] = zeroKeyValue;
@@ -199,7 +200,8 @@ class IntToIntBtree {
if (hasCachedMappings) {
myCachedMappings.put(key, value);
if (myCachedMappings.size() == myCachedMappingsSize) flushCachedMappings();
- } else {
+ }
+ else {
boolean canUseLastKey = myCanUseLastKey;
if (canUseLastKey) {
myCanUseLastKey = false;
@@ -256,12 +258,12 @@ class IntToIntBtree {
}
}
- void doClose() throws IOException {
+ public void doClose() throws IOException {
myCachedMappings = null;
storage.close();
}
- void doFlush() {
+ public void doFlush() {
flushCachedMappings();
storage.force();
}
@@ -445,11 +447,11 @@ class IntToIntBtree {
putInt(offset, value);
}
- private final int indexToOffset(int i) {
+ private int indexToOffset(int i) {
return i * INTERIOR_SIZE + (isHashedLeaf() ? btree.metaDataLeafPageLength:RESERVED_META_PAGE_LEN);
}
- private final int keyAt(int i) {
+ private int keyAt(int i) {
if (doSanityCheck) {
if (isHashedLeaf()) myAssert(i < btree.hashPageCapacity);
else myAssert(i < getChildrenCount());
@@ -495,7 +497,7 @@ class IntToIntBtree {
setFlag(INDEX_LEAF_MASK, value);
}
- private final boolean isHashedLeaf() {
+ private boolean isHashedLeaf() {
return isHashedLeaf;
}
@@ -608,7 +610,8 @@ class IntToIntBtree {
if (hashedLeaf) {
hashLeafData = new HashLeafData(this, recordCount);
if (doOffloadToSiblingsWhenHashed(parent, hashLeafData)) return parentAddress;
- } else {
+ }
+ else {
if (doOffloadToSiblingsSorted(parent)) return parentAddress;
}
}
@@ -1074,16 +1077,14 @@ class IntToIntBtree {
private static final boolean useDoubleHash = true;
private int hashIndex(int value) {
- int hash, index;
-
final int length = btree.hashPageCapacity;
- hash = value & 0x7fffffff;
- index = hash % length;
+ int hash = value & 0x7fffffff;
+ int index = hash % length;
int keyAtIndex = keyAt(index);
- int total = 0;
btree.hashSearchRequests++;
+ int total = 0;
if (useDoubleHash) {
if (keyAtIndex != value && keyAtIndex != HASH_FREE) {
// see Knuth, p. 529
@@ -1148,11 +1149,21 @@ class IntToIntBtree {
if (childrenAddresses.length > 0) {
BtreeIndexNodeView child = new BtreeIndexNodeView(this);
- for(int i = 0; i < childrenAddresses.length; ++i) {
- child.setAddress(childrenAddresses[i]);
- if (!processLeafPages(child, processor)) return false;
+ for (int childrenAddress : childrenAddresses) {
+ child.setAddress(childrenAddress);
+ if (!processLeafPages(child, processor)) return false;
}
}
return true;
}
+
+ public void withStorageLock(@NotNull Runnable runnable) {
+ storage.getPagedFileStorage().lock();
+ try {
+ runnable.run();
+ }
+ finally {
+ storage.getPagedFileStorage().unlock();
+ }
+ }
}
diff --git a/platform/util/src/com/intellij/util/io/PagedFileStorage.java b/platform/util/src/com/intellij/util/io/PagedFileStorage.java
index 69315f1b3764..1fca8e063394 100644
--- a/platform/util/src/com/intellij/util/io/PagedFileStorage.java
+++ b/platform/util/src/com/intellij/util/io/PagedFileStorage.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -88,11 +88,11 @@ public class PagedFileStorage implements Forceable {
private static final ByteOrder ourNativeByteOrder = ByteOrder.nativeOrder();
public void lock() {
- myStorageLockContext.myLock.lock();
+ myStorageLockContext.lock();
}
public void unlock() {
- myStorageLockContext.myLock.unlock();
+ myStorageLockContext.unlock();
}
public StorageLockContext getStorageLockContext() {
@@ -510,11 +510,11 @@ public class PagedFileStorage implements Forceable {
}
public void lock() {
- myDefaultStorageLockContext.myLock.lock();
+ myDefaultStorageLockContext.lock();
}
public void unlock() {
- myDefaultStorageLockContext.myLock.unlock();
+ myDefaultStorageLockContext.unlock();
}
private int registerPagedFileStorage(@NotNull PagedFileStorage storage) {
@@ -658,7 +658,9 @@ public class PagedFileStorage implements Forceable {
LOG.info("Max memory:"+maxMemory.get(null) + ", reserved memory:" + reservedMemory.get(null));
}
}
- catch (Throwable t) {}
+ catch (Throwable t) {
+
+ }
throw new MappingFailedException(
"Cannot recover from OOME in memory mapping: -Xmx=" + Runtime.getRuntime().maxMemory() / MB + "MB " +
"new size limit: " + mySizeLimit / MB + "MB " +
@@ -669,7 +671,7 @@ public class PagedFileStorage implements Forceable {
}
}
- private void checkThreadAccess(StorageLockContext storageLockContext) {
+ private static void checkThreadAccess(StorageLockContext storageLockContext) {
if (storageLockContext.myCheckThreadAccess && !storageLockContext.myLock.isHeldByCurrentThread()) {
throw new IllegalStateException("Must hold StorageLock lock to access PagedFileStorage");
}
@@ -776,5 +778,12 @@ public class PagedFileStorage implements Forceable {
public StorageLockContext(boolean checkAccess) {
this(ourLock, checkAccess);
}
+
+ public void lock() {
+ myLock.lock();
+ }
+ public void unlock() {
+ myLock.unlock();
+ }
}
}
diff --git a/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java b/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java
index 9a297bcef6d1..d4383a55d03e 100644
--- a/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java
+++ b/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -47,11 +47,11 @@ public class RandomAccessDataFile implements Forceable, Closeable {
private static final boolean DEBUG = false;
- public RandomAccessDataFile(final File file) throws IOException {
+ public RandomAccessDataFile(@NotNull File file) throws IOException {
this(file, PagePool.SHARED);
}
- public RandomAccessDataFile(final File file, final PagePool pool) throws IOException {
+ public RandomAccessDataFile(@NotNull File file, @NotNull PagePool pool) throws IOException {
myPool = pool;
myFile = file;
if (!file.exists()) {
@@ -201,6 +201,9 @@ public class RandomAccessDataFile implements Forceable, Closeable {
dispose();
}
+ /**
+ * Flushes dirty pages to underlying buffers
+ */
@Override
public void force() {
assertNotDisposed();
@@ -210,6 +213,23 @@ public class RandomAccessDataFile implements Forceable, Closeable {
}
}
+ /**
+ * Flushes dirty pages to buffers and saves them to disk
+ */
+ public void sync() {
+ force();
+ try {
+ RandomAccessFile file = getRandomAccessFile();
+ file.getChannel().force(true);
+ }
+ catch (IOException ignored) {
+
+ }
+ finally {
+ releaseFile();
+ }
+ }
+
public void flushSomePages(int maxPagesToFlush) {
assertNotDisposed();
if (isDirty()) {
@@ -229,7 +249,7 @@ public class RandomAccessDataFile implements Forceable, Closeable {
private void assertNotDisposed() {
if (myIsDisposed) {
- LOG.assertTrue(false, "storage file is disposed: " + myFile);
+ LOG.error("storage file is disposed: " + myFile);
}
}
@@ -316,6 +336,7 @@ public class RandomAccessDataFile implements Forceable, Closeable {
file.seek(fileOffset);
}
+ @Override
public int hashCode() {
return myCount;
}
diff --git a/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java b/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java
index e0d349c0c7ad..663cd215cfbe 100644
--- a/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java
+++ b/platform/util/src/com/intellij/util/io/storage/HeavyProcessLatch.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -19,19 +19,47 @@
*/
package com.intellij.util.io.storage;
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.util.EventDispatcher;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.EventListener;
+import java.util.concurrent.atomic.AtomicInteger;
+
public class HeavyProcessLatch {
public static final HeavyProcessLatch INSTANCE = new HeavyProcessLatch();
- private int myHeavyProcessCounter = 0;
-
- public synchronized void processStarted() {
- myHeavyProcessCounter++;
+
+ private final AtomicInteger myHeavyProcessCounter = new AtomicInteger();
+ private final EventDispatcher<HeavyProcessListener> myEventDispatcher = EventDispatcher.create(HeavyProcessListener.class);
+
+ private HeavyProcessLatch() {
+ }
+
+ public void processStarted() {
+ myHeavyProcessCounter.incrementAndGet();
+ myEventDispatcher.getMulticaster().processStarted();
}
- public synchronized void processFinished() {
- myHeavyProcessCounter--;
+ public void processFinished() {
+ myHeavyProcessCounter.decrementAndGet();
+ myEventDispatcher.getMulticaster().processFinished();
+ }
+
+ public boolean isRunning() {
+ return myHeavyProcessCounter.get() != 0;
+ }
+
+ public interface HeavyProcessListener extends EventListener {
+ public void processStarted();
+
+ public void processFinished();
}
- public synchronized boolean isRunning() {
- return myHeavyProcessCounter != 0;
+ @NotNull
+ public Disposable addListener(@NotNull HeavyProcessListener listener) {
+ Disposable disposable = Disposer.newDisposable();
+ myEventDispatcher.addListener(listener, disposable);
+ return disposable;
}
} \ No newline at end of file
diff --git a/platform/util/src/com/intellij/util/text/StringSearcher.java b/platform/util/src/com/intellij/util/text/StringSearcher.java
index d5bc95f99cef..f9517ad09ade 100644
--- a/platform/util/src/com/intellij/util/text/StringSearcher.java
+++ b/platform/util/src/com/intellij/util/text/StringSearcher.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -123,7 +123,7 @@ public class StringSearcher {
}
}
- int step = 0 <= lastChar && lastChar < 128 ? mySearchTable[lastChar] : 1;
+ int step = lastChar < 128 ? mySearchTable[lastChar] : 1;
if (step <= 0) {
int index;
@@ -160,7 +160,7 @@ public class StringSearcher {
if (i < 0) return end - start - myPatternLength + 1;
}
- int step = 0 <= lastChar && lastChar < 128 ? mySearchTable[lastChar] : 1;
+ int step = lastChar < 128 ? mySearchTable[lastChar] : 1;
if (step <= 0) {
int index;
diff --git a/platform/util/src/com/intellij/util/xmlb/MapBinding.java b/platform/util/src/com/intellij/util/xmlb/MapBinding.java
index 6a8423d2ed4b..dbc3c0e082c3 100644
--- a/platform/util/src/com/intellij/util/xmlb/MapBinding.java
+++ b/platform/util/src/com/intellij/util/xmlb/MapBinding.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.intellij.util.xmlb;
import com.intellij.openapi.util.JDOMUtil;
@@ -35,22 +34,22 @@ import java.util.Set;
import static com.intellij.util.xmlb.Constants.*;
class MapBinding implements Binding {
- private final Binding myKeyBinding;
- private final Binding myValueBinding;
- private final MapAnnotation myMapAnnotation;
private static final Comparator<Object> KEY_COMPARATOR = new Comparator<Object>() {
+ @SuppressWarnings("unchecked")
@Override
- public int compare(final Object o1, final Object o2) {
+ public int compare(Object o1, Object o2) {
if (o1 instanceof Comparable && o2 instanceof Comparable) {
Comparable c1 = (Comparable)o1;
Comparable c2 = (Comparable)o2;
return c1.compareTo(c2);
}
-
return 0;
}
};
+ private final Binding myKeyBinding;
+ private final Binding myValueBinding;
+ private final MapAnnotation myMapAnnotation;
public MapBinding(ParameterizedType type, Accessor accessor) {
Type[] arguments = type.getActualTypeArguments();
@@ -69,7 +68,7 @@ class MapBinding implements Binding {
Element m;
if (myMapAnnotation == null || myMapAnnotation.surroundWithTag()) {
- m = new Element(Constants.MAP);
+ m = new Element(MAP);
}
else {
m = (Element)context;
@@ -92,14 +91,14 @@ class MapBinding implements Binding {
if (kNode instanceof Text) {
Text text = (Text)kNode;
- entry.setAttribute(getKeyAttributeValue(), text.getText());
+ entry.setAttribute(getKeyAttributeName(), text.getText());
}
else {
if (myMapAnnotation != null && !myMapAnnotation.surroundKeyWithTag()) {
entry.addContent((Content)kNode);
}
else {
- Element key = new Element(getKeyAttributeValue());
+ Element key = new Element(getKeyAttributeName());
entry.addContent(key);
key.addContent((Content)kNode);
}
@@ -129,12 +128,12 @@ class MapBinding implements Binding {
return myMapAnnotation == null ? ENTRY : myMapAnnotation.entryTagName();
}
- private String getValueAttributeName() {
- return myMapAnnotation == null ? VALUE : myMapAnnotation.valueAttributeName();
+ private String getKeyAttributeName() {
+ return myMapAnnotation == null ? KEY : myMapAnnotation.keyAttributeName();
}
- private String getKeyAttributeValue() {
- return myMapAnnotation == null ? KEY : myMapAnnotation.keyAttributeName();
+ private String getValueAttributeName() {
+ return myMapAnnotation == null ? VALUE : myMapAnnotation.valueAttributeName();
}
@Override
@@ -164,7 +163,7 @@ class MapBinding implements Binding {
assert entry.getName().equals(getEntryAttributeName());
- Attribute keyAttr = entry.getAttribute(getKeyAttributeValue());
+ Attribute keyAttr = entry.getAttribute(getKeyAttributeName());
if (keyAttr != null) {
k = myKeyBinding.deserialize(o, keyAttr);
}
@@ -181,7 +180,7 @@ class MapBinding implements Binding {
assert k != null : "no key found";
}
else {
- final Object keyNode = entry.getChildren(getKeyAttributeValue()).get(0);
+ final Object keyNode = entry.getChildren(getKeyAttributeName()).get(0);
k = myKeyBinding.deserialize(o, JDOMUtil.getContent((Element)keyNode));
}
}
@@ -223,7 +222,7 @@ class MapBinding implements Binding {
return myMapAnnotation.entryTagName().equals(((Element)node).getName());
}
- return ((Element)node).getName().equals(Constants.MAP);
+ return ((Element)node).getName().equals(MAP);
}
@Override
diff --git a/platform/util/testSrc/com/intellij/openapi/util/io/FileUtilLightTest.java b/platform/util/testSrc/com/intellij/openapi/util/io/FileUtilLightTest.java
index bf0e0d5b9036..dd1f46dace4c 100644
--- a/platform/util/testSrc/com/intellij/openapi/util/io/FileUtilLightTest.java
+++ b/platform/util/testSrc/com/intellij/openapi/util/io/FileUtilLightTest.java
@@ -18,11 +18,13 @@ package com.intellij.openapi.util.io;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.ArrayUtil;
import com.intellij.util.PairProcessor;
+import com.intellij.util.SystemProperties;
import com.intellij.util.ThreeState;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import org.junit.Test;
+import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.Arrays;
@@ -189,4 +191,11 @@ public class FileUtilLightTest {
assertEquals("/a/b/.././c/", FileUtil.normalize("\\\\\\a\\\\//b//..///./c//"));
}
}
+
+ @Test
+ public void testRelativeToUserHome() {
+ assertEquals(SystemProperties.getUserHome(), FileUtil.getLocationRelativeToUserHome(SystemProperties.getUserHome(), false));
+ String expected = SystemInfo.isWindows ? "~\\relative" : "~/relative";
+ assertEquals(expected, FileUtil.getLocationRelativeToUserHome(SystemProperties.getUserHome() + "/relative", false));
+ }
}
diff --git a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java
index 383c07f2a87e..d2f593d13ff1 100644
--- a/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java
+++ b/platform/util/testSrc/com/intellij/util/text/StringUtilTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -178,6 +178,16 @@ public class StringUtilTest extends TestCase {
assertEquals("foo|", StringUtil.unquoteString("foo|", '|'));
}
+ public void testIsQuotedString() {
+ assertFalse(StringUtil.isQuotedString(""));
+ assertFalse(StringUtil.isQuotedString("'"));
+ assertFalse(StringUtil.isQuotedString("\""));
+ assertTrue(StringUtil.isQuotedString("\"\""));
+ assertTrue(StringUtil.isQuotedString("''"));
+ assertTrue(StringUtil.isQuotedString("'ab'"));
+ assertTrue(StringUtil.isQuotedString("\"foo\""));
+ }
+
public void testJoin() {
assertEquals("foo,,bar", StringUtil.join(Arrays.asList("foo", "", "bar"), ","));
assertEquals("foo,,bar", StringUtil.join(new String[]{"foo", "", "bar"}, ","));
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java b/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java
index c6b0daa0852d..938021c03e55 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/ProjectLevelVcsManager.java
@@ -229,7 +229,8 @@ public abstract class ProjectLevelVcsManager {
public abstract boolean isBackgroundVcsOperationRunning();
public abstract List<VirtualFile> getRootsUnderVcsWithoutFiltering(final AbstractVcs vcs);
- public abstract VirtualFile[] getRootsUnderVcs(AbstractVcs vcs);
+
+ public abstract VirtualFile[] getRootsUnderVcs(@NotNull AbstractVcs vcs);
/**
* Also includes into list all modules under roots
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/update/FileGroup.java b/platform/vcs-api/src/com/intellij/openapi/vcs/update/FileGroup.java
index a5fa2c121ed2..d9684018484a 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/update/FileGroup.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/update/FileGroup.java
@@ -254,6 +254,9 @@ public class FileGroup implements JDOMExternalizable {
return null;
}
+ /**
+ * @deprecated: remove after IDEA 14
+ */
public void setRevisions(final String path, final AbstractVcs vcs, final VcsRevisionNumber revision) {
for (UpdatedFile file : myFiles) {
if (file.getPath().startsWith(path)) {
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/update/UpdatedFiles.java b/platform/vcs-api/src/com/intellij/openapi/vcs/update/UpdatedFiles.java
index d8d6d53371d8..fdd3237af1cd 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/update/UpdatedFiles.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/update/UpdatedFiles.java
@@ -106,6 +106,10 @@ public class UpdatedFiles implements JDOMExternalizable {
return result;
}
+ /**
+ * @deprecated: remove after IDEA 14
+ */
+ @SuppressWarnings("UnusedDeclaration")
public void setRevisions(final String path, final AbstractVcs vcs, final VcsRevisionNumber revision) {
for(FileGroup group: myGroups) {
group.setRevisions(path, vcs, revision);
diff --git a/platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java b/platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java
index bdd9304e9d88..7266e344c72f 100644
--- a/platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java
+++ b/platform/vcs-api/src/com/intellij/vcsUtil/VcsUtil.java
@@ -577,18 +577,6 @@ public class VcsUtil {
return files;
}
- public static boolean caseDiffers(final String s1, final String s2) {
- String s1Trimmed = s1.trim();
- String s2Trimmed = s2.trim();
-
- if (File.separatorChar != '/') {
- s1Trimmed = s1Trimmed.replace(File.separatorChar, '/');
- s2Trimmed = s2Trimmed.replace(File.separatorChar, '/');
- }
-
- return (! s1Trimmed.equals(s2Trimmed)) && s1Trimmed.equalsIgnoreCase(s2Trimmed);
- }
-
private static final String ANNO_ASPECT = "show.vcs.annotation.aspect.";
//public static boolean isAspectAvailableByDefault(LineAnnotationAspect aspect) {
// if (aspect.getId() == null) return aspect.isShowByDefault();
diff --git a/platform/vcs-api/src/com/intellij/lifecycle/PeriodicalTasksCloser.java b/platform/vcs-api/vcs-api-core/src/com/intellij/lifecycle/PeriodicalTasksCloser.java
index bbb4847fbc64..3b6a7ff2a5c6 100644
--- a/platform/vcs-api/src/com/intellij/lifecycle/PeriodicalTasksCloser.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/lifecycle/PeriodicalTasksCloser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/FilePath.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/FilePath.java
index 90fd92f2e78e..1ca489c0d128 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/FilePath.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/FilePath.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsException.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/VcsException.java
index 5a72bfe1fba6..dacf4e654f5f 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsException.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/VcsException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsKey.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/VcsKey.java
index f3a507cf8e56..4e2871b3f539 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsKey.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/VcsKey.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/Change.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/Change.java
index 8e300bd2a291..b1d8978eea68 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/Change.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/Change.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -25,7 +25,7 @@ import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.impl.VcsPathPresenter;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.vcsUtil.VcsUtil;
+import com.intellij.vcsUtil.VcsFilePathUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -120,7 +120,8 @@ public class Change {
}
if ((! Comparing.equal(myBeforeRevision.getFile(), myAfterRevision.getFile())) ||
- ((! SystemInfo.isFileSystemCaseSensitive) && VcsUtil.caseDiffers(myBeforeRevision.getFile().getPath(), myAfterRevision.getFile().getPath()))) {
+ ((! SystemInfo.isFileSystemCaseSensitive) && VcsFilePathUtil
+ .caseDiffers(myBeforeRevision.getFile().getPath(), myAfterRevision.getFile().getPath()))) {
myType = Type.MOVED;
return myType;
}
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ContentRevision.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/ContentRevision.java
index af21b167041f..de5944ac9b3c 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ContentRevision.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/ContentRevision.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/MergeTexts.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/MergeTexts.java
index 18423d8ad490..16ed06a00b41 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/MergeTexts.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/changes/MergeTexts.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/history/LongRevisionNumber.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/history/LongRevisionNumber.java
index ffcedbb456c2..52bae307b01e 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/history/LongRevisionNumber.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/history/LongRevisionNumber.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsRevisionNumber.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/history/VcsRevisionNumber.java
index 4647ecac78af..9d5851da6889 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/history/VcsRevisionNumber.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/history/VcsRevisionNumber.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/VcsPathPresenter.java b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/impl/VcsPathPresenter.java
index b8c239f84a71..9985cf77518f 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/VcsPathPresenter.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/openapi/vcs/impl/VcsPathPresenter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/src/com/intellij/vcsUtil/Rethrow.java b/platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/Rethrow.java
index dc2e3b9409bd..6c42caaa3126 100644
--- a/platform/vcs-api/src/com/intellij/vcsUtil/Rethrow.java
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/Rethrow.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
diff --git a/platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/VcsFilePathUtil.java b/platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/VcsFilePathUtil.java
new file mode 100644
index 000000000000..b6992f53ab0c
--- /dev/null
+++ b/platform/vcs-api/vcs-api-core/src/com/intellij/vcsUtil/VcsFilePathUtil.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2014 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.vcsUtil;
+
+import java.io.File;
+
+public class VcsFilePathUtil {
+ public static boolean caseDiffers(final String s1, final String s2) {
+ String s1Trimmed = s1.trim();
+ String s2Trimmed = s2.trim();
+
+ if (File.separatorChar != '/') {
+ s1Trimmed = s1Trimmed.replace(File.separatorChar, '/');
+ s2Trimmed = s2Trimmed.replace(File.separatorChar, '/');
+ }
+
+ return (! s1Trimmed.equals(s2Trimmed)) && s1Trimmed.equalsIgnoreCase(s2Trimmed);
+ }
+}
diff --git a/platform/vcs-api/vcs-api-core/vcs-api-core.iml b/platform/vcs-api/vcs-api-core/vcs-api-core.iml
new file mode 100644
index 000000000000..434160533f3b
--- /dev/null
+++ b/platform/vcs-api/vcs-api-core/vcs-api-core.iml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="annotations" />
+ <orderEntry type="module" module-name="core-api" />
+ <orderEntry type="module" module-name="editor-ui-api" />
+ </component>
+</module>
+
diff --git a/platform/vcs-api/vcs-api.iml b/platform/vcs-api/vcs-api.iml
index 685d664dd28f..d6c7d2eb1b67 100644
--- a/platform/vcs-api/vcs-api.iml
+++ b/platform/vcs-api/vcs-api.iml
@@ -9,6 +9,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="platform-api" exported="" />
<orderEntry type="library" name="microba" level="project" />
+ <orderEntry type="module" module-name="vcs-api-core" exported="" />
</component>
</module>
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinFilesAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinFilesAction.java
index 89d1f5695e63..1829413f0f7e 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinFilesAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinFilesAction.java
@@ -23,12 +23,14 @@ import com.intellij.openapi.vcs.changes.LocalChangeList;
import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.HashSet;
+import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
public class CommonCheckinFilesAction extends AbstractCommonCheckinAction {
+ @Override
protected String getActionName(final VcsContext dataContext) {
final String checkinActionName = getCheckinActionName(dataContext);
return modifyCheckinActionName(dataContext, checkinActionName);
@@ -125,14 +127,16 @@ public class CommonCheckinFilesAction extends AbstractCommonCheckinAction {
return false;
}
- protected boolean isApplicableRoot(VirtualFile file, FileStatus status, VcsContext dataContext) {
+ protected boolean isApplicableRoot(@NotNull VirtualFile file, @NotNull FileStatus status, @NotNull VcsContext dataContext) {
return status != FileStatus.UNKNOWN && status != FileStatus.IGNORED;
}
+ @Override
protected FilePath[] getRoots(final VcsContext context) {
return context.getSelectedFilePaths();
}
+ @Override
protected boolean filterRootsBeforeAction() {
return true;
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java
index 070a4e95587a..fe20806a8ed4 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/AbstractRefreshablePanel.java
@@ -49,7 +49,7 @@ public abstract class AbstractRefreshablePanel<T> implements RefreshablePanel<Ch
private final DetailsPanel myDetailsPanel;
private final GenericDetailsLoader<Ticket, T> myDetailsLoader;
private final BackgroundTaskQueue myQueue;
- private boolean myDisposed;
+ private volatile boolean myDisposed;
protected AbstractRefreshablePanel(final Project project, final String loadingTitle, final BackgroundTaskQueue queue) {
myQueue = queue;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java
index 025795eb08ed..731634b85080 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesFragmentedDiffPanel.java
@@ -549,7 +549,7 @@ public class ChangesFragmentedDiffPanel implements Disposable {
}
private static final int[] ourMarks = {1,2,4,8,-1};
- public static final Hashtable<Integer,JLabel> LABELS = new Hashtable<Integer, JLabel>();
+ public static final Hashtable<Integer, JComponent> LABELS = new Hashtable<Integer, JComponent>();
public static final int ALL_VALUE = 5;
static {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FragmentedDiffRequestFromChange.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FragmentedDiffRequestFromChange.java
index 77dd9b3f42b3..ce6ca72ab996 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FragmentedDiffRequestFromChange.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/FragmentedDiffRequestFromChange.java
@@ -218,8 +218,8 @@ public class FragmentedDiffRequestFromChange {
final List<BeforeAfter<TextRange>> result = new ArrayList<BeforeAfter<TextRange>>();
if (myRanges == null || myRanges.isEmpty()) return Collections.emptyList();
for (Range range : myRanges) {
- final TextRange before = new TextRange(range.getUOffset1(), range.getUOffset2());
- final TextRange after = new TextRange(range.getOffset1(), range.getOffset2());
+ final TextRange before = new TextRange(range.getVcsLine1(), range.getVcsLine2());
+ final TextRange after = new TextRange(range.getLine1(), range.getLine2());
result.add(new BeforeAfter<TextRange>(before, after));
}
return result;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java
index 2da25f6e92c1..6619b98ea5e9 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CommittedChangesCache.java
@@ -44,6 +44,7 @@ import com.intellij.util.Consumer;
import com.intellij.util.MessageBusUtil;
import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ConcurrentHashMap;
+import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.MessageBusConnection;
@@ -772,16 +773,21 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
}
public void processUpdatedFiles(final UpdatedFiles updatedFiles) {
+ processUpdatedFiles(updatedFiles, null);
+ }
+
+ public void processUpdatedFiles(final UpdatedFiles updatedFiles,
+ @Nullable final Consumer<List<CommittedChangeList>> incomingChangesConsumer) {
final Runnable task = new Runnable() {
@Override
public void run() {
debug("Processing updated files");
final Collection<ChangesCacheFile> caches = myCachesHolder.getAllCaches();
+ myPendingUpdateCount += caches.size();
for(final ChangesCacheFile cache: caches) {
- myPendingUpdateCount++;
try {
if (cache.isEmpty()) {
- pendingUpdateProcessed();
+ pendingUpdateProcessed(incomingChangesConsumer);
continue;
}
debug("Processing updated files in " + cache.getLocation());
@@ -789,12 +795,12 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
if (needRefresh) {
debug("Found unaccounted files, requesting refresh");
// todo do we need double-queueing here???
- processUpdatedFilesAfterRefresh(cache, updatedFiles);
+ processUpdatedFilesAfterRefresh(cache, updatedFiles, incomingChangesConsumer);
}
else {
debug("Clearing cached incoming changelists");
myCachedIncomingChangeLists = null;
- pendingUpdateProcessed();
+ pendingUpdateProcessed(incomingChangesConsumer);
}
}
catch (IOException e) {
@@ -806,15 +812,20 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
myTaskQueue.run(task);
}
- private void pendingUpdateProcessed() {
+ private void pendingUpdateProcessed(@Nullable Consumer<List<CommittedChangeList>> incomingChangesConsumer) {
myPendingUpdateCount--;
if (myPendingUpdateCount == 0) {
notifyIncomingChangesUpdated(myNewIncomingChanges);
+ if (incomingChangesConsumer != null) {
+ incomingChangesConsumer.consume(ContainerUtil.newArrayList(myNewIncomingChanges));
+ }
myNewIncomingChanges.clear();
}
}
- private void processUpdatedFilesAfterRefresh(final ChangesCacheFile cache, final UpdatedFiles updatedFiles) {
+ private void processUpdatedFilesAfterRefresh(final ChangesCacheFile cache,
+ final UpdatedFiles updatedFiles,
+ @Nullable final Consumer<List<CommittedChangeList>> incomingChangesConsumer) {
refreshCacheAsync(cache, false, new RefreshResultConsumer() {
@Override
public void receivedChanges(final List<CommittedChangeList> committedChangeLists) {
@@ -833,7 +844,7 @@ public class CommittedChangesCache implements PersistentStateComponent<Committed
debug("Clearing cached incoming changelists");
myCachedIncomingChangeLists = null;
}
- pendingUpdateProcessed();
+ pendingUpdateProcessed(incomingChangesConsumer);
}
catch (IOException e) {
LOG.error(e);
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java
index 7d4156873d7c..b7a42218e3e6 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java
@@ -150,7 +150,7 @@ public class ChangesBrowserNode<T> extends DefaultMutableTreeNode {
public <T> List<T> getAllObjectsUnder(final Class<T> clazz) {
List<T> changes = new ArrayList<T>();
- final Enumeration enumeration = depthFirstEnumeration();
+ final Enumeration enumeration = preorderEnumeration();
while (enumeration.hasMoreElements()) {
ChangesBrowserNode child = (ChangesBrowserNode)enumeration.nextElement();
final Object value = child.getUserObject();
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.java
index 2ed36d79947f..1efc7b44d66b 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesModuleGroupingPolicy.java
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nullable;
@@ -55,8 +56,9 @@ public class ChangesModuleGroupingPolicy implements ChangesGroupingPolicy {
if (vFile == null) {
vFile = LocalFileSystem.getInstance().findFileByIoFile(new File(node.getPath()));
}
- if (vFile != null && Comparing.equal(vFile, index.getContentRootForFile(vFile))) {
- Module module = index.getModuleForFile(vFile);
+ boolean hideExcludedFiles = Registry.is("ide.hide.excluded.files");
+ if (vFile != null && Comparing.equal(vFile, index.getContentRootForFile(vFile, hideExcludedFiles))) {
+ Module module = index.getModuleForFile(vFile, hideExcludedFiles);
return getNodeForModule(module, rootNode);
}
return null;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurable.java
new file mode 100644
index 000000000000..695f8b9143db
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurable.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2000-2014 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.vcs.configurable;
+
+
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.SearchableConfigurable;
+import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+
+public class VcsBackgroundOperationsConfigurable implements SearchableConfigurable {
+ private VcsBackgroundOperationsConfigurationPanel myPanel;
+ private final Project myProject;
+
+ public VcsBackgroundOperationsConfigurable(Project project) {
+ myProject = project;
+ }
+
+ @Override
+ public void reset() {
+ myPanel.reset();
+ }
+
+ @Override
+ public void apply() throws ConfigurationException {
+ myPanel.apply();
+ }
+
+ @Override
+ public boolean isModified() {
+ return myPanel.isModified();
+ }
+
+ @Nls
+ public String getDisplayName() {
+ return "Background";
+ }
+
+ public String getHelpTopic() {
+ return "project.propVCSSupport.Background";
+ }
+
+ @NotNull
+ public String getId() {
+ return getHelpTopic();
+ }
+
+ public Runnable enableSearch(String option) {
+ return null;
+ }
+
+ public JComponent createComponent() {
+ myPanel = new VcsBackgroundOperationsConfigurationPanel(myProject);
+ return myPanel.getPanel();
+ }
+
+ public void disposeUIResources() {
+ myPanel = null;
+ }
+
+}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.java
index 1a9884ee003b..6b23766b9038 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsBackgroundOperationsConfigurationPanel.java
@@ -31,7 +31,7 @@ import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
import java.util.Map;
-public class VcsBackgroundOperationsConfigurationPanel implements SearchableConfigurable {
+public class VcsBackgroundOperationsConfigurationPanel {
private JPanel myPanel;
@@ -151,30 +151,6 @@ public class VcsBackgroundOperationsConfigurationPanel implements SearchableConf
return myPanel;
}
- @Nls
- public String getDisplayName() {
- return "Background";
- }
-
- public String getHelpTopic() {
- return "project.propVCSSupport.Background";
- }
-
- @NotNull
- public String getId() {
- return getHelpTopic();
- }
-
- public Runnable enableSearch(String option) {
- return null;
- }
-
- public JComponent createComponent() {
- return getPanel();
- }
-
- public void disposeUIResources() {
- }
private void createUIComponents() {
myCacheSettingsPanel = new CacheSettingsPanel();
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationConfigurable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationConfigurable.java
new file mode 100644
index 000000000000..03368a82464c
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationConfigurable.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2000-2014 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.vcs.configurable;
+
+import com.intellij.openapi.options.ConfigurationException;
+import com.intellij.openapi.options.SearchableConfigurable;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.AbstractVcs;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.util.Arrays;
+import java.util.Collection;
+
+public class VcsGeneralConfigurationConfigurable implements SearchableConfigurable {
+ private VcsGeneralConfigurationPanel myPanel;
+ private Project myProject;
+ private VcsManagerConfigurable myMainConfigurable;
+
+ public VcsGeneralConfigurationConfigurable(Project project, VcsManagerConfigurable configurable) {
+ myProject = project;
+ myMainConfigurable = configurable;
+ }
+
+ @Nullable
+ @Override
+ public JComponent createComponent() {
+ myPanel = new VcsGeneralConfigurationPanel(myProject);
+ if (getMappings() != null) {
+ myPanel.updateAvailableOptions(getMappings().getActiveVcses());
+ addListenerToGeneralPanel();
+ }
+ else {
+ myPanel.updateAvailableOptions(Arrays.asList(ProjectLevelVcsManager.getInstance(myProject).getAllActiveVcss()));
+ }
+ addListenerToGeneralPanel();
+
+ return myPanel.getPanel();
+ }
+
+ private VcsDirectoryConfigurationPanel getMappings() {
+ return myMainConfigurable.getMappings();
+ }
+
+ private void addListenerToGeneralPanel() {
+ VcsDirectoryConfigurationPanel mappings = getMappings();
+ if (mappings != null) {
+ mappings.addVcsListener(new ModuleVcsListener() {
+ @Override
+ public void activeVcsSetChanged(Collection<AbstractVcs> activeVcses) {
+ myPanel.updateAvailableOptions(activeVcses);
+ }
+ });
+ }
+ }
+
+ @Override
+ public void apply() throws ConfigurationException {
+ myPanel.apply();
+ }
+
+ @Override
+ public boolean isModified() {
+ return myPanel.isModified();
+ }
+
+ @Override
+ public void reset() {
+ myPanel.reset();
+ }
+
+ @Override
+ public void disposeUIResources() {
+ myPanel = null;
+ }
+ @Nls
+ public String getDisplayName() {
+ return "Confirmation";
+ }
+
+ @NotNull
+ public String getHelpTopic() {
+ return "project.propVCSSupport.Confirmation";
+ }
+
+ @NotNull
+ public String getId() {
+ return getHelpTopic();
+ }
+
+ public Runnable enableSearch(String option) {
+ return null;
+ }
+
+}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java
index 781e4fd949a6..45a7267d7587 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java
@@ -36,7 +36,7 @@ import java.awt.*;
import java.util.*;
import java.util.List;
-public class VcsGeneralConfigurationPanel implements SearchableConfigurable {
+public class VcsGeneralConfigurationPanel {
private JCheckBox myForceNonEmptyComment;
private JCheckBox myShowReadOnlyStatusDialog;
@@ -294,29 +294,4 @@ public class VcsGeneralConfigurationPanel implements SearchableConfigurable {
return StringUtil.join(result, ", ");
}
- @Nls
- public String getDisplayName() {
- return "Confirmation";
- }
-
- @NotNull
- public String getHelpTopic() {
- return "project.propVCSSupport.Confirmation";
- }
-
- public JComponent createComponent() {
- return getPanel();
- }
-
- public void disposeUIResources() {
- }
-
- @NotNull
- public String getId() {
- return getHelpTopic();
- }
-
- public Runnable enableSearch(String option) {
- return null;
- }
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java
index 304275d732d7..a392ff1f5db2 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurable.java
@@ -40,7 +40,7 @@ import java.util.List;
public class VcsManagerConfigurable extends SearchableConfigurable.Parent.Abstract implements Configurable.NoScroll {
private final Project myProject;
private VcsDirectoryConfigurationPanel myMappings;
- private VcsGeneralConfigurationPanel myGeneralPanel;
+ private VcsGeneralConfigurationConfigurable myGeneralPanel;
public VcsManagerConfigurable(Project project) {
myProject = project;
@@ -49,9 +49,6 @@ public class VcsManagerConfigurable extends SearchableConfigurable.Parent.Abstra
@Override
public JComponent createComponent() {
myMappings = new VcsDirectoryConfigurationPanel(myProject);
- if (myGeneralPanel != null) {
- addListenerToGeneralPanel();
- }
return myMappings;
}
@@ -118,26 +115,12 @@ public class VcsManagerConfigurable extends SearchableConfigurable.Parent.Abstra
@Override
protected Configurable[] buildConfigurables() {
- myGeneralPanel = new VcsGeneralConfigurationPanel(myProject){
- @Override
- public void disposeUIResources() {
- super.disposeUIResources();
- myGeneralPanel = null;
- }
- };
-
- if (myMappings != null) {
- myGeneralPanel.updateAvailableOptions(myMappings.getActiveVcses());
- addListenerToGeneralPanel();
- }
- else {
- myGeneralPanel.updateAvailableOptions(Arrays.asList(ProjectLevelVcsManager.getInstance(myProject).getAllActiveVcss()));
- }
+ myGeneralPanel = new VcsGeneralConfigurationConfigurable(myProject, this);
List<Configurable> result = new ArrayList<Configurable>();
result.add(myGeneralPanel);
- result.add(new VcsBackgroundOperationsConfigurationPanel(myProject));
+ result.add(new VcsBackgroundOperationsConfigurable(myProject));
if (!myProject.isDefault()) {
result.add(new IgnoredSettingsPanel(myProject));
@@ -165,13 +148,8 @@ public class VcsManagerConfigurable extends SearchableConfigurable.Parent.Abstra
return result.toArray(new Configurable[result.size()]);
}
- private void addListenerToGeneralPanel() {
- myMappings.addVcsListener(new ModuleVcsListener() {
- @Override
- public void activeVcsSetChanged(Collection<AbstractVcs> activeVcses) {
- myGeneralPanel.updateAvailableOptions(activeVcses);
- }
- });
+ public VcsDirectoryConfigurationPanel getMappings() {
+ return myMappings;
}
private Configurable createVcsConfigurableWrapper(final VcsDescriptor vcs) {
@@ -237,5 +215,4 @@ public class VcsManagerConfigurable extends SearchableConfigurable.Parent.Abstra
}
};
}
-
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/CopyLineStatusRangeAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/CopyLineStatusRangeAction.java
index aaa512c4e674..a9f761a2b5e0 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/CopyLineStatusRangeAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/CopyLineStatusRangeAction.java
@@ -35,7 +35,7 @@ public class CopyLineStatusRangeAction extends BaseLineStatusRangeAction {
}
public void actionPerformed(final AnActionEvent e) {
- final String content = myLineStatusTracker.getUpToDateContent(myRange).toString();
+ final String content = myLineStatusTracker.getVcsContent(myRange).toString();
CopyPasteManager.getInstance().setContents(new StringSelection(content));
}
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
index 44a56e7df517..9d8d73a92be9 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
@@ -32,21 +32,21 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorNotificationPanel;
+import com.intellij.util.ExceptionUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.diff.FilesTooBigForDiffException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
+import java.util.*;
/**
* @author irengrig
@@ -61,7 +61,7 @@ public class LineStatusTracker {
private BaseLoadState myBaseLoaded;
private final Document myDocument;
- private final Document myUpToDateDocument;
+ private final Document myVcsDocument;
private List<Range> myRanges;
@@ -69,34 +69,35 @@ public class LineStatusTracker {
private MyDocumentListener myDocumentListener;
+ private boolean mySuppressUpdate;
private boolean myBulkUpdate;
private final Application myApplication;
@Nullable private RevisionPack myBaseRevisionNumber;
private String myPreviousBaseRevision;
private boolean myAnathemaThrown;
private FileEditorManager myFileEditorManager;
+ private final VcsDirtyScopeManager myVcsDirtyScopeManager;
private final VirtualFile myVirtualFile;
private boolean myReleased = false;
private LineStatusTracker(@NotNull final Document document,
- @NotNull final Document upToDateDocument,
+ @NotNull final Document vcsDocument,
final Project project,
@Nullable final VirtualFile virtualFile) {
myVirtualFile = virtualFile;
myApplication = ApplicationManager.getApplication();
myDocument = document;
- myUpToDateDocument = upToDateDocument;
- myUpToDateDocument.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
+ myVcsDocument = vcsDocument;
+ myVcsDocument.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
myProject = project;
myBaseLoaded = BaseLoadState.LOADING;
- synchronized (myLock) {
- myRanges = new ArrayList<Range>();
- }
+ myRanges = new ArrayList<Range>();
myAnathemaThrown = false;
myFileEditorManager = FileEditorManager.getInstance(myProject);
+ myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
}
- public void initialize(@NotNull final String upToDateContent, @NotNull RevisionPack baseRevisionNumber) {
+ public void initialize(@NotNull final String vcsContent, @NotNull RevisionPack baseRevisionNumber) {
ApplicationManager.getApplication().assertIsDispatchThread();
synchronized (myLock) {
@@ -107,9 +108,9 @@ public class LineStatusTracker {
myBaseRevisionNumber = baseRevisionNumber;
myPreviousBaseRevision = null;
- myUpToDateDocument.setReadOnly(false);
- myUpToDateDocument.replaceString(0, myUpToDateDocument.getTextLength(), upToDateContent);
- myUpToDateDocument.setReadOnly(true);
+ myVcsDocument.setReadOnly(false);
+ myVcsDocument.replaceString(0, myVcsDocument.getTextLength(), vcsContent);
+ myVcsDocument.setReadOnly(true);
reinstallRanges();
if (myDocumentListener == null) {
@@ -144,7 +145,7 @@ public class LineStatusTracker {
removeAnathema();
removeHighlightersFromMarkupModel();
try {
- myRanges = new RangesBuilder(myDocument, myUpToDateDocument).getRanges();
+ myRanges = new RangesBuilder(myDocument, myVcsDocument).getRanges();
}
catch (FilesTooBigForDiffException e) {
myRanges.clear();
@@ -175,10 +176,10 @@ public class LineStatusTracker {
LOG.assertTrue(!myReleased, "Already released");
int first =
- range.getOffset1() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getOffset1());
+ range.getLine1() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getLine1());
int second =
- range.getOffset2() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getOffset2());
+ range.getLine2() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getLine2());
final RangeHighlighter highlighter = DocumentMarkupModel.forDocument(myDocument, myProject, true)
.addRangeHighlighter(first, second, HighlighterLayer.FIRST - 1, null, HighlighterTargetArea.LINES_IN_RANGE);
@@ -192,19 +193,19 @@ public class LineStatusTracker {
highlighter.setEditorFilter(MarkupEditorFilterFactory.createIsNotDiffFilter());
final String tooltip;
- if (range.getOffset1() == range.getOffset2()) {
- if (range.getUOffset1() + 1 == range.getUOffset2()) {
- tooltip = VcsBundle.message("tooltip.text.line.before.deleted", range.getOffset1() + 1);
+ if (range.getLine1() == range.getLine2()) {
+ if (range.getVcsLine1() + 1 == range.getVcsLine2()) {
+ tooltip = VcsBundle.message("tooltip.text.line.before.deleted", range.getLine1() + 1);
}
else {
- tooltip = VcsBundle.message("tooltip.text.lines.before.deleted", range.getOffset1() + 1, range.getUOffset2() - range.getUOffset1());
+ tooltip = VcsBundle.message("tooltip.text.lines.before.deleted", range.getLine1() + 1, range.getVcsLine2() - range.getVcsLine1());
}
}
- else if (range.getOffset1() + 1 == range.getOffset2()) {
- tooltip = VcsBundle.message("tooltip.text.line.changed", range.getOffset1() + 1);
+ else if (range.getLine1() + 1 == range.getLine2()) {
+ tooltip = VcsBundle.message("tooltip.text.line.changed", range.getLine1() + 1);
}
else {
- tooltip = VcsBundle.message("tooltip.text.lines.changed", range.getOffset1() + 1, range.getOffset2());
+ tooltip = VcsBundle.message("tooltip.text.lines.changed", range.getLine1() + 1, range.getLine2());
}
highlighter.setErrorStripeTooltip(tooltip);
@@ -238,9 +239,9 @@ public class LineStatusTracker {
}
}
- public Document getUpToDateDocument() {
+ public Document getVcsDocument() {
myApplication.assertIsDispatchThread();
- return myUpToDateDocument;
+ return myVcsDocument;
}
public void startBulkUpdate() {
@@ -285,11 +286,11 @@ public class LineStatusTracker {
// there can be multiple resets before init -> take from document only firts time -> when right after install(),
// where myPreviousBaseRevision become null
if (BaseLoadState.LOADED.equals(myBaseLoaded) && myPreviousBaseRevision == null) {
- myPreviousBaseRevision = myUpToDateDocument.getText();
+ myPreviousBaseRevision = myVcsDocument.getText();
}
- myUpToDateDocument.setReadOnly(false);
- myUpToDateDocument.setText("");
- myUpToDateDocument.setReadOnly(true);
+ myVcsDocument.setReadOnly(false);
+ myVcsDocument.setText("");
+ myVcsDocument.setReadOnly(true);
removeAnathema();
removeHighlightersFromMarkupModel();
myBaseLoaded = BaseLoadState.LOADING;
@@ -298,15 +299,13 @@ public class LineStatusTracker {
private class MyDocumentListener extends DocumentAdapter {
// We have 3 document versions:
- // * VCS version - upToDate*
- // * before change - my*
- // * after change - current*
+ // * VCS version
+ // * before change
+ // * after change
- private int myFirstChangedLine;
- private int myLastChangedLine;
- private int myChangedLines;
- private int myTotalLines;
- private final VcsDirtyScopeManager myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
+ private int myLine1;
+ private int myBeforeChangedLines;
+ private int myBeforeTotalLines;
@Override
public void beforeDocumentChange(DocumentEvent e) {
@@ -314,13 +313,21 @@ public class LineStatusTracker {
synchronized (myLock) {
if (myReleased) return;
- if (myBulkUpdate || myAnathemaThrown || BaseLoadState.LOADED != myBaseLoaded) return;
+ if (myBulkUpdate || mySuppressUpdate || myAnathemaThrown || BaseLoadState.LOADED != myBaseLoaded) return;
+ assert myDocument == e.getDocument();
+
try {
- myFirstChangedLine = myDocument.getLineNumber(e.getOffset());
- myLastChangedLine = e.getOldLength() == 0 ? myFirstChangedLine : myDocument.getLineNumber(e.getOffset() + e.getOldLength() - 1);
- if (StringUtil.endsWithChar(e.getOldFragment(), '\n')) myLastChangedLine++;
- myChangedLines = myLastChangedLine - myFirstChangedLine;
- myTotalLines = getLineCount(e.getDocument());
+ myLine1 = myDocument.getLineNumber(e.getOffset());
+ if (e.getOldLength() == 0) {
+ myBeforeChangedLines = 1;
+ }
+ else {
+ int line1 = myLine1;
+ int line2 = myDocument.getLineNumber(e.getOffset() + e.getOldLength());
+ myBeforeChangedLines = line2 - line1 + 1;
+ }
+
+ myBeforeTotalLines = getLineCount(myDocument);
}
catch (ProcessCanceledException ignore) {
}
@@ -333,138 +340,307 @@ public class LineStatusTracker {
synchronized (myLock) {
if (myReleased) return;
- if (myBulkUpdate || myAnathemaThrown || BaseLoadState.LOADED != myBaseLoaded) return;
- try {
- int currentFirstChangedLine = myFirstChangedLine;
- int currentLastChangedLine =
- e.getNewLength() == 0 ? currentFirstChangedLine : myDocument.getLineNumber(e.getOffset() + e.getNewLength() - 1);
- if (StringUtil.endsWithChar(e.getNewFragment(), '\n')) currentLastChangedLine++;
- int currentChangedLines = currentLastChangedLine - currentFirstChangedLine;
- int upToDateTotalLine = getLineCount(myUpToDateDocument);
-
- int linesShift = currentChangedLines - myChangedLines;
-
- List<Range> rangesBeforeChange = new ArrayList<Range>();
- List<Range> rangesAfterChange = new ArrayList<Range>();
- List<Range> changedRanges = new ArrayList<Range>();
- sortRanges(myRanges, myFirstChangedLine, myLastChangedLine, rangesBeforeChange, changedRanges, rangesAfterChange);
-
- Range firstChangedRange = ContainerUtil.getFirstItem(changedRanges);
- Range lastChangedRange = ContainerUtil.getLastItem(changedRanges);
- Range lastRangeBefore = ContainerUtil.getLastItem(rangesBeforeChange);
- Range firstRangeAfter = ContainerUtil.getFirstItem(rangesAfterChange);
-
- if (firstChangedRange != null && firstChangedRange.getOffset1() < myFirstChangedLine) {
- myFirstChangedLine = firstChangedRange.getOffset1();
- }
- if (lastChangedRange != null && lastChangedRange.getOffset2() > myLastChangedLine) {
- myLastChangedLine = lastChangedRange.getOffset2() - 1;
- }
+ if (myBulkUpdate || mySuppressUpdate || myAnathemaThrown || BaseLoadState.LOADED != myBaseLoaded) return;
+ assert myDocument == e.getDocument();
- currentFirstChangedLine = myFirstChangedLine;
- currentLastChangedLine = myLastChangedLine + linesShift;
+ int afterChangedLines;
+ if (e.getNewLength() == 0) {
+ afterChangedLines = 1;
+ }
+ else {
+ int line1 = myLine1;
+ int line2 = myDocument.getLineNumber(e.getOffset() + e.getNewLength());
+ afterChangedLines = line2 - line1 + 1;
+ }
- int upToDateFirstLine = getUpToDateLine1(lastRangeBefore, myFirstChangedLine);
- int upToDateLastLine = getUpToDateLine2(firstRangeAfter, myLastChangedLine, myTotalLines, upToDateTotalLine);
+ int linesShift = afterChangedLines - myBeforeChangedLines;
- List<Range> newChangedRanges =
- getNewChangedRanges(currentFirstChangedLine, currentLastChangedLine, upToDateFirstLine, upToDateLastLine);
+ int line1 = myLine1;
+ int line2 = line1 + myBeforeChangedLines; // TODO: optimize some whole-line-changed cases
- shiftRanges(rangesAfterChange, linesShift);
+ int[] fixed = fixRanges(e, line1, line2);
+ line1 = fixed[0];
+ line2 = fixed[1];
- if (!changedRanges.equals(newChangedRanges)) {
- replaceRanges(changedRanges, newChangedRanges);
+ doUpdateRanges(line1, line2, linesShift, myBeforeTotalLines);
+ }
+ }
+ }
- myRanges = new ArrayList<Range>(rangesBeforeChange.size() + newChangedRanges.size() + rangesAfterChange.size());
+ @NotNull
+ private int[] fixRanges(@NotNull DocumentEvent e, int line1, int line2) {
+ CharSequence document = myDocument.getCharsSequence();
+ int offset = e.getOffset();
- myRanges.addAll(rangesBeforeChange);
- myRanges.addAll(newChangedRanges);
- myRanges.addAll(rangesAfterChange);
+ if (e.getOldLength() == 0 && e.getNewLength() != 0) {
+ if (StringUtil.endsWithChar(e.getNewFragment(), '\n') && isNewline(offset - 1, document)) {
+ return new int[]{line1, line2 - 1};
+ }
+ if (StringUtil.startsWithChar(e.getNewFragment(), '\n') && isNewline(offset + e.getNewLength(), document)) {
+ return new int[]{line1 + 1, line2};
+ }
+ }
+ if (e.getOldLength() != 0 && e.getNewLength() == 0) {
+ if (StringUtil.endsWithChar(e.getOldFragment(), '\n') && isNewline(offset - 1, document)) {
+ return new int[]{line1, line2 - 1};
+ }
+ if (StringUtil.startsWithChar(e.getOldFragment(), '\n') && isNewline(offset + e.getNewLength(), document)) {
+ return new int[]{line1 + 1, line2};
+ }
+ }
- for (Range range : myRanges) {
- if (!range.hasHighlighter()) range.setHighlighter(createHighlighter(range));
- }
+ return new int[]{line1, line2};
+ }
- if (myRanges.isEmpty() && myVirtualFile != null) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- FileDocumentManager.getInstance().saveDocument(e.getDocument());
- boolean[] stillEmpty = new boolean[1];
- synchronized (myLock) {
- stillEmpty[0] = myRanges.isEmpty();
- }
- if (stillEmpty[0]) {
- // file was modified, and now it's not -> dirty local change
- myVcsDirtyScopeManager.fileDirty(myVirtualFile);
- }
- }
- });
- }
- }
- }
- catch (ProcessCanceledException ignore) {
+ private static boolean isNewline(int offset, @NotNull CharSequence sequence) {
+ if (offset < 0) return false;
+ if (offset >= sequence.length()) return false;
+ return sequence.charAt(offset) == '\n';
+ }
+
+ private void doUpdateRanges(int beforeChangedLine1,
+ int beforeChangedLine2,
+ int linesShift,
+ int beforeTotalLines) {
+ List<Range> rangesBeforeChange = new ArrayList<Range>();
+ List<Range> rangesAfterChange = new ArrayList<Range>();
+ List<Range> changedRanges = new ArrayList<Range>();
+
+ sortRanges(beforeChangedLine1, beforeChangedLine2, linesShift, rangesBeforeChange, changedRanges, rangesAfterChange);
+
+ Range firstChangedRange = ContainerUtil.getFirstItem(changedRanges);
+ Range lastChangedRange = ContainerUtil.getLastItem(changedRanges);
+
+ if (firstChangedRange != null && firstChangedRange.getLine1() < beforeChangedLine1) {
+ beforeChangedLine1 = firstChangedRange.getLine1();
+ }
+ if (lastChangedRange != null && lastChangedRange.getLine2() > beforeChangedLine2) {
+ beforeChangedLine2 = lastChangedRange.getLine2();
+ }
+
+ doUpdateRanges(beforeChangedLine1, beforeChangedLine2, linesShift, beforeTotalLines,
+ rangesBeforeChange, changedRanges, rangesAfterChange);
+ }
+
+ private void doUpdateRanges(int beforeChangedLine1,
+ int beforeChangedLine2,
+ int linesShift, // before -> after
+ int beforeTotalLines,
+ @NotNull List<Range> rangesBefore,
+ @NotNull List<Range> changedRanges,
+ @NotNull List<Range> rangesAfter) {
+ try {
+ int vcsTotalLines = getLineCount(myVcsDocument);
+
+ Range lastRangeBefore = ContainerUtil.getLastItem(rangesBefore);
+ Range firstRangeAfter = ContainerUtil.getFirstItem(rangesAfter);
+
+ int afterChangedLine1 = beforeChangedLine1;
+ int afterChangedLine2 = beforeChangedLine2 + linesShift;
+
+ int vcsLine1 = getVcsLine1(lastRangeBefore, beforeChangedLine1);
+ int vcsLine2 = getVcsLine2(firstRangeAfter, beforeChangedLine2, beforeTotalLines, vcsTotalLines);
+
+ List<Range> newChangedRanges = getNewChangedRanges(afterChangedLine1, afterChangedLine2, vcsLine1, vcsLine2);
+
+ shiftRanges(rangesAfter, linesShift);
+
+ if (!changedRanges.equals(newChangedRanges)) {
+ replaceRanges(changedRanges, newChangedRanges);
+
+ myRanges = new ArrayList<Range>(rangesBefore.size() + newChangedRanges.size() + rangesAfter.size());
+
+ myRanges.addAll(rangesBefore);
+ myRanges.addAll(newChangedRanges);
+ myRanges.addAll(rangesAfter);
+
+ for (Range range : myRanges) {
+ if (!range.hasHighlighter()) range.setHighlighter(createHighlighter(range));
}
- catch (FilesTooBigForDiffException e1) {
- installAnathema();
- removeHighlightersFromMarkupModel();
+
+ if (myRanges.isEmpty() && myVirtualFile != null) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ FileDocumentManager.getInstance().saveDocument(myDocument);
+ boolean stillEmpty;
+ synchronized (myLock) {
+ stillEmpty = myRanges.isEmpty();
+ }
+ if (stillEmpty) {
+ // file was modified, and now it's not -> dirty local change
+ myVcsDirtyScopeManager.fileDirty(myVirtualFile);
+ }
+ }
+ });
}
}
}
+ catch (ProcessCanceledException ignore) {
+ }
+ catch (FilesTooBigForDiffException e1) {
+ installAnathema();
+ removeHighlightersFromMarkupModel();
+ }
+ }
- private int getUpToDateLine1(@Nullable Range range, int line) {
- return range == null ? line : line + range.getUOffset2() - range.getOffset2();
+ private static int getVcsLine1(@Nullable Range range, int line) {
+ return range == null ? line : line + range.getVcsLine2() - range.getLine2();
+ }
+
+ private static int getVcsLine2(@Nullable Range range, int line, int totalLinesBefore, int totalLinesAfter) {
+ return range == null ? totalLinesAfter - totalLinesBefore + line : line + range.getVcsLine1() - range.getLine1();
+ }
+
+ private List<Range> getNewChangedRanges(int changedLine1, int changedLine2, int vcsLine1, int vcsLine2)
+ throws FilesTooBigForDiffException {
+
+ if (changedLine1 == changedLine2 && vcsLine1 == vcsLine2) {
+ return Collections.emptyList();
+ }
+ if (changedLine1 == changedLine2) {
+ return Collections.singletonList(new Range(changedLine1, changedLine2, vcsLine1, vcsLine2, Range.DELETED));
}
+ if (vcsLine1 == vcsLine2) {
+ return Collections.singletonList(new Range(changedLine1, changedLine2, vcsLine1, vcsLine2, Range.INSERTED));
+ }
+
+ List<String> lines = new DocumentWrapper(myDocument).getLines(changedLine1, changedLine2 - 1);
+ List<String> vcsLines = new DocumentWrapper(myVcsDocument).getLines(vcsLine1, vcsLine2 - 1);
- private int getUpToDateLine2(@Nullable Range range, int line, int totalLinesBefore, int totalLinesAfter) {
- return range == null ? totalLinesAfter - totalLinesBefore + line : line + range.getUOffset1() - range.getOffset1();
+ return new RangesBuilder(lines, vcsLines, changedLine1, vcsLine1).getRanges();
+ }
+
+ private void replaceRanges(@NotNull List<Range> rangesInChange, @NotNull List<Range> newRangesInChange) {
+ for (Range range : rangesInChange) {
+ if (range.getHighlighter() != null) {
+ range.getHighlighter().dispose();
+ }
+ range.setHighlighter(null);
+ range.invalidate();
}
+ for (Range range : newRangesInChange) {
+ range.setHighlighter(createHighlighter(range));
+ }
+ }
- private List<Range> getNewChangedRanges(int firstChangedLine, int lastChangedLine, int upToDateFirstLine, int upToDateLastLine)
- throws FilesTooBigForDiffException {
- List<String> lines = new DocumentWrapper(myDocument).getLines(firstChangedLine, lastChangedLine);
- List<String> uLines = new DocumentWrapper(myUpToDateDocument).getLines(upToDateFirstLine, upToDateLastLine);
- return new RangesBuilder(lines, uLines, firstChangedLine, upToDateFirstLine).getRanges();
+ private static void shiftRanges(@NotNull List<Range> rangesAfterChange, int shift) {
+ for (final Range range : rangesAfterChange) {
+ range.shift(shift);
}
+ }
- private void replaceRanges(@NotNull List<Range> rangesInChange, @NotNull List<Range> newRangesInChange) {
- for (Range range : rangesInChange) {
- if (range.getHighlighter() != null) {
- range.getHighlighter().dispose();
+ private void sortRanges(int beforeChangedLine1,
+ int beforeChangedLine2,
+ int linesShift,
+ @NotNull List<Range> rangesBeforeChange,
+ @NotNull List<Range> changedRanges,
+ @NotNull List<Range> rangesAfterChange) {
+ if (!Registry.is("diff.status.tracker.skip.spaces")) {
+ for (Range range : myRanges) {
+ if (range.getLine2() < beforeChangedLine1) {
+ rangesBeforeChange.add(range);
+ }
+ else if (range.getLine1() > beforeChangedLine2) {
+ rangesAfterChange.add(range);
+ }
+ else {
+ changedRanges.add(range);
}
- range.setHighlighter(null);
- range.invalidate();
- }
- for (Range range : newRangesInChange) {
- range.setHighlighter(createHighlighter(range));
}
}
+ else {
+ int lastBefore = -1;
+ int firstAfter = myRanges.size();
+ for (int i = 0; i < myRanges.size(); i++) {
+ Range range = myRanges.get(i);
- private void shiftRanges(@NotNull List<Range> rangesAfterChange, int shift) {
- for (final Range aRangesAfterChange : rangesAfterChange) {
- aRangesAfterChange.shift(shift);
+ if (range.getLine2() < beforeChangedLine1) {
+ lastBefore = i;
+ }
+ else if (range.getLine1() > beforeChangedLine2) {
+ firstAfter = i;
+ break;
+ }
}
- }
- }
- public static void sortRanges(@NotNull List<Range> ranges,
- int firstChangedLine,
- int lastChangedLine,
- @NotNull List<Range> rangesBeforeChange,
- @NotNull List<Range> changedRanges,
- @NotNull List<Range> rangesAfterChange) {
- for (Range range : ranges) {
- int offset1 = range.getOffset1() - 1;
- int offset2 = range.getOffset2();
- if (offset2 < firstChangedLine) {
- rangesBeforeChange.add(range);
+ // Expand on ranges, that are separated from changes only by empty/whitespaces lines
+ // This is needed to reduce amount of confusing cases, when changed blocks are matched wrong due to matched empty lines between them
+ CharSequence sequence = myDocument.getCharsSequence();
+
+ while (true) {
+ if (lastBefore == -1) break;
+
+ if (lastBefore < myRanges.size() - 1 && firstAfter - lastBefore > 1) {
+ Range firstChangedRange = myRanges.get(lastBefore + 1);
+ if (firstChangedRange.getLine1() < beforeChangedLine1) {
+ beforeChangedLine1 = firstChangedRange.getLine1();
+ }
+ }
+
+ if (beforeChangedLine1 >= getLineCount(myDocument)) break;
+ int offset1 = myDocument.getLineStartOffset(beforeChangedLine1) - 2;
+
+ int deltaLines = 0;
+ while (offset1 > 0) {
+ char c = sequence.charAt(offset1);
+ if (!StringUtil.isWhiteSpace(c)) break;
+ if (c == '\n') deltaLines++;
+ offset1--;
+ }
+
+ if (deltaLines == 0) break;
+ beforeChangedLine1 -= deltaLines;
+
+ if (myRanges.get(lastBefore).getLine2() < beforeChangedLine1) break;
+ while (lastBefore != -1 && myRanges.get(lastBefore).getLine2() >= beforeChangedLine1) {
+ lastBefore--;
+ }
}
- else if (offset1 > lastChangedLine) {
- rangesAfterChange.add(range);
+
+ while (true) {
+ if (firstAfter == myRanges.size()) break;
+
+ if (firstAfter > 0 && firstAfter - lastBefore > 1) {
+ Range lastChangedRange = myRanges.get(firstAfter - 1);
+ if (lastChangedRange.getLine2() > beforeChangedLine2) {
+ beforeChangedLine2 = lastChangedRange.getLine2();
+ }
+ }
+
+ if (beforeChangedLine2 + linesShift < 1) break;
+ int offset2 = myDocument.getLineEndOffset(beforeChangedLine2 + linesShift - 1) + 1;
+
+ int deltaLines = 0;
+ while (offset2 < sequence.length()) {
+ char c = sequence.charAt(offset2);
+ if (!StringUtil.isWhiteSpace(c)) break;
+ if (c == '\n') deltaLines++;
+ offset2++;
+ }
+
+ if (deltaLines == 0) break;
+ beforeChangedLine2 += deltaLines;
+
+ if (myRanges.get(firstAfter).getLine1() > beforeChangedLine2) break;
+ while (firstAfter != myRanges.size() && myRanges.get(firstAfter).getLine1() <= beforeChangedLine2) {
+ firstAfter++;
+ }
}
- else {
- changedRanges.add(range);
+
+
+ for (int i = 0; i < myRanges.size(); i++) {
+ Range range = myRanges.get(i);
+ if (i <= lastBefore) {
+ rangesBeforeChange.add(range);
+ }
+ else if (i >= firstAfter) {
+ rangesAfterChange.add(range);
+ }
+ else {
+ changedRanges.add(range);
+ }
}
}
}
@@ -496,7 +672,7 @@ public class LineStatusTracker {
}
for (final Range range : myRanges) {
- if (line > range.getOffset1() || line > range.getOffset2()) {
+ if (line > range.getLine1() || line > range.getLine2()) {
continue;
}
return range;
@@ -515,7 +691,7 @@ public class LineStatusTracker {
for (ListIterator<Range> iterator = myRanges.listIterator(myRanges.size()); iterator.hasPrevious(); ) {
final Range range = iterator.previous();
- if (range.getOffset1() > line) {
+ if (range.getLine1() > line) {
continue;
}
return range;
@@ -528,10 +704,10 @@ public class LineStatusTracker {
public Range getRangeForLine(final int line) {
synchronized (myLock) {
for (final Range range : myRanges) {
- if (range.getType() == Range.DELETED && line == range.getOffset1()) {
+ if (range.getType() == Range.DELETED && line == range.getLine1()) {
return range;
}
- else if (line >= range.getOffset1() && line < range.getOffset2()) {
+ else if (line >= range.getLine1() && line < range.getLine2()) {
return range;
}
}
@@ -539,172 +715,127 @@ public class LineStatusTracker {
}
}
- public void rollbackChanges(@NotNull Range range) {
- myApplication.assertWriteAccessAllowed();
+ private void doRollbackRange(@NotNull Range range) {
+ if (range.getType() == Range.MODIFIED) {
+ TextRange currentTextRange = getCurrentTextRange(range);
+ int offset1 = currentTextRange.getStartOffset();
+ int offset2 = currentTextRange.getEndOffset();
- synchronized (myLock) {
- if (!range.isValid()) {
- LOG.warn("Rollback of invalid range");
- return;
- }
-
- if (range.getType() == Range.MODIFIED) {
- TextRange currentTextRange = getCurrentTextRange(range);
- int offset1 = currentTextRange.getStartOffset();
- int offset2 = currentTextRange.getEndOffset();
+ CharSequence vcsContent = getVcsContent(range);
+ myDocument.replaceString(offset1, offset2, vcsContent);
+ }
+ else if (range.getType() == Range.INSERTED) {
+ TextRange currentTextRange = getCurrentTextRange(range);
+ int offset1 = currentTextRange.getStartOffset();
+ int offset2 = currentTextRange.getEndOffset();
- CharSequence upToDateContent = getUpToDateContent(range);
- myDocument.replaceString(offset1, offset2, upToDateContent);
+ if (offset1 > 0) {
+ offset1--;
}
- else if (range.getType() == Range.INSERTED) {
- TextRange currentTextRange = getCurrentTextRange(range);
- int offset1 = currentTextRange.getStartOffset();
- int offset2 = currentTextRange.getEndOffset();
-
- if (offset1 > 0) {
- offset1--;
- }
- else if (offset2 < myDocument.getTextLength()) {
- offset2++;
- }
- myDocument.deleteString(offset1, offset2);
+ else if (offset2 < myDocument.getTextLength()) {
+ offset2++;
}
- else if (range.getType() == Range.DELETED) {
- CharSequence content = getUpToDateContent(range);
- if (range.getOffset2() == getLineCount(myDocument)) {
- myDocument.insertString(myDocument.getTextLength(), "\n" + content);
- }
- else {
- myDocument.insertString(myDocument.getLineStartOffset(range.getOffset2()), content + "\n");
- }
+ myDocument.deleteString(offset1, offset2);
+ }
+ else if (range.getType() == Range.DELETED) {
+ CharSequence content = getVcsContent(range);
+ if (range.getLine2() == getLineCount(myDocument)) {
+ myDocument.insertString(myDocument.getTextLength(), "\n" + content);
}
else {
- throw new IllegalArgumentException("Unknown range type: " + range.getType());
+ myDocument.insertString(myDocument.getLineStartOffset(range.getLine2()), content + "\n");
}
}
+ else {
+ throw new IllegalArgumentException("Unknown range type: " + range.getType());
+ }
}
- public void rollbackChanges(@NotNull SegmentTree lines) {
+ public void rollbackChanges(@NotNull Range range) {
myApplication.assertWriteAccessAllowed();
synchronized (myLock) {
- List<Range> affectedRanges = new ArrayList<Range>();
+ if (myBulkUpdate) return;
- boolean wasEnd = false;
- boolean simple = true;
- for (Range range : myRanges) {
- if (!range.isValid()) {
- LOG.warn("Rollback of invalid range");
- return;
- }
-
- boolean check;
- if (range.getOffset1() == range.getOffset2()) {
- check = lines.check(range.getOffset1());
- }
- else {
- check = lines.check(range.getOffset1(), range.getOffset2());
- }
- if (check) {
- if (wasEnd) simple = false;
- affectedRanges.add(range);
- }
- else {
- if (!affectedRanges.isEmpty()) wasEnd = true;
- }
+ if (!range.isValid()) {
+ LOG.warn("Rollback of invalid range");
+ return;
}
- if (simple) {
- rollbackChangesSimple(affectedRanges);
- }
- else {
- rollbackChangesComplex(affectedRanges);
- }
+ doRollbackRange(range);
}
}
- private void rollbackChangesSimple(@NotNull List<Range> ranges) {
- if (ranges.isEmpty()) return;
-
- Range first = ranges.get(0);
- Range last = ranges.get(ranges.size() - 1);
+ public void rollbackChanges(@NotNull BitSet lines) {
+ myApplication.assertWriteAccessAllowed();
- byte type = first == last ? first.getType() : Range.MODIFIED;
- final Range merged = new Range(first.getOffset1(), last.getOffset2(), first.getUOffset1(), last.getUOffset2(), type);
+ synchronized (myLock) {
+ if (myBulkUpdate) return;
- // We don't expect complex Insertion/Deletion operation - they shouldn't exist
- assert type != Range.MODIFIED || (first.getOffset1() != last.getOffset2() && first.getUOffset1() != last.getUOffset2());
+ try {
+ mySuppressUpdate = true;
- rollbackChanges(merged);
- }
+ Range first = null;
+ Range last = null;
- private void rollbackChangesComplex(@NotNull List<Range> ranges) {
- // We can't relay on assumption, that revert of a single change will not affect any other.
- // This, among the others, is because of 'magic' ranges for revert, that will affect nearby lines implicitly.
- // So it's dangerous to apply ranges ony-by-one and we have to create single atomic modification.
- // Usage of Bulk mode will lead to full rebuild of tracker, and therefore will be slow..
+ int shift = 0;
+ for (Range range : myRanges) {
+ if (!range.isValid()) {
+ LOG.warn("Rollback of invalid range");
+ break;
+ }
- if (ranges.isEmpty()) return;
- if (ranges.size() == 1) {
- rollbackChanges(ranges.get(0));
- return;
- }
+ boolean check;
+ if (range.getLine1() == range.getLine2()) {
+ check = lines.get(range.getLine1());
+ }
+ else {
+ int next = lines.nextSetBit(range.getLine1());
+ check = next != -1 && next < range.getLine2();
+ }
- Range first = ranges.get(0);
- Range last = ranges.get(ranges.size() - 1);
+ if (check) {
+ if (first == null) {
+ first = range;
+ }
+ last = range;
- // We don't expect complex Insertion/Deletion operation - they shouldn't exist.
- assert first != last && first.getOffset1() != last.getOffset2() && first.getUOffset1() != last.getUOffset2();
+ Range shiftedRange = new Range(range);
+ shiftedRange.shift(shift);
- final int start = getCurrentTextRange(first).getStartOffset();
- final int end = getCurrentTextRange(last).getEndOffset();
+ doRollbackRange(shiftedRange);
- StringBuilder builder = new StringBuilder();
+ shift += (range.getVcsLine2() - range.getVcsLine1()) - (range.getLine2() - range.getLine1());
+ }
+ }
- int lastOffset = start;
- for (Range range : ranges) {
- TextRange textRange = getCurrentTextRange(range);
+ if (first != null) {
+ int beforeChangedLine1 = first.getLine1();
+ int beforeChangedLine2 = last.getLine2();
- builder.append(myDocument.getText(new TextRange(lastOffset, textRange.getStartOffset())));
- lastOffset = textRange.getEndOffset();
+ int beforeTotalLines = getLineCount(myDocument) - shift;
- if (range.getType() == Range.MODIFIED) {
- builder.append(getUpToDateContent(range));
- }
- else if (range.getType() == Range.INSERTED) {
- if (builder.length() > 0) {
- builder.deleteCharAt(builder.length() - 1);
- }
- else {
- lastOffset++;
+ doUpdateRanges(beforeChangedLine1, beforeChangedLine2, shift, beforeTotalLines);
}
}
- else if (range.getType() == Range.DELETED) {
- CharSequence content = getUpToDateContent(range);
- if (range.getOffset2() == getLineCount(myDocument)) {
- builder.append('\n').append(content);
- }
- else {
- builder.append(content).append('\n');
- }
+ catch (Throwable e) {
+ reinstallRanges();
+ if (e instanceof Error) throw ((Error)e);
+ if (e instanceof RuntimeException) throw ((RuntimeException)e);
+ throw new RuntimeException(e);
}
- else {
- throw new IllegalArgumentException("Unknown range type: " + range.getType());
+ finally {
+ mySuppressUpdate = false;
}
}
- builder.append(myDocument.getText(new TextRange(lastOffset, end)));
-
- final String s = builder.toString();
-
- myDocument.replaceString(start, end, s);
}
- public CharSequence getUpToDateContent(@NotNull Range range) {
+ public CharSequence getVcsContent(@NotNull Range range) {
synchronized (myLock) {
- TextRange textRange = getUpToDateRange(range);
+ TextRange textRange = getVcsRange(range);
final int startOffset = textRange.getStartOffset();
final int endOffset = textRange.getEndOffset();
- return myUpToDateDocument.getCharsSequence().subSequence(startOffset, endOffset);
+ return myVcsDocument.getCharsSequence().subSequence(startOffset, endOffset);
}
}
@@ -715,18 +846,18 @@ public class LineStatusTracker {
LOG.warn("Current TextRange of invalid range");
}
- return getRange(range.getOffset1(), range.getOffset2(), myDocument);
+ return getRange(range.getLine1(), range.getLine2(), myDocument);
}
}
@NotNull
- TextRange getUpToDateRange(@NotNull Range range) {
+ TextRange getVcsRange(@NotNull Range range) {
synchronized (myLock) {
if (!range.isValid()) {
- LOG.warn("UpToDate TextRange of invalid range");
+ LOG.warn("Vcs TextRange of invalid range");
}
- return getRange(range.getUOffset1(), range.getUOffset2(), myUpToDateDocument);
+ return getRange(range.getVcsLine1(), range.getVcsLine2(), myVcsDocument);
}
}
@@ -737,14 +868,14 @@ public class LineStatusTracker {
* So we consider '\n' not as a part of line, but a separator between lines
*/
@NotNull
- private static TextRange getRange(int offset1, int offset2, @NotNull Document document) {
- if (offset1 == offset2) {
- int lineStartOffset = offset1 < getLineCount(document) ? document.getLineStartOffset(offset1) : document.getTextLength();
+ private static TextRange getRange(int line1, int line2, @NotNull Document document) {
+ if (line1 == line2) {
+ int lineStartOffset = line1 < getLineCount(document) ? document.getLineStartOffset(line1) : document.getTextLength();
return new TextRange(lineStartOffset, lineStartOffset);
}
else {
- int startOffset = document.getLineStartOffset(offset1);
- int endOffset = document.getLineEndOffset(offset2 - 1);
+ int startOffset = document.getLineStartOffset(line1);
+ int endOffset = document.getLineEndOffset(line2 - 1);
return new TextRange(startOffset, endOffset);
}
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java
index d332d1faa792..2230f9c4ff59 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java
@@ -208,13 +208,13 @@ public class LineStatusTrackerDrawing {
component.add(toolbarPanel, BorderLayout.NORTH);
if (range.getType() != Range.INSERTED) {
- final DocumentEx doc = (DocumentEx) tracker.getUpToDateDocument();
+ final DocumentEx doc = (DocumentEx) tracker.getVcsDocument();
final EditorEx uEditor = (EditorEx)EditorFactory.getInstance().createViewer(doc, tracker.getProject());
final EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(tracker.getProject(), getFileName(tracker.getDocument()));
uEditor.setHighlighter(highlighter);
final EditorFragmentComponent editorFragmentComponent =
- EditorFragmentComponent.createEditorFragmentComponent(uEditor, range.getUOffset1(), range.getUOffset2(), false, false);
+ EditorFragmentComponent.createEditorFragmentComponent(uEditor, range.getVcsLine1(), range.getVcsLine2(), false, false);
component.add(editorFragmentComponent, BorderLayout.CENTER);
@@ -252,7 +252,7 @@ public class LineStatusTrackerDrawing {
public static void moveToRange(final Range range, final Editor editor, final LineStatusTracker tracker) {
final Document document = tracker.getDocument();
- final int lastOffset = document.getLineStartOffset(Math.min(range.getOffset2(), document.getLineCount() - 1));
+ final int lastOffset = document.getLineStartOffset(Math.min(range.getLine2(), document.getLineCount() - 1));
editor.getCaretModel().moveToOffset(lastOffset);
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/Range.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/Range.java
index e166acd30fec..e788b1849ce3 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/Range.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/Range.java
@@ -31,29 +31,28 @@ public class Range {
public static final byte INSERTED = 2;
public static final byte DELETED = 3;
- // offset1/offset2 - line numbers
// (2,3) - modified 2nd line
// (2,2) - empty range between 1 and 2 lines
// index of first line is 0
- private int myOffset1;
- private int myOffset2;
- private final int myUpToDateOffset1;
- private final int myUpToDateOffset2;
+ private int myLine1;
+ private int myLine2;
+ private final int myVcsLine1;
+ private final int myVcsLine2;
private final byte myType;
@Nullable private RangeHighlighter myRangeHighlighter;
private boolean myValid = true;
- public static Range createOn(@NotNull Diff.Change change, int shift, int upToDateShift) {
+ public static Range createOn(@NotNull Diff.Change change, int shift, int vcsShift) {
byte type = getChangeTypeFrom(change);
- int offset1 = shift + change.line1;
- int offset2 = offset1 + change.inserted;
+ int line1 = shift + change.line1;
+ int line2 = line1 + change.inserted;
- int uOffset1 = upToDateShift + change.line0;
- int uOffset2 = uOffset1 + change.deleted;
+ int vcsLine1 = vcsShift + change.line0;
+ int vcsLine2 = vcsLine1 + change.deleted;
- return new Range(offset1, offset2, uOffset1, uOffset2, type);
+ return new Range(line1, line2, vcsLine1, vcsLine2, type);
}
private static byte getChangeTypeFrom(@NotNull Diff.Change change) {
@@ -64,31 +63,35 @@ public class Range {
return 0;
}
- public Range(int offset1, int offset2, int uOffset1, int uOffset2, byte type) {
- myOffset1 = offset1;
- myOffset2 = offset2;
- myUpToDateOffset1 = uOffset1;
- myUpToDateOffset2 = uOffset2;
+ public Range(@NotNull Range range) {
+ this(range.getLine1(), range.getLine2(), range.getVcsLine1(), range.getVcsLine2(), range.getType());
+ }
+
+ public Range(int line1, int line2, int vcsLine1, int vcsLine2, byte type) {
+ myLine1 = line1;
+ myLine2 = line2;
+ myVcsLine1 = vcsLine1;
+ myVcsLine2 = vcsLine2;
myType = type;
}
public int hashCode() {
- return myUpToDateOffset1 ^ myUpToDateOffset2 ^ myType ^ myOffset1 ^ myOffset2;
+ return myVcsLine1 ^ myVcsLine2 ^ myType ^ myLine1 ^ myLine2;
}
public boolean equals(Object object) {
if (!(object instanceof Range)) return false;
Range other = (Range)object;
return
- (myUpToDateOffset1 == other.myUpToDateOffset1)
- && (myUpToDateOffset2 == other.myUpToDateOffset2)
- && (myOffset1 == other.myOffset1)
- && (myOffset2 == other.myOffset2)
+ (myVcsLine1 == other.myVcsLine1)
+ && (myVcsLine2 == other.myVcsLine2)
+ && (myLine1 == other.myLine1)
+ && (myLine2 == other.myLine2)
&& (myType == other.myType);
}
public String toString() {
- return String.format("%s, %s, %s, %s, %s", myOffset1, myOffset2, myUpToDateOffset1, myUpToDateOffset2, getTypeName());
+ return String.format("%s, %s, %s, %s, %s", myLine1, myLine2, myVcsLine1, myVcsLine2, getTypeName());
}
@NonNls
@@ -109,43 +112,32 @@ public class Range {
}
public int getUpToDateRangeLength() {
- return myUpToDateOffset2 - myUpToDateOffset1;
+ return myVcsLine2 - myVcsLine1;
}
public void shift(int shift) {
- myOffset1 += shift;
- myOffset2 += shift;
- }
-
- public int getOffset1() {
- return myOffset1;
- }
-
- public int getOffset2() {
- return myOffset2;
+ myLine1 += shift;
+ myLine2 += shift;
}
- public int getUOffset1() {
- return myUpToDateOffset1;
+ public int getLine1() {
+ return myLine1;
}
- public int getUOffset2() {
- return myUpToDateOffset2;
+ public int getLine2() {
+ return myLine2;
}
- public boolean canBeMergedWith(@NotNull Range range) {
- return myOffset2 == range.myOffset1;
+ public int getVcsLine1() {
+ return myVcsLine1;
}
- @NotNull
- public Range mergeWith(@NotNull Range range) {
- return new Range(myOffset1, range.myOffset2, myUpToDateOffset1, range.myUpToDateOffset2, mergedStatusWith(range));
+ public int getVcsLine2() {
+ return myVcsLine2;
}
- private byte mergedStatusWith(@NotNull Range range) {
- byte type = myType;
- if (myType != range.myType) type = MODIFIED;
- return type;
+ public boolean rightBefore(@NotNull Range range) {
+ return myLine2 == range.myLine1;
}
public boolean hasHighlighter() {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RangesBuilder.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RangesBuilder.java
index 74f9e43d08ad..509a9168de42 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RangesBuilder.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RangesBuilder.java
@@ -31,17 +31,17 @@ import java.util.List;
public class RangesBuilder {
private List<Range> myRanges;
- public RangesBuilder(@NotNull Document current, @NotNull Document upToDate) throws FilesTooBigForDiffException {
- this(new DocumentWrapper(current).getLines(), new DocumentWrapper(upToDate).getLines(), 0, 0);
+ public RangesBuilder(@NotNull Document current, @NotNull Document vcs) throws FilesTooBigForDiffException {
+ this(new DocumentWrapper(current).getLines(), new DocumentWrapper(vcs).getLines(), 0, 0);
}
- public RangesBuilder(@NotNull List<String> current, @NotNull List<String> upToDate, int shift, int uShift) throws FilesTooBigForDiffException {
+ public RangesBuilder(@NotNull List<String> current, @NotNull List<String> vcs, int shift, int vcsShift) throws FilesTooBigForDiffException {
myRanges = new LinkedList<Range>();
- Diff.Change ch = Diff.buildChanges(ArrayUtil.toStringArray(upToDate), ArrayUtil.toStringArray(current));
+ Diff.Change ch = Diff.buildChanges(ArrayUtil.toStringArray(vcs), ArrayUtil.toStringArray(current));
while (ch != null) {
- Range range = Range.createOn(ch, shift, uShift);
+ Range range = Range.createOn(ch, shift, vcsShift);
myRanges.add(range);
ch = ch.link;
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java
index 6e08d90a3b5d..1286b6815fcf 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java
@@ -29,68 +29,60 @@ import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.util.BitSet;
import java.util.List;
public class RollbackLineStatusAction extends DumbAwareAction {
- public RollbackLineStatusAction() {
- super(ActionsBundle.actionText("Vcs.RollbackChangedLines"),
- ActionsBundle.actionDescription("Vcs.RollbackChangedLines"),
- AllIcons.Actions.Reset);
- }
-
@Override
public void update(AnActionEvent e) {
Project project = e.getProject();
- if (project == null) {
- e.getPresentation().setEnabled(false);
- return;
- }
- Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
- if (editor == null) {
- e.getPresentation().setEnabled(false);
+ Editor editor = e.getData(CommonDataKeys.EDITOR);
+ if (project == null || editor == null) {
+ e.getPresentation().setEnabledAndVisible(false);
return;
}
LineStatusTracker tracker = LineStatusTrackerManager.getInstance(project).getLineStatusTracker(editor.getDocument());
if (tracker == null) {
- e.getPresentation().setEnabled(false);
+ e.getPresentation().setEnabledAndVisible(false);
return;
}
- e.getPresentation().setEnabled(true);
+ e.getPresentation().setEnabledAndVisible(true);
}
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
- Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
+ Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
LineStatusTracker tracker = LineStatusTrackerManager.getInstance(project).getLineStatusTracker(editor.getDocument());
- if (tracker == null) return;
+ assert tracker != null;
rollback(tracker, editor, null);
}
protected static void rollback(@NotNull LineStatusTracker tracker, @Nullable Editor editor, @Nullable Range range) {
+ assert editor != null || range != null;
+
if (range != null) {
doRollback(tracker, range);
return;
}
- if (editor == null) return;
Document document = editor.getDocument();
int totalLines = getLineCount(document);
- SegmentTree lines = new SegmentTree(totalLines + 1);
+ BitSet lines = new BitSet(totalLines + 1);
List<Caret> carets = editor.getCaretModel().getAllCarets();
for (Caret caret : carets) {
if (caret.hasSelection()) {
int line1 = editor.offsetToLogicalPosition(caret.getSelectionStart()).line;
int line2 = editor.offsetToLogicalPosition(caret.getSelectionEnd()).line;
- lines.mark(line1, line2 + 1);
- if (caret.getSelectionEnd() == document.getTextLength()) lines.mark(totalLines);
+ lines.set(line1, line2 + 1);
+ if (caret.getSelectionEnd() == document.getTextLength()) lines.set(totalLines);
}
else {
- lines.mark(caret.getLogicalPosition().line);
- if (caret.getOffset() == document.getTextLength()) lines.mark(totalLines);
+ lines.set(caret.getLogicalPosition().line);
+ if (caret.getOffset() == document.getTextLength()) lines.set(totalLines);
}
}
@@ -106,7 +98,7 @@ public class RollbackLineStatusAction extends DumbAwareAction {
});
}
- private static void doRollback(@NotNull final LineStatusTracker tracker, @NotNull final SegmentTree lines) {
+ private static void doRollback(@NotNull final LineStatusTracker tracker, @NotNull final BitSet lines) {
execute(tracker, new Runnable() {
@Override
public void run() {
@@ -116,7 +108,6 @@ public class RollbackLineStatusAction extends DumbAwareAction {
}
private static void execute(@NotNull final LineStatusTracker tracker, @NotNull final Runnable task) {
- // TODO: is there possible data races?
CommandProcessor.getInstance().executeCommand(tracker.getProject(), new Runnable() {
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusRangeAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusRangeAction.java
index f1795b5efc3c..7f71900654b6 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusRangeAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusRangeAction.java
@@ -30,7 +30,7 @@ public class RollbackLineStatusRangeAction extends RollbackLineStatusAction {
@Override
public void update(AnActionEvent e) {
- e.getPresentation().setEnabled(true);
+ e.getPresentation().setEnabledAndVisible(true);
}
public void actionPerformed(final AnActionEvent e) {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/SegmentTree.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/SegmentTree.java
deleted file mode 100644
index 68307129c13e..000000000000
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/SegmentTree.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package com.intellij.openapi.vcs.ex;
-
-import org.jetbrains.annotations.Nullable;
-
-public class SegmentTree {
- private final int myActualLength;
- private final int myLength;
-
- private final Node myRoot;
-
- public SegmentTree(int length) {
- myActualLength = length;
- myLength = toUpperSquare(length);
- myRoot = new Node();
- }
-
- public void mark(int pos) {
- mark(pos, pos + 1);
- }
-
- public void mark(int start, int end) {
- start = correct(0, myActualLength, start);
- end = correct(0, myActualLength, end);
-
- myRoot.mark(0, myLength, start, end);
- }
-
- public boolean check(int pos) {
- return check(pos, pos + 1);
- }
-
- public boolean check(int start, int end) {
- start = correct(0, myActualLength, start);
- end = correct(0, myActualLength, end);
-
- return myRoot.check(0, myLength, start, end);
- }
-
- private static int toUpperSquare(int value) {
- int high = Integer.highestOneBit(value);
- return high == value ? value : high * 2;
- }
-
- private static class Node {
- @Nullable
- public Node myLeft;
-
- @Nullable
- public Node myRight;
-
- public boolean myMarked;
-
- public boolean mark(int thisStart, int thisEnd, int start, int end) {
- if (myLeft == null && myMarked) return true;
-
- if (start == end) return false;
-
- myMarked = true;
-
- if (thisStart == start && thisEnd == end) {
- myLeft = null;
- myRight = null;
- return true;
- }
-
- if (myLeft == null) {
- myLeft = new Node();
- myRight = new Node();
- }
-
- int mid = thisStart + (thisEnd - thisStart) / 2;
- int start1 = correct(thisStart, mid, start);
- int end1 = correct(thisStart, mid, end);
- int start2 = correct(mid, thisEnd, start);
- int end2 = correct(mid, thisEnd, end);
-
- boolean marked = true;
- marked &= myLeft.mark(thisStart, mid, start1, end1);
- marked &= myRight.mark(mid, thisEnd, start2, end2);
-
- if (marked) {
- myLeft = null;
- myRight = null;
- }
-
- return marked;
- }
-
- public boolean check(int thisStart, int thisEnd, int start, int end) {
- if (start == end) return false;
-
- if (thisStart == start && thisEnd == end) {
- return myMarked;
- }
-
- if (myLeft == null) return myMarked;
-
- int mid = thisStart + (thisEnd - thisStart) / 2;
- int start1 = correct(thisStart, mid, start);
- int end1 = correct(thisStart, mid, end);
- int start2 = correct(mid, thisEnd, start);
- int end2 = correct(mid, thisEnd, end);
-
- if (myLeft.check(thisStart, mid, start1, end1)) return true;
- if (myRight.check(mid, thisEnd, start2, end2)) return true;
-
- return false;
- }
- }
-
- private static int correct(int start, int end, int value) {
- if (value < start) return start;
- if (value > end) return end;
- return value;
- }
-}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java
index 38f65446a56f..23ea7e341edb 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java
@@ -49,10 +49,10 @@ public class ShowLineStatusRangeDiffAction extends BaseLineStatusRangeAction {
return new DiffRequest(myLineStatusTracker.getProject()) {
@NotNull
public DiffContent[] getContents() {
- Range range = expand(myRange, myLineStatusTracker.getDocument(), myLineStatusTracker.getUpToDateDocument());
+ Range range = expand(myRange, myLineStatusTracker.getDocument(), myLineStatusTracker.getVcsDocument());
return new DiffContent[]{
- createDiffContent(myLineStatusTracker.getUpToDateDocument(),
- myLineStatusTracker.getUpToDateRange(range),
+ createDiffContent(myLineStatusTracker.getVcsDocument(),
+ myLineStatusTracker.getVcsRange(range),
null),
createDiffContent(myLineStatusTracker.getDocument(),
myLineStatusTracker.getCurrentTextRange(range),
@@ -81,12 +81,12 @@ public class ShowLineStatusRangeDiffAction extends BaseLineStatusRangeAction {
private static Range expand(@NotNull Range range, @NotNull Document document, @NotNull Document uDocument) {
if (range.getType() == Range.MODIFIED) return range;
if (range.getType() == Range.INSERTED || range.getType() == Range.DELETED) {
- boolean canExpandBefore = range.getOffset1() != 0 && range.getUOffset1() != 0;
- boolean canExpandAfter = range.getOffset2() < document.getLineCount() && range.getUOffset2() < uDocument.getLineCount();
- int offset1 = range.getOffset1() - (canExpandBefore ? 1 : 0);
- int uOffset1 = range.getUOffset1() - (canExpandBefore ? 1 : 0);
- int offset2 = range.getOffset2() + (canExpandAfter ? 1 : 0);
- int uOffset2 = range.getUOffset2() + (canExpandAfter ? 1 : 0);
+ boolean canExpandBefore = range.getLine1() != 0 && range.getVcsLine1() != 0;
+ boolean canExpandAfter = range.getLine2() < document.getLineCount() && range.getVcsLine2() < uDocument.getLineCount();
+ int offset1 = range.getLine1() - (canExpandBefore ? 1 : 0);
+ int uOffset1 = range.getVcsLine1() - (canExpandBefore ? 1 : 0);
+ int offset2 = range.getLine2() + (canExpandAfter ? 1 : 0);
+ int uOffset2 = range.getVcsLine2() + (canExpandAfter ? 1 : 0);
return new Range(offset1, offset2, uOffset1, uOffset2, range.getType());
}
throw new IllegalArgumentException("Unknown range type: " + range.getType());
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java
index 4b057f49b282..615b0fc35e9e 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleDefaultVcsRootPolicy.java
@@ -28,6 +28,7 @@ import com.intellij.openapi.roots.FileIndexFacade;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.DirtBuilder;
import com.intellij.openapi.vcs.changes.FilePathUnderVcs;
@@ -116,7 +117,7 @@ public class ModuleDefaultVcsRootPolicy extends DefaultVcsRootPolicy {
.isValidAncestor(myBaseDir, file)) {
return myBaseDir;
}
- final VirtualFile contentRoot = ProjectRootManager.getInstance(myProject).getFileIndex().getContentRootForFile(file);
+ final VirtualFile contentRoot = ProjectRootManager.getInstance(myProject).getFileIndex().getContentRootForFile(file, Registry.is("ide.hide.excluded.files"));
if (contentRoot != null) {
return contentRoot;
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleVcsPathPresenter.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleVcsPathPresenter.java
index 5c2adcbccd8d..1e1cbdf55f5f 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleVcsPathPresenter.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ModuleVcsPathPresenter.java
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vcs.changes.patch.RelativePathCalculator;
@@ -48,10 +49,10 @@ public class ModuleVcsPathPresenter extends VcsPathPresenter {
return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
- ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject)
- .getFileIndex();
- Module module = fileIndex.getModuleForFile(file);
- VirtualFile contentRoot = fileIndex.getContentRootForFile(file);
+ ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
+ boolean hideExcludedFiles = Registry.is("ide.hide.excluded.files");
+ Module module = fileIndex.getModuleForFile(file, hideExcludedFiles);
+ VirtualFile contentRoot = fileIndex.getContentRootForFile(file, hideExcludedFiles);
if (module == null || contentRoot == null) return file.getPresentableUrl();
StringBuffer result = new StringBuffer();
result.append("[");
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
index e699383321ae..84ca76e1d89f 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/ProjectLevelVcsManagerImpl.java
@@ -661,7 +661,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
@Override
@NotNull
- public VirtualFile[] getRootsUnderVcs(AbstractVcs vcs) {
+ public VirtualFile[] getRootsUnderVcs(@NotNull AbstractVcs vcs) {
return myMappingsToRoots.getRootsUnderVcs(vcs);
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/UpToDateLineNumberProviderImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/UpToDateLineNumberProviderImpl.java
index 795652f0b773..5d049f3e9c14 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/UpToDateLineNumberProviderImpl.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/UpToDateLineNumberProviderImpl.java
@@ -54,15 +54,15 @@ public class UpToDateLineNumberProviderImpl implements UpToDateLineNumberProvide
if (lineInRange(range, start) || lineInRange(range, end)) {
return true;
}
- if (range.getOffset1() > start) {
- return range.getOffset1() < end;
+ if (range.getLine1() > start) {
+ return range.getLine1() < end;
}
}
return false;
}
private static boolean lineInRange(final Range range, final int currentNumber) {
- return range.getOffset1() <= currentNumber && range.getOffset2() >= currentNumber;
+ return range.getLine1() <= currentNumber && range.getLine2() >= currentNumber;
}
@Override
@@ -72,7 +72,7 @@ public class UpToDateLineNumberProviderImpl implements UpToDateLineNumberProvide
return false;
}
for (Range range : tracker.getRanges()) {
- if (range.getOffset1() <= currentNumber && range.getOffset2() >= currentNumber) {
+ if (range.getLine1() <= currentNumber && range.getLine2() >= currentNumber) {
return true;
}
}
@@ -111,8 +111,8 @@ public class UpToDateLineNumberProviderImpl implements UpToDateLineNumberProvide
for (final Object range1 : ranges) {
Range range = (Range)range1;
- int startOffset = range.getOffset1();
- int endOffset = range.getOffset2();
+ int startOffset = range.getLine1();
+ int endOffset = range.getLine2();
if ((startOffset <= currentNumber) && (endOffset > currentNumber)) {
return ABSENT_LINE_NUMBER;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java
index 677c26e6d9f1..1be3cbf0cda3 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/MappingsToRoots.java
@@ -42,7 +42,7 @@ public class MappingsToRoots {
}
@NotNull
- public VirtualFile[] getRootsUnderVcs(final AbstractVcs vcs) {
+ public VirtualFile[] getRootsUnderVcs(@NotNull AbstractVcs vcs) {
List<VirtualFile> result = myMappings.getMappingsAsFilesUnderVcs(vcs);
final AbstractVcs.RootsConvertor convertor = vcs.getCustomConvertor();
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java
index 5ff541ebc67d..57754f0190cc 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/NewMappings.java
@@ -273,7 +273,7 @@ public class NewMappings {
return FileUtil.startsWith(systemIndependentPath, mapping.systemIndependentPath());
}
- public List<VirtualFile> getMappingsAsFilesUnderVcs(final AbstractVcs vcs) {
+ public List<VirtualFile> getMappingsAsFilesUnderVcs(@NotNull AbstractVcs vcs) {
final List<VirtualFile> result = new ArrayList<VirtualFile>();
final String vcsName = vcs.getName();
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java
index d2c7b556b88e..5fa282c06e14 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java
@@ -38,7 +38,6 @@ import com.intellij.openapi.vcs.changes.RemoteRevisionsCache;
import com.intellij.openapi.vcs.changes.VcsAnnotationRefresher;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManagerImpl;
-import com.intellij.openapi.vcs.changes.committed.CommittedChangesAdapter;
import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache;
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
@@ -46,6 +45,7 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
+import com.intellij.util.Consumer;
import com.intellij.util.WaitForProgressToShow;
import com.intellij.util.ui.OptionsDialog;
import com.intellij.vcsUtil.VcsUtil;
@@ -550,10 +550,14 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
}
}
else if (! myUpdatedFiles.isEmpty()) {
- showUpdateTree(continueChainFinal && updateSuccess && noMerged, someSessionWasCancelled);
-
+ final UpdateInfoTree tree = showUpdateTree(continueChainFinal && updateSuccess && noMerged, someSessionWasCancelled);
final CommittedChangesCache cache = CommittedChangesCache.getInstance(myProject);
- cache.processUpdatedFiles(myUpdatedFiles);
+ cache.processUpdatedFiles(myUpdatedFiles, new Consumer<List<CommittedChangeList>>() {
+ @Override
+ public void consume(List<CommittedChangeList> incomingChangeLists) {
+ tree.setChangeLists(incomingChangeLists);
+ }
+ });
if (someSessionWasCancelled) {
VcsBalloonProblemNotifier.showOverChangesView(myProject, "VCS Update Incomplete" + prepareNotificationWithUpdateInfo(), MessageType.WARNING);
@@ -592,7 +596,8 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
}
}
- private void showUpdateTree(final boolean willBeContinued, final boolean wasCanceled) {
+ @NotNull
+ private UpdateInfoTree showUpdateTree(final boolean willBeContinued, final boolean wasCanceled) {
RestoreUpdateTree restoreUpdateTree = RestoreUpdateTree.getInstance(myProject);
restoreUpdateTree.registerUpdateInformation(myUpdatedFiles, myActionInfo);
final String text = getTemplatePresentation().getText() + ((willBeContinued || (myUpdateNumber > 1)) ? ("#" + myUpdateNumber) : "");
@@ -602,13 +607,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
updateInfoTree.setAfter(myAfter);
updateInfoTree.setCanGroupByChangeList(canGroupByChangelist(myVcsToVirtualFiles.keySet()));
- myProject.getMessageBus().connect(updateInfoTree).subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() {
- public void incomingChangesUpdated(final List<CommittedChangeList> receivedChanges) {
- if (receivedChanges != null) {
- updateInfoTree.setChangeLists(receivedChanges);
- }
- }
- });
+ return updateInfoTree;
}
public void onCancel() {
diff --git a/platform/vcs-impl/src/com/intellij/vcsUtil/AuthDialog.java b/platform/vcs-impl/src/com/intellij/vcsUtil/AuthDialog.java
index d3ed9a84de2c..5d6861e6f39b 100644
--- a/platform/vcs-impl/src/com/intellij/vcsUtil/AuthDialog.java
+++ b/platform/vcs-impl/src/com/intellij/vcsUtil/AuthDialog.java
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class AuthDialog extends DialogWrapper {
- private AuthenticationPanel authPanel;
+ private final AuthenticationPanel authPanel;
/**
* If password if prefilled, it is expected to continue remembering it.
@@ -54,6 +54,7 @@ public class AuthDialog extends DialogWrapper {
return rememberByDefault;
}
+ @Override
protected JComponent createCenterPanel() {
return authPanel;
}
diff --git a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogSettings.java b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogSettings.java
index a370379b4d77..f382e23cf480 100644
--- a/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogSettings.java
+++ b/platform/vcs-log/api/src/com/intellij/vcs/log/VcsLogSettings.java
@@ -1,10 +1,24 @@
+/*
+ * Copyright 2000-2014 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.vcs.log;
-import com.intellij.openapi.components.StoragePathMacros;
/**
* <p>Vcs Log user settings, which may have a UI representation, or be implicitly selected based on user actions.</p>
- * <p>Most of the settings are workspace-specific, i. e. they are stored in {@link StoragePathMacros#WORKSPACE_FILE workspace.xml}.</p>
+ * <p>Most of the settings are workspace-specific, i. e. they are stored in {@link com.intellij.openapi.components.StoragePathMacros#WORKSPACE_FILE workspace.xml}.</p>
*
* @author Kirill Likhodedov
*/
diff --git a/platform/vcs-log/api/vcs-log-api.iml b/platform/vcs-log/api/vcs-log-api.iml
index bdbe62ba331d..92d746615afa 100644
--- a/platform/vcs-log/api/vcs-log-api.iml
+++ b/platform/vcs-log/api/vcs-log-api.iml
@@ -10,8 +10,9 @@
<orderEntry type="module" module-name="util-rt" />
<orderEntry type="module" module-name="vcs-log-graph-api" exported="" />
<orderEntry type="module" module-name="core-api" />
- <orderEntry type="module" module-name="vcs-api" />
<orderEntry type="library" name="JUnit4" level="project" />
+ <orderEntry type="module" module-name="vcs-api-core" />
+ <orderEntry type="module" module-name="editor-ui-api" />
</component>
</module>
diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java
index be71aac98d1e..33fa877064db 100644
--- a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java
+++ b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java
@@ -21,6 +21,7 @@ import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunnerLayoutUi;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
@@ -45,6 +46,7 @@ import javax.swing.event.HyperlinkListener;
* @author nik
*/
public interface XDebugSession extends AbstractDebuggerSession {
+ DataKey<XDebugSession> DATA_KEY = DataKey.create("XDebugSessionTab.XDebugSession");
@NotNull
Project getProject();
diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java
index 08a30664f7dc..cb65b84af9d9 100644
--- a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java
+++ b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerManager.java
@@ -58,16 +58,24 @@ public abstract class XDebuggerManager {
public abstract XDebugSession getCurrentSession();
/**
- * Start a new debugging session. Use this method only if debugging is started by using standard 'Debug' action i.e. this methods is called
- * from {@link com.intellij.execution.runners.ProgramRunner#execute} method. Otherwise use {@link #startSessionAndShowTab} method
+ * @deprecated use {@link #startSession(com.intellij.execution.runners.ExecutionEnvironment, XDebugProcessStarter)} instead
+ * to remove in IDEA 15
*/
@NotNull
- public abstract XDebugSession startSession(@NotNull final ProgramRunner runner,
+ @Deprecated
+ public abstract XDebugSession startSession(@NotNull ProgramRunner runner,
@NotNull ExecutionEnvironment env,
@Nullable RunContentDescriptor contentToReuse,
@NotNull XDebugProcessStarter processStarter) throws ExecutionException;
/**
+ * Start a new debugging session. Use this method only if debugging is started by using standard 'Debug' action i.e. this methods is called
+ * from {@link com.intellij.execution.runners.ProgramRunner#execute} method. Otherwise use {@link #startSessionAndShowTab} method
+ */
+ @NotNull
+ public abstract XDebugSession startSession(@NotNull ExecutionEnvironment environment, @NotNull XDebugProcessStarter processStarter) throws ExecutionException;
+
+ /**
* Start a new debugging session and open 'Debug' tool window
* @param sessionName title of 'Debug' tool window
*/
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
index 762855510a1e..8ee2f1ee587a 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
@@ -25,7 +25,6 @@ import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
-import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.execution.ui.RunContentDescriptor;
@@ -108,10 +107,9 @@ public class XDebugSessionImpl implements XDebugSession {
private final EventDispatcher<XDebugSessionListener> myDispatcher = EventDispatcher.create(XDebugSessionListener.class);
private final Project myProject;
private final @Nullable ExecutionEnvironment myEnvironment;
- private final @Nullable ProgramRunner myRunner;
private boolean myStopped;
private boolean myPauseActionSupported;
- private boolean myShowTabOnSuspend;
+ private final AtomicBoolean myShowTabOnSuspend;
private final List<AnAction> myRestartActions = new SmartList<AnAction>();
private final List<AnAction> myExtraStopActions = new SmartList<AnAction>();
private final List<AnAction> myExtraActions = new SmartList<AnAction>();
@@ -121,23 +119,19 @@ public class XDebugSessionImpl implements XDebugSession {
private volatile boolean breakpointsInitialized;
private boolean autoInitBreakpoints = true;
- public XDebugSessionImpl(@NotNull ExecutionEnvironment environment,
- @Nullable ProgramRunner runner,
- @NotNull XDebuggerManagerImpl debuggerManager) {
- this(environment, runner, debuggerManager, environment.getRunProfile().getName(), environment.getRunProfile().getIcon(), false);
+ public XDebugSessionImpl(@NotNull ExecutionEnvironment environment, @NotNull XDebuggerManagerImpl debuggerManager) {
+ this(environment, debuggerManager, environment.getRunProfile().getName(), environment.getRunProfile().getIcon(), false);
}
public XDebugSessionImpl(@Nullable ExecutionEnvironment environment,
- @Nullable ProgramRunner runner,
@NotNull XDebuggerManagerImpl debuggerManager,
@NotNull String sessionName,
@Nullable Icon icon,
boolean showTabOnSuspend) {
myEnvironment = environment;
- myRunner = runner;
mySessionName = sessionName;
myDebuggerManager = debuggerManager;
- myShowTabOnSuspend = showTabOnSuspend;
+ myShowTabOnSuspend = new AtomicBoolean(showTabOnSuspend);
myProject = debuggerManager.getProject();
ValueLookupManager.getInstance(myProject).startListening();
myIcon = icon;
@@ -158,7 +152,7 @@ public class XDebugSessionImpl implements XDebugSession {
}
private void assertSessionTabInitialized() {
- if (myShowTabOnSuspend) {
+ if (myShowTabOnSuspend.get()) {
LOG.error("Debug tool window isn't shown yet because debug process isn't suspended");
}
else {
@@ -176,6 +170,7 @@ public class XDebugSessionImpl implements XDebugSession {
myPauseActionSupported = isSupported;
}
+ @NotNull
public List<AnAction> getRestartActions() {
return myRestartActions;
}
@@ -186,6 +181,7 @@ public class XDebugSessionImpl implements XDebugSession {
}
}
+ @NotNull
public List<AnAction> getExtraActions() {
return myExtraActions;
}
@@ -208,7 +204,7 @@ public class XDebugSessionImpl implements XDebugSession {
@Override
public void rebuildViews() {
- if (!myShowTabOnSuspend && mySessionTab != null) {
+ if (!myShowTabOnSuspend.get() && mySessionTab != null) {
mySessionTab.rebuildViews();
}
}
@@ -262,7 +258,7 @@ public class XDebugSessionImpl implements XDebugSession {
return myCurrentPosition;
}
- public XDebugSessionTab init(final XDebugProcess process, @NotNull final XDebugSessionData sessionData) {
+ public XDebugSessionTab init(@NotNull XDebugProcess process, @NotNull XDebugSessionData sessionData, @Nullable RunContentDescriptor contentToReuse) {
LOG.assertTrue(myDebugProcess == null);
myDebugProcess = process;
mySessionData = sessionData;
@@ -279,8 +275,8 @@ public class XDebugSessionImpl implements XDebugSession {
});
//todo[nik] make 'createConsole()' method return ConsoleView
myConsoleView = (ConsoleView)myDebugProcess.createConsole();
- if (!myShowTabOnSuspend) {
- initSessionTab();
+ if (!myShowTabOnSuspend.get()) {
+ initSessionTab(contentToReuse);
}
return mySessionTab;
@@ -316,11 +312,12 @@ public class XDebugSessionImpl implements XDebugSession {
@Override
public RunnerLayoutUi getUI() {
assertSessionTabInitialized();
+ assert mySessionTab != null;
return mySessionTab.getUi();
}
- private void initSessionTab() {
- mySessionTab = new XDebugSessionTab(myProject, this, myIcon, myEnvironment, myRunner);
+ private void initSessionTab(@Nullable RunContentDescriptor contentToReuse) {
+ mySessionTab = XDebugSessionTab.create(this, myIcon, myEnvironment, contentToReuse);
myDebugProcess.sessionInitialized();
}
@@ -536,12 +533,12 @@ public class XDebugSessionImpl implements XDebugSession {
private void doResume() {
if (!myPaused.getAndSet(false)) return;
- final XSourcePosition oldPosition = myCurrentPosition;
myDispatcher.getMulticaster().beforeSessionResume();
myDebuggerManager.setActiveSession(this, null, false, null);
mySuspendContext = null;
myCurrentExecutionStack = null;
myCurrentStackFrame = null;
+ adjustMouseTrackingCounter(myCurrentPosition, -1);
myCurrentPosition = null;
myActiveNonLineBreakpoint = null;
UIUtil.invokeLaterIfNeeded(new Runnable() {
@@ -550,9 +547,6 @@ public class XDebugSessionImpl implements XDebugSession {
if (mySessionTab != null) {
mySessionTab.getUi().clearAttractionBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
}
- if (oldPosition != null) {
- adjustMouseTrackingCounter(oldPosition, -1);
- }
}
});
myDispatcher.getMulticaster().sessionResumed();
@@ -794,32 +788,37 @@ public class XDebugSessionImpl implements XDebugSession {
if (myCurrentPosition != null) {
myDebuggerManager.setActiveSession(this, myCurrentPosition, false, getPositionIconRenderer(true));
}
- UIUtil.invokeLaterIfNeeded(new Runnable() {
- @Override
- public void run() {
- if (myShowTabOnSuspend) {
- myShowTabOnSuspend = false;
- initSessionTab();
+ adjustMouseTrackingCounter(myCurrentPosition, 1);
+
+ if (myShowTabOnSuspend.compareAndSet(true, false)) {
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ initSessionTab(null);
showSessionTab();
}
- if (myCurrentPosition != null) {
- adjustMouseTrackingCounter(myCurrentPosition, 1);
- }
- }
- });
+ });
+ }
+
myDispatcher.getMulticaster().sessionPaused();
}
- private void adjustMouseTrackingCounter(@NotNull XSourcePosition position, int increment) {
- if (ApplicationManager.getApplication().isUnitTestMode()) return;
+ private void adjustMouseTrackingCounter(final XSourcePosition position, final int increment) {
+ if (position == null || ApplicationManager.getApplication().isUnitTestMode()) return;
- Editor editor = XDebuggerUtilImpl.createEditor(new OpenFileDescriptor(myProject, position.getFile()));
- if (editor != null) {
- JComponent component = editor.getComponent();
- Object o = component.getClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING);
- Integer value = ((o instanceof Integer) ? (Integer)o : 0) + increment;
- component.putClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING, value > 0 ? value : null);
- }
+ // need to always invoke later to maintain order of increment/decrement
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Editor editor = XDebuggerUtilImpl.createEditor(new OpenFileDescriptor(myProject, position.getFile()));
+ if (editor != null) {
+ JComponent component = editor.getComponent();
+ Object o = component.getClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING);
+ Integer value = ((o instanceof Integer) ? (Integer)o : 0) + increment;
+ component.putClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING, value > 0 ? value : null);
+ }
+ }
+ });
}
@Override
@@ -851,6 +850,12 @@ public class XDebugSessionImpl implements XDebugSession {
if (!myProject.isDisposed()) {
myProject.getMessageBus().syncPublisher(XDebuggerManager.TOPIC).processStopped(myDebugProcess);
}
+
+ if (mySessionTab != null) {
+ mySessionTab.detachFromSession();
+ }
+
+ adjustMouseTrackingCounter(myCurrentPosition, -1);
myCurrentPosition = null;
myCurrentExecutionStack = null;
myCurrentStackFrame = null;
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java
index b974150d2c56..2e6f91d43924 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java
@@ -23,10 +23,8 @@ import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.execution.ui.ExecutionConsole;
-import com.intellij.execution.ui.RunContentDescriptor;
-import com.intellij.execution.ui.RunContentManagerImpl;
-import com.intellij.execution.ui.RunContentWithExecutorListener;
+import com.intellij.execution.runners.RunContentBuilder;
+import com.intellij.execution.ui.*;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.*;
@@ -119,11 +117,11 @@ public class XDebuggerManagerImpl extends XDebuggerManager
}
});
- messageBusConnection.subscribe(RunContentManagerImpl.RUN_CONTENT_TOPIC, new RunContentWithExecutorListener() {
+ messageBusConnection.subscribe(RunContentManager.TOPIC, new RunContentWithExecutorListener() {
@Override
- public void contentSelected(RunContentDescriptor descriptor, @NotNull Executor executor) {
- if (executor.equals(DefaultDebugExecutor.getDebugExecutorInstance())) {
- final XDebugSessionImpl session = mySessions.get(descriptor.getProcessHandler());
+ public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
+ if (descriptor != null && executor.equals(DefaultDebugExecutor.getDebugExecutorInstance())) {
+ XDebugSessionImpl session = mySessions.get(descriptor.getProcessHandler());
if (session != null) {
session.activateSession();
}
@@ -134,8 +132,8 @@ public class XDebuggerManagerImpl extends XDebuggerManager
}
@Override
- public void contentRemoved(RunContentDescriptor descriptor, @NotNull Executor executor) {
- if (executor.equals(DefaultDebugExecutor.getDebugExecutorInstance())) {
+ public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
+ if (descriptor != null && executor.equals(DefaultDebugExecutor.getDebugExecutorInstance())) {
mySessions.remove(descriptor.getProcessHandler());
mySessionData.remove(descriptor);
XDebugSessionTab tab = mySessionTabs.remove(descriptor);
@@ -169,11 +167,17 @@ public class XDebuggerManagerImpl extends XDebuggerManager
@Override
@NotNull
- public XDebugSession startSession(@NotNull final ProgramRunner runner,
- @NotNull final ExecutionEnvironment environment,
- @Nullable final RunContentDescriptor contentToReuse,
- @NotNull final XDebugProcessStarter processStarter) throws ExecutionException {
- return startSession(contentToReuse, processStarter, new XDebugSessionImpl(environment, runner, this));
+ public XDebugSession startSession(@NotNull ProgramRunner runner,
+ @NotNull ExecutionEnvironment environment,
+ @Nullable RunContentDescriptor contentToReuse,
+ @NotNull XDebugProcessStarter processStarter) throws ExecutionException {
+ return startSession(contentToReuse, processStarter, new XDebugSessionImpl(RunContentBuilder.fix(environment, runner), this));
+ }
+
+ @Override
+ @NotNull
+ public XDebugSession startSession(@NotNull ExecutionEnvironment environment, @NotNull XDebugProcessStarter processStarter) throws ExecutionException {
+ return startSession(environment.getContentToReuse(), processStarter, new XDebugSessionImpl(environment, this));
}
@Override
@@ -193,10 +197,12 @@ public class XDebuggerManagerImpl extends XDebuggerManager
@NotNull
@Override
- public XDebugSession startSessionAndShowTab(@NotNull String sessionName, final Icon icon, @Nullable RunContentDescriptor contentToReuse,
+ public XDebugSession startSessionAndShowTab(@NotNull String sessionName,
+ Icon icon,
+ @Nullable RunContentDescriptor contentToReuse,
boolean showToolWindowOnSuspendOnly,
@NotNull XDebugProcessStarter starter) throws ExecutionException {
- XDebugSessionImpl session = startSession(contentToReuse, starter, new XDebugSessionImpl(null, null, this, sessionName,
+ XDebugSessionImpl session = startSession(contentToReuse, starter, new XDebugSessionImpl(null, this, sessionName,
icon, showToolWindowOnSuspendOnly));
if (!showToolWindowOnSuspendOnly) {
session.showSessionTab();
@@ -206,8 +212,9 @@ public class XDebuggerManagerImpl extends XDebuggerManager
return session;
}
- private XDebugSessionImpl startSession(final RunContentDescriptor contentToReuse, final XDebugProcessStarter processStarter,
- final XDebugSessionImpl session) throws ExecutionException {
+ private XDebugSessionImpl startSession(@Nullable RunContentDescriptor contentToReuse,
+ @NotNull XDebugProcessStarter processStarter,
+ @NotNull XDebugSessionImpl session) throws ExecutionException {
XDebugProcess process = processStarter.start(session);
myProject.getMessageBus().syncPublisher(TOPIC).processStarted(process);
@@ -222,7 +229,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager
((XDebugProcessConfiguratorStarter)processStarter).configure(oldSessionData);
}
- session.init(process, oldSessionData);
+ session.init(process, oldSessionData, contentToReuse);
mySessions.put(session.getDebugProcess().getProcessHandler(), session);
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerWatchesManager.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerWatchesManager.java
index e803453eb662..4bcc6753925e 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerWatchesManager.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerWatchesManager.java
@@ -16,6 +16,7 @@
package com.intellij.xdebugger.impl;
import com.intellij.openapi.components.PersistentStateComponent;
+import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.annotations.AbstractCollection;
import com.intellij.util.xmlb.annotations.Attribute;
@@ -67,11 +68,13 @@ public class XDebuggerWatchesManager implements PersistentStateComponent<XDebugg
watches.clear();
if (state != null) {
for (ConfigurationState expressionState : state.expressions) {
- WatchState[] states = expressionState.myExpressionStates;
- XExpression[] expressions = new XExpression[states.length];
- for (int i = 0; i < states.length; i++) {
- expressions[i] = states[i].toXExpression();
- }
+ XExpression[] expressions = ContainerUtil.mapNotNull(expressionState.myExpressionStates,
+ new Function<WatchState, XExpression>() {
+ @Override
+ public XExpression fun(WatchState state) {
+ return state.toXExpression();
+ }
+ }, new XExpression[0]);
watches.put(expressionState.myName, expressions);
}
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java
index a9f15890bbea..6384629d19a8 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointAction.java
@@ -19,13 +19,13 @@ import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
+import com.intellij.openapi.project.DumbAware;
import com.intellij.xdebugger.impl.DebuggerSupport;
import org.jetbrains.annotations.NotNull;
-public class EditBreakpointAction extends XDebuggerActionBase {
+public class EditBreakpointAction extends XDebuggerActionBase implements DumbAware {
public static class ContextAction extends AnAction {
private final GutterIconRenderer myRenderer;
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionImpl.java
index b966377a47ba..d049356247b4 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionImpl.java
@@ -18,6 +18,7 @@ package com.intellij.xdebugger.impl.breakpoints;
import com.intellij.lang.Language;
import com.intellij.xdebugger.XExpression;
import com.intellij.xdebugger.evaluation.EvaluationMode;
+import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -65,12 +66,12 @@ public class XExpressionImpl implements XExpression {
return myMode;
}
- @Nullable
+ @Contract("null -> null; !null -> !null")
public static XExpressionImpl fromText(@Nullable String text) {
return text != null ? new XExpressionImpl(text, null, null, EvaluationMode.EXPRESSION) : null;
}
- @Nullable
+ @Contract("null, _ -> null; !null, _ -> !null")
public static XExpressionImpl fromText(@Nullable String text, EvaluationMode mode) {
return text != null ? new XExpressionImpl(text, null, null, mode) : null;
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionState.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionState.java
index 205cc2d9498d..65dc92e97ec1 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionState.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XExpressionState.java
@@ -16,10 +16,12 @@
package com.intellij.xdebugger.impl.breakpoints;
import com.intellij.lang.Language;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Text;
import com.intellij.xdebugger.XExpression;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* @author egor
@@ -65,8 +67,13 @@ public class XExpressionState {
}
}
+ @Nullable
public XExpression toXExpression() {
checkConverted();
+ // old versions may have empty expressions serialized
+ if (StringUtil.isEmptyOrSpaces(myExpression)) {
+ return null;
+ }
return new XExpressionImpl(myExpression, Language.findLanguageByID(myLanguage), myCustomInfo);
}
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java
new file mode 100644
index 000000000000..a3aa8ec43fc5
--- /dev/null
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2000-2014 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.evaluate;
+
+import com.intellij.openapi.editor.EditorLinePainter;
+import com.intellij.openapi.editor.LineExtensionInfo;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.registry.Registry;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.ui.JBColor;
+import com.intellij.ui.SimpleColoredText;
+import com.intellij.xdebugger.frame.presentation.XValuePresentation;
+import com.intellij.xdebugger.impl.frame.XVariablesView;
+import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
+import com.intellij.xdebugger.impl.ui.tree.nodes.XValueTextRendererImpl;
+import org.jetbrains.annotations.NotNull;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public class XDebuggerEditorLinePainter extends EditorLinePainter {
+ @Override
+ public Collection<LineExtensionInfo> getLineExtensions(@NotNull Project project, @NotNull VirtualFile file, int lineNumber) {
+ if (!Registry.is("ide.debugger.inline")) {
+ return null;
+ }
+
+ Map<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>> map = project.getUserData(XVariablesView.DEBUG_VARIABLES);
+ if (map != null) {
+ Set<XValueNodeImpl> values = map.get(Pair.create(file, lineNumber));
+ if (values != null && !values.isEmpty()) {
+ ArrayList<LineExtensionInfo> result = new ArrayList<LineExtensionInfo>();
+ for (XValueNodeImpl value : values) {
+ SimpleColoredText text = new SimpleColoredText();
+ XValueTextRendererImpl renderer = new XValueTextRendererImpl(text);
+ final XValuePresentation presentation = value.getValuePresentation();
+ if (presentation == null) continue;
+ if (presentation instanceof XValueCompactPresentation) {
+ ((XValueCompactPresentation)presentation).renderValue(renderer, value);
+ } else {
+ presentation.renderValue(renderer);
+ }
+ final Color color = new JBColor(new Color(61, 128, 101), new Color(61, 128, 101));
+ result.add(new LineExtensionInfo(" " + value.getName() + ": ", color, null, null, Font.PLAIN));
+ for (String s : text.getTexts()) {
+ result.add(new LineExtensionInfo(s, color, null, null, Font.PLAIN));
+ }
+ }
+ return result;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java
index bee9b3d91fd7..37da856156ea 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java
@@ -129,6 +129,7 @@ public class XDebuggerEvaluationDialog extends DialogWrapper {
evaluate();
}
+ @Override
protected void createDefaultActions() {
super.createDefaultActions();
myOKAction = new OkAction(){
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XValueCompactPresentation.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XValueCompactPresentation.java
new file mode 100644
index 000000000000..f34b5afe1154
--- /dev/null
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XValueCompactPresentation.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2014 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.evaluate;
+
+import com.intellij.xdebugger.frame.presentation.XValuePresentation;
+import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Konstantin Bulenkov
+ */
+public interface XValueCompactPresentation {
+ void renderValue(@NotNull XValuePresentation.XValueTextRenderer renderer, @Nullable XValueNodeImpl node);
+}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java
index 5a956450952a..7b860b49d255 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/AbstractValueHint.java
@@ -178,6 +178,9 @@ public abstract class AbstractValueHint {
}
protected boolean showHint(final JComponent component) {
+ if (myCurrentHint != null) {
+ myCurrentHint.hide();
+ }
myCurrentHint = new LightweightHint(component);
myCurrentHint.addHintListener(new HintListener() {
@Override
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/DebuggerFramesList.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/DebuggerFramesList.java
index 41dd52bcc3b9..18ef7cecd450 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/DebuggerFramesList.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/DebuggerFramesList.java
@@ -39,6 +39,7 @@ public abstract class DebuggerFramesList extends JBList implements OccurenceNavi
getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setCellRenderer(createListRenderer());
getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ @Override
public void valueChanged(final ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
onFrameChanged(getSelectedValue());
@@ -49,6 +50,7 @@ public abstract class DebuggerFramesList extends JBList implements OccurenceNavi
getEmptyText().setText(XDebuggerBundle.message("debugger.frames.not.available"));
}
+ @Override
public DefaultListModel getModel() {
return (DefaultListModel)super.getModel();
}
@@ -61,19 +63,23 @@ public abstract class DebuggerFramesList extends JBList implements OccurenceNavi
return getModel().getSize();
}
+ @Override
public String getNextOccurenceActionName() {
return XDebuggerBundle.message("action.next.frame.text");
}
+ @Override
public String getPreviousOccurenceActionName() {
return XDebuggerBundle.message("action.previous.frame.text");
}
+ @Override
public OccurenceInfo goNextOccurence() {
setSelectedIndex(getSelectedIndex() + 1);
return createInfo();
}
+ @Override
public OccurenceInfo goPreviousOccurence() {
setSelectedIndex(getSelectedIndex() - 1);
return createInfo();
@@ -83,10 +89,12 @@ public abstract class DebuggerFramesList extends JBList implements OccurenceNavi
return OccurenceInfo.position(getSelectedIndex(), getElementCount());
}
+ @Override
public boolean hasNextOccurence() {
return getSelectedIndex() < getElementCount() - 1;
}
+ @Override
public boolean hasPreviousOccurence() {
return getSelectedIndex() > 0;
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugView.java
index 85ff7b2c2357..0007ec2f9997 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugView.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugView.java
@@ -15,14 +15,66 @@
*/
package com.intellij.xdebugger.impl.frame;
+import com.intellij.execution.ui.layout.ViewContext;
+import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.ui.content.ContentManager;
+import com.intellij.util.SingleAlarm;
+import com.intellij.xdebugger.XDebugSession;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.awt.*;
+import java.util.EventObject;
/**
* @author nik
*/
-public interface XDebugView extends Disposable {
- enum SessionEvent {PAUSED, BEFORE_RESUME, RESUMED, STOPPED, FRAME_CHANGED, SETTINGS_CHANGED}
+public abstract class XDebugView implements Disposable {
+ public enum SessionEvent {PAUSED, BEFORE_RESUME, RESUMED, STOPPED, FRAME_CHANGED, SETTINGS_CHANGED}
+
+ private final SingleAlarm myClearAlarm;
+ private static final int VIEW_CLEAR_DELAY = 100; //ms
+
+ public XDebugView() {
+ myClearAlarm = new SingleAlarm(new Runnable() {
+ @Override
+ public void run() {
+ clear();
+ }
+ }, VIEW_CLEAR_DELAY, this);
+ }
+
+ protected final void requestClear() {
+ myClearAlarm.cancelAndRequest();
+ }
+
+ protected final void cancelClear() {
+ myClearAlarm.cancel();
+ }
+
+ protected abstract void clear();
+
+ public abstract void processSessionEvent(@NotNull SessionEvent event);
+
+ @Nullable
+ protected static XDebugSession getSession(@NotNull EventObject e) {
+ Component component = e.getSource() instanceof Component ? (Component)e.getSource() : null;
+ return component == null ? null : getSession(component);
+ }
- void processSessionEvent(@NotNull SessionEvent event);
+ @Nullable
+ public static XDebugSession getSession(@NotNull Component component) {
+ DataContext dataContext = DataManager.getInstance().getDataContext(component);
+ ViewContext viewContext = ViewContext.CONTEXT_KEY.getData(dataContext);
+ ContentManager contentManager = viewContext == null ? null : viewContext.getContentManager();
+ if (contentManager != null) {
+ XDebugSession session = XDebugSession.DATA_KEY.getData(DataManager.getInstance().getDataContext(contentManager.getComponent()));
+ if (session != null) {
+ return session;
+ }
+ }
+ return XDebugSession.DATA_KEY.getData(dataContext);
+ }
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugViewSessionListener.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugViewSessionListener.java
index d265005d3a34..d790113b1816 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugViewSessionListener.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebugViewSessionListener.java
@@ -15,8 +15,8 @@
*/
package com.intellij.xdebugger.impl.frame;
-import com.intellij.openapi.project.Project;
import com.intellij.ui.AppUIUtil;
+import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebugSessionAdapter;
import org.jetbrains.annotations.NotNull;
@@ -25,15 +25,15 @@ import org.jetbrains.annotations.NotNull;
*/
public class XDebugViewSessionListener extends XDebugSessionAdapter {
private final XDebugView myDebugView;
- private final Project myProject;
+ private final XDebugSession session;
- public XDebugViewSessionListener(@NotNull XDebugView debugView, @NotNull Project project) {
+ public XDebugViewSessionListener(@NotNull XDebugView debugView, @NotNull XDebugSession session) {
myDebugView = debugView;
- myProject = project;
+ this.session = session;
}
private void onSessionEvent(final @NotNull XDebugView.SessionEvent event) {
- AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
+ AppUIUtil.invokeLaterIfProjectAlive(session.getProject(), new Runnable() {
@Override
public void run() {
myDebugView.processSessionEvent(event);
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java
index f4b6c2caee8e..9b39ad63deb8 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XDebuggerFramesList.java
@@ -27,6 +27,7 @@ import com.intellij.util.ui.UIUtil;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.frame.XStackFrame;
+import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
@@ -84,7 +85,7 @@ public class XDebuggerFramesList extends DebuggerFramesList {
private XStackFrame mySelectedFrame;
- public XDebuggerFramesList(Project project) {
+ public XDebuggerFramesList(@NotNull Project project) {
super(project);
doInit();
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java
index b7c5f4bf9746..b98440b5d69f 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XFramesView.java
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.*;
@@ -29,6 +30,7 @@ import com.intellij.ui.border.CustomLineBorder;
import com.intellij.ui.components.panels.Wrapper;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashMap;
+import com.intellij.util.containers.TransferToEDTQueue;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.frame.XExecutionStack;
import com.intellij.xdebugger.frame.XStackFrame;
@@ -53,46 +55,47 @@ import java.util.List;
/**
* @author nik
*/
-public class XFramesView implements XDebugView {
+public class XFramesView extends XDebugView {
private final JPanel myMainPanel;
private final XDebuggerFramesList myFramesList;
private final ComboBox myThreadComboBox;
private final Set<XExecutionStack> myExecutionStacks = ContainerUtil.newHashSet();
- @NotNull private final XDebugSession mySession;
private XExecutionStack mySelectedStack;
private boolean myListenersEnabled;
private final Map<XExecutionStack, StackFramesListBuilder> myBuilders = new HashMap<XExecutionStack, StackFramesListBuilder>();
private final ActionToolbarImpl myToolbar;
private final Wrapper myThreadsPanel;
private boolean myThreadsCalculated = false;
+ private final TransferToEDTQueue<Runnable> myLaterInvocator = TransferToEDTQueue.createRunnableMerger("XFramesView later invocator", 50);
- public XFramesView(@NotNull final XDebugSession session) {
- mySession = session;
-
+ public XFramesView(@NotNull Project project) {
myMainPanel = new JPanel(new BorderLayout());
- myFramesList = new XDebuggerFramesList(session.getProject());
+ myFramesList = new XDebuggerFramesList(project);
myFramesList.addListSelectionListener(new ListSelectionListener() {
@Override
- public void valueChanged(final ListSelectionEvent e) {
- if (e.getValueIsAdjusting()) return;
- processFrameSelection();
+ public void valueChanged(ListSelectionEvent e) {
+ if (myListenersEnabled && !e.getValueIsAdjusting()) {
+ processFrameSelection(e);
+ }
}
});
myFramesList.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
- int i = myFramesList.locationToIndex(e.getPoint());
- if (i != -1 && myFramesList.isSelectedIndex(i)) {
- processFrameSelection();
+ if (myListenersEnabled) {
+ int i = myFramesList.locationToIndex(e.getPoint());
+ if (i != -1 && myFramesList.isSelectedIndex(i)) {
+ processFrameSelection(e);
+ }
}
}
});
- final ActionManager actionManager = ActionManager.getInstance();
myFramesList.addMouseListener(new PopupHandler() {
@Override
public void invokePopup(final Component comp, final int x, final int y) {
+ ActionManager actionManager = ActionManager.getInstance();
ActionGroup group = (ActionGroup)actionManager.getAction(XDebuggerActions.FRAMES_TREE_POPUP_GROUP);
actionManager.createActionPopupMenu(ActionPlaces.UNKNOWN, group).getComponent().show(comp, x, y);
}
@@ -103,13 +106,32 @@ public class XFramesView implements XDebugView {
myThreadComboBox = new ComboBox();
//noinspection unchecked
myThreadComboBox.setRenderer(new ThreadComboBoxRenderer(myThreadComboBox));
- myThreadComboBox.addItemListener(new MyItemListener());
+ myThreadComboBox.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(final ItemEvent e) {
+ if (!myListenersEnabled) {
+ return;
+ }
+
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ Object item = e.getItem();
+ if (item instanceof XExecutionStack) {
+ XDebugSession session = getSession(e);
+ if (session != null) {
+ updateFrames((XExecutionStack)item, session);
+ }
+ }
+ }
+ }
+ });
myThreadComboBox.addPopupMenuListener(new PopupMenuListenerAdapter() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
- XSuspendContext context = mySession.getSuspendContext();
+ XDebugSession session = getSession(e);
+ XSuspendContext context = session == null ? null : session.getSuspendContext();
if (context != null && !myThreadsCalculated) {
myThreadsCalculated = true;
+ //noinspection unchecked
myThreadComboBox.addItem(null); // rendered as "Loading..."
context.computeExecutionStacks(new XSuspendContext.XExecutionStackContainer() {
@Override
@@ -130,7 +152,6 @@ public class XFramesView implements XDebugView {
@Override
public void errorOccurred(@NotNull String errorMessage) {
-
}
});
}
@@ -145,12 +166,9 @@ public class XFramesView implements XDebugView {
myToolbar = createToolbar();
myThreadsPanel = new Wrapper();
- CustomLineBorder border = new CustomLineBorder(CaptionPanel.CNT_ACTIVE_BORDER_COLOR, 0, 0, 1, 0);
- myThreadsPanel.setBorder(border);
+ myThreadsPanel.setBorder(new CustomLineBorder(CaptionPanel.CNT_ACTIVE_BORDER_COLOR, 0, 0, 1, 0));
myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST);
myMainPanel.add(myThreadsPanel, BorderLayout.NORTH);
-
- processSessionEvent(SessionEvent.RESUMED);
}
private ActionToolbarImpl createToolbar() {
@@ -181,9 +199,14 @@ public class XFramesView implements XDebugView {
@Override
public void processSessionEvent(@NotNull final SessionEvent event) {
- if (event == SessionEvent.BEFORE_RESUME) return;
+ if (event == SessionEvent.BEFORE_RESUME) {
+ return;
+ }
+
+ XDebugSession session = getSession(getMainPanel());
+
if (event == SessionEvent.FRAME_CHANGED) {
- XStackFrame currentStackFrame = mySession.getCurrentStackFrame();
+ XStackFrame currentStackFrame = session == null ? null : session.getCurrentStackFrame();
if (currentStackFrame != null) {
myFramesList.setSelectedValue(currentStackFrame, true);
}
@@ -196,15 +219,16 @@ public class XFramesView implements XDebugView {
}
myBuilders.clear();
mySelectedStack = null;
- XSuspendContext suspendContext = mySession.getSuspendContext();
- if (suspendContext == null || event == SessionEvent.PAUSED) {
- myThreadComboBox.removeAllItems();
- myFramesList.clear();
- myThreadsCalculated = false;
- myExecutionStacks.clear();
- if (suspendContext == null) {
- return;
- }
+ XSuspendContext suspendContext = session == null ? null : session.getSuspendContext();
+ if (suspendContext == null) {
+ requestClear();
+ return;
+ }
+
+ if (event == SessionEvent.PAUSED) {
+ // clear immediately
+ cancelClear();
+ clear();
}
XExecutionStack[] executionStacks = suspendContext.getExecutionStacks();
@@ -219,10 +243,18 @@ public class XFramesView implements XDebugView {
myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER);
}
myToolbar.setAddSeparatorFirst(!invisible);
- updateFrames(activeExecutionStack);
+ updateFrames(activeExecutionStack, session);
myListenersEnabled = true;
}
+ @Override
+ protected void clear() {
+ myThreadComboBox.removeAllItems();
+ myFramesList.clear();
+ myThreadsCalculated = false;
+ myExecutionStacks.clear();
+ }
+
private void addExecutionStacks(List<? extends XExecutionStack> executionStacks) {
for (XExecutionStack executionStack : executionStacks) {
if (!myExecutionStacks.contains(executionStack)) {
@@ -233,7 +265,7 @@ public class XFramesView implements XDebugView {
}
}
- private void updateFrames(final XExecutionStack executionStack) {
+ private void updateFrames(final XExecutionStack executionStack, @NotNull XDebugSession session) {
if (mySelectedStack == executionStack) {
return;
}
@@ -249,7 +281,7 @@ public class XFramesView implements XDebugView {
XStackFrame topFrame = executionStack.getTopFrame();
if (topFrame != null) {
myFramesList.setSelectedValue(topFrame, true);
- onFrameSelected(executionStack, topFrame);
+ session.setCurrentStackFrame(executionStack, topFrame);
}
}
}
@@ -262,32 +294,16 @@ public class XFramesView implements XDebugView {
return myFramesList;
}
- private void onFrameSelected(XExecutionStack executionStack, final @NotNull XStackFrame stackFrame) {
- mySession.setCurrentStackFrame(executionStack, stackFrame);
- }
-
public JPanel getMainPanel() {
return myMainPanel;
}
- private void processFrameSelection() {
- if (!myListenersEnabled) return;
+ private void processFrameSelection(@NotNull EventObject e) {
Object selected = myFramesList.getSelectedValue();
if (selected instanceof XStackFrame) {
- onFrameSelected(mySelectedStack, (XStackFrame)selected);
- }
- }
-
- private class MyItemListener implements ItemListener {
- @Override
- public void itemStateChanged(final ItemEvent e) {
- if (!myListenersEnabled) return;
-
- if (e.getStateChange() == ItemEvent.SELECTED) {
- Object item = e.getItem();
- if (item instanceof XExecutionStack) {
- updateFrames((XExecutionStack)item);
- }
+ XDebugSession session = getSession(e);
+ if (session != null) {
+ session.setCurrentStackFrame(mySelectedStack, (XStackFrame)selected);
}
}
}
@@ -315,7 +331,7 @@ public class XFramesView implements XDebugView {
@Override
public void addStackFrames(@NotNull final List<? extends XStackFrame> stackFrames, final boolean last) {
- ApplicationManager.getApplication().invokeLater(new Runnable() {
+ myLaterInvocator.offer(new Runnable() {
@Override
public void run() {
myStackFrames.addAll(stackFrames);
@@ -331,7 +347,7 @@ public class XFramesView implements XDebugView {
@Override
public void errorOccurred(@NotNull final String errorMessage) {
- ApplicationManager.getApplication().invokeLater(new Runnable() {
+ myLaterInvocator.offer(new Runnable() {
@Override
public void run() {
if (myErrorMessage == null) {
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XStandaloneVariablesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XStandaloneVariablesView.java
index f7f32ba86b9c..f91146426878 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XStandaloneVariablesView.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XStandaloneVariablesView.java
@@ -42,4 +42,12 @@ public class XStandaloneVariablesView extends XVariablesViewBase {
}
});
}
+
+ @Override
+ public void processSessionEvent(@NotNull SessionEvent event) {
+ }
+
+ @Override
+ protected void clear() {
+ }
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java
index 31b30a8362e3..df43b1147419 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -15,30 +15,37 @@
*/
package com.intellij.xdebugger.impl.frame;
+import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.xdebugger.XDebugProcess;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.frame.XStackFrame;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
+import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import org.jetbrains.annotations.NotNull;
+import java.util.Map;
+import java.util.Set;
+
import static com.intellij.xdebugger.impl.ui.tree.nodes.MessageTreeNode.createInfoMessage;
/**
* @author nik
*/
-public class XVariablesView extends XVariablesViewBase implements XDebugView {
- @NotNull private final XDebugSession mySession;
+public class XVariablesView extends XVariablesViewBase {
+ public static final Key<Map<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>>> DEBUG_VARIABLES = Key.create("debug.frame");
- public XVariablesView(@NotNull XDebugSession session) {
- super(session.getProject(), session.getDebugProcess().getEditorsProvider(), ((XDebugSessionImpl)session).getValueMarkers());
- mySession = session;
+ public XVariablesView(@NotNull XDebugSessionImpl session) {
+ super(session.getProject(), session.getDebugProcess().getEditorsProvider(), session.getValueMarkers());
}
@Override
public void processSessionEvent(@NotNull final SessionEvent event) {
- XStackFrame stackFrame = mySession.getCurrentStackFrame();
+ XDebugSession session = getSession(getPanel());
+ XStackFrame stackFrame = session == null ? null : session.getCurrentStackFrame();
XDebuggerTree tree = getTree();
if (event == SessionEvent.BEFORE_RESUME || event == SessionEvent.SETTINGS_CHANGED) {
@@ -50,20 +57,29 @@ public class XVariablesView extends XVariablesViewBase implements XDebugView {
tree.markNodesObsolete();
if (stackFrame != null) {
+ cancelClear();
buildTreeAndRestoreState(stackFrame);
}
else {
- tree.setSourcePosition(null);
+ requestClear();
+ }
+ }
- XDebuggerTreeNode node;
- if (!mySession.isStopped() && mySession.isPaused()) {
- node = createInfoMessage(tree, "Frame is not available");
- }
- else {
- XDebugProcess debugProcess = mySession.getDebugProcess();
- node = createInfoMessage(tree, debugProcess.getCurrentStateMessage(), debugProcess.getCurrentStateHyperlinkListener());
- }
- tree.setRoot(node, true);
+ @Override
+ protected void clear() {
+ XDebuggerTree tree = getTree();
+ tree.getProject().putUserData(DEBUG_VARIABLES, null);
+ tree.setSourcePosition(null);
+
+ XDebuggerTreeNode node;
+ XDebugSession session = getSession(getPanel());
+ if (session == null || (!session.isStopped() && session.isPaused())) {
+ node = createInfoMessage(tree, "Frame is not available");
+ }
+ else {
+ XDebugProcess debugProcess = session.getDebugProcess();
+ node = createInfoMessage(tree, debugProcess.getCurrentStateMessage(), debugProcess.getCurrentStateHyperlinkListener());
}
+ tree.setRoot(node, true);
}
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java
index 33a1639ba5d7..ace9938318df 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -16,8 +16,9 @@
package com.intellij.xdebugger.impl.frame;
import com.intellij.ide.dnd.DnDManager;
-import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import com.intellij.xdebugger.frame.XStackFrame;
@@ -27,15 +28,18 @@ import com.intellij.xdebugger.impl.ui.tree.XDebuggerTreePanel;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTreeRestorer;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTreeState;
import com.intellij.xdebugger.impl.ui.tree.nodes.XStackFrameNode;
+import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import java.util.HashMap;
+import java.util.Set;
/**
* @author nik
*/
-public abstract class XVariablesViewBase implements Disposable {
+public abstract class XVariablesViewBase extends XDebugView {
protected final XDebuggerTreePanel myDebuggerTreePanel;
private XDebuggerTreeState myTreeState;
private Object myFrameEqualityObject;
@@ -51,6 +55,7 @@ public abstract class XVariablesViewBase implements Disposable {
XDebuggerTree tree = myDebuggerTreePanel.getTree();
tree.setSourcePosition(stackFrame.getSourcePosition());
tree.setRoot(new XStackFrameNode(tree, stackFrame), false);
+ tree.getProject().putUserData(XVariablesView.DEBUG_VARIABLES, new HashMap<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>>());
Object newEqualityObject = stackFrame.getEqualityObject();
if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject)
&& myTreeState != null) {
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java
index 6216c1312349..c510cd17c90a 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XWatchesViewImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -33,6 +33,7 @@ import com.intellij.ui.border.CustomLineBorder;
import com.intellij.util.Alarm;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
+import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.XExpression;
import com.intellij.xdebugger.frame.XStackFrame;
@@ -64,20 +65,18 @@ import java.util.List;
/**
* @author nik
*/
-public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugView {
+public class XWatchesViewImpl extends XDebugView implements DnDNativeTarget, XWatchesView {
private final XDebuggerTreePanel myTreePanel;
private XDebuggerTreeState myTreeState;
private XDebuggerTreeRestorer myTreeRestorer;
private final WatchesRootNode myRootNode;
- @NotNull private final XDebugSessionImpl mySession;
private final JPanel myDecoratedPanel;
private final CompositeDisposable myDisposables = new CompositeDisposable();
private boolean myRebuildNeeded;
- public XWatchesViewImpl(@NotNull final XDebugSessionImpl session) {
- mySession = session;
+ public XWatchesViewImpl(@NotNull XDebugSessionImpl session) {
myTreePanel = new XDebuggerTreePanel(session.getProject(), session.getDebugProcess().getEditorsProvider(), this, null,
- XDebuggerActions.WATCHES_TREE_POPUP_GROUP, ((XDebugSessionImpl)session).getValueMarkers());
+ XDebuggerActions.WATCHES_TREE_POPUP_GROUP, session.getValueMarkers());
ActionManager actionManager = ActionManager.getInstance();
@@ -89,7 +88,7 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
actionManager.getAction(XDebuggerActions.XEDIT_WATCH).registerCustomShortcutSet(f2Shortcut, tree);
DnDManager.getInstance().registerTarget(this, tree);
- myRootNode = new WatchesRootNode(tree, session, this, session.getSessionData().getWatchExpressions());
+ myRootNode = new WatchesRootNode(tree, this, session.getSessionData().getWatchExpressions());
tree.setRoot(myRootNode, false);
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTreePanel.getTree()).disableUpDownActions();
@@ -134,6 +133,7 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
DataContext context = DataManager.getInstance().getDataContext(watchTree);
final AnActionEvent actionEvent = new AnActionEvent(null, context, "WATCH_TREE", presentation, ActionManager.getInstance(), 0);
Runnable runnable = new Runnable() {
+ @Override
public void run() {
editWatchAction.actionPerformed(actionEvent);
}
@@ -161,12 +161,12 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
final FocusListener focusListener = new FocusListener() {
@Override
- public void focusGained(FocusEvent e) {
+ public void focusGained(@NotNull FocusEvent e) {
quitePeriod.addRequest(EmptyRunnable.getInstance(), UIUtil.getMultiClickInterval());
}
@Override
- public void focusLost(FocusEvent e) {
+ public void focusLost(@NotNull FocusEvent e) {
editAlarm.cancelAllRequests();
}
};
@@ -174,7 +174,7 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
final TreeSelectionListener selectionListener = new TreeSelectionListener() {
@Override
- public void valueChanged(TreeSelectionEvent e) {
+ public void valueChanged(@NotNull TreeSelectionEvent e) {
quitePeriod.addRequest(EmptyRunnable.getInstance(), UIUtil.getMultiClickInterval());
}
};
@@ -219,15 +219,20 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
@Override
public void addWatchExpression(@NotNull XExpression expression, int index, final boolean navigateToWatchNode) {
- myRootNode.addWatchExpression(mySession.getDebugProcess().getEvaluator(), expression, index, navigateToWatchNode);
+ XDebugSession session = getSession(getTree());
+ if (session == null) {
+ return;
+ }
+
+ myRootNode.addWatchExpression(session.getDebugProcess().getEvaluator(), expression, index, navigateToWatchNode);
updateSessionData();
if (navigateToWatchNode) {
- showWatchesTab();
+ showWatchesTab((XDebugSessionImpl)session);
}
}
- private void showWatchesTab() {
- XDebugSessionTab tab = mySession.getSessionTab();
+ private static void showWatchesTab(@NotNull XDebugSessionImpl session) {
+ XDebugSessionTab tab = session.getSessionTab();
if (tab != null) {
tab.toFront(false);
// restore watches tab if minimized
@@ -255,7 +260,6 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
return;
}
- XStackFrame stackFrame = mySession.getCurrentStackFrame();
XDebuggerTree tree = myTreePanel.getTree();
if (event == SessionEvent.BEFORE_RESUME || event == SessionEvent.SETTINGS_CHANGED) {
@@ -268,7 +272,10 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
}
}
+ XDebugSession session = getSession(getMainPanel());
+ XStackFrame stackFrame = session == null ? null : session.getCurrentStackFrame();
if (stackFrame != null) {
+ cancelClear();
tree.setSourcePosition(stackFrame.getSourcePosition());
myRootNode.updateWatches(stackFrame.getEvaluator());
if (myTreeState != null) {
@@ -276,11 +283,16 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
}
}
else {
- tree.setSourcePosition(null);
- myRootNode.updateWatches(null);
+ requestClear();
}
}
+ @Override
+ protected void clear() {
+ getTree().setSourcePosition(null);
+ myRootNode.updateWatches(null);
+ }
+
public XDebuggerTree getTree() {
return myTreePanel.getTree();
}
@@ -290,7 +302,7 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
}
@Override
- public void removeWatches(final List<? extends XDebuggerTreeNode> nodes) {
+ public void removeWatches(List<? extends XDebuggerTreeNode> nodes) {
List<? extends WatchNode> children = myRootNode.getAllChildren();
int minIndex = Integer.MAX_VALUE;
List<XDebuggerTreeNode> toRemove = new ArrayList<XDebuggerTreeNode>();
@@ -328,7 +340,11 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
watchExpressions.add(child.getExpression());
}
}
- mySession.setWatchExpressions(watchExpressions.toArray(new XExpression[watchExpressions.size()]));
+
+ XDebugSession session = getSession(getTree());
+ if (session != null) {
+ ((XDebugSessionImpl)session).setWatchExpressions(watchExpressions.toArray(new XExpression[watchExpressions.size()]));
+ }
}
@Override
@@ -348,13 +364,14 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
}
@Override
- public void drop(final DnDEvent aEvent) {
+ public void drop(DnDEvent aEvent) {
Object object = aEvent.getAttachedObject();
if (object instanceof XValueNodeImpl[]) {
final XValueNodeImpl[] nodes = (XValueNodeImpl[])object;
for (XValueNodeImpl node : nodes) {
String expression = node.getValueContainer().getEvaluationExpression();
if (expression != null) {
+ //noinspection ConstantConditions
addWatchExpression(XExpressionImpl.fromText(expression), -1, false);
}
}
@@ -362,6 +379,7 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
else if (object instanceof EventInfo) {
String text = ((EventInfo)object).getTextForFlavor(DataFlavor.stringFlavor);
if (text != null) {
+ //noinspection ConstantConditions
addWatchExpression(XExpressionImpl.fromText(text), -1, false);
}
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java
index f51ce77d3fee..79c8dc49c398 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.keymap.KeymapUtil;
+import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.components.labels.LinkLabel;
import com.intellij.ui.components.labels.LinkListener;
@@ -79,7 +80,7 @@ public class BreakpointEditor {
}
});
- final AnAction doneAction = new AnAction() {
+ final AnAction doneAction = new DumbAwareAction() {
@Override
public void update(AnActionEvent e) {
super.update(e);
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java
index 2134c0c8d4e1..053f18dd14bf 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerSessionTabBase.java
@@ -16,7 +16,8 @@
package com.intellij.xdebugger.impl.ui;
import com.intellij.debugger.ui.DebuggerContentInfo;
-import com.intellij.diagnostic.logging.*;
+import com.intellij.diagnostic.logging.AdditionalTabComponent;
+import com.intellij.diagnostic.logging.DebuggerLogConsoleManager;
import com.intellij.execution.ExecutionManager;
import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunProfile;
@@ -24,6 +25,7 @@ import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.RunContentBuilder;
+import com.intellij.execution.runners.RunTab;
import com.intellij.execution.ui.*;
import com.intellij.execution.ui.layout.LayoutAttractionPolicy;
import com.intellij.execution.ui.layout.LayoutViewOptions;
@@ -48,25 +50,13 @@ import java.util.Collection;
/**
* @author nik
*/
-public abstract class DebuggerSessionTabBase extends LogConsoleManagerBase implements DebuggerLogConsoleManager {
- @NotNull private final LogFilesManager myManager;
-
- @NotNull final String mySessionName;
- @NotNull protected final RunnerLayoutUi myUi;
-
+public abstract class DebuggerSessionTabBase extends RunTab implements DebuggerLogConsoleManager {
protected ExecutionConsole myConsole;
- protected RunContentDescriptor myRunContentDescriptor;
-
- public DebuggerSessionTabBase(@NotNull Project project, @NotNull String runnerId, @NotNull final String sessionName,
- @NotNull GlobalSearchScope searchScope) {
- super(project, searchScope);
- Disposer.register(project, this);
- myManager = new LogFilesManager(project, this, this);
- mySessionName = sessionName;
+ public DebuggerSessionTabBase(@NotNull Project project, @NotNull String runnerId, @NotNull String sessionName, @NotNull GlobalSearchScope searchScope) {
+ super(project, searchScope, runnerId, XDebuggerBundle.message("xdebugger.default.content.title"), sessionName);
- myUi = RunnerLayoutUi.Factory.getInstance(project).create(
- runnerId, XDebuggerBundle.message("xdebugger.default.content.title"), sessionName, this);
+ Disposer.register(project, this);
myUi.getDefaults()
.initTabDefaults(0, XDebuggerBundle.message("xdebugger.debugger.tab.title"), null)
@@ -104,23 +94,6 @@ public abstract class DebuggerSessionTabBase extends LogConsoleManagerBase imple
return myUi;
}
- protected void registerFileMatcher(final RunProfile runConfiguration) {
- if (runConfiguration instanceof RunConfigurationBase) {
- myManager.registerFileMatcher((RunConfigurationBase)runConfiguration);
- }
- }
-
- protected void initLogConsoles(final RunProfile runConfiguration, final ProcessHandler processHandler, ExecutionConsole console) {
- if (runConfiguration instanceof RunConfigurationBase) {
- myManager.initLogConsoles((RunConfigurationBase)runConfiguration, processHandler);
- OutputFileUtil.attachDumpListener((RunConfigurationBase)runConfiguration, processHandler, console);
- }
- }
-
- protected LogFilesManager getLogManager() {
- return myManager;
- }
-
protected void attachNotificationTo(final Content content) {
if (myConsole instanceof ObservableConsoleView) {
ObservableConsoleView observable = (ObservableConsoleView)myConsole;
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java
index 4b6bea217c54..4c3766f23f5d 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -17,11 +17,8 @@ package com.intellij.xdebugger.impl.ui;
import com.intellij.debugger.ui.DebuggerContentInfo;
import com.intellij.execution.Executor;
-import com.intellij.execution.configurations.RunProfile;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.runners.ExecutionEnvironment;
-import com.intellij.execution.runners.ProgramRunner;
-import com.intellij.execution.runners.RestartAction;
import com.intellij.execution.runners.RunContentBuilder;
import com.intellij.execution.ui.ExecutionConsole;
import com.intellij.execution.ui.RunContentDescriptor;
@@ -29,11 +26,11 @@ import com.intellij.execution.ui.actions.CloseAction;
import com.intellij.execution.ui.layout.PlaceInGrid;
import com.intellij.execution.ui.layout.impl.ViewImpl;
import com.intellij.icons.AllIcons;
+import com.intellij.ide.DataManager;
import com.intellij.ide.actions.ContextHelpAction;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.ui.AppUIUtil;
@@ -41,7 +38,7 @@ import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManagerAdapter;
import com.intellij.ui.content.ContentManagerEvent;
import com.intellij.ui.content.tabs.PinToolwindowTabAction;
-import com.intellij.xdebugger.XDebugProcess;
+import com.intellij.util.SystemProperties;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
@@ -57,29 +54,109 @@ import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
-/**
- * @author spleaner
- */
public class XDebugSessionTab extends DebuggerSessionTabBase {
+ private static final DataKey<XDebugSessionTab> TAB_KEY = DataKey.create("XDebugSessionTab");
+
private XWatchesViewImpl myWatchesView;
private final List<XDebugView> myViews = new ArrayList<XDebugView>();
- public XDebugSessionTab(@NotNull Project project,
- @NotNull XDebugSessionImpl session,
- @Nullable Icon icon,
- @Nullable ExecutionEnvironment environment,
- @Nullable ProgramRunner runner) {
- super(project, "Debug", session.getSessionName(), GlobalSearchScope.allScope(project));
+ @Nullable
+ private XDebugSessionImpl mySession;
+ private XDebugSessionData mySessionData;
+
+ @NotNull
+ public static XDebugSessionTab create(@NotNull XDebugSessionImpl session,
+ @Nullable Icon icon,
+ @Nullable ExecutionEnvironment environment,
+ @Nullable RunContentDescriptor contentToReuse) {
+ if (contentToReuse != null && SystemProperties.getBooleanProperty("xdebugger.reuse.session.tab", false)) {
+ JComponent component = contentToReuse.getComponent();
+ if (component != null) {
+ XDebugSessionTab oldTab = TAB_KEY.getData(DataManager.getInstance().getDataContext(component));
+ if (oldTab != null) {
+ oldTab.setSession(session, environment, icon);
+ oldTab.attachToSession(session);
+ return oldTab;
+ }
+ }
+ }
+ return new XDebugSessionTab(session, icon, environment);
+ }
+
+ private XDebugSessionTab(@NotNull XDebugSessionImpl session,
+ @Nullable Icon icon,
+ @Nullable ExecutionEnvironment environment) {
+ super(session.getProject(), "Debug", session.getSessionName(), GlobalSearchScope.allScope(session.getProject()));
+
+ setSession(session, environment, icon);
+
+ myUi.addContent(createFramesContent(), 0, PlaceInGrid.left, false);
+ myUi.addContent(createVariablesContent(session), 0, PlaceInGrid.center, false);
+ myUi.addContent(createWatchesContent(session), 0, PlaceInGrid.right, false);
+
+ for (XDebugView view : myViews) {
+ Disposer.register(this, view);
+ }
+
+ attachToSession(session);
+
+ DefaultActionGroup focus = new DefaultActionGroup();
+ focus.add(ActionManager.getInstance().getAction(XDebuggerActions.FOCUS_ON_BREAKPOINT));
+ myUi.getOptions().setAdditionalFocusActions(focus);
+
+ myUi.addListener(new ContentManagerAdapter() {
+ @Override
+ public void selectionChanged(ContentManagerEvent event) {
+ Content content = event.getContent();
+ XDebugSessionImpl session = mySession;
+ if (session != null && content.isSelected() && DebuggerContentInfo.WATCHES_CONTENT.equals(ViewImpl.ID.get(content))) {
+ if (myWatchesView.rebuildNeeded()) {
+ myWatchesView.processSessionEvent(XDebugView.SessionEvent.SETTINGS_CHANGED);
+ }
+ }
+ }
+ }, this);
+
+ rebuildViews();
+ }
+
+ private void setSession(@NotNull XDebugSessionImpl session, @Nullable ExecutionEnvironment environment, @Nullable Icon icon) {
if (environment != null) {
setEnvironment(environment);
}
+
+ mySession = session;
+ mySessionData = session.getSessionData();
myConsole = session.getConsoleView();
- XDebugProcess debugProcess = session.getDebugProcess();
- myRunContentDescriptor = new RunContentDescriptor(myConsole, debugProcess.getProcessHandler(), myUi.getComponent(), mySessionName, icon);
- attachToSession(session, runner, environment, session.getSessionData(), debugProcess);
+ myRunContentDescriptor = new RunContentDescriptor(myConsole, session.getDebugProcess().getProcessHandler(), myUi.getComponent(), session.getSessionName(), icon);
}
- private Content createVariablesContent(final XDebugSession session) {
+ @Nullable
+ @Override
+ public Object getData(@NonNls String dataId) {
+ if (XWatchesView.DATA_KEY.is(dataId)) {
+ return myWatchesView;
+ }
+ else if (TAB_KEY.is(dataId)) {
+ return this;
+ }
+ else if (XDebugSessionData.DATA_KEY.is(dataId)) {
+ return mySessionData;
+ }
+
+ if (mySession != null) {
+ if (XDebugSession.DATA_KEY.is(dataId)) {
+ return mySession;
+ }
+ else if (LangDataKeys.CONSOLE_VIEW.is(dataId)) {
+ return mySession.getConsoleView();
+ }
+ }
+
+ return super.getData(dataId);
+ }
+
+ private Content createVariablesContent(@NotNull XDebugSessionImpl session) {
final XVariablesView variablesView = new XVariablesView(session);
myViews.add(variablesView);
Content result = myUi.createContent(DebuggerContentInfo.VARIABLES_CONTENT, variablesView.getPanel(),
@@ -89,27 +166,25 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
ActionGroup group = getCustomizedActionGroup(XDebuggerActions.VARIABLES_TREE_TOOLBAR_GROUP);
result.setActions(group, ActionPlaces.DEBUGGER_TOOLBAR, variablesView.getTree());
-
return result;
}
- private Content createWatchesContent(final XDebugSessionImpl session, final XDebugSessionData sessionData) {
+ private Content createWatchesContent(@NotNull XDebugSessionImpl session) {
myWatchesView = new XWatchesViewImpl(session);
myViews.add(myWatchesView);
Content watchesContent = myUi.createContent(DebuggerContentInfo.WATCHES_CONTENT, myWatchesView.getMainPanel(),
- XDebuggerBundle.message("debugger.session.tab.watches.title"), AllIcons.Debugger.Watches, null);
+ XDebuggerBundle.message("debugger.session.tab.watches.title"), AllIcons.Debugger.Watches, null);
watchesContent.setCloseable(false);
-
return watchesContent;
}
- private Content createFramesContent(final XDebugSession session) {
- final XFramesView framesView = new XFramesView(session);
+ @NotNull
+ private Content createFramesContent() {
+ XFramesView framesView = new XFramesView(getProject());
myViews.add(framesView);
Content framesContent = myUi.createContent(DebuggerContentInfo.FRAME_CONTENT, framesView.getMainPanel(),
XDebuggerBundle.message("debugger.session.tab.frames.title"), AllIcons.Debugger.Frame, null);
framesContent.setCloseable(false);
-
return framesContent;
}
@@ -132,34 +207,12 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
return myWatchesView;
}
- private void attachToSession(final @NotNull XDebugSessionImpl session, final @Nullable ProgramRunner runner,
- final @Nullable ExecutionEnvironment environment, final @NotNull XDebugSessionData sessionData,
- final @NotNull XDebugProcess debugProcess) {
- myUi.addContent(createFramesContent(session), 0, PlaceInGrid.left, false);
- myUi.addContent(createVariablesContent(session), 0, PlaceInGrid.center, false);
- myUi.addContent(createWatchesContent(session, sessionData), 0, PlaceInGrid.right, false);
+ private void attachToSession(@NotNull XDebugSessionImpl session) {
for (XDebugView view : myViews) {
- Disposer.register(this, view);
- session.addSessionListener(new XDebugViewSessionListener(view, getProject()), this);
+ session.addSessionListener(new XDebugViewSessionListener(view, session), this);
}
- myUi.getContentManager().addDataProvider(new DataProvider() {
- @Nullable
- @Override
- public Object getData(@NonNls String dataId) {
- if (XWatchesView.DATA_KEY.is(dataId)) {
- return myWatchesView;
- }
- if (LangDataKeys.CONSOLE_VIEW.is(dataId)) {
- return session.getConsoleView();
- }
- if (XDebugSessionData.DATA_KEY.is(dataId)) {
- return sessionData;
- }
- return null;
- }
- });
- XDebugTabLayouter layouter = debugProcess.createTabLayouter();
+ XDebugTabLayouter layouter = session.getDebugProcess().createTabLayouter();
Content consoleContent = layouter.registerConsoleContent(myUi, myConsole);
attachNotificationTo(consoleContent);
@@ -172,18 +225,15 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
DefaultActionGroup leftToolbar = new DefaultActionGroup();
final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
- final Executor executor = environment != null ? environment.getExecutor() : debugExecutor;
- if (runner != null && environment != null) {
- RestartAction restartAction = new RestartAction(executor, runner, myRunContentDescriptor, environment);
- leftToolbar.add(restartAction);
- restartAction.registerShortcut(myUi.getComponent());
-
+ ExecutionEnvironment environment = getEnvironment();
+ if (environment != null) {
List<AnAction> additionalRestartActions = session.getRestartActions();
- leftToolbar.addAll(additionalRestartActions);
- if (!additionalRestartActions.isEmpty()) leftToolbar.addSeparator();
+ if (!additionalRestartActions.isEmpty()) {
+ leftToolbar.addAll(additionalRestartActions);
+ leftToolbar.addSeparator();
+ }
leftToolbar.addAll(session.getExtraActions());
}
-
leftToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP));
for (AnAction action : session.getExtraStopActions()) {
@@ -216,7 +266,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
if (commonSettings.length > 0) {
settings.addSeparator();
}
- if (!debugProcess.isValuesCustomSorted()) {
+ if (!session.getDebugProcess().isValuesCustomSorted()) {
settings.add(new ToggleSortValuesAction(commonSettings.length == 0));
}
@@ -225,41 +275,25 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
leftToolbar.addSeparator();
leftToolbar.add(PinToolwindowTabAction.getPinAction());
- leftToolbar.add(new CloseAction(executor, myRunContentDescriptor, getProject()));
+ leftToolbar.add(new CloseAction(environment != null ? environment.getExecutor() : debugExecutor, myRunContentDescriptor, getProject()));
leftToolbar.add(new ContextHelpAction(debugExecutor.getHelpId()));
DefaultActionGroup topToolbar = new DefaultActionGroup();
topToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_TOP_TOOLBAR_GROUP));
- debugProcess.registerAdditionalActions(leftToolbar, topToolbar);
+ session.getDebugProcess().registerAdditionalActions(leftToolbar, topToolbar);
myUi.getOptions().setLeftToolbar(leftToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
myUi.getOptions().setTopToolbar(topToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
if (environment != null) {
- final RunProfile runConfiguration = environment.getRunProfile();
- registerFileMatcher(runConfiguration);
- initLogConsoles(runConfiguration, myRunContentDescriptor.getProcessHandler(), myConsole);
+ initLogConsoles(environment.getRunProfile(), myRunContentDescriptor.getProcessHandler(), myConsole);
}
-
- final DefaultActionGroup focus = new DefaultActionGroup();
- focus.add(ActionManager.getInstance().getAction(XDebuggerActions.FOCUS_ON_BREAKPOINT));
- myUi.getOptions().setAdditionalFocusActions(focus);
-
- myUi.addListener(new ContentManagerAdapter() {
- @Override
- public void selectionChanged(ContentManagerEvent event) {
- Content content = event.getContent();
- if (content.isSelected() && DebuggerContentInfo.WATCHES_CONTENT.equals(content.getUserData(ViewImpl.ID))) {
- if (myWatchesView.rebuildNeeded()) {
- myWatchesView.processSessionEvent(XDebugView.SessionEvent.SETTINGS_CHANGED);
- }
- }
- }
- }, this);
-
- rebuildViews();
}
+ public void detachFromSession() {
+ assert mySession != null;
+ mySession = null;
+ }
@Override
@Nullable
@@ -283,4 +317,4 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
}
}
}
-} \ No newline at end of file
+}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XValueTextProvider.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XValueTextProvider.java
new file mode 100644
index 000000000000..54ae63776e75
--- /dev/null
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XValueTextProvider.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2014 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.ui;
+
+/**
+ * @author egor
+ */
+public interface XValueTextProvider {
+ String getValueText();
+}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/TreeInplaceEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/TreeInplaceEditor.java
index 629385c9ad20..13fe7802481c 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/TreeInplaceEditor.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/TreeInplaceEditor.java
@@ -17,16 +17,19 @@ package com.intellij.xdebugger.impl.ui.tree;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
-import com.intellij.execution.ExecutionManager;
+import com.intellij.execution.Executor;
import com.intellij.execution.ui.RunContentDescriptor;
-import com.intellij.execution.ui.RunContentListener;
import com.intellij.execution.ui.RunContentManager;
+import com.intellij.execution.ui.RunContentWithExecutorListener;
+import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
+import com.intellij.openapi.util.Disposer;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -176,23 +179,22 @@ public abstract class TreeInplaceEditor implements AWTEventListener {
}
});
- final RunContentManager contentManager = ExecutionManager.getInstance(getProject()).getContentManager();
- final RunContentListener runContentListener = new RunContentListener() {
+ final Disposable disposable = Disposer.newDisposable();
+ getProject().getMessageBus().connect(disposable).subscribe(RunContentManager.TOPIC, new RunContentWithExecutorListener() {
@Override
- public void contentSelected(RunContentDescriptor descriptor) {
+ public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
cancelEditing();
}
@Override
- public void contentRemoved(RunContentDescriptor descriptor) {
+ public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
cancelEditing();
}
- };
- contentManager.addRunContentListener(runContentListener);
+ });
myRemoveActions.add(new Runnable() {
@Override
public void run() {
- contentManager.removeRunContentListener(runContentListener);
+ disposable.dispose();
}
});
@@ -246,13 +248,13 @@ public abstract class TreeInplaceEditor implements AWTEventListener {
if (id != MouseEvent.MOUSE_PRESSED && id != MouseEvent.MOUSE_RELEASED && id != MouseEvent.MOUSE_CLICKED && id != MouseEvent.MOUSE_WHEEL) {
return;
}
-
+
final Component sourceComponent = mouseEvent.getComponent();
final Point originalPoint = mouseEvent.getPoint();
final Editor editor = getEditor();
if (editor == null) return;
-
+
final LookupImpl activeLookup = (LookupImpl)LookupManager.getInstance(editor.getProject()).getActiveLookup();
if (activeLookup != null){
final Point lookupPoint = SwingUtilities.convertPoint(sourceComponent, originalPoint, activeLookup.getComponent());
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java
index fe32920a7ac6..9e4f471b047d 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -18,6 +18,8 @@ package com.intellij.xdebugger.impl.ui.tree;
import com.intellij.ide.dnd.aware.DnDAwareTree;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
@@ -26,10 +28,12 @@ import com.intellij.openapi.vcs.changes.issueLinks.TreeLinkMouseListener;
import com.intellij.ui.DoubleClickListener;
import com.intellij.ui.PopupHandler;
import com.intellij.ui.TreeSpeedSearch;
+import com.intellij.util.SingleAlarm;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Convertor;
import com.intellij.util.containers.TransferToEDTQueue;
import com.intellij.util.ui.TextTransferable;
+import com.intellij.util.ui.tree.TreeModelAdapter;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink;
@@ -41,6 +45,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import javax.swing.event.TreeModelEvent;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
@@ -58,6 +63,17 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa
private final TransferToEDTQueue<Runnable> myLaterInvocator = TransferToEDTQueue.createRunnableMerger("XDebuggerTree later invocator", 100);
private static final DataKey<XDebuggerTree> XDEBUGGER_TREE_KEY = DataKey.create("xdebugger.tree");
+ private final SingleAlarm myAlarm = new SingleAlarm(new Runnable() {
+ @Override
+ public void run() {
+ final Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
+ if (editor != null) {
+ editor.getComponent().revalidate();
+ editor.getComponent().repaint();
+ }
+ }
+ }, 100, this);
+
private static final Convertor<TreePath, String> SPEED_SEARCH_CONVERTER = new Convertor<TreePath, String>() {
@Override
public String convert(TreePath o) {
@@ -135,6 +151,27 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa
myEditorsProvider = editorsProvider;
mySourcePosition = sourcePosition;
myTreeModel = new DefaultTreeModel(null);
+ myTreeModel.addTreeModelListener(new TreeModelAdapter() {
+ @Override
+ public void treeNodesChanged(TreeModelEvent e) {
+ updateEditor();
+ }
+
+ @Override
+ public void treeNodesInserted(TreeModelEvent e) {
+ updateEditor();
+ }
+
+ @Override
+ public void treeNodesRemoved(TreeModelEvent e) {
+ updateEditor();
+ }
+
+ @Override
+ public void treeStructureChanged(TreeModelEvent e) {
+ updateEditor();
+ }
+ });
setModel(myTreeModel);
setCellRenderer(new XDebuggerTreeRenderer());
new TreeLinkMouseListener(new XDebuggerTreeRenderer()) {
@@ -185,6 +222,10 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa
setTransferHandler(DEFAULT_TRANSFER_HANDLER);
}
+ private void updateEditor() {
+ myAlarm.cancelAndRequest();
+ }
+
private boolean expandIfEllipsis() {
MessageTreeNode[] treeNodes = getSelectedNodes(MessageTreeNode.class, null);
if (treeNodes.length == 1) {
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesAction.java
index 66f22bbfd4f1..7c77bafc6553 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesAction.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XAddToWatchesAction.java
@@ -55,7 +55,7 @@ class XAddToWatchesAction extends XDebuggerTreeActionBase {
if (view == null && project != null) {
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session != null) {
- view = ((XDebugSessionImpl)session).getSessionTab().getWatchesView();
+ return ((XDebugSessionImpl)session).getSessionTab().getWatchesView();
}
}
return view;
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XFetchValueActionBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XFetchValueActionBase.java
index 3926e89ecd4c..13121c7fda16 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XFetchValueActionBase.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/actions/XFetchValueActionBase.java
@@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SmartList;
import com.intellij.xdebugger.frame.XFullValueEvaluator;
+import com.intellij.xdebugger.impl.ui.XValueTextProvider;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import com.intellij.xdebugger.impl.ui.tree.nodes.HeadlessValueEvaluationCallback;
import com.intellij.xdebugger.impl.ui.tree.nodes.WatchMessageNode;
@@ -74,7 +75,14 @@ public abstract class XFetchValueActionBase extends AnAction {
XValueNodeImpl valueNode = (XValueNodeImpl)node;
XFullValueEvaluator fullValueEvaluator = valueNode.getFullValueEvaluator();
if (fullValueEvaluator == null) {
- valueCollector.add(StringUtil.notNullize(valueNode.getRawValue()));
+ String rawValue;
+ if (valueNode.getValueContainer() instanceof XValueTextProvider) {
+ rawValue = ((XValueTextProvider)valueNode.getValueContainer()).getValueText();
+ }
+ else {
+ rawValue = valueNode.getRawValue();
+ }
+ valueCollector.add(StringUtil.notNullize(rawValue));
}
else {
new CopyValueEvaluationCallback(valueNode, valueCollector).startFetchingValue(fullValueEvaluator);
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java
index 204f45a4a02d..cf67f7d5fdb5 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/WatchesRootNode.java
@@ -21,6 +21,7 @@ import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
import com.intellij.xdebugger.frame.XValue;
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
import com.intellij.xdebugger.impl.frame.WatchInplaceEditor;
+import com.intellij.xdebugger.impl.frame.XDebugView;
import com.intellij.xdebugger.impl.frame.XWatchesView;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
@@ -37,18 +38,15 @@ import java.util.List;
* @author nik
*/
public class WatchesRootNode extends XDebuggerTreeNode {
- private final XDebugSession mySession;
private final XWatchesView myWatchesView;
private List<WatchNode> myChildren;
private List<XDebuggerTreeNode> myLoadedChildren;
private XDebuggerEvaluator myCurrentEvaluator;
- public WatchesRootNode(final @NotNull XDebuggerTree tree,
- @NotNull XDebugSession session,
+ public WatchesRootNode(@NotNull XDebuggerTree tree,
@NotNull XWatchesView watchesView,
@NotNull XExpression[] watchExpressions) {
super(tree, null, false);
- mySession = session;
myWatchesView = watchesView;
myChildren = new ArrayList<WatchNode>();
for (XExpression watchExpression : watchExpressions) {
@@ -189,7 +187,10 @@ public class WatchesRootNode extends XDebuggerTreeNode {
myChildren.set(index, messageNode);
fireNodeStructureChanged(messageNode);
}
- new WatchInplaceEditor(this, mySession, myWatchesView, messageNode, "watch", node).show();
+ XDebugSession session = XDebugView.getSession(myTree);
+ if (session != null) {
+ new WatchInplaceEditor(this, session, myWatchesView, messageNode, "watch", node).show();
+ }
}
private class MyEvaluationCallback extends XEvaluationCallbackBase {
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerTreeNode.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerTreeNode.java
index e01d0ad7ce79..5e3101bff21a 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerTreeNode.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerTreeNode.java
@@ -49,8 +49,7 @@ public abstract class XDebuggerTreeNode implements TreeNode, TreeSpeedSearch.Pat
@Override
public TreeNode getChildAt(final int childIndex) {
- if (isLeaf()) return null;
- return getChildren().get(childIndex);
+ return isLeaf() ? null : getChildren().get(childIndex);
}
@Override
@@ -64,7 +63,7 @@ public abstract class XDebuggerTreeNode implements TreeNode, TreeSpeedSearch.Pat
}
@Override
- public int getIndex(final TreeNode node) {
+ public int getIndex(@NotNull TreeNode node) {
if (isLeaf()) return -1;
return getChildren().indexOf(node);
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java
index b808c3ca96d8..1f3d4c77e84f 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -16,14 +16,19 @@
package com.intellij.xdebugger.impl.ui.tree.nodes;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.AppUIUtil;
import com.intellij.ui.ColoredTextContainer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.NotNullFunction;
+import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.frame.*;
import com.intellij.xdebugger.frame.presentation.XValuePresentation;
import com.intellij.xdebugger.impl.frame.XValueMarkers;
+import com.intellij.xdebugger.impl.frame.XVariablesView;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
import com.intellij.xdebugger.impl.ui.tree.ValueMarkup;
@@ -35,6 +40,9 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.event.MouseEvent;
import java.util.Comparator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
/**
* @author nik
@@ -111,7 +119,28 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
setIcon(icon);
myValuePresentation = valuePresentation;
myRawValue = XValuePresentationUtil.computeValueText(valuePresentation);
-
+ if (Registry.is("ide.debugger.inline")) {
+ try {
+ getValueContainer().computeSourcePosition(new XNavigatable() {
+ @Override
+ public void setSourcePosition(@Nullable XSourcePosition sourcePosition) {
+ Map<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES);
+ if (map == null || sourcePosition == null) return;
+ VirtualFile file = sourcePosition.getFile();
+ int line = sourcePosition.getLine();
+ Pair<VirtualFile, Integer> key = Pair.create(file, line);
+ Set<XValueNodeImpl> presentations = map.get(key);
+ if (presentations == null) {
+ presentations = new LinkedHashSet<XValueNodeImpl>();
+ map.put(key, presentations);
+ }
+ presentations.add(XValueNodeImpl.this);
+ }
+ });
+ }
+ catch (Exception ignore) {
+ }
+ }
updateText();
setLeaf(!hasChildren);
fireNodeChanged();
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java
index e8b8616e6b69..98410cf62552 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueTextRendererImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
-class XValueTextRendererImpl extends XValueTextRendererBase {
+public class XValueTextRendererImpl extends XValueTextRendererBase {
private final ColoredTextContainer myText;
public XValueTextRendererImpl(@NotNull ColoredTextContainer text) {