Search in sources :

Example 31 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix-docs by Haulmont.

the class ImageScreen method onInit.

// end::set-source[]
// end::listener[]
// tag::value-source[]
// tag::set-source[]
// tag::listener[]
@Subscribe
public void onInit(InitEvent event) {
    // end::listener[]
    // end::set-source[]
    personsTable.addGeneratedColumn("image", entity -> {
        Image<FileRef> image = uiComponents.create(Image.NAME);
        image.setValueSource(new ContainerValueSource<>(personsTable.getInstanceContainer(entity), "image"));
        image.setHeight("100px");
        image.setScaleMode(Image.ScaleMode.CONTAIN);
        return image;
    });
    // end::value-source[]
    // tag::set-source[]
    String address = "https://www.cuba-platform.com/sites/all/themes/cuba_adaptive/img/upper-header-logo.png";
    URL url = null;
    try {
        url = new URL(address);
        programmaticImage.setSource(UrlResource.class).setUrl(url);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
// end::set-source[]
// tag::listener[]
// tag::value-source[]
// tag::set-source[]
}
Also used : MalformedURLException(java.net.MalformedURLException) FileRef(io.jmix.core.FileRef) UrlResource(io.jmix.ui.component.UrlResource) URL(java.net.URL) Subscribe(io.jmix.ui.screen.Subscribe)

Example 32 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix by jmix-framework.

the class NotFoundScreen method onInit.

@Subscribe
protected void onInit(InitEvent event) {
    Window window = getWindow();
    Label<String> msgLabel = uiComponents.create(Label.TYPE_STRING);
    msgLabel.setAlignment(Component.Alignment.TOP_CENTER);
    msgLabel.addStyleName(ThemeClassNames.LABEL_H1);
    msgLabel.setValue(messages.formatMessage("", "notAssociatedRoute", requestedRoute));
    window.add(msgLabel);
    window.setCaption(messages.formatMessage("", "tabCaption", requestedRoute));
}
Also used : Window(io.jmix.ui.component.Window) Subscribe(io.jmix.ui.screen.Subscribe)

Example 33 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix by jmix-framework.

the class UiControllerReflectionInspector method getAnnotatedSubscribeMethodsNotCached.

protected List<AnnotatedMethod<Subscribe>> getAnnotatedSubscribeMethodsNotCached(@SuppressWarnings("unused") Class<?> clazz, Method[] uniqueDeclaredMethods) {
    MethodHandles.Lookup lookup = MethodHandles.lookup();
    List<AnnotatedMethod<Subscribe>> annotatedMethods = new ArrayList<>();
    for (Method m : uniqueDeclaredMethods) {
        if (m.getParameterCount() == 1 && EventObject.class.isAssignableFrom(m.getParameterTypes()[0])) {
            Subscribe annotation = findMergedAnnotation(m, Subscribe.class);
            if (annotation != null) {
                if (!m.isAccessible()) {
                    m.setAccessible(true);
                }
                MethodHandle methodHandle;
                try {
                    methodHandle = lookup.unreflect(m);
                } catch (IllegalAccessException e) {
                    throw new RuntimeException("unable to get method handle " + m);
                }
                annotatedMethods.add(new AnnotatedMethod<>(annotation, m, methodHandle));
            }
        }
    }
    annotatedMethods.sort(this::compareSubscribeMethods);
    return ImmutableList.copyOf(annotatedMethods);
}
Also used : Subscribe(io.jmix.ui.screen.Subscribe)

Example 34 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix by jmix-framework.

the class SaveSetWindow method onInsertBtnClick.

@Subscribe("insertBtn")
protected void onInsertBtnClick(Button.ClickEvent event) {
    SearchFolder folder = folderSelect.getValue();
    AppUI appUI = AppUI.getCurrent();
    if (appUI != null && folder == null) {
        appUI.getNotifications().create(Notifications.NotificationType.TRAY).withCaption(getMessage("saveSetWindow.notSelected")).show();
        return;
    }
    String filterXml = folder.getFilterXml();
    folder.setFilterXml(UserSetHelper.addEntities(filterXml, ids));
    foldersPane.saveFolder(folder);
    foldersPane.refreshFolders();
    close(new StandardCloseAction(COMMIT_ACTION_ID, false));
}
Also used : StandardCloseAction(io.jmix.ui.screen.StandardCloseAction) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) AppUI(io.jmix.ui.AppUI) Subscribe(io.jmix.ui.screen.Subscribe)

Example 35 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix by jmix-framework.

the class SaveSetWindow method onCreateNewClick.

@Subscribe("createNew")
protected void onCreateNewClick(Button.ClickEvent event) {
    AppUI appUI = AppUI.getCurrent();
    if (appUI == null) {
        return;
    }
    QueryParser parser = queryTransformerFactory.parser(query);
    String entityAlias = parser.getEntityAlias(entityType);
    String filterXml = UserSetHelper.generateSetFilter(ids, entityClass, componentId, entityAlias);
    SearchFolder folder = metadata.create(SearchFolder.class);
    folder.setUsername(username);
    folder.setName("");
    folder.setFilterXml(filterXml);
    folder.setFilterComponentId(componentPath);
    folder.setEntityType(entityType);
    folder.setIsSet(true);
    Runnable commitHandler = () -> {
        foldersPane.saveFolder(folder);
        foldersPane.refreshFolders();
    };
    FolderEditWindow window = AppFolderEditWindow.create(false, false, folder, null, commitHandler);
    appUI.addWindow(window);
    window.addCloseListener(e -> close(COMMIT_ACTION_ID));
}
Also used : QueryParser(io.jmix.data.QueryParser) SearchFolder(com.haulmont.cuba.security.entity.SearchFolder) AppUI(io.jmix.ui.AppUI) Subscribe(io.jmix.ui.screen.Subscribe)

Aggregations

Subscribe (io.jmix.ui.screen.Subscribe)79 Report (io.jmix.reports.entity.Report)8 Screen (io.jmix.ui.screen.Screen)8 ListDataProvider (io.jmix.ui.data.impl.ListDataProvider)5 UiController (io.jmix.ui.screen.UiController)5 UiDescriptor (io.jmix.ui.screen.UiDescriptor)5 UUID (java.util.UUID)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ReportOutputDocument (com.haulmont.yarg.reporting.ReportOutputDocument)4 FileRef (io.jmix.core.FileRef)4 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 List (java.util.List)4 Order (test_support.entity.sales.Order)4 Metadata (io.jmix.core.Metadata)3 Visit (io.jmix.petclinic.entity.visit.Visit)3 UiReportRunContext (io.jmix.reportsui.runner.UiReportRunContext)3 FilterCondition (io.jmix.ui.entity.FilterCondition)3 GroupFilterCondition (io.jmix.ui.entity.GroupFilterCondition)3 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)3