All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ingenias.editor.persistence.GraphLoadImp2 Maven / Gradle / Ivy

Go to download

Meta-language editor built over INGENME. It is the most basic editor to be used in the rest of projects

There is a newer version: 1.0.9
Show newest version





/** 
 * Copyright (C) 2010  Jorge J. Gomez-Sanz over original code from Ruben Fuentes
 * 
 *   Modifications over original code from jgraph.sourceforge.net
 * 
 * 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 
 **/
 
package ingenias.editor.persistence;
import java.lang.reflect.*;
import javax.swing.tree.*;
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.InputSource;
import java.awt.Color;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.OutputStreamWriter;
import java.io.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.*;
import java.util.Map;
import java.util.Hashtable;
import java.util.ArrayList;
import javax.xml.parsers.*;
import org.jgraph.JGraph;
import org.jgraph.graph.*;
import org.w3c.dom.*;
import org.w3c.dom.Document;
import org.w3c.dom.DOMImplementation;
import ingenias.editor.entities.*;
import ingenias.exception.*;
import ingenias.editor.cell.*;
import ingenias.editor.*;


public class GraphLoadImp2 extends GraphLoadImp2Abs
    implements GraphLoad {

  /**
   *  Constructor for the GraphLoad object
   */
  public GraphLoadImp2() {}


  // Convert a vertex represented by a GXL DOM node in a DefaultGraphCell.
  // ids contains the already processed vertex ids.

  protected DefaultGraphCell GXLVertex(String id, String type, ModelJGraph graph,
                                    ObjectManager om, RelationshipManager rm) {

    DefaultGraphCell vertex = null;

    ingenias.editor.entities.Entity en = om.getEntity(id, type);
    // if it is registered in the OM, then it is a diagram object
    if (en != null) {


   	if (en.getClass().equals(ingenias.editor.entities.PropertyField.class))
	  return  new ingenias.editor.cell.PropertyFieldCell((ingenias.editor.entities.PropertyField)en);

   	if (en.getClass().equals(ingenias.editor.entities.MetaObjectTypeWrapper.class))
	  return  new ingenias.editor.cell.MetaObjectTypeWrapperCell((ingenias.editor.entities.MetaObjectTypeWrapper)en);

   	if (en.getClass().equals(ingenias.editor.entities.MetaDiagram.class))
	  return  new ingenias.editor.cell.MetaDiagramCell((ingenias.editor.entities.MetaDiagram)en);

   	if (en.getClass().equals(ingenias.editor.entities.ExternalTypeWrapper.class))
	  return  new ingenias.editor.cell.ExternalTypeWrapperCell((ingenias.editor.entities.ExternalTypeWrapper)en);

   	if (en.getClass().equals(ingenias.editor.entities.MetaRelationship.class))
	  return  new ingenias.editor.cell.MetaRelationshipCell((ingenias.editor.entities.MetaRelationship)en);

   	if (en.getClass().equals(ingenias.editor.entities.DefaultValue.class))
	  return  new ingenias.editor.cell.DefaultValueCell((ingenias.editor.entities.DefaultValue)en);

   	if (en.getClass().equals(ingenias.editor.entities.PropertyOrder.class))
	  return  new ingenias.editor.cell.PropertyOrderCell((ingenias.editor.entities.PropertyOrder)en);

   	if (en.getClass().equals(ingenias.editor.entities.Documentation.class))
	  return  new ingenias.editor.cell.DocumentationCell((ingenias.editor.entities.Documentation)en);

   	if (en.getClass().equals(ingenias.editor.entities.PreferredOrder.class))
	  return  new ingenias.editor.cell.PreferredOrderCell((ingenias.editor.entities.PreferredOrder)en);

   	if (en.getClass().equals(ingenias.editor.entities.MetaObject.class))
	  return  new ingenias.editor.cell.MetaObjectCell((ingenias.editor.entities.MetaObject)en);

   	if (en.getClass().equals(ingenias.editor.entities.BasicRepresentation.class))
	  return  new ingenias.editor.cell.BasicRepresentationCell((ingenias.editor.entities.BasicRepresentation)en);

   	if (en.getClass().equals(ingenias.editor.entities.VisualRepresentation.class))
	  return  new ingenias.editor.cell.VisualRepresentationCell((ingenias.editor.entities.VisualRepresentation)en);

   	if (en.getClass().equals(ingenias.editor.entities.TypeWrapper.class))
	  return  new ingenias.editor.cell.TypeWrapperCell((ingenias.editor.entities.TypeWrapper)en);

   	if (en.getClass().equals(ingenias.editor.entities.UMLComment.class))
	  return  new ingenias.editor.cell.UMLCommentCell((ingenias.editor.entities.UMLComment)en);

   	if (en.getClass().equals(ingenias.editor.entities.MetaRole.class))
	  return  new ingenias.editor.cell.MetaRoleCell((ingenias.editor.entities.MetaRole)en);

   	if (en.getClass().equals(ingenias.editor.entities.MetaDiagramTypeWrapper.class))
	  return  new ingenias.editor.cell.MetaDiagramTypeWrapperCell((ingenias.editor.entities.MetaDiagramTypeWrapper)en);

    } else {
    // If not, it is a relationship
      en = rm.getRelationship(id);
    if (en==null) return null;

    if (en instanceof ingenias.editor.entities.Contains)
     return  new ingenias.editor.cell.ContainsEdge((ingenias.editor.entities.Contains)en);

    if (en instanceof ingenias.editor.entities.IsDocumentedBy)
     return  new ingenias.editor.cell.IsDocumentedByEdge((ingenias.editor.entities.IsDocumentedBy)en);

    if (en instanceof ingenias.editor.entities.PropsOrderedAs)
     return  new ingenias.editor.cell.PropsOrderedAsEdge((ingenias.editor.entities.PropsOrderedAs)en);

    if (en instanceof ingenias.editor.entities.VisualizedAs)
     return  new ingenias.editor.cell.VisualizedAsEdge((ingenias.editor.entities.VisualizedAs)en);

    if (en instanceof ingenias.editor.entities.HasMO)
     return  new ingenias.editor.cell.HasMOEdge((ingenias.editor.entities.HasMO)en);

    if (en instanceof ingenias.editor.entities.AssociationEnd)
     return  new ingenias.editor.cell.AssociationEndEdge((ingenias.editor.entities.AssociationEnd)en);

    if (en instanceof ingenias.editor.entities.PlayedBy)
     return  new ingenias.editor.cell.PlayedByEdge((ingenias.editor.entities.PlayedBy)en);

    if (en instanceof ingenias.editor.entities.BinaryRel)
     return  new ingenias.editor.cell.BinaryRelEdge((ingenias.editor.entities.BinaryRel)en);

    if (en instanceof ingenias.editor.entities.InheritsR)
     return  new ingenias.editor.cell.InheritsREdge((ingenias.editor.entities.InheritsR)en);

    if (en instanceof ingenias.editor.entities.UMLAnnotatedElement)
     return  new ingenias.editor.cell.UMLAnnotatedElementEdge((ingenias.editor.entities.UMLAnnotatedElement)en);

    if (en instanceof ingenias.editor.entities.InheritsO)
     return  new ingenias.editor.cell.InheritsOEdge((ingenias.editor.entities.InheritsO)en);

    if (en instanceof ingenias.editor.entities.Has)
     return  new ingenias.editor.cell.HasEdge((ingenias.editor.entities.Has)en);


    }

    return null;
  }


 
}









© 2015 - 2025 Weber Informatics LLC | Privacy Policy