1
1
package ts .eclipse .ide .ui .outline ;
2
2
3
+ import java .util .List ;
4
+
3
5
import org .eclipse .jface .dialogs .Dialog ;
4
6
import org .eclipse .jface .dialogs .PopupDialog ;
5
7
import org .eclipse .jface .text .IInformationControl ;
40
42
import org .eclipse .swt .widgets .TreeItem ;
41
43
import org .eclipse .ui .internal .ide .StringMatcher ;
42
44
45
+ import ts .client .navbar .NavigationBarItem ;
43
46
import ts .eclipse .ide .core .resources .IIDETypeScriptFile ;
47
+ import ts .resources .INavbarListener ;
44
48
45
- public class TypeScriptQuickOutlineDialog extends PopupDialog
46
- implements IInformationControl , IInformationControlExtension , IInformationControlExtension2 , DisposeListener {
49
+ public class TypeScriptQuickOutlineDialog extends PopupDialog implements IInformationControl ,
50
+ IInformationControlExtension , IInformationControlExtension2 , DisposeListener , INavbarListener {
47
51
48
52
/**
49
53
* Current tree viewer for the dialog
@@ -78,11 +82,6 @@ public class TypeScriptQuickOutlineDialog extends PopupDialog
78
82
*/
79
83
private ILabelProvider treeLabelProvider ;
80
84
81
- /**
82
- * Outline page
83
- */
84
- private TypeScriptContentOutlinePage outlinePage ;
85
-
86
85
private IIDETypeScriptFile tsFile ;
87
86
88
87
/**
@@ -98,6 +97,7 @@ public class TypeScriptQuickOutlineDialog extends PopupDialog
98
97
public TypeScriptQuickOutlineDialog (Shell parent , int shellStyle , IIDETypeScriptFile tsFile ) {
99
98
super (parent , shellStyle , true , true , false , true , true , null , null );
100
99
this .tsFile = tsFile ;
100
+ this .tsFile .addNavbarListener (this );
101
101
initialize ();
102
102
// Create all controls early to preserve the life cycle of the original
103
103
// implementation.
@@ -120,7 +120,7 @@ private void initialize() {
120
120
@ Override
121
121
protected Control createDialogArea (Composite parent ) {
122
122
// Create an empty dialog area, if the source page is not defined
123
- if (outlinePage == null ) {
123
+ if (tsFile == null ) {
124
124
return super .createDialogArea (parent );
125
125
}
126
126
createTreeViewer (parent );
@@ -166,7 +166,7 @@ private void createTreeViewer(Composite parent) {
166
166
treeViewer .setLabelProvider (treeLabelProvider );
167
167
treeViewer .setAutoExpandLevel (AbstractTreeViewer .ALL_LEVELS );
168
168
treeViewer .setUseHashlookup (true );
169
- treeViewer .setInput (tsFile );
169
+ treeViewer .setInput (tsFile . getNavBar () );
170
170
}
171
171
172
172
/**
@@ -287,7 +287,7 @@ private void gotoSelectedElement() {
287
287
return ;
288
288
}
289
289
dispose ();
290
- //outlinePage.setSelection(new StructuredSelection(selectedElement));
290
+ // outlinePage.setSelection(new StructuredSelection(selectedElement));
291
291
}
292
292
293
293
@ Override
@@ -474,7 +474,7 @@ public void setInput(Object input) {
474
474
// Input comes from PDESourceInfoProvider.getInformation2()
475
475
// The input should be a model object of some sort
476
476
// Turn it into a structured selection and set the selection in the tree
477
- if (input != null && treeViewer != null ) {
477
+ if (input != null && treeViewer != null ) {
478
478
treeViewer .setSelection (new StructuredSelection (input ));
479
479
}
480
480
}
@@ -542,6 +542,9 @@ public void setLocation(Point location) {
542
542
543
543
@ Override
544
544
public void dispose () {
545
+ if (tsFile != null ) {
546
+ this .tsFile .removeNavbarListener (this );
547
+ }
545
548
close ();
546
549
}
547
550
@@ -658,4 +661,17 @@ public void setStringMatcher(StringMatcher newStringMatcher) {
658
661
}
659
662
660
663
}
664
+
665
+ @ Override
666
+ public void navBarChanged (final List <NavigationBarItem > items ) {
667
+ if (treeViewer != null ) {
668
+ treeViewer .getTree ().getDisplay ().asyncExec (new Runnable () {
669
+
670
+ @ Override
671
+ public void run () {
672
+ treeViewer .setInput (items );
673
+ }
674
+ });
675
+ }
676
+ }
661
677
}
0 commit comments