use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.
the class DesktopWindowManager method createErrorInfo.
protected ErrorInfo createErrorInfo(String caption, String message, Throwable exception) {
UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
Security security = AppBeans.get(Security.NAME);
if (userSessionSource.getUserSession() == null || !security.isSpecificPermitted("cuba.gui.showExceptionDetails")) {
String dialogCaption = StringUtils.isNotEmpty(caption) ? caption : getMessage("errorPane.title");
String dialogMessage = StringUtils.isNotEmpty(message) ? message : getMessage("exceptionDialog.contactAdmin");
return new ErrorInfo(dialogCaption, dialogMessage, null, null, null, null, null);
}
Throwable rootCause = ExceptionUtils.getRootCause(exception);
if (rootCause == null)
rootCause = exception;
StringBuilder msg = new StringBuilder();
if (rootCause instanceof RemoteException) {
RemoteException re = (RemoteException) rootCause;
if (!re.getCauses().isEmpty()) {
RemoteException.Cause cause = re.getCauses().get(re.getCauses().size() - 1);
if (cause.getThrowable() != null)
rootCause = cause.getThrowable();
else {
// root cause is not supported by client
String className = cause.getClassName();
if (className != null && className.indexOf('.') > 0) {
className = className.substring(className.lastIndexOf('.') + 1);
}
msg.append(className).append(": ").append(cause.getMessage());
}
}
}
if (msg.length() == 0) {
msg.append(rootCause.getClass().getSimpleName());
if (!StringUtils.isBlank(rootCause.getMessage()))
msg.append(": ").append(rootCause.getMessage());
if (rootCause instanceof DevelopmentException) {
Map<String, Object> params = new LinkedHashMap<>();
if (rootCause instanceof GuiDevelopmentException) {
GuiDevelopmentException guiDevException = (GuiDevelopmentException) rootCause;
if (guiDevException.getFrameId() != null) {
params.put("Frame ID", guiDevException.getFrameId());
try {
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
params.put("XML descriptor", windowConfig.getWindowInfo(guiDevException.getFrameId()).getTemplate());
} catch (Exception e) {
params.put("XML descriptor", "not found for " + guiDevException.getFrameId());
}
}
}
params.putAll(((DevelopmentException) rootCause).getParams());
if (!params.isEmpty()) {
msg.append("\n\n");
for (Map.Entry<String, Object> entry : params.entrySet()) {
msg.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
}
}
}
}
return new ErrorInfo(getMessage("errorPane.title"), msg.toString(), null, null, rootCause, null, null);
}
use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.
the class ChangePasswordLauncher method run.
@Override
public void run() {
WindowManager wm = App.getInstance().getMainFrame().getWindowManager();
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo windowInfo = windowConfig.getWindowInfo("sec$User.changePassword");
wm.openWindow(windowInfo, OpenType.DIALOG, ParamsMap.of("currentPasswordRequired", true));
}
use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.
the class WebFrame method openWindow.
@Override
public Window openWindow(String windowAlias, WindowManager.OpenType openType, Map<String, Object> params) {
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
WebWindowManager wm = App.getInstance().getWindowManager();
return wm.openWindow(windowInfo, openType, params);
}
use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.
the class WebFrame method openLookup.
@Override
public Window.Lookup openLookup(String windowAlias, Window.Lookup.Handler handler, WindowManager.OpenType openType) {
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
WebWindowManager wm = App.getInstance().getWindowManager();
return wm.openLookup(windowInfo, handler, openType);
}
use of com.haulmont.cuba.gui.config.WindowConfig in project cuba by cuba-platform.
the class WebFrame method openWindow.
@Override
public Window openWindow(String windowAlias, WindowManager.OpenType openType) {
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
WebWindowManager wm = App.getInstance().getWindowManager();
return wm.openWindow(windowInfo, openType);
}
Aggregations