|
9 | 9 | import com.google.common.collect.Maps;
|
10 | 10 | import com.google.common.collect.Sets;
|
11 | 11 | import com.intellij.icons.AllIcons;
|
12 |
| -import com.intellij.ide.CommonActionsManager; |
13 |
| -import com.intellij.ide.DefaultTreeExpander; |
14 |
| -import com.intellij.ide.TreeExpander; |
15 | 12 | import com.intellij.openapi.actionSystem.*;
|
16 | 13 | import com.intellij.openapi.application.ApplicationManager;
|
17 | 14 | import com.intellij.openapi.components.PersistentStateComponent;
|
18 | 15 | import com.intellij.openapi.components.Storage;
|
19 | 16 | import com.intellij.openapi.editor.Caret;
|
20 | 17 | import com.intellij.openapi.editor.Editor;
|
21 |
| -import com.intellij.openapi.editor.event.CaretEvent; |
22 |
| -import com.intellij.openapi.editor.event.CaretListener; |
23 | 18 | import com.intellij.openapi.fileEditor.*;
|
24 | 19 | import com.intellij.openapi.project.Project;
|
25 | 20 | import com.intellij.openapi.ui.SimpleToolWindowPanel;
|
|
28 | 23 | import com.intellij.openapi.util.text.StringUtil;
|
29 | 24 | import com.intellij.openapi.vfs.VirtualFile;
|
30 | 25 | import com.intellij.openapi.wm.ToolWindow;
|
31 |
| -import com.intellij.openapi.wm.ex.ToolWindowEx; |
32 | 26 | import com.intellij.ui.*;
|
33 |
| -import com.intellij.ui.content.Content; |
34 | 27 | import com.intellij.ui.content.ContentFactory;
|
35 | 28 | import com.intellij.ui.content.ContentManager;
|
36 | 29 | import com.intellij.ui.speedSearch.SpeedSearchUtil;
|
37 | 30 | import com.intellij.ui.treeStructure.Tree;
|
38 | 31 | import com.intellij.util.messages.MessageBusConnection;
|
39 | 32 | import io.flutter.FlutterUtils;
|
40 | 33 | import io.flutter.dart.FlutterDartAnalysisServer;
|
41 |
| -import io.flutter.dart.FlutterOutlineListener; |
42 | 34 | import io.flutter.editor.PropertyEditorPanel;
|
43 | 35 | import io.flutter.inspector.InspectorGroupManagerService;
|
44 | 36 | import io.flutter.settings.FlutterSettings;
|
|
62 | 54 | import javax.swing.tree.TreeNode;
|
63 | 55 | import javax.swing.tree.TreePath;
|
64 | 56 | import java.awt.*;
|
65 |
| -import java.awt.event.MouseAdapter; |
66 |
| -import java.awt.event.MouseEvent; |
67 |
| -import java.beans.PropertyChangeEvent; |
68 |
| -import java.beans.PropertyChangeListener; |
69 | 57 | import java.util.List;
|
70 | 58 | import java.util.*;
|
71 | 59 |
|
@@ -106,34 +94,34 @@ public class PreviewView implements PersistentStateComponent<PreviewViewState> {
|
106 | 94 | private final EventStream<List<FlutterOutline>> activeOutlines;
|
107 | 95 |
|
108 | 96 | private final WidgetEditToolbar widgetEditToolbar;
|
109 |
| - private final FlutterOutlineListener outlineListener = new FlutterOutlineListener() { |
110 |
| - @Override |
111 |
| - public void outlineUpdated(@NotNull String filePath, @NotNull FlutterOutline outline, @Nullable String instrumentedCode) { |
112 |
| - |
113 |
| - final String filePathOrUri = flutterAnalysisServer.getAnalysisService().getLocalFileUri(currentFilePath); |
114 |
| - if (Objects.equals(filePathOrUri, filePath)) { |
115 |
| - ApplicationManager.getApplication().invokeLater(() -> updateOutline(outline)); |
116 |
| - } |
117 |
| - } |
118 |
| - }; |
119 |
| - |
120 |
| - private final CaretListener caretListener = new CaretListener() { |
121 |
| - @Override |
122 |
| - public void caretPositionChanged(CaretEvent e) { |
123 |
| - final Caret caret = e.getCaret(); |
124 |
| - if (caret != null) { |
125 |
| - ApplicationManager.getApplication().invokeLater(() -> applyEditorSelectionToTree(caret)); |
126 |
| - } |
127 |
| - } |
128 |
| - |
129 |
| - @Override |
130 |
| - public void caretAdded(@NotNull CaretEvent e) { |
131 |
| - } |
132 |
| - |
133 |
| - @Override |
134 |
| - public void caretRemoved(@NotNull CaretEvent e) { |
135 |
| - } |
136 |
| - }; |
| 97 | + //private final FlutterOutlineListener outlineListener = new FlutterOutlineListener() { |
| 98 | + // @Override |
| 99 | + // public void outlineUpdated(@NotNull String filePath, @NotNull FlutterOutline outline, @Nullable String instrumentedCode) { |
| 100 | + // |
| 101 | + // final String filePathOrUri = flutterAnalysisServer.getAnalysisService().getLocalFileUri(currentFilePath); |
| 102 | + // if (Objects.equals(filePathOrUri, filePath)) { |
| 103 | + // ApplicationManager.getApplication().invokeLater(() -> updateOutline(outline)); |
| 104 | + // } |
| 105 | + // } |
| 106 | + //}; |
| 107 | + |
| 108 | + //private final CaretListener caretListener = new CaretListener() { |
| 109 | + // @Override |
| 110 | + // public void caretPositionChanged(CaretEvent e) { |
| 111 | + // final Caret caret = e.getCaret(); |
| 112 | + // if (caret != null) { |
| 113 | + // ApplicationManager.getApplication().invokeLater(() -> applyEditorSelectionToTree(caret)); |
| 114 | + // } |
| 115 | + // } |
| 116 | + // |
| 117 | + // @Override |
| 118 | + // public void caretAdded(@NotNull CaretEvent e) { |
| 119 | + // } |
| 120 | + // |
| 121 | + // @Override |
| 122 | + // public void caretRemoved(@NotNull CaretEvent e) { |
| 123 | + // } |
| 124 | + //}; |
137 | 125 |
|
138 | 126 | private final TreeSelectionListener treeSelectionListener = this::handleTreeSelectionEvent;
|
139 | 127 | private PropertyEditorPanel propertyEditPanel;
|
@@ -216,9 +204,9 @@ public void initToolWindow(@NotNull ToolWindow toolWindow) {
|
216 | 204 | //
|
217 | 205 | //windowPanel.setToolbar(widgetEditToolbar.getToolbar().getComponent());
|
218 | 206 | //
|
219 |
| - //final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(); |
220 |
| - // |
221 |
| - //tree = new OutlineTree(rootNode); |
| 207 | + final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(); |
| 208 | + |
| 209 | + tree = new OutlineTree(rootNode); |
222 | 210 | //tree.setCellRenderer(new OutlineTreeCellRenderer());
|
223 | 211 | //tree.expandAll();
|
224 | 212 | //
|
@@ -340,15 +328,15 @@ private void jumpToOutlineInEditor(FlutterOutline outline, boolean focusEditor)
|
340 | 328 | final int offset = outline.getDartElement() != null ? outline.getDartElement().getLocation().getOffset() : outline.getOffset();
|
341 | 329 | final int editorOffset = getOutlineOffsetConverter().getConvertedFileOffset(offset);
|
342 | 330 |
|
343 |
| - if (currentFile != null) { |
344 |
| - currentEditor.getCaretModel().removeCaretListener(caretListener); |
345 |
| - try { |
346 |
| - new OpenFileDescriptor(project, currentFile.getValue(), editorOffset).navigate(focusEditor); |
347 |
| - } |
348 |
| - finally { |
349 |
| - currentEditor.getCaretModel().addCaretListener(caretListener); |
350 |
| - } |
351 |
| - } |
| 331 | + //if (currentFile != null) { |
| 332 | + // currentEditor.getCaretModel().removeCaretListener(caretListener); |
| 333 | + // try { |
| 334 | + // new OpenFileDescriptor(project, currentFile.getValue(), editorOffset).navigate(focusEditor); |
| 335 | + // } |
| 336 | + // finally { |
| 337 | + // currentEditor.getCaretModel().addCaretListener(caretListener); |
| 338 | + // } |
| 339 | + //} |
352 | 340 | }
|
353 | 341 |
|
354 | 342 | // TODO: Add parent relationship info to FlutterOutline instead of this O(n^2) traversal.
|
@@ -517,7 +505,7 @@ private void addOutlinesCoveredByRange(List<FlutterOutline> covered, int start,
|
517 | 505 |
|
518 | 506 | private void setSelectedFile(VirtualFile newFile) {
|
519 | 507 | if (currentFile.getValue() != null) {
|
520 |
| - flutterAnalysisServer.removeOutlineListener(currentFilePath, outlineListener); |
| 508 | + //flutterAnalysisServer.removeOutlineListener(currentFilePath, outlineListener); |
521 | 509 | currentFile.setValue(null);
|
522 | 510 | currentFilePath = null;
|
523 | 511 | }
|
@@ -548,19 +536,19 @@ else if (windowPanel.isToolbarVisible()) {
|
548 | 536 | if (newFile != null) {
|
549 | 537 | currentFile.setValue(newFile);
|
550 | 538 | currentFilePath = FileUtil.toSystemDependentName(newFile.getPath());
|
551 |
| - flutterAnalysisServer.addOutlineListener(currentFilePath, outlineListener); |
| 539 | + //flutterAnalysisServer.addOutlineListener(currentFilePath, outlineListener); |
552 | 540 | }
|
553 | 541 | }
|
554 | 542 |
|
555 | 543 | private void setSelectedEditor(FileEditor newEditor) {
|
556 |
| - if (currentEditor != null) { |
557 |
| - currentEditor.getCaretModel().removeCaretListener(caretListener); |
558 |
| - } |
559 |
| - if (newEditor instanceof TextEditor) { |
560 |
| - currentFileEditor = newEditor; |
561 |
| - currentEditor = ((TextEditor)newEditor).getEditor(); |
562 |
| - currentEditor.getCaretModel().addCaretListener(caretListener); |
563 |
| - } |
| 544 | + //if (currentEditor != null) { |
| 545 | + // currentEditor.getCaretModel().removeCaretListener(caretListener); |
| 546 | + //} |
| 547 | + //if (newEditor instanceof TextEditor) { |
| 548 | + // currentFileEditor = newEditor; |
| 549 | + // currentEditor = ((TextEditor)newEditor).getEditor(); |
| 550 | + // currentEditor.getCaretModel().addCaretListener(caretListener); |
| 551 | + //} |
564 | 552 | }
|
565 | 553 |
|
566 | 554 | private void applyEditorSelectionToTree(Caret caret) {
|
|
0 commit comments