X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.csg%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fcsg%2Factions%2FAddPrimitiveAction2.java;h=55748e782adb1f3afd99d6ae23411d6cf1a8b223;hb=62fb6eb651ae640336d71746d7bfa79bcfa211df;hp=3a16a21d35362e9f3c310158cb505030dcaa6a5e;hpb=289aaab900078ef56efc8779e4b15830e472149e;p=simantics%2F3d.git 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); + } + } + +}