Меняю свойства кнопок, после этого редактирование работает, а удаление уже нет, хотя диалог подтверждения удаления всплывает.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
caption="msg://browseCaption"
class="com.company.magazin.gui.workperiods.WorkPeriodsBrowse"
focusComponent="workPeriodsesTable"
lookupComponent="workPeriodsesTable"
messagesPack="com.company.magazin.gui.workperiods">
<dsContext>
<collectionDatasource id="workPeriodsesDs"
class="com.company.magazin.entity.WorkPeriods"
view="_local">
<query>
<![CDATA[select e from magazin$WorkPeriods e order by e.start_period_date desc]]>
</query>
</collectionDatasource>
<collectionDatasource id="lastWorkPeriodDs"
class="com.company.magazin.entity.WorkPeriods"
maxResults="1"
view="_minimal">
<query>
<![CDATA[select e from magazin$WorkPeriods e order by e.start_period_date desc]]>
</query>
</collectionDatasource>
</dsContext>
<layout expand="workPeriodsesTable"
spacing="true">
<filter id="filter"
datasource="workPeriodsesDs">
<properties include=".*"/>
</filter>
<table id="workPeriodsesTable"
width="100%">
<actions>
<action id="refresh"/>
<action id="create"
openType="DIALOG"/>
<action id="edit"
openType="DIALOG"/>
<action id="remove"/>
</actions>
<columns>
<column id="name"/>
<column id="start_period_date"/>
<column id="end_period_date"/>
<column id="counter_day"/>
<column id="parent_clouser"/>
<column id="number_period"/>
</columns>
<rows datasource="workPeriodsesDs"/>
<rowsCount/>
<buttonsPanel id="buttonsPanel"
alwaysVisible="true">
<button id="refreshBtn"
action="workPeriodsesTable.refresh"/>
<button id="createBtn"
action="workPeriodsesTable.create"/>
<button id="editBtn"
action="workPeriodsesTable.edit"
enable="false"/>
<button id="removeBtn"
action="workPeriodsesTable.remove"
enable="false"/>
</buttonsPanel>
</table>
</layout>
</window>
@Override
public void init(Map<String, Object> params) {
workPeriodsesDs.addListener(new CollectionDsListenerAdapter<WorkPeriods>(){
@Override
public void collectionChanged(CollectionDatasource ds, Operation operation, List<WorkPeriods> items) {
workPeriodsesTable.refresh();
}
@Override
public void itemChanged(Datasource<WorkPeriods> ds, @Nullable WorkPeriods prevItem, @Nullable WorkPeriods item) {
lastWorkPeriodDs.refresh();
List<UUID> arrayId = new ArrayList<>();
for (WorkPeriods list : lastWorkPeriodDs.getItems()) {
arrayId.add(list.getId());
}
if (!arrayId.isEmpty()) {
UUID s1 = arrayId.get(0);
WorkPeriods workPeriods = workPeriodsesTable.getSingleSelected();
if (workPeriods != null){
UUID s2 = workPeriods.getId();
if (s1.equals(s2)) {
editBtn.setEnabled(true);
removeBtn.setEnabled(true);
}
else {
editBtn.setEnabled(false);
removeBtn.setEnabled(false);
}
}
}
}
});
}

