001: /* ====================================================================
002: * Copyright (c) 1998 - 2005 David F. Glasser. All rights
003: * reserved.
004: *
005: * This file is part of the QueryForm Database Tool.
006: *
007: * The QueryForm Database Tool is free software; you can redistribute it
008: * and/or modify it under the terms of the GNU General Public License as
009: * published by the Free Software Foundation; either version 2 of the
010: * License, or (at your option) any later version.
011: *
012: * The QueryForm Database Tool is distributed in the hope that it will
013: * be useful, but WITHOUT ANY WARRANTY; without even the implied
014: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
015: * See the GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with the QueryForm Database Tool; if not, write to:
019: *
020: * The Free Software Foundation, Inc.,
021: * 59 Temple Place, Suite 330
022: * Boston, MA 02111-1307 USA
023: *
024: * or visit http://www.gnu.org.
025: *
026: * ====================================================================
027: *
028: * This product includes software developed by the
029: * Apache Software Foundation (http://www.apache.org/).
030: *
031: * ====================================================================
032: *
033: * $Source: /cvsroot/qform/qform/src/org/glasser/qform/Resources.java,v $
034: * $Revision: 1.1 $
035: * $Author: dglasser $
036: * $Date: 2005/01/26 02:52:09 $
037: *
038: * --------------------------------------------------------------------
039: */
040:
041: package org.glasser.qform;
042:
043: import java.util.*;
044: import javax.swing.*;
045:
046: /**
047: * This is the base ResouceBundle for QueryForm.
048: *
049: * @author Dave Glasser
050: */
051: public class Resources extends ResourceBundle {
052:
053: private final static String[][] mappings = {
054: { "menu.CONNECT.title", "Connect" },
055: { "menu.CONNECT.mnemonic", "C" },
056: { "menu.CONNECT.DATA_SOURCE_DIALOG.label", "Data Source..." },
057: { "menu.CONNECT.DATA_SOURCE_DIALOG.mnemonic", "D" },
058: { "menu.CONNECT.DATA_SOURCE_DIALOG.tooltip",
059: "Create, edit or connect to a data source." },
060: { "menu.CONNECT.TABLE_METADATA.label", "Table Metadata..." },
061: { "menu.CONNECT.TABLE_METADATA.mnemonic", "T" },
062: { "menu.CONNECT.TABLE_METADATA.tooltip",
063: "View metadata for a table." },
064: { "menu.CONNECT.CLOSE_WINDOW.label", "Close Window" },
065: { "menu.CONNECT.CLOSE_WINDOW.mnemonic", "C" },
066: { "menu.CONNECT.CLOSE_WINDOW.tooltip",
067: "Close the current window." },
068: { "menu.CONNECT.EXIT.label", "Exit" },
069: { "menu.CONNECT.EXIT.mnemonic", "X" },
070: { "menu.CONNECT.EXIT.tooltip", "Exit the program." }
071:
072: ,
073: { "menu.QUERY_FORM.title", "QueryForm" },
074: { "menu.QUERY_FORM.mnemonic", "Q" },
075: { "menu.QUERY_FORM.NEW_QUERY_FORM.label",
076: "New Query Form..." },
077: { "menu.QUERY_FORM.NEW_QUERY_FORM.mnemonic", "Q" },
078: { "menu.QUERY_FORM.NEW_QUERY_FORM.tooltip",
079: "Open a new query form." },
080: { "menu.QUERY_FORM.WINDOW_TITLE.label", "Window title..." },
081: { "menu.QUERY_FORM.WINDOW_TITLE.mnemonic", "T" },
082: { "menu.QUERY_FORM.WINDOW_TITLE.tooltip",
083: "Set the window title for the current query form." },
084: { "menu.QUERY_FORM.OPEN_FOR_QUERY.label", "Form Query" },
085: { "menu.QUERY_FORM.OPEN_FOR_QUERY.mnemonic", "F" },
086: { "menu.QUERY_FORM.OPEN_FOR_QUERY.tooltip",
087: "Enter query criteria in the current query form." },
088: { "menu.QUERY_FORM.WHERE_CLAUSE_QUERY.label",
089: "Where Clause Query..." },
090: { "menu.QUERY_FORM.WHERE_CLAUSE_QUERY.mnemonic", "W" },
091: { "menu.QUERY_FORM.WHERE_CLAUSE_QUERY.tooltip",
092: "Enter a custom where clause query." },
093: { "menu.QUERY_FORM.ADD_RECORD.label", "Add Record" },
094: { "menu.QUERY_FORM.ADD_RECORD.mnemonic", "A" },
095: { "menu.QUERY_FORM.ADD_RECORD.tooltip",
096: "Add a record through the current query form." },
097: { "menu.QUERY_FORM.MODIFY_RECORD.label", "Modify Record" },
098: { "menu.QUERY_FORM.MODIFY_RECORD.mnemonic", "M" },
099: { "menu.QUERY_FORM.MODIFY_RECORD.tooltip",
100: "Modify the current record." },
101: { "menu.QUERY_FORM.DELETE_RECORD.label", "Delete Record" },
102: { "menu.QUERY_FORM.DELETE_RECORD.mnemonic", "D" },
103: { "menu.QUERY_FORM.DELETE_RECORD.tooltip",
104: "Delete the current record." },
105: { "menu.QUERY_FORM.CLONE_RECORD.label", "Clone Record" },
106: { "menu.QUERY_FORM.CLONE_RECORD.mnemonic", "L" },
107: { "menu.QUERY_FORM.CLONE_RECORD.tooltip",
108: "Clone the current record." },
109: { "menu.QUERY_FORM.GRID_VIEW.label", "Grid View " },
110: { "menu.QUERY_FORM.GRID_VIEW.mnemonic", "G" },
111: { "menu.QUERY_FORM.GRID_VIEW.tooltip",
112: "Configure grid view tab." },
113: { "menu.QUERY_FORM.EXPORT.label", "Export" },
114: { "menu.QUERY_FORM.EXPORT.mnemonic", "X" },
115: { "menu.QUERY_FORM.EXPORT.tooltip",
116: "Export query results to a file." },
117: { "menu.QUERY_FORM.EXECUTE_ACTION.label",
118: "Excecute Operation" },
119: { "menu.QUERY_FORM.EXECUTE_ACTION.mnemonic", "E" },
120: { "menu.QUERY_FORM.EXECUTE_ACTION.tooltip",
121: "Execute the currently pending operation." },
122: { "menu.QUERY_FORM.CANCEL_ACTION.label", "Cancel Operation" },
123: { "menu.QUERY_FORM.CANCEL_ACTION.mnemonic", "C" },
124: { "menu.QUERY_FORM.CANCEL_ACTION.tooltip",
125: "Cancel the currently pending operation." },
126: { "menu.WINDOW.MINIMIZE_ALL.label", "Minimize all" }
127:
128: ,
129: { "menu.WINDOW.title", "Window" },
130: { "menu.WINDOW.mnemonic", "W" },
131: { "menu.WINDOW.MINIMIZE_ALL.mnemonic", "N" },
132: { "menu.WINDOW.MINIMIZE_ALL.tooltip",
133: "Minimize all windows" },
134: { "menu.WINDOW.MAXIMIZE_ALL.label", "Maximize all" },
135: { "menu.WINDOW.MAXIMIZE_ALL.mnemonic", "X" },
136: { "menu.WINDOW.MAXIMIZE_ALL.tooltip",
137: "Maximize all windows" },
138: { "menu.WINDOW.RESTORE_ALL.label", "Restore all" },
139: { "menu.WINDOW.RESTORE_ALL.mnemonic", "R" },
140: { "menu.WINDOW.RESTORE_ALL.tooltip", "Restore all windows" },
141: { "menu.WINDOW.CASCADE.label", "Cascade" },
142: { "menu.WINDOW.CASCADE.mnemonic", "C" },
143: { "menu.WINDOW.CASCADE.tooltip", "Cascade all windows" },
144: { "menu.WINDOW.LOOK_AND_FEEL.label", "Look and Feel" },
145: { "menu.WINDOW.LOOK_AND_FEEL.mnemonic", "L" },
146: { "menu.WINDOW.LOOK_AND_FEEL.tooltip",
147: "Change QueryForm's Look-and-Feel" }
148:
149: ,
150: { "menu.HELP.title", "Help" },
151: { "menu.HELP.mnemonic", "H" },
152: { "menu.HELP.SYSINFO.label", "System Information..." },
153: { "menu.HELP.SYSINFO.mnemonic", "I" },
154: { "menu.HELP.SYSINFO.tooltip",
155: "Display system information." },
156: { "menu.HELP.ABOUT.label", "About..." },
157: { "menu.HELP.ABOUT.mnemonic", "A" },
158: { "menu.HELP.ABOUT.tooltip", "Display program information." }
159:
160: ,
161: { "menu.GRID_VIEW_SUB.COLUMN_MAP_DIALOG.label",
162: "Select visible columns..." },
163: { "menu.GRID_VIEW_SUB.COLUMN_MAP_DIALOG.mnemonic", "V" },
164: { "menu.GRID_VIEW_SUB.COLUMN_MAP_DIALOG.tooltip",
165: "Select which columns will be displayed in this table." },
166: { "menu.GRID_VIEW_SUB.TOGGLE_HORIZONTAL_SCROLLBAR.label",
167: "CHECKBOX_Horizontal scrollbar" },
168: {
169: "menu.GRID_VIEW_SUB.TOGGLE_HORIZONTAL_SCROLLBAR.mnemonic",
170: "H" },
171: { "menu.GRID_VIEW_SUB.TOGGLE_HORIZONTAL_SCROLLBAR.tooltip",
172: "Show or hide the horizontal scrollbar." }
173:
174: ,
175: { "menu.EXPORT_SUB.SELECTED_ROWS.label", "Selected Row(s)" },
176: { "menu.EXPORT_SUB.SELECTED_ROWS.mnemonic", "S" },
177: { "menu.EXPORT_SUB.SELECTED_ROWS.tooltip", "" },
178: { "menu.EXPORT_SUB.ALL_ROWS.label", "All Rows" },
179: { "menu.EXPORT_SUB.ALL_ROWS.mnemonic", "A" },
180: { "menu.EXPORT_SUB.ALL_ROWS.tooltip", "" },
181: { "menu.ALL_ROWS_SUB.EXPORT_ALL_INSERT.label",
182: "To INSERT Statements..." },
183: { "menu.ALL_ROWS_SUB.EXPORT_ALL_INSERT.mnemonic", "I" },
184: { "menu.ALL_ROWS_SUB.EXPORT_ALL_INSERT.tooltip",
185: "Export all rows read as INSERT statements." },
186: { "menu.ALL_ROWS_SUB.EXPORT_ALL_CSV.label",
187: "To CSV File..." },
188: { "menu.ALL_ROWS_SUB.EXPORT_ALL_CSV.mnemonic", "C" },
189: { "menu.ALL_ROWS_SUB.EXPORT_ALL_CSV.tooltip",
190: "Export all rows read as comma-separated values." },
191: { "menu.SELECTED_ROWS_SUB.EXPORT_SELECTED_INSERT.label",
192: "To INSERT Statements..." },
193: { "menu.SELECTED_ROWS_SUB.EXPORT_SELECTED_INSERT.mnemonic",
194: "I" },
195: { "menu.SELECTED_ROWS_SUB.EXPORT_SELECTED_INSERT.tooltip",
196: "Export selected rows as INSERT statements." },
197: { "menu.SELECTED_ROWS_SUB.EXPORT_SELECTED_CSV.label",
198: "To CSV File..." },
199: { "menu.SELECTED_ROWS_SUB.EXPORT_SELECTED_CSV.mnemonic",
200: "C" },
201: { "menu.SELECTED_ROWS_SUB.EXPORT_SELECTED_CSV.tooltip",
202: "Export selected rows as comma-separated values." },
203: { "menu.LOOK_AND_FEEL_SUB.INSTALL_LOOK_AND_FEEL.label",
204: "Install new..." },
205: { "menu.LOOK_AND_FEEL_SUB.INSTALL_LOOK_AND_FEEL.mnemonic",
206: "I" },
207: { "menu.LOOK_AND_FEEL_SUB.INSTALL_LOOK_AND_FEEL.tooltip",
208: "Install a third-party Look-and-Feel" },
209: { "menu.GRID_TAB_POPUP.COLUMN_MAP_DIALOG.label",
210: "Select columns..." },
211: { "menu.GRID_TAB_POPUP.COLUMN_MAP_DIALOG.mnemonic", "" },
212: { "menu.GRID_TAB_POPUP.COLUMN_MAP_DIALOG.tooltip",
213: "Select which columns will be displayed in this table." },
214: { "menu.GRID_TAB_POPUP.WINDOW_TITLE.label",
215: "Window title..." },
216: { "menu.GRID_TAB_POPUP.WINDOW_TITLE.mnemonic", "" },
217: { "menu.GRID_TAB_POPUP.WINDOW_TITLE.tooltip",
218: "Set the title for this window." },
219: { "menu.GRID_TAB_POPUP.QUERYPANEL_TABLE_METADATA.label",
220: "Table Metadata" },
221: { "menu.GRID_TAB_POPUP.QUERYPANEL_TABLE_METADATA.mnemonic",
222: "" },
223: { "menu.GRID_TAB_POPUP.QUERYPANEL_TABLE_METADATA.tooltip",
224: "View medadata for this table." },
225: { "menu.GRID_TAB_POPUP.EXPORT_SELECTED.label",
226: "Export Selected" },
227: { "menu.GRID_TAB_POPUP.EXPORT_SELECTED.mnemonic", "" },
228: { "menu.GRID_TAB_POPUP.EXPORT_SELECTED.tooltip",
229: "Export selected rows to a file." },
230: { "menu.GRID_TAB_POPUP.EXPORT_ALL.label", "Export All" },
231: { "menu.GRID_TAB_POPUP.EXPORT_ALL.mnemonic", "" },
232: { "menu.GRID_TAB_POPUP.EXPORT_ALL.tooltip",
233: "Export all rows read to a file." }
234:
235: };
236:
237: private Hashtable map = new Hashtable();
238:
239: public Resources() {
240: for (int j = 0; j < mappings.length; j++) {
241: map.put(mappings[j][0], mappings[j][1]);
242: }
243: }
244:
245: protected Object handleGetObject(String key) {
246: return map.get(key);
247: }
248:
249: public Enumeration getKeys() {
250: return map.keys();
251: }
252:
253: private static ResourceBundle defaultBundle = new Resources();
254:
255: private static ResourceBundle getBundle() {
256: ResourceBundle bundle = ResourceBundle
257: .getBundle("org.glasser.qform.Resources");
258:
259: if (bundle == null)
260: bundle = defaultBundle;
261: return bundle;
262: }
263:
264: public static void configureButton(JButton button, String command) {
265:
266: ResourceBundle bundle = getBundle();
267:
268: button.setActionCommand(command);
269:
270: String s = bundle.getString("button.label." + command);
271: if (s != null && (s = s.trim()).length() > 0) {
272: button.setText(s);
273: } else {
274: button.setText(null);
275: }
276:
277: s = bundle.getString("button.mnemonic." + command);
278: if (s != null && (s = s.trim()).length() > 0) {
279: button.setMnemonic(s.charAt(0));
280: } else {
281: button.setMnemonic(0);
282: }
283:
284: s = bundle.getString("button.tooltip." + command);
285: if (s != null && (s = s.trim()).length() > 0) {
286: button.setToolTipText(s);
287: } else {
288: button.setToolTipText(null);
289: }
290:
291: }
292:
293: public static JLabel makeLabel(String key) {
294: return new JLabel(getBundle().getString("label." + key));
295: }
296:
297: /**
298: * This will output all of the key-value mappings from
299: * this ResourceBundle to System.out, in properties file format. This
300: * is useful for starting a new bundle based on a properties file.
301: */
302: public static void main(String[] args) throws Exception {
303:
304: String ENDL = System.getProperty("line.separator");
305:
306: for (int j = 0; j < mappings.length; j++) {
307: String val = mappings[j][1];
308: if ("_COMMENT_".equals(mappings[j][0])) {
309: System.out.println(ENDL + "# " + val);
310: } else {
311: System.out.println(mappings[j][0] + "=" + val);
312: }
313: }
314: }
315: }
|