Removed deprecated package com/arsdigita/cms/ui/authoring/assets/relatedinfo from ccm-cms
parent
7ce68f3cd7
commit
fbb07d9501
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class AttachmentListTableRow {
|
|
||||||
|
|
||||||
private long listId;
|
|
||||||
private String name;
|
|
||||||
private String title;
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
public long getListId() {
|
|
||||||
return listId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setListId(final long listId) {
|
|
||||||
this.listId = listId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(final String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(final String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import org.librecms.contentsection.Asset;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class AttachmentTableRow {
|
|
||||||
|
|
||||||
private long attachmentId;
|
|
||||||
private String title;
|
|
||||||
private Class<? extends Asset> type;
|
|
||||||
|
|
||||||
public long getAttachmentId() {
|
|
||||||
return attachmentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttachmentId(final long attachmentId) {
|
|
||||||
this.attachmentId = attachmentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(final String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<? extends Asset> getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(final Class<? extends Asset> type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,203 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
import org.librecms.contentsection.ItemAttachment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class AttachmentsTable extends Table {
|
|
||||||
|
|
||||||
protected static final int COL_TITLE = 0;
|
|
||||||
protected static final int COL_TYPE = 1;
|
|
||||||
protected static final int COL_MOVE = 2;
|
|
||||||
protected static final int COL_REMOVE = 3;
|
|
||||||
|
|
||||||
private final RelatedInfoStep relatedInfoStep;
|
|
||||||
private final ItemSelectionModel itemSelectionModel;
|
|
||||||
private final AttachmentListSelectionModel attachmentListSelectionModel;
|
|
||||||
private final AttachmentSelectionModel selectedAttachmentModel;
|
|
||||||
private final AttachmentSelectionModel moveAttachmentModel;
|
|
||||||
private final StringParameter selectedLanguageParam;
|
|
||||||
|
|
||||||
public AttachmentsTable(
|
|
||||||
final RelatedInfoStep relatedInfoStep,
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AttachmentListSelectionModel attachmentListSelectionModel,
|
|
||||||
final AttachmentSelectionModel selectedAttachmentModel,
|
|
||||||
final AttachmentSelectionModel moveAttachmentModel,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.relatedInfoStep = relatedInfoStep;
|
|
||||||
this.itemSelectionModel = itemSelectionModel;
|
|
||||||
this.attachmentListSelectionModel = attachmentListSelectionModel;
|
|
||||||
this.selectedAttachmentModel = selectedAttachmentModel;
|
|
||||||
this.moveAttachmentModel = moveAttachmentModel;
|
|
||||||
this.selectedLanguageParam = selectedLanguageParam;
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = super.getColumnModel();
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_TITLE,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment.title",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_TYPE,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment.type",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_MOVE,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment.move",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_REMOVE,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment.remove",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
|
|
||||||
super
|
|
||||||
.setModelBuilder(new AttachmentsTableModelBuilder(
|
|
||||||
itemSelectionModel,
|
|
||||||
attachmentListSelectionModel,
|
|
||||||
moveAttachmentModel,
|
|
||||||
selectedLanguageParam));
|
|
||||||
|
|
||||||
super
|
|
||||||
.getColumn(COL_MOVE)
|
|
||||||
.setCellRenderer(new ControlLinkCellRenderer());
|
|
||||||
super
|
|
||||||
.getColumn(COL_REMOVE)
|
|
||||||
.setCellRenderer(new ControlLinkCellRenderer());
|
|
||||||
|
|
||||||
setEmptyView(new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment.none",
|
|
||||||
CmsConstants.CMS_BUNDLE)));
|
|
||||||
|
|
||||||
super
|
|
||||||
.addTableActionListener(new TableActionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel()
|
|
||||||
.get(event.getColumn());
|
|
||||||
|
|
||||||
switch (column.getModelIndex()) {
|
|
||||||
case COL_MOVE: {
|
|
||||||
if (moveAttachmentModel
|
|
||||||
.getSelectedKey(state) == null) {
|
|
||||||
moveAttachmentModel
|
|
||||||
.setSelectedKey(state,
|
|
||||||
Long.parseLong(
|
|
||||||
(String) event
|
|
||||||
.getRowKey()));
|
|
||||||
} else {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final RelatedInfoStepController controller
|
|
||||||
= cdiUtil
|
|
||||||
.findBean(
|
|
||||||
RelatedInfoStepController.class);
|
|
||||||
|
|
||||||
final ItemAttachment<?> attachment
|
|
||||||
= moveAttachmentModel
|
|
||||||
.getSelectedAttachment(state);
|
|
||||||
|
|
||||||
final Long destId = Long.parseLong(
|
|
||||||
(String) event.getRowKey());
|
|
||||||
|
|
||||||
controller.moveAfter(
|
|
||||||
attachmentListSelectionModel
|
|
||||||
.getSelectedAttachmentList(state),
|
|
||||||
attachment,
|
|
||||||
destId);
|
|
||||||
moveAttachmentModel.clearSelection(state);
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COL_REMOVE: {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final RelatedInfoStepController controller = cdiUtil
|
|
||||||
.findBean(RelatedInfoStepController.class);
|
|
||||||
controller.removeAttachment(Long.parseLong(
|
|
||||||
(String) event.getRowKey()));
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException(String
|
|
||||||
.format("Illegal column index: %d",
|
|
||||||
column.getModelIndex()));
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
//Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ControlLinkCellRenderer implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column) {
|
|
||||||
|
|
||||||
return new ControlLink((Component) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
import org.librecms.assets.AssetTypeInfo;
|
|
||||||
import org.librecms.assets.AssetTypesManager;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.MissingResourceException;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class AttachmentsTableModel implements TableModel {
|
|
||||||
|
|
||||||
private final PageState state;
|
|
||||||
private final AttachmentSelectionModel moveAttachmentModel;
|
|
||||||
|
|
||||||
private final Iterator<AttachmentTableRow> iterator;
|
|
||||||
private AttachmentTableRow currentRow;
|
|
||||||
|
|
||||||
AttachmentsTableModel(
|
|
||||||
final List<AttachmentTableRow> rows,
|
|
||||||
final PageState state,
|
|
||||||
final AttachmentSelectionModel moveAttachmentModel) {
|
|
||||||
|
|
||||||
this.state = state;
|
|
||||||
this.moveAttachmentModel = moveAttachmentModel;
|
|
||||||
this.iterator = rows.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
if (iterator.hasNext()) {
|
|
||||||
currentRow = iterator.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
|
|
||||||
switch (columnIndex) {
|
|
||||||
case AttachmentsTable.COL_TITLE:
|
|
||||||
return currentRow.getTitle();
|
|
||||||
case AttachmentsTable.COL_TYPE: {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final AssetTypesManager typesManager = cdiUtil
|
|
||||||
.findBean(AssetTypesManager.class);
|
|
||||||
final AssetTypeInfo typeInfo = typesManager
|
|
||||||
.getAssetTypeInfo(currentRow.getType());
|
|
||||||
try {
|
|
||||||
final ResourceBundle bundle = ResourceBundle
|
|
||||||
.getBundle(typeInfo.getLabelBundle());
|
|
||||||
return bundle.getString(typeInfo.getLabelKey());
|
|
||||||
} catch (MissingResourceException ex) {
|
|
||||||
return typeInfo.getAssetClass().getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case AttachmentsTable.COL_MOVE:
|
|
||||||
if (moveAttachmentModel.getSelectedAttachment(state) == null) {
|
|
||||||
return new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment.move",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
} else {
|
|
||||||
return new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment.move_here",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
}
|
|
||||||
case AttachmentsTable.COL_REMOVE:
|
|
||||||
return new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment.remove",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException(String.format(
|
|
||||||
"Illegal column index %d.", columnIndex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return currentRow.getAttachmentId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentSelectionModel;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.contentsection.AttachmentList;
|
|
||||||
import org.librecms.contentsection.ContentItem;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class AttachmentsTableModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemSelectionModel;
|
|
||||||
private final AttachmentListSelectionModel listSelectionModel;
|
|
||||||
private final AttachmentSelectionModel moveAttachmentModel;
|
|
||||||
private final StringParameter selectedLanguageParam;
|
|
||||||
|
|
||||||
public AttachmentsTableModelBuilder(
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AttachmentListSelectionModel listSelectionModel,
|
|
||||||
final AttachmentSelectionModel moveAttachmentModel,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.itemSelectionModel = itemSelectionModel;
|
|
||||||
this.listSelectionModel = listSelectionModel;
|
|
||||||
this.moveAttachmentModel = moveAttachmentModel;
|
|
||||||
this.selectedLanguageParam = selectedLanguageParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
|
|
||||||
final ContentItem selectedItem = itemSelectionModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final AttachmentList list = listSelectionModel.getSelectedAttachmentList(state);
|
|
||||||
final String selectedLanguage = (String) state
|
|
||||||
.getValue(selectedLanguageParam);
|
|
||||||
final Locale selectedLocale = new Locale(selectedLanguage);
|
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final RelatedInfoStepController controller = cdiUtil
|
|
||||||
.findBean(RelatedInfoStepController.class);
|
|
||||||
|
|
||||||
final List<AttachmentTableRow> rows = controller
|
|
||||||
.retrieveAttachments(selectedItem, list, selectedLocale);
|
|
||||||
|
|
||||||
return new AttachmentsTableModel(rows, state, moveAttachmentModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,133 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Form;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.SaveCancelSection;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.assets.ItemSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class InternalLinkAddForm
|
|
||||||
extends Form
|
|
||||||
implements FormInitListener,
|
|
||||||
FormProcessListener,
|
|
||||||
FormSubmissionListener {
|
|
||||||
|
|
||||||
private final RelatedInfoStep relatedInfoStep;
|
|
||||||
private final ItemSelectionModel itemSelectionModel;
|
|
||||||
private final AttachmentListSelectionModel listSelectionModel;
|
|
||||||
private final StringParameter selectedLanguageParam;
|
|
||||||
|
|
||||||
private final TextField titleField;
|
|
||||||
// private final TextArea descriptionArea;
|
|
||||||
private final ItemSearchWidget itemSearchWidget;
|
|
||||||
private final SaveCancelSection saveCancelSection;
|
|
||||||
|
|
||||||
public InternalLinkAddForm(
|
|
||||||
final RelatedInfoStep relatedInfoStep,
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AttachmentListSelectionModel listSelectionModel,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
|
|
||||||
super("relatedinfo-attach-internallink-form");
|
|
||||||
|
|
||||||
this.relatedInfoStep = relatedInfoStep;
|
|
||||||
this.itemSelectionModel = itemSelectionModel;
|
|
||||||
this.listSelectionModel = listSelectionModel;
|
|
||||||
this.selectedLanguageParam = selectedLanguageParam;
|
|
||||||
|
|
||||||
final Label titleLabel = new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.internal_link.title",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
titleField = new TextField("link-title");
|
|
||||||
|
|
||||||
// descriptionArea = new TextArea("link-description");
|
|
||||||
final Label itemSearchLabel = new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.internal_link.target_item",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
itemSearchWidget = new ItemSearchWidget("link-item-search");
|
|
||||||
|
|
||||||
saveCancelSection = new SaveCancelSection();
|
|
||||||
|
|
||||||
super.add(titleLabel);
|
|
||||||
super.add(titleField);
|
|
||||||
super.add(itemSearchLabel);
|
|
||||||
super.add(itemSearchWidget);
|
|
||||||
super.add(saveCancelSection);
|
|
||||||
|
|
||||||
super.addProcessListener(this);
|
|
||||||
super.addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event) throws
|
|
||||||
FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
if (saveCancelSection.getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final RelatedInfoStepController controller = cdiUtil
|
|
||||||
.findBean(RelatedInfoStepController.class);
|
|
||||||
|
|
||||||
controller.createInternalLink(
|
|
||||||
listSelectionModel.getSelectedAttachmentList(state),
|
|
||||||
(Long) itemSearchWidget.getValue(state),
|
|
||||||
(String) titleField.getValue(state),
|
|
||||||
(String) state.getValue(selectedLanguageParam));
|
|
||||||
|
|
||||||
relatedInfoStep.showAttachmentsTable(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void submitted(final FormSectionEvent event) throws
|
|
||||||
FormProcessException {
|
|
||||||
|
|
||||||
if (saveCancelSection.getCancelButton().isSelected(event.getPageState())) {
|
|
||||||
relatedInfoStep.showAttachmentsTable(event.getPageState());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,148 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Form;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.SaveCancelSection;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.assets.AssetSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.core.UnexpectedErrorException;
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
import org.librecms.contentsection.AttachmentList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class RelatedInfoAttachAssetForm
|
|
||||||
extends Form
|
|
||||||
implements FormInitListener,
|
|
||||||
FormProcessListener,
|
|
||||||
FormSubmissionListener {
|
|
||||||
|
|
||||||
private final RelatedInfoStep relatedInfoStep;
|
|
||||||
private final ItemSelectionModel itemSelectionModel;
|
|
||||||
private final AttachmentListSelectionModel listSelectionModel;
|
|
||||||
private final StringParameter selectedLanguageParameter;
|
|
||||||
|
|
||||||
private final AssetSearchWidget searchWidget;
|
|
||||||
private final SaveCancelSection saveCancelSection;
|
|
||||||
|
|
||||||
public RelatedInfoAttachAssetForm(
|
|
||||||
final RelatedInfoStep relatedInfoStep,
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AttachmentListSelectionModel listSelectionModel,
|
|
||||||
final StringParameter selectedLangugeParam) {
|
|
||||||
|
|
||||||
super("relatedinfo-attach-asset-form");
|
|
||||||
|
|
||||||
this.relatedInfoStep = relatedInfoStep;
|
|
||||||
this.itemSelectionModel = itemSelectionModel;
|
|
||||||
this.listSelectionModel = listSelectionModel;
|
|
||||||
this.selectedLanguageParameter = selectedLangugeParam;
|
|
||||||
|
|
||||||
final Label label = new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attach_asset.selected_asset",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
super.add(label);
|
|
||||||
searchWidget = new AssetSearchWidget("asset-search-widget");
|
|
||||||
super.add(searchWidget);
|
|
||||||
saveCancelSection = new SaveCancelSection();
|
|
||||||
super.add(saveCancelSection);
|
|
||||||
|
|
||||||
super.addInitListener(this);
|
|
||||||
super.addProcessListener(this);
|
|
||||||
super.addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void register(final Page page) {
|
|
||||||
// super.register(page);
|
|
||||||
//
|
|
||||||
// page.addComponentStateParam(this, itemSelectionModel.getStateParameter());
|
|
||||||
// page.addComponentStateParam(this, listSelectionModel.getStateParameter());
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
if (listSelectionModel.getSelectedKey(event.getPageState()) == null) {
|
|
||||||
throw new UnexpectedErrorException("The selected list null. "
|
|
||||||
+ "This should not happen.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event) throws
|
|
||||||
FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
if (listSelectionModel.getSelectedKey(state) == null) {
|
|
||||||
throw new UnexpectedErrorException("The selected list null. "
|
|
||||||
+ "This should not happen.");
|
|
||||||
}
|
|
||||||
|
|
||||||
final Object value = searchWidget.getValue(state);
|
|
||||||
if (value != null) {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
// final ItemAttachmentManager attachmentManager = cdiUtil
|
|
||||||
// .findBean(ItemAttachmentManager.class);
|
|
||||||
// final AssetRepository assetRepo = cdiUtil
|
|
||||||
// .findBean(AssetRepository.class);
|
|
||||||
// final Asset asset = assetRepo
|
|
||||||
// .findById((long) value)
|
|
||||||
// .orElseThrow(() -> new UnexpectedErrorException(String
|
|
||||||
// .format("No Asset with ID %d in the database.", value)));
|
|
||||||
|
|
||||||
final AttachmentList list = listSelectionModel
|
|
||||||
.getSelectedAttachmentList(state);
|
|
||||||
|
|
||||||
// attachmentManager.attachAsset(asset, list);
|
|
||||||
final RelatedInfoStepController controller = cdiUtil
|
|
||||||
.findBean(RelatedInfoStepController.class);
|
|
||||||
controller.attachAsset(list, (long) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
relatedInfoStep.showAttachmentsTable(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void submitted(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
if (saveCancelSection.getCancelButton().isSelected(state)) {
|
|
||||||
relatedInfoStep.showAttachmentsTable(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,405 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.BoxPanel;
|
|
||||||
import com.arsdigita.bebop.Form;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.SaveCancelSection;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
|
||||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
|
||||||
import com.arsdigita.bebop.event.ParameterEvent;
|
|
||||||
import com.arsdigita.bebop.form.Option;
|
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
|
||||||
import com.arsdigita.bebop.form.Submit;
|
|
||||||
import com.arsdigita.bebop.form.TextArea;
|
|
||||||
import com.arsdigita.bebop.form.TextField;
|
|
||||||
import com.arsdigita.bebop.parameters.GlobalizedParameterListener;
|
|
||||||
import com.arsdigita.bebop.parameters.ParameterData;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
import com.arsdigita.kernel.KernelConfig;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.libreccm.core.UnexpectedErrorException;
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
import org.librecms.contentsection.AttachmentList;
|
|
||||||
import org.librecms.contentsection.AttachmentListL10NManager;
|
|
||||||
import org.librecms.contentsection.AttachmentListManager;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.TooManyListenersException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class RelatedInfoListForm
|
|
||||||
extends Form
|
|
||||||
implements FormInitListener,
|
|
||||||
FormProcessListener,
|
|
||||||
FormSubmissionListener {
|
|
||||||
|
|
||||||
private final RelatedInfoStep relatedInfoStep;
|
|
||||||
private final ItemSelectionModel itemSelectionModel;
|
|
||||||
private final AttachmentListSelectionModel listSelectionModel;
|
|
||||||
private final StringParameter selectedLanguage;
|
|
||||||
|
|
||||||
private BoxPanel showLocalePanel;
|
|
||||||
private SingleSelect showLocaleSelect;
|
|
||||||
private Submit showLocaleSubmit;
|
|
||||||
|
|
||||||
private BoxPanel addLocalePanel;
|
|
||||||
private SingleSelect addLocaleSelect;
|
|
||||||
private Submit addLocaleSubmit;
|
|
||||||
|
|
||||||
private TextField nameField;
|
|
||||||
private TextField titleField;
|
|
||||||
private TextArea descriptionArea;
|
|
||||||
|
|
||||||
private SaveCancelSection saveCancelSection;
|
|
||||||
|
|
||||||
public RelatedInfoListForm(
|
|
||||||
final RelatedInfoStep relatedInfoStep,
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AttachmentListSelectionModel listSelectionModel,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
|
|
||||||
super("relatedinfo-list-form", new BoxPanel(BoxPanel.VERTICAL));
|
|
||||||
|
|
||||||
this.relatedInfoStep = relatedInfoStep;
|
|
||||||
this.itemSelectionModel = itemSelectionModel;
|
|
||||||
this.listSelectionModel = listSelectionModel;
|
|
||||||
this.selectedLanguage = selectedLanguageParam;
|
|
||||||
|
|
||||||
showLocalePanel = new BoxPanel(BoxPanel.HORIZONTAL);
|
|
||||||
final Label showLocaleLabel = new Label(event -> {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final Optional<AttachmentList> selectedList = getSelectedList(state);
|
|
||||||
final Label target = (Label) event.getTarget();
|
|
||||||
if (selectedList.isPresent()) {
|
|
||||||
target.setLabel(new GlobalizedMessage(
|
|
||||||
"cms.ui.assetlist.show_locale",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
} else {
|
|
||||||
target.setLabel(new GlobalizedMessage(
|
|
||||||
"cms.ui.assetlist.initial_locale",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
showLocaleSelect = new SingleSelect("selected-locale");
|
|
||||||
try {
|
|
||||||
showLocaleSelect.addPrintListener(event -> {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final Optional<AttachmentList> selectedList = getSelectedList(
|
|
||||||
state);
|
|
||||||
if (selectedList.isPresent()) {
|
|
||||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
|
||||||
|
|
||||||
target.clearOptions();;
|
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final AttachmentListL10NManager l10NManager = cdiUtil
|
|
||||||
.findBean(AttachmentListL10NManager.class);
|
|
||||||
final List<Locale> availableLocales = new ArrayList<>(
|
|
||||||
l10NManager.availableLocales(selectedList.get()));
|
|
||||||
availableLocales.sort((locale1, locale2) -> {
|
|
||||||
return locale1.toString().compareTo(locale2.toString());
|
|
||||||
});
|
|
||||||
availableLocales.forEach(locale -> target.addOption(
|
|
||||||
new Option(locale.toString(),
|
|
||||||
new Text(locale.toString()))));
|
|
||||||
} else {
|
|
||||||
final SingleSelect target = (SingleSelect) event
|
|
||||||
.getTarget();
|
|
||||||
|
|
||||||
target.clearOptions();
|
|
||||||
|
|
||||||
final List<String> langs = new ArrayList<>(
|
|
||||||
KernelConfig.getConfig().getSupportedLanguages());
|
|
||||||
langs.sort((lang1, lang2) -> lang1.compareTo(lang2));
|
|
||||||
|
|
||||||
langs.forEach(lang -> {
|
|
||||||
target.addOption(new Option(lang, new Text(lang)));
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
} catch (TooManyListenersException ex) {
|
|
||||||
throw new UnexpectedErrorException(ex);
|
|
||||||
}
|
|
||||||
showLocaleSubmit = new Submit(new GlobalizedMessage(
|
|
||||||
"cms.ui.assetlist.show_locale",
|
|
||||||
CmsConstants.CMS_BUNDLE)) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVisible(final PageState state) {
|
|
||||||
return getSelectedList(state).isPresent();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
showLocalePanel.add(showLocaleLabel);
|
|
||||||
showLocalePanel.add(showLocaleSelect);
|
|
||||||
showLocalePanel.add(showLocaleSubmit);
|
|
||||||
super.add(showLocalePanel);
|
|
||||||
|
|
||||||
addLocalePanel = new BoxPanel(BoxPanel.HORIZONTAL) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVisible(final PageState state) {
|
|
||||||
return getSelectedList(state).isPresent();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
final Label addLocaleLabel = new Label(
|
|
||||||
new GlobalizedMessage("cms.ui.assetlist.add_locale",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
addLocaleSelect = new SingleSelect("add-locale-select");
|
|
||||||
try {
|
|
||||||
addLocaleSelect.addPrintListener(event -> {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final Optional<AttachmentList> selectedList = getSelectedList(
|
|
||||||
state);
|
|
||||||
if (selectedList.isPresent()) {
|
|
||||||
final SingleSelect target = (SingleSelect) event.getTarget();
|
|
||||||
|
|
||||||
target.clearOptions();
|
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final AttachmentListL10NManager l10nManager = cdiUtil
|
|
||||||
.findBean(AttachmentListL10NManager.class);
|
|
||||||
final List<Locale> creatableLocales = new ArrayList<>(
|
|
||||||
l10nManager.creatableLocales(selectedList.get()));
|
|
||||||
creatableLocales.sort((locale1, locale2) -> {
|
|
||||||
return locale1
|
|
||||||
.toString()
|
|
||||||
.compareTo(locale2.toString());
|
|
||||||
});
|
|
||||||
creatableLocales.forEach(locale -> target.addOption(
|
|
||||||
new Option(locale.toString(),
|
|
||||||
new Text(locale.toString()))));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
} catch (TooManyListenersException ex) {
|
|
||||||
throw new UnexpectedErrorException(ex);
|
|
||||||
}
|
|
||||||
addLocaleSubmit = new Submit(new GlobalizedMessage(
|
|
||||||
"cms.ui.assetlist.add_locale",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
addLocalePanel.add(addLocaleLabel);
|
|
||||||
addLocalePanel.add(addLocaleSelect);
|
|
||||||
addLocalePanel.add(addLocaleSubmit);
|
|
||||||
super.add(addLocalePanel);
|
|
||||||
|
|
||||||
super.add(new Label(new GlobalizedMessage("cms.ui.assetlist.name",
|
|
||||||
CmsConstants.CMS_BUNDLE)));
|
|
||||||
nameField = new TextField("attachmentListName");
|
|
||||||
nameField.addValidationListener(new AssetListNameValidator());
|
|
||||||
super.add(nameField);
|
|
||||||
|
|
||||||
super.add(new Label(new GlobalizedMessage("cms.ui.assetlist.title",
|
|
||||||
CmsConstants.CMS_BUNDLE)));
|
|
||||||
titleField = new TextField("attachmentListTitle");
|
|
||||||
super.add(titleField);
|
|
||||||
|
|
||||||
super.add(new Label(
|
|
||||||
new GlobalizedMessage("cms.ui.assetlist.description",
|
|
||||||
CmsConstants.CMS_BUNDLE)));
|
|
||||||
descriptionArea = new TextArea("attachmentListDesc");
|
|
||||||
super.add(descriptionArea);
|
|
||||||
|
|
||||||
saveCancelSection = new SaveCancelSection();
|
|
||||||
super.add(saveCancelSection);
|
|
||||||
|
|
||||||
super.addInitListener(this);
|
|
||||||
super.addProcessListener(this);
|
|
||||||
super.addSubmissionListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Optional<AttachmentList> getSelectedList(final PageState state) {
|
|
||||||
|
|
||||||
if (listSelectionModel.getSelectedKey(state) == null) {
|
|
||||||
return Optional.empty();
|
|
||||||
} else {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final AttachmentListManager manager = cdiUtil
|
|
||||||
.findBean(AttachmentListManager.class);
|
|
||||||
final AttachmentList list = manager
|
|
||||||
.getAttachmentList(listSelectionModel.getSelectedKey(state))
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No AttachmentList with ID %d in the database.",
|
|
||||||
listSelectionModel.getSelectedKey(state))));
|
|
||||||
return Optional.of(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final Optional<AttachmentList> selectedList = getSelectedList(state);
|
|
||||||
|
|
||||||
if (selectedList.isPresent()) {
|
|
||||||
|
|
||||||
nameField.setValue(state, selectedList.get().getName());
|
|
||||||
|
|
||||||
showLocaleSelect.setValue(state,
|
|
||||||
KernelConfig
|
|
||||||
.getConfig()
|
|
||||||
.getDefaultLocale()
|
|
||||||
.toString());
|
|
||||||
|
|
||||||
titleField.setValue(state,
|
|
||||||
selectedList
|
|
||||||
.get()
|
|
||||||
.getTitle()
|
|
||||||
.getValue(getSelectedLocale(state)));
|
|
||||||
|
|
||||||
descriptionArea.setValue(state,
|
|
||||||
selectedList
|
|
||||||
.get()
|
|
||||||
.getTitle()
|
|
||||||
.getValue(getSelectedLocale(state)));
|
|
||||||
} else {
|
|
||||||
showLocaleSelect.setValue(state,
|
|
||||||
KernelConfig
|
|
||||||
.getConfig()
|
|
||||||
.getDefaultLocale()
|
|
||||||
.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Locale getSelectedLocale(final PageState state) {
|
|
||||||
final String selected = (String) showLocaleSelect.getValue(state);
|
|
||||||
if (selected == null) {
|
|
||||||
return KernelConfig.getConfig().getDefaultLocale();
|
|
||||||
} else {
|
|
||||||
return new Locale(selected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void process(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
|
|
||||||
if (showLocaleSubmit.isSelected(state)) {
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addLocaleSubmit.isSelected(state)) {
|
|
||||||
final AttachmentListL10NManager l10nManager = cdiUtil
|
|
||||||
.findBean(AttachmentListL10NManager.class);
|
|
||||||
final Locale add = new Locale((String) addLocaleSelect
|
|
||||||
.getValue(state));
|
|
||||||
final Optional<AttachmentList> selectedList = getSelectedList(state);
|
|
||||||
l10nManager.addLanguage(selectedList.get(), add);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saveCancelSection.getSaveButton().isSelected(state)) {
|
|
||||||
|
|
||||||
final RelatedInfoStepController controller = cdiUtil
|
|
||||||
.findBean(RelatedInfoStepController.class);
|
|
||||||
final AttachmentListManager attachmentListManager = cdiUtil
|
|
||||||
.findBean(AttachmentListManager.class);
|
|
||||||
|
|
||||||
final Optional<AttachmentList> selectedList = getSelectedList(state);
|
|
||||||
final AttachmentList attachmentList;
|
|
||||||
if (selectedList.isPresent()) {
|
|
||||||
attachmentList = selectedList.get();
|
|
||||||
} else {
|
|
||||||
attachmentList = attachmentListManager
|
|
||||||
.createAttachmentList(itemSelectionModel
|
|
||||||
.getSelectedItem(state),
|
|
||||||
(String) nameField.getValue(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
attachmentList.setName((String) nameField.getValue(state));
|
|
||||||
attachmentList
|
|
||||||
.getTitle()
|
|
||||||
.putValue(getSelectedLocale(state),
|
|
||||||
(String) titleField.getValue(state));
|
|
||||||
attachmentList
|
|
||||||
.getDescription()
|
|
||||||
.putValue(getSelectedLocale(state),
|
|
||||||
(String) descriptionArea.getValue(state));
|
|
||||||
|
|
||||||
controller.saveAttachmentList(attachmentList);
|
|
||||||
}
|
|
||||||
|
|
||||||
relatedInfoStep.showAttachmentListTable(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void submitted(final FormSectionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
if (saveCancelSection.getCancelButton().isSelected(state)) {
|
|
||||||
listSelectionModel.clearSelection(state);
|
|
||||||
relatedInfoStep.showAttachmentListTable(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AssetListNameValidator extends GlobalizedParameterListener {
|
|
||||||
|
|
||||||
public AssetListNameValidator() {
|
|
||||||
super.setError(new GlobalizedMessage(
|
|
||||||
"cms.ui.assetlist.name_cant_start_with_dot",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validate(final ParameterEvent event) throws
|
|
||||||
FormProcessException {
|
|
||||||
|
|
||||||
final ParameterData data = event.getParameterData();
|
|
||||||
final String value = (String) data.getValue();
|
|
||||||
|
|
||||||
if (value.startsWith(".")) {
|
|
||||||
data.addError(getError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,272 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
|
||||||
import com.arsdigita.bebop.ControlLink;
|
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
|
||||||
import com.arsdigita.bebop.table.TableColumn;
|
|
||||||
import com.arsdigita.bebop.table.TableColumnModel;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
import org.librecms.contentsection.AttachmentList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class RelatedInfoListTable extends Table {
|
|
||||||
|
|
||||||
protected static final int COL_NAME = 0;
|
|
||||||
protected static final int COL_TITLE = 1;
|
|
||||||
protected static final int COL_DESC = 2;
|
|
||||||
protected static final int COL_EDIT = 3;
|
|
||||||
protected static final int COL_MOVE = 4;
|
|
||||||
protected static final int COL_DELETE = 5;
|
|
||||||
|
|
||||||
private final RelatedInfoStep relatedInfoStep;
|
|
||||||
private final ItemSelectionModel itemSelectionModel;
|
|
||||||
private final AttachmentListSelectionModel selectedListModel;
|
|
||||||
private final AttachmentListSelectionModel moveListModel;
|
|
||||||
private final StringParameter selectedLanguageParam;
|
|
||||||
|
|
||||||
protected RelatedInfoListTable(
|
|
||||||
final RelatedInfoStep relatedInfoStep,
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AttachmentListSelectionModel selectedListModel,
|
|
||||||
final AttachmentListSelectionModel moveListModel,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
|
|
||||||
super();
|
|
||||||
this.relatedInfoStep = relatedInfoStep;
|
|
||||||
this.itemSelectionModel = itemSelectionModel;
|
|
||||||
this.selectedListModel = selectedListModel;
|
|
||||||
this.moveListModel = moveListModel;
|
|
||||||
this.selectedLanguageParam = selectedLanguageParam;
|
|
||||||
|
|
||||||
final TableColumnModel columnModel = super.getColumnModel();
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_NAME,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.name",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_TITLE,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.title",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_DESC,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.description",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_EDIT,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.edit",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_MOVE,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.move",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
columnModel.add(new TableColumn(
|
|
||||||
COL_DELETE,
|
|
||||||
new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.delete",
|
|
||||||
CmsConstants.CMS_BUNDLE))));
|
|
||||||
|
|
||||||
super
|
|
||||||
.setModelBuilder(new RelatedInfoListTableModelBuilder(
|
|
||||||
itemSelectionModel,
|
|
||||||
moveListModel,
|
|
||||||
selectedLanguageParam));
|
|
||||||
|
|
||||||
super
|
|
||||||
.getColumn(COL_NAME)
|
|
||||||
.setCellRenderer(new ControlLinkCellRenderer());
|
|
||||||
super
|
|
||||||
.getColumn(COL_EDIT)
|
|
||||||
.setCellRenderer(new ControlLinkCellRenderer());
|
|
||||||
super
|
|
||||||
.getColumn(COL_MOVE)
|
|
||||||
.setCellRenderer(new ControlLinkCellRenderer());
|
|
||||||
super
|
|
||||||
.getColumn(COL_DELETE)
|
|
||||||
.setCellRenderer(new ControlLinkCellRenderer());
|
|
||||||
|
|
||||||
super.setEmptyView(new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.none",
|
|
||||||
CmsConstants.CMS_BUNDLE)));
|
|
||||||
|
|
||||||
super
|
|
||||||
.addTableActionListener(new TableActionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cellSelected(final TableActionEvent event)
|
|
||||||
throws FormProcessException {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
final TableColumn column = getColumnModel()
|
|
||||||
.get(event.getColumn());
|
|
||||||
|
|
||||||
switch (column.getModelIndex()) {
|
|
||||||
case COL_NAME:
|
|
||||||
selectedListModel
|
|
||||||
.setSelectedKey(state,
|
|
||||||
Long.parseLong((String) event
|
|
||||||
.getRowKey()));
|
|
||||||
relatedInfoStep.showAttachmentsTable(state);
|
|
||||||
break;
|
|
||||||
case COL_EDIT:
|
|
||||||
selectedListModel
|
|
||||||
.setSelectedKey(state,
|
|
||||||
Long.parseLong((String) event
|
|
||||||
.getRowKey()));
|
|
||||||
relatedInfoStep.showListEditForm(state);
|
|
||||||
break;
|
|
||||||
case COL_MOVE:
|
|
||||||
if (moveListModel.getSelectedKey(state) == null) {
|
|
||||||
|
|
||||||
moveListModel
|
|
||||||
.setSelectedKey(state,
|
|
||||||
Long.parseLong(
|
|
||||||
(String) event
|
|
||||||
.getRowKey()));
|
|
||||||
} else {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final RelatedInfoStepController controller
|
|
||||||
= cdiUtil
|
|
||||||
.findBean(
|
|
||||||
RelatedInfoStepController.class);
|
|
||||||
|
|
||||||
final AttachmentList selectedList
|
|
||||||
= moveListModel
|
|
||||||
.getSelectedAttachmentList(state);
|
|
||||||
|
|
||||||
final Long destId = Long
|
|
||||||
.parseLong((String) event.getRowKey());
|
|
||||||
|
|
||||||
controller.moveAfter(itemSelectionModel
|
|
||||||
.getSelectedItem(state),
|
|
||||||
selectedList,
|
|
||||||
destId);
|
|
||||||
moveListModel.clearSelection(state);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case COL_DELETE: {
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final RelatedInfoStepController controller = cdiUtil
|
|
||||||
.findBean(RelatedInfoStepController.class);
|
|
||||||
controller.deleteList(Long
|
|
||||||
.parseLong((String) event.getRowKey()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException(String
|
|
||||||
.format("Illegal column index: %d",
|
|
||||||
column.getModelIndex()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void headSelected(final TableActionEvent event) {
|
|
||||||
//Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ControlLinkCellRenderer implements TableCellRenderer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getComponent(final Table table,
|
|
||||||
final PageState state,
|
|
||||||
final Object value,
|
|
||||||
final boolean isSelected,
|
|
||||||
final Object key,
|
|
||||||
final int row,
|
|
||||||
final int column) {
|
|
||||||
|
|
||||||
return new ControlLink((Component) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// private class MoveCellRenderer implements TableCellRenderer {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public Component getComponent(final Table table,
|
|
||||||
// final PageState state,
|
|
||||||
// final Object value,
|
|
||||||
// final boolean isSelected,
|
|
||||||
// final Object key,
|
|
||||||
// final int row,
|
|
||||||
// final int column) {
|
|
||||||
//
|
|
||||||
// return new ControlLink((Component) value);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private class EditCellRenderer implements TableCellRenderer {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public Component getComponent(final Table table,
|
|
||||||
// final PageState state,
|
|
||||||
// final Object value,
|
|
||||||
// final boolean isSelected,
|
|
||||||
// final Object key,
|
|
||||||
// final int row,
|
|
||||||
// final int column) {
|
|
||||||
//
|
|
||||||
// return new ControlLink((Component) value);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private class DeleteCellRenderer implements TableCellRenderer {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public Component getComponent(final Table table,
|
|
||||||
// final PageState state,
|
|
||||||
// final Object value,
|
|
||||||
// final boolean isSelected,
|
|
||||||
// final Object key,
|
|
||||||
// final int row,
|
|
||||||
// final int column) {
|
|
||||||
//
|
|
||||||
// return new ControlLink((Component) value);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Text;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class RelatedInfoListTableModel implements TableModel {
|
|
||||||
|
|
||||||
private final PageState state;
|
|
||||||
private final AttachmentListSelectionModel moveListModel;
|
|
||||||
|
|
||||||
private final Iterator<AttachmentListTableRow> iterator;
|
|
||||||
private AttachmentListTableRow currentRow;
|
|
||||||
|
|
||||||
RelatedInfoListTableModel(
|
|
||||||
final List<AttachmentListTableRow> rows,
|
|
||||||
final PageState state,
|
|
||||||
final AttachmentListSelectionModel moveListModel) {
|
|
||||||
|
|
||||||
this.iterator = rows.iterator();
|
|
||||||
this.state = state;
|
|
||||||
this.moveListModel = moveListModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
|
||||||
return 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextRow() {
|
|
||||||
if (iterator.hasNext()) {
|
|
||||||
currentRow = iterator.next();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getElementAt(final int columnIndex) {
|
|
||||||
|
|
||||||
switch (columnIndex) {
|
|
||||||
case RelatedInfoListTable.COL_NAME:
|
|
||||||
return new Text(currentRow.getName());
|
|
||||||
case RelatedInfoListTable.COL_TITLE:
|
|
||||||
return new Text(currentRow.getTitle());
|
|
||||||
case RelatedInfoListTable.COL_DESC:
|
|
||||||
return new Text(currentRow.getDescription());
|
|
||||||
case RelatedInfoListTable.COL_EDIT:
|
|
||||||
return new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.edit",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
case RelatedInfoListTable.COL_MOVE:
|
|
||||||
if (moveListModel.getSelectedAttachmentList(state) == null) {
|
|
||||||
return new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.move",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
} else {
|
|
||||||
return new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.move_here",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
}
|
|
||||||
case RelatedInfoListTable.COL_DELETE:
|
|
||||||
return new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.list.delete",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException(String.format(
|
|
||||||
"Illegal column index %d.", columnIndex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getKeyAt(final int columnIndex) {
|
|
||||||
return currentRow.getListId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.Table;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.bebop.table.TableModel;
|
|
||||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel;
|
|
||||||
import com.arsdigita.util.LockableImpl;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.contentsection.ContentItem;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
class RelatedInfoListTableModelBuilder
|
|
||||||
extends LockableImpl
|
|
||||||
implements TableModelBuilder {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemSelectionModel;
|
|
||||||
private final AttachmentListSelectionModel moveListModel;
|
|
||||||
private final StringParameter selectedLanguageParam;
|
|
||||||
|
|
||||||
protected RelatedInfoListTableModelBuilder(
|
|
||||||
final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AttachmentListSelectionModel moveListModel,
|
|
||||||
final StringParameter selectedLanguageParam) {
|
|
||||||
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.itemSelectionModel = itemSelectionModel;
|
|
||||||
this.moveListModel = moveListModel;
|
|
||||||
this.selectedLanguageParam = selectedLanguageParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableModel makeModel(final Table table, final PageState state) {
|
|
||||||
|
|
||||||
final ContentItem selectedItem = itemSelectionModel
|
|
||||||
.getSelectedItem(state);
|
|
||||||
final String selectedLanguage = (String) state
|
|
||||||
.getValue(selectedLanguageParam);
|
|
||||||
final Locale selectedLocale = new Locale(selectedLanguage);
|
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
|
||||||
final RelatedInfoStepController controller = cdiUtil
|
|
||||||
.findBean(RelatedInfoStepController.class);
|
|
||||||
|
|
||||||
final List<AttachmentListTableRow> rows = controller
|
|
||||||
.retrieveAttachmentLists(selectedItem, selectedLocale);
|
|
||||||
|
|
||||||
return new RelatedInfoListTableModel(rows, state, moveListModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,315 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.ActionLink;
|
|
||||||
import com.arsdigita.bebop.BoxPanel;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.Page;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
import com.arsdigita.bebop.SimpleContainer;
|
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
|
||||||
import com.arsdigita.cms.ui.authoring.ResettableContainer;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentListSelectionModel;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.AttachmentSelectionModel;
|
|
||||||
import com.arsdigita.globalization.GlobalizedMessage;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
|
||||||
import org.librecms.CmsConstants;
|
|
||||||
import org.librecms.contentsection.AttachmentList;
|
|
||||||
import org.librecms.contentsection.ItemAttachment;
|
|
||||||
import org.librecms.ui.authoring.ContentItemAuthoringStep;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@ContentItemAuthoringStep(
|
|
||||||
labelBundle = CmsConstants.CMS_BUNDLE,
|
|
||||||
labelKey = "related_info_step.label",
|
|
||||||
descriptionBundle = CmsConstants.CMS_BUNDLE,
|
|
||||||
descriptionKey = "related_info_step.description")
|
|
||||||
public class RelatedInfoStep extends ResettableContainer {
|
|
||||||
|
|
||||||
private final ItemSelectionModel itemSelectionModel;
|
|
||||||
private final AuthoringKitWizard authoringKitWizard;
|
|
||||||
private final StringParameter selectedLanguageParam;
|
|
||||||
|
|
||||||
private final AttachmentListSelectionModel selectedListModel;
|
|
||||||
private final AttachmentListSelectionModel moveListModel;
|
|
||||||
|
|
||||||
private final RelatedInfoListTable listTable;
|
|
||||||
private final RelatedInfoListForm listForm;
|
|
||||||
private final ActionLink addListLink;
|
|
||||||
private final ActionLink listToFirstLink;
|
|
||||||
|
|
||||||
private final AttachmentSelectionModel selectedAttachmentModel;
|
|
||||||
private final AttachmentSelectionModel moveAttachmentModel;
|
|
||||||
|
|
||||||
private final AttachmentsTable attachmentsTable;
|
|
||||||
private final RelatedInfoAttachAssetForm attachAssetForm;
|
|
||||||
private final InternalLinkAddForm internalLinkAddForm;
|
|
||||||
|
|
||||||
private final ActionLink attachAssetLink;
|
|
||||||
private final ActionLink internalLinkAddLink;
|
|
||||||
private final ActionLink attachmentToFirstLink;
|
|
||||||
|
|
||||||
public RelatedInfoStep(final ItemSelectionModel itemSelectionModel,
|
|
||||||
final AuthoringKitWizard authoringKitWizard,
|
|
||||||
final StringParameter selectedLanguage) {
|
|
||||||
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.itemSelectionModel = itemSelectionModel;
|
|
||||||
this.authoringKitWizard = authoringKitWizard;
|
|
||||||
this.selectedLanguageParam = selectedLanguage;
|
|
||||||
|
|
||||||
selectedListModel = new AttachmentListSelectionModel(
|
|
||||||
"selected-attachment-list");
|
|
||||||
moveListModel = new AttachmentListSelectionModel(
|
|
||||||
"move-attachment-list-model");
|
|
||||||
|
|
||||||
listTable = new RelatedInfoListTable(this,
|
|
||||||
itemSelectionModel,
|
|
||||||
selectedListModel, moveListModel,
|
|
||||||
selectedLanguageParam);
|
|
||||||
listForm = new RelatedInfoListForm(this,
|
|
||||||
itemSelectionModel,
|
|
||||||
selectedListModel,
|
|
||||||
selectedLanguageParam);
|
|
||||||
|
|
||||||
addListLink = new ActionLink(new Label(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.add_list",
|
|
||||||
CmsConstants.CMS_BUNDLE)));
|
|
||||||
addListLink.addActionListener(event -> {
|
|
||||||
showListEditForm(event.getPageState());
|
|
||||||
});
|
|
||||||
|
|
||||||
listToFirstLink = new ActionLink(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment_list"
|
|
||||||
+ ".move_to_beginning",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
listToFirstLink.addActionListener(event -> {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final AttachmentList toMove = moveListModel
|
|
||||||
.getSelectedAttachmentList(state);
|
|
||||||
|
|
||||||
final RelatedInfoStepController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(RelatedInfoStepController.class);
|
|
||||||
|
|
||||||
controller.moveToFirst(itemSelectionModel.getSelectedItem(state),
|
|
||||||
toMove);
|
|
||||||
|
|
||||||
moveListModel.clearSelection(state);
|
|
||||||
});
|
|
||||||
|
|
||||||
moveListModel.addChangeListener(event -> {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
if (moveListModel.getSelectedKey(state) == null) {
|
|
||||||
addListLink.setVisible(state, true);
|
|
||||||
listToFirstLink.setVisible(state, false);
|
|
||||||
} else {
|
|
||||||
addListLink.setVisible(state, false);
|
|
||||||
listToFirstLink.setVisible(state, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
selectedAttachmentModel = new AttachmentSelectionModel(
|
|
||||||
"selected-attachment-model");
|
|
||||||
moveAttachmentModel = new AttachmentSelectionModel(
|
|
||||||
"move-attachment-model");
|
|
||||||
|
|
||||||
attachmentsTable = new AttachmentsTable(this, itemSelectionModel,
|
|
||||||
selectedListModel,
|
|
||||||
selectedAttachmentModel,
|
|
||||||
moveAttachmentModel,
|
|
||||||
selectedLanguageParam);
|
|
||||||
attachAssetForm = new RelatedInfoAttachAssetForm(this,
|
|
||||||
itemSelectionModel,
|
|
||||||
selectedListModel,
|
|
||||||
selectedLanguageParam);
|
|
||||||
internalLinkAddForm = new InternalLinkAddForm(this,
|
|
||||||
itemSelectionModel,
|
|
||||||
selectedListModel,
|
|
||||||
selectedLanguageParam);
|
|
||||||
|
|
||||||
|
|
||||||
attachAssetLink = new ActionLink(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attach_asset",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
attachAssetLink.addActionListener(event -> {
|
|
||||||
showAttachAssetForm(event.getPageState());
|
|
||||||
});
|
|
||||||
|
|
||||||
internalLinkAddLink = new ActionLink(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.add_internal_link",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
internalLinkAddLink.addActionListener(event -> {
|
|
||||||
showAddInternalLinkForm(event.getPageState());
|
|
||||||
});
|
|
||||||
|
|
||||||
attachmentToFirstLink = new ActionLink(new GlobalizedMessage(
|
|
||||||
"cms.ui.authoring.assets.related_info_step.attachment.move_to_first",
|
|
||||||
CmsConstants.CMS_BUNDLE));
|
|
||||||
attachmentToFirstLink.addActionListener(event -> {
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
final ItemAttachment<?> toMove = moveAttachmentModel
|
|
||||||
.getSelectedAttachment(state);
|
|
||||||
|
|
||||||
final RelatedInfoStepController controller = CdiUtil
|
|
||||||
.createCdiUtil()
|
|
||||||
.findBean(RelatedInfoStepController.class);
|
|
||||||
|
|
||||||
controller.moveToFirst(selectedListModel
|
|
||||||
.getSelectedAttachmentList(state), toMove);
|
|
||||||
|
|
||||||
moveAttachmentModel.clearSelection(state);
|
|
||||||
});
|
|
||||||
|
|
||||||
moveAttachmentModel.addChangeListener(event -> {
|
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
|
||||||
|
|
||||||
if (moveAttachmentModel.getSelectedKey(state) == null) {
|
|
||||||
attachAssetLink.setVisible(state, true);
|
|
||||||
attachmentToFirstLink.setVisible(state, false);
|
|
||||||
} else {
|
|
||||||
attachAssetLink.setVisible(state, false);
|
|
||||||
attachmentToFirstLink.setVisible(state, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final SimpleContainer addLinks = new SimpleContainer();
|
|
||||||
addLinks.add(addListLink);
|
|
||||||
addLinks.add(internalLinkAddLink);
|
|
||||||
|
|
||||||
final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL);
|
|
||||||
|
|
||||||
panel.add(addLinks);
|
|
||||||
panel.add(listToFirstLink);
|
|
||||||
panel.add(listTable);
|
|
||||||
panel.add(listForm);
|
|
||||||
|
|
||||||
panel.add(attachAssetLink);
|
|
||||||
panel.add(attachmentToFirstLink);
|
|
||||||
panel.add(attachmentsTable);
|
|
||||||
panel.add(attachAssetForm);
|
|
||||||
panel.add(internalLinkAddForm);
|
|
||||||
|
|
||||||
super.add(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void register(final Page page) {
|
|
||||||
|
|
||||||
super.register(page);
|
|
||||||
|
|
||||||
page.addComponentStateParam(this, selectedListModel.getStateParameter());
|
|
||||||
page.addComponentStateParam(this, moveListModel.getStateParameter());
|
|
||||||
page.addComponentStateParam(this,
|
|
||||||
selectedAttachmentModel.getStateParameter());
|
|
||||||
page.addComponentStateParam(this,
|
|
||||||
moveAttachmentModel.getStateParameter());
|
|
||||||
|
|
||||||
page.setVisibleDefault(listTable, true);
|
|
||||||
page.setVisibleDefault(listForm, false);
|
|
||||||
page.setVisibleDefault(addListLink, true);
|
|
||||||
page.setVisibleDefault(listToFirstLink, false);
|
|
||||||
page.setVisibleDefault(attachmentsTable, false);
|
|
||||||
page.setVisibleDefault(attachAssetForm, false);
|
|
||||||
page.setVisibleDefault(internalLinkAddForm, false);
|
|
||||||
page.setVisibleDefault(internalLinkAddLink, false);
|
|
||||||
page.setVisibleDefault(attachAssetLink, false);
|
|
||||||
page.setVisibleDefault(attachmentToFirstLink, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void showAttachmentListTable(final PageState state) {
|
|
||||||
|
|
||||||
listTable.setVisible(state, true);
|
|
||||||
addListLink.setVisible(state, true);
|
|
||||||
listForm.setVisible(state, false);
|
|
||||||
listToFirstLink.setVisible(state, false);
|
|
||||||
attachmentsTable.setVisible(state, false);
|
|
||||||
attachAssetForm.setVisible(state, false);
|
|
||||||
attachAssetLink.setVisible(state, false);
|
|
||||||
attachmentToFirstLink.setVisible(state, false);
|
|
||||||
internalLinkAddForm.setVisible(state, false);
|
|
||||||
internalLinkAddLink.setVisible(state, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showListEditForm(final PageState state) {
|
|
||||||
|
|
||||||
listTable.setVisible(state, false);
|
|
||||||
listForm.setVisible(state, true);
|
|
||||||
addListLink.setVisible(state, false);
|
|
||||||
listToFirstLink.setVisible(state, false);
|
|
||||||
attachmentsTable.setVisible(state, false);
|
|
||||||
attachAssetForm.setVisible(state, false);
|
|
||||||
attachAssetLink.setVisible(state, false);
|
|
||||||
attachmentToFirstLink.setVisible(state, false);
|
|
||||||
internalLinkAddForm.setVisible(state, false);
|
|
||||||
internalLinkAddLink.setVisible(state, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showAttachmentsTable(final PageState state) {
|
|
||||||
|
|
||||||
listTable.setVisible(state, false);
|
|
||||||
listForm.setVisible(state, false);
|
|
||||||
addListLink.setVisible(state, false);
|
|
||||||
listToFirstLink.setVisible(state, false);
|
|
||||||
attachmentsTable.setVisible(state, true);
|
|
||||||
attachAssetForm.setVisible(state, false);
|
|
||||||
attachAssetLink.setVisible(state, true);
|
|
||||||
attachmentToFirstLink.setVisible(state, false);
|
|
||||||
internalLinkAddForm.setVisible(state, false);
|
|
||||||
internalLinkAddLink.setVisible(state, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showAttachAssetForm(final PageState state) {
|
|
||||||
listTable.setVisible(state, false);
|
|
||||||
listForm.setVisible(state, false);
|
|
||||||
addListLink.setVisible(state, false);
|
|
||||||
listToFirstLink.setVisible(state, false);
|
|
||||||
attachmentsTable.setVisible(state, false);
|
|
||||||
attachAssetForm.setVisible(state, true);
|
|
||||||
attachAssetLink.setVisible(state, false);
|
|
||||||
attachmentToFirstLink.setVisible(state, false);
|
|
||||||
internalLinkAddForm.setVisible(state, false);
|
|
||||||
internalLinkAddLink.setVisible(state, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showAddInternalLinkForm(final PageState state) {
|
|
||||||
listTable.setVisible(state, false);
|
|
||||||
listForm.setVisible(state, false);
|
|
||||||
addListLink.setVisible(state, false);
|
|
||||||
listToFirstLink.setVisible(state, false);
|
|
||||||
attachmentsTable.setVisible(state, false);
|
|
||||||
attachAssetForm.setVisible(state, false);
|
|
||||||
attachAssetLink.setVisible(state, false);
|
|
||||||
attachmentToFirstLink.setVisible(state, false);
|
|
||||||
internalLinkAddForm.setVisible(state, true);
|
|
||||||
internalLinkAddLink.setVisible(state, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,411 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017 LibreCCM Foundation.
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
|
||||||
|
|
||||||
import com.arsdigita.kernel.KernelConfig;
|
|
||||||
|
|
||||||
import org.libreccm.configuration.ConfigurationManager;
|
|
||||||
import org.libreccm.core.UnexpectedErrorException;
|
|
||||||
import org.librecms.assets.RelatedLink;
|
|
||||||
import org.librecms.contentsection.Asset;
|
|
||||||
import org.librecms.contentsection.AssetRepository;
|
|
||||||
import org.librecms.contentsection.AttachmentList;
|
|
||||||
import org.librecms.contentsection.AttachmentListManager;
|
|
||||||
import org.librecms.contentsection.ContentItem;
|
|
||||||
import org.librecms.contentsection.ContentItemRepository;
|
|
||||||
import org.librecms.contentsection.ItemAttachment;
|
|
||||||
import org.librecms.contentsection.ItemAttachmentManager;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
@RequestScoped
|
|
||||||
class RelatedInfoStepController {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AssetRepository assetRepo;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AttachmentListManager attachmentListManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ConfigurationManager confManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ContentItemRepository itemRepo;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private EntityManager entityManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ItemAttachmentManager itemAttachmentManager;
|
|
||||||
|
|
||||||
private Locale defaultLocale;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
private void init() {
|
|
||||||
|
|
||||||
final KernelConfig kernelConfig = confManager
|
|
||||||
.findConfiguration(KernelConfig.class);
|
|
||||||
defaultLocale = kernelConfig.getDefaultLocale();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
protected void saveAttachmentList(final AttachmentList attachmentList) {
|
|
||||||
|
|
||||||
if (attachmentList.getListId() == 0) {
|
|
||||||
entityManager.persist(attachmentList);
|
|
||||||
} else {
|
|
||||||
entityManager.merge(attachmentList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
void moveToFirst(final ContentItem selectedItem,
|
|
||||||
final AttachmentList listToMove) {
|
|
||||||
|
|
||||||
Objects.requireNonNull(selectedItem);
|
|
||||||
Objects.requireNonNull(listToMove);
|
|
||||||
|
|
||||||
final ContentItem item = itemRepo
|
|
||||||
.findById(selectedItem.getObjectId())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No ContentItem with ID %d in the database.",
|
|
||||||
selectedItem.getObjectId())));
|
|
||||||
|
|
||||||
final AttachmentList toMove = attachmentListManager
|
|
||||||
.getAttachmentList(listToMove.getListId())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No AttachmentList with ID %d in the database.",
|
|
||||||
listToMove.getListId())));
|
|
||||||
|
|
||||||
final List<AttachmentList> lists = item
|
|
||||||
.getAttachments()
|
|
||||||
.stream()
|
|
||||||
.sorted((list1, list2) -> list1.compareTo(list2))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
toMove.setListOrder(0);
|
|
||||||
lists
|
|
||||||
.stream()
|
|
||||||
.filter(current -> !current.equals(toMove))
|
|
||||||
.forEach(current -> current.setListOrder(current.getListOrder() + 1));
|
|
||||||
|
|
||||||
lists.forEach(entityManager::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
void moveToFirst(final AttachmentList selectedList,
|
|
||||||
final ItemAttachment<?> attachmentToMove) {
|
|
||||||
|
|
||||||
Objects.requireNonNull(selectedList);
|
|
||||||
Objects.requireNonNull(attachmentToMove);
|
|
||||||
|
|
||||||
final AttachmentList list = attachmentListManager
|
|
||||||
.getAttachmentList(selectedList.getListId())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No AttachmentList with ID %d in the database.",
|
|
||||||
selectedList.getListId())));
|
|
||||||
|
|
||||||
final ItemAttachment<?> toMove = itemAttachmentManager
|
|
||||||
.findById(attachmentToMove.getAttachmentId())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No ItemAttachment with ID %d in the database.",
|
|
||||||
attachmentToMove.getAttachmentId())));
|
|
||||||
|
|
||||||
final List<ItemAttachment<?>> attachments = list
|
|
||||||
.getAttachments()
|
|
||||||
.stream()
|
|
||||||
.sorted((attachment1, attachment2) -> {
|
|
||||||
return attachment1.compareTo(attachment2);
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
toMove.setSortKey(0);
|
|
||||||
attachments
|
|
||||||
.stream()
|
|
||||||
.filter(current -> !current.equals(toMove))
|
|
||||||
.forEach(current -> current.setSortKey(current.getSortKey() + 1));
|
|
||||||
|
|
||||||
attachments.forEach(entityManager::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
protected void moveAfter(final ContentItem selectedItem,
|
|
||||||
final AttachmentList listToMove,
|
|
||||||
final Long destId) {
|
|
||||||
|
|
||||||
Objects.requireNonNull(selectedItem);
|
|
||||||
Objects.requireNonNull(listToMove);
|
|
||||||
|
|
||||||
final ContentItem item = itemRepo
|
|
||||||
.findById(selectedItem.getObjectId())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No ContentItem with ID %d in the database.",
|
|
||||||
selectedItem.getObjectId())));
|
|
||||||
|
|
||||||
final AttachmentList toMove = attachmentListManager
|
|
||||||
.getAttachmentList(listToMove.getListId())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No AttachmentList with ID %d in the database.",
|
|
||||||
listToMove.getListId())));
|
|
||||||
|
|
||||||
final AttachmentList after = attachmentListManager
|
|
||||||
.getAttachmentList(destId)
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No AttachmentList with ID %d in the database.", destId)));
|
|
||||||
|
|
||||||
final List<AttachmentList> lists = item
|
|
||||||
.getAttachments()
|
|
||||||
.stream()
|
|
||||||
.sorted((list1, list2) -> list1.compareTo(list2))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (!lists.contains(toMove)) {
|
|
||||||
throw new IllegalArgumentException(String
|
|
||||||
.format("AttachmentList %d is not part of ContentItem %d.",
|
|
||||||
toMove.getListId(),
|
|
||||||
item.getObjectId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lists.contains(after)) {
|
|
||||||
throw new IllegalArgumentException(String
|
|
||||||
.format("AttachmentList %d is not part of ContentItem %d.",
|
|
||||||
after.getListId(),
|
|
||||||
item.getObjectId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
final int afterIndex = lists.indexOf(after);
|
|
||||||
for (int i = afterIndex + 1; i < lists.size(); i++) {
|
|
||||||
final AttachmentList current = lists.get(i);
|
|
||||||
current.setListOrder(current.getListOrder() + 1);
|
|
||||||
entityManager.merge(current);
|
|
||||||
}
|
|
||||||
|
|
||||||
toMove.setListOrder(afterIndex + 1);
|
|
||||||
entityManager.merge(toMove);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void moveAfter(final AttachmentList list,
|
|
||||||
final ItemAttachment<?> attachment,
|
|
||||||
final long destId) {
|
|
||||||
//ToDo
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void deleteList(final Long listId) {
|
|
||||||
|
|
||||||
final AttachmentList list = attachmentListManager
|
|
||||||
.getAttachmentList(listId)
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No AttachmentList with ID %d in the database.",
|
|
||||||
listId)));
|
|
||||||
|
|
||||||
entityManager.remove(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
protected void removeAttachment(final long attachmentId) {
|
|
||||||
|
|
||||||
final ItemAttachment<?> attachment = itemAttachmentManager
|
|
||||||
.findById(attachmentId)
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No ItemAttachment with ID %d in the database.",
|
|
||||||
attachmentId)));
|
|
||||||
|
|
||||||
entityManager.remove(attachment);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
protected List<AttachmentListTableRow> retrieveAttachmentLists(
|
|
||||||
final ContentItem forContentItem,
|
|
||||||
final Locale selectedLocale) {
|
|
||||||
|
|
||||||
final ContentItem item = itemRepo
|
|
||||||
.findById(forContentItem.getObjectId())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No ContentItem with ID %d in the database.",
|
|
||||||
forContentItem.getObjectId())));
|
|
||||||
|
|
||||||
return item.getAttachments()
|
|
||||||
.stream()
|
|
||||||
.filter(list -> !list.getName().startsWith("."))
|
|
||||||
.map(list -> buildAttachmentListTableRow(list, selectedLocale))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
protected List<AttachmentTableRow> retrieveAttachments(
|
|
||||||
final ContentItem selectedItem,
|
|
||||||
final AttachmentList fromList,
|
|
||||||
final Locale selectedLocale) {
|
|
||||||
|
|
||||||
final AttachmentList list = attachmentListManager
|
|
||||||
.getAttachmentList(fromList.getListId())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No AttachmentList with ID %d in the database.",
|
|
||||||
fromList.getListId())));
|
|
||||||
|
|
||||||
return list
|
|
||||||
.getAttachments()
|
|
||||||
.stream()
|
|
||||||
.map(attachment -> buildAttachmentTableRow(attachment,
|
|
||||||
selectedLocale))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
protected void createInternalLink(final AttachmentList attachmentList,
|
|
||||||
final long targetItemId,
|
|
||||||
final String title,
|
|
||||||
// final String description,
|
|
||||||
final String selectedLanguage) {
|
|
||||||
|
|
||||||
final ContentItem targetItem = itemRepo
|
|
||||||
.findById(targetItemId)
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String
|
|
||||||
.format("No ContentItem with ID %d in the database.", targetItemId)));
|
|
||||||
|
|
||||||
final RelatedLink link = new RelatedLink();
|
|
||||||
link.setTargetItem(targetItem);
|
|
||||||
final Locale selectedLocale = new Locale(selectedLanguage);
|
|
||||||
link.getTitle().putValue(selectedLocale, title);
|
|
||||||
|
|
||||||
final AttachmentList list = attachmentListManager
|
|
||||||
.getAttachmentList(attachmentList.getListId())
|
|
||||||
.orElseThrow(() -> new IllegalArgumentException(String.format(
|
|
||||||
"No AttachmentList with Id %d in the database.",
|
|
||||||
attachmentList.getListId())));
|
|
||||||
|
|
||||||
itemAttachmentManager.attachAsset(link, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
protected void attachAsset(final AttachmentList attachmentList,
|
|
||||||
final long assetId) {
|
|
||||||
|
|
||||||
final Asset asset = assetRepo
|
|
||||||
.findById(assetId)
|
|
||||||
.orElseThrow(() -> new UnexpectedErrorException(String
|
|
||||||
.format("No Asset with ID %d in the database.", assetId)));
|
|
||||||
|
|
||||||
final AttachmentList list = attachmentListManager
|
|
||||||
.getAttachmentList(attachmentList.getListId())
|
|
||||||
.orElseThrow(() -> new UnexpectedErrorException(String
|
|
||||||
.format("No AttachmentList with ID %d in the database.",
|
|
||||||
attachmentList.getListId())));
|
|
||||||
|
|
||||||
itemAttachmentManager.attachAsset(asset, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private AttachmentListTableRow buildAttachmentListTableRow(
|
|
||||||
final AttachmentList attachmentList,
|
|
||||||
final Locale selectedLocale) {
|
|
||||||
|
|
||||||
final AttachmentListTableRow row = new AttachmentListTableRow();
|
|
||||||
|
|
||||||
row.setListId(attachmentList.getListId());
|
|
||||||
|
|
||||||
row.setName(attachmentList.getName());
|
|
||||||
if (attachmentList.getTitle().hasValue(selectedLocale)) {
|
|
||||||
row.setTitle(attachmentList.getTitle().getValue(selectedLocale));
|
|
||||||
} else if (attachmentList.getTitle().hasValue(defaultLocale)) {
|
|
||||||
row.setTitle(attachmentList.getTitle().getValue(defaultLocale));
|
|
||||||
} else {
|
|
||||||
row.setTitle(attachmentList.getTitle().getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attachmentList.getDescription().hasValue(selectedLocale)) {
|
|
||||||
row.setDescription(shortenDescription(attachmentList
|
|
||||||
.getDescription()
|
|
||||||
.getValue(selectedLocale)));
|
|
||||||
} else if (attachmentList.getDescription().hasValue(defaultLocale)) {
|
|
||||||
row.setDescription(shortenDescription(attachmentList
|
|
||||||
.getDescription()
|
|
||||||
.getValue(defaultLocale)));
|
|
||||||
} else {
|
|
||||||
row.setDescription(shortenDescription(attachmentList
|
|
||||||
.getDescription()
|
|
||||||
.getValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AttachmentTableRow buildAttachmentTableRow(
|
|
||||||
final ItemAttachment<?> attachment,
|
|
||||||
final Locale selectedLocale) {
|
|
||||||
|
|
||||||
final AttachmentTableRow row = new AttachmentTableRow();
|
|
||||||
|
|
||||||
row.setAttachmentId(attachment.getAttachmentId());
|
|
||||||
if (attachment.getAsset().getTitle().hasValue(selectedLocale)) {
|
|
||||||
row.setTitle(attachment
|
|
||||||
.getAsset()
|
|
||||||
.getTitle()
|
|
||||||
.getValue(selectedLocale));
|
|
||||||
} else if (attachment.getAsset().getTitle().hasValue(defaultLocale)) {
|
|
||||||
row.setTitle(attachment
|
|
||||||
.getAsset()
|
|
||||||
.getTitle()
|
|
||||||
.getValue(defaultLocale));
|
|
||||||
} else {
|
|
||||||
row.setTitle(attachment
|
|
||||||
.getAsset()
|
|
||||||
.getTitle()
|
|
||||||
.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
row.setType(attachment.getAsset().getClass());
|
|
||||||
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String shortenDescription(final String description) {
|
|
||||||
|
|
||||||
if (description == null) {
|
|
||||||
return "";
|
|
||||||
} else if (description.trim().length() < 140) {
|
|
||||||
return description.trim();
|
|
||||||
} else {
|
|
||||||
final String tmp = description.trim().substring(0, 140);
|
|
||||||
|
|
||||||
return String
|
|
||||||
.format("%s...",
|
|
||||||
tmp.substring(0, tmp.lastIndexOf(" ")));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -18,10 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.contentsection;
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
import com.arsdigita.cms.ui.authoring.ItemCategoryStep;
|
|
||||||
import com.arsdigita.cms.ui.permissions.ItemPermissionsStep;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.relatedinfo.RelatedInfoStep;
|
|
||||||
import com.arsdigita.cms.ui.authoring.assets.images.ImageStep;
|
|
||||||
|
|
||||||
import org.libreccm.cdi.utils.CdiUtil;
|
import org.libreccm.cdi.utils.CdiUtil;
|
||||||
import org.libreccm.configuration.Configuration;
|
import org.libreccm.configuration.Configuration;
|
||||||
|
|
@ -119,19 +115,6 @@ public class ContentSectionConfig {
|
||||||
@Setting
|
@Setting
|
||||||
private int maxAlerts = 5;
|
private int maxAlerts = 5;
|
||||||
|
|
||||||
/**
|
|
||||||
* Assets steps which are added which are present on all content items.
|
|
||||||
*/
|
|
||||||
@Setting
|
|
||||||
private List<String> defaultAuthoringSteps = Arrays
|
|
||||||
.asList(
|
|
||||||
new String[]{
|
|
||||||
ItemCategoryStep.class.getName(),
|
|
||||||
ImageStep.class.getName(),
|
|
||||||
RelatedInfoStep.class.getName(),
|
|
||||||
ItemPermissionsStep.class.getName()
|
|
||||||
});
|
|
||||||
|
|
||||||
public static ContentSectionConfig getConfig() {
|
public static ContentSectionConfig getConfig() {
|
||||||
final ConfigurationManager confManager = CdiUtil.createCdiUtil()
|
final ConfigurationManager confManager = CdiUtil.createCdiUtil()
|
||||||
.findBean(ConfigurationManager.class);
|
.findBean(ConfigurationManager.class);
|
||||||
|
|
@ -182,13 +165,4 @@ public class ContentSectionConfig {
|
||||||
this.maxAlerts = maxAlerts;
|
this.maxAlerts = maxAlerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getDefaultAuthoringSteps() {
|
|
||||||
return new ArrayList<>(defaultAuthoringSteps);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultAuthoringSteps(
|
|
||||||
final List<String> defaultAuthoringSteps) {
|
|
||||||
this.defaultAuthoringSteps = new ArrayList<>(defaultAuthoringSteps);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public class ContentItemAuthoringStepManager {
|
||||||
|
|
||||||
final ContentSectionConfig config = confManager
|
final ContentSectionConfig config = confManager
|
||||||
.findConfiguration(ContentSectionConfig.class);
|
.findConfiguration(ContentSectionConfig.class);
|
||||||
final List<String> classNames = config.getDefaultAuthoringSteps();
|
final List<String> classNames = Collections.emptyList();
|
||||||
|
|
||||||
stepInfos = classNames
|
stepInfos = classNames
|
||||||
.stream()
|
.stream()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue