Search in sources :

Example 6 with Frame

use of com.haulmont.cuba.gui.components.Frame 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);
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) ScreenHistoryEntity(com.haulmont.cuba.security.entity.ScreenHistoryEntity) Entity(com.haulmont.cuba.core.entity.Entity) Frame(com.haulmont.cuba.gui.components.Frame) ScreenHistoryEntity(com.haulmont.cuba.security.entity.ScreenHistoryEntity) DataService(com.haulmont.cuba.core.app.DataService)

Example 7 with Frame

use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.

the class DesktopWindowManager method dispose.

/**
 * Release resources right before throwing away this WindowManager instance.
 */
public void dispose() {
    for (WindowOpenInfo openInfo : windowOpenMode.values()) {
        if (openInfo.getOpenMode() == OpenMode.DIALOG) {
            JDialog dialog = (JDialog) openInfo.getData();
            dialog.setVisible(false);
        }
    }
    if (isMainWindowManager) {
        // Stop background tasks
        WatchDog watchDog = AppBeans.get(WatchDog.NAME);
        watchDog.stopTasks();
    }
    // Dispose windows
    for (Window window : windowOpenMode.keySet()) {
        Frame frame = window.getFrame();
        if (frame instanceof Component.Disposable)
            ((Component.Disposable) frame).dispose();
    }
    tabs.clear();
    windowOpenMode.clear();
    stacks.clear();
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) Frame(com.haulmont.cuba.gui.components.Frame) DesktopAbstractComponent(com.haulmont.cuba.desktop.gui.components.DesktopAbstractComponent) Component(com.haulmont.cuba.gui.components.Component)

Example 8 with Frame

use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.

the class DesktopWindow method disableEventListeners.

protected void disableEventListeners() {
    Frame wrapper = delegate.getWrapper();
    if (wrapper != null) {
        List<ApplicationListener> uiEventListeners = ((AbstractFrame) wrapper).getUiEventListeners();
        if (uiEventListeners != null) {
            for (ApplicationListener listener : uiEventListeners) {
                UiEventsMulticaster multicaster = App.getInstance().getUiEventsMulticaster();
                multicaster.removeApplicationListener(listener);
            }
        }
    }
}
Also used : TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) Frame(com.haulmont.cuba.gui.components.Frame) ApplicationListener(org.springframework.context.ApplicationListener) UiEventsMulticaster(com.haulmont.cuba.gui.events.sys.UiEventsMulticaster)

Example 9 with Frame

use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.

the class DesktopWindow method enableEventListeners.

protected void enableEventListeners() {
    Frame wrapper = delegate.getWrapper();
    if (wrapper != null) {
        List<ApplicationListener> uiEventListeners = ((AbstractFrame) wrapper).getUiEventListeners();
        if (uiEventListeners != null) {
            for (ApplicationListener listener : uiEventListeners) {
                UiEventsMulticaster multicaster = App.getInstance().getUiEventsMulticaster();
                multicaster.addApplicationListener(listener);
            }
        }
    }
}
Also used : TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) Frame(com.haulmont.cuba.gui.components.Frame) ApplicationListener(org.springframework.context.ApplicationListener) UiEventsMulticaster(com.haulmont.cuba.gui.events.sys.UiEventsMulticaster)

Example 10 with Frame

use of com.haulmont.cuba.gui.components.Frame in project cuba by cuba-platform.

the class AbstractCollectionDatasource method getLoggingTag.

protected String getLoggingTag(String prefix) {
    String windowId = "";
    if (dsContext != null) {
        FrameContext windowContext = dsContext.getFrameContext();
        if (windowContext != null) {
            Frame frame = windowContext.getFrame();
            if (frame != null) {
                windowId = ComponentsHelper.getFullFrameId(windowContext.getFrame());
            }
        }
    }
    String tag = prefix + " " + id;
    if (StringUtils.isNotBlank(windowId))
        tag = windowId + "@" + id;
    return tag;
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame) FrameContext(com.haulmont.cuba.gui.FrameContext)

Aggregations

Frame (com.haulmont.cuba.gui.components.Frame)15 Component (com.haulmont.cuba.gui.components.Component)5 TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)3 Window (com.haulmont.cuba.gui.components.Window)3 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)2 UiEventsMulticaster (com.haulmont.cuba.gui.events.sys.UiEventsMulticaster)2 ApplicationListener (org.springframework.context.ApplicationListener)2 DataService (com.haulmont.cuba.core.app.DataService)1 Entity (com.haulmont.cuba.core.entity.Entity)1 DesktopAbstractComponent (com.haulmont.cuba.desktop.gui.components.DesktopAbstractComponent)1 DesktopWindow (com.haulmont.cuba.desktop.gui.components.DesktopWindow)1 FrameContext (com.haulmont.cuba.gui.FrameContext)1 AbstractFrame (com.haulmont.cuba.gui.components.AbstractFrame)1 FilterImplementation (com.haulmont.cuba.gui.components.FilterImplementation)1 WrappedFrame (com.haulmont.cuba.gui.components.WrappedFrame)1 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)1 BackgroundTaskTimeoutEvent (com.haulmont.cuba.gui.event.BackgroundTaskTimeoutEvent)1 ScreenHistoryEntity (com.haulmont.cuba.security.entity.ScreenHistoryEntity)1 Method (java.lang.reflect.Method)1 MethodUtils.getAccessibleMethod (org.apache.commons.lang.reflect.MethodUtils.getAccessibleMethod)1