Kommentare und einige Aufräumarbeiten

git-svn-id: https://svn.libreccm.org/ccm/trunk@1791 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2012-07-31 05:42:30 +00:00
parent c4969bff47
commit b96f23ecba
13 changed files with 314 additions and 186 deletions

View File

@ -15,7 +15,7 @@ cms.contenttypes.ui.person.edit_basic_properties=Bearbeiten
cms.contenttypes.ui.person.surname=Nachname
cms.contenttypes.ui.person.givenname=Vorname
cms.contenttypes.ui.person.titlepre=Titel
cms.contenttypes.ui.person.titlepost=Namesanhang
cms.contenttypes.ui.person.titlepost=Namensanhang
cms.contenttypes.ui.person.birthdate=Geburtstag
cms.contenttypes.ui.person.description=Beschreibung

View File

@ -34,7 +34,6 @@ import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ImageAsset;
import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.Service;
import com.arsdigita.cms.ui.ImageComponent;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.mimetypes.MimeType;
@ -62,6 +61,7 @@ import org.apache.log4j.Logger;
* </code></pre></blockquote>
*
* @author Stanislav Freidin
* @author Sören Bernstein (quasimodo) <sbernstein@quasiweb.de>
* @version $Id: ImageBrowser.java 1940 2009-05-29 07:15:05Z terry $
*/
public class ImageBrowser extends Table {
@ -80,7 +80,7 @@ public class ImageBrowser extends Table {
private static final Logger s_log = Logger.getLogger(ImageBrowser.class);
/**
* Construct a new ImageBrowser
* Construct a new ImageBrowser with default mode.
*
* @param builder the {@link ImageBrowserModelBuilder} that will supply this
* component with its {@link ImageBrowserModel} during each request
@ -90,6 +90,13 @@ public class ImageBrowser extends Table {
this(b, ImageComponent.ATTACH_IMAGE);
}
/**
* Construct a new ImageBrowser with requested mode.
*
* @param builder the {@link ImageBrowserModelBuilder} that will supply this
* component with its {@link ImageBrowserModel} during each request
* @param mode the component mode (see {@link ImageComponent})
*/
public ImageBrowser(ImageBrowserModelBuilder b, int mode) {
super(new BuilderAdapter(b), HEADERS);
m_mode = mode;

View File

@ -1,6 +1,5 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*
*/
package com.arsdigita.cms.ui;
@ -11,11 +10,18 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.cms.ReusableImageAsset;
/**
*
* Interface for ImageCompnents.
*
* All components for image handling (like {@link ImageLibraryComponent} or
* {@link ImageUploadComponent}) should implement this interface.
*
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
public interface ImageComponent {
/**
* The modes
*/
public static final int DISPLAY_ONLY = 0;
public static final int SELECT_IMAGE = 1;
public static final int ATTACH_IMAGE = 2;

View File

@ -18,7 +18,13 @@ import java.util.Map;
import org.apache.log4j.Logger;
/**
*
* An abstract listener for {@link ImageComponent}.
*
* This listener provides the base implementation which is shared between all
* listeners of this kind.
*
* This listerner is used by {@link ImageSelectPage}.
*
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
public abstract class ImageComponentAbstractListener implements FormInitListener, FormProcessListener, FormSubmissionListener {
@ -39,6 +45,13 @@ public abstract class ImageComponentAbstractListener implements FormInitListener
}
}
/**
* Call {@link #cancelled(com.arsdigita.bebop.PageState)} if the cancel button
* was pressed.
*
* @param event the {@link FormSectionEvent}
* @throws FormProcessException
*/
public void submitted(FormSectionEvent event) throws FormProcessException {
PageState ps = event.getPageState();
ImageComponent component = getImageComponent(ps);
@ -48,6 +61,13 @@ public abstract class ImageComponentAbstractListener implements FormInitListener
}
}
/**
* Call {@link #processImage(com.arsdigita.bebop.event.FormSectionEvent, com.arsdigita.bebop.PageState, com.arsdigita.cms.ui.ImageComponent, com.arsdigita.cms.ReusableImageAsset) }
* if the save button was pressed.
*
* @param event the {@link FormSectionEvent}
* @throws FormProcessException
*/
public void process(FormSectionEvent event) throws FormProcessException {
PageState ps = event.getPageState();
ImageComponent component = getImageComponent(ps);
@ -62,8 +82,21 @@ public abstract class ImageComponentAbstractListener implements FormInitListener
}
/**
* To be overridden by child if neccessary.
*
* @param ps
*/
protected void cancelled(PageState ps) {};
/**
* Process the input.
*
* @param event the {@link FormSectionEvent}
* @param ps {@link PageState}
* @param component an {@link ImageComponent}
* @param image the {@link ReusableImageAsset}
*/
protected abstract void processImage(FormSectionEvent event, PageState ps, ImageComponent component, ReusableImageAsset image);
protected ImageComponent getImageComponent(PageState ps) {
@ -80,6 +113,12 @@ public abstract class ImageComponentAbstractListener implements FormInitListener
}
/**
* Sets the active component
*
* @param ps Page state
* @param activeKey the key of the active component
*/
protected void setImageComponent(PageState ps, final String activeKey) {
if (s_log.isDebugEnabled()) {

View File

@ -13,7 +13,10 @@ import com.arsdigita.cms.ReusableImageAsset;
import com.arsdigita.toolbox.ui.ComponentMap;
/**
*
* A listener to administer images.
*
* This listerner is used by {@link ImagesPane}.
*
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
class ImageComponentAdminListener extends ImageComponentAbstractListener implements ActionListener {

View File

@ -4,7 +4,6 @@
*/
package com.arsdigita.cms.ui;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.MapComponentSelectionModel;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent;
@ -12,15 +11,18 @@ import com.arsdigita.cms.ReusableImageAsset;
import org.apache.log4j.Logger;
/**
*
* A listener to select an image and save it for later use.
*
* This listerner is used by {@link ImageSelectPage}.
*
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
public class ImageComponentSelectListener extends ImageComponentAbstractListener {
private static final Logger S_LOG = Logger.getLogger(ImageComponentSelectListener.class);
private final ImageSelectResultPane m_resultPane;
private final ImageSelectResultComponent m_resultPane;
public ImageComponentSelectListener(MapComponentSelectionModel imageComponent, ImageSelectResultPane resultPane) {
public ImageComponentSelectListener(MapComponentSelectionModel imageComponent, ImageSelectResultComponent resultPane) {
super(imageComponent);
m_resultPane = resultPane;
}

View File

@ -25,7 +25,13 @@ import com.arsdigita.domain.DataObjectNotFoundException;
import java.math.BigDecimal;
/**
* An image library component.
*
* This component can be used in different places to add an image library
* in a convinient way. This class uses a listener class which should be extended
* from {@link ImageComponentAbstractListener}.
*
* @author unknown
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
public class ImageLibraryComponent extends SimpleContainer implements ImageComponent, Resettable {
@ -67,7 +73,7 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
try {
final ReusableImageAsset image = new ReusableImageAsset(imageID);
if(m_mode == ImageComponent.SELECT_IMAGE) {
parent.getResultPane().setResult(image.getDisplayName(), image.getID(), image.getWidth(), image.getHeight());
parent.getResultComponent().setResult(image);
}
m_imageModel.setSelectedObject(state, image);
} catch (DataObjectNotFoundException ex) {
@ -164,6 +170,11 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
return m_saveCancel;
}
/**
* Add a link to an {@link ImageUploadComponent}
*
* @param actionListener
*/
public void addUploadLink(final ActionListener actionListener) {
// Add action link to image upload component
if (m_mode != ImageComponent.DISPLAY_ONLY) {
@ -173,7 +184,9 @@ public class ImageLibraryComponent extends SimpleContainer implements ImageCompo
}
}
// Reset this component
/**
* Reset this component.
*/
public void reset(final PageState state) {
// clear selection
m_imageModel.clearSelection(state);

View File

@ -21,7 +21,11 @@ import java.util.HashMap;
import org.apache.log4j.Logger;
/**
*
* A {@link CMSPage} to select and upload images.
*
* This page is used by /web/templates/ccm-cms/content-section/admin/image_select.jsp
* which is used by the OpenCCM plugin for Xihna editor.
*
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
public class ImageSelectPage extends CMSPage {
@ -32,7 +36,7 @@ public class ImageSelectPage extends CMSPage {
private TabbedPane m_tabbedPane;
private ImageLibraryComponent m_imageLibrary;
private ImageUploadComponent m_imageUpload;
private ImageSelectResultPane m_resultPane;
private ImageSelectResultComponent m_result;
private BigDecimalParameter m_sectionId;
private final StringParameter m_imageComponentKey;
private final MapComponentSelectionModel m_imageComponent;
@ -56,7 +60,7 @@ public class ImageSelectPage extends CMSPage {
m_imageComponent =
new MapComponentSelectionModel(componentModel, new HashMap());
m_selectListener = new ImageComponentSelectListener(m_imageComponent, getResultPane());
m_selectListener = new ImageComponentSelectListener(m_imageComponent, getResultComponent());
m_tabbedPane = createTabbedPane();
m_tabbedPane.setIdAttr("page-body");
@ -77,11 +81,16 @@ public class ImageSelectPage extends CMSPage {
}
});
add(m_resultPane);
add(m_result);
addGlobalStateParam(m_imageComponentKey);
}
/**
* Create the image library pane
*
* @return m_imageLibrary
*/
protected ImageLibraryComponent getImageLibraryPane() {
if (m_imageLibrary == null) {
m_imageLibrary = new ImageLibraryComponent(ImageComponent.SELECT_IMAGE, this);
@ -92,6 +101,11 @@ public class ImageSelectPage extends CMSPage {
return m_imageLibrary;
}
/**
* Create the image upload pane
*
* @return m_imageUpload
*/
protected ImageUploadComponent getImageUploadPane() {
if (m_imageUpload == null) {
@ -103,13 +117,21 @@ public class ImageSelectPage extends CMSPage {
return m_imageUpload;
}
protected ImageSelectResultPane getResultPane() {
if (m_resultPane == null) {
m_resultPane = new ImageSelectResultPane();
/**
* Creates an {@link ImageSelectResultComponent}
*
* @return m_resultPane
*/
protected ImageSelectResultComponent getResultComponent() {
if (m_result == null) {
m_result = new ImageSelectResultComponent();
}
return m_resultPane;
return m_result;
}
/**
* Create the tabbed pane
*/
protected TabbedPane createTabbedPane() {
TabbedPane pane = new TabbedPane();
pane.setClassAttr(XSL_CLASS);

View File

@ -7,31 +7,33 @@ package com.arsdigita.cms.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Resettable;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.cms.ImageAsset;
import com.arsdigita.cms.Service;
import com.arsdigita.xml.Element;
import java.math.BigDecimal;
/**
*
* A component which will insert a javascript to the xml output with the
* image information for the OpenCCM plugin for Xinha editor.
*
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
public class ImageSelectResultPane extends SimpleContainer implements Resettable {
public class ImageSelectResultComponent extends SimpleContainer implements Resettable {
boolean m_valid = false;
String m_name;
BigDecimal m_id;
BigDecimal m_width;
BigDecimal m_height;
ImageAsset m_image;
public ImageSelectResultPane() {
public ImageSelectResultComponent() {
super();
}
public void setResult(final String name, final BigDecimal id, final BigDecimal width, final BigDecimal height) {
m_name = name;
m_id = id;
m_width = width;
m_height = height;
m_valid = true;
/**
* Save image imformation
*
* @param iamge an {@link ImageAsset}
*/
public void setResult(final ImageAsset image/*, final String name, final BigDecimal id, final BigDecimal width, final BigDecimal height*/) {
m_image = image;
m_valid = (m_image != null);
}
@Override
@ -48,17 +50,17 @@ public class ImageSelectResultPane extends SimpleContainer implements Resettable
script.append("if(button.id == \"save\" ) {");
script.append("window.opener.openCCM.imageSet({");
script.append(" src : \"/ccm/cms-service/stream/image/?image_id=");
script.append(m_id);
script.append(" src : \"");
script.append(Service.getImageURL(m_image));
script.append("\", ");
script.append(" name : \"");
script.append(m_name);
script.append(m_image.getDisplayName());
script.append("\", ");
script.append(" width : \"");
script.append(m_width);
script.append(m_image.getWidth());
script.append("\", ");
script.append(" height : \"");
script.append(m_height);
script.append(m_image.getHeight());
script.append("\"");
script.append("});");
script.append("}");
@ -71,11 +73,12 @@ public class ImageSelectResultPane extends SimpleContainer implements Resettable
scriptElem.setText(script.toString());
}
/**
* Reset this component.
*
* @param state Page state
*/
public void reset(PageState state) {
m_name = null;
m_id = null;
m_width = null;
m_height = null;
m_valid = false;
setResult(null);
}
}

View File

@ -21,7 +21,13 @@ import java.io.File;
import java.io.IOException;
/**
* An image upload component.
*
* This component can be used in different places to add image upload capabilities
* in a convinient way. This class uses a listener class which should be extended
* from {@link ImageComponentAbstractListener}.
*
* @author unknown
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
public class ImageUploadComponent extends Form implements ImageComponent {
@ -34,10 +40,18 @@ public class ImageUploadComponent extends Form implements ImageComponent {
private final SaveCancelSection m_saveCancel;
private int m_mode;
/**
* Creates an ImageUploadComponent in attach mode.
*/
public ImageUploadComponent() {
this(ImageComponent.ATTACH_IMAGE);
}
/**
* Creates an ImageUploadComponent with the selected mode.
*
* @param mode The operation mode (see {@link ImageComponent)
*/
public ImageUploadComponent(int mode) {
super("imageUploadComponent", new ColumnPanel(2));
m_mode = mode;

View File

@ -34,7 +34,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
/**
* A LayoutPanel to insert into ContentSectionPage or ImageSelectPage
* A {@link LayoutPanel} to insert into {@link ContentSectionPage}.
*
* @author Sören Bernstein (quasimodo) <sbernstein@zes.uni-bremen.de>
*/
@ -77,6 +77,7 @@ public class ImagesPane extends LayoutPanel implements Resettable {
final Map selectors = m_imageComponent.getComponentsMap();
m_adminListener = new ImageComponentAdminListener(m_imageComponent, this);
// Image library component
final ImageLibraryComponent library = new ImageLibraryComponent(ImageComponent.ADMIN_IMAGES);
library.getForm().addInitListener(m_adminListener);
library.getForm().addProcessListener(m_adminListener);
@ -86,6 +87,7 @@ public class ImagesPane extends LayoutPanel implements Resettable {
new Label(GlobalizationUtil.globalize("cms.ui.image_library")),
library));
// Image upload component
final ImageUploadComponent upload = new ImageUploadComponent(ImageComponent.ADMIN_IMAGES);
upload.getForm().addInitListener(m_adminListener);
upload.getForm().addSubmissionListener(m_adminListener);
@ -126,6 +128,11 @@ public class ImagesPane extends LayoutPanel implements Resettable {
page.addComponentStateParam(this, m_imageComponentKey);
}
/**
* Resets this pane and all its resettable components.
*
* @param state Page state
*/
@Override
public final void reset(final PageState state) {
super.reset(state);

View File

@ -75,20 +75,17 @@ import org.apache.log4j.Logger;
* @version $Id: CategoryItemPane.java 1967 2009-08-29 21:05:51Z pboy $
*/
class CategoryItemPane extends BaseItemPane {
private static final Logger s_log = Logger.getLogger
(CategoryItemPane.class);
private static final Logger s_log = Logger.getLogger(CategoryItemPane.class);
private final SingleSelectionModel m_model;
private final CategoryRequestLocal m_category;
private final SimpleContainer m_detailPane;
public CategoryItemPane(final SingleSelectionModel model,
final CategoryRequestLocal category,
final ActionLink addLink,
final ActionLink editLink,
final ActionLink deleteLink) {
final CategoryRequestLocal category,
final ActionLink addLink,
final ActionLink editLink,
final ActionLink deleteLink) {
m_model = model;
m_category = category;
@ -99,16 +96,15 @@ class CategoryItemPane extends BaseItemPane {
setDefault(m_detailPane);
final ActionLink orderItemsLink = new ActionLink(new Label(
gz("cms.ui.category.categorized_objects"))) {
gz("cms.ui.category.categorized_objects"))) {
@Override
public boolean isVisible(PageState state) {
// update for live items only
if (!super.isVisible(state)) {
return false;
}
CategorizedCollection items = m_category.getCategory
(state).getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
items.addEqualsFilter(ContentItem.VERSION,ContentItem.LIVE);
CategorizedCollection items = m_category.getCategory(state).getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
items.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE);
boolean canOrder = items.size() > 1;
items.close();
return canOrder;
@ -123,55 +119,53 @@ class CategoryItemPane extends BaseItemPane {
// Change index item
final ActionLink indexLink = new ActionLink(new Label(gz(
"cms.ui.category.change_index_item")));
"cms.ui.category.change_index_item")));
final Form indexForm = new IndexItemSelectionForm(m_category);
add(indexForm);
ViewItemLink viewIndexLink = new ViewItemLink(new Label(gz(
"cms.ui.category.view_index_item")),"");
"cms.ui.category.view_index_item")), "");
EditItemLink editIndexLink = new EditItemLink(new Label(gz(
"cms.ui.category.edit_index_item")),"");
"cms.ui.category.edit_index_item")), "");
// Summary
m_detailPane.add(new SummarySection(editLink, deleteLink, indexLink,
viewIndexLink, editIndexLink, orderItemsLink));
viewIndexLink, editIndexLink, orderItemsLink));
// Quasimodo: BEGIN
// Localizations
ActionLink addCategoryLocalizationLink = new ActionLink(new Label(gz(
"cms.ui.category.localization_add"))) {
"cms.ui.category.localization_add"))) {
@Override
public boolean isVisible(PageState state) {
// Only show addLanguage button, if there are langauges to add
int countSupportedLanguages = (
Kernel.getConfig()).getSupportedLanguagesTokenizer()
.countTokens();
long countLanguages =
int countSupportedLanguages = (Kernel.getConfig()).getSupportedLanguagesTokenizer()
.countTokens();
long countLanguages =
m_category.getCategory(state)
.getCategoryLocalizationCollection().size();
if(countLanguages < countSupportedLanguages) {
.getCategoryLocalizationCollection().size();
if (countLanguages < countSupportedLanguages) {
return true;
} else {
return false;
}
}
};
CategoryLocalizationAddForm addCategoryLocalizationForm =
new CategoryLocalizationAddForm(m_category);
new CategoryLocalizationAddForm(m_category);
m_detailPane.add(new CategoryLocalizationSection(addCategoryLocalizationLink));
add(addCategoryLocalizationForm);
connect(addCategoryLocalizationLink, addCategoryLocalizationForm);
connect(addCategoryLocalizationForm);
// Quasimodo: END
// Subcategories
m_detailPane.add(new SubcategorySection(addLink));
// Linked categories
final ActionLink linkAddLink = new ActionLink
(new Label(gz("cms.ui.category.linked_add")));
final ActionLink linkAddLink = new ActionLink(new Label(gz("cms.ui.category.linked_add")));
final Form linkForm = new LinkForm(m_category);
add(linkForm);
@ -196,6 +190,7 @@ class CategoryItemPane extends BaseItemPane {
}
private class EditVisible extends VisibilityComponent {
EditVisible(final Component child) {
super(child, null);
}
@ -207,6 +202,7 @@ class CategoryItemPane extends BaseItemPane {
}
private class AdminVisible extends VisibilityComponent {
AdminVisible(final Component child) {
super(child, null);
}
@ -220,9 +216,9 @@ class CategoryItemPane extends BaseItemPane {
private class SummarySection extends Section {
SummarySection(final ActionLink editLink,
final ActionLink deleteLink,
final ActionLink indexLink,
final ActionLink orderItemsLink) {
final ActionLink deleteLink,
final ActionLink indexLink,
final ActionLink orderItemsLink) {
setHeading(new Label(gz("cms.ui.category.details")));
final ActionGroup group = new ActionGroup();
@ -241,11 +237,11 @@ class CategoryItemPane extends BaseItemPane {
* the user to view and edit the content index item.
*/
SummarySection(final ActionLink editLink,
final ActionLink deleteLink,
final ActionLink indexLink,
final BaseLink viewIndexItem,
final BaseLink editIndexItem,
final ActionLink orderItemsLink) {
final ActionLink deleteLink,
final ActionLink indexLink,
final BaseLink viewIndexItem,
final BaseLink editIndexItem,
final ActionLink orderItemsLink) {
setHeading(new Label(gz("cms.ui.category.details")));
final ActionGroup group = new ActionGroup();
@ -262,6 +258,7 @@ class CategoryItemPane extends BaseItemPane {
}
private class Properties extends PropertyList {
@Override
protected final java.util.List properties(final PageState state) {
final java.util.List props = super.properties(state);
@ -272,20 +269,19 @@ class CategoryItemPane extends BaseItemPane {
if (item != null) {
itemTitle = item.getDisplayName();
} else if (!category.ignoreParentIndexItem()
&& category.getParentCategoryCount() > 0)
{
Category ancestor = findParentCategoryWithNonInheritedIndexItem(category);
if (ancestor != null) {
if (ancestor.getIndexObject() != null) {
itemTitle = ancestor.getIndexObject().getDisplayName();
}
itemTitle += " (Inherited from "
+ ancestor.getDisplayName() + ")";
} else {
// The complete hierarchy is set to inherit.
// Just leave the itemTitle as None.
}
} else if (!category.ignoreParentIndexItem()
&& category.getParentCategoryCount() > 0) {
Category ancestor = findParentCategoryWithNonInheritedIndexItem(category);
if (ancestor != null) {
if (ancestor.getIndexObject() != null) {
itemTitle = ancestor.getIndexObject().getDisplayName();
}
itemTitle += " (Inherited from "
+ ancestor.getDisplayName() + ")";
} else {
// The complete hierarchy is set to inherit.
// Just leave the itemTitle as None.
}
}
props.add(new Property(gz("cms.ui.name"),
@ -295,57 +291,67 @@ class CategoryItemPane extends BaseItemPane {
props.add(new Property(gz("cms.ui.category.url"),
category.getURL("")));
props.add(new Property(gz("cms.ui.category.is_not_abstract"),
category.isAbstract() ?
gz("cms.ui.no") :
gz("cms.ui.yes")));
category.isAbstract()
? gz("cms.ui.no")
: gz("cms.ui.yes")));
props.add(new Property(gz("cms.ui.category.is_enabled"),
category.isEnabled("") ?
gz("cms.ui.yes") :
gz("cms.ui.no")));
category.isEnabled("")
? gz("cms.ui.yes")
: gz("cms.ui.no")));
props.add(new Property(gz("cms.ui.category.index_item"),
itemTitle));
itemTitle));
return props;
}
}
}
// Loop over the parents and recurse up the hierarchy the find the first
// parent with an explicit index item ignoreParentIndexItem is true.
private Category findParentCategoryWithNonInheritedIndexItem(Category c) {
if (c.getParentCategoryCount() == 0) {
return null;
}
CategoryCollection parents = c.getParents();
while (parents.next()) {
Category p = parents.getCategory();
if (p.getDirectIndexObject() != null || p.ignoreParentIndexItem()) {
return p;
}
// Try the parents of this parent.
Category gp = findParentCategoryWithNonInheritedIndexItem(p);
if (gp != null) {
return gp;
}
}
return null;
if (c.getParentCategoryCount() == 0) {
return null;
}
CategoryCollection parents = c.getParents();
while (parents.next()) {
Category p = parents.getCategory();
if (p.getDirectIndexObject() != null || p.ignoreParentIndexItem()) {
return p;
}
// Try the parents of this parent.
Category gp = findParentCategoryWithNonInheritedIndexItem(p);
if (gp != null) {
return gp;
}
}
return null;
}
// Quasimodo: BEGIN
// CategoryLocalizationSection
private class CategoryLocalizationSection extends Section {
private CategoryLocalizationTable m_catLocalizationTable;
private CategoryLocalizationEditForm m_editCategoryLocalizationForm;
CategoryLocalizationSection(ActionLink addLink) {
setHeading(new Label(gz("cms.ui.category.localizations")));
final ActionGroup group = new ActionGroup();
setBody(group);
group.setSubject(new CategoryLocalizationTable(m_category, m_model));
m_catLocalizationTable = new CategoryLocalizationTable(m_category, m_model);
group.setSubject(m_catLocalizationTable);
group.addAction(new AdminVisible(addLink), ActionGroup.ADD);
m_editCategoryLocalizationForm = new CategoryLocalizationEditForm(m_category, "de");
connect(m_editCategoryLocalizationForm);
connect(m_catLocalizationTable, 0, m_editCategoryLocalizationForm);
}
}
private class SubcategorySection extends Section {
SubcategorySection(final ActionLink addLink) {
setHeading(new Label(gz("cms.ui.category.subcategories")));
@ -358,6 +364,7 @@ class CategoryItemPane extends BaseItemPane {
}
private class LinkedCategorySection extends Section {
LinkedCategorySection(final ActionLink linkAddLink) {
setHeading(new Label(gz("cms.ui.category.linked")));
@ -375,6 +382,7 @@ class CategoryItemPane extends BaseItemPane {
}
private class CategoryTemplateSection extends Section {
CategoryTemplateSection() {
setHeading(new Label(gz("cms.ui.category.templates")));
@ -388,6 +396,7 @@ class CategoryItemPane extends BaseItemPane {
}
private class PermissionsSection extends Section {
@Override
public boolean isVisible(PageState ps) {
Category cat = m_category.getCategory(ps);
@ -400,7 +409,7 @@ class CategoryItemPane extends BaseItemPane {
final ActionGroup group = new ActionGroup();
setBody(group);
PrivilegeDescriptor[] privs = new PrivilegeDescriptor[] {
PrivilegeDescriptor[] privs = new PrivilegeDescriptor[]{
PrivilegeDescriptor.EDIT,
Category.MAP_DESCRIPTOR,
PrivilegeDescriptor.DELETE,
@ -413,8 +422,7 @@ class CategoryItemPane extends BaseItemPane {
privMap.put(Category.MAP_DESCRIPTOR.getName(), "Categorize Items");
privMap.put("admin", "Admin");
final CMSPermissionsPane permPane = new CMSPermissionsPane
(privs, privMap, new ACSObjectSelectionModel(m_model)) {
final CMSPermissionsPane permPane = new CMSPermissionsPane(privs, privMap, new ACSObjectSelectionModel(m_model)) {
@Override
public void showAdmin(PageState ps) {
Assert.exists(m_model.getSelectedKey(ps));
@ -425,7 +433,7 @@ class CategoryItemPane extends BaseItemPane {
};
final ActionLink restoreDefault = new ActionLink(new Label(gz(
"cms.ui.restore_default_permissions"))) {
"cms.ui.restore_default_permissions"))) {
@Override
public boolean isVisible(PageState ps) {
Category cat = m_category.getCategory(ps);
@ -434,7 +442,7 @@ class CategoryItemPane extends BaseItemPane {
};
final ActionLink useCustom = new ActionLink(new Label(gz(
"cms.ui.use_custom_permissions"))) {
"cms.ui.use_custom_permissions"))) {
@Override
public boolean isVisible(PageState ps) {
Category cat = m_category.getCategory(ps);
@ -460,18 +468,18 @@ class CategoryItemPane extends BaseItemPane {
parent = cat.getDefaultParentCategory();
} catch (CategoryNotFoundException ce) {
throw new IllegalStateException(
"link shouldn't exist for root categories");
"link shouldn't exist for root categories");
}
PermissionService.setContext(cat, parent);
// revoke all direct permissions so category will only
// have inherited permissions
ObjectPermissionCollection perms =
PermissionService.getDirectGrantedPermissions(
PermissionService.getDirectGrantedPermissions(
cat.getOID());
while (perms.next()) {
PermissionService.revokePermission(
new PermissionDescriptor(
new PermissionDescriptor(
perms.getPrivilege(), cat.getOID(),
perms.getGranteeOID()));
}
@ -510,15 +518,15 @@ class CategoryItemPane extends BaseItemPane {
add(new Submit("Done"));
}
}
/*
* This private class creates a link to the index item for a category.
*/
private class ViewItemLink extends Link {
ViewItemLink(Component c, String s) {
super(c,s);
super(c, s);
}
// Build the preview link. This uses a standard redirect link to find
@ -526,10 +534,10 @@ class CategoryItemPane extends BaseItemPane {
@Override
protected String prepareURL(final PageState state, String location) {
ContentItem indexItem = ((ContentBundle)(m_category.getCategory(state)
.getDirectIndexObject()))
.getPrimaryInstance();
if(indexItem==null) {
ContentItem indexItem = ((ContentBundle) (m_category.getCategory(state)
.getDirectIndexObject()))
.getPrimaryInstance();
if (indexItem == null) {
return "";
} else {
return "/redirect/?oid=" + URLEncoder.encode(indexItem.getOID().toString());
@ -543,7 +551,7 @@ class CategoryItemPane extends BaseItemPane {
return false;
}
ACSObject indexItem = m_category.getCategory(state).getDirectIndexObject();
if(indexItem==null) {
if (indexItem == null) {
return false;
} else {
return true;
@ -552,36 +560,38 @@ class CategoryItemPane extends BaseItemPane {
};
private class EditItemLink extends Link {
EditItemLink(Component c, String s) {
super(c,s);
super(c, s);
}
/**
* Build the preview link. This is based on code in the
* ContentSoonExpiredPane class. The prepareURL method of the parent
* is overwritten. This method is called by the printwriter
* Build the preview link. This is based on code in the
* ContentSoonExpiredPane class. The prepareURL method of the parent is
* overwritten. This method is called by the printwriter
*/
@Override
protected String prepareURL(final PageState state, String location) {
boolean canEdit = false;
ContentItem indexItem = ((ContentBundle)(m_category.getCategory(state)
.getDirectIndexObject()))
.getPrimaryInstance();
if(indexItem==null) {
ContentItem indexItem = ((ContentBundle) (m_category.getCategory(state)
.getDirectIndexObject()))
.getPrimaryInstance();
if (indexItem == null) {
return "";
}
if (!isItemEditable(indexItem,state)) {
if (!isItemEditable(indexItem, state)) {
return "";
} else {
BigDecimal draftID = indexItem.getDraftVersion().getID();
return "item.jsp?item_id=" + draftID + "&set_tab=" +
ContentItemPage.AUTHORING_TAB;
return "item.jsp?item_id=" + draftID + "&set_tab="
+ ContentItemPage.AUTHORING_TAB;
}
}
/**
* We only show this link when an index item exists for this category
* and the user is allowed to edit this item.
*
* @param state
* @return
*/
@ -591,16 +601,16 @@ class CategoryItemPane extends BaseItemPane {
return false;
}
ACSObject indexItem = m_category.getCategory(state).getDirectIndexObject();
if(indexItem==null) {
if (indexItem == null) {
return false;
} else {
return isItemEditable((ContentItem)indexItem,state);
return isItemEditable((ContentItem) indexItem, state);
}
}
/**
* This method checks whether a usern is allowed to edit a
* particular item.
* This method checks whether a usern is allowed to edit a particular
* item.
*
* @param item
* @param state
@ -610,13 +620,13 @@ class CategoryItemPane extends BaseItemPane {
BigDecimal id = item.getID();
User user = Web.getContext().getUser();
ContentItem ci = new ContentItem(new OID(ContentItem.class.getName(),
Integer.parseInt(id.toString())));
Integer.parseInt(id.toString())));
Iterator permissions = PermissionService.getImpliedPrivileges(
ci.getOID(), user.getOID());
ci.getOID(), user.getOID());
while (permissions.hasNext()) {
PrivilegeDescriptor permission = (PrivilegeDescriptor)permissions.next();
if (permission.equals(PrivilegeDescriptor.ADMIN) ||
permission.equals(PrivilegeDescriptor.EDIT)) {
PrivilegeDescriptor permission = (PrivilegeDescriptor) permissions.next();
if (permission.equals(PrivilegeDescriptor.ADMIN)
|| permission.equals(PrivilegeDescriptor.EDIT)) {
return true;
}
}

View File

@ -27,6 +27,7 @@ import com.arsdigita.bebop.SingleSelectionModel;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.event.TableActionListener;
import com.arsdigita.bebop.table.DefaultTableCellRenderer;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
@ -49,8 +50,8 @@ import java.util.Locale;
/**
* Lists all existing localizations for a selected category.
*
* This class is part of the admin GUI of CCM and extends the standard form
* in order to present forms for managing the multi-language categories.
* This class is part of the admin GUI of CCM and extends the standard form in
* order to present forms for managing the multi-language categories.
*
* @author Sören Bernstein (quasimodo) quasi@zes.uni-bremen.de
*/
@ -75,7 +76,7 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
// if table is empty:
setEmptyView(new Label(GlobalizationUtil.globalize(
"cms.ui.category.localization_none")));
TableColumnModel tab_model = getColumnModel();
TableColumnModel tab_model = getColumnModel();
// define columns
// XXX globalize
@ -139,7 +140,7 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
/**
* Check collection for the existence of another row.
*
*
* If exists, fetch the value of current CategoryLocalization object
* into m_categoryLocalization class variable.
*/
@ -158,6 +159,7 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
/**
* Return the
*
* @see com.arsdigita.bebop.table.TableModel#getElementAt(int)
*/
public Object getElementAt(int columnIndex) {
@ -197,22 +199,22 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
boolean isSelected, Object key,
int row, int column) {
//
// if (canEdit) {
// CategoryLocalization cl;
//
// try {
// cl = new CategoryLocalization((BigDecimal) key);
// } catch (DataObjectNotFoundException ex) {
// return new Label(value.toString());
// }
//
// ContentSection section = CMS.getContext().getContentSection();
// ItemResolver resolver = section.getItemResolver();
//
// CategoryLocalization cl;
// try {
// cl = new CategoryLocalization((BigDecimal) key);
// } catch (DataObjectNotFoundException ex) {
// return new Label(value.toString());
// }
// ContentSection section = CMS.getContext().getContentSection();
// ItemResolver resolver = section.getItemResolver();
// return new Link(value.toString(), resolver.generateItemURL(state, cl, section, cl.getVersion()));
ControlLink link = new ControlLink(value.toString());
return link;
ControlLink link = new ControlLink(value.toString());
return link;
}
}
@ -230,9 +232,9 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
}
/**
* Provide implementation to TableActionListener method.
* Code that comes into picture when a link on the table is clicked.
* Handles edit and delete event.
* Provide implementation to TableActionListener method. Code that comes
* into picture when a link on the table is clicked. Handles edit and delete
* event.
*/
public void cellSelected(TableActionEvent evt) {
@ -260,8 +262,8 @@ public class CategoryLocalizationTable extends Table implements TableActionListe
}
/**
* provide Implementation to TableActionListener method.
* Does nothing in our case.
* provide Implementation to TableActionListener method. Does nothing in our
* case.
*/
public void headSelected(TableActionEvent e) {
throw new UnsupportedOperationException("Not Implemented");