use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.
the class DesktopWindow method setDescription.
@Override
public void setDescription(String description) {
this.description = description;
DialogWindow dialogWindow = asDialogWindow();
if (dialogWindow != null) {
dialogWindow.setTitle(caption);
} else {
JPanel tabWindow = asTabWindow();
if (tabWindow != null) {
setTabCaptionAndDescription(tabWindow);
} else {
JPanel singleWindow = asDetachedWindow();
if (singleWindow != null) {
TopLevelFrame topLevelFrame = asTopLevelFrame();
if (topLevelFrame != null) {
topLevelFrame.setTitle(formatTabCaption(caption, description));
}
}
}
}
}
use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.
the class DesktopWindow method setCaption.
@Override
public void setCaption(String caption) {
this.caption = caption;
DialogWindow dialogWindow = asDialogWindow();
if (dialogWindow != null) {
dialogWindow.setTitle(caption);
} else {
JPanel tabWindow = asTabWindow();
if (tabWindow != null) {
setTabCaptionAndDescription(tabWindow);
} else {
JPanel singleWindow = asDetachedWindow();
if (singleWindow != null) {
TopLevelFrame topLevelFrame = asTopLevelFrame();
if (topLevelFrame != null) {
topLevelFrame.setTitle(formatTabCaption(caption, description));
}
windowManager.getBreadCrumbs(singleWindow).update();
}
}
}
}
use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.
the class DesktopWindowManager method showNewWindow.
protected JComponent showNewWindow(Window window, OpenType openType, String caption) {
window.setHeight("100%");
window.setWidth("100%");
TopLevelFrame windowFrame = createTopLevelFrame(caption);
windowFrame.setName(window.getId());
Dimension dimension = new Dimension();
dimension.width = 800;
if (openType.getWidth() != null) {
dimension.width = openType.getWidth().intValue();
}
dimension.height = 500;
if (openType.getHeight() != null) {
dimension.height = openType.getHeight().intValue();
}
boolean resizable = true;
if (openType.getResizable() != null) {
resizable = openType.getResizable();
}
windowFrame.setResizable(resizable);
windowFrame.setMinimumSize(dimension);
windowFrame.pack();
getDialogParams().reset();
WindowBreadCrumbs breadCrumbs = createBreadCrumbs();
breadCrumbs.addWindow(window);
JComponent tabContent = createTabPanel(window, breadCrumbs);
WindowOpenInfo openInfo = new WindowOpenInfo(window, OpenMode.NEW_WINDOW);
openInfo.setData(tabContent);
Map<Window, WindowOpenInfo> openInfos = new HashMap<>();
if (window instanceof Window.Wrapper) {
Window wrappedWindow = ((Window.Wrapper) window).getWrappedWindow();
openInfos.put(wrappedWindow, openInfo);
} else {
openInfos.put(window, openInfo);
}
windowFrame.getWindowManager().attachTab(breadCrumbs, new Stack<>(), window, getWindowHashCode(window), tabContent, openInfos);
App.getInstance().registerFrame(windowFrame);
windowFrame.setVisible(true);
return DesktopComponentsHelper.getComposition(window);
}
use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.
the class DesktopWindowManager method detachTab.
protected void detachTab(int tabIndex) {
// Create new top-level frame, put this tab to it with breadcrumbs.
// remove tab data from this window manager
JComponent tabContent = (JComponent) tabsPane.getComponentAt(tabIndex);
WindowBreadCrumbs breadCrumbs = tabs.get(tabContent);
Window window = breadCrumbs.getCurrentWindow();
if (window == null) {
throw new IllegalArgumentException("window is null");
}
// WindowOpenMode map
Map<Window, WindowOpenInfo> detachOpenModes = new HashMap<>();
detachOpenModes.put((Window) window.getFrame(), windowOpenMode.get(window.<Window>getFrame()));
windowOpenMode.remove(window.<Window>getFrame());
Stack<Map.Entry<Window, Integer>> stack = stacks.get(breadCrumbs);
for (Map.Entry<Window, Integer> entry : stack) {
WindowOpenInfo openInfo = windowOpenMode.get(entry.getKey().<Window>getFrame());
detachOpenModes.put((Window) entry.getKey().getFrame(), openInfo);
windowOpenMode.remove(entry.getKey().<Window>getFrame());
}
tabs.remove(tabContent);
Integer hashCode = windows.remove(window);
tabsPane.remove(tabIndex);
stacks.remove(breadCrumbs);
final TopLevelFrame windowFrame = createTopLevelFrame(window.getCaption());
App.getInstance().registerFrame(windowFrame);
windowFrame.setVisible(true);
windowFrame.getWindowManager().attachTab(breadCrumbs, stack, window, hashCode, tabContent, detachOpenModes);
}
use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.
the class JXErrorPaneExt method sendSupportEmail.
private void sendSupportEmail(ErrorInfo jXErrorPaneInfo) {
Configuration configuration = AppBeans.get(Configuration.NAME);
ExceptionReportService reportService = AppBeans.get(ExceptionReportService.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
TopLevelFrame mainFrame = App.getInstance().getMainFrame();
Messages messages = AppBeans.get(Messages.NAME);
Locale locale = App.getInstance().getLocale();
try {
TimeSource timeSource = AppBeans.get(TimeSource.NAME);
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timeSource.currentTimestamp());
UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
User user = userSessionSource.getUserSession().getUser();
Map<String, Object> binding = new HashMap<>();
binding.put("timestamp", date);
binding.put("errorMessage", jXErrorPaneInfo.getBasicErrorMessage());
binding.put("stacktrace", getStackTrace(jXErrorPaneInfo.getErrorException()));
binding.put("systemId", clientConfig.getSystemID());
binding.put("userLogin", user.getLogin());
if (MapUtils.isNotEmpty(additionalExceptionReportBinding)) {
binding.putAll(additionalExceptionReportBinding);
}
reportService.sendExceptionReport(clientConfig.getSupportEmail(), ImmutableMap.copyOf(binding));
mainFrame.showNotification(messages.getMainMessage("errorPane.emailSent", locale), Frame.NotificationType.TRAY);
} catch (Throwable e) {
mainFrame.showNotification(messages.getMainMessage("errorPane.emailSendingErr", locale), Frame.NotificationType.ERROR);
log.error("Can't send error report", e);
}
}
Aggregations