Search in sources :

Example 1 with UITab

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

the class SurveyConfigurationEditVM method addTab.

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

Example 2 with UITab

use of org.openforis.collect.model.ui.UITab 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 3 with UITab

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

the class TabsGroupComposer method addTab.

@Command
@NotifyChange({ "tabs" })
public void addTab() {
    UITab tab = new UITab();
    String tabName = generateNewTabName(tabsGroup);
    tab.setName(tabName);
    tabsGroup.addTab(tab);
}
Also used : UITab(org.openforis.collect.model.ui.UITab) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Aggregations

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