RelatedLinks: title-column can be used for captions

git-svn-id: https://svn.libreccm.org/ccm/trunk@3454 8810af33-2d31-482b-a856-94f89814c4df
master
konermann 2015-06-03 13:21:06 +00:00
parent 88fb5966da
commit 9e7b5ad380
7 changed files with 170 additions and 145 deletions

View File

@ -7,3 +7,5 @@ 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.add_link=Add a Link
cms.contentassets.ui.related_link.caption=Caption: cms.contentassets.ui.related_link.caption=Caption:
cms.contentassets.ui.related_link.Description=Description/Caption: cms.contentassets.ui.related_link.Description=Description/Caption:
cms.contentassets.ui.related_link.title=Title:
cms.contentassets.ui.related_link.description=Description:

View File

@ -7,3 +7,5 @@ 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.add_link=Link hinzuf\u00fcgen
cms.contentassets.ui.related_link.caption=Zwischentitel: cms.contentassets.ui.related_link.caption=Zwischentitel:
cms.contentassets.ui.related_link.Description=Beschreibung/Zwischentitel: cms.contentassets.ui.related_link.Description=Beschreibung/Zwischentitel:
cms.contentassets.ui.related_link.title=Titel:
cms.contentassets.ui.related_link.description=Beschreibung:

View File

@ -9,6 +9,7 @@ import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.RelatedLink; import com.arsdigita.cms.contentassets.RelatedLink;
import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel; import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel;
@ -39,10 +40,11 @@ public class RelatedLinkCaptionEditForm extends RelatedLinkCaptionForm {
RelatedLink link; RelatedLink link;
if (m_linkModel.isSelected(state)) { if (m_linkModel.isSelected(state)) {
link = (RelatedLink) m_linkModel.getSelectedLink(state); link = (RelatedLink) m_linkModel.getSelectedLink(state);
if (link.getTitle().equals("caption")) { if (link.getTargetURI().equals("caption")) {
//make this form visible because we are editing and it is a caption not a link //make this form visible because we are editing and it is a caption not a link
setVisible(state, true); setVisible(state, true);
} }
m_title.setValue(state, link.getTitle());
m_description.setValue(state, link.getDescription()); m_description.setValue(state, link.getDescription());
} }
} }

View File

