preparing new release
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / util / versioning / VersioningHelper.java
index bbc2979..de069b9 100644 (file)
@@ -15,6 +15,7 @@ import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPartSite;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.actions.ExportResourcesAction;
+import org.eclipse.ui.actions.ImportResourcesAction;
 import org.eclipse.ui.part.ViewPart;
 import org.eclipse.ui.part.WorkbenchPart;
 
@@ -112,6 +113,35 @@ public class VersioningHelper {
        return action;
     }
     
+    public static ImportResourcesAction createImportResourcesAction(IWorkbenchWindow window) {
+       ImportResourcesAction action = null;
+       
+       try {
+               if (isEclipse21OrHigher()) {
+                       Constructor constructor = ImportResourcesAction.class.getConstructor(
+                               new Class[] { IWorkbenchWindow.class });
+                       action = (ImportResourcesAction) constructor.newInstance(
+                               new Object[] { window });
+               } else {
+                       Constructor constructor = ImportResourcesAction.class.getConstructor(
+                               new Class[] { IWorkbench.class });
+                       action = (ImportResourcesAction) constructor.newInstance(
+                               new Object[] { window.getWorkbench() });
+               }
+        } catch (NoSuchMethodException e) {
+            // should not happen
+        } catch (IllegalArgumentException e) {
+            // should not happen
+        } catch (IllegalAccessException e) {
+            // should not happen
+        } catch (InvocationTargetException e) {
+            // should not happen
+        } catch (InstantiationException e) {
+            // should not happen
+        }
+       return action;
+    }
+
     public static void registerActionToKeyBindingService(
        IWorkbenchPartSite site, String[] scopes, IAction action) {