Здравствуйте Роман!
Прикладываю полную разметку:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd" caption="msg://browseCaption"
class="ru.npc_springs.techbase.web.typedprocesscard.TypedProcessCardBrowse"
focusComponent="typedProcessCardsTable" lookupComponent="typedProcessCardsTable"
messagesPack="ru.npc_springs.techbase.web.typedprocesscard">
<dsContext>
<hierarchicalDatasource id="typedProcessCardsDs"
class="ru.npc_springs.techbase.entity.techcard.processcard.typed.TypedProcessCard"
hierarchyProperty="parentCard" view="typedProcessCard-view">
<query><![CDATA[select e from techbase$TypedProcessCard e]]></query>
</hierarchicalDatasource>
</dsContext>
<dialogMode height="600" width="800"/>
<layout expand="typedProcessCardsTable" spacing="true">
<filter id="filter" applyTo="typedProcessCardsTable" datasource="typedProcessCardsDs">
<properties include=".*"/>
</filter>
<treeTable id="typedProcessCardsTable" width="100%">
<actions>
<action id="edit"/>
<action id="remove"/>
</actions>
<columns>
<column id="number"/>
<column id="revisionNumber" caption="msg://revisionNumber"/>
<column id="operation"/>
<column id="machine"/>
<column id="employee"/>
<column id="date"/>
</columns>
<rows datasource="typedProcessCardsDs"/>
<buttonsPanel id="buttonsPanel" alwaysVisible="true">
<popupButton id="createBtn" caption="msg://create"/>
<button id="editBtn" action="typedProcessCardsTable.edit"/>
<button id="removeBtn" action="typedProcessCardsTable.remove"/>
</buttonsPanel>
</treeTable>
</layout>
</window>
Как Вы и сказали, после удаления и повторного открытия экрана, поля closePopupOnOutsideClick="false" и togglePopupVisibilityOnClick="false" не добавились и компонент заработал как ожидалось.
Действия к PopupButton добавляются программно.
Код контроллера
import com.haulmont.bali.util.ParamsMap;
import com.haulmont.cuba.core.global.DataManager;
import com.haulmont.cuba.gui.WindowManager;
import com.haulmont.cuba.gui.components.AbstractLookup;
import com.haulmont.cuba.gui.components.Action;
import com.haulmont.cuba.gui.components.PopupButton;
import com.haulmont.cuba.gui.components.TreeTable;
import com.haulmont.cuba.gui.components.actions.CreateAction;
import com.haulmont.cuba.gui.components.actions.EditAction;
import com.haulmont.cuba.gui.data.CollectionDatasource;
import ru.npc_springs.techbase.entity.techcard.processcard.typed.TypedPCConfig;
import ru.npc_springs.techbase.entity.techcard.processcard.typed.TypedProcessCard;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class TypedProcessCardBrowse extends AbstractLookup {
@Inject
private TreeTable<TypedProcessCard> typedProcessCardsTable;
@Inject
private PopupButton createBtn;
@Named("typedProcessCardsTable.edit")
private EditAction typedProcessCardsTableEdit;
@Inject
private CollectionDatasource<TypedProcessCard, UUID> typedProcessCardsDs;
@Inject
private DataManager dataManager;
private CreateAction createAction(final String actionId, final String caption, final String editorWindowId) {
CreateAction createAction = new CreateAction(typedProcessCardsTable, WindowManager.OpenType.THIS_TAB, actionId);
createAction.setCaption(caption);
createAction.setWindowId(editorWindowId);
return createAction;
}
private void addCustomAction(Action action) {
createBtn.addAction(action);
}
/**
* Called by the framework after creation of all components and before showing the screen.
* <br> Override this method and put initialization logic here.
*
* @param params parameters passed from caller's code, usually from
* {@link #openWindow(String, WindowManager.OpenType)} and similar methods, or set in
* {@code screens.xml} for this registered screen
*/
@Override
public void init(Map<String, Object> params) {
List<TypedPCConfig> typedPCConfigList = dataManager.load(TypedPCConfig.class).view("typedPCConfig-view").list();
if (typedPCConfigList.size() != 0) {
for (int i = 0; i < typedPCConfigList.size(); i++) {
TypedPCConfig config = typedPCConfigList.get(i);
CreateAction createAction = createAction("createAction_" + i, config.getCaption(), config.getEditorWindowId());
createAction.setInitialValues(ParamsMap.of("operation", config.getOperation()));
addCustomAction(createAction);
}
typedProcessCardsDs.addItemChangeListener(e -> {
TypedProcessCard typedCard = e.getItem();
if (typedCard != null) {
TypedPCConfig config = typedPCConfigList.stream()
.filter(typedPCConfig ->
typedPCConfig.getOperation().equals(typedCard.getOperation()))
.findFirst().get();
typedProcessCardsTableEdit.setWindowId(config.getEditorWindowId());
}
}
);
}
}
}