Search in sources :

Example 1 with UIConfiguration

use of org.openforis.collect.model.ui.UIConfiguration in project collect by openforis.

the class SurveyConfigurationEditVM method applyChanges.

@Command
@NotifyChange({ "editedTabDefinition", "editedTab", "selectedTab" })
public void applyChanges() {
    CollectSurvey survey = getSurvey();
    UIConfiguration uiConfiguration = survey.getUIConfiguration();
    if (newTab) {
        if (editedTabDefinition != null) {
            uiConfiguration.addTabDefinition(editedTabDefinition);
            treeModel.appendToSelected(editedTabDefinition);
            selectedTab = editedTabDefinition;
        } else if (editedTab != null) {
            selectedTab.addTab(editedTab);
            treeModel.appendToSelected(editedTab);
            selectedTab = editedTab;
        }
    } else {
        String tabName = selectedTab.getName();
        if (editedTabDefinition != null) {
            String newName = editedTabDefinition.getName();
            UITabDefinition newTabDefn = uiConfiguration.updateTabDefinition(tabName, newName);
            // TODO avoid use of side effect...
            // treeModel.updateSelectedNode(newTabDefn);
            selectedTab = newTabDefn;
        } else {
            selectedTab.setName(editedTab.getName());
            ((UITab) selectedTab).setLabel(editedTab.getLabel());
        // TODO avoid use of side effect...
        // treeModel.updateSelectedNode(editedTab);
        }
    }
    newTab = false;
    HashMap<String, Object> args = new HashMap<String, Object>();
    args.put("tab", selectedTab);
    BindUtils.postGlobalCommand(null, null, TAB_DEFINITIONS_UPDATED_COMMAND, args);
}
Also used : UITab(org.openforis.collect.model.ui.UITab) HashMap(java.util.HashMap) UIConfiguration(org.openforis.collect.model.ui.UIConfiguration) UITabDefinition(org.openforis.collect.model.ui.UITabDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Example 2 with UIConfiguration

use of org.openforis.collect.model.ui.UIConfiguration in project collect by openforis.

the class SurveyConfigurationEditVM method getTabs.

public DefaultTreeModel<UITabsGroup> getTabs() {
    if (treeModel == null) {
        UIConfiguration uiConfig = getSurvey().getUIConfiguration();
        treeModel = new UIConfigurationTreeModel(uiConfig);
    }
    return treeModel.getModel();
}
Also used : UIConfiguration(org.openforis.collect.model.ui.UIConfiguration)

Aggregations

UIConfiguration (org.openforis.collect.model.ui.UIConfiguration)2 HashMap (java.util.HashMap)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 UITab (org.openforis.collect.model.ui.UITab)1 UITabDefinition (org.openforis.collect.model.ui.UITabDefinition)1 Command (org.zkoss.bind.annotation.Command)1 NotifyChange (org.zkoss.bind.annotation.NotifyChange)1