mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
eliminating listeners in fields
This commit is contained in:
@@ -38,7 +38,6 @@ public class PaletteManager implements ProjectComponent {
|
||||
private final FileEditorManager myFileEditorManager;
|
||||
private PaletteWindow myPaletteWindow;
|
||||
private ToolWindow myPaletteToolWindow;
|
||||
private final MyFileEditorManagerListener myListener;
|
||||
private final List<KeyListener> myKeyListeners = ContainerUtil.createEmptyCOWList();
|
||||
private final List<PaletteDragEventListener> myDragEventListeners = ContainerUtil.createEmptyCOWList();
|
||||
private final List<ListSelectionListener> mySelectionListeners = ContainerUtil.createEmptyCOWList();
|
||||
@@ -46,7 +45,6 @@ public class PaletteManager implements ProjectComponent {
|
||||
public PaletteManager(Project project, FileEditorManager fileEditorManager) {
|
||||
myProject = project;
|
||||
myFileEditorManager = fileEditorManager;
|
||||
myListener = new MyFileEditorManagerListener();
|
||||
}
|
||||
|
||||
public void projectOpened() {
|
||||
@@ -58,7 +56,8 @@ public class PaletteManager implements ProjectComponent {
|
||||
ToolWindowAnchor.RIGHT);
|
||||
myPaletteToolWindow.setIcon(IconLoader.getIcon("/general/toolWindowPalette.png"));
|
||||
myPaletteToolWindow.setAvailable(false, null);
|
||||
myFileEditorManager.addFileEditorManagerListener(myListener);
|
||||
final MyFileEditorManagerListener myListener = new MyFileEditorManagerListener();
|
||||
myFileEditorManager.addFileEditorManagerListener(myListener, myProject);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -68,7 +67,6 @@ public class PaletteManager implements ProjectComponent {
|
||||
ToolWindowManager.getInstance(myProject).unregisterToolWindow(IdeBundle.message("toolwindow.palette"));
|
||||
myPaletteWindow = null;
|
||||
}
|
||||
myFileEditorManager.removeFileEditorManagerListener(myListener);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -36,8 +36,6 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
|
||||
|
||||
private final JPanel myPanel;
|
||||
|
||||
private final FileEditorManagerListener myEditorManagerListener;
|
||||
|
||||
private final Alarm myAlarm;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -59,37 +57,36 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
|
||||
}
|
||||
});
|
||||
|
||||
myEditorManagerListener = new FileEditorManagerAdapter() {
|
||||
FileEditorManagerListener editorManagerListener = new FileEditorManagerAdapter() {
|
||||
private FileEditorManagerEvent myLastEvent;
|
||||
|
||||
public void selectionChanged(final FileEditorManagerEvent event) {
|
||||
myLastEvent = event;
|
||||
myAlarm.cancelAllRequests();
|
||||
myAlarm.addRequest(
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (myLastEvent == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (myProject.isDisposed()) {
|
||||
return; // project may have been closed
|
||||
}
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
setFileEditor(myLastEvent.getNewEditor());
|
||||
}
|
||||
finally {
|
||||
myLastEvent = null;
|
||||
}
|
||||
myAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (myLastEvent == null) {
|
||||
return;
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
}, 400
|
||||
);
|
||||
try {
|
||||
if (myProject.isDisposed()) {
|
||||
return; // project may have been closed
|
||||
}
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
setFileEditor(myLastEvent.getNewEditor());
|
||||
}
|
||||
finally {
|
||||
myLastEvent = null;
|
||||
}
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
}, 400);
|
||||
}
|
||||
};
|
||||
FileEditorManager.getInstance(project).addFileEditorManagerListener(myEditorManagerListener);
|
||||
FileEditorManager.getInstance(project).addFileEditorManagerListener(editorManagerListener,this);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -102,7 +99,6 @@ public class StructureViewWrapperImpl implements StructureViewWrapper, Disposabl
|
||||
|
||||
public void dispose() {
|
||||
myFileEditor = null;
|
||||
FileEditorManager.getInstance(myProject).removeFileEditorManagerListener(myEditorManagerListener);
|
||||
rebuild();
|
||||
}
|
||||
|
||||
|
||||
@@ -176,8 +176,8 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
|
||||
private final MessageBusConnection myConnection;
|
||||
private JPanel myTopPanel;
|
||||
private ActionToolbar myToolBar;
|
||||
private Map<String, Element> myUninitializedPaneState = new HashMap<String, Element>();
|
||||
private Map<String, SelectInTarget> mySelectInTargets = new HashMap<String, SelectInTarget>();
|
||||
private final Map<String, Element> myUninitializedPaneState = new HashMap<String, Element>();
|
||||
private final Map<String, SelectInTarget> mySelectInTargets = new HashMap<String, SelectInTarget>();
|
||||
|
||||
public ProjectViewImpl(Project project, final FileEditorManager fileEditorManager, final ToolWindowManagerEx toolWindowManager) {
|
||||
myProject = project;
|
||||
@@ -598,7 +598,7 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
|
||||
}
|
||||
|
||||
class FlattenPackagesDependableAction extends PaneOptionAction {
|
||||
public FlattenPackagesDependableAction(Map<String, Boolean> optionsMap,
|
||||
FlattenPackagesDependableAction(Map<String, Boolean> optionsMap,
|
||||
final String text,
|
||||
final String description,
|
||||
final Icon icon,
|
||||
@@ -929,11 +929,6 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "ProjectView";
|
||||
}
|
||||
|
||||
private final class MyPanel extends JPanel implements DataProvider {
|
||||
MyPanel() {
|
||||
super(new BorderLayout());
|
||||
@@ -1412,7 +1407,7 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
|
||||
}
|
||||
|
||||
private class HideEmptyMiddlePackagesAction extends PaneOptionAction {
|
||||
public HideEmptyMiddlePackagesAction() {
|
||||
private HideEmptyMiddlePackagesAction() {
|
||||
super(myHideEmptyPackages, "", "", null, ourHideEmptyPackagesDefaults);
|
||||
}
|
||||
|
||||
@@ -1490,14 +1485,13 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
|
||||
|
||||
private class MyAutoScrollFromSourceHandler extends AutoScrollFromSourceHandler {
|
||||
private final Alarm myAlarm = new Alarm(myProject);
|
||||
private FileEditorManagerAdapter myEditorManagerListener;
|
||||
|
||||
public MyAutoScrollFromSourceHandler() {
|
||||
private MyAutoScrollFromSourceHandler() {
|
||||
super(ProjectViewImpl.this.myProject, ProjectViewImpl.this);
|
||||
}
|
||||
|
||||
public void install() {
|
||||
myEditorManagerListener = new FileEditorManagerAdapter() {
|
||||
FileEditorManagerAdapter myEditorManagerListener = new FileEditorManagerAdapter() {
|
||||
public void selectionChanged(final FileEditorManagerEvent event) {
|
||||
final FileEditor newEditor = event.getNewEditor();
|
||||
myAlarm.cancelAllRequests();
|
||||
@@ -1514,7 +1508,7 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
|
||||
}, 300, ModalityState.NON_MODAL);
|
||||
}
|
||||
};
|
||||
myFileEditorManager.addFileEditorManagerListener(myEditorManagerListener);
|
||||
myFileEditorManager.addFileEditorManagerListener(myEditorManagerListener, this);
|
||||
}
|
||||
|
||||
public void scrollFromSource() {
|
||||
@@ -1541,9 +1535,6 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (myEditorManagerListener != null) {
|
||||
myFileEditorManager.removeFileEditorManagerListener(myEditorManagerListener);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isAutoScrollMode() {
|
||||
@@ -1564,7 +1555,7 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
|
||||
private final PsiFile myPsiFile;
|
||||
private final Editor myEditor;
|
||||
|
||||
public MySelectInContext(final PsiFile psiFile, Editor editor) {
|
||||
private MySelectInContext(final PsiFile psiFile, Editor editor) {
|
||||
myPsiFile = psiFile;
|
||||
myEditor = editor;
|
||||
}
|
||||
|
||||
@@ -7,31 +7,33 @@ package com.intellij.ide.todo;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ChangeList;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListAdapter;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.util.Alarm;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class ChangeListTodosPanel extends TodoPanel{
|
||||
private final MyChangeListManagerListener myChangeListManagerListener = new MyChangeListManagerListener();
|
||||
private final Alarm myAlarm;
|
||||
|
||||
public ChangeListTodosPanel(Project project,TodoPanelSettings settings, Content content){
|
||||
super(project,settings,false,content);
|
||||
ChangeListManager changeListManager = ChangeListManager.getInstance(project);
|
||||
final MyChangeListManagerListener myChangeListManagerListener = new MyChangeListManagerListener();
|
||||
changeListManager.addChangeListListener(myChangeListManagerListener);
|
||||
Disposer.register(this, new Disposable() {
|
||||
public void dispose() {
|
||||
ChangeListManager.getInstance(myProject).removeChangeListListener(myChangeListManagerListener);
|
||||
}
|
||||
});
|
||||
myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD, project);
|
||||
}
|
||||
|
||||
void dispose(){
|
||||
ChangeListManager.getInstance(myProject).removeChangeListListener(myChangeListManagerListener);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private final class MyChangeListManagerListener extends ChangeListAdapter {
|
||||
public void defaultListChanged(final ChangeList oldDefaultList, final ChangeList newDefaultList) {
|
||||
rebuild();
|
||||
|
||||
@@ -21,23 +21,16 @@ import javax.swing.tree.TreePath;
|
||||
abstract class CurrentFileTodosPanel extends TodoPanel{
|
||||
private static final Logger LOG=Logger.getInstance("#com.intellij.ide.todo.CurrentFileTodosPanel");
|
||||
|
||||
private final MyFileEditorManagerListener myFileEditorManagerListener;
|
||||
|
||||
public CurrentFileTodosPanel(Project project,TodoPanelSettings settings,Content content){
|
||||
CurrentFileTodosPanel(Project project,TodoPanelSettings settings,Content content){
|
||||
super(project,settings,true,content);
|
||||
FileEditorManager fileEditorManager=FileEditorManager.getInstance(project);
|
||||
VirtualFile[] files=fileEditorManager.getSelectedFiles();
|
||||
PsiFile psiFile = files.length != 0 ? PsiManager.getInstance(myProject).findFile(files[0]) : null;
|
||||
PsiFile psiFile = files.length == 0 ? null : PsiManager.getInstance(myProject).findFile(files[0]);
|
||||
setFile(psiFile);
|
||||
myFileEditorManagerListener=new MyFileEditorManagerListener();
|
||||
fileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener);
|
||||
}
|
||||
|
||||
void dispose(){
|
||||
MyFileEditorManagerListener fileEditorManagerListener = new MyFileEditorManagerListener();
|
||||
// It's important to remove this listener. It prevents invocation of setFile method after the tree builder
|
||||
// is disposed.
|
||||
FileEditorManager.getInstance(myProject).removeFileEditorManagerListener(myFileEditorManagerListener);
|
||||
super.dispose();
|
||||
fileEditorManager.addFileEditorManagerListener(fileEditorManagerListener,this);
|
||||
}
|
||||
|
||||
private void setFile(PsiFile file){
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.ide.todo.nodes.TodoFileNode;
|
||||
import com.intellij.ide.todo.nodes.TodoItemNode;
|
||||
import com.intellij.ide.todo.nodes.TodoTreeHelper;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
|
||||
import com.intellij.openapi.actionSystem.impl.ActionButton;
|
||||
@@ -32,8 +33,8 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.ui.AutoScrollToSourceHandler;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.TreeSpeedSearch;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.EditSourceOnDoubleClickHandler;
|
||||
import com.intellij.util.Icons;
|
||||
import com.intellij.util.OpenSourceUtil;
|
||||
@@ -54,7 +55,7 @@ import java.awt.event.KeyEvent;
|
||||
/**
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavigator, DataProvider {
|
||||
abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavigator, DataProvider, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.todo.TodoPanel");
|
||||
|
||||
protected Project myProject;
|
||||
@@ -72,7 +73,7 @@ abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavig
|
||||
* @param currentFileMode if <code>true</code> then view doesn't have "Group By Packages" and "Flatten Packages"
|
||||
* actions.
|
||||
*/
|
||||
public TodoPanel(Project project,
|
||||
TodoPanel(Project project,
|
||||
TodoPanelSettings settings,
|
||||
boolean currentFileMode,
|
||||
Content content) {
|
||||
@@ -185,7 +186,7 @@ abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavig
|
||||
setToolbar(toolBarPanel);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
public void dispose() {
|
||||
myVisibilityWatcher.deinstall(this);
|
||||
myVisibilityWatcher = null;
|
||||
myProject = null;
|
||||
@@ -358,7 +359,7 @@ abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavig
|
||||
* Provides support for "auto scroll to source" functionnality.
|
||||
*/
|
||||
private final class MyAutoScrollToSourceHandler extends AutoScrollToSourceHandler {
|
||||
public MyAutoScrollToSourceHandler() {
|
||||
MyAutoScrollToSourceHandler() {
|
||||
}
|
||||
|
||||
protected boolean isAutoScrollMode() {
|
||||
@@ -497,7 +498,7 @@ abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavig
|
||||
}
|
||||
|
||||
private final class MyShowPackagesAction extends ToggleAction {
|
||||
public MyShowPackagesAction() {
|
||||
MyShowPackagesAction() {
|
||||
super(IdeBundle.message("action.group.by.packages"), null, Icons.GROUP_BY_PACKAGES);
|
||||
}
|
||||
|
||||
@@ -512,7 +513,7 @@ abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavig
|
||||
}
|
||||
|
||||
private final class MyShowModulesAction extends ToggleAction {
|
||||
public MyShowModulesAction() {
|
||||
MyShowModulesAction() {
|
||||
super(IdeBundle.message("action.group.by.modules"), null, IconLoader.getIcon("/objectBrowser/showModules.png"));
|
||||
}
|
||||
|
||||
@@ -527,7 +528,7 @@ abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavig
|
||||
}
|
||||
|
||||
private final class MyFlattenPackagesAction extends ToggleAction {
|
||||
public MyFlattenPackagesAction() {
|
||||
MyFlattenPackagesAction() {
|
||||
super(IdeBundle.message("action.flatten.packages"), null, Icons.FLATTEN_PACKAGES_ICON);
|
||||
}
|
||||
|
||||
@@ -547,7 +548,7 @@ abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavig
|
||||
}
|
||||
|
||||
private final class MySetTodoFilterAction extends AnAction implements CustomComponentAction {
|
||||
public MySetTodoFilterAction() {
|
||||
MySetTodoFilterAction() {
|
||||
super(IdeBundle.message("action.filter.todo.items"), null, IconLoader.getIcon("/ant/filter.png"));
|
||||
}
|
||||
|
||||
@@ -599,7 +600,7 @@ abstract class TodoPanel extends SimpleToolWindowPanel implements OccurenceNavig
|
||||
* @param description action's description.
|
||||
* @param filter filter to be applied. <code>null</code> value means "empty" filter.
|
||||
*/
|
||||
public TodoFilterApplier(String text, String description, TodoFilter filter) {
|
||||
TodoFilterApplier(String text, String description, TodoFilter filter) {
|
||||
super(null, description, null);
|
||||
getTemplatePresentation().setText(text, false);
|
||||
myFilter = filter;
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.intellij.openapi.fileTypes.FileTypeListener;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.VcsListener;
|
||||
@@ -44,8 +45,6 @@ import java.beans.PropertyChangeListener;
|
||||
public class TodoView implements PersistentStateComponent<Element>, Disposable {
|
||||
private final Project myProject;
|
||||
private final ProjectLevelVcsManager myVCSManager;
|
||||
private MyPropertyChangeListener myPropertyChangeListener;
|
||||
private MessageBusConnection myConnection;
|
||||
|
||||
private ContentManager myContentManager;
|
||||
private CurrentFileTodosPanel myCurrentFileTodos;
|
||||
@@ -76,11 +75,17 @@ public class TodoView implements PersistentStateComponent<Element>, Disposable {
|
||||
myChangeListTodosPanelSettings = new TodoPanelSettings();
|
||||
|
||||
myVCSManager.addVcsListener(myVcsListener);
|
||||
myPropertyChangeListener=new MyPropertyChangeListener();
|
||||
TodoConfiguration.getInstance().addPropertyChangeListener(myPropertyChangeListener);
|
||||
|
||||
myConnection = myProject.getMessageBus().connect();
|
||||
myConnection.subscribe(AppTopics.FILE_TYPES, new MyFileTypeListener());
|
||||
final MyPropertyChangeListener myPropertyChangeListener = new MyPropertyChangeListener();
|
||||
TodoConfiguration.getInstance().addPropertyChangeListener(myPropertyChangeListener);
|
||||
Disposer.register(this, new Disposable() {
|
||||
public void dispose() {
|
||||
TodoConfiguration.getInstance().removePropertyChangeListener(myPropertyChangeListener);
|
||||
}
|
||||
});
|
||||
|
||||
MessageBusConnection connection = myProject.getMessageBus().connect(this);
|
||||
connection.subscribe(AppTopics.FILE_TYPES, new MyFileTypeListener());
|
||||
}
|
||||
|
||||
public void loadState(Element element) {
|
||||
@@ -137,14 +142,6 @@ public class TodoView implements PersistentStateComponent<Element>, Disposable {
|
||||
|
||||
public void dispose() {
|
||||
myVCSManager.removeVcsListener(myVcsListener);
|
||||
TodoConfiguration.getInstance().removePropertyChangeListener(myPropertyChangeListener);
|
||||
myConnection.disconnect();
|
||||
|
||||
if(myAllTodos!=null){ // Panels can be null if project was closed before starup activities run
|
||||
myCurrentFileTodos.dispose();
|
||||
myAllTodos.dispose();
|
||||
myChangeListTodos.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void initToolWindow(ToolWindow toolWindow) {
|
||||
@@ -159,6 +156,7 @@ public class TodoView implements PersistentStateComponent<Element>, Disposable {
|
||||
}
|
||||
};
|
||||
allTodosContent.setComponent(myAllTodos);
|
||||
Disposer.register(this, myAllTodos);
|
||||
|
||||
Content currentFileTodosContent=
|
||||
ContentFactory.SERVICE.getInstance().createContent(null,IdeBundle.message("title.todo.current.file"),false);
|
||||
@@ -169,6 +167,7 @@ public class TodoView implements PersistentStateComponent<Element>, Disposable {
|
||||
return builder;
|
||||
}
|
||||
};
|
||||
Disposer.register(this, myCurrentFileTodos);
|
||||
currentFileTodosContent.setComponent(myCurrentFileTodos);
|
||||
|
||||
myChangeListTodosContent = ContentFactory.SERVICE.getInstance()
|
||||
@@ -182,6 +181,7 @@ public class TodoView implements PersistentStateComponent<Element>, Disposable {
|
||||
return builder;
|
||||
}
|
||||
};
|
||||
Disposer.register(this, myChangeListTodos);
|
||||
myChangeListTodosContent.setComponent(myChangeListTodos);
|
||||
|
||||
myContentManager=toolWindow.getContentManager();
|
||||
|
||||
+9
-7
@@ -7,21 +7,22 @@ import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.EditorNotificationPanel;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.ui.EditorNotificationPanel;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.text.DateFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -31,15 +32,16 @@ public class OutdatedVersionNotifier implements ProjectComponent {
|
||||
|
||||
private final FileEditorManager myFileEditorManager;
|
||||
private final CommittedChangesCache myCache;
|
||||
private final FileEditorManagerListener myFileEditorManagerListener = new MyFileEditorManagerListener();
|
||||
private final Project myProject;
|
||||
private static final Key<OutdatedRevisionPanel> PANEL_KEY = new Key<OutdatedRevisionPanel>("OutdatedRevisionPanel");
|
||||
private volatile boolean myIncomingChangesRequested;
|
||||
|
||||
public OutdatedVersionNotifier(FileEditorManager fileEditorManager,
|
||||
CommittedChangesCache cache,
|
||||
MessageBus messageBus) {
|
||||
MessageBus messageBus, Project project) {
|
||||
myFileEditorManager = fileEditorManager;
|
||||
myCache = cache;
|
||||
myProject = project;
|
||||
messageBus.connect().subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() {
|
||||
public void incomingChangesUpdated(@Nullable final List<CommittedChangeList> receivedChanges) {
|
||||
if (myCache.getCachedIncomingChanges() == null) {
|
||||
@@ -70,11 +72,11 @@ public class OutdatedVersionNotifier implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void projectOpened() {
|
||||
myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener);
|
||||
final FileEditorManagerListener myFileEditorManagerListener = new MyFileEditorManagerListener();
|
||||
myFileEditorManager.addFileEditorManagerListener(myFileEditorManagerListener, myProject);
|
||||
}
|
||||
|
||||
public void projectClosed() {
|
||||
myFileEditorManager.removeFileEditorManagerListener(myFileEditorManagerListener);
|
||||
}
|
||||
|
||||
@NonNls
|
||||
|
||||
Reference in New Issue
Block a user