Search in sources :

Example 6 with UITabSet

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();
}
Also used : UITabSet(org.openforis.collect.metamodel.ui.UITabSet) ModelVersion(org.openforis.idm.metamodel.ModelVersion) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 7 with UITabSet

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());
}
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 8 with UITabSet

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();
}
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)

Example 9 with UITabSet

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");
    }
}
Also used : SessionStatus(org.openforis.collect.designer.session.SessionStatus) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 10 with UITabSet

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;
}
Also used : UITabSet(org.openforis.collect.metamodel.ui.UITabSet) Stack(java.util.Stack)

Aggregations

UITabSet (org.openforis.collect.metamodel.ui.UITabSet)20 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)9 UITab (org.openforis.collect.metamodel.ui.UITab)8 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)6 CollectSurvey (org.openforis.collect.model.CollectSurvey)5 Schema (org.openforis.idm.metamodel.Schema)5 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)4 ArrayList (java.util.ArrayList)3 SurveyObjectsGenerator (org.openforis.collect.manager.SurveyObjectsGenerator)3 IOException (java.io.IOException)2 SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)2 XmlParseException (org.openforis.idm.metamodel.xml.XmlParseException)2 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)2 Command (org.zkoss.bind.annotation.Command)2 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)2 NotifyChange (org.zkoss.bind.annotation.NotifyChange)2 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 Stack (java.util.Stack)1 Test (org.junit.Test)1