use of org.activityinfo.legacy.shared.command.LinkIndicators in project activityinfo by bedatadriven.
the class IndicatorLinkPage method onToggleLink.
protected void onToggleLink() {
IndicatorDTO source = sourceIndicatorGrid.getSelectedItem();
IndicatorDTO dest = destIndicatorGrid.getSelectedItem();
final boolean isLinked = !linkGraph.linked(source, dest);
linkButton.toggle(isLinked);
LinkIndicators updateCommand = new LinkIndicators();
updateCommand.setLink(isLinked);
updateCommand.setSourceIndicatorId(source.getId());
updateCommand.setDestIndicatorId(dest.getId());
if (isLinked) {
linkGraph.link(sourceDatabaseGrid.getSelectedItem(), source, destDatabaseGrid.getSelectedItem(), dest);
} else {
linkGraph.unlink(source, dest);
}
destDatabaseGrid.setLinked(linkGraph.destDatabases());
sourceDatabaseGrid.setLinked(linkGraph.sourceDatabases());
onDatabaseLinksChanged();
dispatcher.execute(updateCommand, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
Log.error(caught.getMessage(), caught);
}
@Override
public void onSuccess(VoidResult result) {
Info.displayText(I18N.CONSTANTS.saved(), isLinked ? I18N.CONSTANTS.linkCreated() : I18N.CONSTANTS.linkRemoved());
}
});
}
Aggregations