diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml')
8 files changed, 116 insertions, 100 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLEditorResourceHandler.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLEditorResourceHandler.java new file mode 100644 index 0000000000..1c5ae81ec9 --- /dev/null +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLEditorResourceHandler.java @@ -0,0 +1,65 @@ +/***************************************************************************** + * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This + * program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and + * is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + ****************************************************************************/ +package org.eclipse.wst.xml.internal.ui; + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class XMLEditorResourceHandler { + //Resource bundle. + private static ResourceBundle resourceBundle; + private static final String KEY_PREFIX = "%"; //$NON-NLS-1$ + private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$ + + /** + * Returns the string from the plugin's resource bundle, + * or 'key' if not found. + */ + public static String getResourceString(String value) { + String s = value.trim(); + if (!s.startsWith(KEY_PREFIX, 0)) + return s; + if (s.startsWith(KEY_DOUBLE_PREFIX, 0)) + return s.substring(1); + + int ix = s.indexOf(' '); + String key = ix == -1 ? s : s.substring(0, ix); + + ResourceBundle bundle = getResourceBundle(); + try { + return (bundle != null) ? bundle.getString(key.substring(1)) : key; + } catch (MissingResourceException e) { + return key; + } + } + + public static String getResourceString(String key, Object[] args) { + + try { + return MessageFormat.format(getResourceString(key), args); + } catch (IllegalArgumentException e) { + return getResourceString(key); + } + + } + + /** + * Returns the plugin's resource bundle, + */ + public static ResourceBundle getResourceBundle() { + try { + if (resourceBundle == null) + resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.xml.internal.ui.XMLEditorResources"); + } catch (MissingResourceException x) { + resourceBundle = null; + } + return resourceBundle; + } +} diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLEditorResources.properties b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLEditorResources.properties new file mode 100644 index 0000000000..6fcd774694 --- /dev/null +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLEditorResources.properties @@ -0,0 +1,25 @@ +############################################################################### +# Copyright (c) 2004 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +XMLTableTreeViewer.0=Design +XMLMultiPageEditorPart.0=Source +XMLTreeExtension.0=Structure +XMLTreeExtension.1=Value +XMLTreeExtension.3=The document is empty. +XMLTreeExtension.4=Right mouse click here to insert content. +XMLTableTreeActionBarContributor.0=&XML +XMLTableTreeActionBarContributor.1=&Expand All +XMLTableTreeActionBarContributor.2=&Collapse All +XMLTableTreeActionBarContributor.3=Turn Grammar Constraints Off +XMLTableTreeActionBarContributor.4=&Turn Grammar Constraints Off +XMLTableTreeActionBarContributor.5=Turn Grammar Constraints On +XMLTableTreeActionBarContributor.6=&Turn Grammar Constraints On +XMLTableTreeActionBarContributor.7=Reload Dependencies +XMLTableTreeActionBarContributor.8=&Reload Dependencies diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLMultiPageEditorPart.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLMultiPageEditorPart.java index 9a046ba023..9021fe5831 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLMultiPageEditorPart.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/internal/ui/XMLMultiPageEditorPart.java @@ -48,7 +48,7 @@ import org.eclipse.ui.part.MultiPageEditorSite; import org.eclipse.wst.sse.core.IStructuredModel; import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException; import org.eclipse.wst.sse.ui.StructuredTextEditor; -import org.eclipse.wst.sse.ui.nls.ResourceHandler; +import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; import org.eclipse.wst.xml.core.XMLPreferenceNames; import org.eclipse.wst.xml.ui.StructuredTextEditorXML; import org.eclipse.wst.xml.ui.internal.Logger; @@ -58,7 +58,6 @@ import org.eclipse.wst.xml.ui.internal.tabletree.XMLTableTreeViewer; import org.w3c.dom.Document; import org.w3c.dom.Node; - public class XMLMultiPageEditorPart extends MultiPageEditorPart implements IPropertyListener { /** @@ -168,7 +167,7 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements IProp protected void addSourcePage() throws PartInitException { try { fSourcePageIndex = addPage(fTextEditor, getEditorInput()); - setPageText(fSourcePageIndex, org.eclipse.wst.xml.ui.nls2.ResourceHandler.getString("XMLMultiPageEditorPart.0")); //$NON-NLS-1$ + setPageText(fSourcePageIndex, XMLEditorResourceHandler.getResourceString("%XMLMultiPageEditorPart.0")); //$NON-NLS-1$ // the update's critical, to get viewer selection manager and // highlighting to work fTextEditor.update(); @@ -183,7 +182,7 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements IProp // dispose editor dispose(); Logger.logException(exception); - throw new SourceEditingRuntimeException(exception, ResourceHandler.getString("An_error_has_occurred_when1_ERROR_")); //$NON-NLS-1$ + throw new SourceEditingRuntimeException(exception, SSEUIPlugin.getResourceString("%An_error_has_occurred_when1_ERROR_")); //$NON-NLS-1$ } } @@ -375,10 +374,10 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements IProp // very unlikely Logger.logException(ce); } - throw new PartInitException(ResourceHandler.getString("23concat_EXC_", (new Object[]{input.getName()}))); //$NON-NLS-1$ + throw new PartInitException(SSEUIPlugin.getResourceString("%23concat_EXC_", (new Object[]{input.getName()}))); //$NON-NLS-1$ //$NON-NLS-1$ = "Resource {0} does not exist." } else { - throw new PartInitException(ResourceHandler.getString("32concat_EXC_", (new Object[]{input.getName()}))); //$NON-NLS-1$ + throw new PartInitException(SSEUIPlugin.getResourceString("%32concat_EXC_", (new Object[]{input.getName()}))); //$NON-NLS-1$ //$NON-NLS-1$ = "Editor could not be open on {0}" } } @@ -389,7 +388,7 @@ public class XMLMultiPageEditorPart extends MultiPageEditorPart implements IProp } catch (CoreException noStorageExc) { } if (contents == null) { - throw new PartInitException(ResourceHandler.getString("32concat_EXC_", (new Object[]{input.getName()}))); //$NON-NLS-1$ + throw new PartInitException(SSEUIPlugin.getResourceString("%32concat_EXC_", (new Object[]{input.getName()}))); //$NON-NLS-1$ } else { try { contents.close(); diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java index 956c7dee2c..9d37f78fc8 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java @@ -6,8 +6,6 @@ * * Contributors: IBM Corporation - initial API and implementation ****************************************************************************/ - - package org.eclipse.wst.xml.ui.internal.tabletree; import org.eclipse.jface.action.Action; @@ -15,9 +13,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.wst.xml.internal.ui.XMLEditorPluginImageHelper; import org.eclipse.wst.xml.internal.ui.XMLEditorPluginImages; -import org.eclipse.wst.xml.ui.util.XMLCommonResources; - - +import org.eclipse.wst.xml.ui.internal.XMLUIPlugin; public class ViewerExpandCollapseAction extends Action { @@ -32,14 +28,14 @@ public class ViewerExpandCollapseAction extends Action { setImageDescriptor(e_imageDescriptor); setDisabledImageDescriptor(d_imageDescriptor); - setToolTipText(XMLCommonResources.getInstance().getString("_UI_INFO_EXPAND_ALL")); //$NON-NLS-1$ + setToolTipText(XMLUIPlugin.getResourceString("%_UI_INFO_EXPAND_ALL")); //$NON-NLS-1$ } else { ImageDescriptor e_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_ETOOL_COLLAPSEALL); ImageDescriptor d_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_DTOOL_COLLAPSEALL); setImageDescriptor(e_imageDescriptor); setDisabledImageDescriptor(d_imageDescriptor); - setToolTipText(XMLCommonResources.getInstance().getString("_UI_INFO_COLLAPSE_ALL")); //$NON-NLS-1$ + setToolTipText(XMLUIPlugin.getResourceString("%_UI_INFO_COLLAPSE_ALL")); //$NON-NLS-1$ } } diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java index a520562b48..252d0b00a1 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java @@ -35,12 +35,11 @@ import org.eclipse.wst.xml.core.document.XMLModel; import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil; import org.eclipse.wst.xml.internal.ui.IDesignViewer; import org.eclipse.wst.xml.internal.ui.IDesignViewerActionBarContributor; +import org.eclipse.wst.xml.internal.ui.XMLEditorResourceHandler; import org.eclipse.wst.xml.internal.ui.XMLMultiPageEditorPart; -import org.eclipse.wst.xml.ui.nls2.ResourceHandler; import org.eclipse.wst.xml.ui.util.SharedXMLEditorPluginImageHelper; import org.w3c.dom.Document; - /** * */ @@ -98,7 +97,7 @@ public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarC IMenuManager xmlMenu = bars.getMenuManager().findMenuUsingPath("com.ibm.etools.sed.editor.xmlmenu"); //$NON-NLS-1$ if (xmlMenu == null) { - xmlMenu = new MenuManager(ResourceHandler.getString("XMLTableTreeActionBarContributor.0"), "com.ibm.etools.sed.editor.xmlmenu"); //$NON-NLS-1$ //$NON-NLS-2$ + xmlMenu = new MenuManager(XMLEditorResourceHandler.getResourceString("%XMLTableTreeActionBarContributor.0"), "com.ibm.etools.sed.editor.xmlmenu"); //$NON-NLS-1$ //$NON-NLS-2$ bars.getMenuManager().insertBefore(IWorkbenchActionConstants.M_WINDOW, xmlMenu); } else { removeContributions(xmlMenu); @@ -139,13 +138,13 @@ public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarC // xmlMenuExpandAction = new ViewerExpandCollapseAction(true); xmlMenuExpandAction.setId(EXPAND_ALL_ID); - xmlMenuExpandAction.setText(ResourceHandler.getString("XMLTableTreeActionBarContributor.1")); //$NON-NLS-1$ + xmlMenuExpandAction.setText(XMLEditorResourceHandler.getResourceString("%XMLTableTreeActionBarContributor.1")); //$NON-NLS-1$ xmlMenu.add(xmlMenuExpandAction); xmlMenuCollapseAction = new ViewerExpandCollapseAction(false); xmlMenuCollapseAction.setId(COLLAPSE_ALL_ID); xmlMenuCollapseAction.setId(EXPAND_ALL_ID); - xmlMenuCollapseAction.setText(ResourceHandler.getString("XMLTableTreeActionBarContributor.2")); //$NON-NLS-1$ + xmlMenuCollapseAction.setText(XMLEditorResourceHandler.getResourceString("%XMLTableTreeActionBarContributor.2")); //$NON-NLS-1$ xmlMenu.add(xmlMenuCollapseAction); } @@ -262,12 +261,12 @@ public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarC public void setAppearanceForEditMode(int editMode) { if (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) { - setToolTipText(ResourceHandler.getString("XMLTableTreeActionBarContributor.3")); //$NON-NLS-1$ - setText(ResourceHandler.getString("XMLTableTreeActionBarContributor.4")); //$NON-NLS-1$ + setToolTipText(XMLEditorResourceHandler.getResourceString("%XMLTableTreeActionBarContributor.3")); //$NON-NLS-1$ + setText(XMLEditorResourceHandler.getResourceString("%XMLTableTreeActionBarContributor.4")); //$NON-NLS-1$ setImageDescriptor(onImage); } else { - setToolTipText(ResourceHandler.getString("XMLTableTreeActionBarContributor.5")); //$NON-NLS-1$ - setText(ResourceHandler.getString("XMLTableTreeActionBarContributor.6")); //$NON-NLS-1$ + setToolTipText(XMLEditorResourceHandler.getResourceString("%XMLTableTreeActionBarContributor.5")); //$NON-NLS-1$ + setText(XMLEditorResourceHandler.getResourceString("%XMLTableTreeActionBarContributor.6")); //$NON-NLS-1$ setImageDescriptor(offImage); } } @@ -292,8 +291,8 @@ public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarC public ReloadGrammarAction() { setDisabledImageDescriptor(SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_DTOOL_RLDGRMR)); setImageDescriptor(SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_RLDGRMR)); - setToolTipText(ResourceHandler.getString("XMLTableTreeActionBarContributor.7")); //$NON-NLS-1$ - setText(ResourceHandler.getString("XMLTableTreeActionBarContributor.8")); //$NON-NLS-1$ + setToolTipText(XMLEditorResourceHandler.getResourceString("%XMLTableTreeActionBarContributor.7")); //$NON-NLS-1$ + setText(XMLEditorResourceHandler.getResourceString("%XMLTableTreeActionBarContributor.8")); //$NON-NLS-1$ } public void setModel(IStructuredModel newModel) { diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java index 6892a84ce8..34bb4e7af7 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java @@ -34,13 +34,12 @@ import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent; import org.eclipse.wst.xml.core.document.XMLModel; import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil; import org.eclipse.wst.xml.internal.ui.IDesignViewer; +import org.eclipse.wst.xml.internal.ui.XMLEditorResourceHandler; import org.eclipse.wst.xml.ui.actions.NodeAction; import org.eclipse.wst.xml.ui.dnd.XMLDragAndDropManager; -import org.eclipse.wst.xml.ui.nls2.ResourceHandler; import org.eclipse.wst.xml.ui.views.contentoutline.XMLNodeActionManager; import org.w3c.dom.Document; - public class XMLTableTreeViewer extends TreeViewer implements IDesignViewer { /** @@ -246,7 +245,7 @@ public class XMLTableTreeViewer extends TreeViewer implements IDesignViewer { } public String getTitle() { - return ResourceHandler.getString("XMLTableTreeViewer.0"); //$NON-NLS-1$ + return XMLEditorResourceHandler.getResourceString("%XMLTableTreeViewer.0"); //$NON-NLS-1$ } protected void handleDispose(DisposeEvent event) { diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java index 5166eba447..44a0373dfc 100644 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java +++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java @@ -6,8 +6,6 @@ * * Contributors: IBM Corporation - initial API and implementation ****************************************************************************/ - - package org.eclipse.wst.xml.ui.internal.tabletree; import org.eclipse.jface.viewers.CellEditor; @@ -24,15 +22,14 @@ import org.eclipse.ui.views.properties.IPropertyDescriptor; import org.eclipse.wst.common.contentmodel.CMElementDeclaration; import org.eclipse.wst.common.contentmodel.modelquery.ModelQuery; import org.eclipse.wst.common.contentmodel.util.CMDescriptionBuilder; -import org.eclipse.wst.xml.ui.nls2.ResourceHandler; +import org.eclipse.wst.xml.internal.ui.XMLEditorResourceHandler; import org.w3c.dom.Element; import org.w3c.dom.Node; - public class XMLTreeExtension extends TreeExtension { - public final static String STRUCTURE_PROPERTY = ResourceHandler.getString("XMLTreeExtension.0"); //$NON-NLS-1$ - public final static String VALUE_PROPERTY = ResourceHandler.getString("XMLTreeExtension.1"); //$NON-NLS-1$ + public final static String STRUCTURE_PROPERTY = XMLEditorResourceHandler.getResourceString("%XMLTreeExtension.0"); //$NON-NLS-1$ + public final static String VALUE_PROPERTY = XMLEditorResourceHandler.getResourceString("%XMLTreeExtension.1"); //$NON-NLS-1$ protected Composite control; protected MyCellModifier modifier; @@ -112,8 +109,8 @@ public class XMLTreeExtension extends TreeExtension { // so that they know how to proceed to edit the blank view gc.setForeground(tree.getDisplay().getSystemColor(SWT.COLOR_BLACK)); gc.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); - gc.drawString(ResourceHandler.getString("XMLTreeExtension.3"), 10, 10); //$NON-NLS-1$ - gc.drawString(ResourceHandler.getString("XMLTreeExtension.4"), 10, 10 + gc.getFontMetrics().getHeight()); //$NON-NLS-1$ + gc.drawString(XMLEditorResourceHandler.getResourceString("%XMLTreeExtension.3"), 10, 10); //$NON-NLS-1$ + gc.drawString(XMLEditorResourceHandler.getResourceString("%XMLTreeExtension.4"), 10, 10 + gc.getFontMetrics().getHeight()); //$NON-NLS-1$ } public String getElementValueHelper(Element element) { diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/nls2/ResourceHandler.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/nls2/ResourceHandler.java deleted file mode 100644 index 1eae6c1f6e..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/nls2/ResourceHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2004 IBM Corporation and others. All rights reserved. This - * program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and - * is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - ****************************************************************************/ -package org.eclipse.wst.xml.ui.nls2; - -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class ResourceHandler { - - - private static ResourceBundle fgResourceBundle; - - /** - * Returns the resource bundle used by all classes in this Project - */ - public static ResourceBundle getResourceBundle() { - try { - return ResourceBundle.getBundle("xmleditor");//$NON-NLS-1$ - } catch (MissingResourceException e) { - // does nothing - this method will return null and - // getString(String) will return the key - // it was called with - } - return null; - } - - public static String getString(String key) { - if (fgResourceBundle == null) { - fgResourceBundle = getResourceBundle(); - } - - if (fgResourceBundle != null) { - try { - return fgResourceBundle.getString(key); - } catch (MissingResourceException e) { - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - } else { - return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$ - } - } - - public static String getString(String key, Object[] args) { - - try { - return MessageFormat.format(getString(key), args); - } catch (IllegalArgumentException e) { - return getString(key); - } - - } - - public static String getString(String key, Object[] args, int x) { - - return getString(key); - } -}
\ No newline at end of file |