use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.
the class WindowLoader method loadComponent.
@Override
public void loadComponent() {
context.setFrame(resultComponent);
loadDialogOptions(resultComponent, element);
assignXmlDescriptor(resultComponent, element);
loadMessagesPack(resultComponent, element);
loadCaption(resultComponent, element);
loadDescription(resultComponent, element);
loadIcon(resultComponent, element);
loadActions(resultComponent, element);
Element layoutElement = element.element("layout");
if (layoutElement == null) {
throw new GuiDevelopmentException("Required 'layout' element is not found", context.getFullFrameId());
}
loadSpacing(resultComponent, layoutElement);
loadMargin(resultComponent, layoutElement);
loadWidth(resultComponent, layoutElement);
loadHeight(resultComponent, layoutElement);
loadStyleName(resultComponent, layoutElement);
loadResponsive(resultComponent, layoutElement);
loadVisible(resultComponent, layoutElement);
loadTimers(factory, resultComponent, element);
loadSubComponentsAndExpand(resultComponent, layoutElement);
loadFocusedComponent(resultComponent, element);
loadCrossFieldValidate(resultComponent, element);
}
use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.
the class WindowDelegate method getDatasource.
public Datasource getDatasource() {
Datasource ds = null;
Element element = ((Component.HasXmlDescriptor) window).getXmlDescriptor();
String datasourceName = element.attributeValue("datasource");
if (!StringUtils.isEmpty(datasourceName)) {
DsContext context = window.getDsContext();
if (context != null) {
ds = context.get(datasourceName);
}
}
if (ds == null) {
throw new GuiDevelopmentException("Can't find main datasource", window.getId());
}
return ds;
}
use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.
the class DesktopImage method createImageResource.
protected Resource createImageResource(Object propertyValue) {
if (propertyValue == null) {
return null;
}
if (propertyValue instanceof FileDescriptor) {
FileDescriptorResource imageResource = createResource(FileDescriptorResource.class);
imageResource.setFileDescriptor((FileDescriptor) propertyValue);
return imageResource;
}
if (propertyValue instanceof byte[]) {
StreamResource imageResource = createResource(StreamResource.class);
Supplier<InputStream> streamSupplier = () -> new ByteArrayDataProvider((byte[]) propertyValue).provide();
imageResource.setStreamSupplier(streamSupplier);
return imageResource;
}
throw new GuiDevelopmentException("The Image component supports only FileDescriptor and byte[] datasource property value binding", getFrame().getId());
}
use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.
the class ExceptionDialog method getText.
protected String getText(Throwable rootCause) {
StringBuilder msg = new StringBuilder();
if (rootCause instanceof RemoteException) {
RemoteException re = (RemoteException) rootCause;
if (!re.getCauses().isEmpty()) {
RemoteException.Cause cause = re.getCauses().get(re.getCauses().size() - 1);
// noinspection ThrowableResultOfMethodCallIgnored
if (cause.getThrowable() != null) {
rootCause = cause.getThrowable();
} else {
// root cause is not supported by client
String className = cause.getClassName();
if (className != null && className.indexOf('.') > 0) {
className = className.substring(className.lastIndexOf('.') + 1);
}
msg.append(className).append(": ").append(cause.getMessage());
}
}
}
if (msg.length() == 0) {
msg.append(rootCause.getClass().getSimpleName());
if (!StringUtils.isBlank(rootCause.getMessage())) {
msg.append(": ").append(rootCause.getMessage());
}
if (rootCause instanceof DevelopmentException) {
Map<String, Object> params = new LinkedHashMap<>();
if (rootCause instanceof GuiDevelopmentException) {
GuiDevelopmentException guiDevException = (GuiDevelopmentException) rootCause;
if (guiDevException.getFrameId() != null) {
params.put("Frame ID", guiDevException.getFrameId());
try {
params.put("XML descriptor", windowConfig.getWindowInfo(guiDevException.getFrameId()).getTemplate());
} catch (Exception e) {
params.put("XML descriptor", "not found for " + guiDevException.getFrameId());
}
}
}
params.putAll(((DevelopmentException) rootCause).getParams());
if (!params.isEmpty()) {
msg.append("\n\n");
for (Map.Entry<String, Object> entry : params.entrySet()) {
msg.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
}
}
}
}
return msg.toString();
}
use of com.haulmont.cuba.gui.GuiDevelopmentException in project cuba by cuba-platform.
the class WebImage method createImageResource.
protected Resource createImageResource(final Object resourceObject) {
if (resourceObject == null) {
return null;
}
if (resourceObject instanceof FileDescriptor) {
FileDescriptorResource imageResource = createResource(FileDescriptorResource.class);
imageResource.setFileDescriptor((FileDescriptor) resourceObject);
return imageResource;
}
if (resourceObject instanceof byte[]) {
StreamResource imageResource = createResource(StreamResource.class);
Supplier<InputStream> streamSupplier = () -> new ByteArrayDataProvider((byte[]) resourceObject).provide();
imageResource.setStreamSupplier(streamSupplier);
return imageResource;
}
throw new GuiDevelopmentException("The Image component supports only FileDescriptor and byte[] datasource property value binding", getFrame().getId());
}
Aggregations