Ejemplo n.º 1
0
 public void updateTargetData() {
   if (myTarget != null && !myTarget.isContainer()) {
     myTargetLength = myTarget.getSize();
   } else {
     myTargetLength = -1;
   }
 }
Ejemplo n.º 2
0
 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;
   }
 }
Ejemplo n.º 3
0
 @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()]);
 }
Ejemplo n.º 4
0
    @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;
    }
Ejemplo n.º 5
0
    @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);
    }
Ejemplo n.º 6
0
 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());
 }
Ejemplo n.º 7
0
 public static DirDiffElement createChange(
     DTree parent, @NotNull DiffElement source, @NotNull DiffElement target) {
   return new DirDiffElement(parent, source, target, DType.CHANGED, source.getName());
 }
Ejemplo n.º 8
0
 private static String getLastModification(DiffElement file) {
   final long timeStamp = file.getTimeStamp();
   return timeStamp < 0 ? "" : DateFormatUtil.formatDateTime(timeStamp);
 }
Ejemplo n.º 9
0
 public Icon getIcon() {
   return mySource != null ? mySource.getIcon() : myTarget.getIcon();
 }
Ejemplo n.º 10
0
 @Nullable
 public String getTargetName() {
   return myType == DType.CHANGED || myType == DType.TARGET || myType == DType.EQUAL
       ? myTarget.getName()
       : myTarget == null ? null : myTarget.getName();
 }
Ejemplo n.º 11
0
 @Nullable
 public String getSourceName() {
   return myType == DType.CHANGED || myType == DType.SOURCE || myType == DType.EQUAL
       ? mySource.getName()
       : mySource == null ? null : mySource.getName();
 }
Ejemplo n.º 12
0
 public static DirDiffElement createEqual(
     DTree parent, @NotNull DiffElement source, @NotNull DiffElement target) {
   return new DirDiffElement(parent, source, target, DType.EQUAL, source.getName());
 }
Ejemplo n.º 13
0
 @Override
 public int hashCode() {
   int result = sourceElement != null ? sourceElement.hashCode() : 0;
   result = 31 * result + (targetElement != null ? targetElement.hashCode() : 0);
   return result;
 }