001 /* 002 Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com> 003 004 This program is free software; you can redistribute it and/or modify 005 it under the terms of the GNU Lesser General Public License as 006 published by the Free Software Foundation; either version 2 of the 007 License, or (at your option) any later version. 008 009 This program is distributed in the hope that it will be useful, but 010 WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 Lesser General Public License for more details. 013 014 You should have received a copy of the GNU Lesser General Public 015 License along with this program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 017 USA */ 018 019 package org.objectweb.jac.aspects.gui; 020 021 import org.objectweb.jac.core.rtti.ClassItem; 022 import org.objectweb.jac.core.rtti.FieldItem; 023 import org.objectweb.jac.core.rtti.MemberItem; 024 import org.objectweb.jac.core.rtti.MethodItem; 025 026 /** 027 * Defines a generic object view (attributes order, tabs, ...) 028 */ 029 public class ObjectView { 030 ClassItem cl; 031 String name; 032 ObjectView parent; 033 034 public ObjectView(ClassItem cl, String name) { 035 this.cl = cl; 036 this.name = name; 037 } 038 039 public ObjectView(ClassItem cl, String name, ObjectView parent) { 040 this.cl = cl; 041 this.parent = parent; 042 this.name = name; 043 } 044 045 public String getName() { 046 return name; 047 } 048 049 FieldItem[] attributesOrder; 050 public void setAttributesOrder(FieldItem[] attributesOrder) { 051 this.attributesOrder = attributesOrder; 052 } 053 /** 054 * If no attributesOrder were configured for this view, try the 055 * parent view, and then the view of the super class. 056 */ 057 public FieldItem[] getAttributesOrder() { 058 if (attributesOrder!=null) { 059 return attributesOrder; 060 } else { 061 if (parent!=null) 062 return parent.getAttributesOrder(); 063 else { 064 ClassItem superClass = cl.getSuperclass(); 065 if (superClass!=null) 066 return GuiAC.getView(superClass,name).getAttributesOrder(); 067 else 068 return null; 069 } 070 } 071 } 072 073 MethodItem[] methodsOrder; 074 public void setMethodsOrder(MethodItem[] methods) { 075 this.methodsOrder = methods; 076 } 077 /** 078 * If no methodsOrder were configured for this view, try the 079 * parent view. 080 */ 081 public MethodItem[] getMethodsOrder() { 082 if (methodsOrder!=null) { 083 return methodsOrder; 084 } else { 085 if (parent!=null) 086 return parent.getMethodsOrder(); 087 else 088 return null; 089 } 090 } 091 092 MemberItem[] tableMembersOrder; 093 public void setTableMembersOrder(MemberItem[] members) { 094 this.tableMembersOrder = members; 095 } 096 /** 097 * If no tableMembersOrder were configured for this view, try the 098 * parent view. 099 */ 100 public MemberItem[] getTableMembersOrder() { 101 if (tableMembersOrder!=null) { 102 return tableMembersOrder; 103 } else { 104 if (parent!=null) 105 return parent.getTableMembersOrder(); 106 else 107 return null; 108 } 109 } 110 111 String[] categories; 112 public void setCategories(String[] categories) { 113 this.categories = categories; 114 } 115 public String[] getCategories() { 116 if (categories!=null) { 117 return categories; 118 } else { 119 if (parent!=null) 120 return parent.getCategories(); 121 else 122 return null; 123 } 124 } 125 126 /** wether fields should be editable */ 127 boolean readOnly; 128 public boolean isReadOnly() { 129 return readOnly; 130 } 131 public void setReadOnly(boolean newReadOnly) { 132 this.readOnly = newReadOnly; 133 } 134 135 boolean enableLinks = true; 136 public void setEnableLinks(boolean enable) { 137 this.enableLinks = enable; 138 } 139 public boolean areLinksEnabled() { 140 return enableLinks; 141 } 142 }