X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2Fcreator%2FTextCellCreator.java.keep;fp=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2Fcreator%2FTextCellCreator.java.keep;h=382d4a78878c7a2b6249411ab6957e418d3c00bd;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=a4c399e2c14dfc07b41f3c672d1bc1bd6da6505f;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/creator/TextCellCreator.java.keep b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/creator/TextCellCreator.java.keep index a4c399e2c..382d4a788 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/creator/TextCellCreator.java.keep +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/creator/TextCellCreator.java.keep @@ -1,54 +1,54 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.spreadsheet.graph.creator; - -import java.util.Collection; - -import org.simantics.databoard.Bindings; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.spreadsheet.ModelCellManager.CellCreationData; -import org.simantics.spreadsheet.common.cell.Parsers; -import org.simantics.spreadsheet.graph.request.RowsColumnsIndex; -import org.simantics.spreadsheet.resource.SpreadsheetResource; - -public class TextCellCreator extends CellCreatorBase { - - public TextCellCreator(Resource realization) { - super(realization); - } - - @Override - public void create(WriteGraph graph, final RowsColumnsIndex rowIndex, final RowsColumnsIndex columnIndex, final Collection data) throws DatabaseException { - - Layer0 l0 = Layer0.getInstance(graph); - SpreadsheetResource sr = SpreadsheetResource.getInstance(graph); - - Resource spreadsheet = graph.getPossibleObject(realization, l0.Represents); - - for(CellCreationData datum : data) { - Resource newCell = graph.newResource(); - graph.claim(newCell, l0.InstanceOf, null, sr.TextCell); - String label = getProperty(datum, Parsers.LABEL_PROPERTY, Bindings.STRING); - Resource rowResource = rowIndex.getResource(datum.row); - Resource columnResource = columnIndex.getResource(datum.column); - graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource); - graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource); - graph.addLiteral(newCell, sr.Label, sr.LabelOf, l0.String, label, Bindings.STRING); - graph.claim(spreadsheet, l0.ConsistsOf, l0.PartOf, newCell); - } - - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.spreadsheet.graph.creator; + +import java.util.Collection; + +import org.simantics.databoard.Bindings; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.spreadsheet.ModelCellManager.CellCreationData; +import org.simantics.spreadsheet.common.cell.Parsers; +import org.simantics.spreadsheet.graph.request.RowsColumnsIndex; +import org.simantics.spreadsheet.resource.SpreadsheetResource; + +public class TextCellCreator extends CellCreatorBase { + + public TextCellCreator(Resource realization) { + super(realization); + } + + @Override + public void create(WriteGraph graph, final RowsColumnsIndex rowIndex, final RowsColumnsIndex columnIndex, final Collection data) throws DatabaseException { + + Layer0 l0 = Layer0.getInstance(graph); + SpreadsheetResource sr = SpreadsheetResource.getInstance(graph); + + Resource spreadsheet = graph.getPossibleObject(realization, l0.Represents); + + for(CellCreationData datum : data) { + Resource newCell = graph.newResource(); + graph.claim(newCell, l0.InstanceOf, null, sr.TextCell); + String label = getProperty(datum, Parsers.LABEL_PROPERTY, Bindings.STRING); + Resource rowResource = rowIndex.getResource(datum.row); + Resource columnResource = columnIndex.getResource(datum.column); + graph.claim(newCell, sr.HasRow, sr.RowOf, rowResource); + graph.claim(newCell, sr.HasColumn, sr.ColumnOf, columnResource); + graph.addLiteral(newCell, sr.Label, sr.LabelOf, l0.String, label, Bindings.STRING); + graph.claim(spreadsheet, l0.ConsistsOf, l0.PartOf, newCell); + } + + } + +}