com.vividsolutions.jump.workbench.ui
Class EditTransaction
java.lang.Object
com.vividsolutions.jump.workbench.ui.EditTransaction
public class EditTransaction
- extends java.lang.Object
Takes care of "rollback" (if any geometries are invalid) and undo,
for PlugIns and CursorTools that modify geometries.
Also:
- warns the user if invalid geometries are found
- invalidates the layer envelope cache
- invalidates the geometry envelope caches
- (undoably) removes features from the layer when their geometries are made empty
- (undoably) adds features to the layer when they start with empty geometries
|
Constructor Summary |
EditTransaction(java.util.Collection features,
java.lang.String name,
Layer layer,
boolean rollingBackInvalidEdits,
boolean allowAddingAndRemovingFeatures,
LayerViewPanel layerViewPanel)
|
EditTransaction(java.util.Collection features,
java.lang.String name,
Layer layer,
boolean rollingBackInvalidEdits,
boolean allowAddingAndRemovingFeatures,
LayerViewPanelContext layerViewPanelContext)
If you want to delete a feature, you can either (1) include the feature in
the features parameter, set allowAddingAndRemovingFeatures to true,
then call #setGeometry(feature, empty geometry); or (2) not include the feature in
the features parameter, instead using #deleteFeature |
|
Method Summary |
void |
clearEnvelopeCaches()
|
boolean |
commit()
|
static boolean |
commit(java.util.Collection editTransactions)
|
static boolean |
commit(java.util.Collection editTransactions,
EditTransaction.SuccessAction successAction)
Commits several EditTransactions if their proposed geometries are all valid. |
boolean |
commit(EditTransaction.SuccessAction successAction)
|
protected UndoableCommand |
createCommand()
|
void |
createFeature(Feature feature)
|
static EditTransaction |
createTransactionOnSelection(EditTransaction.SelectionEditor editor,
SelectionManagerProxy selectionManagerProxy,
LayerViewPanelContext layerViewPanelContext,
java.lang.String name,
Layer layer,
boolean rollingBackInvalidEdits,
boolean allowAddingAndRemovingFeatures)
|
void |
deleteFeature(Feature feature)
|
static int |
emptyGeometryCount(java.util.Collection transactions)
|
static java.util.Map |
featureToNewGeometryMap(EditTransaction.SelectionEditor editor,
SelectionManagerProxy selectionManagerProxy,
Layer layer)
|
Feature |
getFeature(int i)
|
com.vividsolutions.jts.geom.Geometry |
getGeometry(Feature feature)
|
com.vividsolutions.jts.geom.Geometry |
getGeometry(int i)
|
Layer |
getLayer()
|
boolean |
proposedGeometriesValid()
|
void |
setGeometries(java.util.Map featureToGeometryMap)
|
void |
setGeometry(Feature feature,
com.vividsolutions.jts.geom.Geometry geometry)
|
void |
setGeometry(int i,
com.vividsolutions.jts.geom.Geometry geometry)
|
int |
size()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ROLLING_BACK_INVALID_EDITS_KEY
public static final java.lang.String ROLLING_BACK_INVALID_EDITS_KEY
EditTransaction
public EditTransaction(java.util.Collection features,
java.lang.String name,
Layer layer,
boolean rollingBackInvalidEdits,
boolean allowAddingAndRemovingFeatures,
LayerViewPanel layerViewPanel)
EditTransaction
public EditTransaction(java.util.Collection features,
java.lang.String name,
Layer layer,
boolean rollingBackInvalidEdits,
boolean allowAddingAndRemovingFeatures,
LayerViewPanelContext layerViewPanelContext)
- If you want to delete a feature, you can either (1) include the feature in
the features parameter, set allowAddingAndRemovingFeatures to true,
then call #setGeometry(feature, empty geometry); or (2) not include the feature in
the features parameter, instead using #deleteFeature
- Parameters:
name - Display name for undo. Use PlugIn#getName or CursorTool#getName.layer - the layer to which the features belongallowAddingAndRemovingFeatures - whether to treat empty
geometries as indications to add/remove features or as in fact empty geometries
createTransactionOnSelection
public static EditTransaction createTransactionOnSelection(EditTransaction.SelectionEditor editor,
SelectionManagerProxy selectionManagerProxy,
LayerViewPanelContext layerViewPanelContext,
java.lang.String name,
Layer layer,
boolean rollingBackInvalidEdits,
boolean allowAddingAndRemovingFeatures)
featureToNewGeometryMap
public static java.util.Map featureToNewGeometryMap(EditTransaction.SelectionEditor editor,
SelectionManagerProxy selectionManagerProxy,
Layer layer)
getGeometry
public com.vividsolutions.jts.geom.Geometry getGeometry(int i)
getGeometry
public com.vividsolutions.jts.geom.Geometry getGeometry(Feature feature)
setGeometry
public void setGeometry(Feature feature,
com.vividsolutions.jts.geom.Geometry geometry)
setGeometries
public void setGeometries(java.util.Map featureToGeometryMap)
setGeometry
public void setGeometry(int i,
com.vividsolutions.jts.geom.Geometry geometry)
commit
public boolean commit()
commit
public static boolean commit(java.util.Collection editTransactions)
commit
public static boolean commit(java.util.Collection editTransactions,
EditTransaction.SuccessAction successAction)
- Commits several EditTransactions if their proposed geometries are all valid.
Useful for committing changes to several layers because an EditTransaction
handles one layer only. Gets the undo name and the UndoManager
from the first EditTransaction.
- Parameters:
successAction - run after the first execution (i.e. not after redos) if all
proposed geometries are valid (or rollingBackInvalidEdits is false)
commit
public boolean commit(EditTransaction.SuccessAction successAction)
- Parameters:
successAction - will be run if the geometries are valid (or
OptionsPlugIn#isRollingBackInvalidEdits returns false), before the layer-change
events are fired. Useful for animations and other visual indicators which would
be slowed down if the layer-change events were fired first.
- Returns:
- true if all the proposed geometries are valid
clearEnvelopeCaches
public void clearEnvelopeCaches()
proposedGeometriesValid
public boolean proposedGeometriesValid()
createCommand
protected UndoableCommand createCommand()
size
public int size()
getFeature
public Feature getFeature(int i)
createFeature
public void createFeature(Feature feature)
deleteFeature
public void deleteFeature(Feature feature)
- Parameters:
feature - must not have been passed into the constructor
getLayer
public Layer getLayer()
emptyGeometryCount
public static int emptyGeometryCount(java.util.Collection transactions)