use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class AddConditionHelper method _addCondition.
protected void _addCondition(AbstractConditionDescriptor descriptor, ConditionsTree conditionsTree) {
final AbstractCondition condition = descriptor.createCondition();
if (descriptor instanceof CustomConditionCreator) {
WindowInfo windowInfo = windowConfig.getWindowInfo("customConditionEditor");
Map<String, Object> params = new HashMap<>();
params.put("condition", condition);
params.put("conditionsTree", conditionsTree);
final CustomConditionEditor window = (CustomConditionEditor) windowManager.openWindow(windowInfo, WindowManager.OpenType.DIALOG, params);
window.addCloseListener(actionId -> {
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
handler.handle(condition);
}
});
} else if (descriptor instanceof DynamicAttributesConditionCreator) {
WindowInfo windowInfo = windowConfig.getWindowInfo("dynamicAttributesConditionEditor");
Map<String, Object> params = new HashMap<>();
params.put("condition", condition);
final DynamicAttributesConditionEditor window = (DynamicAttributesConditionEditor) windowManager.openWindow(windowInfo, WindowManager.OpenType.DIALOG, params);
window.addCloseListener(actionId -> {
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
handler.handle(condition);
}
});
} else {
handler.handle(condition);
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class TreeLoader method loadButtonsPanel.
protected void loadButtonsPanel(Tree component) {
if (buttonsPanelLoader != null) {
// noinspection unchecked
buttonsPanelLoader.loadComponent();
ButtonsPanel panel = (ButtonsPanel) buttonsPanelLoader.getResultComponent();
Window window = ComponentsHelper.getWindowImplementation(component);
String alwaysVisible = buttonsPanelElement.attributeValue("alwaysVisible");
panel.setVisible(!(window instanceof Window.Lookup) || "true".equals(alwaysVisible));
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WidgetsTreeLoader method loadButtonsPanel.
protected void loadButtonsPanel(Tree component) {
if (buttonsPanelLoader != null) {
// noinspection unchecked
buttonsPanelLoader.loadComponent();
ButtonsPanel panel = (ButtonsPanel) buttonsPanelLoader.getResultComponent();
Window window = ComponentsHelper.getWindowImplementation(component);
String alwaysVisible = buttonsPanelElement.attributeValue("alwaysVisible");
panel.setVisible(!(window instanceof Window.Lookup) || "true".equals(alwaysVisible));
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class ScreenHistorySupport method saveScreenHistory.
public void saveScreenHistory(Window window, WindowManager.OpenMode openMode) {
Security security = AppBeans.get(Security.NAME);
if (security.isEntityOpPermitted(ScreenHistoryEntity.class, EntityOp.CREATE) && window.getFrame() != null && (window.getFrame() instanceof Window.Editor) && openMode != WindowManager.OpenMode.DIALOG && (screenIds == null || screenIds.contains(window.getId()))) {
String caption = window.getCaption();
UUID entityId = null;
Frame frame = window.getFrame();
Entity entity = null;
if (frame instanceof Window.Editor) {
entity = ((Window.Editor) frame).getItem();
if (entity != null) {
if (PersistenceHelper.isNew(entity)) {
return;
}
if (StringUtils.isBlank(caption))
caption = messages.getTools().getEntityCaption(entity.getMetaClass()) + " " + entity.getInstanceName();
entityId = (UUID) entity.getId();
}
}
ScreenHistoryEntity screenHistoryEntity = metadata.create(ScreenHistoryEntity.class);
screenHistoryEntity.setCaption(StringUtils.abbreviate(caption, 255));
screenHistoryEntity.setUrl(makeLink(window));
screenHistoryEntity.setEntityId(entityId);
addAdditionalFields(screenHistoryEntity, entity);
CommitContext cc = new CommitContext(Collections.singleton(screenHistoryEntity));
DataService dataService = AppBeans.get(DataService.NAME);
dataService.commit(cc);
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopWindowManager method showWindowThisTab.
protected JComponent showWindowThisTab(Window window, String caption, String description) {
getDialogParams().reset();
window.setWidth("100%");
window.setHeight("100%");
JComponent layout;
if (isMainWindowManager) {
layout = (JComponent) tabsPane.getSelectedComponent();
} else {
layout = (JComponent) frame.getContentPane().getComponent(0);
}
WindowBreadCrumbs breadCrumbs = tabs.get(layout);
if (breadCrumbs == null)
throw new IllegalStateException("BreadCrumbs not found");
Window currentWindow = breadCrumbs.getCurrentWindow();
Window currentWindowFrame = (Window) currentWindow.getFrame();
windowOpenMode.get(currentWindowFrame).setFocusOwner(frame.getFocusOwner());
Set<Map.Entry<Window, Integer>> set = windows.entrySet();
boolean pushed = false;
for (Map.Entry<Window, Integer> entry : set) {
if (entry.getKey().equals(currentWindow)) {
windows.remove(currentWindow);
stacks.get(breadCrumbs).push(entry);
pushed = true;
break;
}
}
if (!pushed) {
stacks.get(breadCrumbs).push(new AbstractMap.SimpleEntry<>(currentWindow, null));
}
windows.remove(window);
layout.remove(DesktopComponentsHelper.getComposition(currentWindow));
JComponent component = DesktopComponentsHelper.getComposition(window);
layout.add(component);
breadCrumbs.addWindow(window);
if (isMainWindowManager) {
setActiveWindowCaption(caption, description, tabsPane.getSelectedIndex());
} else {
setTopLevelWindowCaption(caption);
component.revalidate();
component.repaint();
}
return layout;
}
Aggregations