use of org.openforis.collect.metamodel.ui.UITabSet in project collect by openforis.
the class SchemaLayoutVM method nodeSelected.
@Command
@NotifyChange({ "rootTabSet" })
public void nodeSelected(@BindingParam("node") Treeitem node) {
List<ModelVersion> versions = survey.getVersions();
setFormVersion(versions.isEmpty() ? null : versions.get(0));
UITabSet tabSet = getRootTabSet(node);
refreshTabSetLayoutPanel(tabSet, false);
this.rootTabSet = tabSet;
dispatchTabSetChangedCommand();
}
use of org.openforis.collect.metamodel.ui.UITabSet in project collect by openforis.
the class UIOptionsBinderTest method testUnmarshall.
@Test
public void testUnmarshall() throws IOException {
String optionsBody = loadTestOptions();
UIOptionsBinder binder = new UIOptionsBinder();
Survey survey = createTestSurvey();
UIOptions uiOptions = binder.unmarshal(survey, UIOptionsConstants.UI_TYPE, optionsBody);
assertNotNull(uiOptions);
List<UITabSet> tabSets = uiOptions.getTabSets();
assertEquals(1, tabSets.size());
UITabSet clusterRootTabSet = tabSets.get(0);
assertEquals("cluster", clusterRootTabSet.getName());
List<UITab> tabs = clusterRootTabSet.getTabs();
assertEquals(4, tabs.size());
UITab plotTab = tabs.get(1);
assertEquals("plot", plotTab.getName());
String label = plotTab.getLabel("en");
assertEquals("Plot", label);
assertEquals(clusterRootTabSet, plotTab.getParent());
List<UITab> plotInnerTabs = plotTab.getTabs();
assertEquals(6, plotInnerTabs.size());
UITab plotDetTab = plotInnerTabs.get(0);
assertEquals("plot_det", plotDetTab.getName());
}
use of org.openforis.collect.metamodel.ui.UITabSet in project collect by openforis.
the class SchemaVM method performRemoveNode.
protected void performRemoveNode(NodeDefinition nodeDefn) {
EntityDefinition parentDefn = (EntityDefinition) nodeDefn.getParentDefinition();
if (parentDefn == null) {
// root entity
UIOptions uiOpts = survey.getUIOptions();
UITabSet tabSet = uiOpts.getAssignedRootTabSet((EntityDefinition) nodeDefn);
uiOpts.removeTabSet(tabSet);
Schema schema = nodeDefn.getSchema();
String nodeName = nodeDefn.getName();
schema.removeRootEntityDefinition(nodeName);
selectedRootEntity = null;
rootTabSet = null;
notifyChange("selectedRootEntity", "rootEntities");
refreshTreeModel();
} else {
if (treeModel != null) {
treeModel.removeSelectedNode();
notifyChange("treeModel");
}
parentDefn.removeChildDefinition(nodeDefn);
}
survey.refreshSurveyDependencies();
resetEditingStatus();
dispatchCurrentFormValidatedCommand(true);
dispatchSurveyChangedCommand();
}
use of org.openforis.collect.metamodel.ui.UITabSet in project collect by openforis.
the class TabsGroupVM method removeTab.
@Command
@NotifyChange({ "tabs" })
public void removeTab(@BindingParam("tab") UITab tab) {
if (tab.getTabs().isEmpty()) {
SessionStatus sessionStatus = getSessionStatus();
CollectSurvey survey = sessionStatus.getSurvey();
UIOptions uiOpts = survey.getUIOptions();
List<NodeDefinition> nodesPerTab = uiOpts.getNodesPerTab(tab, false);
if (nodesPerTab.isEmpty()) {
UITabSet parent = tab.getParent();
parent.removeTab(tab);
postTabChangedCommand(parent);
} else {
MessageUtil.showWarning("survey.layout.tab.remove.error.associated_nodes_present");
}
} else {
MessageUtil.showWarning("survey.layout.tab.remove.error.nested_tabs_present");
}
}
use of org.openforis.collect.metamodel.ui.UITabSet in project collect by openforis.
the class TabsGroupVM method generateNewTabName.
private String generateNewTabName(UITabSet parentGroup) {
String prefix = TAB_NAME_PREFIX;
Stack<Integer> parts = new Stack<Integer>();
UITabSet currentGroup = parentGroup;
do {
int position = currentGroup.getTabs().size() + 1;
parts.push(position);
currentGroup = currentGroup.getParent();
} while (currentGroup != null);
String suffix = StringUtils.join(parts.toArray(), TAB_NAME_SEPARATOR);
String tabName = prefix + suffix;
return tabName;
}
Aggregations