Search in sources :

Example 56 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.

the class SurveyController method createEmptySurvey.

private CollectSurvey createEmptySurvey(String name, String langCode) {
    // create empty survey
    CollectSurvey survey = surveyManager.createTemporarySurvey(name, langCode);
    // add default root entity
    Schema schema = survey.getSchema();
    EntityDefinition rootEntity = schema.createEntityDefinition();
    rootEntity.setMultiple(true);
    rootEntity.setName(DEFAULT_ROOT_ENTITY_NAME);
    schema.addRootEntityDefinition(rootEntity);
    // create root tab set
    UIOptions uiOptions = survey.getUIOptions();
    UITabSet rootTabSet = uiOptions.createRootTabSet((EntityDefinition) rootEntity);
    UITab mainTab = uiOptions.getMainTab(rootTabSet);
    mainTab.setLabel(langCode, DEFAULT_MAIN_TAB_LABEL);
    SurveyObjectsGenerator surveyObjectsGenerator = new SurveyObjectsGenerator();
    surveyObjectsGenerator.addPredefinedObjects(survey);
    return survey;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UITab(org.openforis.collect.metamodel.ui.UITab) Schema(org.openforis.idm.metamodel.Schema) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) SurveyObjectsGenerator(org.openforis.collect.manager.SurveyObjectsGenerator) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 57 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.

the class SchemaLayoutSimpleVM method initTreeModel.

protected void initTreeModel() {
    if (selectedRootEntity == null) {
        rootTabSet = null;
        treeModel = null;
    } else {
        CollectSurvey survey = getSurvey();
        if (survey == null) {
        // TODO session expired...?
        } else {
            UIOptions uiOptions = survey.getUIOptions();
            rootTabSet = uiOptions.getAssignedRootTabSet(selectedRootEntity);
            treeModel = UITabsTreeModel.createInstance(rootTabSet);
        }
    }
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 58 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions 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 59 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.

the class SchemaLayoutSimpleVM method removeTab.

@Command
public void removeTab() {
    String confirmMessageKey = null;
    if (!selectedTab.getTabs().isEmpty()) {
        confirmMessageKey = "survey.layout.tab.remove.confirm.nested_tabs_present";
    } else {
        CollectSurvey survey = getSurvey();
        UIOptions uiOpts = survey.getUIOptions();
        List<NodeDefinition> nodesPerTab = uiOpts.getNodesPerTab(selectedTab, false);
        if (!nodesPerTab.isEmpty()) {
            confirmMessageKey = "survey.layout.tab.remove.confirm.associated_nodes_present";
        }
    }
    if (confirmMessageKey != null) {
        MessageUtil.ConfirmParams params = new MessageUtil.ConfirmParams(new MessageUtil.ConfirmHandler() {

            @Override
            public void onOk() {
                performRemoveSelectedTab();
            }
        }, confirmMessageKey);
        params.setOkLabelKey("global.delete_item");
        MessageUtil.showConfirm(params);
    } else {
        performRemoveSelectedTab();
    }
}
Also used : MessageUtil(org.openforis.collect.designer.util.MessageUtil) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 60 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.

the class SchemaLayoutVM method isAssociatedToTab.

public boolean isAssociatedToTab(NodeDefinition nodeDefn) {
    UIOptions uiOptions = survey.getUIOptions();
    boolean result = uiOptions.isAssociatedToTab(nodeDefn);
    return result;
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions)

Aggregations

UIOptions (org.openforis.collect.metamodel.ui.UIOptions)69 CollectSurvey (org.openforis.collect.model.CollectSurvey)38 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)22 UITab (org.openforis.collect.metamodel.ui.UITab)19 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)18 Layout (org.openforis.collect.metamodel.ui.UIOptions.Layout)10 ArrayList (java.util.ArrayList)9 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)9 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)9 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)9 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)5 Schema (org.openforis.idm.metamodel.Schema)5 Command (org.zkoss.bind.annotation.Command)5 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)5 ExternalizedProperty (org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)4 SchemaNodeData (org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)4 SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)4 SurveyObjectsGenerator (org.openforis.collect.manager.SurveyObjectsGenerator)3 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)3 SurveyObject (org.openforis.idm.metamodel.SurveyObject)3