public void updateTargetData() {
   if (myTarget != null && !myTarget.isContainer()) {
     myTargetLength = myTarget.getSize();
   } else {
     myTargetLength = -1;
   }
 }
 private DirDiffElement(
     DTree parent,
     @Nullable DiffElement source,
     @Nullable DiffElement target,
     DType type,
     String name) {
   myParent = parent.getParent();
   myNode = parent;
   myType = type;
   mySource = source;
   mySourceLength = source == null || source.isContainer() ? -1 : source.getSize();
   myTarget = target;
   myTargetLength = target == null || target.isContainer() ? -1 : target.getSize();
   myName = name;
   if (type == DType.ERROR) {
     myDefaultOperation = NONE;
   } else if (isSource()) {
     myDefaultOperation = COPY_TO;
   } else if (isTarget()) {
     myDefaultOperation = COPY_FROM;
   } else if (type == DType.EQUAL) {
     myDefaultOperation = EQUAL;
   } else if (type == DType.CHANGED) {
     assert source != null;
     myDefaultOperation = MERGE;
   }
 }
 @Nullable
 private Navigatable[] getNavigatableArray() {
   Project project = myModel.getProject();
   List<DirDiffElementImpl> elements = myModel.getSelectedElements();
   List<Navigatable> navigatables = new ArrayList<>();
   for (DirDiffElementImpl element : elements) {
     DiffElement source = element.getSource();
     DiffElement target = element.getTarget();
     Navigatable navigatable1 = source != null ? source.getNavigatable(project) : null;
     Navigatable navigatable2 = target != null ? target.getNavigatable(project) : null;
     if (navigatable1 != null) navigatables.add(navigatable1);
     if (navigatable2 != null) navigatables.add(navigatable2);
   }
   return ContainerUtil.toArray(navigatables, new Navigatable[navigatables.size()]);
 }
    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;

      ElementWrapper wrapper = (ElementWrapper) o;

      if (sourceElement != null
          ? !sourceElement.equals(wrapper.sourceElement)
          : wrapper.sourceElement != null) return false;
      if (targetElement != null
          ? !targetElement.equals(wrapper.targetElement)
          : wrapper.targetElement != null) return false;

      return true;
    }
    @NotNull
    @Override
    protected DiffRequest loadRequest(
        @NotNull ElementWrapper element, @NotNull ProgressIndicator indicator)
        throws ProcessCanceledException, DiffRequestProducerException {
      final Project project = myModel.getProject();
      DiffElement sourceElement = element.sourceElement;
      DiffElement targetElement = element.targetElement;

      DiffContent sourceContent =
          sourceElement != null
              ? sourceElement.createDiffContent(project, indicator)
              : DiffContentFactory.getInstance().createEmpty();
      DiffContent targetContent =
          targetElement != null
              ? targetElement.createDiffContent(project, indicator)
              : DiffContentFactory.getInstance().createEmpty();

      return new SimpleDiffRequest(null, sourceContent, targetContent, null, null);
    }
 public static DirDiffElement createError(
     DTree parent, @Nullable DiffElement source, @Nullable DiffElement target) {
   return new DirDiffElement(
       parent, source, target, DType.ERROR, source == null ? target.getName() : source.getName());
 }
 public static DirDiffElement createChange(
     DTree parent, @NotNull DiffElement source, @NotNull DiffElement target) {
   return new DirDiffElement(parent, source, target, DType.CHANGED, source.getName());
 }
 private static String getLastModification(DiffElement file) {
   final long timeStamp = file.getTimeStamp();
   return timeStamp < 0 ? "" : DateFormatUtil.formatDateTime(timeStamp);
 }
 public Icon getIcon() {
   return mySource != null ? mySource.getIcon() : myTarget.getIcon();
 }
 @Nullable
 public String getTargetName() {
   return myType == DType.CHANGED || myType == DType.TARGET || myType == DType.EQUAL
       ? myTarget.getName()
       : myTarget == null ? null : myTarget.getName();
 }
 @Nullable
 public String getSourceName() {
   return myType == DType.CHANGED || myType == DType.SOURCE || myType == DType.EQUAL
       ? mySource.getName()
       : mySource == null ? null : mySource.getName();
 }
 public static DirDiffElement createEqual(
     DTree parent, @NotNull DiffElement source, @NotNull DiffElement target) {
   return new DirDiffElement(parent, source, target, DType.EQUAL, source.getName());
 }
Esempio n. 13
0
 @Override
 public int hashCode() {
   int result = sourceElement != null ? sourceElement.hashCode() : 0;
   result = 31 * result + (targetElement != null ? targetElement.hashCode() : 0);
   return result;
 }