templates.RelationshipFactory.xml.sec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
The INGENIAS Meta-Editor core. It is a set of facilities to generate an editor from a detailed xml description
@@@program xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../plantilla.xsd"@@@ @@@saveto@@@ @@@file overwrite="yes"@@@output/ingenias/generator/browser/RelationshipFactory.java@@@/file@@@ @@@text@@@ /** * Copyright (C) 2010 Jorge J. Gomez-Sanz * * * This file is part of the INGENME tool. INGENME is an open source meta-editor * which produces customized editors for user-defined modeling languages * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation version 3 of the License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> **/ package ingenias.generator.browser; import java.util.*; import org.jgraph.graph.DefaultEdge; import org.jgraph.graph.DefaultGraphCell; import org.jgraph.graph.GraphCell; import ingenias.editor.Editor; import ingenias.editor.cell.*; import ingenias.editor.entities.*; public class RelationshipFactory { public static DefaultGraphCell getNRelationshipInstance (String relationshipName, GraphCell[] extremes) { // Search for NAryEdges in selected. int nAryEdgesNum = 0; int edgesNum = 0; NAryEdge selectedEdge = null; for (int i = 0; i < extremes.length; i++) { if (extremes[i] instanceof NAryEdge) { nAryEdgesNum++; selectedEdge = (NAryEdge) extremes[i]; } else if (extremes[i] instanceof DefaultEdge) { edgesNum++; } } if (nAryEdgesNum <= 1 && edgesNum == 0) { @@@repeat id="relationshipedges"@@@ if (relationshipName.equalsIgnoreCase("@@@v@@@relationship@@@/v@@@")) { // ResponsibleNEdge already exists. if (nAryEdgesNum == 1 && selectedEdge instanceof @@@v@@@relationship@@@/v@@@Edge) { return selectedEdge; } // There is no NAryEdges in selected. else if (nAryEdgesNum == 0) { return new @@@v@@@relationship@@@/v@@@Edge(new @@@v@@@relationship@@@/v@@@("" + Editor.getNewId())); } } @@@/repeat@@@ } return null; } } @@@/text@@@ @@@/saveto@@@ @@@/program@@@