From: Reino Ruusu Date: Wed, 3 Jun 2020 07:29:07 +0000 (+0300) Subject: Provide a hook for post-processing after adding a new component X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F73%2F4273%2F2;p=simantics%2F3d.git Provide a hook for post-processing after adding a new component gitlab #131 Change-Id: I3da7ee63cafe3f3f190f57fcc08719cec69ef9c6 (cherry picked from commit 9497b5d9e26b3f6ea39030af6b14f8776a449591) --- diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java index dae8c629..b82a097c 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java @@ -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();