KickJava   Java API By Example, From Geeks To Geeks.

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


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

26 package org.objectweb.openccm.explorer.DCI;
27
28 import org.objectweb.util.explorer.api.DropAction;
29 import org.objectweb.util.explorer.api.DropTreeView;
30 import org.objectweb.util.explorer.swing.gui.api.DialogAction;
31 import org.objectweb.util.explorer.swing.gui.api.DialogBox;
32 import org.objectweb.util.explorer.swing.gui.lib.DefaultDialogBox;
33 import org.objectweb.util.explorer.swing.gui.lib.LabelBox;
34 import org.omg.Components.CCMHome;
35 import org.omg.Components.HomeRegistration;
36
37 /**
38  * This action registers a <code>CCMHome</code> into the given <code>HomeRegistration</code>.
39  *
40  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
41  *
42  * @version 0.1
43  */

44 public class RegisterHomeAction
45   implements DropAction, DialogAction
46 {
47
48     //==================================================================
49
//
50
// Internal states.
51
//
52
//==================================================================
53

54     protected HomeRegistration home_registration_;
55
56     protected LabelBox name_;
57
58     protected CCMHome home_ = null;
59
60     //==================================================================
61
//
62
// No constructor.
63
//
64
//==================================================================
65

66     //==================================================================
67
//
68
// No internal method.
69
//
70
//==================================================================
71

72     //==================================================================
73
//
74
// Public methods for DropAction interface.
75
//
76
//==================================================================
77

78     public void execute(DropTreeView e) throws Exception JavaDoc {
79         home_registration_ = (HomeRegistration)e.getSelectedObject();
80         if(CCMHome.class.isAssignableFrom(e.getDragSourceObject().getClass())){
81             home_ = (CCMHome)e.getDragSourceObject();
82             String JavaDoc defaultName = e.getDragSourceEntry().getName().toString();
83             DialogBox dialog = new DefaultDialogBox("Register an home");
84             name_ = new LabelBox("Home name", defaultName);
85             dialog.addElementBox(name_);
86             dialog.setValidateAction(this);
87             dialog.show();
88         } else {
89             throw new Exception JavaDoc("CCMHome expected !");
90         }
91     }
92
93     //==================================================================
94
//
95
// Public methods for DialogAction interface.
96
//
97
//==================================================================
98

99     /**
100      * Executes an action
101      */

102     public void executeAction() throws Exception JavaDoc {
103         // The InterfaceRepository must be started for obtaining this data.
104
String JavaDoc component_repid = "ir3_not_started";
105         String JavaDoc home_repid = "ir3_not_started";
106 // try{
107
// IRObject component_def = home_.get_component_def();
108
// IRObject home_def = home_.get_home_def();
109
// } catch(Exception e) {
110
// // Ignore
111
// }
112
home_registration_.register_home(home_, home_repid, component_repid, name_.getLabel());
113     }
114
115 }
116
Popular Tags