use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.
the class QNameLocalPartValueBinding method write.
/**
* (non-Javadoc)
*
* @see org.eclipse.sapphire.modeling.ValuePropertyBinding#write(java.lang.String)
*/
@Override
public void write(String value) {
String val = value;
XmlElement parent = xml(true);
/*
* In some cases the parent node and the child nodes will be same, we need to
* ensure that we dont create them accidentally again
*/
// System.out.println( "QNameLocalPartValueBinding.write() - Parent local name:"
// + parent.getLocalName() );
XmlElement qNameElement = null;
if (parent.getLocalName().equals(params[0])) {
qNameElement = parent;
} else {
qNameElement = parent.getChildElement(params[0], true);
}
if (qNameElement != null) {
val = val != null ? value.trim() : StringPool.EMPTY;
if (params.length == 2 && "localpart".equals(params[1])) {
// update only local part
// System.out.println( "VALUE
// ___________________ " + val );
String existingText = qNameElement.getText();
if ((existingText != null) && (existingText.indexOf(":") != -1)) {
String updatedLocalPart = existingText.substring(0, (existingText.indexOf(":") + 1));
updatedLocalPart = updatedLocalPart + val;
// System.out.println( "Updated value ___________________ " + updatedLocalPart
// );
qNameElement.setText(updatedLocalPart);
} else {
qNameElement.setText(PortletAppModelConstants.DEFAULT_QNAME_PREFIX + ":" + val);
}
} else {
qNameElement.setText(PortletAppModelConstants.DEFAULT_QNAME_PREFIX + ":" + val);
}
}
}
use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.
the class QNameLocalPartValueBinding method read.
/**
* (non-Javadoc)
*
* @see org.eclipse.sapphire.modeling.ValuePropertyBinding#read()
*/
@Override
public String read() {
String value = null;
XmlElement parent = xml(false);
// Fix for Alias QName not displayed in list
XmlElement qNameElement = null;
if (parent.getLocalName().equals(params[0])) {
qNameElement = parent;
} else {
qNameElement = parent.getChildElement(params[0], false);
}
if (qNameElement != null) {
value = qNameElement.getText();
if (value != null) {
value = value.trim();
value = PortletUtil.stripPrefix(value);
}
}
return value;
}
use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.
the class QNameTextNodeValueBinding method read.
/**
* (non-Javadoc)
*
* @see org.eclipse.sapphire.modeling.ValuePropertyBinding#read()
*/
@Override
public String read() {
String value = null;
XmlElement parent = xml(false);
if (parent != null) {
XmlElement qNamedElement = parent.getChildElement(this.params[0], false);
if (qNamedElement != null) {
Element domNode = qNamedElement.getDomNode();
value = qNamedElement.getText();
if (value != null) {
String prefix = PortletUtil.stripSuffix(value.trim());
Attr attrib = domNode.getAttributeNode(String.format(PortletAppModelConstants.NS_DECL, prefix));
if (attrib != null) {
QName qname = new QName(attrib.getValue(), PortletUtil.stripPrefix(value));
value = qname.toString();
}
}
}
}
return value;
}
use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.
the class QNameValueBinding method getXmlNode.
@Override
public XmlNode getXmlNode() {
XmlElement parent = xml();
XmlElement element = parent.getChildElement(params[0], false);
if (element != null) {
return element;
}
return null;
}
use of org.eclipse.sapphire.modeling.xml.XmlElement in project liferay-ide by liferay.
the class QNameValueBinding method write.
/**
* (non-Javadoc)
*
* @see org.eclipse.sapphire.modeling.ValuePropertyBinding#write(java.lang.String)
*/
@Override
public void write(String value) {
XmlElement parent = xml(true);
// System.out.println( "EventDefinitionValueBinding.write()" + parent );
XmlElement qNameElement = parent.getChildElement(params[0], true);
qNameElement.setChildNodeText(this.path, value, true);
try {
PortletModelUtil.printDocument(parent.getDomNode().getOwnerDocument(), System.out);
} catch (IOException ioe) {
PortletCore.logError(ioe);
} catch (TransformerException te) {
PortletCore.logError(te);
}
}
Aggregations