Search in sources :

Example 21 with Window

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

the class WindowBreadCrumbs method update.

public void update() {
    AppUI ui = AppUI.getCurrent();
    boolean isTestMode = ui.isTestMode();
    linksLayout.removeAllComponents();
    btn2win.clear();
    for (Iterator<Window> it = windows.iterator(); it.hasNext(); ) {
        Window window = it.next();
        Button button = new CubaButton(StringUtils.trimToEmpty(window.getCaption()), new BtnClickListener());
        button.setSizeUndefined();
        button.setStyleName(BaseTheme.BUTTON_LINK);
        button.setTabIndex(-1);
        if (isTestMode) {
            button.setCubaId("breadCrubms_Button_" + window.getId());
            button.setId(ui.getTestIdManager().getTestId("breadCrubms_Button_" + window.getId()));
        }
        btn2win.put(button, window);
        if (it.hasNext()) {
            linksLayout.addComponent(button);
            Label separatorLab = new Label("&nbsp;&gt;&nbsp;");
            separatorLab.setStyleName("c-breadcrumbs-separator");
            separatorLab.setSizeUndefined();
            separatorLab.setContentMode(ContentMode.HTML);
            linksLayout.addComponent(separatorLab);
        } else {
            Label captionLabel = new Label(window.getCaption());
            captionLabel.setStyleName("c-breadcrumbs-win-caption");
            captionLabel.setSizeUndefined();
            linksLayout.addComponent(captionLabel);
            this.label = captionLabel;
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) Button(com.vaadin.ui.Button) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) Label(com.vaadin.ui.Label) AppUI(com.haulmont.cuba.web.AppUI)

Example 22 with Window

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

the class WebAbstractTable method createColumns.

protected Collection<MetaPropertyPath> createColumns(com.vaadin.data.Container ds) {
    @SuppressWarnings("unchecked") final Collection<MetaPropertyPath> properties = (Collection<MetaPropertyPath>) ds.getContainerPropertyIds();
    Window window = ComponentsHelper.getWindowImplementation(this);
    boolean isLookup = window instanceof Window.Lookup;
    for (MetaPropertyPath propertyPath : properties) {
        final Table.Column column = columns.get(propertyPath);
        if (column != null && !(editable && BooleanUtils.isTrue(column.isEditable()))) {
            final String isLink = column.getXmlDescriptor() == null ? null : column.getXmlDescriptor().attributeValue("link");
            if (propertyPath.getRange().isClass()) {
                if (!isLookup && StringUtils.isNotEmpty(isLink)) {
                    setClickListener(propertyPath.toString(), new LinkCellClickListener());
                }
            } else if (propertyPath.getRange().isDatatype()) {
                if (!isLookup && !StringUtils.isEmpty(isLink)) {
                    setClickListener(propertyPath.toString(), new LinkCellClickListener());
                } else if (editable && BooleanUtils.isTrue(column.isCalculatable())) {
                    addGeneratedColumn(propertyPath, new CalculatableColumnGenerator());
                } else {
                    if (column.getMaxTextLength() != null) {
                        addGeneratedColumn(propertyPath, new AbbreviatedColumnGenerator(column));
                        setClickListener(propertyPath.toString(), new AbbreviatedCellClickListener());
                    }
                }
            } else if (!propertyPath.getRange().isEnum()) {
                throw new UnsupportedOperationException();
            }
        }
    }
    return properties;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) Table(com.haulmont.cuba.gui.components.Table) CubaEnhancedTable(com.haulmont.cuba.web.toolkit.ui.CubaEnhancedTable) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Example 23 with Window

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

the class WebAbstractTable method handleClickAction.

protected void handleClickAction() {
    Action action = getItemClickAction();
    if (action == null) {
        action = getEnterAction();
        if (action == null) {
            action = getAction("edit");
            if (action == null) {
                action = getAction("view");
            }
        }
    }
    if (action != null && action.isEnabled()) {
        Window window = ComponentsHelper.getWindowImplementation(WebAbstractTable.this);
        if (window instanceof Window.Wrapper) {
            window = ((Window.Wrapper) window).getWrappedWindow();
        }
        if (!(window instanceof Window.Lookup)) {
            action.actionPerform(WebAbstractTable.this);
        } else {
            Window.Lookup lookup = (Window.Lookup) window;
            com.haulmont.cuba.gui.components.Component lookupComponent = lookup.getLookupComponent();
            if (lookupComponent != this)
                action.actionPerform(WebAbstractTable.this);
            else if (action.getId().equals(WindowDelegate.LOOKUP_ITEM_CLICK_ACTION_ID)) {
                action.actionPerform(WebAbstractTable.this);
            }
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) CollectionDsListenersWrapper(com.haulmont.cuba.gui.data.impl.CollectionDsListenersWrapper) ItemWrapper(com.haulmont.cuba.web.gui.data.ItemWrapper) CubaResizableTextAreaWrapper(com.haulmont.cuba.web.toolkit.ui.CubaResizableTextAreaWrapper) CollectionDsWrapper(com.haulmont.cuba.web.gui.data.CollectionDsWrapper) PropertyWrapper(com.haulmont.cuba.web.gui.data.PropertyWrapper) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components)

Example 24 with Window

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

the class FileBrowser method init.

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    filesTable.addAction(new ItemTrackingAction("download").withCaption(getMessage("download")).withHandler(event -> {
        FileDescriptor fileDescriptor = filesTable.getSingleSelected();
        if (fileDescriptor != null) {
            exportDisplay.show(fileDescriptor, null);
        }
    }));
    BaseAction multiUploadAction = new BaseAction("multiupload").withCaption(getMessage("multiupload")).withHandler(event -> {
        if (!security.isEntityOpPermitted(FileDescriptor.class, EntityOp.READ)) {
            throw new AccessDeniedException(PermissionType.ENTITY_OP, FileDescriptor.class.getSimpleName());
        }
        Window window = openWindow("multiuploadDialog", OpenType.DIALOG);
        window.addCloseListener(actionId -> {
            if (COMMIT_ACTION_ID.equals(actionId)) {
                Collection<FileDescriptor> items = ((MultiUploader) window).getFiles();
                for (FileDescriptor fdesc : items) {
                    boolean modified = filesDs.isModified();
                    filesDs.addItem(fdesc);
                    ((DatasourceImplementation) filesDs).setModified(modified);
                }
                filesTable.requestFocus();
            }
        });
    });
    multiUploadAction.setEnabled(security.isEntityOpPermitted(FileDescriptor.class, EntityOp.CREATE));
    multiUploadBtn.setAction(multiUploadAction);
}
Also used : Security(com.haulmont.cuba.core.global.Security) Table(com.haulmont.cuba.gui.components.Table) Collection(java.util.Collection) Button(com.haulmont.cuba.gui.components.Button) ExportDisplay(com.haulmont.cuba.gui.export.ExportDisplay) PermissionType(com.haulmont.cuba.security.entity.PermissionType) UUID(java.util.UUID) FileDescriptor(com.haulmont.cuba.core.entity.FileDescriptor) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation) Inject(javax.inject.Inject) AbstractLookup(com.haulmont.cuba.gui.components.AbstractLookup) EntityOp(com.haulmont.cuba.security.entity.EntityOp) Window(com.haulmont.cuba.gui.components.Window) Map(java.util.Map) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) AccessDeniedException(com.haulmont.cuba.core.global.AccessDeniedException) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) Window(com.haulmont.cuba.gui.components.Window) AccessDeniedException(com.haulmont.cuba.core.global.AccessDeniedException) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation) FileDescriptor(com.haulmont.cuba.core.entity.FileDescriptor)

