From: Marko Luukkainen Date: Mon, 12 Aug 2019 10:03:28 +0000 (+0300) Subject: Mark undo pints when committing changes to the graph X-Git-Tag: v1.43.0~227^2~1 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=aae56c70a404cb2198761325eaea81140947b6df;p=simantics%2F3d.git Mark undo pints when committing changes to the graph gitlab #24 Change-Id: I7f3a3a7501acf93b5ffc6e0a92e00fbe5ba38827 --- diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/AddBooleanOpAction2.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/AddBooleanOpAction2.java index e4d82492..be196042 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/AddBooleanOpAction2.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/AddBooleanOpAction2.java @@ -1,80 +1,80 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g3d.csg.actions; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import javax.vecmath.Quat4d; -import javax.vecmath.Vector3d; - -import org.eclipse.jface.action.Action; -import org.simantics.g3d.csg.scenegraph2.CSGparentNode; -import org.simantics.g3d.csg.scenegraph2.CSGrootNode; -import org.simantics.g3d.csg.scenegraph2.ICSGnode; -import org.simantics.utils.ui.ExceptionUtils; - -public class AddBooleanOpAction2 extends Action { - CSGrootNode root; - Class booleanClass; - Collection nodes; - - public AddBooleanOpAction2(CSGrootNode root, Class booleanClass, Collection nodes) { - super(); - String name = booleanClass.getSimpleName(); - if (name.endsWith("Node")) - name = name.substring(0,name.length()-4); - setText(name); - this.booleanClass = booleanClass; - this.nodes = nodes; - this.root = root; - if (nodes.size() != 2) - setEnabled(false); - for (ICSGnode node : nodes) { - if (!node.getParent().equals(root)) - setEnabled(false); - } - } - - @Override - public void run() { - try { - CSGparentNode booleanNode = booleanClass.newInstance(); - Map positions = new HashMap(); - Map orientations = new HashMap(); - for (ICSGnode node : nodes) { - positions.put(node, node.getWorldPosition()); - orientations.put(node, node.getWorldOrientation()); - //root.remChild(node); - node.deattach(); - } - Iterator iter = nodes.iterator(); - booleanNode.addPrimaryChild(iter.next()); - booleanNode.addSecondaryChild(iter.next()); - - String name = root.getUniqueName(booleanNode.getClass().getSimpleName()); - booleanNode.setName(name); - - root.addChild(booleanNode); - for (ICSGnode node : nodes) { - node.setWorldPosition(positions.get(node)); - node.setWorldOrientation(orientations.get(node)); - } - root.getNodeMap().commit(); - } catch (Exception e) { - ExceptionUtils.logAndShowError("Cannot create boolean operation.", e); - } - } - -} +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g3d.csg.actions; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import javax.vecmath.Quat4d; +import javax.vecmath.Vector3d; + +import org.eclipse.jface.action.Action; +import org.simantics.g3d.csg.scenegraph2.CSGparentNode; +import org.simantics.g3d.csg.scenegraph2.CSGrootNode; +import org.simantics.g3d.csg.scenegraph2.ICSGnode; +import org.simantics.utils.ui.ExceptionUtils; + +public class AddBooleanOpAction2 extends Action { + CSGrootNode root; + Class booleanClass; + Collection nodes; + + public AddBooleanOpAction2(CSGrootNode root, Class booleanClass, Collection nodes) { + super(); + String name = booleanClass.getSimpleName(); + if (name.endsWith("Node")) + name = name.substring(0,name.length()-4); + setText(name); + this.booleanClass = booleanClass; + this.nodes = nodes; + this.root = root; + if (nodes.size() != 2) + setEnabled(false); + for (ICSGnode node : nodes) { + if (!node.getParent().equals(root)) + setEnabled(false); + } + } + + @Override + public void run() { + try { + CSGparentNode booleanNode = booleanClass.newInstance(); + Map positions = new HashMap(); + Map orientations = new HashMap(); + for (ICSGnode node : nodes) { + positions.put(node, node.getWorldPosition()); + orientations.put(node, node.getWorldOrientation()); + //root.remChild(node); + node.deattach(); + } + Iterator iter = nodes.iterator(); + booleanNode.addPrimaryChild(iter.next()); + booleanNode.addSecondaryChild(iter.next()); + + String name = root.getUniqueName(booleanNode.getClass().getSimpleName()); + booleanNode.setName(name); + + root.addChild(booleanNode); + for (ICSGnode node : nodes) { + node.setWorldPosition(positions.get(node)); + node.setWorldOrientation(orientations.get(node)); + } + root.getNodeMap().commit("Add Boolean Op"); + } catch (Exception e) { + ExceptionUtils.logAndShowError("Cannot create boolean operation.", e); + } + } + +} diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/AddPrimitiveAction2.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/AddPrimitiveAction2.java index 3a16a21d..55748e78 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/AddPrimitiveAction2.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/AddPrimitiveAction2.java @@ -1,46 +1,46 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g3d.csg.actions; - -import org.eclipse.jface.action.Action; -import org.simantics.g3d.csg.scenegraph2.CSGnode; -import org.simantics.g3d.csg.scenegraph2.CSGrootNode; -import org.simantics.utils.ui.ExceptionUtils; - -public class AddPrimitiveAction2 extends Action { - - CSGrootNode root; - Class primitiveClass; - public AddPrimitiveAction2(CSGrootNode root, Class primitiveClass) { - super(); - String name = primitiveClass.getSimpleName(); - if (name.endsWith("Node")) - name = name.substring(0,name.length()-4); - setText(name); - this.primitiveClass = primitiveClass; - this.root = root; - } - - @Override - public void run() { - try { - CSGnode node = primitiveClass.newInstance(); - String name = root.getUniqueName(node.getClass().getSimpleName()); - node.setName(name); - root.addChild(node); - root.getNodeMap().commit(); - } catch (Exception e) { - ExceptionUtils.logAndShowError("Cannot create primitive.", e); - } - } - -} +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g3d.csg.actions; + +import org.eclipse.jface.action.Action; +import org.simantics.g3d.csg.scenegraph2.CSGnode; +import org.simantics.g3d.csg.scenegraph2.CSGrootNode; +import org.simantics.utils.ui.ExceptionUtils; + +public class AddPrimitiveAction2 extends Action { + + CSGrootNode root; + Class primitiveClass; + public AddPrimitiveAction2(CSGrootNode root, Class primitiveClass) { + super(); + String name = primitiveClass.getSimpleName(); + if (name.endsWith("Node")) + name = name.substring(0,name.length()-4); + setText(name); + this.primitiveClass = primitiveClass; + this.root = root; + } + + @Override + public void run() { + try { + CSGnode node = primitiveClass.newInstance(); + String name = root.getUniqueName(node.getClass().getSimpleName()); + node.setName(name); + root.addChild(node); + root.getNodeMap().commit("Add primitive"); + } catch (Exception e) { + ExceptionUtils.logAndShowError("Cannot create primitive.", e); + } + } + +} diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/SplitBooleanOpAction2.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/SplitBooleanOpAction2.java index ace2262c..cebe1b45 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/SplitBooleanOpAction2.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/actions/SplitBooleanOpAction2.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g3d.csg.actions; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import javax.vecmath.Quat4d; -import javax.vecmath.Vector3d; - -import org.eclipse.jface.action.Action; -import org.simantics.g3d.csg.scenegraph2.CSGparentNode; -import org.simantics.g3d.csg.scenegraph2.CSGrootNode; -import org.simantics.g3d.csg.scenegraph2.ICSGnode; - -public class SplitBooleanOpAction2 extends Action { - private CSGrootNode root; - private CSGparentNode booleanOp; - - public SplitBooleanOpAction2(CSGrootNode root, CSGparentNode booleanOp) { - super(); - setText("Split"); - this.booleanOp = booleanOp; - this.root = root; - } - - @Override - public void run() { - Collection nodes = new ArrayList(); - nodes.addAll(booleanOp.getPrimaryChild()); - nodes.addAll(booleanOp.getSecondaryChild()); - Map positions = new HashMap(); - Map orientations = new HashMap(); - for (ICSGnode node : nodes) { - positions.put(node, node.getWorldPosition()); - orientations.put(node, node.getWorldOrientation()); - node.deattach(); - } - for (ICSGnode node : nodes) { - root.addChild(node); - node.setWorldPosition(positions.get(node)); - node.setWorldOrientation(orientations.get(node)); - } - root.remChild(booleanOp); - root.getNodeMap().commit(); - - } - -} +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g3d.csg.actions; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import javax.vecmath.Quat4d; +import javax.vecmath.Vector3d; + +import org.eclipse.jface.action.Action; +import org.simantics.g3d.csg.scenegraph2.CSGparentNode; +import org.simantics.g3d.csg.scenegraph2.CSGrootNode; +import org.simantics.g3d.csg.scenegraph2.ICSGnode; + +public class SplitBooleanOpAction2 extends Action { + private CSGrootNode root; + private CSGparentNode booleanOp; + + public SplitBooleanOpAction2(CSGrootNode root, CSGparentNode booleanOp) { + super(); + setText("Split"); + this.booleanOp = booleanOp; + this.root = root; + } + + @Override + public void run() { + Collection nodes = new ArrayList(); + nodes.addAll(booleanOp.getPrimaryChild()); + nodes.addAll(booleanOp.getSecondaryChild()); + Map positions = new HashMap(); + Map orientations = new HashMap(); + for (ICSGnode node : nodes) { + positions.put(node, node.getWorldPosition()); + orientations.put(node, node.getWorldOrientation()); + node.deattach(); + } + for (ICSGnode node : nodes) { + root.addChild(node); + node.setWorldPosition(positions.get(node)); + node.setWorldOrientation(orientations.get(node)); + } + root.remChild(booleanOp); + root.getNodeMap().commit("Split"); + + } + +} diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/RemoveAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/RemoveAction.java index df74d2a1..8fcb9368 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/RemoveAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/RemoveAction.java @@ -1,53 +1,53 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g3d.vtk.action; - -import org.eclipse.jface.action.Action; -import org.simantics.g3d.scenegraph.IG3DNode; -import org.simantics.g3d.scenegraph.structural.IStructuralNode; -import org.simantics.g3d.vtk.Activator; -import org.simantics.g3d.vtk.common.VTKNodeMap; - -public class RemoveAction extends Action { - - private VTKNodeMap nodeMap; - protected IG3DNode node; - - public RemoveAction(VTKNodeMap nodeMap) { - setText("Remove"); - setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/delete.png")); - this.nodeMap = nodeMap; - } - - public void setNode(IG3DNode node) { - this.node = node; - setEnabled(isRemovable(node)); - } - - public boolean isRemovable(IG3DNode node) { - if ((node instanceof IStructuralNode) && ((IStructuralNode)node).isPartOfInstantiatedModel() && !((IStructuralNode)node).isInstantiatedModelRoot()) - return false; - return true; - } - - @Override - public void run() { - - doRemove(node); - nodeMap.commit(); - node = null; - } - - protected void doRemove(IG3DNode node) { - node.remove(); - } -} +/******************************************************************************* + * Copyright (c) 2012, 2013 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g3d.vtk.action; + +import org.eclipse.jface.action.Action; +import org.simantics.g3d.scenegraph.IG3DNode; +import org.simantics.g3d.scenegraph.structural.IStructuralNode; +import org.simantics.g3d.vtk.Activator; +import org.simantics.g3d.vtk.common.VTKNodeMap; + +public class RemoveAction extends Action { + + private VTKNodeMap nodeMap; + protected IG3DNode node; + + public RemoveAction(VTKNodeMap nodeMap) { + setText("Remove"); + setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/delete.png")); + this.nodeMap = nodeMap; + } + + public void setNode(IG3DNode node) { + this.node = node; + setEnabled(isRemovable(node)); + } + + public boolean isRemovable(IG3DNode node) { + if ((node instanceof IStructuralNode) && ((IStructuralNode)node).isPartOfInstantiatedModel() && !((IStructuralNode)node).isInstantiatedModelRoot()) + return false; + return true; + } + + @Override + public void run() { + + doRemove(node); + nodeMap.commit("Remove"); + node = null; + } + + protected void doRemove(IG3DNode node) { + node.remove(); + } +} diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/RotateAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/RotateAction.java index f7ffc553..4f62533b 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/RotateAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/RotateAction.java @@ -135,7 +135,7 @@ public class RotateAction extends vtkAwtAction{ public void deattach() { node = null; - nodeMap.commit(); + nodeMap.commit("Rotate"); deattachUI(); super.deattach(); panel.repaint(); diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/TranslateAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/TranslateAction.java index d7d81331..1b07afa8 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/TranslateAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/awt/TranslateAction.java @@ -93,7 +93,7 @@ public class TranslateAction extends vtkAwtAction{ public void deattach() { node = null; - nodeMap.commit(); + nodeMap.commit("Translate"); deattachUI(); super.deattach(); panel.repaint(); diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java index 646fbe41..dab2040e 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java @@ -26,6 +26,7 @@ import org.simantics.db.WriteGraph; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.Layer0Utils; import org.simantics.g3d.ontology.G3D; import org.simantics.g3d.scenegraph.RenderListener; import org.simantics.g3d.scenegraph.base.INode; @@ -204,10 +205,12 @@ public abstract class AbstractVTKNodeMap implements VTKNodeMap< private Set graphModified = new HashSet(); private boolean requestCommit = false; + private String commitMessage = null; @Override - public void commit() { + public void commit(String message) { requestCommit = true; + commitMessage = message; } protected void doCommit() { @@ -216,6 +219,11 @@ public abstract class AbstractVTKNodeMap implements VTKNodeMap< @Override public void perform(WriteGraph graph) throws DatabaseException { commit(graph); + if (commitMessage != null) { + Layer0Utils.addCommentMetadata(graph, commitMessage); + commitMessage = null; + } + graph.markUndoPoint(); } }, new Callback() { @@ -267,7 +275,7 @@ public abstract class AbstractVTKNodeMap implements VTKNodeMap< } if (mapping.isRangeModified()) - commit(); + commit("Graph sync"); } @Override diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/RotateAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/RotateAction.java index 1b2d7914..c45316e8 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/RotateAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/RotateAction.java @@ -141,7 +141,7 @@ public class RotateAction extends vtkSwtAction{ public void deattach() { node = null; - nodeMap.commit(); + nodeMap.commit("Rotate"); deattachUI(); super.deattach(); panel.refresh(); diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/TranslateAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/TranslateAction.java index b6b5ca7f..83c434bb 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/TranslateAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/TranslateAction.java @@ -99,7 +99,7 @@ public class TranslateAction extends vtkSwtAction{ public void deattach() { node = null; - nodeMap.commit(); + nodeMap.commit("Translate"); deattachUI(); super.deattach(); panel.refresh(); diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java b/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java index c3d7376f..a3fca78b 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java @@ -799,7 +799,7 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri if (DEBUG)System.err.println("CELL SET VALUE: " + element + " " + value); manipulator.setValue((String)value,index); viewer.refresh(item); - nodeMap.commit(); + nodeMap.commit("Set " + item.id + " value to " + value); } diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMap.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMap.java index 6324d90e..36ee73a3 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMap.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMap.java @@ -31,7 +31,7 @@ public interface NodeMap { /** * Commit changes to the database. */ - public void commit(); + public void commit(String message); /** 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 a4398a54..18087b68 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java @@ -117,7 +117,7 @@ public class AddComponentAction extends vtkSwtAction { public void deattach() { // deactivate(); component = null; - nodeMap.commit(); + nodeMap.commit("Add component"); deattachUI(); super.deattach(); panel.refresh(); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddEquipmentAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddEquipmentAction.java index 6c66909a..ae7603ca 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddEquipmentAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddEquipmentAction.java @@ -25,7 +25,7 @@ public class AddEquipmentAction extends Action { String n = root.getUniqueName(item.getName()); equipment.setName(n); root.addChild(equipment); - root.getNodeMap().commit(); + root.getNodeMap().commit("Add equipment " + n); } catch (Exception e) { ExceptionUtils.logAndShowError("Cannot create equipment",e); } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddNozzleAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddNozzleAction.java index e6b8ecd6..34069d95 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddNozzleAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddNozzleAction.java @@ -41,7 +41,7 @@ public class AddNozzleAction extends Action { equipment.addChild(nozzle); //root.addChild(nozzle); root.addChild(pipeRun); - root.getNodeMap().commit(); + root.getNodeMap().commit("Add nozzle " + n); } catch (Exception e) { ExceptionUtils.logAndShowError("Cannot create equipment",e); } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java index da7beb45..17455a32 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java @@ -111,7 +111,7 @@ public class RoutePipeAction extends vtkSwtAction { public void deattach() { deactivate(); startComponent = null; - nodeMap.commit(); + nodeMap.commit("Route pipe"); deattachUI(); super.deattach(); panel.refresh(); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java index 23096f7e..7ea42d59 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/TranslateInlineAction.java @@ -46,9 +46,9 @@ public class TranslateInlineAction extends TranslateAction{ setEnabled(false); return; } - if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixed()) + if (prev.getControlPoint().isInline() && !prev.getControlPoint().isFixed() && prev.getPrevious() != null) prev = prev.getPrevious(); - if (next.getControlPoint().isInline() && !next.getControlPoint().isFixed()) { + if (next.getControlPoint().isInline() && !next.getControlPoint().isFixed() && next.getNext() != null) { next = next.getNext(); } Point3d ns = new Point3d(); @@ -61,8 +61,14 @@ public class TranslateInlineAction extends TranslateAction{ dir.normalize(); // We may have offsets in the path leg, hence we have to project the coordinates. Vector3d wp = node.getWorldPosition(); - s = MathTools.closestPointOnStraight(pe, wp, dir); - e = MathTools.closestPointOnStraight(ns, wp, dir); + if (prev.getControlPoint().isVariableLength()) + s = MathTools.closestPointOnStraight(ps, wp, dir); + else + s = MathTools.closestPointOnStraight(pe, wp, dir); + if (next.getControlPoint().isVariableLength()) + e = MathTools.closestPointOnStraight(ne, wp, dir); + else + e = MathTools.closestPointOnStraight(ns, wp, dir); // Remove component's own space from end points to get actual movement range double l = comp.getControlPoint().getInlineLength(); Vector3d ld = new Vector3d(dir); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/editor/P3DNodeMap.java b/org.simantics.plant3d/src/org/simantics/plant3d/editor/P3DNodeMap.java index ea379520..46f3bf64 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/editor/P3DNodeMap.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/editor/P3DNodeMap.java @@ -199,10 +199,10 @@ public class P3DNodeMap extends AbstractVTKNodeMap { } @Override - public void commit() { + public void commit(String commitMessage) { validate(); // System.out.println("Graph commit"); - super.commit(); + super.commit(commitMessage); } @Override