Search in sources :

Example 1 with UITabDefinition

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

the class SurveyConfigurationEditVM method addTabDefinition.

@Command
@NotifyChange({ "newTab", "editedTab", "editedTabDefinition" })
public void addTabDefinition() {
    editedTab = null;
    editedTabDefinition = new UITabDefinition();
    newTab = true;
}
Also used : UITabDefinition(org.openforis.collect.model.ui.UITabDefinition) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Example 2 with UITabDefinition

use of org.openforis.collect.model.ui.UITabDefinition 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)

Aggregations

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