use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopWindowManager method moveFocus.
protected void moveFocus(java.awt.Component tab) {
Window window = tabs.get(tab).getCurrentWindow();
if (window != null) {
String focusComponentId = window.getFocusComponent();
boolean focused = false;
if (focusComponentId != null) {
com.haulmont.cuba.gui.components.Component focusComponent = window.getComponent(focusComponentId);
if (focusComponent != null) {
if (focusComponent.isEnabled() && focusComponent.isVisible()) {
focusComponent.requestFocus();
focused = true;
}
}
}
if (!focused && window instanceof Window.Wrapper) {
Window.Wrapper wrapper = (Window.Wrapper) window;
focused = ((DesktopWindow) wrapper.getWrappedWindow()).findAndFocusChildComponent();
if (!focused) {
tabsPane.requestFocus();
}
}
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopWindowManager method isCloseWithCloseButtonPrevented.
protected boolean isCloseWithCloseButtonPrevented(Window currentWindow) {
DesktopWindow desktopWindow = (DesktopWindow) ComponentsHelper.getWindowImplementation(currentWindow);
if (desktopWindow != null) {
Window.BeforeCloseWithCloseButtonEvent event = new Window.BeforeCloseWithCloseButtonEvent(desktopWindow);
desktopWindow.fireBeforeCloseWithCloseButton(event);
return event.isClosePrevented();
}
return false;
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WindowBreadCrumbs method update.
public void update() {
removeAll();
btn2win.clear();
for (Iterator<Window> it = windows.iterator(); it.hasNext(); ) {
Window window = it.next();
JButton button = new JXHyperlink();
button.setFocusable(false);
button.setText(StringUtils.trimToEmpty(window.getCaption()));
button.addActionListener(new ValidationAwareActionListener() {
@Override
public void actionPerformedAfterValidation(ActionEvent e) {
JButton btn = (JButton) e.getSource();
Window win = btn2win.get(btn);
if (win != null) {
fireListeners(win);
}
}
});
btn2win.put(button, window);
if (it.hasNext()) {
add(button);
JLabel separatorLab = new JLabel(">");
add(separatorLab);
} else {
add(new JLabel(window.getCaption()));
}
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class AddAction method actionPerform.
/**
* This method is invoked by action owner component. Don't override it, there are special methods to
* customize behaviour below.
* @param component component invoking action
*/
@Override
public void actionPerform(Component component) {
if (beforeActionPerformedHandler != null) {
if (!beforeActionPerformedHandler.beforeActionPerformed())
return;
}
Map<String, Object> params = prepareWindowParams();
Window.Lookup.Handler handler = getHandler();
Window.Lookup.Handler itemsHandler = handler != null ? handler : new DefaultHandler();
Window lookupWindow = target.getFrame().openLookup(getWindowId(), itemsHandler, getOpenType(), params);
lookupWindow.addCloseListener(actionId -> {
// move focus to owner
target.requestFocus();
});
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopTabSheet method initLazyTab.
protected void initLazyTab(JComponent tab) {
LazyTabInfo lti = null;
for (LazyTabInfo lazyTabInfo : lazyTabs) {
if (lazyTabInfo.getTabComponent() == tab) {
lti = lazyTabInfo;
break;
}
}
if (lti == null) {
// already initialized
return;
}
if (!lti.getTab().isEnabled()) {
return;
}
lazyTabs.remove(lti);
lti.loader.createComponent();
Component lazyContent = lti.loader.getResultComponent();
lazyContent.setWidth("100%");
lti.tabContent.add(lazyContent);
lti.tabContent.expand(lazyContent, "", "");
lazyContent.setParent(this);
lti.loader.loadComponent();
if (lazyContent instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
((DesktopAbstractComponent) lazyContent).setParentEnabled(false);
}
final Window window = ComponentsHelper.getWindow(DesktopTabSheet.this);
if (window != null) {
ComponentsHelper.walkComponents(lti.tabContent, (component, name) -> {
if (component instanceof HasSettings) {
Settings settings = window.getSettings();
if (settings != null) {
Element e = settings.get(name);
((HasSettings) component).applySettings(e);
}
}
});
lti.getTab().setLazyInitialized(true);
}
}
Aggregations