Search in sources :

Example 1 with Frame

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

the class TaskHandlerImpl method cancel.

@Override
public final boolean cancel() {
    checkState(started, "Task is not running. Task: " + taskExecutor.getTask().toString());
    boolean canceled = taskExecutor.cancelExecution();
    if (canceled) {
        detachCloseListener();
        BackgroundTask<T, V> task = taskExecutor.getTask();
        task.canceled();
        // Notify listeners
        for (BackgroundTask.ProgressListener listener : task.getProgressListeners()) {
            listener.onCancel();
        }
        if (log.isTraceEnabled()) {
            Frame ownerFrame = getTask().getOwnerFrame();
            if (ownerFrame != null) {
                String windowClass = ownerFrame.getClass().getCanonicalName();
                log.trace("Task was cancelled. Task: {}. User: {}. Frame: {}", taskExecutor.getTask(), getUserSession().getId(), windowClass);
            } else {
                log.trace("Task was cancelled. Task: {}. User: {}", taskExecutor.getTask(), getUserSession().getId());
            }
        }
    } else {
        log.trace("Task wasn't cancelled. Execution is already cancelled. Task: {}", taskExecutor.getTask());
    }
    return canceled;
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame)

Example 2 with Frame

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

the class TaskHandlerImpl method ownerWindowClosed.

private void ownerWindowClosed() {
    if (log.isTraceEnabled()) {
        Frame ownerFrame = getTask().getOwnerFrame();
        String windowClass = ownerFrame.getClass().getCanonicalName();
        log.trace("Window closed. User: {}. Window: {}", getUserSession().getId(), windowClass);
    }
    taskExecutor.cancelExecution();
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame)

Example 3 with Frame

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

the class TaskHandlerImpl method timeoutExceeded.

/**
 * Cancel with timeout exceeded event
 */
public final void timeoutExceeded() {
    uiAccessor.access(() -> {
        Frame ownerFrame = getTask().getOwnerFrame();
        if (log.isTraceEnabled()) {
            if (ownerFrame != null) {
                String windowClass = ownerFrame.getClass().getCanonicalName();
                log.trace("Task timeout exceeded. Task: {}. Frame: {}", taskExecutor.getTask(), windowClass);
            } else {
                log.trace("Task timeout exceeded. Task: {}", taskExecutor.getTask());
            }
        }
        checkState(started, "Task is not running");
        boolean canceled = taskExecutor.cancelExecution();
        if (canceled || timeoutHappens) {
            detachCloseListener();
            BackgroundTask<T, V> task = taskExecutor.getTask();
            boolean handled = task.handleTimeoutException();
            if (!handled) {
                log.error("Unhandled timeout exception in background task. Task: " + task.toString());
                events.publish(new BackgroundTaskTimeoutEvent(this, task));
            }
        }
        if (log.isTraceEnabled()) {
            if (ownerFrame != null) {
                String windowClass = ownerFrame.getClass().getCanonicalName();
                log.trace("Timeout was processed. Task: {}. Frame: {}", taskExecutor.getTask(), windowClass);
            } else {
                log.trace("Timeout was processed. Task: {}", taskExecutor.getTask());
            }
        }
    });
}
Also used : BackgroundTaskTimeoutEvent(com.haulmont.cuba.gui.event.BackgroundTaskTimeoutEvent) Frame(com.haulmont.cuba.gui.components.Frame)

Example 4 with Frame

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

the class DeclarativeFieldGenerator method generateField.

@Override
public Component generateField(Datasource datasource, String propertyId) {
    Frame frame = fieldGroup.getFrame();
    if (frame == null) {
        throw new IllegalStateException("Table should be attached to frame");
    }
    Frame controller = ComponentsHelper.getFrameController(frame);
    Class<? extends Frame> cCls = controller.getClass();
    Method exactMethod = getAccessibleMethod(cCls, methodName, new Class[] { Datasource.class, String.class });
    if (exactMethod != null) {
        checkGeneratorMethodResultType(exactMethod, frame);
        try {
            return (Component) exactMethod.invoke(controller, datasource, propertyId);
        } catch (Exception e) {
            throw new RuntimeException("Exception in declarative FieldGroup Field generator " + methodName, e);
        }
    }
    Method dsMethod = getAccessibleMethod(cCls, methodName, new Class[] { Datasource.class });
    if (dsMethod != null) {
        checkGeneratorMethodResultType(dsMethod, frame);
        try {
            return (Component) dsMethod.invoke(controller, datasource);
        } catch (Exception e) {
            throw new RuntimeException("Exception in declarative FieldGroup Field generator " + methodName, e);
        }
    }
    Method parameterLessMethod = getAccessibleMethod(cCls, methodName, new Class[] {});
    if (parameterLessMethod != null) {
        checkGeneratorMethodResultType(parameterLessMethod, frame);
        try {
            return (Component) parameterLessMethod.invoke(controller);
        } catch (Exception e) {
            throw new RuntimeException("Exception in declarative FieldGroup Field generator " + methodName, e);
        }
    }
    String fieldGroupId = fieldGroup.getId() == null ? "" : fieldGroup.getId();
    throw new IllegalStateException(String.format("No suitable method named %s for column generator of table %s", methodName, fieldGroupId));
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame) MethodUtils.getAccessibleMethod(org.apache.commons.lang.reflect.MethodUtils.getAccessibleMethod) Method(java.lang.reflect.Method) Component(com.haulmont.cuba.gui.components.Component) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 5 with Frame

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

the class FrameLoader method createComponent.

@Override
public void createComponent() {
    // noinspection unchecked
    Frame clientSpecificFrame = (T) factory.createComponent(Frame.NAME);
    clientSpecificFrame.setId(frameId);
    loadMessagesPack(clientSpecificFrame, element);
    ComponentLoaderContext parentContext = (ComponentLoaderContext) getContext();
    String frameId = parentContext.getCurrentFrameId();
    if (parentContext.getFullFrameId() != null) {
        frameId = parentContext.getFullFrameId() + "." + frameId;
    }
    innerContext = new ComponentLoaderContext(context.getParams());
    innerContext.setCurrentFrameId(parentContext.getCurrentFrameId());
    innerContext.setFullFrameId(frameId);
    innerContext.setFrame(clientSpecificFrame);
    innerContext.setParent(parentContext);
    setContext(innerContext);
    layoutElement = element.element("layout");
    if (layoutElement == null) {
        throw new GuiDevelopmentException("Required element 'layout' is not found", this.context.getFullFrameId());
    }
    createSubComponents(clientSpecificFrame, layoutElement);
    setContext(parentContext);
    // noinspection unchecked
    resultComponent = (T) wrapByCustomClass(clientSpecificFrame);
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame) WrappedFrame(com.haulmont.cuba.gui.components.WrappedFrame) AbstractFrame(com.haulmont.cuba.gui.components.AbstractFrame)

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