コード例 #1
0
 public ModelResolutionPreferencePage() {
   super(FieldEditorPreferencePage.GRID);
   setPreferenceStore(EMFCompareIDEUIPlugin.getDefault().getPreferenceStore());
 }
コード例 #2
0
ファイル: DataGit.java プロジェクト: eclipse/emf.compare
  public DataGit(
      String zippedRepoLocation, String repoName, String rootProjectName, String modelName) {
    try {
      this.disposers = new ArrayList<Runnable>();
      String systemTmpDir = System.getProperty("java.io.tmpdir");
      Bundle bundle = Platform.getBundle("org.eclipse.emf.compare.tests.performance");
      URL entry = bundle.getEntry(zippedRepoLocation);
      repoFile = new File(systemTmpDir + File.separator + repoName);

      // Delete repo if it already exists
      GitUtil.deleteRepo(repoFile);

      // Unzip repository to temp directory
      GitUtil.unzipRepo(entry, systemTmpDir, new NullProgressMonitor());

      Job importJob =
          new Job("ImportProjects") {
            @Override
            protected IStatus run(IProgressMonitor monitor) {
              GitUtil.importProjectsFromRepo(repoFile);
              return Status.OK_STATUS;
            }
          };
      importJob.schedule();
      importJob.join();

      Job connectJob =
          new Job("ConnectProjects") {
            @Override
            protected IStatus run(IProgressMonitor monitor) {
              try {
                // Connect eclipse projects to egit repository
                File gitDir = new File(repoFile, Constants.DOT_GIT);
                repository = Activator.getDefault().getRepositoryCache().lookupRepository(gitDir);
                IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
                GitUtil.connectProjectsToRepo(repository, Arrays.asList(projects));
              } catch (IOException e) {
                Throwables.propagate(e);
              }
              return Status.OK_STATUS;
            }
          };
      connectJob.schedule();
      connectJob.join();

      IProject rootProject = ResourcesPlugin.getWorkspace().getRoot().getProject(rootProjectName);

      final IFile model = rootProject.getFile(new Path(modelName));
      final String fullPath = model.getFullPath().toString();
      final Subscriber subscriber =
          GitUtil.createSubscriberForComparison(repository, MASTER, MODIFIED, model, disposers);
      final IStorageProviderAccessor accessor = new SubscriberStorageAccessor(subscriber);
      final IStorageProvider sourceProvider =
          accessor.getStorageProvider(model, IStorageProviderAccessor.DiffSide.SOURCE);
      final IStorageProvider remoteProvider =
          accessor.getStorageProvider(model, IStorageProviderAccessor.DiffSide.REMOTE);
      final IStorageProvider ancestorProvider =
          accessor.getStorageProvider(model, IStorageProviderAccessor.DiffSide.ORIGIN);
      assertNotNull(sourceProvider);
      assertNotNull(remoteProvider);
      assertNotNull(ancestorProvider);

      final IProgressMonitor m = new NullProgressMonitor();
      final IStorageProviderAccessor storageAccessor = new SubscriberStorageAccessor(subscriber);
      final ITypedElement left = new StorageTypedElement(sourceProvider.getStorage(m), fullPath);
      final ITypedElement right = new StorageTypedElement(remoteProvider.getStorage(m), fullPath);
      final ITypedElement origin =
          new StorageTypedElement(ancestorProvider.getStorage(m), fullPath);
      ModelResolverRegistry mrr = EMFCompareIDEUIPlugin.getDefault().getModelResolverRegistry();
      IModelResolver resolver = mrr.getBestResolverFor(sourceProvider.getStorage(m));
      final ComparisonScopeBuilder scopeBuilder =
          new ComparisonScopeBuilder(resolver, new IdenticalResourceMinimizer(), storageAccessor);
      scope = scopeBuilder.build(left, right, origin, m);

      resourceSets.add((ResourceSet) scope.getLeft());
      resourceSets.add((ResourceSet) scope.getRight());
      resourceSets.add((ResourceSet) scope.getOrigin());

    } catch (IOException e) {
      Throwables.propagate(e);
    } catch (CoreException e) {
      Throwables.propagate(e);
    } catch (InterruptedException e) {
      Throwables.propagate(e);
    }
  }