]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Provide a hook for post-processing after adding a new component 73/4273/2
authorReino Ruusu <reino.ruusu@semantum.fi>
Wed, 3 Jun 2020 07:29:07 +0000 (10:29 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 3 Jun 2020 09:29:44 +0000 (09:29 +0000)
gitlab #131

Change-Id: I3da7ee63cafe3f3f190f57fcc08719cec69ef9c6
(cherry picked from commit 9497b5d9e26b3f6ea39030af6b14f8776a449591)

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();