Class EditTransaction

java.lang.Object
com.vividsolutions.jump.workbench.ui.EditTransaction

public class EditTransaction extends 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
  • Field Details

    • ROLLING_BACK_INVALID_EDITS_KEY

      public static final String ROLLING_BACK_INVALID_EDITS_KEY
    • EMPTY_GEOMETRY

      public static final org.locationtech.jts.geom.Geometry EMPTY_GEOMETRY
  • Constructor Details

    • EditTransaction

      public EditTransaction(Collection<Feature> features, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures, LayerViewPanel layerViewPanel)
      Creates a new EditTransaction modifying features.
      Parameters:
      features - features to be modified
      name - display name for undo. Use PlugIn#getName or CursorTool#getName.
      layer - the layer to which the features belong
      rollingBackInvalidEdits - is true if we want to roll back transaction in case of invalid edits
      allowAddingAndRemovingFeatures - whether to treat empty geometries as indications to add/remove features or as in fact empty geometries
      layerViewPanel - the view where editing operations take place.
    • EditTransaction

      public EditTransaction(Collection<Feature> features, 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:
      features - features to be modified
      name - display name for undo. Use PlugIn#getName or CursorTool#getName.
      layer - the layer to which the features belong
      rollingBackInvalidEdits - is true if we want to roll back transaction in case of invalid edits
      allowAddingAndRemovingFeatures - whether to treat empty geometries as indications to add/remove features or as in fact empty geometries
      layerViewPanelContext - the view where editing operations take place.
  • Method Details

    • createTransactionOnSelection

      public static EditTransaction createTransactionOnSelection(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, LayerViewPanelContext layerViewPanelContext, String name, Layer layer, boolean rollingBackInvalidEdits, boolean allowAddingAndRemovingFeatures)
      A utility class creating a transaction able to rollback selected features after they have been edited according to the SelectionEditor definition.
    • featureToNewGeometryMap

      public static Map<Feature, org.locationtech.jts.geom.Geometry> featureToNewGeometryMap(EditTransaction.SelectionEditor editor, SelectionManagerProxy selectionManagerProxy, Layer layer)
      Utility method to create a map between features and there modified geometry.
    • getGeometry

      public org.locationtech.jts.geom.Geometry getGeometry(int i)
      Deprecated.
      Returns the geometry of element i of the transaction. This method is deprecated, now that transaction features are held in a This method is deprecated. Use getGeometry(Feature) instead.
    • getGeometry

      public org.locationtech.jts.geom.Geometry getGeometry(Feature feature)
    • setGeometry

      public void setGeometry(Feature feature, org.locationtech.jts.geom.Geometry geometry)
    • setGeometries

      public void setGeometries(Map<Feature, org.locationtech.jts.geom.Geometry> featureToGeometryMap)
    • setGeometry

      public void setGeometry(int i, org.locationtech.jts.geom.Geometry geometry)
      Deprecated.
      This method is deprecated. Use getGeometry(Feature) instead.
    • commit

      public boolean commit()
    • commit

      public static boolean commit(Collection<EditTransaction> editTransactions)
    • commit

      public static boolean commit(Collection<EditTransaction> 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)
      Deprecated.
      Returns the feature of element i of the transaction. This method is deprecated, use getFeatures() to iterate over the whole set of features.
    • getFeatures

      public Collection<Feature> getFeatures()
      Returns the features modified by this transaction [mmichaud 2011-09-17]
    • createFeature

      public void createFeature(Feature feature)
    • deleteFeature

      public void deleteFeature(Feature feature)
      Parameters:
      feature - must not have been passed into the constructor
    • modifyFeatureGeometry

      public void modifyFeatureGeometry(Feature feature, org.locationtech.jts.geom.Geometry newGeometry)
    • getLayer

      public Layer getLayer()
    • emptyGeometryCount

      public static int emptyGeometryCount(Collection<EditTransaction> transactions)