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

ingenias.editor.cellfactories.MetamodelCellViewFactory 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.cellfactories;

import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.util.Map;
import java.util.Hashtable;

import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.awt.event.*;
import java.net.URL;
import java.util.Map;
import java.util.Hashtable;
import java.util.ArrayList;
import javax.swing.event.UndoableEditEvent;
import org.jgraph.JGraph;
import org.jgraph.graph.*;
import org.jgraph.event.*;
import java.util.Vector;
import org.jgraph.JGraph;
import org.jgraph.graph.*;
import org.jgraph.event.*;
import org.jgraph.plaf.basic.*;
import ingenias.editor.entities.*;
import ingenias.editor.cell.*;
import ingenias.editor.events.*;

public class MetamodelCellViewFactory implements CellViewFactory {

public MetamodelCellViewFactory() {}
 

 	public org.jgraph.graph.CellView createView(GraphModel model, Object cell) {
		
			org.jgraph.graph.CellView view = null;
			if (model.isPort(cell))
				view = new PortView(cell);
			else if (model.isEdge(cell))
				view = createEdgeView(cell);
			else
				view = createVertexView(cell);
			return view;
		}

  // Modificar agregando nuevas clases VIEW segun se vayan a?endo

  protected org.jgraph.graph.VertexView createVertexView(Object v) {
    Object userObject = ( (DefaultGraphCell) v).getUserObject();

   // Diagram Objects start here


   if (userObject.getClass().equals(MetaObject.class)){
           return new ingenias.editor.cell.MetaObjectView(v);
   }

   if (userObject.getClass().equals(MetaDiagram.class)){
           return new ingenias.editor.cell.MetaDiagramView(v);
   }

   if (userObject.getClass().equals(MetaRelationship.class)){
           return new ingenias.editor.cell.MetaRelationshipView(v);
   }

   if (userObject.getClass().equals(MetaRole.class)){
           return new ingenias.editor.cell.MetaRoleView(v);
   }

   if (userObject.getClass().equals(VisualRepresentation.class)){
           return new ingenias.editor.cell.VisualRepresentationView(v);
   }

   if (userObject.getClass().equals(BasicRepresentation.class)){
           return new ingenias.editor.cell.BasicRepresentationView(v);
   }

   if (userObject.getClass().equals(PropertyField.class)){
           return new ingenias.editor.cell.PropertyFieldView(v);
   }

   if (userObject.getClass().equals(UMLComment.class)){
           return new ingenias.editor.cell.UMLCommentView(v);
   }

   if (userObject.getClass().equals(PreferredOrder.class)){
           return new ingenias.editor.cell.PreferredOrderView(v);
   }

   if (userObject.getClass().equals(Documentation.class)){
           return new ingenias.editor.cell.DocumentationView(v);
   }

   if (userObject.getClass().equals(PropertyOrder.class)){
           return new ingenias.editor.cell.PropertyOrderView(v);
   }

   if (userObject.getClass().equals(ExternalTypeWrapper.class)){
           return new ingenias.editor.cell.ExternalTypeWrapperView(v);
   }

   if (userObject.getClass().equals(MetaDiagramTypeWrapper.class)){
           return new ingenias.editor.cell.MetaDiagramTypeWrapperView(v);
   }

   if (userObject.getClass().equals(MetaObjectTypeWrapper.class)){
           return new ingenias.editor.cell.MetaObjectTypeWrapperView(v);
   }


   // Diagram Relationships start here

   if (v.getClass().equals(UMLAnnotatedElementEdge.class)){
           return new ingenias.editor.cell.UMLAnnotatedElementView(v);
   }

   if (v.getClass().equals(HasEdge.class)){
           return new ingenias.editor.cell.HasView(v);
   }

   if (v.getClass().equals(InheritsOEdge.class)){
           return new ingenias.editor.cell.InheritsOView(v);
   }

   if (v.getClass().equals(InheritsREdge.class)){
           return new ingenias.editor.cell.InheritsRView(v);
   }

   if (v.getClass().equals(ContainsEdge.class)){
           return new ingenias.editor.cell.ContainsView(v);
   }

   if (v.getClass().equals(VisualizedAsEdge.class)){
           return new ingenias.editor.cell.VisualizedAsView(v);
   }

   if (v.getClass().equals(PlayedByEdge.class)){
           return new ingenias.editor.cell.PlayedByView(v);
   }

   if (v.getClass().equals(AssociationEndEdge.class)){
           return new ingenias.editor.cell.AssociationEndView(v);
   }

   if (v.getClass().equals(BinaryRelEdge.class)){
           return new ingenias.editor.cell.BinaryRelView(v);
   }

   if (v.getClass().equals(PropsOrderedAsEdge.class)){
           return new ingenias.editor.cell.PropsOrderedAsView(v);
   }

   if (v.getClass().equals(IsDocumentedByEdge.class)){
           return new ingenias.editor.cell.IsDocumentedByView(v);
   }

   if (v.getClass().equals(HasMOEdge.class)){
           return new ingenias.editor.cell.HasMOView(v);
   }


    return null;
  }

  protected org.jgraph.graph.EdgeView createEdgeView(Object v) {
  return new org.jgraph.graph.EdgeView(v);

//         if (v instanceof ExecuteEdge){
//           return new ExecuteView(v,this,cm);
//         }

  }

 


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy