KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > ObjectView


1 /*
2   Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com>
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.aspects.gui;
20
21 import org.objectweb.jac.core.rtti.ClassItem;
22 import org.objectweb.jac.core.rtti.FieldItem;
23 import org.objectweb.jac.core.rtti.MemberItem;
24 import org.objectweb.jac.core.rtti.MethodItem;
25
26 /**
27  * Defines a generic object view (attributes order, tabs, ...)
28  */

29 public class ObjectView {
30     ClassItem cl;
31     String JavaDoc name;
32     ObjectView parent;
33
34     public ObjectView(ClassItem cl, String JavaDoc name) {
35         this.cl = cl;
36         this.name = name;
37     }
38
39     public ObjectView(ClassItem cl, String JavaDoc name, ObjectView parent) {
40         this.cl = cl;
41         this.parent = parent;
42         this.name = name;
43     }
44
45     public String JavaDoc getName() {
46         return name;
47     }
48
49     FieldItem[] attributesOrder;
50     public void setAttributesOrder(FieldItem[] attributesOrder) {
51         this.attributesOrder = attributesOrder;
52     }
53     /**
54      * If no attributesOrder were configured for this view, try the
55      * parent view, and then the view of the super class.
56      */

57     public FieldItem[] getAttributesOrder() {
58         if (attributesOrder!=null) {
59             return attributesOrder;
60         } else {
61             if (parent!=null)
62                 return parent.getAttributesOrder();
63             else {
64                 ClassItem superClass = cl.getSuperclass();
65                 if (superClass!=null)
66                     return GuiAC.getView(superClass,name).getAttributesOrder();
67                 else
68                     return null;
69             }
70         }
71     }
72
73     MethodItem[] methodsOrder;
74     public void setMethodsOrder(MethodItem[] methods) {
75         this.methodsOrder = methods;
76     }
77     /**
78      * If no methodsOrder were configured for this view, try the
79      * parent view.
80      */

81     public MethodItem[] getMethodsOrder() {
82         if (methodsOrder!=null) {
83             return methodsOrder;
84         } else {
85             if (parent!=null)
86                 return parent.getMethodsOrder();
87             else {
88                 ClassItem superClass = cl.getSuperclass();
89                 if (superClass!=null)
90                     return GuiAC.getView(superClass,name).getMethodsOrder();
91                 else
92                     return null;
93             }
94         }
95     }
96
97     MemberItem[] tableMembersOrder;
98     public void setTableMembersOrder(MemberItem[] members) {
99         this.tableMembersOrder = members;
100     }
101     /**
102      * If no tableMembersOrder were configured for this view, try the
103      * parent view.
104      */

105     public MemberItem[] getTableMembersOrder() {
106         if (tableMembersOrder!=null) {
107         return tableMembersOrder;
108         } else {
109             if (parent!=null)
110                 return parent.getTableMembersOrder();
111             else
112                 return null;
113         }
114     }
115
116     String JavaDoc[] categories;
117     public void setCategories(String JavaDoc[] categories) {
118         this.categories = categories;
119     }
120     public String JavaDoc[] getCategories() {
121         if (categories!=null) {
122             return categories;
123         } else {
124             if (parent!=null)
125                 return parent.getCategories();
126             else
127                 return null;
128         }
129     }
130
131     /** wether fields should be editable */
132     boolean readOnly;
133     public boolean isReadOnly() {
134         return readOnly;
135     }
136     public void setReadOnly(boolean newReadOnly) {
137         this.readOnly = newReadOnly;
138     }
139
140     boolean enableLinks = true;
141     public void setEnableLinks(boolean enable) {
142         this.enableLinks = enable;
143     }
144     public boolean areLinksEnabled() {
145         return enableLinks;
146     }
147 }
148
Popular Tags