UI separation re-factoring
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/LibraryViewDeleteAction.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/LibraryViewDeleteAction.java
index cd058ac..47f44fc 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/LibraryViewDeleteAction.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/LibraryViewDeleteAction.java
@@ -26,10 +26,10 @@
import org.eclipse.epf.authoring.ui.AuthoringUIResources;
import org.eclipse.epf.authoring.ui.editors.IEditorKeeper;
import org.eclipse.epf.authoring.ui.views.LibraryView;
-import org.eclipse.epf.common.ui.util.MsgBox;
import org.eclipse.epf.library.LibraryService;
import org.eclipse.epf.library.LibraryServiceUtil;
import org.eclipse.epf.library.edit.FeatureValueWrapperItemProvider;
+import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.epf.library.edit.command.DeleteMethodElementCommand;
import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
import org.eclipse.epf.library.edit.util.TngUtil;
@@ -239,7 +239,7 @@
}
IStatus status = UserInteractionHelper.checkModify(modifiedResources,
- MsgBox.getDefaultShell());
+ LibraryEditPlugin.getDefault().getContext());
if (!status.isOK()) {
AuthoringUIPlugin.getDefault().getMsgDialog().display(
AuthoringUIResources.deleteDialog_title,
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/ProcessAutoSynchronizeAction.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/ProcessAutoSynchronizeAction.java
index 09bb7bb..4108559 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/ProcessAutoSynchronizeAction.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/ProcessAutoSynchronizeAction.java
@@ -37,7 +37,6 @@
import org.eclipse.epf.uma.Process;
import org.eclipse.epf.uma.ProcessComponent;
import org.eclipse.epf.uma.TeamProfile;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorInput;
@@ -175,7 +174,7 @@
* @see org.eclipse.emf.edit.ui.action.CommandActionHandler#run()
*/
public void run() {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ org.eclipse.epf.library.edit.util.IRunnableWithProgress runnable = new org.eclipse.epf.library.edit.util.IRunnableWithProgress() {
/*
* (non-Javadoc)
*
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/UserInteractionHandler.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/UserInteractionHandler.java
index 93037de..c417965 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/UserInteractionHandler.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/actions/UserInteractionHandler.java
@@ -15,6 +15,7 @@
import java.util.List;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.epf.authoring.ui.wizards.NewConfigurationWizard;
import org.eclipse.epf.common.ui.util.ErrorDialogNoReason;
import org.eclipse.epf.common.ui.util.MsgBox;
@@ -24,6 +25,7 @@
import org.eclipse.epf.library.ui.LibraryUIPlugin;
import org.eclipse.epf.library.ui.dialogs.UncancelableListSelectionDialog;
import org.eclipse.epf.library.ui.dialogs.UserInputsDialog;
+import org.eclipse.epf.library.ui.providers.DelegateLabelProvider;
import org.eclipse.epf.uma.MethodConfiguration;
import org.eclipse.epf.uma.UmaPackage;
import org.eclipse.jface.dialogs.Dialog;
@@ -251,12 +253,13 @@
* org.eclipse.jface.viewers.ILabelProvider, boolean, java.util.List,
* java.lang.String, java.lang.String)
*/
- public List select(List objectsToSelect, ILabelProvider labelProvider,
+ public List select(List objectsToSelect, final IItemLabelProvider labelProvider,
boolean multiple, List intitialSelection, String title, String msg) {
+ ILabelProvider lp = new DelegateLabelProvider(labelProvider);
if (multiple) {
IStructuredContentProvider contentProvider = new ArrayContentProvider();
UncancelableListSelectionDialog dlg = new UncancelableListSelectionDialog(
- shell, objectsToSelect, contentProvider, labelProvider, msg);
+ shell, objectsToSelect, contentProvider, lp, msg);
dlg.setTitle(title);
dlg.setBlockOnOpen(true);
dlg.open();
@@ -271,7 +274,7 @@
}
} else {
ElementListSelectionDialog dlg = new ElementListSelectionDialog(
- shell, labelProvider);
+ shell, lp);
dlg.setBlockOnOpen(true);
dlg.setElements(objectsToSelect.toArray());
@@ -456,19 +459,4 @@
return dialog.getResult();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.epf.library.edit.command.IUserInteractionHandler#getRunnableContext()
- */
- public IRunnableContext getRunnableContext() {
- Shell shell;
- Object uiCtx = getUIContext();
- if (uiCtx instanceof Shell) {
- shell = (Shell) uiCtx;
- } else {
- shell = MsgBox.getDefaultShell();
- }
- return new ProgressMonitorDialog(shell);
- }
}
\ No newline at end of file
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/ConfigurationPage.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/ConfigurationPage.java
index 2914820..506ca3b 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/ConfigurationPage.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/ConfigurationPage.java
@@ -77,7 +77,6 @@
import org.eclipse.epf.uma.Process;
import org.eclipse.epf.uma.ProcessComponent;
import org.eclipse.epf.uma.util.UmaUtil;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
@@ -471,7 +470,7 @@
public void initializeConfigFactory() {
// loading the configuration closure might be slow,
// display a progress bar
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ org.eclipse.epf.library.edit.util.IRunnableWithProgress runnable = new org.eclipse.epf.library.edit.util.IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
createConfigurationClosure();
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java
index 787f5a7..a4473eb 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java
@@ -164,12 +164,9 @@
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
@@ -181,7 +178,6 @@
import org.eclipse.swt.dnd.HTMLTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
@@ -199,7 +195,6 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.views.markers.internal.MarkerAdapter;
@@ -797,7 +792,7 @@
boolean ret = UserInteractionHelper
.runWithProgress(
- new IRunnableWithProgress() {
+ new org.eclipse.epf.library.edit.util.IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException,
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ViewHelper.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ViewHelper.java
index fcd8d36..c6ec7e2 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ViewHelper.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ViewHelper.java
@@ -59,7 +59,6 @@
import org.eclipse.epf.uma.NamedElement;
import org.eclipse.epf.uma.ProcessComponent;
import org.eclipse.epf.uma.util.UmaUtil;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -453,7 +452,7 @@
if (lib == null)
return;
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ org.eclipse.epf.library.edit.util.IRunnableWithProgress runnable = new org.eclipse.epf.library.edit.util.IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
HashSet modifiedResources = new HashSet();
@@ -545,7 +544,7 @@
if (lib == null)
return;
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ org.eclipse.epf.library.edit.util.IRunnableWithProgress runnable = new org.eclipse.epf.library.edit.util.IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
@@ -678,7 +677,7 @@
if (lib == null)
return;
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ org.eclipse.epf.library.edit.util.IRunnableWithProgress runnable = new org.eclipse.epf.library.edit.util.IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
HashSet modifiedResources = new HashSet();
diff --git a/2.0/plugins/org.eclipse.epf.common.ui/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.common.ui/META-INF/MANIFEST.MF
index 78d2911..c2c9375 100644
--- a/2.0/plugins/org.eclipse.epf.common.ui/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.common.ui/META-INF/MANIFEST.MF
@@ -6,7 +6,7 @@
Bundle-Activator: org.eclipse.epf.common.ui.CommonUIPlugin
Import-Package: org.osgi.framework;version="1.3.0"
Eclipse-LazyStart: true
-Require-Bundle: org.eclipse.ui,
- org.eclipse.epf.common
+Require-Bundle: org.eclipse.ui;visibility:=reexport,
+ org.eclipse.epf.common;visibility:=reexport
Export-Package: org.eclipse.epf.common.ui,
org.eclipse.epf.common.ui.util
diff --git a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java
index 82f1f51..17bf3c8 100644
--- a/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java
+++ b/2.0/plugins/org.eclipse.epf.common.ui/src/org/eclipse/epf/common/ui/ContextProvider.java
@@ -1,6 +1,7 @@
package org.eclipse.epf.common.ui;
import org.eclipse.epf.common.IContextProvider;
+import org.eclipse.epf.common.ui.util.MsgBox;
/**
* content provider for non-ui plugins
@@ -12,7 +13,15 @@
public class ContextProvider implements IContextProvider {
public Object getContext() {
- return CommonUIPlugin.getDefault().getWorkbench().getDisplay().getActiveShell();
+ //TODO: revisit
+ Object ctx = null;
+ try {
+ ctx = CommonUIPlugin.getDefault().getWorkbench().getDisplay().getActiveShell();
+ }
+ catch(Exception e) {
+ //
+ }
+ return ctx != null ? ctx : MsgBox.getDefaultShell();
}
}
diff --git a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java
index a685937..0c5de2f 100644
--- a/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java
+++ b/2.0/plugins/org.eclipse.epf.common/src/org/eclipse/epf/common/AbstractActivator.java
@@ -71,7 +71,7 @@
private String installPath;
// The plug-in icon URL.
- private URL iconURL;
+ protected URL iconURL;
// The profiling flag.
private boolean profiling;
diff --git a/2.0/plugins/org.eclipse.epf.export.msp/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.export.msp/META-INF/MANIFEST.MF
index de6ab5b..8cf7491 100644
--- a/2.0/plugins/org.eclipse.epf.export.msp/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.export.msp/META-INF/MANIFEST.MF
@@ -11,7 +11,8 @@
org.eclipse.epf.publishing,
org.eclipse.epf.publishing.ui;visibility:=reexport,
org.eclipse.ui,
- org.eclipse.epf.common.ui
+ org.eclipse.epf.common.ui,
+ org.eclipse.epf.library.edit.ui
Eclipse-LazyStart: true
Bundle-Vendor: %providerName
Bundle-ClassPath: exportmsp.jar
diff --git a/2.0/plugins/org.eclipse.epf.export.msp/src/org/eclipse/epf/export/msp/ExportMSPXMLOperation.java b/2.0/plugins/org.eclipse.epf.export.msp/src/org/eclipse/epf/export/msp/ExportMSPXMLOperation.java
index 219403e..feef00f 100644
--- a/2.0/plugins/org.eclipse.epf.export.msp/src/org/eclipse/epf/export/msp/ExportMSPXMLOperation.java
+++ b/2.0/plugins/org.eclipse.epf.export.msp/src/org/eclipse/epf/export/msp/ExportMSPXMLOperation.java
@@ -13,8 +13,8 @@
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.epf.library.edit.util.IRunnableWithProgress;
import org.eclipse.epf.publishing.services.AbstractPublishManager;
-import org.eclipse.jface.operation.IRunnableWithProgress;
/**
* The Export Microsoft Project XML file operation.
diff --git a/2.0/plugins/org.eclipse.epf.export.msp/src/org/eclipse/epf/export/msp/ExportMSPXMLService.java b/2.0/plugins/org.eclipse.epf.export.msp/src/org/eclipse/epf/export/msp/ExportMSPXMLService.java
index 55ce725..c7dce7d 100644
--- a/2.0/plugins/org.eclipse.epf.export.msp/src/org/eclipse/epf/export/msp/ExportMSPXMLService.java
+++ b/2.0/plugins/org.eclipse.epf.export.msp/src/org/eclipse/epf/export/msp/ExportMSPXMLService.java
@@ -44,6 +44,7 @@
import org.eclipse.epf.library.edit.process.IBSItemProvider;
import org.eclipse.epf.library.edit.process.RoleDescriptorWrapperItemProvider;
import org.eclipse.epf.library.edit.process.TaskDescriptorWrapperItemProvider;
+import org.eclipse.epf.library.edit.ui.UIHelper;
import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
import org.eclipse.epf.library.edit.util.ConfigurableComposedAdapterFactory;
import org.eclipse.epf.library.edit.util.PredecessorList;
@@ -1329,7 +1330,7 @@
PublishProgressMonitorDialog dlg = new PublishProgressMonitorDialog(
Display.getCurrent().getActiveShell(), publishMgr
.getViewBuilder());
- boolean success = UserInteractionHelper.runWithProgress(operation,
+ boolean success = UIHelper.runWithProgress(operation,
dlg, true, ExportMSPResources.exportMSPWizard_title);
if (operation.getException() != null) {
throw operation.getException();
diff --git a/2.0/plugins/org.eclipse.epf.library.edit.ui/.classpath b/2.0/plugins/org.eclipse.epf.library.edit.ui/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/2.0/plugins/org.eclipse.epf.library.edit.ui/.project b/2.0/plugins/org.eclipse.epf.library.edit.ui/.project
new file mode 100644
index 0000000..f839d92
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.epf.library.edit.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/2.0/plugins/org.eclipse.epf.library.edit.ui/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.library.edit.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..d21d86c
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Library Edit UI Plug-in
+Bundle-SymbolicName: org.eclipse.epf.library.edit.ui;singleton:=true
+Bundle-Version: 1.5.0
+Bundle-Activator: org.eclipse.epf.library.edit.ui.LibraryEditUIPlugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.epf.common.ui,
+ org.eclipse.epf.library.edit,
+ org.eclipse.emf.edit.ui
+Eclipse-LazyStart: true
+Export-Package: org.eclipse.epf.library.edit.ui
diff --git a/2.0/plugins/org.eclipse.epf.library.edit.ui/build.properties b/2.0/plugins/org.eclipse.epf.library.edit.ui/build.properties
new file mode 100644
index 0000000..e9863e2
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit.ui/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/2.0/plugins/org.eclipse.epf.library.edit.ui/plugin.xml b/2.0/plugins/org.eclipse.epf.library.edit.ui/plugin.xml
new file mode 100644
index 0000000..0f64136
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit.ui/plugin.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.epf.library.edit.uiHelper">
+ <uiHelper
+ class="org.eclipse.epf.library.edit.ui.UIHelper">
+ </uiHelper>
+ </extension>
+
+</plugin>
diff --git a/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/LibraryEditUIPlugin.java b/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/LibraryEditUIPlugin.java
new file mode 100644
index 0000000..81eceef
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/LibraryEditUIPlugin.java
@@ -0,0 +1,50 @@
+package org.eclipse.epf.library.edit.ui;
+
+import org.eclipse.epf.common.ui.AbstractPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class LibraryEditUIPlugin extends AbstractPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.epf.library.edit.ui";
+
+ // The shared instance
+ private static LibraryEditUIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public LibraryEditUIPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static LibraryEditUIPlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/ProcessListSelectionDialog.java b/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/ProcessListSelectionDialog.java
similarity index 100%
rename from 2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/ProcessListSelectionDialog.java
rename to 2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/ProcessListSelectionDialog.java
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/TeamSelection.java b/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/TeamSelection.java
similarity index 77%
rename from 2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/TeamSelection.java
rename to 2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/TeamSelection.java
index 494d7b8..73444b9 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/TeamSelection.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/TeamSelection.java
@@ -14,14 +14,14 @@
import java.util.List;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.epf.library.edit.LibraryEditResources;
import org.eclipse.epf.library.edit.TngAdapterFactory;
import org.eclipse.epf.library.edit.command.IUserInteractionHandler;
+import org.eclipse.epf.library.edit.util.AdapterFactoryItemLabelProvider;
import org.eclipse.epf.library.edit.util.ExtensionManager;
import org.eclipse.epf.uma.Role;
import org.eclipse.epf.uma.TeamProfile;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
@@ -76,36 +76,31 @@
final IUserInteractionHandler uiHandler = ExtensionManager
.getDefaultUserInteractionHandler();
if (uiHandler != null) {
- final ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
+ final IItemLabelProvider labelProvider = new AdapterFactoryItemLabelProvider(
TngAdapterFactory.INSTANCE.getOBS_ComposedAdapterFactory());
final String title = LibraryEditResources.selectTeamsDialog_title;
final String msg = NLS.bind(LibraryEditResources.selectTeamsDialog_text, (new Object[] { role.getName() }));
- try {
- final List finalSelected = new ArrayList();
- final List finalTeams = new ArrayList();
- finalTeams.addAll(teamList);
-
- UserInteractionHelper.runInUIThread(new Runnable() {
- public void run() {
- List selected = uiHandler.select(finalTeams, labelProvider, false,
- finalTeams, title, msg);
-
- if (selected != null)
- finalSelected.addAll(selected);
- }
- });
-
- if (finalSelected == null) {
- throw new OperationCanceledException();
+ final List finalSelected = new ArrayList();
+ final List finalTeams = new ArrayList();
+ finalTeams.addAll(teamList);
+
+ UserInteractionHelper.getUIHelper().runSafely(new Runnable() {
+ public void run() {
+ List selected = uiHandler.select(finalTeams, labelProvider, false,
+ finalTeams, title, msg);
+
+ if (selected != null)
+ finalSelected.addAll(selected);
}
- if(finalSelected.isEmpty()) {
- return null;
- }
- return (TeamProfile) finalSelected.get(0);
+ }, true);
+
+ if (finalSelected == null) {
+ throw new OperationCanceledException();
}
- finally {
- labelProvider.dispose();
+ if(finalSelected.isEmpty()) {
+ return null;
}
+ return (TeamProfile) finalSelected.get(0);
}
// no user interaction handler available
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
new file mode 100644
index 0000000..69056ea
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit.ui/src/org/eclipse/epf/library/edit/ui/UIHelper.java
@@ -0,0 +1,609 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2008 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 implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.library.edit.ui;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+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.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.epf.common.ui.util.MsgBox;
+import org.eclipse.epf.library.edit.LibraryEditPlugin;
+import org.eclipse.epf.library.edit.LibraryEditResources;
+import org.eclipse.epf.library.edit.TngAdapterFactory;
+import org.eclipse.epf.library.edit.process.BSActivityItemProvider;
+import org.eclipse.epf.library.edit.util.ExposedAdapterFactory;
+import org.eclipse.epf.library.edit.util.ExtensionManager;
+import org.eclipse.epf.library.edit.util.IRunnableWithProgress;
+import org.eclipse.epf.library.edit.util.ProcessUtil;
+import org.eclipse.epf.library.edit.util.TngUtil;
+import org.eclipse.epf.uma.Activity;
+import org.eclipse.epf.uma.BreakdownElement;
+import org.eclipse.epf.uma.MethodElement;
+import org.eclipse.epf.uma.Process;
+import org.eclipse.epf.uma.ProcessComponent;
+import org.eclipse.epf.uma.Role;
+import org.eclipse.epf.uma.TeamProfile;
+import org.eclipse.epf.uma.VariabilityType;
+import org.eclipse.epf.uma.WorkProduct;
+import org.eclipse.epf.uma.util.MessageException;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.ModalContext;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Phong Nguyen Le
+ * @since 1.5
+ *
+ */
+public class UIHelper implements IUIHelper {
+ /**
+ * Get teams in scope
+ *
+ * @param adapterFactory
+ * @param e
+ * @param role
+ * @param teamList
+ */
+ private static void getTeamsInScope(AdapterFactory adapterFactory,
+ BreakdownElement e, Role role, List teamList) {
+ // get children for activity
+ ITreeItemContentProvider itemProvider = (ITreeItemContentProvider) adapterFactory
+ .adapt(e, ITreeItemContentProvider.class);
+ Collection children = itemProvider.getChildren(e);
+ for (Iterator itor = children.iterator(); itor.hasNext();) {
+ Object obj = itor.next();
+ if (obj instanceof TeamProfile) {
+ TeamProfile team = (TeamProfile) obj;
+ List allTeams = new ArrayList();
+ // get all sub teams as well
+ ProcessUtil.getAllSubTeams(team, allTeams);
+
+ for (Iterator teamItor = allTeams.iterator(); teamItor
+ .hasNext();) {
+ Object o = teamItor.next();
+ if (o instanceof TeamProfile) {
+ // get roles from teams
+ List roles = ProcessUtil.getRoles(((TeamProfile) o)
+ .getTeamRoles());
+ if (roles.contains(role)) {
+ teamList.add(o);
+ }
+ }
+ }
+ }
+ }
+
+ // get parent
+ Object currentParent = itemProvider.getParent(e);
+ if (currentParent != null) {
+ // go up
+ getTeamsInScope(adapterFactory, (BreakdownElement) currentParent,
+ role, teamList);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.epf.library.edit.util.IUIHelper#getTeam(org.eclipse.epf.uma.Activity, org.eclipse.epf.uma.Role, java.lang.Object)
+ */
+ public TeamProfile getTeam(Activity activity, Role role, Object UIContext) {
+ List teamList = new ArrayList();
+ AdapterFactory adapterFactory = TngAdapterFactory.INSTANCE
+ .getOBS_ComposedAdapterFactory();
+ // find out all team in visible scope
+ getTeamsInScope(adapterFactory, activity, role, teamList);
+ if (teamList.size() == 1) {
+ return (TeamProfile) teamList.get(0);
+ }
+ if (teamList.size() > 1) {
+ return TeamSelection.getSelectedTeam(teamList, role,
+ UIContext instanceof Shell ? (Shell) UIContext : null);
+ }
+ // there are no teams to assign
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.epf.library.edit.util.IUIHelper#runInModalContext(org.eclipse.epf.library.edit.util.IRunnableWithProgress, boolean, org.eclipse.core.runtime.IProgressMonitor, java.lang.Object)
+ */
+ public IStatus runInModalContext(final IRunnableWithProgress operation,
+ boolean fork, IProgressMonitor monitor, Object uiContext) {
+ org.eclipse.jface.operation.IRunnableWithProgress op = new org.eclipse.jface.operation.IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ operation.run(monitor);
+ }
+
+ };
+ try {
+ ModalContext.run(op, true, monitor, ((Shell)uiContext)
+ .getDisplay());
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ LibraryEditPlugin.INSTANCE.log(e);
+ Throwable ex;
+ if (e instanceof InvocationTargetException) {
+ ex = ((InvocationTargetException) e)
+ .getTargetException();
+ } else {
+ ex = e;
+ }
+ String msg = TngUtil.toStackTraceString(ex);
+ return new Status(IStatus.ERROR,
+ LibraryEditPlugin.INSTANCE.getSymbolicName(), 0,
+ msg, ex);
+ }
+
+ }
+
+ public List selectTasks(List taskList, WorkProduct wp) {
+ ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
+ TngAdapterFactory.INSTANCE
+ .getNavigatorView_ComposedAdapterFactory()) {
+ public String getColumnText(Object obj, int column) {
+ if (obj instanceof MethodElement) {
+ return TngUtil.getPresentationName(obj);
+ }
+ return super.getText(obj);
+ }
+ };
+
+ IStructuredContentProvider contentProvider = new AdapterFactoryContentProvider(
+ TngAdapterFactory.INSTANCE
+ .getNavigatorView_ComposedAdapterFactory()) {
+ public Object[] getElements(Object object) {
+ return ((List) object).toArray();
+ }
+ };
+
+ try {
+ ProcessListSelectionDialog dlg = new ProcessListSelectionDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell(),
+ taskList,
+ contentProvider,
+ labelProvider,
+ NLS
+ .bind(
+ LibraryEditResources.ui_UserInteractionHelper_wplistdlg_msg,
+ wp.getName()));
+
+ dlg.setTitle(LibraryEditResources.ui_UserInteractionHelper_tasks);
+ dlg.setBlockOnOpen(true);
+ dlg.open();
+ Object[] objs = dlg.getResult();
+
+ List selectedTasks = new ArrayList();
+ if ((objs != null) && (objs.length > 0)) {
+ for (int i = 0; i < objs.length; i++) {
+ selectedTasks.add(objs[i]);
+ }
+ }
+ return selectedTasks;
+ } finally {
+ // dispose
+ labelProvider.dispose();
+ contentProvider.dispose();
+ }
+ }
+
+ public List selectWorkProducts(List wpList, Role role) {
+ ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
+ TngAdapterFactory.INSTANCE
+ .getNavigatorView_ComposedAdapterFactory()) {
+ public String getColumnText(Object obj, int column) {
+ if (obj instanceof MethodElement) {
+ return TngUtil.getPresentationName(obj);
+ }
+ return super.getText(obj);
+ }
+ };
+
+ IStructuredContentProvider contentProvider = new AdapterFactoryContentProvider(
+ TngAdapterFactory.INSTANCE
+ .getNavigatorView_ComposedAdapterFactory()) {
+ public Object[] getElements(Object object) {
+ return ((List) object).toArray();
+ }
+ };
+
+ try {
+ ProcessListSelectionDialog dlg = new ProcessListSelectionDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell(),
+ // MsgBox.getDefaultShell(),
+ wpList,
+ contentProvider,
+ labelProvider,
+ NLS
+ .bind(
+ LibraryEditResources.ui_UserInteractionHelper_rolelistdlg_msg,
+ role.getName()));
+
+ dlg
+ .setTitle(LibraryEditResources.ui_UserInteractionHelper_workproducts);
+ dlg.setBlockOnOpen(true);
+ dlg.open();
+ Object[] objs = dlg.getResult();
+
+ List selectedWps = new ArrayList();
+ if ((objs != null) && (objs.length > 0)) {
+ for (int i = 0; i < objs.length; i++) {
+ selectedWps.add(objs[i]);
+ }
+ }
+ return selectedWps;
+ } finally {
+ // dispose
+ labelProvider.dispose();
+ contentProvider.dispose();
+ }
+ }
+
+ private static class RunnableWithProgress implements org.eclipse.jface.operation.IRunnableWithProgress {
+ private IRunnableWithProgress operation;
+
+ public RunnableWithProgress(IRunnableWithProgress op) {
+ this.operation = op;
+ }
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ operation.run(monitor);
+ }
+
+ }
+
+ public IStatus runAsJob(final IRunnableWithProgress runnable, String taskName,
+ Object shell) {
+ Job job = new WorkspaceJob(taskName) {
+
+ public IStatus runInWorkspace(IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ // monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
+ 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) shell, job);
+ job.schedule();
+ return job.getResult();
+ }
+
+ public boolean runInUI(IRunnableWithProgress runnable,
+ ISchedulingRule rule, Object shell) {
+ if (shell == null) {
+ shell = LibraryEditPlugin.getDefault().getContext();
+ }
+ IRunnableContext context = new ProgressMonitorDialog((Shell) shell);
+ try {
+ PlatformUI.getWorkbench().getProgressService().runInUI(context,
+ new RunnableWithProgress(runnable), rule);
+ return true;
+ } catch (Exception e) {
+ LibraryEditPlugin.getDefault().getLogger().logError(e);
+ String title = LibraryEditResources.errorDialog_title;
+ ExtensionManager.getDefaultUserInteractionHandler().getMessenger()
+ .showError(title, e.toString(), null, e);
+// LibraryEditPlugin.getDefault().getMsgDialog().displayError(title,
+// e.toString(), e);
+ }
+ return false;
+ }
+
+ public static boolean runWithProgress(final IRunnableWithProgress runnable,
+ final IRunnableContext runnableContext, final boolean canCancel, final String msg) {
+ final MultiStatus status = new MultiStatus(LibraryEditPlugin.INSTANCE
+ .getSymbolicName(), IStatus.OK,
+ LibraryEditResources.error_reason, null);
+
+ final org.eclipse.jface.operation.IRunnableWithProgress operation = new org.eclipse.jface.operation.IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ monitor.beginTask(msg, IProgressMonitor.UNKNOWN);
+ monitor.subTask(""); //$NON-NLS-1$
+ try {
+ runnable.run(monitor);
+ } catch (RuntimeException e) {
+ String msg;
+ if (e instanceof MessageException) {
+ msg = e.getMessage();
+ } else {
+ StringWriter strWriter = new StringWriter();
+ e.printStackTrace(new PrintWriter(strWriter));
+ msg = strWriter.toString();
+ }
+ status.add(new Status(IStatus.ERROR,
+ LibraryEditPlugin.INSTANCE.getSymbolicName(), 0,
+ msg, e));
+ } finally {
+ monitor.done();
+ }
+ }
+
+ };
+
+ try {
+ if (Display.getCurrent() == null) {
+ // current thread is not a user-interface thread
+ //
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ runnableContext.run(true, canCancel, operation);
+ } catch (Exception e) {
+ LibraryEditPlugin.getDefault().getLogger().logError(e);
+ }
+ }
+
+ });
+ } else {
+ runnableContext.run(true, canCancel, operation);
+ }
+
+ if (!status.isOK()) {
+ ExtensionManager.getDefaultUserInteractionHandler()
+ .getMessenger().showError(
+ LibraryEditResources.errorDialog_title,
+ LibraryEditResources.error_msgWithDetails,
+ status);
+ } else {
+ return true;
+ }
+ } catch (Exception exception) {
+ // Something went wrong that shouldn't.
+ //
+ LibraryEditPlugin.getDefault().getLogger().logError(exception);
+ }
+
+ return false;
+ }
+
+ public boolean runWithProgress(IRunnableWithProgress runnable,
+ boolean canCancel, String msg) {
+ return runWithProgress(runnable, getRunnableContext(), false, msg);
+ }
+
+ public IRunnableContext getRunnableContext() {
+ Shell shell;
+ Object uiCtx = ExtensionManager.getDefaultUserInteractionHandler().getUIContext();
+ if (uiCtx instanceof Shell) {
+ shell = (Shell) uiCtx;
+ } else {
+ shell = MsgBox.getDefaultShell();
+ }
+ return new ProgressMonitorDialog(shell);
+ }
+
+ public static Viewer doGetViewer(AdapterFactory adapterFactory, Process proc) {
+ if (adapterFactory instanceof ExposedAdapterFactory) {
+ for (Iterator iter = Collections.unmodifiableList(
+ ((ExposedAdapterFactory) adapterFactory)
+ .getChangeListeners()).iterator(); iter.hasNext();) {
+ Object listener = iter.next();
+ if (listener instanceof IContentProvider && listener instanceof IViewerProvider) {
+ Viewer viewer = ((IViewerProvider) listener).getViewer();
+ if (viewer.getInput() instanceof ProcessComponent
+ && ((ProcessComponent) viewer.getInput())
+ .getProcess() == proc)
+ return viewer;
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean refreshNeeded(AdapterFactory adapterFactory,
+ BSActivityItemProvider itemProvider) {
+ Process process = (Process) itemProvider.getTopItem();
+ if (process == null)
+ return false;
+
+ // check if the given process is currently opened in editor
+ //
+ Viewer viewer = doGetViewer(adapterFactory, process);
+ if (viewer != null && viewer.getControl() != null
+ && !viewer.getControl().isDisposed()) {
+ return true;
+ }
+
+ for (Iterator iter = TngUtil.getContributors(process); iter.hasNext();) {
+ Object element = iter.next();
+ BSActivityItemProvider adapter = (BSActivityItemProvider) adapterFactory
+ .adapt(element, ITreeItemContentProvider.class);
+ if (refreshNeeded(adapterFactory, adapter))
+ return true;
+ }
+
+ for (Iterator iter = TngUtil.getGeneralizers(process,
+ VariabilityType.EXTENDS_LITERAL); iter.hasNext();) {
+ Object element = iter.next();
+ BSActivityItemProvider adapter = (BSActivityItemProvider) adapterFactory
+ .adapt(element, ITreeItemContentProvider.class);
+ if (refreshNeeded(adapterFactory, adapter))
+ return true;
+ }
+
+ return false;
+ }
+
+ public void refreshAllViewers(final ExposedAdapterFactory adapterFactory) {
+ UserInteractionHelper.getUIHelper().runSafely(new Runnable() {
+
+ public void run() {
+ for (Iterator iter = Collections.unmodifiableList(
+ adapterFactory.getChangeListeners()).iterator(); iter.hasNext();) {
+ Object listener = iter.next();
+ if (listener instanceof IContentProvider && listener instanceof IViewerProvider) {
+ Viewer viewer = ((IViewerProvider) listener).getViewer();
+ if (viewer != null && viewer.getControl() != null
+ && !viewer.getControl().isDisposed()
+ && viewer.getInput() instanceof ProcessComponent) {
+ viewer.refresh();
+ }
+ }
+ }
+ }
+
+ }, true);
+ }
+
+ public void refreshViewer(AdapterFactory factory, Process proc) {
+ final Viewer viewer = doGetViewer(factory, proc);
+ if (viewer != null && viewer.getControl() != null
+ && !viewer.getControl().isDisposed()) {
+ UserInteractionHelper.getUIHelper().runSafely(new Runnable() {
+
+ public void run() {
+ viewer.refresh();
+ }
+
+ }, true);
+ }
+ }
+
+ public void refreshIDsInViewer(final ExposedAdapterFactory adapterFactory) {
+ UserInteractionHelper.getUIHelper().runSafely(new Runnable() {
+
+ public void run() {
+ for (Iterator iter = Collections.unmodifiableList(
+ adapterFactory.getChangeListeners()).iterator(); iter.hasNext();) {
+ Object listener = iter.next();
+ if (listener instanceof IContentProvider && listener instanceof IViewerProvider) {
+ Viewer viewer = ((IViewerProvider) listener).getViewer();
+ if (viewer != null && viewer.getControl() != null
+ && !viewer.getControl().isDisposed()
+ && viewer.getInput() instanceof ProcessComponent) {
+ Process proc = ((ProcessComponent) viewer.getInput())
+ .getProcess();
+ BSActivityItemProvider itemProvider = (BSActivityItemProvider) adapterFactory
+ .adapt(proc, ITreeItemContentProvider.class);
+ if (itemProvider.isRefreshAllIDsRequired()) {
+ ProcessUtil.updateIDs(adapterFactory, proc);
+ viewer.refresh();
+ itemProvider.setRefreshAllIDsRequired(false);
+ }
+ }
+ }
+ }
+ }
+
+ }, true);
+ }
+
+ public Object getViewer(AdapterFactory adapterFactory, Process proc) {
+ return doGetViewer(adapterFactory, proc);
+ }
+
+ public void runSafely(final Runnable runnable, boolean synchronous) {
+ Display display = null;
+ try {
+ display = Display.getCurrent();
+ } catch (Exception e) {
+ //
+ }
+
+ Runnable runner = new Runnable() {
+
+ public void run() {
+ try {
+ runnable.run();
+ } catch (Exception e) {
+ LibraryEditUIPlugin.getDefault().getLogger().logError(e);
+ }
+ }
+
+ };
+
+ if(display == null) {
+ // current thread is not a user-interface thread
+ //
+ try {
+ display = Display.getDefault();
+ }
+ catch(Exception e) {
+
+ }
+ if(display != null) {
+ if(synchronous) {
+ display.syncExec(runner);
+ }
+ else {
+ display.asyncExec(runner);
+ }
+ }
+ else {
+ runner.run();
+ }
+ }
+ else {
+ // current thread is a user-interface thread
+ //
+ if(synchronous) {
+ runner.run();
+ }
+ else {
+ display.asyncExec(runner);
+ }
+ }
+ }
+
+ public void runWithBusyIndicator(Runnable runnable) {
+ BusyIndicator.showWhile(Display.getCurrent(), runnable);
+ }
+
+}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.library.edit/META-INF/MANIFEST.MF
index 81399fc..47b6683 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.library.edit/META-INF/MANIFEST.MF
@@ -9,13 +9,7 @@
Bundle-Localization: plugin
Require-Bundle: org.eclipse.epf.common;visibility:=reexport,
org.eclipse.epf.uma.edit;visibility:=reexport,
- org.eclipse.core.runtime,
- org.eclipse.core.resources,
- org.eclipse.epf.services;visibility:=reexport,
- org.eclipse.emf.common.ui,
- org.eclipse.emf.edit.ui,
- org.eclipse.epf.ui,
- org.eclipse.epf.common.ui
+ org.eclipse.epf.services;visibility:=reexport
Eclipse-LazyStart: true
Export-Package: org.eclipse.epf.library.edit,
org.eclipse.epf.library.edit.category,
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/plugin.xml b/2.0/plugins/org.eclipse.epf.library.edit/plugin.xml
index 8104632..836f90f 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/plugin.xml
+++ b/2.0/plugins/org.eclipse.epf.library.edit/plugin.xml
@@ -9,6 +9,7 @@
<extension-point id="oppositeFeatureLoaders" name="OppositeFeature Loaders" schema="schema/oppositeFeatureLoaders.exsd"/>
<extension-point id="userInteractionHandler" name="User Interaction Handler" schema="schema/userInteractionHandler.exsd"/>
<extension-point id="validationSupport" name="Validation Support" schema="schema/validationSupport.exsd"/>
+ <extension-point id="uiHelper" name="UI Helper" schema="schema/uiHelper.exsd"/>
<extension point="org.eclipse.emf.ecore.generated_package">
<package
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/schema/uiHelper.exsd b/2.0/plugins/org.eclipse.epf.library.edit/schema/uiHelper.exsd
new file mode 100644
index 0000000..74de832
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit/schema/uiHelper.exsd
@@ -0,0 +1,107 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.epf.library.edit">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.epf.library.edit" id="uiHelper" name="UI Helper"/>
+ </appInfo>
+ <documentation>
+ Extension point to provide implementation of some UI-specific operations/functions
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <choice>
+ <element ref="uiHelper"/>
+ </choice>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="uiHelper">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.epf.library.edit.ui.IUIHelper"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 1.5
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ org.eclipse.epf.library.edit.ui.IUIHelper
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2005, 2008 IBM Corporation and others.<br>
+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 <a
+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/LibraryEditPlugin.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/LibraryEditPlugin.java
index 0f2bc55..8a372ac 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/LibraryEditPlugin.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/LibraryEditPlugin.java
@@ -10,19 +10,23 @@
//------------------------------------------------------------------------------
package org.eclipse.epf.library.edit;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.emf.common.util.WrappedException;
import org.eclipse.epf.common.AbstractActivator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
import org.osgi.framework.BundleContext;
/**
* The Library Edit plug-in class.
*
* @author Kelvin Low
+ * @author Phong Nguyen Le
* @since 1.0
*/
public class LibraryEditPlugin extends AbstractActivator {
@@ -36,8 +40,8 @@
public static LibraryEditPlugin INSTANCE;
// The shared image hash map.
- private static Map sharedImages = new HashMap();
-
+ protected Map<String, Object> images = new HashMap<String, Object>();
+
/**
* Creates a new instance.
*/
@@ -85,33 +89,27 @@
return getId();
}
- /**
- * @see org.eclipse.epf.common.ui.AbstractPlugin#getImage(String)
- */
- public Image getImage(String relativePath) {
- return super.getSharedImage(relativePath + ".gif"); //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.epf.common.ui.AbstractPlugin#getSharedImage(String)
- */
- public Image getSharedImage(String relativePath) {
- return super.getSharedImage(relativePath + ".gif"); //$NON-NLS-1$
- }
-
- /**
- * Returns the image descriptor given the URI.
- *
- * @param imageURI
- * The image's URI.
- * @return The image descriptor.
- */
- public ImageDescriptor getImageDescriptor(URI imageURI) {
- try {
- return ImageDescriptor.createFromURL(imageURI.toURL());
- } catch (Exception e) {
- return null;
+ public Object getImage(String key) {
+ Object result = images.get(key);
+ if (result == null) {
+ try {
+ result = doGetImage(key);
+ } catch (Exception exception) {
+ throw new WrappedException(exception);
+ }
+ if(result != null) {
+ images.put(key, result);
+ }
}
+
+ return result;
+ }
+
+ private Object doGetImage(String key) throws IOException {
+ URL url = new URL(iconURL + key + ".gif"); //$NON-NLS-1$
+ InputStream inputStream = url.openStream();
+ inputStream.close();
+ return url;
}
/**
@@ -121,24 +119,12 @@
* The image's URI.
* @return The image.
*/
- public Image getSharedImage(URI imageURI) {
- if (imageURI == null) {
+ public Object getSharedImage(URI imageURI) {
+ try {
+ return imageURI.toURL();
+ } catch (MalformedURLException e) {
return null;
}
- Image image = (Image) sharedImages.get(imageURI);
- if (image != null) {
- return image;
- }
-
- ImageDescriptor imageDescriptor = getImageDescriptor(imageURI);
- if (imageDescriptor != null) {
- image = imageDescriptor.createImage(false);
- if (image != null) {
- sharedImages.put(imageURI, image);
- }
- }
-
- return image;
}
}
\ No newline at end of file
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/PluginUIPackageContext.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/PluginUIPackageContext.java
index 46e4fdc..0ddb14b 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/PluginUIPackageContext.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/PluginUIPackageContext.java
@@ -14,9 +14,6 @@
import java.util.Iterator;
import java.util.List;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
/**
* Stores (in memory only) the Flat/Hierarchical plugin-package layout
* @author Jeff Hardy
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Providers.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Providers.java
index b752e74..ce110f4 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Providers.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Providers.java
@@ -20,9 +20,7 @@
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.epf.common.AbstractActivator;
import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.osgi.framework.Bundle;
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/DeleteMethodElementCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/DeleteMethodElementCommand.java
index 932fc09..e9091ae 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/DeleteMethodElementCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/DeleteMethodElementCommand.java
@@ -40,7 +40,6 @@
import org.eclipse.emf.ecore.util.EContentsEList;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
-import org.eclipse.epf.common.ui.util.MsgBox;
import org.eclipse.epf.common.utils.StrUtil;
import org.eclipse.epf.library.edit.ICommandListener;
import org.eclipse.epf.library.edit.IReferencer;
@@ -50,6 +49,7 @@
import org.eclipse.epf.library.edit.Providers;
import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
import org.eclipse.epf.library.edit.util.ExtensionManager;
+import org.eclipse.epf.library.edit.util.IRunnableWithProgress;
import org.eclipse.epf.library.edit.util.Messenger;
import org.eclipse.epf.library.edit.util.ProcessUtil;
import org.eclipse.epf.library.edit.util.TngUtil;
@@ -65,10 +65,7 @@
import org.eclipse.epf.uma.ecore.impl.MultiResourceEObject;
import org.eclipse.epf.uma.util.AssociationHelper;
import org.eclipse.epf.uma.util.UmaUtil;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
/**
* This command is used to delete a method element permanently. This involves
@@ -321,7 +318,7 @@
modifiedResources.removeAll(unmodifiedResources);
final Exception[] exceptions = new Exception[1];
- BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
+ UserInteractionHelper.getUIHelper().runWithBusyIndicator(new Runnable() {
public void run() {
try {
@@ -387,7 +384,7 @@
// check affected resources for unmodifiable
//
IStatus status = UserInteractionHelper.checkModify(modifiedResources,
- MsgBox.getDefaultShell());
+ LibraryEditPlugin.getDefault().getContext());
if (!status.isOK()) {
Messenger.INSTANCE.showError(
LibraryEditResources.deleteDialog_title,
@@ -613,7 +610,7 @@
// check if the referencers can be changed
//
for (EObject e : referencers) {
- IStatus status = UserInteractionHelper.checkModify(e, MsgBox.getDefaultShell());
+ IStatus status = UserInteractionHelper.checkModify(e, LibraryEditPlugin.getDefault().getContext());
if (!status.isOK()) {
Messenger.INSTANCE
.showError(
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/IUserInteractionHandler.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/IUserInteractionHandler.java
index 10d0864..a39195f 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/IUserInteractionHandler.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/IUserInteractionHandler.java
@@ -13,8 +13,7 @@
import java.util.List;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
/**
* Interface to handle user interactions during command execution
@@ -128,7 +127,7 @@
* @return the collection of selected elements, or <code>null</code> if
* the selection was canceled.
*/
- List select(List objectsToSelect, ILabelProvider labelProvider,
+ List select(List objectsToSelect, IItemLabelProvider labelProvider,
boolean multiple, List intitialSelection, String title, String msg);
/**
@@ -166,13 +165,6 @@
Object getUIContext();
/**
- * Gets the runnable context.
- *
- * @return the runnable context
- */
- IRunnableContext getRunnableContext();
-
- /**
* Gets the messenger
*
* @return
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/MethodElementAddCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/MethodElementAddCommand.java
index 74bcacc..b510215 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/MethodElementAddCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/MethodElementAddCommand.java
@@ -45,16 +45,17 @@
import org.eclipse.emf.ecore.xml.type.XMLTypePackage.Literals;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.epf.common.ui.util.MsgBox;
import org.eclipse.epf.common.utils.StrUtil;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.epf.library.edit.LibraryEditResources;
import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
import org.eclipse.epf.library.edit.util.ExtensionManager;
+import org.eclipse.epf.library.edit.util.IRunnableWithProgress;
import org.eclipse.epf.library.edit.util.ITextReferenceReplacer;
import org.eclipse.epf.library.edit.util.Messenger;
import org.eclipse.epf.library.edit.util.Misc;
import org.eclipse.epf.library.edit.util.TngUtil;
+import org.eclipse.epf.library.edit.validation.AbstractStringValidator;
import org.eclipse.epf.library.edit.validation.IValidator;
import org.eclipse.epf.library.edit.validation.IValidatorFactory;
import org.eclipse.epf.library.edit.validation.NameChecker;
@@ -81,15 +82,7 @@
import org.eclipse.epf.uma.util.ContentDescriptionFactory;
import org.eclipse.epf.uma.util.MessageException;
import org.eclipse.epf.uma.util.UmaUtil;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.operation.ModalContext;
-import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
/**
* This command is used to add a method element to a containing method element.
@@ -190,7 +183,7 @@
public void execute() {
- Shell shell = MsgBox.getDefaultShell();
+ Object shell = LibraryEditPlugin.getDefault().getContext();
// Check whether the owner resource can be modified.
//
Collection resourcesToChange = getModifiedResources();
@@ -255,7 +248,7 @@
/**
* @return
*/
- private boolean checkFolder(Shell shell) {
+ private boolean checkFolder(Object shell) {
// if any of the elements to be added will be saved in its own file
// check if the folder to save the file to can be modified
//
@@ -742,8 +735,7 @@
if (newName != null) {
// new name required, check if the element can be modified
//
- IStatus status = UserInteractionHelper.checkModify(e, MsgBox
- .getDefaultShell());
+ IStatus status = UserInteractionHelper.checkModify(e, LibraryEditPlugin.getDefault().getContext());
String title = LibraryEditResources.errorDialog_title;
String msg = MessageFormat.format(
LibraryEditResources.errorDialog_cannotRename,
@@ -805,7 +797,8 @@
StrUtil.toLower(featureTxt), e.getName());
String currentValue = (String) e.eGet(feature);
- IInputValidator inputValidator = new IInputValidator() {
+ IValidator inputValidator = new AbstractStringValidator() {
+
public String isValid(String newText) {
if (strValidator != null) {
return UserInteractionHelper
@@ -814,15 +807,20 @@
}
return null;
}
+
};
- // TODO: replace with org.eclipse.epf.library.edit.command.IUserInteractionHandler.requestInput(String, String, List)
- InputDialog inputDlg = new InputDialog(
- MsgBox.getDefaultShell(), title, dlgMsg, currentValue,
- inputValidator);
- if (inputDlg.open() == Window.CANCEL) {
- throw new OperationCanceledException();
+ IUserInteractionHandler uiHandler = ExtensionManager.getDefaultUserInteractionHandler();
+ if(uiHandler != null) {
+ UserInput input = new UserInput("", UserInput.TEXT, false, null, null, inputValidator, null);
+ input.setInput(currentValue);
+ List<UserInput> userInputs = Collections.singletonList(input);
+ if(uiHandler.requestInput(title, dlgMsg, userInputs)) {
+ return (String) userInputs.get(0).getInput();
+ }
+ else {
+ throw new OperationCanceledException();
+ }
}
- return inputDlg.getValue();
}
}
@@ -1183,10 +1181,15 @@
throw new RuntimeException(e.toString());
}
}
- if (msgBuff.length() > 0
- && MsgBox.prompt(Display.getCurrent().getActiveShell(),
- msgBuff.toString(), SWT.YES | SWT.NO) == SWT.NO) {
- return;
+ if (msgBuff.length() > 0) {
+ IUserInteractionHandler uiHandler = ExtensionManager.getDefaultUserInteractionHandler();
+ if(uiHandler != null) {
+ int ret = uiHandler.selectOne(new int[] {IUserInteractionHandler.ACTION_YES, IUserInteractionHandler.ACTION_NO },
+ getLabel(), msgBuff.toString(), null);
+ if(ret == IUserInteractionHandler.ACTION_NO) {
+ return;
+ }
+ }
}
status = new MultiStatus(
@@ -1571,7 +1574,7 @@
private IProgressMonitor monitor;
- private Shell shell;
+ private Object shell;
private HashSet movedResources;
@@ -1590,7 +1593,7 @@
private HashMap elementToOldContainerMap;
public MoveOperation(Command command, IProgressMonitor monitor,
- Shell shell) {
+ Object shell) {
// this.command = command;
addCommand = (AddCommand) TngUtil.unwrap(command);
this.monitor = monitor;
@@ -1683,29 +1686,21 @@
};
- try {
- ModalContext.run(runnable, true, monitor, shell
- .getDisplay());
- } catch (Exception e) {
- LibraryEditPlugin.INSTANCE.log(e);
- Throwable ex;
- if (e instanceof InvocationTargetException) {
- ex = ((InvocationTargetException) e)
- .getTargetException();
- } else {
- ex = e;
- }
- String msg = TngUtil.toStackTraceString(ex);
- status.add(new Status(IStatus.ERROR,
- LibraryEditPlugin.INSTANCE.getSymbolicName(), 0,
- msg, ex));
+ IStatus stat = UserInteractionHelper.getUIHelper().runInModalContext(runnable, true, monitor, shell);
+ if(!stat.isOK()) {
+ status.add(stat);
return;
}
- if (msgBuffer.length() > 0
- && MsgBox.prompt(shell, msgBuffer.toString(), SWT.YES
- | SWT.NO) == SWT.NO) {
- return;
+ if (msgBuffer.length() > 0) {
+ IUserInteractionHandler uiHandler = ExtensionManager.getDefaultUserInteractionHandler();
+ if(uiHandler != null) {
+ int ret = uiHandler.selectOne(new int[] {IUserInteractionHandler.ACTION_YES, IUserInteractionHandler.ACTION_NO },
+ LibraryEditResources.moveDialog_title, msgBuffer.toString(), null);
+ if(ret == IUserInteractionHandler.ACTION_NO) {
+ return;
+ }
+ }
}
// save reference to old resource of all elements in the
@@ -1741,22 +1736,9 @@
}
};
- try {
- ModalContext.run(runnable, true, monitor, shell
- .getDisplay());
- } catch (Exception e) {
- LibraryEditPlugin.INSTANCE.log(e);
- Throwable ex;
- if (e instanceof InvocationTargetException) {
- ex = ((InvocationTargetException) e)
- .getTargetException();
- } else {
- ex = e;
- }
- String msg = TngUtil.toStackTraceString(ex);
- status.add(new Status(IStatus.ERROR,
- LibraryEditPlugin.INSTANCE.getSymbolicName(),
- 0, msg, ex));
+ stat = UserInteractionHelper.getUIHelper().runInModalContext(runnable, true, monitor, shell);
+ if(!stat.isOK()) {
+ status.add(stat);
return;
}
@@ -1817,25 +1799,14 @@
}
};
- try {
- ModalContext.run(runnable, true, monitor, shell
- .getDisplay());
- } catch (Exception e) {
+ stat = UserInteractionHelper.getUIHelper().runInModalContext(runnable, true, monitor, shell);
+ if(!stat.isOK()) {
undo();
- Throwable ex;
- if (e instanceof InvocationTargetException) {
- ex = ((InvocationTargetException) e)
- .getTargetException();
- } else {
- ex = e;
- }
- String msg = TngUtil.toStackTraceString(ex);
- status.add(new Status(IStatus.ERROR,
- LibraryEditPlugin.INSTANCE.getSymbolicName(), 0,
- msg, ex));
+ status.add(stat);
return;
}
+
// check moved resources that are not in modifiable resources
// for unmodifiable
//
@@ -1869,21 +1840,9 @@
}
};
- try {
- ModalContext.run(runnable, true, monitor, shell
- .getDisplay());
- } catch (Exception e) {
- Throwable ex;
- if (e instanceof InvocationTargetException) {
- ex = ((InvocationTargetException) e)
- .getTargetException();
- } else {
- ex = e;
- }
- String msg = TngUtil.toStackTraceString(ex);
- status.add(new Status(IStatus.ERROR,
- LibraryEditPlugin.INSTANCE.getSymbolicName(), 0,
- msg, ex));
+ stat = UserInteractionHelper.getUIHelper().runInModalContext(runnable, true, monitor, shell);
+ if(!stat.isOK()) {
+ status.add(stat);
return;
}
@@ -2241,7 +2200,7 @@
private static StringValidator stringValidator = null;
- private static class StringValidator implements IInputValidator {
+ private static class StringValidator extends AbstractStringValidator {
private Collection elements;
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/UserInput.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/UserInput.java
index bdf1133..3d2f3ba 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/UserInput.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/command/UserInput.java
@@ -12,8 +12,8 @@
import java.util.List;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.epf.library.edit.validation.IValidator;
-import org.eclipse.jface.viewers.ILabelProvider;
/**
* Class that keeps the information about the input request and reference to the
@@ -37,14 +37,14 @@
private Object input;
- private ILabelProvider labelProvider;
+ private IItemLabelProvider labelProvider;
private Object context;
private IValidator validator;
public UserInput(String label, int type, boolean multiple, List choices,
- ILabelProvider labelProvider, Object context) {
+ IItemLabelProvider labelProvider, Object context) {
this(label, type, multiple, choices, labelProvider, null, context);
}
@@ -64,7 +64,7 @@
* contain addional information about the user input.
*/
public UserInput(String label, int type, boolean multiple, List choices,
- ILabelProvider labelProvider, IValidator validator, Object context) {
+ IItemLabelProvider labelProvider, IValidator validator, Object context) {
super();
this.label = label;
this.type = type;
@@ -104,7 +104,7 @@
*
* @return the label provider
*/
- public ILabelProvider getLabelProvider() {
+ public IItemLabelProvider getLabelProvider() {
return labelProvider;
}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/internal/TngAdapterFactoryImpl.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/internal/TngAdapterFactoryImpl.java
index b394a16..a35e16f 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/internal/TngAdapterFactoryImpl.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/internal/TngAdapterFactoryImpl.java
@@ -38,7 +38,8 @@
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.epf.common.preferences.IPreferenceStoreWrapper;
-import org.eclipse.epf.common.ui.PreferenceStoreWrapper;
+import org.eclipse.epf.common.preferences.IPropertyChangeEventWrapper;
+import org.eclipse.epf.common.preferences.IPropertyChangeListenerWrapper;
import org.eclipse.epf.library.edit.IConfigurable;
import org.eclipse.epf.library.edit.IConfigurator;
import org.eclipse.epf.library.edit.IFilter;
@@ -62,9 +63,6 @@
import org.eclipse.epf.uma.Milestone;
import org.eclipse.epf.uma.TaskDescriptor;
import org.eclipse.epf.uma.TeamProfile;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
/**
* The default method library adapter factory implementation.
@@ -794,7 +792,7 @@
synchronized (this) {
if (procAdapterFactory == null) {
org.eclipse.epf.library.edit.process.consolidated.ItemProviderAdapterFactory adapterFactory = new org.eclipse.epf.library.edit.process.consolidated.ItemProviderAdapterFactory();
- final IPreferenceStore prefStore = (IPreferenceStore)Providers.getPreferenceStore();
+ final IPreferenceStoreWrapper prefStore = Providers.getPreferenceStore();
if (prefStore != null) {
adapterFactory
.setColumnIndexToNameMap(ProcessUtil
@@ -806,9 +804,9 @@
// and add listener to its change
//
Suppression.setAutoInheritSuppressionStates(prefStore.getBoolean(LibraryEditConstants.PREF_INHERIT_SUPPRESSION_STATE));
- prefStore.addPropertyChangeListener(new IPropertyChangeListener() {
+ prefStore.addPropertyChangeListener(new IPropertyChangeListenerWrapper() {
- public void propertyChange(PropertyChangeEvent event) {
+ public void propertyChange(IPropertyChangeEventWrapper event) {
if(LibraryEditConstants.PREF_INHERIT_SUPPRESSION_STATE.equals(event.getProperty())) {
Suppression.setAutoInheritSuppressionStates(prefStore.getBoolean(LibraryEditConstants.PREF_INHERIT_SUPPRESSION_STATE));
}
@@ -883,22 +881,13 @@
// remove adapter factory as property change listener from
// preference store
//
-
- // PreferenceStoreWrapper is not visible in this plugin,
- // need to use the wrappers, this requires changes to the property change listeners in the procAdapterFactories
- // TODO
- IPreferenceStore prefStore = null;
- IPreferenceStoreWrapper wrapper = Providers.getAuthoringPluginPreferenceStore();
- if ( wrapper instanceof PreferenceStoreWrapper ) {
- prefStore = ((PreferenceStoreWrapper)wrapper).getStore();
- }
-
+ IPreferenceStoreWrapper prefStore = Providers.getAuthoringPluginPreferenceStore();
if (prefStore != null) {
for (int i = 0; i < procAdapterFactories.length; i++) {
Object adapterFactory = procAdapterFactories[i];
- if (adapterFactory instanceof IPropertyChangeListener) {
+ if (adapterFactory instanceof IPropertyChangeListenerWrapper) {
prefStore
- .removePropertyChangeListener((IPropertyChangeListener) adapterFactory);
+ .removePropertyChangeListener((IPropertyChangeListenerWrapper) adapterFactory);
}
}
}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/navigator/AbstractProcessesItemProvider.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/navigator/AbstractProcessesItemProvider.java
index 59a5f41..cb930be 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/navigator/AbstractProcessesItemProvider.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/navigator/AbstractProcessesItemProvider.java
@@ -30,8 +30,6 @@
import org.eclipse.epf.library.edit.Providers;
import org.eclipse.epf.library.edit.element.IElementItemProvider;
import org.eclipse.epf.library.edit.util.ModelStructure;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
/**
* The abstract base item provider adapter class for the "Processes" folder in
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/BSActivityItemProvider.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/BSActivityItemProvider.java
index d16f8e6..b7b6e39 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/BSActivityItemProvider.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/BSActivityItemProvider.java
@@ -48,6 +48,7 @@
import org.eclipse.epf.library.edit.command.IActionManager;
import org.eclipse.epf.library.edit.command.IResourceAwareCommand;
import org.eclipse.epf.library.edit.process.command.ActivityAddCommand;
+import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
import org.eclipse.epf.library.edit.util.GraphicalData;
import org.eclipse.epf.library.edit.util.PredecessorList;
import org.eclipse.epf.library.edit.util.ProcessUtil;
@@ -70,7 +71,6 @@
import org.eclipse.epf.uma.edit.command.MethodElementInitializeCopyCommand;
import org.eclipse.epf.uma.provider.ActivityItemProvider;
import org.eclipse.epf.uma.util.AssociationHelper;
-import org.eclipse.swt.widgets.Display;
/**
@@ -1020,13 +1020,6 @@
protected void refreshChildren(final Notification notification,
final List newOrOldChildren) {
if (!newOrOldChildren.isEmpty()) {
-
- Display display = null;
- try {
- display = Display.getCurrent();
- } catch (Exception e) {
- //
- }
Runnable runnable = new Runnable() {
public void run() {
@@ -1034,29 +1027,11 @@
}
};
- if (display != null) {
- display.asyncExec(runnable);
- } else {
- runnable.run();
- }
+ UserInteractionHelper.getUIHelper().runSafely(runnable, false);
}
}
protected void refreshAffectedViewers() {
- Display display = null;
- try {
- display = Display.getCurrent();
- } catch (Exception e) {
- //
- }
- if(display == null) {
- try {
- display = Display.getDefault();
- }
- catch(Exception e) {
-
- }
- }
Runnable runnable = new Runnable() {
public void run() {
@@ -1064,11 +1039,7 @@
}
};
- if (display != null) {
- display.asyncExec(runnable);
- } else {
- runnable.run();
- }
+ UserInteractionHelper.getUIHelper().runSafely(runnable, false);
}
protected void doRefreshAffectedViewers() {
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/WBSItemProviderAdapterFactory.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/WBSItemProviderAdapterFactory.java
index 8652331..b773824 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/WBSItemProviderAdapterFactory.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/WBSItemProviderAdapterFactory.java
@@ -13,11 +13,11 @@
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
+import org.eclipse.epf.common.preferences.IPropertyChangeEventWrapper;
+import org.eclipse.epf.common.preferences.IPropertyChangeListenerWrapper;
import org.eclipse.epf.library.edit.util.LibraryEditConstants;
import org.eclipse.epf.library.edit.util.ProcessUtil;
import org.eclipse.epf.library.edit.util.TngUtil;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
/**
@@ -25,7 +25,7 @@
* @since 1.0
*/
public class WBSItemProviderAdapterFactory extends ItemProviderAdapterFactory
- implements IPropertyChangeListener {
+ implements IPropertyChangeListenerWrapper {
public WBSItemProviderAdapterFactory() {
super();
@@ -87,13 +87,12 @@
return new WBSProcessItemProvider(this, (ItemProviderAdapter) TngUtil.umaItemProviderAdapterFactory
.createDeliveryProcessAdapter());
}
-
+
/*
* (non-Javadoc)
- *
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ * @see org.eclipse.epf.common.preferences.IPropertyChangeListenerWrapper#propertyChange(org.eclipse.epf.common.preferences.IPropertyChangeEventWrapper)
*/
- public void propertyChange(PropertyChangeEvent event) {
+ public void propertyChange(IPropertyChangeEventWrapper event) {
if (event.getProperty().equals(LibraryEditConstants.PREF_WBS_COLUMNS)) {
setColumnIndexToNameMap(ProcessUtil
.toColumnIndexToNameMap((String) event.getNewValue()));
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDropCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDropCommand.java
index 400b0b3..9abd758 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDropCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDropCommand.java
@@ -32,6 +32,7 @@
import org.eclipse.epf.library.edit.ui.IActionTypeProvider;
import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
import org.eclipse.epf.library.edit.util.ActivityHandler;
+import org.eclipse.epf.library.edit.util.IRunnableWithProgress;
import org.eclipse.epf.library.edit.util.ProcessUtil;
import org.eclipse.epf.library.edit.util.Suppression;
import org.eclipse.epf.library.edit.util.TngUtil;
@@ -47,8 +48,6 @@
import org.eclipse.epf.uma.Process;
import org.eclipse.epf.uma.ProcessPackage;
import org.eclipse.epf.uma.TeamProfile;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.Viewer;
/**
@@ -59,7 +58,7 @@
*/
public class ActivityDropCommand extends BSDropCommand {
- private Viewer viewer;
+ private Object viewer;
private List<CapabilityPattern> oldPatterns;
@@ -83,7 +82,7 @@
protected IConfigurator activityDeepCopyConfigurator;
- public ActivityDropCommand(Activity target, List activities, Viewer viewer, AdapterFactory adapterFactory) {
+ public ActivityDropCommand(Activity target, List activities, Object viewer, AdapterFactory adapterFactory) {
super(target, activities);
setLabel(LibraryEditResources.ActivityDropCommand_label);
this.viewer = viewer;
@@ -97,7 +96,7 @@
}
}
- public ActivityDropCommand(Activity target, List activities, Viewer viewer,
+ public ActivityDropCommand(Activity target, List activities, Object viewer,
AdapterFactory adapterFactory,IConfigurator deepCopyConfigurator){
this(target, activities, viewer, adapterFactory);
this.activityDeepCopyConfigurator = deepCopyConfigurator;
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/BSDragAndDropCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/BSDragAndDropCommand.java
index 3111f15..1267efa 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/BSDragAndDropCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/BSDragAndDropCommand.java
@@ -21,21 +21,17 @@
import org.eclipse.emf.common.command.IdentityCommand;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.ui.viewer.IViewerProvider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.epf.library.edit.command.ResourceAwareCompoundCommand;
import org.eclipse.epf.library.edit.command.ResourceAwareDragAndDropCommand;
-import org.eclipse.epf.library.edit.util.ExposedAdapterFactory;
+import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
import org.eclipse.epf.library.edit.util.TngUtil;
import org.eclipse.epf.library.edit.validation.DependencyChecker;
import org.eclipse.epf.uma.Activity;
import org.eclipse.epf.uma.BreakdownElement;
import org.eclipse.epf.uma.Process;
-import org.eclipse.epf.uma.ProcessComponent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.Viewer;
/**
@@ -126,26 +122,12 @@
return result;
}
- protected Viewer getTargetViewer() {
+ protected Object getTargetViewer() {
if (domain instanceof AdapterFactoryEditingDomain) {
Process proc = TngUtil.getOwningProcess((BreakdownElement) owner);
AdapterFactory adapterFactory = ((AdapterFactoryEditingDomain) domain)
.getAdapterFactory();
- if (adapterFactory instanceof ExposedAdapterFactory) {
- for (Iterator iter = Collections.unmodifiableList(
- ((ExposedAdapterFactory) adapterFactory)
- .getChangeListeners()).iterator(); iter
- .hasNext();) {
- Object listener = iter.next();
- if (listener instanceof IContentProvider && listener instanceof IViewerProvider) {
- Viewer viewer = ((IViewerProvider) listener).getViewer();
- if (viewer.getInput() instanceof ProcessComponent
- && ((ProcessComponent) viewer.getInput())
- .getProcess() == proc)
- return viewer;
- }
- }
- }
+ return UserInteractionHelper.getUIHelper().getViewer(adapterFactory, proc);
}
return null;
}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/BSDropCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/BSDropCommand.java
index 58a1a3c..de068a4 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/BSDropCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/BSDropCommand.java
@@ -38,6 +38,7 @@
import org.eclipse.epf.library.edit.command.NestedCommandExcecutor;
import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
import org.eclipse.epf.library.edit.util.ExtensionManager;
+import org.eclipse.epf.library.edit.util.IRunnableWithProgress;
import org.eclipse.epf.library.edit.util.ProcessUtil;
import org.eclipse.epf.library.edit.util.TngUtil;
import org.eclipse.epf.uma.Activity;
@@ -52,8 +53,6 @@
import org.eclipse.epf.uma.TaskDescriptor;
import org.eclipse.epf.uma.UmaPackage;
import org.eclipse.epf.uma.WorkProductDescriptor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
/**
* Abstract base DropCommand class for breakdown structure editor
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/CreateProcessComponentCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/CreateProcessComponentCommand.java
index 42a0650..df4e45b 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/CreateProcessComponentCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/CreateProcessComponentCommand.java
@@ -28,8 +28,6 @@
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.command.CreateChildCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.epf.common.ui.util.MsgBox;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.epf.library.edit.LibraryEditResources;
import org.eclipse.epf.library.edit.TngAdapterFactory;
@@ -38,7 +36,9 @@
import org.eclipse.epf.library.edit.command.UserInput;
import org.eclipse.epf.library.edit.navigator.ProcessPackageItemProvider;
import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
+import org.eclipse.epf.library.edit.util.AdapterFactoryItemLabelProvider;
import org.eclipse.epf.library.edit.util.ExtensionManager;
+import org.eclipse.epf.library.edit.util.ItemLabelProvider;
import org.eclipse.epf.library.edit.util.TngUtil;
import org.eclipse.epf.library.edit.validation.IValidator;
import org.eclipse.epf.library.edit.validation.IValidatorFactory;
@@ -61,9 +61,7 @@
import org.eclipse.epf.uma.util.ContentDescriptionFactory;
import org.eclipse.epf.uma.util.MessageException;
import org.eclipse.epf.uma.util.UmaUtil;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Shell;
/**
@@ -126,7 +124,7 @@
public void execute() {
MethodLibrary lib = UmaUtil.getMethodLibrary(owner);
- Shell shell = MsgBox.getDefaultShell();
+ Object shell = LibraryEditPlugin.getDefault().getContext();
// The owner must be updatable.
//
@@ -191,7 +189,7 @@
// default configuration
//
UserInput defaultConfigInput = new UserInput(LibraryEditResources.defaultConfigLabel_text, UserInput.SELECTION,
- false, methodConfigs, new LabelProvider() {
+ false, methodConfigs, new ItemLabelProvider() {
public String getText(Object element) {
if (element instanceof MethodElement) {
return ((MethodElement) element).getName();
@@ -206,7 +204,7 @@
if(procComp.getProcess() instanceof ProcessPlanningTemplate) {
baseProcInput = new UserInput(LibraryEditResources.basedOnProcessesLabel_text, UserInput.SELECTION,
- true, baseProcList, new AdapterFactoryLabelProvider(TngAdapterFactory.INSTANCE
+ true, baseProcList, new AdapterFactoryItemLabelProvider(TngAdapterFactory.INSTANCE
.getNavigatorView_ComposedAdapterFactory()), null);
userInputs.add(baseProcInput);
}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/DeleteUnusedDescriptorsCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/DeleteUnusedDescriptorsCommand.java
index f5133d5..163971d 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/DeleteUnusedDescriptorsCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/DeleteUnusedDescriptorsCommand.java
@@ -19,19 +19,18 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.util.AbstractTreeIterator;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.epf.library.edit.LibraryEditResources;
import org.eclipse.epf.library.edit.TngAdapterFactory;
import org.eclipse.epf.library.edit.command.IInteractive;
import org.eclipse.epf.library.edit.command.IUserInteractionHandler;
+import org.eclipse.epf.library.edit.util.AdapterFactoryItemLabelProvider;
import org.eclipse.epf.library.edit.util.ProcessUtil;
import org.eclipse.epf.uma.Activity;
import org.eclipse.epf.uma.Descriptor;
import org.eclipse.epf.uma.RoleDescriptor;
import org.eclipse.epf.uma.WorkProductDescriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
/**
@@ -138,22 +137,17 @@
private void selectDescriptorsToDelete(List descriptorsToDelete) {
if(userInteractionHandler != null) {
- ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
+ IItemLabelProvider labelProvider = new AdapterFactoryItemLabelProvider(
TngAdapterFactory.INSTANCE
.getNavigatorView_ComposedAdapterFactory());
String title = LibraryEditResources.ui_references;
String msg = LibraryEditResources.selectDescriptorsToDelete_msg;
List list = new ArrayList(descriptorsToDelete);
- try {
- Collection selected = userInteractionHandler.select(list, labelProvider, true, list, title, msg);
- if(selected == null) {
- throw new OperationCanceledException();
- }
- descriptorsToDelete.retainAll(selected);
+ Collection selected = userInteractionHandler.select(list, labelProvider, true, list, title, msg);
+ if(selected == null) {
+ throw new OperationCanceledException();
}
- finally {
- labelProvider.dispose();
- }
+ descriptorsToDelete.retainAll(selected);
}
}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/OBSDropCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/OBSDropCommand.java
index a3cf107..280f554 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/OBSDropCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/OBSDropCommand.java
@@ -179,7 +179,7 @@
finalWps.addAll(workProducts);
final Role finalRole = role;
- UserInteractionHelper.runInUIThread(new Runnable() {
+ UserInteractionHelper.getUIHelper().runSafely(new Runnable() {
public void run() {
List selected = UserInteractionHelper
.selectWorkProducts(finalWps, finalRole);
@@ -187,7 +187,7 @@
finalSelectedWps.addAll(selected);
}
}
- });
+ }, true);
}
selectedWorkProducts.addAll(finalSelectedWps);
@@ -270,13 +270,13 @@
final List finalSelected = new ArrayList();
List selectedTasks = new ArrayList();
// show task selections dialog
- UserInteractionHelper.runInUIThread(new Runnable() {
+ UserInteractionHelper.getUIHelper().runSafely(new Runnable() {
public void run() {
List selected = UserInteractionHelper
.selectTasks(finalTasks, finalWp);
finalSelected.addAll(selected);
}
- });
+ }, true);
selectedTasks.addAll(finalSelected);
if ((selectedTasks != null)
&& ((!selectedTasks.isEmpty()))) {
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/PBSDropCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/PBSDropCommand.java
index 0cfb6ff..fadcaf3 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/PBSDropCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/PBSDropCommand.java
@@ -225,13 +225,13 @@
final List finalSelected = new ArrayList();
List selectedTasks = new ArrayList();
// show task selections dialog
- UserInteractionHelper.runInUIThread(new Runnable() {
+ UserInteractionHelper.getUIHelper().runSafely(new Runnable() {
public void run() {
List selected = UserInteractionHelper.selectTasks(
finalTasks, finalWp);
finalSelected.addAll(selected);
}
- });
+ }, true);
selectedTasks.addAll(finalSelected);
// create task descriptors for this workproduct
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/SynchronizeCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/SynchronizeCommand.java
index fc1c389..269e51a 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/SynchronizeCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/SynchronizeCommand.java
@@ -57,8 +57,6 @@
import org.eclipse.epf.uma.VariabilityElement;
import org.eclipse.epf.uma.WorkProduct;
import org.eclipse.epf.uma.WorkProductDescriptor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
/**
@@ -563,7 +561,7 @@
* @see org.eclipse.emf.common.command.CompoundCommand#undo()
*/
public void undo() {
- BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
+ UserInteractionHelper.getUIHelper().runWithBusyIndicator(new Runnable() {
public void run() {
if (!deleteCommandList.isEmpty()) {
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/DeliverableSelection.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/DeliverableSelection.java
deleted file mode 100644
index eeb2836..0000000
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/DeliverableSelection.java
+++ /dev/null
@@ -1,70 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.library.edit.ui;
-
-import java.util.List;
-
-import org.eclipse.epf.library.edit.LibraryEditResources;
-import org.eclipse.epf.library.edit.TngAdapterFactory;
-import org.eclipse.epf.uma.WorkProduct;
-import org.eclipse.epf.uma.WorkProductDescriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-
-
-/**
- * UI Dialog class which will ask user to assign a wp to deliverable
- * automatically
- *
- * @author Shilpa Toraskar
- * @since 1.0
- */
-public class DeliverableSelection {
-
- /**
- * It shows dialog box all deliverable. Returns deliverable user selected
- *
- * @param element
- * @return
- */
-// public static WorkProductDescriptor getSelectedDeliverable(
-// List deliverableList, WorkProduct wp) {
-// ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
-// TngAdapterFactory.INSTANCE.getPBS_ComposedAdapterFactory()) {
-// public String getText(Object obj) {
-// if (obj instanceof WorkProductDescriptor) {
-// return ((WorkProductDescriptor) obj).getName();
-// }
-// return ""; //$NON-NLS-1$
-// }
-// };
-//
-// ElementListSelectionDialog dlg = new ElementListSelectionDialog(null,
-// labelProvider);
-//
-// dlg.setTitle(LibraryEditResources.deliverables_text); //$NON-NLS-1$
-// dlg.setBlockOnOpen(true);
-// dlg.setElements(deliverableList.toArray());
-// dlg.setMultipleSelection(false);
-// dlg.setMessage(NLS.bind(LibraryEditResources.selectDeliverablesDialog_text, wp.getName()));
-// dlg.setTitle(LibraryEditResources.selectDeliverablesDialog_title); //$NON-NLS-1$
-// dlg.setFilter(null);
-// dlg.open();
-//
-// Object obj = dlg.getFirstResult();
-//
-// // dispose
-// labelProvider.dispose();
-// return (WorkProductDescriptor) obj;
-// }
-
-}
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
new file mode 100644
index 0000000..179a6ab
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/IUIHelper.java
@@ -0,0 +1,80 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2008 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 implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.library.edit.ui;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.epf.library.edit.process.BSActivityItemProvider;
+import org.eclipse.epf.library.edit.util.ExposedAdapterFactory;
+import org.eclipse.epf.library.edit.util.IRunnableWithProgress;
+import org.eclipse.epf.uma.Activity;
+import org.eclipse.epf.uma.Process;
+import org.eclipse.epf.uma.Role;
+import org.eclipse.epf.uma.TeamProfile;
+import org.eclipse.epf.uma.WorkProduct;
+
+/**
+ * @author Phong Nguyen Le
+ * @since 1.5
+ *
+ */
+public interface IUIHelper {
+ public void runSafely(Runnable runnable, boolean synchronous);
+
+ public void runWithBusyIndicator(Runnable runnable);
+
+ public boolean runWithProgress(IRunnableWithProgress runnable, boolean canCancel, String msg);
+
+ public IStatus runAsJob(IRunnableWithProgress runnable, String taskName,
+ Object shell);
+
+ public boolean runInUI(IRunnableWithProgress runnable,
+ ISchedulingRule rule, Object shell);
+
+ IStatus runInModalContext(IRunnableWithProgress operation, boolean fork,
+ IProgressMonitor monitor, Object uiContext);
+
+ public TeamProfile getTeam(Activity activity, Role role, Object UIContext);
+
+ /**
+ * Select tasks which has given workproduct as output.
+ *
+ * @param taskList
+ * @param wp
+ * @return
+ */
+ public List selectTasks(List taskList, WorkProduct wp);
+
+ /**
+ * Select responsible work products for the given role
+ *
+ * @param wpList
+ * @param role
+ * @return
+ */
+ public List selectWorkProducts(List wpList, Role role);
+
+ public boolean refreshNeeded(AdapterFactory adapterFactory,
+ BSActivityItemProvider itemProvider);
+
+ public void refreshViewer(AdapterFactory factory, Process proc);
+
+ public void refreshAllViewers(final ExposedAdapterFactory adapterFactory);
+
+ public void refreshIDsInViewer(ExposedAdapterFactory adapterFactory);
+
+ public Object getViewer(AdapterFactory adapterFactory, Process proc);
+
+}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/NewProcessComponentDialog.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/NewProcessComponentDialog.java
deleted file mode 100644
index b0e4d6b..0000000
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/NewProcessComponentDialog.java
+++ /dev/null
@@ -1,326 +0,0 @@
-//------------------------------------------------------------------------------
-// Copyright (c) 2005, 2006 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 implementation
-//------------------------------------------------------------------------------
-package org.eclipse.epf.library.edit.ui;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.epf.common.utils.StrUtil;
-import org.eclipse.epf.library.edit.LibraryEditPlugin;
-import org.eclipse.epf.library.edit.LibraryEditResources;
-import org.eclipse.epf.library.edit.TngAdapterFactory;
-import org.eclipse.epf.library.edit.validation.IValidator;
-import org.eclipse.epf.library.edit.validation.IValidatorFactory;
-import org.eclipse.epf.uma.MethodConfiguration;
-import org.eclipse.epf.uma.MethodElement;
-import org.eclipse.epf.uma.MethodPlugin;
-import org.eclipse.epf.uma.Process;
-import org.eclipse.epf.uma.ProcessComponent;
-import org.eclipse.epf.uma.ProcessPackage;
-import org.eclipse.epf.uma.ProcessPlanningTemplate;
-import org.eclipse.epf.uma.UmaPackage;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-
-/**
- * Displays the New Process dialog.
- *
- * @author Phong Nguyen Le
- * @author Kelvin Low
- * @since 1.0
- */
-public class NewProcessComponentDialog extends Dialog {
-
- private Composite area;
-
- private Text ctrl_name;
-
- private ComboViewer configComboViewer;
-
- private MethodConfiguration[] availableConfigurations;
-
- private ProcessComponent newProcComp;
-
- private Process[] availableBaseProcesses;
-
- private CheckboxTableViewer processTableViewer;
-
- // private ProcessPackage owner;
-
- private static final Collection ECLASS = new HashSet();
-
- private IValidator validator;
-
- static {
- ECLASS.add(UmaPackage.eINSTANCE.getProcessComponent());
- }
-
- /**
- * Creates a new instance.
- */
- public NewProcessComponentDialog(Shell parent,
- MethodConfiguration[] availableConfigurations,
- ProcessComponent newComp, Process[] availableBaseProcesses,
- MethodPlugin currentPlugin, ProcessPackage owner) {
- super(parent);
- this.availableConfigurations = availableConfigurations;
- this.newProcComp = newComp;
- this.availableBaseProcesses = availableBaseProcesses;
- // this.owner = owner;
- validator = IValidatorFactory.INSTANCE.createNameValidator(owner,
- newProcComp);
- }
-
- /**
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite parent)
- */
- protected Control createDialogArea(Composite parent) {
- area = (Composite) super.createDialogArea(parent);
- final GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- area.setLayout(gridLayout);
- GridData areaGridData = new GridData();
-// areaGridData.widthHint = 300;
- area.setLayoutData(areaGridData);
-
- // Name
- Label nameLabel = new Label(area, SWT.NONE);
- nameLabel.setText(LibraryEditResources.nameLabel_text);
- {
- GridData gridData = new GridData(GridData.BEGINNING);
- nameLabel.setLayoutData(gridData);
- }
-
- ctrl_name = new Text(area, SWT.BORDER);
- {
- GridData gridData = new GridData(GridData.BEGINNING
- | GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
- gridData.widthHint = 200;
- ctrl_name.setLayoutData(gridData);
- }
-
- // Ref. Models
- Label refModelLabel = new Label(area, SWT.NONE);
- refModelLabel.setText(LibraryEditResources.defaultConfigLabel_text);
- {
- GridData gridData = new GridData(GridData.BEGINNING);
- refModelLabel.setLayoutData(gridData);
- }
-
- Composite comp = new Composite(area, SWT.NONE);
- {
- GridData gridData = new GridData(GridData.BEGINNING
- | GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
- comp.setLayoutData(gridData);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- comp.setLayout(layout);
- }
-
- configComboViewer = new ComboViewer(comp, SWT.BORDER | SWT.READ_ONLY);
- {
- GridData gridData = new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL);
- gridData.widthHint = 200;
- configComboViewer.getCombo().setLayoutData(gridData);
- }
-
-
- ILabelProvider labelProvider = new LabelProvider() {
- public String getText(Object element) {
- if (element instanceof MethodElement) {
- return ((MethodElement) element).getName();
- } else {
- return element.toString();
- }
- }
- };
-
- // configListViewer = new ListViewer(comp, SWT.BORDER | SWT.SINGLE);
- // configListViewer.setLabelProvider(labelProvider);
- // configListViewer.add(availableConfigurations);
- // if(newProcComp.getProcess().getDefaultContext() != null) {
- // configListViewer.setSelection(new
- // StructuredSelection(newProcComp.getProcess().getDefaultContext()));
- // }
-
- configComboViewer.setLabelProvider(labelProvider);
- configComboViewer.add(availableConfigurations);
- if (newProcComp.getProcess().getDefaultContext() != null) {
- configComboViewer.setSelection(new StructuredSelection(newProcComp
- .getProcess().getDefaultContext()));
- }
- // configComboViewer.getControl().setSize(100,
- // configComboViewer.getControl().getSize().y);
-
- if (newProcComp.getProcess() instanceof ProcessPlanningTemplate) {
- // based on processes
- //
- Label label = new Label(area, SWT.NONE);
- label.setText(LibraryEditResources.basedOnProcessesLabel_text);
- {
- GridData gridData = new GridData(GridData.BEGINNING);
- label.setLayoutData(gridData);
- }
-
- comp = new Composite(area, SWT.NONE);
- {
- GridData gridData = new GridData(GridData.BEGINNING
- | GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
- comp.setLayoutData(gridData);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- comp.setLayout(layout);
- }
-
- processTableViewer = CheckboxTableViewer.newCheckList(comp,
- SWT.BORDER);
- processTableViewer.getTable()
- .setLayoutData(
- new GridData(GridData.BEGINNING
- | GridData.FILL_HORIZONTAL));
- AdapterFactory adapterFactory = TngAdapterFactory.INSTANCE
- .getNavigatorView_ComposedAdapterFactory();
- processTableViewer
- .setContentProvider(new AdapterFactoryContentProvider(
- adapterFactory));
- processTableViewer
- .setLabelProvider(new AdapterFactoryLabelProvider(
- adapterFactory));
- processTableViewer.add(availableBaseProcesses);
- }
-
- if (newProcComp.getName() != null)
- ctrl_name.setText(newProcComp.getName());
-
- super
- .getShell()
- .setText(
- LibraryEditResources.newProcessComponentDialog_title);
-
- // addListeners();
-
- return area;
- }
-
- // protected void addListeners() {
- // // DON'T use FocusLost listener because otherwise it goes infinite loop
- // // and user cannot cancel out of it.
- // ctrl_name.addTraverseListener(new TraverseListener() {
- // public void keyTraversed(TraverseEvent e) {
- // if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail ==
- // SWT.TRAVERSE_TAB_PREVIOUS) {
- // String name = ctrl_name.getText();
- // String msg = validator.isValid(name);
- // if (msg != null) {
- // LibraryEditPlugin.getDefault().getMsgDialog().displayError(
- // LibraryEditResources.getString("LibraryEdit.createProcess.text"),
- // //$NON-NLS-1$
- // msg);
- //
- // ctrl_name.getDisplay().asyncExec(new Runnable() {
- // public void run () {
- // ctrl_name.setFocus();
- // }
- // });
- // ctrl_name.selectAll();
- // }
- // }
- // }
- // });
- // }
-
- /**
- * Creates the dialog buttons.
- */
- protected void createButtonsForButtonBar(Composite parent) {
- // Create the OK button.
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
- true);
-
- // Create the Cancel button.
- createButton(parent, IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL, false);
-
- // Set help context for the OK button.
- super.getButton(IDialogConstants.OK_ID);
-
- // Set help context for the Cancel button.
- super.getButton(IDialogConstants.CANCEL_ID);
- }
-
- /**
- * Called when the OK button is selected.
- */
- protected void okPressed() {
- // Need to do validation again since TraverseListener only listens to
- // tab out of field
- // and doesn't take care of mouse clicks
- String name = ctrl_name.getText().trim();
- name = StrUtil.makeValidFileName(name);
- String msg = validator.isValid(name);
- if (msg != null) {
- LibraryEditPlugin.getDefault().getMsgCallback().displayError(LibraryEditPlugin.getDefault(),
- LibraryEditResources.createProcess_text,
- msg);
- ctrl_name.setFocus();
- ctrl_name.selectAll();
- return;
- }
-
- IStructuredSelection selected = (IStructuredSelection) configComboViewer
- .getSelection();
- if (selected.isEmpty()) {
- LibraryEditPlugin.getDefault().getMsgCallback().displayError(LibraryEditPlugin.getDefault(),
- LibraryEditResources.createProcess_text,
- LibraryEditResources.noDefaultConfigError_msg);
- return;
- }
-
- newProcComp.setName(name);
- newProcComp.getProcess().setName(name);
- newProcComp.getProcess().setPresentationName(name);
- newProcComp.getProcess().setDefaultContext(
- (MethodConfiguration) ((IStructuredSelection) configComboViewer
- .getSelection()).getFirstElement());
- if (newProcComp.getProcess() instanceof ProcessPlanningTemplate) {
- ProcessPlanningTemplate procPlanningTempl = (ProcessPlanningTemplate) newProcComp
- .getProcess();
- procPlanningTempl.getBasedOnProcesses().addAll(
- Arrays.asList(processTableViewer.getCheckedElements()));
- }
- super.okPressed();
- }
-
-}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/ReferenceSelection.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/ReferenceSelection.java
index a82e6b4..ef2cd45 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/ReferenceSelection.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/ReferenceSelection.java
@@ -10,18 +10,16 @@
//------------------------------------------------------------------------------
package org.eclipse.epf.library.edit.ui;
-import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.epf.library.edit.LibraryEditResources;
import org.eclipse.epf.library.edit.TngAdapterFactory;
import org.eclipse.epf.library.edit.command.IUserInteractionHandler;
+import org.eclipse.epf.library.edit.util.AdapterFactoryItemLabelProvider;
import org.eclipse.epf.library.edit.util.ExtensionManager;
import org.eclipse.epf.uma.Descriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.osgi.util.NLS;
/**
@@ -98,20 +96,16 @@
IUserInteractionHandler uiHandler = ExtensionManager
.getDefaultUserInteractionHandler();
if (uiHandler != null) {
- ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
+ IItemLabelProvider labelProvider = new AdapterFactoryItemLabelProvider(
TngAdapterFactory.INSTANCE
.getNavigatorView_ComposedAdapterFactory());
String title = LibraryEditResources.ui_references;
- try {
- List selected = uiHandler.select(ref, labelProvider, true, ref,
- title, msg);
- if (selected == null) {
- throw new OperationCanceledException();
- }
- return selected.toArray();
- } finally {
- labelProvider.dispose();
+ List selected = uiHandler.select(ref, labelProvider, true, ref,
+ title, msg);
+ if (selected == null) {
+ throw new OperationCanceledException();
}
+ return selected.toArray();
}
// no user interaction handler available
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/UserInteractionHelper.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/UserInteractionHelper.java
index e353e14..1914040 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/UserInteractionHelper.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/ui/UserInteractionHelper.java
@@ -10,12 +10,11 @@
//------------------------------------------------------------------------------
package org.eclipse.epf.library.edit.ui;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -23,8 +22,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.resources.WorkspaceJob;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -34,29 +31,26 @@
import org.eclipse.core.runtime.Path;
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.util.WrappedException;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.epf.common.ui.util.MsgBox;
import org.eclipse.epf.library.edit.IConfigurator;
import org.eclipse.epf.library.edit.IFilter;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.epf.library.edit.LibraryEditResources;
import org.eclipse.epf.library.edit.Providers;
-import org.eclipse.epf.library.edit.TngAdapterFactory;
import org.eclipse.epf.library.edit.command.IUserInteractionHandler;
+import org.eclipse.epf.library.edit.command.UserInput;
import org.eclipse.epf.library.edit.util.ExtensionManager;
+import org.eclipse.epf.library.edit.util.IRunnableWithProgress;
import org.eclipse.epf.library.edit.util.Messenger;
import org.eclipse.epf.library.edit.util.ProcessUtil;
import org.eclipse.epf.library.edit.util.TngUtil;
+import org.eclipse.epf.library.edit.validation.AbstractStringValidator;
import org.eclipse.epf.library.edit.validation.IValidator;
import org.eclipse.epf.services.IAccessController;
import org.eclipse.epf.services.Services;
@@ -76,22 +70,8 @@
import org.eclipse.epf.uma.WorkProductDescriptor;
import org.eclipse.epf.uma.ecore.impl.MultiResourceEObject;
import org.eclipse.epf.uma.ecore.util.OppositeFeature;
-import org.eclipse.epf.uma.util.MessageException;
import org.eclipse.epf.uma.util.UmaUtil;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.WorkbenchJob;
/**
* Defines static methods that interact with user via dialog boxes to retrieve
@@ -102,7 +82,11 @@
* @since 1.0
*/
public final class UserInteractionHelper {
+
private static final boolean canInteract = true;
+
+ private static final IUIHelper uiHelper = (IUIHelper) ExtensionManager.getExtension(
+ LibraryEditPlugin.getDefault().getId(), "uiHelper"); //$NON-NLS-1$
private UserInteractionHelper() {
super();
@@ -192,46 +176,32 @@
String msg = NLS
.bind(
LibraryEditResources.ui_UserInteractionHelper_defaultconfigcheck,
- ((MethodElement) e).getName());
-
- int ret = MsgBox.prompt(msg);
- if (TngUtil.DEBUG) {
- System.out
- .println("UserInteractionHelper.checkAgainstDefaultConfiguration(): element=" //$NON-NLS-1$
- + e + ", path=" + TngUtil.getLabelWithPath(e)); //$NON-NLS-1$
- }
- switch (ret) {
- case SWT.YES:
- IStatus status = TngUtil.checkEdit(proc.getDefaultContext(), null);
- if (!status.isOK()) {
- return 0;
+ ((MethodElement) e).getName());
+ IUserInteractionHandler uiHandler = ExtensionManager.getDefaultUserInteractionHandler();
+ if(uiHandler != null) {
+ int ret = uiHandler.selectOne(new int[] {
+ IUserInteractionHandler.ACTION_YES,
+ IUserInteractionHandler.ACTION_NO,
+ IUserInteractionHandler.ACTION_CANCEL
+ }, "Add to default configuration", msg, null);
+ if (TngUtil.DEBUG) {
+ System.out
+ .println("UserInteractionHelper.checkAgainstDefaultConfiguration(): element=" //$NON-NLS-1$
+ + e + ", path=" + TngUtil.getLabelWithPath(e)); //$NON-NLS-1$
}
- return 2;
- case SWT.NO:
- return 0;
- case SWT.CANCEL:
- return -1;
+ switch (ret) {
+ case IUserInteractionHandler.ACTION_YES:
+ IStatus status = TngUtil.checkEdit(proc.getDefaultContext(), null);
+ if (!status.isOK()) {
+ return 0;
+ }
+ return 2;
+ case IUserInteractionHandler.ACTION_NO:
+ return 0;
+ case IUserInteractionHandler.ACTION_CANCEL:
+ return -1;
+ }
}
-
- // WrappedMessageDialog msgBox = new
- // WrappedMessageDialog(MsgBox.getDefaultShell(), null, null, msg,
- // MessageDialog.QUESTION,
- // new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
- // IDialogConstants.CANCEL_LABEL },
- // 0);
- // switch (msgBox.open()) {
- // case IDialogConstants.OK_ID:
- // IStatus status = TngUtil.checkEdit(proc.getDefaultContext(), null);
- // if (!status.isOK()) {
- // return 0;
- // }
- // return 2;
- // case IDialogConstants.NO_ID:
- // return 0;
- // case IDialogConstants.CANCEL_ID:
- // return -1;
- // };
-
return 0;
}
@@ -243,54 +213,7 @@
* @return
*/
public static List selectTasks(List taskList, WorkProduct wp) {
- ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
- TngAdapterFactory.INSTANCE
- .getNavigatorView_ComposedAdapterFactory()) {
- public String getColumnText(Object obj, int column) {
- if (obj instanceof MethodElement) {
- return TngUtil.getPresentationName(obj);
- }
- return super.getText(obj);
- }
- };
-
- IStructuredContentProvider contentProvider = new AdapterFactoryContentProvider(
- TngAdapterFactory.INSTANCE
- .getNavigatorView_ComposedAdapterFactory()) {
- public Object[] getElements(Object object) {
- return ((List) object).toArray();
- }
- };
-
- try {
- ProcessListSelectionDialog dlg = new ProcessListSelectionDialog(
- PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getShell(),
- taskList,
- contentProvider,
- labelProvider,
- NLS
- .bind(
- LibraryEditResources.ui_UserInteractionHelper_wplistdlg_msg,
- wp.getName()));
-
- dlg.setTitle(LibraryEditResources.ui_UserInteractionHelper_tasks);
- dlg.setBlockOnOpen(true);
- dlg.open();
- Object[] objs = dlg.getResult();
-
- List selectedTasks = new ArrayList();
- if ((objs != null) && (objs.length > 0)) {
- for (int i = 0; i < objs.length; i++) {
- selectedTasks.add(objs[i]);
- }
- }
- return selectedTasks;
- } finally {
- // dispose
- labelProvider.dispose();
- contentProvider.dispose();
- }
+ return uiHelper.selectTasks(taskList, wp);
}
/**
@@ -301,56 +224,7 @@
* @return
*/
public static List selectWorkProducts(List wpList, Role role) {
- ILabelProvider labelProvider = new AdapterFactoryLabelProvider(
- TngAdapterFactory.INSTANCE
- .getNavigatorView_ComposedAdapterFactory()) {
- public String getColumnText(Object obj, int column) {
- if (obj instanceof MethodElement) {
- return TngUtil.getPresentationName(obj);
- }
- return super.getText(obj);
- }
- };
-
- IStructuredContentProvider contentProvider = new AdapterFactoryContentProvider(
- TngAdapterFactory.INSTANCE
- .getNavigatorView_ComposedAdapterFactory()) {
- public Object[] getElements(Object object) {
- return ((List) object).toArray();
- }
- };
-
- try {
- ProcessListSelectionDialog dlg = new ProcessListSelectionDialog(
- PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getShell(),
- // MsgBox.getDefaultShell(),
- wpList,
- contentProvider,
- labelProvider,
- NLS
- .bind(
- LibraryEditResources.ui_UserInteractionHelper_rolelistdlg_msg,
- role.getName()));
-
- dlg
- .setTitle(LibraryEditResources.ui_UserInteractionHelper_workproducts);
- dlg.setBlockOnOpen(true);
- dlg.open();
- Object[] objs = dlg.getResult();
-
- List selectedWps = new ArrayList();
- if ((objs != null) && (objs.length > 0)) {
- for (int i = 0; i < objs.length; i++) {
- selectedWps.add(objs[i]);
- }
- }
- return selectedWps;
- } finally {
- // dispose
- labelProvider.dispose();
- contentProvider.dispose();
- }
+ return uiHelper.selectWorkProducts(wpList, role);
}
/**
@@ -363,7 +237,7 @@
public static String requestName(Object child,
EStructuralFeature nameFeature, String title,
final IValidator validator) {
- IInputValidator inputValidator = new IInputValidator() {
+ IValidator inputValidator = new AbstractStringValidator() {
public String isValid(String newText) {
if (validator != null) {
@@ -381,12 +255,16 @@
name = str;
}
}
- InputDialog inputDialog = new InputDialog(Display.getCurrent()
- .getActiveShell(), title,
- LibraryEditResources.UserInteractionHelper_ProcessPackage_Name,
- name, inputValidator);
- if (inputDialog.open() == Window.OK) {
- return inputDialog.getValue().trim();
+ IUserInteractionHandler uiHandler = ExtensionManager.getDefaultUserInteractionHandler();
+ if(uiHandler == null) {
+ return null;
+ }
+ UserInput input = new UserInput("", UserInput.TEXT, false, null, null, inputValidator, null);
+ input.setInput(name);
+ boolean ret = uiHandler.requestInput(title, LibraryEditResources.UserInteractionHelper_ProcessPackage_Name,
+ Collections.singletonList(input));
+ if(ret) {
+ return input.getInput().toString().trim();
}
return null;
}
@@ -441,146 +319,21 @@
public static TeamProfile getTeam(Activity activity, Role role,
Object UIContext) {
- List teamList = new ArrayList();
- AdapterFactory adapterFactory = TngAdapterFactory.INSTANCE
- .getOBS_ComposedAdapterFactory();
- // find out all team in visible scope
- getTeamsInScope(adapterFactory, activity, role, teamList);
- if (teamList.size() == 1) {
- return (TeamProfile) teamList.get(0);
- }
- if (teamList.size() > 1) {
- return TeamSelection.getSelectedTeam(teamList, role,
- UIContext instanceof Shell ? (Shell) UIContext : null);
- }
- // there are no teams to assign
- return null;
- }
-
- /**
- * Get teams in scope
- *
- * @param adapterFactory
- * @param e
- * @param role
- * @param teamList
- */
- private static void getTeamsInScope(AdapterFactory adapterFactory,
- BreakdownElement e, Role role, List teamList) {
- // get children for activity
- ITreeItemContentProvider itemProvider = (ITreeItemContentProvider) adapterFactory
- .adapt(e, ITreeItemContentProvider.class);
- Collection children = itemProvider.getChildren(e);
- for (Iterator itor = children.iterator(); itor.hasNext();) {
- Object obj = itor.next();
- if (obj instanceof TeamProfile) {
- TeamProfile team = (TeamProfile) obj;
- List allTeams = new ArrayList();
- // get all sub teams as well
- ProcessUtil.getAllSubTeams(team, allTeams);
-
- for (Iterator teamItor = allTeams.iterator(); teamItor
- .hasNext();) {
- Object o = teamItor.next();
- if (o instanceof TeamProfile) {
- // get roles from teams
- List roles = ProcessUtil.getRoles(((TeamProfile) o)
- .getTeamRoles());
- if (roles.contains(role)) {
- teamList.add(o);
- }
- }
- }
- }
- }
-
- // get parent
- Object currentParent = itemProvider.getParent(e);
- if (currentParent != null) {
- // go up
- getTeamsInScope(adapterFactory, (BreakdownElement) currentParent,
- role, teamList);
- }
- }
-
- private static IRunnableContext getRunnableContext() {
- return ExtensionManager.getDefaultUserInteractionHandler()
- .getRunnableContext();
+ return uiHelper.getTeam(activity, role, UIContext);
}
public static final boolean runWithProgress(final Runnable runnable,
final String msg) {
- final MultiStatus status = new MultiStatus(LibraryEditPlugin.INSTANCE
- .getSymbolicName(), IStatus.OK,
- LibraryEditResources.error_reason, null);
-
final IRunnableWithProgress operation = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
- monitor.beginTask(msg, IProgressMonitor.UNKNOWN);
- monitor.subTask(""); //$NON-NLS-1$
- try {
- runnable.run();
- } catch (RuntimeException e) {
- String msg;
- Throwable ex = null;
- if (e instanceof MessageException) {
- msg = e.getMessage();
- } else {
- StringWriter strWriter = new StringWriter();
- e.printStackTrace(new PrintWriter(strWriter));
- msg = strWriter.toString();
- ex = e;
- }
- status.add(new Status(IStatus.ERROR,
- LibraryEditPlugin.INSTANCE.getSymbolicName(), 0,
- msg, ex));
- } finally {
- monitor.done();
- }
+ runnable.run();
}
};
-
- try {
- // This runs the operation, and shows progress.
- //
- if (Display.getCurrent() == null) {
- // current thread is not a user-interface thread
- //
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- try {
- getRunnableContext().run(true, false, operation);
- } catch (Exception e) {
- LibraryEditPlugin.getDefault().getLogger().logError(e);
- }
- }
-
- });
- } else {
- getRunnableContext().run(true, false, operation);
- }
-
-
-
- if (!status.isOK()) {
- Messenger.INSTANCE.showError(
- LibraryEditResources.errorDialog_title,
- LibraryEditResources.error_msgWithDetails,
- status);
- } else {
- return true;
- }
- } catch (Exception exception) {
- // Something went wrong that shouldn't.
- //
- LibraryEditPlugin.getDefault().getLogger().logError(exception);
- }
-
- return false;
+
+ return runWithProgress(operation, msg);
}
public static final boolean runWithProgress(
@@ -591,12 +344,12 @@
public static final boolean runWithProgress(
final IRunnableWithProgress runnable, final boolean canCancel,
final String msg) {
- return runWithProgress(runnable, getRunnableContext(), canCancel, msg);
+ return uiHelper.runWithProgress(runnable, canCancel, msg);
}
public static final IStatus runAsJob(IRunnableWithProgress runnable,
String taskName) {
- Shell shell = MsgBox.getDefaultShell();
+ Object shell = LibraryEditPlugin.getDefault().getContext();
if (shell == null) {
try {
runnable.run(new NullProgressMonitor());
@@ -611,112 +364,10 @@
}
public static final IStatus runAsJob(final IRunnableWithProgress runnable,
- final String taskName, Shell shell) {
- Job job = new WorkspaceJob(taskName) {
-
- public IStatus runInWorkspace(IProgressMonitor monitor)
- throws CoreException {
- try {
- // monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
- 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();
- return job.getResult();
- }
-
- public static void runInUI(final IRunnableWithProgress runnable,
- final String taskName) {
- Shell shell = MsgBox.getDefaultShell();
- 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();
+ final String taskName, Object shell) {
+ return uiHelper.runAsJob(runnable, taskName, shell);
}
- public static final void runInUIThread(Runnable runnable) {
- runInUIThread(runnable, false);
- }
-
- public static final void runInUIThread(Runnable runnable, boolean async) {
- if(Display.getCurrent() == null) {
- // current thread is not a user-interface thread
- //
- Display display = null;
- try {
- display = Display.getDefault();
- }
- catch(Exception e) {
-
- }
- if(display != null) {
- if(async) {
- display.asyncExec(runnable);
- }
- else {
- display.syncExec(runnable);
- }
- }
- else {
- runnable.run();
- }
- }
- else {
- runnable.run();
- }
-
- }
-
public static final boolean runInUI(final Runnable runnable,
final String taskName) {
return runInUI(runnable, taskName, null);
@@ -724,7 +375,7 @@
public static final boolean runInUI(final Runnable runnable,
final String taskName, ISchedulingRule rule) {
- Shell shell = MsgBox.getDefaultShell();
+ Object shell = LibraryEditPlugin.getDefault().getContext();
if (shell == null) {
runnable.run();
return true;
@@ -748,101 +399,13 @@
}
public static final boolean runInUI(IRunnableWithProgress runnable,
- Shell shell) {
+ Object shell) {
return runInUI(runnable, null, shell);
}
public static final boolean runInUI(IRunnableWithProgress runnable,
- ISchedulingRule rule, Shell shell) {
- if (shell == null) {
- shell = MsgBox.getDefaultShell();
- }
- IRunnableContext context = new ProgressMonitorDialog(shell);
- try {
- PlatformUI.getWorkbench().getProgressService().runInUI(context,
- runnable, rule);
- return true;
- } catch (Exception e) {
- LibraryEditPlugin.getDefault().getLogger().logError(e);
- String title = LibraryEditResources.errorDialog_title;
- ExtensionManager.getDefaultUserInteractionHandler().getMessenger()
- .showError(title, e.toString(), null, e);
-// LibraryEditPlugin.getDefault().getMsgDialog().displayError(title,
-// e.toString(), e);
- }
- return false;
- }
-
- public static final boolean runWithProgress(
- final IRunnableWithProgress runnable,
- final IRunnableContext runnableContext, final boolean canCancel,
- final String msg) {
- final MultiStatus status = new MultiStatus(LibraryEditPlugin.INSTANCE
- .getSymbolicName(), IStatus.OK,
- LibraryEditResources.error_reason, null);
-
- final IRunnableWithProgress operation = new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- monitor.beginTask(msg, IProgressMonitor.UNKNOWN);
- monitor.subTask(""); //$NON-NLS-1$
- try {
- runnable.run(monitor);
- } catch (RuntimeException e) {
- String msg;
- if (e instanceof MessageException) {
- msg = e.getMessage();
- } else {
- StringWriter strWriter = new StringWriter();
- e.printStackTrace(new PrintWriter(strWriter));
- msg = strWriter.toString();
- }
- status.add(new Status(IStatus.ERROR,
- LibraryEditPlugin.INSTANCE.getSymbolicName(), 0,
- msg, e));
- } finally {
- monitor.done();
- }
- }
-
- };
-
- try {
- if (Display.getCurrent() == null) {
- // current thread is not a user-interface thread
- //
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- try {
- runnableContext.run(true, canCancel, operation);
- } catch (Exception e) {
- LibraryEditPlugin.getDefault().getLogger().logError(e);
- }
- }
-
- });
- } else {
- runnableContext.run(true, canCancel, operation);
- }
-
- if (!status.isOK()) {
- ExtensionManager.getDefaultUserInteractionHandler()
- .getMessenger().showError(
- LibraryEditResources.errorDialog_title,
- LibraryEditResources.error_msgWithDetails,
- status);
- } else {
- return true;
- }
- } catch (Exception exception) {
- // Something went wrong that shouldn't.
- //
- LibraryEditPlugin.getDefault().getLogger().logError(exception);
- }
-
- return false;
+ ISchedulingRule rule, Object shell) {
+ return uiHelper.runInUI(runnable, rule, shell);
}
/**
@@ -924,7 +487,7 @@
* @param shell
* @return
*/
- public static IStatus checkModify(EObject element, Shell shell) {
+ public static IStatus checkModify(EObject element, Object shell) {
if (TngUtil.isLocked(element)) {
String msg = MessageFormat
.format(
@@ -942,18 +505,18 @@
*
* @param modifiedResources
* A collection of resources.
- * @param shell
- * The parent shell.
+ * @param context
+ * The context of this call. For RCP, this is the shell.
* @return An <code>IStatus</code> object.
*/
- public static IStatus checkModify(Collection modifiedResources, Shell shell) {
+ public static IStatus checkModify(Collection modifiedResources, Object context) {
IAccessController ac = Services.getAccessController();
if (ac == null) {
return Status.OK_STATUS;
}
Resource[] resources = new Resource[modifiedResources.size()];
modifiedResources.toArray(resources);
- return ac.checkModify(resources, shell);
+ return ac.checkModify(resources, context);
}
public static IResource getWorkspaceResource(Resource resource) {
@@ -1067,7 +630,7 @@
* @return
*/
public static IStatus checkConfigurationsToUpdate(AddCommand addCommand,
- Shell shell) {
+ Object shell) {
EObject parent = addCommand.getOwner();
if (!(parent instanceof MethodPackage)) {
return Status.OK_STATUS;
@@ -1159,18 +722,30 @@
&& currentConfig != targetProcess.getDefaultContext()) {
if (UserInteractionHelper.canInteract()) {
String msg = LibraryEditResources.ActivityDropCommand_deepCopy_promptConfigurationMsg;
- switch (MsgBox.prompt(msg)) {
- case SWT.YES:
- break;
- case SWT.NO:
- deepCopyConfig = currentConfig;
- break;
- case SWT.CANCEL:
- throw new OperationCanceledException();
+ IUserInteractionHandler uiHandler = ExtensionManager.getDefaultUserInteractionHandler();
+ if(uiHandler != null) {
+ int ret = uiHandler.selectOne(new int[] {
+ IUserInteractionHandler.ACTION_YES,
+ IUserInteractionHandler.ACTION_NO,
+ IUserInteractionHandler.ACTION_CANCEL
+ }, LibraryEditResources.deepCopy_title, msg, null);
+ switch (ret) {
+ case IUserInteractionHandler.ACTION_YES:
+ break;
+ case IUserInteractionHandler.ACTION_NO:
+ deepCopyConfig = currentConfig;
+ break;
+ case IUserInteractionHandler.ACTION_CANCEL:
+ throw new OperationCanceledException();
+ }
}
}
}
}
return deepCopyConfig;
}
+
+ public static IUIHelper getUIHelper() {
+ return uiHelper;
+ }
}
\ No newline at end of file
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/AdapterFactoryItemLabelProvider.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/AdapterFactoryItemLabelProvider.java
new file mode 100644
index 0000000..72b921c
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/AdapterFactoryItemLabelProvider.java
@@ -0,0 +1,50 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2008 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 implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.library.edit.util;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+
+/**
+ * @author Phong Nguyen Le
+ * @since 1.5
+ *
+ */
+public class AdapterFactoryItemLabelProvider extends ItemLabelProvider {
+ private AdapterFactory adapterFactory;
+
+ public AdapterFactoryItemLabelProvider(AdapterFactory adapterFactory) {
+ super();
+ this.adapterFactory = adapterFactory;
+ }
+
+ @Override
+ public Object getImage(Object object) {
+ // Get the adapter from the factory.
+ //
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory
+ .adapt(object, IItemLabelProvider.class);
+
+ return itemLabelProvider != null ? itemLabelProvider.getImage(object)
+ : super.getImage(object);
+ }
+
+ @Override
+ public String getText(Object object) {
+ // Get the adapter from the factory.
+ //
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory
+ .adapt(object, IItemLabelProvider.class);
+
+ return itemLabelProvider != null ? itemLabelProvider.getText(object)
+ : super.getText(object);
+ }
+}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/IRunnableWithProgress.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/IRunnableWithProgress.java
new file mode 100644
index 0000000..ebd2ace
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/IRunnableWithProgress.java
@@ -0,0 +1,43 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2008 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 implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.library.edit.util;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * @author Phong Nguyen Le
+ * @since 1.5
+ *
+ */
+public interface IRunnableWithProgress {
+ /**
+ * Runs this operation. Progress should be reported to the given progress monitor.
+ * This method is usually invoked by an <code>IRunnableContext</code>'s <code>run</code> method,
+ * which supplies the progress monitor.
+ * A request to cancel the operation should be honored and acknowledged
+ * by throwing <code>InterruptedException</code>.
+ *
+ * @param monitor the progress monitor to use to display progress and receive
+ * requests for cancelation
+ * @exception InvocationTargetException if the run method must propagate a checked exception,
+ * it should wrap it inside an <code>InvocationTargetException</code>; runtime exceptions are automatically
+ * wrapped in an <code>InvocationTargetException</code> by the calling context
+ * @exception InterruptedException if the operation detects a request to cancel,
+ * using <code>IProgressMonitor.isCanceled()</code>, it should exit by throwing
+ * <code>InterruptedException</code>
+ *
+ * @see IRunnableContext#run
+ */
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException;
+}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ItemLabelProvider.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ItemLabelProvider.java
new file mode 100644
index 0000000..27db8fb
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ItemLabelProvider.java
@@ -0,0 +1,36 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2008 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 implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.library.edit.util;
+
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+
+/**
+ * @author Phong Nguyen Le
+ * @since 1.5
+ *
+ */
+public class ItemLabelProvider implements IItemLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.edit.provider.IItemLabelProvider#getImage(java.lang.Object)
+ */
+ public Object getImage(Object object) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.emf.edit.provider.IItemLabelProvider#getText(java.lang.Object)
+ */
+ public String getText(Object object) {
+ return object == null ? "" : object.toString();//$NON-NLS-1$
+ }
+
+}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ProcessUtil.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ProcessUtil.java
index 8727bee..9e58e51 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ProcessUtil.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ProcessUtil.java
@@ -27,7 +27,6 @@
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.NotificationImpl;
-import org.eclipse.emf.common.ui.viewer.IViewerProvider;
import org.eclipse.emf.common.util.AbstractTreeIterator;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAttribute;
@@ -100,8 +99,6 @@
import org.eclipse.epf.uma.provider.UmaEditPlugin;
import org.eclipse.epf.uma.util.AssociationHelper;
import org.eclipse.epf.uma.util.UmaUtil;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.Viewer;
import com.ibm.icu.text.MessageFormat;
import com.ibm.icu.util.StringTokenizer;
@@ -473,56 +470,9 @@
return wpDesc;
}
- public static Viewer getViewer(AdapterFactory adapterFactory, Process proc) {
- if (adapterFactory instanceof ExposedAdapterFactory) {
- for (Iterator iter = Collections.unmodifiableList(
- ((ExposedAdapterFactory) adapterFactory)
- .getChangeListeners()).iterator(); iter.hasNext();) {
- Object listener = iter.next();
- if (listener instanceof IContentProvider && listener instanceof IViewerProvider) {
- Viewer viewer = ((IViewerProvider) listener).getViewer();
- if (viewer.getInput() instanceof ProcessComponent
- && ((ProcessComponent) viewer.getInput())
- .getProcess() == proc)
- return viewer;
- }
- }
- }
- return null;
- }
-
public static boolean refreshNeeded(AdapterFactory adapterFactory,
BSActivityItemProvider itemProvider) {
- Process process = (Process) itemProvider.getTopItem();
- if (process == null)
- return false;
-
- // check if the given process is currently opened in editor
- //
- Viewer viewer = getViewer(adapterFactory, process);
- if (viewer != null && viewer.getControl() != null
- && !viewer.getControl().isDisposed()) {
- return true;
- }
-
- for (Iterator iter = TngUtil.getContributors(process); iter.hasNext();) {
- Object element = iter.next();
- BSActivityItemProvider adapter = (BSActivityItemProvider) adapterFactory
- .adapt(element, ITreeItemContentProvider.class);
- if (refreshNeeded(adapterFactory, adapter))
- return true;
- }
-
- for (Iterator iter = TngUtil.getGeneralizers(process,
- VariabilityType.EXTENDS_LITERAL); iter.hasNext();) {
- Object element = iter.next();
- BSActivityItemProvider adapter = (BSActivityItemProvider) adapterFactory
- .adapt(element, ITreeItemContentProvider.class);
- if (refreshNeeded(adapterFactory, adapter))
- return true;
- }
-
- return false;
+ return UserInteractionHelper.getUIHelper().refreshNeeded(adapterFactory, itemProvider);
}
public static void refreshPredeccessorLists(AdapterFactory factory, Process proc) {
@@ -576,17 +526,7 @@
}
public static void refreshViewer(AdapterFactory factory, Process proc) {
- final Viewer viewer = getViewer(factory, proc);
- if (viewer != null && viewer.getControl() != null
- && !viewer.getControl().isDisposed()) {
- UserInteractionHelper.runInUIThread(new Runnable() {
-
- public void run() {
- viewer.refresh();
- }
-
- });
- }
+ UserInteractionHelper.getUIHelper().refreshViewer(factory, proc);
}
/**
@@ -595,53 +535,11 @@
* @param adapterFactory
*/
public static void refreshIDsInViewers(final ExposedAdapterFactory adapterFactory) {
- UserInteractionHelper.runInUIThread(new Runnable() {
-
- public void run() {
- for (Iterator iter = Collections.unmodifiableList(
- adapterFactory.getChangeListeners()).iterator(); iter.hasNext();) {
- Object listener = iter.next();
- if (listener instanceof IContentProvider && listener instanceof IViewerProvider) {
- Viewer viewer = ((IViewerProvider) listener).getViewer();
- if (viewer != null && viewer.getControl() != null
- && !viewer.getControl().isDisposed()
- && viewer.getInput() instanceof ProcessComponent) {
- Process proc = ((ProcessComponent) viewer.getInput())
- .getProcess();
- BSActivityItemProvider itemProvider = (BSActivityItemProvider) adapterFactory
- .adapt(proc, ITreeItemContentProvider.class);
- if (itemProvider.isRefreshAllIDsRequired()) {
- updateIDs(adapterFactory, proc);
- viewer.refresh();
- itemProvider.setRefreshAllIDsRequired(false);
- }
- }
- }
- }
- }
-
- });
+ UserInteractionHelper.getUIHelper().refreshIDsInViewer(adapterFactory);
}
public static void refreshAllViewers(final ExposedAdapterFactory adapterFactory) {
- UserInteractionHelper.runInUIThread(new Runnable() {
-
- public void run() {
- for (Iterator iter = Collections.unmodifiableList(
- adapterFactory.getChangeListeners()).iterator(); iter.hasNext();) {
- Object listener = iter.next();
- if (listener instanceof IContentProvider && listener instanceof IViewerProvider) {
- Viewer viewer = ((IViewerProvider) listener).getViewer();
- if (viewer != null && viewer.getControl() != null
- && !viewer.getControl().isDisposed()
- && viewer.getInput() instanceof ProcessComponent) {
- viewer.refresh();
- }
- }
- }
- }
-
- });
+ UserInteractionHelper.getUIHelper().refreshAllViewers(adapterFactory);
}
/**
diff --git a/2.0/plugins/org.eclipse.epf.library.ui/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.library.ui/META-INF/MANIFEST.MF
index f0a3184..7f2c1ed 100644
--- a/2.0/plugins/org.eclipse.epf.library.ui/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.library.ui/META-INF/MANIFEST.MF
@@ -21,6 +21,7 @@
org.eclipse.epf.library.ui.actions,
org.eclipse.epf.library.ui.dialogs,
org.eclipse.epf.library.ui.preferences,
+ org.eclipse.epf.library.ui.providers,
org.eclipse.epf.library.ui.util,
org.eclipse.epf.library.ui.views,
org.eclipse.epf.library.ui.wizards
diff --git a/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/LibraryUIManager.java b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/LibraryUIManager.java
index 8b8e511..bf85ff5 100644
--- a/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/LibraryUIManager.java
+++ b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/LibraryUIManager.java
@@ -869,7 +869,7 @@
final StringBuffer newPath = new StringBuffer();
- UserInteractionHelper.runInUIThread(new Runnable() {
+ UserInteractionHelper.getUIHelper().runSafely(new Runnable() {
public void run() {
String title = LibraryUIResources.copyLibraryDialog_title;
String message = LibraryUIResources.copyLibraryDialog_text_readOnlyLib;
diff --git a/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/dialogs/UserInputsDialog.java b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/dialogs/UserInputsDialog.java
index 40922c1..1b0f65f 100644
--- a/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/dialogs/UserInputsDialog.java
+++ b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/dialogs/UserInputsDialog.java
@@ -17,6 +17,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.epf.library.edit.command.UserInput;
import org.eclipse.epf.library.edit.validation.IValidator;
+import org.eclipse.epf.library.ui.providers.DelegateLabelProvider;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
@@ -236,7 +237,7 @@
new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.setContentProvider(new ArrayContentProvider());
if (userInput.getLabelProvider() != null) {
- viewer.setLabelProvider(userInput.getLabelProvider());
+ viewer.setLabelProvider(new DelegateLabelProvider(userInput.getLabelProvider()));
}
List choices = userInput.getChoices();
viewer.setInput(choices);
diff --git a/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/providers/DelegateLabelProvider.java b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/providers/DelegateLabelProvider.java
new file mode 100644
index 0000000..040fb17
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/providers/DelegateLabelProvider.java
@@ -0,0 +1,40 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2005, 2008 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 implementation
+//------------------------------------------------------------------------------
+package org.eclipse.epf.library.ui.providers;
+
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Phong Nguyen Le
+ * @since 1.5
+ *
+ */
+public class DelegateLabelProvider extends LabelProvider {
+ private IItemLabelProvider itemLabelProvider;
+
+ public DelegateLabelProvider(IItemLabelProvider itemLabelProvider) {
+ super();
+ this.itemLabelProvider = itemLabelProvider;
+ }
+
+ @Override
+ public String getText(Object element) {
+ return itemLabelProvider.getText(element);
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return ExtendedImageRegistry.getInstance().getImage(itemLabelProvider.getImage(element));
+ }
+}
diff --git a/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/views/ProcessTreeContentProvider.java b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/views/ProcessTreeContentProvider.java
index 888d692..91a72e1 100644
--- a/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/views/ProcessTreeContentProvider.java
+++ b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/views/ProcessTreeContentProvider.java
@@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.epf.library.LibraryServiceUtil;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.epf.library.edit.util.TngUtil;
@@ -99,8 +100,8 @@
if (capabilityPatternUIFolder == null) {
capabilityPatternUIFolder = new ProcessTreeUIFolder(
CAPABILITY_PATTERNS,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/CapabilityPatterns"), parentElement); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/CapabilityPatterns")), parentElement); //$NON-NLS-1$
capabilityPatternUIFolders.put(plugin,
capabilityPatternUIFolder);
}
@@ -110,8 +111,8 @@
if (deliveryProcessUIFolder == null) {
deliveryProcessUIFolder = new ProcessTreeUIFolder(
DELIVERY_PROCESSES,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/DeliveryProcesses"), parentElement); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/DeliveryProcesses")), parentElement); //$NON-NLS-1$
deliveryProcessUIFolders.put(plugin, deliveryProcessUIFolder);
}
diff --git a/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/views/ProcessTreeUIFolder.java b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/views/ProcessTreeUIFolder.java
index 93eee1d..8d92e4c 100644
--- a/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/views/ProcessTreeUIFolder.java
+++ b/2.0/plugins/org.eclipse.epf.library.ui/src/org/eclipse/epf/library/ui/views/ProcessTreeUIFolder.java
@@ -10,6 +10,7 @@
//------------------------------------------------------------------------------
package org.eclipse.epf.library.ui.views;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.swt.graphics.Image;
@@ -21,8 +22,8 @@
*/
public class ProcessTreeUIFolder {
- private static final Image DEFAULT_IMAGE = LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/Folder"); //$NON-NLS-1$
+ private static final Image DEFAULT_IMAGE = ExtendedImageRegistry.getInstance().getImage(
+ LibraryEditPlugin.INSTANCE.getImage("full/obj16/Folder")); //$NON-NLS-1$
private String name;
diff --git a/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/DiagramMigrationPlugin.class b/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/DiagramMigrationPlugin.class
index 9f5d01c..69732fb 100644
--- a/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/DiagramMigrationPlugin.class
+++ b/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/DiagramMigrationPlugin.class
Binary files differ
diff --git a/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/ad/wizards/MigrationExportWizard.class b/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/ad/wizards/MigrationExportWizard.class
index b79fa0e..e8c19a4 100644
--- a/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/ad/wizards/MigrationExportWizard.class
+++ b/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/ad/wizards/MigrationExportWizard.class
Binary files differ
diff --git a/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/util/MigrationUtil.class b/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/util/MigrationUtil.class
index 3e72f21..e9b7f49 100644
--- a/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/util/MigrationUtil.class
+++ b/2.0/plugins/org.eclipse.epf.migration.diagram/bin/org/eclipse/epf/migration/diagram/util/MigrationUtil.class
Binary files differ
diff --git a/2.0/plugins/org.eclipse.epf.publishing.ui/META-INF/MANIFEST.MF b/2.0/plugins/org.eclipse.epf.publishing.ui/META-INF/MANIFEST.MF
index 773454d..3906bf1 100644
--- a/2.0/plugins/org.eclipse.epf.publishing.ui/META-INF/MANIFEST.MF
+++ b/2.0/plugins/org.eclipse.epf.publishing.ui/META-INF/MANIFEST.MF
@@ -13,7 +13,8 @@
org.eclipse.jface.text,
org.eclipse.help.base,
org.eclipse.ui.browser,
- org.eclipse.epf.common.ui
+ org.eclipse.epf.common.ui,
+ org.eclipse.epf.library.edit.ui
Eclipse-LazyStart: true
Export-Package: org.eclipse.epf.publishing.ui,
org.eclipse.epf.publishing.ui.preferences,
diff --git a/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/wizards/PublishConfigWizard.java b/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/wizards/PublishConfigWizard.java
index 6837ac6..3b06626 100644
--- a/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/wizards/PublishConfigWizard.java
+++ b/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/wizards/PublishConfigWizard.java
@@ -21,7 +21,7 @@
import org.eclipse.epf.common.utils.FileUtil;
import org.eclipse.epf.library.LibraryService;
import org.eclipse.epf.library.LibraryServiceUtil;
-import org.eclipse.epf.library.edit.ui.UserInteractionHelper;
+import org.eclipse.epf.library.edit.ui.UIHelper;
import org.eclipse.epf.publishing.services.PublishHTMLOptions;
import org.eclipse.epf.publishing.services.PublishManager;
import org.eclipse.epf.publishing.services.PublishOptions;
@@ -207,7 +207,7 @@
Display.getCurrent().getActiveShell(), publisher
.getViewBuilder());
- UserInteractionHelper.runWithProgress(operation, dlg, true,
+ UIHelper.runWithProgress(operation, dlg, true,
PublishingUIResources.publishConfigWizard_title);
return true;
diff --git a/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/wizards/PublishingOperation.java b/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/wizards/PublishingOperation.java
index 9a2bb28..e410946 100644
--- a/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/wizards/PublishingOperation.java
+++ b/2.0/plugins/org.eclipse.epf.publishing.ui/src/org/eclipse/epf/publishing/ui/wizards/PublishingOperation.java
@@ -46,7 +46,7 @@
* @author Kelvin Low
* @since 1.0
*/
-public class PublishingOperation implements IRunnableWithProgress {
+public class PublishingOperation implements IRunnableWithProgress, org.eclipse.epf.library.edit.util.IRunnableWithProgress {
private static final String PUBLISH_CONFIG_ERROR_TITLE = PublishingUIResources.publishConfigDialog_title; //$NON-NLS-1$
diff --git a/2.0/plugins/org.eclipse.epf.search.ui/src/org/eclipse/epf/search/ui/internal/SearchResultTreeContentProvider.java b/2.0/plugins/org.eclipse.epf.search.ui/src/org/eclipse/epf/search/ui/internal/SearchResultTreeContentProvider.java
index 15cedf5..4b110e7 100644
--- a/2.0/plugins/org.eclipse.epf.search.ui/src/org/eclipse/epf/search/ui/internal/SearchResultTreeContentProvider.java
+++ b/2.0/plugins/org.eclipse.epf.search.ui/src/org/eclipse/epf/search/ui/internal/SearchResultTreeContentProvider.java
@@ -17,6 +17,7 @@
import java.util.Map;
import java.util.Set;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.epf.search.ui.SearchUIResources;
import org.eclipse.epf.uma.Activity;
@@ -347,11 +348,11 @@
Object element = elements[i];
if (element instanceof MethodPlugin) {
SearchResultUIFolder methodContentFolder = new SearchResultUIFolder(
- METHOD_CONTENT, LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/Content"), element); //$NON-NLS-1$
+ METHOD_CONTENT, ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/Content")), element); //$NON-NLS-1$
SearchResultUIFolder processesFolder = new SearchResultUIFolder(
- PROCESSES, LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/Processes"), element); //$NON-NLS-1$
+ PROCESSES, ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/Processes")), element); //$NON-NLS-1$
Object[] methodPackages = getChildren(element);
for (int j = 0; j < methodPackages.length; j++) {
Object methodPackage = methodPackages[j];
@@ -369,18 +370,18 @@
pkg,
new SearchResultUIFolder(
CONTENT_PACKAGES,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/MethodPackages"), methodContentFolder)); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/MethodPackages")), methodContentFolder)); //$NON-NLS-1$
} else if (((ContentPackage) pkg).getName()
.equals(PKG_NAME_CATEGORIES)) {
SearchResultUIFolder standardCategoriesFolder = new SearchResultUIFolder(
STANDARD_CATEGORIES,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/StandardCategories"), methodContentFolder); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/StandardCategories")), methodContentFolder); //$NON-NLS-1$
SearchResultUIFolder customCategoriesFolder = new SearchResultUIFolder(
CUSTOM_CATEGORIES,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/CustomCategories"), methodContentFolder); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/CustomCategories")), methodContentFolder); //$NON-NLS-1$
Object[] contentPackages = getChildren(pkg);
for (int l = 0; l < contentPackages.length; l++) {
Object contentPackage = contentPackages[l];
@@ -406,8 +407,8 @@
contentPackage,
new SearchResultUIFolder(
DISCIPLINES,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/Disciplines"), standardCategoriesFolder)); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/Disciplines")), standardCategoriesFolder)); //$NON-NLS-1$
} else if (pkgName
.equals(PKG_NAME_DOMAINS)) {
insert(
@@ -418,8 +419,8 @@
contentPackage,
new SearchResultUIFolder(
DOMAINS,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/Domains"), standardCategoriesFolder)); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/Domains")), standardCategoriesFolder)); //$NON-NLS-1$
} else if (pkgName
.equals(PKG_NAME_WORK_PRODUCT_TYPES)) {
insert(
@@ -430,8 +431,8 @@
contentPackage,
new SearchResultUIFolder(
WORK_PRODUCT_TYPES,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/WorkProductTypes"), standardCategoriesFolder)); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/WorkProductTypes")), standardCategoriesFolder)); //$NON-NLS-1$
} else if (pkgName
.equals(PKG_NAME_ROLESETS)) {
insert(
@@ -442,8 +443,8 @@
contentPackage,
new SearchResultUIFolder(
ROLESETS,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/Roles"), standardCategoriesFolder)); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/Roles")), standardCategoriesFolder)); //$NON-NLS-1$
} else if (pkgName
.equals(PKG_NAME_TOOLS)) {
insert(
@@ -454,8 +455,8 @@
contentPackage,
new SearchResultUIFolder(
TOOLS,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/Tools"), standardCategoriesFolder)); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/Tools")), standardCategoriesFolder)); //$NON-NLS-1$
}
}
}
@@ -469,8 +470,8 @@
pkg,
new SearchResultUIFolder(
CAPABILITY_PATTERNS,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/CapabilityPatterns"), processesFolder)); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/CapabilityPatterns")), processesFolder)); //$NON-NLS-1$
}
}
Set children = (Set) elementMap.get(element);
@@ -483,8 +484,8 @@
methodPackage,
new SearchResultUIFolder(
DELIVERY_PROCESSES,
- LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/DeliveryProcesses"), processesFolder)); //$NON-NLS-1$
+ ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/DeliveryProcesses")), processesFolder)); //$NON-NLS-1$
}
}
}
diff --git a/2.0/plugins/org.eclipse.epf.search.ui/src/org/eclipse/epf/search/ui/internal/SearchResultUIFolder.java b/2.0/plugins/org.eclipse.epf.search.ui/src/org/eclipse/epf/search/ui/internal/SearchResultUIFolder.java
index 9cc90bb..551b7d6 100644
--- a/2.0/plugins/org.eclipse.epf.search.ui/src/org/eclipse/epf/search/ui/internal/SearchResultUIFolder.java
+++ b/2.0/plugins/org.eclipse.epf.search.ui/src/org/eclipse/epf/search/ui/internal/SearchResultUIFolder.java
@@ -10,6 +10,7 @@
//------------------------------------------------------------------------------
package org.eclipse.epf.search.ui.internal;
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.swt.graphics.Image;
@@ -21,8 +22,8 @@
*/
public class SearchResultUIFolder {
- private static final Image DEFAULT_IMAGE = LibraryEditPlugin.INSTANCE
- .getImage("full/obj16/Folder"); //$NON-NLS-1$
+ private static final Image DEFAULT_IMAGE = ExtendedImageRegistry.getInstance().getImage(LibraryEditPlugin.INSTANCE
+ .getImage("full/obj16/Folder")); //$NON-NLS-1$
private String name;