-
Notifications
You must be signed in to change notification settings - Fork 4
[WIP]Move a ContingencyElement by using drag and drop in ContingencyStoreEditor #87
base: main
Are you sure you want to change the base?
Conversation
gse-afs-ext-base/src/main/java/com/powsybl/gse/afs/ext/base/ContingencyStoreEditor.java
Outdated
Show resolved
Hide resolved
return new BranchContingency(equipmentInfo.getIdAndName().getId()); | ||
|
||
default: | ||
return null; | ||
} | ||
} | ||
|
||
private EquipmentInfo createEquipmentInfo(ContingencyElement contingencyElement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be static
5335313
to
75f2870
Compare
setOnDragDropped(this::onDragDropped); | ||
} | ||
|
||
private TreeItem<Object> checkTreeItem() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find a better name for this method. If I understand well, it get the TreeItem corresponding the selected element or null, if nothing is selected.
Proposal: getContingencyTreeItem()
This code is duplicate in addContingencyElement. Refactor addContingencyElement to use your method.
private void onDragDropped(DragEvent event) { | ||
if (event.getTransferMode().equals(TransferMode.MOVE) && | ||
event.getGestureSource() instanceof ContingencyTreeCell) { | ||
remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If something goes wrong later, you can lost a Contingency item by removing it too early. I think you've to remove the item only if success = true
, at the end of this method.
private void onDragOver(DragEvent event) { | ||
Dragboard db = event.getDragboard(); | ||
if (!(event.getGestureSource() instanceof ContingencyTreeCell) || | ||
checkTreeItem() != ((ContingencyTreeCell) event.getGestureSource()).checkTreeItem()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly I think this code is quiet difficult to understand. In that case, feel free to put it in a dedicated method with an explicit name to hide complexity.
I think there is only one thing to check here, that can maybe be done in acceptSingleDraggedElement
& acceptMultipleDraggedElements
: test if the target node doesn't already contain one of the contingency element you're trying to drop.
[WIP] Waiting for #124 to be approved |
No description provided.