diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicItemForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicItemForm.java
index 312561c58..8ed8c3a9a 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicItemForm.java
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/authoring/BasicItemForm.java
@@ -50,9 +50,9 @@ import org.librecms.CmsConstants;
* @author Stanislav Freidin
*/
public abstract class BasicItemForm extends FormSection
- implements FormInitListener,
- FormProcessListener,
- FormValidationListener {
+ implements FormInitListener,
+ FormProcessListener,
+ FormValidationListener {
/**
* Internal logger instance to faciliate debugging. Enable logging output by
@@ -74,9 +74,9 @@ public abstract class BasicItemForm extends FormSection
* Construct a new BasicItemForm with 2 ColumnPanels and add basic content.
* The left Panel is used for Labels, the right Panel for values.
*
- * @param formName the name of this form
+ * @param formName the name of this form
* @param itemModel The {@link ItemSelectionModel} which will be responsible
- * for loading the current item
+ * for loading the current item
*/
public BasicItemForm(String formName, ItemSelectionModel itemModel) {
@@ -111,10 +111,10 @@ public abstract class BasicItemForm extends FormSection
* Construct a new BasicItemForm with a specified number of ColumnPanels and
* without any content.
*
- * @param formName the name of this form
+ * @param formName the name of this form
* @param columnPanel the columnpanel of the form
- * @param itemModel The {@link ItemSelectionModel} which will be responsible
- * for loading the current item
+ * @param itemModel The {@link ItemSelectionModel} which will be
+ * responsible for loading the current item
*/
public BasicItemForm(String formName,
ColumnPanel columnPanel,
@@ -122,7 +122,7 @@ public abstract class BasicItemForm extends FormSection
super(columnPanel);
m_widgetSection = new FormSection(new ColumnPanel(columnPanel.
- getNumCols(),
+ getNumCols(),
true));
super.add(m_widgetSection, ColumnPanel.INSERT);
m_itemModel = itemModel;
@@ -133,17 +133,16 @@ public abstract class BasicItemForm extends FormSection
*/
public void addSaveCancelSection() {
m_saveCancelSection = new SaveCancelSection();
- super.
- add(m_saveCancelSection, ColumnPanel.FULL_WIDTH
- | ColumnPanel.LEFT);
+ super.add(m_saveCancelSection,
+ ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
}
/**
* Currently, to insert javascript code the Label Widget is "abused".
*/
private final Label m_script = new Label(String.format(
- "",
- Web.getWebappContextPath()),
+ "",
+ Web.getWebappContextPath()),
false);
/**
@@ -172,16 +171,16 @@ public abstract class BasicItemForm extends FormSection
// it breaks URLs & potentially overwrites the user's
// customizations.
final TextField titleWidget = new TextField(new TrimmedStringParameter(
- TITLE));
+ TITLE));
titleWidget.setLabel(getTitleLabel());
titleWidget.setHint(getTitleHint());
titleWidget.addValidationListener(new NotNullValidationListener());
titleWidget.setOnFocus("if (this.form." + NAME + ".value == '') { "
- + " defaulting = true; this.form." + NAME
- + ".value = urlize(this.value); }");
+ + " defaulting = true; this.form." + NAME
+ + ".value = urlize(this.value); }");
titleWidget.setOnKeyUp(
- "if (defaulting) { this.form." + NAME
- + ".value = urlize(this.value) }");
+ "if (defaulting) { this.form." + NAME
+ + ".value = urlize(this.value) }");
add(titleWidget);
// For some content types it may be useful to change the label of
@@ -190,7 +189,7 @@ public abstract class BasicItemForm extends FormSection
// (jensp 2011-01-28)
// add(new Label(getNameLabel()));
final TextField nameWidget = new TextField(new TrimmedStringParameter(
- NAME));
+ NAME));
nameWidget.setLabel(getNameLabel());
nameWidget.setHint(getNameHint());
// We just check parameter specific properties here! Additionally,
@@ -202,11 +201,11 @@ public abstract class BasicItemForm extends FormSection
nameWidget.setMaxLength(190);
nameWidget.setOnFocus("defaulting = false");
nameWidget.setOnBlur(
- "if (this.value == '') "
- + "{ defaulting = true; this.value = urlize(this.form."
- + TITLE
- + ".value) } "
- + " else { this.value = urlize(this.value); }");
+ "if (this.value == '') "
+ + "{ defaulting = true; this.value = urlize(this.form."
+ + TITLE
+ + ".value) } "
+ + " else { this.value = urlize(this.value); }");
add(nameWidget);
}
@@ -236,6 +235,7 @@ public abstract class BasicItemForm extends FormSection
* pre-fill the widgets with data, instantiate the content item, etc.
*
* @param e
+ *
* @throws FormProcessException
*/
@Override
@@ -246,6 +246,7 @@ public abstract class BasicItemForm extends FormSection
* user's changes to the database.
*
* @param e
+ *
* @throws FormProcessException
*/
@Override
@@ -256,6 +257,7 @@ public abstract class BasicItemForm extends FormSection
* context form validation, specifically name (url) uniqueness in a folder!
*
* @param e
+ *
* @throws com.arsdigita.bebop.FormProcessException
*/
@Override
@@ -279,9 +281,9 @@ public abstract class BasicItemForm extends FormSection
* Layout constraints are defined in each layout container as static ints.
* Use a bitwise OR to specify multiple constraints.
*
- * @param pc the component to add to this container
+ * @param pc the component to add to this container
* @param constraints layout constraints (a bitwise OR of static ints in the
- * particular layout)
+ * particular layout)
*/
@Override
public void add(Component pc, int constraints) {
@@ -326,7 +328,7 @@ public abstract class BasicItemForm extends FormSection
}
/**
- * Provides the text for the unser hint providing some detailed information
+ * Provides the text for the user hint providing some detailed information
* how to use this widget. This method can be overwritten to adjust the text
* for some content types. {@link #getNameLabel()}
*
@@ -347,8 +349,8 @@ public abstract class BasicItemForm extends FormSection
* form should call this method in the validation listener.
*
* @param parent the folder in which to check
- * @param event the {@link FormSectionEvent} which was passed to the
- * validation listener
+ * @param event the {@link FormSectionEvent} which was passed to the
+ * validation listener
*/
// public void validateNameUniqueness(Category parent, FormSectionEvent event) {
//
@@ -417,27 +419,38 @@ public abstract class BasicItemForm extends FormSection
* only be called from the validation listener of an "edit" form.
*
* @param event the {@link FormSectionEvent} which was passed to the
- * validation listener
- * @param id The id of the item that is being checked. This must no be null.
+ * validation listener
+ * @param id The id of the item that is being checked. This must no be
+ * null.
+ *
* @return
*
* @throws FormProcessException if the folder already contains an item with
- * the name the user provided on the input form. / public void
- * validateNameUniquenessWithinCategory(FormSectionEvent event, BigDecimal
- * id) throws FormProcessException { if (id == null) { s_log.warn("Trying to
- * validation the name uniqueness without " + " a valid item is invalid.
- * This method should only " + " be called in \"edit\" forms. The passed in
- * id " + " was null."); return; } // now we check to make sure that the new
- * name is valid // within every category that the item is mapped to // this
- * is only necessary for category browsing FormData data =
- * event.getFormData(); String url = (String) data.get(NAME); if (url ==
- * null) { return; } DataQuery query =
- * SessionManager.getSession().retrieveQuery(
- * "com.arsdigita.categorization.getAllItemURLsForCategoryFromItem");
- * query.setParameter("itemID", id); query.addEqualsFilter("lower(url)",
- * url.toLowerCase()); if (query.size() > 0) { // we need to make sure that
- * the conflicting item is not a // pending or live version of the same item
- * BigDecimal itemID = null;
+ * the name the user provided on the input
+ * form. / public void
+ * validateNameUniquenessWithinCategory(FormSectionEvent
+ * event, BigDecimal id) throws
+ * FormProcessException { if (id == null) {
+ * s_log.warn("Trying to validation the name
+ * uniqueness without " + " a valid item is
+ * invalid. This method should only " + " be
+ * called in \"edit\" forms. The passed in id "
+ * + " was null."); return; } // now we check
+ * to make sure that the new name is valid //
+ * within every category that the item is
+ * mapped to // this is only necessary for
+ * category browsing FormData data =
+ * event.getFormData(); String url = (String)
+ * data.get(NAME); if (url == null) { return; }
+ * DataQuery query =
+ * SessionManager.getSession().retrieveQuery(
+ * "com.arsdigita.categorization.getAllItemURLsForCategoryFromItem");
+ * query.setParameter("itemID", id);
+ * query.addEqualsFilter("lower(url)",
+ * url.toLowerCase()); if (query.size() > 0) {
+ * // we need to make sure that the conflicting
+ * item is not a // pending or live version of
+ * the same item BigDecimal itemID = null;
*
* ContentItem item = (ContentItem)getItemSelectionModel()
* .getSelectedObject(event.getPageState()); Collection list =
@@ -456,6 +469,7 @@ public abstract class BasicItemForm extends FormSection
* Helper Method for name uniqueness validation.
*
* @param item
+ *
* @return
*/
// public static Collection getAllVersionIDs(ContentItem item) {
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderCreator.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderCreator.java
new file mode 100755
index 000000000..29c8db7ba
--- /dev/null
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderCreator.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2001-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.folder;
+
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.cms.ItemSelectionModel;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.libreccm.categorization.Category;
+
+import java.math.BigDecimal;
+
+public class FolderCreator extends FolderForm {
+
+ private static Logger LOGGER = LogManager.getLogger(FolderCreator.class);
+
+ public FolderCreator(final String name, final FolderSelectionModel parent) {
+ super(name, parent);
+ }
+
+ @Override
+ public void init(final FormSectionEvent event) throws FormProcessException {
+ final PageState state = event.getPageState();
+ final FolderSelectionModel model = getFolderSelectionModel();
+
+ // Create a new item_id and set it as the key
+ model.setSelectedKey(state, -1L);
+ }
+
+ @Override
+ public void process(final FormSectionEvent event)
+ throws FormProcessException {
+
+ final PageState state = event.getPageState();
+ final FormData data = event.getFormData();
+ final FolderSelectionModel model = getFolderSelectionModel();
+ final long id = model.getSelectedKey(state);
+ final Category parent = getCurrentFolder(state);
+
+ final Category child = new Category();
+
+ updateFolder(child,
+ parent,
+ data.getString(NAME),
+ data.getString(TITLE));
+ }
+
+}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderCreator.java.off b/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderCreator.java.off
deleted file mode 100755
index bfb1ad53b..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderCreator.java.off
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2001-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.folder;
-
-import com.arsdigita.bebop.FormData;
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.cms.Folder;
-import com.arsdigita.cms.ItemSelectionModel;
-import com.arsdigita.cms.util.GlobalizationUtil;
-import com.arsdigita.db.Sequences;
-import com.arsdigita.domain.DataObjectNotFoundException;
-import com.arsdigita.persistence.OID;
-import com.arsdigita.persistence.SessionManager;
-import org.apache.log4j.Logger;
-
-import java.math.BigDecimal;
-
-public class FolderCreator extends FolderForm {
-
- private static Logger s_log =
- Logger.getLogger(FolderCreator.class.getName());
-
-
- public FolderCreator(String name, FolderSelectionModel parent) {
- super(name, parent);
- }
-
- public void init(FormSectionEvent e) throws FormProcessException {
- PageState state = e.getPageState();
- ItemSelectionModel m = getItemSelectionModel();
-
- // Create a new item_id and set it as the key
- try {
- m.setSelectedKey(state, Sequences.getNextValue());
- } catch (java.sql.SQLException ex) {
- s_log.error("Error retrieving sequence.nextval", ex);
- throw new FormProcessException(ex);
- }
- }
-
-
- public void process(FormSectionEvent e) throws FormProcessException {
- PageState s = e.getPageState();
- FormData data = e.getFormData();
- ItemSelectionModel m = getItemSelectionModel();
- BigDecimal id = (BigDecimal) m.getSelectedKey(s);
- Folder parent = getCurrentFolder(s);
-
- Folder child = null;
- try {
- child = new Folder(id);
- } catch (DataObjectNotFoundException ex) {
- child = new Folder(SessionManager.getSession().create
- (new OID(Folder.BASE_DATA_OBJECT_TYPE, id)));
- }
-
- updateFolder(child, parent, (String)data.get(NAME), (String)data.get(TITLE));
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderEditor.java.off b/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderEditor.java
similarity index 87%
rename from ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderEditor.java.off
rename to ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderEditor.java
index 3cb3a48c5..7b11cd4fd 100755
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderEditor.java.off
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderEditor.java
@@ -29,10 +29,9 @@ import org.libreccm.categorization.Category;
* Implements functionality for renaming a folder. Most code taken from FolderCreator. Need to refactor out base
* functionality of FolderEditor & Creator.
*
- * @author Jon Orris (jorris@arsdigita.com)
+ * @author Jens >Pelzetter
+ * @author Jon Orris
*
- * @version $Revision: #9 $ $DateTime: 2004/08/17 23:15:09 $
- * @version $Id: FolderEditor.java 287 2005-02-22 00:29:02Z sskracic $
*/
public class FolderEditor extends FolderForm {
@@ -41,21 +40,22 @@ public class FolderEditor extends FolderForm {
super(name, folder);
}
-
/**
- * Initialize the form with name & label of folder being edited.
+ * Initialise the form with name & label of folder being edited.
* @param e
* @throws com.arsdigita.bebop.FormProcessException
*/
+ @Override
public void init(FormSectionEvent e) throws FormProcessException {
PageState s = e.getPageState();
FormData data = e.getFormData();
Category folder = getCurrentFolder(s);
data.put(NAME, folder.getName());
- data.put(TITLE, folder.getLabel());
+ data.put(TITLE, folder.getDisplayName());
}
+ @Override
public void process(FormSectionEvent e) throws FormProcessException {
PageState s = e.getPageState();
FormData data = e.getFormData();
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderForm.java
new file mode 100755
index 000000000..f5339af7d
--- /dev/null
+++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderForm.java
@@ -0,0 +1,398 @@
+/*
+ * Copyright (C) 2002-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.folder;
+
+import com.arsdigita.bebop.ColumnPanel;
+import com.arsdigita.bebop.Component;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.FormSection;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.Page;
+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.FormValidationListener;
+import com.arsdigita.bebop.form.Hidden;
+import com.arsdigita.bebop.form.TextField;
+import com.arsdigita.bebop.parameters.NotNullValidationListener;
+import com.arsdigita.bebop.parameters.TrimmedStringParameter;
+import com.arsdigita.bebop.parameters.URLTokenValidationListener;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+import com.arsdigita.globalization.GlobalizedMessage;
+import com.arsdigita.util.Assert;
+import com.arsdigita.web.Web;
+import com.arsdigita.xml.Element;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.libreccm.categorization.Category;
+import org.libreccm.categorization.CategoryRepository;
+import org.libreccm.cdi.utils.CdiUtil;
+import org.librecms.CmsConstants;
+
+/**
+ * Class FolderForm implements the basic form for creating or editing folders.
+ *
+ * Originally folders were ContentItems. For CCM NG we changed that and now use
+ * Categories to provide the folder hierarchy. Thus this class originally
+ * extended the {@link BasicItemForm} class. Now this class is separate. Some
+ * parts have been created by simply coping the relevant parts from
+ * {@link BasicItemForm}. Therefore it is possible that comments etc still refer
+ * to {@link BasicItemForm}.
+ *
+ * @author Jens Pelzetter
+ * @author Jon Orris
+ *
+ */
+public abstract class FolderForm extends FormSection
+ implements FormInitListener,
+ FormProcessListener,
+ FormValidationListener {
+
+ public static final Logger LOGGER = LogManager.getLogger(FolderForm.class);
+
+ public static final String FOLDER_ID = "FolderId";
+ public static final String NAME = "FolderName";
+ public static final String TITLE = "FolderTitle";
+ public static final String DESC = "FolderDesc";
+
+ private final FolderSelectionModel currentFolder;
+ private final SaveCancelSection saveCancelSection;
+ private final FormSection widgetSection;
+
+ /**
+ * Currently, to insert javascript code the Label Widget is "abused".
+ */
+ private final Label m_script = new Label(String.format(
+ "",
+ Web.getWebappContextPath()),
+ false);
+
+ /**
+ * Create a new folder form.
+ *
+ * @param name Name of the form
+ * @param currentFolder SelectionModel containing the current folder being
+ * operated on.
+ *
+ * @pre name != null && folder != null
+ */
+ public FolderForm(final String name,
+ final FolderSelectionModel currentFolder) {
+ super(new ColumnPanel(2));
+
+ widgetSection = new FormSection(new ColumnPanel(2, true));
+
+ super.add(widgetSection, ColumnPanel.INSERT);
+
+ this.currentFolder = currentFolder;
+
+ final ColumnPanel panel = (ColumnPanel) getPanel();
+ panel.setBorder(false);
+ panel.setPadColor("#FFFFFF");
+ panel.setColumnWidth(1, "20%");
+ panel.setColumnWidth(2, "80%");
+ panel.setWidth("100%");
+
+ /* Add basic contents */
+ addWidgets();
+
+ saveCancelSection = new SaveCancelSection();
+ super.add(saveCancelSection,
+ ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
+
+ addInitListener(this);
+ addProcessListener(this);
+ addValidationListener(this);
+ }
+
+ /**
+ * Constructs a new {@code FolderForm} with a specified number of
+ * {@link ColumnPanel}s and without content.
+ *
+ * @param formName
+ * @param columnPanel
+ * @param currentFolder
+ */
+ public FolderForm(final String formName,
+ final ColumnPanel columnPanel,
+ final FolderSelectionModel currentFolder) {
+ super(columnPanel);
+
+ widgetSection = new FormSection(
+ new ColumnPanel(columnPanel.getNumCols()));
+ super.add(widgetSection, ColumnPanel.INSERT);
+ this.currentFolder = currentFolder;
+
+ saveCancelSection = new SaveCancelSection();
+ super.add(saveCancelSection,
+ ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
+ }
+
+ /**
+ * Add basic widgets to the form.
+ *
+ * Widgets added are 'title' and 'name (url)'. Child classes will override
+ * this method to perform all their widget-adding needs but are supposed to
+ * use super() to add the basic widgets.
+ */
+ protected void addWidgets() {
+ final Hidden id = new Hidden(FOLDER_ID);
+ add(id);
+
+ // JavaScript auto-name generation is off by default.
+ // It is turned on under the following circumstances
+ //
+ // * If the name is null, upon starting edit of the title
+ // * If the name is null, upon finishing edit of name
+ //
+ // The rationale is that, auto-name generation is useful
+ // if the name is currently null, but once a name has been
+ // created you don't want to subsequently change it since
+ // it breaks URLs & potentially overwrites the user's
+ // customizations.
+ final TextField titleWidget = new TextField(new TrimmedStringParameter(
+ TITLE));
+ titleWidget.setLabel(getTitleLabel());
+ titleWidget.setHint(getTitleHint());
+ titleWidget.addValidationListener(new NotNullValidationListener());
+ titleWidget.setOnFocus("if (this.form." + NAME + ".value == '') { "
+ + " defaulting = true; this.form." + NAME
+ + ".value = urlize(this.value); }");
+ titleWidget.setOnKeyUp(
+ "if (defaulting) { this.form." + NAME
+ + ".value = urlize(this.value) }");
+ add(titleWidget);
+
+ final TextField nameWidget = new TextField(new TrimmedStringParameter(
+ NAME));
+ nameWidget.setLabel(getNameLabel());
+ nameWidget.setHint(getNameHint());
+
+ // We just check parameter specific properties here! Additionally,
+ // context properties as uniqueness in folder must be validated
+ // for the form es the whole (using the validate method required by
+ // implementing FormValidationListener in this form.
+ nameWidget.addValidationListener(new NotNullValidationListener());
+ nameWidget.addValidationListener(new URLTokenValidationListener());
+ nameWidget.setMaxLength(190);
+ nameWidget.setOnFocus("defaulting = false");
+ nameWidget.setOnBlur(
+ "if (this.value == '') "
+ + "{ defaulting = true; this.value = urlize(this.form."
+ + TITLE
+ + ".value) } "
+ + " else { this.value = urlize(this.value); }");
+ add(nameWidget);
+ }
+
+ @Override
+ public void register(final Page page) {
+ super.register(page);
+ page.addComponentStateParam(this, currentFolder.getStateParameter());
+ }
+
+ @Override
+ public void generateXML(final PageState state, final Element parent) {
+ m_script.generateXML(state, parent);
+ super.generateXML(state, parent);
+ }
+
+ /**
+ * Perform form initialisation. Children should override this this method to
+ * pre-fill the widgets with data, instantiate the content item, etc.
+ *
+ * @param event
+ *
+ * @throws FormProcessException
+ */
+ @Override
+ public abstract void init(final FormSectionEvent event)
+ throws FormProcessException;
+
+ /**
+ * Process the form. Children have to override this method to save the
+ * user's changes to the database.
+ *
+ * @param event
+ *
+ * @throws FormProcessException
+ */
+ @Override
+ public abstract void process(final FormSectionEvent event)
+ throws FormProcessException;
+
+ /**
+ * Validates the form. Checks for name uniqueness.
+ *
+ * @param event
+ *
+ * @throws com.arsdigita.bebop.FormProcessException
+ */
+ @Override
+ public void validate(final FormSectionEvent event)
+ throws FormProcessException {
+ Category folder = (Category) currentFolder.getSelectedObject(event
+ .getPageState());
+ Assert.exists(folder);
+// validateNameUniqueness(folder, event);
+ }
+
+ /**
+ * Adds a component to this container.
+ *
+ * @param component the component to add to this FolderForm
+ *
+ */
+ @Override
+ public void add(final Component component) {
+ widgetSection.add(component);
+ }
+
+ /**
+ * Adds a component with the specified layout constraints to this container.
+ * Layout constraints are defined in each layout container as static ints.
+ * Use a bitwise OR to specify multiple constraints.
+ *
+ * @param component the component to add to this container
+ * @param constraints layout constraints (a bitwise OR of static ints in the
+ * particular layout)
+ */
+ @Override
+ public void add(final Component component, final int constraints) {
+ widgetSection.add(component, constraints);
+ }
+
+ /**
+ * This method can be overridden to change the label of the title field. To
+ * change to label of the title field can be useful for some content types.
+ * For example, for an organization the label "Title" for the field may be
+ * confusing for the normal user. For such a content type, the label would
+ * be changed to something like "Name of the organization".
+ *
+ * @return (Content for the) Label for the title field as string
+ */
+ protected GlobalizedMessage getTitleLabel() {
+ return new GlobalizedMessage("cms.contenttypes.ui.title",
+ CmsConstants.CMS_BUNDLE);
+ }
+
+ /**
+ * Provides the text for the user hint providing some detailed information
+ * how to use this widget. This method can be overwritten to adjust the text
+ * for some content types. {@link #getTitleLabel()}
+ *
+ * @return
+ */
+ protected GlobalizedMessage getTitleHint() {
+ return new GlobalizedMessage("cms.contenttypes.ui.title_hint",
+ CmsConstants.CMS_BUNDLE);
+ }
+
+ /**
+ * This method does the same as {@link #getTitleLabel() } for the labe l of
+ * the name (URL) field.
+ *
+ * @return (Content for the) Label for the name field as string
+ */
+ protected GlobalizedMessage getNameLabel() {
+ return new GlobalizedMessage("cms.contenttypes.ui.name",
+ CmsConstants.CMS_BUNDLE);
+ }
+
+ /**
+ * Provides the text for the user hint providing some detailed information
+ * how to use this widget. This method can be overwritten to adjust the text
+ * for some content types. {@link #getNameLabel()}
+ *
+ * @return
+ */
+ protected GlobalizedMessage getNameHint() {
+ return new GlobalizedMessage("cms.contenttypes.ui.name_hint",
+ CmsConstants.CMS_BUNDLE);
+ }
+
+ /**
+ * Returns true if the form submission was cancelled.
+ *
+ * @param state
+ *
+ * @return
+ */
+ public boolean isCancelled(final PageState state) {
+ return saveCancelSection.getCancelButton().isSelected(state);
+ }
+
+ /**
+ * Updates a folder with a new parent, name, and label.
+ *
+ * @param folder The folder to update
+ * @param parent The new parent folder. May be null.
+ * @param name The new name of the folder
+ * @param label The new label for the folder
+ */
+ final protected void updateFolder(final Category folder,
+ final Category parent,
+ final String name,
+ final String label) {
+ folder.setParentCategory(parent);
+ updateFolder(folder, name, label);
+ }
+
+ /**
+ * Updates a folder with a new name and label.
+ *
+ * @param folder The folder to update
+ * @param name The new name of the folder
+ * @param label The new label for the folder
+ */
+ final protected void updateFolder(final Category folder,
+ final String name,
+ final String label) {
+ folder.setName(name);
+ folder.setDisplayName(label);
+
+ final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
+ final CategoryRepository categoryRepo = cdiUtil.findBean(
+ CategoryRepository.class);
+ categoryRepo.save(folder);
+ }
+
+ /**
+ * Returns the current folder being operated on.
+ *
+ * @return The current folder
+ *
+ * @pre state != null
+ * @post return != null
+ */
+ final protected Category getCurrentFolder(final PageState state) {
+ final Category folder = (Category) currentFolder
+ .getSelectedObject(state);
+ return folder;
+ }
+
+ final protected FolderSelectionModel getFolderSelectionModel() {
+ return currentFolder;
+ }
+
+}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderForm.java.off b/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderForm.java.off
deleted file mode 100755
index ebffaf580..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/folder/FolderForm.java.off
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2002-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.folder;
-
-import com.arsdigita.bebop.FormProcessException;
-import com.arsdigita.bebop.Page;
-import com.arsdigita.bebop.PageState;
-import com.arsdigita.bebop.event.FormSectionEvent;
-import com.arsdigita.cms.ItemSelectionModel;
-import com.arsdigita.cms.ui.authoring.BasicItemForm;
-import com.arsdigita.util.Assert;
-
-// ToDo: Form can't extend BasicItemForm longer because Folders are Categories
-// and not items. These means that this form must become indepenent. The
-// BasicItemForm may be used as an template for this form.
-// - Extends FormSection
-// - Fields for:
-// - Name
-// - Title/Displayname
-// - Description
-// - abstractCategory?
-// - visible?
-// - enabled?
-//
-// - Localizable fields for default language
-// - FolderCreator#process method must take care or adding category to parent and order field
-// -
-
-/**
- * Class FolderForm implements the basic form for creating or editing folders.
- *
- * @author Jens Pelzetter
- * @author Jon Orris
- *
- */
-public abstract class FolderForm extends BasicItemForm{
-
- FolderSelectionModel m_currentFolder;
-
- /**
- * Create a new folder form.
- *
- * @param name Name of the form
- * @param folder SelectionModel containing the current folder being operated on.
- *
- * @pre name != null && folder != null
- */
- public FolderForm(String name, FolderSelectionModel folder) {
- super(name, new ItemSelectionModel(Folder.BASE_DATA_OBJECT_TYPE, Folder.BASE_DATA_OBJECT_TYPE, "fldr"));
- m_currentFolder = folder;
- }
-
- public void register(Page p) {
- super.register(p);
- p.addComponentStateParam(this, getItemSelectionModel().getStateParameter());
- }
-
- /**
- * Returns true if the form submission was cancelled.
- */
- public boolean isCancelled(PageState s) {
- return getSaveCancelSection().getCancelButton().isSelected(s);
- }
-
- /**
- * Validates the form. Checks for name uniqueness.
- */
- public void validate(FormSectionEvent e) throws FormProcessException {
- Folder folder = (Folder) m_currentFolder.getSelectedObject(e.getPageState());
- Assert.exists(folder);
- validateNameUniqueness(folder, e);
- }
-
- /**
- * Updates a folder with a new parent, name, and label.
- *
- * @param folder The folder to update
- * @param parent The new parent folder. May be null.
- * @param name The new name of the folder
- * @param label The new label for the folder
- */
- final protected void updateFolder(Folder folder, Folder parent, String name, String label) {
- folder.setParent(parent);
- updateFolder(folder, name, label);
- }
-
- /**
- * Updates a folder with a new name and label.
- *
- * @param folder The folder to update
- * @param name The new name of the folder
- * @param label The new label for the folder
- */
- final protected void updateFolder(Folder folder, String name, String label) {
- folder.setName(name);
- folder.setLabel(label);
- folder.save();
-
- // also modify the live version of the folder,
- // otherwise items within this folder will keep
- // using the old URL, for example
- Folder live = (Folder) folder.getLiveVersion();
- if (live != null) {
- live.setName(name);
- live.setLabel(label);
- live.save();
- }
- }
-
- /**
- * Returns the current folder being operated on.
- *
- * @return The current folder
- *
- * @pre state != null
- * @post return != null
- */
- final protected Folder getCurrentFolder(PageState state) {
- Folder folder = (Folder) m_currentFolder.getSelectedObject(state);
- return folder;
- }
-}