Search in sources :

Example 11 with Frame

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

the class DsContextImpl method get.

@Override
public Datasource get(String id) {
    Preconditions.checkNotNullArgument(id, "Null datasource ID");
    Datasource ds = null;
    if (!id.contains(".")) {
        ds = datasourceMap.get(id);
        if (ds == null && parent != null) {
            ds = parent.get(id);
        }
    } else {
        if (windowContext != null) {
            String nestedFramePath = id.substring(0, id.indexOf("."));
            Component nestedFrame = getFrameContext().getFrame().getComponent(nestedFramePath);
            if ((nestedFrame) != null && (nestedFrame instanceof Frame)) {
                String nestedDsId = id.substring(id.indexOf(".") + 1);
                ds = ((Frame) nestedFrame).getDsContext().get(nestedDsId);
            }
        }
    }
    return ds;
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame) Component(com.haulmont.cuba.gui.components.Component)

Example 12 with Frame

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

the class TaskHandlerImpl method kill.

/**
 * Cancel without events for tasks
 */
public final void kill() {
    uiAccessor.access(() -> {
        Frame ownerFrame = getTask().getOwnerFrame();
        detachCloseListener();
        if (log.isTraceEnabled()) {
            if (ownerFrame != null) {
                String windowClass = ownerFrame.getClass().getCanonicalName();
                log.trace("Task killed. Task: {}. User: {}. Frame: {}", taskExecutor.getTask(), getUserSession().getId(), windowClass);
            } else {
                log.trace("Task killed. Task: {}. User: {}", taskExecutor.getTask(), getUserSession().getId());
            }
        }
        taskExecutor.cancelExecution();
    });
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame)

Example 13 with Frame

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

the class TaskHandlerImpl method detachCloseListener.

private void detachCloseListener() {
    // force remove close listener
    Frame ownerFrame = getTask().getOwnerFrame();
    if (ownerFrame != null) {
        Window ownerWindow = ComponentsHelper.getWindowImplementation(ownerFrame);
        if (ownerWindow != null) {
            ownerWindow.removeCloseListener(closeListener);
            String windowClass = ownerFrame.getClass().getCanonicalName();
            log.trace("Resources were disposed. Task: {}. Frame: {}", taskExecutor.getTask(), windowClass);
        } else {
            log.trace("Empty ownerWindow. Resources were not disposed. Task: {}", taskExecutor.getTask());
        }
    } else {
        log.trace("Empty ownerFrame. Resources were not disposed. Task: {}", taskExecutor.getTask());
    }
    closeListener = null;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) Frame(com.haulmont.cuba.gui.components.Frame)

Example 14 with Frame

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

the class DeclarativeColumnGenerator method generateCell.

@Override
public Component generateCell(Entity entity) {
    if (unableToFindMethod) {
        return null;
    }
    Frame frame = table.getFrame();
    if (frame == null) {
        throw new IllegalStateException("Table should be attached to frame");
    }
    Frame controller = ComponentsHelper.getFrameController(frame);
    if (method == null) {
        method = findGeneratorMethod(controller.getClass(), methodName);
        if (method == null) {
            this.unableToFindMethod = true;
            String tableId = table.getId() == null ? "" : table.getId();
            throw new IllegalStateException(String.format("No suitable method named %s for column generator of table %s", methodName, tableId));
        }
    }
    try {
        return (Component) method.invoke(controller, entity);
    } catch (Exception e) {
        throw new RuntimeException("Exception in declarative Table column generator " + methodName, e);
    }
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame) Component(com.haulmont.cuba.gui.components.Component)

Example 15 with Frame

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

the class FilterLoader method loadComponent.

@Override
public void loadComponent() {
    assignXmlDescriptor(resultComponent, element);
    assignFrame(resultComponent);
    loadAlign(resultComponent, element);
    loadVisible(resultComponent, element);
    loadEnable(resultComponent, element);
    loadStyleName(resultComponent, element);
    loadMargin(resultComponent, element);
    loadIcon(resultComponent, element);
    loadCaption(resultComponent, element);
    loadDescription(resultComponent, element);
    loadWidth(resultComponent, element, "100%");
    loadCollapsible(resultComponent, element, true);
    loadSettingsEnabled(resultComponent, element);
    loadBorderVisible(resultComponent, element);
    String useMaxResults = element.attributeValue("useMaxResults");
    resultComponent.setUseMaxResults(useMaxResults == null || Boolean.parseBoolean(useMaxResults));
    String textMaxResults = element.attributeValue("textMaxResults");
    resultComponent.setTextMaxResults(Boolean.parseBoolean(textMaxResults));
    final String manualApplyRequired = element.attributeValue("manualApplyRequired");
    resultComponent.setManualApplyRequired(BooleanUtils.toBooleanObject(manualApplyRequired));
    String editable = element.attributeValue("editable");
    resultComponent.setEditable(editable == null || Boolean.parseBoolean(editable));
    String columnsCount = element.attributeValue("columnsCount");
    if (!Strings.isNullOrEmpty(columnsCount)) {
        resultComponent.setColumnsCount(Integer.parseInt(columnsCount));
    }
    String folderActionsEnabled = element.attributeValue("folderActionsEnabled");
    if (folderActionsEnabled != null) {
        resultComponent.setFolderActionsEnabled(Boolean.parseBoolean(folderActionsEnabled));
    }
    String datasource = element.attributeValue("datasource");
    if (!StringUtils.isBlank(datasource)) {
        CollectionDatasource ds = (CollectionDatasource) context.getDsContext().get(datasource);
        if (ds == null) {
            throw new GuiDevelopmentException("Can't find datasource by name: " + datasource, context.getCurrentFrameId());
        }
        resultComponent.setDatasource(ds);
    }
    Frame frame = context.getFrame();
    String applyTo = element.attributeValue("applyTo");
    if (!StringUtils.isEmpty(applyTo)) {
        context.addPostInitTask((context1, window) -> {
            Component c = frame.getComponent(applyTo);
            if (c == null) {
                throw new GuiDevelopmentException("Can't apply component to component with ID: " + applyTo, context1.getFullFrameId());
            }
            resultComponent.setApplyTo(c);
        });
    }
    String modeSwitchVisible = element.attributeValue("modeSwitchVisible");
    resultComponent.setModeSwitchVisible(modeSwitchVisible == null || Boolean.parseBoolean(modeSwitchVisible));
    context.addPostInitTask((context1, window) -> {
        ((FilterImplementation) resultComponent).loadFiltersAndApplyDefault();
        String defaultMode = element.attributeValue("defaultMode");
        if (defaultMode != null && "fts".equals(defaultMode)) {
            resultComponent.switchFilterMode(FilterDelegate.FilterMode.FTS_MODE);
        }
    });
}
Also used : Frame(com.haulmont.cuba.gui.components.Frame) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException) Component(com.haulmont.cuba.gui.components.Component) FilterImplementation(com.haulmont.cuba.gui.components.FilterImplementation)

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