Example 25 with Window

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

the class DesktopAbstractTable method handleClickAction.

protected void handleClickAction() {
    Action action = getItemClickAction();
    if (action == null) {
        action = getEnterAction();
        if (action == null) {
            action = getAction("edit");
            if (action == null) {
                action = getAction("view");
            }
        }
    }
    if (action != null && action.isEnabled() && action.isVisible()) {
        Window window = ComponentsHelper.getWindow(DesktopAbstractTable.this);
        if (window instanceof Window.Wrapper) {
            window = ((Window.Wrapper) window).getWrappedWindow();
        }
        if (!(window instanceof Window.Lookup)) {
            action.actionPerform(DesktopAbstractTable.this);
        } else {
            Window.Lookup lookup = (Window.Lookup) window;
            com.haulmont.cuba.gui.components.Component lookupComponent = lookup.getLookupComponent();
            if (lookupComponent != this) {
                action.actionPerform(DesktopAbstractTable.this);
            } else if (action.getId().equals(WindowDelegate.LOOKUP_ITEM_CLICK_ACTION_ID)) {
                action.actionPerform(DesktopAbstractTable.this);
            }
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) AbstractAction(javax.swing.AbstractAction) BoundAction(org.jdesktop.swingx.action.BoundAction) Action(com.haulmont.cuba.gui.components.Action) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components)

Aggregations

Window (com.haulmont.cuba.gui.components.Window)54 DesktopWindow (com.haulmont.cuba.desktop.gui.components.DesktopWindow)15 WebWindow (com.haulmont.cuba.web.gui.WebWindow)13 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)10 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)6 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)6 ParamsMap (com.haulmont.bali.util.ParamsMap)5 Component (com.haulmont.cuba.gui.components.Component)5 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)5 Component (com.vaadin.ui.Component)5 Entity (com.haulmont.cuba.core.entity.Entity)4 TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)4 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)4 CssLayout (com.vaadin.ui.CssLayout)4 Pair (com.haulmont.bali.datastruct.Pair)3 WindowManager (com.haulmont.cuba.gui.WindowManager)3 Action (com.haulmont.cuba.gui.components.Action)3 ButtonsPanel (com.haulmont.cuba.gui.components.ButtonsPanel)3 Frame (com.haulmont.cuba.gui.components.Frame)3 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)3