1 package org.simantics.modeling.ui.diagram.monitor;
3 import org.simantics.browsing.ui.swt.widgets.impl.ModifyComboListenerImpl;
4 import org.simantics.databoard.Bindings;
5 import org.simantics.db.Resource;
6 import org.simantics.db.WriteGraph;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.diagram.stubs.DiagramResource;
9 import org.simantics.layer0.Layer0;
10 import org.simantics.ui.fonts.FontDescriptor;
12 public class FontModifier extends ModifyComboListenerImpl<Resource, String> {
15 public void applySelection(WriteGraph graph, Resource monitor, String newFamily) throws DatabaseException {
16 Layer0 L0 = Layer0.getInstance(graph);
17 DiagramResource DIA = DiagramResource.getInstance(graph);
18 FontDescriptor fd = graph.getPossibleRelatedAdapter(monitor, DIA.HasFont, FontDescriptor.class);
20 graph.markUndoPoint();
21 Resource font = graph.newResource();
22 graph.claim(font, L0.InstanceOf, null, DIA.RealizedFont);
23 graph.addLiteral(font, DIA.RealizedFont_HasFamily, DIA.RealizedFont_HasFamily_Inverse, L0.String, newFamily, Bindings.STRING);
24 graph.addLiteral(font, DIA.RealizedFont_HasStyle, DIA.RealizedFont_HasStyle_Inverse, L0.Integer, fd.getStyle(), Bindings.INTEGER);
25 graph.addLiteral(font, DIA.RealizedFont_HasSize, DIA.RealizedFont_HasSize_Inverse, L0.Integer, fd.getSize(), Bindings.INTEGER);
26 graph.deny(monitor, DIA.HasFont);
27 graph.claim(monitor, DIA.HasFont, font);