use of io.jmix.ui.Screens in project jmix by jmix-framework.
the class BulkEditors method buildEditor.
protected <E> BulkEditorWindow<E> buildEditor(BulkEditorBuilder<E> builder) {
FrameOwner origin = builder.getOrigin();
Screens screens = getScreenContext(origin).getScreens();
if (CollectionUtils.isEmpty(builder.getEntities())) {
throw new IllegalStateException(String.format("BulkEditor of %s cannot be open with no entities were set", builder.getMetaClass()));
}
// noinspection unchecked
BulkEditorWindow<E> bulkEditorWindow = screens.create(BulkEditorWindow.class, builder.openMode);
BulkEditorContext<E> context = createBulkEditorContext(builder);
bulkEditorWindow.setBulkEditorContext(context);
bulkEditorWindow.addAfterCloseListener(createAfterCloseHandler(builder));
return bulkEditorWindow;
}
use of io.jmix.ui.Screens in project jmix by jmix-framework.
the class RelatedEntitiesSupportImpl method createScreen.
protected Screen createScreen(RelatedEntitiesBuilder builder, MetaClass metaClass, MetaProperty metaProperty) {
FrameOwner origin = builder.getOrigin();
Screens screens = UiControllerUtils.getScreenContext(origin).getScreens();
if (builder instanceof RelatedEntitiesClassBuilder) {
return screens.create(((RelatedEntitiesClassBuilder<?>) builder).getScreenClass(), builder.getOpenMode(), builder.getOptions());
} else {
String screenId = builder.getScreenId();
if (Strings.isNullOrEmpty(screenId)) {
// try to get default browse screen id
screenId = windowConfig.getBrowseScreenId(metaProperty.getRange().asClass());
if (Strings.isNullOrEmpty(screenId)) {
String message = String.format("Can't create related entities screen: passed screen id is null and " + "there is no default browse screen for %s", metaClass.getName());
throw new IllegalStateException(message);
}
}
return screens.create(screenId, builder.getOpenMode(), builder.getOptions());
}
}
use of io.jmix.ui.Screens in project jmix by jmix-framework.
the class BackgroundWorkProgressWindow method show.
/**
* Show modal window with message which will last until task completes.
* Optionally cancel button can be displayed. By pressing cancel button user can cancel task execution.
*
* @param task background task containing long operation
* @param title window title, optional
* @param message window message, optional
* @param total total number of items, that will be processed
* @param cancelAllowed show or not cancel button
* @param percentProgress show progress in percents
* @param <V> task result type
*/
public static <T extends Number, V> void show(BackgroundTask<T, V> task, @Nullable String title, @Nullable String message, Number total, boolean cancelAllowed, boolean percentProgress) {
if (task.getOwnerScreen() == null) {
throw new IllegalArgumentException("Task without owner cannot be run");
}
Map<String, Object> params = new HashMap<>();
params.put("task", task);
params.put("title", title);
params.put("message", message);
params.put("total", total);
params.put("cancelAllowed", cancelAllowed);
params.put("percentProgress", percentProgress);
Screens screens = UiControllerUtils.getScreenContext(task.getOwnerScreen()).getScreens();
WindowInfo windowInfo = AppBeans.get(WindowConfig.class).getWindowInfo("backgroundWorkProgressWindow");
((WindowManager) screens).openWindow(windowInfo, OpenType.DIALOG, params);
}
use of io.jmix.ui.Screens in project jmix by jmix-framework.
the class AddToSetAction method actionPerform.
@Override
public void actionPerform(Component component) {
MetaClass entityMetaClass;
if (target.getItems() instanceof EntityDataUnit) {
entityMetaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
} else {
throw new UnsupportedOperationException("Unsupported data unit " + target.getItems());
}
String query;
if (filter.getDatasource() != null) {
query = filter.getDatasource().getQuery();
} else {
query = filter.getDataLoader().getQuery();
}
String[] strings = ValuePathHelper.parse(CubaComponentsHelper.getFilterComponentPath(filter));
String componentId = ValuePathHelper.pathSuffix(strings);
Set ownerSelection = target.getSelected();
Map<String, Object> params = new HashMap<>();
params.put("entityType", entityMetaClass.getName());
params.put("items", ownerSelection);
params.put("componentPath", CubaComponentsHelper.getFilterComponentPath(filter));
params.put("componentId", componentId);
params.put("foldersPane", filterHelper.getFoldersPane());
params.put("entityClass", entityMetaClass.getJavaClass().getName());
params.put("query", query);
params.put("username", userSessionSource.getUserSession().getUser().getUsername());
Screens screens = ComponentsHelper.getScreenContext(filter).getScreens();
screens.create("saveSetInFolder", OpenMode.DIALOG, new MapScreenOptions(params)).show();
}
use of io.jmix.ui.Screens in project jmix by jmix-framework.
the class LayoutAnalyzerContextMenuProvider method initContextMenu.
public void initContextMenu(Screen screen, io.jmix.ui.component.Component contextMenuTarget) {
if (screenProperties.isLayoutAnalyzerEnabled()) {
ContextMenu contextMenu = new ContextMenu(contextMenuTarget.unwrap(AbstractComponent.class), true);
MenuBar.MenuItem menuItem = contextMenu.addItem(messages.getMessage("actions.analyzeLayout"), c -> {
LayoutAnalyzer analyzer = new LayoutAnalyzer();
List<LayoutTip> tipsList = analyzer.analyze(screen);
if (tipsList.isEmpty()) {
Notifications notifications = UiControllerUtils.getScreenContext(screen).getNotifications();
notifications.create(Notifications.NotificationType.HUMANIZED).withCaption("No layout problems found").show();
} else {
Screens screens = UiControllerUtils.getScreenContext(screen).getScreens();
LayoutAnalyzerScreen layoutAnalyzerScreen = screens.create(LayoutAnalyzerScreen.class, OpenMode.DIALOG);
layoutAnalyzerScreen.setLayoutTips(tipsList);
layoutAnalyzerScreen.show();
}
});
menuItem.setStyleName("jmix-cm-item");
}
}
Aggregations