]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Provide a hook for post-processing after adding a new component 66/4266/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Wed, 3 Jun 2020 07:29:07 +0000 (10:29 +0300)
committerReino Ruusu <reino.ruusu@semantum.fi>
Wed, 3 Jun 2020 07:29:07 +0000 (10:29 +0300)
gitlab #131

Change-Id: I3da7ee63cafe3f3f190f57fcc08719cec69ef9c6

org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java

index dae8c629b4335a7bfacb88503086d7d34285311b..b82a097cb7b250b554588e942ad832c8f358ff21 100644 (file)
@@ -206,12 +206,23 @@ public class AddComponentAction extends vtkSwtAction {
                        inst.insertPosition = insertPosition;
                        inst.rotationAngle = rotationAngle;
                        inst.position = position;
-                       ComponentUtils.addComponent(root, component, inst);
+                       PipelineComponent newComponent = ComponentUtils.addComponent(root, component, inst);
+                       componentAdded(newComponent);
                } catch (Exception e) {
                        ExceptionUtils.logAndShowError("Cannot add component", e);
                }
        }
        
+       /**
+        * This method does nothing, but can be overridden by a subclass to do additional
+        * post-processing for a newly added component.
+        * 
+        * @param newComponent  A newly added pipeline component
+        */
+       protected void componentAdded(PipelineComponent newComponent) {
+               // Nothing to do here
+       }
+
        public boolean mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON1) {
                        int type = panel.getPickType();