KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > parser > lib > PanelManager


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.util.explorer.parser.lib;
27
28 import java.util.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30
31 import org.objectweb.util.explorer.core.common.api.ExplorerConstants;
32 import org.objectweb.util.explorer.core.panel.api.CompositePanelDescription;
33 import org.objectweb.util.explorer.core.panel.api.PanelDescription;
34 import org.objectweb.util.explorer.core.panel.api.TableDescription;
35 import org.objectweb.util.explorer.core.panel.lib.BasicCompositePanelDescription;
36 import org.objectweb.util.explorer.core.panel.lib.BasicPanelDescription;
37 import org.objectweb.util.explorer.core.panel.lib.BasicTableDescription;
38 import org.objectweb.util.explorer.explorerConfig.Node;
39 import org.objectweb.util.explorer.explorerConfig.Panel;
40 import org.objectweb.util.explorer.explorerConfig.Table;
41 import org.objectweb.util.explorer.explorerConfig.beans.PanelBean;
42
43 /**
44  * This component manages the "panel" XML element.
45  *
46  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
47  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
48  *
49  * @version 0.1
50  */

51 public class PanelManager
52      extends AbstractNodeParser
53 {
54
55     //==================================================================
56
//
57
// Internal States.
58
//
59
// ==================================================================
60

61     // ==================================================================
62
//
63
// Constructors.
64
//
65
// ==================================================================
66

67     // ==================================================================
68
//
69
// Internal methods.
70
//
71
// ==================================================================
72

73     protected PanelDescription getPanelDescription(Table table){
74        TableDescription tableDescription = null;
75        if(table!=null && table.getCode()!=null){
76            tableDescription = new BasicTableDescription();
77            tableDescription.setCodeDescription(ParserUtils.getCodeDescription(table.getCode()));
78         }
79        return tableDescription;
80     }
81     
82     protected PanelDescription getPanelDescription(Panel panel){
83         PanelDescription panelDesc = null;
84         if(panel!=null){
85             if(panel.getCode()!=null){
86                 panelDesc = new BasicPanelDescription();
87                 panelDesc.setCodeDescription(ParserUtils.getCodeDescription(panel.getCode()));
88             } else {
89                 panelDesc = new BasicCompositePanelDescription();
90                 CompositePanelDescription compositePanel = (CompositePanelDescription)panelDesc;
91                 List JavaDoc subPanels = ((PanelBean)panel).getChildrenList();
92                 Iterator JavaDoc it = subPanels.iterator();
93                 while (it.hasNext()) {
94                     Object JavaDoc element = it.next();
95                     if(Panel.class.isAssignableFrom(element.getClass())){
96                         compositePanel.addPanelDescription(getPanelDescription((Panel)element));
97                     } else if (Table.class.isAssignableFrom(element.getClass())){
98                         compositePanel.addPanelDescription(getPanelDescription((Table)element));
99                     }
100                 }
101             }
102             panelDesc.setInheritTypePanel(panel.getInheritTypePanel().equals("false")?false:true);
103         }
104         return panelDesc;
105     }
106     
107     // ==================================================================
108
//
109
// Public methods for NodeParser interface.
110
//
111
// ==================================================================
112

113     /* (non-Javadoc)
114      * @see org.objectweb.util.explorer.parser.api.NodeParser#parseNode(java.lang.Object, org.objectweb.util.explorer.explorerConfig.Node)
115      */

116     public void parseNode(Object JavaDoc key, Node node) {
117         PanelDescription panelDesc = getPanelDescription(node.getPanel());
118         if(panelDesc!=null && !panelDesc.isEmpty()){
119             getFeeder().feed(ExplorerConstants.PANEL_PROPERTY, key, panelDesc);
120         }
121     }
122
123 }
124
125
126
Popular Tags