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;
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) {