Search in sources :

Example 16 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.

the class SchemaVM method moveNode.

protected void moveNode(boolean up) {
    SurveyObject surveyObject = selectedTreeNode.getSurveyObject();
    List<SurveyObject> siblings = getSiblingsInTree(surveyObject);
    int oldIndex = siblings.indexOf(surveyObject);
    int newIndexInTree = up ? oldIndex - 1 : oldIndex + 1;
    moveNode(newIndexInTree);
}
Also used : SurveyObject(org.openforis.idm.metamodel.SurveyObject)

Example 17 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.

the class SchemaVM method getIcon.

public static String getIcon(SchemaNodeData data) {
    SurveyObject surveyObject = data.getSurveyObject();
    boolean key = surveyObject instanceof KeyAttributeDefinition && ((KeyAttributeDefinition) surveyObject).isKey();
    boolean calculated = surveyObject instanceof AttributeDefinition && ((AttributeDefinition) surveyObject).isCalculated();
    return getIcon(data, key, calculated);
}
Also used : SurveyObject(org.openforis.idm.metamodel.SurveyObject) KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition)

Example 18 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.

the class SchemaVM method isMoveNodeDisabled.

protected boolean isMoveNodeDisabled(boolean up) {
    if (newNode || selectedTreeNode == null || isMainTab(selectedTreeNode)) {
        return true;
    } else {
        SurveyObject surveyObject = selectedTreeNode.getSurveyObject();
        List<SurveyObject> siblings = getSiblingsInTree(surveyObject);
        int index = siblings.indexOf(surveyObject);
        return isMoveItemDisabled(siblings, index, up);
    }
}
Also used : SurveyObject(org.openforis.idm.metamodel.SurveyObject)

Example 19 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject 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)

Example 20 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.

the class SchemaVM method getIcon.

public static String getIcon(SchemaNodeData data, boolean key, boolean calculated) {
    SurveyObject surveyObject = data.getSurveyObject();
    String imagesRootPath = NODE_TYPES_IMAGES_PATH;
    if (surveyObject instanceof UITab) {
        return imagesRootPath + "tab-small.png";
    } else if (surveyObject instanceof EntityDefinition) {
        return getEntityIcon((EntityDefinition) surveyObject);
    } else if (key) {
        return imagesRootPath + "key-small.png";
    } else if (calculated) {
        return imagesRootPath + "calculated-small.png";
    } else {
        AttributeType attributeType = AttributeType.valueOf((AttributeDefinition) surveyObject);
        return getAttributeIcon(attributeType.name());
    }
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) SurveyObject(org.openforis.idm.metamodel.SurveyObject) AttributeType(org.openforis.collect.designer.metamodel.AttributeType) KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Aggregations

SurveyObject (org.openforis.idm.metamodel.SurveyObject)23 UITab (org.openforis.collect.metamodel.ui.UITab)10 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)9 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)7 SchemaNodeData (org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)6 Window (org.zkoss.zul.Window)6 SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)5 Predicate (org.openforis.collect.designer.util.Predicate)5 NodeSelectedEvent (org.openforis.collect.designer.viewmodel.SchemaTreePopUpVM.NodeSelectedEvent)5 Command (org.zkoss.bind.annotation.Command)5 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)4 HashSet (java.util.HashSet)3 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)3 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)3 ArrayList (java.util.ArrayList)2 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)2 TreeNode (org.zkoss.zul.TreeNode)2 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 AbstractNode (org.openforis.collect.designer.component.BasicTreeModel.AbstractNode)1