KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > filetransfer > explorer > ProgCreationAction


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): Jérôme Moroy, Areski Flissi.
23 Contributor(s): ______________________________________.
24
25 ===========================================================================*/

26
27 package org.objectweb.ccm.filetransfer.explorer;
28
29 import java.awt.Component JavaDoc;
30 import javax.swing.JOptionPane JavaDoc;
31 import java.io.File JavaDoc;
32 import java.io.BufferedReader JavaDoc;
33 import java.io.FileReader JavaDoc;
34
35 import org.objectweb.ccm.filetransfer.Prog;
36 import org.objectweb.ccm.filetransfer.ProgHome;
37 import org.objectweb.openccm.explorer.menu.OpenCCMBrowserConstants;
38 import org.objectweb.openccm.explorer.menu.JFileChooserSingleton;
39 import org.objectweb.util.explorer.api.MenuItemTreeView;
40 import org.objectweb.util.explorer.api.MenuItem;
41 import org.objectweb.util.explorer.api.TreeView;
42 import org.objectweb.util.explorer.swing.gui.api.DialogAction;
43 import org.objectweb.util.explorer.swing.gui.api.DialogBox;
44 import org.objectweb.util.explorer.swing.gui.lib.DefaultDialogBox;
45 import org.objectweb.util.explorer.swing.gui.lib.LabelBox;
46 import org.objectweb.util.explorer.swing.gui.lib.FileChooserBox;
47
48 /**
49  *
50  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>,
51  * <a HREF="mailto:Areski.Flissi@lifl.fr">Areski Flissi</a>
52  * @version 0.1
53  */

54 public class ProgCreationAction
55   implements MenuItem, DialogAction
56 {
57
58     //==================================================================
59
//
60
// Internal states.
61
//
62
//==================================================================
63

64     protected FileChooserBox channelDir_;
65     
66     protected ProgHome progHome_;
67     
68     //==================================================================
69
//
70
// No constructor.
71
//
72
//==================================================================
73

74     //==================================================================
75
//
76
//No internal method.
77
//
78
//==================================================================
79

80     //==================================================================
81
//
82
// Public methods for MenuItem interface.
83
//
84
//==================================================================
85

86     public int getStatus(TreeView arg0){
87         return MenuItem.ENABLED_STATUS;
88     }
89
90     public void actionPerformed(MenuItemTreeView e) throws Exception JavaDoc {
91         progHome_ = (ProgHome) e.getSelectedObject();
92         DialogBox dialogBox = new DefaultDialogBox("Choose a Program directory");
93         channelDir_ = new FileChooserBox("Dir",JFileChooserSingleton.getInstance(OpenCCMBrowserConstants.DIRECTORY_FILE_CHOOSER));
94         dialogBox.addElementBox(channelDir_);
95         dialogBox.setValidateAction(this);
96         dialogBox.setValidateLabel("Create");
97         dialogBox.setCancelLabel("Cancel");
98         dialogBox.show();
99     }
100
101     //==================================================================
102
//
103
// Public methods for DialogAction interface.
104
//
105
//==================================================================
106

107     /**
108      * Executes an action
109      */

110     public void executeAction() throws Exception JavaDoc {
111         File JavaDoc f = channelDir_.getFile();
112         if (f != null && f.exists()) {
113             String JavaDoc name = f.getName();
114             Prog p = progHome_.create();
115             p.the_name(name);
116         }
117     }
118
119 }
Popular Tags