KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > CosTrading > AddQuery


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): Sylvain Leblanc.
23 Contributor(s): ______________________________________.
24
25 ===========================================================================*/

26
27 package org.objectweb.openccm.explorer.CosTrading;
28
29 import java.awt.Component JavaDoc;
30 import java.awt.event.ActionEvent JavaDoc;
31
32 import javax.swing.JOptionPane JavaDoc;
33
34 import org.objectweb.openccm.explorer.CosTrading.gui.AddQueryPanel;
35 import org.objectweb.util.explorer.api.MenuItem;
36 import org.objectweb.util.explorer.api.MenuItemTreeView;
37 import org.objectweb.util.explorer.api.TreeView;
38
39 /**
40  * This action creates a new query.
41  *
42  * @author <a HREF="mailto:Sylvain.Leblanc@lifl.fr">Sylvain Leblanc</a>
43  * @version 0.1
44  */

45 public class AddQuery
46   implements MenuItem
47 {
48
49     // ==================================================================
50
//
51
// Internal state.
52
//
53
// ==================================================================
54

55     // ==================================================================
56
//
57
// Constructors.
58
//
59
// ==================================================================
60

61     // ==================================================================
62
//
63
// Internal methods.
64
//
65
// ==================================================================
66

67     // ==================================================================
68
//
69
// Public methods.
70
//
71
// ==================================================================
72

73     /* (non-Javadoc)
74      * @see org.objectweb.util.explorer.api.MenuItem#getStatus(org.objectweb.util.explorer.api.TreeView)
75      */

76     public int getStatus(TreeView arg0){
77         return MenuItem.ENABLED_STATUS;
78     }
79
80     /* (non-Javadoc)
81      * @see org.objectweb.util.explorer.api.MenuItem#actionPerformed(org.objectweb.util.explorer.api.MenuItemTreeView)
82      */

83     public void actionPerformed(MenuItemTreeView e) {
84
85         Queries queries = (Queries) e.getSelectedObject();
86         AddQueryPanel lp = new AddQueryPanel(queries);
87
88         ActionEvent JavaDoc ae = (ActionEvent JavaDoc)e.getEvent();
89         
90         int result =
91             JOptionPane.showOptionDialog(
92                 (Component JavaDoc) ae.getSource(),
93                 lp,
94                 "Create a new query",
95                 JOptionPane.OK_CANCEL_OPTION,
96                 JOptionPane.PLAIN_MESSAGE,
97                 null,
98                 null,
99                 null);
100
101         if (result == 0) {
102             String JavaDoc label = lp.getQueryLabel();
103             String JavaDoc st = lp.getServiceTypeName();
104             String JavaDoc constr = lp.getConstraint();
105             String JavaDoc pref = lp.getPref();
106             
107             if (st != null && st.length() > 0 &&
108                 constr != null && pref != null)
109                 queries.addQuery(new Query(label, queries, st, constr, pref, lp.getPolicies()));
110             else
111                 JOptionPane.showMessageDialog(null, "Invalid parameters !", "Error !", JOptionPane.ERROR_MESSAGE);
112         }
113     }
114 }
115
Popular Tags