Search in sources :

Example 6 with GlobalCommand

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

the class SchemaVM method cancelChangesToEditedNodeInPopUp.

@GlobalCommand
public void cancelChangesToEditedNodeInPopUp(@ContextParam(ContextType.BINDER) Binder binder) {
    Component nodeFormContainer = getNodeEditorForm();
    NodeDefinitionVM<?> vm = ComponentUtil.getViewModel(nodeFormContainer);
    vm.undoLastChanges();
    closeNodeEditPopUp();
}
Also used : Component(org.zkoss.zk.ui.Component) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 7 with GlobalCommand

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

the class SurveySelectVM method closeSurveyImportPopUp.

@GlobalCommand
public void closeSurveyImportPopUp(@BindingParam("successfullyImported") Boolean successfullyImported) {
    Binder binder = null;
    if (surveyImportPopUp != null) {
        binder = ComponentUtil.getBinder(surveyImportPopUp);
        SurveyImportVM vm = (SurveyImportVM) binder.getViewModel();
        vm.reset();
    }
    closePopUp(surveyImportPopUp);
    surveyImportPopUp = null;
    if (successfullyImported != null && successfullyImported.booleanValue()) {
        reloadSurveySummaries(binder);
    }
}
Also used : Binder(org.zkoss.bind.Binder) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 8 with GlobalCommand

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

the class SurveySelectVM method updateSurveyList.

@GlobalCommand
public void updateSurveyList() {
    if (surveyImportPopUp != null || jobStatusPopUp != null) {
        // skip survey list update
        return;
    }
    try {
        List<SurveySummary> newSummaries = loadSurveySummaries(null);
        if (summaries == null) {
            summaries = newSummaries;
        } else {
            for (SurveySummary newSummary : newSummaries) {
                SurveySummary oldSummary = findSummary(newSummary.getId(), newSummary.isPublished(), newSummary.isTemporary());
                if (oldSummary == null) {
                // TODO handle this??
                } else {
                    oldSummary.setRecordValidationProcessStatus(newSummary.getRecordValidationProcessStatus());
                    BindUtils.postNotifyChange(null, null, oldSummary, "recordValidationProgressStatus");
                    BindUtils.postNotifyChange(null, null, oldSummary, "recordValidationInProgress");
                    BindUtils.postNotifyChange(null, null, oldSummary, "recordValidationProgressPercent");
                }
            }
        }
    } catch (Exception e) {
        return;
    }
}
Also used : SurveySummary(org.openforis.collect.model.SurveySummary) SurveyStoreException(org.openforis.collect.persistence.SurveyStoreException) IOException(java.io.IOException) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 9 with GlobalCommand

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

the class SchemaVM method editedNodeChanged.

@GlobalCommand
public void editedNodeChanged(@ContextParam(ContextType.VIEW) Component view, @BindingParam("parentEntity") EntityDefinition parentEntity, @BindingParam("node") SurveyObject editedNode, @BindingParam("newItem") Boolean newNode) {
    if (parentEntity == null && editedNode instanceof EntityDefinition) {
        // root entity
        EntityDefinition rootEntity = (EntityDefinition) editedNode;
        updateRootTabLabel(view, rootEntity);
    } else {
        if (newNode) {
            // editing tab or nested node definition
            // update tree node
            selectedTreeNode.setDetached(false);
            BindUtils.postNotifyChange(null, null, selectedTreeNode, "detached");
            this.newNode = false;
            notifyChange("newNode");
            selectTreeNode(editedNode);
        }
        notifyChange("editedNodePath");
        // to be called when not notifying changes on treeModel
        refreshSelectedTreeNode(view);
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 10 with GlobalCommand

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

the class SchemaVM method applyChangesToEditedNodeInPopUp.

@GlobalCommand
public void applyChangesToEditedNodeInPopUp(@ContextParam(ContextType.BINDER) Binder binder) {
    Component nodeFormContainer = getNodeEditorForm();
    NodeDefinitionVM<?> vm = ComponentUtil.getViewModel(nodeFormContainer);
    vm.dispatchValidateCommand(ComponentUtil.getBinder(nodeFormContainer));
    if (vm.isCurrentFormValid()) {
        vm.commitChanges(binder);
        closeNodeEditPopUp();
    } else {
        checkCanLeaveForm(new CanLeaveFormConfirmHandler() {

            @Override
            public void onOk(boolean confirmed) {
                closeNodeEditPopUp();
            }
        });
    }
}
Also used : Component(org.zkoss.zk.ui.Component) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Aggregations

GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)13 CodeList (org.openforis.idm.metamodel.CodeList)3 File (java.io.File)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 PersistedCodeListItem (org.openforis.idm.metamodel.PersistedCodeListItem)2 Component (org.zkoss.zk.ui.Component)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 CodeAttributeDefinitionFormObject (org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject)1 CodeListFormObject (org.openforis.collect.designer.form.CodeListFormObject)1 Type (org.openforis.collect.designer.form.CodeListFormObject.Type)1 DataBackupError (org.openforis.collect.io.data.DataBackupError)1 SchemaSummaryCSVExportJob (org.openforis.collect.io.metadata.SchemaSummaryCSVExportJob)1 CodeListBatchImportJob (org.openforis.collect.io.metadata.codelist.CodeListBatchImportJob)1 CodeListImportTask (org.openforis.collect.io.metadata.codelist.CodeListImportTask)1 SurveySummary (org.openforis.collect.model.SurveySummary)1 SurveyStoreException (org.openforis.collect.persistence.SurveyStoreException)1