use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class PortletDescriptorHelper method getAllPortletNames.
public String[] getAllPortletNames() {
List<String> allPortletNames = new ArrayList<>();
IFile descriptorFile = getDescriptorFile();
if (descriptorFile != null) {
DOMModelOperation op = new DOMModelReadOperation(descriptorFile) {
protected IStatus doExecute(IDOMDocument document) {
NodeList nodeList = document.getElementsByTagName("portlet-name");
for (int i = 0; i < nodeList.getLength(); i++) {
Element portletName = (Element) nodeList.item(i);
allPortletNames.add(NodeUtil.getTextContent(portletName));
}
return Status.OK_STATUS;
}
};
op.execute();
}
return allPortletNames.toArray(new String[0]);
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class PortletDescriptorHelper method getAllResourceBundles.
public String[] getAllResourceBundles() {
List<String> allResourceBundles = new ArrayList<>();
IFile descriptorFile = getDescriptorFile();
if (descriptorFile != null) {
DOMModelOperation op = new DOMModelReadOperation(descriptorFile) {
protected IStatus doExecute(IDOMDocument document) {
NodeList nodeList = document.getElementsByTagName("resource-bundle");
for (int i = 0; i < nodeList.getLength(); i++) {
Element resourceBundle = (Element) nodeList.item(i);
allResourceBundles.add(NodeUtil.getTextContent(resourceBundle));
}
return Status.OK_STATUS;
}
};
op.execute();
}
return allResourceBundles.toArray(new String[0]);
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class LayoutTplElementsFactory method newLayoutTplFromModel.
public LayoutTplElement newLayoutTplFromModel(IDOMModel model, Boolean bootstrapStyle, Boolean is62) {
if (model == null) {
return null;
}
LayoutTplElement layoutTpl = null;
IDOMDocument rootDocument = model.getDocument();
IDOMElement mainContentElement = LayoutTplUtil.findMainContentElement(rootDocument);
if (mainContentElement != null) {
layoutTpl = LayoutTplElement.TYPE.instantiate();
layoutTpl.setBootstrapStyle(bootstrapStyle);
layoutTpl.setClassName(mainContentElement.getAttribute("class"));
layoutTpl.setIs62(is62);
IDOMElement[] portletLayoutElements = LayoutTplUtil.findChildElementsByClassName(mainContentElement, "div", "portlet-layout");
if (ListUtil.isNotEmpty(portletLayoutElements)) {
for (IDOMElement portletLayoutElement : portletLayoutElements) {
PortletLayoutElement portletLayout = layoutTpl.getPortletLayouts().insert();
initPortletLayoutFromElement(portletLayout, portletLayoutElement);
}
}
}
return layoutTpl;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class LayoutTplDescriptorHelper method addNewLayoutTemplate.
public IStatus addNewLayoutTemplate(IDataModel dm) {
IFile descriptorFile = getDescriptorFile();
DOMModelOperation operation = new DOMModelEditOperation(descriptorFile) {
protected void createDefaultFile() {
createDefaultDescriptor(_LAYOUT_DESCRIPTOR_TEMPLATE, getDescriptorVersion());
}
protected IStatus doExecute(IDOMDocument document) {
return doAddLayoutTemplate(document, dm);
}
};
IStatus status = operation.execute();
if (!status.isOK()) {
return status;
}
return status;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class JSFLiferayPortletDescriptorHelper method doAddNewPortlet.
@Override
protected IStatus doAddNewPortlet(IDOMDocument document, IDataModel model) {
IStatus status = Status.OK_STATUS;
status = super.doAddNewPortlet(document, model);
if (!status.isOK()) {
return status;
}
Version runtimeVersion = ServerUtil.getRuntimeVersion(project);
if (CoreUtil.compareVersions(runtimeVersion, ILiferayConstants.V620) >= 0) {
IFile descriptorFile = getDescriptorFile();
if (descriptorFile != null) {
DOMModelOperation op = new DOMModelEditOperation(descriptorFile) {
@Override
protected void createDefaultFile() {
// Getting document from super( descriptorFile );
}
@Override
protected IStatus doExecute(IDOMDocument document) {
return _updateJSFLiferayPortletXMLTo62(document);
}
};
status = op.execute();
}
}
return status;
}
Aggregations