use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project liferay-ide by liferay.
the class HookDescriptorHelper method doAddLanguageProperties.
protected IStatus doAddLanguageProperties(IDOMDocument document, List<String> languageProperties) {
// <hook> element
Element rootElement = document.getDocumentElement();
FormatProcessorXML processor = new FormatProcessorXML();
Element newLanguageElement = null;
// check if we have existing custom_dir
Node refChild = null;
NodeList nodeList = rootElement.getElementsByTagName("custom-jsp-dir");
if ((nodeList != null) && (nodeList.getLength() > 0)) {
refChild = nodeList.item(0);
} else {
nodeList = rootElement.getElementsByTagName("service");
if ((nodeList != null) && (nodeList.getLength() > 0)) {
refChild = nodeList.item(0);
}
}
if (languageProperties != null) {
for (String languageProperty : languageProperties) {
newLanguageElement = NodeUtil.insertChildElement(rootElement, refChild, "language-properties", languageProperty);
processor.formatNode(newLanguageElement);
}
if (newLanguageElement != null) {
// append a newline text node
rootElement.appendChild(document.createTextNode(System.getProperty("line.separator")));
processor.formatNode(newLanguageElement);
}
}
return Status.OK_STATUS;
}
use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project liferay-ide by liferay.
the class HookDescriptorHelper method doAddActionItems.
protected IStatus doAddActionItems(IDOMDocument document, List<String[]> actionItems) {
// <hook> element
Element rootElement = document.getDocumentElement();
FormatProcessorXML processor = new FormatProcessorXML();
Element newServiceElement = null;
if (actionItems != null) {
for (String[] actionItem : actionItems) {
newServiceElement = NodeUtil.appendChildElement(rootElement, "service");
NodeUtil.appendChildElement(newServiceElement, "service-type", actionItem[0]);
NodeUtil.appendChildElement(newServiceElement, "service-impl", actionItem[1]);
processor.formatNode(newServiceElement);
}
if (newServiceElement != null) {
// append a newline text node
rootElement.appendChild(document.createTextNode(System.getProperty("line.separator")));
processor.formatNode(newServiceElement);
}
}
return Status.OK_STATUS;
}
use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project liferay-ide by liferay.
the class HookDescriptorHelper method doSetPortalProperties.
protected IStatus doSetPortalProperties(IDOMDocument document, IDataModel model, String propertiesFile) {
// <hook> element
Element rootElement = document.getDocumentElement();
// check for existing element
Element portalPropertiesElement = null;
NodeList nodeList = rootElement.getElementsByTagName("portal-properties");
if ((nodeList != null) && (nodeList.getLength() > 0)) {
portalPropertiesElement = (Element) nodeList.item(0);
NodeUtil.removeChildren(portalPropertiesElement);
Node textNode = document.createTextNode(propertiesFile);
portalPropertiesElement.appendChild(textNode);
} else {
portalPropertiesElement = NodeUtil.insertChildElement(rootElement, rootElement.getFirstChild(), "portal-properties", propertiesFile);
}
// format the new node added to the model;
FormatProcessorXML processor = new FormatProcessorXML();
processor.formatNode(portalPropertiesElement);
return Status.OK_STATUS;
}
use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project liferay-ide by liferay.
the class LiferayDisplayDescriptorHelper method doAddNewPortlet.
protected IStatus doAddNewPortlet(IDOMDocument document, IDataModel model) {
// <display> element
Element rootElement = document.getDocumentElement();
// for the category assignment check to see if there is already a
// category element with that id
Element category = null;
String modelCategory = model.getStringProperty(CATEGORY);
for (Element child : getChildElements(rootElement)) {
if (child.getNodeName().equals("category") && modelCategory.equals(child.getAttribute("name"))) {
category = child;
break;
}
}
Element id = null;
String modelId = model.getStringProperty(ID);
if (category != null) {
for (Element child : getChildElements(category)) {
if (child.getNodeName().equals("portlet") && modelId.equals(child.getAttribute("id"))) {
id = child;
break;
}
}
} else {
category = document.createElement("category");
category.setAttribute("name", modelCategory);
rootElement.appendChild(category);
Node newline = document.createTextNode(System.getProperty("line.separator"));
rootElement.appendChild(newline);
}
if (id == null) {
NodeUtil.appendChildElement(category, "portlet").setAttribute("id", modelId);
}
// format the new node added to the model;
FormatProcessorXML processor = new FormatProcessorXML();
processor.formatNode(category);
return Status.OK_STATUS;
}
use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project liferay-ide by liferay.
the class LiferayPortletDescriptorHelper method doAddNewPortlet.
protected IStatus doAddNewPortlet(IDOMDocument document, IDataModel model) {
// <liferay-portlet-app> element
Element rootElement = document.getDocumentElement();
// new <portlet> element
Element newPortletElement = document.createElement("portlet");
NodeUtil.appendChildElement(newPortletElement, "portlet-name", model.getStringProperty(LIFERAY_PORTLET_NAME));
NodeUtil.appendChildElement(newPortletElement, "icon", model.getStringProperty(ICON_FILE));
if (model.getBooleanProperty(ADD_TO_CONTROL_PANEL)) {
String entryCategory = model.getStringProperty(ENTRY_CATEGORY).replaceAll("^category\\.", StringPool.EMPTY);
NodeUtil.appendChildElement(newPortletElement, "control-panel-entry-category", entryCategory);
NodeUtil.appendChildElement(newPortletElement, "control-panel-entry-weight", model.getStringProperty(ENTRY_WEIGHT));
String javaPackage = model.getStringProperty(JAVA_PACKAGE);
if (!CoreUtil.isNullOrEmpty(javaPackage)) {
javaPackage = javaPackage + StringPool.PERIOD;
}
if (model.getBooleanProperty(CREATE_ENTRY_CLASS)) {
NodeUtil.appendChildElement(newPortletElement, "control-panel-entry-class", javaPackage + model.getStringProperty(ENTRY_CLASS_NAME));
}
}
if (model.getBooleanProperty(ALLOW_MULTIPLE)) {
NodeUtil.appendChildElement(newPortletElement, "instanceable", Boolean.toString(model.getBooleanProperty(ALLOW_MULTIPLE)));
}
NodeUtil.appendChildElement(newPortletElement, "header-portlet-css", model.getStringProperty(CSS_FILE));
NodeUtil.appendChildElement(newPortletElement, "footer-portlet-javascript", model.getStringProperty(JAVASCRIPT_FILE));
NodeUtil.appendChildElement(newPortletElement, "css-class-wrapper", model.getStringProperty(CSS_CLASS_WRAPPER));
// must append this before any role-mapper elements
Element firstRoleMapper = null;
for (Element child : getChildElements(rootElement)) {
if (child.getNodeName().equals("role-mapper")) {
firstRoleMapper = child;
break;
}
}
Node newline = document.createTextNode(System.getProperty("line.separator"));
if (firstRoleMapper != null) {
rootElement.insertBefore(newPortletElement, firstRoleMapper);
rootElement.insertBefore(newline, firstRoleMapper);
} else {
rootElement.appendChild(newPortletElement);
rootElement.appendChild(newline);
}
// format the new node added to the model;
FormatProcessorXML processor = new FormatProcessorXML();
processor.formatNode(newPortletElement);
return Status.OK_STATUS;
}
Aggregations