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();
|
||||||
}
|
}
|
||||||
|
|
@ -67,6 +68,13 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||||
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();
|
||||||
|
|
|
||||||
|
|
@ -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,7 +80,7 @@ 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";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -94,10 +93,16 @@ public class LinkPropertyForm extends FormSection
|
||||||
*/
|
*/
|
||||||
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,25 +127,23 @@ 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);
|
||||||
|
|
@ -170,23 +173,22 @@ public class LinkPropertyForm extends FormSection
|
||||||
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,6 +197,7 @@ 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())) {
|
||||||
|
|
@ -203,10 +206,10 @@ public class LinkPropertyForm extends FormSection
|
||||||
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())) {
|
||||||
|
|
@ -215,8 +218,7 @@ public class LinkPropertyForm extends FormSection
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
@ -279,8 +281,8 @@ public class LinkPropertyForm extends FormSection
|
||||||
// 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,8 +291,7 @@ 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 {
|
||||||
|
|
@ -353,7 +354,6 @@ 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
|
||||||
*
|
*
|
||||||
|
|
@ -398,7 +398,6 @@ public class LinkPropertyForm extends FormSection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process listener. Saves/creates the new or modified Link
|
* Process listener. Saves/creates the new or modified Link
|
||||||
*
|
*
|
||||||
|
|
@ -444,8 +443,7 @@ public class LinkPropertyForm extends FormSection
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue