KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > packaging > DescriptorEditActionListener


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): Christophe Contreras
23 Contributor(s): ___________________________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.packaging;
28
29 import org.objectweb.openccm.descriptor.corbacomponent.beans.CorbacomponentBean;
30 import org.objectweb.openccm.descriptor.corbacomponent.beans.CorbacomponentBeanImpl;
31
32 /**
33  * This is the action class for opening a CCD from a software package descriptor
34  *
35  */

36 public class DescriptorEditActionListener
37   implements org.objectweb.util.browser.api.MenuItem
38 {
39     /**
40      * Status of the menu item
41      *
42      * @param treeView to obtain the activated node
43      */

44     public int
45     getStatus(org.objectweb.util.browser.api.TreeView treeView)
46     {
47         return org.objectweb.util.browser.api.MenuItem.ENABLED_STATUS;
48     }
49
50     public void
51     actionPerformed (org.objectweb.util.browser.api.MenuItemTreeView the_event)
52     {
53         // gets the calling tree
54
org.objectweb.util.browser.core.common.DynamicTree calling_tree
55          = (org.objectweb.util.browser.core.common.DynamicTree)
56            the_event.getTree();
57
58         //gets the frame
59
org.objectweb.apollon.gui.ApollonFrame calling_frame
60          = (org.objectweb.apollon.gui.ApollonFrame)
61             calling_tree.getRootPane().getParent();
62
63         // gets the calling XML element
64
org.objectweb.openccm.descriptor.softpkg.beans.DescriptorBean ccd_file
65          = (org.objectweb.openccm.descriptor.softpkg.beans.DescriptorBean)
66            the_event.getSelectedObject();
67
68         java.io.File JavaDoc corbacomponent
69          = new java.io.File JavaDoc(ccd_file.getFileinarchive().getName());
70
71         // file is new
72
if (!corbacomponent.exists())
73         {
74             CorbacomponentBean ccd_instance
75              = new CorbacomponentBeanImpl();
76
77             ccd_instance.setDocType("corbacomponent","","dtd/corbacomponent.dtd");
78
79             try {
80                 ccd_instance.marshalBean(
81                     new java.io.File JavaDoc(ccd_file.getFileinarchive().getName())
82                     );
83             } catch (Exception JavaDoc exception) {
84                 exception.printStackTrace();
85             }
86         }
87         else
88         {
89             // file exists
90
}
91
92         FileOperations.open_file(
93             new java.io.File JavaDoc(ccd_file.getFileinarchive().getName())
94             , calling_frame
95             );
96     }
97 }
98
Popular Tags