--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in 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.spreadsheet.ui;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.synchronization.graph.ElementWriter;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.spreadsheet.resource.SpreadsheetResource;\r
+\r
+public class SheetWriter implements ElementWriter {\r
+\r
+ public static final Object LABEL = new Object();\r
+\r
+ @Override\r
+ public void addToGraph(WriteGraph g, IElement element, Resource elementResource) throws DatabaseException {\r
+\r
+ final Resource sheetComponent = element.getHint(SheetClass.KEY_SHEET);\r
+ final String rvi = element.getHint(SheetClass.KEY_RVI);\r
+\r
+ if (sheetComponent == null)\r
+ throw new IllegalArgumentException("KEY_SHEET hint not set");\r
+\r
+ if (rvi == null)\r
+ throw new IllegalArgumentException("KEY_RVI hint not set");\r
+\r
+ SpreadsheetResource sr = SpreadsheetResource.getInstance(g);\r
+\r
+ g.claim(elementResource, sr.HasSheet, sheetComponent);\r
+ g.claimLiteral(elementResource, sr.HasRVI, rvi, Bindings.STRING);\r
+\r
+ }\r
+\r
+ @Override\r
+ public void removeFromGraph(WriteGraph graph, Resource elementResource) throws DatabaseException {\r
+ }\r
+\r
+}\r