Removed depcrecated package com/arsdigita/cms/ui from ccm-cms

pull/28/head
Jens Pelzetter 2022-03-16 19:54:09 +01:00
parent 980f958bae
commit 7e3b0821bb
4 changed files with 28 additions and 570 deletions

View File

@ -46,7 +46,6 @@ import com.arsdigita.cms.ui.item.CustomizedPreviewLink;
import com.arsdigita.cms.ui.item.ItemLanguages; import com.arsdigita.cms.ui.item.ItemLanguages;
import com.arsdigita.cms.ui.item.Summary; import com.arsdigita.cms.ui.item.Summary;
import com.arsdigita.cms.ui.lifecycle.ItemLifecycleAdminPane; import com.arsdigita.cms.ui.lifecycle.ItemLifecycleAdminPane;
import com.arsdigita.cms.ui.revision.ItemRevisionAdminPane;
import com.arsdigita.cms.ui.workflow.ItemWorkflowAdminPane; import com.arsdigita.cms.ui.workflow.ItemWorkflowAdminPane;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
@ -91,36 +90,45 @@ public class ContentItemPage extends CMSPage implements ActionListener {
*/ */
private static final Logger LOGGER = LogManager.getLogger( private static final Logger LOGGER = LogManager.getLogger(
ContentItemPage.class); ContentItemPage.class);
/** /**
* The URL parameter that must be passed in in order to set the current tab. * The URL parameter that must be passed in in order to set the current tab.
* This is a KLUDGE right now because the TabbedDialog's current tab is * This is a KLUDGE right now because the TabbedDialog's current tab is
* selected with a local state parameter * selected with a local state parameter
*/ */
public static final String SET_TAB = "set_tab"; public static final String SET_TAB = "set_tab";
/** /**
* The name of the global state parameter that holds the item id. * The name of the global state parameter that holds the item id.
*/ */
public static final String ITEM_ID = "item_id"; public static final String ITEM_ID = "item_id";
/** /**
* The name of th global state parameter that holds the selected language. * The name of th global state parameter that holds the selected language.
*/ */
public static final String SELECTED_LANGUAGE = "selected_language"; public static final String SELECTED_LANGUAGE = "selected_language";
/** /**
* The name of the global state parameter which holds the return URL. * The name of the global state parameter which holds the return URL.
*/ */
public static final String RETURN_URL = "return_url"; public static final String RETURN_URL = "return_url";
/** /**
* The name of the global state parameter that determines whether or not to * The name of the global state parameter that determines whether or not to
* use the streamlined authoring process (assuming the option is turned on). * use the streamlined authoring process (assuming the option is turned on).
* *
*/ */
public static final String STREAMLINED_CREATION = "streamlined_creation"; public static final String STREAMLINED_CREATION = "streamlined_creation";
public static final String STREAMLINED_CREATION_ACTIVE = "active"; public static final String STREAMLINED_CREATION_ACTIVE = "active";
public static final String STREAMLINED_CREATION_INACTIVE = "active"; public static final String STREAMLINED_CREATION_INACTIVE = "active";
/** /**
* Index of the summary tab * Index of the summary tab
*/ */
public static final int SUMMARY_TAB = 0; public static final int SUMMARY_TAB = 0;
/** /**
* <p> * <p>
* The name of the state parameter which indicates the content type of the * The name of the state parameter which indicates the content type of the
@ -131,26 +139,42 @@ public class ContentItemPage extends CMSPage implements ActionListener {
* content type.</p> * content type.</p>
*/ */
public static final String CONTENT_TYPE = "content_type"; public static final String CONTENT_TYPE = "content_type";
public static final int AUTHORING_TAB = 1; public static final int AUTHORING_TAB = 1;
public static final int LANGUAGE_TAB = 2; public static final int LANGUAGE_TAB = 2;
public static final int WORKFLOW_TAB = 3; public static final int WORKFLOW_TAB = 3;
public static final int PUBLISHING_TAB = 4; public static final int PUBLISHING_TAB = 4;
public static final int HISTORY_TAB = 5; public static final int HISTORY_TAB = 5;
public static final int TEMPLATES_TAB = 6; public static final int TEMPLATES_TAB = 6;
private final TabbedPane tabbedPane; private final TabbedPane tabbedPane;
private final StringParameter returnUrlParameter; private final StringParameter returnUrlParameter;
private final ItemSelectionModel itemSelectionModel; private final ItemSelectionModel itemSelectionModel;
// private final SingleSelectionModel<String> selectedLanguageModel; // private final SingleSelectionModel<String> selectedLanguageModel;
private final ACSObjectSelectionModel typeSelectionModel; private final ACSObjectSelectionModel typeSelectionModel;
private final ContentItemRequestLocal itemRequestLocal; private final ContentItemRequestLocal itemRequestLocal;
private final Summary summaryPane; private final Summary summaryPane;
private final ItemWorkflowAdminPane workflowPane; private final ItemWorkflowAdminPane workflowPane;
private final ItemLifecycleAdminPane lifecyclePane; private final ItemLifecycleAdminPane lifecyclePane;
private final WizardSelector wizardPane; private final WizardSelector wizardPane;
private final ItemLanguages languagesPane; private final ItemLanguages languagesPane;
private final ItemRevisionAdminPane revisionsPane;
private final Link previewLink; private final Link previewLink;
private final GlobalNavigation globalNavigation; private final GlobalNavigation globalNavigation;
private final StringParameter selectedLanguageParam; private final StringParameter selectedLanguageParam;
@ -263,18 +287,14 @@ public class ContentItemPage extends CMSPage implements ActionListener {
globalNavigation = new GlobalNavigation(); globalNavigation = new GlobalNavigation();
add(globalNavigation); add(globalNavigation);
// Create panels. // Create panels.
summaryPane = new Summary(itemSelectionModel); summaryPane = new Summary(itemSelectionModel);
wizardPane = new WizardSelector(itemSelectionModel, typeSelectionModel); wizardPane = new WizardSelector(itemSelectionModel, typeSelectionModel);
languagesPane = new ItemLanguages(itemSelectionModel, languagesPane = new ItemLanguages(itemSelectionModel,
// selectedLanguageModel, // selectedLanguageModel,
selectedLanguageParam); selectedLanguageParam);
workflowPane = new ItemWorkflowAdminPane(itemId); // Make this use m_item XXX workflowPane = new ItemWorkflowAdminPane(itemId); // Make this use m_item XXX
lifecyclePane = new ItemLifecycleAdminPane(itemRequestLocal); lifecyclePane = new ItemLifecycleAdminPane(itemRequestLocal);
revisionsPane = new ItemRevisionAdminPane(itemRequestLocal);
// templatesPane = new ItemTemplates(itemSelectionModel);
// Create tabbed pane. // Create tabbed pane.
tabbedPane = new TabbedPane(); tabbedPane = new TabbedPane();
@ -291,10 +311,6 @@ public class ContentItemPage extends CMSPage implements ActionListener {
workflowPane); workflowPane);
tabbedPane.addTab(new Label(gz("cms.ui.item.lifecycles")), tabbedPane.addTab(new Label(gz("cms.ui.item.lifecycles")),
lifecyclePane); lifecyclePane);
tabbedPane.addTab(new Label(gz("cms.ui.item.history")),
revisionsPane);
// tabbedPane.addTab(new Label(gz("cms.ui.item.templates")),
// templatesPane);
tabbedPane.addActionListener(new ActionListener() { tabbedPane.addActionListener(new ActionListener() {
@ -538,7 +554,7 @@ public class ContentItemPage extends CMSPage implements ActionListener {
*/ */
public static String getItemURL(final ContentItem item, public static String getItemURL(final ContentItem item,
final int tab) { final int tab) {
final ContentSection section = item.getContentType().getContentSection(); final ContentSection section = item.getContentType().getContentSection();
if (section == null) { if (section == null) {

View File

@ -1,361 +0,0 @@
/*
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.ui.revision;
import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.GridPanel;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.Text;
import com.arsdigita.bebop.event.TableActionAdapter;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.bebop.form.RadioGroup;
import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.table.DefaultTableCellRenderer;
import com.arsdigita.bebop.table.DefaultTableColumnModel;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection;
import com.arsdigita.cms.dispatcher.CMSDispatcher;
import com.arsdigita.cms.ui.BaseItemPane;
import com.arsdigita.cms.ui.item.ContentItemRequestLocal;
import com.arsdigita.toolbox.ui.ActionGroup;
import com.arsdigita.toolbox.ui.LayoutPanel;
import com.arsdigita.toolbox.ui.NullComponent;
import com.arsdigita.toolbox.ui.Section;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.contentsection.ContentItemRepository;
import org.librecms.contentsection.ContentSectionManager;
import org.librecms.dispatcher.ItemResolver;
import java.math.BigInteger;
/**
* Displays the revision history of a {@link ContentItem}
*
* @author unknown
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
*/
public final class ItemRevisionAdminPane extends BaseItemPane {
private final ContentItemRequestLocal itemRequestLocal;
private final RevisionTable revisionsTable;
private final RevisionRequestLocal fromRequestLocal;
private final RevisionRequestLocal toRequestLocal;
private final LayoutPanel selectPane;
//ToDo
//private final DifferencePane diffPane;
public ItemRevisionAdminPane(final ContentItemRequestLocal itemRequestLocal) {
this.itemRequestLocal = itemRequestLocal;
final RadioGroup fromSelect = new RadioGroup("from");
final RadioGroup toSelect = new RadioGroup("to");
fromRequestLocal = new SelectionRequestLocal(fromSelect);
toRequestLocal = new SelectionRequestLocal(toSelect);
revisionsTable = new RevisionTable(fromSelect, toSelect);
final RevisionForm form = new RevisionForm(fromSelect, toSelect,
revisionsTable);
selectPane = new LayoutPanel();
add(selectPane);
setDefault(selectPane);
selectPane.setBody(new Section(gz("cms.ui.item.revisions"), form));
final ActionLink returnLink = new ActionLink(new Label(gz(
"cms.ui.item.revision.return")));
// Todo
// diffPane = new DifferencePane(itemRequestLocal,
// fromRequestLocal,
// toRequestLocal,
// returnLink);
// add(diffPane);
//
// connect(form, diffPane);
connect(returnLink, selectPane);
}
private class SelectionRequestLocal extends RevisionRequestLocal {
private final RadioGroup group;
SelectionRequestLocal(final RadioGroup group) {
this.group = group;
}
@Override
protected final Object initialValue(final PageState state) {
final Object selected = group.getValue(state);
if (selected == null || selected.toString().equals("")) {
return null;
} else {
final long revisionNumber = Long.parseLong(selected.toString());
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
final ContentItemRepository itemRepository = cdiUtil.findBean(
ContentItemRepository.class);
return itemRepository.retrieveRevision(revisionNumber);
}
}
}
private class RevisionForm extends Form {
RevisionForm(final RadioGroup fromSelect,
final RadioGroup toSelect,
final RevisionTable revisions) {
super("revisions", new GridPanel(1));
setMethod("get");
add(fromSelect);
add(toSelect);
// Sets the 'to' revision to the dummy current revision
// and the 'from' revision to the dummy root revision.
fromSelect.setOptionSelected("");
toSelect.setOptionSelected("");
final ActionGroup group = new ActionGroup();
add(group);
group.setSubject(revisions);
group.addAction(new Submit("diff",
gz("cms.ui.item.revision.difference.show")));
}
}
private class RevisionTable extends Table {
// XXX Need to fix the static l18n stuff
private final TableColumn fromCol = new TableColumn(
RevisionTableModelBuilder.FROM, lz("cms.ui.item.revision.from"));
private final TableColumn toCol = new TableColumn(
RevisionTableModelBuilder.TO,
lz("cms.ui.item.revision.to"));
private final TableColumn timestampCol = new TableColumn(
RevisionTableModelBuilder.TIMESTAMP, lz("cms.ui.item.revision"));
private final TableColumn userCol = new TableColumn(
RevisionTableModelBuilder.USER, lz("cms.ui.user"));
private final TableColumn descriptionCol = new TableColumn(
RevisionTableModelBuilder.DESCRIPTION, lz("cms.ui.description"));
private final TableColumn previewCol = new TableColumn(
RevisionTableModelBuilder.PREVIEW, lz("cms.ui.item.revision.view"));
private final TableColumn rollbackCol = new TableColumn(
RevisionTableModelBuilder.ROLLBACK,
lz("cms.ui.item.revision.rollback"));
public RevisionTable(final RadioGroup fromSelect,
final RadioGroup toSelect) {
super(new RevisionTableModelBuilder(itemRequestLocal),
new DefaultTableColumnModel());
final TableColumnModel columns = getColumnModel();
columns.add(fromCol);
columns.add(toCol);
columns.add(timestampCol);
columns.add(userCol);
columns.add(descriptionCol);
columns.add(previewCol);
columns.add(rollbackCol);
fromCol.setCellRenderer(new RadioCellRenderer(fromSelect));
toCol.setCellRenderer(new RadioCellRenderer(toSelect));
timestampCol.setCellRenderer(new DefaultTableCellRenderer(false));
userCol.setCellRenderer(new DefaultTableCellRenderer(false));
descriptionCol.setCellRenderer(new DefaultTableCellRenderer(false));
previewCol.setCellRenderer(new ViewCellRenderer());
rollbackCol.setCellRenderer(new RollbackCellRenderer());
setEmptyView(new Label(gz("cms.ui.item.revision.none")));
addTableActionListener(new RollbackActionListener());
}
class RadioCellRenderer implements TableCellRenderer {
private final RadioGroup group;
RadioCellRenderer(final RadioGroup group) {
this.group = group;
}
@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) {
switch (key.toString()) {
case "first":
if (column == RevisionTableModelBuilder.FROM) {
return new NullComponent();
} else {
final Option option = new Option("", new Text(""));
option.setGroup(group);
return option;
}
case "last":
if (column == RevisionTableModelBuilder.FROM) {
final Option option = new Option("", "");
option.setGroup(group);
return option;
} else {
return new NullComponent();
}
default:
final Option option = new Option(key.toString(),
new Text(""));
option.setGroup(group);
return option;
}
}
}
class ViewCellRenderer 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) {
if (key instanceof String) {
return new NullComponent();
} else {
final BigInteger transID = (BigInteger) key;
final ContentItem item = itemRequestLocal.getContentItem(
state);
final ContentSection section = item.getContentType()
.getContentSection();
final ContentSectionManager sectionManager = CdiUtil
.createCdiUtil().findBean(ContentSectionManager.class);
final ItemResolver itemResolver = sectionManager
.getItemResolver(section);
final StringBuffer url = new StringBuffer(itemResolver
.generateItemURL(state, item, section,
CMSDispatcher.PREVIEW));
// Cheesy code should be fixed
final String sep;
if (url.toString().indexOf('?') == -1) {
sep = "?";
} else {
sep = "&";
}
// TODO: fix this
//url.append(sep).append
// (HistoryCollection.TRANS_ID).append("=");
url.append(sep).append("transID").append("=");
url.append(transID.toString());
final Link link = new Link(new Label(gz(
"cms.ui.item.revision.view")),
url.toString());
link.setTargetFrame(lz("cms.ui.item.revision.view"));
return link;
}
}
}
class RollbackActionListener extends TableActionAdapter {
@Override
public final void cellSelected(final TableActionEvent event) {
final PageState state = event.getPageState();
if (event.getColumn() == RevisionTableModelBuilder.ROLLBACK) {
final ContentItem item = itemRequestLocal.getContentItem(
state);
//Rollback not supported yet
// Versions.rollback(item.getOID(),
// new BigInteger(event.getRowKey()
// .toString()));
//
// item.applyTag(lz("cms.ui.item.revision.rolled_back"));
}
}
}
class RollbackCellRenderer 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) {
if (key instanceof String) {
return new NullComponent();
} else {
return new ControlLink(new Label(gz(
"cms.ui.item.revision.rollback")));
}
}
}
}
}

View File

@ -1,33 +0,0 @@
/*
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.ui.revision;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal;
import org.libreccm.auditing.CcmRevision;
public abstract class RevisionRequestLocal extends RequestLocal {
public final CcmRevision getRevision(final PageState state) {
final CcmRevision revision = (CcmRevision) get(state);
return revision;
}
}

View File

@ -1,164 +0,0 @@
/*
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.ui.revision;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.table.AbstractTableModelBuilder;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.cms.ui.item.ContentItemRequestLocal;
import com.arsdigita.globalization.GlobalizedMessage;
import org.libreccm.security.User;
import com.arsdigita.toolbox.ui.FormatStandards;
import org.libreccm.auditing.CcmRevision;
import org.libreccm.cdi.utils.CdiUtil;
import org.librecms.CmsConstants;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemRepository;
import java.util.List;
/**
* @author Stanislav Freidin &lt;sfreidin@redhat.com&gt;
* @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: RevisionTableModelBuilder.java 1942 2009-05-29 07:53:23Z terry
* $
*/
class RevisionTableModelBuilder extends AbstractTableModelBuilder {
static final int FROM = 0;
static final int TO = 1;
static final int TIMESTAMP = 2;
static final int USER = 3;
static final int DESCRIPTION = 4;
static final int PREVIEW = 5;
static final int ROLLBACK = 6;
static final int COLUMNS = 7;
private final ContentItemRequestLocal itemRequestLocal;
RevisionTableModelBuilder(final ContentItemRequestLocal itemRequestLocal) {
this.itemRequestLocal = itemRequestLocal;
}
@Override
public final TableModel makeModel(final Table table,
final PageState state) {
return new Model(itemRequestLocal.getContentItem(state));
}
private static class Model implements TableModel {
private final List<CcmRevision> revisions;
private CcmRevision currentRevision;
private long count = 0;
private long last = 2;
private int index = -1;
public Model(final ContentItem item) {
final ContentItemRepository itemRepository = CdiUtil
.createCdiUtil()
.findBean(ContentItemRepository.class);
revisions = itemRepository.retrieveRevisions(item,
item.getObjectId());
last = revisions.size() + 2;
}
@Override
public final int getColumnCount() {
return COLUMNS;
}
@Override
public final boolean nextRow() {
count++;
index++;
if (count == 1) {
return true;
} else if (count == last) {
return true;
} else if (revisions.size() < index) {
currentRevision = revisions.get(index);
return true;
} else {
return false;
}
}
@Override
public final Object getElementAt(final int column) {
if (count == 1) {
switch (column) {
case TIMESTAMP:
return lz("cms.ui.item.revision.current");
default:
return "";
}
} else if (count == last) {
switch (column) {
case TIMESTAMP:
return lz("cms.ui.item.revision.first");
default:
return "";
}
} else {
switch (column) {
case TIMESTAMP:
return FormatStandards.formatDateTime(
currentRevision.getRevisionDate());
case USER:
return currentRevision.getUserName();
case DESCRIPTION:
return "";
default:
return "";
}
}
}
@Override
public final Object getKeyAt(final int column) {
if (count == 1) {
return "first";
} else if (count == last) {
return "last";
} else {
return currentRevision.getId();
}
}
}
private static GlobalizedMessage gz(final String key) {
return new GlobalizedMessage(key, CmsConstants.CMS_BUNDLE);
}
private static String lz(final String key) {
return (String) gz(key).localize();
}
}