Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

[WIP]Move a ContingencyElement by using drag and drop in ContingencyStoreEditor #87

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

miovd
Copy link
Contributor

@miovd miovd commented Oct 24, 2018

No description provided.

@miovd miovd requested a review from mathbagu October 24, 2018 15:50
return new BranchContingency(equipmentInfo.getIdAndName().getId());

default:
return null;
}
}

private EquipmentInfo createEquipmentInfo(ContingencyElement contingencyElement) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be static

@miovd miovd changed the title Move a ContingencyElement by using drag and drop in ContingencyStoreEditor [WIP] Move a ContingencyElement by using drag and drop in ContingencyStoreEditor Oct 29, 2018
@miovd miovd force-pushed the move_contingencyelements branch 2 times, most recently from 5335313 to 75f2870 Compare November 7, 2018 10:02
@miovd miovd changed the title [WIP] Move a ContingencyElement by using drag and drop in ContingencyStoreEditor Move a ContingencyElement by using drag and drop in ContingencyStoreEditor Nov 7, 2018
setOnDragDropped(this::onDragDropped);
}

private TreeItem<Object> checkTreeItem() {
Copy link
Contributor

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();
Copy link
Contributor

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()) {
Copy link
Contributor

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.

@miovd miovd changed the title Move a ContingencyElement by using drag and drop in ContingencyStoreEditor [WIP] Move a ContingencyElement by using drag and drop in ContingencyStoreEditor Nov 9, 2018
@miovd miovd changed the title [WIP] Move a ContingencyElement by using drag and drop in ContingencyStoreEditor Move a ContingencyElement by using drag and drop in ContingencyStoreEditor Nov 12, 2018
@miovd miovd changed the title Move a ContingencyElement by using drag and drop in ContingencyStoreEditor [WIP] Move a ContingencyElement by using drag and drop in ContingencyStoreEditor Nov 14, 2018
@miovd
Copy link
Contributor Author

miovd commented Nov 14, 2018

[WIP] Waiting for #124 to be approved

@miovd miovd changed the title [WIP] Move a ContingencyElement by using drag and drop in ContingencyStoreEditor [WIP]Move a ContingencyElement by using drag and drop in ContingencyStoreEditor Apr 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants