Search in sources :

Example 46 with Subscribe

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

the class FileMultiUploadFieldScreen method onInit.

@Subscribe
public void onInit(InitEvent event) {
    // <2>
    fileMultiUploadField.addQueueUploadCompleteListener(queueUploadCompleteEvent -> {
        // <3>
        for (Map.Entry<UUID, String> entry : fileMultiUploadField.getUploadsMap().entrySet()) {
            // <4>
            UUID fileId = entry.getKey();
            String fileName = entry.getValue();
            // <5>
            FileRef fileRef = temporaryStorage.putFileIntoStorage(fileId, fileName);
        }
        notifications.create().withCaption("Uploaded files: " + fileMultiUploadField.getUploadsMap().values()).show();
        // <6>
        fileMultiUploadField.clearUploads();
    });
    fileMultiUploadField.addFileUploadErrorListener(queueFileUploadErrorEvent -> notifications.create().withCaption("File upload error").show());
}
Also used : FileRef(io.jmix.core.FileRef) UUID(java.util.UUID) Map(java.util.Map) Subscribe(io.jmix.ui.screen.Subscribe)

Example 47 with Subscribe

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

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 48 with Subscribe

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

the class PopupButtonScreen method onInit.

// end::event[]
@Subscribe
protected void onInit(InitEvent event) {
    // end::listener[]
    popupButton.addAction(new BaseAction("saveAsDocAction").withCaption("Save as .doc").withHandler(actionPerformedEvent -> saveAsDoc()));
    popupButton.addAction(new BaseAction("saveAsPdfAction").withCaption("Save as .pdf").withHandler(actionPerformedEvent -> saveAsPdf()));
    // tag::listener[]
    popupButton.addPopupVisibilityListener(popupVisibilityEvent -> notifications.create().withCaption("Popup visibility changed").show());
}
Also used : Subscribe(io.jmix.ui.screen.Subscribe) Status(ui.ex1.entity.Status) UiController(io.jmix.ui.screen.UiController) Autowired(org.springframework.beans.factory.annotation.Autowired) Screen(io.jmix.ui.screen.Screen) UiDescriptor(io.jmix.ui.screen.UiDescriptor) Notifications(io.jmix.ui.Notifications) ComboBox(io.jmix.ui.component.ComboBox) PopupButton(io.jmix.ui.component.PopupButton) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Button(io.jmix.ui.component.Button) TextField(io.jmix.ui.component.TextField) BaseAction(io.jmix.ui.action.BaseAction) Subscribe(io.jmix.ui.screen.Subscribe)

Example 49 with Subscribe

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

the class RunReportScreen method onRrBtn2Click.

// end::rr-btn1-end[]
// tag::rr-btn2-start[]
@Subscribe("rrBtn2")
protected void onRrBtn2Click(Button.ClickEvent event) {
    // end::rr-btn2-start[]
    Report report = getReportByCode("BOOKS");
    LiteratureType type = dataManager.load(LiteratureType.class).query("select c from jmxrpr_LiteratureType c where c.name = :name").parameter("name", "Art").one();
    // tag::report-runner-v3[]
    ReportOutputDocument document = reportRunner.byReportEntity(report).addParam("type", type).withOutputType(// <1>
    ReportOutputType.PDF).withOutputNamePattern(// <2>
    "Books").run();
    // end::report-runner-v3[]
    // tag::get-content[]
    String documentName = document.getDocumentName();
    byte[] content = document.getContent();
// end::get-content[]
// tag::rr-btn2-end[]
}
Also used : ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) Report(io.jmix.reports.entity.Report) LiteratureType(reports.ex2.entity.LiteratureType) Subscribe(io.jmix.ui.screen.Subscribe)

Example 50 with Subscribe

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

the class RunReportScreen method onUrrBtn1Click.

// end::rr-btn2-end[]
@Subscribe("urrBtn1")
protected void onUrrBtn1Click(Button.ClickEvent event) {
    Report report = getReportByCode("BOOK_COUNT");
    // tag::run-and-show[]
    uiReportRunner.runAndShow(new UiReportRunContext(report));
// end::run-and-show[]
}
Also used : UiReportRunContext(io.jmix.reportsui.runner.UiReportRunContext) Report(io.jmix.reports.entity.Report) Subscribe(io.jmix.ui.screen.Subscribe)

Aggregations

Subscribe (io.jmix.ui.screen.Subscribe)121 Report (io.jmix.reports.entity.Report)14 Screen (io.jmix.ui.screen.Screen)11 ListDataProvider (io.jmix.ui.data.impl.ListDataProvider)10 ReportOutputDocument (com.haulmont.yarg.reporting.ReportOutputDocument)8 FileRef (io.jmix.core.FileRef)8 UUID (java.util.UUID)8 UiController (io.jmix.ui.screen.UiController)7 UiDescriptor (io.jmix.ui.screen.UiDescriptor)7 Autowired (org.springframework.beans.factory.annotation.Autowired)7 BigDecimal (java.math.BigDecimal)6 LiteratureType (reports.ex2.entity.LiteratureType)6 UiReportRunContext (io.jmix.reportsui.runner.UiReportRunContext)5 Date (java.util.Date)5 List (java.util.List)5 ReportTemplate (io.jmix.reports.entity.ReportTemplate)4 DataLoader (io.jmix.ui.model.DataLoader)4 ArrayList (java.util.ArrayList)4 Order (charts.ex1.entity.Order)3 Metadata (io.jmix.core.Metadata)3