Skip to content

Commit

Permalink
'#39 Properly implements clone methods of DecisionNode subclasses, so
Browse files Browse the repository at this point in the history
they can be cloned when dragging with CTRL button pressed (COPY
operation).
  • Loading branch information
patrickdalla committed Jul 1, 2024
1 parent 76eebde commit 47f1a07
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,8 @@ public void invert() {
}

@Override
public DecisionNode clone() {
DecisionNode clone = new DecisionNode(model);
clone.parent = this.parent;
clone.inverted = this.inverted;
for (DecisionNode child : this.children) {
clone.children.add(child.clone());
}
return clone;
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ public String toString() {
return filter.toString();
}

@Override
public DecisionNode clone() {
FilterNode clone = new FilterNode(filter, model);
clone.parent = this.parent;
clone.inverted = this.inverted;
model.getFiltersToNodeMap().get(filter).add(this);
return clone;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,21 @@ public void addDecisionNode(DecisionNode dnode) {
public Operand getOperand() {
return operand;
}

@Override
public DecisionNode clone() {
OperandNode clone = new OperandNode(this.operand, model);
clone.parent = this.parent;
clone.inverted = this.inverted;
for (DecisionNode child : this.children) {
try {
DecisionNode dn = (DecisionNode) child.clone();
dn.parent = clone;
clone.children.add(dn);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
return clone;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public boolean importData(TransferSupport support) {
OperandNode operand = (OperandNode) data.getTransferData(operandNodeFlavor);
if (operand != null) {
if (support.getDropAction() == COPY) {
DecisionNode dn = (DecisionNode) clone(operand);
DecisionNode dn = (DecisionNode) operand.clone();
if (dn != null) {
dest.addDecisionNode(dn);
} else {
Expand Down

0 comments on commit 47f1a07

Please sign in to comment.