Examples of ITypedElement


Examples of org.eclipse.compare.ITypedElement

   */
  private static void compareLocalWithRef(Repository repository,
      IPath location, String refName, IWorkbenchPage page)
      throws IOException {
    final String gitPath = getRepoRelativePath(location, repository);
    final ITypedElement base = new LocalNonWorkspaceTypedElement(location);

    CompareEditorInput in = prepareCompareInput(repository, gitPath, base,
        refName);

    if (page != null)
View Full Code Here

Examples of org.eclipse.compare.ITypedElement

   * base and the reference we compare it with.
   */
  private static CompareEditorInput prepareCompareInput(
      Repository repository, String gitPath, ITypedElement base,
      String refName) throws IOException {
    final ITypedElement destCommit;
    ITypedElement commonAncestor = null;

    if (GitFileRevision.INDEX.equals(refName))
      destCommit = getIndexTypedElement(repository, gitPath);
    else if (Constants.HEAD.equals(refName))
      destCommit = getHeadTypedElement(repository, gitPath);
View Full Code Here

Examples of org.eclipse.compare.ITypedElement

   * @throws IOException
   */
  private static void compareBetween(Repository repository,
      String leftGitPath, String rightGitPath, String leftRev,
      String rightRev, IWorkbenchPage page) throws IOException {
    final ITypedElement left = getTypedElementFor(repository, leftGitPath,
        leftRev);
    final ITypedElement right = getTypedElementFor(repository,
        rightGitPath,
        rightRev);

    final ITypedElement commonAncestor;
    if (left != null && right != null && !GitFileRevision.INDEX.equals(leftRev)
        && !GitFileRevision.INDEX.equals(rightRev))
      commonAncestor = getTypedElementForCommonAncestor(repository,
          rightGitPath, leftRev, rightRev);
    else
View Full Code Here

Examples of org.eclipse.compare.ITypedElement

    }
    return gitPath;
  }

  private static ITypedElement getTypedElementFor(Repository repository, String gitPath, String rev) throws IOException {
    final ITypedElement typedElement;
    if (GitFileRevision.INDEX.equals(rev))
      typedElement = getIndexTypedElement(repository, gitPath);
    else if (Constants.HEAD.equals(rev))
      typedElement = getHeadTypedElement(repository, gitPath);
    else {
View Full Code Here

Examples of org.eclipse.compare.ITypedElement

  }

  private static ITypedElement getTypedElementForCommonAncestor(
      Repository repository, final String gitPath, String srcRev,
      String dstRev) {
    ITypedElement ancestor = null;
    try {
      final ObjectId srcID = repository.resolve(srcRev);
      final ObjectId dstID = repository.resolve(dstRev);
      if (srcID != null && dstID != null)
        ancestor = getFileRevisionTypedElementForCommonAncestor(
View Full Code Here

Examples of org.eclipse.compare.ITypedElement

   * @param repository
   * @param path
   */
  public static void compareHeadWithWorkingTree(Repository repository,
      String path) {
    ITypedElement base = getHeadTypedElement(repository, path);
    if (base == null)
      return;
    IFileRevision nextFile;
    nextFile = new WorkingTreeFileRevision(new File(
        repository.getWorkTree(), path));
    String encoding = ResourcesPlugin.getEncoding();
    ITypedElement next = new FileRevisionTypedElement(nextFile, encoding);
    GitCompareFileRevisionEditorInput input = new GitCompareFileRevisionEditorInput(
        next, base, null);
    CompareUI.openCompareDialog(input);
  }
View Full Code Here

Examples of org.eclipse.compare.ITypedElement

  }

  private void reactOnOpen(OpenEvent event) {
    Object selected = ((IStructuredSelection) event.getSelection())
        .getFirstElement();
    ITypedElement left;
    ITypedElement right;
    if (selected instanceof ContainerNode) {
      // open/close folder
      TreeViewer tv = (TreeViewer) event.getViewer();
      tv.setExpandedState(selected, !tv.getExpandedState(selected));
    } else if (selected instanceof FileNode) {
View Full Code Here

Examples of org.eclipse.compare.ITypedElement

  public Object getAdapter(Class adapter) {
    if (adapter == IFile.class || adapter == IResource.class) {
      Object selectedEdition = getSelectedEdition();
      if (selectedEdition instanceof DiffNode) {
        DiffNode diffNode = (DiffNode) selectedEdition;
        ITypedElement element = diffNode.getLeft();
        if (element instanceof ResourceEditableRevision) {
          ResourceEditableRevision resourceRevision = (ResourceEditableRevision) element;
          return resourceRevision.getFile();
        }
      }
View Full Code Here

Examples of org.eclipse.compare.ITypedElement

        // if this is neither conflicting nor changed, we skip it
        if (!conflicting && !modified)
          continue;

        ITypedElement right;
        if (conflicting) {
          GitFileRevision revision = GitFileRevision.inIndex(
              repository, gitPath, DirCacheEntry.STAGE_3);
          String encoding = CompareCoreUtils.getResourceEncoding(
              repository, gitPath);
          right = new FileRevisionTypedElement(revision, encoding);
        } else
          right = CompareUtils.getFileRevisionTypedElement(gitPath,
              headCommit, repository);

        // can this really happen?
        if (right instanceof EmptyTypedElement)
          continue;

        IFileRevision rev;
        // if the file is not conflicting (as it was auto-merged)
        // we will show the auto-merged (local) version

        Path repositoryPath = new Path(repository.getWorkTree()
            .getAbsolutePath());
        IPath location = repositoryPath
            .append(fit.getEntryPathString());
        IFile file = ResourceUtil.getFileForLocation(location);
        if (!conflicting || useWorkspace) {
          if (file != null)
            rev = new LocalFileRevision(file);
          else
            rev = new WorkingTreeFileRevision(location.toFile());
        } else {
          rev = GitFileRevision.inIndex(repository, gitPath,
              DirCacheEntry.STAGE_2);
        }

        IRunnableContext runnableContext = getContainer();
        if (runnableContext == null)
          runnableContext = PlatformUI.getWorkbench().getProgressService();

        EditableRevision leftEditable;
        if (file != null)
          leftEditable = new ResourceEditableRevision(rev, file,
              runnableContext);
        else
          leftEditable = new LocationEditableRevision(rev, location,
              runnableContext);
        // make sure we don't need a round trip later
        try {
          leftEditable.cacheContents(monitor);
        } catch (CoreException e) {
          throw new IOException(e.getMessage());
        }

        int kind = Differencer.NO_CHANGE;
        if (conflicting)
          kind = Differencer.CONFLICTING;
        else if (modified)
          kind = Differencer.PSEUDO_CONFLICT;

        IDiffContainer fileParent = getFileParent(result,
            repositoryPath, file, location);

        ITypedElement anc;
        if (ancestorCommit != null)
          anc = CompareUtils.getFileRevisionTypedElement(gitPath,
              ancestorCommit, repository);
        else
          anc = null;
View Full Code Here

Examples of org.eclipse.compare.ITypedElement

        ac = (ITypedElement[]) ((IStructureComparator) actAncestor)
            .getChildren();
      int li=0;
      int ri=0;
      while (li<lc.length && ri<rc.length) {
        ITypedElement ln = lc[li];
        ITypedElement rn = rc[ri];
        ITypedElement an = null;
        if (ac != null)
          an = ac[ri];
        int compareTo = ln.getName().compareTo(rn.getName());
        // TODO: Git ordering!
        if (compareTo == 0) {
          if (!ln.equals(rn))
            diffNode.add(compare(ln,rn, an));
          ++li;
          ++ri;
        } else if (compareTo < 0) {
          DiffNode childDiffNode = new DiffNode(Differencer.ADDITION, an, ln, null);
          diffNode.add(childDiffNode);
          if (ln.getType().equals(ITypedElement.FOLDER_TYPE)) {
            ITypedElement[] children = (ITypedElement[])((IStructureComparator)ln).getChildren();
            if(children != null && children.length > 0) {
              for (ITypedElement child : children) {
                childDiffNode.add(addDirectoryFiles(child, Differencer.ADDITION));
              }
            }
          }
          ++li;
        } else {
          DiffNode childDiffNode = new DiffNode(Differencer.DELETION, an, null, rn);
          diffNode.add(childDiffNode);
          if (rn.getType().equals(ITypedElement.FOLDER_TYPE)) {
            ITypedElement[] children = (ITypedElement[])((IStructureComparator)rn).getChildren();
            if(children != null && children.length > 0) {
              for (ITypedElement child : children) {
                childDiffNode.add(addDirectoryFiles(child, Differencer.DELETION));
              }
            }
          }
          ++ri;
        }
      }
      while (li<lc.length) {
        ITypedElement ln = lc[li];
        ITypedElement an = null;
        if (ac != null)
          an= ac[li];
        DiffNode childDiffNode = new DiffNode(Differencer.ADDITION, an, ln, null);
        diffNode.add(childDiffNode);
        if (ln.getType().equals(ITypedElement.FOLDER_TYPE)) {
          ITypedElement[] children = (ITypedElement[])((IStructureComparator)ln).getChildren();
          if(children != null && children.length > 0) {
            for (ITypedElement child : children) {
              childDiffNode.add(addDirectoryFiles(child, Differencer.ADDITION));
            }
          }
        }
        ++li;
      }
      while (ri<rc.length) {
        ITypedElement rn = rc[ri];
        ITypedElement an = null;
        if (ac != null)
          an = ac[ri];
        DiffNode childDiffNode = new DiffNode(Differencer.DELETION, an, null, rn);
        diffNode.add(childDiffNode);
        if (rn.getType().equals(ITypedElement.FOLDER_TYPE)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.