mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
committed by
Kirill Kalishev
parent
37e35c262b
commit
7e4a2f6891
@@ -82,17 +82,11 @@ import java.util.List;
|
||||
class DaemonListeners implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.DaemonListeners");
|
||||
|
||||
private final EditorColorsListener myEditorColorsListener = new MyEditorColorsListener();
|
||||
private final PropertyChangeListener myTodoListener = new MyTodoListener();
|
||||
|
||||
private final Project myProject;
|
||||
private final DaemonCodeAnalyzerImpl myDaemonCodeAnalyzer;
|
||||
private final ModalityStateListener myModalityStateListener;
|
||||
|
||||
private boolean myEscPressed;
|
||||
|
||||
private final ErrorStripeHandler myErrorStripeHandler;
|
||||
|
||||
private volatile boolean cutOperationJustHappened;
|
||||
private final EditorTracker myEditorTracker;
|
||||
|
||||
@@ -208,9 +202,9 @@ class DaemonListeners implements Disposable {
|
||||
CommandProcessor.getInstance().addCommandListener(new MyCommandListener(), this);
|
||||
ApplicationListener applicationListener = new MyApplicationListener();
|
||||
ApplicationManager.getApplication().addApplicationListener(applicationListener, this);
|
||||
EditorColorsManager.getInstance().addEditorColorsListener(myEditorColorsListener);
|
||||
EditorColorsManager.getInstance().addEditorColorsListener(new MyEditorColorsListener(),this);
|
||||
InspectionProfileManager.getInstance().addProfileChangeListener(new MyProfileChangeListener(), this);
|
||||
TodoConfiguration.getInstance().addPropertyChangeListener(myTodoListener);
|
||||
TodoConfiguration.getInstance().addPropertyChangeListener(new MyTodoListener(), this);
|
||||
ActionManagerEx.getInstanceEx().addAnActionListener(new MyAnActionListener(), this);
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
|
||||
public void propertyChanged(VirtualFilePropertyEvent event) {
|
||||
@@ -242,8 +236,7 @@ class DaemonListeners implements Disposable {
|
||||
}
|
||||
}, this);
|
||||
|
||||
myErrorStripeHandler = new ErrorStripeHandler(myProject);
|
||||
((EditorEventMulticasterEx)eventMulticaster).addErrorStripeListener(myErrorStripeHandler);
|
||||
((EditorEventMulticasterEx)eventMulticaster).addErrorStripeListener(new ErrorStripeHandler(myProject), this);
|
||||
|
||||
final NamedScopesHolder[] holders = NamedScopesHolder.getAllNamedScopeHolders(project);
|
||||
NamedScopesHolder.ScopeListener scopeListener = new NamedScopesHolder.ScopeListener() {
|
||||
@@ -255,7 +248,7 @@ class DaemonListeners implements Disposable {
|
||||
holder.addScopeListener(scopeListener);
|
||||
}
|
||||
|
||||
myModalityStateListener = new ModalityStateListener() {
|
||||
ModalityStateListener modalityStateListener = new ModalityStateListener() {
|
||||
public void beforeModalityStateChanged(boolean entering) {
|
||||
// before showing dialog we are in non-modal context yet, and before closing dialog we are still in modal context
|
||||
boolean inModalContext = LaterInvocator.isInModalContext();
|
||||
@@ -263,7 +256,7 @@ class DaemonListeners implements Disposable {
|
||||
myDaemonCodeAnalyzer.setUpdateByTimerEnabled(inModalContext);
|
||||
}
|
||||
};
|
||||
LaterInvocator.addModalityStateListener(myModalityStateListener);
|
||||
LaterInvocator.addModalityStateListener(modalityStateListener,this);
|
||||
}
|
||||
|
||||
static boolean isUnderIgnoredAction(Object action) {
|
||||
@@ -281,13 +274,6 @@ class DaemonListeners implements Disposable {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
|
||||
|
||||
EditorColorsManager.getInstance().removeEditorColorsListener(myEditorColorsListener);
|
||||
TodoConfiguration.getInstance().removePropertyChangeListener(myTodoListener);
|
||||
|
||||
((EditorEventMulticasterEx)eventMulticaster).removeErrorStripeListener(myErrorStripeHandler);
|
||||
LaterInvocator.removeModalityStateListener(myModalityStateListener);
|
||||
}
|
||||
|
||||
boolean canChangeFileSilently(PsiFileSystemItem file) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.ide.todo;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
@@ -55,7 +56,7 @@ public class TodoConfiguration implements ApplicationComponent, JDOMExternalizab
|
||||
/**
|
||||
* Invoked by reflection
|
||||
*/
|
||||
TodoConfiguration(MessageBus messageBus) {
|
||||
TodoConfiguration(@NotNull MessageBus messageBus) {
|
||||
myMessageBus = messageBus;
|
||||
resetToDefaultTodoPatterns();
|
||||
}
|
||||
@@ -89,19 +90,21 @@ public class TodoConfiguration implements ApplicationComponent, JDOMExternalizab
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TodoPattern[] getTodoPatterns() {
|
||||
return myTodoPatterns;
|
||||
}
|
||||
|
||||
@NotNull public IndexPattern[] getIndexPatterns() {
|
||||
@NotNull
|
||||
public IndexPattern[] getIndexPatterns() {
|
||||
return myIndexPatterns;
|
||||
}
|
||||
|
||||
public void setTodoPatterns(TodoPattern[] todoPatterns) {
|
||||
public void setTodoPatterns(@NotNull TodoPattern[] todoPatterns) {
|
||||
doSetTodoPatterns(todoPatterns, true);
|
||||
}
|
||||
|
||||
private void doSetTodoPatterns(TodoPattern[] todoPatterns, final boolean shouldNotifyIndices) {
|
||||
private void doSetTodoPatterns(@NotNull TodoPattern[] todoPatterns, final boolean shouldNotifyIndices) {
|
||||
TodoPattern[] oldTodoPatterns = myTodoPatterns;
|
||||
IndexPattern[] oldIndexPatterns = myIndexPatterns;
|
||||
|
||||
@@ -138,21 +141,24 @@ public class TodoConfiguration implements ApplicationComponent, JDOMExternalizab
|
||||
/**
|
||||
* @return all <code>TodoFilter</code>s.
|
||||
*/
|
||||
@NotNull
|
||||
public TodoFilter[] getTodoFilters() {
|
||||
return myTodoFilters;
|
||||
}
|
||||
|
||||
public void setTodoFilters(TodoFilter[] filters) {
|
||||
public void setTodoFilters(@NotNull TodoFilter[] filters) {
|
||||
TodoFilter[] oldFilters = myTodoFilters;
|
||||
myTodoFilters = filters;
|
||||
myPropertyChangeMulticaster.getMulticaster().propertyChange(new PropertyChangeEvent(this, PROP_TODO_FILTERS, oldFilters, filters));
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
public void addPropertyChangeListener(@NotNull PropertyChangeListener listener) {
|
||||
myPropertyChangeMulticaster.addListener(listener);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
public void addPropertyChangeListener(@NotNull PropertyChangeListener listener, @NotNull Disposable parentDisposable) {
|
||||
myPropertyChangeMulticaster.addListener(listener,parentDisposable);
|
||||
}
|
||||
public void removePropertyChangeListener(@NotNull PropertyChangeListener listener) {
|
||||
myPropertyChangeMulticaster.removeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,12 +94,7 @@ public class TodoView implements PersistentStateComponent<Element>, Disposable {
|
||||
myVCSManager.addVcsListener(myVcsListener);
|
||||
|
||||
final MyPropertyChangeListener myPropertyChangeListener = new MyPropertyChangeListener();
|
||||
TodoConfiguration.getInstance().addPropertyChangeListener(myPropertyChangeListener);
|
||||
Disposer.register(this, new Disposable() {
|
||||
public void dispose() {
|
||||
TodoConfiguration.getInstance().removePropertyChangeListener(myPropertyChangeListener);
|
||||
}
|
||||
});
|
||||
TodoConfiguration.getInstance().addPropertyChangeListener(myPropertyChangeListener,this);
|
||||
|
||||
MessageBusConnection connection = myProject.getMessageBus().connect(this);
|
||||
connection.subscribe(AppTopics.FILE_TYPES, new MyFileTypeListener());
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ui.Table;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -85,8 +86,7 @@ public class TodoConfigurable extends BaseConfigurable implements SearchableConf
|
||||
if (initialPatterns.length != myPatterns.size()) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < initialPatterns.length; i++) {
|
||||
TodoPattern initialPattern = initialPatterns[i];
|
||||
for (TodoPattern initialPattern : initialPatterns) {
|
||||
if (!myPatterns.contains(initialPattern)) {
|
||||
return true;
|
||||
}
|
||||
@@ -100,8 +100,7 @@ public class TodoConfigurable extends BaseConfigurable implements SearchableConf
|
||||
if (initialFilters.length != myFilters.size()) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < initialFilters.length; i++) {
|
||||
TodoFilter initialFilter = initialFilters[i];
|
||||
for (TodoFilter initialFilter : initialFilters) {
|
||||
if (!myFilters.contains(initialFilter)) {
|
||||
return true;
|
||||
}
|
||||
@@ -391,7 +390,7 @@ public class TodoConfigurable extends BaseConfigurable implements SearchableConf
|
||||
}
|
||||
TodoPattern sourcePattern = myPatterns.get(selectedIndex);
|
||||
TodoPattern pattern = sourcePattern.clone();
|
||||
PatternDialog dialog = new PatternDialog(TodoConfigurable.this.myPanel, pattern);
|
||||
PatternDialog dialog = new PatternDialog(myPanel, pattern);
|
||||
dialog.setTitle(IdeBundle.message("title.edit.todo.pattern"));
|
||||
dialog.show();
|
||||
if (!dialog.isOK()) {
|
||||
@@ -459,6 +458,7 @@ public class TodoConfigurable extends BaseConfigurable implements SearchableConf
|
||||
return IdeBundle.message("title.todo");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getHelpTopic() {
|
||||
return "preferences.toDoOptions";
|
||||
}
|
||||
@@ -472,15 +472,15 @@ public class TodoConfigurable extends BaseConfigurable implements SearchableConf
|
||||
myPatterns.clear();
|
||||
TodoConfiguration todoConfiguration = TodoConfiguration.getInstance();
|
||||
TodoPattern[] patterns = todoConfiguration.getTodoPatterns();
|
||||
for (int i = 0; i < patterns.length; i++) {
|
||||
myPatterns.add(patterns[i].clone());
|
||||
for (TodoPattern pattern : patterns) {
|
||||
myPatterns.add(pattern.clone());
|
||||
}
|
||||
myPatternsModel.fireTableDataChanged();
|
||||
// Filters
|
||||
myFilters.clear();
|
||||
TodoFilter[] filters = todoConfiguration.getTodoFilters();
|
||||
for (int i = 0; i < filters.length; i++) {
|
||||
myFilters.add(filters[i].clone());
|
||||
for (TodoFilter filter : filters) {
|
||||
myFilters.add(filter.clone());
|
||||
}
|
||||
myFiltersModel.fireTableDataChanged();
|
||||
//
|
||||
@@ -506,6 +506,7 @@ public class TodoConfigurable extends BaseConfigurable implements SearchableConf
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getId() {
|
||||
return getHelpTopic();
|
||||
}
|
||||
|
||||
+17
-12
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.application.impl;
|
||||
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ModalityStateListener;
|
||||
@@ -84,15 +85,18 @@ public class LaterInvocator {
|
||||
|
||||
private static final ArrayList<RunnableInfo> ourForcedFlushQueue = new ArrayList<RunnableInfo>();
|
||||
|
||||
public static void addModalityStateListener(ModalityStateListener listener){
|
||||
public static void addModalityStateListener(@NotNull ModalityStateListener listener){
|
||||
ourModalityStateMulticaster.addListener(listener);
|
||||
}
|
||||
public static void addModalityStateListener(@NotNull ModalityStateListener listener, @NotNull Disposable parentDisposable){
|
||||
ourModalityStateMulticaster.addListener(listener,parentDisposable);
|
||||
}
|
||||
|
||||
public static void removeModalityStateListener(ModalityStateListener listener){
|
||||
public static void removeModalityStateListener(@NotNull ModalityStateListener listener){
|
||||
ourModalityStateMulticaster.removeListener(listener);
|
||||
}
|
||||
|
||||
static ModalityStateEx modalityStateForWindow(Window window){
|
||||
static ModalityStateEx modalityStateForWindow(@NotNull Window window){
|
||||
int index = ourModalEntities.indexOf(window);
|
||||
if (index < 0){
|
||||
Window owner = window.getOwner();
|
||||
@@ -120,20 +124,20 @@ public class LaterInvocator {
|
||||
return new ModalityStateEx(result.toArray());
|
||||
}
|
||||
|
||||
public static ActionCallback invokeLater(Runnable runnable) {
|
||||
public static ActionCallback invokeLater(@NotNull Runnable runnable) {
|
||||
return invokeLater(runnable, Conditions.FALSE);
|
||||
}
|
||||
|
||||
public static ActionCallback invokeLater(Runnable runnable, @NotNull Condition expired) {
|
||||
public static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull Condition expired) {
|
||||
ModalityState modalityState = ModalityState.defaultModalityState();
|
||||
return invokeLater(runnable, modalityState, expired);
|
||||
}
|
||||
|
||||
public static ActionCallback invokeLater(Runnable runnable, @NotNull ModalityState modalityState) {
|
||||
public static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState modalityState) {
|
||||
return invokeLater(runnable, modalityState, Conditions.FALSE);
|
||||
}
|
||||
|
||||
public static ActionCallback invokeLater(Runnable runnable, @NotNull ModalityState modalityState, @NotNull Condition<Object> expired) {
|
||||
public static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState modalityState, @NotNull Condition<Object> expired) {
|
||||
final ActionCallback callback = new ActionCallback();
|
||||
synchronized (LOCK) {
|
||||
ourQueue.add(new RunnableInfo(runnable, modalityState, expired, callback));
|
||||
@@ -144,7 +148,7 @@ public class LaterInvocator {
|
||||
|
||||
|
||||
|
||||
public static void invokeAndWait(final Runnable runnable, @NotNull ModalityState modalityState) {
|
||||
public static void invokeAndWait(@NotNull final Runnable runnable, @NotNull ModalityState modalityState) {
|
||||
LOG.assertTrue(!isDispatchThread());
|
||||
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
@@ -168,7 +172,7 @@ public class LaterInvocator {
|
||||
semaphore.waitFor();
|
||||
}
|
||||
|
||||
public static void enterModal(Object modalEntity) {
|
||||
public static void enterModal(@NotNull Object modalEntity) {
|
||||
if (!IS_TEST_MODE) {
|
||||
LOG.assertTrue(isDispatchThread(), "enterModal() should be invoked in event-dispatch thread");
|
||||
}
|
||||
@@ -184,7 +188,7 @@ public class LaterInvocator {
|
||||
ourModalEntities.add(modalEntity);
|
||||
}
|
||||
|
||||
public static void leaveModal(Object modalEntity) {
|
||||
public static void leaveModal(@NotNull Object modalEntity) {
|
||||
if (!IS_TEST_MODE) {
|
||||
LOG.assertTrue(isDispatchThread(), "leaveModal() should be invoked in event-dispatch thread");
|
||||
}
|
||||
@@ -204,7 +208,7 @@ public class LaterInvocator {
|
||||
requestFlush();
|
||||
}
|
||||
|
||||
private static void cleanupQueueForModal(final Object modalEntity) {
|
||||
private static void cleanupQueueForModal(@NotNull final Object modalEntity) {
|
||||
synchronized (LOCK) {
|
||||
for (Iterator<RunnableInfo> iterator = ourQueue.iterator(); iterator.hasNext();) {
|
||||
RunnableInfo runnableInfo = iterator.next();
|
||||
@@ -233,6 +237,7 @@ public class LaterInvocator {
|
||||
requestFlush();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Object[] getCurrentModalEntities() {
|
||||
if (!IS_TEST_MODE) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
@@ -300,7 +305,7 @@ public class LaterInvocator {
|
||||
private static final AtomicBoolean FLUSHER_SCHEDULED = new AtomicBoolean(false);
|
||||
private static final Object RUN_LOCK = new Object();
|
||||
|
||||
static class FlushQueue implements Runnable {
|
||||
private static class FlushQueue implements Runnable {
|
||||
private RunnableInfo myLastInfo;
|
||||
|
||||
public void run() {
|
||||
|
||||
+11
-9
@@ -15,21 +15,23 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.ex;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.editor.event.EditorEventMulticaster;
|
||||
import com.intellij.openapi.editor.event.DocumentListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
public interface EditorEventMulticasterEx extends EditorEventMulticaster{
|
||||
void addErrorStripeListener(ErrorStripeListener listener);
|
||||
void removeErrorStripeListener(ErrorStripeListener listener);
|
||||
void addErrorStripeListener(@NotNull ErrorStripeListener listener);
|
||||
void addErrorStripeListener(@NotNull ErrorStripeListener listener, @NotNull Disposable parentDisposable);
|
||||
void removeErrorStripeListener(@NotNull ErrorStripeListener listener);
|
||||
|
||||
void addEditReadOnlyListener(EditReadOnlyListener listener);
|
||||
void removeEditReadOnlyListener(EditReadOnlyListener listener);
|
||||
void addEditReadOnlyListener(@NotNull EditReadOnlyListener listener);
|
||||
void removeEditReadOnlyListener(@NotNull EditReadOnlyListener listener);
|
||||
|
||||
void addPropertyChangeListener(PropertyChangeListener listener);
|
||||
void removePropertyChangeListener(PropertyChangeListener listener);
|
||||
void addPropertyChangeListener(@NotNull PropertyChangeListener listener);
|
||||
void removePropertyChangeListener(@NotNull PropertyChangeListener listener);
|
||||
|
||||
void addFocusChangeListner(FocusChangeListener listener);
|
||||
void removeFocusChangeListner(FocusChangeListener listener);
|
||||
void addFocusChangeListner(@NotNull FocusChangeListener listener);
|
||||
void removeFocusChangeListner(@NotNull FocusChangeListener listener);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.injected.editor.DocumentWindow;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityStateListener;
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -51,13 +52,6 @@ public class EditorFactoryImpl extends EditorFactory {
|
||||
private final EventDispatcher<EditorFactoryListener> myEditorFactoryEventDispatcher = EventDispatcher.create(EditorFactoryListener.class);
|
||||
private final ArrayList<Editor> myEditors = new ArrayList<Editor>();
|
||||
private static final Key<String> EDITOR_CREATOR = new Key<String>("Editor creator");
|
||||
private final ModalityStateListener myModalityStateListener = new ModalityStateListener() {
|
||||
public void beforeModalityStateChanged(boolean entering) {
|
||||
for (Editor editor : myEditors) {
|
||||
((EditorImpl)editor).beforeModalityStateChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public EditorFactoryImpl(ProjectManager projectManager) {
|
||||
projectManager.addProjectManagerListener(new ProjectManagerAdapter() {
|
||||
@@ -77,7 +71,14 @@ public class EditorFactoryImpl extends EditorFactory {
|
||||
}
|
||||
|
||||
public void initComponent() {
|
||||
LaterInvocator.addModalityStateListener(myModalityStateListener);
|
||||
ModalityStateListener myModalityStateListener = new ModalityStateListener() {
|
||||
public void beforeModalityStateChanged(boolean entering) {
|
||||
for (Editor editor : myEditors) {
|
||||
((EditorImpl)editor).beforeModalityStateChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
LaterInvocator.addModalityStateListener(myModalityStateListener, ApplicationManager.getApplication());
|
||||
}
|
||||
|
||||
public void validateEditorsAreReleased(Project project) {
|
||||
@@ -100,7 +101,6 @@ public class EditorFactoryImpl extends EditorFactory {
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
LaterInvocator.removeModalityStateListener(myModalityStateListener);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+13
-8
@@ -134,11 +134,16 @@ public class EditorEventMulticasterImpl implements EditorEventMulticasterEx {
|
||||
mySelectionMulticaster.removeListener(listener);
|
||||
}
|
||||
|
||||
public void addErrorStripeListener(ErrorStripeListener listener) {
|
||||
public void addErrorStripeListener(@NotNull ErrorStripeListener listener) {
|
||||
myErrorStripeMulticaster.addListener(listener);
|
||||
}
|
||||
|
||||
public void removeErrorStripeListener(ErrorStripeListener listener) {
|
||||
@Override
|
||||
public void addErrorStripeListener(@NotNull ErrorStripeListener listener, @NotNull Disposable parentDisposable) {
|
||||
myErrorStripeMulticaster.addListener(listener, parentDisposable);
|
||||
}
|
||||
|
||||
public void removeErrorStripeListener(@NotNull ErrorStripeListener listener) {
|
||||
myErrorStripeMulticaster.removeListener(listener);
|
||||
}
|
||||
|
||||
@@ -150,27 +155,27 @@ public class EditorEventMulticasterImpl implements EditorEventMulticasterEx {
|
||||
myVisibleAreaMulticaster.removeListener(listener);
|
||||
}
|
||||
|
||||
public void addEditReadOnlyListener(EditReadOnlyListener listener) {
|
||||
public void addEditReadOnlyListener(@NotNull EditReadOnlyListener listener) {
|
||||
myEditReadOnlyMulticaster.addListener(listener);
|
||||
}
|
||||
|
||||
public void removeEditReadOnlyListener(EditReadOnlyListener listener) {
|
||||
public void removeEditReadOnlyListener(@NotNull EditReadOnlyListener listener) {
|
||||
myEditReadOnlyMulticaster.removeListener(listener);
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
public void addPropertyChangeListener(@NotNull PropertyChangeListener listener) {
|
||||
myPropertyChangeMulticaster.addListener(listener);
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
public void removePropertyChangeListener(@NotNull PropertyChangeListener listener) {
|
||||
myPropertyChangeMulticaster.removeListener(listener);
|
||||
}
|
||||
|
||||
public void addFocusChangeListner(FocusChangeListener listener) {
|
||||
public void addFocusChangeListner(@NotNull FocusChangeListener listener) {
|
||||
myFocusChangeListenerMulticaster.addListener(listener);
|
||||
}
|
||||
|
||||
public void removeFocusChangeListner(FocusChangeListener listener) {
|
||||
public void removeFocusChangeListner(@NotNull FocusChangeListener listener) {
|
||||
myFocusChangeListenerMulticaster.removeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -37,11 +38,11 @@ public class EventDispatcher <T extends EventListener>{
|
||||
|
||||
private final List<T> myListeners = ContainerUtil.createEmptyCOWList();
|
||||
|
||||
public static <T extends EventListener> EventDispatcher<T> create(Class<T> listenerClass) {
|
||||
public static <T extends EventListener> EventDispatcher<T> create(@NotNull Class<T> listenerClass) {
|
||||
return new EventDispatcher<T>(listenerClass);
|
||||
}
|
||||
|
||||
private EventDispatcher(Class<T> listenerClass) {
|
||||
private EventDispatcher(@NotNull Class<T> listenerClass) {
|
||||
InvocationHandler handler = new InvocationHandler() {
|
||||
@NonNls public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
|
||||
if (method.getDeclaringClass().getName().equals("java.lang.Object")) {
|
||||
@@ -75,6 +76,7 @@ public class EventDispatcher <T extends EventListener>{
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public T getMulticaster() {
|
||||
return myMulticaster;
|
||||
}
|
||||
@@ -102,11 +104,11 @@ public class EventDispatcher <T extends EventListener>{
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(T listener) {
|
||||
public void addListener(@NotNull T listener) {
|
||||
myListeners.add(listener);
|
||||
}
|
||||
|
||||
public void addListener(final T listener, Disposable parentDisposable) {
|
||||
public void addListener(@NotNull final T listener, @NotNull Disposable parentDisposable) {
|
||||
addListener(listener);
|
||||
Disposer.register(parentDisposable, new Disposable() {
|
||||
public void dispose() {
|
||||
@@ -115,7 +117,7 @@ public class EventDispatcher <T extends EventListener>{
|
||||
});
|
||||
}
|
||||
|
||||
public void removeListener(T listener) {
|
||||
public void removeListener(@NotNull T listener) {
|
||||
myListeners.remove(listener);
|
||||
}
|
||||
|
||||
@@ -123,6 +125,7 @@ public class EventDispatcher <T extends EventListener>{
|
||||
return !myListeners.isEmpty();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<T> getListeners() {
|
||||
return myListeners;
|
||||
}
|
||||
|
||||
+5
-9
@@ -16,9 +16,11 @@
|
||||
package org.jetbrains.idea.maven.utils;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityStateListener;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.event.*;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
@@ -26,7 +28,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ModuleRootListener;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue;
|
||||
import com.intellij.util.ui.update.Update;
|
||||
@@ -140,15 +141,10 @@ public class MavenMergingUpdateQueue extends MergingUpdateQueue {
|
||||
}
|
||||
}
|
||||
};
|
||||
LaterInvocator.addModalityStateListener(listener);
|
||||
LaterInvocator.addModalityStateListener(listener,MavenMergingUpdateQueue.this);
|
||||
if (MavenUtil.isInModalContext()) {
|
||||
suspend();
|
||||
}
|
||||
Disposer.register(MavenMergingUpdateQueue.this, new Disposable() {
|
||||
public void dispose() {
|
||||
LaterInvocator.removeModalityStateListener(listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user