Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2009-01-06 13:00:15 -0500
committerDarin Wright2009-01-06 13:00:15 -0500
commit2c923fdbd9ae3f70855b37a92a39689b799a53a7 (patch)
treefc545a94c26d8070d070bb589739568f5b1df031 /org.eclipse.debug.core
parentfc2cd2401bca0f8da3615a451bfd0b2f271c619d (diff)
downloadeclipse.platform.debug-2c923fdbd9ae3f70855b37a92a39689b799a53a7.tar.gz
eclipse.platform.debug-2c923fdbd9ae3f70855b37a92a39689b799a53a7.tar.xz
eclipse.platform.debug-2c923fdbd9ae3f70855b37a92a39689b799a53a7.zip
[r342] Bug 245314 - Populating variables view with logical structures is really slow
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java174
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java9
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java9
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ResumeCommand.java9
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java9
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepIntoCommand.java9
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepOverCommand.java9
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepReturnCommand.java9
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java9
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java9
10 files changed, 201 insertions, 54 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java
index 60e64e463..c3ad9c263 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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,8 @@ import org.eclipse.core.runtime.CoreException;
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.IJobChangeListener;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
@@ -34,6 +36,123 @@ import org.eclipse.debug.internal.core.DebugOptions;
public abstract class DebugCommand implements IDebugCommandHandler {
/**
+ * Job to update enabled state of action.
+ */
+ class UpdateJob extends Job implements IJobChangeListener {
+
+ /**
+ * The request to update
+ */
+ private IEnabledStateRequest request;
+
+ /**
+ * Whether this job has been run
+ */
+ private boolean run = false;
+
+ /**
+ * Creates a new job to update the specified request
+ *
+ * @param stateRequest
+ */
+ UpdateJob(IEnabledStateRequest stateRequest) {
+ super(getEnablementTaskName());
+ request = stateRequest;
+ setSystem(true);
+ setRule(createUpdateSchedulingRule(request));
+ getJobManager().addJobChangeListener(this);
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ run = true;
+ if (DebugOptions.DEBUG_COMMANDS) {
+ System.out.print("can execute command: " + DebugCommand.this); //$NON-NLS-1$
+ }
+ if (monitor.isCanceled()) {
+ if (DebugOptions.DEBUG_COMMANDS) {
+ System.out.println(" >> *CANCELED* <<"); //$NON-NLS-1$
+ }
+ request.cancel();
+ }
+ Object[] elements = request.getElements();
+ Object[] targets = new Object[elements.length];
+ if (!request.isCanceled()) {
+ for (int i = 0; i < elements.length; i++) {
+ targets[i] = getTarget(elements[i]);
+ if (targets[i] == null) {
+ request.setEnabled(false);
+ request.cancel();
+ if (DebugOptions.DEBUG_COMMANDS) {
+ System.out.println(" >> false (no adapter)"); //$NON-NLS-1$
+ }
+ }
+ }
+ if (monitor.isCanceled()) {
+ request.cancel();
+ }
+ }
+ if (!request.isCanceled()) {
+ targets = coalesce(targets);
+ monitor.beginTask(getEnablementTaskName(), targets.length);
+ try {
+ boolean executable = isExecutable(targets, monitor, request);
+ if (DebugOptions.DEBUG_COMMANDS) {
+ System.out.println(" >> " + executable); //$NON-NLS-1$
+ }
+ request.setEnabled(executable);
+ } catch (CoreException e) {
+ request.setStatus(e.getStatus());
+ request.setEnabled(false);
+ if (DebugOptions.DEBUG_COMMANDS) {
+ System.out.println(" >> ABORTED"); //$NON-NLS-1$
+ System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
+ }
+ }
+ }
+ monitor.setCanceled(request.isCanceled());
+ request.done();
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
+ */
+ public boolean belongsTo(Object family) {
+ return getUpdateJobFamily().equals(family);
+ }
+
+ public void aboutToRun(IJobChangeEvent event) {
+ }
+
+ public void awake(IJobChangeEvent event) {
+ }
+
+ public void done(IJobChangeEvent event) {
+ if (event.getJob() == this) {
+ if (!run) {
+ request.cancel();
+ request.done();
+ if (DebugOptions.DEBUG_COMMANDS) {
+ System.out.println(" >> *CANCELED* <<" + DebugCommand.this); //$NON-NLS-1$
+ }
+ }
+ getJobManager().removeJobChangeListener(this);
+ }
+ }
+
+ public void running(IJobChangeEvent event) {
+ }
+
+ public void scheduled(IJobChangeEvent event) {
+ }
+
+ public void sleeping(IJobChangeEvent event) {
+ }
+
+ }
+
+ /**
* Scheduling rule to serialize commands on an object
*/
class SerialPerObjectRule implements ISchedulingRule {
@@ -110,51 +229,8 @@ public abstract class DebugCommand implements IDebugCommandHandler {
}
public void canExecute(final IEnabledStateRequest request) {
- Job job = new Job(getEnablementTaskName()) {
- protected IStatus run(IProgressMonitor monitor) {
- if (DebugOptions.DEBUG_COMMANDS) {
- System.out.print("can execute command: " + DebugCommand.this); //$NON-NLS-1$
- }
- Object[] elements = request.getElements();
- Object[] targets = new Object[elements.length];
- for (int i = 0; i < elements.length; i++) {
- targets[i] = getTarget(elements[i]);
- if (targets[i] == null) {
- request.setEnabled(false);
- request.cancel();
- if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println(" >> false (no adapter)"); //$NON-NLS-1$
- }
- }
- }
- if (!request.isCanceled()) {
- targets = coalesce(targets);
- monitor.beginTask(getEnablementTaskName(), targets.length);
- try {
- boolean executable = isExecutable(targets, monitor, request);
- if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println(" >> " + executable); //$NON-NLS-1$
- }
- request.setEnabled(executable);
- } catch (CoreException e) {
- request.setStatus(e.getStatus());
- request.setEnabled(false);
- if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println(" >> ABORTED"); //$NON-NLS-1$
- System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
- }
- }
- }
- monitor.setCanceled(request.isCanceled());
- request.done();
- monitor.done();
- return Status.OK_STATUS;
- }
- };
- job.setSystem(true);
- job.setRule(createUpdateSchedulingRule(request));
+ Job job = new UpdateJob(request);
job.schedule();
-
}
/**
@@ -237,4 +313,12 @@ public abstract class DebugCommand implements IDebugCommandHandler {
return set.toArray();
}
}
+
+ /**
+ * Returns the job family for this command's "can execute" job.
+ *
+ * @return the job family for this command's "can execute" job
+ */
+ protected abstract Object getUpdateJobFamily();
+
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java
index 93f49189a..8540df1ba 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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
@@ -38,4 +38,11 @@ public class DisconnectCommand extends ForEachCommand implements IDisconnectHand
protected boolean isExecutable(Object target) {
return ((IDisconnect)target).canDisconnect();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
+ */
+ protected Object getUpdateJobFamily() {
+ return IDisconnectHandler.class;
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java
index fe4a6f073..692cf3080 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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
@@ -38,4 +38,11 @@ public class DropToFrameCommand extends StepCommand implements IDropToFrameHandl
protected void step(Object target) throws CoreException {
((IDropToFrame)target).dropToFrame();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
+ */
+ protected Object getUpdateJobFamily() {
+ return IDropToFrameHandler.class;
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ResumeCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ResumeCommand.java
index 3fbb24d6b..6a9ea43dc 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ResumeCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ResumeCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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
@@ -28,5 +28,12 @@ public class ResumeCommand extends SuspendCommand implements IResumeHandler {
protected boolean isExecutable(Object target) {
return ((ISuspendResume)target).canResume();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.commands.SuspendCommand#getUpdateJobFamily()
+ */
+ protected Object getUpdateJobFamily() {
+ return IResumeHandler.class;
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java
index ef5cf2f07..df01527e3 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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
@@ -88,4 +88,11 @@ public class StepFiltersCommand extends ForEachCommand implements IStepFiltersHa
}
return true;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
+ */
+ protected Object getUpdateJobFamily() {
+ return IStepFiltersHandler.class;
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepIntoCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepIntoCommand.java
index d96b0888d..368ad65ac 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepIntoCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepIntoCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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,11 @@ public class StepIntoCommand extends StepCommand implements IStepIntoHandler {
((IStep)target).stepInto();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
+ */
+ protected Object getUpdateJobFamily() {
+ return IStepIntoHandler.class;
+ }
+
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepOverCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepOverCommand.java
index fe48eb043..2535a2b38 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepOverCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepOverCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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
@@ -33,4 +33,11 @@ public class StepOverCommand extends StepCommand implements IStepOverHandler {
return ((IStep)target).canStepOver();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
+ */
+ protected Object getUpdateJobFamily() {
+ return IStepOverHandler.class;
+ }
+
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepReturnCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepReturnCommand.java
index 7110016a4..f8ade6827 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepReturnCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepReturnCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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,11 @@ public class StepReturnCommand extends StepCommand implements IStepReturnHandler
((IStep)target).stepReturn();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
+ */
+ protected Object getUpdateJobFamily() {
+ return IStepReturnHandler.class;
+ }
+
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java
index 94013d1b1..ef99bff4b 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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
@@ -32,4 +32,11 @@ public class SuspendCommand extends ForEachCommand implements ISuspendHandler {
protected boolean isExecutable(Object target) {
return ((ISuspendResume)target).canSuspend();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
+ */
+ protected Object getUpdateJobFamily() {
+ return ISuspendHandler.class;
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java
index 686154e66..85bc34ce7 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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
@@ -32,4 +32,11 @@ public class TerminateCommand extends ForEachCommand implements ITerminateHandle
protected boolean isExecutable(Object target) {
return ((ITerminate)target).canTerminate();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
+ */
+ protected Object getUpdateJobFamily() {
+ return ITerminateHandler.class;
+ }
}

Back to the top