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

GuiInputBackupFrame.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 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): ______________________.
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 import java.awt.event.WindowEvent;
00037 import java.awt.event.WindowListener;
00038 import java.awt.event.WindowStateListener;
00039 
00040 import javax.swing.BorderFactory;
00041 import javax.swing.JButton;
00042 import javax.swing.JDialog;
00043 import javax.swing.JLabel;
00044 import javax.swing.JList;
00045 import javax.swing.JPanel;
00046 import javax.swing.JScrollPane;
00047 import javax.swing.JTextField;
00048 import javax.swing.border.Border;
00049 import javax.swing.event.ListSelectionEvent;
00050 import javax.swing.event.ListSelectionListener;
00051 
00052 import org.objectweb.cjdbc.common.i18n.GuiTranslate;
00053 import org.objectweb.cjdbc.console.gui.FrameConfirmKeyListener;
00054 import org.objectweb.cjdbc.console.gui.constants.GuiCommands;
00055 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
00056 
00057 /**
00058  * This class defines a GuiSelectCheckpoint
00059  * 
00060  * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
00061  * @version 1.0
00062  */
00063 public class GuiInputBackupFrame extends JDialog
00064     implements
00065       WindowListener,
00066       WindowStateListener
00067 {
00068   private JList      sampleJList;
00069   private JTextField valueField;
00070   private FrameConfirmKeyListener keyListener;
00071 
00072   /**
00073    * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
00074    */
00075   public void windowActivated(WindowEvent e)
00076   {
00077 
00078   }
00079 
00080   /**
00081    * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
00082    */
00083   public void windowClosed(WindowEvent e)
00084   {
00085     this.setVisible(false);
00086     valueField = null;
00087   }
00088 
00089   /**
00090    * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
00091    */
00092   public void windowClosing(WindowEvent e)
00093   {
00094     valueField = null;
00095   }
00096 
00097   /**
00098    * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
00099    */
00100   public void windowDeactivated(WindowEvent e)
00101   {
00102 
00103   }
00104 
00105   /**
00106    * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
00107    */
00108   public void windowDeiconified(WindowEvent e)
00109   {
00110 
00111   }
00112 
00113   /**
00114    * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
00115    */
00116   public void windowIconified(WindowEvent e)
00117   {
00118 
00119   }
00120 
00121   /**
00122    * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
00123    */
00124   public void windowOpened(WindowEvent e)
00125   {
00126 
00127   }
00128 
00129   /**
00130    * @see java.awt.event.WindowStateListener#windowStateChanged(java.awt.event.WindowEvent)
00131    */
00132   public void windowStateChanged(WindowEvent e)
00133   {
00134 
00135   }
00136 
00137   /**
00138    * Creates a new <code>GuiSelectCheckpoint</code> object
00139    * 
00140    * @param owner frame owner
00141    * @param entries choices for selection
00142    * @param listener to receive events
00143    * @throws java.awt.HeadlessException if fails
00144    */
00145   public GuiInputBackupFrame(Frame owner, String[] entries,
00146       ActionListener listener) throws HeadlessException
00147   {
00148     super(owner, GuiTranslate.get("frame.backup.title"), true);
00149 
00150     // Center
00151     Toolkit toolkit = Toolkit.getDefaultToolkit();
00152     Dimension dim = toolkit.getScreenSize();
00153     int screenHeight = dim.height;
00154     int screenWidth = dim.width;
00155     int frameWidth = 550;
00156     int frameHeight = 50;
00157     this.setBounds((screenWidth - frameWidth) / 2,
00158         (screenHeight - frameHeight) / 2, frameWidth, frameHeight);
00159 
00160     this.addWindowListener(this);
00161     this.addWindowStateListener(this);
00162 
00163     JButton optionConfirm = new JButton(GuiTranslate.get("frame.ok"));
00164     optionConfirm.setActionCommand(GuiCommands.COMMAND_HIDE_BACKUP_FRAME);
00165     optionConfirm.addActionListener(listener);
00166     
00167     keyListener = new FrameConfirmKeyListener(optionConfirm);
00168     this.addKeyListener(keyListener);
00169     
00170     Container content = getContentPane();
00171     sampleJList = new JList(entries);
00172     sampleJList.setVisibleRowCount(4);
00173     Font displayFont = new Font("Serif", Font.BOLD, 10);
00174     sampleJList.setFont(displayFont);
00175     sampleJList.addListSelectionListener(new ValueReporter());
00176     sampleJList.addKeyListener(keyListener);
00177     JScrollPane listPane = new JScrollPane(sampleJList);
00178 
00179     JPanel listPanel = new JPanel();
00180     listPanel.setEnabled(false);
00181     listPanel.setBackground(Color.white);
00182     Border listPanelBorder = BorderFactory.createTitledBorder(GuiTranslate
00183         .get("frame.backup.list"));
00184     listPanel.setBorder(listPanelBorder);
00185     listPanel.add(listPane);
00186     content.add(listPanel, BorderLayout.CENTER);
00187     JLabel valueLabel = new JLabel(GuiTranslate.get("frame.backup.selection"));
00188     valueLabel.setFont(displayFont);
00189     valueField = new JTextField(GuiConstants.BACKEND_NO_CHECKPOINT, 7);
00190     valueField.setFont(displayFont);
00191     valueField.addKeyListener(keyListener);
00192 
00193     JPanel valuePanel = new JPanel();
00194     valuePanel.setBackground(Color.white);
00195     Border valuePanelBorder = BorderFactory.createTitledBorder(GuiTranslate
00196         .get("frame.backup"));
00197     valuePanel.setBorder(valuePanelBorder);
00198     valuePanel.add(valueLabel);
00199     valuePanel.add(valueField);
00200     content.add(valuePanel, BorderLayout.NORTH);
00201 
00202     JPanel selectPanel = new JPanel();
00203     selectPanel.setBackground(Color.white);
00204     Border selectPanelBorder = BorderFactory.createTitledBorder(GuiTranslate
00205         .get("frame.select"));
00206     selectPanel.setBorder(selectPanelBorder);
00207     
00208     
00209     selectPanel.add(optionConfirm);
00210     content.add(selectPanel, BorderLayout.SOUTH);
00211     pack();
00212   }
00213 
00214   private class ValueReporter implements ListSelectionListener
00215   {
00216     /**
00217      * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
00218      */
00219     public void valueChanged(ListSelectionEvent event)
00220     {
00221       if (!event.getValueIsAdjusting())
00222         valueField.setText(sampleJList.getSelectedValue().toString());
00223     }
00224   }
00225 
00226   /**
00227    * Returns the valueField value.
00228    * 
00229    * @return Returns the valueField.
00230    */
00231   public JTextField getValueField()
00232   {
00233     return valueField;
00234   }
00235 
00236   /**
00237    * Sets the value value.
00238    * 
00239    * @param value The value to set.
00240    */
00241   public final void setValue(String value)
00242   {
00243     valueField.setText(value);
00244     valueField.repaint();
00245   }
00246 }

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