KickJava   Java API By Example, From Geeks To Geeks.

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


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.properties.beans.PropertiesBean;
30 import org.objectweb.openccm.descriptor.properties.beans.PropertiesBeanImpl;
31
32 /**
33  * This is the action class for opening a CPF from an assembly
34  *
35  */

36 public class ComponentpropertiesEditActionListener
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.componentassembly.beans.ComponentpropertiesBean cpf_file
65          = (org.objectweb.openccm.descriptor.componentassembly.beans.ComponentpropertiesBean)
66            the_event.getSelectedObject();
67
68
69         java.io.File JavaDoc properties
70          = new java.io.File JavaDoc(cpf_file.getFileinarchive().getName());
71
72         // file is new
73
if (!properties.exists())
74         {
75             PropertiesBean properties_instance
76              = new PropertiesBeanImpl();
77
78             properties_instance.setDocType("properties","","dtd/properties.dtd");
79
80             try {
81                 properties_instance.marshalBean(
82                     new java.io.File JavaDoc(cpf_file.getFileinarchive().getName())
83                     );
84             } catch (Exception JavaDoc exception) {
85                 exception.printStackTrace();
86             }
87         }
88         else
89         {
90             // file exists
91
}
92
93         FileOperations.open_file(
94             new java.io.File JavaDoc(cpf_file.getFileinarchive().getName())
95             , calling_frame
96             );
97     }
98 }
99
Popular Tags