diff options
author | bvosburgh | 2012-05-23 19:54:56 +0000 |
---|---|---|
committer | bvosburgh | 2012-05-23 19:54:56 +0000 |
commit | 794fd11cec8da4bb859c0c1e657e0bf2b600d451 (patch) | |
tree | eca081ea75d3a295c3c0c3ec34608cffc8b2b58a | |
parent | a651bb639b786ce03a403f78e6eae52abe609d42 (diff) | |
download | webtools.dali-794fd11cec8da4bb859c0c1e657e0bf2b600d451.tar.gz webtools.dali-794fd11cec8da4bb859c0c1e657e0bf2b600d451.tar.xz webtools.dali-794fd11cec8da4bb859c0c1e657e0bf2b600d451.zip |
[379000] synchronize JPA selection with updates etc.
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentAttributeMapAsHandler.java | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentAttributeMapAsHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentAttributeMapAsHandler.java index 6362a224da..36eabcf594 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentAttributeMapAsHandler.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/PersistentAttributeMapAsHandler.java @@ -13,8 +13,14 @@ import java.util.Map; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +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.jface.viewers.IStructuredSelection; import org.eclipse.jpt.common.core.internal.utility.PlatformTools; +import org.eclipse.jpt.common.ui.internal.util.SWTUtil; +import org.eclipse.jpt.common.utility.internal.RunnableAdapter; import org.eclipse.jpt.jpa.core.context.PersistentAttribute; import org.eclipse.jpt.jpa.ui.selection.JpaSelectionManager; import org.eclipse.ui.ISources; @@ -110,14 +116,50 @@ public class PersistentAttributeMapAsHandler */ private void setJpaSelection(Object[] items) { if (items.length == 1) { - JpaSelectionManager mgr = this.getSelectionManager(); - mgr.setSelection(null); - mgr.setSelection((PersistentAttribute) items[0]); + new PostExecutionJob((PersistentAttribute) items[0]).schedule(); } } - private JpaSelectionManager getSelectionManager() { - return PlatformTools.getAdapter(PlatformUI.getWorkbench(), JpaSelectionManager.class); + /** + * This job will not run until any outstanding updates etc. are complete. + * As a result, the runnable dispatched to the UI thread will not run + * until the previously scheduled UI runnables are complete also (e.g. the + * events triggered by the aforementioned updates etc.). + */ + /* CU private */ static class PostExecutionJob + extends Job + { + private final Runnable setSelectionRunnable; + + PostExecutionJob(PersistentAttribute attribute) { + super("select attribute"); + this.setSelectionRunnable = new SetSelectionRunnable(attribute); + this.setRule(attribute.getJpaProject().getProject()); + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + SWTUtil.execute(this.setSelectionRunnable); + return Status.OK_STATUS; + } + + /* class private */ static class SetSelectionRunnable + extends RunnableAdapter + { + private final PersistentAttribute attribute; + + SetSelectionRunnable(PersistentAttribute attribute) { + super(); + this.attribute = attribute; + } + + @Override + public void run() { + JpaSelectionManager mgr = PlatformTools.getAdapter(PlatformUI.getWorkbench(), JpaSelectionManager.class); + mgr.setSelection(null); + mgr.setSelection(attribute); + } + } } public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) { |