use of org.eclipse.wst.sse.core.internal.provisional.IModelManager 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.IModelManager in project webtools.sourceediting by eclipse.
the class HTMLValidator method getModel.
/**
*/
protected IDOMModel getModel(IProject project, IFile file) {
if (project == null || file == null)
return null;
if (!file.exists())
return null;
if (!canHandle(file))
return null;
IModelManager manager = StructuredModelManager.getModelManager();
if (manager == null)
return null;
IStructuredModel model = null;
try {
file.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
} catch (CoreException e) {
Logger.logException(e);
}
try {
try {
model = manager.getModelForRead(file);
} catch (UnsupportedEncodingException ex) {
// retry ignoring META charset for invalid META charset
// specification
// recreate input stream, because it is already partially read
model = manager.getModelForRead(file, new String(), null);
}
} catch (UnsupportedEncodingException ex) {
} catch (IOException ex) {
} catch (CoreException e) {
Logger.logException(e);
}
if (model == null)
return null;
if (!(model instanceof IDOMModel)) {
releaseModel(model);
return null;
}
return (IDOMModel) model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class URLModelProvider method getModelForEdit.
/**
*/
private IStructuredModel getModelForEdit(IFile file) throws IOException {
if (file == null)
return null;
IModelManager manager = getModelManager();
// create a fake InputStream
IStructuredModel model = null;
try {
model = manager.getModelForEdit(file);
} catch (UnsupportedCharsetException ex) {
try {
model = manager.getModelForEdit(file, EncodingRule.FORCE_DEFAULT);
} catch (IOException ioe) {
} catch (CoreException ce) {
}
} catch (CoreException ce) {
}
return model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class URLModelProvider method getModelForRead.
/**
*/
private IStructuredModel getModelForRead(IFile file) throws IOException {
if (file == null)
return null;
IModelManager manager = getModelManager();
// create a fake InputStream
IStructuredModel model = null;
try {
model = manager.getModelForRead(file);
} catch (UnsupportedCharsetException ex) {
try {
model = manager.getModelForRead(file, EncodingRule.FORCE_DEFAULT);
} catch (IOException ioe) {
} catch (CoreException ce) {
}
} catch (CoreException ce) {
}
return model;
}
use of org.eclipse.wst.sse.core.internal.provisional.IModelManager in project webtools.sourceediting by eclipse.
the class TestStructuredPartitionerHTML method getModelForEdit.
/**
* must release model (from edit) after
* @param filename relative to this class (TestStructuredPartitioner)
*/
private IStructuredModel getModelForEdit(String filename) {
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
InputStream inStream = getClass().getResourceAsStream(filename);
if (inStream == null)
inStream = new StringBufferInputStream("");
model = modelManager.getModelForEdit(filename, inStream, null);
} catch (IOException ex) {
ex.printStackTrace();
}
return model;
}
Aggregations