|
From: <mba...@us...> - 2006-12-30 09:43:18
|
Revision: 1746
http://svn.sourceforge.net/rubyeclipse/?rev=1746&view=rev
Author: mbarchfe
Date: 2006-12-30 01:43:16 -0800 (Sat, 30 Dec 2006)
Log Message:
-----------
next step for ruby debug integration
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/CodeReloadJob.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/InspectAction.java
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/CodeReloadJob.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/CodeReloadJob.java 2006-12-30 09:42:59 UTC (rev 1745)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/CodeReloadJob.java 2006-12-30 09:43:16 UTC (rev 1746)
@@ -38,7 +38,7 @@
if (!loadResult.isOk()) {
DebugUIPlugin.getStandardDisplay().syncExec(new Runnable() {
public void run() {
- MessageDialog.openInformation(DebugUIPlugin.getStandardDisplay().getActiveShell(), "Error during load: " + loadResult.getExceptionType(), loadResult.getExceptionMessage());
+ MessageDialog.openInformation(DebugUIPlugin.getStandardDisplay().getActiveShell(), "Error loading " + filename +": " + loadResult.getExceptionType(), loadResult.getExceptionMessage());
}
});
}
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/InspectAction.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/InspectAction.java 2006-12-30 09:42:59 UTC (rev 1745)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/actions/InspectAction.java 2006-12-30 09:43:16 UTC (rev 1746)
@@ -8,9 +8,14 @@
* compliance with the License. For further information see org.rubypeople.rdt/rdt.license.
*/
-
package org.rubypeople.rdt.internal.debug.ui.actions;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
@@ -23,64 +28,89 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
+import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin;
import org.rubypeople.rdt.internal.debug.core.model.RubyExpression;
import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
import org.rubypeople.rdt.internal.debug.core.model.RubyVariable;
public class InspectAction extends AbstractInspectAction implements IViewActionDelegate, IEditorActionDelegate {
+ private RubyVariable inspectResult;
- protected RubyStackFrame getRubyStackFrame() {
- IViewPart part = page.findView(IDebugUIConstants.ID_DEBUG_VIEW);
- if (part == null) {
- return null;
- }
- IDebugView launchView = (IDebugView) part;
- StructuredSelection selected = (StructuredSelection) launchView.getViewer().getSelection();
- if (selected.isEmpty()) {
- return null;
- }
- if (!(selected.getFirstElement() instanceof RubyStackFrame)) {
- return null;
- }
- return (RubyStackFrame) selected.getFirstElement();
+ protected RubyStackFrame getRubyStackFrame() {
+ IViewPart part = page.findView(IDebugUIConstants.ID_DEBUG_VIEW);
+ if (part == null) {
+ return null;
+ }
+ IDebugView launchView = (IDebugView) part;
+ StructuredSelection selected = (StructuredSelection) launchView.getViewer().getSelection();
+ if (selected.isEmpty()) {
+ return null;
+ }
+ if (!(selected.getFirstElement() instanceof RubyStackFrame)) {
+ return null;
+ }
+ return (RubyStackFrame) selected.getFirstElement();
- }
+ }
- public void run(IAction action) {
- final RubyStackFrame stackFrame = this.getRubyStackFrame();
- if (stackFrame == null) {
- MessageDialog.openInformation(
- page.getActivePart().getSite().getShell(),
- "No suitable stack frame",
- "Could not inspect because there is no context (a ruby stack frame) for inspection selected.");
- return;
- }
- if (!(selection instanceof ITextSelection)) {
- return;
- }
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- String selectedText = ((ITextSelection) selection).getText().replace('\n', ';');
- selectedText = selectedText.replace('\r', ' ');
- try {
- RubyVariable rubyVariable = stackFrame.getRubyDebuggerProxy().readInspectExpression(stackFrame, selectedText);
- showExpressionView();
- DebugPlugin.getDefault().getExpressionManager().addExpression(new RubyExpression(selectedText, rubyVariable));
- } catch (RubyProcessingException e) {
- MessageDialog.openInformation(page.getActivePart().getSite().getShell(), e.getRubyExceptionType(), "Could not inspect '" + selectedText + "': " + e.getMessage());
- }
- }
- });
- }
+ public void run(IAction action) {
+ final RubyStackFrame stackFrame = this.getRubyStackFrame();
+ if (stackFrame == null) {
+ MessageDialog.openInformation(page.getActivePart().getSite().getShell(), "No suitable stack frame", "Could not inspect because there is no context (a ruby stack frame) for inspection selected.");
+ return;
+ }
+ if (!(selection instanceof ITextSelection)) {
+ return;
+ }
+ final String selectedText = ((ITextSelection) selection).getText().replace('\n', ';').replace('\r', ' ');
+ String jobName = "Inspect " + (selectedText.length() < 20 ? selectedText : selectedText.substring(0, 19) + "...");
+ Job job = new Job(jobName) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("inspecting", IProgressMonitor.UNKNOWN);
+ IStatus result = null;
+ try {
+ inspectResult = stackFrame.getRubyDebuggerProxy().readInspectExpression(stackFrame, selectedText);
+ result = Status.OK_STATUS;
+ } catch (RubyProcessingException e) {
+ String message = e.getRubyExceptionType() + " inspecting '" + selectedText + "':\n" + e.getMessage();
+ result = new Status(IStatus.ERROR, RdtDebugCorePlugin.PLUGIN_ID, IStatus.ERROR, message, e);
+ }
+ return result;
+ }
- public void setActiveEditor(IAction action, IEditorPart targetEditor) {
- if (targetEditor == null || targetEditor.getEditorSite() == null) {
- this.page = null;
- } else {
- this.page = targetEditor.getEditorSite().getPage();
+ };
+ job.addJobChangeListener(new JobChangeAdapter() {
+ public void done(final IJobChangeEvent event) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ if (event.getResult().isOK()) {
+ showExpressionView();
+ DebugPlugin.getDefault().getExpressionManager().addExpression(new RubyExpression(selectedText, inspectResult));
+ }
+ // if (event.getResult().getSeverity() == IStatus.ERROR)
+ // {
+ // String message = event.getResult().getMessage();
+ // MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
+ // "Error", "Could not inspect '" + selectedText + "': "
+ // + message);
+ // }
+ }
+ });
+ }
+ });
+ job.setPriority(Job.SHORT);
+ job.schedule();
+ }
- }
- }
+ public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+ if (targetEditor == null || targetEditor.getEditorSite() == null) {
+ this.page = null;
+ } else {
+ this.page = targetEditor.getEditorSite().getPage();
+ }
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|