Revision 39582 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/EditionManager.java
EditionManager.java | ||
---|---|---|
42 | 42 |
import org.gvsig.editing.layers.VectorialLayerEdited; |
43 | 43 |
import org.gvsig.fmap.dal.exception.DataException; |
44 | 44 |
import org.gvsig.fmap.dal.exception.DataRuntimeException; |
45 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
46 |
import org.gvsig.fmap.dal.exception.WriteException; |
|
45 | 47 |
import org.gvsig.fmap.dal.feature.AbstractFeatureRule; |
46 | 48 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
47 | 49 |
import org.gvsig.fmap.dal.feature.Feature; |
... | ... | |
57 | 59 |
import org.gvsig.fmap.geom.GeometryManager; |
58 | 60 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
59 | 61 |
import org.gvsig.fmap.geom.primitive.Envelope; |
62 |
import org.gvsig.fmap.mapcontext.exceptions.CancelEditingLayerException; |
|
60 | 63 |
import org.gvsig.fmap.mapcontext.layers.CancelationException; |
61 | 64 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
62 | 65 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent; |
... | ... | |
111 | 114 |
*/ |
112 | 115 |
public void editLayer(FLyrVect lv, DefaultViewPanel vista) |
113 | 116 |
throws DataException { |
117 |
|
|
118 |
notifyObservers(EditionNotifycation.BEFORE_ENTER_EDIT_LAYER, lv, null, null); |
|
114 | 119 |
|
120 |
|
|
115 | 121 |
CADExtension.initFocus(); |
116 | 122 |
vista.showConsole(); |
117 | 123 |
MapControl mapControl = vista.getMapControl(); |
... | ... | |
132 | 138 |
// ---------------------------- |
133 | 139 |
// this forces a true repaint: |
134 | 140 |
lv.drawValueChanged(LayerEvent.createDrawValuesChangedEvent(lv, "")); |
135 |
|
|
141 |
|
|
142 |
notifyObservers(EditionNotifycation.AFTER_ENTER_EDIT_LAYER, lv, null, null); |
|
136 | 143 |
} |
137 | 144 |
|
138 | 145 |
public void visibilityChanged(LayerEvent e) { |
... | ... | |
740 | 747 |
} |
741 | 748 |
|
742 | 749 |
} |
750 |
|
|
751 |
|
|
752 |
public void stopEditLayer(DefaultViewPanel view, FLyrVect lv, int mode) |
|
753 |
throws CancelEditingLayerException, ReadException { |
|
754 |
|
|
755 |
notifyObservers(EditionNotifycation.BEFORE_EXIT_EDIT_LAYER, lv, null, null); |
|
756 |
VectorialLayerEdited lyrEd = null; |
|
757 |
FeatureStore featureStore = null; |
|
758 |
|
|
759 |
switch (mode) { |
|
760 |
|
|
761 |
case CANCEL_EDITING: |
|
762 |
lyrEd = (VectorialLayerEdited) this.getActiveLayerEdited(); |
|
763 |
lv.getFeatureStore().deleteObserver(lyrEd); |
|
764 |
|
|
765 |
try { |
|
766 |
featureStore = lv.getFeatureStore(); |
|
767 |
|
|
768 |
featureStore.cancelEditing(); |
|
769 |
} catch (ReadException e) { |
|
770 |
throw new CancelEditingLayerException(lv.getName(), e); |
|
771 |
} catch (DataException e) { |
|
772 |
throw new CancelEditingLayerException(lv.getName(), e); |
|
773 |
} |
|
774 |
lv.getFeatureStore().deleteObserver(view); |
|
775 |
lv.removeLayerListener(this); |
|
776 |
|
|
777 |
if (view != null) { |
|
778 |
view.getMapControl().getMapContext().removeLayerDrawListener(lyrEd); |
|
779 |
} |
|
780 |
break; |
|
781 |
case ACCEPT_EDITING: |
|
782 |
lyrEd = (VectorialLayerEdited) this.getActiveLayerEdited(); |
|
783 |
lv.getFeatureStore().deleteObserver(lyrEd); |
|
784 |
featureStore = lv.getFeatureStore(); |
|
785 |
try { |
|
786 |
featureStore.finishEditing(); |
|
787 |
} catch (WriteException e) { |
|
788 |
throw new ReadException(lv.getName(), e); |
|
789 |
} catch (DataException e) { |
|
790 |
throw new ReadException(lv.getName(), e); |
|
791 |
} |
|
792 |
lv.getFeatureStore().deleteObserver(view); |
|
793 |
lv.removeLayerListener(this); |
|
794 |
if (view != null) { |
|
795 |
view.getMapControl().getMapContext().removeLayerDrawListener(lyrEd); |
|
796 |
} |
|
797 |
|
|
798 |
break; |
|
799 |
case CONTINUE_EDITING: |
|
800 |
break; |
|
801 |
} |
|
802 |
|
|
803 |
notifyObservers(EditionNotifycation.AFTER_EXIT_EDIT_LAYER, lv, null, null); |
|
804 |
|
|
805 |
} |
|
743 | 806 |
} |
Also available in: Unified diff