Search in sources :

Example 21 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange in project collect by openforis.

the class CodeListsVM method addLevel.

@Command
@NotifyChange({ "listLevels" })
public void addLevel() {
    List<CodeListLevel> levels = editedItem.getHierarchy();
    int levelPosition = levels.size() + 1;
    CodeListLevel level = new CodeListLevel();
    String generatedName = Labels.getLabel(SURVEY_CODE_LIST_GENERATED_LEVEL_NAME_LABEL_KEY, new Object[] { levelPosition });
    level.setName(generatedName);
    editedItem.addLevel(level);
}
Also used : CodeListLevel(org.openforis.idm.metamodel.CodeListLevel) NotifyChange(org.zkoss.bind.annotation.NotifyChange) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 22 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange in project collect by openforis.

the class SchemaLayoutSimpleVM method addTab.

@Command
@NotifyChange({ "treeModel", "selectedTab" })
public void addTab(@BindingParam("parent") UITabSet parent) {
    if (rootTabSet != null) {
        if (parent == null) {
            parent = rootTabSet;
            treeModel.deselect();
        }
        CollectSurvey survey = getSurvey();
        UIOptions uiOptions = survey.getUIOptions();
        UITab tab = uiOptions.createTab();
        String label = Labels.getLabel("survey.schema.node.layout.default_tab_label");
        tab.setLabel(currentLanguageCode, label);
        parent.addTab(tab);
        treeModel.appendNodeToSelected(tab);
        selectedTab = tab;
        dispatchTabSetChangedCommand();
    }
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) 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 23 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange 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 24 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange in project collect by openforis.

the class CalculatedAttributeVM method deleteFormula.

@Command
@NotifyChange({ "selectedFormula", "formulas" })
public void deleteFormula() {
    ConfirmParams params = new MessageUtil.ConfirmParams(new MessageUtil.ConfirmHandler() {

        @Override
        public void onOk() {
            editedItem.removeFormula(selectedFormula);
            selectedFormula = null;
            initFormulas();
            notifyChange("selectedFormula", "formulas");
        }
    }, "survey.schema.attribute.calculated.formula.confirm_delete");
    params.setOkLabelKey("global.delete_item");
    MessageUtil.showConfirm(params);
}
Also used : ConfirmParams(org.openforis.collect.designer.util.MessageUtil.ConfirmParams) MessageUtil(org.openforis.collect.designer.util.MessageUtil) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 25 with NotifyChange

use of org.zkoss.bind.annotation.NotifyChange in project collect by openforis.

the class CalculatedAttributeVM method addFormula.

@Command
@NotifyChange("formulas")
public void addFormula() {
    editingNewFormula = true;
    editedFormula = new Formula();
    openFormulaEditPopUp();
}
Also used : Formula(org.openforis.idm.metamodel.CalculatedAttributeDefinition.Formula) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Aggregations

Command (org.zkoss.bind.annotation.Command)26 NotifyChange (org.zkoss.bind.annotation.NotifyChange)26 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)17 UserCredential (es.bsc.compss.ui.auth.UserCredential)4 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)4 File (java.io.File)3 IOException (java.io.IOException)3 MessageUtil (org.openforis.collect.designer.util.MessageUtil)3 UITab (org.openforis.collect.metamodel.ui.UITab)3 CollectSurvey (org.openforis.collect.model.CollectSurvey)3 UITab (org.openforis.collect.model.ui.UITab)3 Session (org.zkoss.zk.ui.Session)3 SimpleDateFormat (java.text.SimpleDateFormat)2 SessionStatus (org.openforis.collect.designer.session.SessionStatus)2 ConfirmParams (org.openforis.collect.designer.util.MessageUtil.ConfirmParams)2 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)2 UITabDefinition (org.openforis.collect.model.ui.UITabDefinition)2 EmptyCompleteGraphException (es.bsc.compss.exceptions.EmptyCompleteGraphException)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1