コード例 #1
0
 /*
  * @see IWorkspaceRunnable#run(IProgressMonitor)
  */
 public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
   if (monitor == null) {
     monitor = new NullProgressMonitor();
   }
   monitor.beginTask(MDEUIMessages.FeatureImportWizard_operation_creating, fModels.length);
   try {
     MultiStatus multiStatus =
         new MultiStatus(
             MDEPlugin.getPluginId(),
             IStatus.OK,
             MDEUIMessages.FeatureImportWizard_operation_multiProblem,
             null);
     for (int i = 0; i < fModels.length; i++) {
       try {
         createProject(fModels[i], new SubProgressMonitor(monitor, 1));
       } catch (CoreException e) {
         multiStatus.merge(e.getStatus());
       }
       if (monitor.isCanceled()) {
         throw new OperationCanceledException();
       }
     }
     if (!multiStatus.isOK()) {
       throw new CoreException(multiStatus);
     }
   } finally {
     monitor.done();
   }
 }
コード例 #2
0
  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());
    }
  }