1 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 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 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 |