use of com.haulmont.cuba.web.App in project cuba by cuba-platform.
the class ScreensLinkHandlerProcessor method handle.
@Override
public void handle(ExternalLinkContext linkContext) {
String screenName = linkContext.getRequestParams().get("screen");
App app = linkContext.getApp();
final WindowInfo windowInfo = windowConfig.getWindowInfo(screenName);
if (windowInfo == null) {
log.warn("WindowInfo not found for screen: {}", screenName);
return;
}
try {
openWindow(windowInfo, linkContext);
} catch (EntityAccessException e) {
entityAccessExceptionHandler.handle(e, app.getWindowManager());
} catch (AccessDeniedException e) {
accessDeniedHandler.handle(e, app.getWindowManager());
} catch (NoSuchScreenException e) {
noSuchScreenHandler.handle(e, app.getWindowManager());
}
}
use of com.haulmont.cuba.web.App in project cuba by cuba-platform.
the class ScreensLinkHandlerProcessor method openWindow.
protected void openWindow(WindowInfo windowInfo, ExternalLinkContext linkContext) {
Map<String, String> requestParams = linkContext.getRequestParams();
App app = linkContext.getApp();
String itemStr = requestParams.get("item");
String openTypeParam = requestParams.get("openType");
WindowManager.OpenType openType = WindowManager.OpenType.NEW_TAB;
if (StringUtils.isNotEmpty(openTypeParam)) {
try {
openType = WindowManager.OpenType.valueOf(openTypeParam);
} catch (IllegalArgumentException e) {
log.warn("Unknown open type ({}) in request parameters", openTypeParam);
}
}
if (itemStr == null) {
app.getWindowManager().openWindow(windowInfo, openType, getParamsMap(requestParams));
} else {
EntityLoadInfo info = EntityLoadInfo.parse(itemStr);
if (info == null) {
log.warn("Invalid item definition: {}", itemStr);
} else {
Entity entity = loadEntityInstance(info);
if (entity != null)
app.getWindowManager().openEditor(windowInfo, entity, openType, getParamsMap(requestParams));
else
throw new EntityAccessException();
}
}
}
use of com.haulmont.cuba.web.App in project cuba by cuba-platform.
the class UserSwitchLinkHandlerProcessor method substituteUserAndOpenWindow.
protected void substituteUserAndOpenWindow(ExternalLinkContext linkContext, UUID userId) {
App app = linkContext.getApp();
UserSession userSession = app.getConnection().getSession();
assert userSession != null;
final User substitutedUser = loadUser(userId, userSession.getUser());
if (substitutedUser != null) {
app.getWindowManager().showOptionDialog(messages.getMainMessage("toSubstitutedUser.title"), getDialogMessage(substitutedUser), Frame.MessageType.CONFIRMATION_HTML, new Action[] { new ChangeSubstUserAction(substitutedUser) {
@Override
public void doAfterChangeUser() {
super.doAfterChangeUser();
screenHandler.handle(linkContext);
}
@Override
public void doRevert() {
super.doRevert();
JavaScript js = Page.getCurrent().getJavaScript();
js.execute("window.close();");
}
@Override
public String getCaption() {
return messages.getMainMessage("action.switch");
}
}, new DoNotChangeSubstUserAction() {
@Override
public void actionPerform(Component component) {
super.actionPerform(component);
JavaScript js = Page.getCurrent().getJavaScript();
js.execute("window.close();");
}
@Override
public String getCaption() {
return messages.getMainMessage("action.cancel");
}
} });
} else {
User user = loadUser(userId);
app.getWindowManager().showOptionDialog(messages.getMainMessage("warning.title"), getWarningMessage(user), Frame.MessageType.WARNING_HTML, new Action[] { new DialogAction(DialogAction.Type.OK).withHandler(event -> {
JavaScript js = Page.getCurrent().getJavaScript();
js.execute("window.close();");
}) });
}
}
use of com.haulmont.cuba.web.App in project cuba by cuba-platform.
the class WebBackgroundWorker method handle.
@Override
public <T, V> BackgroundTaskHandler<V> handle(final BackgroundTask<T, V> task) {
checkNotNull(task);
checkUIAccess();
App appInstance;
try {
appInstance = App.getInstance();
} catch (IllegalStateException ex) {
log.error("Couldn't handle task", ex);
throw ex;
}
// create task executor
final WebTaskExecutor<T, V> taskExecutor = new WebTaskExecutor<>(appInstance.getAppUI(), task);
// add thread to taskSet
appInstance.addBackgroundTask(taskExecutor.getFuture());
// create task handler
TaskHandlerImpl<T, V> taskHandler = new TaskHandlerImpl<>(getUIAccessor(), taskExecutor, watchDog);
taskExecutor.setTaskHandler(taskHandler);
return taskHandler;
}
use of com.haulmont.cuba.web.App in project cuba by cuba-platform.
the class ExceptionDialog method logoutPrompt.
protected void logoutPrompt() {
App app = AppUI.getCurrent().getApp();
final WebWindowManager wm = app.getWindowManager();
wm.showOptionDialog(messages.getMainMessage("exceptionDialog.logoutCaption"), messages.getMainMessage("exceptionDialog.logoutMessage"), Frame.MessageType.WARNING, new Action[] { new AbstractAction(messages.getMainMessage("closeApplication")) {
@Override
public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
forceLogout();
}
@Override
public String getIcon() {
return "icons/ok.png";
}
}, new DialogAction(Type.CANCEL, Status.PRIMARY) });
}
Aggregations