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));
}
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;
});
}
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;
}
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);
});
}
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));
}
Aggregations