use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class SurveyController method createEmptySurvey.
private 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(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, 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 SchemaLayoutSimpleVM method initTreeModel.
protected void initTreeModel() {
if (selectedRootEntity == null) {
rootTabSet = null;
treeModel = null;
} else {
CollectSurvey survey = getSurvey();
if (survey == null) {
// TODO session expired...?
} else {
UIOptions uiOptions = survey.getUIOptions();
rootTabSet = uiOptions.getAssignedRootTabSet(selectedRootEntity);
treeModel = UITabsTreeModel.createInstance(rootTabSet);
}
}
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class SchemaLayoutSimpleVM method addTab.
@Command
@NotifyChange({ "treeModel", "selectedTab" })
public void addTab(@BindingParam("parent") UITabSet parent) {
if (rootTabSet != null) {
if (parent == null) {
parent = rootTabSet;
treeModel.deselect();
}
CollectSurvey survey = getSurvey();
UIOptions uiOptions = survey.getUIOptions();
UITab tab = uiOptions.createTab();
String label = Labels.getLabel("survey.schema.node.layout.default_tab_label");
tab.setLabel(currentLanguageCode, label);
parent.addTab(tab);
treeModel.appendNodeToSelected(tab);
selectedTab = tab;
dispatchTabSetChangedCommand();
}
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class SchemaLayoutSimpleVM method removeTab.
@Command
public void removeTab() {
String confirmMessageKey = null;
if (!selectedTab.getTabs().isEmpty()) {
confirmMessageKey = "survey.layout.tab.remove.confirm.nested_tabs_present";
} else {
CollectSurvey survey = getSurvey();
UIOptions uiOpts = survey.getUIOptions();
List<NodeDefinition> nodesPerTab = uiOpts.getNodesPerTab(selectedTab, false);
if (!nodesPerTab.isEmpty()) {
confirmMessageKey = "survey.layout.tab.remove.confirm.associated_nodes_present";
}
}
if (confirmMessageKey != null) {
MessageUtil.ConfirmParams params = new MessageUtil.ConfirmParams(new MessageUtil.ConfirmHandler() {
@Override
public void onOk() {
performRemoveSelectedTab();
}
}, confirmMessageKey);
params.setOkLabelKey("global.delete_item");
MessageUtil.showConfirm(params);
} else {
performRemoveSelectedTab();
}
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class SchemaLayoutVM method isAssociatedToTab.
public boolean isAssociatedToTab(NodeDefinition nodeDefn) {
UIOptions uiOptions = survey.getUIOptions();
boolean result = uiOptions.isAssociatedToTab(nodeDefn);
return result;
}
Aggregations