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.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.Link;
|
||||
import com.arsdigita.cms.contenttypes.ui.LinkPropertyForm;
|
||||
|
|
@ -45,10 +46,10 @@ import com.arsdigita.util.Assert;
|
|||
* @version $Revision: #3 $ $Date: 2004/03/30 $
|
||||
* @author Scott Seago (sseago@redhat.com)
|
||||
*/
|
||||
|
||||
public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||
|
||||
private static boolean isHideAdditionalResourceFields;
|
||||
|
||||
static {
|
||||
isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields();
|
||||
}
|
||||
|
|
@ -67,6 +68,13 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
|||
super(itemModel, link);
|
||||
}
|
||||
|
||||
public RelatedLinkPropertyForm(ItemSelectionModel itemModel,
|
||||
LinkSelectionModel link, ContentType contentType) {
|
||||
|
||||
super(itemModel, link, contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
|
||||
super.addWidgets();
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ import com.arsdigita.cms.*;
|
|||
|
||||
object type RelationAttribute extends ContentItem {
|
||||
|
||||
String[1..1] attribute = cms_contacttypes.attribute VARCHAR(100);
|
||||
String[1..1] key = cms_contacttypes.key VARCHAR(100);
|
||||
String[1..1] lang = cms_contacttypes.lang VARCHAR(2);
|
||||
// String[1..1] name = cms_contacttypes.name VARCHAR(100);
|
||||
String[0..1] description = cms_contacttypes.description VARCHAR(500);
|
||||
String[1..1] attribute = cms_relation_attribute.attribute VARCHAR(100);
|
||||
String[1..1] key = cms_relation_attribute.key VARCHAR(100);
|
||||
String[1..1] lang = cms_relation_attribute.lang VARCHAR(2);
|
||||
// String[1..1] name = cms_relation_attribute.name VARCHAR(100);
|
||||
String[0..1] description = cms_relation_attribute.description VARCHAR(500);
|
||||
|
||||
unique (attribute, key, lang);
|
||||
reference key(cms_relationAttribute.relationattribute_id);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import com.arsdigita.util.UncheckedWrapperException;
|
|||
import com.arsdigita.web.Web;
|
||||
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.Link;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
|
|
@ -62,16 +63,14 @@ import org.apache.log4j.Logger;
|
|||
* @version $Revision: #5 $ $Date: 2004/08/17 $
|
||||
* @author Nobuko Asakai (nasakai@redhat.com)
|
||||
*/
|
||||
|
||||
public class LinkPropertyForm extends FormSection
|
||||
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 */
|
||||
public static final String ID = "link_edit";
|
||||
public static final String SSL_PROTOCOL = "https://";
|
||||
public static final String HTTP_PROTOCOL = "http://";
|
||||
|
||||
private TextArea m_description;
|
||||
private TextField m_title;
|
||||
private TextField m_targetURI;
|
||||
|
|
@ -81,7 +80,7 @@ public class LinkPropertyForm extends FormSection
|
|||
private LinkSelectionModel m_linkModel;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
|
||||
private ContentType m_contentType;
|
||||
private final String ITEM_SEARCH = "contentItem";
|
||||
|
||||
/**
|
||||
|
|
@ -94,10 +93,16 @@ public class LinkPropertyForm extends FormSection
|
|||
*/
|
||||
public LinkPropertyForm(ItemSelectionModel itemModel,
|
||||
LinkSelectionModel link) {
|
||||
this(itemModel, link, null);
|
||||
}
|
||||
|
||||
public LinkPropertyForm(ItemSelectionModel itemModel,
|
||||
LinkSelectionModel link, ContentType contentType) {
|
||||
super(new ColumnPanel(2));
|
||||
s_log.debug("property form constructor");
|
||||
m_linkModel = link;
|
||||
m_itemModel = itemModel;
|
||||
m_contentType = contentType;
|
||||
|
||||
addWidgets();
|
||||
addSaveCancelSection();
|
||||
|
|
@ -122,25 +127,23 @@ public class LinkPropertyForm extends FormSection
|
|||
m_description = new TextArea("description");
|
||||
m_description.setCols(40);
|
||||
m_description.setRows(5);
|
||||
add(new Label(GlobalizationUtil.
|
||||
globalize("cms.contenttypes.ui.description")));
|
||||
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.description")));
|
||||
|
||||
add(m_description);
|
||||
|
||||
add(new Label(
|
||||
"<script language=\"javascript\">\n" +
|
||||
"<!-- \n" +
|
||||
"function toggle_link_fields(status) { \n" +
|
||||
" document.forms['linkEditForm'].targetURI.disabled = status; \n" +
|
||||
" document.forms['linkEditForm'].openOption.disabled = status; \n" +
|
||||
" document.forms['linkEditForm'].contentItem.disabled = !status; \n" +
|
||||
" document.forms['linkEditForm'].contentItem_search.disabled = !status; \n" +
|
||||
" document.forms['linkEditForm'].contentItem_clear.disabled = !status; \n" +
|
||||
"}\n" +
|
||||
"// -->\n" +
|
||||
"</script>\n",
|
||||
false
|
||||
));
|
||||
"<script language=\"javascript\">\n"
|
||||
+ "<!-- \n"
|
||||
+ "function toggle_link_fields(status) { \n"
|
||||
+ " document.forms['linkEditForm'].targetURI.disabled = status; \n"
|
||||
+ " document.forms['linkEditForm'].openOption.disabled = status; \n"
|
||||
+ " document.forms['linkEditForm'].contentItem.disabled = !status; \n"
|
||||
+ " document.forms['linkEditForm'].contentItem_search.disabled = !status; \n"
|
||||
+ " document.forms['linkEditForm'].contentItem_clear.disabled = !status; \n"
|
||||
+ "}\n"
|
||||
+ "// -->\n"
|
||||
+ "</script>\n",
|
||||
false));
|
||||
|
||||
add(new Label("Choose either a URL or a Content Item", Label.BOLD),
|
||||
ColumnPanel.FULL_WIDTH);
|
||||
|
|
@ -170,23 +173,22 @@ public class LinkPropertyForm extends FormSection
|
|||
add(m_targetURI);
|
||||
|
||||
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.getClearButton().setOnFocus("toggle_link_fields(true)");
|
||||
add(m_itemSearch);
|
||||
|
||||
add(new Label(
|
||||
"<script language=\"javascript\">\n" +
|
||||
"<!-- \n" +
|
||||
"if (document.forms['linkEditForm'].linkType[0].checked) { \n" +
|
||||
" toggle_link_fields(false); \n" +
|
||||
"} else { \n" +
|
||||
" toggle_link_fields(true); \n" +
|
||||
"} \n" +
|
||||
"// -->\n" +
|
||||
"</script>\n",
|
||||
false
|
||||
));
|
||||
"<script language=\"javascript\">\n"
|
||||
+ "<!-- \n"
|
||||
+ "if (document.forms['linkEditForm'].linkType[0].checked) { \n"
|
||||
+ " toggle_link_fields(false); \n"
|
||||
+ "} else { \n"
|
||||
+ " toggle_link_fields(true); \n"
|
||||
+ "} \n"
|
||||
+ "// -->\n"
|
||||
+ "</script>\n",
|
||||
false));
|
||||
}
|
||||
|
||||
/** Adds the saveCancelSection */
|
||||
|
|
@ -195,6 +197,7 @@ public class LinkPropertyForm extends FormSection
|
|||
try {
|
||||
m_saveCancelSection.getCancelButton().addPrintListener(
|
||||
new PrintListener() {
|
||||
|
||||
public void prepare(PrintEvent e) {
|
||||
Submit target = (Submit) e.getTarget();
|
||||
if (m_linkModel.isSelected(e.getPageState())) {
|
||||
|
|
@ -203,10 +206,10 @@ public class LinkPropertyForm extends FormSection
|
|||
target.setButtonLabel("Reset");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
m_saveCancelSection.getSaveButton().addPrintListener(
|
||||
new PrintListener() {
|
||||
|
||||
public void prepare(PrintEvent e) {
|
||||
Submit target = (Submit) e.getTarget();
|
||||
if (m_linkModel.isSelected(e.getPageState())) {
|
||||
|
|
@ -215,8 +218,7 @@ public class LinkPropertyForm extends FormSection
|
|||
target.setButtonLabel("Create");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
} catch (TooManyListenersException e) {
|
||||
throw new UncheckedWrapperException("this cannot happen", e);
|
||||
}
|
||||
|
|
@ -279,8 +281,8 @@ public class LinkPropertyForm extends FormSection
|
|||
// For a local link, see if it would be ok if we stuck
|
||||
// "http://servername" on the front
|
||||
|
||||
newURL = HTTP_PROTOCOL + Web.getConfig().getHost() +
|
||||
url;
|
||||
newURL = HTTP_PROTOCOL + Web.getConfig().getHost()
|
||||
+ url;
|
||||
} else if (!hasProtocol) {
|
||||
// There's no protocol. See if it would be ok if we
|
||||
// put one on the beginning
|
||||
|
|
@ -289,8 +291,7 @@ public class LinkPropertyForm extends FormSection
|
|||
} else {
|
||||
// No idea, just throw the error
|
||||
|
||||
throw new FormProcessException
|
||||
( "URL is not valid: " + ex.getMessage() );
|
||||
throw new FormProcessException("URL is not valid: " + ex.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -353,7 +354,6 @@ public class LinkPropertyForm extends FormSection
|
|||
return link;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init listener. For edit actions, fills the form with current data
|
||||
*
|
||||
|
|
@ -398,7 +398,6 @@ public class LinkPropertyForm extends FormSection
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process listener. Saves/creates the new or modified Link
|
||||
*
|
||||
|
|
@ -444,8 +443,7 @@ public class LinkPropertyForm extends FormSection
|
|||
FormData data = fse.getFormData();
|
||||
// * Set required properties *
|
||||
link.setTitle((String) m_title.getValue(state));
|
||||
link.setDescription( (String)
|
||||
m_description.getValue(state));
|
||||
link.setDescription((String) m_description.getValue(state));
|
||||
link.setTargetType((String) m_linkType.getValue(state));
|
||||
|
||||
// Process internal and external urls
|
||||
|
|
|
|||
Loading…
Reference in New Issue