1 |
alfonx |
96 |
package skrueger.geotools.selection; |
2 |
|
|
|
3 |
|
|
import java.beans.PropertyChangeListener; |
4 |
|
|
|
5 |
|
|
import javax.swing.ListSelectionModel; |
6 |
|
|
|
7 |
alfonx |
97 |
import org.apache.log4j.Logger; |
8 |
|
|
|
9 |
mojays |
103 |
/** |
10 |
|
|
* The {@link StyledLayerSelectionModelSynchronizer} is the super class for all |
11 |
|
|
* |
12 |
|
|
* @author mojays |
13 |
alfonx |
151 |
* |
14 |
mojays |
103 |
* @param <E> |
15 |
alfonx |
151 |
* The concrete implementation of {@link StyledLayerSelectionModel} |
16 |
|
|
* that this Synchronizer works on. |
17 |
mojays |
103 |
*/ |
18 |
alfonx |
151 |
public abstract class StyledLayerSelectionModelSynchronizer<E extends StyledLayerSelectionModel<?>> |
19 |
|
|
implements PropertyChangeListener { |
20 |
alfonx |
97 |
protected final Logger LOGGER = Logger.getLogger(this.getClass()); |
21 |
alfonx |
96 |
|
22 |
alfonx |
151 |
/** |
23 |
|
|
* Flag to avoid event circles between {@link DpLayerVectorSelectionModel} |
24 |
|
|
* and {@link ListSelectionModel} of the feature table. |
25 |
|
|
*/ |
26 |
|
|
protected boolean selectionChangeCausedByMe = false; |
27 |
|
|
/** |
28 |
|
|
* Holds the selection model of the layer to keep synchronized with the |
29 |
|
|
* feature table. |
30 |
|
|
*/ |
31 |
|
|
protected final E layerSelModel; |
32 |
alfonx |
96 |
|
33 |
alfonx |
151 |
/** |
34 |
|
|
* Allows to enable/disable the Synchronizer's functionality it. |
35 |
|
|
*/ |
36 |
|
|
private boolean enabled = true; |
37 |
|
|
|
38 |
|
|
/** |
39 |
|
|
* Creates a new synchronizer |
40 |
|
|
* |
41 |
|
|
* @param layerSelModel |
42 |
|
|
* layer selection model to keep synchronized with |
43 |
|
|
*/ |
44 |
|
|
protected StyledLayerSelectionModelSynchronizer(E layerSelModel) { |
45 |
|
|
|
46 |
|
|
this.layerSelModel = layerSelModel; |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
/** |
50 |
|
|
* Allows to disable this Synchronizer. Used to disable the selection |
51 |
|
|
* functionality if no corresponding dialog is open. |
52 |
|
|
* |
53 |
|
|
* @param enabled |
54 |
|
|
* <code>true</code> or <code>false</code> |
55 |
|
|
*/ |
56 |
|
|
public void setEnabled(boolean enabled) { |
57 |
|
|
this.enabled = enabled; |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
public boolean isEnabled() { |
61 |
|
|
return enabled; |
62 |
|
|
} |
63 |
|
|
|
64 |
alfonx |
96 |
} |