ingenias.editor.ProjectTreeRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ingened Show documentation
Show all versions of ingened Show documentation
Meta-language editor built over INGENME. It is the most basic editor to be used in the rest of projects
/**
* 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
**/
package ingenias.editor;
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
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.*;
public class ProjectTreeRenderer extends javax.swing.tree.DefaultTreeCellRenderer{
// Meta-models icons
static ImageIcon modeloMetamodel=new ImageIcon(ImageLoader.getImage("images/diag.gif"));
// Object icons
static ImageIcon PropertyFieldIcon=new ImageIcon(ImageLoader.getImage("images/mproperty.gif"));
static ImageIcon MetaObjectTypeWrapperIcon=new ImageIcon(ImageLoader.getImage("images/miusecase.gif"));
static ImageIcon MetaDiagramIcon=new ImageIcon(ImageLoader.getImage("images/mmetadiagram.gif"));
static ImageIcon ExternalTypeWrapperIcon=new ImageIcon(ImageLoader.getImage("images/miusecase.gif"));
static ImageIcon MetaRelationshipIcon=new ImageIcon(ImageLoader.getImage("images/mmetarel.gif"));
static ImageIcon DefaultValueIcon=new ImageIcon(ImageLoader.getImage("images/miusecase.gif"));
static ImageIcon PropertyOrderIcon=new ImageIcon(ImageLoader.getImage("images/miusecase.gif"));
static ImageIcon DocumentationIcon=new ImageIcon(ImageLoader.getImage("images/mproperty.gif"));
static ImageIcon PreferredOrderIcon=new ImageIcon(ImageLoader.getImage("images/mproperty.gif"));
static ImageIcon MetaObjectIcon=new ImageIcon(ImageLoader.getImage("images/mmetaobj.gif"));
static ImageIcon BasicRepresentationIcon=new ImageIcon(ImageLoader.getImage("images/basvisualrepr.gif"));
static ImageIcon VisualRepresentationIcon=new ImageIcon(ImageLoader.getImage("images/visualrepr.gif"));
static ImageIcon TypeWrapperIcon=new ImageIcon(ImageLoader.getImage("images/miusecase.gif"));
static ImageIcon UMLCommentIcon=new ImageIcon(ImageLoader.getImage("images/mumlcomment.gif"));
static ImageIcon MetaRoleIcon=new ImageIcon(ImageLoader.getImage("images/mmetarol.gif"));
static ImageIcon MetaDiagramTypeWrapperIcon=new ImageIcon(ImageLoader.getImage("images/miusecase.gif"));
static ImageIcon ConventionalFolderIcon=new ImageIcon(ImageLoader.getImage("images/folder.png"));
static ImageIcon RootFolderIcon=new ImageIcon(ImageLoader.getImage("images/world.png"));
public ProjectTreeRenderer() {
super();
}
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(
tree, value, sel,
expanded, leaf, row,
hasFocus);
ImageIcon img=this.selectIcon(value);
if (row==0)
img=RootFolderIcon;
if (img!=null) {
setIcon(img);
return this;
} else
return super.getTreeCellRendererComponent(tree,value,sel,expanded,leaf,row,hasFocus);
}
public static ImageIcon selectIcon(Object value) {
DefaultMutableTreeNode node =
(DefaultMutableTreeNode)value;
return selectIconByUserObject(node.getUserObject());
}
public static String getIconNameByUserObject(Object userObject) {
if (userObject.getClass().equals(String.class))
return "images/folder.png";
if (userObject.getClass().equals(PropertyField.class))
return "images/mproperty.gif";
if (userObject.getClass().equals(MetaObjectTypeWrapper.class))
return "images/miusecase.gif";
if (userObject.getClass().equals(MetaDiagram.class))
return "images/mmetadiagram.gif";
if (userObject.getClass().equals(ExternalTypeWrapper.class))
return "images/miusecase.gif";
if (userObject.getClass().equals(MetaRelationship.class))
return "images/mmetarel.gif";
if (userObject.getClass().equals(DefaultValue.class))
return "images/miusecase.gif";
if (userObject.getClass().equals(PropertyOrder.class))
return "images/miusecase.gif";
if (userObject.getClass().equals(Documentation.class))
return "images/mproperty.gif";
if (userObject.getClass().equals(PreferredOrder.class))
return "images/mproperty.gif";
if (userObject.getClass().equals(MetaObject.class))
return "images/mmetaobj.gif";
if (userObject.getClass().equals(BasicRepresentation.class))
return "images/basvisualrepr.gif";
if (userObject.getClass().equals(VisualRepresentation.class))
return "images/visualrepr.gif";
if (userObject.getClass().equals(TypeWrapper.class))
return "images/miusecase.gif";
if (userObject.getClass().equals(UMLComment.class))
return "images/mumlcomment.gif";
if (userObject.getClass().equals(MetaRole.class))
return "images/mmetarol.gif";
if (userObject.getClass().equals(MetaDiagramTypeWrapper.class))
return "images/miusecase.gif";
if (userObject.getClass().equals(ingenias.editor.models.MetamodelModelJGraph.class))
return "images/diag.gif";
return null;
}
public static ImageIcon selectIconByUserObject(Object userObject) {
if (userObject.getClass().equals(String.class))
return ConventionalFolderIcon;
if (userObject.getClass().equals(PropertyField.class))
return PropertyFieldIcon;
if (userObject.getClass().equals(MetaObjectTypeWrapper.class))
return MetaObjectTypeWrapperIcon;
if (userObject.getClass().equals(MetaDiagram.class))
return MetaDiagramIcon;
if (userObject.getClass().equals(ExternalTypeWrapper.class))
return ExternalTypeWrapperIcon;
if (userObject.getClass().equals(MetaRelationship.class))
return MetaRelationshipIcon;
if (userObject.getClass().equals(DefaultValue.class))
return DefaultValueIcon;
if (userObject.getClass().equals(PropertyOrder.class))
return PropertyOrderIcon;
if (userObject.getClass().equals(Documentation.class))
return DocumentationIcon;
if (userObject.getClass().equals(PreferredOrder.class))
return PreferredOrderIcon;
if (userObject.getClass().equals(MetaObject.class))
return MetaObjectIcon;
if (userObject.getClass().equals(BasicRepresentation.class))
return BasicRepresentationIcon;
if (userObject.getClass().equals(VisualRepresentation.class))
return VisualRepresentationIcon;
if (userObject.getClass().equals(TypeWrapper.class))
return TypeWrapperIcon;
if (userObject.getClass().equals(UMLComment.class))
return UMLCommentIcon;
if (userObject.getClass().equals(MetaRole.class))
return MetaRoleIcon;
if (userObject.getClass().equals(MetaDiagramTypeWrapper.class))
return MetaDiagramTypeWrapperIcon;
if (userObject.getClass().equals(ingenias.editor.models.MetamodelModelJGraph.class))
return modeloMetamodel;
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy