RelatedLinks: added possibility to add captions. Therefor reworked LinkPropertiesStep so it works with SecurityPropertyEditor
git-svn-id: https://svn.libreccm.org/ccm/trunk@3400 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
a04278d1c0
commit
a386fc9811
|
|
@ -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_size=Resource Size
|
||||||
cms.contentassets.ui.related_link.resource_type=Resource Type
|
cms.contentassets.ui.related_link.resource_type=Resource Type
|
||||||
cms.contentassets.ui.related_link.resource_type_unknown=Unknown
|
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:
|
||||||
|
|
|
||||||
|
|
@ -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_size=Gr\u00f6\u00dfe
|
||||||
cms.contentassets.ui.related_link.resource_type=Ressourcen Typ
|
cms.contentassets.ui.related_link.resource_type=Ressourcen Typ
|
||||||
cms.contentassets.ui.related_link.resource_type_unknown=Unbekannt
|
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:
|
||||||
|
|
|
||||||
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
* <code>RelatedLink</code> 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -15,15 +15,28 @@
|
||||||
package com.arsdigita.cms.contentassets.ui;
|
package com.arsdigita.cms.contentassets.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
import com.arsdigita.bebop.FormSection;
|
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.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.ContentType;
|
||||||
import com.arsdigita.cms.contentassets.RelatedLinkConfig;
|
import com.arsdigita.cms.contentassets.RelatedLinkConfig;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
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.ui.authoring.AuthoringKitWizard;
|
||||||
import com.arsdigita.cms.contenttypes.ui.LinkPropertiesStep;
|
import com.arsdigita.cms.contenttypes.ui.LinkPropertiesStep;
|
||||||
import com.arsdigita.cms.contenttypes.ui.LinkTable;
|
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.
|
* Authoring step to create a RelatedLink and change ordering.
|
||||||
|
|
@ -35,25 +48,94 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
|
||||||
|
|
||||||
protected String linkListName;
|
protected String linkListName;
|
||||||
protected ContentType contentType;
|
protected ContentType contentType;
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
private RelatedLinkPropertyForm m_RelatedLinkPropertyForm;
|
||||||
|
private RelatedLinkCaptionForm m_RelatedLinkCaptionForm;
|
||||||
|
private RelatedLinkTable m_linkList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates a <code>RelatedLinkPropertiesStep</code> given an
|
* Constructor. Creates a <code>RelatedLinkPropertiesStep</code> given an
|
||||||
* <code>ItemSelectionModel</code> and an
|
* <code>ItemSelectionModel</code> and an <code>AuthoringKitWizard</code>.
|
||||||
* <code>AuthoringKitWizard</code>.
|
|
||||||
*
|
*
|
||||||
* @param itemModel The <code>ItemSelectionModel</code> for the current page.
|
* @param itemModel The <code>ItemSelectionModel</code> for the current
|
||||||
* @param parent The <code>AuthoringKitWizard</code> to track the
|
* page.
|
||||||
* current link
|
* @param parent The <code>AuthoringKitWizard</code> to track the current
|
||||||
|
* link
|
||||||
*/
|
*/
|
||||||
public RelatedLinkPropertiesStep(ItemSelectionModel itemModel,
|
public RelatedLinkPropertiesStep(ItemSelectionModel itemModel,
|
||||||
AuthoringKitWizard parent) {
|
AuthoringKitWizard parent) {
|
||||||
super(itemModel, 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
|
* Sets a RelatedLinkSelectionModel as the LinkSelectionModel for this
|
||||||
* authoring step.
|
* authoring step. Also, set the linkListName and contentType if neccessary
|
||||||
* Also, set the linkListName and contentType if neccessary
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void setLinkSelectionModel() {
|
protected void setLinkSelectionModel() {
|
||||||
|
|
@ -78,31 +160,66 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
|
||||||
if (RelatedLinkConfig.getInstance().isHideAdditionalResourceFields()) {
|
if (RelatedLinkConfig.getInstance().isHideAdditionalResourceFields()) {
|
||||||
// CMS LinkTable it it's standard form
|
// CMS LinkTable it it's standard form
|
||||||
table = new LinkTable(getItemSelectionModel(),
|
table = new LinkTable(getItemSelectionModel(),
|
||||||
getLinkSelectionModel());
|
getLinkSelectionModel());
|
||||||
table.setModelBuilder(new
|
table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel(),
|
||||||
RelatedLinkTableModelBuilder(getItemSelectionModel(),
|
linkListName));
|
||||||
linkListName));
|
|
||||||
} else {
|
} else {
|
||||||
// Add columns to standard CMS LinkTable
|
// Add columns to standard CMS LinkTable
|
||||||
table = new RelatedLinkTable(getItemSelectionModel(),
|
table = new RelatedLinkTable(getItemSelectionModel(),
|
||||||
getLinkSelectionModel(),
|
getLinkSelectionModel(),
|
||||||
linkListName);
|
linkListName);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.add(table);
|
container.add(table);
|
||||||
return container;
|
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)
|
* Gets the edit form (a RelatedLinkPropertyForm)
|
||||||
*
|
*
|
||||||
* @return The edit form
|
* @return The edit form
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected FormSection getEditSheet() {
|
protected FormSection getEditSheet() {
|
||||||
return new RelatedLinkPropertyForm(getItemSelectionModel(),
|
return new RelatedLinkEditForm(getItemSelectionModel(),
|
||||||
getLinkSelectionModel(),
|
getLinkSelectionModel(), linkListName);
|
||||||
linkListName,
|
|
||||||
contentType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,10 @@ import com.arsdigita.util.Assert;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form to edit the basic properties of a RelatedLink. This form extends LinkPropertyForm in order
|
* Form to edit the basic properties of a RelatedLink. This form extends
|
||||||
* to create items of the correct subclass and set the linkOwner property. Users have found the
|
* LinkPropertyForm in order to create items of the correct subclass and set the
|
||||||
* additional fields confusing at authoring time (resourceSize and resourceType) so we have added a
|
* 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.
|
* configuration parameter that allows us to hide them on a site wide basis.
|
||||||
*
|
*
|
||||||
* @version $Revision: #3 $ $Date: 2004/03/30 $
|
* @version $Revision: #3 $ $Date: 2004/03/30 $
|
||||||
|
|
@ -52,30 +53,30 @@ import org.apache.log4j.Logger;
|
||||||
public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(
|
private static final Logger logger = Logger.getLogger(
|
||||||
RelatedLinkPropertyForm.class);
|
RelatedLinkPropertyForm.class);
|
||||||
private static boolean isHideNewTargetWindow = RelatedLinkConfig.getInstance()
|
private static boolean isHideNewTargetWindow = RelatedLinkConfig.getInstance()
|
||||||
.isHideNewTargetWindow();
|
.isHideNewTargetWindow();
|
||||||
private static boolean isHideAdditionalResourceFields = RelatedLinkConfig.getInstance()
|
private static boolean isHideAdditionalResourceFields = RelatedLinkConfig.getInstance()
|
||||||
.isHideAdditionalResourceFields();
|
.isHideAdditionalResourceFields();
|
||||||
private String m_linkListName;
|
private String m_linkListName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new form to edit the RelatedLink object specified by the item selection model
|
* Creates a new form to edit the RelatedLink object specified by the item
|
||||||
* passed in.
|
* selection model passed in.
|
||||||
*
|
*
|
||||||
* @param itemModel The ItemSelectionModel to use to obtain the ContentItem to which this link
|
* @param itemModel The ItemSelectionModel to use to obtain the ContentItem
|
||||||
* is (or will be) attached
|
* to which this link is (or will be) attached
|
||||||
* @param link The LinkSelectionModel to use to obtain the Link to work on
|
* @param link The LinkSelectionModel to use to obtain the Link to work on
|
||||||
*/
|
*/
|
||||||
public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
|
public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
|
||||||
LinkSelectionModel link, String linkListName) {
|
LinkSelectionModel link, String linkListName) {
|
||||||
|
|
||||||
this(itemModel, link, linkListName, null);
|
this(itemModel, link, linkListName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
|
public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
|
||||||
LinkSelectionModel link, String linkListName,
|
LinkSelectionModel link, String linkListName,
|
||||||
ContentType contentType) {
|
ContentType contentType) {
|
||||||
|
|
||||||
super(itemModel, link, contentType);
|
super(itemModel, link, contentType);
|
||||||
logger.debug(String.format("linkListName = %s", linkListName));
|
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.
|
// Do nothing except protect the poor users from themselves.
|
||||||
} else {
|
} else {
|
||||||
add(new Label(RelatedLinkGlobalizationUtil.globalize(
|
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));
|
TextField resSize = new TextField(new StringParameter(RelatedLink.RESOURCE_SIZE));
|
||||||
add(resSize);
|
add(resSize);
|
||||||
|
|
||||||
add(new Label(RelatedLinkGlobalizationUtil.globalize(
|
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));
|
SingleSelect resType = new SingleSelect(new StringParameter(RelatedLink.RESOURCE_TYPE));
|
||||||
addMimeOptions(resType);
|
addMimeOptions(resType);
|
||||||
add(resType);
|
add(resType);
|
||||||
}
|
}
|
||||||
|
|
||||||
Hidden linkListName = new Hidden(new StringParameter(
|
Hidden linkListName = new Hidden(new StringParameter(
|
||||||
RelatedLink.LINK_LIST_NAME));
|
RelatedLink.LINK_LIST_NAME));
|
||||||
add(linkListName);
|
add(linkListName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add mime-type options to the option group by loading all mime types which match a certain
|
* Add mime-type options to the option group by loading all mime types which
|
||||||
* prefix from the database
|
* match a certain prefix from the database
|
||||||
*
|
*
|
||||||
* @param w The mime type widget to which options should be added
|
* @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
|
* Take care of basic RelatedLink creation steps. Creates the RelatedLink
|
||||||
* property.
|
* and sets the linkOwner property.
|
||||||
*
|
*
|
||||||
* @param s the PageState
|
* @param s the PageState
|
||||||
*
|
*
|
||||||
|
|
@ -174,26 +175,17 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||||
if (isHideAdditionalResourceFields) {
|
if (isHideAdditionalResourceFields) {
|
||||||
// Do nothing except protect the poor users from themselves.
|
// Do nothing except protect the poor users from themselves.
|
||||||
} else {
|
} else {
|
||||||
if (getLinkSelectionModel().isSelected(ps)) {
|
|
||||||
//We are editing the link , populate our addtional fields.
|
// New Link creation , clear the fields.
|
||||||
rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps);
|
data.put(RelatedLink.RESOURCE_SIZE, null);
|
||||||
data.put(RelatedLink.RESOURCE_SIZE, rl.getResourceSize());
|
data.put(RelatedLink.RESOURCE_TYPE, null);
|
||||||
if (rl.getResourceType() != null) {
|
data.put(RelatedLink.LINK_LIST_NAME, m_linkListName);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* over-ride super class method to set extended properties for <code>RelatedLink</code>.
|
* over-ride super class method to set extended properties for
|
||||||
|
* <code>RelatedLink</code>.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void setLinkProperties(Link link, FormSectionEvent fse) {
|
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));
|
rl.setLinkListName((String) data.get(RelatedLink.LINK_LIST_NAME));
|
||||||
|
|
||||||
DataCollection links = RelatedLink.getRelatedLinks(
|
DataCollection links = RelatedLink.getRelatedLinks(
|
||||||
getContentItem(fse.getPageState()),
|
getContentItem(fse.getPageState()),
|
||||||
m_linkListName);
|
m_linkListName);
|
||||||
//Only change link order if we are creating a new link
|
//Only change link order if we are creating a new link
|
||||||
if (!getLinkSelectionModel().isSelected(fse.getPageState())) {
|
if (!getLinkSelectionModel().isSelected(fse.getPageState())) {
|
||||||
rl.setOrder((int) links.size() + 1);
|
rl.setOrder((int) links.size() + 1);
|
||||||
|
|
|
||||||
|
|
@ -1011,7 +1011,7 @@ cms.ui.authoring.go=Go
|
||||||
cms.ui.upload=File Upload
|
cms.ui.upload=File Upload
|
||||||
cms.ui.section.new_section_name=Name of the new Content Section
|
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_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_edit=Edit
|
||||||
cms.contenttyes.link.ui.table_header_delete=Delete
|
cms.contenttyes.link.ui.table_header_delete=Delete
|
||||||
cms.contenttyes.link.ui.table_header_move_up=Move Up
|
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.lifecycle.publish.not_possible_abstract_category\ =
|
||||||
cms.ui.authoring.couldnt_create_item=Couldn't create new Item
|
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.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
|
||||||
|
|
|
||||||
|
|
@ -1005,9 +1005,9 @@ cms.ui.authoring.go=Anlegen
|
||||||
cms.ui.upload=Datei laden
|
cms.ui.upload=Datei laden
|
||||||
cms.ui.section.new_section_name=Name der neuen Content Section
|
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_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_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_up=Nach Oben bewegen
|
||||||
cms.contenttyes.link.ui.table_header_move_down=Nach Unten bewegen
|
cms.contenttyes.link.ui.table_header_move_down=Nach Unten bewegen
|
||||||
cms.contenttyes.link.ui.table_cell_edit_link=bearbeiten
|
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.lifecycle.publish.not_possible_abstract_category\ =
|
||||||
cms.ui.authoring.couldnt_create_item=Konnte ein neues Element nicht erstellen
|
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.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
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ cms.ui.authoring.go=Go
|
||||||
cms.ui.upload=File Upload
|
cms.ui.upload=File Upload
|
||||||
cms.ui.section.new_section_name=
|
cms.ui.section.new_section_name=
|
||||||
cms.contenttyes.link.ui.table_header_link=Link
|
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_edit=Edit
|
||||||
cms.contenttyes.link.ui.table_header_delete=Delete
|
cms.contenttyes.link.ui.table_header_delete=Delete
|
||||||
cms.contenttyes.link.ui.table_header_move_up=Move Up
|
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.lifecycle.publish.not_possible_abstract_category\ =
|
||||||
cms.ui.authoring.couldnt_create_item=
|
cms.ui.authoring.couldnt_create_item=
|
||||||
cms.ui.type.content_editing_failed=
|
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
|
||||||
|
|
|
||||||
|
|
@ -526,7 +526,7 @@ cms.ui.title=Title
|
||||||
cms.ui.upload=Transf\u00e9re
|
cms.ui.upload=Transf\u00e9re
|
||||||
cms.ui.section.new_section_name=
|
cms.ui.section.new_section_name=
|
||||||
cms.contenttyes.link.ui.table_header_link=Link
|
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_edit=Edit
|
||||||
cms.contenttyes.link.ui.table_header_delete=Delete
|
cms.contenttyes.link.ui.table_header_delete=Delete
|
||||||
cms.contenttyes.link.ui.table_header_move_up=Move Up
|
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.lifecycle.publish.not_possible_abstract_category\ =
|
||||||
cms.ui.authoring.couldnt_create_item=Impossible de cr\u00e9er un nouveau \u00e9l\u00e9ment
|
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.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
|
||||||
|
|
|
||||||
|
|
@ -18,58 +18,132 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Form;
|
|
||||||
import com.arsdigita.bebop.FormSection;
|
import com.arsdigita.bebop.FormSection;
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.Component;
|
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.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.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
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.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedContainer;
|
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
|
* Authoring step to create a link and change ordering. This class is declared
|
||||||
* declared abstract, as this and related Link* base classes do not
|
* abstract, as this and related Link* base classes do not assign the Links to a
|
||||||
* assign the Links to a specific role/association.
|
* specific role/association. <code>RelatedLinkPropertiesStep</code> extends
|
||||||
* <code>RelatedLinkPropertiesStep</code> extends this functionality to
|
* this functionality to view/assign RelatedLinks in the specific "links" role
|
||||||
* view/assign RelatedLinks in the specific "links" role on ContentItem.
|
* on ContentItem.
|
||||||
*/
|
*/
|
||||||
public abstract class LinkPropertiesStep extends ResettableContainer {
|
public abstract class LinkPropertiesStep extends SecurityPropertyEditor {
|
||||||
|
|
||||||
private AuthoringKitWizard m_parent;
|
private AuthoringKitWizard m_parent;
|
||||||
private ItemSelectionModel m_itemModel;
|
public ItemSelectionModel m_itemModel;
|
||||||
private BigDecimalParameter m_linkParam = new BigDecimalParameter("link");
|
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 <code>LinkPropertiesStep</code> given an
|
* Constructor. Creates a <code>LinkPropertiesStep</code> given an
|
||||||
* <code>ItemSelectionModel</code> and an
|
* <code>ItemSelectionModel</code> and an <code>AuthoringKitWizard</code>.
|
||||||
* <code>AuthoringKitWizard</code>.
|
|
||||||
*
|
*
|
||||||
* @param itemModel The <code>ItemSelectionModel</code> for the current page.
|
* @param itemModel The <code>ItemSelectionModel</code> for the current
|
||||||
* @param parent The <code>AuthoringKitWizard</code> to track the
|
* page.
|
||||||
* current link
|
* @param parent The <code>AuthoringKitWizard</code> to track the current
|
||||||
|
* link
|
||||||
*/
|
*/
|
||||||
public LinkPropertiesStep(ItemSelectionModel itemModel,
|
public LinkPropertiesStep(ItemSelectionModel itemModel,
|
||||||
AuthoringKitWizard parent) {
|
AuthoringKitWizard parent) {
|
||||||
|
|
||||||
m_itemModel = itemModel;
|
m_itemModel = itemModel;
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
setLinkSelectionModel();
|
m_display = new CMSContainer();
|
||||||
add(getDisplayComponent());
|
|
||||||
|
|
||||||
|
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 form = new Form("linkEditForm");
|
||||||
form.add(getEditSheet());
|
form.add(getEditSheet());
|
||||||
|
|
||||||
WorkflowLockedContainer edit = new WorkflowLockedContainer(itemModel);
|
WorkflowLockedContainer edit = new WorkflowLockedContainer(m_itemModel);
|
||||||
edit.add(form);
|
edit.add(form);
|
||||||
add(edit);
|
add(edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the LinkSelectionModel for this authoring step. Subclasses
|
* Adds a table with links.
|
||||||
* should override this method if a custom LinkSelectionModel is desired.
|
*/
|
||||||
|
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() {
|
protected void setLinkSelectionModel() {
|
||||||
setLinkSelectionModel(new LinkSelectionModel(m_linkParam));
|
setLinkSelectionModel(new LinkSelectionModel(m_linkParam));
|
||||||
|
|
@ -78,8 +152,8 @@ public abstract class LinkPropertiesStep extends ResettableContainer {
|
||||||
/**
|
/**
|
||||||
* Sets the LinkSelectionModel for this authoring step.
|
* Sets the LinkSelectionModel for this authoring step.
|
||||||
*
|
*
|
||||||
* @param linkModel The <code>LinkSelectionModel</code> to use for
|
* @param linkModel The <code>LinkSelectionModel</code> to use for the
|
||||||
* the authoring step
|
* authoring step
|
||||||
*/
|
*/
|
||||||
protected void setLinkSelectionModel(LinkSelectionModel linkModel) {
|
protected void setLinkSelectionModel(LinkSelectionModel linkModel) {
|
||||||
m_linkModel = linkModel;
|
m_linkModel = linkModel;
|
||||||
|
|
@ -88,8 +162,7 @@ public abstract class LinkPropertiesStep extends ResettableContainer {
|
||||||
/**
|
/**
|
||||||
* Gets the LinkSelectionModel for this authoring step.
|
* Gets the LinkSelectionModel for this authoring step.
|
||||||
*
|
*
|
||||||
* @return The <code>LinkSelectionModel</code> to use for
|
* @return The <code>LinkSelectionModel</code> to use for the authoring step
|
||||||
* the authoring step
|
|
||||||
*/
|
*/
|
||||||
protected LinkSelectionModel getLinkSelectionModel() {
|
protected LinkSelectionModel getLinkSelectionModel() {
|
||||||
return m_linkModel;
|
return m_linkModel;
|
||||||
|
|
@ -98,8 +171,7 @@ public abstract class LinkPropertiesStep extends ResettableContainer {
|
||||||
/**
|
/**
|
||||||
* Gets the ItemSelectionModel for this authoring step.
|
* Gets the ItemSelectionModel for this authoring step.
|
||||||
*
|
*
|
||||||
* @return The <code>ItemSelectionModel</code> to use for
|
* @return The <code>ItemSelectionModel</code> to use for the authoring step
|
||||||
* the authoring step
|
|
||||||
*/
|
*/
|
||||||
protected ItemSelectionModel getItemSelectionModel() {
|
protected ItemSelectionModel getItemSelectionModel() {
|
||||||
return m_itemModel;
|
return m_itemModel;
|
||||||
|
|
@ -108,8 +180,7 @@ public abstract class LinkPropertiesStep extends ResettableContainer {
|
||||||
/**
|
/**
|
||||||
* Gets the link parameter for this authoring step.
|
* Gets the link parameter for this authoring step.
|
||||||
*
|
*
|
||||||
* @return The link parameter to use for
|
* @return The link parameter to use for the authoring step
|
||||||
* the authoring step
|
|
||||||
*/
|
*/
|
||||||
protected BigDecimalParameter getLinkParam() {
|
protected BigDecimalParameter getLinkParam() {
|
||||||
return m_linkParam;
|
return m_linkParam;
|
||||||
|
|
@ -118,8 +189,7 @@ public abstract class LinkPropertiesStep extends ResettableContainer {
|
||||||
/**
|
/**
|
||||||
* Gets the display compoent for this authoring step.
|
* Gets the display compoent for this authoring step.
|
||||||
*
|
*
|
||||||
* @return The display component to use for
|
* @return The display component to use for the authoring step
|
||||||
* the authoring step
|
|
||||||
*/
|
*/
|
||||||
public Component getDisplayComponent() {
|
public Component getDisplayComponent() {
|
||||||
SimpleContainer container = new SimpleContainer();
|
SimpleContainer container = new SimpleContainer();
|
||||||
|
|
@ -137,8 +207,8 @@ public abstract class LinkPropertiesStep extends ResettableContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When this component is registered, the link parameter is added
|
* When this component is registered, the link parameter is added as a
|
||||||
* as a ComponentStateParameter
|
* ComponentStateParameter
|
||||||
*
|
*
|
||||||
* @param p The Page object
|
* @param p The Page object
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -495,13 +495,17 @@ public class LinkPropertyForm extends FormSection
|
||||||
@Override
|
@Override
|
||||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||||
FormData data = fse.getFormData();
|
FormData data = fse.getFormData();
|
||||||
PageState state = fse.getPageState();
|
PageState state = fse.getPageState();
|
||||||
s_log.debug("Init");
|
s_log.debug("Init");
|
||||||
setVisible(state, true);
|
setVisible(state, true);
|
||||||
Link link;
|
Link link;
|
||||||
if (m_linkModel.isSelected(state)) {
|
if (m_linkModel.isSelected(state)) {
|
||||||
s_log.debug("Edit");
|
s_log.debug("Edit");
|
||||||
link = m_linkModel.getSelectedLink(state);
|
link = m_linkModel.getSelectedLink(state);
|
||||||
|
|
||||||
|
if(link.getTitle().equals("caption")){
|
||||||
|
setVisible(state,false);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
m_title.setValue(state, link.getTitle());
|
m_title.setValue(state, link.getTitle());
|
||||||
m_description.setValue(state, link.getDescription());
|
m_description.setValue(state, link.getDescription());
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ import com.arsdigita.util.Assert;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bebop table to display a list of Links associated with a ContentItem.
|
* Bebop table to display a list of Links associated with a ContentItem.
|
||||||
*
|
*
|
||||||
|
|
@ -72,11 +71,11 @@ public class LinkTable extends Table {
|
||||||
private RequestLocal m_editor;
|
private RequestLocal m_editor;
|
||||||
|
|
||||||
// match columns by (symbolic) index, makes for easier reordering
|
// match columns by (symbolic) index, makes for easier reordering
|
||||||
private static final int COL_IDX_LINK = 0; //Link;
|
private static final int COL_IDX_LINK = 0; //Link;
|
||||||
private static final int COL_IDX_DESCR = 1; //Description;
|
private static final int COL_IDX_DESCR = 1; //Description;
|
||||||
private static final int COL_IDX_EDIT = 2; //Description;
|
private static final int COL_IDX_EDIT = 2; //Description;
|
||||||
private static final int COL_IDX_DELETE = 3; //Description;
|
private static final int COL_IDX_DELETE = 3; //Description;
|
||||||
private static final int COL_IDX_MOVE_UP = 4; //Description;
|
private static final int COL_IDX_MOVE_UP = 4; //Description;
|
||||||
private static final int COL_IDX_MOVE_DOWN = 5; //Description;
|
private static final int COL_IDX_MOVE_DOWN = 5; //Description;
|
||||||
|
|
||||||
protected static final String EDIT_EVENT = "Edit";
|
protected static final String EDIT_EVENT = "Edit";
|
||||||
|
|
@ -86,13 +85,11 @@ public class LinkTable extends Table {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates a <code>LinkTable</code> given an
|
* Constructor. Creates a <code>LinkTable</code> given an
|
||||||
* <code>ItemSelectionModel</code> and a
|
* <code>ItemSelectionModel</code> and a <code>LinkSelectionModel</code>,
|
||||||
* <code>LinkSelectionModel</code>, which track the current item
|
* which track the current item and link.
|
||||||
* and link.
|
|
||||||
*
|
*
|
||||||
* @param item The <code>ItemSelectionModel</code> for the current page.
|
* @param item The <code>ItemSelectionModel</code> for the current page.
|
||||||
* @param link The <code>LinkSelectionModel</code> to track the
|
* @param link The <code>LinkSelectionModel</code> to track the current link
|
||||||
* current link
|
|
||||||
*/
|
*/
|
||||||
public LinkTable(ItemSelectionModel item, LinkSelectionModel link) {
|
public LinkTable(ItemSelectionModel item, LinkSelectionModel link) {
|
||||||
|
|
||||||
|
|
@ -109,16 +106,16 @@ public class LinkTable extends Table {
|
||||||
public Object initialValue(PageState state) {
|
public Object initialValue(PageState state) {
|
||||||
SecurityManager sm = CMS.getSecurityManager(state);
|
SecurityManager sm = CMS.getSecurityManager(state);
|
||||||
ContentItem item = (ContentItem) m_itemModel
|
ContentItem item = (ContentItem) m_itemModel
|
||||||
.getSelectedObject(state);
|
.getSelectedObject(state);
|
||||||
Boolean val = new Boolean(sm.canAccess(state.getRequest(),
|
Boolean val = new Boolean(sm.canAccess(state.getRequest(),
|
||||||
SecurityManager.EDIT_ITEM,
|
SecurityManager.EDIT_ITEM,
|
||||||
item));
|
item));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Label empty = new Label(GlobalizationUtil.globalize(
|
Label empty = new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_no_entries"));
|
"cms.contenttyes.link.ui.table_no_entries"));
|
||||||
setEmptyView(empty);
|
setEmptyView(empty);
|
||||||
addTableActionListener(new LinkTableActionListener());
|
addTableActionListener(new LinkTableActionListener());
|
||||||
setRowSelectionModel(m_linkModel);
|
setRowSelectionModel(m_linkModel);
|
||||||
|
|
@ -133,35 +130,35 @@ public class LinkTable extends Table {
|
||||||
TableColumnModel model = getColumnModel();
|
TableColumnModel model = getColumnModel();
|
||||||
|
|
||||||
m_titleCol = new TableColumn(
|
m_titleCol = new TableColumn(
|
||||||
COL_IDX_LINK,
|
COL_IDX_LINK,
|
||||||
new Label(GlobalizationUtil.globalize(
|
new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_header_link"))
|
"cms.contenttyes.link.ui.table_header_link"))
|
||||||
);
|
);
|
||||||
m_descCol = new TableColumn(
|
m_descCol = new TableColumn(
|
||||||
COL_IDX_DESCR,
|
COL_IDX_DESCR,
|
||||||
new Label(GlobalizationUtil.globalize(
|
new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_header_descr"))
|
"cms.contenttyes.link.ui.table_header_descr"))
|
||||||
);
|
);
|
||||||
m_editCol = new TableColumn(
|
m_editCol = new TableColumn(
|
||||||
COL_IDX_EDIT,
|
COL_IDX_EDIT,
|
||||||
new Label(GlobalizationUtil.globalize(
|
new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_header_edit"))
|
"cms.contenttyes.link.ui.table_header_edit"))
|
||||||
);
|
);
|
||||||
m_delCol = new TableColumn(
|
m_delCol = new TableColumn(
|
||||||
COL_IDX_DELETE,
|
COL_IDX_DELETE,
|
||||||
new Label(GlobalizationUtil.globalize(
|
new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_header_delete"))
|
"cms.contenttyes.link.ui.table_header_delete"))
|
||||||
);
|
);
|
||||||
m_moveUpCol = new TableColumn(
|
m_moveUpCol = new TableColumn(
|
||||||
COL_IDX_MOVE_UP,
|
COL_IDX_MOVE_UP,
|
||||||
new Label(GlobalizationUtil.globalize(
|
new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_header_move_up"))
|
"cms.contenttyes.link.ui.table_header_move_up"))
|
||||||
);
|
);
|
||||||
m_moveDownCol = new TableColumn(
|
m_moveDownCol = new TableColumn(
|
||||||
COL_IDX_MOVE_DOWN,
|
COL_IDX_MOVE_DOWN,
|
||||||
new Label(GlobalizationUtil.globalize(
|
new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_header_move_down"))
|
"cms.contenttyes.link.ui.table_header_move_down"))
|
||||||
);
|
);
|
||||||
|
|
||||||
model.add(m_titleCol);
|
model.add(m_titleCol);
|
||||||
model.add(m_descCol);
|
model.add(m_descCol);
|
||||||
|
|
@ -190,28 +187,33 @@ public class LinkTable extends Table {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Component getComponent(Table table,
|
public Component getComponent(Table table,
|
||||||
PageState state,
|
PageState state,
|
||||||
Object value,
|
Object value,
|
||||||
boolean isSelected,
|
boolean isSelected,
|
||||||
Object key,
|
Object key,
|
||||||
int row,
|
int row,
|
||||||
int column) {
|
int column) {
|
||||||
|
|
||||||
Link link = (Link) value;
|
Link link = (Link) value;
|
||||||
boolean isFirst = (row == 0);
|
boolean isFirst = (row == 0);
|
||||||
if (m_size.get(state) == null) {
|
if (m_size.get(state) == null) {
|
||||||
m_size.set(state,
|
m_size.set(state,
|
||||||
new Long(((LinkTableModelBuilder.LinkTableModel) table.
|
new Long(((LinkTableModelBuilder.LinkTableModel) table.
|
||||||
getTableModel(state)).size()));
|
getTableModel(state)).size()));
|
||||||
}
|
}
|
||||||
boolean isLast = (row == ((Long) m_size.get(state)).intValue() - 1);
|
boolean isLast = (row == ((Long) m_size.get(state)).intValue() - 1);
|
||||||
|
|
||||||
|
|
||||||
if (column == m_titleCol.getModelIndex()) {
|
if (column == m_titleCol.getModelIndex()) {
|
||||||
String url = link.getInternalOrExternalURI(state);
|
String url = link.getInternalOrExternalURI(state);
|
||||||
ExternalLink extLink = new ExternalLink(link.getTitle(), url);
|
if (link.getTitle().equals("caption")) {
|
||||||
extLink.setTargetFrame("_blank");
|
ExternalLink extLink = new ExternalLink("", url);
|
||||||
return extLink;
|
extLink.setTargetFrame("_blank");
|
||||||
|
return extLink;
|
||||||
|
} else {
|
||||||
|
ExternalLink extLink = new ExternalLink(link.getTitle(), url);
|
||||||
|
extLink.setTargetFrame("_blank");
|
||||||
|
return extLink;
|
||||||
|
}
|
||||||
} else if (column == m_descCol.getModelIndex()) {
|
} else if (column == m_descCol.getModelIndex()) {
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
return new Label(link.getDescription(), Label.BOLD);
|
return new Label(link.getDescription(), Label.BOLD);
|
||||||
|
|
@ -222,28 +224,28 @@ public class LinkTable extends Table {
|
||||||
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
return new Label(GlobalizationUtil.globalize(
|
return new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_cell_edit_link"),
|
"cms.contenttyes.link.ui.table_cell_edit_link"),
|
||||||
Label.BOLD);
|
Label.BOLD);
|
||||||
} else {
|
} else {
|
||||||
return new ControlLink( new Label(GlobalizationUtil.globalize(
|
return new ControlLink(new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_cell_edit_link")) );
|
"cms.contenttyes.link.ui.table_cell_edit_link")));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new Label(GlobalizationUtil.globalize(
|
return new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_cell_edit_link"));
|
"cms.contenttyes.link.ui.table_cell_edit_link"));
|
||||||
}
|
}
|
||||||
} else if (column == m_delCol.getModelIndex()) {
|
} else if (column == m_delCol.getModelIndex()) {
|
||||||
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
if (Boolean.TRUE.equals(m_editor.get(state))) {
|
||||||
return new ControlLink( new Label(GlobalizationUtil.globalize(
|
return new ControlLink(new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_cell_delete_link")) );
|
"cms.contenttyes.link.ui.table_cell_delete_link")));
|
||||||
} else {
|
} else {
|
||||||
return new Label(GlobalizationUtil.globalize(
|
return new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_cell_delete_link"));
|
"cms.contenttyes.link.ui.table_cell_delete_link"));
|
||||||
}
|
}
|
||||||
} else if (column == m_moveUpCol.getModelIndex()) {
|
} else if (column == m_moveUpCol.getModelIndex()) {
|
||||||
if (Boolean.TRUE.equals(m_editor.get(state)) && !isFirst) {
|
if (Boolean.TRUE.equals(m_editor.get(state)) && !isFirst) {
|
||||||
Label upLabel = new Label(GlobalizationUtil.globalize(
|
Label upLabel = new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_cell_move_up"));
|
"cms.contenttyes.link.ui.table_cell_move_up"));
|
||||||
upLabel.setClassAttr("linkSort");
|
upLabel.setClassAttr("linkSort");
|
||||||
return new ControlLink(upLabel);
|
return new ControlLink(upLabel);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -252,7 +254,7 @@ public class LinkTable extends Table {
|
||||||
} else if (column == m_moveDownCol.getModelIndex()) {
|
} else if (column == m_moveDownCol.getModelIndex()) {
|
||||||
if (Boolean.TRUE.equals(m_editor.get(state)) && !isLast) {
|
if (Boolean.TRUE.equals(m_editor.get(state)) && !isLast) {
|
||||||
Label downLabel = new Label(GlobalizationUtil.globalize(
|
Label downLabel = new Label(GlobalizationUtil.globalize(
|
||||||
"cms.contenttyes.link.ui.table_cell_move_down"));
|
"cms.contenttyes.link.ui.table_cell_move_down"));
|
||||||
downLabel.setClassAttr("linkSort");
|
downLabel.setClassAttr("linkSort");
|
||||||
return new ControlLink(downLabel);
|
return new ControlLink(downLabel);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue