Revision 44976

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureReferenceSelection.java
1 1
/**
2 2
 * gvSIG. Desktop Geographic Information System.
3 3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
4
 * Copyright (C) 2007-2020 gvSIG Association.
5 5
 *
6 6
 * This program is free software; you can redistribute it and/or
7 7
 * modify it under the terms of the GNU General Public License
......
23 23
 */
24 24
package org.gvsig.fmap.dal.feature.impl;
25 25

  
26
import java.lang.ref.Reference;
27 26
import java.util.Collections;
28 27
import java.util.HashSet;
29 28
import java.util.Iterator;
30 29
import java.util.Set;
31
import java.util.logging.Level;
32
import java.util.logging.Logger;
33 30

  
34 31
import org.gvsig.fmap.dal.DataStore;
35 32
import org.gvsig.fmap.dal.DataStoreNotification;
36 33
import org.gvsig.fmap.dal.exception.DataException;
34
import org.gvsig.fmap.dal.feature.Feature;
37 35
import org.gvsig.fmap.dal.feature.FeatureReference;
38 36
import org.gvsig.fmap.dal.feature.FeatureReferenceSelection;
39 37
import org.gvsig.fmap.dal.feature.FeatureStore;
......
47 45
import org.gvsig.tools.lang.Cloneable;
48 46
import org.gvsig.tools.observer.Observable;
49 47
import org.gvsig.tools.observer.Observer;
50
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable;
51 48
import org.gvsig.tools.observer.impl.DelegateWeakReferencingObservable;
52 49
import org.gvsig.tools.persistence.PersistentState;
53 50
import org.gvsig.tools.persistence.exception.PersistenceException;
54 51
import org.gvsig.tools.visitor.Visitor;
52
import org.slf4j.Logger;
53
import org.slf4j.LoggerFactory;
55 54

  
56 55
/**
57 56
 * Default implementation of a FeatureReferenceSelection, based on the usage of
58 57
 * a java.util.Set to store individual selected or not selected
59 58
 * FeatureReferences, depending on the usage of the {@link #reverse()} method.
60 59
 *
61
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
60
 * @author gvSIG Team
62 61
 */
62
@SuppressWarnings("UseSpecificCatch")
63 63
public class DefaultFeatureReferenceSelection extends AbstractDisposable
64
		implements FeatureReferenceSelection {
64
        implements FeatureReferenceSelection {
65 65

  
66
	public static final String DYNCLASS_PERSISTENT_NAME =
67
			"DefaultFeatureReferenceSelection";
66
    protected static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureReferenceSelection.class);
68 67

  
68
    public static final String DYNCLASS_PERSISTENT_NAME = "DefaultFeatureReferenceSelection";
69

  
69 70
    private Boolean available = null;
70
    
71

  
71 72
    protected SelectionData selectionData = null;
72 73

  
73 74
    private FeatureStore featureStore;
74 75

  
75 76
    private FeatureSelectionHelper helper;
76 77

  
77
	private DelegateWeakReferencingObservable delegateObservable =
78
			new DelegateWeakReferencingObservable(this);
78
    private DelegateWeakReferencingObservable delegateObservable
79
            = new DelegateWeakReferencingObservable(this);
79 80

  
80
	/**
81
	 * Creates a new Selection with the total size of Features from which the
82
	 * selection will be performed.
83
	 *
84
	 * @param featureStore
85
	 *            the FeatureStore of the selected FeatureReferences
86
	 * @throws DataException
87
	 *             if there is an error while getting the total number of
88
	 *             Features of the Store.
89
	 */
81
    /**
82
     * Creates a new Selection with the total size of Features from which the
83
     * selection will be performed.
84
     *
85
     * @param featureStore the FeatureStore of the selected FeatureReferences
86
     * @throws DataException if there is an error while getting the total number
87
     * of Features of the Store.
88
     */
90 89
    public DefaultFeatureReferenceSelection(DefaultFeatureStore featureStore)
91 90
            throws DataException {
92 91
        super();
......
98 97
     * Creates a new Selection with the total size of Features from which the
99 98
     * selection will be performed.
100 99
     *
101
     * @param featureStore
102
     *            the FeatureStore of the selected FeatureReferences
103
     * @param helper
104
     *            to get some information of the Store
105
     * @throws DataException
106
     *             if there is an error while getting the total number of
107
     *             Features of the Store.
100
     * @param featureStore the FeatureStore of the selected FeatureReferences
101
     * @param helper to get some information of the Store
102
     * @throws DataException if there is an error while getting the total number
103
     * of Features of the Store.
108 104
     */
109 105
    public DefaultFeatureReferenceSelection(FeatureStore featureStore,
110 106
            FeatureSelectionHelper helper)
......
114 110
        this.helper = helper;
115 111
    }
116 112

  
117
	/**
118
	 * Constructor used by the persistence manager. Don't use directly. After to
119
	 * invoke this method, the persistence manager calls the the method
120
	 * {@link #loadFromState(PersistentState)} to set the values of the internal
121
	 * attributes that this class needs to work.
122
	 */
123
	public DefaultFeatureReferenceSelection() {
124
		super();
125
	}
113
    /**
114
     * Constructor used by the persistence manager. Don't use directly. After to
115
     * invoke this method, the persistence manager calls the the method
116
     * {@link #loadFromState(PersistentState)} to set the values of the internal
117
     * attributes that this class needs to work.
118
     */
119
    public DefaultFeatureReferenceSelection() {
120
        super();
121
    }
126 122

  
123
    @Override
127 124
    public boolean select(FeatureReference reference) {
128 125
        return select(reference, true);
129 126
    }
130 127

  
131 128
    /**
129
     * @param reference
130
     * @param undoable if the action must be undoable
131
     * @return
132 132
     * @see #select(FeatureReference)
133
     * @param undoable
134
     *            if the action must be undoable
135 133
     */
136 134
    public boolean select(FeatureReference reference, boolean undoable) {
137
        
138 135
        if (reference == null) {
139 136
            throw new IllegalArgumentException("reference");
140 137
        }
141
        
142 138
        if (isSelected(reference)) {
143 139
            return false;
144 140
        }
145

  
146 141
        if (undoable && getFeatureStore().isEditing()) {
147 142
            getCommands().select(this, reference);
148 143
        }
149
        boolean change = false;
150
        if ( this.getData().isReversed()) {
144
        boolean change;
145
        if (this.getData().isReversed()) {
151 146
            change = this.getData().remove(reference);
152 147
        } else {
153 148
            change = this.getData().add(reference);
154 149
        }
155

  
156 150
        if (change) {
157 151
            notifyObservers(DataStoreNotification.SELECTION_CHANGE);
158 152
        }
159

  
160 153
        return change;
161 154
    }
162 155

  
156
    @Override
163 157
    public boolean deselect(FeatureReference reference) {
164 158
        return deselect(reference, true);
165 159
    }
166 160

  
167 161
    /**
162
     * @param reference
163
     * @param undoable if the action must be undoable
164
     * @return
168 165
     * @see #deselect(FeatureReference)
169
     * @param undoable
170
     *            if the action must be undoable
171 166
     */
172 167
    public boolean deselect(FeatureReference reference, boolean undoable) {
173 168
        if (!isSelected(reference)) {
174 169
            return false;
175 170
        }
176

  
177 171
        if (undoable && getFeatureStore().isEditing()) {
178 172
            getCommands().deselect(this, reference);
179 173
        }
180
        boolean change = false;
174
        boolean change;
181 175
        if (this.getData().isReversed()) {
182 176
            change = this.getData().add(reference);
183 177
        } else {
184 178
            change = this.getData().remove(reference);
185 179
        }
186

  
187 180
        if (change) {
188 181
            notifyObservers(DataStoreNotification.SELECTION_CHANGE);
189 182
        }
190

  
191 183
        return change;
192 184
    }
193 185

  
186
    @Override
194 187
    public void selectAll() throws DataException {
195 188
        selectAll(true);
196 189
    }
197 190

  
198 191
    /**
199 192
     * @see #selectAll()
200
     * @param undoable
201
     *            if the action must be undoable
193
     * @param undoable if the action must be undoable
194
     * @throws org.gvsig.fmap.dal.exception.DataException
202 195
     */
203 196
    public void selectAll(boolean undoable) throws DataException {
204 197
        if (undoable && getFeatureStore().isEditing()) {
......
215 208
        notifyObservers(DataStoreNotification.SELECTION_CHANGE);
216 209
    }
217 210

  
211
    @Override
218 212
    public void deselectAll() throws DataException {
219 213
        deselectAll(false);
220 214
    }
221 215

  
222 216
    /**
217
     * @param undoable if the action must be undoable
218
     * @throws org.gvsig.fmap.dal.exception.DataException
223 219
     * @see #deselectAll()
224
     * @param undoable
225
     *            if the action must be undoable
226 220
     */
227 221
    public void deselectAll(boolean undoable) throws DataException {
228
        if( this.selectionData==null ) {
222
        if (this.selectionData == null) {
229 223
            return;
230 224
        }
231 225
        if (undoable && getFeatureStore().isEditing()) {
......
239 233
        if (undoable && getFeatureStore().isEditing()) {
240 234
            getCommands().endComplex();
241 235
        }
242

  
243 236
        notifyObservers(DataStoreNotification.SELECTION_CHANGE);
244 237
    }
245 238

  
239
    @Override
246 240
    public boolean isSelected(FeatureReference reference) {
247
        if( this.selectionData==null ) {
241
        if (this.selectionData == null) {
248 242
            return false;
249 243
        }
250 244
        if (this.getData().isReversed()) {
......
254 248
        }
255 249
    }
256 250

  
251
    @Override
257 252
    public void reverse() {
258 253
        reverse(true);
259 254
    }
260 255

  
261 256
    /**
262 257
     * @see #reverse()
263
     * @param undoable
264
     *            if the action must be undoable
258
     * @param undoable if the action must be undoable
265 259
     */
266 260
    public void reverse(boolean undoable) {
267 261
        if (undoable && getFeatureStore().isEditing()) {
......
270 264
        this.getData().setReversed(!this.getData().isReversed());
271 265
        notifyObservers(DataStoreNotification.SELECTION_CHANGE);
272 266
    }
273
    
267

  
274 268
    public boolean isEmpty() {
275
        if( this.selectionData == null ) {
269
        if (this.selectionData == null) {
276 270
            return true;
277 271
        }
278
        return this.getSelectedCount()==0;
272
        return this.getSelectedCount() == 0;
279 273
    }
280 274

  
275
    @Override
281 276
    public long getSelectedCount() {
282
        if( this.selectionData == null ) {
277
        if (this.selectionData == null) {
283 278
            return 0;
284 279
        }
285 280
        if (this.getData().isReversed()) {
286
                return this.getData().getTotalSize() - this.getData().getSize()
287
                        + helper.getFeatureStoreDeltaSize();
281
            return this.getData().getTotalSize() - this.getData().getSize()
282
                    + helper.getFeatureStoreDeltaSize();
288 283
        } else {
289 284
            return this.getData().getSize();
290 285
        }
291 286
    }
292 287

  
288
    @Override
293 289
    public Iterator referenceIterator() {
294 290
        return Collections.unmodifiableSet(this.getData().getSelected())
295 291
                .iterator();
296 292
    }
297 293

  
298
	protected void doDispose() throws BaseException {
299
		delegateObservable.deleteObservers();
300
		deselectAll(false);
294
    @Override
295
    protected void doDispose() throws BaseException {
296
        delegateObservable.deleteObservers();
297
        deselectAll(false);
301 298
    }
302 299

  
300
    @Override
303 301
    public boolean isFromStore(DataStore store) {
304 302
        return featureStore.equals(store);
305 303
    }
306 304

  
305
    @Override
307 306
    public void accept(Visitor visitor) throws BaseException {
308
        if( this.selectionData==null ) {
307
        if (this.selectionData == null) {
309 308
            return;
310
        }        
311
        for (Iterator iter = this.getData().getSelected().iterator(); iter
312
                .hasNext();) {
309
        }
310
        for (Iterator iter = this.getData().getSelected().iterator(); iter.hasNext();) {
313 311
            visitor.visit(iter.next());
314 312
        }
315 313
    }
316 314

  
317
    public void update(Observable observable,
318
			Object notification) {
315
    @Override
316
    public void update(Observable observable, Object notification) {
319 317
        // If a Feature is deleted, remove it from the selection Set.
320 318
        if (notification instanceof FeatureStoreNotification) {
321 319
            FeatureStoreNotification storeNotif = (FeatureStoreNotification) notification;
......
327 325
    }
328 326

  
329 327
    public SelectionData getData() {
330
        if( selectionData==null ) {
328
        if (selectionData == null) {
331 329
            selectionData = new SelectionData();
332 330
            try {
333 331
                selectionData.setTotalSize(featureStore.getFeatureCount());
334 332
            } catch (DataException ex) {
335
                throw new RuntimeException("Can't initialize SelectionData, don't get the feature count.",ex);
333
                throw new RuntimeException("Can't initialize SelectionData, don't get the feature count.", ex);
336 334
            }
337 335
        }
338 336
        return selectionData;
......
343 341
        notifyObservers(DataStoreNotification.SELECTION_CHANGE);
344 342
    }
345 343

  
344
    @Override
346 345
    public String toString() {
347 346
        return getClass().getName() + ": " + getSelectedCount()
348 347
                + " features selected, reversed = "
......
351 350
    }
352 351

  
353 352
    protected boolean isReversed() {
354
        if( this.selectionData==null ) {
353
        if (this.selectionData == null) {
355 354
            return false;
356 355
        }
357 356
        return this.getData().isReversed();
......
361 360
     * Removes all the stored FeatureRefence objects.
362 361
     */
363 362
    protected void clearFeatureReferences() {
364
        if( this.selectionData==null ) {
363
        if (this.selectionData == null) {
365 364
            return;
366 365
        }
367 366
        this.getData().clear();
368 367
    }
369 368

  
370
	/**
371
	 * Returns the FeatureStore of the selected FeatureReferences.
372
	 *
373
	 * @return the featureStore
374
	 */
369
    /**
370
     * Returns the FeatureStore of the selected FeatureReferences.
371
     *
372
     * @return the featureStore
373
     */
375 374
    protected FeatureStore getFeatureStore() {
376 375
        return featureStore;
377 376
    }
378 377

  
379
	/**
380
	 * Returns the reference to the commands record.
381
	 *
382
	 * @return the reference to the commands record
383
	 */
378
    /**
379
     * Returns the reference to the commands record.
380
     *
381
     * @return the reference to the commands record
382
     */
384 383
    protected FeatureCommandsStack getCommands() {
385 384
        return helper.getFeatureStoreCommandsStack();
386 385
    }
387 386

  
388
	public static class SelectionData implements Cloneable {
387
    public static class SelectionData implements Cloneable {
388

  
389 389
        private Set selected = new HashSet();
390 390

  
391 391
        /**
......
411 411
        }
412 412

  
413 413
        /**
414
         * @param selected
415
         *            the selected to set
414
         * @param selected the selected to set
416 415
         */
417 416
        public void setSelected(Set selected) {
418 417
            this.selected = selected;
......
426 425
        }
427 426

  
428 427
        /**
429
         * @param reversed
430
         *            the reversed to set
428
         * @param reversed the reversed to set
431 429
         */
432 430
        public void setReversed(boolean reversed) {
433 431
            this.reversed = reversed;
......
441 439
        }
442 440

  
443 441
        /**
444
         * @param totalSize
445
         *            the totalSize to set
442
         * @param totalSize the totalSize to set
446 443
         */
447 444
        public void setTotalSize(long totalSize) {
448 445
            this.totalSize = totalSize;
......
468 465
            return selected.size();
469 466
        }
470 467

  
468
        @Override
471 469
        public Object clone() throws CloneNotSupportedException {
472
			SelectionData clone = (SelectionData) super.clone();
473
			// reversed and totalSize already cloned by parent.
474
			// clone the selected Set
475
			clone.selected = new HashSet(selected);
470
            SelectionData clone = (SelectionData) super.clone();
471
            // reversed and totalSize already cloned by parent.
472
            // clone the selected Set
473
            clone.selected = new HashSet(selected);
476 474
            return clone;
477 475
        }
478 476
    }
479 477

  
480
    // *** Persistence ***
478
    @Override
479
    public void saveToState(PersistentState state) throws PersistenceException {
480
        state.set("store", featureStore);
481
        state.set("reversed", this.getData().isReversed());
482
        state.set("totalSize", this.getData().getTotalSize());
483
        state.set("selected", this.getData().getSelected().iterator());
484
    }
481 485

  
482
        @Override
483
	public void saveToState(PersistentState state) throws PersistenceException {
484
		state.set("store", featureStore);
485
		state.set("reversed", this.getData().isReversed());
486
		state.set("totalSize", this.getData().getTotalSize());
487
		state.set("selected", this.getData().getSelected().iterator());
488
	}
486
    @Override
487
    public void loadFromState(PersistentState state)
488
            throws PersistenceException {
489
        SelectionData data = new SelectionData(); // Do not use this.getData()
490
        featureStore = (FeatureStore) state.get("store");
491
        helper = new DefaultFeatureSelectionHelper((DefaultFeatureStore) featureStore);
492
        data.setReversed(state.getBoolean("reversed"));
493
        data.setTotalSize(state.getLong("totalSize"));
494
        Iterator it = state.getIterator("selected");
495
        while (it.hasNext()) {
496
            DefaultFeatureReference ref = (DefaultFeatureReference) it.next();
497
            data.add(ref);
498
        }
489 499

  
490
        @Override
491
	public void loadFromState(PersistentState state)
492
			throws PersistenceException {
493
            SelectionData data = new SelectionData(); // Do not use this.getData()
494
            featureStore = (FeatureStore)state.get("store");
495
            helper = new DefaultFeatureSelectionHelper((DefaultFeatureStore)featureStore);
496
            data.setReversed(state.getBoolean("reversed"));
497
            data.setTotalSize(state.getLong("totalSize"));
498
            Iterator it = state.getIterator("selected");
499
            while (it.hasNext()) {
500
                    DefaultFeatureReference ref = (DefaultFeatureReference) it.next();
501
                    data.add(ref);
502
            }
503

  
504
            /*
500
        /*
505 501
             * If we do not do this, feature store will not listen
506 502
             * to changes in selection after instantiating a
507 503
             * persisted selection. For non-persisted instances,
......
510 506
             * This is not dangerous because "addObserver" only adds
511 507
             * if they were not already added, so future invocations
512 508
             * with same instances will have no effect.
513
             */
514
            this.addObserver((DefaultFeatureStore)featureStore);
515
	}
509
         */
510
        this.addObserver((DefaultFeatureStore) featureStore);
511
    }
516 512

  
517
	public static void registerPersistent() {
518
		DynStruct definition = ToolsLocator.getPersistenceManager().addDefinition(
519
				DefaultFeatureReferenceSelection.class, 
520
				DYNCLASS_PERSISTENT_NAME, 
521
				"DefaultFeatureReferenceSelection Persistent definition",
522
				null, 
523
				null
524
			);
513
    public static void registerPersistent() {
514
        DynStruct definition = ToolsLocator.getPersistenceManager().addDefinition(
515
                DefaultFeatureReferenceSelection.class,
516
                DYNCLASS_PERSISTENT_NAME,
517
                "DefaultFeatureReferenceSelection Persistent definition",
518
                null,
519
                null
520
        );
525 521

  
526
		definition.addDynFieldObject("store").setClassOfValue(FeatureStore.class).setMandatory(true);
527
		definition.addDynFieldBoolean("reversed").setMandatory(true);
528
		definition.addDynFieldLong("totalSize").setMandatory(true);
529
		definition.addDynFieldList("selected").setClassOfItems(DefaultFeatureReference.class).setMandatory(true);
522
        definition.addDynFieldObject("store").setClassOfValue(FeatureStore.class).setMandatory(true);
523
        definition.addDynFieldBoolean("reversed").setMandatory(true);
524
        definition.addDynFieldLong("totalSize").setMandatory(true);
525
        definition.addDynFieldList("selected").setClassOfItems(DefaultFeatureReference.class).setMandatory(true);
530 526

  
531
	}
527
    }
532 528

  
533
	public void addObserver(Observer observer) {
534
		delegateObservable.addObserver(observer);
535
	}
529
    @Override
530
    public void addObserver(Observer observer) {
531
        delegateObservable.addObserver(observer);
532
    }
536 533

  
537
	public void addObserver(Reference ref) {
538
		delegateObservable.addObserver(ref);
539
	}
534
    @Override
535
    public void beginComplexNotification() {
536
        delegateObservable.beginComplexNotification();
537
    }
540 538

  
541
	public void addObservers(BaseWeakReferencingObservable observable) {
542
		delegateObservable.addObservers(observable);
543
	}
539
    @Override
540
    public void deleteObserver(Observer observer) {
541
        delegateObservable.deleteObserver(observer);
542
    }
544 543

  
545
	public void beginComplexNotification() {
546
		delegateObservable.beginComplexNotification();
547
	}
544
    @Override
545
    public void deleteObservers() {
546
        delegateObservable.deleteObservers();
547
    }
548 548

  
549
	public int countObservers() {
550
		return delegateObservable.countObservers();
551
	}
549
    @Override
550
    public void disableNotifications() {
551
        delegateObservable.disableNotifications();
552
    }
552 553

  
553
	public void deleteObserver(Observer observer) {
554
		delegateObservable.deleteObserver(observer);
555
	}
554
    @Override
555
    public void enableNotifications() {
556
        delegateObservable.enableNotifications();
557
    }
556 558

  
557
	public void deleteObserver(Reference ref) {
558
		delegateObservable.deleteObserver(ref);
559
	}
559
    @Override
560
    public void endComplexNotification() {
561
        // We don't want to notify many times in a complex notification
562
        // scenario, so ignore notifications if in complex.
563
        // Only one notification will be sent when the complex notification
564
        // ends.
565
        delegateObservable.notifyObservers(DataStoreNotification.SELECTION_CHANGE);
566
        delegateObservable.endComplexNotification();
567
    }
560 568

  
561
	public void deleteObservers() {
562
		delegateObservable.deleteObservers();
563
	}
569
    public boolean inComplex() {
570
        return delegateObservable.inComplex();
571
    }
564 572

  
565
	public void disableNotifications() {
566
		delegateObservable.disableNotifications();
567
	}
573
    public boolean isEnabledNotifications() {
574
        return delegateObservable.isEnabledNotifications();
575
    }
568 576

  
569
	public void enableNotifications() {
570
		delegateObservable.enableNotifications();
571
	}
577
    public void notifyObservers() {
578
        // We don't want to notify many times in a complex notification
579
        // scenario, so ignore notifications if in complex.
580
        // Only one notification will be sent when the complex notification
581
        // ends.
582
        if (!delegateObservable.inComplex()) {
583
            delegateObservable.notifyObservers();
584
        }
585
    }
572 586

  
573
	public void endComplexNotification() {
574
		// We don't want to notify many times in a complex notification
575
		// scenario, so ignore notifications if in complex.
576
		// Only one notification will be sent when the complex notification
577
		// ends.
578
		delegateObservable
579
				.notifyObservers(DataStoreNotification.SELECTION_CHANGE);
580
		delegateObservable.endComplexNotification();
581
	}
587
    public void notifyObservers(Object arg) {
588
        if (!delegateObservable.inComplex()) {
589
            delegateObservable.notifyObservers(arg);
590
        }
591
    }
582 592

  
583
	public boolean inComplex() {
584
		return delegateObservable.inComplex();
585
	}
586

  
587
	public boolean isEnabledNotifications() {
588
		return delegateObservable.isEnabledNotifications();
589
	}
590

  
591
	public void notifyObservers() {
592
		// We don't want to notify many times in a complex notification
593
		// scenario, so ignore notifications if in complex.
594
		// Only one notification will be sent when the complex notification
595
		// ends.
596
		if (!delegateObservable.inComplex()) {
597
			delegateObservable.notifyObservers();
598
		}
599
	}
600

  
601
	public void notifyObservers(Object arg) {
602
		if (!delegateObservable.inComplex()) {
603
			delegateObservable.notifyObservers(arg);
604
		}
605
	}
606

  
607 593
    @Override
608
	public Object clone() throws CloneNotSupportedException {
609
		DefaultFeatureReferenceSelection clone = (DefaultFeatureReferenceSelection) super
610
				.clone();
611
		// Original observers aren't cloned
612
		clone.delegateObservable = new DelegateWeakReferencingObservable(clone);
613
		// Clone internal data
614
		clone.selectionData = (SelectionData) this.getData().clone();
615
		// featureStore and helper are already swallow cloned by our parent
616
		return clone;
617
	}
594
    public Object clone() throws CloneNotSupportedException {
595
        DefaultFeatureReferenceSelection clone = (DefaultFeatureReferenceSelection) super.clone();
596
        // Original observers aren't cloned
597
        clone.delegateObservable = new DelegateWeakReferencingObservable(clone);
598
        // Clone internal data
599
        clone.selectionData = (SelectionData) this.getData().clone();
600
        // featureStore and helper are already swallow cloned by our parent
601
        return clone;
602
    }
618 603

  
619 604
    @Override
620 605
    public boolean isAvailable() {
621
        if( this.available==null ) {
606
        if (this.available == null) {
622 607
            try {
623 608
                FeatureType type = this.featureStore.getDefaultFeatureType();
624 609
                this.available = type.supportReferences();
......
628 613
        }
629 614
        return this.available;
630 615
    }
631
        
632
        
616

  
633 617
}

Also available in: Unified diff