Search in sources :

Example 1 with Widgetset

use of com.vaadin.annotations.Widgetset in project jmix by jmix-framework.

the class JmixUIProvider method getWidgetsetInfo.

@Nullable
@Override
public WidgetsetInfo getWidgetsetInfo(UICreateEvent event) {
    Widgetset uiWidgetset = getAnnotationFor(event.getUIClass(), Widgetset.class);
    // First case: We have an @Widgetset annotation, use that
    if (uiWidgetset != null) {
        String value = resolvePropertyPlaceholders(uiWidgetset.value());
        return new WidgetsetInfoImpl(value);
    }
    // Second case: We might have an init parameter, use that
    String initParameterWidgetSet = event.getService().getDeploymentConfiguration().getWidgetset(null);
    if (initParameterWidgetSet != null) {
        return new WidgetsetInfoImpl(initParameterWidgetSet);
    }
    // Find the class AppWidgetset in the default package if one exists
    WidgetsetInfo info = getWidgetsetClassInfo();
    // Third case: we have a generated class called APP_WIDGETSET_NAME
    if (info != null) {
        return info;
    } else {
        // Fourth case: we have an AppWidgetset.gwt.xml file
        try (InputStream resource = event.getUIClass().getResourceAsStream("/" + APP_WIDGETSET_NAME + ".gwt.xml")) {
            if (resource != null) {
                return new WidgetsetInfoImpl(false, null, APP_WIDGETSET_NAME);
            }
        } catch (IOException e) {
            throw new RuntimeException("AppWidgetset.gwt.xml file I/O exception", e);
        }
    }
    // fifth case: we are using the default widgetset
    return null;
}
Also used : InputStream(java.io.InputStream) Widgetset(com.vaadin.annotations.Widgetset) IOException(java.io.IOException) Nullable(javax.annotation.Nullable)

Aggregations

Widgetset (com.vaadin.annotations.Widgetset)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Nullable (javax.annotation.Nullable)1