001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package net.refractions.udig.ui.internal;
018:
019: import java.lang.reflect.Field;
020:
021: import net.refractions.udig.internal.ui.Images;
022: import net.refractions.udig.internal.ui.UiPlugin;
023:
024: import org.eclipse.jface.action.IAction;
025: import org.eclipse.jface.resource.ImageDescriptor;
026: import org.eclipse.osgi.util.NLS;
027:
028: public class Messages extends NLS {
029: private static final String BUNDLE_NAME = "net.refractions.udig.ui.internal.messages"; //$NON-NLS-1$
030: public static String AttributeValidator_missingAtt1;
031: public static String AttributeValidator_missingAtt2;
032: public static String AttributeValidator_restriction;
033: public static String AttributeValidator_wrongType;
034: public static String BooleanCellEditor_FALSE;
035: public static String BooleanCellEditor_TRUE;
036: public static String CRSChooser_unknownWKT;
037: public static String ErrorManager_very_informative_error;
038: public static String ExceptionDisplayer_very_informative_error;
039: public static String FeatureTableContentProvider_errorHeader;
040: public static String FeatureTableContentProvider_loadedFeatures;
041: public static String FeatureTableContentProvider_loading;
042: public static String FeatureTableContentProvider_outOfMemory;
043: public static String FeatureTableContentProvider_sortTable;
044: public static String FeatureTableContentProvider_unexpectedErro;
045: public static String FeatureTableContentProvider_updateTaskName;
046: public static String FeatureTableContentProvider_updatingFeatures;
047: public static String FeatureTableControl_1;
048: public static String FeatureTableControl_loading1;
049: public static String FeatureTableControl_loading2;
050: public static String FeatureTableControl_noEditor1;
051: public static String FeatureTableControl_noEditor2;
052: public static String FeatureTableControl_warningMessage;
053: public static String FeatureTableControl_warningTitle;
054: public static String FeatureTableControl_warningToggle;
055: public static String FeatureTableSelectionProvider_loading_new_selection;
056: public static String FeatureTypeEditor_booleanType;
057: public static String FileExportOperation_allFiles;
058: public static String FileExportOperation_defaultName;
059: public static String FileExportOperation_finishStatus;
060: public static String FileExportOperation_prompt;
061: public static String FileExportOperation_writingStatus;
062: public static String OpAction_errorMessage;
063: public static String OpAction_errorTitle;
064: public static String OperationLabelProvider_unknown;
065: public static String PlatformGIS_background;
066: public static String RunOperationDialog_run_operation;
067: public static String SendLogDialog_contact;
068: public static String SendLogDialog_contact_message;
069: public static String SendLogDialog_description;
070: public static String SendLogDialog_empty;
071: public static String SendLogDialog_log;
072: public static String SendLogDialog_notes;
073: public static String SendLogDialog_notes_message;
074: public static String SendLogDialog_reading;
075: public static String SendLogDialog_submit;
076: public static String SendLogDialog_title;
077: public static String ShutdownTaskList_shutDown;
078: public static String TransferPreference_transfer_preference_description;
079: public static String FeatureTextTransfer_transfer_name;
080: public static String FeatureTextTransfer_strategy_wkt_name;
081: public static String FeatureTextTransfer_strategy_gml_name;
082: public static String TipDialog_question;
083: public static String TipDialog_shellText;
084: public static String NewFeatureTypeOp_duplicateTypeName;
085: public static String net_refractions_udig_ui_deleteAttributeType_tooltip;
086: public static String net_refractions_udig_ui_deleteAttributeType_image;
087: public static String net_refractions_udig_ui_deleteAttributeType_label;
088: public static String net_refractions_udig_ui_NewAttributeType_tooltip;
089: public static String net_refractions_udig_ui_NewAttributeType_image;
090: public static String net_refractions_udig_ui_NewAttributeType_label;
091: public static String newAttributeType_tooltip;
092: public static String newAttributeType_image;
093: public static String newAttributeType_label;
094: public static String newAttributeType_description;
095: public static String deleteAttributeAction_tooltip;
096: public static String deleteAttributeAction_image;
097: public static String deleteAttributeAction_label;
098: public static String deleteAttributeAction_description;
099: public static String FeatureTypeEditor_newAttributeTypeDefaultName;
100: public static String FeatureTypeEditor_newFeatureTypeName;
101: public static String FeatureTypeEditor_typeColumnName;
102: public static String FeatureTypeEditor_nameColumnName;
103: public static String FeatureTableControl_loadingMessage;
104: public static String FeatureTypeEditor_multiPolygonType;
105: public static String FeatureTypeEditor_defaultNameAttributeName;
106: public static String FeatureTypeEditor_defaultGeometryName;
107: public static String FeatureTypeEditor_multiLineStringType;
108: public static String FeatureTypeEditor_multiPointType;
109: public static String FeatureTypeEditor_geometryType;
110: public static String FeatureTypeEditor_polygonType;
111: public static String FeatureTypeEditor_lineStringType;
112: public static String FeatureTypeEditor_pointType;
113: public static String FeatureTypeEditor_floatType;
114: public static String FeatureTypeEditor_doubleType;
115: public static String FeatureTypeEditor_longType;
116: public static String FeatureTypeEditor_integerType;
117: public static String FeatureTypeEditor_dateType;
118: public static String FeatureTypeEditor_stringType;
119: public static String ColourPaletteMasterList_notKnown;
120: public static String ColourPaletteMasterList_schema;
121: public static String UDIGApplication_error2;
122: public static String UDIGApplication_error1;
123: public static String UDIGApplication_title;
124: public static String UDIGApplication_error;
125: public static String UDIGDropHandler_jobName;
126: public static String UDIGDropHandler_error;
127: public static String orientation_automatic_image;
128: public static String orientation_automatic_label;
129: public static String orientation_automatic_description;
130: public static String orientation_automatic_tooltip;
131: public static String orientation_single_image;
132: public static String orientation_single_label;
133: public static String orientation_single_description;
134: public static String orientation_single_tooltip;
135: public static String orientation_vertical_image;
136: public static String orientation_vertical_label;
137: public static String orientation_vertical_description;
138: public static String orientation_vertical_tooltip;
139: public static String orientation_horizontal_image;
140: public static String orientation_horizontal_label;
141: public static String orientation_horizontal_description;
142: public static String orientation_horizontal_tooltip;
143: public static String cancel_image;
144: public static String cancel_label;
145: public static String cancel_description;
146: public static String cancel_tooltip;
147: public static String OperationMenuFactory_menu_text;
148: public static String AuthenticationDialog_dialog_title;
149: public static String AuthenticationDialog_label_rememberPassword;
150: public static String AuthenticationDialog_label_password;
151: public static String AuthenticationDialog_label_username;
152: public static String AuthenticationDialog_label_prompt;
153: public static String UDIGDropHandler_performing_task;
154: public static String UDIGWorkbenchAdvisor_welcome_text;
155: public static String UDIGWorkbenchAdvisor_saveAll_text;
156: public static String UDIGWorkbenchAdvisor_closeAllPerspectives_text;
157: public static String UDIGWorkbenchAdvisor_closePerspective_text;
158: public static String UDIGWorkbenchAdvisor_closeAll_text;
159: public static String UDIGWorkbenchAdvisor_aboutUDig_text;
160: public static String UDIGWorkbenchAdvisor_newWindow_text;
161: public static String UDIGWorkbenchAdvisor_navigationMenu;
162: public static String UDIGWorkbenchAdvisor_helpContents_text;
163: public static String UDIGWorkbenchAdvisor_preferences_text;
164: public static String UDIGWorkbenchAdvisor_resetPerspective_text;
165: public static String UDIGWorkbenchAdvisor_open_perspective;
166: public static String UDIGWorkbenchAdvisor_help;
167: public static String UDIGWorkbenchAdvisor_exit_text;
168: public static String UDIGWorkbenchAdvisor_export_text;
169: public static String UDIGWorkbenchAdvisor_import_text;
170: public static String UDIGWorkbenchAdvisor_close_text;
171: public static String UDIGWorkbenchAdvisor_layerMenu;
172: public static String UDIGWorkbenchAdvisor_save_text;
173: public static String UDIGWorkbenchAdvisor_show_view;
174: public static String UDIGWorkbenchAdvisor_window;
175: public static String UDIGWorkbenchAdvisor_tools;
176: public static String UDIGWorkbenchAdvisor_edit;
177: public static String UDIGWorkbenchAdvisor_other;
178: public static String UDIGWorkbenchAdvisor_new;
179: public static String UDIGWorkbenchAdvisor_file;
180: public static String UDIGApplication_error_jai_warning_text;
181: public static String UDIGApplication_error_jai_warning_title;
182: public static String UDIGWorkbenchWindowAdvisor_classNotFound;
183: public static String UDIGWorkbenchWindowAdvisor_implementationNotSpecified;
184: public static String UDIGWorkbenchWindowAdvisor_specifiedButNotFound;
185: public static String UiPreferences_advancedGraphics_label;
186: public static String UiPreferences_description;
187: public static String CRSChooser_tooltip;
188: public static String CRSChooser_unnamed;
189: public static String CRSChooser_keywordsLabel;
190: public static String CRSChooser_tab_customCRS;
191: public static String CRSChooser_tab_standardCRS;
192: public static String CRSChooser_label_crs;
193: public static String CRSChooser_label_crsWKT;
194:
195: static {
196: // initialize resource bundle
197: NLS.initializeMessages(BUNDLE_NAME, Messages.class);
198: }
199:
200: private Messages() {
201: }
202:
203: /**
204: * Initialize the given Action from a ResourceBundle.
205: * <p>
206: * Makes use of the following keys:
207: * <ul>
208: * <li>prefix.label
209: * <li>prefix.tooltip
210: * <li>prefix.image
211: * <li>prefix.description
212: * </p>
213: * <p>
214: * Note: The use of a single image value is mapped to images for both the enabled and distabled
215: * state of the IAction. the Local toolbar (elcl16/ and dlcl16/) is assumed if a path has not
216: * been provided.
217: *
218: * <pre><code>
219: * add_co.gif (prefix.image)
220: * enabled: elcl16/add_co.gif
221: * disabled: dlcl/remove_co.gif
222: * tool16/discovery_wiz.16 (prefix.image)
223: * enabled: etool16/discovery_wiz.16
224: * disabled: etool16/discovery_wiz.16
225: * </code></pre>
226: *
227: * </p>
228: *
229: * @param a action
230: * @param id used for binding (id.label, id.tooltip, ...)
231: */
232: public static void initAction(IAction a, String id) {
233: String labelKey = "_label"; //$NON-NLS-1$
234: String tooltipKey = "_tooltip"; //$NON-NLS-1$
235: String imageKey = "_image"; //$NON-NLS-1$
236: String descriptionKey = "_description"; //$NON-NLS-1$
237: if (id != null && id.length() > 0) {
238: labelKey = id + labelKey;
239: tooltipKey = id + tooltipKey;
240: imageKey = id + imageKey;
241: descriptionKey = id + descriptionKey;
242: }
243: String s = bind(labelKey);
244: if (s != null)
245: a.setText(s);
246: s = bind(tooltipKey);
247: if (s != null)
248: a.setToolTipText(s);
249: s = bind(descriptionKey);
250: if (s != null)
251: a.setDescription(s);
252: String relPath = bind(imageKey);
253: if (relPath != null && !relPath.equals(imageKey)
254: && relPath.trim().length() > 0) {
255: String dPath;
256: String ePath;
257: if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$
258: String path = relPath.substring(1);
259: dPath = 'd' + path;
260: ePath = 'e' + path;
261: } else {
262: dPath = "dlcl16/" + relPath; //$NON-NLS-1$
263: ePath = "elcl16/" + relPath; //$NON-NLS-1$
264: }
265: ImageDescriptor image;
266:
267: image = Images.getDescriptor(ePath);
268: if (id != null) {
269: a.setImageDescriptor(image);
270: }
271: image = Images.getDescriptor(dPath);
272: if (id != null) {
273: a.setDisabledImageDescriptor(image);
274: }
275: }
276: }
277:
278: private static String bind(String fieldName) {
279: Field field;
280: try {
281: field = Messages.class.getDeclaredField(fieldName);
282: return (String) field.get(null);
283: } catch (Exception e) {
284: UiPlugin.log("Error loading key " + fieldName, e); //$NON-NLS-1$
285: }
286: return null;
287: }
288: }
|