RelatedLinks
* RelatedLinks bzw. Links so erweitert, daß man den gewünschten CT angeben kann git-svn-id: https://svn.libreccm.org/ccm/trunk@562 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
a6e26d4566
commit
57c8e789a5
|
|
@ -25,6 +25,7 @@ import com.arsdigita.bebop.form.TextField;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.ContentSection;
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.contenttypes.Link;
|
import com.arsdigita.cms.contenttypes.Link;
|
||||||
import com.arsdigita.cms.contenttypes.ui.LinkPropertyForm;
|
import com.arsdigita.cms.contenttypes.ui.LinkPropertyForm;
|
||||||
|
|
@ -45,10 +46,10 @@ import com.arsdigita.util.Assert;
|
||||||
* @version $Revision: #3 $ $Date: 2004/03/30 $
|
* @version $Revision: #3 $ $Date: 2004/03/30 $
|
||||||
* @author Scott Seago (sseago@redhat.com)
|
* @author Scott Seago (sseago@redhat.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||||
|
|
||||||
private static boolean isHideAdditionalResourceFields;
|
private static boolean isHideAdditionalResourceFields;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields();
|
isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields();
|
||||||
}
|
}
|
||||||
|
|
@ -61,17 +62,24 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||||
* @param link The LinkSelectionModel to use to obtain the
|
* @param link The LinkSelectionModel to use to obtain the
|
||||||
* Link to work on
|
* Link to work on
|
||||||
*/
|
*/
|
||||||
public RelatedLinkPropertyForm( ItemSelectionModel itemModel,
|
public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
|
||||||
LinkSelectionModel link ) {
|
LinkSelectionModel link) {
|
||||||
|
|
||||||
super(itemModel, link);
|
super(itemModel, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
|
||||||
|
LinkSelectionModel link, ContentType contentType) {
|
||||||
|
|
||||||
|
super(itemModel, link, contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void addWidgets() {
|
protected void addWidgets() {
|
||||||
|
|
||||||
super.addWidgets();
|
super.addWidgets();
|
||||||
|
|
||||||
if ( isHideAdditionalResourceFields ) {
|
if (isHideAdditionalResourceFields) {
|
||||||
// Do nothing except protect the poor users from themselves.
|
// Do nothing except protect the poor users from themselves.
|
||||||
} else {
|
} else {
|
||||||
//Hack to get the form layout right.
|
//Hack to get the form layout right.
|
||||||
|
|
@ -103,7 +111,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||||
public static void addMimeOptions(SingleSelect w) {
|
public static void addMimeOptions(SingleSelect w) {
|
||||||
MimeTypeCollection types;
|
MimeTypeCollection types;
|
||||||
types = MimeType.getAllMimeTypes();
|
types = MimeType.getAllMimeTypes();
|
||||||
while(types.next()) {
|
while (types.next()) {
|
||||||
MimeType type = types.getMimeType();
|
MimeType type = types.getMimeType();
|
||||||
w.addOption(new Option(type.getMimeType(), type.getLabel()));
|
w.addOption(new Option(type.getMimeType(), type.getLabel()));
|
||||||
}
|
}
|
||||||
|
|
@ -138,20 +146,20 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||||
FormData data = fse.getFormData();
|
FormData data = fse.getFormData();
|
||||||
PageState ps = fse.getPageState();
|
PageState ps = fse.getPageState();
|
||||||
RelatedLink rl;
|
RelatedLink rl;
|
||||||
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)) {
|
if (getLinkSelectionModel().isSelected(ps)) {
|
||||||
//We are editing the link , populate our addtional fields.
|
//We are editing the link , populate our addtional fields.
|
||||||
rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps);
|
rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps);
|
||||||
data.put(RelatedLink.RESOURCE_SIZE , rl.getResourceSize());
|
data.put(RelatedLink.RESOURCE_SIZE, rl.getResourceSize());
|
||||||
if(rl.getResourceType() != null){
|
if (rl.getResourceType() != null) {
|
||||||
data.put(RelatedLink.RESOURCE_TYPE , rl.getResourceType().getMimeType());
|
data.put(RelatedLink.RESOURCE_TYPE, rl.getResourceType().getMimeType());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// New Link creation , clear the fields.
|
// New Link creation , clear the fields.
|
||||||
data.put(RelatedLink.RESOURCE_SIZE , null);
|
data.put(RelatedLink.RESOURCE_SIZE, null);
|
||||||
data.put(RelatedLink.RESOURCE_TYPE , null);
|
data.put(RelatedLink.RESOURCE_TYPE, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -160,19 +168,19 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||||
* over-ride super class method to set extended properties for
|
* over-ride super class method to set extended properties for
|
||||||
* <code>RelatedLink</code>.
|
* <code>RelatedLink</code>.
|
||||||
*/
|
*/
|
||||||
protected void setLinkProperties(Link link , FormSectionEvent fse){
|
protected void setLinkProperties(Link link, FormSectionEvent fse) {
|
||||||
RelatedLink rl = (RelatedLink) (link);
|
RelatedLink rl = (RelatedLink) (link);
|
||||||
FormData data = fse.getFormData();
|
FormData data = fse.getFormData();
|
||||||
if ( isHideAdditionalResourceFields ) {
|
if (isHideAdditionalResourceFields) {
|
||||||
// We are not using these but let's try to set some reasonable defaults.
|
// We are not using these but let's try to set some reasonable defaults.
|
||||||
rl.setResourceSize( "" );
|
rl.setResourceSize("");
|
||||||
rl.setResourceType(MimeType.loadMimeType("text/html"));
|
rl.setResourceType(MimeType.loadMimeType("text/html"));
|
||||||
} else {
|
} else {
|
||||||
rl.setResourceSize( (String) data.get(RelatedLink.RESOURCE_SIZE));
|
rl.setResourceSize((String) data.get(RelatedLink.RESOURCE_SIZE));
|
||||||
String typeName = (String) data.get(RelatedLink.RESOURCE_TYPE);
|
String typeName = (String) data.get(RelatedLink.RESOURCE_TYPE);
|
||||||
MimeType mType = MimeType.loadMimeType(typeName);
|
MimeType mType = MimeType.loadMimeType(typeName);
|
||||||
rl.setResourceType(mType);
|
rl.setResourceType(mType);
|
||||||
}
|
}
|
||||||
super.setLinkProperties(link , fse);
|
super.setLinkProperties(link, fse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@ import com.arsdigita.cms.*;
|
||||||
|
|
||||||
object type RelationAttribute extends ContentItem {
|
object type RelationAttribute extends ContentItem {
|
||||||
|
|
||||||
String[1..1] attribute = cms_contacttypes.attribute VARCHAR(100);
|
String[1..1] attribute = cms_relation_attribute.attribute VARCHAR(100);
|
||||||
String[1..1] key = cms_contacttypes.key VARCHAR(100);
|
String[1..1] key = cms_relation_attribute.key VARCHAR(100);
|
||||||
String[1..1] lang = cms_contacttypes.lang VARCHAR(2);
|
String[1..1] lang = cms_relation_attribute.lang VARCHAR(2);
|
||||||
// String[1..1] name = cms_contacttypes.name VARCHAR(100);
|
// String[1..1] name = cms_relation_attribute.name VARCHAR(100);
|
||||||
String[0..1] description = cms_contacttypes.description VARCHAR(500);
|
String[0..1] description = cms_relation_attribute.description VARCHAR(500);
|
||||||
|
|
||||||
unique (attribute, key, lang);
|
unique (attribute, key, lang);
|
||||||
reference key(cms_relationAttribute.relationattribute_id);
|
reference key(cms_relationAttribute.relationattribute_id);
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ import com.arsdigita.util.UncheckedWrapperException;
|
||||||
import com.arsdigita.web.Web;
|
import com.arsdigita.web.Web;
|
||||||
|
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.contenttypes.Link;
|
import com.arsdigita.cms.contenttypes.Link;
|
||||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
|
|
@ -62,16 +63,14 @@ import org.apache.log4j.Logger;
|
||||||
* @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)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class LinkPropertyForm extends FormSection
|
public class LinkPropertyForm extends FormSection
|
||||||
implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener {
|
implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener {
|
||||||
private static final Logger s_log = Logger.getLogger(LinkPropertyForm.class);
|
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(LinkPropertyForm.class);
|
||||||
/** Name of this form */
|
/** Name of this form */
|
||||||
public static final String ID = "link_edit";
|
public static final String ID = "link_edit";
|
||||||
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://";
|
||||||
|
|
||||||
private TextArea m_description;
|
private TextArea m_description;
|
||||||
private TextField m_title;
|
private TextField m_title;
|
||||||
private TextField m_targetURI;
|
private TextField m_targetURI;
|
||||||
|
|
@ -81,8 +80,8 @@ public class LinkPropertyForm extends FormSection
|
||||||
private LinkSelectionModel m_linkModel;
|
private LinkSelectionModel m_linkModel;
|
||||||
private SaveCancelSection m_saveCancelSection;
|
private SaveCancelSection m_saveCancelSection;
|
||||||
private ItemSearchWidget m_itemSearch;
|
private ItemSearchWidget m_itemSearch;
|
||||||
|
private ContentType m_contentType;
|
||||||
private final String ITEM_SEARCH ="contentItem";
|
private final String ITEM_SEARCH = "contentItem";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new form to edit the Link object specified
|
* Creates a new form to edit the Link object specified
|
||||||
|
|
@ -92,12 +91,18 @@ public class LinkPropertyForm extends FormSection
|
||||||
* @param link The LinkSelectionModel to use to obtain the
|
* @param link The LinkSelectionModel to use to obtain the
|
||||||
* Link to work on
|
* Link to work on
|
||||||
*/
|
*/
|
||||||
public LinkPropertyForm( ItemSelectionModel itemModel,
|
public LinkPropertyForm(ItemSelectionModel itemModel,
|
||||||
LinkSelectionModel link ) {
|
LinkSelectionModel link) {
|
||||||
|
this(itemModel, link, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkPropertyForm(ItemSelectionModel itemModel,
|
||||||
|
LinkSelectionModel link, ContentType contentType) {
|
||||||
super(new ColumnPanel(2));
|
super(new ColumnPanel(2));
|
||||||
s_log.debug("property form constructor");
|
s_log.debug("property form constructor");
|
||||||
m_linkModel = link;
|
m_linkModel = link;
|
||||||
m_itemModel = itemModel;
|
m_itemModel = itemModel;
|
||||||
|
m_contentType = contentType;
|
||||||
|
|
||||||
addWidgets();
|
addWidgets();
|
||||||
addSaveCancelSection();
|
addSaveCancelSection();
|
||||||
|
|
@ -122,27 +127,25 @@ public class LinkPropertyForm extends FormSection
|
||||||
m_description = new TextArea("description");
|
m_description = new TextArea("description");
|
||||||
m_description.setCols(40);
|
m_description.setCols(40);
|
||||||
m_description.setRows(5);
|
m_description.setRows(5);
|
||||||
add(new Label(GlobalizationUtil.
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.description")));
|
||||||
globalize("cms.contenttypes.ui.description")));
|
|
||||||
|
|
||||||
add(m_description);
|
add(m_description);
|
||||||
|
|
||||||
add(new Label(
|
add(new Label(
|
||||||
"<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"
|
||||||
" document.forms['linkEditForm'].openOption.disabled = status; \n" +
|
+ " document.forms['linkEditForm'].openOption.disabled = status; \n"
|
||||||
" document.forms['linkEditForm'].contentItem.disabled = !status; \n" +
|
+ " document.forms['linkEditForm'].contentItem.disabled = !status; \n"
|
||||||
" document.forms['linkEditForm'].contentItem_search.disabled = !status; \n" +
|
+ " document.forms['linkEditForm'].contentItem_search.disabled = !status; \n"
|
||||||
" document.forms['linkEditForm'].contentItem_clear.disabled = !status; \n" +
|
+ " document.forms['linkEditForm'].contentItem_clear.disabled = !status; \n"
|
||||||
"}\n" +
|
+ "}\n"
|
||||||
"// -->\n" +
|
+ "// -->\n"
|
||||||
"</script>\n",
|
+ "</script>\n",
|
||||||
false
|
false));
|
||||||
));
|
|
||||||
|
|
||||||
add(new Label( "Choose either a URL or a Content Item", Label.BOLD),
|
add(new Label("Choose either a URL or a Content Item", Label.BOLD),
|
||||||
ColumnPanel.FULL_WIDTH);
|
ColumnPanel.FULL_WIDTH);
|
||||||
m_linkType = new RadioGroup("linkType");
|
m_linkType = new RadioGroup("linkType");
|
||||||
Option m_external = new Option(Link.EXTERNAL_LINK, "URL");
|
Option m_external = new Option(Link.EXTERNAL_LINK, "URL");
|
||||||
|
|
@ -166,27 +169,26 @@ public class LinkPropertyForm extends FormSection
|
||||||
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("Enter a URL such as http://www.example.com/ or /ccm/forum/");
|
m_targetURI.setHint("Enter a URL such as http://www.example.com/ or /ccm/forum/");
|
||||||
add( new Label( "URL: " ) );
|
add(new Label("URL: "));
|
||||||
add( m_targetURI );
|
add(m_targetURI);
|
||||||
|
|
||||||
add(new Label("Content Item:"));
|
add(new Label("Content Item:"));
|
||||||
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH);
|
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)");
|
||||||
add(m_itemSearch);
|
add(m_itemSearch);
|
||||||
|
|
||||||
add(new Label(
|
add(new Label(
|
||||||
"<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"
|
||||||
"} else { \n" +
|
+ "} else { \n"
|
||||||
" toggle_link_fields(true); \n" +
|
+ " toggle_link_fields(true); \n"
|
||||||
"} \n" +
|
+ "} \n"
|
||||||
"// -->\n" +
|
+ "// -->\n"
|
||||||
"</script>\n",
|
+ "</script>\n",
|
||||||
false
|
false));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds the saveCancelSection */
|
/** Adds the saveCancelSection */
|
||||||
|
|
@ -195,28 +197,28 @@ public class LinkPropertyForm extends FormSection
|
||||||
try {
|
try {
|
||||||
m_saveCancelSection.getCancelButton().addPrintListener(
|
m_saveCancelSection.getCancelButton().addPrintListener(
|
||||||
new PrintListener() {
|
new PrintListener() {
|
||||||
|
|
||||||
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("Cancel");
|
target.setButtonLabel("Cancel");
|
||||||
} else {
|
} else {
|
||||||
target.setButtonLabel("Reset");
|
target.setButtonLabel("Reset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
m_saveCancelSection.getSaveButton().addPrintListener(
|
m_saveCancelSection.getSaveButton().addPrintListener(
|
||||||
new PrintListener() {
|
new PrintListener() {
|
||||||
|
|
||||||
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("Save");
|
target.setButtonLabel("Save");
|
||||||
} else {
|
} else {
|
||||||
target.setButtonLabel("Create");
|
target.setButtonLabel("Create");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
} catch (TooManyListenersException e) {
|
} catch (TooManyListenersException e) {
|
||||||
throw new UncheckedWrapperException("this cannot happen", e);
|
throw new UncheckedWrapperException("this cannot happen", e);
|
||||||
}
|
}
|
||||||
|
|
@ -229,7 +231,7 @@ public class LinkPropertyForm extends FormSection
|
||||||
}
|
}
|
||||||
|
|
||||||
/** return selection model for Link that we are dealing with. */
|
/** return selection model for Link that we are dealing with. */
|
||||||
protected LinkSelectionModel getLinkSelectionModel(){
|
protected LinkSelectionModel getLinkSelectionModel() {
|
||||||
return m_linkModel;
|
return m_linkModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -258,30 +260,30 @@ public class LinkPropertyForm extends FormSection
|
||||||
PageState state = event.getPageState();
|
PageState state = event.getPageState();
|
||||||
FormData data = event.getFormData();
|
FormData data = event.getFormData();
|
||||||
|
|
||||||
if (Link.EXTERNAL_LINK.equals((String)m_linkType.getValue(state))) {
|
if (Link.EXTERNAL_LINK.equals((String) m_linkType.getValue(state))) {
|
||||||
// The link is external, the URL must be valid and not null
|
// The link is external, the URL must be valid and not null
|
||||||
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("The URI field is required for an external link.");
|
throw new FormProcessException("The URI field is required for an external link.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String url = (String)m_targetURI.getValue(state);
|
String url = (String) m_targetURI.getValue(state);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// See if it's a valid URL
|
// See if it's a valid URL
|
||||||
URL test = new URL( url );
|
URL test = new URL(url);
|
||||||
} catch (MalformedURLException ex ) {
|
} catch (MalformedURLException ex) {
|
||||||
boolean localLink = url.startsWith( "/" );
|
boolean localLink = url.startsWith("/");
|
||||||
boolean hasProtocol = url.indexOf("://") != -1;
|
boolean hasProtocol = url.indexOf("://") != -1;
|
||||||
|
|
||||||
String newURL;
|
String newURL;
|
||||||
if( localLink ) {
|
if (localLink) {
|
||||||
// For a local link, see if it would be ok if we stuck
|
// For a local link, see if it would be ok if we stuck
|
||||||
// "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
|
||||||
|
|
||||||
|
|
@ -289,40 +291,39 @@ public class LinkPropertyForm extends FormSection
|
||||||
} else {
|
} else {
|
||||||
// No idea, just throw the error
|
// No idea, just throw the error
|
||||||
|
|
||||||
throw new FormProcessException
|
throw new FormProcessException("URL is not valid: " + ex.getMessage());
|
||||||
( "URL is not valid: " + ex.getMessage() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL test = new URL( newURL );
|
URL test = new URL(newURL);
|
||||||
} catch (MalformedURLException ex2 ) {
|
} catch (MalformedURLException ex2) {
|
||||||
StringBuffer msg = new StringBuffer();
|
StringBuffer msg = new StringBuffer();
|
||||||
|
|
||||||
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( msg.toString() );
|
throw new FormProcessException(msg.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we fixed it by adding a protocol, notify the user to
|
// If we fixed it by adding a protocol, notify the user to
|
||||||
// check that's what they intended
|
// check that's what they intended
|
||||||
if( !localLink && !hasProtocol ) {
|
if (!localLink && !hasProtocol) {
|
||||||
m_targetURI.setValue( state, newURL );
|
m_targetURI.setValue(state, newURL);
|
||||||
throw new FormProcessException( "A valid URL starts with a protocol, eg http://" );
|
throw new FormProcessException("A valid URL starts with a protocol, eg http://");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Link.INTERNAL_LINK.equals((String)m_linkType.getValue(state))) {
|
} else if (Link.INTERNAL_LINK.equals((String) m_linkType.getValue(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("Item selection is required for internal link.");
|
throw new FormProcessException("Item selection is required for internal link.");
|
||||||
|
|
@ -337,7 +338,7 @@ public class LinkPropertyForm extends FormSection
|
||||||
* @return the ContentItem
|
* @return the ContentItem
|
||||||
*/
|
*/
|
||||||
protected ContentItem getContentItem(PageState s) {
|
protected ContentItem getContentItem(PageState s) {
|
||||||
return (ContentItem)m_itemModel.getSelectedObject(s);
|
return (ContentItem) m_itemModel.getSelectedObject(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -353,26 +354,25 @@ public class LinkPropertyForm extends FormSection
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init listener. For edit actions, fills the form with current data
|
* Init listener. For edit actions, fills the form with current data
|
||||||
*
|
*
|
||||||
* @param fse the FormSectionEvent
|
* @param fse the FormSectionEvent
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
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());
|
||||||
m_targetURI.setValue(state, link.getTargetURI());
|
m_targetURI.setValue(state, link.getTargetURI());
|
||||||
if ( com.arsdigita.bebop.Link.NEW_FRAME.equals(link.getTargetWindow()) ) {
|
if (com.arsdigita.bebop.Link.NEW_FRAME.equals(link.getTargetWindow())) {
|
||||||
m_URIOption.setValue(state, Link.TARGET_WINDOW);
|
m_URIOption.setValue(state, Link.TARGET_WINDOW);
|
||||||
} else {
|
} else {
|
||||||
m_URIOption.setValue(state, null);
|
m_URIOption.setValue(state, null);
|
||||||
|
|
@ -382,7 +382,7 @@ public class LinkPropertyForm extends FormSection
|
||||||
data.put(ITEM_SEARCH, link.getTargetItem());
|
data.put(ITEM_SEARCH, link.getTargetItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IllegalStateException e ) {
|
} catch (IllegalStateException e) {
|
||||||
s_log.error(e.getMessage());
|
s_log.error(e.getMessage());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
@ -398,18 +398,17 @@ public class LinkPropertyForm extends FormSection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process listener. Saves/creates the new or modified Link
|
* Process listener. Saves/creates the new or modified Link
|
||||||
*
|
*
|
||||||
* @param fse the FormSectionEvent
|
* @param fse the FormSectionEvent
|
||||||
*/
|
*/
|
||||||
public void process( FormSectionEvent fse ) throws FormProcessException {
|
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||||
PageState state = fse.getPageState();
|
PageState state = fse.getPageState();
|
||||||
Link link;
|
Link link;
|
||||||
|
|
||||||
// save only if save button was pressed
|
// save only if save button was pressed
|
||||||
if ( getSaveCancelSection().getCancelButton().isSelected(state) ) {
|
if (getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||||
// cancel button is selected
|
// cancel button is selected
|
||||||
m_linkModel.clearSelection(state);
|
m_linkModel.clearSelection(state);
|
||||||
s_log.debug("link save canceled");
|
s_log.debug("link save canceled");
|
||||||
|
|
@ -426,7 +425,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());
|
||||||
}
|
}
|
||||||
|
|
@ -439,14 +438,13 @@ public class LinkPropertyForm extends FormSection
|
||||||
* Set various properties of the Link.Child clases can over-ride this
|
* Set various properties of the Link.Child clases can over-ride this
|
||||||
* method to add additional properties to Link.
|
* method to add additional properties to Link.
|
||||||
*/
|
*/
|
||||||
protected void setLinkProperties(Link link , FormSectionEvent fse){
|
protected void setLinkProperties(Link link, FormSectionEvent fse) {
|
||||||
PageState state = fse.getPageState();
|
PageState state = fse.getPageState();
|
||||||
FormData data = fse.getFormData();
|
FormData data = fse.getFormData();
|
||||||
// * Set required properties *
|
// * Set required properties *
|
||||||
link.setTitle((String)m_title.getValue(state));
|
link.setTitle((String) m_title.getValue(state));
|
||||||
link.setDescription( (String)
|
link.setDescription((String) m_description.getValue(state));
|
||||||
m_description.getValue(state));
|
link.setTargetType((String) m_linkType.getValue(state));
|
||||||
link.setTargetType((String)m_linkType.getValue(state));
|
|
||||||
|
|
||||||
// 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))) {
|
||||||
|
|
@ -475,7 +473,7 @@ public class LinkPropertyForm extends FormSection
|
||||||
}
|
}
|
||||||
// Process whether link is to be opened in new window
|
// Process whether link is to be opened in new window
|
||||||
boolean isNewWindow = false;
|
boolean isNewWindow = false;
|
||||||
String[] value = (String[])m_URIOption.getValue(state);
|
String[] value = (String[]) m_URIOption.getValue(state);
|
||||||
// Technically this isn't really necessary as there is only one box so any
|
// Technically this isn't really necessary as there is only one box so any
|
||||||
// non-null value means it was checked
|
// non-null value means it was checked
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue