ingenias.editor.cell.MetaObjectRenderer Maven / Gradle / Ivy
/**
* Copyright (C) 2010 Jorge J. Gomez-Sanz over original code from Ruben Fuentes
*
* Modifications over original code from Jon Barrileaux.
* It has been significantly modified to enhance drawing speed.
*
* 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.cell;
import org.jgraph.JGraph;
import org.jgraph.graph.*;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.beans.*;
import java.io.*;
import java.util.*;
import ingenias.editor.entities.*;
import ingenias.editor.entities.*;
import org.swixml.SwingEngine;
import ingenias.editor.entities.Entity;
public class MetaObjectRenderer extends CompositeRenderer implements CellViewRenderer, Serializable {
private static ViewPreferences.ViewType current = ViewPreferences.ViewType.INGENIAS;
static {
try {
ViewPreferences.ViewType index=ViewPreferences.ViewType.INGENIAS;
index=ViewPreferences.ViewType.INGENIAS;
index=ViewPreferences.ViewType.UML;
RenderComponentManager.loadRenderFile("MetaObject",
index,"/rendererxml/MetaObjectUMLPanel.xml");
index=ViewPreferences.ViewType.INGENIAS;
RenderComponentManager.loadRenderFile("MetaObject",
index,"/rendererxml/MetaObjectINGENIASPanel.xml");
}
catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* Constructs a renderer that may be used to render vertices.
*/
public MetaObjectRenderer() {
}
public JComponent getConcreteSubComponent(String fieldname, Entity ent, Map map) {
Map currentMap=(Map) RenderComponentManager.retrieveIDs("MetaObject",ent.getPrefs(map).getView());
return currentMap.get(fieldname);
}
public Dimension getSize() {
return RenderComponentManager.getSize("MetaObject",current);
}
public boolean supportsAttribute(Object key) {
return true;
}
public static void setEntity(MetaObject ent, Map attributes){
Map currentMap=(Map) RenderComponentManager.retrieveIDs("MetaObject",ent.getPrefs(attributes).getView());
current=ent.getPrefs(attributes).getView();
if (ent != null
&& currentMap.get("_attributes_") != null
&& currentMap.get("_attributes_") instanceof ingenias.editor.rendererxml.AttributesPanel) {
((ingenias.editor.rendererxml.AttributesPanel) currentMap
.get("_attributes_")).setEntity(ent);
}
if (currentMap.get("VisualRepresentations")!=null &&
currentMap.get("VisualRepresentations") instanceof ingenias.editor.rendererxml.CollectionPanel) {
try {
( (ingenias.editor.rendererxml.CollectionPanel) currentMap.get(
"VisualRepresentations")).setCollection("VisualRepresentations",ent.VisualRepresentations, ent.VisualRepresentations.getType());
}
catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
catch (IllegalAccessException ex) {
ex.printStackTrace();
}
}
if (currentMap.get("Properties")!=null &&
currentMap.get("Properties") instanceof ingenias.editor.rendererxml.CollectionPanel) {
try {
( (ingenias.editor.rendererxml.CollectionPanel) currentMap.get(
"Properties")).setCollection("Properties",ent.Properties, ent.Properties.getType());
}
catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
catch (IllegalAccessException ex) {
ex.printStackTrace();
}
}
if (currentMap.get("PreferredOrder")!=null &&
currentMap.get("PreferredOrder") instanceof ingenias.editor.rendererxml.CollectionPanel) {
try {
( (ingenias.editor.rendererxml.CollectionPanel) currentMap.get(
"PreferredOrder")).setCollection("PreferredOrder",ent.PreferredOrder, ent.PreferredOrder.getType());
}
catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
catch (IllegalAccessException ex) {
ex.printStackTrace();
}
}
if (currentMap.get("VisualRepresentations")!=null &&
currentMap.get("VisualRepresentations") instanceof ingenias.editor.rendererxml.CollectionPanel) {
try {
( (ingenias.editor.rendererxml.CollectionPanel) currentMap.get(
"VisualRepresentations")).setCollection("VisualRepresentations",ent.VisualRepresentations, ent.VisualRepresentations.getType());
}
catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
catch (IllegalAccessException ex) {
ex.printStackTrace();
}
}
if (currentMap.get("Properties")!=null &&
currentMap.get("Properties") instanceof ingenias.editor.rendererxml.CollectionPanel) {
try {
( (ingenias.editor.rendererxml.CollectionPanel) currentMap.get(
"Properties")).setCollection("Properties",ent.Properties, ent.Properties.getType());
}
catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
catch (IllegalAccessException ex) {
ex.printStackTrace();
}
}
if (currentMap.get("PreferredOrder")!=null &&
currentMap.get("PreferredOrder") instanceof ingenias.editor.rendererxml.CollectionPanel) {
try {
( (ingenias.editor.rendererxml.CollectionPanel) currentMap.get(
"PreferredOrder")).setCollection("PreferredOrder",ent.PreferredOrder, ent.PreferredOrder.getType());
}
catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
catch (IllegalAccessException ex) {
ex.printStackTrace();
}
}
if (currentMap.get("Description")!=null){
if (ent!=null && ent.getDescription()!=null){
if (currentMap.get("Description") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("Description")).setText(ent.getDescription().toString());
} else {
if (currentMap.get("Description") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("Description")).setText(ent.getDescription().toString());
}
} else {
if (currentMap.get("Description") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("Description")).setText("");
else {
if (!(currentMap.get("Description") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("Description")).setText("");
}
}
}
if (currentMap.get("VisualRepresentations")!=null){
if (ent!=null && ent.getVisualRepresentations()!=null){
if (currentMap.get("VisualRepresentations") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("VisualRepresentations")).setText(ent.getVisualRepresentations().toString());
} else {
if (currentMap.get("VisualRepresentations") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("VisualRepresentations")).setText(ent.getVisualRepresentations().toString());
}
} else {
if (currentMap.get("VisualRepresentations") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("VisualRepresentations")).setText("");
else {
if (!(currentMap.get("VisualRepresentations") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("VisualRepresentations")).setText("");
}
}
}
if (currentMap.get("Id")!=null){
if (ent!=null && ent.getId()!=null){
if (currentMap.get("Id") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("Id")).setText(ent.getId().toString());
} else {
if (currentMap.get("Id") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("Id")).setText(ent.getId().toString());
}
} else {
if (currentMap.get("Id") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("Id")).setText("");
else {
if (!(currentMap.get("Id") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("Id")).setText("");
}
}
}
if (currentMap.get("Keyfield")!=null){
if (ent!=null && ent.getKeyfield()!=null){
if (currentMap.get("Keyfield") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("Keyfield")).setText(ent.getKeyfield().toString());
} else {
if (currentMap.get("Keyfield") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("Keyfield")).setText(ent.getKeyfield().toString());
}
} else {
if (currentMap.get("Keyfield") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("Keyfield")).setText("");
else {
if (!(currentMap.get("Keyfield") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("Keyfield")).setText("");
}
}
}
if (currentMap.get("BasicRepresentations")!=null){
if (ent!=null && ent.getBasicRepresentations()!=null){
if (currentMap.get("BasicRepresentations") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("BasicRepresentations")).setText(ent.getBasicRepresentations().toString());
} else {
if (currentMap.get("BasicRepresentations") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("BasicRepresentations")).setText(ent.getBasicRepresentations().toString());
}
} else {
if (currentMap.get("BasicRepresentations") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("BasicRepresentations")).setText("");
else {
if (!(currentMap.get("BasicRepresentations") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("BasicRepresentations")).setText("");
}
}
}
if (currentMap.get("Recommendation")!=null){
if (ent!=null && ent.getRecommendation()!=null){
if (currentMap.get("Recommendation") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("Recommendation")).setText(ent.getRecommendation().toString());
} else {
if (currentMap.get("Recommendation") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("Recommendation")).setText(ent.getRecommendation().toString());
}
} else {
if (currentMap.get("Recommendation") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("Recommendation")).setText("");
else {
if (!(currentMap.get("Recommendation") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("Recommendation")).setText("");
}
}
}
if (currentMap.get("Package")!=null){
if (ent!=null && ent.getPackage()!=null){
if (currentMap.get("Package") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("Package")).setText(ent.getPackage().toString());
} else {
if (currentMap.get("Package") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("Package")).setText(ent.getPackage().toString());
}
} else {
if (currentMap.get("Package") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("Package")).setText("");
else {
if (!(currentMap.get("Package") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("Package")).setText("");
}
}
}
if (currentMap.get("Properties")!=null){
if (ent!=null && ent.getProperties()!=null){
if (currentMap.get("Properties") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("Properties")).setText(ent.getProperties().toString());
} else {
if (currentMap.get("Properties") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("Properties")).setText(ent.getProperties().toString());
}
} else {
if (currentMap.get("Properties") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("Properties")).setText("");
else {
if (!(currentMap.get("Properties") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("Properties")).setText("");
}
}
}
if (currentMap.get("ExampleId")!=null){
if (ent!=null && ent.getExampleId()!=null){
if (currentMap.get("ExampleId") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("ExampleId")).setText(ent.getExampleId().toString());
} else {
if (currentMap.get("ExampleId") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("ExampleId")).setText(ent.getExampleId().toString());
}
} else {
if (currentMap.get("ExampleId") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("ExampleId")).setText("");
else {
if (!(currentMap.get("ExampleId") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("ExampleId")).setText("");
}
}
}
if (currentMap.get("PreferredOrder")!=null){
if (ent!=null && ent.getPreferredOrder()!=null){
if (currentMap.get("PreferredOrder") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("PreferredOrder")).setText(ent.getPreferredOrder().toString());
} else {
if (currentMap.get("PreferredOrder") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("PreferredOrder")).setText(ent.getPreferredOrder().toString());
}
} else {
if (currentMap.get("PreferredOrder") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("PreferredOrder")).setText("");
else {
if (!(currentMap.get("PreferredOrder") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("PreferredOrder")).setText("");
}
}
}
if (currentMap.get("Instantiable")!=null){
if (ent!=null && ent.getInstantiable()!=null){
if (currentMap.get("Instantiable") instanceof javax.swing.JLabel){
((javax.swing.JLabel)( currentMap).get("Instantiable")).setText(ent.getInstantiable().toString());
} else {
if (currentMap.get("Instantiable") instanceof javax.swing.text.JTextComponent)
((javax.swing.text.JTextComponent)( currentMap).get("Instantiable")).setText(ent.getInstantiable().toString());
}
} else {
if (currentMap.get("Instantiable") instanceof javax.swing.JLabel)
((javax.swing.JLabel)( currentMap).get("Instantiable")).setText("");
else {
if (!(currentMap.get("Instantiable") instanceof ingenias.editor.rendererxml.CollectionPanel))
((javax.swing.text.JTextComponent)( currentMap).get("Instantiable")).setText("");
}
}
}
}
public Component getRendererComponent(JGraph graph,
CellView view, boolean sel,
boolean focus, boolean preview)
{
return RenderComponentManager.retrievePanel("MetaObject",
((Entity)((DefaultGraphCell)(view.getCell())).getUserObject()).getPrefs(graph.getModel().getAttributes(view.getCell())).getView());
}
public static JPanel setCurrent(ViewPreferences.ViewType c) {
current = ViewPreferences.ViewType.INGENIAS;
return (JPanel) RenderComponentManager.retrievePanel("MetaObject",current);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy