Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag & drop multiple tree nodes in structure tree #6340

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.kitodo.production.metadata.InsertionPosition.PARENT_OF_CURRENT_ELEMENT;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
Expand Down Expand Up @@ -181,10 +182,10 @@ private void addSingleDocStruc(boolean selectViews) {
}
}
dataEditor.refreshStructurePanel();
TreeNode selectedLogicalTreeNode = dataEditor.getStructurePanel().updateLogicalNodeSelectionRecursive(newStructure,
List<TreeNode> selectedLogicalTreeNodes = dataEditor.getStructurePanel().updateLogicalNodeSelectionRecursive(newStructure,
this.dataEditor.getStructurePanel().getLogicalTree());
if (Objects.nonNull(selectedLogicalTreeNode)) {
this.dataEditor.getStructurePanel().setSelectedLogicalNode(selectedLogicalTreeNode);
if (Objects.nonNull(selectedLogicalTreeNodes)) {
this.dataEditor.getStructurePanel().setSelectedLogicalNodes(selectedLogicalTreeNodes);
this.dataEditor.getMetadataPanel().showLogical(this.dataEditor.getSelectedStructure());
dataEditor.refreshStructurePanel();
}
Expand Down Expand Up @@ -435,13 +436,13 @@ public void prepare() {

private void checkSelectedLogicalNode() {
//If a view is selected in logical tree then the 'selectedLogicalNode' will be set to the parent of this view
TreeNode selectedLogicalNode = dataEditor.getStructurePanel().getSelectedLogicalNode();
TreeNode selectedLogicalNode = dataEditor.getStructurePanel().getSelectedLogicalNodeIfSingle();
if (Objects.nonNull(selectedLogicalNode) && selectedLogicalNode.getData() instanceof StructureTreeNode) {
StructureTreeNode structureTreeNode = (StructureTreeNode) selectedLogicalNode.getData();
if (structureTreeNode.getDataObject() instanceof View) {
if (Objects.nonNull(selectedLogicalNode.getParent())) {
previouslySelectedLogicalNode = selectedLogicalNode;
dataEditor.getStructurePanel().setSelectedLogicalNode(selectedLogicalNode.getParent());
dataEditor.getStructurePanel().setSelectedLogicalNodes(Arrays.asList(selectedLogicalNode.getParent()));
}
}
}
Expand Down Expand Up @@ -593,7 +594,7 @@ public void resetValues() {
selectFirstPageOnAddNode = null;
selectLastPageOnAddNode = null;
if (Objects.nonNull(previouslySelectedLogicalNode)) {
dataEditor.getStructurePanel().setSelectedLogicalNode(previouslySelectedLogicalNode);
dataEditor.getStructurePanel().setSelectedLogicalNodes(Arrays.asList(previouslySelectedLogicalNode));
previouslySelectedLogicalNode = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ private void init() {
structurePanel.getSeveralAssignments().addAll(severalAssignments);

structurePanel.show();
structurePanel.getSelectedLogicalNode().setSelected(true);
for (TreeNode node : structurePanel.getSelectedLogicalNodes()) {
node.setSelected(true);
}
structurePanel.getSelectedPhysicalNode().setSelected(true);
metadataPanel.showLogical(getSelectedStructure());
metadataPanel.showPhysical(getSelectedPhysicalDivision());
Expand Down Expand Up @@ -647,7 +649,7 @@ public void deleteStructure() {
* clicked on the context menu entry to delete the physical division.
*/
public void deletePhysicalDivision() {
structurePanel.deleteSelectedPhysicalDivision();
structurePanel.deleteSelectedPhysicalDivisions();
updateNumberOfScans();
}

Expand Down Expand Up @@ -1330,7 +1332,7 @@ public String getMetadataFileLoadingError() {
*/
public boolean canUpdateMetadata() {
try {
return DataEditorService.canUpdateCatalogMetadata(process, workpiece, structurePanel.getSelectedLogicalNode());
return DataEditorService.canUpdateCatalogMetadata(process, workpiece, structurePanel.getSelectedLogicalNodeIfSingle());
} catch (IOException e) {
Helper.setErrorMessage(e.getLocalizedMessage(), logger, e);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,14 @@ public void startPaginationClick() {
private void updateMetadataPanel() {
if (dataEditor.getSelectedStructure().isPresent()) {
dataEditor.getMetadataPanel().showLogical(dataEditor.getSelectedStructure());
} else if (Objects.nonNull(dataEditor.getStructurePanel().getSelectedLogicalNode())
&& dataEditor.getStructurePanel().getSelectedLogicalNode().getData() instanceof StructureTreeNode
} /* else if (Objects.nonNull(dataEditor.getStructurePanel().getSelectedLogicalNodes())
&& dataEditor.getStructurePanel().getSelectedLogicalNodes().getData() instanceof StructureTreeNode
&& Objects.nonNull(dataEditor.getStructurePanel().getSelectedLogicalNode().getData())
&& ((StructureTreeNode) dataEditor.getStructurePanel().getSelectedLogicalNode().getData())
.getDataObject() instanceof View) {
View view = (View) ((StructureTreeNode) dataEditor.getStructurePanel().getSelectedLogicalNode().getData()).getDataObject();
dataEditor.getMetadataPanel().showPageInLogical(view.getPhysicalDivision());
}
}*/
}

/**
Expand Down
Loading
Loading