View | Details | Raw Unified | Return to bug 353225 | Differences between
and this patch

Collapse All | Expand All

(-)OSGI-INF/l10n/bundle.properties (+17 lines)
Lines 42-44 Link Here
42
openSourceObjectAction.tooltip = Shows the JavaScript source for the selected script element
42
openSourceObjectAction.tooltip = Shows the JavaScript source for the selected script element
43
commandCategory.description = Tooling for debugging JavaScript
43
commandCategory.description = Tooling for debugging JavaScript
44
commandCategory.name = JavaScript Debug
44
commandCategory.name = JavaScript Debug
45
46
showFunctionVarAction.label = Show function variables
47
showFunctionVarAction.tooltip = Show or hide function variables
48
showThisVarAction.label = Show 'this' variable
49
showThisVarAction.tooltip = Show or hide the this variable
50
showProtoVarAction.label = Show proto variables
51
showProtoVarAction.tooltip = Show or hide proto variables
52
53
evaluateAction.label = E&valuate
54
evaluateCommand.label = Evaluate
55
evaluateAction.description = Evaluates the selected text in the JavaScript editor
56
hyperlinkDetector.description = Allows for quickly stepping into functions in JavaScript source using hyper-links
57
hyperlinkDetector.name = Step Into Selection
58
debugPrefPage.name = Debug
59
debugPrefPageKeyword.label = debug,jsdt,javascript,wst,breakpoint,launch,suspend,scripts
60
hover.description = Shows the value of the selected variable while debugging
61
hover.label = JavaScript Variable Hover
(-)build.properties (+10 lines)
Lines 1-3 Link Here
1
###############################################################################
2
# Copyright (c) 2010, 2011 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
1
source.. = src/
11
source.. = src/
2
output.. = bin/
12
output.. = bin/
3
bin.includes = META-INF/,\
13
bin.includes = META-INF/,\
(-)plugin.xml (-32 / +182 lines)
Lines 37-42 Link Here
37
         <adapter
37
         <adapter
38
               type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
38
               type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
39
         </adapter>
39
         </adapter>
40
         <adapter
41
               type="org.eclipse.debug.ui.actions.IRunToLineTarget">
42
         </adapter>
40
      </factory>
43
      </factory>
41
      <factory
44
      <factory
42
            adaptableType="org.eclipse.wst.jsdt.core.IFunction"
45
            adaptableType="org.eclipse.wst.jsdt.core.IFunction"
Lines 173-179 Link Here
173
               class="org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.ToggleFunctionBreakpointActionDelegate"
176
               class="org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.ToggleFunctionBreakpointActionDelegate"
174
               enablesFor="+"
177
               enablesFor="+"
175
               helpContextId="toggle_function_bp_outline"
178
               helpContextId="toggle_function_bp_outline"
176
               icon="icons/elcl16/brkp_obj.gif"
179
               icon="$nl$/icons/elcl16/brkp_obj.gif"
177
               id="org.eclipse.wst.jsdt.debug.ui.outline.function.toggle.breakpoint.action"
180
               id="org.eclipse.wst.jsdt.debug.ui.outline.function.toggle.breakpoint.action"
178
               label="%toggleFunctionBreakpointAction.name"
181
               label="%toggleFunctionBreakpointAction.name"
179
               menubarPath="additions"
182
               menubarPath="additions"
Lines 220-230 Link Here
220
               tooltip="%openSourceObjectAction.tooltip">
223
               tooltip="%openSourceObjectAction.tooltip">
221
         </action>
224
         </action>
222
      </objectContribution>
225
      </objectContribution>
226
      <viewerContribution
227
            id="org.eclipse.wst.jsdt.debug.ui.classfile.editor.actions"
228
            targetID="#ClassFileEditorContext">
229
         <visibility>
230
            <and>
231
               <objectClass
232
                     name="org.eclipse.jface.text.ITextSelection">
233
               </objectClass>
234
               <systemProperty
235
                     name="org.eclipse.wst.jsdt.debug.ui.jsdebuggerActive"
236
                     value="true">
237
               </systemProperty>
238
            </and>
239
         </visibility>
240
         <action
241
               class="org.eclipse.wst.jsdt.debug.internal.ui.actions.EvaluateEditorPopupAction"
242
               definitionId="org.eclipse.wst.jsdt.debug.ui.evaluate.command"
243
               helpContextId="evaluate_jsunit_snippet_action_context"
244
               icon="$nl$/icons/elcl16/jsbook_obj.gif"
245
               id="org.eclipse.wst.jsdt.debug.ui.jsunit.popup.evaluate"
246
               label="%evaluateAction.label"
247
               menubarPath="jsdebug"
248
               tooltip="%evaluateAction.description">
249
         </action>
250
      </viewerContribution>
251
      <viewerContribution
252
            id="org.eclipse.wst.jsdt.debug.ui.jsunit.editor.actions"
253
            targetID="#JavaScriptEditorContext">
254
         <visibility>
255
            <and>
256
               <objectClass
257
                     name="org.eclipse.jface.text.ITextSelection">
258
               </objectClass>
259
               <systemProperty
260
                     name="org.eclipse.wst.jsdt.debug.ui.jsdebuggerActive"
261
                     value="true">
262
               </systemProperty>
263
            </and>
264
         </visibility>
265
         <action
266
               class="org.eclipse.wst.jsdt.debug.internal.ui.actions.EvaluateEditorPopupAction"
267
               definitionId="org.eclipse.wst.jsdt.debug.ui.evaluate.command"
268
               helpContextId="evaluate_jsunit_snippet_action_context"
269
               icon="$nl$/icons/elcl16/jsbook_obj.gif"
270
               id="org.eclipse.wst.jsdt.debug.ui.jsunit.popup.evaluate"
271
               label="%evaluateAction.label"
272
               menubarPath="jsdebug"
273
               tooltip="%evaluateAction.description">
274
         </action>
275
         <menu
276
               id="org.eclipse.wst.jsdt.debug.ui.jsdebug.cu.menu"
277
               label="%javascriptMenu.name"
278
               path="additions">
279
            <groupMarker
280
                  name="jsdebug">
281
            </groupMarker>
282
            <separator
283
                  name="jsdebug">
284
            </separator>
285
         </menu>
286
      </viewerContribution>
223
   </extension>
287
   </extension>
224
   <extension
288
   <extension
225
         point="org.eclipse.debug.ui.debugModelPresentations">
289
         point="org.eclipse.debug.ui.debugModelPresentations">
226
      <debugModelPresentation
290
      <debugModelPresentation
227
            class="org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptModelPresentation"
291
            class="org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptModelPresentation"
292
            detailsViewerConfiguration="org.eclipse.wst.jsdt.debug.internal.ui.display.JavaScriptDebugViewerConfiguration"
228
            id="org.eclipse.wst.jsdt.debug.model">
293
            id="org.eclipse.wst.jsdt.debug.model">
229
      </debugModelPresentation>
294
      </debugModelPresentation>
230
   </extension>
295
   </extension>
Lines 260-265 Link Here
260
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
325
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
261
            sequence="M1+M2+3">
326
            sequence="M1+M2+3">
262
      </key>
327
      </key>
328
      <key
329
            commandId="org.eclipse.wst.jsdt.debug.ui.evaluate.command"
330
            contextId="org.eclipse.wst.jsdt.ui.javaEditorScope"
331
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
332
            sequence="M3+M2+E">
333
      </key>
263
   </extension>
334
   </extension>
264
   <extension
335
   <extension
265
         point="org.eclipse.ui.commands">
336
         point="org.eclipse.ui.commands">
Lines 282-287 Link Here
282
            id="org.eclipse.wst.jsdt.debug.ui.category"
353
            id="org.eclipse.wst.jsdt.debug.ui.category"
283
            name="%commandCategory.name">
354
            name="%commandCategory.name">
284
      </category>
355
      </category>
356
      <command
357
            categoryId="org.eclipse.wst.jsdt.debug.ui.category"
358
            description="%evaluateAction.description"
359
            helpContextId="evaluate_command_help_context"
360
            id="org.eclipse.wst.jsdt.debug.ui.evaluate.command"
361
            name="%evaluateCommand.label">
362
      </command>
285
   </extension>
363
   </extension>
286
   <extension
364
   <extension
287
         point="org.eclipse.ui.viewActions">
365
         point="org.eclipse.ui.viewActions">
Lines 341-346 Link Here
341
               tooltip="%showAllScripts.tooltip">
419
               tooltip="%showAllScripts.tooltip">
342
         </action>
420
         </action>
343
      </viewContribution>
421
      </viewContribution>
422
      <viewContribution
423
            id="variableViewActions"
424
            targetID="org.eclipse.debug.ui.VariableView">
425
         <menu
426
               id="org.eclipse.wst.jsdt.debug.ui.variableview.menu"
427
               label="%javascriptMenu.name">
428
            <groupMarker
429
                  name="js">
430
            </groupMarker>
431
         </menu>
432
         <action
433
               class="org.eclipse.wst.jsdt.debug.internal.ui.actions.FunctionFilterAction"
434
               helpContextId="show_functions_variable_help_context"
435
               id="org.eclipse.wst.jsdt.debug.ui.variableview.show.functions"
436
               label="%showFunctionVarAction.label"
437
               menubarPath="org.eclipse.wst.jsdt.debug.ui.variableview.menu/js"
438
               style="toggle"
439
               tooltip="%showFunctionVarAction.tooltip">
440
         </action>
441
         <action
442
               class="org.eclipse.wst.jsdt.debug.internal.ui.actions.ThisFilterAction"
443
               helpContextId="show_this_variable_help_context"
444
               icon="$nl$/icons/elcl16/this_var.gif"
445
               id="org.eclipse.wst.jsdt.debug.ui.variableview.show.this"
446
               label="%showThisVarAction.label"
447
               menubarPath="org.eclipse.wst.jsdt.debug.ui.variableview.menu/js"
448
               style="toggle"
449
               tooltip="%showThisVarAction.tooltip">
450
         </action>
451
         <action
452
               class="org.eclipse.wst.jsdt.debug.internal.ui.actions.ProtoFilterAction"
453
               helpContextId="show_proto_variables_help_context"
454
               icon="$nl$/icons/elcl16/proto_var.gif"
455
               id="org.eclipse.wst.jsdt.debug.ui.variableview.show.prototypes"
456
               label="%showProtoVarAction.label"
457
               menubarPath="org.eclipse.wst.jsdt.debug.ui.variableview.menu/js"
458
               style="toggle"
459
               tooltip="%showProtoVarAction.tooltip">
460
         </action>
461
      </viewContribution>
344
   </extension>
462
   </extension>
345
   <extension
463
   <extension
346
         point="org.eclipse.debug.ui.detailPaneFactories">
464
         point="org.eclipse.debug.ui.detailPaneFactories">
Lines 370-406 Link Here
370
      </detailFactories>
488
      </detailFactories>
371
   </extension>
489
   </extension>
372
   <extension
490
   <extension
373
         point="org.eclipse.debug.ui.launchShortcuts">
374
      <shortcut
375
            class="org.eclipse.wst.jsdt.debug.internal.ui.launching.JavaScriptLaunchShortcut"
376
            description="%javascriptLaunchShortcut.description"
377
            helpContextId="javasript_lanch_shortcut"
378
            icon="$nl$/icons/elcl16/script.gif"
379
            id="org.eclipse.wst.jsdt.debug.ui.launch.shortcut"
380
            label="%javascriptLaunchShortcut.label"
381
            modes="debug">
382
         <configurationType
383
               id="org.eclipse.wst.jsdt.debug.core.launchConfigurationType">
384
         </configurationType>
385
         <contextualLaunch>
386
            <enablement>
387
               <with
388
                     variable="selection">
389
                  <iterate>
390
                     <and>
391
                        <adapt
392
                              type="org.eclipse.wst.jsdt.core.IJavaScriptElement">
393
                        </adapt>
394
                     </and></iterate>
395
                  <count
396
                        value="1">
397
                  </count>
398
               </with>
399
            </enablement>
400
         </contextualLaunch>
401
      </shortcut>
402
   </extension>
403
   <extension
404
         point="org.eclipse.ui.ide.markerSupport">
491
         point="org.eclipse.ui.ide.markerSupport">
405
      <markerTypeCategory
492
      <markerTypeCategory
406
            name="%breakpointMarkerCategory.name">
493
            name="%breakpointMarkerCategory.name">
Lines 421-424 Link Here
421
         </markerTypeReference>
508
         </markerTypeReference>
422
      </markerTypeCategory>
509
      </markerTypeCategory>
423
   </extension>
510
   </extension>
511
   <extension
512
         point="org.eclipse.core.runtime.preferences">
513
      <initializer
514
            class="org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPreferenceInitializer">
515
      </initializer>
516
   </extension>
517
   <extension
518
         point="org.eclipse.ui.handlers">
519
      <handler
520
            class="org.eclipse.wst.jsdt.debug.internal.ui.actions.EvaluateEditorPopupAction"
521
            commandId="org.eclipse.wst.jsdt.debug.ui.evaluate.command"
522
            helpContextId="evaluate_command_help_context">
523
      </handler>
524
   </extension>
525
   <extension
526
         point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
527
      <hyperlinkDetector
528
            activate="true"
529
            class="org.eclipse.wst.jsdt.debug.internal.ui.eval.JavaScriptHyperlinkDetector"
530
            description="%hyperlinkDetector.description"
531
            id="org.eclipse.wst.jsdt.debug.ui.hyperlink.detector"
532
            modifierKeys="M1+M3"
533
            name="%hyperlinkDetector.name"
534
            targetId="org.eclipse.wst.jsdt.ui.javaCode">
535
      </hyperlinkDetector>
536
   </extension>
537
   <extension
538
         point="org.eclipse.ui.preferencePages">
539
      <page
540
            category="org.eclipse.wst.jsdt.ui.preferences.JavaBasePreferencePage"
541
            class="org.eclipse.wst.jsdt.debug.internal.ui.preferences.JavaScriptDebugPreferencePage"
542
            id="org.eclipse.wst.jsdt.debug.ui.debug.page"
543
            name="%debugPrefPage.name">
544
         <keywordReference
545
               id="org.eclipse.wst.jsdt.debug.ui.debug.pref.page.keyword">
546
         </keywordReference>
547
      </page>
548
   </extension>
549
   <extension
550
         point="org.eclipse.ui.keywords">
551
      <keyword
552
            id="org.eclipse.wst.jsdt.debug.ui.debug.pref.page.keyword"
553
            label="%debugPrefPageKeyword.label">
554
      </keyword>
555
   </extension>
556
   <extension
557
         point="org.eclipse.wst.jsdt.ui.javaEditorTextHovers">
558
      <hover
559
            class="org.eclipse.wst.jsdt.debug.internal.ui.eval.JavaScriptDebugHover"
560
            description="%hover.description"
561
            id="org.eclipse.wst.jsdt.debug.ui.variable.value.hover"
562
            label="%hover.label">
563
      </hover>
564
   </extension>
565
   <extension
566
         point="org.eclipse.ui.editors.markerUpdaters">
567
      <updater
568
            class="org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.JavaScriptBreakpointUpdater"
569
            id="org.eclipse.wst.jsdt.debug.ui.breakpoint.updater"
570
            markerType="org.eclipse.wst.jsdt.debug.core.breakpoint.marker">
571
      </updater>
572
   </extension>
573
424
</plugin>
574
</plugin>
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/Constants.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui;
12
13
/**
14
 * Constants for the {@link JavaScriptDebugUIPlugin}
15
 * 
16
 * @since 1.1
17
 */
