KickJava   Java API By Example, From Geeks To Geeks.

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


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.apollon.gui.ApollonFrame;
30
31 /**
32  * This is the CCM Menu Bar for OpenCCM's Packaging/Assembling Tool
33  *
34  * @author <a HREF="mailto:Christophe.Contreras@lifl.fr">Christophe Contreras</a>
35  *
36  */

37 public class CCMMenuBar
38   implements java.awt.event.ActionListener JavaDoc
39 {
40     // ==================================================================
41
//
42
// Internal state.
43
//
44
// ==================================================================
45

46     /** the associated frame */
47     private ApollonFrame frame_;
48
49     // ==================================================================
50
//
51
// Constructors
52
//
53
// ==================================================================
54

55     public
56     CCMMenuBar(ApollonFrame frame)
57     {
58         this.frame_ = frame;
59
60         javax.swing.JMenu JavaDoc archive_menu = new javax.swing.JMenu JavaDoc("CCM");
61
62         javax.swing.JMenuItem JavaDoc openitem = new javax.swing.JMenuItem JavaDoc("Open Archive...");
63         openitem.setActionCommand("Open");
64         openitem.addActionListener(this);
65         archive_menu.add(openitem);
66
67         this.frame_.getJMenuBar().add(archive_menu);
68     }
69
70     /**
71      * When an action is performed on this frame.
72      *
73      */

74     public void
75     actionPerformed(java.awt.event.ActionEvent JavaDoc e)
76     {
77
78         if (e.getActionCommand().equals("Open"))
79         {
80             // get a file from an open dialog box
81
java.io.File JavaDoc file=null;
82             javax.swing.JFileChooser JavaDoc dialogBox
83              = new javax.swing.JFileChooser JavaDoc(
84                 System.getProperty("user.dir")
85                 );
86             int returnVal = dialogBox.showOpenDialog(new javax.swing.JPanel JavaDoc());
87
88             if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION)
89             {
90                 file = dialogBox.getSelectedFile().getAbsoluteFile();
91             }
92             else
93                 return;
94
95             FileOperations.open_file(file,frame_);
96         }
97     }
98 }
99
Popular Tags