@ -32,8 +32,10 @@ import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.DHTMLEditor;
import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringLengthValidationListener; import com.arsdigita.bebop.parameters.StringLengthValidationListener;
import com.arsdigita.cms.CMSConfig; import com.arsdigita.cms.CMSConfig;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
@ -73,6 +75,7 @@ public class RelatedLinkCaptionForm extends FormSection
public static final String SSL_PROTOCOL = "https://"; public static final String SSL_PROTOCOL = "https://";
public static final String HTTP_PROTOCOL = "http://"; public static final String HTTP_PROTOCOL = "http://";
protected TextArea m_description; protected TextArea m_description;
protected TextArea m_title;
protected ItemSelectionModel m_itemModel; protected ItemSelectionModel m_itemModel;
protected LinkSelectionModel m_linkModel; protected LinkSelectionModel m_linkModel;
private SaveCancelSection m_saveCancelSection; private SaveCancelSection m_saveCancelSection;
@ -128,14 +131,17 @@ public class RelatedLinkCaptionForm extends FormSection
* Adds widgets to the form. * Adds widgets to the form.
*/ */
protected void addWidgets() { protected void addWidgets() {
m_title = new DHTMLEditor("captiontitle");
add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.title")));
add(m_title);
/* Add the standard description field */ /* Add the standard description field */
m_description = new TextArea("description"); m_description = new DHTMLEditor("description");
m_description.setCols(40); m_description.addValidationListener(new NotNullValidationListener());
m_description.setRows(5);
m_description.addValidationListener(new StringLengthValidationListener(CMSConfig m_description.addValidationListener(new StringLengthValidationListener(CMSConfig
.getInstanceOf().getLinkDescMaxLength())); .getInstanceOf().getLinkDescMaxLength()));
add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.caption"))); add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.Description")));
add(m_description); add(m_description);
} }
@ -231,6 +237,8 @@ public class RelatedLinkCaptionForm extends FormSection
public void validate(FormSectionEvent event) public void validate(FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
} }
/** /**
@ -278,6 +286,7 @@ public class RelatedLinkCaptionForm extends FormSection
s_log.debug("Init"); s_log.debug("Init");
s_log.debug("new link"); s_log.debug("new link");
m_description.setValue(state, null); m_description.setValue(state, null);
m_title.setValue(state,null);
} }
/** /**
@ -328,10 +337,17 @@ public class RelatedLinkCaptionForm extends FormSection
protected void setLinkProperties(RelatedLink link, FormSectionEvent fse) { protected void setLinkProperties(RelatedLink link, FormSectionEvent fse) {
PageState state = fse.getPageState(); PageState state = fse.getPageState();
FormData data = fse.getFormData(); FormData data = fse.getFormData();
link.setTitle("caption");
String title = (String) m_title.getValue(state);
if(!title.isEmpty()){
link.setTitle(title);
} else {
//if user did not typed in a title
link.setTitle(" ");
}
link.setDescription((String) m_description.getValue(state)); link.setDescription((String) m_description.getValue(state));
link.setTargetType(RelatedLink.EXTERNAL_LINK); link.setTargetType(RelatedLink.EXTERNAL_LINK);
link.setTargetURI(null); link.setTargetURI("caption");
link.setTargetWindow(""); link.setTargetWindow("");
link.setResourceSize(""); link.setResourceSize("");
link.setResourceType(MimeType.loadMimeType("text/html")); link.setResourceType(MimeType.loadMimeType("text/html"));

View File

@ -88,7 +88,7 @@ public class RelatedLinkEditForm extends RelatedLinkPropertyForm {
if (getLinkSelectionModel().isSelected(ps)) { if (getLinkSelectionModel().isSelected(ps)) {
rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps); rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps);
if (!rl.getTitle().equals("caption")) { if (!rl.getTargetURI().equals("caption")) {
//make this form visible because we are editing and its not a caption //make this form visible because we are editing and its not a caption
setVisible(ps, true); setVisible(ps, true);
} }

View File

@ -62,16 +62,16 @@ import java.net.URL;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Form to edit the basic properties of an Link. This form can be extended to create forms for Link * Form to edit the basic properties of an Link. This form can be extended to
* subclasses. * create forms for Link subclasses.
* *
* @version $Revision: #5 $ $Date: 2004/08/17 $ * @version $Revision: #5 $ $Date: 2004/08/17 $
* @author Nobuko Asakai (nasakai@redhat.com) * @author Nobuko Asakai (nasakai@redhat.com)
* @author Sören Bernstein <quasi@quasiweb.de> * @author Sören Bernstein <quasi@quasiweb.de>
*/ */
public class LinkPropertyForm extends FormSection public class LinkPropertyForm extends FormSection
implements FormInitListener, FormProcessListener, implements FormInitListener, FormProcessListener,
FormValidationListener, FormSubmissionListener { FormValidationListener, FormSubmissionListener {
private static final Logger s_log = Logger.getLogger(LinkPropertyForm.class); private static final Logger s_log = Logger.getLogger(LinkPropertyForm.class);
@ -95,29 +95,29 @@ public class LinkPropertyForm extends FormSection
protected final String ITEM_SEARCH = "contentItem"; protected final String ITEM_SEARCH = "contentItem";
/** /**
* Constructor creates a new form to edit the Link object specified by the item selection model * Constructor creates a new form to edit the Link object specified by the
* passed in. * item 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 LinkPropertyForm(ItemSelectionModel itemModel, public LinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel link) { LinkSelectionModel link) {
this(itemModel, link, null); this(itemModel, link, null);
} }
/** /**
* Constructor creates a new form to edit the Link object specified by the item selection model * Constructor creates a new form to edit the Link object specified by the
* passed in. * item selection model passed in.
* *
* @param itemModel * @param itemModel
* @param link * @param link
* @param contentType * @param contentType
*/ */
public LinkPropertyForm(ItemSelectionModel itemModel, public LinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel link, LinkSelectionModel link,
ContentType contentType) { ContentType contentType) {
super(new ColumnPanel(2)); super(new ColumnPanel(2));
@ -153,14 +153,14 @@ public class LinkPropertyForm extends FormSection
m_description.setCols(40); m_description.setCols(40);
m_description.setRows(5); m_description.setRows(5);
m_description.addValidationListener(new StringLengthValidationListener(CMSConfig m_description.addValidationListener(new StringLengthValidationListener(CMSConfig
.getInstanceOf().getLinkDescMaxLength())); .getInstanceOf().getLinkDescMaxLength()));
add(new Label(GlobalizationUtil.globalize( add(new Label(GlobalizationUtil.globalize(
"cms.contenttypes.ui.description"))); "cms.contenttypes.ui.description")));
add(m_description); add(m_description);
//add(new Label( //add(new Label(
add(new Embedded( add(new Embedded(
"<script language=\"javascript\">\n" "<script language=\"javascript\">\n"
+ "<!-- \n" + "<!-- \n"
+ "function toggle_link_fields(status) { \n" + "function toggle_link_fields(status) { \n"
+ "// document.forms['linkEditForm'].targetURI.disabled = status; \n" + "// document.forms['linkEditForm'].targetURI.disabled = status; \n"
@ -188,27 +188,27 @@ public class LinkPropertyForm extends FormSection
+ "} \n" + "} \n"
+ "// -->\n" + "// -->\n"
+ "</script>\n", + "</script>\n",
false)); false));
/* Sub-title external URL / internal URL (content item) */ /* Sub-title external URL / internal URL (content item) */
add(new Label(GlobalizationUtil.globalize( add(new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.link_type_subtitle"), "cms.contenttyes.link.ui.link_type_subtitle"),
Label.BOLD), Label.BOLD),
ColumnPanel.FULL_WIDTH); ColumnPanel.FULL_WIDTH);
/* Option group to choose either external oder internal */ /* Option group to choose either external oder internal */
m_linkType = new RadioGroup("linkType"); m_linkType = new RadioGroup("linkType");
Option m_external = new Option( Option m_external = new Option(
Link.EXTERNAL_LINK, Link.EXTERNAL_LINK,
new Label(GlobalizationUtil.globalize( new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.option_group.link_type.external"))); "cms.contenttyes.link.ui.option_group.link_type.external")));
m_external.setOnClick("enableUrlFields()"); m_external.setOnClick("enableUrlFields()");
Option m_internal = new Option( Option m_internal = new Option(
Link.INTERNAL_LINK, Link.INTERNAL_LINK,
new Label(GlobalizationUtil.globalize( new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.option_group.link_type.internal"))); "cms.contenttyes.link.ui.option_group.link_type.internal")));
m_internal.setOnClick("enableItemFields()"); m_internal.setOnClick("enableItemFields()");
m_linkType.addOption(m_external); m_linkType.addOption(m_external);
@ -216,28 +216,28 @@ public class LinkPropertyForm extends FormSection
m_linkType.setOptionSelected(m_internal); m_linkType.setOptionSelected(m_internal);
m_linkType.addValidationListener(new NotNullValidationListener()); m_linkType.addValidationListener(new NotNullValidationListener());
add(new Label(GlobalizationUtil.globalize( add(new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.option_group.link_type.label"))); "cms.contenttyes.link.ui.option_group.link_type.label")));
add(m_linkType); add(m_linkType);
/* External target */ /* External target */
Fieldset externalFieldset = new Fieldset(GlobalizationUtil.globalize( Fieldset externalFieldset = new Fieldset(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.target_uri")); "cms.contenttyes.link.ui.target_uri"));
externalFieldset.setClassAttr("externalLink autoHide"); externalFieldset.setClassAttr("externalLink autoHide");
m_targetURI = new TextField("targetURI"); m_targetURI = new TextField("targetURI");
m_targetURI.setOnFocus("toggle_link_fields(false)"); m_targetURI.setOnFocus("toggle_link_fields(false)");
m_targetURI.setHint(GlobalizationUtil.globalize( m_targetURI.setHint(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.target_uri_hint")); "cms.contenttyes.link.ui.target_uri_hint"));
externalFieldset.add(new Label(GlobalizationUtil.globalize( externalFieldset.add(new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.target_uri"))); "cms.contenttyes.link.ui.target_uri")));
externalFieldset.add(m_targetURI); externalFieldset.add(m_targetURI);
add(externalFieldset); add(externalFieldset);
/* Internal target */ /* Internal target */
Fieldset internalFieldset = new Fieldset(GlobalizationUtil.globalize( Fieldset internalFieldset = new Fieldset(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.target_content_item")); "cms.contenttyes.link.ui.target_content_item"));
internalFieldset.setClassAttr("internalLink autoHide"); internalFieldset.setClassAttr("internalLink autoHide");
internalFieldset.add(new Label(GlobalizationUtil.globalize( internalFieldset.add(new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.target_content_item"))); "cms.contenttyes.link.ui.target_content_item")));
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, m_contentType); m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, m_contentType);
m_itemSearch.getSearchButton().setOnFocus("toggle_link_fields(true)"); m_itemSearch.getSearchButton().setOnFocus("toggle_link_fields(true)");
m_itemSearch.getClearButton().setOnFocus("toggle_link_fields(true)"); m_itemSearch.getClearButton().setOnFocus("toggle_link_fields(true)");
@ -245,11 +245,11 @@ public class LinkPropertyForm extends FormSection
/* Optional parameters for internal target */ /* Optional parameters for internal target */
internalFieldset.add(new Label(GlobalizationUtil.globalize( internalFieldset.add(new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.target_parameters"))); "cms.contenttyes.link.ui.target_parameters")));
m_itemParams = new TextField("itemParams"); m_itemParams = new TextField("itemParams");
m_itemParams.setOnFocus("toggle_link_fields(true)"); m_itemParams.setOnFocus("toggle_link_fields(true)");
m_itemParams.setHint(GlobalizationUtil.globalize( m_itemParams.setHint(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.target_parameters_hint")); "cms.contenttyes.link.ui.target_parameters_hint"));
internalFieldset.add(m_itemParams); internalFieldset.add(m_itemParams);
add(internalFieldset); add(internalFieldset);
@ -260,9 +260,9 @@ public class LinkPropertyForm extends FormSection
// cms_links to cms_related_links which shoud become ca_related_links // cms_links to cms_related_links which shoud become ca_related_links
/* Single option whether to open in new window, strongly discouraged!*/ /* Single option whether to open in new window, strongly discouraged!*/
Option m_selectWindow = new Option( Option m_selectWindow = new Option(
Link.TARGET_WINDOW, Link.TARGET_WINDOW,
new Label(GlobalizationUtil.globalize( new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.option.new_window"))); "cms.contenttyes.link.ui.option.new_window")));
// "Open URL in new window"); // "Open URL in new window");
m_URIOption = new CheckboxGroup("openOption"); m_URIOption = new CheckboxGroup("openOption");
m_URIOption.addOption(m_selectWindow); m_URIOption.addOption(m_selectWindow);
@ -270,7 +270,7 @@ public class LinkPropertyForm extends FormSection
//add(new Label( //add(new Label(
add(new Embedded( add(new Embedded(
"<script language=\"javascript\">\n" "<script language=\"javascript\">\n"
+ "<!-- \n" + "<!-- \n"
+ "if (document.forms['linkEditForm'].linkType[0].checked) { \n" + "if (document.forms['linkEditForm'].linkType[0].checked) { \n"
+ " //toggle_link_fields(false); \n" + " //toggle_link_fields(false); \n"
@ -281,7 +281,7 @@ public class LinkPropertyForm extends FormSection
+ "} \n" + "} \n"
+ "// -->\n" + "// -->\n"
+ "</script>\n", + "</script>\n",
false), ColumnPanel.FULL_WIDTH); false), ColumnPanel.FULL_WIDTH);
} }
/** /**
@ -291,37 +291,37 @@ public class LinkPropertyForm extends FormSection
m_saveCancelSection = new SaveCancelSection(); m_saveCancelSection = new SaveCancelSection();
try { try {
m_saveCancelSection.getCancelButton().addPrintListener( m_saveCancelSection.getCancelButton().addPrintListener(
new PrintListener() { new PrintListener() {
@Override @Override
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
Submit target = (Submit) e.getTarget(); Submit target = (Submit) e.getTarget();
if (m_linkModel.isSelected(e.getPageState())) { if (m_linkModel.isSelected(e.getPageState())) {
target.setButtonLabel(GlobalizationUtil.globalize( target.setButtonLabel(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.button_cancel")); "cms.contenttyes.link.ui.button_cancel"));
} else { } else {
target.setButtonLabel(GlobalizationUtil.globalize( target.setButtonLabel(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.button_reset")); "cms.contenttyes.link.ui.button_reset"));
}
} }
}
}); });
m_saveCancelSection.getSaveButton().addPrintListener( m_saveCancelSection.getSaveButton().addPrintListener(
new PrintListener() { new PrintListener() {
@Override @Override
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
Submit target = (Submit) e.getTarget(); Submit target = (Submit) e.getTarget();
if (m_linkModel.isSelected(e.getPageState())) { if (m_linkModel.isSelected(e.getPageState())) {
target.setButtonLabel(GlobalizationUtil.globalize( target.setButtonLabel(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.button_save")); "cms.contenttyes.link.ui.button_save"));
} else { } else {
target.setButtonLabel(GlobalizationUtil.globalize( target.setButtonLabel(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.button_create")); "cms.contenttyes.link.ui.button_create"));
}
} }
}
}); });
} catch (TooManyListenersException e) { } catch (TooManyListenersException e) {
throw new UncheckedWrapperException("this cannot happen", e); throw new UncheckedWrapperException("this cannot happen", e);
} }
@ -353,7 +353,7 @@ public class LinkPropertyForm extends FormSection
*/ */
@Override @Override
public void submitted(FormSectionEvent e) public void submitted(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
if (m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) { if (m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) {
s_log.debug("cancel in submission listener"); s_log.debug("cancel in submission listener");
m_linkModel.clearSelection(e.getPageState()); m_linkModel.clearSelection(e.getPageState());
@ -364,7 +364,8 @@ public class LinkPropertyForm extends FormSection
} }
/** /**
* Validation listener. Ensures consistency of internal vs. external link data * Validation listener. Ensures consistency of internal vs. external link
* data
* *
* @param event the FormSectionEvent * @param event the FormSectionEvent
* *
@ -372,7 +373,7 @@ public class LinkPropertyForm extends FormSection
*/ */
@Override @Override
public void validate(FormSectionEvent event) public void validate(FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
PageState state = event.getPageState(); PageState state = event.getPageState();
FormData data = event.getFormData(); FormData data = event.getFormData();
@ -381,7 +382,7 @@ public class LinkPropertyForm extends FormSection
String externalURI = (String) m_targetURI.getValue(state); String externalURI = (String) m_targetURI.getValue(state);
if (externalURI == null || externalURI.length() == 0) { if (externalURI == null || externalURI.length() == 0) {
throw new FormProcessException(GlobalizationUtil.globalize( throw new FormProcessException(GlobalizationUtil.globalize(
"cms.contenttypes.ui.external_link_requires_uri_field")); "cms.contenttypes.ui.external_link_requires_uri_field"));
} }
String url = (String) m_targetURI.getValue(state); String url = (String) m_targetURI.getValue(state);
@ -399,7 +400,7 @@ public class LinkPropertyForm extends FormSection
// "http://servername" on the front // "http://servername" on the front
newURL = HTTP_PROTOCOL + Web.getConfig().getHost() newURL = HTTP_PROTOCOL + Web.getConfig().getHost()
+ url; + url;
} else if (!hasProtocol) { } else if (!hasProtocol) {
// There's no protocol. See if it would be ok if we // There's no protocol. See if it would be ok if we
// put one on the beginning // put one on the beginning
@ -419,18 +420,18 @@ public class LinkPropertyForm extends FormSection
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
/* excluded by Tobias Osmers to change the FormProcessException /* excluded by Tobias Osmers to change the FormProcessException
if (localLink) { if (localLink) {
// For local link, report the error after we put a // For local link, report the error after we put a
// protocol and servername on it // protocol and servername on it
msg.append("Local URL is not valid: "); msg.append("Local URL is not valid: ");
msg.append(ex2.getMessage()); msg.append(ex2.getMessage());
} else { } else {
// For external link, report the error before we tried // For external link, report the error before we tried
// to munge it // to munge it
msg.append("External URL is not valid: "); msg.append("External URL is not valid: ");
msg.append(ex.getMessage()); msg.append(ex.getMessage());
} }
*/ */
throw new FormProcessException(GlobalizationUtil.globalize( throw new FormProcessException(GlobalizationUtil.globalize(
"cms.contenttypes.ui.url_not_valid")); "cms.contenttypes.ui.url_not_valid"));
} }
@ -440,20 +441,20 @@ public class LinkPropertyForm extends FormSection
if (!localLink && !hasProtocol) { if (!localLink && !hasProtocol) {
m_targetURI.setValue(state, newURL); m_targetURI.setValue(state, newURL);
throw new FormProcessException( throw new FormProcessException(
GlobalizationUtil.globalize("cms.contenttypes.ui.url_missing_protocol")); GlobalizationUtil.globalize("cms.contenttypes.ui.url_missing_protocol"));
} }
} }
} else if (Link.INTERNAL_LINK.equals((String) m_linkType.getValue( } else if (Link.INTERNAL_LINK.equals((String) m_linkType.getValue(
state))) { state))) {
// The link is internal, the item selected must be not null // The link is internal, the item selected must be not null
if (data.get(ITEM_SEARCH) == null) { if (data.get(ITEM_SEARCH) == null) {
throw new FormProcessException( throw new FormProcessException(
GlobalizationUtil.globalize("cms.contenttypes.ui.internal_link_requires_item_selection")); GlobalizationUtil.globalize("cms.contenttypes.ui.internal_link_requires_item_selection"));
} }
// Quasimodo // Quasimodo
// The target of the link must not be the same as the owner // The target of the link must not be the same as the owner
if (m_itemModel.getSelectedItem(state).getID().equals( if (m_itemModel.getSelectedItem(state).getID().equals(
((ContentItem) data.get(ITEM_SEARCH)).getID())) { ((ContentItem) data.get(ITEM_SEARCH)).getID())) {
throw new FormProcessException(GlobalizationUtil.globalize( throw new FormProcessException(GlobalizationUtil.globalize(
"cms.contenttypes.ui.false_link_target")); "cms.contenttypes.ui.false_link_target"));
} }
@ -495,7 +496,7 @@ 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;
@ -503,16 +504,18 @@ public class LinkPropertyForm extends FormSection
s_log.debug("Edit"); s_log.debug("Edit");
link = m_linkModel.getSelectedLink(state); link = m_linkModel.getSelectedLink(state);
if(link.getTitle().equals("caption")){ if (link.getTargetURI()!= null && link.getTargetURI().equals("caption")) {
setVisible(state,false); setVisible(state, false);
} }
try { try {
m_title.setValue(state, link.getTitle()); if(link.getTitle()!=null){
m_title.setValue(state, link.getTitle());}
m_description.setValue(state, link.getDescription()); m_description.setValue(state, link.getDescription());
if ((link.getTargetURI() != null) if ((link.getTargetURI() != null)
&& (!link.getTargetURI().equals("caption"))
&& link.getTargetURI().startsWith("&")) { && link.getTargetURI().startsWith("&")) {
m_itemParams.setValue(state, m_itemParams.setValue(state,
link.getTargetURI().substring(1)); link.getTargetURI().substring(1));
} else { } else {
m_targetURI.setValue(state, link.getTargetURI()); m_targetURI.setValue(state, link.getTargetURI());
} }
@ -574,7 +577,7 @@ public class LinkPropertyForm extends FormSection
//call to set various properties of Link. //call to set various properties of Link.
setLinkProperties(link, fse); setLinkProperties(link, fse);
s_log.debug("Created Link with ID: " + link.getOID().toString() s_log.debug("Created Link with ID: " + link.getOID().toString()
+ "Title " + link.getTitle()); + "Title " + link.getTitle());
} }
// XXX Initialize the form // XXX Initialize the form
m_linkModel.clearSelection(state); m_linkModel.clearSelection(state);
@ -582,8 +585,8 @@ public class LinkPropertyForm extends FormSection
} }
/** /**
* Set various properties of the Link.Child clases can over-ride this method to add additional * Set various properties of the Link.Child clases can over-ride this method
* properties to Link. * to add additional properties to Link.
* *
* @param link * @param link
* @param fse * @param fse
@ -599,7 +602,7 @@ public class LinkPropertyForm extends FormSection
// Process internal and external urls // Process internal and external urls
if (Link.EXTERNAL_LINK.equals(m_linkType.getValue(state))) { if (Link.EXTERNAL_LINK.equals(m_linkType.getValue(state))) {
link.setTargetURI( link.setTargetURI(
(String) m_targetURI.getValue(state)); (String) m_targetURI.getValue(state));
link.setTargetItem(null); link.setTargetItem(null);
} else { } else {
// Internal // Internal
@ -607,7 +610,7 @@ public class LinkPropertyForm extends FormSection
link.setTargetURI(null); link.setTargetURI(null);
} else { } else {
link.setTargetURI(String.format("&%s", m_itemParams.getValue( link.setTargetURI(String.format("&%s", m_itemParams.getValue(
state))); state)));
} }
// Quasimodo: BEGIN // Quasimodo: BEGIN

View File

@ -204,16 +204,16 @@ public class LinkTable extends Table {
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);
if (link.getTitle().equals("caption")) { if (link.getTargetURI()!=null && link.getTargetURI().equals("caption")) {
ExternalLink extLink = new ExternalLink("", url); Label label = new Label(link.getTitle());
extLink.setTargetFrame("_blank"); return label;
return extLink;
} else {
ExternalLink extLink = new ExternalLink(link.getTitle(), url);
extLink.setTargetFrame("_blank");
return extLink;
} }
String url = link.getInternalOrExternalURI(state);
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);