use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class SchemaLayoutVM method listOfNodesDropHandler.
@Listen("onDrop = tree#nodesTree")
public void listOfNodesDropHandler(DropEvent evt) {
Component dragged = evt.getDragged();
if (dragged instanceof Listitem) {
NodeDefinition node = ((Listitem) dragged).getValue();
CollectSurvey survey = getSurvey();
UIOptions uiOpts = survey.getUIOptions();
UITab oldTab = uiOpts.getAssignedTab(node, false);
uiOpts.removeTabAssociation(node);
if (oldTab != null) {
postNodePerTabChangedCommand(oldTab);
}
}
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class UIOptionsBinderTest method roundTripMarshallingTest.
@Test
public void roundTripMarshallingTest() throws IOException {
String optionsBody = loadTestOptions();
UIOptionsBinder binder = new UIOptionsBinder();
Survey survey = createTestSurvey();
UIOptions uiOptions = binder.unmarshal(survey, UIOptionsConstants.UI_TYPE, optionsBody);
new File("target/test/output").mkdirs();
FileOutputStream fos = new FileOutputStream("target/test/output/marshalled.uioptions.xml");
String marshalled = binder.marshal(uiOptions, survey.getDefaultLanguage());
IOUtils.write(marshalled, fos);
fos.flush();
fos.close();
}
use of org.openforis.collect.metamodel.ui.UIOptions 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.UIOptions in project collect by openforis.
the class SchemaVM method getSelectedNodeParentTab.
private UITab getSelectedNodeParentTab() {
UITab parentTab;
SurveyObject selectedSurveyObject = selectedTreeNode.getSurveyObject();
if (selectedSurveyObject instanceof UITab) {
parentTab = (UITab) selectedSurveyObject;
} else {
UIOptions uiOptions = survey.getUIOptions();
parentTab = uiOptions.getAssignedTab((NodeDefinition) selectedSurveyObject);
}
return parentTab;
}
use of org.openforis.collect.metamodel.ui.UIOptions 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();
}
Aggregations