Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

GuiSelectShutdownFrame.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2005 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk.
00022  * Contributor(s): Emmanuel Cecchet.
00023  */
00024 
00025 package org.objectweb.cjdbc.console.gui.frames;
00026 
00027 import java.awt.BorderLayout;
00028 import java.awt.Color;
00029 import java.awt.Container;
00030 import java.awt.Dimension;
00031 import java.awt.Font;
00032 import java.awt.Frame;
00033 import java.awt.HeadlessException;
00034 import java.awt.Toolkit;
00035 import java.awt.event.ActionListener;
00036 
00037 import javax.swing.BorderFactory;
00038 import javax.swing.JButton;
00039 import javax.swing.JDialog;
00040 import javax.swing.JLabel;
00041 import javax.swing.JList;
00042 import javax.swing.JPanel;
00043 import javax.swing.JScrollPane;
00044 import javax.swing.JTextField;
00045 import javax.swing.border.Border;
00046 import javax.swing.event.ListSelectionEvent;
00047 import javax.swing.event.ListSelectionListener;
00048 
00049 import org.objectweb.cjdbc.common.i18n.GuiTranslate;
00050 import org.objectweb.cjdbc.console.gui.FrameConfirmKeyListener;
00051 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
00052 
00053 /**
00054  * This class defines a GuiSelectCheckpoint
00055  * 
00056  * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
00057  * @author <a href="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
00058  *         </a>
00059  * @version 1.0
00060  */
00061 public class GuiSelectShutdownFrame extends JDialog
00062 {
00063   private JList                   sampleJList;
00064   private JTextField              valueField;
00065   private final String[]          entries = new String[]{
00066       GuiCommands.COMMAND_SHUTDOWN_SAFE, GuiCommands.COMMAND_SHUTDOWN_WAIT,
00067       GuiCommands.COMMAND_SHUTDOWN_FORCE  };
00068 
00069   private FrameConfirmKeyListener keyListener;
00070 
00071   /**
00072    * Creates a new <code>GuiSelectCheckpoint</code> object
00073    * 
00074    * @param owner the frame to attach to
00075    * @param listener for handback
00076    * @throws java.awt.HeadlessException if fails
00077    */
00078   public GuiSelectShutdownFrame(Frame owner, ActionListener listener)
00079       throws HeadlessException
00080   {
00081     super(owner, GuiTranslate.get("frame.shutdown.title"), true);
00082 
00083     // Center
00084     Toolkit toolkit = Toolkit.getDefaultToolkit();
00085     Dimension dim = toolkit.getScreenSize();
00086     int screenHeight = dim.height;
00087     int screenWidth = dim.width;
00088     int frameWidth = 450;
00089     int frameHeight = 50;
00090     this.setBounds((screenWidth - frameWidth) / 2,
00091         (screenHeight - frameHeight) / 2, frameWidth, frameHeight);
00092 
00093     JButton optionConfirm = new JButton(GuiTranslate.get("frame.ok"));
00094     optionConfirm.setActionCommand(GuiCommands.COMMAND_HIDE_SHUTDOWN_FRAME);
00095     optionConfirm.addActionListener(listener);
00096 
00097     keyListener = new FrameConfirmKeyListener(optionConfirm);
00098     this.addKeyListener(keyListener);
00099 
00100     Container content = getContentPane();
00101     sampleJList = new JList(entries);
00102     sampleJList.setVisibleRowCount(4);
00103     Font displayFont = new Font("Serif", Font.BOLD, 12);
00104     sampleJList.setFont(displayFont);
00105     sampleJList.addListSelectionListener(new ValueReporter());
00106     sampleJList.addKeyListener(keyListener);
00107     JScrollPane listPane = new JScrollPane(sampleJList);
00108 
00109     JPanel listPanel = new JPanel();
00110     listPanel.setBackground(Color.white);
00111     Border listPanelBorder = BorderFactory.createTitledBorder(GuiTranslate
00112         .get("frame.shutdown.levels"));
00113     listPanel.setBorder(listPanelBorder);
00114     listPanel.add(listPane);
00115     content.add(listPanel, BorderLayout.CENTER);
00116     JLabel valueLabel = new JLabel(GuiTranslate.get("frame.shutdown.selection"));
00117     valueLabel.setFont(displayFont);
00118     valueField = new JTextField(GuiCommands.COMMAND_SHUTDOWN_SAFE, 7);
00119     valueField.setEditable(false);
00120     valueField.setFont(displayFont);
00121     valueField.addKeyListener(keyListener);
00122 
00123     JPanel valuePanel = new JPanel();
00124     valuePanel.setBackground(Color.white);
00125     Border valuePanelBorder = BorderFactory.createTitledBorder(GuiTranslate
00126         .get("frame.shutdown"));
00127     valuePanel.setBorder(valuePanelBorder);
00128     valuePanel.add(valueLabel);
00129     valuePanel.add(valueField);
00130     content.add(valuePanel, BorderLayout.NORTH);
00131 
00132     JPanel selectPanel = new JPanel();
00133     selectPanel.setBackground(Color.white);
00134     Border selectPanelBorder = BorderFactory.createTitledBorder(GuiTranslate
00135         .get("frame.select"));
00136     selectPanel.setBorder(selectPanelBorder);
00137 
00138     selectPanel.add(optionConfirm);
00139     content.add(selectPanel, BorderLayout.SOUTH);
00140     pack();
00141   }
00142 
00143   private class ValueReporter implements ListSelectionListener
00144   {
00145     /**
00146      * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
00147      */
00148     public void valueChanged(ListSelectionEvent event)
00149     {
00150       if (!event.getValueIsAdjusting())
00151         valueField.setText(sampleJList.getSelectedValue().toString());
00152     }
00153   }
00154 
00155   /**
00156    * Returns the sampleJList value.
00157    * 
00158    * @return Returns the sampleJList.
00159    */
00160   public JList getSampleJList()
00161   {
00162     return sampleJList;
00163   }
00164 
00165   /**
00166    * Returns the valueField value.
00167    * 
00168    * @return Returns the valueField.
00169    */
00170   public JTextField getValueField()
00171   {
00172     return valueField;
00173   }
00174 }

Generated on Mon Apr 11 22:01:32 2005 for C-JDBC by  doxygen 1.3.9.1