18
public interface Constants {
19
20
	/**
21
	 * Constant for the preference for showing / hiding functions from the variables view
22
	 * <br><br>
23
	 * Value is: <code>org.eclipse.wst.jsdt.debug.ui.show_functions</code>
24
	 */
25
	public static final String SHOW_FUNCTIONS = JavaScriptDebugUIPlugin.PLUGIN_ID + ".show_functions"; //$NON-NLS-1$
26
	/**
27
	 * Constant for the preference for showing / hiding prototypes from the variables view
28
	 * <br><br>
29
	 * Value is: <code>org.eclipse.wst.jsdt.debug.ui.show_protoypes</code>
30
	 */
31
	public static final String SHOW_PROTOTYPES = JavaScriptDebugUIPlugin.PLUGIN_ID + ".show_prototypes"; //$NON-NLS-1$
32
	/**
33
	 * Constant for the preference for showing / hiding the <code>this</code> variable from the variables view
34
	 * <br><br>
35
	 * Value is: <code>org.eclipse.wst.jsdt.debug.ui.show_this</code>
36
	 */
37
	public static final String SHOW_THIS = JavaScriptDebugUIPlugin.PLUGIN_ID + "show_this"; //$NON-NLS-1$
38
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/IHelpContextIds.java (-1 / +21 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 29-32 Link Here
29
	 * Help constant for the connect tab
29
	 * Help constant for the connect tab
30
	 */
30
	 */
31
	public static final String CONNECT_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".connect_tab"; //$NON-NLS-1$
31
	public static final String CONNECT_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".connect_tab"; //$NON-NLS-1$
32
	/**
33
	 * Help constant for the Debug root preference page
34
	 * @since 1.1
35
	 */
36
	public static final String DEBUG_PREFERENCE_PAGE = JavaScriptDebugUIPlugin.PLUGIN_ID + ".debug_pref_page"; //$NON-NLS-1$
37
	/**
38
	 * Help constant for the Source tab
39
	 * @since 1.2
40
	 */
41
	public static final String SOURCE_LOOKUP_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".source_lookup_tab"; //$NON-NLS-1$
42
	/**
43
	 * Help constant for the Environment tab
44
	 * @since 1.2
45
	 */
46
	public static final String ENVIRONMENT_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".environment_tab"; //$NON-NLS-1$
47
	/**
48
	 * Help constant for the Common tab
49
	 * @since 1.2
50
	 */
51
	public static final String COMMON_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".common_tab"; //$NON-NLS-1$
32
}
52
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPlugin.java (-1 / +32 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-21 Link Here
16
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.preferences.InstanceScope;
20
import org.eclipse.jface.preference.IPreferenceStore;
21
import org.eclipse.swt.widgets.Display;
19
import org.eclipse.ui.IEditorReference;
22
import org.eclipse.ui.IEditorReference;
20
import org.eclipse.ui.IWorkbench;
23
import org.eclipse.ui.IWorkbench;
21
import org.eclipse.ui.IWorkbenchListener;
24
import org.eclipse.ui.IWorkbenchListener;
Lines 25-31 Link Here
25
import org.eclipse.ui.PlatformUI;
28
import org.eclipse.ui.PlatformUI;
26
import org.eclipse.ui.ide.ResourceUtil;
29
import org.eclipse.ui.ide.ResourceUtil;
27
import org.eclipse.ui.plugin.AbstractUIPlugin;
30
import org.eclipse.ui.plugin.AbstractUIPlugin;
31
import org.eclipse.ui.preferences.ScopedPreferenceStore;
28
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
32
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
33
import org.eclipse.wst.jsdt.debug.internal.ui.eval.EvaluationManager;
29
import org.osgi.framework.BundleContext;
34
import org.osgi.framework.BundleContext;
30
35
31
/**
36
/**
Lines 48-53 Link Here
48
53
49
	// The shared instance
54
	// The shared instance
50
	private static JavaScriptDebugUIPlugin plugin;
55
	private static JavaScriptDebugUIPlugin plugin;
56
	private static ScopedPreferenceStore corestore = new ScopedPreferenceStore(InstanceScope.INSTANCE, JavaScriptDebugPlugin.PLUGIN_ID);
51
	
57
	
52
	/*
58
	/*
53
	 * (non-Javadoc)
59
	 * (non-Javadoc)
Lines 57-62 Link Here
57
		super.start(context);
63
		super.start(context);
58
		plugin = this;
64
		plugin = this;
59
		PlatformUI.getWorkbench().addWorkbenchListener(this);
65
		PlatformUI.getWorkbench().addWorkbenchListener(this);
66
		EvaluationManager.getManager().start();
60
	}
67
	}
61
68
62
	/*
69
	/*
Lines 67-72 Link Here
67
		try {
74
		try {
68
			plugin = null;
75
			plugin = null;
69
			PlatformUI.getWorkbench().removeWorkbenchListener(this);
76
			PlatformUI.getWorkbench().removeWorkbenchListener(this);
77
			EvaluationManager.getManager().stop();
70
			super.stop(context);
78
			super.stop(context);
71
		}
79
		}
72
		finally {
80
		finally {
Lines 173-176 Link Here
173
	 */
181
	 */
174
	public void postShutdown(IWorkbench workbench) {
182
	public void postShutdown(IWorkbench workbench) {
175
	}
183
	}
184
	
185
	/**
186
	 * Returns the standard display to be used. The method first checks, if
187
	 * the thread calling this method has an associated display. If so, this
188
	 * display is returned. Otherwise the method returns the default display.
189
	 */
190
	public static Display getStandardDisplay() {
191
		Display display;
192
		display = Display.getCurrent();
193
		if (display == null) {
194
			display = Display.getDefault();
195
		}
196
		return display;		
197
	}
198
	
199
	/**
200
	 * Returns an {@link IPreferenceStore} wrapper for the {@link JavaScriptDebugPlugin} core preferences
201
	 * 
202
	 * @return an {@link IPreferenceStore} for the core preferences
203
	 */
204
	public static IPreferenceStore getCorePreferenceStore() {
205
		return corestore;
206
	}
176
}
207
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPreferenceInitializer.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui;
12
13
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
14
import org.eclipse.jface.preference.IPreferenceStore;
15
16
/**
17
 * Initialize common preferences for {@link JavaScriptDebugUIPlugin}
18
 * 
19
 * @since 1.1
20
 */
21
public class JavaScriptDebugUIPreferenceInitializer extends AbstractPreferenceInitializer {
22
23
	/**
24
	 * Constructor
25
	 */
26
	public JavaScriptDebugUIPreferenceInitializer() {
27
	}
28
29
	/* (non-Javadoc)
30
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
31
	 */
32
	public void initializeDefaultPreferences() {
33
		IPreferenceStore store = JavaScriptDebugUIPlugin.getDefault().getPreferenceStore();
34
		store.setDefault(Constants.SHOW_FUNCTIONS, true);
35
		store.setDefault(Constants.SHOW_PROTOTYPES, true);
36
		store.setDefault(Constants.SHOW_THIS, true);
37
	}
38
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptModelPresentation.java (-36 / +188 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
2
 * Copyright (c) 2009, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-17 Link Here
11
package org.eclipse.wst.jsdt.debug.internal.ui;
11
package org.eclipse.wst.jsdt.debug.internal.ui;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.UnsupportedEncodingException;
14
import java.net.URISyntaxException;
15
import java.net.URISyntaxException;
16
import java.net.URLDecoder;
15
import java.util.HashMap;
17
import java.util.HashMap;
16
18
17
import org.eclipse.core.filesystem.EFS;
19
import org.eclipse.core.filesystem.EFS;
Lines 19-32 Link Here
19
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.resources.ResourcesPlugin;
22
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.core.runtime.Path;
25
import org.eclipse.core.runtime.Path;
23
import org.eclipse.core.runtime.URIUtil;
26
import org.eclipse.core.runtime.URIUtil;
24
import org.eclipse.debug.core.DebugException;
27
import org.eclipse.debug.core.DebugException;
28
import org.eclipse.debug.core.model.IBreakpoint;
29
import org.eclipse.debug.core.model.IDebugElement;
25
import org.eclipse.debug.core.model.IDebugTarget;
30
import org.eclipse.debug.core.model.IDebugTarget;
31
import org.eclipse.debug.core.model.IDisconnect;
26
import org.eclipse.debug.core.model.IStackFrame;
32
import org.eclipse.debug.core.model.IStackFrame;
33
import org.eclipse.debug.core.model.ITerminate;
27
import org.eclipse.debug.core.model.IThread;
34
import org.eclipse.debug.core.model.IThread;
28
import org.eclipse.debug.core.model.IValue;
35
import org.eclipse.debug.core.model.IValue;
29
import org.eclipse.debug.core.model.IVariable;
36
import org.eclipse.debug.core.model.IVariable;
37
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
30
import org.eclipse.debug.ui.IDebugModelPresentationExtension;
38
import org.eclipse.debug.ui.IDebugModelPresentationExtension;
31
import org.eclipse.debug.ui.IValueDetailListener;
39
import org.eclipse.debug.ui.IValueDetailListener;
32
import org.eclipse.jface.viewers.LabelProvider;
40
import org.eclipse.jface.viewers.LabelProvider;
Lines 43-53 Link Here
43
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint;
51
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint;
44
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
52
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
45
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLoadBreakpoint;
53
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLoadBreakpoint;
54
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame;
55
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptThread;
46
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue;
56
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue;
47
import org.eclipse.wst.jsdt.debug.core.model.IScript;
57
import org.eclipse.wst.jsdt.debug.core.model.IScript;
48
import org.eclipse.wst.jsdt.debug.core.model.IScriptGroup;
58
import org.eclipse.wst.jsdt.debug.core.model.IScriptGroup;
59
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
60
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
49
import org.eclipse.wst.jsdt.debug.internal.core.TextUtils;
61
import org.eclipse.wst.jsdt.debug.internal.core.TextUtils;
62
import org.eclipse.wst.jsdt.debug.internal.core.breakpoints.JavaScriptExceptionBreakpoint;
50
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptValue;
63
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptValue;
64
import org.eclipse.wst.jsdt.debug.internal.ui.eval.JavaScriptInspectExpression;
51
65
52
/**
66
/**
53
 * Default model presentation for JSDI model elements
67
 * Default model presentation for JSDI model elements
Lines 126-177 Link Here
126
	 * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
140
	 * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
127
	 */
141
	 */
128
	public String getText(Object element) {
142
	public String getText(Object element) {
143
		StringBuffer buffer = new StringBuffer();
129
		try {
144
		try {
130
			if(element instanceof IDebugTarget) {
145
			if(element instanceof IDebugElement) {
131
				return ((IDebugTarget)element).getName();
146
				if(element instanceof IDebugTarget) {
147
					buffer.append(((IDebugTarget)element).getName());
148
				}
149
				else if(element instanceof IStackFrame) {
150
					buffer.append(getStackframeText((IJavaScriptStackFrame) element));
151
				}
152
				else if(element instanceof IThread) {
153
					buffer.append(getThreadText((IJavaScriptThread) element));
154
				}
155
				else if(element instanceof IVariable) {
156
					buffer.append(((IVariable)element).getName());
157
				}
158
				else if(element instanceof IValue) {
159
					buffer.append(((IValue)element).getValueString());
160
				}
161
				else if(element instanceof IScriptGroup) {
162
					buffer.append(Messages.scripts);
163
				}
164
				else if(element instanceof IScript) {
165
					buffer.append(getScriptText((IScript) element));
166
				}
132
			}
167
			}
133
			if(element instanceof IStackFrame) {
168
			if(element instanceof JavaScriptInspectExpression) {
134
				return ((IStackFrame)element).getName();
169
				JavaScriptInspectExpression exp = (JavaScriptInspectExpression) element;
170
				return exp.getValue().getReferenceTypeName();
171
			}
172
			if(element instanceof ITerminate) {
173
				if(((ITerminate)element).isTerminated()) {
174
					buffer.insert(0, Messages.terminated);
175
				}
176
				else if(element instanceof IDisconnect) {
177
					if(((IDisconnect)element).isDisconnected()) {
178
						buffer.insert(0, Messages.disconnected);
179
					}
180
				}
135
			}
181
			}
136
			if(element instanceof IThread) {
182
			else if(element instanceof IDisconnect) {
137
				return ((IThread)element).getName();
183
				if(((IDisconnect)element).isDisconnected()) {
184
					buffer.insert(0, Messages.disconnected);
185
				}
138
			}
186
			}
139
			if(element instanceof IVariable) {
187
			else if(element instanceof IJavaScriptFunctionBreakpoint) {
140
				return ((IVariable)element).getName();
188
				buffer.append(getFunctionBreakpointText((IJavaScriptFunctionBreakpoint) element));
141
			}
189
			}
142
			if(element instanceof IValue) {
190
			else if(element instanceof IJavaScriptLoadBreakpoint) {
143
				return ((IValue)element).getValueString();
191
				buffer.append(getScriptLoadBreakpointText((IJavaScriptLoadBreakpoint) element));
144
			}
192
			}
145
			if(element instanceof IJavaScriptFunctionBreakpoint) {
193
			else if(element instanceof IJavaScriptLineBreakpoint) {
146
				return getFunctionBreakpointText((IJavaScriptFunctionBreakpoint) element);
194
				buffer.append(getLineBreakpointText((IJavaScriptLineBreakpoint) element));
147
			}
195
			}
148
			if(element instanceof IJavaScriptLoadBreakpoint) {
196
		}
149
				return getScriptLoadBreakpointText((IJavaScriptLoadBreakpoint) element);
197
		catch(CoreException ce) {
198
			JavaScriptDebugUIPlugin.log(ce);
199
			buffer.append(Messages.unknown);
200
		}
201
		if(buffer.length() < 1) {
202
			return Messages.unknown;
203
		}
204
		return buffer.toString();
205
	}
206
	
207
	/**
208
	 * Computes the thread name + adornment
209
	 * 
210
	 * @param thread
211
	 * @return
212
	 * @throws DebugException
213
	 */
214
	String getThreadText(IJavaScriptThread thread) throws DebugException {
215
		String adornment = Messages.unknown_state;
216
		if(thread.isSuspended()) {
217
			IBreakpoint[] bps = thread.getBreakpoints();
218
			if(bps.length > 0) {
219
				try {
220
					IJavaScriptBreakpoint breakpoint = (IJavaScriptBreakpoint) bps[0];
221
					if (breakpoint instanceof IJavaScriptLoadBreakpoint) {
222
						String name = breakpoint.getScriptPath();
223
						if (Constants.EMPTY_STRING.equals(name)) {
224
							name = getSourceName(thread);
225
						}
226
						else {
227
							//decode it
228
							try {
229
								name = URLDecoder.decode(name, Constants.UTF_8);
230
							}
231
							catch(UnsupportedEncodingException uee) {
232
								//ignore
233
							}
234
						}
235
						adornment = NLS.bind(Messages.suspend_loading_script, name);
236
					}
237
					else if(breakpoint instanceof JavaScriptExceptionBreakpoint) {
238
						adornment = NLS.bind(Messages.suspended_on_exception, breakpoint.getMarker().getAttribute(JavaScriptExceptionBreakpoint.MESSAGE));
239
					}
240
					else if (breakpoint instanceof IJavaScriptLineBreakpoint) {
241
						IJavaScriptLineBreakpoint bp = (IJavaScriptLineBreakpoint) breakpoint;
242
						adornment = NLS.bind(Messages.suspended_on_line_breakpoint, new String[] { Integer.toString(bp.getLineNumber()), getSourceName(thread) });
243
					}
244
					else if(breakpoint instanceof IJavaScriptFunctionBreakpoint) {
245
						IJavaScriptFunctionBreakpoint bp = (IJavaScriptFunctionBreakpoint) breakpoint;
246
						adornment = NLS.bind(Messages.suspended_on_func_breakpoint, new String[] {bp.getFunctionName(), getSourceName(thread)});
247
					}
248
					// TODO also need to report stopped at debugger; statement
249
				} catch (CoreException ce) {
250
					JavaScriptDebugPlugin.log(ce);
251
				}
150
			}
252
			}
151
			if(element instanceof IJavaScriptLineBreakpoint) {
253
			else {
152
				return getLineBreakpointText((IJavaScriptLineBreakpoint) element);
254
				adornment = Messages.suspended_state;
153
			}
255
			}
154
			if(element instanceof IScriptGroup) {
256
		}
155
				return Messages.scripts;
257
		else if(thread.isStepping()) {
258
			adornment = Messages.stepping_state;
259
		}
260
		else if(thread.isTerminated()) {
261
			adornment = Messages.terminated_state;
262
		}
263
		else {
264
			adornment = Messages.running_state;
265
		}
266
		return NLS.bind(Messages.thread_name, new String[] {thread.getName(), adornment});
267
	}
268
	
269
	/**
270
	 * Returns the name of the source from the top stackframe or a default name
271
	 * <code>&lt;evaluated_source&gt;</code>
272
	 * 
273
	 * @return the name for the source
274
	 * @throws DebugException
275
	 */
276
	String getSourceName(IJavaScriptThread thread) throws DebugException {
277
		IJavaScriptStackFrame frame = (IJavaScriptStackFrame) thread.getTopStackFrame();
278
		if (frame != null) {
279
			try {
280
				String uri = URLDecoder.decode(frame.getSourceName(), Constants.UTF_8);
281
				return TextUtils.shortenText(uri, 100);
156
			}
282
			}
157
			if(element instanceof IScript) {
283
			catch (UnsupportedEncodingException uee) {
158
				return getScriptText((IScript) element);
284
				//ignore
159
			}
285
			}
160
		}
286
		}
161
		catch(CoreException ce) {
287
		// all else failed say "evaluated_script"
162
			JavaScriptDebugUIPlugin.log(ce);
288
		return Messages.evald_script;
289
	}
290
	
291
	/**
292
	 * Returns the display name of the given {@link IJavaScriptStackFrame}
293
	 * 
294
	 * @param frame
295
	 * @return the display text or {@link Messages#unknown}
296
	 * @throws DebugException
297
	 */
298
	String getStackframeText(IJavaScriptStackFrame frame) throws DebugException {
299
		try {
300
			return TextUtils.shortenText(NLS.bind(Messages.stackframe_name, new String[] {
301
					URLDecoder.decode(frame.getName(), Constants.UTF_8),
302
					Integer.toString(frame.getLineNumber())}), 100);
303
		}
304
		catch (UnsupportedEncodingException uee) {
305
			//ignore
163
		}
306
		}
164
		return element.toString();
307
		return Messages.unknown;
165
	}
308
	}
166
	
309
	
167
	/**
310
	/**
168
	 * Returns the display text for the given script element
311
	 * Returns the display text for the given script element
312
	 * 
169
	 * @param script
313
	 * @param script
170
	 * @return the display text for the given script
314
	 * @return the display text for the given script or {@link Messages#unknown}
171
	 */
315
	 */
172
	String getScriptText(IScript script) {
316
	String getScriptText(IScript script) {
173
		String uri = script.sourceURI().toString();
317
		String uri;
174
		return TextUtils.shortenText(uri, 100);
318
		try {
319
			uri = URLDecoder.decode(script.sourceURI().toString(), Constants.UTF_8);
320
			return TextUtils.shortenText(uri, 100);
321
		} catch (UnsupportedEncodingException e) {
322
			//do nothing
323
		}
324
		return Messages.unknown;
175
	}
325
	}
176
326
177
	/**
327
	/**
Lines 182-189 Link Here
182
	 */
332
	 */
183
	String getLineBreakpointText(IJavaScriptLineBreakpoint breakpoint) throws CoreException {
333
	String getLineBreakpointText(IJavaScriptLineBreakpoint breakpoint) throws CoreException {
184
		String path = getElementPath(breakpoint.getScriptPath());
334
		String path = getElementPath(breakpoint.getScriptPath());
185
		StringBuffer buffer = new StringBuffer();
335
		StringBuffer buffer = new StringBuffer(path);
186
		buffer.append(path).append(NLS.bind(Messages.bp_line_number, new String[] {Integer.toString(breakpoint.getLineNumber())}));
336
		buffer.append(NLS.bind(Messages.bp_line_number, new String[] {Integer.toString(breakpoint.getLineNumber())}));
187
		int hitcount = breakpoint.getHitCount();
337
		int hitcount = breakpoint.getHitCount();
188
		if(hitcount > 0) {
338
		if(hitcount > 0) {
189
			buffer.append(NLS.bind(Messages.bp_hit_count, new String[] {Integer.toString(hitcount)}));
339
			buffer.append(NLS.bind(Messages.bp_hit_count, new String[] {Integer.toString(hitcount)}));
Lines 205-212 Link Here
205
	 */
355
	 */
206
	String getFunctionBreakpointText(IJavaScriptFunctionBreakpoint breakpoint) throws CoreException {
356
	String getFunctionBreakpointText(IJavaScriptFunctionBreakpoint breakpoint) throws CoreException {
207
		String path = getElementPath(breakpoint.getScriptPath());
357
		String path = getElementPath(breakpoint.getScriptPath());
208
		StringBuffer buffer = new StringBuffer();
358
		StringBuffer buffer = new StringBuffer(path);
209
		buffer.append(path);
210
		if(breakpoint.isEntry()) {
359
		if(breakpoint.isEntry()) {
211
			if(breakpoint.isExit()) {
360
			if(breakpoint.isExit()) {
212
				buffer.append(Messages.bp_entry_and_exit);
361
				buffer.append(Messages.bp_entry_and_exit);
Lines 241-248 Link Here
241
	 */
390
	 */
242
	String getScriptLoadBreakpointText(IJavaScriptLoadBreakpoint breakpoint) throws CoreException {
391
	String getScriptLoadBreakpointText(IJavaScriptLoadBreakpoint breakpoint) throws CoreException {
243
		String path = getElementPath(breakpoint.getScriptPath());
392
		String path = getElementPath(breakpoint.getScriptPath());
244
		StringBuffer buffer = new StringBuffer();
393
		StringBuffer buffer = new StringBuffer(path);
245
		buffer.append(path);
246
		int hitcount = breakpoint.getHitCount();
394
		int hitcount = breakpoint.getHitCount();
247
		if(hitcount > 0) {
395
		if(hitcount > 0) {
248
			buffer.append(NLS.bind(Messages.bp_hit_count, new String[] {Integer.toString(hitcount)}));
396
			buffer.append(NLS.bind(Messages.bp_hit_count, new String[] {Integer.toString(hitcount)}));
Lines 259-265 Link Here
259
	 * @return
407
	 * @return
260
	 */
408
	 */
261
	String getElementPath(String path) {
409
	String getElementPath(String path) {
262
		if(! showQualifiedNames()) {
410
		if(!showQualifiedNames()) {
263
			try {
411
			try {
264
				return URIUtil.lastSegment(URIUtil.fromString(path));
412
				return URIUtil.lastSegment(URIUtil.fromString(path));
265
			}
413
			}
Lines 370-375 Link Here
370
	 * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object)
518
	 * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object)
371
	 */
519
	 */
372
	public IEditorInput getEditorInput(Object element) {
520
	public IEditorInput getEditorInput(Object element) {
521
		if(element instanceof LocalFileStorage) {
522
			return getEditorInput(((LocalFileStorage)element).getFile());
523
		}
373
		if(element instanceof File) {
524
		if(element instanceof File) {
374
			return new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile((File) element));
525
			return new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile((File) element));
375
		}
526
		}
Lines 379-386 Link Here
379
		if(element instanceof IJavaScriptLoadBreakpoint) {
530
		if(element instanceof IJavaScriptLoadBreakpoint) {
380
			try {
531
			try {
381
				IJavaScriptLoadBreakpoint bp = (IJavaScriptLoadBreakpoint) element;
532
				IJavaScriptLoadBreakpoint bp = (IJavaScriptLoadBreakpoint) element;
382
				IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(bp.getScriptPath()));
533
				IPath path = new Path(bp.getScriptPath());
383
				if(resource.getType() == IResource.FILE) {
534
				IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
535
				if(resource != null && resource.getType() == IResource.FILE) {
384
					return new FileEditorInput((IFile) resource);
536
					return new FileEditorInput((IFile) resource);
385
				}
537
				}
386
			}
538
			}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/Messages.java (+16 lines)
Lines 31-47 Link Here
31
	public static String connector;
31
	public static String connector;
32
	public static String connector_properties;
32
	public static String connector_properties;
33
	public static String creating_script_load_bp;
33
	public static String creating_script_load_bp;
34
	public static String disconnected;
34
	public static String enable_hit_count;
35
	public static String enable_hit_count;
35
	public static String enter_new_hit_count;
36
	public static String enter_new_hit_count;
37
	public static String evald_script;
36
	public static String exception_occurred_setting_bp_properties;
38
	public static String exception_occurred_setting_bp_properties;
37
	public static String hit_count_must_be_positive;
39
	public static String hit_count_must_be_positive;
38
	public static String no_description_provided;
40
	public static String no_description_provided;
41
	public static String opening_source__0;
42
	public static String running_state;
39
	public static String scripts;
43
	public static String scripts;
40
	public static String select_javascript_file;
44
	public static String select_javascript_file;
41
	public static String set_bp_hit_count;
45
	public static String set_bp_hit_count;
46
	public static String stackframe_name;
47
	public static String stepping_state;
48
	public static String suspend_loading_script;
42
	public static String suspend_target;
49
	public static String suspend_target;
43
	public static String suspend_thread;
50
	public static String suspend_thread;
51
	public static String suspended_on_exception;
52
	public static String suspended_on_func_breakpoint;
53
	public static String suspended_on_line_breakpoint;
54
	public static String suspended_state;
55
	public static String terminated;
56
	public static String terminated_state;
44
	public static String the_argument_0_is_not_valid;
57
	public static String the_argument_0_is_not_valid;
58
	public static String thread_name;
59
	public static String unknown;
60
	public static String unknown_state;
45
	static {
61
	static {
46
		// initialize resource bundle
62
		// initialize resource bundle
47
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
63
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/PreferencesManager.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.internal.ui;
11
package org.eclipse.wst.jsdt.debug.internal.ui;
2
12
3
import org.eclipse.jface.util.IPropertyChangeListener;
13
import org.eclipse.jface.util.IPropertyChangeListener;
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/AddScriptLoadBreakpointAction.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 54-60 Link Here
54
			if(dialog.open() == IDialogConstants.OK_ID) {
54
			if(dialog.open() == IDialogConstants.OK_ID) {
55
				final IFile file = (IFile) dialog.getFirstResult();
55
				final IFile file = (IFile) dialog.getFirstResult();
56
				final String scriptname = file.getName();
56
				final String scriptname = file.getName();
57
				final String scriptpath = file.getFullPath().makeRelative().toString();
57
				final String scriptpath = file.getProjectRelativePath().makeAbsolute().toString();
58
				
58
				
59
				IJavaScriptLoadBreakpoint breakpoint = findBreakpoint(scriptpath, scriptname);
59
				IJavaScriptLoadBreakpoint breakpoint = findBreakpoint(scriptpath, scriptname);
60
				if(breakpoint != null) {
60
				if(breakpoint != null) {
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateAction.java (+367 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.actions;
12
13
import org.eclipse.core.commands.IHandler;
14
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.text.BadLocationException;
16
import org.eclipse.jface.text.IDocument;
17
import org.eclipse.jface.text.IRegion;
18
import org.eclipse.jface.text.ITextSelection;
19
import org.eclipse.jface.text.ITextViewer;
20
import org.eclipse.jface.text.Region;
21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.ISelectionProvider;
23
import org.eclipse.jface.viewers.IStructuredSelection;
24
import org.eclipse.swt.custom.StyledText;
25
import org.eclipse.swt.graphics.GC;
26
import org.eclipse.swt.graphics.Point;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Event;
29
import org.eclipse.ui.IActionDelegate2;
30
import org.eclipse.ui.IEditorActionDelegate;
31
import org.eclipse.ui.IEditorPart;
32
import org.eclipse.ui.IObjectActionDelegate;
33
import org.eclipse.ui.IViewActionDelegate;
34
import org.eclipse.ui.IViewPart;
35
import org.eclipse.ui.IWorkbenchPage;
36
import org.eclipse.ui.IWorkbenchPart;
37
import org.eclipse.ui.IWorkbenchSite;
38
import org.eclipse.ui.IWorkbenchWindow;
39
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
40
import org.eclipse.ui.texteditor.ITextEditor;
41
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame;
42
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue;
43
import org.eclipse.wst.jsdt.debug.internal.ui.eval.EvaluationManager;
44
import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder;
45
46
/**
47
 * Action for evaluating selected source
48
 * 
49
 * @since 1.1
50
 */
51
public abstract class EvaluateAction implements IEditorActionDelegate, IObjectActionDelegate, IActionDelegate2, IViewActionDelegate, IWorkbenchWindowActionDelegate, IHandler {
52
53
	private IRegion region = null;
54
	private IWorkbenchPart targetpart = null;
55
	private IWorkbenchWindow window = null;
56
	private IAction action = null;
57
	private Object selection = null;
58
	private IJavaScriptValue value = null;
59
	
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.ui.IActionDelegate2#dispose()
62
	 */
63
	public void dispose() {
64
	}
65
	
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
68
	 */
69
	public void runWithEvent(IAction action, Event event) {
70
		run(action);
71
	}
72
	
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
75
	 */
76
	public void run(IAction action) {
77
		IJavaScriptStackFrame frame = getStackFrameContext();
78
		if(frame != null) {
79
			resolveSelection();
80
			//XXX hack, if we want to support evaluations from the variables view this will not work
81
			setValue(frame.evaluate(getSelection().toString()));
82
			showResult(getValue());
83
		}
84
	}
85
	
86
	/**
87
	 * Shows the result of the evaluation to the user. Sub-classes must implement. 
88
	 * 
89
	 * @param value the {@link IJavaScriptValue} to show to the user
90
	 */
91
	protected abstract void showResult(IJavaScriptValue value);
92
	
93
	/* (non-Javadoc)
94
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
95
	 */
96
	public void selectionChanged(IAction action, ISelection selection) {
97
		setAction(action);
98
	}
99
	
100
	/* (non-Javadoc)
101
	 * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
102
	 */
103
	public void init(IAction action) {
104
		setAction(action);
105
	}
106
	
107
	/* (non-Javadoc)
108
	 * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
109
	 */
110
	public void init(IViewPart view) {
111
		setTargetpart(view);
112
	}
113
	
114
	/* (non-Javadoc)
115
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
116
	 */
117
	public void init(IWorkbenchWindow window) {
118
		IWorkbenchPage page = window.getActivePage();
119
		if(page != null) {
120
			setTargetpart(window.getActivePage().getActivePart());
121
		}
122
	}
123
	
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
126
	 */
127
	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
128
		setTargetpart(targetPart);
129
		setAction(action);
130
	}
131
132
	/* (non-Javadoc)
133
	 * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
134
	 */
135
	public void setActiveEditor(IAction action, IEditorPart targetEditor) {
136
		setTargetpart(targetEditor);
137
		setAction(action);
138
	}
139
	
140
	/**
141
	 * Resolves the selected object from the target part
142
	 */
143
	protected void resolveSelection() {
144
		ISelection sel = getTargetSelection();
145
		setRegion(null);
146
		if(sel instanceof ITextSelection) {
147
			ITextSelection ts = (ITextSelection)sel;
148
			String text= ts.getText();
149
			if (text.trim().length() > 0) {
150
				setSelection(text);
151
				setRegion(new Region(ts.getOffset(), ts.getLength()));
152
			} else if (getTargetPart() instanceof IEditorPart) {
153
				IEditorPart editor= (IEditorPart)getTargetPart();
154
				if (editor instanceof ITextEditor) {
155
					setSelection(resolveText(null, ts, editor));
156
				}
157
			}
158
		}
159
		else if(sel instanceof IStructuredSelection) {
160
			
161
		}
162
	}
163
	
164
	/**
165
	 * Resolve the word from the given text selection. If no new word infos can be resolved 
166
	 * the original string is returned.
167
	 * @param text the text
168
	 * @param ts the current text selection
169
	 * @param editor the current editor
170
	 * @return the new resolved text for the whole word of the selection
171
	 */
172
	String resolveText(String text, ITextSelection ts, IEditorPart editor) {
173
		ITextEditor textEditor= (ITextEditor) editor;
174
		IDocument doc= textEditor.getDocumentProvider().getDocument(editor.getEditorInput());
175
		region = JavaWordFinder.findWord(doc, ts.getOffset());
176
		if (region != null) {
177
			try {
178
				return doc.get(region.getOffset(), region.getLength());
179
			} 
180
			catch (BadLocationException e) {
181
				//ignore
182
			}
183
		}
184
		return text;
185
	}
186
	
187
	/**
188
	 * Returns the select from the {@link IWorkbenchSite} of the {@link #getTargetPart()} {@link IWorkbenchPart}
189
	 * @return the selection or <code>null</code>
190
	 */
191
	protected ISelection getTargetSelection() {
192
		IWorkbenchPart part = getTargetPart();
193
		if(part != null) {
194
			ISelectionProvider provider = part.getSite().getSelectionProvider();
195
			if (provider != null) {
196
				return provider.getSelection();
197
			}
198
		}
199
		return null;
200
	}
201
	
202
	/**
203
	 * Finds the currently selected {@link IJavaScriptStackFrame} in the UI.
204
	 */
205
	protected IJavaScriptStackFrame getStackFrameContext() {
206
		IWorkbenchPart part = getTargetPart();
207
		IJavaScriptStackFrame frame = null;
208
		if (part == null) {
209
			frame = EvaluationManager.getManager().getEvaluationContext(getWindow());
210
		} else {
211
			frame = EvaluationManager.getManager().getEvaluationContext(part);
212
		}		
213
		return frame;
214
	}
215
	
216
	/**
217
	 * Allows the result of the evaluation to be set
218
	 * 
219
	 * @param value the {@link IJavaScriptValue} of the evaluation
220
	 */
221
	protected void setValue(IJavaScriptValue value) {
222
		this.value = value;
223
	}
224
	
225
	/**
226
	 * Returns the {@link IJavaScriptValue} result of the evaluation
227
	 * 
228
	 * @return the {@link IJavaScriptValue} result or <code>null</code>
229
	 */
230
	protected IJavaScriptValue getValue() {
231
		return value;
232
	}
233
	
234
	/**
235
	 * Allows the resolved selection to be set
236
	 * 
237
	 * @param obj
238
	 */
239
	protected void setSelection(Object obj) {
240
		selection = obj;
241
	}
242
	
243
	/**
244
	 * Returns the resolved selection or <code>null</code>. If <code>null</code>
245
	 * is returned attempts can be made to re-resolve the selection using {@link #resolveSelection()}
246
	 * 
247
	 * @return the resolved selection or <code>null</code>
248
	 */
249
	protected Object getSelection() {
250
		return selection;
251
	}
252
	
253
	/**
254
	 * Returns the current target {@link IWorkbenchPart}
255
	 * @return the {@link IWorkbenchPart} target or <code>null</code>
256
	 */
257
	protected IWorkbenchPart getTargetPart() {
258
		return targetpart;
259
	}
260
	
261
	/**
262
	 * Allows the target {@link IWorkbenchPart} to be set
263
	 * @param targetpart the targetpart to set
264
	 */
265
	protected void setTargetpart(IWorkbenchPart targetpart) {
266
		this.targetpart = targetpart;
267
	}
268
	
269
	/**
270
	 * Returns the current active {@link IWorkbenchWindow}
271
	 * 
272
	 * @return the current active {@link IWorkbenchWindow}
273
	 */
274
	protected IWorkbenchWindow getWindow() {
275
		return window;
276
	}
277
	
278
	/**
279
	 * Allows the current {@link IWorkbenchWindow} context to be set
280
	 * 
281
	 * @param window the {@link IWorkbenchWindow} context
282
	 */
283
	protected void setWindow(IWorkbenchWindow window) {
284
		this.window = window;
285
	}
286
	
287
	/**
288
	 * Returns the selected text {@link IRegion}, or <code>null</code> if none.
289
	 * 
290
	 * @return the selected text {@link IRegion} or <code>null</code>
291
	 */
292
	protected IRegion getRegion() {
293
		return region;
294
	}
295
	
296
	/**
297
	 * Allows the selected {@link IRegion} to be set
298
	 * 
299
	 * @param region the {@link IRegion} to set
300
	 */
301
	protected void setRegion(IRegion region) {
302
		this.region = region;
303
	}
304
	
305
	/**
306
	 * Returns the {@link IAction} context or <code>null</code>
307
	 * 
308
	 * @return the backing {@link IAction} or <code>null</code>
309
	 */
310
	protected IAction getAction() {
311
		return action;
312
	}
313
	
314
	/**
315
	 * Allows the backing {@link IAction} to be set
316
	 * 
317
	 * @param action the action to set
318
	 */
319
	protected void setAction(IAction action) {
320
		this.action = action;
321
	}
322
	
323
	/**
324
	 * Returns the styled text widget associated with the given part
325
	 * or <code>null</code> if none.
326
	 * 
327
	 * @param part workbench part
328
	 * @return associated style text widget or <code>null</code>
329
	 */
330
	protected StyledText getStyledText(IWorkbenchPart part) {
331
		ITextViewer viewer = (ITextViewer)part.getAdapter(ITextViewer.class);
332
		StyledText textWidget = null;
333
		if (viewer == null) {
334
			Control control = (Control) part.getAdapter(Control.class);
335
			if (control instanceof StyledText) {
336
				textWidget = (StyledText) control;
337
			}
338
		} else {
339
			textWidget = viewer.getTextWidget();
340
		}
341
		return textWidget;
342
	}
343
	
344
	/**
345
	 * Returns an anchor point for a popup dialog on top of a styled text
346
	 * or <code>null</code> if none.
347
	 * 
348
	 * @param part or <code>null</code>
349
	 * @return anchor point or <code>null</code>
350
	 */
351
	protected Point getPopupAnchor(StyledText textWidget) {
352
		if (textWidget != null) {
353
	        Point docRange = textWidget.getSelectionRange();
354
	        int midOffset = docRange.x + (docRange.y / 2);
355
	        Point point = textWidget.getLocationAtOffset(midOffset);
356
	        point = textWidget.toDisplay(point);
357
	
358
	        GC gc = new GC(textWidget);
359
	        gc.setFont(textWidget.getFont());
360
	        int height = gc.getFontMetrics().getHeight();
361
	        gc.dispose();
362
	        point.y += height;
363
	        return point;
364
		}
365
		return null;
366
	}
367
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateEditorPopupAction.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.actions;
12
13
import org.eclipse.core.commands.ExecutionEvent;
14
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.core.commands.IHandlerListener;
16
import org.eclipse.debug.ui.InspectPopupDialog;
17
import org.eclipse.ui.IWorkbenchPage;
18
import org.eclipse.ui.IWorkbenchWindow;
19
import org.eclipse.ui.PlatformUI;
20
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue;
21
import org.eclipse.wst.jsdt.debug.internal.ui.eval.JavaScriptInspectExpression;
22
23
24
/**
25
 * Default handler for the {@link EvaluateAction}
26
 * 
27
 * @since 1.0
28
 */
29
public class EvaluateEditorPopupAction extends EvaluateAction {
30
31
	/**
32
	 * Constructor
33
	 */
34
	public EvaluateEditorPopupAction() {
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
39
	 */
40
	public Object execute(ExecutionEvent event) throws ExecutionException {
41
		run(null);
42
		return null;
43
	}
44
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.EvaluateAction#showResult(org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue)
47
	 */
48
	protected void showResult(IJavaScriptValue value) {
49
		InspectPopupDialog dialog = new InspectPopupDialog(
50
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
51
				getPopupAnchor(getStyledText(getTargetPart())), 
52
				null, 
53
				new JavaScriptInspectExpression(getValue()));
54
		dialog.open();
55
	}
56
	
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.core.commands.IHandler#isEnabled()
59
	 */
60
	public boolean isEnabled() {
61
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
62
		setWindow(window);
63
		if(window != null) {
64
			IWorkbenchPage page = window.getActivePage();
65
			if(page != null) {
66
				setTargetpart(page.getActivePart());
67
				return true;
68
			}
69
		}
70
		return false;
71
	}
72
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.core.commands.IHandler#isHandled()
75
	 */
76
	public boolean isHandled() {
77
		return true;
78
	}
79
	
80
	/* (non-Javadoc)
81
	 * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener)
82
	 */
83
	public void removeHandlerListener(IHandlerListener handlerListener) {}
84
	
85
	/* (non-Javadoc)
86
	 * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener)
87
	 */
88
	public void addHandlerListener(IHandlerListener handlerListener) {}
89
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/FunctionFilterAction.java (+59 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.actions;
12
13
import org.eclipse.debug.core.DebugException;
14
import org.eclipse.jface.viewers.Viewer;
15
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue;
16
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptProperty;
17
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptVariable;
18
import org.eclipse.wst.jsdt.debug.internal.ui.Constants;
19
20
21
/**
22
 * Viewer filter action for filtering functions
23
 * 
24
 * @since 1.1
25
 */
26
public class FunctionFilterAction extends ViewFilterAction {
27
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey()
30
	 */
31
	protected String getPreferenceKey() {
32
		return Constants.SHOW_FUNCTIONS;
33
	}
34
35
	/* (non-Javadoc)
36
	 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
37
	 */
38
	public boolean select(Viewer viewer, Object parentElement, Object element) {
39
		if(element instanceof JavaScriptVariable){
40
			JavaScriptVariable var = (JavaScriptVariable) element;
41
			try {
42
				if(IJavaScriptValue.FUNCTION.equals(var.getReferenceTypeName())) {
43
					return getValue();
44
				}
45
			} catch (DebugException e) {
46
			}
47
		}
48
		if(element instanceof JavaScriptProperty){
49
			JavaScriptProperty prop = (JavaScriptProperty) element;
50
			try {
51
				if(IJavaScriptValue.FUNCTION.equals(prop.getReferenceTypeName())) {
52
					return getValue();
53
				}
54
			} catch (DebugException e) {
55
			}
56
		}
57
		return true;
58
	}
59
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/OpenSourceAction.java (-3 / +18 lines)
Lines 17-35 Link Here
17
import org.eclipse.core.commands.IHandler2;
17
import org.eclipse.core.commands.IHandler2;
18
import org.eclipse.core.commands.IHandlerListener;
18
import org.eclipse.core.commands.IHandlerListener;
19
import org.eclipse.core.expressions.EvaluationContext;
19
import org.eclipse.core.expressions.EvaluationContext;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Status;
23
import org.eclipse.core.runtime.jobs.Job;
20
import org.eclipse.debug.ui.DebugUITools;
24
import org.eclipse.debug.ui.DebugUITools;
21
import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult;
25
import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult;
22
import org.eclipse.jface.action.IAction;
26
import org.eclipse.jface.action.IAction;
23
import org.eclipse.jface.viewers.ISelection;
27
import org.eclipse.jface.viewers.ISelection;
24
import org.eclipse.jface.viewers.IStructuredSelection;
28
import org.eclipse.jface.viewers.IStructuredSelection;
29
import org.eclipse.osgi.util.NLS;
25
import org.eclipse.swt.widgets.Event;
30
import org.eclipse.swt.widgets.Event;
26
import org.eclipse.ui.IActionDelegate2;
31
import org.eclipse.ui.IActionDelegate2;
27
import org.eclipse.ui.IObjectActionDelegate;
32
import org.eclipse.ui.IObjectActionDelegate;
28
import org.eclipse.ui.IWorkbenchPage;
33
import org.eclipse.ui.IWorkbenchPage;
29
import org.eclipse.ui.IWorkbenchPart;
34
import org.eclipse.ui.IWorkbenchPart;
30
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.PlatformUI;
36
import org.eclipse.ui.progress.UIJob;
31
import org.eclipse.wst.jsdt.debug.core.model.IScript;
37
import org.eclipse.wst.jsdt.debug.core.model.IScript;
32
import org.eclipse.wst.jsdt.debug.internal.core.model.Script;
38
import org.eclipse.wst.jsdt.debug.internal.core.model.Script;
39
import org.eclipse.wst.jsdt.debug.internal.ui.Messages;
33
40
34
/**
41
/**
35
 * Context menu action to show the source for a selected {@link IScript}
42
 * Context menu action to show the source for a selected {@link IScript}
Lines 50-58 Link Here
50
	 */
57
	 */
51
	public void run(IAction action) {
58
	public void run(IAction action) {
52
		if(script != null) {
59
		if(script != null) {
53
			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
60
			UIJob job = new UIJob(PlatformUI.getWorkbench().getDisplay(), NLS.bind(Messages.opening_source__0, script.sourceURI())) {
54
			ISourceLookupResult result = DebugUITools.lookupSource(script, script.getDebugTarget().getLaunch().getSourceLocator());
61
				public IStatus runInUIThread(IProgressMonitor monitor) {
55
			DebugUITools.displaySource(result, page);
62
					IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
63
					ISourceLookupResult result = DebugUITools.lookupSource(script, script.getDebugTarget().getLaunch().getSourceLocator());
64
					DebugUITools.displaySource(result, page);
65
					return Status.OK_STATUS;
66
				}
67
			};
68
			job.setPriority(Job.INTERACTIVE);
69
			job.setUser(true);
70
			job.schedule();
56
		}
71
		}
57
	}
72
	}
58
73
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ProtoFilterAction.java (+44 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.actions;
12
13
import org.eclipse.jface.viewers.Viewer;
14
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptProperty;
15
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptValue;
16
import org.eclipse.wst.jsdt.debug.internal.ui.Constants;
17
18
/**
19
 * Viewer filter action for <code>proto</code> variables
20
 * 
21
 * @since 1.1
22
 */
23
public class ProtoFilterAction extends ViewFilterAction {
24
25
	/* (non-Javadoc)
26
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey()
27
	 */
28
	protected String getPreferenceKey() {
29
		return Constants.SHOW_PROTOTYPES;
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
34
	 */
35
	public boolean select(Viewer viewer, Object parentElement, Object element) {
36
		if(element instanceof JavaScriptProperty){
37
			JavaScriptProperty var = (JavaScriptProperty) element;
38
			if(JavaScriptValue.PROTO.equals(var.getName())) {
39
				return getValue();
40
			}
41
		}
42
		return true;
43
	}
44
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ShowLoadedScriptsAction.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.internal.ui.actions;
11
package org.eclipse.wst.jsdt.debug.internal.ui.actions;
2
12
3
import org.eclipse.debug.ui.IDebugView;
13
import org.eclipse.debug.ui.IDebugView;
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnAllScriptLoadsAction.java (-3 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-20 Link Here
15
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
15
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
16
import org.eclipse.core.runtime.preferences.InstanceScope;
16
import org.eclipse.core.runtime.preferences.InstanceScope;
17
import org.eclipse.jface.action.IAction;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.preference.IPreferenceStore;
18
import org.eclipse.jface.viewers.Viewer;
19
import org.eclipse.jface.viewers.Viewer;
19
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
20
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
20
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
21
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
Lines 28-34 Link Here
28
 */
29
 */
29
public class SuspendOnAllScriptLoadsAction extends ViewFilterAction {
30
public class SuspendOnAllScriptLoadsAction extends ViewFilterAction {
30
	
31
	
31
	
32
	/* (non-Javadoc)
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey()
33
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey()
34
	 */
34
	 */
Lines 47-53 Link Here
47
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
47
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
48
	 */
48
	 */
49
	public void run(IAction action) {
49
	public void run(IAction action) {
50
		IEclipsePreferences prefs = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
50
		IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
51
		if(prefs != null) {
51
		if(prefs != null) {
52
			prefs.putBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, getValue());
52
			prefs.putBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, getValue());
53
			try {
53
			try {
Lines 59-64 Link Here
59
	}
59
	}
60
	
60
	
61
	/* (non-Javadoc)
61
	/* (non-Javadoc)
62
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceStore()
63
	 */
64
	protected IPreferenceStore getPreferenceStore() {
65
		return JavaScriptDebugUIPlugin.getCorePreferenceStore();
66
	}
67
	
68
	/* (non-Javadoc)
62
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceValue()
69
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceValue()
63
	 */
70
	 */
64
	protected boolean getPreferenceValue() {
71
	protected boolean getPreferenceValue() {
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnExceptionsAction.java (-22 / +31 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-22 Link Here
14
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
14
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
15
import org.eclipse.core.runtime.preferences.InstanceScope;
15
import org.eclipse.core.runtime.preferences.InstanceScope;
16
import org.eclipse.jface.action.IAction;
16
import org.eclipse.jface.action.IAction;
17
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jface.preference.IPreferenceStore;
18
import org.eclipse.ui.IViewActionDelegate;
18
import org.eclipse.jface.viewers.Viewer;
19
import org.eclipse.ui.IViewPart;
20
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
19
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
21
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
20
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
22
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
21
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
Lines 27-43 Link Here
27
 * 
26
 * 
28
 * @since 1.1
27
 * @since 1.1
29
 */
28
 */
30
public class SuspendOnExceptionsAction implements IViewActionDelegate {
29
public class SuspendOnExceptionsAction extends ViewFilterAction {
31
	
32
	boolean initialized = false;
33
	
30
	
34
	/* (non-Javadoc)
31
	/* (non-Javadoc)
35
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
32
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
36
	 */
33
	 */
37
	public void run(IAction action) {
34
	public void run(IAction action) {
38
		IEclipsePreferences prefs = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID);
35
		IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID);
39
		if(prefs != null) {
36
		if(prefs != null) {
40
			prefs.putBoolean(Constants.SUSPEN_ON_THROWN_EXCEPTION, action.isChecked());
37
			prefs.putBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, action.isChecked());
41
			try {
38
			try {
42
				prefs.flush();
39
				prefs.flush();
43
			} catch (BackingStoreException e) {
40
			} catch (BackingStoreException e) {
Lines 47-68 Link Here
47
	}
44
	}
48
45
49
	/* (non-Javadoc)
46
	/* (non-Javadoc)
50
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
47
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceStore()
51
	 */
48
	 */
52
	public void selectionChanged(IAction action, ISelection selection) {
49
	protected IPreferenceStore getPreferenceStore() {
53
		if(!initialized) {
50
		return JavaScriptDebugUIPlugin.getCorePreferenceStore();
54
			boolean checked = Platform.getPreferencesService().getBoolean(
51
	}
55
								JavaScriptDebugPlugin.PLUGIN_ID,
52
	
56
								Constants.SUSPEN_ON_THROWN_EXCEPTION, 
53
	/* (non-Javadoc)
57
								false, 
54
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceValue()
58
								null);
55
	 */
59
			action.setChecked(checked);
56
	protected boolean getPreferenceValue() {
60
			initialized = true;
57
		return Platform.getPreferencesService().getBoolean(
61
		}
58
				JavaScriptDebugPlugin.PLUGIN_ID,
59
				Constants.SUSPEND_ON_THROWN_EXCEPTION, 
60
				false, 
61
				null);
62
	}
62
	}
63
63
64
	/* (non-Javadoc)
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
65
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey()
66
	 */
66
	 */
67
	public void init(IViewPart view) {}
67
	protected String getPreferenceKey() {
68
		return Constants.SUSPEND_ON_THROWN_EXCEPTION;
69
	}
70
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
73
	 */
74
	public boolean select(Viewer viewer, Object parentElement, Object element) {
75
		return false;
76
	}
68
}
77
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ThisFilterAction.java (+44 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.actions;
12
13
import org.eclipse.jface.viewers.Viewer;
14
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptValue;
15
import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptVariable;
16
import org.eclipse.wst.jsdt.debug.internal.ui.Constants;
17
18
/**
19
 * Viewer filter action for the <code>this</code> variable
20
 * 
21
 * @since 1.1
22
 */
23
public class ThisFilterAction extends ViewFilterAction {
24
25
	/* (non-Javadoc)
26
	 * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey()
27
	 */
28
	protected String getPreferenceKey() {
29
		return Constants.SHOW_THIS;
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
34
	 */
35
	public boolean select(Viewer viewer, Object parentElement, Object element) {
36
		if(element instanceof JavaScriptVariable){
37
			JavaScriptVariable var = (JavaScriptVariable) element;
38
			if(JavaScriptValue.THIS.equals(var.getName())) {
39
				return getValue();
40
			}
41
		}
42
		return true;
43
	}
44
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ViewFilterAction.java (-10 / +2 lines)
Lines 107-114 Link Here
107
			viewer.refresh();
107
			viewer.refresh();
108
		}
108
		}
109
		IPreferenceStore store = getPreferenceStore();
109
		IPreferenceStore store = getPreferenceStore();
110
		String key = getView().getSite().getId() + "." + getPreferenceKey(); //$NON-NLS-1$
110
		store.setValue(getPreferenceKey(), action.isChecked());
111
		store.setValue(key, action.isChecked());
112
	}
111
	}
113
112
114
	/* (non-Javadoc)
113
	/* (non-Javadoc)
Lines 132-146 Link Here
132
	 * @return boolean
131
	 * @return boolean
133
	 */
132
	 */
134
	protected boolean getPreferenceValue() {
133
	protected boolean getPreferenceValue() {
135
		String key = getCompositeKey();
136
		IPreferenceStore store = getPreferenceStore();
134
		IPreferenceStore store = getPreferenceStore();
137
		boolean value = false;
135
		return store.getBoolean(getPreferenceKey());		
138
		if (store.contains(key)) {
139
			value = store.getBoolean(key);
140
		} else {
141
			value = store.getBoolean(getPreferenceKey());
142
		}
143
		return value;		
144
	}
136
	}
145
	
137
	
146
	/**
138
	/**
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAdapterFactory.java (-1 / +18 lines)
Lines 14-19 Link Here
14
import org.eclipse.core.runtime.IAdapterFactory;
14
import org.eclipse.core.runtime.IAdapterFactory;
15
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
15
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
16
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory2;
16
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory2;
17
import org.eclipse.debug.ui.actions.IRunToLineTarget;
17
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
18
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
18
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.ui.model.IWorkbenchAdapter;
20
import org.eclipse.ui.model.IWorkbenchAdapter;
Lines 22-27 Link Here
22
import org.eclipse.wst.jsdt.debug.core.model.IScriptGroup;
23
import org.eclipse.wst.jsdt.debug.core.model.IScriptGroup;
23
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
24
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
24
import org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.ToggleBreakpointAdapter;
25
import org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.ToggleBreakpointAdapter;
26
import org.eclipse.wst.jsdt.debug.internal.ui.eval.RunToLineAdapter;
25
27
26
/**
28
/**
27
 * Adapter factory
29
 * Adapter factory
Lines 73-78 Link Here
73
	static ToggleBreakpointAdapter tbadapter = null;
75
	static ToggleBreakpointAdapter tbadapter = null;
74
	static JavaScriptAsyncContentProvider jscontent = null;
76
	static JavaScriptAsyncContentProvider jscontent = null;
75
	static JavaScriptModelProxyFactory jsproxyfactory = null;
77
	static JavaScriptModelProxyFactory jsproxyfactory = null;
78
	static RunToLineAdapter runtoline = null;
76
	
79
	
77
	/*
80
	/*
78
	 * (non-Javadoc)
81
	 * (non-Javadoc)
Lines 86-91 Link Here
86
		if(adapterType.equals(IWorkbenchAdapter.class) && adaptableObject instanceof IJavaScriptBreakpoint) {
89
		if(adapterType.equals(IWorkbenchAdapter.class) && adaptableObject instanceof IJavaScriptBreakpoint) {
87
			return getWorkbenchAdapter();
90
			return getWorkbenchAdapter();
88
		}
91
		}
92
		if(adapterType.equals(IRunToLineTarget.class)) {
93
			return getRunToLine();
94
		}
89
		if (adapterType.equals(IElementContentProvider.class)) {
95
		if (adapterType.equals(IElementContentProvider.class)) {
90
			if (adaptableObject instanceof IJavaScriptDebugTarget ||
96
			if (adaptableObject instanceof IJavaScriptDebugTarget ||
91
					adaptableObject instanceof IScriptGroup) {
97
					adaptableObject instanceof IScriptGroup) {
Lines 105-116 Link Here
105
	 */
111
	 */
106
	public Class[] getAdapterList() {
112
	public Class[] getAdapterList() {
107
		return new Class[] {IToggleBreakpointsTarget.class, 
113
		return new Class[] {IToggleBreakpointsTarget.class, 
108
				IWorkbenchAdapter.class, 
114
				IWorkbenchAdapter.class,
115
				IRunToLineTarget.class,
109
				IElementContentProvider.class,
116
				IElementContentProvider.class,
110
				IModelProxyFactory2.class};
117
				IModelProxyFactory2.class};
111
	}
118
	}
112
	
119
	
113
	/**
120
	/**
121
	 * @return the singleton {@link RunToLineAdapter}
122
	 */
123
	synchronized RunToLineAdapter getRunToLine() {
124
		if(runtoline == null) {
125
			runtoline = new RunToLineAdapter();
126
		}
127
		return runtoline;
128
	}
129
	
130
	/**
114
	 * @return the singleton {@link JavaScriptModelProxyFactory}
131
	 * @return the singleton {@link JavaScriptModelProxyFactory}
115
	 */
132
	 */
116
	synchronized JavaScriptModelProxyFactory getJSProxyFactory() {
133
	synchronized JavaScriptModelProxyFactory getJSProxyFactory() {
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAsyncContentProvider.java (+10 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.jsdt.debug.internal.ui.adapters;
11
package org.eclipse.wst.jsdt.debug.internal.ui.adapters;
2
12
3
import java.util.List;
13
import java.util.List;
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptDebugTargetEventHandler.java (-1 / +79 lines)
Lines 20-25 Link Here
20
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptDebugTarget;
20
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptDebugTarget;
21
import org.eclipse.wst.jsdt.debug.core.model.IScriptGroup;
21
import org.eclipse.wst.jsdt.debug.core.model.IScriptGroup;
22
import org.eclipse.wst.jsdt.debug.internal.core.model.ScriptGroup;
22
import org.eclipse.wst.jsdt.debug.internal.core.model.ScriptGroup;
23
import org.eclipse.wst.jsdt.debug.internal.ui.PreferencesManager;
23
24
24
/**
25
/**
25
 * Custom handler for JavaScript debug target model proxy events
26
 * Custom handler for JavaScript debug target model proxy events
Lines 45-50 Link Here
45
	}
46
	}
46
	
47
	
47
	/* (non-Javadoc)
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleChange(org.eclipse.debug.core.DebugEvent)
50
	 */
51
	protected void handleChange(DebugEvent event) {
52
		Object source = event.getSource();
53
		if(source instanceof IDebugTarget) {
54
			super.handleChange(event);
55
		}
56
		else if(source instanceof IScriptGroup) {
57
			if(PreferencesManager.getManager().showLoadedScripts()) {
58
				fireScriptGroupDelta((IScriptGroup) source);
59
			}
60
		}
61
	}
62
	
63
	/* (non-Javadoc)
64
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleCreate(org.eclipse.debug.core.DebugEvent)
65
	 */
66
	protected void handleCreate(DebugEvent event) {
67
		Object source = event.getSource();
68
		if(source instanceof IDebugTarget) {
69
			super.handleCreate(event);
70
		}
71
		else if(source instanceof IScriptGroup) {
72
			if(PreferencesManager.getManager().showLoadedScripts()) {
73
				fireScriptGroupDelta((IScriptGroup) source);
74
			}
75
		}
76
	}
77
	
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleResume(org.eclipse.debug.core.DebugEvent)
80
	 */
81
	protected void handleResume(DebugEvent event) {
82
		Object source = event.getSource();
83
		if(source instanceof IDebugTarget) {
84
			super.handleResume(event);
85
		}
86
		else if(source instanceof IScriptGroup) {
87
			if(PreferencesManager.getManager().showLoadedScripts()) {
88
				fireScriptGroupDelta((IScriptGroup) source);
89
			}
90
		}
91
	}
92
	
93
	/* (non-Javadoc)
94
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleSuspend(org.eclipse.debug.core.DebugEvent)
95
	 */
96
	protected void handleSuspend(DebugEvent event) {
97
		Object source = event.getSource();
98
		if(source instanceof IDebugTarget) {
99
			super.handleSuspend(event);
100
		}
101
		else if(source instanceof IScriptGroup) {
102
			if(PreferencesManager.getManager().showLoadedScripts()) {
103
				fireScriptGroupDelta((IScriptGroup) source);
104
			}
105
		}
106
	}
107
	
108
	/* (non-Javadoc)
109
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleTerminate(org.eclipse.debug.core.DebugEvent)
110
	 */
111
	protected void handleTerminate(DebugEvent event) {
112
		Object source = event.getSource();
113
		if(source instanceof IDebugTarget) {
114
			super.handleTerminate(event);
115
		}
116
		else if(source instanceof IScriptGroup){
117
			if(PreferencesManager.getManager().showLoadedScripts()) {
118
				fireScriptGroupDelta((IScriptGroup) source);
119
			}
120
		}
121
	}
122
	
123
	/* (non-Javadoc)
48
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleOther(org.eclipse.debug.core.DebugEvent)
124
	 * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleOther(org.eclipse.debug.core.DebugEvent)
49
	 */
125
	 */
50
	protected void handleOther(DebugEvent event) {
126
	protected void handleOther(DebugEvent event) {
Lines 53-59 Link Here
53
			super.handleOther(event);
129
			super.handleOther(event);
54
		}
130
		}
55
		else if(source instanceof IScriptGroup){
131
		else if(source instanceof IScriptGroup){
56
			fireScriptGroupDelta((IScriptGroup) source);
132
			if(PreferencesManager.getManager().showLoadedScripts()) {
133
				fireScriptGroupDelta((IScriptGroup) source);
134
			}
57
		}
135
		}
58
	}
136
	}
59
	
137
	
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointPropertyPage.java (-3 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 190-203 Link Here
190
	protected void createLabels(Composite parent) {
190
	protected void createLabels(Composite parent) {
191
		Composite labelComposite = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL);
191
		Composite labelComposite = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL);
192
		try {
192
		try {
193
			String name = getBreakpoint().getTypeName();
193
			IJavaScriptBreakpoint bp = getBreakpoint();
194
			String name = bp.getTypeName();
194
			if (name != null) {
195
			if (name != null) {
195
				SWTFactory.createLabel(labelComposite, Messages.type_name, 1); 
196
				SWTFactory.createLabel(labelComposite, Messages.type_name, 1); 
196
				Text text = SWTFactory.createText(labelComposite, SWT.READ_ONLY | SWT.SINGLE, 1, GridData.FILL_HORIZONTAL);
197
				Text text = SWTFactory.createText(labelComposite, SWT.READ_ONLY | SWT.SINGLE, 1, GridData.FILL_HORIZONTAL);
197
				text.setText(name);
198
				text.setText(name);
198
				text.setBackground(parent.getBackground());
199
				text.setBackground(parent.getBackground());
199
			}
200
			}
200
			name = getBreakpoint().getScriptPath();
201
			name = bp.getScriptPath();
201
			if(name != null) {
202
			if(name != null) {
202
				SWTFactory.createLabel(labelComposite, Messages.script_path, 1);
203
				SWTFactory.createLabel(labelComposite, Messages.script_path, 1);
203
				Text text = SWTFactory.createText(labelComposite, SWT.READ_ONLY, 1, GridData.FILL_HORIZONTAL);
204
				Text text = SWTFactory.createText(labelComposite, SWT.READ_ONLY, 1, GridData.FILL_HORIZONTAL);
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointUpdater.java (+196 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.breakpoints;
12
13
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IMarker;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.debug.core.DebugPlugin;
18
import org.eclipse.debug.core.IBreakpointManager;
19
import org.eclipse.debug.core.model.IBreakpoint;
20
import org.eclipse.jface.text.BadLocationException;
21
import org.eclipse.jface.text.IDocument;
22
import org.eclipse.jface.text.IRegion;
23
import org.eclipse.jface.text.Position;
24
import org.eclipse.ui.texteditor.IMarkerUpdater;
25
import org.eclipse.ui.texteditor.MarkerUtilities;
26
import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
27
import org.eclipse.wst.jsdt.core.JavaScriptCore;
28
import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
29
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpoint;
30
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
31
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
32
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
33
import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
34
import org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider;
35
36
/**
37
 * A marker updater for {@link IJavaScriptBreakpoint}s
38
 * 
39
 * @since 1.1
40
 */
41
public class JavaScriptBreakpointUpdater implements IMarkerUpdater {
42
43
	/**
44
	 * Constructor
45
	 */
46
	public JavaScriptBreakpointUpdater() {
47
	}
48
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.ui.texteditor.IMarkerUpdater#getMarkerType()
51
	 */
52
	public String getMarkerType() {
53
		return IJavaScriptBreakpoint.MARKER_ID;
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.ui.texteditor.IMarkerUpdater#getAttribute()
58
	 */
59
	public String[] getAttribute() {
60
		return new String[] {IMarker.LINE_NUMBER};
61
	}
62
63
	/* (non-Javadoc)
64
	 * @see org.eclipse.ui.texteditor.IMarkerUpdater#updateMarker(org.eclipse.core.resources.IMarker, org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position)
65
	 */
66
	public boolean updateMarker(IMarker marker, IDocument document, Position position) {
67
		if(position.isDeleted()) {
68
			return false;
69
		}
70
		IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
71
		IBreakpoint breakpoint = manager.getBreakpoint(marker);
72
		if(breakpoint == null) {
73
			return false;
74
		}
75
		IJavaScriptUnit unit = JavaScriptCore.createCompilationUnitFrom((IFile) marker.getResource());
76
		if(unit == null) {
77
			return false;
78
		}
79
		JavaScriptUnit jsunit = JavaScriptPlugin.getDefault().getASTProvider().getAST(unit, ASTProvider.WAIT_YES, null);
80
		try {
81
			BreakpointLocationFinder finder = new BreakpointLocationFinder(jsunit, document.getLineOfOffset(position.getOffset())+1, true);
82
			jsunit.accept(finder);
83
			if(finder.getLocation() == BreakpointLocationFinder.UNKNOWN) {
84
				return false;
85
			}
86
			int line = finder.getLineNumber();
87
			if(MarkerUtilities.getLineNumber(marker) == line) {
88
				//if there exists a breakpoint on the line remove this one
89
				if(isLineBreakpoint(marker)) {
90
					ensureRanges(document, marker, line);
91
					return lineBreakpointExists(marker.getResource(), ((IJavaScriptLineBreakpoint)breakpoint).getScriptPath(), line, marker, true) == null;
92
				}
93
				return true;
94
			}
95
			if(isLineBreakpoint(marker) & line == -1) {
96
				return false;
97
			}
98
			if(lineBreakpointExists(marker.getResource(), ((IJavaScriptLineBreakpoint)breakpoint).getScriptPath(), line, marker, false) != null) {
99
				return false;
100
			}
101
			MarkerUtilities.setLineNumber(marker, line);
102
			if(isLineBreakpoint(marker)) {
103
				ensureRanges(document, marker, line);
104
			}
105
			return true;
106
		}
107
		catch(BadLocationException ble) {
108
			JavaScriptDebugUIPlugin.log(ble);
109
		} catch (CoreException e) {
110
			JavaScriptDebugUIPlugin.log(e);
111
		}
112
		return false;
113
	}
114
	
115
	/**
116
	 * Returns if the given marker is of the type {@link IJavaScriptLineBreakpoint#MARKER_ID}
117
	 * @param marker
118
	 * @return true if the marker is a {@link IJavaScriptLineBreakpoint} marker
119
	 */
120
	boolean isLineBreakpoint(IMarker marker) {
121
		return MarkerUtilities.isMarkerType(marker, IJavaScriptLineBreakpoint.MARKER_ID);
122
	}
123
	
124
	/**
125
	 * Corrects the {@link IMarker#CHAR_START} and {@link IMarker#CHAR_END} values as needed
126
	 * 
127
	 * @param document
128
	 * @param marker
129
	 * @param line
130
	 * @throws BadLocationException
131
	 */
132
	void ensureRanges(IDocument document, IMarker marker, int line) throws BadLocationException {
133
		if(line < 0 || line > document.getNumberOfLines()) {
134
			return;
135
		}
136
		IRegion region = document.getLineInformation(line - 1);
137
		int charstart = region.getOffset();
138
		int charend = charstart + region.getLength();
139
		MarkerUtilities.setCharStart(marker, charstart);
140
		MarkerUtilities.setCharEnd(marker, charend);
141
	}
142
	
143
	/**
144
	 * Looks up the {@link IJavaScriptLineBreakpoint} that is associated with the given marker. Returns <code>null</code> if one 
145
	 * does not exist
146
	 * 
147
	 * @param resource
148
	 * @param typeName
149
	 * @param lineNumber
150
	 * @param currentmarker
151
	 * @param useid if the id of the markers should be compared
152
	 * @return the {@link IJavaScriptLineBreakpoint} for the given marker or <code>null</code> if one does not exist
153
	 * @throws CoreException
154
	 */
155
	IJavaScriptLineBreakpoint lineBreakpointExists(IResource resource, String typeName, int lineNumber, IMarker currentmarker, boolean useid) throws CoreException {
156
		String modelId = JavaScriptDebugModel.MODEL_ID;
157
		IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
158
		IBreakpoint[] breakpoints = manager.getBreakpoints(modelId);
159
		for (int i = 0; i < breakpoints.length; i++) {
160
			if ((breakpoints[i] instanceof IJavaScriptLineBreakpoint)) {
161
				IJavaScriptLineBreakpoint breakpoint = (IJavaScriptLineBreakpoint) breakpoints[i];
162
				if(breakpoint.getLineNumber() == lineNumber) {
163
					IMarker marker = breakpoint.getMarker();
164
					if (marker != null && 
165
							marker.exists() && 
166
							marker.getType().equals(IJavaScriptLineBreakpoint.MARKER_ID) && 
167
							pathsEqual(breakpoint.getScriptPath(), typeName) &&
168
							resource.equals(marker.getResource())) {
169
						if(useid) {
170
							if(currentmarker.getId() != marker.getId()) {
171
								return breakpoint;
172
							}
173
							return null;
174
						}
175
						return breakpoint;
176
					}
177
				}
178
				
179
			}
180
		}
181
		return null;
182
	}
183
	
184
	/**
185
	 * Returns if n1 equals n2, where both being <code>null</code> is also considered equal
186
	 * @param n1
187
	 * @param n2
188
	 * @return 
189
	 */
190
	boolean pathsEqual(String n1, String n2) {
191
		if(n1 == null) {
192
			return n2 == null;
193
		}
194
		return n1.equals(n2);
195
	}
196
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/Messages.java (+6 lines)
Lines 27-32 Link Here
27
	public static String enter_condition;
27
	public static String enter_condition;
28
	public static String entry;
28
	public static String entry;
29
	public static String exit;
29
	public static String exit;
30
	public static String failed_function_bp_no_element;
31
	public static String failed_function_bp_no_resource;
32
	public static String failed_line_bp_no_element;
33
	public static String failed_line_bp_no_resource;
30
	public static String failed_to_create_function_bp;
34
	public static String failed_to_create_function_bp;
31
	public static String failed_to_create_line_bp;
35
	public static String failed_to_create_line_bp;
32
	public static String fuction;
36
	public static String fuction;
Lines 38-43 Link Here
38
	public static String line_breakpoint_settings;
42
	public static String line_breakpoint_settings;
39
	public static String line_number;
43
	public static String line_number;
40
	public static String member;
44
	public static String member;
45
	public static String no_editor_could_be_found;
41
	public static String no_valid_location;
46
	public static String no_valid_location;
42
	public static String script_load_bp;
47
	public static String script_load_bp;
43
	public static String script_load_breakpoint;
48
	public static String script_load_breakpoint;
Lines 47-52 Link Here
47
	public static String suspend_when_changed;
52
	public static String suspend_when_changed;
48
	public static String suspend_when_true;
53
	public static String suspend_when_true;
49
	public static String type_name;
54
	public static String type_name;
55
	public static String type_root_could_not_be_computed;
50
	static {
56
	static {
51
		// initialize resource bundle
57
		// initialize resource bundle
52
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
58
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/ToggleBreakpointAdapter.java (-55 / +28 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-18 Link Here
13
import java.util.HashMap;
13
import java.util.HashMap;
14
14
15
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IMarker;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
Lines 31-36 Link Here
31
import org.eclipse.jface.text.TextSelection;
32
import org.eclipse.jface.text.TextSelection;
32
import org.eclipse.jface.viewers.ISelection;
33
import org.eclipse.jface.viewers.ISelection;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.jface.viewers.IStructuredSelection;
35
import org.eclipse.osgi.util.NLS;
34
import org.eclipse.swt.widgets.Display;
36
import org.eclipse.swt.widgets.Display;
35
import org.eclipse.ui.IEditorInput;
37
import org.eclipse.ui.IEditorInput;
36
import org.eclipse.ui.IEditorPart;
38
import org.eclipse.ui.IEditorPart;
Lines 46-63 Link Here
46
import org.eclipse.wst.jsdt.core.ISourceRange;
48
import org.eclipse.wst.jsdt.core.ISourceRange;
47
import org.eclipse.wst.jsdt.core.IType;
49
import org.eclipse.wst.jsdt.core.IType;
48
import org.eclipse.wst.jsdt.core.ITypeRoot;
50
import org.eclipse.wst.jsdt.core.ITypeRoot;
49
import org.eclipse.wst.jsdt.core.dom.AST;
50
import org.eclipse.wst.jsdt.core.dom.ASTParser;
51
import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
51
import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
52
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpoint;
52
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpoint;
53
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint;
53
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint;
54
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
54
import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint;
55
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
55
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
56
import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin;
57
import org.eclipse.wst.jsdt.debug.internal.ui.DebugWCManager;
56
import org.eclipse.wst.jsdt.debug.internal.ui.DebugWCManager;
57
import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin;
58
import org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider;
58
59
59
/**
60
/**
60
 * Javascript adapter for toggling breakpoints in the JSDT editor
61
 * JavaScript adapter for toggling breakpoints in the JSDT editor
61
 * 
62
 * 
62
 * @since 1.0
63
 * @since 1.0
63
 */
64
 */
Lines 90-99 Link Here
90
            		ITextEditor editor = getTextEditor(part);
91
            		ITextEditor editor = getTextEditor(part);
91
					if(editor != null && part instanceof IEditorPart) {
92
					if(editor != null && part instanceof IEditorPart) {
92
						if(element == null) {
93
						if(element == null) {
93
							reportToStatusLine(part, Messages.failed_to_create_line_bp);
94
							reportToStatusLine(part, Messages.failed_line_bp_no_element);
95
							return Status.CANCEL_STATUS;
96
						}
97
						IResource resource = element.getResource();
98
						if(resource == null) {
99
							reportToStatusLine(part, NLS.bind(Messages.failed_line_bp_no_resource, element.getElementName()));
94
							return Status.CANCEL_STATUS;
100
							return Status.CANCEL_STATUS;
95
						}
101
						}
96
						IResource resource = getBreakpointResource(element);
97
						IBreakpoint bp = lineBreakpointExists(resource, linenumber);
102
						IBreakpoint bp = lineBreakpointExists(resource, linenumber);
98
						if(bp != null) {
103
						if(bp != null) {
99
							DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true);
104
							DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true);
Lines 135-178 Link Here
135
	 * @return the path to the script 
140
	 * @return the path to the script 
136
	 */
141
	 */
137
	String getScriptPath(IJavaScriptElement element) {
142
	String getScriptPath(IJavaScriptElement element) {
138
		IPath path  = getElementScriptPath(element).makeRelative();
143
		IPath path = element.getPath();
139
		if(JavaScriptDebugPlugin.isExternalSource(path)) {
144
		return path.makeAbsolute().toString();
140
			String extpath = (JavaScriptDebugPlugin.getExternalScriptPath(path.removeFirstSegments(1)));
141
			if(extpath != null) {
142
				return extpath;
143
			}
144
		}
145
		return path.toString();
146
	}
147
148
	private IPath getElementScriptPath(IJavaScriptElement element) {
149
		switch (element.getElementType()) {
150
		case IJavaScriptElement.TYPE: {
151
			return ((IType) element).getPath();
152
		}
153
		case IJavaScriptElement.METHOD:
154
		case IJavaScriptElement.FIELD: {
155
			IMember member = (IMember) element;
156
			IType type = member.getDeclaringType();
157
			if (type == null) {
158
				IJavaScriptElement parent = element.getParent();
159
				switch (parent.getElementType()) {
160
				case IJavaScriptElement.TYPE: {
161
					return ((IType) parent).getPath();
162
				}
163
				case IJavaScriptElement.JAVASCRIPT_UNIT:
164
				case IJavaScriptElement.CLASS_FILE: {
165
					return ((ITypeRoot) parent).getPath();
166
				}
167
				}
168
				return element.getParent().getPath();
169
			}
170
			return type.getPath();
171
		}
172
		default: {
173
			return element.getPath();
174
		}
175
		}
176
	}
145
	}
177
	
146
	
178
	/**
147
	/**
Lines 282-299 Link Here
282
	 * Delegate for toggling a method breakpoint
251
	 * Delegate for toggling a method breakpoint
283
	 * @param part
252
	 * @param part
284
	 * @param element
253
	 * @param element
254
	 * @param line
285
	 */
255
	 */
286
	void toggleMethodBreakpoint(final IWorkbenchPart part, final IJavaScriptElement element) {
256
	void toggleMethodBreakpoint(final IWorkbenchPart part, final IJavaScriptElement element, final int line) {
287
		Job job = new Job("Toggle Function Breakpoints") { //$NON-NLS-1$
257
		Job job = new Job("Toggle Function Breakpoints") { //$NON-NLS-1$
288
            protected IStatus run(IProgressMonitor monitor) {
258
            protected IStatus run(IProgressMonitor monitor) {
289
            	try {
259
            	try {
290
					if(element == null) {
260
					if(element == null) {
291
						reportToStatusLine(part, Messages.failed_to_create_function_bp);
261
						reportToStatusLine(part, Messages.failed_function_bp_no_element);
292
						return Status.CANCEL_STATUS;
262
						return Status.CANCEL_STATUS;
293
					}
263
					}
294
					if(element.getElementType() == IJavaScriptElement.METHOD) {
264
					if(element.getElementType() == IJavaScriptElement.METHOD) {
295
						IFunction method = (IFunction) element;
265
						IFunction method = (IFunction) element;
296
						IResource resource = getBreakpointResource(element);
266
						IResource resource = element.getResource();
267
						if(resource == null) {
268
							reportToStatusLine(part, NLS.bind(Messages.failed_function_bp_no_resource, element.getElementName()));
269
							return Status.CANCEL_STATUS;
270
						}
297
						IBreakpoint bp = methodBreakpointExists(resource, method.getElementName(), method.getSignature());
271
						IBreakpoint bp = methodBreakpointExists(resource, method.getElementName(), method.getSignature());
298
						if(bp != null) {
272
						if(bp != null) {
299
							DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true);
273
							DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true);
Lines 310-315 Link Here
310
						//nothing else we can do
284
						//nothing else we can do
311
						attributes.put(IJavaScriptBreakpoint.TYPE_NAME, getTypeName(element));
285
						attributes.put(IJavaScriptBreakpoint.TYPE_NAME, getTypeName(element));
312
						attributes.put(IJavaScriptBreakpoint.SCRIPT_PATH, getScriptPath(element));
286
						attributes.put(IJavaScriptBreakpoint.SCRIPT_PATH, getScriptPath(element));
287
						attributes.put(IMarker.LINE_NUMBER, new Integer(line));
313
						IJavaScriptFunctionBreakpoint breakpoint = JavaScriptDebugModel.createFunctionBreakpoint(resource, method.getElementName(), method.getSignature(), start, end, attributes, true);
288
						IJavaScriptFunctionBreakpoint breakpoint = JavaScriptDebugModel.createFunctionBreakpoint(resource, method.getElementName(), method.getSignature(), start, end, attributes, true);
314
						breakpoint.setJavaScriptElementHandle(element.getHandleIdentifier());
289
						breakpoint.setJavaScriptElementHandle(element.getHandleIdentifier());
315
						return Status.OK_STATUS;
290
						return Status.OK_STATUS;
Lines 373-379 Link Here
373
		if(selection instanceof ITextSelection) {
348
		if(selection instanceof ITextSelection) {
374
			ITextEditor textEditor = getTextEditor(part);
349
			ITextEditor textEditor = getTextEditor(part);
375
			if(textEditor == null) {
350
			if(textEditor == null) {
376
				reportToStatusLine(part, Messages.no_valid_location);
351
				reportToStatusLine(part, Messages.no_editor_could_be_found);
377
				return;
352
				return;
378
			}
353
			}
379
			ITypeRoot root = getTypeRoot(textEditor.getEditorInput());
354
			ITypeRoot root = getTypeRoot(textEditor.getEditorInput());
Lines 384-395 Link Here
384
                }
359
                }
385
            }
360
            }
386
            if(root == null) {
361
            if(root == null) {
387
            	reportToStatusLine(part, Messages.no_valid_location);
362
            	reportToStatusLine(part, Messages.type_root_could_not_be_computed);
388
            	return;
363
            	return;
389
            }
364
            }
390
			ASTParser parser = ASTParser.newParser(AST.JLS3);
365
			JavaScriptUnit jsunit = JavaScriptPlugin.getDefault().getASTProvider().getAST(root, ASTProvider.WAIT_YES, null);
391
			parser.setSource(root);
392
			JavaScriptUnit jsunit = (JavaScriptUnit) parser.createAST(null);
393
			BreakpointLocationFinder finder = new BreakpointLocationFinder(jsunit, ((TextSelection)selection).getStartLine()+1, false);
366
			BreakpointLocationFinder finder = new BreakpointLocationFinder(jsunit, ((TextSelection)selection).getStartLine()+1, false);
394
			jsunit.accept(finder);
367
			jsunit.accept(finder);
395
			switch(finder.getLocation()) {
368
			switch(finder.getLocation()) {
Lines 406-412 Link Here
406
					return;
379
					return;
407
				}
380
				}
408
				case BreakpointLocationFinder.FUNCTION: {
381
				case BreakpointLocationFinder.FUNCTION: {
409
					toggleMethodBreakpoint(part, root.getElementAt(finder.getOffset()));
382
					toggleMethodBreakpoint(part, root.getElementAt(finder.getOffset()), finder.getLineNumber());
410
					return;
383
					return;
411
				}
384
				}
412
			}
385
			}
Lines 417-423 Link Here
417
        	if(o instanceof IMember) {
390
        	if(o instanceof IMember) {
418
        		IMember member = (IMember) o;
391
        		IMember member = (IMember) o;
419
        		if(member.getElementType() == IJavaScriptElement.METHOD) {
392
        		if(member.getElementType() == IJavaScriptElement.METHOD) {
420
    				toggleMethodBreakpoint(part, member);
393
    				toggleMethodBreakpoint(part, member, -1);
421
    			}
394
    			}
422
        	}
395
        	}
423
		}
396
		}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/messages.properties (+6 lines)
Lines 18-23 Link Here
18
enter_condition=Enter a condition
18
enter_condition=Enter a condition
19
entry=E&ntry
19
entry=E&ntry
20
exit=E&xit
20
exit=E&xit
21
failed_function_bp_no_element=Failed to create Javascript function breakpoint - the JavaScript element could not be computed
22
failed_function_bp_no_resource=Failed to create Javascript function breakpoint - the resource could no be computed for {0}
23
failed_line_bp_no_element=Failed to create Javascript line breakpoint - the JavaScript element could not be computed
24
failed_line_bp_no_resource=Failed to create Javascript line breakpoint - the resource could no be computed for {0}
21
failed_to_create_function_bp=Failed to create Javascript function breakpoint
25
failed_to_create_function_bp=Failed to create Javascript function breakpoint
22
failed_to_create_line_bp=Failed to create Javascript line breakpoint
26
failed_to_create_line_bp=Failed to create Javascript line breakpoint
23
fuction=F&unction
27
fuction=F&unction
Lines 29-34 Link Here
29
line_breakpoint_settings=Line Breakpoint Settings
33
line_breakpoint_settings=Line Breakpoint Settings
30
line_number=&Line Number:
34
line_number=&Line Number:
31
member=&Member:
35
member=&Member:
36
no_editor_could_be_found=No editor could be found for the associated part
32
no_valid_location=A valid location could not be found for the breakpoint
37
no_valid_location=A valid location could not be found for the breakpoint
33
script_load_bp=Script Load Breakpoint
38
script_load_bp=Script Load Breakpoint
34
script_load_breakpoint=Script Load Breakpoint
39
script_load_breakpoint=Script Load Breakpoint
Lines 38-40 Link Here
38
suspend_when_changed=Suspend &when value changes
43
suspend_when_changed=Suspend &when value changes
39
suspend_when_true=Suspend when 'tr&ue'
44
suspend_when_true=Suspend when 'tr&ue'
40
type_name=&Type Name:
45
type_name=&Type Name:
46
type_root_could_not_be_computed=The type root could not be computed for the editor
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/EvaluationManager.java (+273 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.List;
16
17
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.debug.ui.DebugUITools;
19
import org.eclipse.debug.ui.contexts.DebugContextEvent;
20
import org.eclipse.debug.ui.contexts.IDebugContextListener;
21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.ui.IWindowListener;
24
import org.eclipse.ui.IWorkbench;
25
import org.eclipse.ui.IWorkbenchPage;
26
import org.eclipse.ui.IWorkbenchPart;
27
import org.eclipse.ui.IWorkbenchWindow;
28
import org.eclipse.ui.PlatformUI;
29
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame;
30
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
31
32
/**
33
 * Manager to handle contexts for evaluations
34
 * 
35
 * @since 1.0
36
 */
37
public class EvaluationManager implements IDebugContextListener, IWindowListener {
38
39
	/**
40
	 * System property used to know if the debugger is active or not
41
	 */
42
	public static final String DEBUGGER_ACTIVE = JavaScriptDebugUIPlugin.PLUGIN_ID + ".jsdebuggerActive"; //$NON-NLS-1$
43
	
44
	private static EvaluationManager instance = null;
45
	
46
	private IWorkbenchWindow activewindow = null;
47
	private HashMap contextmap = null;
48
	
49
	/**
50
	 * Constructor
51
	 */
52
	private EvaluationManager() {
53
		//no instantiation
54
		DebugUITools.getDebugContextManager().addDebugContextListener(this);
55
	}
56
	
57
	/**
58
	 * Returns the singleton instance
59
	 * 
60
	 * @return the instance
61
	 */
62
	public static synchronized EvaluationManager getManager() {
63
		if(instance == null) {
64
			instance = new EvaluationManager();
65
		}
66
		return instance;
67
	}
68
	
69
	/**
70
	 * Start the manager
71
	 */
72
	public void start() {
73
		IWorkbench workbench = PlatformUI.getWorkbench();
74
		IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
75
		for (int i = 0; i < windows.length; i++) {
76
			instance.windowOpened(windows[i]);	
77
		}
78
		workbench.addWindowListener(this);
79
		instance.activewindow = workbench.getActiveWorkbenchWindow();
80
	}
81
	
82
	/**
83
	 * Stop the manager and un-hook it as listeners
84
	 */
85
	public void stop() {
86
		DebugUITools.getDebugContextManager().removeDebugContextListener(this);
87
		PlatformUI.getWorkbench().removeWindowListener(this);
88
	}
89
	
90
	/**
91
	 * Returns the evaluation context for the given window, or <code>null</code> if none.
92
	 * The evaluation context corresponds to the selected stack frame in the following
93
	 * priority order:<ol>
94
	 * <li>stack frame in active page of the window</li>
95
	 * <li>stack frame in another page of the window</li>
96
	 * <li>stack frame in active page of another window</li>
97
	 * <li>stack frame in a page of another window</li>
98
	 * </ol>
99
	 * 
100
	 * @param window the window that the evaluation action was invoked from, or
101
	 *  <code>null</code> if the current window should be consulted
102
	 * @return the stack frame that supplies an evaluation context, or <code>null</code>
103
	 *   if none
104
	 * @return IJavaStackFrame
105
	 */
106
	public IJavaScriptStackFrame getEvaluationContext(IWorkbenchWindow window) {
107
		List otherwindows = new ArrayList();
108
		if (window == null) {
109
			return getEvaluationContext(activewindow, otherwindows);
110
		}
111
		return getEvaluationContext(window, otherwindows);
112
	}
113
	
114
	/**
115
	 * Returns the evaluation context for the given part, or <code>null</code> if none.
116
	 * The evaluation context corresponds to the selected stack frame in the following
117
	 * priority order:<ol>
118
	 * <li>stack frame in the same page</li>
119
	 * <li>stack frame in the same window</li>
120
	 * <li>stack frame in active page of other window</li>
121
	 * <li>stack frame in page of other windows</li>
122
	 * </ol>
123
	 * 
124
	 * @param part the part that the evaluation action was invoked from
125
	 * @return the stack frame that supplies an evaluation context, or <code>null</code>
126
	 *   if none
127
	 */
128
	public IJavaScriptStackFrame getEvaluationContext(IWorkbenchPart part) {
129
		IWorkbenchPage page = part.getSite().getPage();
130
		IJavaScriptStackFrame frame = getContext(page);
131
		if (frame == null) {
132
			return getEvaluationContext(page.getWorkbenchWindow());
133
		}
134
		return frame;
135
	}
136
	
137
	/**
138
	 * Looks up the current evaluation context for the given window. Tries all workbench windows
139
	 * if the active window does not have a context
140
	 * 
141
	 * @param window the window to look in
142
	 * @param otherwindows a listing of all other windows to try if the given window does not have a context
143
	 * @return the evaluation context or <code>null</code>
144
	 */
145
	IJavaScriptStackFrame getEvaluationContext(IWorkbenchWindow window, List otherwindows) {
146
		IWorkbenchPage activePage = window.getActivePage();
147
		IJavaScriptStackFrame frame = null;
148
		if (activePage != null) {
149
			frame = getContext(activePage);
150
		}
151
		if (frame == null) {
152
			IWorkbenchPage[] pages = window.getPages();
153
			for (int i = 0; i < pages.length; i++) {
154
				if (activePage != pages[i]) {
155
					frame = getContext(pages[i]);
156
					if (frame != null) {
157
						return frame;
158
					}
159
				}
160
			}
161
			otherwindows.add(window);
162
			IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
163
			for (int i = 0; i < windows.length; i++) {
164
				if (!otherwindows.contains(windows[i])) {
165
					frame = getEvaluationContext(windows[i], otherwindows);
166
					if (frame != null) {
167
						return frame;
168
					}
169
				}
170
			}
171
			return null;
172
		}
173
		return frame;
174
	}
175
	
176
	/**
177
	 * Looks up a context for the given page. Returns <code>null</code> if no mapping is found
178
	 * or if the context map has not been initialized
179
	 * 
180
	 * @param page the page to look up a context for
181
	 * 
182
	 * @return the {@link IJavaScriptStackFrame} context for the given page or <code>null</code>
183
	 */
184
	IJavaScriptStackFrame getContext(IWorkbenchPage page) {
185
		if (contextmap != null) {
186
			return (IJavaScriptStackFrame)contextmap.get(page);
187
		}
188
		return null;
189
	}
190
	
191
	/* (non-Javadoc)
192
	 * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent)
193
	 */
194
	public void debugContextChanged(DebugContextEvent event) {
195
		if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) {
196
			IWorkbenchPart part = event.getDebugContextProvider().getPart();
197
			if (part != null) {
198
				IWorkbenchPage page = part.getSite().getPage();
199
				ISelection selection = event.getContext();
200
				if (selection instanceof IStructuredSelection) {
201
					IStructuredSelection ss = (IStructuredSelection)selection;
202
					if (ss.size() == 1) {
203
						Object element = ss.getFirstElement();
204
						if (element instanceof IAdaptable) {
205
							IJavaScriptStackFrame frame = (IJavaScriptStackFrame)((IAdaptable)element).getAdapter(IJavaScriptStackFrame.class);
206
							if (frame != null) {
207
								setContext(page, frame);
208
								return;
209
							}
210
						}
211
					}
212
				}
213
				// no context in the given view
214
				removeContext(page);
215
			}
216
		}
217
	}
218
219
	/**
220
	 * Sets the evaluation context for the given page, and notes that
221
	 * a valid execution context exists.
222
	 * 
223
	 * @param page
224
	 * @param frame
225
	 */
226
	private synchronized void setContext(IWorkbenchPage page, IJavaScriptStackFrame frame) {
227
		if (contextmap == null) {
228
			contextmap = new HashMap();
229
		}
230
		contextmap.put(page, frame);
231
		System.setProperty(DEBUGGER_ACTIVE, "true"); //$NON-NLS-1$
232
	}
233
	
234
	/**
235
	 * Removes an evaluation context for the given page, and determines if
236
	 * any valid execution context remain.
237
	 * 
238
	 * @param page
239
	 */
240
	private void removeContext(IWorkbenchPage page) {
241
		if (contextmap != null) {
242
			contextmap.remove(page);
243
			if (contextmap.isEmpty()) {
244
				System.setProperty(DEBUGGER_ACTIVE, "false"); //$NON-NLS-1$
245
			}
246
		}
247
	}
248
	
249
	/* (non-Javadoc)
250
	 * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
251
	 */
252
	public void windowActivated(IWorkbenchWindow window) {
253
		activewindow = window;
254
	}
255
256
	/* (non-Javadoc)
257
	 * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
258
	 */
259
	public void windowDeactivated(IWorkbenchWindow window) {
260
	}
261
262
	/* (non-Javadoc)
263
	 * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
264
	 */
265
	public void windowClosed(IWorkbenchWindow window) {
266
	}
267
268
	/* (non-Javadoc)
269
	 * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
270
	 */
271
	public void windowOpened(IWorkbenchWindow window) {
272
	}
273
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/ExpressionInformationControlCreator.java (+441 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.model.IVariable;
15
import org.eclipse.debug.internal.ui.SWTFactory;
16
import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider;
17
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
18
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
19
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
20
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener;
21
import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
22
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
23
import org.eclipse.debug.internal.ui.views.variables.details.DefaultDetailPane;
24
import org.eclipse.debug.internal.ui.views.variables.details.DetailPaneProxy;
25
import org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer;
26
import org.eclipse.debug.ui.AbstractDebugView;
27
import org.eclipse.debug.ui.IDebugUIConstants;
28
import org.eclipse.jface.dialogs.IDialogSettings;
29
import org.eclipse.jface.text.AbstractInformationControl;
30
import org.eclipse.jface.text.IInformationControl;
31
import org.eclipse.jface.text.IInformationControlCreator;
32
import org.eclipse.jface.text.IInformationControlExtension2;
33
import org.eclipse.jface.viewers.IStructuredSelection;
34
import org.eclipse.jface.viewers.StructuredViewer;
35
import org.eclipse.jface.viewers.TreePath;
36
import org.eclipse.jface.viewers.TreeSelection;
37
import org.eclipse.jface.viewers.ViewerFilter;
38
import org.eclipse.swt.SWT;
39
import org.eclipse.swt.custom.SashForm;
40
import org.eclipse.swt.events.SelectionEvent;
41
import org.eclipse.swt.events.SelectionListener;
42
import org.eclipse.swt.graphics.Color;
43
import org.eclipse.swt.graphics.Point;
44
import org.eclipse.swt.layout.GridData;
45
import org.eclipse.swt.layout.GridLayout;
46
import org.eclipse.swt.widgets.Composite;
47
import org.eclipse.swt.widgets.Layout;
48
import org.eclipse.swt.widgets.Shell;
49
import org.eclipse.swt.widgets.Tree;
50
import org.eclipse.ui.IWorkbenchPage;
51
import org.eclipse.ui.IWorkbenchPartSite;
52
import org.eclipse.ui.PlatformUI;
53
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
54
55
/**
56
 * Creates an information control to display an expression in a hover control.
57
 * 
58
 * @since 1.1
59
 */
60
public class ExpressionInformationControlCreator implements IInformationControlCreator {
61
62
	class ExpressionInformationControl extends AbstractInformationControl implements IInformationControlExtension2 {
63
64
		/**
65
		 * Dialog setting key for height
66
		 */
67
		private static final String HEIGHT = "HEIGHT"; //$NON-NLS-1$
68
69
		/**
70
		 * Dialog setting key for width. 
71
		 */
72
		private static final String WIDTH = "WIDTH"; //$NON-NLS-1$
73
74
		/**
75
		 * Dialog setting key for tree sash weight
76
		 */
77
		private static final String SASH_WEIGHT_TREE = "SashWeightTree"; //$NON-NLS-1$
78
		
79
		/**
80
		 * Dialog setting key for details sash weight
81
		 */
82
		private static final String SASH_WEIGHT_DETAILS = "SashWeightDetails"; //$NON-NLS-1$		
83
		
84
		/**
85
		 * Variable to display.
86
		 */
87
		private IVariable fVariable;
88
		
89
		private IPresentationContext fContext;
90
	    private TreeModelViewer fViewer;
91
	    private SashForm fSashForm;
92
	    private Composite fDetailPaneComposite;
93
	    private DetailPaneProxy fDetailPane;
94
	    private Tree fTree;
95
		    
96
		/**
97
	     * Creates the content for the root element of the tree viewer in the hover
98
	     */
99
	    private class TreeRoot extends ElementContentProvider {
100
			/* (non-Javadoc)
101
			 * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext)
102
			 */
103
			protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
104
				return 1;
105
			}
106
			/* (non-Javadoc)
107
			 * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildren(java.lang.Object, int, int, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext)
108
			 */
109
			protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException {
110
				return new Object[] { fVariable };
111
			}
112
			
113
			/* (non-Javadoc)
114
			 * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String)
115
			 */
116
			protected boolean supportsContextId(String id) {
117
				return true;
118
			}
119
	    }
120
	    
121
		/**
122
		 * Inner class implementing IDetailPaneContainer methods.  Handles changes to detail
123
		 * pane and provides limited access to the detail pane proxy.
124
		 */
125
		private class DetailPaneContainer implements IDetailPaneContainer{
126
		
127
			/* (non-Javadoc)
128
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getCurrentPaneID()
129
			 */
130
			public String getCurrentPaneID() {
131
				return fDetailPane.getCurrentPaneID();
132
			}
133
		
134
			/* (non-Javadoc)
135
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getCurrentSelection()
136
			 */
137
			public IStructuredSelection getCurrentSelection() {
138
				return (IStructuredSelection)fViewer.getSelection();
139
			}
140
		
141
			/* (non-Javadoc)
142
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#refreshDetailPaneContents()
143
			 */
144
			public void refreshDetailPaneContents() {		
145
				fDetailPane.display(getCurrentSelection());
146
			}
147
		
148
			/* (non-Javadoc)
149
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getParentComposite()
150
			 */
151
			public Composite getParentComposite() {
152
				return fDetailPaneComposite;
153
			}
154
		
155
			/* (non-Javadoc)
156
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getWorkbenchPartSite()
157
			 */
158
			public IWorkbenchPartSite getWorkbenchPartSite() {
159
				return null;
160
			}
161
		
162
			/* (non-Javadoc)
163
			 * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#paneChanged(java.lang.String)
164
			 */
165
			public void paneChanged(String newPaneID) {
166
				if (newPaneID.equals(DefaultDetailPane.ID)){
167
					fDetailPane.getCurrentControl().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
168
				}
169
			}
170
		
171
		}	    
172
173
		/**
174
		 * Constructs a new control in the given shell.
175
		 * 
176
		 * @param parentShell shell
177
		 * @param resize whether resize is supported
178
		 */
179
		ExpressionInformationControl(Shell parentShell, boolean resize) {
180
			super(parentShell, resize);
181
			create();
182
		}
183
		
184
		/* (non-Javadoc)
185
		 * @see org.eclipse.jface.text.AbstractInformationControl#computeSizeHint()
186
		 */
187
		public Point computeSizeHint() {
188
			IDialogSettings settings = getDialogSettings(false);
189
			if (settings != null) {
190
				int x = getIntSetting(settings, WIDTH);
191
				if (x > 0) {
192
					int y = getIntSetting(settings, HEIGHT);
193
					if (y > 0) {
194
						return new Point(x,y);
195
					}
196
				}
197
			}
198
			return super.computeSizeHint();
199
		}
200
201
		/**
202
		 * Returns the dialog settings for this hover or <code>null</code> if none
203
		 * 
204
		 * @param create whether to create the settings
205
		 */
206
		private IDialogSettings getDialogSettings(boolean create) {
207
			IDialogSettings settings = JavaScriptDebugUIPlugin.getDefault().getDialogSettings();
208
			IDialogSettings section = settings.getSection(this.getClass().getName());
209
			if (section == null & create) {
210
				section = settings.addNewSection(this.getClass().getName());
211
			}
212
			return section;
213
		}
214
		
215
		/**
216
		 * Returns an integer value in the given dialog settings or -1 if none.
217
		 * 
218
		 * @param settings dialog settings
219
		 * @param key key
220
		 * @return value or -1 if not present
221
		 */
222
		private int getIntSetting(IDialogSettings settings, String key) {
223
			try {
224
				return settings.getInt(key);
225
			} catch (NumberFormatException e) {
226
				return -1;
227
			}
228
		}
229
		
230
		/* (non-Javadoc)
231
		 * @see org.eclipse.jface.text.AbstractInformationControl#dispose()
232
		 */
233
		public void dispose() {
234
			persistSettings(getShell());
235
            fContext.dispose();
236
			super.dispose();
237
		}
238
239
		/**
240
		 * Persists dialog settings.
241
		 * 
242
		 * @param shell
243
		 */
244
		private void persistSettings(Shell shell) {
245
			if (shell != null && !shell.isDisposed()) {
246
				if (isResizable()) {
247
					IDialogSettings settings = getDialogSettings(true);
248
					Point size = shell.getSize();
249
					settings.put(WIDTH, size.x);
250
					settings.put(HEIGHT, size.y);
251
					int[] weights = fSashForm.getWeights();
252
					settings.put(SASH_WEIGHT_TREE, weights[0]);
253
					settings.put(SASH_WEIGHT_DETAILS, weights[1]);
254
				}
255
			}
256
		}
257
		
258
		/* (non-Javadoc)
259
		 * @see org.eclipse.jface.text.AbstractInformationControl#setVisible(boolean)
260
		 */
261
		public void setVisible(boolean visible) {
262
			if (!visible) {		
263
				persistSettings(getShell());
264
			}
265
			super.setVisible(visible);
266
		}
267
268
		/* (non-Javadoc)
269
		 * @see org.eclipse.jface.text.AbstractInformationControl#createContent(org.eclipse.swt.widgets.Composite)
270
		 */
271
		protected void createContent(Composite parent) {
272
273
	        fSashForm = new SashForm(parent, parent.getStyle());
274
	        fSashForm.setOrientation(SWT.VERTICAL);
275
276
		    // update presentation context
277
	        AbstractDebugView view = getViewToEmulate();
278
	        fContext = new PresentationContext(IDebugUIConstants.ID_VARIABLE_VIEW);
279
	        if (view != null) {
280
	        	// copy over properties
281
	        	IPresentationContext copy = ((TreeModelViewer)view.getViewer()).getPresentationContext();
282
	        	String[] properties = copy.getProperties();
283
	        	for (int i = 0; i < properties.length; i++) {
284
					String key = properties[i];
285
					fContext.setProperty(key, copy.getProperty(key));
286
				}
287
	        }
288
	       
289
	        fViewer = new TreeModelViewer(fSashForm, SWT.NO_TRIM | SWT.MULTI | SWT.VIRTUAL, fContext);
290
	        fViewer.setAutoExpandLevel(1);
291
	        
292
	        if (view != null) {
293
	        	// copy over filters
294
	        	StructuredViewer structuredViewer = (StructuredViewer) view.getViewer();
295
	            if (structuredViewer != null) {
296
	                ViewerFilter[] filters = structuredViewer.getFilters();
297
	                for (int i = 0; i < filters.length; i++) {
298
	                    fViewer.addFilter(filters[i]);
299
	                }
300
	            }
301
	        }
302
303
	        fDetailPaneComposite = SWTFactory.createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
304
	        Layout layout = fDetailPaneComposite.getLayout();
305
	        if (layout instanceof GridLayout) {
306
				GridLayout gl = (GridLayout) layout;
307
				gl.marginHeight = 0;
308
				gl.marginWidth = 0;
309
			}
310
	        
311
	        fDetailPane = new DetailPaneProxy(new DetailPaneContainer());
312
	        fDetailPane.display(null); // Bring up the default pane so the user doesn't see an empty composite
313
	      
314
	        fTree = fViewer.getTree();
315
	        fTree.addSelectionListener(new SelectionListener() {
316
	            public void widgetSelected(SelectionEvent e) {
317
	            	fDetailPane.display((IStructuredSelection)fViewer.getSelection());
318
	            }
319
	            public void widgetDefaultSelected(SelectionEvent e) {}
320
	        });
321
322
	        initSashWeights();
323
	              
324
	        // add update listener to auto-select and display details of root expression
325
	        fViewer.addViewerUpdateListener(new IViewerUpdateListener() {
326
				public void viewerUpdatesComplete() {
327
				}		
328
				public void viewerUpdatesBegin() {
329
				}
330
				public void updateStarted(IViewerUpdate update) {
331
				}
332
				public void updateComplete(IViewerUpdate update) {
333
					if (update instanceof IChildrenUpdate) {
334
						TreeSelection selection = new TreeSelection(new TreePath(new Object[]{fVariable}));
335
						fViewer.setSelection(selection);
336
						fDetailPane.display(selection);
337
						fViewer.removeViewerUpdateListener(this);
338
					}
339
				}
340
			});        
341
	        
342
	        setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
343
		}
344
		
345
346
		/**
347
	     * Attempts to find an appropriate view to emulate, this will either be the
348
	     * variables view or the expressions view.
349
	     * @return a view to emulate or <code>null</code>
350
	     */
351
	    private AbstractDebugView getViewToEmulate() {
352
	        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
353
	        AbstractDebugView expressionsView = (AbstractDebugView) page.findView(IDebugUIConstants.ID_EXPRESSION_VIEW);
354
	        if (expressionsView != null && expressionsView.isVisible()) {
355
	            return expressionsView;
356
	        }
357
	        AbstractDebugView variablesView = (AbstractDebugView) page.findView(IDebugUIConstants.ID_VARIABLE_VIEW);
358
	        if (variablesView != null && variablesView.isVisible()) {
359
	            return variablesView;
360
	        }
361
	        if (expressionsView != null) {
362
	            return expressionsView;
363
	        }
364
	        return variablesView;
365
	    }	
366
367
		/**
368
	     * Initializes the sash form weights from the preference store (using default values if 
369
	     * no sash weights were stored previously).
370
	     */
371
	    protected void initSashWeights(){
372
	    	IDialogSettings settings = getDialogSettings(false);
373
	    	if (settings != null) {
374
		    	int tree = getIntSetting(settings, SASH_WEIGHT_TREE);
375
		    	if (tree > 0) {
376
		    		int details = getIntSetting(settings, SASH_WEIGHT_DETAILS);
377
		    		if (details > 0) {
378
		    			fSashForm.setWeights(new int[]{tree, details});
379
		    		}
380
		    	}
381
	    	}
382
	    }
383
	    		
384
		/* (non-Javadoc)
385
		 * @see org.eclipse.jface.text.AbstractInformationControl#setBackgroundColor(org.eclipse.swt.graphics.Color)
386
		 */
387
		public void setBackgroundColor(Color background) {
388
			super.setBackgroundColor(background);
389
			fDetailPaneComposite.setBackground(background);
390
			fTree.setBackground(background);
391
		}
392
	
393
		/* (non-Javadoc)
394
		 * @see org.eclipse.jface.text.AbstractInformationControl#setFocus()
395
		 */
396
		public void setFocus() {
397
			super.setFocus();
398
			fTree.setFocus();
399
		}
400
		
401
		/* (non-Javadoc)
402
		 * @see org.eclipse.jface.text.IInformationControlExtension#hasContents()
403
		 */
404
		public boolean hasContents() {
405
			return fVariable != null;
406
		}
407
408
		/* (non-Javadoc)
409
		 * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
410
		 */
411
		public void setInput(Object input) {
412
			if (input instanceof IVariable) {	        
413
				fVariable = (IVariable) input;
414
		        fViewer.setInput(new TreeRoot());
415
			}
416
		}
417
418
		/* (non-Javadoc)
419
		 * @see org.eclipse.jface.text.AbstractInformationControl#getInformationPresenterControlCreator()
420
		 */
421
		public IInformationControlCreator getInformationPresenterControlCreator() {
422
			return new ExpressionInformationControlCreator() {
423
				/* (non-Javadoc)
424
				 * @see org.eclipse.jdt.internal.debug.ui.ExpressionInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
425
				 */
426
				public IInformationControl createInformationControl(Shell shell) {
427
					return new ExpressionInformationControl(shell, true);
428
				}
429
			};
430
		}
431
	}
432
433
	/* (non-Javadoc)
434
	 * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
435
	 */
436
	public IInformationControl createInformationControl(Shell parent) {
437
		return new ExpressionInformationControl(parent, false);
438
	}
439
440
441
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptDebugHover.java (+193 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.debug.core.DebugException;
15
import org.eclipse.debug.core.model.IValue;
16
import org.eclipse.debug.core.model.IVariable;
17
import org.eclipse.debug.ui.DebugUITools;
18
import org.eclipse.jface.text.BadLocationException;
19
import org.eclipse.jface.text.IDocument;
20
import org.eclipse.jface.text.IInformationControlCreator;
21
import org.eclipse.jface.text.IRegion;
22
import org.eclipse.jface.text.ITextHoverExtension;
23
import org.eclipse.jface.text.ITextHoverExtension2;
24
import org.eclipse.jface.text.ITextViewer;
25
import org.eclipse.ui.IEditorPart;
26
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame;
27
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
28
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptModelPresentation;
29
import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder;
30
import org.eclipse.wst.jsdt.ui.text.java.hover.IJavaEditorTextHover;
31
32
/**
33
 * JavaScript hover to show variables
34
 * 
35
 * @since 1.1
36
 */
37
public class JavaScriptDebugHover implements IJavaEditorTextHover, ITextHoverExtension, ITextHoverExtension2 {
38
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
41
	 */
42
	public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
43
		Object object = getHoverInfo2(textViewer, hoverRegion);
44
		if (object instanceof IVariable) {	
45
			IVariable var = (IVariable) object;
46
			return getVariableText(var);
47
		}
48
		return null;
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
53
	 */
54
	public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
55
		return JavaWordFinder.findWord(textViewer.getDocument(), offset);
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
60
	 */
61
	public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
62
		IJavaScriptStackFrame frame = getFrame();
63
	    if (frame != null) {
64
	        IDocument document = textViewer.getDocument();
65
			if (document != null) {
66
			    try {
67
                    String variableName = document.get(hoverRegion.getOffset(), hoverRegion.getLength());
68
                    IVariable var = findLocalVariable(frame, variableName);
69
                    if(var != null) {
70
                    	return var;
71
                    }
72
                    //might be in 'this'
73
                    var = frame.getThisObject();
74
                    try {
75
	                    IValue val = var.getValue();
76
	                    if(val != null) {
77
	                    	IVariable[] vars = val.getVariables();
78
	                    	for (int i = 0; i < vars.length; i++) {
79
	                    		if(vars[i].getName().equals(variableName)) {
80
	                    			return vars[i];
81
	                    		}
82
							}
83
	                    }
84
                    }
85
                    catch(DebugException de) {
86
                    	return null;
87
                    }
88
                    	
89
                } catch (BadLocationException e) {
90
                    return null;
91
                }
92
			}
93
	    }
94
	    return null;
95
	}
96
97
	/**
98
	 * Returns a local variable in the given frame based on the the given name
99
	 * or <code>null</code> if none.
100
	 * 
101
	 * @return local variable or <code>null</code>
102
	 */
103
	private IVariable findLocalVariable(IJavaScriptStackFrame frame, String variableName) {
104
		if (frame != null) {
105
			try {
106
				IVariable[] vars = frame.getVariables();
107
            	for (int i = 0; i < vars.length; i++) {
108
					if(vars[i].getName().equals(variableName)) {
109
						return vars[i];
110
					}
111
				}
112
			} catch (DebugException x) {
113
				JavaScriptDebugUIPlugin.log(x);
114
			}
115
		}
116
		return null;
117
	}	
118
	
119
	/* (non-Javadoc)
120
	 * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
121
	 */
122
	public IInformationControlCreator getHoverControlCreator() {
123
		return new ExpressionInformationControlCreator();
124
	}
125
126
	/* (non-Javadoc)
127
	 * @see org.eclipse.wst.jsdt.ui.text.java.hover.IJavaEditorTextHover#setEditor(org.eclipse.ui.IEditorPart)
128
	 */
129
	public void setEditor(IEditorPart editor) {
130
	}
131
	
132
	/**
133
	 * Returns HTML text for the given variable
134
	 */
135
	private static String getVariableText(IVariable variable) {
136
	    StringBuffer buffer= new StringBuffer();
137
		JavaScriptModelPresentation modelPresentation = new JavaScriptModelPresentation();
138
		buffer.append("<p><pre>"); //$NON-NLS-1$
139
		String variableText= modelPresentation.getText(variable);
140
		buffer.append(replaceHTMLChars(variableText));
141
		buffer.append("</pre></p>"); //$NON-NLS-1$
142
		modelPresentation.dispose();
143
		if (buffer.length() > 0) {
144
			return buffer.toString();
145
		}
146
		return null;
147
	}
148
	
149
	/**
150
	 * Replaces reserved HTML characters in the given string with
151
	 * their escaped equivalents. This is to ensure that variable
152
	 * values containing reserved characters are correctly displayed.
153
     */
154
    private static String replaceHTMLChars(String variableText) {
155
        StringBuffer buffer = new StringBuffer(variableText.length());
156
        char[] characters = variableText.toCharArray();
157
        for (int i = 0; i < characters.length; i++) {
158
            char character = characters[i];
159
            switch (character) {
160
            	case '<':
161
            	    buffer.append("&lt;"); //$NON-NLS-1$
162
            	    break;
163
            	case '>':
164
            	    buffer.append("&gt;"); //$NON-NLS-1$
165
            	    break;
166
            	case '&':
167
            	    buffer.append("&amp;"); //$NON-NLS-1$
168
            	    break;
169
            	case '"':
170
            	    buffer.append("&quot;"); //$NON-NLS-1$
171
            	    break;
172
            	default:
173
            	    buffer.append(character);
174
            }
175
        }
176
        return buffer.toString();
177
    }
178
	
179
	/**
180
	 * Returns the stack frame in which to search for variables, or <code>null</code>
181
	 * if none.
182
	 * 
183
	 * @return the stack frame in which to search for variables, or <code>null</code>
184
	 * if none
185
	 */
186
	protected IJavaScriptStackFrame getFrame() {
187
	    IAdaptable adaptable = DebugUITools.getDebugContext();
188
		if (adaptable != null) {
189
			return (IJavaScriptStackFrame)adaptable.getAdapter(IJavaScriptStackFrame.class);
190
		}
191
		return null;
192
	}
193
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptHyperlinkDetector.java (+122 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
import org.eclipse.jface.text.IDocument;
14
import org.eclipse.jface.text.IRegion;
15
import org.eclipse.jface.text.ITextViewer;
16
import org.eclipse.jface.text.TextSelection;
17
import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
18
import org.eclipse.jface.text.hyperlink.IHyperlink;
19
import org.eclipse.ui.IEditorInput;
20
import org.eclipse.ui.PlatformUI;
21
import org.eclipse.ui.texteditor.ITextEditor;
22
import org.eclipse.wst.jsdt.core.IFunction;
23
import org.eclipse.wst.jsdt.core.IJavaScriptElement;
24
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
25
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame;
26
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
27
import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder;
28
29
/**
30
 * Hyper-link detector for stepping into selections in the JavaScript editor
31
 * 
32
 * @since 1.0
33
 */
34
public class JavaScriptHyperlinkDetector extends AbstractHyperlinkDetector {
35
36
	/**
37
	 * Hyper-link for stepping into the selection
38
	 */
39
	class StepIntoSelectionHyperlink implements IHyperlink {
40
		
41
		private IRegion fRegion = null;
42
		
43
		/**
44
		 * Constructor
45
		 * @param region
46
		 */
47
		public StepIntoSelectionHyperlink(IRegion region) {
48
			fRegion = region;
49
		}
50
51
		/* (non-Javadoc)
52
		 * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion()
53
		 */
54
		public IRegion getHyperlinkRegion() {
55
			return fRegion;
56
		}
57
58
		/* (non-Javadoc)
59
		 * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
60
		 */
61
		public String getHyperlinkText() {
62
			return Messages.hyperlink_step_into;
63
		}
64
65
		/* (non-Javadoc)
66
		 * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
67
		 */
68
		public String getTypeLabel() {
69
			return null;
70
		}
71
		
72
		/* (non-Javadoc)
73
		 * @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
74
		 */
75
		public void open() {
76
			StepIntoSelectionActionDelegate delegate = new StepIntoSelectionActionDelegate(fRegion);
77
			delegate.init(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
78
			delegate.run(null);
79
		}
80
	}
81
	
82
	/**
83
	 * Constructor
84
	 */
85
	public JavaScriptHyperlinkDetector() {
86
	}
87
88
	/* (non-Javadoc)
89
	 * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, boolean)
90
	 */
91
	public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
92
		ITextEditor editor = (ITextEditor) getAdapter(ITextEditor.class);
93
		if(editor != null) {
94
			IJavaScriptStackFrame frame = EvaluationManager.getManager().getEvaluationContext(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
95
			if (frame == null) {
96
				return null;
97
			}
98
			IEditorInput input = editor.getEditorInput();
99
			IJavaScriptElement element = StepIntoSelectionUtils.getJavaElement(input);
100
			int offset = region.getOffset();
101
			if(element != null) {
102
				try {
103
					IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
104
					if(document != null) {
105
						IRegion wregion = JavaWordFinder.findWord(document, offset);
106
						if(wregion != null) {
107
							IFunction method = StepIntoSelectionUtils.getFunction(new TextSelection(document, wregion.getOffset(), wregion.getLength()), element);
108
							if (method != null) {
109
								return new IHyperlink[] {new StepIntoSelectionHyperlink(wregion)};
110
							}
111
						}
112
					}
113
				}
114
				catch(JavaScriptModelException jme) {
115
					JavaScriptDebugUIPlugin.log(jme);
116
				}
117
			}
118
		}
119
		return null;
120
	}
121
122
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptInspectExpression.java (+158 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
import org.eclipse.debug.core.DebugException;
14
import org.eclipse.debug.core.ILaunch;
15
import org.eclipse.debug.core.model.IDebugElement;
16
import org.eclipse.debug.core.model.IDebugTarget;
17
import org.eclipse.debug.core.model.IExpression;
18
import org.eclipse.debug.core.model.IValue;
19
import org.eclipse.debug.core.model.IWatchExpression;
20
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptDebugTarget;
21
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue;
22
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
23
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
24
25
/**
26
 * Inspect expression for a JavaScript evaluation result
27
 * 
28
 * @since 1.0
29
 */
30
public class JavaScriptInspectExpression implements IWatchExpression {
31
32
	private IJavaScriptValue value = null;
33
	
34
	/**
35
	 * Constructor
36
	 * 
37
	 * @param value the value to show
38
	 */
39
	public JavaScriptInspectExpression(IJavaScriptValue value) {
40
		this.value = value;
41
	}
42
	
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
45
	 */
46
	public String getModelIdentifier() {
47
		return JavaScriptDebugModel.MODEL_ID;
48
	}
49
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
52
	 */
53
	public ILaunch getLaunch() {
54
		return value.getLaunch();
55
	}
56
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
59
	 */
60
	public Object getAdapter(Class adapter) {
61
		if(IJavaScriptValue.class.equals(adapter)) {
62
			return value;
63
		}
64
		if(IExpression.class.equals(adapter)) {
65
			return this;
66
		}
67
		if(IJavaScriptDebugTarget.class.equals(adapter)) {
68
			return value.getDebugTarget();
69
		}
70
		return null;
71
	}
72
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.debug.core.model.IExpression#getExpressionText()
75
	 */
76
	public String getExpressionText() {
77
		try {
78
			return value.getValueString();
79
		}
80
		catch(DebugException de) {
81
			JavaScriptDebugUIPlugin.log(de);
82
			return null;
83
		}
84
	}
85
86
	/* (non-Javadoc)
87
	 * @see org.eclipse.debug.core.model.IExpression#getValue()
88
	 */
89
	public IValue getValue() {
90
		return value;
91
	}
92
93
	/* (non-Javadoc)
94
	 * @see org.eclipse.debug.core.model.IExpression#getDebugTarget()
95
	 */
96
	public IDebugTarget getDebugTarget() {
97
		return value.getDebugTarget();
98
	}
99
100
	/* (non-Javadoc)
101
	 * @see org.eclipse.debug.core.model.IExpression#dispose()
102
	 */
103
	public void dispose() {
104
		value = null;
105
	}
106
107
	/* (non-Javadoc)
108
	 * @see org.eclipse.debug.core.model.IErrorReportingExpression#hasErrors()
109
	 */
110
	public boolean hasErrors() {
111
		return false;
112
	}
113
114
	/* (non-Javadoc)
115
	 * @see org.eclipse.debug.core.model.IErrorReportingExpression#getErrorMessages()
116
	 */
117
	public String[] getErrorMessages() {
118
		return null;
119
	}
120
121
	/* (non-Javadoc)
122
	 * @see org.eclipse.debug.core.model.IWatchExpression#evaluate()
123
	 */
124
	public void evaluate() {
125
	}
126
127
	/* (non-Javadoc)
128
	 * @see org.eclipse.debug.core.model.IWatchExpression#setExpressionContext(org.eclipse.debug.core.model.IDebugElement)
129
	 */
130
	public void setExpressionContext(IDebugElement context) {
131
	}
132
133
	/* (non-Javadoc)
134
	 * @see org.eclipse.debug.core.model.IWatchExpression#setExpressionText(java.lang.String)
135
	 */
136
	public void setExpressionText(String expressionText) {
137
	}
138
139
	/* (non-Javadoc)
140
	 * @see org.eclipse.debug.core.model.IWatchExpression#isPending()
141
	 */
142
	public boolean isPending() {
143
		return false;
144
	}
145
146
	/* (non-Javadoc)
147
	 * @see org.eclipse.debug.core.model.IWatchExpression#isEnabled()
148
	 */
149
	public boolean isEnabled() {
150
		return value != null;
151
	}
152
153
	/* (non-Javadoc)
154
	 * @see org.eclipse.debug.core.model.IWatchExpression#setEnabled(boolean)
155
	 */
156
	public void setEnabled(boolean enabled) {
157
	}
158
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/Messages.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
import org.eclipse.osgi.util.NLS;
14
15
/**
16
 * 
17
 */
18
public class Messages extends NLS {
19
	private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.ui.eval.messages"; //$NON-NLS-1$
20
	public static String cannot_find_debug_target;
21
	public static String cursor_position_not_valid;
22
	public static String empty_editor;
23
	public static String exception_running_to_line;
24
	public static String exe_did_not_enter__0__before_returning;
25
	public static String hyperlink_step_into;
26
	public static String missing_doc;
27
	public static String only_in_the_js_editor;
28
	public static String selected_line_not_valid;
29
	public static String step_into_only_top_frame;
30
	public static String step_into_selection;
31
	static {
32
		// initialize resource bundle
33
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
34
	}
35
36
	private Messages() {
37
	}
38
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/RunToLineAdapter.java (+123 lines)
Added Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2010 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
16
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.NullProgressMonitor;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.debug.core.model.IBreakpoint;
23
import org.eclipse.debug.core.model.IDebugElement;
24
import org.eclipse.debug.core.model.IDebugTarget;
25
import org.eclipse.debug.core.model.ISuspendResume;
26
import org.eclipse.debug.ui.actions.IRunToLineTarget;
27
import org.eclipse.debug.ui.actions.RunToLineHandler;
28
import org.eclipse.jface.text.IDocument;
29
import org.eclipse.jface.text.ITextSelection;
30
import org.eclipse.jface.viewers.ISelection;
31
import org.eclipse.swt.custom.BusyIndicator;
32
import org.eclipse.ui.IEditorInput;
33
import org.eclipse.ui.IWorkbenchPart;
34
import org.eclipse.ui.texteditor.ITextEditor;
35
import org.eclipse.wst.jsdt.core.dom.AST;
36
import org.eclipse.wst.jsdt.core.dom.ASTParser;
37
import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit;
38
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptDebugTarget;
39
import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel;
40
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
41
import org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.BreakpointLocationFinder;
42
43
/**
44
 * Run to line target for the JavaScript debugger
45
 * 
46
 * @since 1.0
47
 */
48
public class RunToLineAdapter implements IRunToLineTarget {
49
	
50
	/**
51
	 * Marker attribute used to denote a run to line breakpoint
52
	 */
53
	private static final String RUN_TO_LINE =  JavaScriptDebugUIPlugin.PLUGIN_ID + ".run_to_line"; //$NON-NLS-1$
54
	
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
57
	 */
58
	public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException {
59
		ITextEditor textEditor = StepIntoSelectionUtils.getTextEditor(part);
60
		if (textEditor == null) {
61
			throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.missing_doc, null));
62
		} 
63
		IEditorInput input = textEditor.getEditorInput();
64
		if (input == null) {
65
			throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.empty_editor, null));
66
		} 
67
		final IDocument document= textEditor.getDocumentProvider().getDocument(input);
68
		if (document == null) {
69
			throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.missing_doc, null));
70
		} 
71
		final int[] validLine = new int[1];
72
		final String[] typeName = new String[1];
73
		final int[] lineNumber = new int[1];
74
		final ITextSelection textSelection = (ITextSelection) selection;
75
		Runnable r = new Runnable() {
76
			public void run() {
77
				lineNumber[0] = textSelection.getStartLine() + 1;
78
				ASTParser parser = ASTParser.newParser(AST.JLS3);
79
				parser.setSource(document.get().toCharArray());
80
				JavaScriptUnit compilationUnit = (JavaScriptUnit)parser.createAST(null);
81
				BreakpointLocationFinder locator = new BreakpointLocationFinder(compilationUnit, lineNumber[0], false);
82
				compilationUnit.accept(locator);
83
				validLine[0] = locator.getLineNumber();		
84
				typeName[0] = locator.getFunctionName();
85
			}
86
		};
87
		BusyIndicator.showWhile(JavaScriptDebugUIPlugin.getStandardDisplay(), r);
88
		if (validLine[0] == lineNumber[0]) {
89
			IBreakpoint breakpoint= null;
90
			Map attributes = new HashMap(4);
91
			attributes.put(IBreakpoint.PERSISTED, Boolean.FALSE);
92
			attributes.put(RUN_TO_LINE, Boolean.TRUE);
93
			breakpoint = JavaScriptDebugModel.createLineBreakpoint(ResourcesPlugin.getWorkspace().getRoot(), lineNumber[0], -1, -1, attributes, false);
94
			if (target instanceof IAdaptable) {
95
				IDebugTarget debugTarget = (IDebugTarget) ((IAdaptable)target).getAdapter(IDebugTarget.class);
96
				if (debugTarget == null) {
97
					throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.cannot_find_debug_target, null));
98
				}
99
                RunToLineHandler handler = new RunToLineHandler(debugTarget, target, breakpoint);
100
                handler.run(new NullProgressMonitor());
101
				return;
102
			}
103
		} else {
104
			// invalid line
105
			if (textSelection.getLength() > 0) {
106
				throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.selected_line_not_valid, null));
107
			} 
108
			throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.cursor_position_not_valid, null));
109
		}
110
	}
111
	
112
	/* (non-Javadoc)
113
	 * @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
114
	 */
115
	public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) {
116
	    if (target instanceof IDebugElement) {
117
            IDebugElement element = (IDebugElement) target;
118
            IJavaScriptDebugTarget adapter = (IJavaScriptDebugTarget) element.getDebugTarget().getAdapter(IJavaScriptDebugTarget.class);
119
            return adapter != null;
120
        }
121
		return false;
122
	}
123
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionActionDelegate.java (+325 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IAdapterManager;
16
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.debug.core.DebugEvent;
18
import org.eclipse.debug.core.DebugException;
19
import org.eclipse.debug.core.DebugPlugin;
20
import org.eclipse.debug.core.IDebugEventSetListener;
21
import org.eclipse.debug.core.model.IStackFrame;
22
import org.eclipse.debug.core.model.IThread;
23
import org.eclipse.debug.ui.actions.IRunToLineTarget;
24
import org.eclipse.jface.action.IAction;
25
import org.eclipse.jface.text.IDocument;
26
import org.eclipse.jface.text.IRegion;
27
import org.eclipse.jface.text.ITextSelection;
28
import org.eclipse.jface.text.TextSelection;
29
import org.eclipse.jface.viewers.ISelection;
30
import org.eclipse.ui.IEditorActionDelegate;
31
import org.eclipse.ui.IEditorPart;
32
import org.eclipse.ui.IWorkbenchWindow;
33
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
34
import org.eclipse.ui.texteditor.IEditorStatusLine;
35
import org.eclipse.ui.texteditor.ITextEditor;
36
import org.eclipse.wst.jsdt.core.IFunction;
37
import org.eclipse.wst.jsdt.core.IJavaScriptElement;
38
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
39
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame;
40
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptThread;
41
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
42
43
/**
44
 * Steps into the selected function.
45
 * 
46
 * @since 1.0
47
 */
48
public class StepIntoSelectionActionDelegate implements IEditorActionDelegate, IWorkbenchWindowActionDelegate {
49
	
50
	private IEditorPart editor = null;
51
	private IWorkbenchWindow window = null;
52
	private IRegion region = null;
53
	
54
	/**
55
	 * Default constructor
56
	 */
57
	public StepIntoSelectionActionDelegate() {}
58
	
59
	/**
60
	 * Constructor
61
	 * @param region
62
	 */
63
	public StepIntoSelectionActionDelegate(IRegion region) {
64
		this.region = region;
65
	}
66
67
	/**
68
	 * The line number being "run to."
69
	 */
70
	private int line = -1;
71
	
72
	/**
73
	 * The debug event list listener used to know when a run to line has finished.
74
	 * @see StepIntoSelectionActionDelegate#runToLineBeforeStepIn(ITextSelection, IJavaScriptStackFrame, IFunction)
75
	 */
76
	private IDebugEventSetListener listener = null;
77
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
80
	 */
81
	public void run(IAction action) {
82
		IJavaScriptStackFrame frame = getStackFrame();
83
		if (frame == null || !frame.isSuspended()) {
84
			// no longer suspended - unexpected
85
			return;
86
		}
87
		ITextSelection textSelection = getTextSelection();
88
		try {
89
			IEditorPart activeEditor = getActiveEditor();
90
			IJavaScriptElement javaElement= StepIntoSelectionUtils.getJavaElement(activeEditor.getEditorInput());
91
			IFunction function = StepIntoSelectionUtils.getFunction(textSelection, javaElement);
92
			if (function == null) {
93
				function = StepIntoSelectionUtils.getFirstFunctionOnLine(textSelection.getOffset(), activeEditor, javaElement);
94
			}
95
			int lineNumber = frame.getLineNumber();
96
			if (textSelection.getStartLine() == (lineNumber - 1)) {
97
                doStepIn(frame, function);
98
			} else {
99
				runToLineBeforeStepIn(textSelection, frame.getThread(), function);
100
				return;
101
			}
102
		} 
103
		catch (DebugException e) {
104
			showErrorMessage(e.getStatus().getMessage());
105
			return;
106
		}
107
		catch(JavaScriptModelException jme) {
108
			showErrorMessage(jme.getStatus().getMessage());
109
			return;
110
		}
111
	}
112
	
113
	/**
114
	 * Steps into the given function in the given stack frame
115
	 * @param frame the frame in which the step should begin
116
	 * @param function the function to step into
117
	 * @throws DebugException
118
	 */
119
	private void doStepIn(IJavaScriptStackFrame frame, IFunction function) throws DebugException {
120
		// ensure top stack frame
121
		IStackFrame tos = frame.getThread().getTopStackFrame();
122
		if (tos == null) {
123
			return; 
124
		}		
125
		if (!tos.equals(frame)) {
126
			showErrorMessage(Messages.step_into_only_top_frame); 
127
			return;
128
		}
129
		StepIntoSelectionHandler handler = new StepIntoSelectionHandler((IJavaScriptThread)frame.getThread(), frame, function);
130
		handler.step();
131
	}
132
	
133
	/**
134
	 * When the user chooses to "step into selection" on a line other than
135
	 * the currently executing one, first perform a "run to line" to get to
136
	 * the desired location, then perform a "step into selection."
137
	 */
138
	private void runToLineBeforeStepIn(ITextSelection textSelection, final IThread thread, final IFunction function) {
139
		line = textSelection.getStartLine() + 1;
140
		if (line == -1) {
141
			return;
142
		}
143
		// see bug 65489 - get the run-to-line adapter from the editor
144
		IRunToLineTarget runToLineAction = null;
145
		IEditorPart ed = getActiveEditor();
146
		if (ed != null) {
147
			runToLineAction  = (IRunToLineTarget) ed.getAdapter(IRunToLineTarget.class);
148
			if (runToLineAction == null) {
149
				IAdapterManager adapterManager = Platform.getAdapterManager();
150
				if (adapterManager.hasAdapter(ed, IRunToLineTarget.class.getName())) { 
151
					runToLineAction = (IRunToLineTarget) adapterManager.loadAdapter(ed,IRunToLineTarget.class.getName()); 
152
				}
153
			}
154
		}	
155
		// if no adapter exists, use the Java adapter
156
		if (runToLineAction == null) {
157
		  runToLineAction = new RunToLineAdapter();
158
		}
159
		listener = new IDebugEventSetListener() {
160
161
			/* (non-Javadoc)
162
			 * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
163
			 */
164
			public void handleDebugEvents(DebugEvent[] events) {
165
				for (int i = 0; i < events.length; i++) {
166
					DebugEvent event = events[i];
167
					switch (event.getKind()) {
168
						case DebugEvent.SUSPEND :
169
							handleSuspendEvent(event);
170
							break;
171
						case DebugEvent.TERMINATE :
172
							handleTerminateEvent(event);
173
							break;
174
						default :
175
							break;
176
					}
177
				}
178
			}
179
			/**
180
			 * Listen for the completion of the "run to line." When the thread
181
			 * suspends at the correct location, perform a "step into selection"
182
			 * 
183
			 * @param event the debug event
184
			 */
185
			private void handleSuspendEvent(DebugEvent event) {
186
				Object source = event.getSource();
187
				if (source instanceof IJavaScriptThread) {
188
					try {
189
						final IJavaScriptStackFrame frame= (IJavaScriptStackFrame) ((IJavaScriptThread) source).getTopStackFrame();
190
						if (isExpectedFrame(frame)) {
191
							DebugPlugin plugin = DebugPlugin.getDefault();
192
							plugin.removeDebugEventListener(listener);
193
							plugin.asyncExec(new Runnable() {
194
								public void run() {
195
									try {
196
										doStepIn(frame, function);
197
									} catch (DebugException e) {
198
										showErrorMessage(e.getStatus().getMessage());
199
									}
200
								}
201
							});
202
						}
203
					} catch (DebugException e) {
204
						return;
205
					}
206
				}
207
			}
208
			/**
209
			 * Returns whether the given frame is the frame that this action is expecting.
210
			 * This frame is expecting a stack frame for the suspension of the "run to line".
211
			 * @param frame the given stack frame or <code>null</code>
212
			 * @return whether the given stack frame is the expected frame
213
			 * @throws DebugException
214
			 */
215
			private boolean isExpectedFrame(IJavaScriptStackFrame frame) throws DebugException {
216
				return frame != null && line == frame.getLineNumber();
217
			}
218
			/**
219
			 * When the debug target we're listening for terminates, stop listening
220
			 * to debug events.
221
			 * @param event the debug event
222
			 */
223
			private void handleTerminateEvent(DebugEvent event) {
224
				Object source = event.getSource();
225
				if (thread.getDebugTarget() == source) {
226
					DebugPlugin.getDefault().removeDebugEventListener(listener);
227
				}
228
			}
229
		};
230
		DebugPlugin.getDefault().addDebugEventListener(listener);
231
		try {
232
			runToLineAction.runToLine(getActiveEditor(), textSelection, thread);
233
		} catch (CoreException e) {
234
			DebugPlugin.getDefault().removeDebugEventListener(listener);
235
			showErrorMessage(Messages.exception_running_to_line); 
236
			JavaScriptDebugUIPlugin.log(e.getStatus());
237
		}
238
	}
239
	
240
	/**
241
	 * Gets the current text selection from the currently active editor
242
	 * @return the current text selection
243
	 */
244
	private ITextSelection getTextSelection() {
245
		IEditorPart part = getActiveEditor();
246
		if (part instanceof ITextEditor) { 
247
			ITextEditor editor = (ITextEditor)part;
248
			if(region != null) {
249
				IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
250
				if(document != null) {
251
					return new TextSelection(document, region.getOffset(), region.getLength());
252
				}
253
			}
254
			else {
255
				return (ITextSelection)editor.getSelectionProvider().getSelection();
256
			}
257
		}
258
		showErrorMessage(Messages.only_in_the_js_editor); 
259
		return null;
260
	}
261
	
262
	/**
263
	 * Displays an error message in the status area
264
	 * 
265
	 * @param message
266
	 */
267
	protected void showErrorMessage(String message) {	
268
		if (getActiveEditor() != null) {
269
			IEditorStatusLine statusLine= (IEditorStatusLine) getActiveEditor().getAdapter(IEditorStatusLine.class);
270
			if (statusLine != null) {
271
				statusLine.setMessage(true, message, null);
272
			}
273
		}		
274
		JavaScriptDebugUIPlugin.getStandardDisplay().beep();		
275
	}
276
277
	/* (non-Javadoc)
278
	 * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
279
	 */
280
	public void setActiveEditor(IAction action, IEditorPart targetEditor) {
281
		editor = targetEditor;
282
	}
283
	
284
	/**
285
	 * Returns the active editor or <code>null</code>.
286
	 * 
287
	 * @return active editor or <code>null</code>
288
	 */
289
	protected IEditorPart getActiveEditor() {
290
		if (window != null) {
291
			// global action
292
			return window.getActivePage().getActiveEditor();
293
		}
294
		// pop-up action
295
		return editor;
296
	}
297
298
	/* (non-Javadoc)
299
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
300
	 */
301
	public void selectionChanged(IAction action, ISelection selection) {
302
	}
303
304
	/**
305
	 * Returns the current stack frame context, or <code>null</code> if none.
306
	 * 
307
	 * @return the current stack frame context, or <code>null</code> if none
308
	 */
309
	protected IJavaScriptStackFrame getStackFrame() {
310
		return EvaluationManager.getManager().getEvaluationContext(getActiveEditor());
311
	}
312
	
313
	/* (non-Javadoc)
314
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
315
	 */
316
	public void dispose() {}
317
318
	/* (non-Javadoc)
319
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
320
	 */
321
	public void init(IWorkbenchWindow window) {
322
		this.window = window;
323
	}
324
325
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionHandler.java (+306 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.DebugEvent;
16
import org.eclipse.debug.core.DebugException;
17
import org.eclipse.debug.core.DebugPlugin;
18
import org.eclipse.debug.core.IDebugEventFilter;
19
import org.eclipse.jface.dialogs.IDialogConstants;
20
import org.eclipse.jface.dialogs.MessageDialog;
21
import org.eclipse.osgi.util.NLS;
22
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.wst.jsdt.core.IFunction;
24
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
25
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptDebugTarget;
26
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame;
27
import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptThread;
28
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
29
30
/**
31
 * Handles stepping into a selected function, for a specific thread.
32
 * 
33
 * @since 1.0
34
 */
35
public class StepIntoSelectionHandler implements IDebugEventFilter {
36
	
37
	/**
38
	 * The function to step into
39
	 */
40
	private IFunction function;
41
	
42
	/**
43
	 * Resolved signature of the function to step into
44
	 */
45
	private String signature;
46
	
47
	/**
48
	 * The thread in which to step
49
	 */
50
	private IJavaScriptThread thread;
51
52
	/**
53
	 * The initial stack frame
54
	 */
55
	private String origname;
56
	private int origdepth;
57
	
58
	/**
59
	 * Whether this is the first step into.
60
	 */
61
	private boolean firststep = true;
62
	
63
	/**
64
	 * Expected event kind
65
	 */
66
	private int eventkind = -1;
67
	
68
	/**
69
	 * Expected event detail
70
	 */
71
	private int eventdetail = -1;
72
73
	/**
74
	 * Constructs a step handler to step into the given function in the given thread
75
	 * starting from the given stack frame.
76
	 * 
77
	 * @param thread
78
	 * @param frame
79
	 * @param func
80
	 */
81
	public StepIntoSelectionHandler(IJavaScriptThread thread, IJavaScriptStackFrame frame, IFunction func) {
82
		function = func;
83
		this.thread = thread;
84
		try {
85
			origname = frame.getName();
86
			signature = func.getSignature();
87
		} catch (CoreException e) {
88
			JavaScriptDebugUIPlugin.log(e);
89
		}
90
	}
91
	
92
	/**
93
	 * Returns the target thread for the step.
94
	 * 
95
	 * @return the target thread for the step
96
	 */
97
	protected IJavaScriptThread getThread() {
98
		return thread;
99
	}
100
	
101
	protected IJavaScriptDebugTarget getDebugTarget() {
102
		return (IJavaScriptDebugTarget)getThread().getDebugTarget();
103
	}
104
	
105
	/**
106
	 * Returns the function to step into
107
	 * 
108
	 * @return the function to step into
109
	 */
110
	protected IFunction getMethod() {
111
		return function;
112
	}
113
	
114
	/**
115
	 * Returns the resolved signature of the function to step into
116
	 * 
117
	 * @return the resolved signature of the function to step into
118
	 */
119
	protected String getSignature() {
120
		return signature;
121
	}	
122
	
123
	/* (non-Javadoc)
124
	 * @see org.eclipse.debug.core.IDebugEventFilter#filterDebugEvents(org.eclipse.debug.core.DebugEvent[])
125
	 */
126
	public DebugEvent[] filterDebugEvents(DebugEvent[] events) {
127
		// we only expect one event from our thread - find the event
128
		DebugEvent event = null;
129
		int index = -1;
130
		int threadEvents = 0;
131
		for (int i = 0; i < events.length; i++) {
132
			DebugEvent e = events[i];
133
			if (isExpectedEvent(e)) {
134
				event = e;
135
				index = i;
136
				threadEvents++;
137
			} else if (e.getSource() == getThread()) {
138
				threadEvents++;
139
			} 
140
		}
141
		if (event == null) {
142
			// nothing to process in this event set
143
			return events;
144
		}
145
		// create filtered event set
146
		DebugEvent[] filtered = new DebugEvent[events.length - 1];
147
		if (filtered.length > 0) {
148
			int j = 0;
149
			for (int i = 0; i < events.length; i++) {
150
				if (i != index) {
151
					filtered[j] = events[i];
152
					j++;
153
				}
154
			}
155
		}
156
		// if more than one event in our thread, abort (filtering our event)
157
		if (threadEvents > 1) {
158
			cleanup();
159
			return filtered;
160
		}
161
		// we have the one expected event - process it
162
		switch (event.getKind()) {
163
			case DebugEvent.RESUME:
164
				// next, we expect a step end
165
				setExpectedEvent(DebugEvent.SUSPEND, DebugEvent.STEP_END);
166
				if (firststep) {
167
					firststep = false;
168
					return events; // include the first resume event
169
				}
170
				// secondary step - filter the event
171
				return filtered;			
172
			case DebugEvent.SUSPEND:
173
				// compare location to desired location
174
				try {
175
					final IJavaScriptStackFrame frame = (IJavaScriptStackFrame)getThread().getTopStackFrame();
176
					int stackDepth = frame.getThread().getStackFrames().length;
177
					String name = frame.getName();
178
					if (name.equals(getMethod().getElementName())) {
179
						// hit
180
						cleanup();
181
						return events;
182
					}
183
					// step again
184
					Runnable r = null;
185
					if (stackDepth > origdepth) {
186
						r = new Runnable() {
187
							public void run() {
188
								try {
189
									setExpectedEvent(DebugEvent.RESUME, DebugEvent.STEP_RETURN);
190
									frame.stepReturn();
191
								} catch (DebugException e) {
192
									JavaScriptDebugUIPlugin.log(e);
193
									cleanup();
194
									DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(getDebugTarget(), DebugEvent.CHANGE)});
195
								}
196
							}
197
						};
198
					} else if (stackDepth == origdepth){
199
						// we should be back in the original stack frame - if not, abort
200
						if (!frame.getName().equals(origname)) {
201
							missed();
202
							return events;
203
						}
204
						r = new Runnable() {
205
							public void run() {
206
								try {
207
									setExpectedEvent(DebugEvent.RESUME, DebugEvent.STEP_INTO);
208
									frame.stepInto();	
209
								} catch (DebugException e) {
210
									JavaScriptDebugUIPlugin.log(e);
211
									cleanup();
212
									DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(getDebugTarget(), DebugEvent.CHANGE)});
213
								}
214
							}
215
						};																
216
					} else {
217
						// we returned from the original frame - never hit the desired method
218
						missed();
219
						return events;								
220
					}
221
					DebugPlugin.getDefault().asyncExec(r);
222
					// filter the events
223
						return filtered;
224
				} catch (CoreException e) {
225
					// abort
226
					JavaScriptDebugUIPlugin.log(e);
227
					cleanup();
228
					return events;
229
				}			
230
		}
231
		// execution should not reach here
232
		return events;
233
		 
234
	}
235
	
236
	/** 
237
	 * Called when stepping returned from the original frame without entering the desired method.
238
	 */
239
	protected void missed() {
240
		cleanup();
241
		Runnable r = new Runnable() {
242
			public void run() {
243
				String methodName = null;
244
				try {
245
					methodName = org.eclipse.wst.jsdt.core.Signature.toString(getMethod().getSignature(), getMethod().getElementName(), getMethod().getParameterNames(), false, false);
246
				} catch (JavaScriptModelException e) {
247
					methodName = getMethod().getElementName();
248
				}
249
				new MessageDialog(
250
						PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),  
251
						Messages.step_into_selection, 
252
						null, 
253
						NLS.bind(Messages.exe_did_not_enter__0__before_returning, new String[]{methodName}), 
254
						MessageDialog.INFORMATION, new String[] {IDialogConstants.OK_LABEL}, 0).open();    
255
			}
256
		};
257
		JavaScriptDebugUIPlugin.getStandardDisplay().asyncExec(r);		
258
	}
259
260
	/**
261
	 * Performs the step.
262
	 */
263
	public void step() {
264
		// add event filter and turn off step filters
265
		DebugPlugin.getDefault().addDebugEventFilter(this);
266
		try {
267
			origdepth = getThread().getStackFrames().length;
268
			setExpectedEvent(DebugEvent.RESUME, DebugEvent.STEP_INTO);
269
			getThread().stepInto();
270
		} catch (DebugException e) {
271
			JavaScriptDebugUIPlugin.log(e);
272
			cleanup();
273
			DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(getDebugTarget(), DebugEvent.CHANGE)});			
274
		}
275
	}
276
	
277
	/**
278
	 * Cleans up when the step is complete/aborted.
279
	 */
280
	protected void cleanup() {
281
		DebugPlugin.getDefault().removeDebugEventFilter(this);
282
	}
283
	
284
	/**
285
	 * Sets the expected debug event kind and detail we are waiting for next.
286
	 * 
287
	 * @param kind event kind
288
	 * @param detail event detail
289
	 */
290
	private void setExpectedEvent(int kind, int detail) {
291
		eventkind = kind;
292
		eventdetail = detail;
293
	}
294
	
295
	/**
296
	 * Returns whether the given event is what we expected.
297
	 * 
298
	 * @param event fire event
299
	 * @return whether the event is what we expected
300
	 */
301
	protected boolean isExpectedEvent(DebugEvent event) {
302
		return event.getSource().equals(getThread()) &&
303
			event.getKind() == eventkind &&
304
			event.getDetail() == eventdetail;
305
	}
306
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionUtils.java (+149 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.eval;
12
13
import org.eclipse.jface.text.BadLocationException;
14
import org.eclipse.jface.text.IDocument;
15
import org.eclipse.jface.text.IRegion;
16
import org.eclipse.jface.text.ITextSelection;
17
import org.eclipse.ui.IEditorInput;
18
import org.eclipse.ui.IEditorPart;
19
import org.eclipse.ui.IWorkbenchPart;
20
import org.eclipse.ui.texteditor.IDocumentProvider;
21
import org.eclipse.ui.texteditor.ITextEditor;
22
import org.eclipse.wst.jsdt.core.ICodeAssist;
23
import org.eclipse.wst.jsdt.core.IFunction;
24
import org.eclipse.wst.jsdt.core.IJavaScriptElement;
25
import org.eclipse.wst.jsdt.core.JavaScriptCore;
26
import org.eclipse.wst.jsdt.core.JavaScriptModelException;
27
import org.eclipse.wst.jsdt.core.ToolFactory;
28
import org.eclipse.wst.jsdt.core.compiler.IScanner;
29
import org.eclipse.wst.jsdt.core.compiler.ITerminalSymbols;
30
import org.eclipse.wst.jsdt.core.compiler.InvalidInputException;
31
import org.eclipse.wst.jsdt.ui.JavaScriptUI;
32
33
/**
34
 * Utility class for aiding step into selection actions and hyper-linking
35
 * 
36
 * @since 1.1
37
 */
38
public class StepIntoSelectionUtils {
39
40
	/**
41
     * Returns the text editor associated with the given part or <code>null</code>
42
     * if none. In case of a multi-page editor, this method should be used to retrieve
43
     * the correct editor to perform the operation on.
44
     * 
45
     * @param part workbench part
46
     * @return text editor part or <code>null</code>
47
     */
48
    public static ITextEditor getTextEditor(IWorkbenchPart part) {
49
    	if (part instanceof ITextEditor) {
50
    		return (ITextEditor) part;
51
    	}
52
    	return (ITextEditor) part.getAdapter(ITextEditor.class);
53
    }	
54
	
55
	/**
56
     * gets the <code>IJavaScriptElement</code> from the editor input
57
     * @param input the current editor input
58
     * @return the corresponding <code>IJavaScriptElement</code>
59
     */
60
    public static IJavaScriptElement getJavaElement(IEditorInput input) {
61
    	IJavaScriptElement je = JavaScriptUI.getEditorInputJavaElement(input);
62
    	if(je != null) {
63
    		return je;
64
    	}
65
    	return JavaScriptUI.getWorkingCopyManager().getWorkingCopy(input);
66
    }
67
    
68
    /**
69
     * Returns the <code>IFuntion</code> from the given selection within the given <code>IJavaScriptElement</code>, 
70
     * or <code>null</code> if the selection does not container or is not an <code>IFunction</code>
71
     * @param selection
72
     * @param element
73
     * @return the corresponding <code>IFunction</code> from the selection within the provided <code>IJavaScriptElement</code>
74
     * @throws JavaScriptModelException
75
     */
76
    public static IFunction getFunction(ITextSelection selection, IJavaScriptElement element) throws JavaScriptModelException {
77
    	if(element != null && element instanceof ICodeAssist) {
78
    		return resolveFunction(selection.getOffset(), selection.getLength(), (ICodeAssist)element);
79
    	}
80
    	return null;
81
    }
82
83
	/**
84
	 * @param offset selection offset
85
	 * @param length selection length
86
	 * @param codeAssist context
87
	 * @return the function at the given position, or <code>null</code> if no function could be resolved 
88
	 * @throws JavaScriptModelException
89
	 */
90
	private static IFunction resolveFunction(int offset, int length, ICodeAssist codeAssist) throws JavaScriptModelException {
91
		IJavaScriptElement[] elements = codeAssist.codeSelect(offset, length);
92
		for (int i = 0; i < elements.length; i++) {
93
			if (elements[i] instanceof IFunction) {
94
				return (IFunction)elements[i];
95
			}
96
		}
97
		return null;
98
	}
99
    
100
	/**
101
	 * @param offset
102
	 * @param activeEditor
103
	 * @param element
104
	 * @return the first function found at or after <code>offset</code> on the same line
105
	 * @throws JavaScriptModelException
106
	 */
107
	public static IFunction getFirstFunctionOnLine(int offset, IEditorPart activeEditor, IJavaScriptElement element) throws JavaScriptModelException {
108
		if (! (activeEditor instanceof ITextEditor) || ! (element instanceof ICodeAssist)) {
109
			return null;
110
		}
111
		ITextEditor editor = (ITextEditor)activeEditor;
112
		IDocumentProvider documentProvider = editor.getDocumentProvider();
113
		if (documentProvider == null) {
114
			return null;
115
		}
116
		IDocument document = documentProvider.getDocument(editor.getEditorInput());
117
		if (document == null) {
118
			return null;
119
		}
120
		try {
121
			IRegion lineInfo = document.getLineInformationOfOffset(offset);
122
			String line = document.get(lineInfo.getOffset(), lineInfo.getLength());
123
			IScanner scanner = ToolFactory.createScanner(false, false, false, null, JavaScriptCore.VERSION_1_5);
124
			scanner.setSource(line.toCharArray());
125
			scanner.resetTo(offset - lineInfo.getOffset(), lineInfo.getLength());
126
			int token = scanner.getNextToken();
127
			while (token != ITerminalSymbols.TokenNameEOF) {
128
				if (token == ITerminalSymbols.TokenNameIdentifier) {
129
					int methodStart = scanner.getCurrentTokenStartPosition();
130
					token = scanner.getNextToken();
131
					if (token == ITerminalSymbols.TokenNameLPAREN) {
132
						return resolveFunction(lineInfo.getOffset() + methodStart, 0, (ICodeAssist)element);
133
					}
134
				} 
135
				else {
136
					token = scanner.getNextToken();
137
				}
138
			}
139
		} 
140
		catch (BadLocationException e) {
141
			return null;
142
		} 
143
		catch (InvalidInputException e) {
144
			return null;
145
		}
146
		return null;
147
	}
148
149
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties (+21 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 201o IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
cannot_find_debug_target=Unable to locate debug target
12
cursor_position_not_valid=Cursor position is not a valid location to run to
13
empty_editor=Empty editor
14
exception_running_to_line=An exception occurred attempting to run to the selected line.
15
exe_did_not_enter__0__before_returning=Execution did not enter "{0}" before the current function returned.
16
hyperlink_step_into=Step Into
17
missing_doc=Missing document
18
only_in_the_js_editor=Step into selection only available in JavaScript editor.
19
selected_line_not_valid=Selected line is not a valid location to run to
20
step_into_only_top_frame=Step into selection only available in top stack frame.
21
step_into_selection=Step into selection
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java (-6 / +74 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.launching;
11
package org.eclipse.wst.jsdt.debug.internal.ui.launching;
12
12
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.Comparator;
13
import java.util.HashMap;
16
import java.util.HashMap;
14
import java.util.Iterator;
17
import java.util.Iterator;
15
import java.util.List;
18
import java.util.List;
Lines 62-80 Link Here
62
 */
65
 */
63
public class JavaScriptConnectTab extends AbstractLaunchConfigurationTab implements IPropertyChangeListener {
66
public class JavaScriptConnectTab extends AbstractLaunchConfigurationTab implements IPropertyChangeListener {
64
	
67
	
68
	class ArgComparator implements Comparator {
69
		/* (non-Javadoc)
70
		 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
71
		 */
72
		public int compare(Object o1, Object o2) {
73
			if(o1 instanceof Entry && o2 instanceof Entry) {
74
				//String > Integer > List > Boolean 
75
				//sort by kind and by label
76
				Object val1 = ((Entry)o1).getValue();
77
				Object val2 = ((Entry)o2).getValue();
78
				if(val1 instanceof StringArgument) {
79
					if(val2 instanceof StringArgument) {
80
						return stripAccel(((Argument)val1).label()).compareTo(stripAccel(((Argument)val2).label()));
81
					}
82
					return -1;
83
				}
84
				else if(val1 instanceof IntegerArgument) {
85
					if(val2 instanceof IntegerArgument) {
86
						return stripAccel(((Argument)val1).label()).compareTo(stripAccel(((Argument)val2).label()));
87
					}
88
					else if(val2 instanceof StringArgument) {
89
						return 1;
90
					}
91
					return -1;
92
				}
93
				else if(val1 instanceof SelectedArgument) {
94
					if(val2 instanceof SelectedArgument) {
95
						return stripAccel(((Argument)val1).label()).compareTo(stripAccel(((Argument)val2).label()));
96
					}
97
					else if(val2 instanceof StringArgument || val2 instanceof IntegerArgument) {
98
						return 1;
99
					}
100
					return -1;
101
				}
102
				else if(val1 instanceof BooleanArgument) {
103
					if(val2 instanceof BooleanArgument) {
104
						return stripAccel(((Argument)val1).label()).compareTo(stripAccel(((Argument)val2).label()));
105
					}
106
					else if(val2 instanceof StringArgument || val2 instanceof IntegerArgument || val2 instanceof SelectedArgument) {
107
						return 1;
108
					}
109
					return -1;
110
				}
111
			}
112
			return o1.equals(o2) ? 0 : -1;
113
		}
114
		
115
		String stripAccel(String text) {
116
			return text.replaceAll("\\&", ""); //$NON-NLS-1$ //$NON-NLS-2$
117
		}
118
	}
119
	
65
	Text description = null;
120
	Text description = null;
66
	Combo connectorcombo = null;
121
	Combo connectorcombo = null;
67
	Connector selectedconnector = null;
122
	Connector selectedconnector = null;
68
	Group argumentsgroup = null;
123
	Group argumentsgroup = null;
69
	HashMap editormap = new HashMap();
124
	HashMap editormap = new HashMap();
125
	Comparator comparator = new ArgComparator();
70
	
126
	
71
	/* (non-Javadoc)
127
	/* (non-Javadoc)
72
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
128
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
73
	 */
129
	 */
74
	public void createControl(Composite parent) {
130
	public void createControl(Composite parent) {
75
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL);
131
		Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_HORIZONTAL);
76
		//connectors combo
132
		//connectors combo
77
		Group group = SWTFactory.createGroup(comp, Messages.connector, 1, 2, GridData.FILL_HORIZONTAL);
133
		Group group = SWTFactory.createGroup(comp, Messages.connector, 1, 1, GridData.FILL_HORIZONTAL);
78
		this.connectorcombo = SWTFactory.createCombo(group, SWT.FLAT | SWT.BORDER | SWT.READ_ONLY, 1, null);
134
		this.connectorcombo = SWTFactory.createCombo(group, SWT.FLAT | SWT.BORDER | SWT.READ_ONLY, 1, null);
79
		GridData gd = (GridData) this.connectorcombo.getLayoutData();
135
		GridData gd = (GridData) this.connectorcombo.getLayoutData();
80
		gd.grabExcessHorizontalSpace = true;
136
		gd.grabExcessHorizontalSpace = true;
Lines 86-91 Link Here
86
		this.description = SWTFactory.createText(group, SWT.WRAP | SWT.READ_ONLY, 1);
142
		this.description = SWTFactory.createText(group, SWT.WRAP | SWT.READ_ONLY, 1);
87
		gd = (GridData) this.description.getLayoutData();
143
		gd = (GridData) this.description.getLayoutData();
88
		gd.heightHint = 30;
144
		gd.heightHint = 30;
145
		//hack to make sure the disabled colour is propagated on *Nix's 
146
		this.description.setBackground(group.getBackground());
89
		List connectors = JavaScriptDebugPlugin.getConnectionsManager().getConnectors();
147
		List connectors = JavaScriptDebugPlugin.getConnectionsManager().getConnectors();
90
		Connector connector = null;
148
		Connector connector = null;
91
		for (int i = 0; i < connectors.size(); i++) {
149
		for (int i = 0; i < connectors.size(); i++) {
Lines 94-105 Link Here
94
			this.connectorcombo.setData(connector.name(), connector);
152
			this.connectorcombo.setData(connector.name(), connector);
95
		}
153
		}
96
		
154
		
97
		this.argumentsgroup = SWTFactory.createGroup(comp, Messages.connector_properties, 2, 2, GridData.FILL_HORIZONTAL);
155
		this.argumentsgroup = SWTFactory.createGroup(comp, Messages.connector_properties, 2, 1, GridData.FILL_HORIZONTAL);
98
		this.argumentsgroup.setVisible(false);
156
		this.argumentsgroup.setVisible(false);
99
		setControl(comp);
100
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.CONNECT_TAB);
157
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.CONNECT_TAB);
158
		setControl(comp);
101
	}
159
	}
102
160
161
	/* (non-Javadoc)
162
	 * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getHelpContextId()
163
	 */
164
	public String getHelpContextId() {
165
		return IHelpContextIds.CONNECT_TAB;
166
	};
167
	
103
	/**
168
	/**
104
	 * Returns the {@link Connector} based on the selection of the combo
169
	 * Returns the {@link Connector} based on the selection of the combo
105
	 * @return the selected combo
170
	 * @return the selected combo
Lines 142-148 Link Here
142
		Argument argument = null;
207
		Argument argument = null;
143
		FieldEditor editor = null;
208
		FieldEditor editor = null;
144
		String key = null;
209
		String key = null;
145
		for (Iterator iter = this.selectedconnector.defaultArguments().entrySet().iterator(); iter.hasNext();) {
210
		ArrayList entries = new ArrayList(this.selectedconnector.defaultArguments().entrySet());
211
		Collections.sort(entries, comparator);
212
		for (Iterator iter = entries.iterator(); iter.hasNext();) {
146
			entry = (Entry) iter.next();
213
			entry = (Entry) iter.next();
147
			key = (String) entry.getKey();
214
			key = (String) entry.getKey();
148
			argument = (Argument) entry.getValue();
215
			argument = (Argument) entry.getValue();
Lines 188-193 Link Here
188
		GridLayout gd = (GridLayout) this.argumentsgroup.getLayout();
255
		GridLayout gd = (GridLayout) this.argumentsgroup.getLayout();
189
		gd.marginHeight = 5;
256
		gd.marginHeight = 5;
190
		gd.marginWidth = 5;
257
		gd.marginWidth = 5;
258
		gd.numColumns = 2;
191
		this.argumentsgroup.getParent().layout(true);
259
		this.argumentsgroup.getParent().layout(true);
192
		this.argumentsgroup.setVisible(true);
260
		this.argumentsgroup.setVisible(true);
193
		this.argumentsgroup.layout(true);
261
		this.argumentsgroup.layout(true);
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptLaunchShortcut.java (-124 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.launching;
12
13
import java.util.Arrays;
14
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.debug.core.DebugPlugin;
18
import org.eclipse.debug.core.ILaunchConfiguration;
19
import org.eclipse.debug.core.ILaunchConfigurationType;
20
import org.eclipse.debug.core.ILaunchManager;
21
import org.eclipse.debug.internal.ui.DebugUIPlugin;
22
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
23
import org.eclipse.debug.ui.DebugUITools;
24
import org.eclipse.debug.ui.IDebugUIConstants;
25
import org.eclipse.debug.ui.ILaunchGroup;
26
import org.eclipse.debug.ui.ILaunchShortcut2;
27
import org.eclipse.jface.viewers.ISelection;
28
import org.eclipse.jface.viewers.StructuredSelection;
29
import org.eclipse.ui.IEditorPart;
30
import org.eclipse.ui.PlatformUI;
31
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
32
33
/**
34
 * Default reusable launch shortcut for JavaScript debug consumers
35
 * @since 1.0
36
 */
37
public class JavaScriptLaunchShortcut implements ILaunchShortcut2 {
38
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchConfigurations(org.eclipse.jface.viewers.ISelection)
41
	 */
42
	public ILaunchConfiguration[] getLaunchConfigurations(ISelection selection) {
43
		return null;
44
	}
45
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchConfigurations(org.eclipse.ui.IEditorPart)
48
	 */
49
	public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editorpart) {
50
		return null;
51
	}
52
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchableResource(org.eclipse.jface.viewers.ISelection)
55
	 */
56
	public IResource getLaunchableResource(ISelection selection) {
57
		return null;
58
	}
59
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchableResource(org.eclipse.ui.IEditorPart)
62
	 */
63
	public IResource getLaunchableResource(IEditorPart editorpart) {
64
		return null;
65
	}
66
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String)
69
	 */
70
	public void launch(ISelection selection, String mode) {
71
		openLaunchDialogOnSelection();
72
	}
73
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
76
	 */
77
	public void launch(IEditorPart editor, String mode) {
78
		openLaunchDialogOnSelection();
79
	}
80
81
	/**
82
	 * Default behavior to open the launch configuration dialog on the {@link ILaunchConfigurationType}
83
	 * for JavaScript
84
	 */
85
	void openLaunchDialogOnSelection() {
86
		DebugUITools.openLaunchConfigurationDialogOnGroup(
87
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
88
				new StructuredSelection(getSelection()), 
89
				IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP);
90
	}
91
	
92
	/**
93
	 * Returns the type of the default launch configuration
94
	 * @return the default item to select when opening the dialog
95
	 */
96
	Object getSelection() {
97
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
98
		ILaunchConfigurationType type = manager.getLaunchConfigurationType(Constants.LAUNCH_CONFIG_ID);
99
		if(type != null) {
100
			try {
101
				ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
102
				if(configs != null && configs.length > 0) {
103
					LaunchConfigurationManager cmanager = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
104
					ILaunchGroup group = cmanager.getLaunchGroup(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP);
105
					if(group != null) {
106
						ILaunchConfiguration config = cmanager.getMRUConfiguration(
107
								Arrays.asList(configs), 
108
								group, 
109
								null);
110
						if(config != null) {
111
							return config;
112
						}
113
					}
114
				}
115
			}
116
			catch (CoreException ce) {
117
				//do nothing, just return type
118
			}
119
			return type;
120
		}
121
		return null;
122
	}
123
	
124
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java (-5 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
2
 * Copyright (c) 2010, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-24 Link Here
16
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
16
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
17
import org.eclipse.debug.ui.ILaunchConfigurationTab;
17
import org.eclipse.debug.ui.ILaunchConfigurationTab;
18
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
18
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
19
import org.eclipse.wst.jsdt.debug.internal.ui.IHelpContextIds;
19
20
20
/**
21
/**
21
 * Default tab group for Javascript debugging
22
 * Default tab group for JavaScript debugging
22
 * 
23
 * 
23
 * @since 1.0
24
 * @since 1.0
24
 */
25
 */
Lines 28-38 Link Here
28
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
29
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
29
	 */
30
	 */
30
	public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
31
	public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
32
		SourceLookupTab slt = new SourceLookupTab();
33
		slt.setHelpContextId(IHelpContextIds.SOURCE_LOOKUP_TAB);
34
		EnvironmentTab et = new EnvironmentTab();
35
		et.setHelpContextId(IHelpContextIds.ENVIRONMENT_TAB);
36
		CommonTab ct = new CommonTab();
37
		ct.setHelpContextId(IHelpContextIds.COMMON_TAB);
31
		ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
38
		ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
32
				new JavaScriptConnectTab(),
39
				new JavaScriptConnectTab(),
33
				new SourceLookupTab(),
40
				slt,
34
				new EnvironmentTab(),
41
				et,
35
				new CommonTab()
42
				ct
36
		};
43
		};
37
		setTabs(tabs);
44
		setTabs(tabs);
38
	}
45
	}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties (+16 lines)
Lines 22-35 Link Here
22
connector=Connector
22
connector=Connector
23
connector_properties=Connector Properties
23
connector_properties=Connector Properties
24
creating_script_load_bp=Creating Script Load Breakpoint...
24
creating_script_load_bp=Creating Script Load Breakpoint...
25
disconnected=<disconnected>
25
enable_hit_count=Enable &Hit Count
26
enable_hit_count=Enable &Hit Count
26
enter_new_hit_count=&Enter the new hit count for the breakpoint:
27
enter_new_hit_count=&Enter the new hit count for the breakpoint:
28
evald_script=<evaluated script>
27
exception_occurred_setting_bp_properties=Exceptions occurred attempting to modify breakpoint.
29
exception_occurred_setting_bp_properties=Exceptions occurred attempting to modify breakpoint.
28
hit_count_must_be_positive=Hit count must be a positive integer
30
hit_count_must_be_positive=Hit count must be a positive integer
29
no_description_provided=No description provided.
31
no_description_provided=No description provided.
32
opening_source__0=Opening Source: {0}
33
running_state=running
30
scripts=Scripts
34
scripts=Scripts
31
select_javascript_file=Select a JavaScript script file
35
select_javascript_file=Select a JavaScript script file
32
set_bp_hit_count=Set Breakpoint Hit Count
36
set_bp_hit_count=Set Breakpoint Hit Count
37
stackframe_name={0} - line: {1}
38
stepping_state=stepping
39
suspend_loading_script=suspended loading script: {0}
33
suspend_target=&Suspend Target
40
suspend_target=&Suspend Target
34
suspend_thread=&Suspend Thread
41
suspend_thread=&Suspend Thread
42
suspended_on_exception=suspended on exception: {0}
43
suspended_on_func_breakpoint=suspended at breakpoint on function {0} in {1}
44
suspended_on_line_breakpoint=suspended at breakpoint on line {0} in {1}
45
suspended_state=suspended
46
terminated=<terminated>
47
terminated_state=terminated
35
the_argument_0_is_not_valid=The specified argument: {0} is not valid
48
the_argument_0_is_not_valid=The specified argument: {0} is not valid
49
thread_name=Thread [{0}] ({1})
50
unknown=<unknown>
51
unknown_state=<unknown state>
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/JavaScriptDebugPreferencePage.java (+112 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.preferences;
12
13
import org.eclipse.jface.preference.BooleanFieldEditor;
14
import org.eclipse.jface.preference.FieldEditor;
15
import org.eclipse.jface.preference.FieldEditorPreferencePage;
16
import org.eclipse.jface.preference.IPreferenceStore;
17
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.layout.GridLayout;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.swt.widgets.Group;
22
import org.eclipse.ui.IWorkbench;
23
import org.eclipse.ui.IWorkbenchPreferencePage;
24
import org.eclipse.ui.PlatformUI;
25
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
26
import org.eclipse.wst.jsdt.debug.internal.ui.IHelpContextIds;
27
import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin;
28
import org.eclipse.wst.jsdt.debug.internal.ui.SWTFactory;
29
30
/**
31
 * Default preference page for JavaScript debugging
32
 * @since 1.1
33
 */
34
public class JavaScriptDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
35
36
	public static final String PAGE_ID = "org.eclipse.wst.jsdt.debug.ui.debug.page"; //$NON-NLS-1$
37
	
38
	/**
39
	 * Constructor
40
	 */
41
	public JavaScriptDebugPreferencePage() {
42
		super(GRID);
43
		setPreferenceStore(JavaScriptDebugUIPlugin.getDefault().getPreferenceStore());
44
		setDescription(Messages.js_debug_pref_page_desc);
45
	}
46
	
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
49
	 */
50
	public void init(IWorkbench workbench) {}
51
52
	/* (non-Javadoc)
53
	 * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
54
	 */
55
	public void createControl(Composite parent) {
56
		super.createControl(parent);
57
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.DEBUG_PREFERENCE_PAGE);
58
	}
59
	
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
62
	 */
63
	protected Control createContents(Composite parent) {
64
		Composite comp = SWTFactory.createComposite(parent, parent.getFont(), 1, 1, GridData.FILL_HORIZONTAL, 0, 0);
65
		//General
66
		Group group = SWTFactory.createGroup(comp, Messages.general, 1, 1, GridData.FILL_HORIZONTAL);
67
		BooleanFieldEditor editor = new BooleanFieldEditor(Constants.DELETE_EXT_PROJECT_ON_EXIT, Messages.delete_ext_project_on_exit, group);
68
		initEditor(editor, JavaScriptDebugUIPlugin.getCorePreferenceStore());
69
		initGroup(group);
70
		//Suspend Execution
71
		group = SWTFactory.createGroup(comp, Messages.suspend_execution, 1, 1, GridData.FILL_HORIZONTAL);
72
		editor = new BooleanFieldEditor(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, Messages.suspend_for_all_script_loads, group);
73
		initEditor(editor, JavaScriptDebugUIPlugin.getCorePreferenceStore());
74
		editor = new BooleanFieldEditor(Constants.SUSPEND_ON_THROWN_EXCEPTION, Messages.suspend_on_exceptions, group);
75
		initEditor(editor, JavaScriptDebugUIPlugin.getCorePreferenceStore());
76
		initGroup(group);
77
		return comp;
78
	}
79
80
	/**
81
	 * Refreshes the specified group to re-set the default spacings that have been 
82
	 * trashed by the field editors
83
	 * 
84
	 * @param group
85
	 */
86
	void initGroup(Group group) {
87
		GridData gd = (GridData) group.getLayoutData();
88
		gd.grabExcessHorizontalSpace = true;
89
		GridLayout lo = (GridLayout) group.getLayout();
90
		lo.marginWidth = 5;
91
		lo.marginHeight = 5;
92
	}
93
	
94
	/**
95
	 * Initializes and sets up the given editor
96
	 * 
97
	 * @param editor
98
	 * @param store
99
	 */
100
	void initEditor(FieldEditor editor, IPreferenceStore store) {
101
		addField(editor);
102
		editor.setPage(this);
103
		editor.setPropertyChangeListener(this);
104
		editor.setPreferenceStore(store);
105
		editor.load();
106
	}
107
	
108
	/* (non-Javadoc)
109
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
110
	 */
111
	protected void createFieldEditors() {}
112
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/Messages.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.jsdt.debug.internal.ui.preferences;
12
13
import org.eclipse.osgi.util.NLS;
14
15
/**
16
 *
17
 */
18
public class Messages extends NLS {
19
	private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.ui.preferences.messages"; //$NON-NLS-1$
20
	public static String delete_ext_project_on_exit;
21
	public static String general;
22
	public static String js_debug_pref_page_desc;
23
	public static String suspend_execution;
24
	public static String suspend_for_all_script_loads;
25
	public static String suspend_on_exceptions;
26
	static {
27
		// initialize resource bundle
28
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
29
	}
30
31
	private Messages() {
32
	}
33
}
(-)src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/messages.properties (+16 lines)
Added Link Here
1
general=General
2
###############################################################################
3
# Copyright (c) 2010 IBM Corporation and others.
4
# All rights reserved. This program and the accompanying materials
5
# are made available under the terms of the Eclipse Public License v1.0
6
# which accompanies this distribution, and is available at
7
# http://www.eclipse.org/legal/epl-v10.html
8
#
9
# Contributors:
10
#     IBM Corporation - initial API and implementation
11
###############################################################################
12
delete_ext_project_on_exit=Delete the 'E&xternal JavaScript Source' project on workbench shutdown
13
js_debug_pref_page_desc=General settings for JavaScript debugging
14
suspend_execution=Suspend Execution
15
suspend_for_all_script_loads=Suspend for all script &loads
16
suspend_on_exceptions=Suspend on JavaScript e&xceptions

Return to bug 353225