KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > tools > admin > AdminCommandDialog


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA.
18  *
19  * Initial developer(s): ScalAgent DT
20  * Contributor(s):
21  */

22 package org.objectweb.joram.client.tools.admin;
23
24 import javax.swing.*;
25 import java.awt.*;
26 import java.awt.event.*;
27
28 import org.objectweb.joram.client.jms.admin.AdminModule;
29 import org.objectweb.util.monolog.api.*;
30
31 public class AdminCommandDialog extends JDialog {
32   private JLabel msgLabel;
33   private JButton abortButton;
34
35   private AdminController ctrl;
36
37   public AdminCommandDialog(Frame frame,
38                             AdminController ctrl) {
39     super(frame, true);
40     this.ctrl = ctrl;
41
42     msgLabel = new JLabel("The command is running...");
43
44     // Buttons
45
abortButton = new JButton("Abort");
46     abortButton.addActionListener(new ActionListener() {
47       public void actionPerformed(ActionEvent e) {
48         abort();
49       }
50     });
51
52     getRootPane().setDefaultButton(abortButton);
53
54     Container contentPane = getContentPane();
55     contentPane.add(msgLabel, BorderLayout.CENTER);
56     contentPane.add(abortButton, BorderLayout.SOUTH);
57
58     addWindowListener(new WindowAdapter() {
59     public void windowClosing(WindowEvent e) {
60           abort();
61         }
62       });
63     
64     setLocationRelativeTo(frame);
65     pack();
66   }
67
68   private void abort() {
69     try {
70       AdminModule.abortRequest();
71     } catch (Exception JavaDoc exc) {
72       if (Log.logger.isLoggable(BasicLevel.DEBUG))
73         Log.logger.log(BasicLevel.DEBUG, "", exc);
74     }
75     setVisible(false);
76   }
77
78   public void showDialog() {
79     setVisible(true);
80   }
81
82   public void close() {
83     setVisible(false);
84   }
85 }
86
Popular Tags