use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class SchemaVM method performRemoveTab.
protected void performRemoveTab(UITab tab) {
// remove all nodes associated to the tab
UIOptions uiOptions = tab.getUIOptions();
List<NodeDefinition> nodesPerTab = uiOptions.getNodesPerTab(tab, false);
for (NodeDefinition nodeDefn : nodesPerTab) {
EntityDefinition parentDefn = nodeDefn.getParentEntityDefinition();
parentDefn.removeChildDefinition(nodeDefn);
}
performRemoveSelectedTreeNode();
UITabSet parent = tab.getParent();
parent.removeTab(tab);
refreshTreeModel();
dispatchSurveyChangedCommand();
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class NewSurveyParametersPopUpVM method createEmptySurvey.
protected CollectSurvey createEmptySurvey(String name, String langCode) {
// create empty survey
CollectSurvey survey = surveyManager.createTemporarySurvey(name, langCode);
// add default root entity
Schema schema = survey.getSchema();
EntityDefinition rootEntity = schema.createEntityDefinition();
rootEntity.setMultiple(true);
rootEntity.setName(SurveyController.DEFAULT_ROOT_ENTITY_NAME);
schema.addRootEntityDefinition(rootEntity);
// create root tab set
UIOptions uiOptions = survey.getUIOptions();
UITabSet rootTabSet = uiOptions.createRootTabSet((EntityDefinition) rootEntity);
UITab mainTab = uiOptions.getMainTab(rootTabSet);
mainTab.setLabel(langCode, SurveyController.DEFAULT_MAIN_TAB_LABEL);
SurveyObjectsGenerator surveyObjectsGenerator = new SurveyObjectsGenerator();
surveyObjectsGenerator.addPredefinedObjects(survey);
return survey;
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class EntityDefinitionFormValidator method validateLayout.
protected void validateLayout(ValidationContext ctx) {
EntityDefinition editedNode = (EntityDefinition) getEditedNode(ctx);
if (editedNode.isVirtual()) {
// skip check
return;
}
String field = LAYOUT_FIELD;
String layoutValue = getValue(ctx, field);
Layout layout = Layout.valueOf(layoutValue);
EntityDefinition parentEntity = getParentEntity(ctx);
CollectSurvey survey = (CollectSurvey) editedNode.getSurvey();
UIOptions uiOptions = survey.getUIOptions();
Boolean multiple = getValue(ctx, MULTIPLE_FIELD);
UITab tab = uiOptions.getAssignedTab(editedNode);
// UITab tab = getAssociatedTab(ctx, uiOptions, parentEntity);
if (tab != null) {
boolean valid = uiOptions.isLayoutSupported(parentEntity, editedNode.getId(), tab, multiple, layout);
if (!valid) {
String message = Labels.getLabel(LabelKeys.LAYOUT_NOT_SUPPORTED_MESSAGE_KEY);
addInvalidMessage(ctx, field, message);
}
} else {
// defining root entity, not yet added to schema...
}
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class TextAttributeDefinitionFormObject method loadFrom.
@Override
public void loadFrom(T source, String languageCode) {
super.loadFrom(source, languageCode);
Type typeEnum = source.getType();
if (typeEnum == null) {
typeEnum = Type.SHORT;
}
type = typeEnum.name();
autocompleteGroup = source.getAnnotation(Annotation.AUTOCOMPLETE.getQName());
UIOptions uiOptions = getUIOptions(source);
autoUppercase = uiOptions.isAutoUppercase(source);
CollectAnnotations annotations = ((CollectSurvey) source.getSurvey()).getAnnotations();
TextInput textInput = annotations.getTextInput(source);
input = textInput.name();
geometry = annotations.isGeometry(source);
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class SchemaUpdater method generateAlias.
public EntityDefinition generateAlias(EntityDefinition sourceDef, String sourceFilterAttributeName, EntityDefinition targetParentDef, String targetFilterAttributeName) {
EntityDefinition aliasDef = survey.getSchema().cloneDefinition(sourceDef, targetFilterAttributeName);
// add "Alias" suffix to labels
for (NodeLabel nodeLabel : aliasDef.getLabels()) {
aliasDef.setLabel(nodeLabel.getType(), nodeLabel.getLanguage(), nodeLabel.getText() + " Alias");
}
aliasDef.traverse(new NodeDefinitionVisitor() {
public void visit(NodeDefinition def) {
if (def instanceof AttributeDefinition) {
AttributeDefinition attrDef = (AttributeDefinition) def;
attrDef.setCalculated(false);
attrDef.removeAllChecks();
attrDef.removeAllAttributeDefaults();
}
def.setRelevantExpression(null);
def.setRequiredExpression(null);
}
});
targetParentDef.addChildDefinition(aliasDef);
aliasDef.setVirtual(true);
aliasDef.setGeneratorExpression(generateAliasGeneratorExpression(sourceDef, sourceFilterAttributeName, targetParentDef, targetFilterAttributeName));
UIOptions uiOptions = survey.getUIOptions();
// prevent layout errors
uiOptions.setLayout(aliasDef, Layout.FORM);
uiOptions.setHidden(aliasDef, true);
return aliasDef;
}
Aggregations