Search in sources :

Example 11 with SchemaTreeNode

use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode 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);
}
Also used : Treeitem(org.zkoss.zul.Treeitem) SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) Menupopup(org.zkoss.zul.Menupopup) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)

Example 12 with SchemaTreeNode

use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode in project collect by openforis.

the class SchemaVM method moveNode.

protected void moveNode(int newIndexInTree) {
    SurveyObject surveyObject = selectedTreeNode.getSurveyObject();
    List<SurveyObject> siblings = getSiblingsInTree(surveyObject);
    SurveyObject newIndexItem = siblings.get(newIndexInTree);
    SchemaTreeNode newIndexNode = treeModel.getTreeNode(newIndexItem);
    int newIndexInModel = newIndexNode.getIndexInModel();
    if (surveyObject instanceof NodeDefinition) {
        NodeDefinition nodeDefn = (NodeDefinition) surveyObject;
        EntityDefinition parentEntity = nodeDefn.getParentEntityDefinition();
        if (parentEntity != null) {
            parentEntity.moveChildDefinition(nodeDefn, newIndexInModel);
        } else {
            EntityDefinition rootEntity = nodeDefn.getRootEntity();
            Schema schema = rootEntity.getSchema();
            schema.moveRootEntityDefinition(rootEntity, newIndexInModel);
        }
    } else {
        UITab tab = (UITab) surveyObject;
        UITabSet parent = tab.getParent();
        parent.moveTab(tab, newIndexInModel);
    }
    treeModel.moveSelectedNode(newIndexInTree);
    notifyChange("treeModel", "moveNodeUpDisabled", "moveNodeDownDisabled");
    dispatchSurveyChangedCommand();
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UITab(org.openforis.collect.metamodel.ui.UITab) SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) SurveyObject(org.openforis.idm.metamodel.SurveyObject) Schema(org.openforis.idm.metamodel.Schema) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Aggregations

SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)12 SchemaNodeData (org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)9 UITab (org.openforis.collect.metamodel.ui.UITab)6 SurveyObject (org.openforis.idm.metamodel.SurveyObject)5 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)4 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)4 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)4 AbstractNode (org.openforis.collect.designer.component.BasicTreeModel.AbstractNode)3 ArrayList (java.util.ArrayList)2 Predicate (org.openforis.collect.designer.util.Predicate)2 NodeSelectedEvent (org.openforis.collect.designer.viewmodel.SchemaTreePopUpVM.NodeSelectedEvent)2 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 Treeitem (org.zkoss.zul.Treeitem)2 Window (org.zkoss.zul.Window)2 HashSet (java.util.HashSet)1 Schema (org.openforis.idm.metamodel.Schema)1 Menupopup (org.zkoss.zul.Menupopup)1