https://bugs.eclipse.org/bugs/show_bug.cgi?id=390869 - Snippet editor
diff --git a/org.eclipse.jdt.debug.ui/plugin.xml b/org.eclipse.jdt.debug.ui/plugin.xml
index 34592cd..1f71d4e 100644
--- a/org.eclipse.jdt.debug.ui/plugin.xml
+++ b/org.eclipse.jdt.debug.ui/plugin.xml
@@ -69,55 +69,6 @@
id="org.eclipse.jdt.debug.ui.actions.ManageBreakpointRulerAction">
</action>
</editorContribution>
- <editorContribution
- targetID="org.eclipse.jdt.debug.ui.SnippetEditor"
- id="org.eclipse.jdt.debug.ui.JavaSnippetToolbarActions">
- <action
- toolbarPath="evaluationGroup"
- id="org.eclipse.jdt.debug.ui.SnippetExecute"
- hoverIcon="$nl$/icons/full/etool16/run_sbook.gif"
- class="org.eclipse.jdt.internal.debug.ui.actions.ExecuteAction"
- disabledIcon="$nl$/icons/full/dtool16/run_sbook.gif"
- enablesFor="+"
- icon="$nl$/icons/full/etool16/run_sbook.gif"
- helpContextId="execute_action_context"
- label="%Execute.label"
- tooltip="%Execute.tooltip">
- <selection
- class="org.eclipse.jface.text.ITextSelection">
- </selection>
- </action>
- <action
- toolbarPath="evaluationGroup"
- id="org.eclipse.jdt.debug.ui.SnippetDisplay"
- hoverIcon="$nl$/icons/full/etool16/disp_sbook.gif"
- class="org.eclipse.jdt.internal.debug.ui.actions.PopupDisplayAction"
- disabledIcon="$nl$/icons/full/dtool16/disp_sbook.gif"
- enablesFor="+"
- icon="$nl$/icons/full/etool16/disp_sbook.gif"
- helpContextId="display_action_context"
- label="%Display.label"
- tooltip="%Display.tooltip">
- <selection
- class="org.eclipse.jface.text.ITextSelection">
- </selection>
- </action>
- <action
- toolbarPath="evaluationGroup"
- id="org.eclipse.jdt.debug.ui.SnippetInspect"
- hoverIcon="$nl$/icons/full/etool16/insp_sbook.gif"
- class="org.eclipse.jdt.internal.debug.ui.actions.PopupInspectAction"
- disabledIcon="$nl$/icons/full/dtool16/insp_sbook.gif"
- enablesFor="+"
- icon="$nl$/icons/full/etool16/insp_sbook.gif"
- helpContextId="inspect_action_context"
- label="%Inspect.label"
- tooltip="%Inspect.tooltip">
- <selection
- class="org.eclipse.jface.text.ITextSelection">
- </selection>
- </action>
- </editorContribution>
</extension>
<extension
point="org.eclipse.ui.actionSets">
@@ -197,7 +148,6 @@
<action
id="org.eclipse.jdt.debug.ui.actions.Execute"
hoverIcon="$nl$/icons/full/etool16/run_sbook.gif"
- class="org.eclipse.jdt.internal.debug.ui.actions.ExecuteAction"
definitionId="org.eclipse.jdt.debug.ui.commands.Execute"
disabledIcon="$nl$/icons/full/dtool16/run_sbook.gif"
enablesFor="+"
@@ -226,7 +176,6 @@
<action
id="org.eclipse.jdt.debug.ui.actions.Display"
hoverIcon="$nl$/icons/full/etool16/disp_sbook.gif"
- class="org.eclipse.jdt.internal.debug.ui.actions.PopupDisplayAction"
definitionId="org.eclipse.jdt.debug.ui.commands.Display"
disabledIcon="$nl$/icons/full/dtool16/disp_sbook.gif"
icon="$nl$/icons/full/etool16/disp_sbook.gif"
@@ -252,14 +201,14 @@
</enablement>
</action>
<action
- id="org.eclipse.jdt.debug.ui.actions.Inspect"
- hoverIcon="$nl$/icons/full/etool16/insp_sbook.gif"
class="org.eclipse.jdt.internal.debug.ui.actions.PopupInspectAction"
definitionId="org.eclipse.jdt.debug.ui.commands.Inspect"
disabledIcon="$nl$/icons/full/dtool16/insp_sbook.gif"
- icon="$nl$/icons/full/etool16/insp_sbook.gif"
- label="%Inspect.label"
helpContextId="inspect_action_context"
+ hoverIcon="$nl$/icons/full/etool16/insp_sbook.gif"
+ icon="$nl$/icons/full/etool16/insp_sbook.gif"
+ id="org.eclipse.jdt.debug.ui.actions.Inspect"
+ label="%Inspect.label"
menubarPath="org.eclipse.ui.run/jdtGroup">
<enablement>
<and>
@@ -429,6 +378,79 @@
</command>
</menuContribution>
<menuContribution
+ allPopups="false"
+ locationURI="popup:#JavaSnippetEditorContext?before=additions">
+ <separator
+ name="evaluationGroup"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.commands.Execute"
+ icon="$nl$/icons/full/etool16/run_sbook.gif"
+ mnemonic="x"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.commands.Display"
+ icon="$nl$/icons/full/etool16/disp_sbook.gif"
+ mnemonic="y"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.commands.Inspect"
+ icon="$nl$/icons/full/etool16/insp_sbook.gif"
+ mnemonic="e"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.stop.snippet.eval"
+ icon="$nl$/icons/full/etool16/term_sbook.gif"
+ mnemonic="o"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.select.imports"
+ icon="platform:/plugin/org.eclipse.jdt.ui/icons/full/obj16/impc_obj.gif"
+ mnemonic="r"
+ style="push">
+ </command>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="toolbar:org.eclipse.jdt.debug.ui.SnippetEditor">
+ <separator
+ name="evaluationGroup"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.commands.Execute"
+ icon="$nl$/icons/full/etool16/run_sbook.gif"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.commands.Display"
+ icon="$nl$/icons/full/etool16/disp_sbook.gif"
+ mnemonic="y"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.commands.Inspect"
+ icon="$nl$/icons/full/etool16/insp_sbook.gif"
+ mnemonic="e"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.stop.snippet.eval"
+ icon="$nl$/icons/full/etool16/term_sbook.gif"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.select.imports"
+ icon="platform:/plugin/org.eclipse.jdt.ui/icons/full/obj16/impc_obj.gif"
+ style="push">
+ </command>
+ </menuContribution>
+ <menuContribution
locationURI="menu:org.eclipse.debug.ui.ExpressionView">
<menu
id="org.eclipse.jdt.debug.ui.expSubmenu"
@@ -858,49 +880,6 @@
</visibility>
</objectContribution>
<viewerContribution
- targetID="#JavaSnippetEditorContext"
- id="org.eclipse.jdt.debug.ui.JavaSnippetPopupActions">
- <action
- label="%Execute.label"
- icon="$nl$/icons/full/etool16/run_sbook.gif"
- helpContextId="execute_action_context"
- definitionId="org.eclipse.jdt.debug.ui.commands.Execute"
- class="org.eclipse.jdt.internal.debug.ui.actions.ExecuteAction"
- menubarPath="additions"
- enablesFor="+"
- id="org.eclipse.jdt.debug.ui.actions.Execute">
- <selection
- class="org.eclipse.jface.text.ITextSelection">
- </selection>
- </action>
- <action
- label="%Display.label"
- icon="$nl$/icons/full/etool16/disp_sbook.gif"
- helpContextId="display_action_context"
- definitionId="org.eclipse.jdt.debug.ui.commands.Display"
- class="org.eclipse.jdt.internal.debug.ui.actions.PopupDisplayAction"
- menubarPath="additions"
- enablesFor="+"
- id="org.eclipse.jdt.debug.ui.actions.Display">
- <selection
- class="org.eclipse.jface.text.ITextSelection">
- </selection>
- </action>
- <action
- label="%Inspect.label"
- icon="$nl$/icons/full/etool16/insp_sbook.gif"
- helpContextId="inspect_action_context"
- definitionId="org.eclipse.jdt.debug.ui.commands.Inspect"
- class="org.eclipse.jdt.internal.debug.ui.actions.PopupInspectAction"
- menubarPath="additions"
- enablesFor="+"
- id="org.eclipse.jdt.debug.ui.actions.Inspect">
- <selection
- class="org.eclipse.jface.text.ITextSelection">
- </selection>
- </action>
- </viewerContribution>
- <viewerContribution
targetID="#ClassFileRulerContext"
id="org.eclipse.jdt.debug.ui.ClassFileRulerPopupActions">
<action
@@ -2632,22 +2611,25 @@
id="org.eclipse.jdt.debug.ui.commands.StepIntoSelection">
</command>
<command
- name="%ActionDefinition.execute.name"
+ categoryId="org.eclipse.debug.ui.category.run"
description="%ActionDefinition.execute.description"
- categoryId="org.eclipse.debug.ui.category.run"
- id="org.eclipse.jdt.debug.ui.commands.Execute">
+ helpContextId="execute_action_context"
+ id="org.eclipse.jdt.debug.ui.commands.Execute"
+ name="%ActionDefinition.execute.name">
</command>
<command
- name="%ActionDefinition.display.name"
+ categoryId="org.eclipse.debug.ui.category.run"
description="%ActionDefinition.display.description"
- categoryId="org.eclipse.debug.ui.category.run"
- id="org.eclipse.jdt.debug.ui.commands.Display">
+ helpContextId="display_action_context"
+ id="org.eclipse.jdt.debug.ui.commands.Display"
+ name="%ActionDefinition.display.name">
</command>
<command
- name="%ActionDefinition.inspect.name"
- description="%ActionDefinition.inspect.description"
categoryId="org.eclipse.debug.ui.category.run"
- id="org.eclipse.jdt.debug.ui.commands.Inspect">
+ description="%ActionDefinition.inspect.description"
+ helpContextId="inspect_action_context"
+ id="org.eclipse.jdt.debug.ui.commands.Inspect"
+ name="%ActionDefinition.inspect.name">
</command>
<command
name="%ActionDefinition.forceReturn.name"
@@ -2721,6 +2703,21 @@
</command>
<command
categoryId="org.eclipse.debug.ui.category.run"
+ defaultHandler="org.eclipse.jdt.internal.debug.ui.snippeteditor.SelectImportsHandler"
+ description="Sets the Import Declarations to use when running the snippet"
+ helpContextId="scrapbook_imports_action_context"
+ id="org.eclipse.jdt.debug.ui.select.imports"
+ name="Set Imports...">
+ </command>
+ <command
+ categoryId="org.eclipse.debug.ui.category.run"
+ description="Stops the evaluation and terminates the evaluation context"
+ helpContextId="terminate_scrapbook_vm_action_context"
+ id="org.eclipse.jdt.debug.ui.stop.snippet.eval"
+ name="Stop Evaluation">
+ </command>
+ <command
+ categoryId="org.eclipse.debug.ui.category.run"
defaultHandler="org.eclipse.jdt.internal.debug.ui.commands.VariableOptionsHandler"
description="%variablePreferences.tooltip"
helpContextId="edit_variable_preferences"
@@ -3703,4 +3700,45 @@
type="org.eclipse.swt.widgets.Composite"
description="%descriptionSWTComposite"/>
</extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.jdt.internal.debug.ui.snippeteditor.StopEvaluationHandler"
+ commandId="org.eclipse.jdt.debug.ui.stop.snippet.eval">
+ <enabledWhen>
+ <with
+ variable="activeEditor">
+ <test
+ args="activeEditor"
+ property="org.eclipse.jdt.debug.ui.snippetRunning"
+ value="true">
+ </test>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.eclipse.jdt.internal.debug.ui.actions.ExecuteSnippetHandler"
+ commandId="org.eclipse.jdt.debug.ui.commands.Execute">
+ <enabledWhen>
+ <and>
+ <with
+ variable="activeEditor">
+ <instanceof
+ value="org.eclipse.jdt.internal.debug.ui.snippeteditor.JavaSnippetEditor">
+ </instanceof>
+ </with>
+ </and>
+ </enabledWhen>
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.jdt.internal.debug.ui.JavaDebugUIPropertyTester"
+ id="org.eclipse.jdt.debug.ui.propertytester"
+ namespace="org.eclipse.jdt.debug.ui"
+ properties="snippetRunning"
+ type="java.lang.Object">
+ </propertyTester>
+ </extension>
</plugin>
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugUIPropertyTester.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugUIPropertyTester.java
new file mode 100644
index 0000000..bfa463e
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugUIPropertyTester.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) Jan 2, 2013 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.jdt.internal.debug.ui;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.jdt.internal.debug.ui.snippeteditor.JavaSnippetEditor;
+
+/**
+ *
+ */
+public class JavaDebugUIPropertyTester extends PropertyTester {
+
+ public static final String SNIPPET_RUNNING = "snippetRunning"; //$NON-NLS-1$
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if(SNIPPET_RUNNING.equals(property)) {
+ if(receiver instanceof JavaSnippetEditor) {
+ JavaSnippetEditor editor = (JavaSnippetEditor) receiver;
+ return editor.isEvaluating();
+ }
+ }
+ return false;
+ }
+}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/AbstractEvaluateHandler.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/AbstractEvaluateHandler.java
new file mode 100644
index 0000000..319ed28
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/AbstractEvaluateHandler.java
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) Jan 4, 2013 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.jdt.internal.debug.ui.actions;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.debug.core.IJavaValue;
+import org.eclipse.jdt.debug.eval.IEvaluationListener;
+import org.eclipse.jdt.debug.eval.IEvaluationResult;
+import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
+import org.eclipse.jdt.internal.debug.ui.display.IDataDisplay;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+
+import com.sun.jdi.InvocationException;
+import com.sun.jdi.ObjectReference;
+
+/**
+ * Default base class for all handlers that perform some kind of evaluation
+ *
+ * @since 3.6.200
+ */
+public abstract class AbstractEvaluateHandler extends AbstractHandler implements IEvaluationListener {
+
+ /**
+ * Display the given evaluation result.
+ */
+ abstract protected void displayResult(IEvaluationResult result);
+
+ /**
+ * Returns the target part this handler should use to resolve debug UI elements against
+ *
+ * @return the target {@link IWorkbenchPart}
+ */
+ abstract protected IWorkbenchPart getTargetPart();
+
+ /**
+ * Displays a failed evaluation message in the data display.
+ */
+ protected void reportErrors(IEvaluationResult result) {
+ String message= getErrorMessage(result);
+ reportError(message);
+ }
+
+ protected Shell getShell() {
+ if (getTargetPart() != null) {
+ return getTargetPart().getSite().getShell();
+ }
+ return JDIDebugUIPlugin.getActiveWorkbenchShell();
+ }
+
+ protected void reportError(String message) {
+ IDataDisplay dataDisplay= getDirectDataDisplay();
+ if (dataDisplay != null) {
+ if (message.length() != 0) {
+ dataDisplay.displayExpressionValue(NLS.bind(ActionMessages.EvaluateAction__evaluation_failed__Reason, new String[] {format(message)}));
+ } else {
+ dataDisplay.displayExpressionValue(ActionMessages.EvaluateAction__evaluation_failed__1);
+ }
+ } else {
+ Status status= new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, message, null);
+ ErrorDialog.openError(getShell(), ActionMessages.Evaluate_error_title_eval_problems, null, status);
+ }
+ }
+
+ protected String getErrorMessage(IEvaluationResult result) {
+ String[] errors= result.getErrorMessages();
+ if (errors.length == 0) {
+ return getExceptionMessage(result.getException());
+ }
+ return getErrorMessage(errors);
+ }
+
+ protected String getErrorMessage(String[] errors) {
+ String message= ""; //$NON-NLS-1$
+ for (int i= 0; i < errors.length; i++) {
+ String msg= errors[i];
+ if (i == 0) {
+ message= msg;
+ } else {
+ message= NLS.bind(ActionMessages.Evaluate_error_problem_append_pattern, new Object[] { message, msg });
+ }
+ }
+ return message;
+ }
+
+ public static String getExceptionMessage(Throwable exception) {
+ if (exception instanceof CoreException) {
+ CoreException ce = (CoreException)exception;
+ Throwable throwable= ce.getStatus().getException();
+ if (throwable instanceof com.sun.jdi.InvocationException) {
+ return getInvocationExceptionMessage((com.sun.jdi.InvocationException)throwable);
+ } else if (throwable instanceof CoreException) {
+ // Traverse nested CoreExceptions
+ return getExceptionMessage(throwable);
+ }
+ return ce.getStatus().getMessage();
+ }
+ String message= NLS.bind(ActionMessages.Evaluate_error_message_direct_exception, new Object[] { exception.getClass() });
+ if (exception.getMessage() != null) {
+ message= NLS.bind(ActionMessages.Evaluate_error_message_exception_pattern, new Object[] { message, exception.getMessage() });
+ }
+ return message;
+ }
+
+ /**
+ * Returns a message for the exception wrapped in an invocation exception
+ */
+ protected static String getInvocationExceptionMessage(com.sun.jdi.InvocationException exception) {
+ InvocationException ie= exception;
+ ObjectReference ref= ie.exception();
+ return NLS.bind(ActionMessages.Evaluate_error_message_wrapped_exception, new Object[] { ref.referenceType().name() });
+ }
+
+ private String format(String message) {
+ StringBuffer result= new StringBuffer();
+ int index= 0, pos;
+ while ((pos= message.indexOf('\n', index)) != -1) {
+ result.append("\t\t").append(message.substring(index, index= pos + 1)); //$NON-NLS-1$
+ }
+ if (index < message.length()) {
+ result.append("\t\t").append(message.substring(index)); //$NON-NLS-1$
+ }
+ return result.toString();
+ }
+
+ protected IDataDisplay getDataDisplay() {
+ IDataDisplay display= getDirectDataDisplay();
+ if (display != null) {
+ return display;
+ }
+ IWorkbenchPage page= JDIDebugUIPlugin.getActivePage();
+ if (page != null) {
+ IWorkbenchPart activePart= page.getActivePart();
+ if (activePart != null) {
+ IViewPart view = page.findView(IJavaDebugUIConstants.ID_DISPLAY_VIEW);
+ if (view == null) {
+ try {
+ view= page.showView(IJavaDebugUIConstants.ID_DISPLAY_VIEW);
+ } catch (PartInitException e) {
+ JDIDebugUIPlugin.statusDialog(ActionMessages.EvaluateAction_Cannot_open_Display_view, e.getStatus());
+ } finally {
+ page.activate(activePart);
+
+ }
+ }
+ if (view != null) {
+ page.bringToTop(view);
+ return (IDataDisplay)view.getAdapter(IDataDisplay.class);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ protected IDataDisplay getDirectDataDisplay() {
+ IWorkbenchPart part= getTargetPart();
+ if (part != null) {
+ IDataDisplay display= (IDataDisplay)part.getAdapter(IDataDisplay.class);
+ if (display != null) {
+ IWorkbenchPage page= JDIDebugUIPlugin.getActivePage();
+ if (page != null) {
+ IWorkbenchPart activePart= page.getActivePart();
+ if (activePart != null) {
+ if (activePart != part) {
+ page.activate(part);
+ }
+ }
+ }
+ return display;
+ }
+ }
+ IWorkbenchPage page= JDIDebugUIPlugin.getActivePage();
+ if (page != null) {
+ IWorkbenchPart activePart= page.getActivePart();
+ if (activePart != null) {
+ IDataDisplay display= (IDataDisplay)activePart.getAdapter(IDataDisplay.class);
+ if (display != null) {
+ return display;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see IEvaluationListener#evaluationComplete(IEvaluationResult)
+ */
+ public void evaluationComplete(final IEvaluationResult result) {
+ // if plug-in has shutdown, ignore - see bug# 8693
+ if (JDIDebugUIPlugin.getDefault() == null) {
+ return;
+ }
+
+ final IJavaValue value= result.getValue();
+ if (result.hasErrors() || value != null) {
+ final Display display= JDIDebugUIPlugin.getStandardDisplay();
+ if (display.isDisposed()) {
+ return;
+ }
+ displayResult(result);
+ }
+ }
+}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/EvaluateAction.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/EvaluateAction.java
index 8f072a1..7258bd8 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/EvaluateAction.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/EvaluateAction.java
@@ -15,7 +15,6 @@
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -23,17 +22,12 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.ISourceLocator;
-import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
-import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.debug.core.IJavaDebugTarget;
import org.eclipse.jdt.debug.core.IJavaObject;
import org.eclipse.jdt.debug.core.IJavaStackFrame;
@@ -46,6 +40,7 @@
import org.eclipse.jdt.debug.eval.IEvaluationResult;
import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
+import org.eclipse.jdt.internal.debug.core.JavaDebugUtils;
import org.eclipse.jdt.internal.debug.ui.EvaluationContextManager;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.internal.debug.ui.JavaWordFinder;
@@ -73,7 +68,6 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorActionDelegate;
-import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IPartListener;
@@ -237,9 +231,8 @@
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (stackFrame.isSuspended()) {
- IJavaElement javaElement= getJavaElement(stackFrame);
- if (javaElement != null) {
- IJavaProject project = javaElement.getJavaProject();
+ IJavaProject project = JavaDebugUtils.resolveJavaProject(stackFrame);
+ if(project != null) {
IEvaluationEngine engine = null;
try {
Object selection= getSelectedObject();
@@ -292,29 +285,6 @@
}
}
- protected IJavaElement getJavaElement(IStackFrame stackFrame) {
-
- // Get the corresponding element.
- ILaunch launch = stackFrame.getLaunch();
- if (launch == null) {
- return null;
- }
- ISourceLocator locator= launch.getSourceLocator();
- if (locator == null)
- return null;
-
- Object sourceElement = locator.getSourceElement(stackFrame);
- if (sourceElement instanceof IJavaElement) {
- return (IJavaElement) sourceElement;
- } else if (sourceElement instanceof IResource) {
- IJavaProject project = JavaCore.create(((IResource)sourceElement).getProject());
- if (project.exists()) {
- return project;
- }
- }
- return null;
- }
-
/**
* Updates the enabled state of the action that this is a
* delegate for.
@@ -337,7 +307,7 @@
if (selection instanceof ITextSelection) {
ITextSelection ts = (ITextSelection)selection;
String text= ts.getText();
- if (textHasContent(text)) {
+ if (text != null && text.length() > 0) {
selectedObject= text;
fRegion = new Region(ts.getOffset(), ts.getLength());
} else if (getTargetPart() instanceof IEditorPart) {
@@ -356,7 +326,7 @@
if (selection instanceof ITextSelection) {
ITextSelection ts = (ITextSelection)selection;
String text= ts.getText();
- if (textHasContent(text)) {
+ if (text != null && text.length() > 0) {
selectedObject= text;
} else if (editor instanceof ITextEditor) {
selectedObject= resolveSelectedObjectUsingToken(selectedObject, ts, editor);
@@ -402,31 +372,6 @@
return null;
}
- /**
- * Resolve an editor input from the source element of the stack frame
- * argument, and return whether it's equal to the editor input for the
- * editor that owns this action.
- */
- protected boolean compareToEditorInput(IStackFrame stackFrame) {
- ILaunch launch = stackFrame.getLaunch();
- if (launch == null) {
- return false;
- }
- ISourceLocator locator= launch.getSourceLocator();
- if (locator == null) {
- return false;
- }
- Object sourceElement = locator.getSourceElement(stackFrame);
- if (sourceElement == null) {
- return false;
- }
- IEditorInput sfEditorInput= getDebugModelPresentation().getEditorInput(sourceElement);
- if (getTargetPart() instanceof IEditorPart) {
- return ((IEditorPart)getTargetPart()).getEditorInput().equals(sfEditorInput);
- }
- return false;
- }
-
protected Shell getShell() {
if (getTargetPart() != null) {
return getTargetPart().getSite().getShell();
@@ -493,20 +438,6 @@
return null;
}
- protected boolean textHasContent(String text) {
- if (text != null) {
- int length= text.length();
- if (length > 0) {
- for (int i= 0; i < length; i++) {
- if (Character.isLetterOrDigit(text.charAt(i))) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
/**
* Displays a failed evaluation message in the data display.
*/
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ExecuteSnippetHandler.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ExecuteSnippetHandler.java
new file mode 100644
index 0000000..79be2d4
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ExecuteSnippetHandler.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) Jan 2, 2013 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.jdt.internal.debug.ui.actions;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jdt.debug.eval.IEvaluationResult;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
+import org.eclipse.jdt.internal.debug.ui.display.IDataDisplay;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Default handler for the 'Execute' command
+ *
+ * @since 3.6.200
+ */
+public class ExecuteSnippetHandler extends AbstractEvaluateHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ return null;
+ }
+
+ @Override
+ protected IWorkbenchPart getTargetPart() {
+ return null;
+ }
+
+ @Override
+ protected void displayResult(final IEvaluationResult result) {
+ if (result.hasErrors()) {
+ final Display display = JDIDebugUIPlugin.getStandardDisplay();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ if (display.isDisposed()) {
+ return;
+ }
+ reportErrors(result);
+ }
+ });
+ }
+ }
+
+ @Override
+ protected IDataDisplay getDataDisplay() {
+ return super.getDirectDataDisplay();
+ }
+}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetEditor.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetEditor.java
index b85ad8c..730ca7b 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetEditor.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/JavaSnippetEditor.java
@@ -76,12 +76,10 @@
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jdt.ui.IContextMenuConstants;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -120,7 +118,6 @@
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.TextOperationAction;
@@ -334,28 +331,8 @@
Action action = new TextOperationAction(SnippetMessages.getBundle(), "SnippetEditor.ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS); //$NON-NLS-1$
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
setAction("ContentAssistProposal", action);//$NON-NLS-1$
- setAction("ShowInPackageView", new ShowInPackageViewAction(this)); //$NON-NLS-1$
- setAction("Stop", new StopAction(this)); //$NON-NLS-1$
- setAction("SelectImports", new SelectImportsAction(this)); //$NON-NLS-1$
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- @Override
- protected void editorContextMenuAboutToShow(IMenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
- addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_GENERATE);
- addGroup(menu, ITextEditorActionConstants.GROUP_FIND, IContextMenuConstants.GROUP_SEARCH);
- addGroup(menu, IContextMenuConstants.GROUP_SEARCH, IContextMenuConstants.GROUP_SHOW);
- if (getFile() != null) {
- addAction(menu, IContextMenuConstants.GROUP_SHOW, "ShowInPackageView"); //$NON-NLS-1$
- addAction(menu, IContextMenuConstants.GROUP_ADDITIONS, "Run"); //$NON-NLS-1$
- addAction(menu, IContextMenuConstants.GROUP_ADDITIONS, "Stop"); //$NON-NLS-1$
- addAction(menu, IContextMenuConstants.GROUP_ADDITIONS, "SelectImports"); //$NON-NLS-1$
- }
- }
protected boolean isVMLaunched() {
return fVM != null;
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SelectImportsDialog.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SelectImportsDialog.java
index 135c17a..80522e9 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SelectImportsDialog.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SelectImportsDialog.java
@@ -31,21 +31,17 @@
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -53,7 +49,6 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.dialogs.SelectionDialog;
@@ -138,19 +133,11 @@
private void createImportButtons(Composite container) {
PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IJavaDebugHelpContextIds.SNIPPET_IMPORTS_DIALOG);
-
- // button container
- Composite buttonContainer = new Composite(container, SWT.NONE);
- GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
- buttonContainer.setLayoutData(gd);
- GridLayout buttonLayout = new GridLayout();
- buttonLayout.numColumns = 1;
- buttonLayout.marginHeight = 0;
- buttonLayout.marginWidth = 0;
- buttonContainer.setLayout(buttonLayout);
-
+ Composite bcomp = SWTFactory.createComposite(container, container.getFont(), 1, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL, 0, 0);
+ GridLayout gl = (GridLayout) bcomp.getLayout();
+ gl.verticalSpacing = 0;
// Add type button
- fAddTypeButton = SWTFactory.createPushButton(buttonContainer,
+ fAddTypeButton = SWTFactory.createPushButton(bcomp,
SnippetMessages.getString("SelectImportsDialog.Add_&Type_1"), //$NON-NLS-1$
SnippetMessages.getString("SelectImportsDialog.Choose_a_Type_to_Add_as_an_Import_2"), //$NON-NLS-1$
null);
@@ -163,7 +150,7 @@
});
// Add package button
- fAddPackageButton = SWTFactory.createPushButton(buttonContainer,
+ fAddPackageButton = SWTFactory.createPushButton(bcomp,
SnippetMessages.getString("SelectImportsDialog.Add_&Package_3"), //$NON-NLS-1$
SnippetMessages.getString("SelectImportsDialog.Choose_a_Package_to_Add_as_an_Import_4"), //$NON-NLS-1$
null);
@@ -176,7 +163,7 @@
});
// Remove button
- fRemoveImportsButton = SWTFactory.createPushButton(buttonContainer,
+ fRemoveImportsButton = SWTFactory.createPushButton(bcomp,
SnippetMessages.getString("SelectImportsDialog.&Remove_5"), //$NON-NLS-1$
SnippetMessages.getString("SelectImportsDialog.Remove_All_Selected_Imports_6"), //$NON-NLS-1$
null);
@@ -188,7 +175,6 @@
}
});
fRemoveImportsButton.setEnabled(false);
-
}
private void removeImports() {
@@ -266,34 +252,18 @@
*/
@Override
protected Control createDialogArea(Composite parent) {
- Font font = parent.getFont();
-
- Composite dialogComp = (Composite)super.createDialogArea(parent);
- // top level container
- Composite outer = new Composite(dialogComp, SWT.NONE);
- GridLayout topLayout = new GridLayout();
- topLayout.numColumns = 2;
- outer.setLayout(topLayout);
- outer.setFont(font);
-
setTitle(NLS.bind(SnippetMessages.getString("SelectImportsDialog.Manage_the_Java_Snippet_Editor_Imports_for___{0}__1"), new String[]{fEditor.getEditorInput().getName()})); //$NON-NLS-1$
-
- GridData gd = new GridData();
- gd.verticalAlignment = GridData.FILL;
- gd.horizontalAlignment = GridData.FILL;
- outer.setLayoutData(gd);
-
- // filter table
+ setMessage(NLS.bind(SnippetMessages.getString("SelectImportsDialog.add_remove_imports"), new String[]{fEditor.getEditorInput().getName()})); //$NON-NLS-1$
+ Composite outer = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH);
+ GridLayout gl = (GridLayout) outer.getLayout();
+ gl.marginLeft = 7;
+ gl.marginTop = 0;
+ gl.marginBottom = 0;
+ SWTFactory.createLabel(outer, SnippetMessages.getString("SelectImportsDialog.imports_heading"), 2); //$NON-NLS-1$
fImportsTable= new Table(outer, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
-
- TableLayout tableLayout= new TableLayout();
- ColumnLayoutData[] columnLayoutData= new ColumnLayoutData[1];
- columnLayoutData[0]= new ColumnWeightData(100);
- tableLayout.addColumnData(columnLayoutData[0]);
- fImportsTable.setLayout(tableLayout);
- fImportsTable.setFont(font);
- new TableColumn(fImportsTable, SWT.NONE);
-
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 150;
+ fImportsTable.setLayoutData(gd);
fImportsViewer = new TableViewer(fImportsTable);
fImportsViewer.setLabelProvider(new FilterLabelProvider());
fImportsViewer.setComparator(new FilterViewerComparator());
@@ -301,10 +271,6 @@
fImportsViewer.setContentProvider(fImportContentProvider);
// input just needs to be non-null
fImportsViewer.setInput(this);
- gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
- gd.widthHint = 100;
- gd.heightHint= 300;
- fImportsViewer.getTable().setLayoutData(gd);
fImportsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
@@ -315,10 +281,9 @@
}
}
});
-
createImportButtons(outer);
applyDialogFont(outer);
- return outer;
+ return parent;
}
/* (non-Javadoc)
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SelectImportsHandler.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SelectImportsHandler.java
new file mode 100644
index 0000000..5bbbe82
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SelectImportsHandler.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) Dec 31, 2012 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.jdt.internal.debug.ui.snippeteditor;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Default handler for the Set Imports action in the snippet editor used in
+ * the scrapbook page editor
+ *
+ * @since 3.6.200
+ */
+public class SelectImportsHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IEditorPart part = HandlerUtil.getActiveEditor(event);
+ if(part instanceof JavaSnippetEditor) {
+ JavaSnippetEditor editor = (JavaSnippetEditor) part;
+ if (!editor.isInJavaProject()) {
+ editor.reportNotInJavaProjectError();
+ }
+ else {
+ String[] imports = editor.getImports();
+ Dialog dialog = new SelectImportsDialog(editor, imports);
+ dialog.open();
+ }
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetEditorActionContributor.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetEditorActionContributor.java
index 19700ef..2cd2810 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetEditorActionContributor.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetEditorActionContributor.java
@@ -11,11 +11,8 @@
package org.eclipse.jdt.internal.debug.ui.snippeteditor;
-import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
import org.eclipse.jdt.internal.ui.javaeditor.BasicCompilationUnitEditorActionContributor;
import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
@@ -26,8 +23,6 @@
protected JavaSnippetEditor fSnippetEditor;
- private StopAction fStopAction;
- private SelectImportsAction fSelectImportsAction;
private SnippetOpenOnSelectionAction fOpenOnSelectionAction;
private SnippetOpenHierarchyOnSelectionAction fOpenOnTypeSelectionAction;
@@ -36,21 +31,6 @@
}
/* (non-Javadoc)
- * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(org.eclipse.jface.action.IToolBarManager)
- */
- @Override
- public void contributeToToolBar(IToolBarManager toolBarManager) {
-
- if (fStopAction == null) {
- toolBarManager.add(new Separator(IJavaDebugUIConstants.EVALUATION_GROUP));
- return;
- }
- toolBarManager.add(fStopAction);
- toolBarManager.add(fSelectImportsAction);
- toolBarManager.update(false);
- }
-
- /* (non-Javadoc)
* @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
@@ -86,8 +66,6 @@
}
if (fOpenOnSelectionAction != null) {
- fStopAction.setEditor(fSnippetEditor);
- fSelectImportsAction.setEditor(fSnippetEditor);
fOpenOnSelectionAction.setEditor(fSnippetEditor);
fOpenOnTypeSelectionAction.setEditor(fSnippetEditor);
}
@@ -99,12 +77,6 @@
fOpenOnSelectionAction= new SnippetOpenOnSelectionAction(fSnippetEditor);
fOpenOnTypeSelectionAction= new SnippetOpenHierarchyOnSelectionAction(fSnippetEditor);
- fStopAction= new StopAction(fSnippetEditor);
-
- fSelectImportsAction= new SelectImportsAction(fSnippetEditor);
- if (fSnippetEditor.getFile() == null) {
- fSelectImportsAction.setEnabled(false);
- }
}
protected void updateStatus(JavaSnippetEditor editor) {
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetMessages.properties b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetMessages.properties
index 053eabd..00ae3e6 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetMessages.properties
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/SnippetMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2009 IBM Corporation and others.
+# Copyright (c) 2000, 2012 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
@@ -21,9 +21,6 @@
ScrapbookLauncher.error.pagenotfound=Could not find a scrapbook page to launch
ScrapbookLauncher.error.title=Java Scrapbook Launcher
ScrapbookLauncher.17=[Scrapbook] {0}
-SelectImports.description=Sets the Import Declarations with which Code is Run
-SelectImports.label=Set Impo&rts...
-SelectImports.tooltip=Sets the Import Declarations for Running Code
SelectImportsDialog.&Remove_5=&Remove
SelectImportsDialog.&Select_a_package_to_add_as_an_Import_10=&Select the packages to add as imports:
@@ -31,11 +28,13 @@
SelectImportsDialog.Add_&Package_3=Add &Packages...
SelectImportsDialog.Add_&Type_1=Add &Type...
SelectImportsDialog.Add_package_as_import_7=Add Packages as Imports
+SelectImportsDialog.add_remove_imports=Add or remove package imports for {0}
SelectImportsDialog.Add_Type_as_Import_12=Add Type as Import
SelectImportsDialog.Choose_a_Package_to_Add_as_an_Import_4=Choose the Packages to Add as Imports
SelectImportsDialog.Choose_a_Type_to_Add_as_an_Import_2=Choose a Type to Add as an Import
SelectImportsDialog.Could_not_open_class_selection_dialog_13=Could not open class selection dialog
SelectImportsDialog.Could_not_open_package_selection_dialog_8=Could not open package selection dialog
+SelectImportsDialog.imports_heading=&Imports:
SelectImportsDialog.Java_Snippet_Imports_18=Java Snippet Imports
SelectImportsDialog.Manage_the_Java_Snippet_Editor_Imports_for___{0}__1=Manage the Java Snippet Editor Imports for \"{0}\"
SelectImportsDialog.Remove_All_Selected_Imports_6=Remove All Selected Imports
@@ -71,16 +70,6 @@
SnippetOpenOnSelectionDialog.message=&Select or enter the element to open:
SnippetOpenOnSelectionDialog.title=Open on Selection
-StopAction.description=Stop the evaluation and terminate the evaluation context
-StopAction.label=St&op Evaluation
-StopAction.tooltip=Stop the Evaluation
-
-ShowInPackageViewAction.label=Show in Pac&kage Explorer
-ShowInPackageViewAction.description=Show the selected element in Package Explorer
-ShowInPackageViewAction.tooltip=Show in Package Explorer
-ShowInPackageViewAction.dialog.title=Show In Package Explorer
-ShowInPackageViewAction.not_found=Cannot reveal the selected element in Package Explorer. The element may be filtered out.
-
NewSnippetFileCreationWizard.title=New Scrapbook Page
NewSnippetFileWizardPage.description=Create a new Java scrapbook page
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/StopEvaluationHandler.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/StopEvaluationHandler.java
new file mode 100644
index 0000000..963192a
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/snippeteditor/StopEvaluationHandler.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) Jan 2, 2013 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.jdt.internal.debug.ui.snippeteditor;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Default handler for the 'Stop Evaluation' action in the snippet editor
+ *
+ * @since 3.6.200
+ */
+public class StopEvaluationHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IEditorPart part = HandlerUtil.getActiveEditor(event);
+ if(part instanceof JavaSnippetEditor) {
+ JavaSnippetEditor editor = (JavaSnippetEditor) part;
+ editor.shutDownVM();
+ }
+ return null;
+ }
+
+}