-/*******************************************************************************\r
- * Copyright (c) 2012 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.modeling.ui.actions;\r
-\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.eclipse.core.runtime.jobs.Job;\r
-import org.simantics.DatabaseJob;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.ActionFactory;\r
-import org.simantics.modeling.NewComponentType;\r
-import org.simantics.modeling.ui.Activator;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class NewComponentTypeAction implements ActionFactory {\r
-\r
- @Override\r
- public Runnable create(Object target) {\r
- if(!(target instanceof Resource))\r
- return null;\r
- final Resource library = (Resource) target;\r
- return new Runnable() {\r
- @Override\r
- public void run() {\r
- Job job = new DatabaseJob("New User Component") {\r
- @Override\r
- protected IStatus run(IProgressMonitor monitor) {\r
- try {\r
- SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- graph.markUndoPoint();\r
- NewComponentType.createComponentType(graph, library);\r
- }\r
- });\r
- return Status.OK_STATUS;\r
- } catch (DatabaseException e) {\r
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create new user component.", e); \r
- }\r
- }\r
- };\r
- job.schedule();\r
- }\r
- };\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 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.modeling.ui.actions;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.simantics.DatabaseJob;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.modeling.NewComponentType;
+import org.simantics.modeling.ui.Activator;
+import org.simantics.ui.SimanticsUI;
+
+public class NewComponentTypeAction implements ActionFactory {
+
+ @Override
+ public Runnable create(Object target) {
+ if(!(target instanceof Resource))
+ return null;
+ final Resource library = (Resource) target;
+ return new Runnable() {
+ @Override
+ public void run() {
+ Job job = new DatabaseJob("New User Component") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ graph.markUndoPoint();
+ NewComponentType.createComponentType(graph, library);
+ }
+ });
+ return Status.OK_STATUS;
+ } catch (DatabaseException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create new user component.", e);
+ }
+ }
+ };
+ job.schedule();
+ }
+ };
+ }
+
+}