1 package org.simantics.spreadsheet.graph.adapter;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.WriteGraph;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.layer0.variable.StandardGraphChildVariable;
8 import org.simantics.db.layer0.variable.Variable;
9 import org.simantics.spreadsheet.common.cell.VariableCellEditor;
11 public class CellVariable extends StandardGraphChildVariable {
13 public CellVariable(Variable parent, Resource resource) throws DatabaseException {
14 super(parent, null, resource);
18 public String getLabel(ReadGraph graph) throws DatabaseException {
22 @SuppressWarnings("unchecked")
23 protected <T> T tryAdapt(ReadGraph graph, Class<T> clazz) throws DatabaseException {
24 if(VariableCellEditor.class == clazz) {
25 return (T)new VariableCellEditor() {
28 public void edit(WriteGraph graph, Variable cell, String text) throws DatabaseException {
32 public void copy(WriteGraph graph, Variable cell, String location) throws DatabaseException {
41 public <T> T adapt(ReadGraph graph, Class<T> clazz) throws DatabaseException {
42 T t = tryAdapt(graph, clazz);
43 return t != null ? t : super.adapt(graph, clazz);
47 public <T> T adaptPossible(ReadGraph graph, Class<T> clazz) throws DatabaseException {
48 T t = tryAdapt(graph, clazz);
49 return t != null ? t : super.adaptPossible(graph, clazz);