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);
}
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);
}
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);
}
}
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();
}
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());
}
}
Aggregations