Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/LifecycleProxy.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 | |
children |
comparison
equal
deleted
inserted
replaced
519:934037edbea0 | 520:1ee452f31187 |
---|---|
1 /* | |
2 * Copyright (c) 2012 TMate Software Ltd | |
3 * | |
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 | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.internal; | |
18 | |
19 import org.tmatesoft.hg.util.Adaptable; | |
20 | |
21 /** | |
22 * Save callback and delegate to another lifecycle instance, if any | |
23 * | |
24 * @author Artem Tikhomirov | |
25 * @author TMate Software Ltd. | |
26 */ | |
27 public class LifecycleProxy implements Lifecycle { | |
28 | |
29 private Callback lifecycleCallback; | |
30 private Lifecycle target; | |
31 | |
32 public LifecycleProxy() { | |
33 } | |
34 | |
35 public LifecycleProxy(Object delegate) { | |
36 init(delegate); | |
37 } | |
38 | |
39 | |
40 public void start(int count, Callback callback, Object token) { | |
41 lifecycleCallback = callback; | |
42 if (target != null) { | |
43 target.start(count, callback, token); | |
44 } | |
45 } | |
46 | |
47 public void finish(Object token) { | |
48 if (target != null) { | |
49 target.finish(token); | |
50 } | |
51 lifecycleCallback = null; | |
52 } | |
53 | |
54 public void init(Object delegate) { | |
55 target = Adaptable.Factory.getAdapter(delegate, Lifecycle.class, null); | |
56 } | |
57 | |
58 public void stop() { | |
59 assert lifecycleCallback != null; | |
60 if (lifecycleCallback != null) { | |
61 lifecycleCallback.stop(); | |
62 } | |
63 } | |
64 } |