use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.
the class DesktopWindowManager method moveWindowTab.
/**
* @param window Window implementation (DesktopWindow)
* @param position new tab position
*/
protected void moveWindowTab(Window window, int position) {
if (isMainWindowManager && position >= 0 && position < tabsPane.getComponentCount()) {
WindowOpenInfo openInfo = windowOpenMode.get(window);
if (openInfo != null) {
OpenMode openMode = openInfo.getOpenMode();
if (openMode == OpenMode.NEW_TAB || openMode == OpenMode.THIS_TAB) {
// show in tabsheet
JComponent layout = (JComponent) openInfo.getData();
int currentPosition = getTabPosition(layout);
String label = tabsPane.getTitleAt(currentPosition);
Icon icon = tabsPane.getIconAt(currentPosition);
Icon iconDis = tabsPane.getDisabledIconAt(currentPosition);
String tooltip = tabsPane.getToolTipTextAt(currentPosition);
boolean enabled = tabsPane.isEnabledAt(currentPosition);
int keycode = tabsPane.getMnemonicAt(currentPosition);
int mnemonicLoc = tabsPane.getDisplayedMnemonicIndexAt(currentPosition);
Color fg = tabsPane.getForegroundAt(currentPosition);
Color bg = tabsPane.getBackgroundAt(currentPosition);
java.awt.Component tabHeaderComponent = tabsPane.getTabComponentAt(currentPosition);
tabsPane.remove(layout);
tabsPane.insertTab(label, icon, layout, tooltip, position);
tabsPane.setDisabledIconAt(position, iconDis);
tabsPane.setEnabledAt(position, enabled);
tabsPane.setMnemonicAt(position, keycode);
tabsPane.setDisplayedMnemonicIndexAt(position, mnemonicLoc);
tabsPane.setForegroundAt(position, fg);
tabsPane.setBackgroundAt(position, bg);
tabsPane.setTabComponentAt(position, tabHeaderComponent);
tabsPane.setSelectedComponent(layout);
}
}
}
}
use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.
the class DesktopWindowManager method selectWindowTab.
@Override
public void selectWindowTab(Window window) {
if (isMainWindowManager) {
WindowOpenInfo openInfo = windowOpenMode.get(window);
if (openInfo != null) {
OpenMode openMode = openInfo.getOpenMode();
if (openMode == OpenMode.NEW_TAB || openMode == OpenMode.THIS_TAB) {
// show in tabsheet
JComponent layout = (JComponent) openInfo.getData();
tabsPane.setSelectedComponent(layout);
}
}
}
}
use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.
the class ScreenNavigationHandler method createScreen.
protected Screen createScreen(NavigationState requestedState, String screenRoute, WindowInfo windowInfo, AppUI ui) {
Screen screen;
if (isEditor(windowInfo)) {
screen = createEditor(windowInfo, screenRoute, requestedState, ui);
} else {
OpenMode openMode = getScreenOpenMode(requestedState.getNestedRoute(), screenRoute, ui);
screen = ui.getScreens().create(windowInfo.getId(), openMode);
}
return screen;
}
use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.
the class ScreenNavigationHandler method createEditor.
protected Screen createEditor(WindowInfo windowInfo, String screenRoute, NavigationState requestedState, AppUI ui) {
Map<String, Object> options = createEditorScreenOptions(windowInfo, requestedState, ui);
if (MapUtils.isEmpty(options)) {
log.info("Unable to load entity for editor: '{}'. " + "Subscribe for 'UrlParamsChangedEvent' to obtain its serialized id", windowInfo.getId());
}
Screen editor;
OpenMode openMode = getScreenOpenMode(requestedState.getNestedRoute(), screenRoute, ui);
if (isLegacyScreen(windowInfo.getControllerClass())) {
editor = ui.getScreens().create(windowInfo.getId(), openMode, new MapScreenOptions(options));
} else {
editor = ui.getScreens().create(windowInfo.getId(), openMode);
}
if (MapUtils.isNotEmpty(options)) {
Entity entity = (Entity) options.get(WindowParams.ITEM.name());
// noinspection unchecked
((EditorScreen<Entity>) editor).setEntityToEdit(entity);
}
return editor;
}
use of com.haulmont.cuba.gui.screen.OpenMode in project cuba by cuba-platform.
the class DesktopWindowManager method setWindowCaption.
@Override
public void setWindowCaption(Window window, String caption, String description) {
Window desktopWindow = window;
if (window instanceof Window.Wrapper) {
desktopWindow = ((Window.Wrapper) window).getWrappedWindow();
}
window.setCaption(caption);
String formattedCaption = formatTabDescription(caption, description);
WindowOpenInfo openInfo = windowOpenMode.get(desktopWindow);
if (openInfo != null) {
OpenMode openMode = openInfo.getOpenMode();
if (openMode != OpenMode.DIALOG) {
if (tabsPane != null) {
int selectedIndex = tabsPane.getSelectedIndex();
if (selectedIndex != -1) {
setActiveWindowCaption(caption, description, selectedIndex);
}
} else if (!isMainWindowManager) {
setTopLevelWindowCaption(formattedCaption);
}
} else {
JDialog jDialog = (JDialog) openInfo.getData();
if (jDialog != null) {
jDialog.setTitle(formattedCaption);
}
}
}
}
Aggregations