KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > wizard > WizardTab


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk.
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.console.wizard;
26
27 import java.awt.GridBagConstraints JavaDoc;
28 import java.awt.GridBagLayout JavaDoc;
29 import java.util.ResourceBundle JavaDoc;
30 import java.util.StringTokenizer JavaDoc;
31
32 import javax.swing.BorderFactory JavaDoc;
33 import javax.swing.JOptionPane JavaDoc;
34 import javax.swing.JPanel JavaDoc;
35 import javax.swing.border.BevelBorder JavaDoc;
36
37 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
38 import org.objectweb.cjdbc.console.wizard.listeners.WizardListener;
39
40 /**
41  * This is the asbtract class used to define tabs in the wizard. A tab is used
42  * to write and fill the necessary configuration of a particular point of the
43  * virtual database xml configuration file.
44  *
45  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
46  * @version 1.0
47  */

48 public abstract class WizardTab extends JPanel JavaDoc implements WizardListener
49 {
50   protected WizardTabs tabs;
51   protected GridBagConstraints JavaDoc constraints;
52   protected static ResourceBundle JavaDoc types;
53
54   /**
55    * Creates a new <code>WizardTab</code> object
56    *
57    * @param tabs tabs to display
58    * @param name Wizard name
59    */

60   public WizardTab(WizardTabs tabs, String JavaDoc name)
61   {
62     super();
63     this.tabs = tabs;
64     this.setName(WizardTranslate.get(name));
65     this.setLayout(new GridBagLayout JavaDoc());
66     this.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
67     constraints = new GridBagConstraints JavaDoc();
68     constraints.gridy = 0;
69
70     constraints.fill = GridBagConstraints.BOTH;
71     constraints.weightx = 1.0;
72     constraints.weighty = 1.0;
73   }
74
75   /**
76    * @see org.objectweb.cjdbc.console.wizard.listeners.WizardListener#backendListChanged()
77    */

78   public void backendListChanged()
79   {
80
81   }
82
83   /**
84    * @see org.objectweb.cjdbc.console.wizard.listeners.WizardListener#distributionChanged()
85    */

86   public void distributionChanged()
87   {
88   }
89
90   /**
91    * @see org.objectweb.cjdbc.console.wizard.listeners.WizardListener#usersChanged()
92    */

93   public void usersChanged()
94   {
95
96   }
97
98   /**
99    * Get the Databases Types.
100    *
101    * @return database types
102    */

103   public static final String JavaDoc[] getDatabasesTypes()
104   {
105     if (types == null)
106       types = ResourceBundle.getBundle("database");
107     String JavaDoc typestring = types.getString("database.types");
108
109     StringTokenizer JavaDoc token = new StringTokenizer JavaDoc(typestring, ",");
110     int tokens = token.countTokens();
111     String JavaDoc[] databases = new String JavaDoc[tokens];
112     int count = 0;
113     while (token.hasMoreTokens())
114     {
115       databases[count] = token.nextToken();
116       count++;
117     }
118
119     return databases;
120   }
121
122   /**
123    * Show backend select dialog
124    *
125    * @return the selected backend
126    */

127   public static String JavaDoc showBackendSelectDialog()
128   {
129     return (String JavaDoc) JOptionPane.showInputDialog(null, WizardTranslate
130         .get("label.backend.select"), WizardTranslate
131         .get("label.backend.select"), JOptionPane.QUESTION_MESSAGE, null,
132         getDatabasesTypes(), null);
133   }
134 }
Popular Tags