use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class JSFLiferayPortletDescriptorHelper method addDescriptorOperations.
@Override
protected void addDescriptorOperations() {
super.addDescriptorOperations();
UpdateDescriptorVersionOperation operation = new UpdateDescriptorVersionOperation() {
@Override
public IStatus update(Version preVersion, Version postVersion) {
if ((CoreUtil.compareVersions(preVersion, ILiferayConstants.V620) >= 0) && (CoreUtil.compareVersions(postVersion, ILiferayConstants.V620) < 0)) {
IFile descriptorFile = getDescriptorFile();
IDOMModel domModel = null;
try {
domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(descriptorFile);
IDOMDocument document = domModel.getDocument();
IStatus status = _downgradeJSFLiferayPortletXMLTo61(document);
if (!status.isOK()) {
return status;
}
domModel.save();
} catch (Exception e) {
PortletCore.logError("Error editing liferay-portlet.xml", e);
} finally {
if (domModel != null) {
domModel.releaseFromEdit();
}
}
}
return Status.OK_STATUS;
}
};
addDescriptorOperation(operation);
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class VaadinLiferayPortletDescriptorHelper 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 _updateVaadinLiferayPortletXMLTo62(document);
}
};
return op.execute();
}
}
return status;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class BaseValidator method checkAllClassElements.
@SuppressWarnings("unchecked")
protected Map<String, Object>[] checkAllClassElements(Map<String, String> map, IJavaProject javaProject, IFile liferayDescriptorXml, String classExistPreferenceKey, String classHierarchyPreferenceKey, IScopeContext[] preferenceScopes, String preferenceNodeQualifier, List<Map<String, Object>> problems) throws CoreException {
IStructuredModel liferayDescriptorXmlModel = null;
IDOMDocument liferayDescriptorXmlDocument = null;
try {
liferayDescriptorXmlModel = StructuredModelManager.getModelManager().getModelForRead(liferayDescriptorXml);
if ((liferayDescriptorXmlModel != null) && liferayDescriptorXmlModel instanceof IDOMModel && (map != null)) {
liferayDescriptorXmlDocument = ((IDOMModel) liferayDescriptorXmlModel).getDocument();
for (String elementName : map.keySet()) {
checkClassElements(liferayDescriptorXmlDocument, javaProject, elementName, preferenceNodeQualifier, preferenceScopes, classExistPreferenceKey, classHierarchyPreferenceKey, problems, map.get(elementName));
}
}
} catch (IOException ioe) {
ProjectCore.logError(ioe);
} finally {
if (liferayDescriptorXmlModel != null) {
liferayDescriptorXmlModel.releaseFromRead();
}
}
Map<String, Object>[] retval = new Map[problems.size()];
return (Map<String, Object>[]) problems.toArray(retval);
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class JSPFileWTP method createSearchResult.
@Override
protected SearchResult createSearchResult(String searchContext, int startOffset, int endOffset, int startLine, int endLine, boolean fullMatch) {
IDOMModel jspModel = null;
try {
int jspStartOffset = _translation.getJspOffset(startOffset);
int jspEndOffset = _translation.getJspOffset(endOffset);
jspModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(_translation.getJspFile());
IDOMDocument domDocument = jspModel.getDocument();
IStructuredDocument structuredDocument = domDocument.getStructuredDocument();
int jspStartLine = structuredDocument.getLineOfOffset(jspStartOffset) + 1;
int jspEndLine = structuredDocument.getLineOfOffset(jspEndOffset) + 1;
return super.createSearchResult(searchContext, jspStartOffset, jspEndOffset, jspStartLine, jspEndLine, fullMatch);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jspModel != null) {
jspModel.releaseFromRead();
}
}
return super.createSearchResult(searchContext, startOffset, endOffset, startLine, endLine, fullMatch);
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class SSEXMLFile method findElement.
@Override
public List<SearchResult> findElement(String tagName, String value) {
List<SearchResult> results = new ArrayList<>();
IFile xmlFile = getIFile(file);
IDOMModel domModel = null;
try {
domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(xmlFile);
IDOMDocument document = domModel.getDocument();
NodeList elements = document.getElementsByTagName(tagName);
if (elements != null) {
for (int i = 0; i < elements.getLength(); i++) {
IDOMElement element = (IDOMElement) elements.item(i);
String textContent = element.getTextContent();
if ((textContent != null) && value.trim().equals(textContent.trim())) {
int startOffset = element.getStartOffset();
int endOffset = element.getEndOffset();
int startLine = document.getStructuredDocument().getLineOfOffset(startOffset) + 1;
int endLine = document.getStructuredDocument().getLineOfOffset(endOffset) + 1;
SearchResult result = new SearchResult(file, "startOffset:" + startOffset, startOffset, endOffset, startLine, endLine, true);
results.add(result);
}
}
}
} catch (Exception e) {
} finally {
if (domModel != null) {
domModel.releaseFromRead();
}
}
return results;
}
Aggregations