use of org.eclipse.vorto.core.api.model.model.ModelType in project vorto by eclipse.
the class VortoModelProject method addModelElement.
@Override
public IModelElement addModelElement(ModelId modelId, InputStream inputStream) {
try {
final ModelType modelType = modelId.getModelType();
IFolder folder = getFolderByType(modelId.getModelType());
IFile file = folder.getFile(modelId.getFileName());
if (file.exists()) {
file.delete(true, new NullProgressMonitor());
}
file.create(inputStream, true, new NullProgressMonitor());
if (modelType == ModelType.InformationModel) {
return new InformationModelElement(this, file, modelParser);
} else if (modelType == ModelType.Functionblock) {
return new FunctionblockModelElement(this, file, modelParser);
} else if (modelType == ModelType.Datatype) {
return new DatatypeModelElement(this, file, modelParser);
} else if (modelType == ModelType.Mapping) {
return new MappingModelElement(this, file, modelParser);
} else {
throw new UnsupportedOperationException("Modeltype is not supported");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of org.eclipse.vorto.core.api.model.model.ModelType in project vorto by eclipse.
the class AbstractModelElement method getReferences.
public Set<IModelElement> getReferences() {
Set<IModelElement> references = new TreeSet<>();
for (ModelReference modelReference : getModel().getReferences()) {
for (ModelType possibleType : getPossibleReferenceTypes()) {
ModelId modelId = ModelIdFactory.newInstance(possibleType, modelReference);
IModelElement modelElementReference = this.modelProject.getModelElementById(modelId);
if (modelElementReference != null) {
references.add(modelElementReference);
break;
}
}
}
return references;
}
Aggregations