Skip to content

Commit fee0a12

Browse files
author
angelozerr
committed
Add "Link Editor" in the menu. See
#79
1 parent 43110ce commit fee0a12

File tree

6 files changed

+52
-3
lines changed

6 files changed

+52
-3
lines changed
Loading
Loading

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/TypeScriptUIMessages.java

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public class TypeScriptUIMessages extends NLS {
119119
public static String TypeScriptContentOutlinePage_CollapseAllAction_label;
120120
public static String TypeScriptContentOutlinePage_CollapseAllAction_description;
121121
public static String TypeScriptContentOutlinePage_CollapseAllAction_tooltip;
122+
public static String TypeScriptContentOutlinePage_ToggleLinkingAction_label;
123+
public static String TypeScriptContentOutlinePage_ToggleLinkingAction_description;
124+
public static String TypeScriptContentOutlinePage_ToggleLinkingAction_tooltip;
122125

123126
public static ResourceBundle getResourceBundle() {
124127
try {

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/TypeScriptUIMessages.properties

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,7 @@ DiscoverBuildPathDialog_SearchBuildPathJob_name=Search tsconfig.json files job
9292
# Outline
9393
TypeScriptContentOutlinePage_CollapseAllAction_label=Collapse All
9494
TypeScriptContentOutlinePage_CollapseAllAction_tooltip=Collapse All
95-
TypeScriptContentOutlinePage_CollapseAllAction_description=Collapse All
95+
TypeScriptContentOutlinePage_CollapseAllAction_description=Collapse All
96+
TypeScriptContentOutlinePage_ToggleLinkingAction_label=Lin&k With Editor
97+
TypeScriptContentOutlinePage_ToggleLinkingAction_tooltip=Link with Editor
98+
TypeScriptContentOutlinePage_ToggleLinkingAction_description=Link with active editor

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/TypeScriptUIImageResource.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public class TypeScriptUIImageResource {
5454
public static final String IMG_STOP_DISABLED = "stop_disabled";
5555
public static final String IMG_COLLAPSE_ALL_ENABLED = "collapseall_enabled";
5656
public static final String IMG_COLLAPSE_ALL_DISABLED = "collapseall_disabled";
57-
57+
public static final String IMG_SYNCED_ENABLED = "synced_enabled";
58+
public static final String IMG_SYNCED_DISABLED = "synced_disabled";
59+
5860
public static final String DESC_OVR_LIBRARY = "ovr_library";
5961

6062
private static Map<ImageDescriptor, URL> fURLMap;
@@ -153,6 +155,8 @@ protected static void initializeImageRegistry() {
153155
registerImage(IMG_STOP_DISABLED, URL_DLCL + "launch_stop.gif");
154156
registerImage(IMG_COLLAPSE_ALL_ENABLED, URL_ELCL + "collapseall.gif");
155157
registerImage(IMG_COLLAPSE_ALL_DISABLED, URL_DLCL + "collapseall.gif");
158+
registerImage(IMG_SYNCED_ENABLED, URL_ELCL + "synced.gif");
159+
registerImage(IMG_SYNCED_DISABLED, URL_DLCL + "synced.gif");
156160

157161
registerImage(DESC_OVR_LIBRARY, URL_OVR + "library_ovr.gif");
158162
}

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

+40-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
import org.eclipse.core.runtime.ListenerList;
1616
import org.eclipse.jface.action.Action;
17+
import org.eclipse.jface.action.IMenuManager;
1718
import org.eclipse.jface.action.IToolBarManager;
19+
import org.eclipse.jface.action.Separator;
1820
import org.eclipse.jface.viewers.IPostSelectionProvider;
1921
import org.eclipse.jface.viewers.ISelection;
2022
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -44,7 +46,8 @@ public class TypeScriptContentOutlinePage extends Page
4446
implements IContentOutlinePage, IPostSelectionProvider, INavbarListener {
4547

4648
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+
4851
private CommonViewer fOutlineViewer;
4952
private ITypeScriptFile tsFile;
5053

@@ -182,8 +185,15 @@ public void dispose() {
182185
* @param actionBars
183186
*/
184187
private void registerToolbarActions(IActionBars actionBars) {
188+
// Toolbar
185189
IToolBarManager toolBarManager = actionBars.getToolBarManager();
186190
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+
187197
}
188198

189199
/**
@@ -210,4 +220,33 @@ public void run() {
210220
}
211221
}
212222

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+
213252
}

0 commit comments

Comments
 (0)