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