CCM NG/ccm-cms: Moving attached images works now
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4901 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
ab697c06ac
commit
075e94e0ee
|
|
@ -33,18 +33,18 @@ import org.librecms.contentsection.ItemAttachmentManager;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
public class ItemAttachmentSelectionModel implements SingleSelectionModel<Long>{
|
public class ItemAttachmentSelectionModel implements SingleSelectionModel<Long> {
|
||||||
|
|
||||||
private final SingleSelectionModel<Long> model;
|
private final SingleSelectionModel<Long> model;
|
||||||
|
|
||||||
public ItemAttachmentSelectionModel(final LongParameter parameter) {
|
public ItemAttachmentSelectionModel(final LongParameter parameter) {
|
||||||
this.model = new ParameterSingleSelectionModel<>(parameter);
|
this.model = new ParameterSingleSelectionModel<>(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemAttachmentSelectionModel(final String parameterName) {
|
public ItemAttachmentSelectionModel(final String parameterName) {
|
||||||
this(new LongParameter(parameterName));
|
this(new LongParameter(parameterName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSelected(final PageState state) {
|
public boolean isSelected(final PageState state) {
|
||||||
return model.isSelected(state);
|
return model.isSelected(state);
|
||||||
|
|
@ -71,12 +71,16 @@ public class ItemAttachmentSelectionModel implements SingleSelectionModel<Long>{
|
||||||
|
|
||||||
public ItemAttachment<?> getSelectedAttachment(final PageState state) {
|
public ItemAttachment<?> getSelectedAttachment(final PageState state) {
|
||||||
final Long key = getSelectedKey(state);
|
final Long key = getSelectedKey(state);
|
||||||
final ItemAttachmentManager manager = CdiUtil
|
if (key == null) {
|
||||||
.createCdiUtil()
|
return null;
|
||||||
.findBean(ItemAttachmentManager.class);
|
} else {
|
||||||
return manager.findById(key).get();
|
final ItemAttachmentManager manager = CdiUtil
|
||||||
|
.createCdiUtil()
|
||||||
|
.findBean(ItemAttachmentManager.class);
|
||||||
|
return manager.findById(key).get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearSelection(final PageState state) {
|
public void clearSelection(final PageState state) {
|
||||||
model.clearSelection(state);
|
model.clearSelection(state);
|
||||||
|
|
@ -96,5 +100,5 @@ public class ItemAttachmentSelectionModel implements SingleSelectionModel<Long>{
|
||||||
public ParameterModel getStateParameter() {
|
public ParameterModel getStateParameter() {
|
||||||
return model.getStateParameter();
|
return model.getStateParameter();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,11 +133,12 @@ class AssignedImagesTable extends Table {
|
||||||
switch (column.getModelIndex()) {
|
switch (column.getModelIndex()) {
|
||||||
case COL_MOVE:
|
case COL_MOVE:
|
||||||
if (moveAttachmentModel
|
if (moveAttachmentModel
|
||||||
.getSelectedAttachment(state) == null) {
|
.getSelectedKey(state) == null) {
|
||||||
|
|
||||||
moveAttachmentModel
|
moveAttachmentModel
|
||||||
.setSelectedKey(state,
|
.setSelectedKey(state,
|
||||||
Long.parseLong(column.getKey()));
|
Long.parseLong((String) event
|
||||||
|
.getRowKey()));
|
||||||
} else {
|
} else {
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final ImageStepController controller = cdiUtil
|
final ImageStepController controller = cdiUtil
|
||||||
|
|
@ -151,6 +152,7 @@ class AssignedImagesTable extends Table {
|
||||||
.parseLong((String) event.getRowKey());
|
.parseLong((String) event.getRowKey());
|
||||||
|
|
||||||
controller.moveAfter(selectedAttachment, destId);
|
controller.moveAfter(selectedAttachment, destId);
|
||||||
|
moveAttachmentModel.setSelectedKey(state, null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COL_REMOVE:
|
case COL_REMOVE:
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,8 @@ public class ImageStep extends ResettableContainer {
|
||||||
.findBean(ImageStepController.class);
|
.findBean(ImageStepController.class);
|
||||||
|
|
||||||
controller.moveToFirst(toMove);
|
controller.moveToFirst(toMove);
|
||||||
|
|
||||||
|
moveAttachmentModel.setSelectedKey(state, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
assignedImagesTable = new AssignedImagesTable(itemSelectionModel,
|
assignedImagesTable = new AssignedImagesTable(itemSelectionModel,
|
||||||
|
|
@ -197,6 +199,8 @@ public class ImageStep extends ResettableContainer {
|
||||||
page.setVisibleDefault(addImageHeader, false);
|
page.setVisibleDefault(addImageHeader, false);
|
||||||
page.setVisibleDefault(cancelAddImage, false);
|
page.setVisibleDefault(cancelAddImage, false);
|
||||||
page.setVisibleDefault(availableImages, false);
|
page.setVisibleDefault(availableImages, false);
|
||||||
|
|
||||||
|
page.addComponentStateParam(assignedImagesTable, moveAttachmentParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showAssignedImages(final PageState state) {
|
protected void showAssignedImages(final PageState state) {
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ public class ItemAttachmentManager {
|
||||||
@Inject
|
@Inject
|
||||||
private AssetManager assetManager;
|
private AssetManager assetManager;
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public Optional<ItemAttachment<?>> findById(final long attachmentId) {
|
public Optional<ItemAttachment<?>> findById(final long attachmentId) {
|
||||||
|
|
||||||
final TypedQuery<ItemAttachment> query = entityManager
|
final TypedQuery<ItemAttachment> query = entityManager
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue