Search in sources :

Example 1 with LinkIndicators

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());
        }
    });
}
Also used : IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) LinkIndicators(org.activityinfo.legacy.shared.command.LinkIndicators)

Aggregations

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