use of org.eclipse.wst.sse.core.internal.provisional.IStructuredModel in project liferay-ide by liferay.
the class LayoutTplEditor method initSourceModel.
protected void initSourceModel() {
if (_sourceModel == null) {
if ((_sourcePage != null) && (_sourcePage.getDocumentProvider() != null)) {
IDocumentProvider documentProvider = _sourcePage.getDocumentProvider();
IDocument doc = documentProvider.getDocument(getEditorInput());
_sourceModel = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForEdit(doc);
_sourceModel.addModelStateListener(new IModelStateListener() {
public void modelAboutToBeChanged(IStructuredModel model) {
}
public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
}
public void modelChanged(IStructuredModel model) {
setSourceModelChanged(true);
}
public void modelDirtyStateChanged(IStructuredModel model, boolean dirty) {
}
public void modelReinitialized(IStructuredModel structuredModel) {
}
public void modelResourceDeleted(IStructuredModel model) {
}
public void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel) {
}
});
}
}
}
use of org.eclipse.wst.sse.core.internal.provisional.IStructuredModel 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.sse.core.internal.provisional.IStructuredModel in project liferay-ide by liferay.
the class LiferayLanguageFileEncodingTests method removeSpecifiedNode.
private void removeSpecifiedNode(IFile file, String nodeName, String content) throws Exception {
final IStructuredModel model = StructuredModelManager.getModelManager().getModelForEdit(file);
final IDOMDocument document = ((IDOMModel) model).getDocument();
final NodeList elements = document.getElementsByTagName(nodeName);
for (int i = 0; i < elements.getLength(); i++) {
Node node = elements.item(i);
if (content.equals(node.getTextContent())) {
node.getParentNode().removeChild(node);
break;
}
}
model.save(file);
model.releaseFromEdit();
}
use of org.eclipse.wst.sse.core.internal.provisional.IStructuredModel in project liferay-ide by liferay.
the class WorkflowDefinitionValidator method detectProblems.
@SuppressWarnings("unchecked")
public Map<String, Object>[] detectProblems(IFile workflowDefinitionXml, IScopeContext[] preferenceScopes) throws CoreException {
List<Map<String, Object>> problems = new ArrayList<>();
IStructuredModel model = null;
try {
IModelManager modelManage = StructuredModelManager.getModelManager();
model = modelManage.getModelForRead(workflowDefinitionXml);
if ((model != null) && model instanceof IDOMModel) {
IDOMDocument document = ((IDOMModel) model).getDocument();
try {
IWorkflowValidation workflowValidation = KaleoCore.getWorkflowValidation(ServerUtil.getRuntime(workflowDefinitionXml.getProject()));
Exception error = workflowValidation.validate(workflowDefinitionXml.getContents());
if ((error != null) && !CoreUtil.isNullOrEmpty(error.getMessage())) {
Map<String, Object> problem = createMarkerValues(PREFERENCE_NODE_QUALIFIER, preferenceScopes, WORKFLOW_DEFINITION_VALIDATE, (IDOMNode) document.getFirstChild(), error.getMessage());
problems.add(problem);
}
} catch (Exception e) {
}
}
} catch (Exception e) {
} finally {
if (model != null) {
model.releaseFromRead();
}
}
Map<String, Object>[] retval = new Map[problems.size()];
return (Map<String, Object>[]) problems.toArray(retval);
}
use of org.eclipse.wst.sse.core.internal.provisional.IStructuredModel in project liferay-ide by liferay.
the class LiferayMavenProjectProvider method updateDtdVersion.
protected void updateDtdVersion(IProject project, String dtdVersion, String archetypeVesion) {
String tmpPublicId = dtdVersion;
String tmpSystemId = dtdVersion.replaceAll("\\.", "_");
IStructuredModel editModel = null;
IFile[] metaFiles = _getLiferayMetaFiles(project);
for (IFile file : metaFiles) {
try {
editModel = StructuredModelManager.getModelManager().getModelForEdit(file);
if ((editModel != null) && editModel instanceof IDOMModel) {
IDOMDocument xmlDocument = ((IDOMModel) editModel).getDocument();
DocumentTypeImpl docType = (DocumentTypeImpl) xmlDocument.getDoctype();
String publicId = docType.getPublicId();
String newPublicId = _getNewDoctTypeSetting(publicId, tmpPublicId, _publicid_pattern);
if (newPublicId != null) {
docType.setPublicId(newPublicId);
}
String systemId = docType.getSystemId();
String newSystemId = _getNewDoctTypeSetting(systemId, tmpSystemId, _systemid_pattern);
if (newSystemId != null) {
docType.setSystemId(newSystemId);
}
editModel.save();
}
} catch (Exception e) {
IStatus error = ProjectCore.createErrorStatus("Unable to upgrade deployment meta file for " + file.getName(), e);
ProjectCore.logError(error);
} finally {
if (editModel != null) {
editModel.releaseFromEdit();
}
}
}
ProjectCore.operate(project, UpdateDescriptorVersionOperation.class, archetypeVesion, dtdVersion);
}
Aggregations