1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.flag;
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.layer0.adapter.StringModifier;
18 import org.simantics.db.layer0.adapter.StringModifierFactory;
19 import org.simantics.layer0.Layer0;
22 * Makes sure that two things apply:
24 * <li>If a flag is joined with another flag, both flags must have the same label property</li>
25 * <li>A flag's label is unique within its own diagram</li>
27 * @author Tuukka Lehtonen
29 public final class FlagStringModifierFactory implements StringModifierFactory {
31 private Resource subject;
33 public FlagStringModifierFactory(ReadGraph graph, Resource subject) throws DatabaseException {
34 this.subject = subject;
38 public StringModifier createModifier(ReadGraph graph, Resource relation, Resource property) throws DatabaseException {
39 // System.out.println(NameUtils.getSafeName(graph, subject));
40 // System.out.println(NameUtils.getSafeName(graph, relation));
41 // System.out.println(NameUtils.getSafeName(graph, property));
42 Layer0 L0 = Layer0.getInstance(graph);
43 if (L0.HasLabel.equals(relation)) {
44 return new FlagLabelModifier(graph, subject, relation, property);