1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.spreadsheet.ui;
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;
22 public class SheetWriter implements ElementWriter {
24 public static final Object LABEL = new Object();
27 public void addToGraph(WriteGraph g, IElement element, Resource elementResource) throws DatabaseException {
29 final Resource sheetComponent = element.getHint(SheetClass.KEY_SHEET);
30 final String rvi = element.getHint(SheetClass.KEY_RVI);
32 if (sheetComponent == null)
33 throw new IllegalArgumentException("KEY_SHEET hint not set");
36 throw new IllegalArgumentException("KEY_RVI hint not set");
38 SpreadsheetResource sr = SpreadsheetResource.getInstance(g);
40 g.claim(elementResource, sr.HasSheet, sheetComponent);
41 g.claimLiteral(elementResource, sr.HasRVI, rvi, Bindings.STRING);
46 public void removeFromGraph(WriteGraph graph, Resource elementResource) throws DatabaseException {