Search in sources :

Example 6 with RemoveAction

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

the class EntityCombinedScreen method initBrowseRemoveAction.

/**
 * Adds AfterRemoveHandler for table's Remove action to reset the record contained in editDs.
 */
@SuppressWarnings("unchecked")
protected void initBrowseRemoveAction() {
    ListComponent table = getTable();
    Datasource editDs = getFieldGroup().getDatasource();
    RemoveAction removeAction = (RemoveAction) table.getAction(RemoveAction.ACTION_ID);
    if (removeAction != null)
        removeAction.setAfterRemoveHandler(removedItems -> editDs.setItem(null));
}
Also used : Datasource(com.haulmont.cuba.gui.data.Datasource) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) java.util(java.util) Datasource(com.haulmont.cuba.gui.data.Datasource) LockService(com.haulmont.cuba.core.app.LockService) EditAction(com.haulmont.cuba.gui.components.actions.EditAction) MetaClass(com.haulmont.chile.core.model.MetaClass) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) com.haulmont.cuba.core.global(com.haulmont.cuba.core.global) CreateAction(com.haulmont.cuba.gui.components.actions.CreateAction) EntityOp(com.haulmont.cuba.security.entity.EntityOp) ComponentsHelper(com.haulmont.cuba.gui.ComponentsHelper) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) Nullable(javax.annotation.Nullable) Entity(com.haulmont.cuba.core.entity.Entity) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction)

Example 7 with RemoveAction

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

the class CategoryBrowser method init.

@Override
public void init(Map<String, Object> params) {
    categoryTable.addAction(new CreateAction());
    categoryTable.addAction(new EditAction());
    categoryTable.addAction(new RemoveAction(categoryTable));
    categoryTable.addAction(new BaseAction("applyChanges").withCaption(getMessage("categoryTable.applyChanges")).withHandler(actionPerformedEvent -> {
        dynamicAttributesCacheService.loadCache();
        clientCacheManager.refreshCached(DynamicAttributesCacheStrategy.NAME);
        permissionConfig.clearConfigCache();
        showNotification(getMessage("notification.changesApplied"));
    }));
    categoryTable.removeGeneratedColumn("entityType");
    categoryTable.addGeneratedColumn("entityType", entity -> {
        Label dataTypeLabel = componentsFactory.createComponent(Label.class);
        MetaClass meta = metadata.getSession().getClassNN(entity.getEntityType());
        dataTypeLabel.setValue(messageTools.getEntityCaption(meta));
        return dataTypeLabel;
    });
}
Also used : DynamicAttributesCacheStrategy(com.haulmont.cuba.client.sys.cache.DynamicAttributesCacheStrategy) Category(com.haulmont.cuba.core.entity.Category) Set(java.util.Set) MetaClass(com.haulmont.chile.core.model.MetaClass) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) Metadata(com.haulmont.cuba.core.global.Metadata) Inject(javax.inject.Inject) ComponentsFactory(com.haulmont.cuba.gui.xml.layout.ComponentsFactory) PermissionConfig(com.haulmont.cuba.gui.config.PermissionConfig) Map(java.util.Map) ClientCacheManager(com.haulmont.cuba.client.sys.cache.ClientCacheManager) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) DynamicAttributesCacheService(com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesCacheService) MessageTools(com.haulmont.cuba.core.global.MessageTools) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) MetaClass(com.haulmont.chile.core.model.MetaClass) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction)

Example 8 with RemoveAction

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

the class EntityInspectorEditor method createButtonsPanel.

/**
 * Creates a buttons panel managing table's content.
 *
 * @param metaProperty property representing table's data
 * @param propertyDs   property's Datasource (CollectionPropertyDatasource usually)
 * @param table        table
 * @return buttons panel
 */
@SuppressWarnings("unchecked")
protected ButtonsPanel createButtonsPanel(final MetaProperty metaProperty, final CollectionDatasource propertyDs, Table table) {
    MetaClass propertyMetaClass = metaProperty.getRange().asClass();
    ButtonsPanel propertyButtonsPanel = componentsFactory.createComponent(ButtonsPanel.class);
    Button createButton = componentsFactory.createComponent(Button.class);
    CreateAction createAction = new CreateAction(metaProperty, propertyDs, propertyMetaClass);
    createButton.setAction(createAction);
    table.addAction(createAction);
    createButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "create"));
    createButton.setIcon("icons/create.png");
    Button addButton = componentsFactory.createComponent(Button.class);
    AddAction addAction = createAddAction(metaProperty, propertyDs, table, propertyMetaClass);
    table.addAction(addAction);
    addButton.setAction(addAction);
    addButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "add"));
    addButton.setIcon("icons/add.png");
    Button editButton = componentsFactory.createComponent(Button.class);
    EditAction editAction = new EditAction(metaProperty, table, propertyDs);
    editButton.setAction(editAction);
    editButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "edit"));
    editButton.setIcon("icons/edit.png");
    table.addAction(editAction);
    table.setItemClickAction(editAction);
    table.setEnterPressAction(editAction);
    RemoveAction removeAction = createRemoveAction(metaProperty, table);
    Button removeButton = componentsFactory.createComponent(Button.class);
    removeButton.setAction(removeAction);
    table.addAction(removeAction);
    removeButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "remove"));
    removeButton.setIcon("icons/remove.png");
    propertyButtonsPanel.add(createButton);
    propertyButtonsPanel.add(addButton);
    propertyButtonsPanel.add(editButton);
    propertyButtonsPanel.add(removeButton);
    return propertyButtonsPanel;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) AddAction(com.haulmont.cuba.gui.components.actions.AddAction)

