KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > gui > TitlePane


1 /***
2  * FractalGUI: a graphical tool to edit Fractal component configurations.
3  * Copyright (C) 2003 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: fractal@objectweb.org
20  *
21  * Authors: Eric Bruneton, Patrice Fauvel
22  */

23
24 package org.objectweb.fractal.gui;
25
26 import org.objectweb.fractal.swing.JTabbedPaneImpl;
27 import org.objectweb.fractal.gui.model.ConfigurationListener;
28 import org.objectweb.fractal.gui.model.Component;
29 import org.objectweb.fractal.gui.model.Interface;
30 import org.objectweb.fractal.gui.model.ClientInterface;
31 import org.objectweb.fractal.gui.model.ServerInterface;
32
33 public class TitlePane extends JTabbedPaneImpl
34   implements ConfigurationListener
35 {
36
37   // -------------------------------------------------------------------------
38
// Implementation of the ConfigurationListener interface
39
// -------------------------------------------------------------------------
40

41   public void changeCountChanged (Component component, long changeCount) {
42     updateTitle(component);
43   }
44
45   public void rootComponentChanged (final Component oldValue) {
46     // does nothing
47
}
48
49   public void nameChanged (final Component component, final String JavaDoc oldValue) {
50     updateTitle(component);
51   }
52
53   public void typeChanged (final Component component, final String JavaDoc oldValue) {
54     updateTitle(component);
55   }
56
57   public void implementationChanged (
58     final Component component,
59     final String JavaDoc oldValue)
60   {
61     updateTitle(component);
62   }
63
64   public void interfaceNameChanged (final Interface i, final String JavaDoc oldValue) {
65     updateTitle(i.getOwner());
66   }
67
68   public void interfaceSignatureChanged (
69     final Interface i,
70     final String JavaDoc oldValue)
71   {
72     updateTitle(i.getOwner());
73   }
74
75   public void interfaceContingencyChanged (
76     final Interface i,
77     final boolean oldValue)
78   {
79     updateTitle(i.getOwner());
80   }
81
82   public void interfaceCardinalityChanged (
83     final Interface i,
84     final boolean oldValue)
85   {
86     updateTitle(i.getOwner());
87   }
88
89   public void clientInterfaceAdded (
90     final Component component,
91     final ClientInterface i,
92     final int index)
93   {
94     updateTitle(component);
95   }
96
97   public void clientInterfaceRemoved (
98     final Component component,
99     final ClientInterface i,
100     final int index)
101   {
102     updateTitle(component);
103   }
104
105   public void serverInterfaceAdded (
106     final Component component,
107     final ServerInterface i,
108     final int index)
109   {
110     updateTitle(component);
111   }
112
113   public void serverInterfaceRemoved (
114     final Component component,
115     final ServerInterface i,
116     final int index)
117   {
118     updateTitle(component);
119   }
120
121   public void interfaceBound (
122     final ClientInterface citf, final ServerInterface sitf)
123   {
124     updateTitle(citf.getOwner());
125   }
126
127   public void interfaceRebound (
128     final ClientInterface citf,
129     final ServerInterface oldSitf)
130   {
131     updateTitle(citf.getOwner());
132   }
133
134   public void interfaceUnbound (
135     final ClientInterface citf,
136     final ServerInterface sitf)
137   {
138     updateTitle(citf.getOwner());
139   }
140
141   public void attributeControllerChanged (
142     final Component component,
143     final String JavaDoc oldValue)
144   {
145     updateTitle(component);
146   }
147
148   public void attributeChanged (
149     final Component component,
150     final String JavaDoc attributeName,
151     final String JavaDoc oldValue)
152   {
153     updateTitle(component);
154   }
155
156   public void templateControllerDescriptorChanged (
157     final Component component,
158     final String JavaDoc oldValue)
159   {
160     updateTitle(component);
161   }
162
163   public void componentControllerDescriptorChanged (
164     final Component component,
165     final String JavaDoc oldValue)
166   {
167     updateTitle(component);
168   }
169
170   public void subComponentAdded (
171     final Component parent,
172     final Component child,
173     final int index)
174   {
175     updateTitle(parent);
176   }
177
178   public void subComponentRemoved (
179     final Component parent,
180     final Component child,
181     final int index)
182   {
183     updateTitle(parent);
184   }
185
186   // -------------------------------------------------------------------------
187
// Other methods
188
// -------------------------------------------------------------------------
189

190   private void updateTitle (final Component c) {
191     String JavaDoc title = c.getRootComponent().getName();
192     if (c.getConfiguration().getChangeCount() != 0) {
193       title += "*";//+c.getConfiguration().getChangeCount();
194
}
195     if (!getTitleAt(0).equals(title)) {
196       setTitleAt(0, title);
197     }
198   }
199 }
200
Popular Tags