KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > DCI > DCIInstalledAssembliesTable


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
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.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.explorer.DCI;
28
29 import java.util.Vector JavaDoc;
30
31 import org.ist.coach.DCI.AssemblyManager;
32 import org.ist.coach.DCI.DCIDeployment;
33 import org.ist.coach.DCI.DCIInformation;
34 import org.ist.coach.DCI.DCIManager;
35 import org.ist.coach.DCI.UnknownAssembly;
36 import org.objectweb.util.explorer.api.Table;
37 import org.objectweb.util.explorer.api.TreeView;
38 import org.objectweb.util.explorer.core.naming.lib.DefaultEntry;
39
40 /**
41  * Displays the installed assemblies for the given DCIManager.
42  *
43  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
44  *
45  * @version 0.1
46  */

47 public class DCIInstalledAssembliesTable
48   implements Table
49 {
50
51     //==================================================================
52
//
53
// Internal states.
54
//
55
//==================================================================
56

57     //==================================================================
58
//
59
// No constructor.
60
//
61
//==================================================================
62

63     // ==================================================================
64
//
65
// Internal methods.
66
//
67
// ==================================================================
68

69     /**
70      * Provides a name depending on the AssemblyManager id.
71      */

72     protected String JavaDoc getName(AssemblyManager assemblyManager){
73         String JavaDoc returnedValue = "Assembly ";
74         String JavaDoc assemblyId = assemblyManager.ass_id();
75         if(assemblyId.indexOf(":")!=-1)
76             returnedValue = assemblyId.substring(0,assemblyId.indexOf(":"));
77         return returnedValue;
78     }
79
80     /**
81      * Provides a name depending on the AssemblyManager id.
82      */

83     protected String JavaDoc getName(String JavaDoc assemblyUUID){
84         String JavaDoc returnedValue = "Assembly ";
85         if(assemblyUUID!=null && assemblyUUID.indexOf(":")!=-1)
86             returnedValue = assemblyUUID.substring(0,assemblyUUID.indexOf(":")) + " Assembly";
87         return returnedValue;
88     }
89     
90     //==================================================================
91
//
92
// Public methods for Table interface.
93
//
94
//==================================================================
95

96     /* (non-Javadoc)
97      * @see org.objectweb.util.explorer.api.Table#getHeaders(org.objectweb.util.explorer.api.TreeView)
98      */

99     public String JavaDoc[] getHeaders(TreeView treeView) {
100         return new String JavaDoc[]{"Model","Assemblies"};
101     }
102     
103     /* (non-Javadoc)
104      * @see org.objectweb.util.explorer.api.Table#getRows(org.objectweb.util.explorer.api.TreeView)
105      */

106     public Object JavaDoc[][] getRows(TreeView treeView) {
107         DCIManager DCIManager_ = (DCIManager)treeView.getSelectedObject();
108         DCIInformation DCIInfo = DCIManager_.provide_dci_information();
109         DCIDeployment DCIDeploy = DCIManager_.provide_dci_deployment();
110         String JavaDoc[] assemblyUUIDs = DCIDeploy.get_assemblies();
111         
112         Vector JavaDoc values = new Vector JavaDoc();
113         for (int i = 0; i < assemblyUUIDs.length; i++){
114             // Calculating the assemblies for this model.
115
try{
116                 String JavaDoc[] instanceUUID = DCIDeploy.get_assembly_instances(assemblyUUIDs[i]);
117                 if(instanceUUID.length>0){
118                     boolean isFirst = true;
119                     for (int j = 0; j < instanceUUID.length; j++) {
120                         AssemblyManager assemblyManager = DCIDeploy.get_assembly_manager(instanceUUID[j]);
121                         AssemblyManagerWrapperWithDCIDeployment am = new AssemblyManagerWrapperWithDCIDeployment();
122                         am.setAssemblyManager(assemblyManager);
123                         am.setDCIDeployment(DCIDeploy);
124                         am.setUUID(instanceUUID[j]);
125                         if(isFirst){
126                             isFirst = false;
127                             values.add(new Object JavaDoc[]{new DefaultEntry(getName(assemblyUUIDs[i]) + " (" + (i+1) + ")", new AssemblyUUIDWrapper(assemblyUUIDs[i],DCIDeploy)), new DefaultEntry(getName(assemblyManager) + " (" + (j+1) + ")", am)});
128                         } else {
129                             values.add(new Object JavaDoc[]{null,new DefaultEntry(getName(assemblyManager) + " (" + (j+1) + ")", am)});
130                         }
131                     }
132                 } else {
133                     values.add(new Object JavaDoc[]{new DefaultEntry(getName(assemblyUUIDs[i]) + " (" + (i+1) + ")", new AssemblyUUIDWrapper(assemblyUUIDs[i],DCIDeploy)),null});
134                 }
135             } catch (UnknownAssembly e) {
136                 e.printStackTrace();
137             }
138         }
139              
140         Object JavaDoc[][] contenu = new Object JavaDoc[values.size()][2];
141         for(int i=0 ; i<values.size() ; i++){
142             contenu[i] = (Object JavaDoc[])values.get(i);
143         }
144         
145         return contenu;
146     }
147 }
148
Popular Tags