From b3a39df526b70ee487b69b9f104c53bcaa910bdb Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 5 Mar 2014 15:53:52 +0400 Subject: [PATCH] caret listeners API change (IDEA-80056) --- .../intellij/openapi/editor/CaretModel.java | 4 +-- ...leCaretListener.java => CaretAdapter.java} | 27 ++++++--------- .../openapi/editor/event/CaretListener.java | 14 ++++++-- .../options/colors/ClickNavigator.java | 8 ++--- .../options/colors/SimpleEditorPreview.java | 5 +-- .../completion/CompletionPhase.java | 6 ++-- .../daemon/impl/DaemonListeners.java | 2 +- .../QuickDocOnMouseOverManager.java | 4 +-- .../highlighting/BraceHighlighter.java | 4 +-- .../hint/ParameterInfoController.java | 9 ++--- .../codeInsight/lookup/impl/LookupImpl.java | 2 +- .../navigation/CtrlMouseHandler.java | 4 +-- .../navigation/IncrementalSearchHandler.java | 2 +- .../template/impl/TemplateState.java | 12 ++----- .../console/LanguageConsoleImpl.java | 4 +-- .../src/com/intellij/find/FindUtil.java | 5 +-- .../injected/editor/CaretModelWindow.java | 3 +- .../internal/psiView/PsiViewerDialog.java | 5 ++- .../diff/impl/settings/DiffPreviewPanel.java | 12 ++++++- .../MethodSignatureEditor.java | 9 ++--- .../codeInsight/hint/HintManagerImpl.java | 2 +- .../ide/impl/SelectInEditorManagerImpl.java | 10 +++++- .../openapi/diff/impl/CurrentLineMarker.java | 12 ++++++- .../openapi/editor/impl/CaretModelImpl.java | 34 ++----------------- .../openapi/editor/impl/EditorImpl.java | 2 +- .../impl/IdeDocumentHistoryImpl.java | 2 +- .../openapi/wm/impl/status/PositionPanel.java | 10 +++++- .../TextEditorBasedStructureViewModel.java | 4 +-- .../maven/utils/MavenMergingUpdateQueue.java | 4 +-- .../breadcrumbs/BreadcrumbsXmlWrapper.java | 5 +-- 30 files changed, 115 insertions(+), 111 deletions(-) rename platform/editor-ui-api/src/com/intellij/openapi/editor/event/{MultipleCaretListener.java => CaretAdapter.java} (52%) diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java index 81ecddbdd0f6..dd3aa88ae5b7 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java @@ -129,14 +129,14 @@ public interface CaretModel { int getOffset(); /** - * Adds a listener for receiving notifications about caret movement. + * Adds a listener for receiving notifications about caret movement and caret addition/removal * * @param listener the listener instance. */ void addCaretListener(@NotNull CaretListener listener); /** - * Removes a listener for receiving notifications about caret movement. + * Removes a listener for receiving notifications about caret movement and caret addition/removal * * @param listener the listener instance. */ diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/MultipleCaretListener.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretAdapter.java similarity index 52% rename from platform/editor-ui-api/src/com/intellij/openapi/editor/event/MultipleCaretListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretAdapter.java index 0c225cf922a6..86b2bac7f4fd 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/MultipleCaretListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretAdapter.java @@ -15,21 +15,16 @@ */ package com.intellij.openapi.editor.event; -/** - * In addition to caret movement event received by CaretListener instances, these listeners will also get caret creation/destroying events. - * - * @see CaretListener - * @see com.intellij.openapi.editor.CaretModel#addCaretListener(CaretListener) - * @see EditorEventMulticaster#addCaretListener(CaretListener) - */ -public interface MultipleCaretListener extends CaretListener { - /** - * Called when a new caret was added to the document. - */ - void caretAdded(CaretEvent e); +public abstract class CaretAdapter implements CaretListener { + @Override + public void caretPositionChanged(CaretEvent e) { + } - /** - * Called when a caret was removed from the document. - */ - void caretRemoved(CaretEvent e); + @Override + public void caretAdded(CaretEvent e) { + } + + @Override + public void caretRemoved(CaretEvent e) { + } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretListener.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretListener.java index d99649c97d2f..fe73fc1a4cc5 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretListener.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,7 +18,7 @@ package com.intellij.openapi.editor.event; import java.util.EventListener; /** - * Allows to receive notifications about caret movement. + * Allows to receive notifications about caret movement, and caret additions/removal * * @see com.intellij.openapi.editor.CaretModel#addCaretListener(CaretListener) * @see EditorEventMulticaster#addCaretListener(CaretListener) @@ -30,4 +30,14 @@ public interface CaretListener extends EventListener { * @param e the event containing information about the caret movement. */ void caretPositionChanged(CaretEvent e); + + /** + * Called when a new caret was added to the document. + */ + void caretAdded(CaretEvent e); + + /** + * Called when a caret was removed from the document. + */ + void caretRemoved(CaretEvent e); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ClickNavigator.java b/platform/lang-impl/src/com/intellij/application/options/colors/ClickNavigator.java index 464bf038d986..df10c20fe536 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ClickNavigator.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ClickNavigator.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. @@ -25,6 +24,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.HighlighterColors; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.editor.event.CaretAdapter; import com.intellij.openapi.editor.event.CaretEvent; import com.intellij.openapi.editor.event.CaretListener; import com.intellij.openapi.editor.ex.EditorEx; @@ -56,7 +56,7 @@ public class ClickNavigator { } }); - CaretListener listener = new CaretListener() { + CaretListener listener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { setSelectedItem(HighlighterColors.TEXT.getExternalName(), true); @@ -98,7 +98,7 @@ public class ClickNavigator { final boolean isBackgroundImportant) { addMouseMotionListener(view, highlighter, data, isBackgroundImportant); - CaretListener listener = new CaretListener() { + CaretListener listener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { navigate(view, true, e.getNewPosition(), highlighter, data, isBackgroundImportant); diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java b/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java index 6daa2db58134..e7e92ca98401 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.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. @@ -23,6 +23,7 @@ import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.colors.CodeInsightColors; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.editor.event.CaretAdapter; import com.intellij.openapi.editor.event.CaretEvent; import com.intellij.openapi.editor.event.CaretListener; import com.intellij.openapi.editor.ex.EditorEx; @@ -80,7 +81,7 @@ public class SimpleEditorPreview implements PreviewPanel{ if (navigatable) { addMouseMotionListener(myEditor, page.getHighlighter(), myHighlightData, false); - CaretListener listener = new CaretListener() { + CaretListener listener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { navigate(myEditor, true, e.getNewPosition(), page.getHighlighter(), myHighlightData, false); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.java index 6ba44fde4fdc..d135e19f9e52 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionPhase.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. @@ -253,7 +253,7 @@ public abstract class CompletionPhase implements Disposable { CompletionServiceImpl.setCompletionPhase(NoCompletion); } }; - final CaretListener caretListener = new CaretListener() { + final CaretListener caretListener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { CompletionServiceImpl.setCompletionPhase(NoCompletion); @@ -341,7 +341,7 @@ public abstract class CompletionPhase implements Disposable { } }; - caretListener = new CaretListener() { + caretListener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { if (!TypedAction.isTypedActionInProgress()) { 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 51e1686104dc..b33a029cc7c3 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 @@ -176,7 +176,7 @@ public class DaemonListeners implements Disposable { } }, this); - eventMulticaster.addCaretListener(new CaretListener() { + eventMulticaster.addCaretListener(new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { final Editor editor = e.getEditor(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java index 89e8b55f9b4c..199f66732699 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/QuickDocOnMouseOverManager.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. @@ -354,7 +354,7 @@ public class QuickDocOnMouseOverManager { } } - private class MyCaretListener implements CaretListener { + private class MyCaretListener extends CaretAdapter { @Override public void caretPositionChanged(CaretEvent e) { allowUpdateFromContext(true); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlighter.java b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlighter.java index 597610416c9f..52b955ef73c7 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlighter.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/highlighting/BraceHighlighter.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. @@ -42,7 +42,7 @@ public class BraceHighlighter implements StartupActivity { public void runActivity(@NotNull final Project project) { final EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster(); - CaretListener myCaretListener = new CaretListener() { + CaretListener myCaretListener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { myAlarm.cancelAllRequests(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java index 533562858621..73ad86b2fa72 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.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. @@ -25,10 +25,7 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.editor.ScrollType; -import com.intellij.openapi.editor.event.CaretEvent; -import com.intellij.openapi.editor.event.CaretListener; -import com.intellij.openapi.editor.event.DocumentAdapter; -import com.intellij.openapi.editor.event.DocumentEvent; +import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; @@ -177,7 +174,7 @@ public class ParameterInfoController implements Disposable { List allControllers = getAllControllers(myEditor); allControllers.add(this); - myEditorCaretListener = new CaretListener(){ + myEditorCaretListener = new CaretAdapter(){ @Override public void caretPositionChanged(CaretEvent e) { myAlarm.cancelAllRequests(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index 26115d4b307e..cecdce57dad0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -868,7 +868,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable } }, this); - final CaretListener caretListener = new CaretListener() { + final CaretListener caretListener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { if (!myChangeGuard && !myFinishing) { 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 3e0e26424bb5..1ee91b8212b8 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/CtrlMouseHandler.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. @@ -250,7 +250,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent { EditorEventMulticaster eventMulticaster = editorFactory.getEventMulticaster(); eventMulticaster.addEditorMouseListener(myEditorMouseAdapter, project); eventMulticaster.addEditorMouseMotionListener(myEditorMouseMotionListener, project); - eventMulticaster.addCaretListener(new CaretListener() { + eventMulticaster.addCaretListener(new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { if (myHint != null) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java index 36e5d2988029..fc0aed021ceb 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/IncrementalSearchHandler.java @@ -170,7 +170,7 @@ public class IncrementalSearchHandler { }; document.addDocumentListener(documentListener[0]); - caretListener[0] = new CaretListener() { + caretListener[0] = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { PerHintSearchData data = hint.getUserData(SEARCH_DATA_IN_HINT_KEY); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java index 72d6d056080d..f7eac646dc67 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java @@ -34,10 +34,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.colors.EditorColors; import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.event.CaretEvent; -import com.intellij.openapi.editor.event.DocumentAdapter; -import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.editor.event.MultipleCaretListener; +import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.markup.HighlighterLayer; import com.intellij.openapi.editor.markup.HighlighterTargetArea; @@ -86,7 +83,7 @@ public class TemplateState implements Disposable { private boolean myDocumentChanged = false; @Nullable private CommandAdapter myCommandListener; - @Nullable private MultipleCaretListener myCaretListener; + @Nullable private CaretListener myCaretListener; private final List myListeners = ContainerUtil.createLockFreeCopyOnWriteList(); private DocumentAdapter myEditorDocumentListener; @@ -146,7 +143,7 @@ public class TemplateState implements Disposable { } }; - myCaretListener = new MultipleCaretListener() { + myCaretListener = new CaretAdapter() { @Override public void caretAdded(CaretEvent e) { if (isMultiCaretMode()) { @@ -160,9 +157,6 @@ public class TemplateState implements Disposable { finishTemplateEditing(false); } } - - @Override - public void caretPositionChanged(CaretEvent e) {} }; if (myEditor != null) { 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 b564df1105af..77e9e1d09e18 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.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. @@ -627,7 +627,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { myCurrentEditor = editor; } EmptyAction.registerActionShortcuts(editor.getComponent(), myConsoleEditor.getComponent()); - editor.getCaretModel().addCaretListener(new CaretListener() { + editor.getCaretModel().addCaretListener(new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { queueUiUpdate(false); diff --git a/platform/lang-impl/src/com/intellij/find/FindUtil.java b/platform/lang-impl/src/com/intellij/find/FindUtil.java index e54074d08461..5c931bb26a5b 100644 --- a/platform/lang-impl/src/com/intellij/find/FindUtil.java +++ b/platform/lang-impl/src/com/intellij/find/FindUtil.java @@ -34,6 +34,7 @@ import com.intellij.openapi.editor.actionSystem.EditorActionManager; import com.intellij.openapi.editor.actions.IncrementalFindAction; import com.intellij.openapi.editor.colors.EditorColors; import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.event.CaretAdapter; import com.intellij.openapi.editor.event.CaretEvent; import com.intellij.openapi.editor.event.CaretListener; import com.intellij.openapi.editor.ex.DocumentEx; @@ -752,7 +753,7 @@ public class FindUtil { return result; } - private static class MyListener implements CaretListener { + private static class MyListener extends CaretAdapter { private final Editor myEditor; private final RangeHighlighter mySegmentHighlighter; @@ -818,7 +819,7 @@ public class FindUtil { position = HintManager.ABOVE; } } - CaretListener listener = new CaretListener() { + CaretListener listener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { editor.putUserData(KEY, null); diff --git a/platform/lang-impl/src/com/intellij/injected/editor/CaretModelWindow.java b/platform/lang-impl/src/com/intellij/injected/editor/CaretModelWindow.java index 368c9f4082ce..5e8c23ce433d 100644 --- a/platform/lang-impl/src/com/intellij/injected/editor/CaretModelWindow.java +++ b/platform/lang-impl/src/com/intellij/injected/editor/CaretModelWindow.java @@ -17,6 +17,7 @@ package com.intellij.injected.editor; import com.intellij.openapi.editor.*; +import com.intellij.openapi.editor.event.CaretAdapter; import com.intellij.openapi.editor.event.CaretEvent; import com.intellij.openapi.editor.event.CaretListener; import com.intellij.openapi.editor.ex.EditorEx; @@ -103,7 +104,7 @@ public class CaretModelWindow implements CaretModel { private final ListenerWrapperMap myCaretListeners = new ListenerWrapperMap(); @Override public void addCaretListener(@NotNull final CaretListener listener) { - CaretListener wrapper = new CaretListener() { + CaretListener wrapper = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { if (!myEditorWindow.getDocument().isValid()) return; // injected document can be destroyed by now diff --git a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java index 124b5d6ca7b5..dfaa6501831b 100644 --- a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java +++ b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.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. @@ -34,7 +34,6 @@ import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataProvider; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -1211,7 +1210,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp myEditor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, lightFile)); } - private class EditorListener implements CaretListener, SelectionListener, DocumentListener { + private class EditorListener extends CaretAdapter implements SelectionListener, DocumentListener { @Override public void caretPositionChanged(CaretEvent e) { if (!available() || myEditor.getSelectionModel().hasSelection()) return; diff --git a/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java b/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java index 9e227b0d8fe0..9e329582ddad 100644 --- a/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java +++ b/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.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. @@ -165,6 +165,16 @@ public class DiffPreviewPanel implements PreviewPanel { public void caretPositionChanged(CaretEvent e) { select(MergeSearchHelper.findChangeAt(e, getMergePanel(), myIndex)); } + + @Override + public void caretAdded(CaretEvent e) { + + } + + @Override + public void caretRemoved(CaretEvent e) { + + } } @Override diff --git a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MethodSignatureEditor.java b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MethodSignatureEditor.java index 83122e1cc00b..d5d4812d93da 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MethodSignatureEditor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/MethodSignatureEditor.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. @@ -21,10 +21,7 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.LogicalPosition; -import com.intellij.openapi.editor.event.CaretEvent; -import com.intellij.openapi.editor.event.CaretListener; -import com.intellij.openapi.editor.event.DocumentAdapter; -import com.intellij.openapi.editor.event.DocumentEvent; +import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.impl.CaretModelImpl; import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.util.Key; @@ -163,7 +160,7 @@ public abstract class MethodSignatureEditor extends Editor CodeStyleManager.getInstance(getProject()).reformatText(myFile, range.getStartOffset(), range.getEndOffset()); } }); - editor.getCaretModel().addCaretListener(new CaretListener() { + editor.getCaretModel().addCaretListener(new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { createFromString(); diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java index e79890eaaecd..c4c8c8f7d8c7 100644 --- a/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java @@ -104,7 +104,7 @@ public class HintManagerImpl extends HintManager implements Disposable { myAnActionListener = new MyAnActionListener(); actionManagerEx.addAnActionListener(myAnActionListener); - myCaretMoveListener = new CaretListener() { + myCaretMoveListener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { hideHints(HIDE_BY_ANY_KEY, false, false); diff --git a/platform/platform-impl/src/com/intellij/ide/impl/SelectInEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/ide/impl/SelectInEditorManagerImpl.java index 6c7efde06915..2eebf984707a 100644 --- a/platform/platform-impl/src/com/intellij/ide/impl/SelectInEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/impl/SelectInEditorManagerImpl.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. @@ -143,6 +143,14 @@ public class SelectInEditorManagerImpl extends SelectInEditorManager implements releaseAll(); } + @Override + public void caretAdded(CaretEvent e) { + } + + @Override + public void caretRemoved(CaretEvent e) { + } + private void releaseAll() { if (mySegmentHighlighter != null && myEditor != null){ mySegmentHighlighter.dispose(); diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/CurrentLineMarker.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/CurrentLineMarker.java index 8d7559dc575d..515fc9df9936 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/CurrentLineMarker.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/CurrentLineMarker.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. @@ -64,4 +64,14 @@ public class CurrentLineMarker implements CaretListener { if (isHiden()) return; set(); } + + @Override + public void caretAdded(CaretEvent e) { + + } + + @Override + public void caretRemoved(CaretEvent e) { + + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java index e6f07a5d9c34..cc7f1339f767 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java @@ -31,7 +31,6 @@ import com.intellij.openapi.editor.colors.EditorColors; import com.intellij.openapi.editor.event.CaretEvent; import com.intellij.openapi.editor.event.CaretListener; import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.editor.event.MultipleCaretListener; import com.intellij.openapi.editor.ex.DocumentBulkUpdateListener; import com.intellij.openapi.editor.ex.PrioritizedDocumentListener; import com.intellij.openapi.editor.impl.event.DocumentEventImpl; @@ -47,8 +46,7 @@ import java.util.*; public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, Disposable { private final EditorImpl myEditor; - private final EventDispatcher myCaretListeners = EventDispatcher.create(MultipleCaretListener.class); - private final Map myListenerMap = new HashMap(); + private final EventDispatcher myCaretListeners = EventDispatcher.create(CaretListener.class); private final boolean mySupportsMultipleCarets = Registry.is("editor.allow.multiple.carets"); private TextAttributes myTextAttributes; @@ -201,38 +199,12 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, @Override public void addCaretListener(@NotNull final CaretListener listener) { - MultipleCaretListener newListener; - if (listener instanceof MultipleCaretListener) { - newListener = (MultipleCaretListener)listener; - } - else { - newListener = new MultipleCaretListener() { - @Override - public void caretAdded(CaretEvent e) { - - } - - @Override - public void caretRemoved(CaretEvent e) { - - } - - @Override - public void caretPositionChanged(CaretEvent e) { - listener.caretPositionChanged(e); - } - }; - } - myListenerMap.put(listener, newListener); - myCaretListeners.addListener(newListener); + myCaretListeners.addListener(listener); } @Override public void removeCaretListener(@NotNull CaretListener listener) { - MultipleCaretListener newListener = myListenerMap.remove(listener); - if (newListener != null) { - myCaretListeners.removeListener(newListener); - } + myCaretListeners.removeListener(listener); } @Override 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 25f559eb5961..8b4192947be8 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 @@ -393,7 +393,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi myFoldingModel.addListener(mySoftWrapModel, myCaretModel); myIndentsModel = new IndentsModelImpl(this); - myCaretModel.addCaretListener(new MultipleCaretListener() { + myCaretModel.addCaretListener(new CaretListener() { @Nullable private LightweightHint myCurrentHint = null; @Nullable private IndentGuideDescriptor myCurrentCaretGuide = null; diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java index 6e80c6da70fa..752ab1228c3e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/IdeDocumentHistoryImpl.java @@ -119,7 +119,7 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Projec }; eventMulticaster.addDocumentListener(documentListener, myProject); - CaretListener caretListener = new CaretListener() { + CaretListener caretListener = new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { onCaretPositionChanged(e); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/PositionPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/PositionPanel.java index 9be7a9245544..76bbc49d6146 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/PositionPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/PositionPanel.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. @@ -124,6 +124,14 @@ public class PositionPanel extends EditorBasedWidget implements StatusBarWidget. updatePosition(e.getEditor()); } + @Override + public void caretAdded(CaretEvent e) { + } + + @Override + public void caretRemoved(CaretEvent e) { + } + private void updatePosition(final Editor editor) { if (editor == null) { myText = ""; diff --git a/platform/structure-view-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java b/platform/structure-view-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java index 5cef3a5801a6..34641fe63557 100644 --- a/platform/structure-view-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java +++ b/platform/structure-view-api/src/com/intellij/ide/structureView/TextEditorBasedStructureViewModel.java @@ -19,8 +19,8 @@ import com.intellij.ide.util.treeView.smartTree.*; import com.intellij.openapi.Disposable; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; +import com.intellij.openapi.editor.event.CaretAdapter; import com.intellij.openapi.editor.event.CaretEvent; -import com.intellij.openapi.editor.event.CaretListener; import com.intellij.openapi.util.Disposer; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -71,7 +71,7 @@ public abstract class TextEditorBasedStructureViewModel implements StructureView myPsiFile = file; if (editor != null) { - EditorFactory.getInstance().getEventMulticaster().addCaretListener(new CaretListener() { + EditorFactory.getInstance().getEventMulticaster().addCaretListener(new CaretAdapter() { @Override public void caretPositionChanged(CaretEvent e) { if (e.getEditor().equals(myEditor)) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenMergingUpdateQueue.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenMergingUpdateQueue.java index cb9ec71caa7f..e988b98add51 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenMergingUpdateQueue.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenMergingUpdateQueue.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. @@ -78,7 +78,7 @@ public class MavenMergingUpdateQueue extends MergingUpdateQueue { try { EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster(); - multicaster.addCaretListener(new CaretListener() { + multicaster.addCaretListener(new CaretAdapter() { public void caretPositionChanged(CaretEvent e) { MavenMergingUpdateQueue.this.restartTimer(); } diff --git a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java index cd62adf16f1d..1b2fabde81b3 100644 --- a/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.java +++ b/xml/impl/src/com/intellij/xml/breadcrumbs/BreadcrumbsXmlWrapper.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. @@ -26,6 +26,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.colors.EditorFontType; +import com.intellij.openapi.editor.event.CaretAdapter; import com.intellij.openapi.editor.event.CaretEvent; import com.intellij.openapi.editor.event.CaretListener; import com.intellij.openapi.extensions.Extensions; @@ -103,7 +104,7 @@ public class BreadcrumbsXmlWrapper implements BreadcrumbsItemListener