UI separation refactoring
diff --git a/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/UIHelper.java b/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/UIHelper.java
index 69056ea..f9a0eb9 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/UIHelper.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/UIHelper.java
@@ -24,11 +24,13 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.ISchedulingRule;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.emf.common.notify.AdapterFactory;
 import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+import org.eclipse.emf.common.util.WrappedException;
 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
 import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
 import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
@@ -64,6 +66,7 @@
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.WorkbenchJob;
 
 /**
  * @author Phong Nguyen Le
@@ -606,4 +609,44 @@
 		BusyIndicator.showWhile(Display.getCurrent(), runnable);
 	}
 
+	public void runInUI(final IRunnableWithProgress runnable, String taskName) {
+		Shell shell = (Shell) LibraryEditPlugin.getDefault().getContext();
+		if (shell == null) {
+			try {
+				runnable.run(new NullProgressMonitor());
+				return;
+			} catch (Exception e) {
+				LibraryEditPlugin.getDefault().getLogger().logError(e);
+				throw new WrappedException(e);
+			}
+		}
+		Job job = new WorkbenchJob(taskName) {
+
+			public IStatus runInUIThread(IProgressMonitor monitor) {
+				monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+				try {
+					runnable.run(monitor);
+					return Status.OK_STATUS;
+				} catch (InvocationTargetException e) {
+					Throwable ex;
+					if (e.getCause() != null) {
+						ex = e.getCause();
+					} else {
+						ex = e;
+					}
+					return new Status(IStatus.ERROR, LibraryEditPlugin
+							.getPlugin().getId(), 0, ex.toString(), ex);
+				} catch (InterruptedException e) {
+					return new Status(IStatus.ERROR, LibraryEditPlugin
+							.getPlugin().getId(), 0, e.toString(), e);
+				} finally {
+					monitor.done();
+				}
+			}
+
+		};
+		PlatformUI.getWorkbench().getProgressService().showInDialog(shell, job);
+		job.schedule();
+	}
+
 }
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/IUIHelper.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/IUIHelper.java
index 179a6ab..ae6efae 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/IUIHelper.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/IUIHelper.java
@@ -42,6 +42,9 @@
 
 	public boolean runInUI(IRunnableWithProgress runnable,
 			ISchedulingRule rule, Object shell);
+	
+	public void runInUI(IRunnableWithProgress runnable,
+			String taskName);
 
 	IStatus runInModalContext(IRunnableWithProgress operation, boolean fork,
 			IProgressMonitor monitor, Object uiContext);