- @SCLValue(type = "VariableMap")
- public static VariableMap queryRangeChildren = new VariableMapImpl() {
-
- @Override
- public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
-
- TMap<String, Variable> map = new THashMap<String, Variable>();
- getVariables(graph, context, map);
- return map.get(name);
-
- }
-
- @Override
- public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
-
- SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);
-
- String location = "A1";
-
- try {
-
- Object object = context.getPropertyValue(graph, sr.ExpressionRange_cells);
-
- List<?> data = (List<?>)object;
-
- if(map == null) map = new HashMap<String,Variable>();
-
- for(Object o : data) {
- if(o instanceof ITableCell) {
-
- ITableCell cell = (ITableCell)o;
-
- String valueLocation = SpreadsheetUtils.offset(location, cell.getRow(), cell.getColumn());
-
- ArrayList<ConstantPropertyVariableBuilder> builders = new ArrayList<ConstantPropertyVariableBuilder>();
-
- builders.add(new ConstantPropertyVariableBuilder(ClientModel.CONTENT, Variant.ofInstance(cell.getText()), Bindings.VARIANT, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
- builders.add(new ConstantPropertyVariableBuilder(Variables.TYPE, sr.Cell, null, Collections.<ConstantPropertyVariableBuilder>emptyList(), Collections.<String>emptySet()));
-
- IFont font = cell.getFont();
- if(font != null) {
- builders.add(new ConstantPropertyVariableBuilder(ClientModel.FONT, new Font(font.getFamily(), font.getHeight(), font.getStyle()), Font.BINDING, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
- }
-
- int align = cell.getAlign();
- builders.add(new ConstantPropertyVariableBuilder(ClientModel.ALIGN, align, Bindings.INTEGER, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
-
- IColor foreground = cell.getFGColor();
- if(foreground != null) {
- builders.add(new ConstantPropertyVariableBuilder(ClientModel.FOREGROUND, new RGB.Integer(foreground.red(), foreground.green(), foreground.blue()), RGB.Integer.BINDING, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
- }
-
- IColor background = cell.getBGColor();
- if(background != null) {
- builders.add(new ConstantPropertyVariableBuilder(ClientModel.BACKGROUND, new RGB.Integer(background.red(), background.green(), background.blue()), RGB.Integer.BINDING, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
- }
-
- map.put(valueLocation, new ConstantChildVariable(context, valueLocation, builders));
-
- }
- }
-
- } catch (DatabaseException e) {
- throw (DatabaseException)e;
- } catch (Throwable t) {
- throw new DatabaseException(t);
- } finally {
- }
-
- return map;
-
- }
-
+ @SCLValue(type = "VariableMap")
+ public static VariableMap stringArrayChildren = new VariableMapImpl() {
+
+ @Override
+ public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+
+ TMap<String, Variable> map = new THashMap<String, Variable>();
+ getVariables(graph, context, map);
+ return map.get(name);
+
+ }
+
+ @Override
+ public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+
+ Resource resource = context.getRepresents(graph);
+
+ SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);
+
+ String location = graph.getPossibleRelatedValue(resource, sr.Range_location, Bindings.STRING);
+ if(location == null) return map;
+ Integer width = graph.getPossibleRelatedValue(resource, sr.Range_widthBound, Bindings.INTEGER);
+ if(width == null) return map;
+ String[] array = graph.getPossibleRelatedValue(resource, sr.StringArrayRange_array, Bindings.STRING_ARRAY);
+ if(array == null) return map;
+
+ int rows = array.length / width;
+
+ if(map == null) map = new HashMap<String,Variable>();
+
+ for(int offset=0,i=0;i<rows;i++) {
+ for(int j=0;j<width;j++) {
+
+ String value = array[offset++];
+ String valueLocation = Spreadsheets.offset(location, i, j);
+
+ ConstantPropertyVariableBuilder labelBuilder = new ConstantPropertyVariableBuilder(ClientModel.LABEL, value, Bindings.STRING, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS);
+ ConstantPropertyVariableBuilder typeBuilder = new ConstantPropertyVariableBuilder(Variables.TYPE, sr.Cell, null, Collections.<ConstantPropertyVariableBuilder>emptyList(), Collections.<String>emptySet());
+
+ map.put(valueLocation, new ConstantChildVariable(context, valueLocation, labelBuilder, typeBuilder, immutableBuilder));
+
+ }
+ }
+
+ return map;
+
+ }
+
+ };
+
+ @SCLValue(type = "VariableMap")
+ public static VariableMap queryRangeChildren = new VariableMapImpl() {
+
+ @Override
+ public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
+
+ TMap<String, Variable> map = new THashMap<String, Variable>();
+ getVariables(graph, context, map);
+ return map.get(name);
+
+ }
+
+ @Override
+ public Map<String, Variable> getVariables(ReadGraph graph, Variable context, Map<String, Variable> map) throws DatabaseException {
+
+ SpreadsheetResource sr = SpreadsheetResource.getInstance(graph);
+
+ String location = "A1";
+
+ try {
+
+ Object object = context.getPropertyValue(graph, sr.ExpressionRange_cells);
+
+ List<?> data = (List<?>)object;
+
+ if(map == null) map = new HashMap<String,Variable>();
+
+ for(Object o : data) {
+ if(o instanceof ITableCell) {
+
+ ITableCell cell = (ITableCell)o;
+
+ String valueLocation = Spreadsheets.offset(location, cell.getRow(), cell.getColumn());
+
+ ArrayList<ConstantPropertyVariableBuilder> builders = new ArrayList<ConstantPropertyVariableBuilder>();
+
+ builders.add(new ConstantPropertyVariableBuilder(ClientModel.CONTENT, Variant.ofInstance(cell.getText()), Bindings.VARIANT, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
+ builders.add(new ConstantPropertyVariableBuilder(Variables.TYPE, sr.Cell, null, Collections.<ConstantPropertyVariableBuilder>emptyList(), Collections.<String>emptySet()));
+
+ IFont font = cell.getFont();
+ if(font != null) {
+ builders.add(new ConstantPropertyVariableBuilder(ClientModel.FONT, new Font(font.getFamily(), font.getHeight(), font.getStyle()), Font.BINDING, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
+ }
+
+ int align = cell.getAlign();
+ builders.add(new ConstantPropertyVariableBuilder(ClientModel.ALIGN, align, Bindings.INTEGER, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
+
+ IColor foreground = cell.getFGColor();
+ if(foreground != null) {
+ builders.add(new ConstantPropertyVariableBuilder(ClientModel.FOREGROUND, new RGB.Integer(foreground.red(), foreground.green(), foreground.blue()), RGB.Integer.BINDING, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
+ }
+
+ IColor background = cell.getBGColor();
+ if(background != null) {
+ builders.add(new ConstantPropertyVariableBuilder(ClientModel.BACKGROUND, new RGB.Integer(background.red(), background.green(), background.blue()), RGB.Integer.BINDING, Collections.<ConstantPropertyVariableBuilder>emptyList(), CLASSIFICATIONS));
+ }
+
+ map.put(valueLocation, new ConstantChildVariable(context, valueLocation, builders));
+
+ }
+ }
+
+ } catch (DatabaseException e) {
+ throw (DatabaseException)e;
+ } catch (Throwable t) {
+ throw new DatabaseException(t);
+ } finally {
+ }
+
+ return map;
+
+ }
+