Example 9 with RemoveAction

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

the class ScheduledTaskBrowser method init.

@Override
public void init(Map<String, Object> params) {
    ComponentsHelper.createActions(tasksTable);
    final Action editAction = tasksTable.getActionNN(EditAction.ACTION_ID);
    editAction.setEnabled(false);
    final Action removeAction = tasksTable.getActionNN(RemoveAction.ACTION_ID);
    removeAction.setEnabled(false);
    activateBtn.setAction(new AbstractAction("activate") {

        @Override
        public void actionPerform(Component component) {
            Set<ScheduledTask> tasks = tasksTable.getSelected();
            service.setActive(tasks, !BooleanUtils.isTrue(tasks.iterator().next().getActive()));
            tasksDs.refresh();
        }
    });
    activateBtn.setEnabled(false);
    final ShowExecutionsAction showExecutionsAction = new ShowExecutionsAction();
    showExecutionsAction.setEnabled(false);
    tasksTable.addAction(showExecutionsAction);
    tasksDs.addItemChangeListener(e -> {
        ScheduledTask singleSelected = tasksTable.getSingleSelected();
        Set<ScheduledTask> selected = tasksTable.getSelected();
        boolean isSingleSelected = selected.size() == 1;
        boolean enableEdit = isSingleSelected && !BooleanUtils.isTrue(singleSelected.getActive());
        editAction.setEnabled(enableEdit);
        removeAction.setEnabled(checkAllTasksIsNotActive(selected));
        activateBtn.setEnabled(checkAllTasksHaveSameStatus(selected));
        if (singleSelected == null) {
            activateBtn.setCaption(getMessage("activate"));
        } else {
            activateBtn.setCaption(BooleanUtils.isTrue(singleSelected.getActive()) ? getMessage("deactivate") : getMessage("activate"));
        }
        showExecutionsAction.setEnabled(isSingleSelected);
    });
}
Also used : EditAction(com.haulmont.cuba.gui.components.actions.EditAction) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) ScheduledTask(com.haulmont.cuba.core.entity.ScheduledTask)

Example 10 with RemoveAction

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

the class AttributeEditor method init.

@Override
public void init(Map<String, Object> params) {
    getDialogOptions().setWidth(themeConstants.get("cuba.gui.AttributeEditor.width"));
    fieldWidth = themeConstants.get("cuba.gui.AttributeEditor.field.width");
    initLocalizedFrame();
    initFieldGroup();
    targetScreensTable.addAction(new AbstractAction("create") {

        @Override
        public void actionPerform(Component component) {
            screensDs.addItem(new ScreenAndComponent());
        }
    });
    targetScreensTable.addAction(new RemoveAction(targetScreensTable));
}
Also used : RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction)

Aggregations

RemoveAction (com.haulmont.cuba.gui.components.actions.RemoveAction)13 MetaClass (com.haulmont.chile.core.model.MetaClass)4 EditAction (com.haulmont.cuba.gui.components.actions.EditAction)3 ItemTrackingAction (com.haulmont.cuba.gui.components.actions.ItemTrackingAction)3 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)3 Entity (com.haulmont.cuba.core.entity.Entity)2 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)2 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)2 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)2 CreateAction (com.haulmont.cuba.gui.components.actions.CreateAction)2 FileUploadingAPI (com.haulmont.cuba.gui.upload.FileUploadingAPI)2 ComponentsFactory (com.haulmont.cuba.gui.xml.layout.ComponentsFactory)2 File (java.io.File)2 java.util (java.util)2 Files (com.google.common.io.Files)1 ParamsMap (com.haulmont.bali.util.ParamsMap)1 ClientCacheManager (com.haulmont.cuba.client.sys.cache.ClientCacheManager)1 DynamicAttributesCacheStrategy (com.haulmont.cuba.client.sys.cache.DynamicAttributesCacheStrategy)1 ConstraintLocalizationService (com.haulmont.cuba.core.app.ConstraintLocalizationService)1 LockService (com.haulmont.cuba.core.app.LockService)1