use of org.kie.workbench.common.services.datamodeller.core.impl.JavaTypeInfoImpl in project kie-wb-common by kiegroup.
the class DataModelerScreenPresenter method checkDirtyAndSaveFile.
private void checkDirtyAndSaveFile() {
final JavaTypeInfoImpl newTypeInfo = new JavaTypeInfoImpl();
if (isDirty()) {
if (context.isEditorChanged()) {
newTypeInfo.setPackageName(context.getDataObject().getPackageName());
newTypeInfo.setName(context.getDataObject().getName());
saveFile(newTypeInfo);
} else {
view.showLoading();
modelerService.call(new RemoteCallback<TypeInfoResult>() {
@Override
public void callback(TypeInfoResult typeInfoResult) {
view.hideBusyIndicator();
if (!typeInfoResult.hasErrors() && typeInfoResult.getJavaTypeInfo() != null) {
newTypeInfo.setPackageName(typeInfoResult.getJavaTypeInfo().getPackageName());
newTypeInfo.setName(typeInfoResult.getJavaTypeInfo().getName());
saveFile(newTypeInfo);
} else {
saveFile(null);
}
}
}).loadJavaTypeInfo(getSource());
}
} else {
saveFile(null);
}
}
use of org.kie.workbench.common.services.datamodeller.core.impl.JavaTypeInfoImpl in project kie-wb-common by kiegroup.
the class JavaRoasterModelDriver method loadJavaTypeInfo.
public TypeInfoResult loadJavaTypeInfo(final String source) throws ModelDriverException {
TypeInfoResult result = new TypeInfoResult();
if (source == null || "".equals(source)) {
logger.debug("source: " + source + " is empty.");
result.addError(new DriverError("Source is empty"));
return result;
}
try {
JavaType<?> javaType = Roaster.parse(source);
if (javaType.getSyntaxErrors() != null && !javaType.getSyntaxErrors().isEmpty()) {
addSyntaxErrors(result, null, javaType.getSyntaxErrors());
} else {
JavaTypeInfoImpl typeInfo = new JavaTypeInfoImpl();
result.setTypeInfo(typeInfo);
typeInfo.setName(javaType.getName());
typeInfo.setPackageName(javaType.getPackage());
typeInfo.setAnnotation(javaType.isAnnotation());
typeInfo.setClass(javaType.isClass());
typeInfo.setEnum(javaType.isEnum());
typeInfo.setInterface(javaType.isInterface());
typeInfo.setPackagePrivate(javaType.isPackagePrivate());
typeInfo.setPrivate(javaType.isPrivate());
typeInfo.setProtected(javaType.isProtected());
typeInfo.setPublic(javaType.isPublic());
}
} catch (ParserException e) {
result.addError(new DriverError(e.getMessage()));
} catch (Exception e) {
// Unexpected parsing o model loading exception.
logger.error(errorMessage(GENERIC_ERROR, e));
throw new ModelDriverException(errorMessage(MODEL_LOAD_GENERIC_ERROR), e);
}
return result;
}
Aggregations