Search in sources :

Example 1 with LinkIndicators

use of org.activityinfo.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 link = !linkGraph.linked(source, dest);
    linkButton.toggle(link);
    LinkIndicators update = new LinkIndicators();
    update.setLink(link);
    update.setSourceIndicatorId(source.getId());
    update.setDestIndicatorId(dest.getId());
    if (link) {
        linkGraph.link(sourceDatabaseGrid.getSelectedItem(), source, destDatabaseGrid.getSelectedItem(), dest);
    } else {
        linkGraph.unlink(source, dest);
    }
    destDatabaseGrid.setLinked(linkGraph.destDatabases());
    sourceDatabaseGrid.setLinked(linkGraph.sourceDatabases());
    onDatabaseLinksChanged();
    dispatcher.execute(update, new AsyncCallback<VoidResult>() {

        @Override
        public void onFailure(Throwable caught) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onSuccess(VoidResult result) {
            Info.display(I18N.CONSTANTS.saved(), link ? "Link created" : "Link removed");
        }
    });
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) VoidResult(org.activityinfo.shared.command.result.VoidResult) LinkIndicators(org.activityinfo.shared.command.LinkIndicators)

Aggregations

LinkIndicators (org.activityinfo.shared.command.LinkIndicators)1 VoidResult (org.activityinfo.shared.command.result.VoidResult)1 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1