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-94f89814c4dfmaster
parent
1597b2c568
commit
3a57117a6a
|
|
@ -31,37 +31,35 @@ import com.arsdigita.util.Assert;
|
|||
import com.arsdigita.xml.Element;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* This list offers the option for the code to provide the developer
|
||||
* with links to sort the given categories.
|
||||
* This list offers the option for the code to provide the developer with links
|
||||
* to sort the given categories.
|
||||
*
|
||||
* NOTE: This UI currently does not scale well with large numbers of items
|
||||
* since it just lists all of them. It would probably be nice to integrate
|
||||
* a paginator as well to as to allow the user to move an item in large
|
||||
* distances and to insert an item in the middle. Right now, when you add
|
||||
* an item it is just placed at the end. However, if you want the item to
|
||||
* appear in the middle then you must hit the "up" arrow n/2 times where
|
||||
* n is the number of items in the list. This clearly is not a good setup.
|
||||
* NOTE: This UI currently does not scale well with large numbers of items since
|
||||
* it just lists all of them. It would probably be nice to integrate a paginator
|
||||
* as well to as to allow the user to move an item in large distances and to
|
||||
* insert an item in the middle. Right now, when you add an item it is just
|
||||
* placed at the end. However, if you want the item to appear in the middle then
|
||||
* you must hit the "up" arrow n/2 times where n is the number of items in the
|
||||
* list. This clearly is not a good setup.
|
||||
*
|
||||
* @author Randy Graebner (randyg@alum.mit.edu)
|
||||
* @version $Id: SortableList.java 1618 2007-09-13 12:14:51Z chrisg23 $
|
||||
*/
|
||||
public abstract class SortableList extends List {
|
||||
|
||||
private static final org.apache.log4j.Logger s_log =
|
||||
org.apache.log4j.Logger.getLogger(SortableList.class);
|
||||
private static final org.apache.log4j.Logger s_log
|
||||
= org.apache.log4j.Logger.getLogger(SortableList.class);
|
||||
|
||||
// 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.
|
||||
private static final String SELECT_EVENT = "s";
|
||||
protected static final String PREV_EVENT = "prev";
|
||||
protected static final String NEXT_EVENT = "next";
|
||||
private boolean m_sortItems;
|
||||
public boolean m_sortItems;
|
||||
|
||||
/**
|
||||
* This just makes a standard
|
||||
* {@link SortableList}
|
||||
* This just makes a standard {@link SortableList}
|
||||
*/
|
||||
public SortableList(ParameterSingleSelectionModel model) {
|
||||
this(model, false);
|
||||
|
|
@ -71,9 +69,10 @@ public abstract class SortableList extends List {
|
|||
super(model);
|
||||
m_sortItems = !suppressSort;
|
||||
}
|
||||
|
||||
/**
|
||||
* This geneates the XML as specified by the arguments pass in to
|
||||
* the constructor.
|
||||
* This geneates the XML as specified by the arguments pass in to the
|
||||
* constructor.
|
||||
*/
|
||||
public void generateXML(PageState state, Element parent) {
|
||||
if (!isVisible(state)) {
|
||||
|
|
@ -90,8 +89,7 @@ public abstract class SortableList extends List {
|
|||
|
||||
// because m.next() returned true, we know there are items
|
||||
// in the list
|
||||
Element list = parent.newChildElement
|
||||
("cms:sortableList", CMS.CMS_XML_NS);
|
||||
Element list = parent.newChildElement("cms:sortableList", CMS.CMS_XML_NS);
|
||||
exportAttributes(list);
|
||||
|
||||
Component c;
|
||||
|
|
@ -99,8 +97,7 @@ public abstract class SortableList extends List {
|
|||
int i = 0;
|
||||
boolean hasNext;
|
||||
do {
|
||||
Element item = list.newChildElement
|
||||
(BebopConstants.BEBOP_CELL, BEBOP_XML_NS);
|
||||
Element item = list.newChildElement(BebopConstants.BEBOP_CELL, BEBOP_XML_NS);
|
||||
if (m_sortItems) {
|
||||
|
||||
item.addAttribute("configure", "true");
|
||||
|
|
@ -110,15 +107,15 @@ public abstract class SortableList extends List {
|
|||
|
||||
// Converting both keys to String for comparison
|
||||
// since ListModel.getKey returns a String
|
||||
boolean selected = (selKey != null) &&
|
||||
key.equals(selKey.toString());
|
||||
boolean selected = (selKey != null)
|
||||
&& key.equals(selKey.toString());
|
||||
|
||||
if ( selected ) {
|
||||
if (selected) {
|
||||
item.addAttribute("selected", "selected");
|
||||
}
|
||||
|
||||
generateLabelXML(state, item,
|
||||
new Label(m.getElement().toString()), key);
|
||||
new Label(m.getElement().toString()), key, m.getElement());
|
||||
|
||||
hasNext = m.next();
|
||||
|
||||
|
|
@ -138,8 +135,8 @@ public abstract class SortableList extends List {
|
|||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException("Caught IOException: " +
|
||||
ex.getMessage());
|
||||
throw new IllegalStateException("Caught IOException: "
|
||||
+ ex.getMessage());
|
||||
}
|
||||
i++;
|
||||
} while (hasNext);
|
||||
|
|
@ -148,7 +145,7 @@ public abstract class SortableList extends List {
|
|||
}
|
||||
|
||||
protected void generateLabelXML(PageState state, Element parent,
|
||||
Label label, String key) {
|
||||
Label label, String key, Object element) {
|
||||
state.setControlEvent(this, SELECT_EVENT, key);
|
||||
Component c = new ControlLink(label);
|
||||
c.generateXML(state, parent);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
*/
|
||||
package com.arsdigita.cms.ui.category;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.List;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
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.CategorizedCollection;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
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.kernel.ACSObject;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import javax.servlet.ServletException;
|
||||
|
|
@ -40,7 +46,8 @@ import javax.servlet.ServletException;
|
|||
*
|
||||
* @author Randy Graebner (randyg@redhat.com)
|
||||
* @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 {
|
||||
|
||||
|
|
@ -50,7 +57,6 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
super(category);
|
||||
|
||||
setModelBuilder(new CategorizedObjectsModelBuilder());
|
||||
|
||||
Label label = new Label(GlobalizationUtil.globalize("cms.ui.category.item.none"));
|
||||
label.setFontWeight(Label.ITALIC);
|
||||
setEmptyView(label);
|
||||
|
|
@ -118,6 +124,33 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
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
|
||||
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 {
|
||||
|
||||
|
|
@ -147,8 +181,10 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
public CategorizedCollectionListModel(CategorizedCollection coll) {
|
||||
m_objs = coll;
|
||||
m_object = null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean next() {
|
||||
if (m_objs.next()) {
|
||||
m_object = (ACSObject) m_objs.getDomainObject();
|
||||
|
|
@ -158,10 +194,12 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElement() {
|
||||
return m_object.getDisplayName();
|
||||
return m_object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return m_object.getID().toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,12 @@
|
|||
package com.arsdigita.cms.ui.category;
|
||||
|
||||
import com.arsdigita.bebop.ColumnPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
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.categorization.Category;
|
||||
import com.arsdigita.categorization.CategorizedCollection;
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.dispatcher.ItemResolver;
|
||||
import com.arsdigita.cms.ui.CMSForm;
|
||||
import com.arsdigita.cms.ui.FormSecurityListener;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
|
|
@ -49,16 +54,16 @@ import com.arsdigita.util.UncheckedWrapperException;
|
|||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Allows the user to select an index item to display when the
|
||||
* front end user is browsing by Category
|
||||
* Allows the user to select an index item to display when the front end user is
|
||||
* browsing by Category
|
||||
*
|
||||
* @author Randy Graebner (randyg@alum.mit.edu)
|
||||
* @version $Revision: #18 $ $DateTime: 2004/08/17 23:15:09 $
|
||||
*/
|
||||
public class IndexItemSelectionForm extends CMSForm {
|
||||
|
||||
private static org.apache.log4j.Logger s_log =
|
||||
org.apache.log4j.Logger.getLogger(
|
||||
private static org.apache.log4j.Logger s_log
|
||||
= org.apache.log4j.Logger.getLogger(
|
||||
IndexItemSelectionForm.class);
|
||||
private final CategoryRequestLocal m_category;
|
||||
private RadioGroup m_options;
|
||||
|
|
@ -106,13 +111,27 @@ public class IndexItemSelectionForm extends CMSForm {
|
|||
}
|
||||
|
||||
while (children.next()) {
|
||||
ACSObject item =
|
||||
(ACSObject) children.getDomainObject();
|
||||
ACSObject item
|
||||
= (ACSObject) children.getDomainObject();
|
||||
|
||||
if ((item instanceof ContentItem) && ((ContentItem) item).getVersion().
|
||||
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(),
|
||||
((ContentItem) item).getName()));
|
||||
linkComponent));
|
||||
}
|
||||
}
|
||||
// get currently selected item
|
||||
|
|
@ -154,8 +173,8 @@ public class IndexItemSelectionForm extends CMSForm {
|
|||
ParameterData param = data.getParameter(m_options.getParameterModel().getName());
|
||||
String selectedValue = (String) param.getValue();
|
||||
|
||||
Category category =
|
||||
getCategory(event.getPageState());
|
||||
Category category
|
||||
= getCategory(event.getPageState());
|
||||
|
||||
ContentItem item = null;
|
||||
if (selectedValue != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue