private void importContent(
      Object source,
      IPath destPath,
      IImportStructureProvider provider,
      List filesToImport,
      IProgressMonitor monitor)
      throws CoreException {
    IOverwriteQuery query =
        new IOverwriteQuery() {
          public String queryOverwrite(String file) {
            return ALL;
          }
        };
    ImportOperation op = new ImportOperation(destPath, source, provider, query);
    op.setCreateContainerStructure(false);
    if (filesToImport != null) {
      op.setFilesToImport(filesToImport);
    }

    try {
      op.run(monitor);
    } catch (InvocationTargetException e) {
      Throwable th = e.getTargetException();
      if (th instanceof CoreException) {
        throw (CoreException) th;
      }
      IStatus status =
          new Status(IStatus.ERROR, MDEPlugin.getPluginId(), IStatus.ERROR, e.getMessage(), e);
      throw new CoreException(status);
    } catch (InterruptedException e) {
      throw new OperationCanceledException(e.getMessage());
    }
  }
 public static void importFilesFromZip(
     ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor)
     throws InvocationTargetException {
   ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(srcZipFile);
   try {
     ImportOperation op =
         new ImportOperation(
             destPath, structureProvider.getRoot(), structureProvider, new ImportOverwriteQuery());
     op.run(monitor);
   } catch (InterruptedException e) {
     // should not happen
   }
 }
 public static void importFilesFromDirectory(
     File rootDir, IPath destPath, IProgressMonitor monitor)
     throws InvocationTargetException, IOException {
   IImportStructureProvider structureProvider = FileSystemStructureProvider.INSTANCE;
   List<File> files = new ArrayList<>(100);
   addFiles(rootDir, files);
   try {
     ImportOperation op =
         new ImportOperation(
             destPath, rootDir, structureProvider, new ImportOverwriteQuery(), files);
     op.setCreateContainerStructure(false);
     op.run(monitor);
   } catch (InterruptedException e) {
     // should not happen
   }
 }
  public static void importFromZip(
      final File file, final IPath destination, final IProgressMonitor monitor)
      throws InvocationTargetException {
    final IImportStructureProvider structureProvider = FileSystemStructureProvider.INSTANCE;

    final IOverwriteQuery overwriteQuery =
        new IOverwriteQuery() {
          @Override
          public String queryOverwrite(final String file) {
            return ALL;
          }
        };
    try {
      final ImportOperation op =
          new ImportOperation(destination, file, structureProvider, overwriteQuery);
      op.setCreateContainerStructure(false);
      op.run(monitor);
    } catch (final InterruptedException e) {
      // should not happen
    }
  }
Example #5
0
 private void importSamples(IProject project)
     throws InvocationTargetException, InterruptedException, CoreException {
   Location installLocation = Platform.getInstallLocation();
   if (installLocation == null) {
     return;
   }
   String installFileStr = installLocation.getURL().getFile();
   File installFile = new File(installFileStr, "sample_data");
   if (installFile.isDirectory()) {
     IFolder sampleData = project.getFolder("sample_data");
     sampleData.create(true, true, new NullProgressMonitor());
     ImportOperation importOperation =
         new ImportOperation(
             sampleData.getFullPath(),
             installFile,
             FileSystemStructureProvider.INSTANCE,
             overwriteQuery);
     importOperation.setCreateContainerStructure(false);
     importOperation.run(new NullProgressMonitor());
   }
 }
 private void doCreateProject(ProjectCandidate pc, IProgressMonitor monitor)
     throws CoreException, InterruptedException, InvocationTargetException {
   HybridProjectCreator projectCreator = new HybridProjectCreator();
   Widget w = pc.getWidget();
   String projectName = pc.getProjectName();
   URI location = null;
   if (!copyFiles) {
     location = pc.wwwLocation.getParentFile().toURI();
   }
   IProject project =
       projectCreator.createProject(
           projectName,
           location,
           w.getName(),
           w.getId(),
           HybridMobileEngineManager.getDefaultEngine(),
           monitor);
   if (copyFiles) {
     ImportOperation operation =
         new ImportOperation(
             project.getFullPath(),
             pc.wwwLocation.getParentFile(),
             FileSystemStructureProvider.INSTANCE,
             this);
     operation.setContext(getShell());
     operation.setOverwriteResources(true);
     operation.setCreateContainerStructure(false);
     operation.run(monitor);
     IStatus status = operation.getStatus();
     if (!status.isOK()) throw new InvocationTargetException(new CoreException(status));
   }
 }
  private static void importProject(
      Shell shell,
      IImportStructureProvider provider,
      Object source,
      IPath path,
      boolean overwriteResources,
      boolean createContainerStructure,
      IProgressMonitor monitor)
      throws InvocationTargetException, InterruptedException {
    monitor.beginTask(
        Messages.getString("ImportProjectsUtilities.task.importingProject"), 1); // $NON-NLS-1$

    ArrayList fileSystemObjects = new ArrayList();
    ImportProjectsUtilities.getFilesForProject(fileSystemObjects, provider, source);

    ImportOperation operation =
        new ImportOperation(path, source, provider, new MyOverwriteQuery(), fileSystemObjects);
    operation.setContext(shell);
    operation.setOverwriteResources(overwriteResources);
    operation.setCreateContainerStructure(createContainerStructure);
    operation.run(new SubProgressMonitor(monitor, 1));
    monitor.done();
  }