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.catalog.ui.internal;
018:
019: import java.lang.reflect.Field;
020:
021: import net.refractions.udig.catalog.internal.ui.Images;
022: import net.refractions.udig.catalog.ui.CatalogUIPlugin;
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.catalog.ui.internal.messages"; //$NON-NLS-1$
030: public static String action_remove_tooltip;
031: public static String action_remove_label;
032: public static String action_remove_image;
033: public static String action_remove_description;
034: public static String action_refresh_tooltip;
035: public static String action_refresh_label;
036: public static String action_refresh_image;
037: public static String action_refresh_description;
038: public static String action_cancel_tooltip;
039: public static String action_cancel_label;
040: public static String action_cancel_image;
041: public static String action_cancel_description;
042: public static String action_add_tooltip;
043: public static String action_add_label;
044: public static String action_add_image;
045: public static String CatalogExport_fileNameNotChosen;
046: public static String CatalogExport_reprojectError;
047: public static String CatalogExport_UnexpectedError;
048: public static String CatalogTreeViewer_broken;
049: public static String CatalogTreeViewer_permission;
050: public static String ConnectionErrorState_error_name;
051: public static String ConnectionFailurePage_canProcess;
052: public static String ConnectionFailurePage_displayedTitle;
053: public static String ConnectionFailurePage_message;
054: public static String ConnectionFailurePage_selectChild;
055: public static String ConnectionFailurePage_title;
056: public static String ConnectionFailureState_name;
057: public static String ReprojectingFeatureCollection_transformationError;
058: public static String ResourceSelectionPage_brokenReportError;
059: public static String ResourceSelectionPage_brokenUnknown;
060: public static String ResourceSelectionPage_connectedButNoResources;
061: public static String ResourceSelectionPage_noPermission;
062: public static String ResourceSelectionPage_noServices;
063: public static String ResourceSelectionPage_searching;
064: public static String Workflow_task_name;
065: public static String WorkflowWizardDialog_importTask;
066: public static String WorkflowWizard_noStates;
067: public static String WorkflowWizard_noPage;
068: public static String Workflow_busy;
069: public static String SearchView_wait;
070: public static String SearchView_title;
071: public static String SearchView_server;
072: public static String SearchView_searching_for;
073: public static String SearchView_searching;
074: public static String SearchView_prompt;
075: public static String SearchView_notFound;
076: public static String SearchView_name;
077: public static String SearchView_keywords;
078: public static String SearchView_instructions;
079: public static String SearchView_description;
080: public static String SearchView_default;
081: public static String SearchView_bboxTooltip;
082: public static String SearchView_bbox;
083: public static String ResourceSelectionState_taskName;
084: public static String ResourceSelectionState_stateName;
085: public static String ResourceSelectionPage_title;
086: public static String ResourceSelectionPage_message;
087: public static String ResolveTitlesDecorator_0;
088: public static String ResolveLabelProvider_missingText;
089: public static String ResolveContentProvider_searching;
090: public static String OpenFilePage_pageTitle;
091: public static String OpenFilePage_backButton2;
092: public static String OpenFilePage_backButton1;
093: public static String OpenFilePage_1;
094: public static String NewFeatureTypeState_name;
095: public static String NewFeatureTypeOp_2;
096: public static String NewFeatureTypeOp_1;
097: public static String NewFeatureTypeOp_0;
098: public static String NewFeatureTypeOp_title;
099: public static String NewFeatureTypeOp_shpTitle;
100: public static String NewFeatureTypeOp_shpMessage;
101: public static String NewFeatureTypeOp_message;
102: public static String NewFeatureTypeOp_cantWriteTitle;
103: public static String NewFeatureTypeOp_cantWriteMessage1;
104: public static String FileConnectionPage_taskname;
105: public static String FileChooserWizardPage_title;
106: public static String FileChooserWizardPage_taskname;
107: public static String FileChooserWizardPage_subtask_name;
108: public static String FileChooserWizardPage_rootDirectory_label_tooltip;
109: public static String FileChooserWizardPage_rootDirectory_label_text;
110: public static String FileChooserWizardPage_directoryDialog_text;
111: public static String FileChooserWizardPage_browseButton_text;
112: public static String DataSourceSelectionState_name;
113: public static String DataSourceSelectionPage_pageTitle;
114: public static String DataSourceSelectionPage_defaultMessage;
115: public static String DataImportWizard_importErrorMessage;
116: public static String DataBaseRegistryWizardPage_schemaMessage;
117: public static String DataBaseRegistryWizardPage_label_username_tooltip;
118: public static String DataBaseRegistryWizardPage_label_username_text;
119: public static String DataBaseRegistryWizardPage_label_schema_tooltip;
120: public static String DataBaseRegistryWizardPage_label_schema_text;
121: public static String DataBaseRegistryWizardPage_label_port_tooltip;
122: public static String DataBaseRegistryWizardPage_label_port_text;
123: public static String DataBaseRegistryWizardPage_label_password_tooltip;
124: public static String DataBaseRegistryWizardPage_label_password_text;
125: public static String DataBaseRegistryWizardPage_label_host_tooltip;
126: public static String DataBaseRegistryWizardPage_label_host_text;
127: public static String DataBaseRegistryWizardPage_label_database_tooltip;
128: public static String DataBaseRegistryWizardPage_label_database_text;
129: public static String DataBaseRegistryWizardPage_label_advanced_tooltip;
130: public static String DataBaseRegistryWizardPage_label_advanced_text;
131: public static String CountOp_numberOfFeatures;
132: public static String CountOp_featureCount;
133: public static String ConnectionState_task;
134: public static String ConnectionState_name;
135: public static String ConnectionState_loadingLayer;
136: public static String ConnectionState_findLayers;
137: public static String ConnectionPage_illegalHost;
138: public static String ConnectionPage_genericError;
139: public static String ConnectionPage_badUsername;
140: public static String ConnectionPage_badPassword;
141: public static String ConnectionErrorPage_pageTitle;
142: public static String ConnectionErrorPage_pageName;
143: public static String ConnectionErrorPage_pageDescription;
144: public static String ConnectionErrorPage_message;
145: public static String CatalogView_save_label;
146: public static String CatalogView_load_label;
147: public static String CatalogUIPlugin_these_do_not_work;
148: public static String CatalogUIPlugin_childContainerException;
149: public static String CatalogPreferencePage_fieldName;
150: public static String CatalogPreferencePage_description;
151: public static String CatalogImportWizard_title;
152: public static String CatalogImportWizard_serviceErrorMessage;
153: public static String CatalogImportWizard_selectionErrorMessage;
154: public static String CatalogImportWizard_resourceErrorMessage;
155: public static String CatalogImportWizard_pageName;
156: public static String CatalogImportWizard_pageMessage;
157: public static String CatalogImportWizard_importJobName;
158: public static String CatalogImportDelegateWizard_windowTitle;
159: public static String CatalogImport_monitor_task;
160: public static String NewServiceConnectionFactory_defaultGeom;
161: public static String DependencyQueryPreferencePage_restartQuestion;
162: public static String DependencyQueryPreferencePage_restartNeeded;
163: public static String DependencyQueryPreferencePage_restartTitle;
164: public static String DependencyQueryPreferencePage_notValid;
165: public static String DependencyQueryPreferencePage_copyError;
166: public static String DependencyQueryPreferencePage_archive;
167: public static String DependencyQueryPreferencePage_browse;
168: public static String DependencyQueryPreferencePage_fileExists;
169: public static String DependencyQueryPreferencePage_fileNotFound;
170: public static String CatalogExport_cannotWrite;
171: public static String CatalogExport_dupeTryAgain;
172: public static String CatalogExport_subtaskName;
173: public static String CatalogExport_taskname;
174: public static String CatalogExport_duplicate;
175: public static String CatalogExport_layerFail;
176: public static String CatalogExport_exportLayersTask;
177: public static String CatalogExport_existsMulti;
178: public static String CatalogExport_exists;
179: public static String CatalogExport_save;
180: public static String CatalogExport_taskName;
181: public static String CountDownProgressMonitor_taskNamePart1;
182: public static String CountDownProgressMonitor_taskNamePart2;
183: public static String LayerSelectionPage_message;
184: public static String LayerSelectionPage_title;
185:
186: static {
187: // initialize resource bundle
188: NLS.initializeMessages(BUNDLE_NAME, Messages.class);
189: }
190:
191: private Messages() {
192: }
193:
194: /**
195: * Initialize the given Action from a ResourceBundle.
196: * <p>
197: * Makes use of the following keys:
198: * <ul>
199: * <li>prefix.label
200: * <li>prefix.tooltip
201: * <li>prefix.image
202: * <li>prefix.description
203: * </p>
204: * <p>
205: * Note: The use of a single image value is mapped to images for both the enabled and distabled
206: * state of the IAction. the Local toolbar (elcl16/ and dlcl16/) is assumed if a path has not
207: * been provided.
208: *
209: * <pre><code>
210: * add_co.gif (prefix.image)
211: * enabled: elcl16/add_co.gif
212: * disabled: dlcl/remove_co.gif
213: * tool16/discovery_wiz.16 (prefix.image)
214: * enabled: etool16/discovery_wiz.16
215: * disabled: etool16/discovery_wiz.16
216: * </code></pre>
217: *
218: * </p>
219: *
220: * @param a action
221: * @param id used for binding (id.label, id.tooltip, ...)
222: */
223: public static void initAction(IAction a, String id) {
224: String labelKey = "_label"; //$NON-NLS-1$
225: String tooltipKey = "_tooltip"; //$NON-NLS-1$
226: String imageKey = "_image"; //$NON-NLS-1$
227: String descriptionKey = "_description"; //$NON-NLS-1$
228: if (id != null && id.length() > 0) {
229: labelKey = id + labelKey;
230: tooltipKey = id + tooltipKey;
231: imageKey = id + imageKey;
232: descriptionKey = id + descriptionKey;
233: }
234: String s = bind(labelKey);
235: if (s != null)
236: a.setText(s);
237: s = bind(tooltipKey);
238: if (s != null)
239: a.setToolTipText(s);
240: s = bind(descriptionKey);
241: if (s != null)
242: a.setDescription(s);
243: String relPath = bind(imageKey);
244: if (relPath != null && !relPath.equals(imageKey)
245: && relPath.trim().length() > 0) {
246: String dPath;
247: String ePath;
248: if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$
249: String path = relPath.substring(1);
250: dPath = 'd' + path;
251: ePath = 'e' + path;
252: } else {
253: dPath = "dlcl16/" + relPath; //$NON-NLS-1$
254: ePath = "elcl16/" + relPath; //$NON-NLS-1$
255: }
256: ImageDescriptor image;
257:
258: image = Images.getDescriptor(ePath);
259: if (id != null) {
260: CatalogUIPlugin.trace(id
261: + ": '" + ePath + "' found " + id); //$NON-NLS-1$ //$NON-NLS-2$
262: a.setImageDescriptor(image);
263: }
264: image = Images.getDescriptor(dPath);
265: if (id != null) {
266: CatalogUIPlugin.trace(id
267: + ": '" + dPath + "' found " + id); //$NON-NLS-1$ //$NON-NLS-2$
268: a.setDisabledImageDescriptor(image);
269: }
270: }
271: }
272:
273: private static String bind(String fieldName) {
274: Field field;
275: try {
276: field = Messages.class.getDeclaredField(fieldName);
277: return (String) field.get(null);
278: } catch (Exception e) {
279: CatalogUIPlugin.log("Error loading key " + fieldName, e); //$NON-NLS-1$
280: }
281: return null;
282: }
283: }
|