use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
the class LocalizedTaskWrapper method handleException.
@Override
public boolean handleException(Exception ex) {
boolean handled = wrappedTask.handleException(ex);
if (handled || wrappedTask.getOwnerScreen() == null) {
Screens screens = getScreenContext().getScreens();
screens.remove(screen);
} else {
Screens screens = getScreenContext().getScreens();
screens.remove(screen);
showExecutionError(ex);
log.error("Exception occurred in background task", ex);
handled = true;
}
return handled;
}
use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
the class App method createTopLevelWindow.
/**
* Called on each browser tab initialization.
*/
public void createTopLevelWindow(AppUI ui) {
String topLevelWindowId = routeTopLevelWindowId();
Screens screens = ui.getScreens();
Screen screen = screens.create(topLevelWindowId, OpenMode.ROOT);
screens.show(screen);
}
use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
the class App method logout.
/**
* Try to perform logout. If there are unsaved changes in opened windows then logout will not be performed and
* unsaved changes dialog will appear.
*
* @return operation result object
*/
public OperationResult logout() {
AppUI ui = AppUI.getCurrent();
try {
RootWindow topLevelWindow = ui != null ? ui.getTopLevelWindow() : null;
if (topLevelWindow != null) {
Screens screens = ui.getScreens();
if (!screens.hasUnsavedChanges()) {
performStandardLogout(ui);
return OperationResult.success();
}
UnknownOperationResult result = new UnknownOperationResult();
Messages messages = beanLocator.get(Messages.NAME);
Icons icons = beanLocator.get(Icons.NAME);
Dialogs dialogs = ui.getDialogs();
dialogs.createOptionDialog().withCaption(messages.getMainMessage("closeUnsaved.caption")).withMessage(messages.getMainMessage("discardChangesOnClose")).withActions(new BaseAction("closeApplication").withCaption(messages.getMainMessage("closeApplication")).withIcon(icons.get(CubaIcon.DIALOG_OK)).withHandler(event -> {
performStandardLogout(ui);
result.success();
}), new DialogAction(DialogAction.Type.CANCEL, Action.Status.PRIMARY).withHandler(event -> {
result.fail();
})).show();
return OperationResult.fail();
} else {
forceLogout();
return OperationResult.success();
}
} catch (Exception e) {
log.error("Error on logout", e);
String url = ControllerUtils.getLocationWithoutParams() + "?restartApp";
if (ui != null) {
ui.getPage().open(url, "_self");
}
return new UnknownOperationResult();
}
}
use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
the class App method navigateTo.
/**
* Initialize new TopLevelWindow and replace current.
*
* @param topLevelWindowId target top level window id
* @deprecated Use {@link Screens#create(Class, Screens.LaunchMode)} with {@link OpenMode#ROOT}
*/
@Deprecated
public void navigateTo(String topLevelWindowId) {
AppUI ui = AppUI.getCurrent();
WindowInfo windowInfo = windowConfig.getWindowInfo(topLevelWindowId);
Screens screens = ui.getScreens();
Screen screen = screens.create(windowInfo.asScreen(), OpenMode.ROOT);
screens.show(screen);
}
use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
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(ComponentsHelper.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", ComponentsHelper.getFilterComponentPath(filter));
params.put("componentId", componentId);
params.put("foldersPane", filterHelper.getFoldersPane());
params.put("entityClass", entityMetaClass.getJavaClass().getName());
params.put("query", query);
Screens screens = ComponentsHelper.getScreenContext(filter).getScreens();
screens.create("saveSetInFolder", OpenMode.DIALOG, new MapScreenOptions(params)).show();
}
Aggregations