comparison src/org/tmatesoft/hg/internal/IterateControlMediator.java @ 520:1ee452f31187

Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 21 Dec 2012 21:20:26 +0100
parents f9f3e9b67ccc
children
comparison
equal deleted inserted replaced
519:934037edbea0 520:1ee452f31187
1 /* 1 /*
2 * Copyright (c) 2011 TMate Software Ltd 2 * Copyright (c) 2011-2012 TMate Software Ltd
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License. 6 * the Free Software Foundation; version 2 of the License.
7 * 7 *
26 * @author TMate Software Ltd. 26 * @author TMate Software Ltd.
27 */ 27 */
28 public class IterateControlMediator { 28 public class IterateControlMediator {
29 29
30 private final CancelSupport src; 30 private final CancelSupport src;
31 private Callback receiver; 31 private final Callback receiver;
32 private CancelledException cancellation;
32 33
33 public IterateControlMediator(CancelSupport source, Lifecycle.Callback target) { 34 public IterateControlMediator(CancelSupport source, Lifecycle.Callback target) {
34 assert target != null; 35 assert target != null;
35 src = source; 36 src = source;
36 receiver = target; 37 receiver = target;
38 39
39 public boolean checkCancelled() { 40 public boolean checkCancelled() {
40 if (src == null) { 41 if (src == null) {
41 return false; 42 return false;
42 } 43 }
44 if (cancellation != null) {
45 return true;
46 }
43 try { 47 try {
44 src.checkCancelled(); 48 src.checkCancelled();
45 return false; 49 return false;
46 } catch (CancelledException ex) { 50 } catch (CancelledException ex) {
47 receiver.stop(); 51 receiver.stop();
52 cancellation = ex;
48 return true; 53 return true;
49 } 54 }
50 } 55 }
51 56
52 public void stop() { 57 public void stop() {
53 receiver.stop(); 58 receiver.stop();
54 } 59 }
60
61 public CancelledException getCancelException() {
62 return cancellation;
63 }
55 } 64 }