use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData in project collect by openforis.
the class SchemaVM method openSelectParentNodePopupForDuplicate.
private void openSelectParentNodePopupForDuplicate(final NodeDefinition node) {
Predicate<SurveyObject> includedNodePredicate = new Predicate<SurveyObject>() {
@Override
public boolean evaluate(SurveyObject item) {
return item instanceof UITab || item instanceof EntityDefinition;
}
};
Predicate<SurveyObject> disabledPredicate = new Predicate<SurveyObject>() {
@Override
public boolean evaluate(SurveyObject item) {
return !(item instanceof UITab || item instanceof EntityDefinition);
}
};
String nodeName = node.getName();
UITab assignedTab = survey.getUIOptions().getAssignedTab((NodeDefinition) node);
String assignedTabLabel = assignedTab.getLabel(currentLanguageCode);
String title = Labels.getLabel("survey.schema.duplicate_node_popup_title", new String[] { getNodeTypeHeaderLabel(), nodeName, assignedTabLabel });
// calculate parent item (tab or entity)
SchemaTreeNode treeNode = treeModel.getTreeNode(node);
TreeNode<SchemaNodeData> parentTreeNode = treeNode.getParent();
SurveyObject parentItem = parentTreeNode.getData().getSurveyObject();
final Window popup = SchemaTreePopUpVM.openPopup(title, selectedRootEntity, null, includedNodePredicate, false, true, disabledPredicate, null, parentItem, false);
popup.addEventListener(SchemaTreePopUpVM.NODE_SELECTED_EVENT_NAME, new EventListener<NodeSelectedEvent>() {
public void onEvent(NodeSelectedEvent event) throws Exception {
SurveyObject selectedParent = event.getSelectedItem();
duplicateEditedNodeInto(node, selectedParent);
closePopUp(popup);
}
});
}
use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData in project collect by openforis.
the class SchemaVM method getTreeItem.
// TODO move it to tree model class
private Treeitem getTreeItem(SurveyObject item) {
for (Treeitem treeItem : nodesTree.getItems()) {
SchemaTreeNode node = treeItem.getValue();
SchemaNodeData data = node.getData();
SurveyObject itemSO = data.getSurveyObject();
if (itemSO == item) {
return treeItem;
}
}
return null;
}
use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData in project collect by openforis.
the class SchemaVM method refreshSelectedTreeNode.
protected void refreshSelectedTreeNode(Component view) {
Treeitem selectedItem = nodesTree.getSelectedItem();
SchemaTreeNode treeNode = selectedItem.getValue();
SchemaNodeData data = treeNode.getData();
// update context menu
Menupopup popupMenu = getPopupMenu(data);
selectedItem.setContext(popupMenu);
}
Aggregations