Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 202827 Details for
Bug 353225
Backport JSDI debugging support from 3.4 to 3.2.x stream
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
jsdt.debug.ui
debug.ui-3.2.5-backport.patch (text/plain), 210.10 KB, created by
Michael Rennie
on 2011-09-06 12:37:11 EDT
(
hide
)
Description:
jsdt.debug.ui
Filename:
MIME Type:
Creator:
Michael Rennie
Created:
2011-09-06 12:37:11 EDT
Size:
210.10 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.jsdt.debug.ui >Index: OSGI-INF/l10n/bundle.properties >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/OSGI-INF/l10n/bundle.properties,v >retrieving revision 1.9.2.3 >diff -u -r1.9.2.3 bundle.properties >--- OSGI-INF/l10n/bundle.properties 21 Jun 2011 14:06:00 -0000 1.9.2.3 >+++ OSGI-INF/l10n/bundle.properties 6 Sep 2011 16:36:38 -0000 >@@ -42,3 +42,20 @@ > openSourceObjectAction.tooltip = Shows the JavaScript source for the selected script element > commandCategory.description = Tooling for debugging JavaScript > commandCategory.name = JavaScript Debug >+ >+showFunctionVarAction.label = Show function variables >+showFunctionVarAction.tooltip = Show or hide function variables >+showThisVarAction.label = Show 'this' variable >+showThisVarAction.tooltip = Show or hide the this variable >+showProtoVarAction.label = Show proto variables >+showProtoVarAction.tooltip = Show or hide proto variables >+ >+evaluateAction.label = E&valuate >+evaluateCommand.label = Evaluate >+evaluateAction.description = Evaluates the selected text in the JavaScript editor >+hyperlinkDetector.description = Allows for quickly stepping into functions in JavaScript source using hyper-links >+hyperlinkDetector.name = Step Into Selection >+debugPrefPage.name = Debug >+debugPrefPageKeyword.label = debug,jsdt,javascript,wst,breakpoint,launch,suspend,scripts >+hover.description = Shows the value of the selected variable while debugging >+hover.label = JavaScript Variable Hover >\ No newline at end of file >Index: build.properties >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/build.properties,v >retrieving revision 1.6 >diff -u -r1.6 build.properties >--- build.properties 1 Apr 2010 18:37:29 -0000 1.6 >+++ build.properties 6 Sep 2011 16:36:38 -0000 >@@ -1,3 +1,13 @@ >+############################################################################### >+# Copyright (c) 2010, 2011 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### > source.. = src/ > output.. = bin/ > bin.includes = META-INF/,\ >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/plugin.xml,v >retrieving revision 1.14.2.5 >diff -u -r1.14.2.5 plugin.xml >--- plugin.xml 21 Jun 2011 14:05:59 -0000 1.14.2.5 >+++ plugin.xml 6 Sep 2011 16:36:38 -0000 >@@ -37,6 +37,9 @@ > <adapter > type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget"> > </adapter> >+ <adapter >+ type="org.eclipse.debug.ui.actions.IRunToLineTarget"> >+ </adapter> > </factory> > <factory > adaptableType="org.eclipse.wst.jsdt.core.IFunction" >@@ -173,7 +176,7 @@ > class="org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.ToggleFunctionBreakpointActionDelegate" > enablesFor="+" > helpContextId="toggle_function_bp_outline" >- icon="icons/elcl16/brkp_obj.gif" >+ icon="$nl$/icons/elcl16/brkp_obj.gif" > id="org.eclipse.wst.jsdt.debug.ui.outline.function.toggle.breakpoint.action" > label="%toggleFunctionBreakpointAction.name" > menubarPath="additions" >@@ -220,11 +223,73 @@ > tooltip="%openSourceObjectAction.tooltip"> > </action> > </objectContribution> >+ <viewerContribution >+ id="org.eclipse.wst.jsdt.debug.ui.classfile.editor.actions" >+ targetID="#ClassFileEditorContext"> >+ <visibility> >+ <and> >+ <objectClass >+ name="org.eclipse.jface.text.ITextSelection"> >+ </objectClass> >+ <systemProperty >+ name="org.eclipse.wst.jsdt.debug.ui.jsdebuggerActive" >+ value="true"> >+ </systemProperty> >+ </and> >+ </visibility> >+ <action >+ class="org.eclipse.wst.jsdt.debug.internal.ui.actions.EvaluateEditorPopupAction" >+ definitionId="org.eclipse.wst.jsdt.debug.ui.evaluate.command" >+ helpContextId="evaluate_jsunit_snippet_action_context" >+ icon="$nl$/icons/elcl16/jsbook_obj.gif" >+ id="org.eclipse.wst.jsdt.debug.ui.jsunit.popup.evaluate" >+ label="%evaluateAction.label" >+ menubarPath="jsdebug" >+ tooltip="%evaluateAction.description"> >+ </action> >+ </viewerContribution> >+ <viewerContribution >+ id="org.eclipse.wst.jsdt.debug.ui.jsunit.editor.actions" >+ targetID="#JavaScriptEditorContext"> >+ <visibility> >+ <and> >+ <objectClass >+ name="org.eclipse.jface.text.ITextSelection"> >+ </objectClass> >+ <systemProperty >+ name="org.eclipse.wst.jsdt.debug.ui.jsdebuggerActive" >+ value="true"> >+ </systemProperty> >+ </and> >+ </visibility> >+ <action >+ class="org.eclipse.wst.jsdt.debug.internal.ui.actions.EvaluateEditorPopupAction" >+ definitionId="org.eclipse.wst.jsdt.debug.ui.evaluate.command" >+ helpContextId="evaluate_jsunit_snippet_action_context" >+ icon="$nl$/icons/elcl16/jsbook_obj.gif" >+ id="org.eclipse.wst.jsdt.debug.ui.jsunit.popup.evaluate" >+ label="%evaluateAction.label" >+ menubarPath="jsdebug" >+ tooltip="%evaluateAction.description"> >+ </action> >+ <menu >+ id="org.eclipse.wst.jsdt.debug.ui.jsdebug.cu.menu" >+ label="%javascriptMenu.name" >+ path="additions"> >+ <groupMarker >+ name="jsdebug"> >+ </groupMarker> >+ <separator >+ name="jsdebug"> >+ </separator> >+ </menu> >+ </viewerContribution> > </extension> > <extension > point="org.eclipse.debug.ui.debugModelPresentations"> > <debugModelPresentation > class="org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptModelPresentation" >+ detailsViewerConfiguration="org.eclipse.wst.jsdt.debug.internal.ui.display.JavaScriptDebugViewerConfiguration" > id="org.eclipse.wst.jsdt.debug.model"> > </debugModelPresentation> > </extension> >@@ -260,6 +325,12 @@ > schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" > sequence="M1+M2+3"> > </key> >+ <key >+ commandId="org.eclipse.wst.jsdt.debug.ui.evaluate.command" >+ contextId="org.eclipse.wst.jsdt.ui.javaEditorScope" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" >+ sequence="M3+M2+E"> >+ </key> > </extension> > <extension > point="org.eclipse.ui.commands"> >@@ -282,6 +353,13 @@ > id="org.eclipse.wst.jsdt.debug.ui.category" > name="%commandCategory.name"> > </category> >+ <command >+ categoryId="org.eclipse.wst.jsdt.debug.ui.category" >+ description="%evaluateAction.description" >+ helpContextId="evaluate_command_help_context" >+ id="org.eclipse.wst.jsdt.debug.ui.evaluate.command" >+ name="%evaluateCommand.label"> >+ </command> > </extension> > <extension > point="org.eclipse.ui.viewActions"> >@@ -341,6 +419,46 @@ > tooltip="%showAllScripts.tooltip"> > </action> > </viewContribution> >+ <viewContribution >+ id="variableViewActions" >+ targetID="org.eclipse.debug.ui.VariableView"> >+ <menu >+ id="org.eclipse.wst.jsdt.debug.ui.variableview.menu" >+ label="%javascriptMenu.name"> >+ <groupMarker >+ name="js"> >+ </groupMarker> >+ </menu> >+ <action >+ class="org.eclipse.wst.jsdt.debug.internal.ui.actions.FunctionFilterAction" >+ helpContextId="show_functions_variable_help_context" >+ id="org.eclipse.wst.jsdt.debug.ui.variableview.show.functions" >+ label="%showFunctionVarAction.label" >+ menubarPath="org.eclipse.wst.jsdt.debug.ui.variableview.menu/js" >+ style="toggle" >+ tooltip="%showFunctionVarAction.tooltip"> >+ </action> >+ <action >+ class="org.eclipse.wst.jsdt.debug.internal.ui.actions.ThisFilterAction" >+ helpContextId="show_this_variable_help_context" >+ icon="$nl$/icons/elcl16/this_var.gif" >+ id="org.eclipse.wst.jsdt.debug.ui.variableview.show.this" >+ label="%showThisVarAction.label" >+ menubarPath="org.eclipse.wst.jsdt.debug.ui.variableview.menu/js" >+ style="toggle" >+ tooltip="%showThisVarAction.tooltip"> >+ </action> >+ <action >+ class="org.eclipse.wst.jsdt.debug.internal.ui.actions.ProtoFilterAction" >+ helpContextId="show_proto_variables_help_context" >+ icon="$nl$/icons/elcl16/proto_var.gif" >+ id="org.eclipse.wst.jsdt.debug.ui.variableview.show.prototypes" >+ label="%showProtoVarAction.label" >+ menubarPath="org.eclipse.wst.jsdt.debug.ui.variableview.menu/js" >+ style="toggle" >+ tooltip="%showProtoVarAction.tooltip"> >+ </action> >+ </viewContribution> > </extension> > <extension > point="org.eclipse.debug.ui.detailPaneFactories"> >@@ -370,37 +488,6 @@ > </detailFactories> > </extension> > <extension >- point="org.eclipse.debug.ui.launchShortcuts"> >- <shortcut >- class="org.eclipse.wst.jsdt.debug.internal.ui.launching.JavaScriptLaunchShortcut" >- description="%javascriptLaunchShortcut.description" >- helpContextId="javasript_lanch_shortcut" >- icon="$nl$/icons/elcl16/script.gif" >- id="org.eclipse.wst.jsdt.debug.ui.launch.shortcut" >- label="%javascriptLaunchShortcut.label" >- modes="debug"> >- <configurationType >- id="org.eclipse.wst.jsdt.debug.core.launchConfigurationType"> >- </configurationType> >- <contextualLaunch> >- <enablement> >- <with >- variable="selection"> >- <iterate> >- <and> >- <adapt >- type="org.eclipse.wst.jsdt.core.IJavaScriptElement"> >- </adapt> >- </and></iterate> >- <count >- value="1"> >- </count> >- </with> >- </enablement> >- </contextualLaunch> >- </shortcut> >- </extension> >- <extension > point="org.eclipse.ui.ide.markerSupport"> > <markerTypeCategory > name="%breakpointMarkerCategory.name"> >@@ -421,4 +508,67 @@ > </markerTypeReference> > </markerTypeCategory> > </extension> >+ <extension >+ point="org.eclipse.core.runtime.preferences"> >+ <initializer >+ class="org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPreferenceInitializer"> >+ </initializer> >+ </extension> >+ <extension >+ point="org.eclipse.ui.handlers"> >+ <handler >+ class="org.eclipse.wst.jsdt.debug.internal.ui.actions.EvaluateEditorPopupAction" >+ commandId="org.eclipse.wst.jsdt.debug.ui.evaluate.command" >+ helpContextId="evaluate_command_help_context"> >+ </handler> >+ </extension> >+ <extension >+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors"> >+ <hyperlinkDetector >+ activate="true" >+ class="org.eclipse.wst.jsdt.debug.internal.ui.eval.JavaScriptHyperlinkDetector" >+ description="%hyperlinkDetector.description" >+ id="org.eclipse.wst.jsdt.debug.ui.hyperlink.detector" >+ modifierKeys="M1+M3" >+ name="%hyperlinkDetector.name" >+ targetId="org.eclipse.wst.jsdt.ui.javaCode"> >+ </hyperlinkDetector> >+ </extension> >+ <extension >+ point="org.eclipse.ui.preferencePages"> >+ <page >+ category="org.eclipse.wst.jsdt.ui.preferences.JavaBasePreferencePage" >+ class="org.eclipse.wst.jsdt.debug.internal.ui.preferences.JavaScriptDebugPreferencePage" >+ id="org.eclipse.wst.jsdt.debug.ui.debug.page" >+ name="%debugPrefPage.name"> >+ <keywordReference >+ id="org.eclipse.wst.jsdt.debug.ui.debug.pref.page.keyword"> >+ </keywordReference> >+ </page> >+ </extension> >+ <extension >+ point="org.eclipse.ui.keywords"> >+ <keyword >+ id="org.eclipse.wst.jsdt.debug.ui.debug.pref.page.keyword" >+ label="%debugPrefPageKeyword.label"> >+ </keyword> >+ </extension> >+ <extension >+ point="org.eclipse.wst.jsdt.ui.javaEditorTextHovers"> >+ <hover >+ class="org.eclipse.wst.jsdt.debug.internal.ui.eval.JavaScriptDebugHover" >+ description="%hover.description" >+ id="org.eclipse.wst.jsdt.debug.ui.variable.value.hover" >+ label="%hover.label"> >+ </hover> >+ </extension> >+ <extension >+ point="org.eclipse.ui.editors.markerUpdaters"> >+ <updater >+ class="org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.JavaScriptBreakpointUpdater" >+ id="org.eclipse.wst.jsdt.debug.ui.breakpoint.updater" >+ markerType="org.eclipse.wst.jsdt.debug.core.breakpoint.marker"> >+ </updater> >+ </extension> >+ > </plugin> >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/Constants.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/Constants.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/Constants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/Constants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2008, 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui; >+ >+/** >+ * Constants for the {@link JavaScriptDebugUIPlugin} >+ * >+ * @since 1.1 >+ */ >+public interface Constants { >+ >+ /** >+ * Constant for the preference for showing / hiding functions from the variables view >+ * <br><br> >+ * Value is: <code>org.eclipse.wst.jsdt.debug.ui.show_functions</code> >+ */ >+ public static final String SHOW_FUNCTIONS = JavaScriptDebugUIPlugin.PLUGIN_ID + ".show_functions"; //$NON-NLS-1$ >+ /** >+ * Constant for the preference for showing / hiding prototypes from the variables view >+ * <br><br> >+ * Value is: <code>org.eclipse.wst.jsdt.debug.ui.show_protoypes</code> >+ */ >+ public static final String SHOW_PROTOTYPES = JavaScriptDebugUIPlugin.PLUGIN_ID + ".show_prototypes"; //$NON-NLS-1$ >+ /** >+ * Constant for the preference for showing / hiding the <code>this</code> variable from the variables view >+ * <br><br> >+ * Value is: <code>org.eclipse.wst.jsdt.debug.ui.show_this</code> >+ */ >+ public static final String SHOW_THIS = JavaScriptDebugUIPlugin.PLUGIN_ID + "show_this"; //$NON-NLS-1$ >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/IHelpContextIds.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/IHelpContextIds.java,v >retrieving revision 1.2 >diff -u -r1.2 IHelpContextIds.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/IHelpContextIds.java 11 Mar 2010 18:53:32 -0000 1.2 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/IHelpContextIds.java 6 Sep 2011 16:36:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >+ * Copyright (c) 2010, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -29,4 +29,24 @@ > * Help constant for the connect tab > */ > public static final String CONNECT_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".connect_tab"; //$NON-NLS-1$ >+ /** >+ * Help constant for the Debug root preference page >+ * @since 1.1 >+ */ >+ public static final String DEBUG_PREFERENCE_PAGE = JavaScriptDebugUIPlugin.PLUGIN_ID + ".debug_pref_page"; //$NON-NLS-1$ >+ /** >+ * Help constant for the Source tab >+ * @since 1.2 >+ */ >+ public static final String SOURCE_LOOKUP_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".source_lookup_tab"; //$NON-NLS-1$ >+ /** >+ * Help constant for the Environment tab >+ * @since 1.2 >+ */ >+ public static final String ENVIRONMENT_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".environment_tab"; //$NON-NLS-1$ >+ /** >+ * Help constant for the Common tab >+ * @since 1.2 >+ */ >+ public static final String COMMON_TAB = JavaScriptDebugUIPlugin.PLUGIN_ID + ".common_tab"; //$NON-NLS-1$ > } >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPlugin.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPlugin.java,v >retrieving revision 1.2 >diff -u -r1.2 JavaScriptDebugUIPlugin.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPlugin.java 10 May 2010 18:15:50 -0000 1.2 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPlugin.java 6 Sep 2011 16:36:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >+ * Copyright (c) 2010, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -16,6 +16,9 @@ > import org.eclipse.core.resources.IProject; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.preferences.InstanceScope; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.IEditorReference; > import org.eclipse.ui.IWorkbench; > import org.eclipse.ui.IWorkbenchListener; >@@ -25,7 +28,9 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.ide.ResourceUtil; > import org.eclipse.ui.plugin.AbstractUIPlugin; >+import org.eclipse.ui.preferences.ScopedPreferenceStore; > import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin; >+import org.eclipse.wst.jsdt.debug.internal.ui.eval.EvaluationManager; > import org.osgi.framework.BundleContext; > > /** >@@ -48,6 +53,7 @@ > > // The shared instance > private static JavaScriptDebugUIPlugin plugin; >+ private static ScopedPreferenceStore corestore = new ScopedPreferenceStore(InstanceScope.INSTANCE, JavaScriptDebugPlugin.PLUGIN_ID); > > /* > * (non-Javadoc) >@@ -57,6 +63,7 @@ > super.start(context); > plugin = this; > PlatformUI.getWorkbench().addWorkbenchListener(this); >+ EvaluationManager.getManager().start(); > } > > /* >@@ -67,6 +74,7 @@ > try { > plugin = null; > PlatformUI.getWorkbench().removeWorkbenchListener(this); >+ EvaluationManager.getManager().stop(); > super.stop(context); > } > finally { >@@ -173,4 +181,27 @@ > */ > public void postShutdown(IWorkbench workbench) { > } >+ >+ /** >+ * Returns the standard display to be used. The method first checks, if >+ * the thread calling this method has an associated display. If so, this >+ * display is returned. Otherwise the method returns the default display. >+ */ >+ public static Display getStandardDisplay() { >+ Display display; >+ display = Display.getCurrent(); >+ if (display == null) { >+ display = Display.getDefault(); >+ } >+ return display; >+ } >+ >+ /** >+ * Returns an {@link IPreferenceStore} wrapper for the {@link JavaScriptDebugPlugin} core preferences >+ * >+ * @return an {@link IPreferenceStore} for the core preferences >+ */ >+ public static IPreferenceStore getCorePreferenceStore() { >+ return corestore; >+ } > } >\ No newline at end of file >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPreferenceInitializer.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPreferenceInitializer.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPreferenceInitializer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptDebugUIPreferenceInitializer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui; >+ >+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; >+import org.eclipse.jface.preference.IPreferenceStore; >+ >+/** >+ * Initialize common preferences for {@link JavaScriptDebugUIPlugin} >+ * >+ * @since 1.1 >+ */ >+public class JavaScriptDebugUIPreferenceInitializer extends AbstractPreferenceInitializer { >+ >+ /** >+ * Constructor >+ */ >+ public JavaScriptDebugUIPreferenceInitializer() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() >+ */ >+ public void initializeDefaultPreferences() { >+ IPreferenceStore store = JavaScriptDebugUIPlugin.getDefault().getPreferenceStore(); >+ store.setDefault(Constants.SHOW_FUNCTIONS, true); >+ store.setDefault(Constants.SHOW_PROTOTYPES, true); >+ store.setDefault(Constants.SHOW_THIS, true); >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptModelPresentation.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptModelPresentation.java,v >retrieving revision 1.7.2.2 >diff -u -r1.7.2.2 JavaScriptModelPresentation.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptModelPresentation.java 30 Jun 2010 15:52:53 -0000 1.7.2.2 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/JavaScriptModelPresentation.java 6 Sep 2011 16:36:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2009 IBM Corporation and others. >+ * Copyright (c) 2009, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -11,7 +11,9 @@ > package org.eclipse.wst.jsdt.debug.internal.ui; > > import java.io.File; >+import java.io.UnsupportedEncodingException; > import java.net.URISyntaxException; >+import java.net.URLDecoder; > import java.util.HashMap; > > import org.eclipse.core.filesystem.EFS; >@@ -19,14 +21,20 @@ > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.URIUtil; > import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.model.IBreakpoint; >+import org.eclipse.debug.core.model.IDebugElement; > import org.eclipse.debug.core.model.IDebugTarget; >+import org.eclipse.debug.core.model.IDisconnect; > import org.eclipse.debug.core.model.IStackFrame; >+import org.eclipse.debug.core.model.ITerminate; > import org.eclipse.debug.core.model.IThread; > import org.eclipse.debug.core.model.IValue; > import org.eclipse.debug.core.model.IVariable; >+import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; > import org.eclipse.debug.ui.IDebugModelPresentationExtension; > import org.eclipse.debug.ui.IValueDetailListener; > import org.eclipse.jface.viewers.LabelProvider; >@@ -43,11 +51,17 @@ > import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint; > import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint; > import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLoadBreakpoint; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptThread; > import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue; > import org.eclipse.wst.jsdt.debug.core.model.IScript; > import org.eclipse.wst.jsdt.debug.core.model.IScriptGroup; >+import org.eclipse.wst.jsdt.debug.internal.core.Constants; >+import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin; > import org.eclipse.wst.jsdt.debug.internal.core.TextUtils; >+import org.eclipse.wst.jsdt.debug.internal.core.breakpoints.JavaScriptExceptionBreakpoint; > import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptValue; >+import org.eclipse.wst.jsdt.debug.internal.ui.eval.JavaScriptInspectExpression; > > /** > * Default model presentation for JSDI model elements >@@ -126,52 +140,188 @@ > * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) > */ > public String getText(Object element) { >+ StringBuffer buffer = new StringBuffer(); > try { >- if(element instanceof IDebugTarget) { >- return ((IDebugTarget)element).getName(); >+ if(element instanceof IDebugElement) { >+ if(element instanceof IDebugTarget) { >+ buffer.append(((IDebugTarget)element).getName()); >+ } >+ else if(element instanceof IStackFrame) { >+ buffer.append(getStackframeText((IJavaScriptStackFrame) element)); >+ } >+ else if(element instanceof IThread) { >+ buffer.append(getThreadText((IJavaScriptThread) element)); >+ } >+ else if(element instanceof IVariable) { >+ buffer.append(((IVariable)element).getName()); >+ } >+ else if(element instanceof IValue) { >+ buffer.append(((IValue)element).getValueString()); >+ } >+ else if(element instanceof IScriptGroup) { >+ buffer.append(Messages.scripts); >+ } >+ else if(element instanceof IScript) { >+ buffer.append(getScriptText((IScript) element)); >+ } > } >- if(element instanceof IStackFrame) { >- return ((IStackFrame)element).getName(); >+ if(element instanceof JavaScriptInspectExpression) { >+ JavaScriptInspectExpression exp = (JavaScriptInspectExpression) element; >+ return exp.getValue().getReferenceTypeName(); >+ } >+ if(element instanceof ITerminate) { >+ if(((ITerminate)element).isTerminated()) { >+ buffer.insert(0, Messages.terminated); >+ } >+ else if(element instanceof IDisconnect) { >+ if(((IDisconnect)element).isDisconnected()) { >+ buffer.insert(0, Messages.disconnected); >+ } >+ } > } >- if(element instanceof IThread) { >- return ((IThread)element).getName(); >+ else if(element instanceof IDisconnect) { >+ if(((IDisconnect)element).isDisconnected()) { >+ buffer.insert(0, Messages.disconnected); >+ } > } >- if(element instanceof IVariable) { >- return ((IVariable)element).getName(); >+ else if(element instanceof IJavaScriptFunctionBreakpoint) { >+ buffer.append(getFunctionBreakpointText((IJavaScriptFunctionBreakpoint) element)); > } >- if(element instanceof IValue) { >- return ((IValue)element).getValueString(); >+ else if(element instanceof IJavaScriptLoadBreakpoint) { >+ buffer.append(getScriptLoadBreakpointText((IJavaScriptLoadBreakpoint) element)); > } >- if(element instanceof IJavaScriptFunctionBreakpoint) { >- return getFunctionBreakpointText((IJavaScriptFunctionBreakpoint) element); >+ else if(element instanceof IJavaScriptLineBreakpoint) { >+ buffer.append(getLineBreakpointText((IJavaScriptLineBreakpoint) element)); > } >- if(element instanceof IJavaScriptLoadBreakpoint) { >- return getScriptLoadBreakpointText((IJavaScriptLoadBreakpoint) element); >+ } >+ catch(CoreException ce) { >+ JavaScriptDebugUIPlugin.log(ce); >+ buffer.append(Messages.unknown); >+ } >+ if(buffer.length() < 1) { >+ return Messages.unknown; >+ } >+ return buffer.toString(); >+ } >+ >+ /** >+ * Computes the thread name + adornment >+ * >+ * @param thread >+ * @return >+ * @throws DebugException >+ */ >+ String getThreadText(IJavaScriptThread thread) throws DebugException { >+ String adornment = Messages.unknown_state; >+ if(thread.isSuspended()) { >+ IBreakpoint[] bps = thread.getBreakpoints(); >+ if(bps.length > 0) { >+ try { >+ IJavaScriptBreakpoint breakpoint = (IJavaScriptBreakpoint) bps[0]; >+ if (breakpoint instanceof IJavaScriptLoadBreakpoint) { >+ String name = breakpoint.getScriptPath(); >+ if (Constants.EMPTY_STRING.equals(name)) { >+ name = getSourceName(thread); >+ } >+ else { >+ //decode it >+ try { >+ name = URLDecoder.decode(name, Constants.UTF_8); >+ } >+ catch(UnsupportedEncodingException uee) { >+ //ignore >+ } >+ } >+ adornment = NLS.bind(Messages.suspend_loading_script, name); >+ } >+ else if(breakpoint instanceof JavaScriptExceptionBreakpoint) { >+ adornment = NLS.bind(Messages.suspended_on_exception, breakpoint.getMarker().getAttribute(JavaScriptExceptionBreakpoint.MESSAGE)); >+ } >+ else if (breakpoint instanceof IJavaScriptLineBreakpoint) { >+ IJavaScriptLineBreakpoint bp = (IJavaScriptLineBreakpoint) breakpoint; >+ adornment = NLS.bind(Messages.suspended_on_line_breakpoint, new String[] { Integer.toString(bp.getLineNumber()), getSourceName(thread) }); >+ } >+ else if(breakpoint instanceof IJavaScriptFunctionBreakpoint) { >+ IJavaScriptFunctionBreakpoint bp = (IJavaScriptFunctionBreakpoint) breakpoint; >+ adornment = NLS.bind(Messages.suspended_on_func_breakpoint, new String[] {bp.getFunctionName(), getSourceName(thread)}); >+ } >+ // TODO also need to report stopped at debugger; statement >+ } catch (CoreException ce) { >+ JavaScriptDebugPlugin.log(ce); >+ } > } >- if(element instanceof IJavaScriptLineBreakpoint) { >- return getLineBreakpointText((IJavaScriptLineBreakpoint) element); >+ else { >+ adornment = Messages.suspended_state; > } >- if(element instanceof IScriptGroup) { >- return Messages.scripts; >+ } >+ else if(thread.isStepping()) { >+ adornment = Messages.stepping_state; >+ } >+ else if(thread.isTerminated()) { >+ adornment = Messages.terminated_state; >+ } >+ else { >+ adornment = Messages.running_state; >+ } >+ return NLS.bind(Messages.thread_name, new String[] {thread.getName(), adornment}); >+ } >+ >+ /** >+ * Returns the name of the source from the top stackframe or a default name >+ * <code><evaluated_source></code> >+ * >+ * @return the name for the source >+ * @throws DebugException >+ */ >+ String getSourceName(IJavaScriptThread thread) throws DebugException { >+ IJavaScriptStackFrame frame = (IJavaScriptStackFrame) thread.getTopStackFrame(); >+ if (frame != null) { >+ try { >+ String uri = URLDecoder.decode(frame.getSourceName(), Constants.UTF_8); >+ return TextUtils.shortenText(uri, 100); > } >- if(element instanceof IScript) { >- return getScriptText((IScript) element); >+ catch (UnsupportedEncodingException uee) { >+ //ignore > } > } >- catch(CoreException ce) { >- JavaScriptDebugUIPlugin.log(ce); >+ // all else failed say "evaluated_script" >+ return Messages.evald_script; >+ } >+ >+ /** >+ * Returns the display name of the given {@link IJavaScriptStackFrame} >+ * >+ * @param frame >+ * @return the display text or {@link Messages#unknown} >+ * @throws DebugException >+ */ >+ String getStackframeText(IJavaScriptStackFrame frame) throws DebugException { >+ try { >+ return TextUtils.shortenText(NLS.bind(Messages.stackframe_name, new String[] { >+ URLDecoder.decode(frame.getName(), Constants.UTF_8), >+ Integer.toString(frame.getLineNumber())}), 100); >+ } >+ catch (UnsupportedEncodingException uee) { >+ //ignore > } >- return element.toString(); >+ return Messages.unknown; > } > > /** > * Returns the display text for the given script element >+ * > * @param script >- * @return the display text for the given script >+ * @return the display text for the given script or {@link Messages#unknown} > */ > String getScriptText(IScript script) { >- String uri = script.sourceURI().toString(); >- return TextUtils.shortenText(uri, 100); >+ String uri; >+ try { >+ uri = URLDecoder.decode(script.sourceURI().toString(), Constants.UTF_8); >+ return TextUtils.shortenText(uri, 100); >+ } catch (UnsupportedEncodingException e) { >+ //do nothing >+ } >+ return Messages.unknown; > } > > /** >@@ -182,8 +332,8 @@ > */ > String getLineBreakpointText(IJavaScriptLineBreakpoint breakpoint) throws CoreException { > String path = getElementPath(breakpoint.getScriptPath()); >- StringBuffer buffer = new StringBuffer(); >- buffer.append(path).append(NLS.bind(Messages.bp_line_number, new String[] {Integer.toString(breakpoint.getLineNumber())})); >+ StringBuffer buffer = new StringBuffer(path); >+ buffer.append(NLS.bind(Messages.bp_line_number, new String[] {Integer.toString(breakpoint.getLineNumber())})); > int hitcount = breakpoint.getHitCount(); > if(hitcount > 0) { > buffer.append(NLS.bind(Messages.bp_hit_count, new String[] {Integer.toString(hitcount)})); >@@ -205,8 +355,7 @@ > */ > String getFunctionBreakpointText(IJavaScriptFunctionBreakpoint breakpoint) throws CoreException { > String path = getElementPath(breakpoint.getScriptPath()); >- StringBuffer buffer = new StringBuffer(); >- buffer.append(path); >+ StringBuffer buffer = new StringBuffer(path); > if(breakpoint.isEntry()) { > if(breakpoint.isExit()) { > buffer.append(Messages.bp_entry_and_exit); >@@ -241,8 +390,7 @@ > */ > String getScriptLoadBreakpointText(IJavaScriptLoadBreakpoint breakpoint) throws CoreException { > String path = getElementPath(breakpoint.getScriptPath()); >- StringBuffer buffer = new StringBuffer(); >- buffer.append(path); >+ StringBuffer buffer = new StringBuffer(path); > int hitcount = breakpoint.getHitCount(); > if(hitcount > 0) { > buffer.append(NLS.bind(Messages.bp_hit_count, new String[] {Integer.toString(hitcount)})); >@@ -259,7 +407,7 @@ > * @return > */ > String getElementPath(String path) { >- if(! showQualifiedNames()) { >+ if(!showQualifiedNames()) { > try { > return URIUtil.lastSegment(URIUtil.fromString(path)); > } >@@ -370,6 +518,9 @@ > * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object) > */ > public IEditorInput getEditorInput(Object element) { >+ if(element instanceof LocalFileStorage) { >+ return getEditorInput(((LocalFileStorage)element).getFile()); >+ } > if(element instanceof File) { > return new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile((File) element)); > } >@@ -379,8 +530,9 @@ > if(element instanceof IJavaScriptLoadBreakpoint) { > try { > IJavaScriptLoadBreakpoint bp = (IJavaScriptLoadBreakpoint) element; >- IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(bp.getScriptPath())); >- if(resource.getType() == IResource.FILE) { >+ IPath path = new Path(bp.getScriptPath()); >+ IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); >+ if(resource != null && resource.getType() == IResource.FILE) { > return new FileEditorInput((IFile) resource); > } > } >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/Messages.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/Messages.java,v >retrieving revision 1.4.2.1 >diff -u -r1.4.2.1 Messages.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/Messages.java 21 Jun 2011 14:06:00 -0000 1.4.2.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/Messages.java 6 Sep 2011 16:36:39 -0000 >@@ -31,17 +31,33 @@ > public static String connector; > public static String connector_properties; > public static String creating_script_load_bp; >+ public static String disconnected; > public static String enable_hit_count; > public static String enter_new_hit_count; >+ public static String evald_script; > public static String exception_occurred_setting_bp_properties; > public static String hit_count_must_be_positive; > public static String no_description_provided; >+ public static String opening_source__0; >+ public static String running_state; > public static String scripts; > public static String select_javascript_file; > public static String set_bp_hit_count; >+ public static String stackframe_name; >+ public static String stepping_state; >+ public static String suspend_loading_script; > public static String suspend_target; > public static String suspend_thread; >+ public static String suspended_on_exception; >+ public static String suspended_on_func_breakpoint; >+ public static String suspended_on_line_breakpoint; >+ public static String suspended_state; >+ public static String terminated; >+ public static String terminated_state; > public static String the_argument_0_is_not_valid; >+ public static String thread_name; >+ public static String unknown; >+ public static String unknown_state; > static { > // initialize resource bundle > NLS.initializeMessages(BUNDLE_NAME, Messages.class); >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/PreferencesManager.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/PreferencesManager.java,v >retrieving revision 1.1 >diff -u -r1.1 PreferencesManager.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/PreferencesManager.java 16 Mar 2010 20:09:05 -0000 1.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/PreferencesManager.java 6 Sep 2011 16:36:39 -0000 >@@ -1,3 +1,13 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ > package org.eclipse.wst.jsdt.debug.internal.ui; > > import org.eclipse.jface.util.IPropertyChangeListener; >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/AddScriptLoadBreakpointAction.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/actions/AddScriptLoadBreakpointAction.java,v >retrieving revision 1.4 >diff -u -r1.4 AddScriptLoadBreakpointAction.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/actions/AddScriptLoadBreakpointAction.java 24 May 2010 22:37:42 -0000 1.4 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/AddScriptLoadBreakpointAction.java 6 Sep 2011 16:36:39 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >+ * Copyright (c) 2010, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -54,7 +54,7 @@ > if(dialog.open() == IDialogConstants.OK_ID) { > final IFile file = (IFile) dialog.getFirstResult(); > final String scriptname = file.getName(); >- final String scriptpath = file.getFullPath().makeRelative().toString(); >+ final String scriptpath = file.getProjectRelativePath().makeAbsolute().toString(); > > IJavaScriptLoadBreakpoint breakpoint = findBreakpoint(scriptpath, scriptname); > if(breakpoint != null) { >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateAction.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateAction.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,367 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.actions; >+ >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IActionDelegate2; >+import org.eclipse.ui.IEditorActionDelegate; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IObjectActionDelegate; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchSite; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.IWorkbenchWindowActionDelegate; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue; >+import org.eclipse.wst.jsdt.debug.internal.ui.eval.EvaluationManager; >+import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder; >+ >+/** >+ * Action for evaluating selected source >+ * >+ * @since 1.1 >+ */ >+public abstract class EvaluateAction implements IEditorActionDelegate, IObjectActionDelegate, IActionDelegate2, IViewActionDelegate, IWorkbenchWindowActionDelegate, IHandler { >+ >+ private IRegion region = null; >+ private IWorkbenchPart targetpart = null; >+ private IWorkbenchWindow window = null; >+ private IAction action = null; >+ private Object selection = null; >+ private IJavaScriptValue value = null; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate2#dispose() >+ */ >+ public void dispose() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) >+ */ >+ public void runWithEvent(IAction action, Event event) { >+ run(action); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) >+ */ >+ public void run(IAction action) { >+ IJavaScriptStackFrame frame = getStackFrameContext(); >+ if(frame != null) { >+ resolveSelection(); >+ //XXX hack, if we want to support evaluations from the variables view this will not work >+ setValue(frame.evaluate(getSelection().toString())); >+ showResult(getValue()); >+ } >+ } >+ >+ /** >+ * Shows the result of the evaluation to the user. Sub-classes must implement. >+ * >+ * @param value the {@link IJavaScriptValue} to show to the user >+ */ >+ protected abstract void showResult(IJavaScriptValue value); >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IAction action, ISelection selection) { >+ setAction(action); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) >+ */ >+ public void init(IAction action) { >+ setAction(action); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) >+ */ >+ public void init(IViewPart view) { >+ setTargetpart(view); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) >+ */ >+ public void init(IWorkbenchWindow window) { >+ IWorkbenchPage page = window.getActivePage(); >+ if(page != null) { >+ setTargetpart(window.getActivePage().getActivePart()); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) >+ */ >+ public void setActivePart(IAction action, IWorkbenchPart targetPart) { >+ setTargetpart(targetPart); >+ setAction(action); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) >+ */ >+ public void setActiveEditor(IAction action, IEditorPart targetEditor) { >+ setTargetpart(targetEditor); >+ setAction(action); >+ } >+ >+ /** >+ * Resolves the selected object from the target part >+ */ >+ protected void resolveSelection() { >+ ISelection sel = getTargetSelection(); >+ setRegion(null); >+ if(sel instanceof ITextSelection) { >+ ITextSelection ts = (ITextSelection)sel; >+ String text= ts.getText(); >+ if (text.trim().length() > 0) { >+ setSelection(text); >+ setRegion(new Region(ts.getOffset(), ts.getLength())); >+ } else if (getTargetPart() instanceof IEditorPart) { >+ IEditorPart editor= (IEditorPart)getTargetPart(); >+ if (editor instanceof ITextEditor) { >+ setSelection(resolveText(null, ts, editor)); >+ } >+ } >+ } >+ else if(sel instanceof IStructuredSelection) { >+ >+ } >+ } >+ >+ /** >+ * Resolve the word from the given text selection. If no new word infos can be resolved >+ * the original string is returned. >+ * @param text the text >+ * @param ts the current text selection >+ * @param editor the current editor >+ * @return the new resolved text for the whole word of the selection >+ */ >+ String resolveText(String text, ITextSelection ts, IEditorPart editor) { >+ ITextEditor textEditor= (ITextEditor) editor; >+ IDocument doc= textEditor.getDocumentProvider().getDocument(editor.getEditorInput()); >+ region = JavaWordFinder.findWord(doc, ts.getOffset()); >+ if (region != null) { >+ try { >+ return doc.get(region.getOffset(), region.getLength()); >+ } >+ catch (BadLocationException e) { >+ //ignore >+ } >+ } >+ return text; >+ } >+ >+ /** >+ * Returns the select from the {@link IWorkbenchSite} of the {@link #getTargetPart()} {@link IWorkbenchPart} >+ * @return the selection or <code>null</code> >+ */ >+ protected ISelection getTargetSelection() { >+ IWorkbenchPart part = getTargetPart(); >+ if(part != null) { >+ ISelectionProvider provider = part.getSite().getSelectionProvider(); >+ if (provider != null) { >+ return provider.getSelection(); >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Finds the currently selected {@link IJavaScriptStackFrame} in the UI. >+ */ >+ protected IJavaScriptStackFrame getStackFrameContext() { >+ IWorkbenchPart part = getTargetPart(); >+ IJavaScriptStackFrame frame = null; >+ if (part == null) { >+ frame = EvaluationManager.getManager().getEvaluationContext(getWindow()); >+ } else { >+ frame = EvaluationManager.getManager().getEvaluationContext(part); >+ } >+ return frame; >+ } >+ >+ /** >+ * Allows the result of the evaluation to be set >+ * >+ * @param value the {@link IJavaScriptValue} of the evaluation >+ */ >+ protected void setValue(IJavaScriptValue value) { >+ this.value = value; >+ } >+ >+ /** >+ * Returns the {@link IJavaScriptValue} result of the evaluation >+ * >+ * @return the {@link IJavaScriptValue} result or <code>null</code> >+ */ >+ protected IJavaScriptValue getValue() { >+ return value; >+ } >+ >+ /** >+ * Allows the resolved selection to be set >+ * >+ * @param obj >+ */ >+ protected void setSelection(Object obj) { >+ selection = obj; >+ } >+ >+ /** >+ * Returns the resolved selection or <code>null</code>. If <code>null</code> >+ * is returned attempts can be made to re-resolve the selection using {@link #resolveSelection()} >+ * >+ * @return the resolved selection or <code>null</code> >+ */ >+ protected Object getSelection() { >+ return selection; >+ } >+ >+ /** >+ * Returns the current target {@link IWorkbenchPart} >+ * @return the {@link IWorkbenchPart} target or <code>null</code> >+ */ >+ protected IWorkbenchPart getTargetPart() { >+ return targetpart; >+ } >+ >+ /** >+ * Allows the target {@link IWorkbenchPart} to be set >+ * @param targetpart the targetpart to set >+ */ >+ protected void setTargetpart(IWorkbenchPart targetpart) { >+ this.targetpart = targetpart; >+ } >+ >+ /** >+ * Returns the current active {@link IWorkbenchWindow} >+ * >+ * @return the current active {@link IWorkbenchWindow} >+ */ >+ protected IWorkbenchWindow getWindow() { >+ return window; >+ } >+ >+ /** >+ * Allows the current {@link IWorkbenchWindow} context to be set >+ * >+ * @param window the {@link IWorkbenchWindow} context >+ */ >+ protected void setWindow(IWorkbenchWindow window) { >+ this.window = window; >+ } >+ >+ /** >+ * Returns the selected text {@link IRegion}, or <code>null</code> if none. >+ * >+ * @return the selected text {@link IRegion} or <code>null</code> >+ */ >+ protected IRegion getRegion() { >+ return region; >+ } >+ >+ /** >+ * Allows the selected {@link IRegion} to be set >+ * >+ * @param region the {@link IRegion} to set >+ */ >+ protected void setRegion(IRegion region) { >+ this.region = region; >+ } >+ >+ /** >+ * Returns the {@link IAction} context or <code>null</code> >+ * >+ * @return the backing {@link IAction} or <code>null</code> >+ */ >+ protected IAction getAction() { >+ return action; >+ } >+ >+ /** >+ * Allows the backing {@link IAction} to be set >+ * >+ * @param action the action to set >+ */ >+ protected void setAction(IAction action) { >+ this.action = action; >+ } >+ >+ /** >+ * Returns the styled text widget associated with the given part >+ * or <code>null</code> if none. >+ * >+ * @param part workbench part >+ * @return associated style text widget or <code>null</code> >+ */ >+ protected StyledText getStyledText(IWorkbenchPart part) { >+ ITextViewer viewer = (ITextViewer)part.getAdapter(ITextViewer.class); >+ StyledText textWidget = null; >+ if (viewer == null) { >+ Control control = (Control) part.getAdapter(Control.class); >+ if (control instanceof StyledText) { >+ textWidget = (StyledText) control; >+ } >+ } else { >+ textWidget = viewer.getTextWidget(); >+ } >+ return textWidget; >+ } >+ >+ /** >+ * Returns an anchor point for a popup dialog on top of a styled text >+ * or <code>null</code> if none. >+ * >+ * @param part or <code>null</code> >+ * @return anchor point or <code>null</code> >+ */ >+ protected Point getPopupAnchor(StyledText textWidget) { >+ if (textWidget != null) { >+ Point docRange = textWidget.getSelectionRange(); >+ int midOffset = docRange.x + (docRange.y / 2); >+ Point point = textWidget.getLocationAtOffset(midOffset); >+ point = textWidget.toDisplay(point); >+ >+ GC gc = new GC(textWidget); >+ gc.setFont(textWidget.getFont()); >+ int height = gc.getFontMetrics().getHeight(); >+ gc.dispose(); >+ point.y += height; >+ return point; >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateEditorPopupAction.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateEditorPopupAction.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateEditorPopupAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/EvaluateEditorPopupAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,89 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.actions; >+ >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandlerListener; >+import org.eclipse.debug.ui.InspectPopupDialog; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue; >+import org.eclipse.wst.jsdt.debug.internal.ui.eval.JavaScriptInspectExpression; >+ >+ >+/** >+ * Default handler for the {@link EvaluateAction} >+ * >+ * @since 1.0 >+ */ >+public class EvaluateEditorPopupAction extends EvaluateAction { >+ >+ /** >+ * Constructor >+ */ >+ public EvaluateEditorPopupAction() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ run(null); >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.EvaluateAction#showResult(org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue) >+ */ >+ protected void showResult(IJavaScriptValue value) { >+ InspectPopupDialog dialog = new InspectPopupDialog( >+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), >+ getPopupAnchor(getStyledText(getTargetPart())), >+ null, >+ new JavaScriptInspectExpression(getValue())); >+ dialog.open(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.IHandler#isEnabled() >+ */ >+ public boolean isEnabled() { >+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); >+ setWindow(window); >+ if(window != null) { >+ IWorkbenchPage page = window.getActivePage(); >+ if(page != null) { >+ setTargetpart(page.getActivePart()); >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.IHandler#isHandled() >+ */ >+ public boolean isHandled() { >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener) >+ */ >+ public void removeHandlerListener(IHandlerListener handlerListener) {} >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener) >+ */ >+ public void addHandlerListener(IHandlerListener handlerListener) {} >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/FunctionFilterAction.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/FunctionFilterAction.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/actions/FunctionFilterAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/FunctionFilterAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.actions; >+ >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue; >+import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptProperty; >+import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptVariable; >+import org.eclipse.wst.jsdt.debug.internal.ui.Constants; >+ >+ >+/** >+ * Viewer filter action for filtering functions >+ * >+ * @since 1.1 >+ */ >+public class FunctionFilterAction extends ViewFilterAction { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey() >+ */ >+ protected String getPreferenceKey() { >+ return Constants.SHOW_FUNCTIONS; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) >+ */ >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ if(element instanceof JavaScriptVariable){ >+ JavaScriptVariable var = (JavaScriptVariable) element; >+ try { >+ if(IJavaScriptValue.FUNCTION.equals(var.getReferenceTypeName())) { >+ return getValue(); >+ } >+ } catch (DebugException e) { >+ } >+ } >+ if(element instanceof JavaScriptProperty){ >+ JavaScriptProperty prop = (JavaScriptProperty) element; >+ try { >+ if(IJavaScriptValue.FUNCTION.equals(prop.getReferenceTypeName())) { >+ return getValue(); >+ } >+ } catch (DebugException e) { >+ } >+ } >+ return true; >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/OpenSourceAction.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/actions/OpenSourceAction.java,v >retrieving revision 1.1 >diff -u -r1.1 OpenSourceAction.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/actions/OpenSourceAction.java 7 Apr 2010 20:31:18 -0000 1.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/OpenSourceAction.java 6 Sep 2011 16:36:40 -0000 >@@ -17,19 +17,26 @@ > import org.eclipse.core.commands.IHandler2; > import org.eclipse.core.commands.IHandlerListener; > import org.eclipse.core.expressions.EvaluationContext; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.debug.ui.DebugUITools; > import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.widgets.Event; > import org.eclipse.ui.IActionDelegate2; > import org.eclipse.ui.IObjectActionDelegate; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.progress.UIJob; > import org.eclipse.wst.jsdt.debug.core.model.IScript; > import org.eclipse.wst.jsdt.debug.internal.core.model.Script; >+import org.eclipse.wst.jsdt.debug.internal.ui.Messages; > > /** > * Context menu action to show the source for a selected {@link IScript} >@@ -50,9 +57,17 @@ > */ > public void run(IAction action) { > if(script != null) { >- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >- ISourceLookupResult result = DebugUITools.lookupSource(script, script.getDebugTarget().getLaunch().getSourceLocator()); >- DebugUITools.displaySource(result, page); >+ UIJob job = new UIJob(PlatformUI.getWorkbench().getDisplay(), NLS.bind(Messages.opening_source__0, script.sourceURI())) { >+ public IStatus runInUIThread(IProgressMonitor monitor) { >+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >+ ISourceLookupResult result = DebugUITools.lookupSource(script, script.getDebugTarget().getLaunch().getSourceLocator()); >+ DebugUITools.displaySource(result, page); >+ return Status.OK_STATUS; >+ } >+ }; >+ job.setPriority(Job.INTERACTIVE); >+ job.setUser(true); >+ job.schedule(); > } > } > >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ProtoFilterAction.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ProtoFilterAction.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ProtoFilterAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ProtoFilterAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.actions; >+ >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptProperty; >+import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptValue; >+import org.eclipse.wst.jsdt.debug.internal.ui.Constants; >+ >+/** >+ * Viewer filter action for <code>proto</code> variables >+ * >+ * @since 1.1 >+ */ >+public class ProtoFilterAction extends ViewFilterAction { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey() >+ */ >+ protected String getPreferenceKey() { >+ return Constants.SHOW_PROTOTYPES; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) >+ */ >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ if(element instanceof JavaScriptProperty){ >+ JavaScriptProperty var = (JavaScriptProperty) element; >+ if(JavaScriptValue.PROTO.equals(var.getName())) { >+ return getValue(); >+ } >+ } >+ return true; >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ShowLoadedScriptsAction.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ShowLoadedScriptsAction.java,v >retrieving revision 1.1 >diff -u -r1.1 ShowLoadedScriptsAction.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ShowLoadedScriptsAction.java 16 Mar 2010 20:09:05 -0000 1.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ShowLoadedScriptsAction.java 6 Sep 2011 16:36:41 -0000 >@@ -1,3 +1,13 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ > package org.eclipse.wst.jsdt.debug.internal.ui.actions; > > import org.eclipse.debug.ui.IDebugView; >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnAllScriptLoadsAction.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnAllScriptLoadsAction.java,v >retrieving revision 1.1 >diff -u -r1.1 SuspendOnAllScriptLoadsAction.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnAllScriptLoadsAction.java 3 Mar 2010 18:29:59 -0000 1.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnAllScriptLoadsAction.java 6 Sep 2011 16:36:41 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >+ * Copyright (c) 2010, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -15,6 +15,7 @@ > import org.eclipse.core.runtime.preferences.IEclipsePreferences; > import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.wst.jsdt.debug.internal.core.Constants; > import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin; >@@ -28,7 +29,6 @@ > */ > public class SuspendOnAllScriptLoadsAction extends ViewFilterAction { > >- > /* (non-Javadoc) > * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey() > */ >@@ -47,7 +47,7 @@ > * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) > */ > public void run(IAction action) { >- IEclipsePreferences prefs = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID); >+ IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID); > if(prefs != null) { > prefs.putBoolean(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, getValue()); > try { >@@ -59,6 +59,13 @@ > } > > /* (non-Javadoc) >+ * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceStore() >+ */ >+ protected IPreferenceStore getPreferenceStore() { >+ return JavaScriptDebugUIPlugin.getCorePreferenceStore(); >+ } >+ >+ /* (non-Javadoc) > * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceValue() > */ > protected boolean getPreferenceValue() { >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnExceptionsAction.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnExceptionsAction.java,v >retrieving revision 1.1 >diff -u -r1.1 SuspendOnExceptionsAction.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnExceptionsAction.java 11 May 2010 22:01:42 -0000 1.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/SuspendOnExceptionsAction.java 6 Sep 2011 16:36:41 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >+ * Copyright (c) 2010, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -14,9 +14,8 @@ > import org.eclipse.core.runtime.preferences.IEclipsePreferences; > import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.action.IAction; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.ui.IViewActionDelegate; >-import org.eclipse.ui.IViewPart; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.viewers.Viewer; > import org.eclipse.wst.jsdt.debug.internal.core.Constants; > import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin; > import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >@@ -27,17 +26,15 @@ > * > * @since 1.1 > */ >-public class SuspendOnExceptionsAction implements IViewActionDelegate { >- >- boolean initialized = false; >+public class SuspendOnExceptionsAction extends ViewFilterAction { > > /* (non-Javadoc) > * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) > */ > public void run(IAction action) { >- IEclipsePreferences prefs = new InstanceScope().getNode(JavaScriptDebugPlugin.PLUGIN_ID); >+ IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JavaScriptDebugPlugin.PLUGIN_ID); > if(prefs != null) { >- prefs.putBoolean(Constants.SUSPEN_ON_THROWN_EXCEPTION, action.isChecked()); >+ prefs.putBoolean(Constants.SUSPEND_ON_THROWN_EXCEPTION, action.isChecked()); > try { > prefs.flush(); > } catch (BackingStoreException e) { >@@ -47,22 +44,34 @@ > } > > /* (non-Javadoc) >- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) >+ * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceStore() > */ >- public void selectionChanged(IAction action, ISelection selection) { >- if(!initialized) { >- boolean checked = Platform.getPreferencesService().getBoolean( >- JavaScriptDebugPlugin.PLUGIN_ID, >- Constants.SUSPEN_ON_THROWN_EXCEPTION, >- false, >- null); >- action.setChecked(checked); >- initialized = true; >- } >+ protected IPreferenceStore getPreferenceStore() { >+ return JavaScriptDebugUIPlugin.getCorePreferenceStore(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceValue() >+ */ >+ protected boolean getPreferenceValue() { >+ return Platform.getPreferencesService().getBoolean( >+ JavaScriptDebugPlugin.PLUGIN_ID, >+ Constants.SUSPEND_ON_THROWN_EXCEPTION, >+ false, >+ null); > } > > /* (non-Javadoc) >- * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) >+ * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey() > */ >- public void init(IViewPart view) {} >+ protected String getPreferenceKey() { >+ return Constants.SUSPEND_ON_THROWN_EXCEPTION; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) >+ */ >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ return false; >+ } > } >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ThisFilterAction.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ThisFilterAction.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ThisFilterAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ThisFilterAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.actions; >+ >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptValue; >+import org.eclipse.wst.jsdt.debug.internal.core.model.JavaScriptVariable; >+import org.eclipse.wst.jsdt.debug.internal.ui.Constants; >+ >+/** >+ * Viewer filter action for the <code>this</code> variable >+ * >+ * @since 1.1 >+ */ >+public class ThisFilterAction extends ViewFilterAction { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.jsdt.debug.internal.ui.actions.ViewFilterAction#getPreferenceKey() >+ */ >+ protected String getPreferenceKey() { >+ return Constants.SHOW_THIS; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) >+ */ >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ if(element instanceof JavaScriptVariable){ >+ JavaScriptVariable var = (JavaScriptVariable) element; >+ if(JavaScriptValue.THIS.equals(var.getName())) { >+ return getValue(); >+ } >+ } >+ return true; >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ViewFilterAction.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ViewFilterAction.java,v >retrieving revision 1.1 >diff -u -r1.1 ViewFilterAction.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ViewFilterAction.java 3 Mar 2010 18:29:59 -0000 1.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/actions/ViewFilterAction.java 6 Sep 2011 16:36:41 -0000 >@@ -107,8 +107,7 @@ > viewer.refresh(); > } > IPreferenceStore store = getPreferenceStore(); >- String key = getView().getSite().getId() + "." + getPreferenceKey(); //$NON-NLS-1$ >- store.setValue(key, action.isChecked()); >+ store.setValue(getPreferenceKey(), action.isChecked()); > } > > /* (non-Javadoc) >@@ -132,15 +131,8 @@ > * @return boolean > */ > protected boolean getPreferenceValue() { >- String key = getCompositeKey(); > IPreferenceStore store = getPreferenceStore(); >- boolean value = false; >- if (store.contains(key)) { >- value = store.getBoolean(key); >- } else { >- value = store.getBoolean(getPreferenceKey()); >- } >- return value; >+ return store.getBoolean(getPreferenceKey()); > } > > /** >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAdapterFactory.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAdapterFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 JavaScriptAdapterFactory.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAdapterFactory.java 16 Mar 2010 20:09:05 -0000 1.3 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAdapterFactory.java 6 Sep 2011 16:36:41 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.core.runtime.IAdapterFactory; > import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider; > import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory2; >+import org.eclipse.debug.ui.actions.IRunToLineTarget; > import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.ui.model.IWorkbenchAdapter; >@@ -22,6 +23,7 @@ > import org.eclipse.wst.jsdt.debug.core.model.IScriptGroup; > import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; > import org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.ToggleBreakpointAdapter; >+import org.eclipse.wst.jsdt.debug.internal.ui.eval.RunToLineAdapter; > > /** > * Adapter factory >@@ -73,6 +75,7 @@ > static ToggleBreakpointAdapter tbadapter = null; > static JavaScriptAsyncContentProvider jscontent = null; > static JavaScriptModelProxyFactory jsproxyfactory = null; >+ static RunToLineAdapter runtoline = null; > > /* > * (non-Javadoc) >@@ -86,6 +89,9 @@ > if(adapterType.equals(IWorkbenchAdapter.class) && adaptableObject instanceof IJavaScriptBreakpoint) { > return getWorkbenchAdapter(); > } >+ if(adapterType.equals(IRunToLineTarget.class)) { >+ return getRunToLine(); >+ } > if (adapterType.equals(IElementContentProvider.class)) { > if (adaptableObject instanceof IJavaScriptDebugTarget || > adaptableObject instanceof IScriptGroup) { >@@ -105,12 +111,23 @@ > */ > public Class[] getAdapterList() { > return new Class[] {IToggleBreakpointsTarget.class, >- IWorkbenchAdapter.class, >+ IWorkbenchAdapter.class, >+ IRunToLineTarget.class, > IElementContentProvider.class, > IModelProxyFactory2.class}; > } > > /** >+ * @return the singleton {@link RunToLineAdapter} >+ */ >+ synchronized RunToLineAdapter getRunToLine() { >+ if(runtoline == null) { >+ runtoline = new RunToLineAdapter(); >+ } >+ return runtoline; >+ } >+ >+ /** > * @return the singleton {@link JavaScriptModelProxyFactory} > */ > synchronized JavaScriptModelProxyFactory getJSProxyFactory() { >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAsyncContentProvider.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAsyncContentProvider.java,v >retrieving revision 1.3.2.1 >diff -u -r1.3.2.1 JavaScriptAsyncContentProvider.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAsyncContentProvider.java 1 Oct 2010 14:03:35 -0000 1.3.2.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptAsyncContentProvider.java 6 Sep 2011 16:36:41 -0000 >@@ -1,3 +1,13 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ > package org.eclipse.wst.jsdt.debug.internal.ui.adapters; > > import java.util.List; >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptDebugTargetEventHandler.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptDebugTargetEventHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 JavaScriptDebugTargetEventHandler.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptDebugTargetEventHandler.java 17 Mar 2010 20:21:30 -0000 1.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/adapters/JavaScriptDebugTargetEventHandler.java 6 Sep 2011 16:36:41 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptDebugTarget; > import org.eclipse.wst.jsdt.debug.core.model.IScriptGroup; > import org.eclipse.wst.jsdt.debug.internal.core.model.ScriptGroup; >+import org.eclipse.wst.jsdt.debug.internal.ui.PreferencesManager; > > /** > * Custom handler for JavaScript debug target model proxy events >@@ -45,6 +46,81 @@ > } > > /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleChange(org.eclipse.debug.core.DebugEvent) >+ */ >+ protected void handleChange(DebugEvent event) { >+ Object source = event.getSource(); >+ if(source instanceof IDebugTarget) { >+ super.handleChange(event); >+ } >+ else if(source instanceof IScriptGroup) { >+ if(PreferencesManager.getManager().showLoadedScripts()) { >+ fireScriptGroupDelta((IScriptGroup) source); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleCreate(org.eclipse.debug.core.DebugEvent) >+ */ >+ protected void handleCreate(DebugEvent event) { >+ Object source = event.getSource(); >+ if(source instanceof IDebugTarget) { >+ super.handleCreate(event); >+ } >+ else if(source instanceof IScriptGroup) { >+ if(PreferencesManager.getManager().showLoadedScripts()) { >+ fireScriptGroupDelta((IScriptGroup) source); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleResume(org.eclipse.debug.core.DebugEvent) >+ */ >+ protected void handleResume(DebugEvent event) { >+ Object source = event.getSource(); >+ if(source instanceof IDebugTarget) { >+ super.handleResume(event); >+ } >+ else if(source instanceof IScriptGroup) { >+ if(PreferencesManager.getManager().showLoadedScripts()) { >+ fireScriptGroupDelta((IScriptGroup) source); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleSuspend(org.eclipse.debug.core.DebugEvent) >+ */ >+ protected void handleSuspend(DebugEvent event) { >+ Object source = event.getSource(); >+ if(source instanceof IDebugTarget) { >+ super.handleSuspend(event); >+ } >+ else if(source instanceof IScriptGroup) { >+ if(PreferencesManager.getManager().showLoadedScripts()) { >+ fireScriptGroupDelta((IScriptGroup) source); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.viewers.update.DebugTargetEventHandler#handleTerminate(org.eclipse.debug.core.DebugEvent) >+ */ >+ protected void handleTerminate(DebugEvent event) { >+ Object source = event.getSource(); >+ if(source instanceof IDebugTarget) { >+ super.handleTerminate(event); >+ } >+ else if(source instanceof IScriptGroup){ >+ if(PreferencesManager.getManager().showLoadedScripts()) { >+ fireScriptGroupDelta((IScriptGroup) source); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) > * @see org.eclipse.debug.internal.ui.viewers.update.DebugEventHandler#handleOther(org.eclipse.debug.core.DebugEvent) > */ > protected void handleOther(DebugEvent event) { >@@ -53,7 +129,9 @@ > super.handleOther(event); > } > else if(source instanceof IScriptGroup){ >- fireScriptGroupDelta((IScriptGroup) source); >+ if(PreferencesManager.getManager().showLoadedScripts()) { >+ fireScriptGroupDelta((IScriptGroup) source); >+ } > } > } > >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointPropertyPage.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointPropertyPage.java,v >retrieving revision 1.3 >diff -u -r1.3 JavaScriptBreakpointPropertyPage.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointPropertyPage.java 22 Mar 2010 16:55:33 -0000 1.3 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointPropertyPage.java 6 Sep 2011 16:36:41 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >+ * Copyright (c) 2010, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -190,14 +190,15 @@ > protected void createLabels(Composite parent) { > Composite labelComposite = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL); > try { >- String name = getBreakpoint().getTypeName(); >+ IJavaScriptBreakpoint bp = getBreakpoint(); >+ String name = bp.getTypeName(); > if (name != null) { > SWTFactory.createLabel(labelComposite, Messages.type_name, 1); > Text text = SWTFactory.createText(labelComposite, SWT.READ_ONLY | SWT.SINGLE, 1, GridData.FILL_HORIZONTAL); > text.setText(name); > text.setBackground(parent.getBackground()); > } >- name = getBreakpoint().getScriptPath(); >+ name = bp.getScriptPath(); > if(name != null) { > SWTFactory.createLabel(labelComposite, Messages.script_path, 1); > Text text = SWTFactory.createText(labelComposite, SWT.READ_ONLY, 1, GridData.FILL_HORIZONTAL); >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointUpdater.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointUpdater.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointUpdater.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/JavaScriptBreakpointUpdater.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,196 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.breakpoints; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IMarker; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.IBreakpointManager; >+import org.eclipse.debug.core.model.IBreakpoint; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.Position; >+import org.eclipse.ui.texteditor.IMarkerUpdater; >+import org.eclipse.ui.texteditor.MarkerUtilities; >+import org.eclipse.wst.jsdt.core.IJavaScriptUnit; >+import org.eclipse.wst.jsdt.core.JavaScriptCore; >+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit; >+import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpoint; >+import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint; >+import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin; >+import org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider; >+ >+/** >+ * A marker updater for {@link IJavaScriptBreakpoint}s >+ * >+ * @since 1.1 >+ */ >+public class JavaScriptBreakpointUpdater implements IMarkerUpdater { >+ >+ /** >+ * Constructor >+ */ >+ public JavaScriptBreakpointUpdater() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.texteditor.IMarkerUpdater#getMarkerType() >+ */ >+ public String getMarkerType() { >+ return IJavaScriptBreakpoint.MARKER_ID; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.texteditor.IMarkerUpdater#getAttribute() >+ */ >+ public String[] getAttribute() { >+ return new String[] {IMarker.LINE_NUMBER}; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.texteditor.IMarkerUpdater#updateMarker(org.eclipse.core.resources.IMarker, org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position) >+ */ >+ public boolean updateMarker(IMarker marker, IDocument document, Position position) { >+ if(position.isDeleted()) { >+ return false; >+ } >+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); >+ IBreakpoint breakpoint = manager.getBreakpoint(marker); >+ if(breakpoint == null) { >+ return false; >+ } >+ IJavaScriptUnit unit = JavaScriptCore.createCompilationUnitFrom((IFile) marker.getResource()); >+ if(unit == null) { >+ return false; >+ } >+ JavaScriptUnit jsunit = JavaScriptPlugin.getDefault().getASTProvider().getAST(unit, ASTProvider.WAIT_YES, null); >+ try { >+ BreakpointLocationFinder finder = new BreakpointLocationFinder(jsunit, document.getLineOfOffset(position.getOffset())+1, true); >+ jsunit.accept(finder); >+ if(finder.getLocation() == BreakpointLocationFinder.UNKNOWN) { >+ return false; >+ } >+ int line = finder.getLineNumber(); >+ if(MarkerUtilities.getLineNumber(marker) == line) { >+ //if there exists a breakpoint on the line remove this one >+ if(isLineBreakpoint(marker)) { >+ ensureRanges(document, marker, line); >+ return lineBreakpointExists(marker.getResource(), ((IJavaScriptLineBreakpoint)breakpoint).getScriptPath(), line, marker, true) == null; >+ } >+ return true; >+ } >+ if(isLineBreakpoint(marker) & line == -1) { >+ return false; >+ } >+ if(lineBreakpointExists(marker.getResource(), ((IJavaScriptLineBreakpoint)breakpoint).getScriptPath(), line, marker, false) != null) { >+ return false; >+ } >+ MarkerUtilities.setLineNumber(marker, line); >+ if(isLineBreakpoint(marker)) { >+ ensureRanges(document, marker, line); >+ } >+ return true; >+ } >+ catch(BadLocationException ble) { >+ JavaScriptDebugUIPlugin.log(ble); >+ } catch (CoreException e) { >+ JavaScriptDebugUIPlugin.log(e); >+ } >+ return false; >+ } >+ >+ /** >+ * Returns if the given marker is of the type {@link IJavaScriptLineBreakpoint#MARKER_ID} >+ * @param marker >+ * @return true if the marker is a {@link IJavaScriptLineBreakpoint} marker >+ */ >+ boolean isLineBreakpoint(IMarker marker) { >+ return MarkerUtilities.isMarkerType(marker, IJavaScriptLineBreakpoint.MARKER_ID); >+ } >+ >+ /** >+ * Corrects the {@link IMarker#CHAR_START} and {@link IMarker#CHAR_END} values as needed >+ * >+ * @param document >+ * @param marker >+ * @param line >+ * @throws BadLocationException >+ */ >+ void ensureRanges(IDocument document, IMarker marker, int line) throws BadLocationException { >+ if(line < 0 || line > document.getNumberOfLines()) { >+ return; >+ } >+ IRegion region = document.getLineInformation(line - 1); >+ int charstart = region.getOffset(); >+ int charend = charstart + region.getLength(); >+ MarkerUtilities.setCharStart(marker, charstart); >+ MarkerUtilities.setCharEnd(marker, charend); >+ } >+ >+ /** >+ * Looks up the {@link IJavaScriptLineBreakpoint} that is associated with the given marker. Returns <code>null</code> if one >+ * does not exist >+ * >+ * @param resource >+ * @param typeName >+ * @param lineNumber >+ * @param currentmarker >+ * @param useid if the id of the markers should be compared >+ * @return the {@link IJavaScriptLineBreakpoint} for the given marker or <code>null</code> if one does not exist >+ * @throws CoreException >+ */ >+ IJavaScriptLineBreakpoint lineBreakpointExists(IResource resource, String typeName, int lineNumber, IMarker currentmarker, boolean useid) throws CoreException { >+ String modelId = JavaScriptDebugModel.MODEL_ID; >+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); >+ IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); >+ for (int i = 0; i < breakpoints.length; i++) { >+ if ((breakpoints[i] instanceof IJavaScriptLineBreakpoint)) { >+ IJavaScriptLineBreakpoint breakpoint = (IJavaScriptLineBreakpoint) breakpoints[i]; >+ if(breakpoint.getLineNumber() == lineNumber) { >+ IMarker marker = breakpoint.getMarker(); >+ if (marker != null && >+ marker.exists() && >+ marker.getType().equals(IJavaScriptLineBreakpoint.MARKER_ID) && >+ pathsEqual(breakpoint.getScriptPath(), typeName) && >+ resource.equals(marker.getResource())) { >+ if(useid) { >+ if(currentmarker.getId() != marker.getId()) { >+ return breakpoint; >+ } >+ return null; >+ } >+ return breakpoint; >+ } >+ } >+ >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Returns if n1 equals n2, where both being <code>null</code> is also considered equal >+ * @param n1 >+ * @param n2 >+ * @return >+ */ >+ boolean pathsEqual(String n1, String n2) { >+ if(n1 == null) { >+ return n2 == null; >+ } >+ return n1.equals(n2); >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/Messages.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/Messages.java,v >retrieving revision 1.4.2.1 >diff -u -r1.4.2.1 Messages.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/Messages.java 23 Mar 2011 19:55:06 -0000 1.4.2.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/Messages.java 6 Sep 2011 16:36:42 -0000 >@@ -27,6 +27,10 @@ > public static String enter_condition; > public static String entry; > public static String exit; >+ public static String failed_function_bp_no_element; >+ public static String failed_function_bp_no_resource; >+ public static String failed_line_bp_no_element; >+ public static String failed_line_bp_no_resource; > public static String failed_to_create_function_bp; > public static String failed_to_create_line_bp; > public static String fuction; >@@ -38,6 +42,7 @@ > public static String line_breakpoint_settings; > public static String line_number; > public static String member; >+ public static String no_editor_could_be_found; > public static String no_valid_location; > public static String script_load_bp; > public static String script_load_breakpoint; >@@ -47,6 +52,7 @@ > public static String suspend_when_changed; > public static String suspend_when_true; > public static String type_name; >+ public static String type_root_could_not_be_computed; > static { > // initialize resource bundle > NLS.initializeMessages(BUNDLE_NAME, Messages.class); >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/ToggleBreakpointAdapter.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/ToggleBreakpointAdapter.java,v >retrieving revision 1.9.2.1 >diff -u -r1.9.2.1 ToggleBreakpointAdapter.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/ToggleBreakpointAdapter.java 19 Oct 2010 20:24:35 -0000 1.9.2.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/ToggleBreakpointAdapter.java 6 Sep 2011 16:36:42 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >+ * Copyright (c) 2010, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -13,6 +13,7 @@ > import java.util.HashMap; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IMarker; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; >@@ -31,6 +32,7 @@ > import org.eclipse.jface.text.TextSelection; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IEditorPart; >@@ -46,18 +48,17 @@ > import org.eclipse.wst.jsdt.core.ISourceRange; > import org.eclipse.wst.jsdt.core.IType; > import org.eclipse.wst.jsdt.core.ITypeRoot; >-import org.eclipse.wst.jsdt.core.dom.AST; >-import org.eclipse.wst.jsdt.core.dom.ASTParser; > import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit; > import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptBreakpoint; > import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptFunctionBreakpoint; > import org.eclipse.wst.jsdt.debug.core.breakpoints.IJavaScriptLineBreakpoint; > import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel; >-import org.eclipse.wst.jsdt.debug.internal.core.JavaScriptDebugPlugin; > import org.eclipse.wst.jsdt.debug.internal.ui.DebugWCManager; >+import org.eclipse.wst.jsdt.internal.ui.JavaScriptPlugin; >+import org.eclipse.wst.jsdt.internal.ui.javaeditor.ASTProvider; > > /** >- * Javascript adapter for toggling breakpoints in the JSDT editor >+ * JavaScript adapter for toggling breakpoints in the JSDT editor > * > * @since 1.0 > */ >@@ -90,10 +91,14 @@ > ITextEditor editor = getTextEditor(part); > if(editor != null && part instanceof IEditorPart) { > if(element == null) { >- reportToStatusLine(part, Messages.failed_to_create_line_bp); >+ reportToStatusLine(part, Messages.failed_line_bp_no_element); >+ return Status.CANCEL_STATUS; >+ } >+ IResource resource = element.getResource(); >+ if(resource == null) { >+ reportToStatusLine(part, NLS.bind(Messages.failed_line_bp_no_resource, element.getElementName())); > return Status.CANCEL_STATUS; > } >- IResource resource = getBreakpointResource(element); > IBreakpoint bp = lineBreakpointExists(resource, linenumber); > if(bp != null) { > DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true); >@@ -135,44 +140,8 @@ > * @return the path to the script > */ > String getScriptPath(IJavaScriptElement element) { >- IPath path = getElementScriptPath(element).makeRelative(); >- if(JavaScriptDebugPlugin.isExternalSource(path)) { >- String extpath = (JavaScriptDebugPlugin.getExternalScriptPath(path.removeFirstSegments(1))); >- if(extpath != null) { >- return extpath; >- } >- } >- return path.toString(); >- } >- >- private IPath getElementScriptPath(IJavaScriptElement element) { >- switch (element.getElementType()) { >- case IJavaScriptElement.TYPE: { >- return ((IType) element).getPath(); >- } >- case IJavaScriptElement.METHOD: >- case IJavaScriptElement.FIELD: { >- IMember member = (IMember) element; >- IType type = member.getDeclaringType(); >- if (type == null) { >- IJavaScriptElement parent = element.getParent(); >- switch (parent.getElementType()) { >- case IJavaScriptElement.TYPE: { >- return ((IType) parent).getPath(); >- } >- case IJavaScriptElement.JAVASCRIPT_UNIT: >- case IJavaScriptElement.CLASS_FILE: { >- return ((ITypeRoot) parent).getPath(); >- } >- } >- return element.getParent().getPath(); >- } >- return type.getPath(); >- } >- default: { >- return element.getPath(); >- } >- } >+ IPath path = element.getPath(); >+ return path.makeAbsolute().toString(); > } > > /** >@@ -282,18 +251,23 @@ > * Delegate for toggling a method breakpoint > * @param part > * @param element >+ * @param line > */ >- void toggleMethodBreakpoint(final IWorkbenchPart part, final IJavaScriptElement element) { >+ void toggleMethodBreakpoint(final IWorkbenchPart part, final IJavaScriptElement element, final int line) { > Job job = new Job("Toggle Function Breakpoints") { //$NON-NLS-1$ > protected IStatus run(IProgressMonitor monitor) { > try { > if(element == null) { >- reportToStatusLine(part, Messages.failed_to_create_function_bp); >+ reportToStatusLine(part, Messages.failed_function_bp_no_element); > return Status.CANCEL_STATUS; > } > if(element.getElementType() == IJavaScriptElement.METHOD) { > IFunction method = (IFunction) element; >- IResource resource = getBreakpointResource(element); >+ IResource resource = element.getResource(); >+ if(resource == null) { >+ reportToStatusLine(part, NLS.bind(Messages.failed_function_bp_no_resource, element.getElementName())); >+ return Status.CANCEL_STATUS; >+ } > IBreakpoint bp = methodBreakpointExists(resource, method.getElementName(), method.getSignature()); > if(bp != null) { > DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(bp, true); >@@ -310,6 +284,7 @@ > //nothing else we can do > attributes.put(IJavaScriptBreakpoint.TYPE_NAME, getTypeName(element)); > attributes.put(IJavaScriptBreakpoint.SCRIPT_PATH, getScriptPath(element)); >+ attributes.put(IMarker.LINE_NUMBER, new Integer(line)); > IJavaScriptFunctionBreakpoint breakpoint = JavaScriptDebugModel.createFunctionBreakpoint(resource, method.getElementName(), method.getSignature(), start, end, attributes, true); > breakpoint.setJavaScriptElementHandle(element.getHandleIdentifier()); > return Status.OK_STATUS; >@@ -373,7 +348,7 @@ > if(selection instanceof ITextSelection) { > ITextEditor textEditor = getTextEditor(part); > if(textEditor == null) { >- reportToStatusLine(part, Messages.no_valid_location); >+ reportToStatusLine(part, Messages.no_editor_could_be_found); > return; > } > ITypeRoot root = getTypeRoot(textEditor.getEditorInput()); >@@ -384,12 +359,10 @@ > } > } > if(root == null) { >- reportToStatusLine(part, Messages.no_valid_location); >+ reportToStatusLine(part, Messages.type_root_could_not_be_computed); > return; > } >- ASTParser parser = ASTParser.newParser(AST.JLS3); >- parser.setSource(root); >- JavaScriptUnit jsunit = (JavaScriptUnit) parser.createAST(null); >+ JavaScriptUnit jsunit = JavaScriptPlugin.getDefault().getASTProvider().getAST(root, ASTProvider.WAIT_YES, null); > BreakpointLocationFinder finder = new BreakpointLocationFinder(jsunit, ((TextSelection)selection).getStartLine()+1, false); > jsunit.accept(finder); > switch(finder.getLocation()) { >@@ -406,7 +379,7 @@ > return; > } > case BreakpointLocationFinder.FUNCTION: { >- toggleMethodBreakpoint(part, root.getElementAt(finder.getOffset())); >+ toggleMethodBreakpoint(part, root.getElementAt(finder.getOffset()), finder.getLineNumber()); > return; > } > } >@@ -417,7 +390,7 @@ > if(o instanceof IMember) { > IMember member = (IMember) o; > if(member.getElementType() == IJavaScriptElement.METHOD) { >- toggleMethodBreakpoint(part, member); >+ toggleMethodBreakpoint(part, member, -1); > } > } > } >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/messages.properties >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/messages.properties,v >retrieving revision 1.4.2.1 >diff -u -r1.4.2.1 messages.properties >--- src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/messages.properties 23 Mar 2011 19:55:06 -0000 1.4.2.1 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/breakpoints/messages.properties 6 Sep 2011 16:36:42 -0000 >@@ -18,6 +18,10 @@ > enter_condition=Enter a condition > entry=E&ntry > exit=E&xit >+failed_function_bp_no_element=Failed to create Javascript function breakpoint - the JavaScript element could not be computed >+failed_function_bp_no_resource=Failed to create Javascript function breakpoint - the resource could no be computed for {0} >+failed_line_bp_no_element=Failed to create Javascript line breakpoint - the JavaScript element could not be computed >+failed_line_bp_no_resource=Failed to create Javascript line breakpoint - the resource could no be computed for {0} > failed_to_create_function_bp=Failed to create Javascript function breakpoint > failed_to_create_line_bp=Failed to create Javascript line breakpoint > fuction=F&unction >@@ -29,6 +33,7 @@ > line_breakpoint_settings=Line Breakpoint Settings > line_number=&Line Number: > member=&Member: >+no_editor_could_be_found=No editor could be found for the associated part > no_valid_location=A valid location could not be found for the breakpoint > script_load_bp=Script Load Breakpoint > script_load_breakpoint=Script Load Breakpoint >@@ -38,3 +43,4 @@ > suspend_when_changed=Suspend &when value changes > suspend_when_true=Suspend when 'tr&ue' > type_name=&Type Name: >+type_root_could_not_be_computed=The type root could not be computed for the editor >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/EvaluationManager.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/EvaluationManager.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/EvaluationManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/EvaluationManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,273 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.List; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.contexts.DebugContextEvent; >+import org.eclipse.debug.ui.contexts.IDebugContextListener; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ui.IWindowListener; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+ >+/** >+ * Manager to handle contexts for evaluations >+ * >+ * @since 1.0 >+ */ >+public class EvaluationManager implements IDebugContextListener, IWindowListener { >+ >+ /** >+ * System property used to know if the debugger is active or not >+ */ >+ public static final String DEBUGGER_ACTIVE = JavaScriptDebugUIPlugin.PLUGIN_ID + ".jsdebuggerActive"; //$NON-NLS-1$ >+ >+ private static EvaluationManager instance = null; >+ >+ private IWorkbenchWindow activewindow = null; >+ private HashMap contextmap = null; >+ >+ /** >+ * Constructor >+ */ >+ private EvaluationManager() { >+ //no instantiation >+ DebugUITools.getDebugContextManager().addDebugContextListener(this); >+ } >+ >+ /** >+ * Returns the singleton instance >+ * >+ * @return the instance >+ */ >+ public static synchronized EvaluationManager getManager() { >+ if(instance == null) { >+ instance = new EvaluationManager(); >+ } >+ return instance; >+ } >+ >+ /** >+ * Start the manager >+ */ >+ public void start() { >+ IWorkbench workbench = PlatformUI.getWorkbench(); >+ IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); >+ for (int i = 0; i < windows.length; i++) { >+ instance.windowOpened(windows[i]); >+ } >+ workbench.addWindowListener(this); >+ instance.activewindow = workbench.getActiveWorkbenchWindow(); >+ } >+ >+ /** >+ * Stop the manager and un-hook it as listeners >+ */ >+ public void stop() { >+ DebugUITools.getDebugContextManager().removeDebugContextListener(this); >+ PlatformUI.getWorkbench().removeWindowListener(this); >+ } >+ >+ /** >+ * Returns the evaluation context for the given window, or <code>null</code> if none. >+ * The evaluation context corresponds to the selected stack frame in the following >+ * priority order:<ol> >+ * <li>stack frame in active page of the window</li> >+ * <li>stack frame in another page of the window</li> >+ * <li>stack frame in active page of another window</li> >+ * <li>stack frame in a page of another window</li> >+ * </ol> >+ * >+ * @param window the window that the evaluation action was invoked from, or >+ * <code>null</code> if the current window should be consulted >+ * @return the stack frame that supplies an evaluation context, or <code>null</code> >+ * if none >+ * @return IJavaStackFrame >+ */ >+ public IJavaScriptStackFrame getEvaluationContext(IWorkbenchWindow window) { >+ List otherwindows = new ArrayList(); >+ if (window == null) { >+ return getEvaluationContext(activewindow, otherwindows); >+ } >+ return getEvaluationContext(window, otherwindows); >+ } >+ >+ /** >+ * Returns the evaluation context for the given part, or <code>null</code> if none. >+ * The evaluation context corresponds to the selected stack frame in the following >+ * priority order:<ol> >+ * <li>stack frame in the same page</li> >+ * <li>stack frame in the same window</li> >+ * <li>stack frame in active page of other window</li> >+ * <li>stack frame in page of other windows</li> >+ * </ol> >+ * >+ * @param part the part that the evaluation action was invoked from >+ * @return the stack frame that supplies an evaluation context, or <code>null</code> >+ * if none >+ */ >+ public IJavaScriptStackFrame getEvaluationContext(IWorkbenchPart part) { >+ IWorkbenchPage page = part.getSite().getPage(); >+ IJavaScriptStackFrame frame = getContext(page); >+ if (frame == null) { >+ return getEvaluationContext(page.getWorkbenchWindow()); >+ } >+ return frame; >+ } >+ >+ /** >+ * Looks up the current evaluation context for the given window. Tries all workbench windows >+ * if the active window does not have a context >+ * >+ * @param window the window to look in >+ * @param otherwindows a listing of all other windows to try if the given window does not have a context >+ * @return the evaluation context or <code>null</code> >+ */ >+ IJavaScriptStackFrame getEvaluationContext(IWorkbenchWindow window, List otherwindows) { >+ IWorkbenchPage activePage = window.getActivePage(); >+ IJavaScriptStackFrame frame = null; >+ if (activePage != null) { >+ frame = getContext(activePage); >+ } >+ if (frame == null) { >+ IWorkbenchPage[] pages = window.getPages(); >+ for (int i = 0; i < pages.length; i++) { >+ if (activePage != pages[i]) { >+ frame = getContext(pages[i]); >+ if (frame != null) { >+ return frame; >+ } >+ } >+ } >+ otherwindows.add(window); >+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); >+ for (int i = 0; i < windows.length; i++) { >+ if (!otherwindows.contains(windows[i])) { >+ frame = getEvaluationContext(windows[i], otherwindows); >+ if (frame != null) { >+ return frame; >+ } >+ } >+ } >+ return null; >+ } >+ return frame; >+ } >+ >+ /** >+ * Looks up a context for the given page. Returns <code>null</code> if no mapping is found >+ * or if the context map has not been initialized >+ * >+ * @param page the page to look up a context for >+ * >+ * @return the {@link IJavaScriptStackFrame} context for the given page or <code>null</code> >+ */ >+ IJavaScriptStackFrame getContext(IWorkbenchPage page) { >+ if (contextmap != null) { >+ return (IJavaScriptStackFrame)contextmap.get(page); >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent) >+ */ >+ public void debugContextChanged(DebugContextEvent event) { >+ if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { >+ IWorkbenchPart part = event.getDebugContextProvider().getPart(); >+ if (part != null) { >+ IWorkbenchPage page = part.getSite().getPage(); >+ ISelection selection = event.getContext(); >+ if (selection instanceof IStructuredSelection) { >+ IStructuredSelection ss = (IStructuredSelection)selection; >+ if (ss.size() == 1) { >+ Object element = ss.getFirstElement(); >+ if (element instanceof IAdaptable) { >+ IJavaScriptStackFrame frame = (IJavaScriptStackFrame)((IAdaptable)element).getAdapter(IJavaScriptStackFrame.class); >+ if (frame != null) { >+ setContext(page, frame); >+ return; >+ } >+ } >+ } >+ } >+ // no context in the given view >+ removeContext(page); >+ } >+ } >+ } >+ >+ /** >+ * Sets the evaluation context for the given page, and notes that >+ * a valid execution context exists. >+ * >+ * @param page >+ * @param frame >+ */ >+ private synchronized void setContext(IWorkbenchPage page, IJavaScriptStackFrame frame) { >+ if (contextmap == null) { >+ contextmap = new HashMap(); >+ } >+ contextmap.put(page, frame); >+ System.setProperty(DEBUGGER_ACTIVE, "true"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Removes an evaluation context for the given page, and determines if >+ * any valid execution context remain. >+ * >+ * @param page >+ */ >+ private void removeContext(IWorkbenchPage page) { >+ if (contextmap != null) { >+ contextmap.remove(page); >+ if (contextmap.isEmpty()) { >+ System.setProperty(DEBUGGER_ACTIVE, "false"); //$NON-NLS-1$ >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow) >+ */ >+ public void windowActivated(IWorkbenchWindow window) { >+ activewindow = window; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow) >+ */ >+ public void windowDeactivated(IWorkbenchWindow window) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow) >+ */ >+ public void windowClosed(IWorkbenchWindow window) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow) >+ */ >+ public void windowOpened(IWorkbenchWindow window) { >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/ExpressionInformationControlCreator.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/ExpressionInformationControlCreator.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/ExpressionInformationControlCreator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/ExpressionInformationControlCreator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,441 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.model.IVariable; >+import org.eclipse.debug.internal.ui.SWTFactory; >+import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider; >+import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; >+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; >+import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; >+import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener; >+import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext; >+import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer; >+import org.eclipse.debug.internal.ui.views.variables.details.DefaultDetailPane; >+import org.eclipse.debug.internal.ui.views.variables.details.DetailPaneProxy; >+import org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer; >+import org.eclipse.debug.ui.AbstractDebugView; >+import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.text.AbstractInformationControl; >+import org.eclipse.jface.text.IInformationControl; >+import org.eclipse.jface.text.IInformationControlCreator; >+import org.eclipse.jface.text.IInformationControlExtension2; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.StructuredViewer; >+import org.eclipse.jface.viewers.TreePath; >+import org.eclipse.jface.viewers.TreeSelection; >+import org.eclipse.jface.viewers.ViewerFilter; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.SashForm; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Layout; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPartSite; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+ >+/** >+ * Creates an information control to display an expression in a hover control. >+ * >+ * @since 1.1 >+ */ >+public class ExpressionInformationControlCreator implements IInformationControlCreator { >+ >+ class ExpressionInformationControl extends AbstractInformationControl implements IInformationControlExtension2 { >+ >+ /** >+ * Dialog setting key for height >+ */ >+ private static final String HEIGHT = "HEIGHT"; //$NON-NLS-1$ >+ >+ /** >+ * Dialog setting key for width. >+ */ >+ private static final String WIDTH = "WIDTH"; //$NON-NLS-1$ >+ >+ /** >+ * Dialog setting key for tree sash weight >+ */ >+ private static final String SASH_WEIGHT_TREE = "SashWeightTree"; //$NON-NLS-1$ >+ >+ /** >+ * Dialog setting key for details sash weight >+ */ >+ private static final String SASH_WEIGHT_DETAILS = "SashWeightDetails"; //$NON-NLS-1$ >+ >+ /** >+ * Variable to display. >+ */ >+ private IVariable fVariable; >+ >+ private IPresentationContext fContext; >+ private TreeModelViewer fViewer; >+ private SashForm fSashForm; >+ private Composite fDetailPaneComposite; >+ private DetailPaneProxy fDetailPane; >+ private Tree fTree; >+ >+ /** >+ * Creates the content for the root element of the tree viewer in the hover >+ */ >+ private class TreeRoot extends ElementContentProvider { >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#getChildCount(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext) >+ */ >+ protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { >+ return 1; >+ } >+ /* (non-Javadoc) >+ * @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) >+ */ >+ protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { >+ return new Object[] { fVariable }; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.elements.ElementContentProvider#supportsContextId(java.lang.String) >+ */ >+ protected boolean supportsContextId(String id) { >+ return true; >+ } >+ } >+ >+ /** >+ * Inner class implementing IDetailPaneContainer methods. Handles changes to detail >+ * pane and provides limited access to the detail pane proxy. >+ */ >+ private class DetailPaneContainer implements IDetailPaneContainer{ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getCurrentPaneID() >+ */ >+ public String getCurrentPaneID() { >+ return fDetailPane.getCurrentPaneID(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getCurrentSelection() >+ */ >+ public IStructuredSelection getCurrentSelection() { >+ return (IStructuredSelection)fViewer.getSelection(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#refreshDetailPaneContents() >+ */ >+ public void refreshDetailPaneContents() { >+ fDetailPane.display(getCurrentSelection()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getParentComposite() >+ */ >+ public Composite getParentComposite() { >+ return fDetailPaneComposite; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#getWorkbenchPartSite() >+ */ >+ public IWorkbenchPartSite getWorkbenchPartSite() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.views.variables.details.IDetailPaneContainer#paneChanged(java.lang.String) >+ */ >+ public void paneChanged(String newPaneID) { >+ if (newPaneID.equals(DefaultDetailPane.ID)){ >+ fDetailPane.getCurrentControl().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >+ } >+ } >+ >+ } >+ >+ /** >+ * Constructs a new control in the given shell. >+ * >+ * @param parentShell shell >+ * @param resize whether resize is supported >+ */ >+ ExpressionInformationControl(Shell parentShell, boolean resize) { >+ super(parentShell, resize); >+ create(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#computeSizeHint() >+ */ >+ public Point computeSizeHint() { >+ IDialogSettings settings = getDialogSettings(false); >+ if (settings != null) { >+ int x = getIntSetting(settings, WIDTH); >+ if (x > 0) { >+ int y = getIntSetting(settings, HEIGHT); >+ if (y > 0) { >+ return new Point(x,y); >+ } >+ } >+ } >+ return super.computeSizeHint(); >+ } >+ >+ /** >+ * Returns the dialog settings for this hover or <code>null</code> if none >+ * >+ * @param create whether to create the settings >+ */ >+ private IDialogSettings getDialogSettings(boolean create) { >+ IDialogSettings settings = JavaScriptDebugUIPlugin.getDefault().getDialogSettings(); >+ IDialogSettings section = settings.getSection(this.getClass().getName()); >+ if (section == null & create) { >+ section = settings.addNewSection(this.getClass().getName()); >+ } >+ return section; >+ } >+ >+ /** >+ * Returns an integer value in the given dialog settings or -1 if none. >+ * >+ * @param settings dialog settings >+ * @param key key >+ * @return value or -1 if not present >+ */ >+ private int getIntSetting(IDialogSettings settings, String key) { >+ try { >+ return settings.getInt(key); >+ } catch (NumberFormatException e) { >+ return -1; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#dispose() >+ */ >+ public void dispose() { >+ persistSettings(getShell()); >+ fContext.dispose(); >+ super.dispose(); >+ } >+ >+ /** >+ * Persists dialog settings. >+ * >+ * @param shell >+ */ >+ private void persistSettings(Shell shell) { >+ if (shell != null && !shell.isDisposed()) { >+ if (isResizable()) { >+ IDialogSettings settings = getDialogSettings(true); >+ Point size = shell.getSize(); >+ settings.put(WIDTH, size.x); >+ settings.put(HEIGHT, size.y); >+ int[] weights = fSashForm.getWeights(); >+ settings.put(SASH_WEIGHT_TREE, weights[0]); >+ settings.put(SASH_WEIGHT_DETAILS, weights[1]); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#setVisible(boolean) >+ */ >+ public void setVisible(boolean visible) { >+ if (!visible) { >+ persistSettings(getShell()); >+ } >+ super.setVisible(visible); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#createContent(org.eclipse.swt.widgets.Composite) >+ */ >+ protected void createContent(Composite parent) { >+ >+ fSashForm = new SashForm(parent, parent.getStyle()); >+ fSashForm.setOrientation(SWT.VERTICAL); >+ >+ // update presentation context >+ AbstractDebugView view = getViewToEmulate(); >+ fContext = new PresentationContext(IDebugUIConstants.ID_VARIABLE_VIEW); >+ if (view != null) { >+ // copy over properties >+ IPresentationContext copy = ((TreeModelViewer)view.getViewer()).getPresentationContext(); >+ String[] properties = copy.getProperties(); >+ for (int i = 0; i < properties.length; i++) { >+ String key = properties[i]; >+ fContext.setProperty(key, copy.getProperty(key)); >+ } >+ } >+ >+ fViewer = new TreeModelViewer(fSashForm, SWT.NO_TRIM | SWT.MULTI | SWT.VIRTUAL, fContext); >+ fViewer.setAutoExpandLevel(1); >+ >+ if (view != null) { >+ // copy over filters >+ StructuredViewer structuredViewer = (StructuredViewer) view.getViewer(); >+ if (structuredViewer != null) { >+ ViewerFilter[] filters = structuredViewer.getFilters(); >+ for (int i = 0; i < filters.length; i++) { >+ fViewer.addFilter(filters[i]); >+ } >+ } >+ } >+ >+ fDetailPaneComposite = SWTFactory.createComposite(fSashForm, 1, 1, GridData.FILL_BOTH); >+ Layout layout = fDetailPaneComposite.getLayout(); >+ if (layout instanceof GridLayout) { >+ GridLayout gl = (GridLayout) layout; >+ gl.marginHeight = 0; >+ gl.marginWidth = 0; >+ } >+ >+ fDetailPane = new DetailPaneProxy(new DetailPaneContainer()); >+ fDetailPane.display(null); // Bring up the default pane so the user doesn't see an empty composite >+ >+ fTree = fViewer.getTree(); >+ fTree.addSelectionListener(new SelectionListener() { >+ public void widgetSelected(SelectionEvent e) { >+ fDetailPane.display((IStructuredSelection)fViewer.getSelection()); >+ } >+ public void widgetDefaultSelected(SelectionEvent e) {} >+ }); >+ >+ initSashWeights(); >+ >+ // add update listener to auto-select and display details of root expression >+ fViewer.addViewerUpdateListener(new IViewerUpdateListener() { >+ public void viewerUpdatesComplete() { >+ } >+ public void viewerUpdatesBegin() { >+ } >+ public void updateStarted(IViewerUpdate update) { >+ } >+ public void updateComplete(IViewerUpdate update) { >+ if (update instanceof IChildrenUpdate) { >+ TreeSelection selection = new TreeSelection(new TreePath(new Object[]{fVariable})); >+ fViewer.setSelection(selection); >+ fDetailPane.display(selection); >+ fViewer.removeViewerUpdateListener(this); >+ } >+ } >+ }); >+ >+ setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); >+ } >+ >+ >+ /** >+ * Attempts to find an appropriate view to emulate, this will either be the >+ * variables view or the expressions view. >+ * @return a view to emulate or <code>null</code> >+ */ >+ private AbstractDebugView getViewToEmulate() { >+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >+ AbstractDebugView expressionsView = (AbstractDebugView) page.findView(IDebugUIConstants.ID_EXPRESSION_VIEW); >+ if (expressionsView != null && expressionsView.isVisible()) { >+ return expressionsView; >+ } >+ AbstractDebugView variablesView = (AbstractDebugView) page.findView(IDebugUIConstants.ID_VARIABLE_VIEW); >+ if (variablesView != null && variablesView.isVisible()) { >+ return variablesView; >+ } >+ if (expressionsView != null) { >+ return expressionsView; >+ } >+ return variablesView; >+ } >+ >+ /** >+ * Initializes the sash form weights from the preference store (using default values if >+ * no sash weights were stored previously). >+ */ >+ protected void initSashWeights(){ >+ IDialogSettings settings = getDialogSettings(false); >+ if (settings != null) { >+ int tree = getIntSetting(settings, SASH_WEIGHT_TREE); >+ if (tree > 0) { >+ int details = getIntSetting(settings, SASH_WEIGHT_DETAILS); >+ if (details > 0) { >+ fSashForm.setWeights(new int[]{tree, details}); >+ } >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#setBackgroundColor(org.eclipse.swt.graphics.Color) >+ */ >+ public void setBackgroundColor(Color background) { >+ super.setBackgroundColor(background); >+ fDetailPaneComposite.setBackground(background); >+ fTree.setBackground(background); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#setFocus() >+ */ >+ public void setFocus() { >+ super.setFocus(); >+ fTree.setFocus(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.IInformationControlExtension#hasContents() >+ */ >+ public boolean hasContents() { >+ return fVariable != null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object) >+ */ >+ public void setInput(Object input) { >+ if (input instanceof IVariable) { >+ fVariable = (IVariable) input; >+ fViewer.setInput(new TreeRoot()); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.AbstractInformationControl#getInformationPresenterControlCreator() >+ */ >+ public IInformationControlCreator getInformationPresenterControlCreator() { >+ return new ExpressionInformationControlCreator() { >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.debug.ui.ExpressionInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell) >+ */ >+ public IInformationControl createInformationControl(Shell shell) { >+ return new ExpressionInformationControl(shell, true); >+ } >+ }; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell) >+ */ >+ public IInformationControl createInformationControl(Shell parent) { >+ return new ExpressionInformationControl(parent, false); >+ } >+ >+ >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptDebugHover.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptDebugHover.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptDebugHover.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptDebugHover.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,193 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.model.IValue; >+import org.eclipse.debug.core.model.IVariable; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IInformationControlCreator; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextHoverExtension; >+import org.eclipse.jface.text.ITextHoverExtension2; >+import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptModelPresentation; >+import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder; >+import org.eclipse.wst.jsdt.ui.text.java.hover.IJavaEditorTextHover; >+ >+/** >+ * JavaScript hover to show variables >+ * >+ * @since 1.1 >+ */ >+public class JavaScriptDebugHover implements IJavaEditorTextHover, ITextHoverExtension, ITextHoverExtension2 { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) >+ */ >+ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { >+ Object object = getHoverInfo2(textViewer, hoverRegion); >+ if (object instanceof IVariable) { >+ IVariable var = (IVariable) object; >+ return getVariableText(var); >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int) >+ */ >+ public IRegion getHoverRegion(ITextViewer textViewer, int offset) { >+ return JavaWordFinder.findWord(textViewer.getDocument(), offset); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) >+ */ >+ public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { >+ IJavaScriptStackFrame frame = getFrame(); >+ if (frame != null) { >+ IDocument document = textViewer.getDocument(); >+ if (document != null) { >+ try { >+ String variableName = document.get(hoverRegion.getOffset(), hoverRegion.getLength()); >+ IVariable var = findLocalVariable(frame, variableName); >+ if(var != null) { >+ return var; >+ } >+ //might be in 'this' >+ var = frame.getThisObject(); >+ try { >+ IValue val = var.getValue(); >+ if(val != null) { >+ IVariable[] vars = val.getVariables(); >+ for (int i = 0; i < vars.length; i++) { >+ if(vars[i].getName().equals(variableName)) { >+ return vars[i]; >+ } >+ } >+ } >+ } >+ catch(DebugException de) { >+ return null; >+ } >+ >+ } catch (BadLocationException e) { >+ return null; >+ } >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Returns a local variable in the given frame based on the the given name >+ * or <code>null</code> if none. >+ * >+ * @return local variable or <code>null</code> >+ */ >+ private IVariable findLocalVariable(IJavaScriptStackFrame frame, String variableName) { >+ if (frame != null) { >+ try { >+ IVariable[] vars = frame.getVariables(); >+ for (int i = 0; i < vars.length; i++) { >+ if(vars[i].getName().equals(variableName)) { >+ return vars[i]; >+ } >+ } >+ } catch (DebugException x) { >+ JavaScriptDebugUIPlugin.log(x); >+ } >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator() >+ */ >+ public IInformationControlCreator getHoverControlCreator() { >+ return new ExpressionInformationControlCreator(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.jsdt.ui.text.java.hover.IJavaEditorTextHover#setEditor(org.eclipse.ui.IEditorPart) >+ */ >+ public void setEditor(IEditorPart editor) { >+ } >+ >+ /** >+ * Returns HTML text for the given variable >+ */ >+ private static String getVariableText(IVariable variable) { >+ StringBuffer buffer= new StringBuffer(); >+ JavaScriptModelPresentation modelPresentation = new JavaScriptModelPresentation(); >+ buffer.append("<p><pre>"); //$NON-NLS-1$ >+ String variableText= modelPresentation.getText(variable); >+ buffer.append(replaceHTMLChars(variableText)); >+ buffer.append("</pre></p>"); //$NON-NLS-1$ >+ modelPresentation.dispose(); >+ if (buffer.length() > 0) { >+ return buffer.toString(); >+ } >+ return null; >+ } >+ >+ /** >+ * Replaces reserved HTML characters in the given string with >+ * their escaped equivalents. This is to ensure that variable >+ * values containing reserved characters are correctly displayed. >+ */ >+ private static String replaceHTMLChars(String variableText) { >+ StringBuffer buffer = new StringBuffer(variableText.length()); >+ char[] characters = variableText.toCharArray(); >+ for (int i = 0; i < characters.length; i++) { >+ char character = characters[i]; >+ switch (character) { >+ case '<': >+ buffer.append("<"); //$NON-NLS-1$ >+ break; >+ case '>': >+ buffer.append(">"); //$NON-NLS-1$ >+ break; >+ case '&': >+ buffer.append("&"); //$NON-NLS-1$ >+ break; >+ case '"': >+ buffer.append("""); //$NON-NLS-1$ >+ break; >+ default: >+ buffer.append(character); >+ } >+ } >+ return buffer.toString(); >+ } >+ >+ /** >+ * Returns the stack frame in which to search for variables, or <code>null</code> >+ * if none. >+ * >+ * @return the stack frame in which to search for variables, or <code>null</code> >+ * if none >+ */ >+ protected IJavaScriptStackFrame getFrame() { >+ IAdaptable adaptable = DebugUITools.getDebugContext(); >+ if (adaptable != null) { >+ return (IJavaScriptStackFrame)adaptable.getAdapter(IJavaScriptStackFrame.class); >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptHyperlinkDetector.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptHyperlinkDetector.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptHyperlinkDetector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptHyperlinkDetector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,122 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextViewer; >+import org.eclipse.jface.text.TextSelection; >+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector; >+import org.eclipse.jface.text.hyperlink.IHyperlink; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.jsdt.core.IFunction; >+import org.eclipse.wst.jsdt.core.IJavaScriptElement; >+import org.eclipse.wst.jsdt.core.JavaScriptModelException; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+import org.eclipse.wst.jsdt.internal.ui.text.JavaWordFinder; >+ >+/** >+ * Hyper-link detector for stepping into selections in the JavaScript editor >+ * >+ * @since 1.0 >+ */ >+public class JavaScriptHyperlinkDetector extends AbstractHyperlinkDetector { >+ >+ /** >+ * Hyper-link for stepping into the selection >+ */ >+ class StepIntoSelectionHyperlink implements IHyperlink { >+ >+ private IRegion fRegion = null; >+ >+ /** >+ * Constructor >+ * @param region >+ */ >+ public StepIntoSelectionHyperlink(IRegion region) { >+ fRegion = region; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion() >+ */ >+ public IRegion getHyperlinkRegion() { >+ return fRegion; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText() >+ */ >+ public String getHyperlinkText() { >+ return Messages.hyperlink_step_into; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel() >+ */ >+ public String getTypeLabel() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#open() >+ */ >+ public void open() { >+ StepIntoSelectionActionDelegate delegate = new StepIntoSelectionActionDelegate(fRegion); >+ delegate.init(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); >+ delegate.run(null); >+ } >+ } >+ >+ /** >+ * Constructor >+ */ >+ public JavaScriptHyperlinkDetector() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, boolean) >+ */ >+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { >+ ITextEditor editor = (ITextEditor) getAdapter(ITextEditor.class); >+ if(editor != null) { >+ IJavaScriptStackFrame frame = EvaluationManager.getManager().getEvaluationContext(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); >+ if (frame == null) { >+ return null; >+ } >+ IEditorInput input = editor.getEditorInput(); >+ IJavaScriptElement element = StepIntoSelectionUtils.getJavaElement(input); >+ int offset = region.getOffset(); >+ if(element != null) { >+ try { >+ IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); >+ if(document != null) { >+ IRegion wregion = JavaWordFinder.findWord(document, offset); >+ if(wregion != null) { >+ IFunction method = StepIntoSelectionUtils.getFunction(new TextSelection(document, wregion.getOffset(), wregion.getLength()), element); >+ if (method != null) { >+ return new IHyperlink[] {new StepIntoSelectionHyperlink(wregion)}; >+ } >+ } >+ } >+ } >+ catch(JavaScriptModelException jme) { >+ JavaScriptDebugUIPlugin.log(jme); >+ } >+ } >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptInspectExpression.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptInspectExpression.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptInspectExpression.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/JavaScriptInspectExpression.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,158 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.model.IDebugElement; >+import org.eclipse.debug.core.model.IDebugTarget; >+import org.eclipse.debug.core.model.IExpression; >+import org.eclipse.debug.core.model.IValue; >+import org.eclipse.debug.core.model.IWatchExpression; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptDebugTarget; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptValue; >+import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+ >+/** >+ * Inspect expression for a JavaScript evaluation result >+ * >+ * @since 1.0 >+ */ >+public class JavaScriptInspectExpression implements IWatchExpression { >+ >+ private IJavaScriptValue value = null; >+ >+ /** >+ * Constructor >+ * >+ * @param value the value to show >+ */ >+ public JavaScriptInspectExpression(IJavaScriptValue value) { >+ this.value = value; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() >+ */ >+ public String getModelIdentifier() { >+ return JavaScriptDebugModel.MODEL_ID; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() >+ */ >+ public ILaunch getLaunch() { >+ return value.getLaunch(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) >+ */ >+ public Object getAdapter(Class adapter) { >+ if(IJavaScriptValue.class.equals(adapter)) { >+ return value; >+ } >+ if(IExpression.class.equals(adapter)) { >+ return this; >+ } >+ if(IJavaScriptDebugTarget.class.equals(adapter)) { >+ return value.getDebugTarget(); >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IExpression#getExpressionText() >+ */ >+ public String getExpressionText() { >+ try { >+ return value.getValueString(); >+ } >+ catch(DebugException de) { >+ JavaScriptDebugUIPlugin.log(de); >+ return null; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IExpression#getValue() >+ */ >+ public IValue getValue() { >+ return value; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IExpression#getDebugTarget() >+ */ >+ public IDebugTarget getDebugTarget() { >+ return value.getDebugTarget(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IExpression#dispose() >+ */ >+ public void dispose() { >+ value = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IErrorReportingExpression#hasErrors() >+ */ >+ public boolean hasErrors() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IErrorReportingExpression#getErrorMessages() >+ */ >+ public String[] getErrorMessages() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IWatchExpression#evaluate() >+ */ >+ public void evaluate() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IWatchExpression#setExpressionContext(org.eclipse.debug.core.model.IDebugElement) >+ */ >+ public void setExpressionContext(IDebugElement context) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IWatchExpression#setExpressionText(java.lang.String) >+ */ >+ public void setExpressionText(String expressionText) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IWatchExpression#isPending() >+ */ >+ public boolean isPending() { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IWatchExpression#isEnabled() >+ */ >+ public boolean isEnabled() { >+ return value != null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.model.IWatchExpression#setEnabled(boolean) >+ */ >+ public void setEnabled(boolean enabled) { >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/Messages.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/Messages.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/Messages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/Messages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * >+ */ >+public class Messages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.ui.eval.messages"; //$NON-NLS-1$ >+ public static String cannot_find_debug_target; >+ public static String cursor_position_not_valid; >+ public static String empty_editor; >+ public static String exception_running_to_line; >+ public static String exe_did_not_enter__0__before_returning; >+ public static String hyperlink_step_into; >+ public static String missing_doc; >+ public static String only_in_the_js_editor; >+ public static String selected_line_not_valid; >+ public static String step_into_only_top_frame; >+ public static String step_into_selection; >+ static { >+ // initialize resource bundle >+ NLS.initializeMessages(BUNDLE_NAME, Messages.class); >+ } >+ >+ private Messages() { >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/RunToLineAdapter.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/RunToLineAdapter.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/RunToLineAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/RunToLineAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,123 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.model.IBreakpoint; >+import org.eclipse.debug.core.model.IDebugElement; >+import org.eclipse.debug.core.model.IDebugTarget; >+import org.eclipse.debug.core.model.ISuspendResume; >+import org.eclipse.debug.ui.actions.IRunToLineTarget; >+import org.eclipse.debug.ui.actions.RunToLineHandler; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.swt.custom.BusyIndicator; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.jsdt.core.dom.AST; >+import org.eclipse.wst.jsdt.core.dom.ASTParser; >+import org.eclipse.wst.jsdt.core.dom.JavaScriptUnit; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptDebugTarget; >+import org.eclipse.wst.jsdt.debug.core.model.JavaScriptDebugModel; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+import org.eclipse.wst.jsdt.debug.internal.ui.breakpoints.BreakpointLocationFinder; >+ >+/** >+ * Run to line target for the JavaScript debugger >+ * >+ * @since 1.0 >+ */ >+public class RunToLineAdapter implements IRunToLineTarget { >+ >+ /** >+ * Marker attribute used to denote a run to line breakpoint >+ */ >+ private static final String RUN_TO_LINE = JavaScriptDebugUIPlugin.PLUGIN_ID + ".run_to_line"; //$NON-NLS-1$ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) >+ */ >+ public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException { >+ ITextEditor textEditor = StepIntoSelectionUtils.getTextEditor(part); >+ if (textEditor == null) { >+ throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.missing_doc, null)); >+ } >+ IEditorInput input = textEditor.getEditorInput(); >+ if (input == null) { >+ throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.empty_editor, null)); >+ } >+ final IDocument document= textEditor.getDocumentProvider().getDocument(input); >+ if (document == null) { >+ throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.missing_doc, null)); >+ } >+ final int[] validLine = new int[1]; >+ final String[] typeName = new String[1]; >+ final int[] lineNumber = new int[1]; >+ final ITextSelection textSelection = (ITextSelection) selection; >+ Runnable r = new Runnable() { >+ public void run() { >+ lineNumber[0] = textSelection.getStartLine() + 1; >+ ASTParser parser = ASTParser.newParser(AST.JLS3); >+ parser.setSource(document.get().toCharArray()); >+ JavaScriptUnit compilationUnit = (JavaScriptUnit)parser.createAST(null); >+ BreakpointLocationFinder locator = new BreakpointLocationFinder(compilationUnit, lineNumber[0], false); >+ compilationUnit.accept(locator); >+ validLine[0] = locator.getLineNumber(); >+ typeName[0] = locator.getFunctionName(); >+ } >+ }; >+ BusyIndicator.showWhile(JavaScriptDebugUIPlugin.getStandardDisplay(), r); >+ if (validLine[0] == lineNumber[0]) { >+ IBreakpoint breakpoint= null; >+ Map attributes = new HashMap(4); >+ attributes.put(IBreakpoint.PERSISTED, Boolean.FALSE); >+ attributes.put(RUN_TO_LINE, Boolean.TRUE); >+ breakpoint = JavaScriptDebugModel.createLineBreakpoint(ResourcesPlugin.getWorkspace().getRoot(), lineNumber[0], -1, -1, attributes, false); >+ if (target instanceof IAdaptable) { >+ IDebugTarget debugTarget = (IDebugTarget) ((IAdaptable)target).getAdapter(IDebugTarget.class); >+ if (debugTarget == null) { >+ throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.cannot_find_debug_target, null)); >+ } >+ RunToLineHandler handler = new RunToLineHandler(debugTarget, target, breakpoint); >+ handler.run(new NullProgressMonitor()); >+ return; >+ } >+ } else { >+ // invalid line >+ if (textSelection.getLength() > 0) { >+ throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.selected_line_not_valid, null)); >+ } >+ throw new CoreException(new Status(IStatus.ERROR, JavaScriptDebugUIPlugin.PLUGIN_ID, Messages.cursor_position_not_valid, null)); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) >+ */ >+ public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) { >+ if (target instanceof IDebugElement) { >+ IDebugElement element = (IDebugElement) target; >+ IJavaScriptDebugTarget adapter = (IJavaScriptDebugTarget) element.getDebugTarget().getAdapter(IJavaScriptDebugTarget.class); >+ return adapter != null; >+ } >+ return false; >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionActionDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionActionDelegate.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,325 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdapterManager; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.IDebugEventSetListener; >+import org.eclipse.debug.core.model.IStackFrame; >+import org.eclipse.debug.core.model.IThread; >+import org.eclipse.debug.ui.actions.IRunToLineTarget; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.TextSelection; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.ui.IEditorActionDelegate; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.IWorkbenchWindowActionDelegate; >+import org.eclipse.ui.texteditor.IEditorStatusLine; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.jsdt.core.IFunction; >+import org.eclipse.wst.jsdt.core.IJavaScriptElement; >+import org.eclipse.wst.jsdt.core.JavaScriptModelException; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptThread; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+ >+/** >+ * Steps into the selected function. >+ * >+ * @since 1.0 >+ */ >+public class StepIntoSelectionActionDelegate implements IEditorActionDelegate, IWorkbenchWindowActionDelegate { >+ >+ private IEditorPart editor = null; >+ private IWorkbenchWindow window = null; >+ private IRegion region = null; >+ >+ /** >+ * Default constructor >+ */ >+ public StepIntoSelectionActionDelegate() {} >+ >+ /** >+ * Constructor >+ * @param region >+ */ >+ public StepIntoSelectionActionDelegate(IRegion region) { >+ this.region = region; >+ } >+ >+ /** >+ * The line number being "run to." >+ */ >+ private int line = -1; >+ >+ /** >+ * The debug event list listener used to know when a run to line has finished. >+ * @see StepIntoSelectionActionDelegate#runToLineBeforeStepIn(ITextSelection, IJavaScriptStackFrame, IFunction) >+ */ >+ private IDebugEventSetListener listener = null; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) >+ */ >+ public void run(IAction action) { >+ IJavaScriptStackFrame frame = getStackFrame(); >+ if (frame == null || !frame.isSuspended()) { >+ // no longer suspended - unexpected >+ return; >+ } >+ ITextSelection textSelection = getTextSelection(); >+ try { >+ IEditorPart activeEditor = getActiveEditor(); >+ IJavaScriptElement javaElement= StepIntoSelectionUtils.getJavaElement(activeEditor.getEditorInput()); >+ IFunction function = StepIntoSelectionUtils.getFunction(textSelection, javaElement); >+ if (function == null) { >+ function = StepIntoSelectionUtils.getFirstFunctionOnLine(textSelection.getOffset(), activeEditor, javaElement); >+ } >+ int lineNumber = frame.getLineNumber(); >+ if (textSelection.getStartLine() == (lineNumber - 1)) { >+ doStepIn(frame, function); >+ } else { >+ runToLineBeforeStepIn(textSelection, frame.getThread(), function); >+ return; >+ } >+ } >+ catch (DebugException e) { >+ showErrorMessage(e.getStatus().getMessage()); >+ return; >+ } >+ catch(JavaScriptModelException jme) { >+ showErrorMessage(jme.getStatus().getMessage()); >+ return; >+ } >+ } >+ >+ /** >+ * Steps into the given function in the given stack frame >+ * @param frame the frame in which the step should begin >+ * @param function the function to step into >+ * @throws DebugException >+ */ >+ private void doStepIn(IJavaScriptStackFrame frame, IFunction function) throws DebugException { >+ // ensure top stack frame >+ IStackFrame tos = frame.getThread().getTopStackFrame(); >+ if (tos == null) { >+ return; >+ } >+ if (!tos.equals(frame)) { >+ showErrorMessage(Messages.step_into_only_top_frame); >+ return; >+ } >+ StepIntoSelectionHandler handler = new StepIntoSelectionHandler((IJavaScriptThread)frame.getThread(), frame, function); >+ handler.step(); >+ } >+ >+ /** >+ * When the user chooses to "step into selection" on a line other than >+ * the currently executing one, first perform a "run to line" to get to >+ * the desired location, then perform a "step into selection." >+ */ >+ private void runToLineBeforeStepIn(ITextSelection textSelection, final IThread thread, final IFunction function) { >+ line = textSelection.getStartLine() + 1; >+ if (line == -1) { >+ return; >+ } >+ // see bug 65489 - get the run-to-line adapter from the editor >+ IRunToLineTarget runToLineAction = null; >+ IEditorPart ed = getActiveEditor(); >+ if (ed != null) { >+ runToLineAction = (IRunToLineTarget) ed.getAdapter(IRunToLineTarget.class); >+ if (runToLineAction == null) { >+ IAdapterManager adapterManager = Platform.getAdapterManager(); >+ if (adapterManager.hasAdapter(ed, IRunToLineTarget.class.getName())) { >+ runToLineAction = (IRunToLineTarget) adapterManager.loadAdapter(ed,IRunToLineTarget.class.getName()); >+ } >+ } >+ } >+ // if no adapter exists, use the Java adapter >+ if (runToLineAction == null) { >+ runToLineAction = new RunToLineAdapter(); >+ } >+ listener = new IDebugEventSetListener() { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[]) >+ */ >+ public void handleDebugEvents(DebugEvent[] events) { >+ for (int i = 0; i < events.length; i++) { >+ DebugEvent event = events[i]; >+ switch (event.getKind()) { >+ case DebugEvent.SUSPEND : >+ handleSuspendEvent(event); >+ break; >+ case DebugEvent.TERMINATE : >+ handleTerminateEvent(event); >+ break; >+ default : >+ break; >+ } >+ } >+ } >+ /** >+ * Listen for the completion of the "run to line." When the thread >+ * suspends at the correct location, perform a "step into selection" >+ * >+ * @param event the debug event >+ */ >+ private void handleSuspendEvent(DebugEvent event) { >+ Object source = event.getSource(); >+ if (source instanceof IJavaScriptThread) { >+ try { >+ final IJavaScriptStackFrame frame= (IJavaScriptStackFrame) ((IJavaScriptThread) source).getTopStackFrame(); >+ if (isExpectedFrame(frame)) { >+ DebugPlugin plugin = DebugPlugin.getDefault(); >+ plugin.removeDebugEventListener(listener); >+ plugin.asyncExec(new Runnable() { >+ public void run() { >+ try { >+ doStepIn(frame, function); >+ } catch (DebugException e) { >+ showErrorMessage(e.getStatus().getMessage()); >+ } >+ } >+ }); >+ } >+ } catch (DebugException e) { >+ return; >+ } >+ } >+ } >+ /** >+ * Returns whether the given frame is the frame that this action is expecting. >+ * This frame is expecting a stack frame for the suspension of the "run to line". >+ * @param frame the given stack frame or <code>null</code> >+ * @return whether the given stack frame is the expected frame >+ * @throws DebugException >+ */ >+ private boolean isExpectedFrame(IJavaScriptStackFrame frame) throws DebugException { >+ return frame != null && line == frame.getLineNumber(); >+ } >+ /** >+ * When the debug target we're listening for terminates, stop listening >+ * to debug events. >+ * @param event the debug event >+ */ >+ private void handleTerminateEvent(DebugEvent event) { >+ Object source = event.getSource(); >+ if (thread.getDebugTarget() == source) { >+ DebugPlugin.getDefault().removeDebugEventListener(listener); >+ } >+ } >+ }; >+ DebugPlugin.getDefault().addDebugEventListener(listener); >+ try { >+ runToLineAction.runToLine(getActiveEditor(), textSelection, thread); >+ } catch (CoreException e) { >+ DebugPlugin.getDefault().removeDebugEventListener(listener); >+ showErrorMessage(Messages.exception_running_to_line); >+ JavaScriptDebugUIPlugin.log(e.getStatus()); >+ } >+ } >+ >+ /** >+ * Gets the current text selection from the currently active editor >+ * @return the current text selection >+ */ >+ private ITextSelection getTextSelection() { >+ IEditorPart part = getActiveEditor(); >+ if (part instanceof ITextEditor) { >+ ITextEditor editor = (ITextEditor)part; >+ if(region != null) { >+ IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); >+ if(document != null) { >+ return new TextSelection(document, region.getOffset(), region.getLength()); >+ } >+ } >+ else { >+ return (ITextSelection)editor.getSelectionProvider().getSelection(); >+ } >+ } >+ showErrorMessage(Messages.only_in_the_js_editor); >+ return null; >+ } >+ >+ /** >+ * Displays an error message in the status area >+ * >+ * @param message >+ */ >+ protected void showErrorMessage(String message) { >+ if (getActiveEditor() != null) { >+ IEditorStatusLine statusLine= (IEditorStatusLine) getActiveEditor().getAdapter(IEditorStatusLine.class); >+ if (statusLine != null) { >+ statusLine.setMessage(true, message, null); >+ } >+ } >+ JavaScriptDebugUIPlugin.getStandardDisplay().beep(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) >+ */ >+ public void setActiveEditor(IAction action, IEditorPart targetEditor) { >+ editor = targetEditor; >+ } >+ >+ /** >+ * Returns the active editor or <code>null</code>. >+ * >+ * @return active editor or <code>null</code> >+ */ >+ protected IEditorPart getActiveEditor() { >+ if (window != null) { >+ // global action >+ return window.getActivePage().getActiveEditor(); >+ } >+ // pop-up action >+ return editor; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) >+ */ >+ public void selectionChanged(IAction action, ISelection selection) { >+ } >+ >+ /** >+ * Returns the current stack frame context, or <code>null</code> if none. >+ * >+ * @return the current stack frame context, or <code>null</code> if none >+ */ >+ protected IJavaScriptStackFrame getStackFrame() { >+ return EvaluationManager.getManager().getEvaluationContext(getActiveEditor()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() >+ */ >+ public void dispose() {} >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) >+ */ >+ public void init(IWorkbenchWindow window) { >+ this.window = window; >+ } >+ >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionHandler.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,306 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.IDebugEventFilter; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.wst.jsdt.core.IFunction; >+import org.eclipse.wst.jsdt.core.JavaScriptModelException; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptDebugTarget; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptStackFrame; >+import org.eclipse.wst.jsdt.debug.core.model.IJavaScriptThread; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+ >+/** >+ * Handles stepping into a selected function, for a specific thread. >+ * >+ * @since 1.0 >+ */ >+public class StepIntoSelectionHandler implements IDebugEventFilter { >+ >+ /** >+ * The function to step into >+ */ >+ private IFunction function; >+ >+ /** >+ * Resolved signature of the function to step into >+ */ >+ private String signature; >+ >+ /** >+ * The thread in which to step >+ */ >+ private IJavaScriptThread thread; >+ >+ /** >+ * The initial stack frame >+ */ >+ private String origname; >+ private int origdepth; >+ >+ /** >+ * Whether this is the first step into. >+ */ >+ private boolean firststep = true; >+ >+ /** >+ * Expected event kind >+ */ >+ private int eventkind = -1; >+ >+ /** >+ * Expected event detail >+ */ >+ private int eventdetail = -1; >+ >+ /** >+ * Constructs a step handler to step into the given function in the given thread >+ * starting from the given stack frame. >+ * >+ * @param thread >+ * @param frame >+ * @param func >+ */ >+ public StepIntoSelectionHandler(IJavaScriptThread thread, IJavaScriptStackFrame frame, IFunction func) { >+ function = func; >+ this.thread = thread; >+ try { >+ origname = frame.getName(); >+ signature = func.getSignature(); >+ } catch (CoreException e) { >+ JavaScriptDebugUIPlugin.log(e); >+ } >+ } >+ >+ /** >+ * Returns the target thread for the step. >+ * >+ * @return the target thread for the step >+ */ >+ protected IJavaScriptThread getThread() { >+ return thread; >+ } >+ >+ protected IJavaScriptDebugTarget getDebugTarget() { >+ return (IJavaScriptDebugTarget)getThread().getDebugTarget(); >+ } >+ >+ /** >+ * Returns the function to step into >+ * >+ * @return the function to step into >+ */ >+ protected IFunction getMethod() { >+ return function; >+ } >+ >+ /** >+ * Returns the resolved signature of the function to step into >+ * >+ * @return the resolved signature of the function to step into >+ */ >+ protected String getSignature() { >+ return signature; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.IDebugEventFilter#filterDebugEvents(org.eclipse.debug.core.DebugEvent[]) >+ */ >+ public DebugEvent[] filterDebugEvents(DebugEvent[] events) { >+ // we only expect one event from our thread - find the event >+ DebugEvent event = null; >+ int index = -1; >+ int threadEvents = 0; >+ for (int i = 0; i < events.length; i++) { >+ DebugEvent e = events[i]; >+ if (isExpectedEvent(e)) { >+ event = e; >+ index = i; >+ threadEvents++; >+ } else if (e.getSource() == getThread()) { >+ threadEvents++; >+ } >+ } >+ if (event == null) { >+ // nothing to process in this event set >+ return events; >+ } >+ // create filtered event set >+ DebugEvent[] filtered = new DebugEvent[events.length - 1]; >+ if (filtered.length > 0) { >+ int j = 0; >+ for (int i = 0; i < events.length; i++) { >+ if (i != index) { >+ filtered[j] = events[i]; >+ j++; >+ } >+ } >+ } >+ // if more than one event in our thread, abort (filtering our event) >+ if (threadEvents > 1) { >+ cleanup(); >+ return filtered; >+ } >+ // we have the one expected event - process it >+ switch (event.getKind()) { >+ case DebugEvent.RESUME: >+ // next, we expect a step end >+ setExpectedEvent(DebugEvent.SUSPEND, DebugEvent.STEP_END); >+ if (firststep) { >+ firststep = false; >+ return events; // include the first resume event >+ } >+ // secondary step - filter the event >+ return filtered; >+ case DebugEvent.SUSPEND: >+ // compare location to desired location >+ try { >+ final IJavaScriptStackFrame frame = (IJavaScriptStackFrame)getThread().getTopStackFrame(); >+ int stackDepth = frame.getThread().getStackFrames().length; >+ String name = frame.getName(); >+ if (name.equals(getMethod().getElementName())) { >+ // hit >+ cleanup(); >+ return events; >+ } >+ // step again >+ Runnable r = null; >+ if (stackDepth > origdepth) { >+ r = new Runnable() { >+ public void run() { >+ try { >+ setExpectedEvent(DebugEvent.RESUME, DebugEvent.STEP_RETURN); >+ frame.stepReturn(); >+ } catch (DebugException e) { >+ JavaScriptDebugUIPlugin.log(e); >+ cleanup(); >+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(getDebugTarget(), DebugEvent.CHANGE)}); >+ } >+ } >+ }; >+ } else if (stackDepth == origdepth){ >+ // we should be back in the original stack frame - if not, abort >+ if (!frame.getName().equals(origname)) { >+ missed(); >+ return events; >+ } >+ r = new Runnable() { >+ public void run() { >+ try { >+ setExpectedEvent(DebugEvent.RESUME, DebugEvent.STEP_INTO); >+ frame.stepInto(); >+ } catch (DebugException e) { >+ JavaScriptDebugUIPlugin.log(e); >+ cleanup(); >+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(getDebugTarget(), DebugEvent.CHANGE)}); >+ } >+ } >+ }; >+ } else { >+ // we returned from the original frame - never hit the desired method >+ missed(); >+ return events; >+ } >+ DebugPlugin.getDefault().asyncExec(r); >+ // filter the events >+ return filtered; >+ } catch (CoreException e) { >+ // abort >+ JavaScriptDebugUIPlugin.log(e); >+ cleanup(); >+ return events; >+ } >+ } >+ // execution should not reach here >+ return events; >+ >+ } >+ >+ /** >+ * Called when stepping returned from the original frame without entering the desired method. >+ */ >+ protected void missed() { >+ cleanup(); >+ Runnable r = new Runnable() { >+ public void run() { >+ String methodName = null; >+ try { >+ methodName = org.eclipse.wst.jsdt.core.Signature.toString(getMethod().getSignature(), getMethod().getElementName(), getMethod().getParameterNames(), false, false); >+ } catch (JavaScriptModelException e) { >+ methodName = getMethod().getElementName(); >+ } >+ new MessageDialog( >+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), >+ Messages.step_into_selection, >+ null, >+ NLS.bind(Messages.exe_did_not_enter__0__before_returning, new String[]{methodName}), >+ MessageDialog.INFORMATION, new String[] {IDialogConstants.OK_LABEL}, 0).open(); >+ } >+ }; >+ JavaScriptDebugUIPlugin.getStandardDisplay().asyncExec(r); >+ } >+ >+ /** >+ * Performs the step. >+ */ >+ public void step() { >+ // add event filter and turn off step filters >+ DebugPlugin.getDefault().addDebugEventFilter(this); >+ try { >+ origdepth = getThread().getStackFrames().length; >+ setExpectedEvent(DebugEvent.RESUME, DebugEvent.STEP_INTO); >+ getThread().stepInto(); >+ } catch (DebugException e) { >+ JavaScriptDebugUIPlugin.log(e); >+ cleanup(); >+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(getDebugTarget(), DebugEvent.CHANGE)}); >+ } >+ } >+ >+ /** >+ * Cleans up when the step is complete/aborted. >+ */ >+ protected void cleanup() { >+ DebugPlugin.getDefault().removeDebugEventFilter(this); >+ } >+ >+ /** >+ * Sets the expected debug event kind and detail we are waiting for next. >+ * >+ * @param kind event kind >+ * @param detail event detail >+ */ >+ private void setExpectedEvent(int kind, int detail) { >+ eventkind = kind; >+ eventdetail = detail; >+ } >+ >+ /** >+ * Returns whether the given event is what we expected. >+ * >+ * @param event fire event >+ * @return whether the event is what we expected >+ */ >+ protected boolean isExpectedEvent(DebugEvent event) { >+ return event.getSource().equals(getThread()) && >+ event.getKind() == eventkind && >+ event.getDetail() == eventdetail; >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionUtils.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionUtils.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/StepIntoSelectionUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,149 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.eval; >+ >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.texteditor.IDocumentProvider; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.jsdt.core.ICodeAssist; >+import org.eclipse.wst.jsdt.core.IFunction; >+import org.eclipse.wst.jsdt.core.IJavaScriptElement; >+import org.eclipse.wst.jsdt.core.JavaScriptCore; >+import org.eclipse.wst.jsdt.core.JavaScriptModelException; >+import org.eclipse.wst.jsdt.core.ToolFactory; >+import org.eclipse.wst.jsdt.core.compiler.IScanner; >+import org.eclipse.wst.jsdt.core.compiler.ITerminalSymbols; >+import org.eclipse.wst.jsdt.core.compiler.InvalidInputException; >+import org.eclipse.wst.jsdt.ui.JavaScriptUI; >+ >+/** >+ * Utility class for aiding step into selection actions and hyper-linking >+ * >+ * @since 1.1 >+ */ >+public class StepIntoSelectionUtils { >+ >+ /** >+ * Returns the text editor associated with the given part or <code>null</code> >+ * if none. In case of a multi-page editor, this method should be used to retrieve >+ * the correct editor to perform the operation on. >+ * >+ * @param part workbench part >+ * @return text editor part or <code>null</code> >+ */ >+ public static ITextEditor getTextEditor(IWorkbenchPart part) { >+ if (part instanceof ITextEditor) { >+ return (ITextEditor) part; >+ } >+ return (ITextEditor) part.getAdapter(ITextEditor.class); >+ } >+ >+ /** >+ * gets the <code>IJavaScriptElement</code> from the editor input >+ * @param input the current editor input >+ * @return the corresponding <code>IJavaScriptElement</code> >+ */ >+ public static IJavaScriptElement getJavaElement(IEditorInput input) { >+ IJavaScriptElement je = JavaScriptUI.getEditorInputJavaElement(input); >+ if(je != null) { >+ return je; >+ } >+ return JavaScriptUI.getWorkingCopyManager().getWorkingCopy(input); >+ } >+ >+ /** >+ * Returns the <code>IFuntion</code> from the given selection within the given <code>IJavaScriptElement</code>, >+ * or <code>null</code> if the selection does not container or is not an <code>IFunction</code> >+ * @param selection >+ * @param element >+ * @return the corresponding <code>IFunction</code> from the selection within the provided <code>IJavaScriptElement</code> >+ * @throws JavaScriptModelException >+ */ >+ public static IFunction getFunction(ITextSelection selection, IJavaScriptElement element) throws JavaScriptModelException { >+ if(element != null && element instanceof ICodeAssist) { >+ return resolveFunction(selection.getOffset(), selection.getLength(), (ICodeAssist)element); >+ } >+ return null; >+ } >+ >+ /** >+ * @param offset selection offset >+ * @param length selection length >+ * @param codeAssist context >+ * @return the function at the given position, or <code>null</code> if no function could be resolved >+ * @throws JavaScriptModelException >+ */ >+ private static IFunction resolveFunction(int offset, int length, ICodeAssist codeAssist) throws JavaScriptModelException { >+ IJavaScriptElement[] elements = codeAssist.codeSelect(offset, length); >+ for (int i = 0; i < elements.length; i++) { >+ if (elements[i] instanceof IFunction) { >+ return (IFunction)elements[i]; >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * @param offset >+ * @param activeEditor >+ * @param element >+ * @return the first function found at or after <code>offset</code> on the same line >+ * @throws JavaScriptModelException >+ */ >+ public static IFunction getFirstFunctionOnLine(int offset, IEditorPart activeEditor, IJavaScriptElement element) throws JavaScriptModelException { >+ if (! (activeEditor instanceof ITextEditor) || ! (element instanceof ICodeAssist)) { >+ return null; >+ } >+ ITextEditor editor = (ITextEditor)activeEditor; >+ IDocumentProvider documentProvider = editor.getDocumentProvider(); >+ if (documentProvider == null) { >+ return null; >+ } >+ IDocument document = documentProvider.getDocument(editor.getEditorInput()); >+ if (document == null) { >+ return null; >+ } >+ try { >+ IRegion lineInfo = document.getLineInformationOfOffset(offset); >+ String line = document.get(lineInfo.getOffset(), lineInfo.getLength()); >+ IScanner scanner = ToolFactory.createScanner(false, false, false, null, JavaScriptCore.VERSION_1_5); >+ scanner.setSource(line.toCharArray()); >+ scanner.resetTo(offset - lineInfo.getOffset(), lineInfo.getLength()); >+ int token = scanner.getNextToken(); >+ while (token != ITerminalSymbols.TokenNameEOF) { >+ if (token == ITerminalSymbols.TokenNameIdentifier) { >+ int methodStart = scanner.getCurrentTokenStartPosition(); >+ token = scanner.getNextToken(); >+ if (token == ITerminalSymbols.TokenNameLPAREN) { >+ return resolveFunction(lineInfo.getOffset() + methodStart, 0, (ICodeAssist)element); >+ } >+ } >+ else { >+ token = scanner.getNextToken(); >+ } >+ } >+ } >+ catch (BadLocationException e) { >+ return null; >+ } >+ catch (InvalidInputException e) { >+ return null; >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/eval/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+############################################################################### >+# Copyright (c) 201o IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+cannot_find_debug_target=Unable to locate debug target >+cursor_position_not_valid=Cursor position is not a valid location to run to >+empty_editor=Empty editor >+exception_running_to_line=An exception occurred attempting to run to the selected line. >+exe_did_not_enter__0__before_returning=Execution did not enter "{0}" before the current function returned. >+hyperlink_step_into=Step Into >+missing_doc=Missing document >+only_in_the_js_editor=Step into selection only available in JavaScript editor. >+selected_line_not_valid=Selected line is not a valid location to run to >+step_into_only_top_frame=Step into selection only available in top stack frame. >+step_into_selection=Step into selection >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java,v >retrieving revision 1.3.2.2 >diff -u -r1.3.2.2 JavaScriptConnectTab.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java 30 Jun 2010 16:16:16 -0000 1.3.2.2 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptConnectTab.java 6 Sep 2011 16:36:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >+ * Copyright (c) 2010, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,6 +10,9 @@ > *******************************************************************************/ > package org.eclipse.wst.jsdt.debug.internal.ui.launching; > >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.Comparator; > import java.util.HashMap; > import java.util.Iterator; > import java.util.List; >@@ -62,19 +65,72 @@ > */ > public class JavaScriptConnectTab extends AbstractLaunchConfigurationTab implements IPropertyChangeListener { > >+ class ArgComparator implements Comparator { >+ /* (non-Javadoc) >+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) >+ */ >+ public int compare(Object o1, Object o2) { >+ if(o1 instanceof Entry && o2 instanceof Entry) { >+ //String > Integer > List > Boolean >+ //sort by kind and by label >+ Object val1 = ((Entry)o1).getValue(); >+ Object val2 = ((Entry)o2).getValue(); >+ if(val1 instanceof StringArgument) { >+ if(val2 instanceof StringArgument) { >+ return stripAccel(((Argument)val1).label()).compareTo(stripAccel(((Argument)val2).label())); >+ } >+ return -1; >+ } >+ else if(val1 instanceof IntegerArgument) { >+ if(val2 instanceof IntegerArgument) { >+ return stripAccel(((Argument)val1).label()).compareTo(stripAccel(((Argument)val2).label())); >+ } >+ else if(val2 instanceof StringArgument) { >+ return 1; >+ } >+ return -1; >+ } >+ else if(val1 instanceof SelectedArgument) { >+ if(val2 instanceof SelectedArgument) { >+ return stripAccel(((Argument)val1).label()).compareTo(stripAccel(((Argument)val2).label())); >+ } >+ else if(val2 instanceof StringArgument || val2 instanceof IntegerArgument) { >+ return 1; >+ } >+ return -1; >+ } >+ else if(val1 instanceof BooleanArgument) { >+ if(val2 instanceof BooleanArgument) { >+ return stripAccel(((Argument)val1).label()).compareTo(stripAccel(((Argument)val2).label())); >+ } >+ else if(val2 instanceof StringArgument || val2 instanceof IntegerArgument || val2 instanceof SelectedArgument) { >+ return 1; >+ } >+ return -1; >+ } >+ } >+ return o1.equals(o2) ? 0 : -1; >+ } >+ >+ String stripAccel(String text) { >+ return text.replaceAll("\\&", ""); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ } >+ > Text description = null; > Combo connectorcombo = null; > Connector selectedconnector = null; > Group argumentsgroup = null; > HashMap editormap = new HashMap(); >+ Comparator comparator = new ArgComparator(); > > /* (non-Javadoc) > * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) > */ > public void createControl(Composite parent) { >- Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL); >+ Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_HORIZONTAL); > //connectors combo >- Group group = SWTFactory.createGroup(comp, Messages.connector, 1, 2, GridData.FILL_HORIZONTAL); >+ Group group = SWTFactory.createGroup(comp, Messages.connector, 1, 1, GridData.FILL_HORIZONTAL); > this.connectorcombo = SWTFactory.createCombo(group, SWT.FLAT | SWT.BORDER | SWT.READ_ONLY, 1, null); > GridData gd = (GridData) this.connectorcombo.getLayoutData(); > gd.grabExcessHorizontalSpace = true; >@@ -86,6 +142,8 @@ > this.description = SWTFactory.createText(group, SWT.WRAP | SWT.READ_ONLY, 1); > gd = (GridData) this.description.getLayoutData(); > gd.heightHint = 30; >+ //hack to make sure the disabled colour is propagated on *Nix's >+ this.description.setBackground(group.getBackground()); > List connectors = JavaScriptDebugPlugin.getConnectionsManager().getConnectors(); > Connector connector = null; > for (int i = 0; i < connectors.size(); i++) { >@@ -94,12 +152,19 @@ > this.connectorcombo.setData(connector.name(), connector); > } > >- this.argumentsgroup = SWTFactory.createGroup(comp, Messages.connector_properties, 2, 2, GridData.FILL_HORIZONTAL); >+ this.argumentsgroup = SWTFactory.createGroup(comp, Messages.connector_properties, 2, 1, GridData.FILL_HORIZONTAL); > this.argumentsgroup.setVisible(false); >- setControl(comp); > PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.CONNECT_TAB); >+ setControl(comp); > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getHelpContextId() >+ */ >+ public String getHelpContextId() { >+ return IHelpContextIds.CONNECT_TAB; >+ }; >+ > /** > * Returns the {@link Connector} based on the selection of the combo > * @return the selected combo >@@ -142,7 +207,9 @@ > Argument argument = null; > FieldEditor editor = null; > String key = null; >- for (Iterator iter = this.selectedconnector.defaultArguments().entrySet().iterator(); iter.hasNext();) { >+ ArrayList entries = new ArrayList(this.selectedconnector.defaultArguments().entrySet()); >+ Collections.sort(entries, comparator); >+ for (Iterator iter = entries.iterator(); iter.hasNext();) { > entry = (Entry) iter.next(); > key = (String) entry.getKey(); > argument = (Argument) entry.getValue(); >@@ -188,6 +255,7 @@ > GridLayout gd = (GridLayout) this.argumentsgroup.getLayout(); > gd.marginHeight = 5; > gd.marginWidth = 5; >+ gd.numColumns = 2; > this.argumentsgroup.getParent().layout(true); > this.argumentsgroup.setVisible(true); > this.argumentsgroup.layout(true); >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptLaunchShortcut.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptLaunchShortcut.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptLaunchShortcut.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavaScriptLaunchShortcut.java 1 Mar 2010 21:55:02 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,124 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.wst.jsdt.debug.internal.ui.launching; >- >-import java.util.Arrays; >- >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.debug.core.DebugPlugin; >-import org.eclipse.debug.core.ILaunchConfiguration; >-import org.eclipse.debug.core.ILaunchConfigurationType; >-import org.eclipse.debug.core.ILaunchManager; >-import org.eclipse.debug.internal.ui.DebugUIPlugin; >-import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; >-import org.eclipse.debug.ui.DebugUITools; >-import org.eclipse.debug.ui.IDebugUIConstants; >-import org.eclipse.debug.ui.ILaunchGroup; >-import org.eclipse.debug.ui.ILaunchShortcut2; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.ui.IEditorPart; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.wst.jsdt.debug.internal.core.Constants; >- >-/** >- * Default reusable launch shortcut for JavaScript debug consumers >- * @since 1.0 >- */ >-public class JavaScriptLaunchShortcut implements ILaunchShortcut2 { >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchConfigurations(org.eclipse.jface.viewers.ISelection) >- */ >- public ILaunchConfiguration[] getLaunchConfigurations(ISelection selection) { >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchConfigurations(org.eclipse.ui.IEditorPart) >- */ >- public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editorpart) { >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchableResource(org.eclipse.jface.viewers.ISelection) >- */ >- public IResource getLaunchableResource(ISelection selection) { >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchableResource(org.eclipse.ui.IEditorPart) >- */ >- public IResource getLaunchableResource(IEditorPart editorpart) { >- return null; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String) >- */ >- public void launch(ISelection selection, String mode) { >- openLaunchDialogOnSelection(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String) >- */ >- public void launch(IEditorPart editor, String mode) { >- openLaunchDialogOnSelection(); >- } >- >- /** >- * Default behavior to open the launch configuration dialog on the {@link ILaunchConfigurationType} >- * for JavaScript >- */ >- void openLaunchDialogOnSelection() { >- DebugUITools.openLaunchConfigurationDialogOnGroup( >- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), >- new StructuredSelection(getSelection()), >- IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP); >- } >- >- /** >- * Returns the type of the default launch configuration >- * @return the default item to select when opening the dialog >- */ >- Object getSelection() { >- ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); >- ILaunchConfigurationType type = manager.getLaunchConfigurationType(Constants.LAUNCH_CONFIG_ID); >- if(type != null) { >- try { >- ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type); >- if(configs != null && configs.length > 0) { >- LaunchConfigurationManager cmanager = DebugUIPlugin.getDefault().getLaunchConfigurationManager(); >- ILaunchGroup group = cmanager.getLaunchGroup(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP); >- if(group != null) { >- ILaunchConfiguration config = cmanager.getMRUConfiguration( >- Arrays.asList(configs), >- group, >- null); >- if(config != null) { >- return config; >- } >- } >- } >- } >- catch (CoreException ce) { >- //do nothing, just return type >- } >- return type; >- } >- return null; >- } >- >-} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java,v >retrieving revision 1.2 >diff -u -r1.2 JavascriptTabGroup.java >--- src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java 24 Feb 2010 21:49:42 -0000 1.2 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/launching/JavascriptTabGroup.java 6 Sep 2011 16:36:43 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2010 IBM Corporation and others. >+ * Copyright (c) 2010, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -16,9 +16,10 @@ > import org.eclipse.debug.ui.ILaunchConfigurationDialog; > import org.eclipse.debug.ui.ILaunchConfigurationTab; > import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; >+import org.eclipse.wst.jsdt.debug.internal.ui.IHelpContextIds; > > /** >- * Default tab group for Javascript debugging >+ * Default tab group for JavaScript debugging > * > * @since 1.0 > */ >@@ -28,11 +29,17 @@ > * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String) > */ > public void createTabs(ILaunchConfigurationDialog dialog, String mode) { >+ SourceLookupTab slt = new SourceLookupTab(); >+ slt.setHelpContextId(IHelpContextIds.SOURCE_LOOKUP_TAB); >+ EnvironmentTab et = new EnvironmentTab(); >+ et.setHelpContextId(IHelpContextIds.ENVIRONMENT_TAB); >+ CommonTab ct = new CommonTab(); >+ ct.setHelpContextId(IHelpContextIds.COMMON_TAB); > ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { > new JavaScriptConnectTab(), >- new SourceLookupTab(), >- new EnvironmentTab(), >- new CommonTab() >+ slt, >+ et, >+ ct > }; > setTabs(tabs); > } >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsdt/plugins/org.eclipse.wst.jsdt.debug.ui/src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties,v >retrieving revision 1.4.2.2 >diff -u -r1.4.2.2 messages.properties >--- src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties 21 Jun 2011 14:06:00 -0000 1.4.2.2 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/messages.properties 6 Sep 2011 16:36:43 -0000 >@@ -22,14 +22,30 @@ > connector=Connector > connector_properties=Connector Properties > creating_script_load_bp=Creating Script Load Breakpoint... >+disconnected=<disconnected> > enable_hit_count=Enable &Hit Count > enter_new_hit_count=&Enter the new hit count for the breakpoint: >+evald_script=<evaluated script> > exception_occurred_setting_bp_properties=Exceptions occurred attempting to modify breakpoint. > hit_count_must_be_positive=Hit count must be a positive integer > no_description_provided=No description provided. >+opening_source__0=Opening Source: {0} >+running_state=running > scripts=Scripts > select_javascript_file=Select a JavaScript script file > set_bp_hit_count=Set Breakpoint Hit Count >+stackframe_name={0} - line: {1} >+stepping_state=stepping >+suspend_loading_script=suspended loading script: {0} > suspend_target=&Suspend Target > suspend_thread=&Suspend Thread >+suspended_on_exception=suspended on exception: {0} >+suspended_on_func_breakpoint=suspended at breakpoint on function {0} in {1} >+suspended_on_line_breakpoint=suspended at breakpoint on line {0} in {1} >+suspended_state=suspended >+terminated=<terminated> >+terminated_state=terminated > the_argument_0_is_not_valid=The specified argument: {0} is not valid >+thread_name=Thread [{0}] ({1}) >+unknown=<unknown> >+unknown_state=<unknown state> >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/JavaScriptDebugPreferencePage.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/JavaScriptDebugPreferencePage.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/JavaScriptDebugPreferencePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/JavaScriptDebugPreferencePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,112 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.preferences; >+ >+import org.eclipse.jface.preference.BooleanFieldEditor; >+import org.eclipse.jface.preference.FieldEditor; >+import org.eclipse.jface.preference.FieldEditorPreferencePage; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPreferencePage; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.wst.jsdt.debug.internal.core.Constants; >+import org.eclipse.wst.jsdt.debug.internal.ui.IHelpContextIds; >+import org.eclipse.wst.jsdt.debug.internal.ui.JavaScriptDebugUIPlugin; >+import org.eclipse.wst.jsdt.debug.internal.ui.SWTFactory; >+ >+/** >+ * Default preference page for JavaScript debugging >+ * @since 1.1 >+ */ >+public class JavaScriptDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { >+ >+ public static final String PAGE_ID = "org.eclipse.wst.jsdt.debug.ui.debug.page"; //$NON-NLS-1$ >+ >+ /** >+ * Constructor >+ */ >+ public JavaScriptDebugPreferencePage() { >+ super(GRID); >+ setPreferenceStore(JavaScriptDebugUIPlugin.getDefault().getPreferenceStore()); >+ setDescription(Messages.js_debug_pref_page_desc); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) >+ */ >+ public void init(IWorkbench workbench) {} >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite parent) { >+ super.createControl(parent); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.DEBUG_PREFERENCE_PAGE); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createContents(Composite parent) { >+ Composite comp = SWTFactory.createComposite(parent, parent.getFont(), 1, 1, GridData.FILL_HORIZONTAL, 0, 0); >+ //General >+ Group group = SWTFactory.createGroup(comp, Messages.general, 1, 1, GridData.FILL_HORIZONTAL); >+ BooleanFieldEditor editor = new BooleanFieldEditor(Constants.DELETE_EXT_PROJECT_ON_EXIT, Messages.delete_ext_project_on_exit, group); >+ initEditor(editor, JavaScriptDebugUIPlugin.getCorePreferenceStore()); >+ initGroup(group); >+ //Suspend Execution >+ group = SWTFactory.createGroup(comp, Messages.suspend_execution, 1, 1, GridData.FILL_HORIZONTAL); >+ editor = new BooleanFieldEditor(Constants.SUSPEND_ON_ALL_SCRIPT_LOADS, Messages.suspend_for_all_script_loads, group); >+ initEditor(editor, JavaScriptDebugUIPlugin.getCorePreferenceStore()); >+ editor = new BooleanFieldEditor(Constants.SUSPEND_ON_THROWN_EXCEPTION, Messages.suspend_on_exceptions, group); >+ initEditor(editor, JavaScriptDebugUIPlugin.getCorePreferenceStore()); >+ initGroup(group); >+ return comp; >+ } >+ >+ /** >+ * Refreshes the specified group to re-set the default spacings that have been >+ * trashed by the field editors >+ * >+ * @param group >+ */ >+ void initGroup(Group group) { >+ GridData gd = (GridData) group.getLayoutData(); >+ gd.grabExcessHorizontalSpace = true; >+ GridLayout lo = (GridLayout) group.getLayout(); >+ lo.marginWidth = 5; >+ lo.marginHeight = 5; >+ } >+ >+ /** >+ * Initializes and sets up the given editor >+ * >+ * @param editor >+ * @param store >+ */ >+ void initEditor(FieldEditor editor, IPreferenceStore store) { >+ addField(editor); >+ editor.setPage(this); >+ editor.setPropertyChangeListener(this); >+ editor.setPreferenceStore(store); >+ editor.load(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() >+ */ >+ protected void createFieldEditors() {} >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/Messages.java >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/Messages.java >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/Messages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/Messages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.jsdt.debug.internal.ui.preferences; >+ >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * >+ */ >+public class Messages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.wst.jsdt.debug.internal.ui.preferences.messages"; //$NON-NLS-1$ >+ public static String delete_ext_project_on_exit; >+ public static String general; >+ public static String js_debug_pref_page_desc; >+ public static String suspend_execution; >+ public static String suspend_for_all_script_loads; >+ public static String suspend_on_exceptions; >+ static { >+ // initialize resource bundle >+ NLS.initializeMessages(BUNDLE_NAME, Messages.class); >+ } >+ >+ private Messages() { >+ } >+} >Index: src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/messages.properties >=================================================================== >RCS file: src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/messages.properties >diff -N src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/jsdt/debug/internal/ui/preferences/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,16 @@ >+general=General >+############################################################################### >+# Copyright (c) 2010 IBM Corporation and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# IBM Corporation - initial API and implementation >+############################################################################### >+delete_ext_project_on_exit=Delete the 'E&xternal JavaScript Source' project on workbench shutdown >+js_debug_pref_page_desc=General settings for JavaScript debugging >+suspend_execution=Suspend Execution >+suspend_for_all_script_loads=Suspend for all script &loads >+suspend_on_exceptions=Suspend on JavaScript e&xceptions
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 353225
:
202822
|
202824
|
202827
|
202844