itemlinks in table lead to the actual item now.(see categories; change index item and order live objects)

git-svn-id: https://svn.libreccm.org/ccm/trunk@3895 8810af33-2d31-482b-a856-94f89814c4df
master
konermann 2016-02-25 10:46:33 +00:00
parent 1597b2c568
commit 3a57117a6a
3 changed files with 113 additions and 59 deletions

View File

@ -31,37 +31,35 @@ import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.io.IOException; import java.io.IOException;
/** /**
* This list offers the option for the code to provide the developer * This list offers the option for the code to provide the developer with links
* with links to sort the given categories. * to sort the given categories.
* *
* NOTE: This UI currently does not scale well with large numbers of items * NOTE: This UI currently does not scale well with large numbers of items since
* since it just lists all of them. It would probably be nice to integrate * it just lists all of them. It would probably be nice to integrate a paginator
* a paginator as well to as to allow the user to move an item in large * as well to as to allow the user to move an item in large distances and to
* distances and to insert an item in the middle. Right now, when you add * insert an item in the middle. Right now, when you add an item it is just
* an item it is just placed at the end. However, if you want the item to * placed at the end. However, if you want the item to appear in the middle then
* appear in the middle then you must hit the "up" arrow n/2 times where * you must hit the "up" arrow n/2 times where n is the number of items in the
* n is the number of items in the list. This clearly is not a good setup. * list. This clearly is not a good setup.
* *
* @author Randy Graebner (randyg@alum.mit.edu) * @author Randy Graebner (randyg@alum.mit.edu)
* @version $Id: SortableList.java 1618 2007-09-13 12:14:51Z chrisg23 $ * @version $Id: SortableList.java 1618 2007-09-13 12:14:51Z chrisg23 $
*/ */
public abstract class SortableList extends List { public abstract class SortableList extends List {
private static final org.apache.log4j.Logger s_log = private static final org.apache.log4j.Logger s_log
org.apache.log4j.Logger.getLogger(SortableList.class); = org.apache.log4j.Logger.getLogger(SortableList.class);
// It would be really nice if this used the save variable as is // It would be really nice if this used the save variable as is
// used by List but because List has it as private, we cannot do that. // used by List but because List has it as private, we cannot do that.
private static final String SELECT_EVENT = "s"; private static final String SELECT_EVENT = "s";
protected static final String PREV_EVENT = "prev"; protected static final String PREV_EVENT = "prev";
protected static final String NEXT_EVENT = "next"; protected static final String NEXT_EVENT = "next";
private boolean m_sortItems; public boolean m_sortItems;
/** /**
* This just makes a standard * This just makes a standard {@link SortableList}
* {@link SortableList}
*/ */
public SortableList(ParameterSingleSelectionModel model) { public SortableList(ParameterSingleSelectionModel model) {
this(model, false); this(model, false);
@ -71,9 +69,10 @@ public abstract class SortableList extends List {
super(model); super(model);
m_sortItems = !suppressSort; m_sortItems = !suppressSort;
} }
/** /**
* This geneates the XML as specified by the arguments pass in to * This geneates the XML as specified by the arguments pass in to the
* the constructor. * constructor.
*/ */
public void generateXML(PageState state, Element parent) { public void generateXML(PageState state, Element parent) {
if (!isVisible(state)) { if (!isVisible(state)) {
@ -90,8 +89,7 @@ public abstract class SortableList extends List {
// because m.next() returned true, we know there are items // because m.next() returned true, we know there are items
// in the list // in the list
Element list = parent.newChildElement Element list = parent.newChildElement("cms:sortableList", CMS.CMS_XML_NS);
("cms:sortableList", CMS.CMS_XML_NS);
exportAttributes(list); exportAttributes(list);
Component c; Component c;
@ -99,8 +97,7 @@ public abstract class SortableList extends List {
int i = 0; int i = 0;
boolean hasNext; boolean hasNext;
do { do {
Element item = list.newChildElement Element item = list.newChildElement(BebopConstants.BEBOP_CELL, BEBOP_XML_NS);
(BebopConstants.BEBOP_CELL, BEBOP_XML_NS);
if (m_sortItems) { if (m_sortItems) {
item.addAttribute("configure", "true"); item.addAttribute("configure", "true");
@ -110,15 +107,15 @@ public abstract class SortableList extends List {
// Converting both keys to String for comparison // Converting both keys to String for comparison
// since ListModel.getKey returns a String // since ListModel.getKey returns a String
boolean selected = (selKey != null) && boolean selected = (selKey != null)
key.equals(selKey.toString()); && key.equals(selKey.toString());
if ( selected ) { if (selected) {
item.addAttribute("selected", "selected"); item.addAttribute("selected", "selected");
} }
generateLabelXML(state, item, generateLabelXML(state, item,
new Label(m.getElement().toString()), key); new Label(m.getElement().toString()), key, m.getElement());
hasNext = m.next(); hasNext = m.next();
@ -138,8 +135,8 @@ public abstract class SortableList extends List {
} }
} catch (IOException ex) { } catch (IOException ex) {
throw new IllegalStateException("Caught IOException: " + throw new IllegalStateException("Caught IOException: "
ex.getMessage()); + ex.getMessage());
} }
i++; i++;
} while (hasNext); } while (hasNext);
@ -148,7 +145,7 @@ public abstract class SortableList extends List {
} }
protected void generateLabelXML(PageState state, Element parent, protected void generateLabelXML(PageState state, Element parent,
Label label, String key) { Label label, String key, Object element) {
state.setControlEvent(this, SELECT_EVENT, key); state.setControlEvent(this, SELECT_EVENT, key);
Component c = new ControlLink(label); Component c = new ControlLink(label);
c.generateXML(state, parent); c.generateXML(state, parent);

View File

@ -18,7 +18,9 @@
*/ */
package com.arsdigita.cms.ui.category; package com.arsdigita.cms.ui.category;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.List; import com.arsdigita.bebop.List;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.list.ListModel; import com.arsdigita.bebop.list.ListModel;
@ -26,11 +28,15 @@ import com.arsdigita.bebop.list.ListModelBuilder;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
import com.arsdigita.categorization.CategorizedCollection; import com.arsdigita.categorization.CategorizedCollection;
import com.arsdigita.cms.CMS; import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.dispatcher.ItemResolver;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.ACSObject;
import com.arsdigita.util.LockableImpl; import com.arsdigita.util.LockableImpl;
import com.arsdigita.xml.Element;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -40,7 +46,8 @@ import javax.servlet.ServletException;
* *
* @author Randy Graebner (randyg@redhat.com) * @author Randy Graebner (randyg@redhat.com)
* @version $Revision: #18 $ $DateTime: 2004/08/17 23:15:09 $ * @version $Revision: #18 $ $DateTime: 2004/08/17 23:15:09 $
* @version $Revision: #18 $Id: CategorizedObjectsList.java 2090 2010-04-17 08:04:14Z pboy $ * @version $Revision: #18 $Id: CategorizedObjectsList.java 2090 2010-04-17
* 08:04:14Z pboy $
*/ */
public class CategorizedObjectsList extends SortableCategoryList { public class CategorizedObjectsList extends SortableCategoryList {
@ -50,7 +57,6 @@ public class CategorizedObjectsList extends SortableCategoryList {
super(category); super(category);
setModelBuilder(new CategorizedObjectsModelBuilder()); setModelBuilder(new CategorizedObjectsModelBuilder());
Label label = new Label(GlobalizationUtil.globalize("cms.ui.category.item.none")); Label label = new Label(GlobalizationUtil.globalize("cms.ui.category.item.none"));
label.setFontWeight(Label.ITALIC); label.setFontWeight(Label.ITALIC);
setEmptyView(label); setEmptyView(label);
@ -118,6 +124,33 @@ public class CategorizedObjectsList extends SortableCategoryList {
return swapID; return swapID;
} }
@Override
protected void generateLabelXML(PageState state, Element parent, Label label, String key, Object element) {
SecurityManager securityManager = CMS.getSecurityManager(state);
ContentBundle item = (ContentBundle) element;
boolean canEdit = securityManager.canAccess(
state.getRequest(),
SecurityManager.EDIT_ITEM,
item);
if (canEdit) {
ContentSection section = item.getContentSection();
ItemResolver resolver = section.getItemResolver();
Link link = new Link(
item.getDisplayName(),
resolver.generateItemURL(
state,
((ContentBundle) item.getDraftVersion()).getPrimaryInstance(),
section,
((ContentBundle) item.getDraftVersion()).getPrimaryInstance().getVersion()));
Component c = link;
c.generateXML(state, parent);
}
}
private class CategorizedObjectsModelBuilder extends LockableImpl private class CategorizedObjectsModelBuilder extends LockableImpl
implements ListModelBuilder { implements ListModelBuilder {
@ -137,7 +170,8 @@ public class CategorizedObjectsList extends SortableCategoryList {
} }
/** /**
* A {@link ListModel} that iterates over categorized objects via an iterator * A {@link ListModel} that iterates over categorized objects via an
* iterator
*/ */
private static class CategorizedCollectionListModel implements ListModel { private static class CategorizedCollectionListModel implements ListModel {
@ -147,8 +181,10 @@ public class CategorizedObjectsList extends SortableCategoryList {
public CategorizedCollectionListModel(CategorizedCollection coll) { public CategorizedCollectionListModel(CategorizedCollection coll) {
m_objs = coll; m_objs = coll;
m_object = null; m_object = null;
} }
@Override
public boolean next() { public boolean next() {
if (m_objs.next()) { if (m_objs.next()) {
m_object = (ACSObject) m_objs.getDomainObject(); m_object = (ACSObject) m_objs.getDomainObject();
@ -158,10 +194,12 @@ public class CategorizedObjectsList extends SortableCategoryList {
} }
} }
@Override
public Object getElement() { public Object getElement() {
return m_object.getDisplayName(); return m_object;
} }
@Override
public String getKey() { public String getKey() {
return m_object.getID().toString(); return m_object.getID().toString();
} }

View File

@ -19,10 +19,12 @@
package com.arsdigita.cms.ui.category; package com.arsdigita.cms.ui.category;
import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.ColumnPanel;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.SaveCancelSection;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
@ -37,8 +39,11 @@ import com.arsdigita.bebop.parameters.ParameterData;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
import com.arsdigita.categorization.CategorizedCollection; import com.arsdigita.categorization.CategorizedCollection;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.dispatcher.ItemResolver;
import com.arsdigita.cms.ui.CMSForm; import com.arsdigita.cms.ui.CMSForm;
import com.arsdigita.cms.ui.FormSecurityListener; import com.arsdigita.cms.ui.FormSecurityListener;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
@ -49,16 +54,16 @@ import com.arsdigita.util.UncheckedWrapperException;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* Allows the user to select an index item to display when the * Allows the user to select an index item to display when the front end user is
* front end user is browsing by Category * browsing by Category
* *
* @author Randy Graebner (randyg@alum.mit.edu) * @author Randy Graebner (randyg@alum.mit.edu)
* @version $Revision: #18 $ $DateTime: 2004/08/17 23:15:09 $ * @version $Revision: #18 $ $DateTime: 2004/08/17 23:15:09 $
*/ */
public class IndexItemSelectionForm extends CMSForm { public class IndexItemSelectionForm extends CMSForm {
private static org.apache.log4j.Logger s_log = private static org.apache.log4j.Logger s_log
org.apache.log4j.Logger.getLogger( = org.apache.log4j.Logger.getLogger(
IndexItemSelectionForm.class); IndexItemSelectionForm.class);
private final CategoryRequestLocal m_category; private final CategoryRequestLocal m_category;
private RadioGroup m_options; private RadioGroup m_options;
@ -106,13 +111,27 @@ public class IndexItemSelectionForm extends CMSForm {
} }
while (children.next()) { while (children.next()) {
ACSObject item = ACSObject item
(ACSObject) children.getDomainObject(); = (ACSObject) children.getDomainObject();
if ((item instanceof ContentItem) && ((ContentItem) item).getVersion(). if ((item instanceof ContentItem) && ((ContentItem) item).getVersion().
equals(ContentItem.DRAFT)) { equals(ContentItem.DRAFT)) {
//create a link to the item:
ContentBundle bundleItem = (ContentBundle) item;
ContentSection section = bundleItem.getContentSection();
ItemResolver resolver = section.getItemResolver();
Link link = new Link(
bundleItem.getDisplayName(),
resolver.generateItemURL(state,
((ContentBundle) bundleItem.getDraftVersion()).getPrimaryInstance(),
section,
((ContentBundle) bundleItem.getDraftVersion()).getPrimaryInstance().getVersion()));
Component linkComponent = link;
//add the option with the link
group.addOption(new Option(item.getID().toString(), group.addOption(new Option(item.getID().toString(),
((ContentItem) item).getName())); linkComponent));
} }
} }
// get currently selected item // get currently selected item
@ -154,8 +173,8 @@ public class IndexItemSelectionForm extends CMSForm {
ParameterData param = data.getParameter(m_options.getParameterModel().getName()); ParameterData param = data.getParameter(m_options.getParameterModel().getName());
String selectedValue = (String) param.getValue(); String selectedValue = (String) param.getValue();
Category category = Category category
getCategory(event.getPageState()); = getCategory(event.getPageState());
ContentItem item = null; ContentItem item = null;
if (selectedValue != null) { if (selectedValue != null) {