KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > InvokeServiceAction


1 /*====================================================================
2  
3  Objectweb Browser Framework
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): Jerome Moroy.
23  Contributor(s): ______________________________________.
24  
25  ---------------------------------------------------------------------
26  $Id: InvokeServiceAction.java,v 1.2 2004/04/28 15:04:13 moroy Exp $
27  ====================================================================*/

28
29 /** The console's imports */
30 import javax.swing.Box JavaDoc;
31 import javax.swing.JOptionPane JavaDoc;
32
33 /** The Browser API's imports*/
34 import org.objectweb.util.browser.api.MenuItem;
35 import org.objectweb.util.browser.api.MenuItemTreeView;
36 import org.objectweb.util.browser.api.TreeView;
37 import org.objectweb.util.browser.gui.lib.LabelBox;
38
39 /**
40  * This action allows to invoke the main method of the demo.
41  *
42  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
43  * @version 0.1
44  */

45 public class InvokeServiceAction
46     implements MenuItem
47 {
48
49     protected LabelBox id_ = null;
50
51     /**
52      * Create a box containing all the box to specify all the params
53      */

54     protected Box JavaDoc createBox() {
55         Box JavaDoc box = Box.createVerticalBox();
56         box.add(Box.createVerticalGlue());
57         id_ = new LabelBox("Value");
58         box.add(id_);
59         box.add(Box.createVerticalGlue());
60         return box;
61     }
62
63     public void actionPerformed(MenuItemTreeView e) {
64         Service s = (Service)e.getSelectedObject();
65         InvokeThread t = new InvokeThread(s);
66         t.start();
67     }
68
69     /**
70      * @see org.objectweb.util.browser.api.MenuItem#isActive(org.objectweb.util.browser.gui.common.TreeView)
71      */

72     public int getStatus(TreeView treeView) {
73         return MenuItem.ENABLED_STATUS;
74     }
75
76     public class InvokeThread extends Thread JavaDoc {
77          
78         protected Service s_ = null;
79          
80         public InvokeThread(Service s) {
81             s_ = s;
82         }
83  
84         public void run() {
85             int result = JOptionPane.showOptionDialog(null, createBox(), "Invokes the print method", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
86             if (result == 0) {
87                 if(id_!=null) {
88                     String JavaDoc message = id_.getLabel();
89                     s_.print(message);
90                 }
91             }
92         }
93      }
94  
95 }
Popular Tags