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);
}
});
}
}
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);
}
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");
}
}
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);
}
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");
}
}
Aggregations