1 package org.simantics.modeling.ui.actions;
3 import org.simantics.Simantics;
4 import org.simantics.db.Resource;
5 import org.simantics.db.WriteGraph;
6 import org.simantics.db.common.request.WriteRequest;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.db.layer0.adapter.ActionFactory;
9 import org.simantics.modeling.userComponent.ComponentTypeCommands;
10 import org.simantics.utils.ui.ErrorLogger;
13 * @author Tuukka Lehtonen
15 public class NewSymbol implements ActionFactory {
18 public Runnable create(Object target) {
19 if (!(target instanceof Resource))
21 final Resource componentType = (Resource) target;
22 return new Runnable() {
26 Simantics.getSession().syncRequest(new WriteRequest() {
28 public void perform(WriteGraph graph) throws DatabaseException {
29 graph.markUndoPoint();
30 ComponentTypeCommands.createSymbol(graph, componentType);
33 } catch (DatabaseException e) {
34 ErrorLogger.defaultLogError(e);