Skip to content

Commit

Permalink
Make the contextMenu in StructurePanel und in GalleryPanel identical
Browse files Browse the repository at this point in the history
  • Loading branch information
IkramMaalej committed Mar 26, 2021
1 parent 2266082 commit 8fe372e
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ private void sortMetadataList(List<SelectItem> itemList) {
* Prepare popup dialog by retrieving available insertion positions and doc struct types for selected element.
*/
public void prepare() {
checkSelectedLogicalNode();
Optional<IncludedStructuralElement> selectedStructure = dataEditor.getSelectedStructure();
if (selectedStructure.isPresent()) {
this.parents = MetadataEditor.getAncestorsOfStructure(selectedStructure.get(),
Expand All @@ -418,6 +419,19 @@ public void prepare() {
prepareSelectPageOnAddNodeItems();
}

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();
if (Objects.nonNull(selectedLogicalNode) && selectedLogicalNode.getData() instanceof StructureTreeNode) {
StructureTreeNode structureTreeNode = (StructureTreeNode) selectedLogicalNode.getData();
if (structureTreeNode.getDataObject() instanceof View) {
if (Objects.nonNull(selectedLogicalNode.getParent())) {
dataEditor.getStructurePanel().setSelectedLogicalNode(selectedLogicalNode.getParent());
}
}
}
}

/**
* Update lists of available doc struct types that can be added to the currently selected structure element in the
* currently selected position.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ void setProcess(Process process) {
*
* @return value of selectedMedia
*/
List<Pair<MediaUnit, IncludedStructuralElement>> getSelectedMedia() {
public List<Pair<MediaUnit, IncludedStructuralElement>> getSelectedMedia() {
return selectedMedia;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@ public void assign() {
dataEditor.assignView(includedStructuralElement, viewToAssign, 0);
severalAssignments.add(viewToAssign.getMediaUnit());
show();
dataEditor.getSelectedMedia().clear();
dataEditor.getGalleryPanel().updateStripes();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
imagePreviewForm:mediaViewData
logicalTree
physicalTree
mediaContextMenu
metadataAccordion:logicalMetadataWrapperPanel"/>
<p:remoteCommand name="setGalleryViewMode"
action="#{DataEditorForm.galleryPanel.setGalleryViewMode}"
Expand Down Expand Up @@ -350,8 +351,34 @@
oncomplete="PF('dialogAddDocStrucType').show()"
update="dialogAddDocStrucTypeDialog">
<f:actionListener binding="#{DataEditorForm.addDocStrucTypeDialog.preparePreselectedViews()}"/>
<f:actionListener binding="#{DataEditorForm.structurePanel.setSelectedLogicalNode(DataEditorForm.structurePanel.logicalTree.children.get(DataEditorForm.structurePanel.logicalTree.childCount - 1))}"/>
</p:menuitem>
<p:menuitem value="#{msgs.assignToNextElement}"
icon="fa fa-link fa-sm"
styleClass="plain"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignableSeveralTimes and not
DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() eq 1}"
action="#{DataEditorForm.structurePanel.assign}"
process="@this"
oncomplete="$('#loadingScreen').hide()"
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.unassign}"
icon="fa fa-chain-broken fa-sm"
styleClass="plain"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() == 1}"
action="#{DataEditorForm.structurePanel.unassign}"
process="@this"
oncomplete="$('#loadingScreen').hide()"
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
</p:contextMenu>
<p:contextMenu id="stripeContextMenu"
widgetVar="stripeContextMenu"
Expand All @@ -364,6 +391,14 @@
actionListener="#{DataEditorForm.addDocStrucTypeDialog.resetValues}"
oncomplete="PF('dialogAddDocStrucType').show()"
update="dialogAddDocStrucTypeDialog"/>
<p:menuitem value="#{msgs.changeDocstructType}"
icon="fa fa-pencil fa-sm"
styleClass="plain"
disabled="#{readOnly}"
actionListener="#{DataEditorForm.changeDocStrucTypeDialog.prepare}"
process="@this"
oncomplete="PF('dialogEditDocStrucType').show()"
update="dialogEditDocStrucTypeDialog"/>
<p:menuitem value="#{msgs.removeElement}"
icon="fa fa-trash fa-sm"
styleClass="plain"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
Expand All @@ -36,6 +37,7 @@
imagePreviewForm:mediaViewData
contextMenuLogicalTree
physicalTree
imagePreviewForm:mediaContextMenu
metadataAccordion:logicalMetadataWrapperPanel"/>
<p:ajax event="contextMenu"
listener="#{DataEditorForm.structurePanel.treeLogicalSelect}"
Expand All @@ -53,7 +55,8 @@
update="logicalTree
contextMenuLogicalTree
metadataAccordion:logicalMetadataWrapperPanel
@(.pageList)"/>
@(.pageList)
imagePreviewForm:mediaContextMenu"/>
<p:ajax event="collapse"
listener="#{DataEditorForm.structurePanel.onNodeCollapse}"/>
<p:ajax event="expand"
Expand All @@ -72,15 +75,17 @@
</p:treeNode>
</p:tree>
<p:contextMenu for="logicalTree" id="contextMenuLogicalTree" widgetVar="contextMenuLogicalTree">
<p:menuitem value="#{msgs.addElement}"
<p:menuitem value="#{msgs.addElement} #{DataEditorForm.selectedMedia.size() ge 1 ? msgs.assignMedia : ''}"
icon="fa fa-plus fa-sm"
styleClass="plain"
disabled="#{readOnly}"
action="#{DataEditorForm.addDocStrucTypeDialog.prepare}"
actionListener="#{DataEditorForm.addDocStrucTypeDialog.resetValues}"
process="@this"
oncomplete="PF('dialogAddDocStrucType').show()"
update="dialogAddDocStrucTypeDialog"/>
update="dialogAddDocStrucTypeDialog">
<f:actionListener binding="#{DataEditorForm.addDocStrucTypeDialog.preparePreselectedViews()}"/>
</p:menuitem>
<p:menuitem value="#{msgs.changeDocstructType}"
rendered="#{DataEditorForm.structurePanel.selectedLogicalNode.data.dataObject['class'].simpleName ne 'View'}"
icon="fa fa-pencil fa-sm"
Expand All @@ -101,7 +106,8 @@
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)"/>
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.unassign}"
icon="fa fa-chain-broken fa-sm"
styleClass="plain"
Expand All @@ -113,7 +119,8 @@
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)"/>
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.removeElement}"
rendered="#{DataEditorForm.structurePanel.selectedLogicalNode.data.dataObject['class'].simpleName ne 'View'}"
icon="fa fa-trash fa-sm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,33 @@
actionListener="#{DataEditorForm.addMediaUnitDialog.prepare}"
oncomplete="PF('dialogAddMediaUnit').show()"
update="dialogAddMediaUnitForm"/>
<p:menuitem value="#{msgs.assignToNextElement}"
icon="fa fa-link fa-sm"
styleClass="plain"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignableSeveralTimes and not
DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() eq 1}"
action="#{DataEditorForm.structurePanel.assign}"
process="@this"
oncomplete="$('#loadingScreen').hide()"
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.unassign}"
icon="fa fa-chain-broken fa-sm"
styleClass="plain"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() == 1}"
action="#{DataEditorForm.structurePanel.unassign}"
process="@this"
oncomplete="$('#loadingScreen').hide()"
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.removeElement}"
rendered="#{DataEditorForm.structurePanel.selectedPhysicalNode.data.dataObject.type ne 'page'}"
icon="fa fa-trash fa-sm"
Expand Down

0 comments on commit 8fe372e

Please sign in to comment.