14
14
15
15
import org .eclipse .core .runtime .ListenerList ;
16
16
import org .eclipse .jface .action .Action ;
17
+ import org .eclipse .jface .action .IMenuManager ;
17
18
import org .eclipse .jface .action .IToolBarManager ;
19
+ import org .eclipse .jface .action .Separator ;
18
20
import org .eclipse .jface .viewers .IPostSelectionProvider ;
19
21
import org .eclipse .jface .viewers .ISelection ;
20
22
import org .eclipse .jface .viewers .ISelectionChangedListener ;
@@ -44,7 +46,8 @@ public class TypeScriptContentOutlinePage extends Page
44
46
implements IContentOutlinePage , IPostSelectionProvider , INavbarListener {
45
47
46
48
private static final String OUTLINE_COMMON_NAVIGATOR_ID = TypeScriptUIPlugin .PLUGIN_ID + ".outline" ; //$NON-NLS-1$
47
-
49
+ private static final String EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE = "TypeScriptEditor.SyncOutlineOnCursorMove" ; //$NON-NLS-1$
50
+
48
51
private CommonViewer fOutlineViewer ;
49
52
private ITypeScriptFile tsFile ;
50
53
@@ -182,8 +185,15 @@ public void dispose() {
182
185
* @param actionBars
183
186
*/
184
187
private void registerToolbarActions (IActionBars actionBars ) {
188
+ // Toolbar
185
189
IToolBarManager toolBarManager = actionBars .getToolBarManager ();
186
190
toolBarManager .add (new CollapseAllAction (this .fOutlineViewer ));
191
+
192
+ // Menu
193
+ IMenuManager viewMenuManager = actionBars .getMenuManager ();
194
+ viewMenuManager .add (new Separator ("EndFilterGroup" )); //$NON-NLS-1$
195
+ viewMenuManager .add (new ToggleLinkingAction ());
196
+
187
197
}
188
198
189
199
/**
@@ -210,4 +220,33 @@ public void run() {
210
220
}
211
221
}
212
222
223
+ /**
224
+ * Link with editor.
225
+ *
226
+ */
227
+ private class ToggleLinkingAction extends Action {
228
+ public ToggleLinkingAction () {
229
+ super (TypeScriptUIMessages .TypeScriptContentOutlinePage_ToggleLinkingAction_label );
230
+ setDescription (TypeScriptUIMessages .TypeScriptContentOutlinePage_ToggleLinkingAction_description );
231
+ setToolTipText (TypeScriptUIMessages .TypeScriptContentOutlinePage_ToggleLinkingAction_tooltip );
232
+ super .setImageDescriptor (
233
+ TypeScriptUIImageResource .getImageDescriptor (TypeScriptUIImageResource .IMG_SYNCED_ENABLED ));
234
+ super .setDisabledImageDescriptor (
235
+ TypeScriptUIImageResource .getImageDescriptor (TypeScriptUIImageResource .IMG_SYNCED_DISABLED ));
236
+ boolean isLinkingEnabled = TypeScriptUIPlugin .getDefault ().getPreferenceStore ()
237
+ .getBoolean (EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE );
238
+ setChecked (isLinkingEnabled );
239
+ }
240
+
241
+ @ Override
242
+ public void run () {
243
+ TypeScriptUIPlugin .getDefault ().getPreferenceStore ().setValue (EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE ,
244
+ isChecked ());
245
+ // TODO
246
+ //if (isChecked() && fEditor != null)
247
+ // fEditor.synchronizeOutlinePage(fEditor.computeHighlightRangeSourceReference(), false);
248
+ }
249
+ }
250
+
251
+
213
252
}
0 commit comments