Search in sources :

Example 26 with GuiDevelopmentException

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);
}
Also used : Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 27 with GuiDevelopmentException

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;
}
Also used : Datasource(com.haulmont.cuba.gui.data.Datasource) DsContext(com.haulmont.cuba.gui.data.DsContext) Element(org.dom4j.Element) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 28 with GuiDevelopmentException

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());
}
Also used : ByteArrayDataProvider(com.haulmont.cuba.gui.export.ByteArrayDataProvider) InputStream(java.io.InputStream) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) FileDescriptor(com.haulmont.cuba.core.entity.FileDescriptor)

Example 29 with GuiDevelopmentException

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();
}
Also used : GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 30 with GuiDevelopmentException

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());
}
Also used : ByteArrayDataProvider(com.haulmont.cuba.gui.export.ByteArrayDataProvider) StreamResource(com.haulmont.cuba.gui.components.StreamResource) InputStream(java.io.InputStream) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) FileDescriptorResource(com.haulmont.cuba.gui.components.FileDescriptorResource) FileDescriptor(com.haulmont.cuba.core.entity.FileDescriptor)

Aggregations

GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)55 Element (org.dom4j.Element)23 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)8 Component (com.haulmont.cuba.gui.components.Component)7 Datasource (com.haulmont.cuba.gui.data.Datasource)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 MetaClass (com.haulmont.chile.core.model.MetaClass)5 ComponentLoader (com.haulmont.cuba.gui.xml.layout.ComponentLoader)4 MetaProperty (com.haulmont.chile.core.model.MetaProperty)3 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)3 CategoryAttribute (com.haulmont.cuba.core.entity.CategoryAttribute)3 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)3 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)3 LayoutLoader (com.haulmont.cuba.gui.xml.layout.LayoutLoader)3 FileDescriptor (com.haulmont.cuba.core.entity.FileDescriptor)2 WindowManager (com.haulmont.cuba.gui.WindowManager)2 Column (com.haulmont.cuba.gui.components.DataGrid.Column)2 ListComponent (com.haulmont.cuba.gui.components.ListComponent)2 DsContext (com.haulmont.cuba.gui.data.DsContext)2 ByteArrayDataProvider (com.haulmont.cuba.gui.export.ByteArrayDataProvider)2