Skip to content

Commit 2666e20

Browse files
author
angelozerr
committed
Open Quick Outline. See
#51
1 parent 0671ea5 commit 2666e20

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

core/ts.core/src/ts/resources/AbstractTypeScriptFile.java

+5
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ public void removeNavbarListener(INavbarListener listener) {
216216
}
217217
}
218218

219+
@Override
220+
public List<NavigationBarItem> getNavBar() {
221+
return navbar;
222+
}
223+
219224
// @Override
220225
// public List<NavigationBarItem> getNavBar() throws TypeScriptException {
221226
// TypeScriptNavBarCollector c = new TypeScriptNavBarCollector();

core/ts.core/src/ts/resources/ITypeScriptFile.java

+2
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,6 @@ public interface ITypeScriptFile {
148148
void addNavbarListener(INavbarListener listener);
149149

150150
void removeNavbarListener(INavbarListener listener);
151+
152+
List<NavigationBarItem> getNavBar();
151153
}

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/outline/TypeScriptContentOutlinePage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void doubleClick(DoubleClickEvent event) {
8484
}
8585
});
8686
viewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
87-
viewer.setInput(tsFile);
87+
//viewer.setInput(tsFile);
8888

8989
}
9090

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/outline/TypeScriptQuickOutlineDialog.java

+27-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package ts.eclipse.ide.ui.outline;
22

3+
import java.util.List;
4+
35
import org.eclipse.jface.dialogs.Dialog;
46
import org.eclipse.jface.dialogs.PopupDialog;
57
import org.eclipse.jface.text.IInformationControl;
@@ -40,10 +42,12 @@
4042
import org.eclipse.swt.widgets.TreeItem;
4143
import org.eclipse.ui.internal.ide.StringMatcher;
4244

45+
import ts.client.navbar.NavigationBarItem;
4346
import ts.eclipse.ide.core.resources.IIDETypeScriptFile;
47+
import ts.resources.INavbarListener;
4448

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 {
4751

4852
/**
4953
* Current tree viewer for the dialog
@@ -78,11 +82,6 @@ public class TypeScriptQuickOutlineDialog extends PopupDialog
7882
*/
7983
private ILabelProvider treeLabelProvider;
8084

81-
/**
82-
* Outline page
83-
*/
84-
private TypeScriptContentOutlinePage outlinePage;
85-
8685
private IIDETypeScriptFile tsFile;
8786

8887
/**
@@ -98,6 +97,7 @@ public class TypeScriptQuickOutlineDialog extends PopupDialog
9897
public TypeScriptQuickOutlineDialog(Shell parent, int shellStyle, IIDETypeScriptFile tsFile) {
9998
super(parent, shellStyle, true, true, false, true, true, null, null);
10099
this.tsFile = tsFile;
100+
this.tsFile.addNavbarListener(this);
101101
initialize();
102102
// Create all controls early to preserve the life cycle of the original
103103
// implementation.
@@ -120,7 +120,7 @@ private void initialize() {
120120
@Override
121121
protected Control createDialogArea(Composite parent) {
122122
// Create an empty dialog area, if the source page is not defined
123-
if (outlinePage == null) {
123+
if (tsFile == null) {
124124
return super.createDialogArea(parent);
125125
}
126126
createTreeViewer(parent);
@@ -166,7 +166,7 @@ private void createTreeViewer(Composite parent) {
166166
treeViewer.setLabelProvider(treeLabelProvider);
167167
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
168168
treeViewer.setUseHashlookup(true);
169-
treeViewer.setInput(tsFile);
169+
treeViewer.setInput(tsFile.getNavBar());
170170
}
171171

172172
/**
@@ -287,7 +287,7 @@ private void gotoSelectedElement() {
287287
return;
288288
}
289289
dispose();
290-
//outlinePage.setSelection(new StructuredSelection(selectedElement));
290+
// outlinePage.setSelection(new StructuredSelection(selectedElement));
291291
}
292292

293293
@Override
@@ -474,7 +474,7 @@ public void setInput(Object input) {
474474
// Input comes from PDESourceInfoProvider.getInformation2()
475475
// The input should be a model object of some sort
476476
// 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) {
478478
treeViewer.setSelection(new StructuredSelection(input));
479479
}
480480
}
@@ -542,6 +542,9 @@ public void setLocation(Point location) {
542542

543543
@Override
544544
public void dispose() {
545+
if (tsFile != null) {
546+
this.tsFile.removeNavbarListener(this);
547+
}
545548
close();
546549
}
547550

@@ -658,4 +661,17 @@ public void setStringMatcher(StringMatcher newStringMatcher) {
658661
}
659662

660663
}
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+
}
661677
}

0 commit comments

Comments
 (0)