diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLinkResources.properties b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLinkResources.properties index 711913f1f..b818ebee6 100755 --- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLinkResources.properties +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLinkResources.properties @@ -3,3 +3,7 @@ cms.contentassets.related_link.description=Related Links cms.contentassets.ui.related_link.resource_size=Resource Size cms.contentassets.ui.related_link.resource_type=Resource Type cms.contentassets.ui.related_link.resource_type_unknown=Unknown +cms.contentassets.ui.related_link.add_caption=Add a caption +cms.contentassets.ui.related_link.add_link=Add a Link +cms.contentassets.ui.related_link.caption=Caption: +cms.contentassets.ui.related_link.Description=Description/Caption: diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLinkResources_de.properties b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLinkResources_de.properties index 1e01682d3..2bb817f5a 100644 --- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLinkResources_de.properties +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/RelatedLinkResources_de.properties @@ -3,3 +3,7 @@ cms.contentassets.related_link.description=Weiterf\u00fchrende Links cms.contentassets.ui.related_link.resource_size=Gr\u00f6\u00dfe cms.contentassets.ui.related_link.resource_type=Ressourcen Typ cms.contentassets.ui.related_link.resource_type_unknown=Unbekannt +cms.contentassets.ui.related_link.add_caption=Zwischentitel hinzuf\u00fcgen +cms.contentassets.ui.related_link.add_link=Link hinzuf\u00fcgen +cms.contentassets.ui.related_link.caption=Zwischentitel: +cms.contentassets.ui.related_link.Description=Beschreibung/Zwischentitel: diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionEditForm.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionEditForm.java new file mode 100644 index 000000000..cfd0ac8e9 --- /dev/null +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionEditForm.java @@ -0,0 +1,49 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.arsdigita.cms.contentassets.ui; + +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 com.arsdigita.cms.contentassets.RelatedLink; +import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel; + +/** + * + * @author Koalamann + */ +public class RelatedLinkCaptionEditForm extends RelatedLinkCaptionForm { + + public RelatedLinkCaptionEditForm(ItemSelectionModel itemModel, + LinkSelectionModel link, String linkListName) { + super(itemModel, link, linkListName); + } + + /** + * Init listener. For edit actions, fills the form with current data + * + * @param fse the FormSectionEvent + * + * @throws com.arsdigita.bebop.FormProcessException + */ + @Override + public void init(FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + setVisible(state, false); + RelatedLink link; + if (m_linkModel.isSelected(state)) { + link = (RelatedLink) m_linkModel.getSelectedLink(state); + if (link.getTitle().equals("caption")) { + //make this form visible because we are editing and it is a caption not a link + setVisible(state, true); + } + m_description.setValue(state, link.getDescription()); + } + } +} diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionForm.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionForm.java new file mode 100644 index 000000000..cb943532e --- /dev/null +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkCaptionForm.java @@ -0,0 +1,351 @@ +/* + * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.cms.contentassets.ui; + +import com.arsdigita.bebop.ColumnPanel; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormSection; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SaveCancelSection; +import com.arsdigita.bebop.event.PrintEvent; +import com.arsdigita.bebop.event.PrintListener; +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.event.FormSubmissionListener; +import com.arsdigita.bebop.form.Submit; +import com.arsdigita.bebop.form.TextArea; +import com.arsdigita.bebop.parameters.StringLengthValidationListener; +import com.arsdigita.cms.CMSConfig; +import com.arsdigita.util.Assert; +import com.arsdigita.util.UncheckedWrapperException; + +import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contentassets.RelatedLink; +import com.arsdigita.cms.contentassets.util.RelatedLinkGlobalizationUtil; +import com.arsdigita.cms.contenttypes.Link; +import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel; +import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.mimetypes.MimeType; +import com.arsdigita.persistence.DataCollection; + +import java.util.TooManyListenersException; + +import org.apache.log4j.Logger; + +/** + * Form to edit captions. based on LinkPropertyForm and RelatedLinkPropertyForm + * + * @version $Revision: 1# $ $Date: 2015/04/13 $ + * @author konerman (konerman@tzi.de) + */ +public class RelatedLinkCaptionForm extends FormSection + implements FormInitListener, FormProcessListener, + FormValidationListener, FormSubmissionListener { + + private static final Logger s_log = Logger.getLogger(RelatedLinkCaptionForm.class); + + /** + * Name of this form + */ + public static final String ID = "caption"; + public static final String SSL_PROTOCOL = "https://"; + public static final String HTTP_PROTOCOL = "http://"; + protected TextArea m_description; + protected ItemSelectionModel m_itemModel; + protected LinkSelectionModel m_linkModel; + private SaveCancelSection m_saveCancelSection; + protected final String ITEM_SEARCH = "contentItem"; + private ContentType m_contentType; + private String m_linkListName; + + /** + * Constructor creates a new form to edit the Link object specified by the + * item selection model passed in. + * + * @param itemModel The ItemSelectionModel to use to obtain the ContentItem + * to which this link is (or will be) attached + * @param link The LinkSelectionModel to use to obtain the Link to work on + * @param linkListName + */ + public RelatedLinkCaptionForm(ItemSelectionModel itemModel, + LinkSelectionModel link, String linkListName) { + this(itemModel, link, linkListName, null); + } + + /** + * Constructor creates a new form to edit the Link object specified by the + * item selection model passed in. + * + * @param itemModel + * @param link + * @param contentType + */ + public RelatedLinkCaptionForm(ItemSelectionModel itemModel, + LinkSelectionModel link, String linkListName, + ContentType contentType) { + super(new ColumnPanel(2)); + m_linkListName = linkListName; + + s_log.debug("caption form constructor"); + m_linkModel = link; + m_itemModel = itemModel; + m_contentType = contentType; + + addWidgets(); + addSaveCancelSection(); + + addInitListener(this); + + addValidationListener(this); + + addProcessListener(this); + addSubmissionListener(this); + } + + /** + * Adds widgets to the form. + */ + protected void addWidgets() { + + /* Add the standard description field */ + m_description = new TextArea("description"); + m_description.setCols(40); + m_description.setRows(5); + m_description.addValidationListener(new StringLengthValidationListener(CMSConfig + .getInstanceOf().getLinkDescMaxLength())); + add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.caption"))); + add(m_description); + + } + + /** + * Adds the saveCancelSection + */ + public void addSaveCancelSection() { + m_saveCancelSection = new SaveCancelSection(); + try { + m_saveCancelSection.getCancelButton().addPrintListener( + new PrintListener() { + + @Override + public void prepare(PrintEvent e) { + Submit target = (Submit) e.getTarget(); + if (m_linkModel.isSelected(e.getPageState())) { + target.setButtonLabel(GlobalizationUtil.globalize( + "cms.contenttyes.link.ui.button_cancel")); + } else { + target.setButtonLabel(GlobalizationUtil.globalize( + "cms.contenttyes.link.ui.button_reset")); + } + } + + }); + m_saveCancelSection.getSaveButton().addPrintListener( + new PrintListener() { + + @Override + public void prepare(PrintEvent e) { + Submit target = (Submit) e.getTarget(); + if (m_linkModel.isSelected(e.getPageState())) { + target.setButtonLabel(GlobalizationUtil.globalize( + "cms.contenttyes.link.ui.button_save")); + } else { + target.setButtonLabel(GlobalizationUtil.globalize( + "cms.contenttyes.link.ui.button_create")); + } + } + + }); + } catch (TooManyListenersException e) { + throw new UncheckedWrapperException("this cannot happen", e); + } + add(m_saveCancelSection, ColumnPanel.FULL_WIDTH); + } + + /** + * Retrieves the saveCancelSection. + * + * @return Save/Cencel section + */ + public SaveCancelSection getSaveCancelSection() { + return m_saveCancelSection; + } + + /** + * return selection model for Link that we are dealing with. + */ + protected LinkSelectionModel getLinkSelectionModel() { + return m_linkModel; + } + + /** + * Submission listener. Handles cancel events. + * + * @param e the FormSectionEvent + * + * @throws com.arsdigita.bebop.FormProcessException + */ + @Override + public void submitted(FormSectionEvent e) + throws FormProcessException { + if (m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) { + s_log.debug("cancel in submission listener"); + m_linkModel.clearSelection(e.getPageState()); + init(e); + throw new FormProcessException( + GlobalizationUtil.globalize("cms.contenttypes.ui.cancelled")); + } + } + + /** + * Validation listener. Ensures consistency of internal vs. external link + * data + * + * @param event the FormSectionEvent + * + * @throws com.arsdigita.bebop.FormProcessException + */ + @Override + public void validate(FormSectionEvent event) + throws FormProcessException { + + } + + /** + * Get the current ContentItem + * + * @param s the PageState + * + * @return the ContentItem + */ + protected ContentItem getContentItem(PageState s) { + return (ContentItem) m_itemModel.getSelectedObject(s); + } + + /** + * Take care of basic Link creation steps + * + * @param s the PageState + * + * @return the newly-created Link + */ + protected Link createLink(PageState s) { + ContentItem item = getContentItem(s); + Assert.exists(item, ContentItem.class); + RelatedLink link = new RelatedLink(); + + // remove the following line if we make Link extend ACSObject + //link.setName(item.getName() + "_link_" + item.getID()); + // set the owner of the link + link.setLinkOwner(item); + + return link; + } + + /** + * Init listener. For edit actions, fills the form with current data + * + * @param fse the FormSectionEvent + * + * @throws com.arsdigita.bebop.FormProcessException + */ + @Override + public void init(FormSectionEvent fse) throws FormProcessException { + FormData data = fse.getFormData(); + PageState state = fse.getPageState(); + s_log.debug("Init"); + s_log.debug("new link"); + m_description.setValue(state, null); + } + + /** + * Process listener. Saves/creates the new or modified Link + * + * @param fse the FormSectionEvent + * + * @throws com.arsdigita.bebop.FormProcessException + */ + @Override + public void process(FormSectionEvent fse) throws FormProcessException { + PageState state = fse.getPageState(); + RelatedLink link; + + // save only if save button was pressed + if (getSaveCancelSection().getCancelButton().isSelected(state)) { + // cancel button is selected + m_linkModel.clearSelection(state); + s_log.debug("link save canceled"); + + } else { + + if (m_linkModel.isSelected(state)) { + // Editing a link + s_log.debug("processing link edit"); + link = (RelatedLink) m_linkModel.getSelectedLink(state); + } else { + s_log.debug("processing new link"); + link = (RelatedLink) createLink(state); + } + //call to set various properties of Link. + setLinkProperties(link, fse); + s_log.debug("Created Link with ID: " + link.getOID().toString() + + "Title " + link.getTitle()); + } + // XXX Initialize the form + m_linkModel.clearSelection(state); + init(fse); + } + + /** + * Set various properties of the Link.Child clases can over-ride this method + * to add additional properties to Link. + * + * @param link + * @param fse + */ + protected void setLinkProperties(RelatedLink link, FormSectionEvent fse) { + PageState state = fse.getPageState(); + FormData data = fse.getFormData(); + link.setTitle("caption"); + link.setDescription((String) m_description.getValue(state)); + link.setTargetType(RelatedLink.EXTERNAL_LINK); + link.setTargetURI(null); + link.setTargetWindow(""); + link.setResourceSize(""); + link.setResourceType(MimeType.loadMimeType("text/html")); + link.setTargetItem(null); + link.setLinkListName(m_linkListName); + DataCollection links = RelatedLink.getRelatedLinks( + getContentItem(fse.getPageState()), + m_linkListName); + //Only change link order if we are creating a new link + if (!getLinkSelectionModel().isSelected(fse.getPageState())) { + link.setOrder((int) links.size() + 1); + } + + link.save(); + } + +} diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkEditForm.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkEditForm.java new file mode 100644 index 000000000..0d89a8099 --- /dev/null +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkEditForm.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2004 Red Hat Inc. All Rights Reserved. + * + * The contents of this file are subject to the Open Software License v2.1 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * http://rhea.redhat.com/licenses/osl2.1.html. + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + */ +package com.arsdigita.cms.contentassets.ui; + +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.form.Hidden; +import com.arsdigita.bebop.form.Option; +import com.arsdigita.bebop.form.SingleSelect; +import com.arsdigita.bebop.form.TextField; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contentassets.RelatedLink; +import com.arsdigita.cms.contentassets.RelatedLinkConfig; +import com.arsdigita.cms.contentassets.util.RelatedLinkGlobalizationUtil; +import com.arsdigita.cms.contenttypes.Link; +import com.arsdigita.cms.contenttypes.ui.LinkPropertyForm; +import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel; +import com.arsdigita.mimetypes.MimeType; +import com.arsdigita.mimetypes.MimeTypeCollection; +import com.arsdigita.persistence.DataCollection; +import com.arsdigita.util.Assert; + +import org.apache.log4j.Logger; + +/** + * Form to edit the basic properties of a RelatedLink. This form is a copy&paste + * of relatedlinkform + * + * @version $Revision: #3 $ $Date: 2004/03/30 $ + * @author Scott Seago (sseago@redhat.com) + */ +public class RelatedLinkEditForm extends RelatedLinkPropertyForm { + + private static final Logger logger = Logger.getLogger( + RelatedLinkEditForm.class); + private static boolean isHideNewTargetWindow = RelatedLinkConfig.getInstance() + .isHideNewTargetWindow(); + private static boolean isHideAdditionalResourceFields = RelatedLinkConfig.getInstance() + .isHideAdditionalResourceFields(); + private String m_linkListName; + + /** + * Creates a new form to edit the RelatedLink object specified by the item + * selection model passed in. + * + * @param itemModel The ItemSelectionModel to use to obtain the ContentItem + * to which this link is (or will be) attached + * @param link The LinkSelectionModel to use to obtain the Link to work on + */ + public RelatedLinkEditForm(ItemSelectionModel itemModel, + LinkSelectionModel link, String linkListName) { + + super(itemModel, link, linkListName); + } + + /** + * Over-ride super class method to initialize addtional fields specific to + * RelatedLink content asset. + */ + @Override + public void init(FormSectionEvent fse) throws FormProcessException { + super.init(fse); + FormData data = fse.getFormData(); + PageState ps = fse.getPageState(); + RelatedLink rl; + setVisible(ps, false); + if (isHideAdditionalResourceFields) { + // Do nothing except protect the poor users from themselves. + } else { + if (getLinkSelectionModel().isSelected(ps)) { + + rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps); + if (!rl.getTitle().equals("caption")) { + //make this form visible because we are editing and its not a caption + setVisible(ps, true); + } + //We are editing the link , populate our addtional fields. + data.put(RelatedLink.RESOURCE_SIZE, rl.getResourceSize()); + if (rl.getResourceType() != null) { + data.put(RelatedLink.RESOURCE_TYPE, + rl.getResourceType().getMimeType()); + } + data.put(RelatedLink.LINK_LIST_NAME, rl.getLinkListName()); + } + } + } + +} diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertiesStep.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertiesStep.java index 41d4fe55e..65a8e2873 100755 --- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertiesStep.java +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertiesStep.java @@ -15,45 +15,127 @@ package com.arsdigita.cms.contentassets.ui; import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.Form; import com.arsdigita.bebop.FormSection; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SaveCancelSection; import com.arsdigita.bebop.SimpleContainer; -import com.arsdigita.cms.ContentSection; +import com.arsdigita.bebop.event.ActionEvent; +import com.arsdigita.bebop.event.ActionListener; +import com.arsdigita.bebop.event.PrintEvent; +import com.arsdigita.bebop.event.PrintListener; +import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.contentassets.RelatedLinkConfig; import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contentassets.RelatedLink; +import com.arsdigita.cms.contentassets.util.RelatedLinkGlobalizationUtil; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.contenttypes.ui.LinkPropertiesStep; import com.arsdigita.cms.contenttypes.ui.LinkTable; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; +import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer; +import com.arsdigita.persistence.DataCollection; /** - * Authoring step to create a RelatedLink and change ordering. - * - * It is just a front end to the cms Link asset and makes RelatedLink accessible + * Authoring step to create a RelatedLink and change ordering. + * + * It is just a front end to the cms Link asset and makes RelatedLink accessible * as installable add related link authoring step */ public class RelatedLinkPropertiesStep extends LinkPropertiesStep { protected String linkListName; protected ContentType contentType; + private SaveCancelSection m_saveCancelSection; + private RelatedLinkPropertyForm m_RelatedLinkPropertyForm; + private RelatedLinkCaptionForm m_RelatedLinkCaptionForm; + private RelatedLinkTable m_linkList; /** * Constructor. Creates a RelatedLinkPropertiesStep given an - * ItemSelectionModel and an - * AuthoringKitWizard. + * ItemSelectionModel and an AuthoringKitWizard. * - * @param itemModel The ItemSelectionModel for the current page. - * @param parent The AuthoringKitWizard to track the - * current link + * @param itemModel The ItemSelectionModel for the current + * page. + * @param parent The AuthoringKitWizard to track the current + * link */ public RelatedLinkPropertiesStep(ItemSelectionModel itemModel, - AuthoringKitWizard parent) { + AuthoringKitWizard parent) { super(itemModel, parent); + + // Reset the editing when this component becomes visible + parent.getList().addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + PageState state = event.getPageState(); + showDisplayPane(state); + } + }); + } + + + @Override + protected void addForms() { + + m_Form = new RelatedLinkPropertyForm(m_itemModel, m_linkModel, linkListName); + add("addlink", RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.add_link"), + new WorkflowLockedComponentAccess(m_Form, m_itemModel), + m_Form.getSaveCancelSection().getCancelButton()); + + m_RelatedLinkCaptionForm = new RelatedLinkCaptionForm(m_itemModel, m_linkModel, linkListName); + add("caption", RelatedLinkGlobalizationUtil.globalize( + "cms.contentassets.ui.related_link.add_caption"), + new WorkflowLockedComponentAccess(m_RelatedLinkCaptionForm, m_itemModel), + m_RelatedLinkCaptionForm.getSaveCancelSection().getCancelButton()); + + // the link edit form + Form linkform = new Form("linkEditForm"); + linkform.add(getEditSheet()); + + WorkflowLockedContainer edit = new WorkflowLockedContainer(m_itemModel); + edit.add(linkform); + add(edit); + + //the caption edit form + Form captionform = new Form("captionEditForm"); + captionform.add(getcaptionSheet()); + + WorkflowLockedContainer captionEdit = new WorkflowLockedContainer(m_itemModel); + captionEdit.add(captionform); + add(captionEdit); + + } + + @Override + protected void addTable() { + m_linkList = new RelatedLinkTable(m_itemModel, m_linkModel, linkListName); + Label mainLabel = new Label("bla"); + mainLabel.setFontWeight(Label.ITALIC); + mainLabel.addPrintListener(new PrintListener() { + public void prepare(PrintEvent event) { + PageState state = event.getPageState(); + ContentItem item = (ContentItem) m_itemModel.getSelectedObject(state); + if (item != null) { + DataCollection rlinks = RelatedLink.getRelatedLinks(item); + Label mainTarget = (Label) event.getTarget(); + if (rlinks.isEmpty()) { + mainTarget.setLabel( + "no RELATEDLinks"); + } else { + mainTarget.setLabel(""); + } + } + } + }); + m_display.add(mainLabel); + m_display.add(m_linkList); } /** - * Sets a RelatedLinkSelectionModel as the LinkSelectionModel for this - * authoring step. - * Also, set the linkListName and contentType if neccessary + * Sets a RelatedLinkSelectionModel as the LinkSelectionModel for this + * authoring step. Also, set the linkListName and contentType if neccessary */ @Override protected void setLinkSelectionModel() { @@ -62,11 +144,11 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep { } /** - * Returns a RelatedLinkTable as the display component for this authoring + * Returns a RelatedLinkTable as the display component for this authoring * step. * * Uses CMS LinkTable and its display facilities. - * + * * @return The display component to use for the authoring step */ @Override @@ -77,32 +159,67 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep { LinkTable table; if (RelatedLinkConfig.getInstance().isHideAdditionalResourceFields()) { // CMS LinkTable it it's standard form - table = new LinkTable(getItemSelectionModel(), - getLinkSelectionModel()); - table.setModelBuilder(new - RelatedLinkTableModelBuilder(getItemSelectionModel(), - linkListName)); + table = new LinkTable(getItemSelectionModel(), + getLinkSelectionModel()); + table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel(), + linkListName)); } else { // Add columns to standard CMS LinkTable - table = new RelatedLinkTable(getItemSelectionModel(), - getLinkSelectionModel(), - linkListName); + table = new RelatedLinkTable(getItemSelectionModel(), + getLinkSelectionModel(), + linkListName); } container.add(table); return container; } + /** + * Retrieves the saveCancelSection. + * + * @return Save/Cencel section + */ + public SaveCancelSection getSaveCancelSection() { + m_saveCancelSection = new SaveCancelSection(); +// add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); + + return m_saveCancelSection; + } + +// public String getLinkListName() { +// return linkListName; +// +// } + + /** + * Gets the edit form for related links + * + * @return The edit form + */ +// @Override +// protected FormSection getEditSheet() { +// return new RelatedLinkPropertyForm(m_itemModel, m_linkModel, linkListName); +// } + + /** + * Gets the edit form for captions + * + * @return The edit form + */ + protected FormSection getcaptionSheet() { + return new RelatedLinkCaptionEditForm(m_itemModel, m_linkModel, linkListName); + } + + /** * Gets the edit form (a RelatedLinkPropertyForm) * * @return The edit form */ @Override protected FormSection getEditSheet() { - return new RelatedLinkPropertyForm(getItemSelectionModel(), - getLinkSelectionModel(), - linkListName, - contentType); + return new RelatedLinkEditForm(getItemSelectionModel(), + getLinkSelectionModel(), linkListName); } + } diff --git a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java index 96891d78a..1a690c5d5 100755 --- a/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java +++ b/ccm-cms-assets-relatedlink/src/com/arsdigita/cms/contentassets/ui/RelatedLinkPropertyForm.java @@ -41,9 +41,10 @@ import com.arsdigita.util.Assert; import org.apache.log4j.Logger; /** - * Form to edit the basic properties of a RelatedLink. This form extends LinkPropertyForm in order - * to create items of the correct subclass and set the linkOwner property. Users have found the - * additional fields confusing at authoring time (resourceSize and resourceType) so we have added a + * Form to edit the basic properties of a RelatedLink. This form extends + * LinkPropertyForm in order to create items of the correct subclass and set the + * linkOwner property. Users have found the additional fields confusing at + * authoring time (resourceSize and resourceType) so we have added a * configuration parameter that allows us to hide them on a site wide basis. * * @version $Revision: #3 $ $Date: 2004/03/30 $ @@ -52,30 +53,30 @@ import org.apache.log4j.Logger; public class RelatedLinkPropertyForm extends LinkPropertyForm { private static final Logger logger = Logger.getLogger( - RelatedLinkPropertyForm.class); + RelatedLinkPropertyForm.class); private static boolean isHideNewTargetWindow = RelatedLinkConfig.getInstance() - .isHideNewTargetWindow(); + .isHideNewTargetWindow(); private static boolean isHideAdditionalResourceFields = RelatedLinkConfig.getInstance() - .isHideAdditionalResourceFields(); + .isHideAdditionalResourceFields(); private String m_linkListName; /** - * Creates a new form to edit the RelatedLink object specified by the item selection model - * passed in. + * Creates a new form to edit the RelatedLink object specified by the item + * selection model passed in. * - * @param itemModel The ItemSelectionModel to use to obtain the ContentItem to which this link - * is (or will be) attached - * @param link The LinkSelectionModel to use to obtain the Link to work on + * @param itemModel The ItemSelectionModel to use to obtain the ContentItem + * to which this link is (or will be) attached + * @param link The LinkSelectionModel to use to obtain the Link to work on */ public RelatedLinkPropertyForm(ItemSelectionModel itemModel, - LinkSelectionModel link, String linkListName) { + LinkSelectionModel link, String linkListName) { this(itemModel, link, linkListName, null); } public RelatedLinkPropertyForm(ItemSelectionModel itemModel, - LinkSelectionModel link, String linkListName, - ContentType contentType) { + LinkSelectionModel link, String linkListName, + ContentType contentType) { super(itemModel, link, contentType); logger.debug(String.format("linkListName = %s", linkListName)); @@ -107,25 +108,25 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm { // Do nothing except protect the poor users from themselves. } else { add(new Label(RelatedLinkGlobalizationUtil.globalize( - "cms.contentassets.ui.related_link.resource_size"))); + "cms.contentassets.ui.related_link.resource_size"))); TextField resSize = new TextField(new StringParameter(RelatedLink.RESOURCE_SIZE)); add(resSize); add(new Label(RelatedLinkGlobalizationUtil.globalize( - "cms.contentassets.ui.related_link.resource_type"))); + "cms.contentassets.ui.related_link.resource_type"))); SingleSelect resType = new SingleSelect(new StringParameter(RelatedLink.RESOURCE_TYPE)); addMimeOptions(resType); add(resType); } Hidden linkListName = new Hidden(new StringParameter( - RelatedLink.LINK_LIST_NAME)); + RelatedLink.LINK_LIST_NAME)); add(linkListName); } /** - * Add mime-type options to the option group by loading all mime types which match a certain - * prefix from the database + * Add mime-type options to the option group by loading all mime types which + * match a certain prefix from the database * * @param w The mime type widget to which options should be added * @@ -140,8 +141,8 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm { } /** - * Take care of basic RelatedLink creation steps. Creates the RelatedLink and sets the linkOwner - * property. + * Take care of basic RelatedLink creation steps. Creates the RelatedLink + * and sets the linkOwner property. * * @param s the PageState * @@ -174,26 +175,17 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm { if (isHideAdditionalResourceFields) { // Do nothing except protect the poor users from themselves. } else { - if (getLinkSelectionModel().isSelected(ps)) { - //We are editing the link , populate our addtional fields. - rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps); - data.put(RelatedLink.RESOURCE_SIZE, rl.getResourceSize()); - if (rl.getResourceType() != null) { - data.put(RelatedLink.RESOURCE_TYPE, - rl.getResourceType().getMimeType()); - } - data.put(RelatedLink.LINK_LIST_NAME, rl.getLinkListName()); - } else { - // New Link creation , clear the fields. - data.put(RelatedLink.RESOURCE_SIZE, null); - data.put(RelatedLink.RESOURCE_TYPE, null); - data.put(RelatedLink.LINK_LIST_NAME, m_linkListName); - } + + // New Link creation , clear the fields. + data.put(RelatedLink.RESOURCE_SIZE, null); + data.put(RelatedLink.RESOURCE_TYPE, null); + data.put(RelatedLink.LINK_LIST_NAME, m_linkListName); } } /** - * over-ride super class method to set extended properties for RelatedLink. + * over-ride super class method to set extended properties for + * RelatedLink. */ @Override protected void setLinkProperties(Link link, FormSectionEvent fse) { @@ -212,8 +204,8 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm { rl.setLinkListName((String) data.get(RelatedLink.LINK_LIST_NAME)); DataCollection links = RelatedLink.getRelatedLinks( - getContentItem(fse.getPageState()), - m_linkListName); + getContentItem(fse.getPageState()), + m_linkListName); //Only change link order if we are creating a new link if (!getLinkSelectionModel().isSelected(fse.getPageState())) { rl.setOrder((int) links.size() + 1); diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties index 7f8c50901..e837dca86 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties @@ -1011,7 +1011,7 @@ cms.ui.authoring.go=Go cms.ui.upload=File Upload cms.ui.section.new_section_name=Name of the new Content Section cms.contenttyes.link.ui.table_header_link=Link -cms.contenttyes.link.ui.table_header_descr=Description +cms.contenttyes.link.ui.table_header_descr=Description/Caption cms.contenttyes.link.ui.table_header_edit=Edit cms.contenttyes.link.ui.table_header_delete=Delete cms.contenttyes.link.ui.table_header_move_up=Move Up @@ -1109,3 +1109,6 @@ cms.ui.authoring.html_file_missing_body_tags=The file (which should be type HTML cms.ui.lifecycle.publish.not_possible_abstract_category\ = cms.ui.authoring.couldnt_create_item=Couldn't create new Item cms.ui.type.content_editing_failed=Failed to edit the content type: {0} +cms.contenttyes.link.ui.caption=Caption: +cms.contenttyes.link.ui.option_group.caption=caption +cms.contenttypes.ui.title_is_required=A title is required diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties index ac1493d74..ca4e3b0c6 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties @@ -1005,9 +1005,9 @@ cms.ui.authoring.go=Anlegen cms.ui.upload=Datei laden cms.ui.section.new_section_name=Name der neuen Content Section cms.contenttyes.link.ui.table_header_link=Link -cms.contenttyes.link.ui.table_header_descr=Beschreibung +cms.contenttyes.link.ui.table_header_descr=Beschreibung/Zwischentitel cms.contenttyes.link.ui.table_header_edit=Bearbeiten -cms.contenttyes.link.ui.table_header_delete=DeleteEntfernen +cms.contenttyes.link.ui.table_header_delete=Entfernen cms.contenttyes.link.ui.table_header_move_up=Nach Oben bewegen cms.contenttyes.link.ui.table_header_move_down=Nach Unten bewegen cms.contenttyes.link.ui.table_cell_edit_link=bearbeiten @@ -1103,3 +1103,6 @@ cms.ui.authoring.html_file_missing_body_tags=Der Datei (vom Type HTML) fehlt der cms.ui.lifecycle.publish.not_possible_abstract_category\ = cms.ui.authoring.couldnt_create_item=Konnte ein neues Element nicht erstellen cms.ui.type.content_editing_failed=Bearbeitung des Dokumenttyps: {0} ist fehlgeschlagen +cms.contenttyes.link.ui.caption=Zwischentitel: +cms.contenttyes.link.ui.option_group.caption=Zwischentitel +cms.contenttypes.ui.title_is_required=Ein Titel wird ben\u00f6tigt diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties index c4fdd63d7..5a4025add 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_en_GB.properties @@ -57,7 +57,7 @@ cms.ui.authoring.go=Go cms.ui.upload=File Upload cms.ui.section.new_section_name= cms.contenttyes.link.ui.table_header_link=Link -cms.contenttyes.link.ui.table_header_descr=Description +cms.contenttyes.link.ui.table_header_descr=Description/Caption cms.contenttyes.link.ui.table_header_edit=Edit cms.contenttyes.link.ui.table_header_delete=Delete cms.contenttyes.link.ui.table_header_move_up=Move Up @@ -147,3 +147,6 @@ cms.ui.authoring.html_file_missing_body_tags= cms.ui.lifecycle.publish.not_possible_abstract_category\ = cms.ui.authoring.couldnt_create_item= cms.ui.type.content_editing_failed= +cms.contenttyes.link.ui.caption=Caption: +cms.contenttyes.link.ui.option_group.caption=caption +cms.contenttypes.ui.title_is_required=A title is required diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties index b1d85ef78..f48fbe93a 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_fr.properties @@ -526,7 +526,7 @@ cms.ui.title=Title cms.ui.upload=Transf\u00e9re cms.ui.section.new_section_name= cms.contenttyes.link.ui.table_header_link=Link -cms.contenttyes.link.ui.table_header_descr=Description +cms.contenttyes.link.ui.table_header_descr=Description/Caption cms.contenttyes.link.ui.table_header_edit=Edit cms.contenttyes.link.ui.table_header_delete=Delete cms.contenttyes.link.ui.table_header_move_up=Move Up @@ -619,3 +619,6 @@ cms.ui.authoring.html_file_missing_body_tags=Le fichier (qui devrait \u00eatre d cms.ui.lifecycle.publish.not_possible_abstract_category\ = cms.ui.authoring.couldnt_create_item=Impossible de cr\u00e9er un nouveau \u00e9l\u00e9ment cms.ui.type.content_editing_failed=Impossible de modifier le type de contenu: {0} +cms.contenttyes.link.ui.caption=Caption: +cms.contenttyes.link.ui.option_group.caption=caption +cms.contenttypes.ui.title_is_required=A title is required diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertiesStep.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertiesStep.java index 540f3329f..934f0d29a 100755 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertiesStep.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertiesStep.java @@ -18,108 +18,178 @@ */ package com.arsdigita.cms.contenttypes.ui; -import com.arsdigita.bebop.Form; import com.arsdigita.bebop.FormSection; import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SimpleContainer; +import com.arsdigita.bebop.event.ActionEvent; +import com.arsdigita.bebop.event.ActionListener; +import com.arsdigita.bebop.event.PrintEvent; +import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.parameters.BigDecimalParameter; +import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.Link; +import com.arsdigita.cms.ui.CMSContainer; +import com.arsdigita.cms.ui.SecurityPropertyEditor; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; +import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer; +import com.arsdigita.cms.util.GlobalizationUtil; +import com.arsdigita.persistence.DataCollection; /** - * Authoring step to create a link and change ordering. This class is - * declared abstract, as this and related Link* base classes do not - * assign the Links to a specific role/association. - * RelatedLinkPropertiesStep extends this functionality to - * view/assign RelatedLinks in the specific "links" role on ContentItem. + * Authoring step to create a link and change ordering. This class is declared + * abstract, as this and related Link* base classes do not assign the Links to a + * specific role/association. RelatedLinkPropertiesStep extends + * this functionality to view/assign RelatedLinks in the specific "links" role + * on ContentItem. */ -public abstract class LinkPropertiesStep extends ResettableContainer { +public abstract class LinkPropertiesStep extends SecurityPropertyEditor { private AuthoringKitWizard m_parent; - private ItemSelectionModel m_itemModel; + public ItemSelectionModel m_itemModel; private BigDecimalParameter m_linkParam = new BigDecimalParameter("link"); - private LinkSelectionModel m_linkModel = new LinkSelectionModel(m_linkParam); + public LinkSelectionModel m_linkModel = new LinkSelectionModel(m_linkParam); + protected CMSContainer m_display; + protected LinkPropertyForm m_Form; + private LinkTable m_linkList; /** * Constructor. Creates a LinkPropertiesStep given an - * ItemSelectionModel and an - * AuthoringKitWizard. + * ItemSelectionModel and an AuthoringKitWizard. * - * @param itemModel The ItemSelectionModel for the current page. - * @param parent The AuthoringKitWizard to track the - * current link + * @param itemModel The ItemSelectionModel for the current + * page. + * @param parent The AuthoringKitWizard to track the current + * link */ public LinkPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { m_itemModel = itemModel; m_parent = parent; - setLinkSelectionModel(); - add(getDisplayComponent()); + m_display = new CMSContainer(); + setLinkSelectionModel(); + + //add(getDisplayComponent()); + addTable(); + + setDisplayComponent(m_display); + + m_parent.getList().addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + PageState state = event.getPageState(); + showDisplayPane(state); + } + }); + addForms(); + } + + /** + * Adds buttons to create a new link and adds the editform + * + * Override this method if you want different forms or more than one + * + * @author konerman + */ + protected void addForms() { + //button to add a new link + m_Form = new LinkPropertyForm(m_itemModel, m_linkModel); + add("addlink", GlobalizationUtil.globalize("Link hinzufügen"), + new WorkflowLockedComponentAccess(m_Form, m_itemModel), + m_Form.getSaveCancelSection().getCancelButton()); + + // shows the propertyform to edit Form form = new Form("linkEditForm"); form.add(getEditSheet()); - WorkflowLockedContainer edit = new WorkflowLockedContainer(itemModel); + WorkflowLockedContainer edit = new WorkflowLockedContainer(m_itemModel); edit.add(form); add(edit); } /** - * Sets the LinkSelectionModel for this authoring step. Subclasses - * should override this method if a custom LinkSelectionModel is desired. + * Adds a table with links. + */ + protected void addTable() { + m_linkList = new LinkTable(m_itemModel, m_linkModel); + Label mainLabel = new Label("bla"); + mainLabel.setFontWeight(Label.ITALIC); + mainLabel.addPrintListener(new PrintListener() { + public void prepare(PrintEvent event) { + PageState state = event.getPageState(); + ContentItem item = (ContentItem) m_itemModel.getSelectedObject(state); + if (item != null) { + DataCollection links = Link.getReferringLinks(item); + Label mainTarget = (Label) event.getTarget(); + if (links.isEmpty()) { + mainTarget.setLabel( + "no Links"); + } else { + mainTarget.setLabel(""); + } + } + } + }); + m_display.add(mainLabel); + + m_display.add(m_linkList); + } + + /** + * Sets the LinkSelectionModel for this authoring step. Subclasses should + * override this method if a custom LinkSelectionModel is desired. */ protected void setLinkSelectionModel() { setLinkSelectionModel(new LinkSelectionModel(m_linkParam)); } /** - * Sets the LinkSelectionModel for this authoring step. + * Sets the LinkSelectionModel for this authoring step. * - * @param linkModel The LinkSelectionModel to use for - * the authoring step + * @param linkModel The LinkSelectionModel to use for the + * authoring step */ protected void setLinkSelectionModel(LinkSelectionModel linkModel) { m_linkModel = linkModel; } /** - * Gets the LinkSelectionModel for this authoring step. + * Gets the LinkSelectionModel for this authoring step. * - * @return The LinkSelectionModel to use for - * the authoring step + * @return The LinkSelectionModel to use for the authoring step */ protected LinkSelectionModel getLinkSelectionModel() { return m_linkModel; } /** - * Gets the ItemSelectionModel for this authoring step. + * Gets the ItemSelectionModel for this authoring step. * - * @return The ItemSelectionModel to use for - * the authoring step + * @return The ItemSelectionModel to use for the authoring step */ protected ItemSelectionModel getItemSelectionModel() { return m_itemModel; } /** - * Gets the link parameter for this authoring step. + * Gets the link parameter for this authoring step. * - * @return The link parameter to use for - * the authoring step + * @return The link parameter to use for the authoring step */ protected BigDecimalParameter getLinkParam() { return m_linkParam; } /** - * Gets the display compoent for this authoring step. + * Gets the display compoent for this authoring step. * - * @return The display component to use for - * the authoring step + * @return The display component to use for the authoring step */ public Component getDisplayComponent() { SimpleContainer container = new SimpleContainer(); @@ -137,8 +207,8 @@ public abstract class LinkPropertiesStep extends ResettableContainer { } /** - * When this component is registered, the link parameter is added - * as a ComponentStateParameter + * When this component is registered, the link parameter is added as a + * ComponentStateParameter * * @param p The Page object */ diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertyForm.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertyForm.java index 7c0c4b181..9a77e8ec5 100755 --- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertyForm.java +++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ui/LinkPropertyForm.java @@ -157,7 +157,7 @@ public class LinkPropertyForm extends FormSection add(new Label(GlobalizationUtil.globalize( "cms.contenttypes.ui.description"))); add(m_description); - + //add(new Label( add(new Embedded( "