]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet.ui/src/org/simantics/spreadsheet/ui/SheetWriter.java
Database backwards compatibility fix for fail-safe import changes
[simantics/platform.git] / bundles / org.simantics.spreadsheet.ui / src / org / simantics / spreadsheet / ui / SheetWriter.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.spreadsheet.ui;
13
14 import org.simantics.databoard.Bindings;
15 import org.simantics.db.Resource;
16 import org.simantics.db.WriteGraph;
17 import org.simantics.db.exception.DatabaseException;
18 import org.simantics.diagram.synchronization.graph.ElementWriter;
19 import org.simantics.g2d.element.IElement;
20 import org.simantics.spreadsheet.resource.SpreadsheetResource;
21
22 public class SheetWriter implements ElementWriter {
23
24     public static final Object LABEL = new Object();
25
26     @Override
27     public void addToGraph(WriteGraph g, IElement element, Resource elementResource) throws DatabaseException {
28
29         final Resource sheetComponent = element.getHint(SheetClass.KEY_SHEET);
30         final String rvi = element.getHint(SheetClass.KEY_RVI);
31
32         if (sheetComponent == null)
33             throw new IllegalArgumentException("KEY_SHEET hint not set");
34
35         if (rvi == null)
36             throw new IllegalArgumentException("KEY_RVI hint not set");
37
38         SpreadsheetResource sr = SpreadsheetResource.getInstance(g);
39
40         g.claim(elementResource, sr.HasSheet, sheetComponent);
41         g.claimLiteral(elementResource, sr.HasRVI, rvi, Bindings.STRING);
42
43     }
44
45     @Override
46     public void removeFromGraph(WriteGraph graph, Resource elementResource) throws DatabaseException {
47     }
48
49 }