X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fdiagram%2FSheetFactory.java.keep;h=29a1b73105d23b70774832f38a2f04e866d0bcde;hb=01829f2ac0839902c07f29ef723cbd37751bfc51;hp=e87e26fabe1b5b55f1bbbf46495969071a8032d6;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SheetFactory.java.keep b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SheetFactory.java.keep index e87e26fab..29a1b7310 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SheetFactory.java.keep +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SheetFactory.java.keep @@ -1,87 +1,87 @@ -/******************************************************************************* - * Copyright (c) 2007- VTT Technical Research Centre of Finland. - * 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.modeling.ui.diagram; - -import java.awt.geom.AffineTransform; - -import org.simantics.db.AsyncReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.procedure.AsyncProcedure; -import org.simantics.diagram.adapter.ElementFactory; -import org.simantics.diagram.synchronization.graph.BasicResources; -import org.simantics.g2d.canvas.ICanvasContext; -import org.simantics.g2d.diagram.IDiagram; -import org.simantics.g2d.element.ElementClass; -import org.simantics.g2d.element.ElementUtils; -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.element.handler.impl.StaticObjectAdapter; -import org.simantics.spreadsheet.graph.GraphBackend; -import org.simantics.spreadsheet.graph.SpreadsheetResource; -import org.simantics.spreadsheet.ui.SimpleContainerTableModel; - - -/** - * TODO: recognize experiment disposal and reset monitor contents at that point - */ -public class SheetFactory implements ElementFactory { - - public static ElementClass createSheetClass(Resource elementType) { - return SheetClass.create(null, null, null, 1.0, 1.0, new StaticObjectAdapter(elementType)); - } - - @Override - public void getClass(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, - Resource resource, AsyncProcedure procedure) { - procedure.execute(graph, createSheetClass(graph.getSession().getService(SpreadsheetResource.class).SpreadsheetElement)); - } - - @Override - public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, - Resource elementType, AsyncProcedure procedure) { - procedure.execute(graph, createSheetClass(graph.getSession().getService(SpreadsheetResource.class).SpreadsheetElement)); - } - - @Override - public void load(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, - Resource resource, final IElement element) { - - SpreadsheetResource sr = graph.getService(SpreadsheetResource.class); - - AffineTransform at = new AffineTransform(); - ElementUtils.setTransform(element, at); - - graph.forPossibleObject(resource, sr.HasSheet, new AsyncProcedure() { - - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - throwable.printStackTrace(); - } - - @Override - public void execute(AsyncReadGraph graph, Resource sheet) { - - GraphBackend backend = new GraphBackend(graph.getSession()); - - SimpleContainerTableModel tableModel = new SimpleContainerTableModel(backend); - - element.setHint(SheetClass.KEY_MODEL, tableModel); - element.setHint(SheetClass.KEY_TABLE_MODEL, tableModel); - - backend.load(sheet, tableModel); - - } - - }); - - } - - +/******************************************************************************* + * Copyright (c) 2007- VTT Technical Research Centre of Finland. + * 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.modeling.ui.diagram; + +import java.awt.geom.AffineTransform; + +import org.simantics.db.AsyncReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.procedure.AsyncProcedure; +import org.simantics.diagram.adapter.ElementFactory; +import org.simantics.diagram.synchronization.graph.BasicResources; +import org.simantics.g2d.canvas.ICanvasContext; +import org.simantics.g2d.diagram.IDiagram; +import org.simantics.g2d.element.ElementClass; +import org.simantics.g2d.element.ElementUtils; +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.element.handler.impl.StaticObjectAdapter; +import org.simantics.spreadsheet.graph.GraphBackend; +import org.simantics.spreadsheet.graph.SpreadsheetResource; +import org.simantics.spreadsheet.ui.SimpleContainerTableModel; + + +/** + * TODO: recognize experiment disposal and reset monitor contents at that point + */ +public class SheetFactory implements ElementFactory { + + public static ElementClass createSheetClass(Resource elementType) { + return SheetClass.create(null, null, null, 1.0, 1.0, new StaticObjectAdapter(elementType)); + } + + @Override + public void getClass(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, + Resource resource, AsyncProcedure procedure) { + procedure.execute(graph, createSheetClass(graph.getSession().getService(SpreadsheetResource.class).SpreadsheetElement)); + } + + @Override + public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, + Resource elementType, AsyncProcedure procedure) { + procedure.execute(graph, createSheetClass(graph.getSession().getService(SpreadsheetResource.class).SpreadsheetElement)); + } + + @Override + public void load(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, + Resource resource, final IElement element) { + + SpreadsheetResource sr = graph.getService(SpreadsheetResource.class); + + AffineTransform at = new AffineTransform(); + ElementUtils.setTransform(element, at); + + graph.forPossibleObject(resource, sr.HasSheet, new AsyncProcedure() { + + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + throwable.printStackTrace(); + } + + @Override + public void execute(AsyncReadGraph graph, Resource sheet) { + + GraphBackend backend = new GraphBackend(graph.getSession()); + + SimpleContainerTableModel tableModel = new SimpleContainerTableModel(backend); + + element.setHint(SheetClass.KEY_MODEL, tableModel); + element.setHint(SheetClass.KEY_TABLE_MODEL, tableModel); + + backend.load(sheet, tableModel); + + } + + }); + + } + + } \ No newline at end of file