Search in sources :

Example 6 with UIOptions

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);
        }
    }
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) Listitem(org.zkoss.zul.Listitem) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) Component(org.zkoss.zk.ui.Component) CollectSurvey(org.openforis.collect.model.CollectSurvey) Listen(org.zkoss.zk.ui.select.annotation.Listen)

Example 7 with UIOptions

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();
}
Also used : Survey(org.openforis.idm.metamodel.Survey) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) FileOutputStream(java.io.FileOutputStream) File(java.io.File) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 8 with UIOptions

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());
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) Survey(org.openforis.idm.metamodel.Survey) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 9 with UIOptions

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;
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) SurveyObject(org.openforis.idm.metamodel.SurveyObject) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 10 with UIOptions

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();
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) Schema(org.openforis.idm.metamodel.Schema)

Aggregations

UIOptions (org.openforis.collect.metamodel.ui.UIOptions)69 CollectSurvey (org.openforis.collect.model.CollectSurvey)38 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)22 UITab (org.openforis.collect.metamodel.ui.UITab)19 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)18 Layout (org.openforis.collect.metamodel.ui.UIOptions.Layout)10 ArrayList (java.util.ArrayList)9 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)9 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)9 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)9 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)5 Schema (org.openforis.idm.metamodel.Schema)5 Command (org.zkoss.bind.annotation.Command)5 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)5 ExternalizedProperty (org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)4 SchemaNodeData (org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)4 SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)4 SurveyObjectsGenerator (org.openforis.collect.manager.SurveyObjectsGenerator)3 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)3 SurveyObject (org.openforis.idm.metamodel.SurveyObject)3