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());
}
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[]
}
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());
}
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[]
}
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[]
}
Aggregations