-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 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.desktop.ui.internal;\r
-\r
- import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\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.Simantics;\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.request.Configuration;\r
-import org.simantics.modeling.ModelingUtils;\r
-import org.simantics.platform.ui.PlatformUIResource;\r
-import org.simantics.spreadsheet.graph.SpreadsheetGraphUtils;\r
-import org.simantics.spreadsheet.util.SpreadsheetUtils;\r
-\r
-public class NewModel extends AbstractHandler {\r
-\r
- public static Resource execute(WriteGraph graph) throws DatabaseException {\r
- PlatformUIResource PLATFORM = PlatformUIResource.getInstance(graph);\r
- return execute(graph, PLATFORM.Model, null);\r
- }\r
-\r
- @Override\r
- public Object execute(ExecutionEvent event) throws ExecutionException {\r
- Job job = new DatabaseJob("Creating Model") {\r
- @Override\r
- protected IStatus run(IProgressMonitor monitor) {\r
- try {\r
- Simantics.sync(new WriteRequest() {\r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- execute(graph);\r
- }\r
- });\r
- return Status.OK_STATUS;\r
- } catch (DatabaseException e) {\r
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, getName() + " failed.", e);\r
- }\r
- }\r
- };\r
- job.setUser(true);\r
- job.schedule();\r
- return null;\r
- }\r
-\r
- public static Resource execute(WriteGraph graph, Resource type, String name) throws DatabaseException {\r
- Resource model = ModelingUtils.createModel(graph, type, name);\r
- Resource conf = graph.syncRequest(new Configuration(model));\r
-\r
- ModelingUtils.addSCLMainToModel(graph, model, "SCLMain", "");\r
- ModelingUtils.createLocalLibrary(graph, model, "Library");\r
-\r
- Resource book = SpreadsheetGraphUtils.createBook(graph, conf, "Book1");\r
- SpreadsheetUtils.createSheet(graph, book, "Sheet1", new String[] { }, new int[] { 50 });\r
- SpreadsheetUtils.createSheet(graph, book, "Sheet2", new String[] { }, new int[] { 50 });\r
- SpreadsheetUtils.createSheet(graph, book, "Sheet3", new String[] { }, new int[] { 50 });\r
-\r
- return model;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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.desktop.ui.internal;
+
+ import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+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.Simantics;
+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.request.Configuration;
+import org.simantics.modeling.ModelingUtils;
+import org.simantics.platform.ui.PlatformUIResource;
+import org.simantics.spreadsheet.graph.SpreadsheetGraphUtils;
+import org.simantics.spreadsheet.util.SpreadsheetUtils;
+
+public class NewModel extends AbstractHandler {
+
+ public static Resource execute(WriteGraph graph) throws DatabaseException {
+ PlatformUIResource PLATFORM = PlatformUIResource.getInstance(graph);
+ return execute(graph, PLATFORM.Model, null);
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Job job = new DatabaseJob("Creating Model") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ Simantics.sync(new WriteRequest() {
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ execute(graph);
+ }
+ });
+ return Status.OK_STATUS;
+ } catch (DatabaseException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, getName() + " failed.", e);
+ }
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ return null;
+ }
+
+ public static Resource execute(WriteGraph graph, Resource type, String name) throws DatabaseException {
+ Resource model = ModelingUtils.createModel(graph, type, name);
+ Resource conf = graph.syncRequest(new Configuration(model));
+
+ ModelingUtils.addSCLMainToModel(graph, model, "SCLMain", "");
+ ModelingUtils.createLocalLibrary(graph, model, "Library");
+
+ Resource book = SpreadsheetGraphUtils.createBook(graph, conf, "Book1");
+ SpreadsheetUtils.createSheet(graph, book, "Sheet1", new String[] { }, new int[] { 50 });
+ SpreadsheetUtils.createSheet(graph, book, "Sheet2", new String[] { }, new int[] { 50 });
+ SpreadsheetUtils.createSheet(graph, book, "Sheet3", new String[] { }, new int[] { 50 });
+
+ return model;
+ }
+
+}