mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-77663: Lazy bookmark manager loading causes bookmarks to appear in editor only after some bookmark actions have been called. Also, ctrl/cmd+click bookmark toggling is re-done (never actually worked)
This commit is contained in:
@@ -289,6 +289,10 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
if (event.getButton() != 1) {
|
||||
return;
|
||||
}
|
||||
if (e.getMouseEvent().isControlDown() || e.getMouseEvent().isMetaDown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (XDebuggerUtil.getInstance().canPutBreakpointAt(myProject, FileDocumentManager.getInstance().getFile(document), line)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,23 +16,23 @@
|
||||
|
||||
package com.intellij.ide.bookmarks;
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.event.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.util.*;
|
||||
@@ -44,7 +44,7 @@ import java.util.List;
|
||||
@Storage( file = "$WORKSPACE_FILE$")
|
||||
}
|
||||
)
|
||||
public class BookmarkManager implements PersistentStateComponent<Element> {
|
||||
public class BookmarkManager implements PersistentStateComponent<Element>, ProjectComponent {
|
||||
|
||||
private static final int MAX_AUTO_DESCRIPTION_SIZE = 50;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BookmarkManager implements PersistentStateComponent<Element> {
|
||||
private final MessageBus myBus;
|
||||
|
||||
public static BookmarkManager getInstance(Project project) {
|
||||
return ServiceManager.getService(project, BookmarkManager.class);
|
||||
return project.getComponent(BookmarkManager.class);
|
||||
}
|
||||
|
||||
public BookmarkManager(Project project, MessageBus bus) {
|
||||
@@ -65,8 +65,24 @@ public class BookmarkManager implements PersistentStateComponent<Element> {
|
||||
}
|
||||
|
||||
public void projectOpened() {
|
||||
EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
|
||||
eventMulticaster.addEditorMouseListener(myEditorMouseListener, myProject);
|
||||
EditorFactory.getInstance().getEventMulticaster().addEditorMouseListener(myEditorMouseListener, myProject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
EditorFactory.getInstance().getEventMulticaster().removeEditorMouseListener(myEditorMouseListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return "BookmarkManager";
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
@@ -174,15 +190,19 @@ public class BookmarkManager implements PersistentStateComponent<Element> {
|
||||
return container;
|
||||
}
|
||||
|
||||
public void loadState(Element state) {
|
||||
BookmarksListener publisher = myBus.syncPublisher(BookmarksListener.TOPIC);
|
||||
for (Bookmark bookmark : myBookmarks) {
|
||||
bookmark.release();
|
||||
publisher.bookmarkRemoved(bookmark);
|
||||
}
|
||||
myBookmarks.clear();
|
||||
public void loadState(final Element state) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
BookmarksListener publisher = myBus.syncPublisher(BookmarksListener.TOPIC);
|
||||
for (Bookmark bookmark : myBookmarks) {
|
||||
bookmark.release();
|
||||
publisher.bookmarkRemoved(bookmark);
|
||||
}
|
||||
myBookmarks.clear();
|
||||
|
||||
readExternal(state);
|
||||
readExternal(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void readExternal(Element element) {
|
||||
@@ -338,7 +358,7 @@ public class BookmarkManager implements PersistentStateComponent<Element> {
|
||||
public void mouseClicked(final EditorMouseEvent e) {
|
||||
if (e.getArea() != EditorMouseEventArea.LINE_MARKERS_AREA) return;
|
||||
if (e.getMouseEvent().isPopupTrigger()) return;
|
||||
if ((e.getMouseEvent().getModifiers() & InputEvent.CTRL_MASK) == 0) return;
|
||||
if ((e.getMouseEvent().getModifiers() & (SystemInfo.isMac ? InputEvent.META_MASK : InputEvent.CTRL_MASK)) == 0) return;
|
||||
|
||||
Editor editor = e.getEditor();
|
||||
int line = editor.xyToLogicalPosition(new Point(e.getMouseEvent().getX(), e.getMouseEvent().getY())).line;
|
||||
|
||||
@@ -610,9 +610,6 @@
|
||||
<projectService serviceInterface="com.intellij.execution.ui.RunnerLayoutUi$Factory"
|
||||
serviceImplementation="com.intellij.execution.ui.layout.impl.RunnerLayoutUiFactoryImpl"/>
|
||||
|
||||
<projectService serviceInterface="com.intellij.ide.bookmarks.BookmarkManager"
|
||||
serviceImplementation="com.intellij.ide.bookmarks.BookmarkManager"/>
|
||||
|
||||
<http.fileEditorActionProvider implementation="com.intellij.openapi.fileEditor.impl.http.LangRemoteFileEditorActionProvider"/>
|
||||
|
||||
<toolWindow id="Project" anchor="left" icon="/general/toolWindowProject.png"
|
||||
|
||||
@@ -66,5 +66,8 @@
|
||||
<component>
|
||||
<implementation-class>com.intellij.ui.switcher.QuickActionManager</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>com.intellij.ide.bookmarks.BookmarkManager</implementation-class>
|
||||
</component>
|
||||
</project-components>
|
||||
</components>
|
||||
|
||||
+1
@@ -235,6 +235,7 @@ public class XLineBreakpointManager {
|
||||
final Editor editor = e.getEditor();
|
||||
final MouseEvent mouseEvent = e.getMouseEvent();
|
||||
if (mouseEvent.isPopupTrigger()
|
||||
|| mouseEvent.isMetaDown() || mouseEvent.isControlDown()
|
||||
|| mouseEvent.getButton() != MouseEvent.BUTTON1
|
||||
|| MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(editor)
|
||||
|| e.getArea() != EditorMouseEventArea.LINE_MARKERS_AREA
|
||||
|
||||
Reference in New Issue
Block a user