1 package org.simantics.modeling.typicals.rules;
3 import org.simantics.db.Resource;
4 import org.simantics.db.WriteGraph;
5 import org.simantics.db.exception.DatabaseException;
6 import org.simantics.diagram.query.DiagramRequests;
7 import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;
8 import org.simantics.g2d.page.DiagramDesc;
9 import org.simantics.modeling.typicals.ITypicalSynchronizationRule;
10 import org.simantics.modeling.typicals.TypicalInfo;
13 * @author Tuukka Lehtonen
14 * @since 1.22.2, 1.25.0
16 public enum PageSettingsTypicalRule implements ITypicalSynchronizationRule {
20 public static PageSettingsTypicalRule get() {
25 public boolean synchronize(WriteGraph graph, Resource template, Resource instance, TypicalInfo info) throws DatabaseException {
26 DiagramDesc mdesc = graph.syncRequest(DiagramRequests.getDiagramDesc(template));
27 DiagramDesc idesc = graph.syncRequest(DiagramRequests.getDiagramDesc(instance));
28 if (mdesc.equals(idesc))
31 DiagramGraphUtil.setDiagramDesc(graph, instance, mdesc);
32 info.messageLog.add("\t\tset diagram page settings:"
33 + "\n\t\t\tshow page borders: " + mdesc.isPageBordersVisible()
34 + "\n\t\t\tshow margins: " + mdesc.isMarginsVisible()
35 + "\n\t\t\tgrid size: " + mdesc.getGridSize()
36 + "\n\t\t\tpage settings: " + mdesc.getPageDesc()