use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.
the class CodeAttributeVM method openParentAttributeSelector.
@Command
public void openParentAttributeSelector(@ContextParam(ContextType.BINDER) final Binder binder) {
String title = Labels.getLabel("survey.schema.attribute.code.select_parent_for_node", new String[] { editedItem.getName() });
final Collection<CodeAttributeDefinition> assignableParentAttributes = editedItem.getAssignableParentCodeAttributeDefinitions();
if (assignableParentAttributes.isEmpty()) {
MessageUtil.showWarning("survey.schema.attribute.code.no_assignable_parent_available");
} else {
CodeAttributeDefinition parentCodeAttributeDefinition = ((CodeAttributeDefinitionFormObject) formObject).getParentCodeAttributeDefinition();
Predicate<SurveyObject> includedNodePredicate = new Predicate<SurveyObject>() {
@Override
public boolean evaluate(SurveyObject item) {
return item instanceof UITab || item instanceof EntityDefinition || item instanceof CodeAttributeDefinition && assignableParentAttributes.contains(item);
}
};
Predicate<SurveyObject> disabledNodePredicate = new Predicate<SurveyObject>() {
@Override
public boolean evaluate(SurveyObject item) {
return !(item instanceof CodeAttributeDefinition);
}
};
final Window parentSelectorPopUp = SchemaTreePopUpVM.openPopup(title, editedItem.getRootEntity(), null, includedNodePredicate, false, false, disabledNodePredicate, null, parentCodeAttributeDefinition, true);
parentSelectorPopUp.addEventListener(SchemaTreePopUpVM.NODE_SELECTED_EVENT_NAME, new EventListener<NodeSelectedEvent>() {
public void onEvent(NodeSelectedEvent event) throws Exception {
CodeAttributeDefinition parentAttrDefn = (CodeAttributeDefinition) event.getSelectedItem();
CodeAttributeDefinitionFormObject fo = (CodeAttributeDefinitionFormObject) formObject;
fo.setParentCodeAttributeDefinition(parentAttrDefn);
String hierarchicalLevel = getHierarchicalLevelName(parentAttrDefn);
fo.setHierarchicalLevel(hierarchicalLevel);
notifyChange("formObject");
dispatchApplyChangesCommand(binder);
notifyChange("dependentCodePaths");
closePopUp(parentSelectorPopUp);
}
});
}
}
use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.
the class SchemaVM method getSelectedNodeParentTab.
private UITab getSelectedNodeParentTab() {
UITab parentTab;
SurveyObject selectedSurveyObject = selectedTreeNode.getSurveyObject();
if (selectedSurveyObject instanceof UITab) {
parentTab = (UITab) selectedSurveyObject;
} else {
UIOptions uiOptions = survey.getUIOptions();
parentTab = uiOptions.getAssignedTab((NodeDefinition) selectedSurveyObject);
}
return parentTab;
}
use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.
the class SchemaVM method openMoveNodePopup.
@Command
public void openMoveNodePopup() {
SchemaNodeData selectedTreeNode = getSelectedTreeNode();
if (selectedTreeNode == null) {
return;
}
SurveyObject selectedItem = selectedTreeNode.getSurveyObject();
if (selectedItem instanceof NodeDefinition) {
NodeDefinition selectedNode = (NodeDefinition) selectedItem;
boolean changeParentNodeAllowed = checkChangeParentNodeAllowed(selectedNode);
if (changeParentNodeAllowed) {
openSelectParentNodePopupForReparent(selectedNode);
}
} else {
// TODO support tab moving
return;
}
}
use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.
the class SchemaVM method performSelectNode.
protected void performSelectNode(Binder binder, SchemaNodeData data) {
selectedTreeNode = data;
treeModel.select(data);
SurveyObject surveyObject = data.getSurveyObject();
EntityDefinition parentDefn = treeModel.getNearestParentEntityDefinition(surveyObject);
editNode(binder, false, parentDefn, surveyObject);
}
use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.
the class SchemaVM method openDuplicateNodePopup.
@Command
public void openDuplicateNodePopup() {
if (!checkCanLeaveForm()) {
return;
}
SchemaNodeData selectedTreeNode = getSelectedTreeNode();
if (selectedTreeNode == null) {
return;
}
SurveyObject selectedItem = selectedTreeNode.getSurveyObject();
if (selectedItem instanceof NodeDefinition) {
openSelectParentNodePopupForDuplicate((NodeDefinition) selectedItem);
}
}
Aggregations