]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/monitor/FormatModifier.java
(refs #7571) Fixed incorrect handling of effects in edo
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / diagram / monitor / FormatModifier.java
1 package org.simantics.modeling.ui.diagram.monitor;
2
3 import org.simantics.browsing.ui.swt.widgets.impl.ModifyComboListenerImpl;
4 import org.simantics.db.Resource;
5 import org.simantics.db.WriteGraph;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.diagram.stubs.DiagramResource;
8
9 public class FormatModifier extends ModifyComboListenerImpl<Resource, Resource> {
10
11         @Override
12         public void applySelection(WriteGraph graph, Resource monitor, Resource newFormatter) throws DatabaseException {
13                 graph.markUndoPoint();
14                 DiagramResource DIA = DiagramResource.getInstance(graph);
15                 Resource exist = graph.getPossibleObject(monitor, DIA.HasFormatter);
16                 if (newFormatter.equals(exist))
17                         return;
18                 graph.deny(monitor, DIA.HasFormatter);
19                 graph.claim(monitor, DIA.HasFormatter, newFormatter);
20         }
21
22 }