]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/adapter/CellVariable.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.spreadsheet.graph / src / org / simantics / spreadsheet / graph / adapter / CellVariable.java
1 package org.simantics.spreadsheet.graph.adapter;
2
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;
10
11 public class CellVariable extends StandardGraphChildVariable {
12
13         public CellVariable(Variable parent, Resource resource) throws DatabaseException {
14                 super(parent, null, resource);
15         }
16         
17         @Override
18         public String getLabel(ReadGraph graph) throws DatabaseException {
19                 return null;
20         }
21         
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() {
26                                 
27                                 @Override
28                                 public void edit(WriteGraph graph, Variable cell, String text) throws DatabaseException {
29                                 }
30                                 
31                                 @Override
32                                 public void copy(WriteGraph graph, Variable cell, String location) throws DatabaseException {
33                                 }
34                                 
35                         };
36         }
37         return null;
38     }
39
40     @Override
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);
44     }
45
46     @Override
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);
50     }
51
52 }