Search in sources :

Example 26 with Command

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

the class SurveySelectVM method publishSelectedSurvey.

@Command
public void publishSelectedSurvey(@ContextParam(ContextType.BINDER) final Binder binder) throws IOException {
    final CollectSurvey survey = loadSelectedSurvey();
    final CollectSurvey publishedSurvey = selectedSurvey.isPublished() ? surveyManager.getByUri(survey.getUri()) : null;
    SurveyValidator validator = getSurveyValidator(survey);
    SurveyValidationResults validationResults = validator.validateCompatibility(publishedSurvey, survey);
    if (validationResults.isOk()) {
        askConfirmThenPublishSurvey(survey, binder);
    } else {
        final Window validationResultsPopUp = SurveyValidationResultsVM.showPopUp(validationResults, !validationResults.hasErrors());
        validationResultsPopUp.addEventListener(SurveyValidationResultsVM.CONFIRM_EVENT_NAME, new EventListener<ConfirmEvent>() {

            public void onEvent(ConfirmEvent event) throws Exception {
                CollectSurvey survey = loadSelectedSurvey();
                askConfirmThenPublishSurvey(survey, binder);
                closePopUp(validationResultsPopUp);
            }
        });
    }
}
Also used : SurveyValidator(org.openforis.collect.manager.validation.SurveyValidator) CollectEarthSurveyValidator(org.openforis.collect.manager.validation.CollectEarthSurveyValidator) SurveyValidationResults(org.openforis.collect.manager.validation.SurveyValidator.SurveyValidationResults) Window(org.zkoss.zul.Window) ConfirmEvent(org.openforis.collect.designer.viewmodel.SurveyValidationResultsVM.ConfirmEvent) CollectSurvey(org.openforis.collect.model.CollectSurvey) SurveyStoreException(org.openforis.collect.persistence.SurveyStoreException) IOException(java.io.IOException) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 27 with Command

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

the class EditableListOfNodesVM method setLayout.

@Command
@NotifyChange({ "nodesPerTab" })
public void setLayout(@BindingParam("type") String type, @BindingParam("node") EntityDefinition node) {
    UIOptions uiOpts = getUIOptions();
    Layout layout = Layout.valueOf(type);
    uiOpts.setLayout(node, layout);
}
Also used : Layout(org.openforis.collect.metamodel.ui.UIOptions.Layout) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 28 with Command

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

the class TabsGroupVM method removeTab.

@Command
@NotifyChange({ "tabs" })
public void removeTab(@BindingParam("tab") UITab tab) {
    if (tab.getTabs().isEmpty()) {
        SessionStatus sessionStatus = getSessionStatus();
        CollectSurvey survey = sessionStatus.getSurvey();
        UIOptions uiOpts = survey.getUIOptions();
        List<NodeDefinition> nodesPerTab = uiOpts.getNodesPerTab(tab, false);
        if (nodesPerTab.isEmpty()) {
            UITabSet parent = tab.getParent();
            parent.removeTab(tab);
            postTabChangedCommand(parent);
        } else {
            MessageUtil.showWarning("survey.layout.tab.remove.error.associated_nodes_present");
        }
    } else {
        MessageUtil.showWarning("survey.layout.tab.remove.error.nested_tabs_present");
    }
}
Also used : SessionStatus(org.openforis.collect.designer.session.SessionStatus) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) 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 29 with Command

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

the class TabsGroupVM method addTab.

@Command
@NotifyChange({ "tabs" })
public void addTab() {
    UIOptions uiOptions = tabSet.getUIOptions();
    UITab tab = uiOptions.createTab();
    String tabName = generateNewTabName(tabSet);
    tab.setName(tabName);
    tabSet.addTab(tab);
    postTabChangedCommand(tabSet);
    openTabLabelEditPopUp(tab);
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 30 with Command

use of org.zkoss.bind.annotation.Command in project compss by bsc-wdc.

the class CurrentGraphViewModel method update.

@Command
@NotifyChange("graph")
void update(Application monitoredApp) {
    logger.debug("Updating Graph...");
    String monitorLocation = monitoredApp.getPath() + Constants.MONITOR_CURRENT_DOT_FILE;
    File monitorFile = new File(monitorLocation);
    if (monitorFile.exists()) {
        if (monitorFile.length() > 45) {
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            String modifiedTime = sdf.format(monitorFile.lastModified());
            if (!modifiedTime.equals(graphLastUpdateTime)) {
                try {
                    String graphSVG = File.separator + "svg" + File.separator + monitoredApp.getName() + "_" + Constants.GRAPH_FILE_NAME;
                    graph = loadGraph(monitorLocation, graphSVG);
                    graphLastUpdateTime = modifiedTime;
                } catch (Exception e) {
                    graph = Constants.GRAPH_NOT_FOUND_PATH;
                    graphLastUpdateTime = "";
                    logger.error("Graph generation error");
                }
            } else {
                logger.debug("Graph is already loaded");
            }
        } else {
            // The empty graph has length = 45
            graph = Constants.GRAPH_EXECUTION_DONE_PATH;
            graphLastUpdateTime = "";
        }
    } else {
        graph = Constants.GRAPH_NOT_FOUND_PATH;
        graphLastUpdateTime = "";
        logger.debug("Graph file not found");
    }
}
Also used : File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) IOException(java.io.IOException) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command)

Aggregations

Command (org.zkoss.bind.annotation.Command)62 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)44 NotifyChange (org.zkoss.bind.annotation.NotifyChange)26 File (java.io.File)12 CollectSurvey (org.openforis.collect.model.CollectSurvey)10 MessageUtil (org.openforis.collect.designer.util.MessageUtil)9 UITab (org.openforis.collect.metamodel.ui.UITab)6 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)6 FileInputStream (java.io.FileInputStream)5 ConfirmParams (org.openforis.collect.designer.util.MessageUtil.ConfirmParams)5 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)5 SurveyObject (org.openforis.idm.metamodel.SurveyObject)5 Media (org.zkoss.util.media.Media)5 Window (org.zkoss.zul.Window)5 UserCredential (es.bsc.compss.ui.auth.UserCredential)4 IOException (java.io.IOException)4 Date (java.util.Date)4 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)4 SessionStatus (org.openforis.collect.designer.session.SessionStatus)3 ConfirmHandler (org.openforis.collect.designer.util.MessageUtil.ConfirmHandler)3