Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3a4982c3b556bbffdcddb95341ca6041fe79d83e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*******************************************************************************
 * Copyright (c) 2001, 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
 *     Jens Lukowski/Innoopract - initial renaming/restructuring
 *     
 *******************************************************************************/


package org.eclipse.wst.xml.ui.util;


import java.text.MessageFormat;
import java.util.ResourceBundle;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.views.markers.internal.ImageFactory;
import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;



/**
 * This class exists temporarily until the properties files can be
 * re-organized and the various resource references can be updated
 */
public class XMLCommonResources {
	protected static XMLCommonResources instance;

	public synchronized static XMLCommonResources getInstance() {
		if (instance == null)
			instance = new XMLCommonResources(XMLUIPlugin.getDefault());
		return instance;
	}

	private XMLUIPlugin editorPlugin;

	protected ImageFactory imageFactory;
	private ResourceBundle resourceBundle;

	public XMLCommonResources(XMLUIPlugin editorPlugin) {
		instance = this;
		this.editorPlugin = editorPlugin;
		//imageFactory = new ImageFactory();
		try {
			resourceBundle = ResourceBundle.getBundle("EditingXML"); //$NON-NLS-1$
			imageFactory = new ImageFactory();
		} catch (java.util.MissingResourceException exception) {
			//TODO... log an error message
			//B2BUtilPlugin.getPlugin().getMsgLogger().write(B2BUtilPlugin.getGUIString("_WARN_PLUGIN_PROPERTIES_MISSING")
			// + descriptor.getLabel());
			resourceBundle = null;
		}
	}

	 ImageDescriptor _getImageDescriptor(String iconName) {
		return AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, iconName);
	}


	public ResourceBundle getResourceBundle() {
		return resourceBundle;
	}

	/**
	 * This gets the string resource.
	 */
	public String getString(String key) {
		return getResourceBundle().getString(key);
	}

	/**
	 * This gets the string resource and does one substitution.
	 */
	public String getString(String key, Object s1) {
		return MessageFormat.format(getString(key), new Object[]{s1});
	}

	/**
	 * This gets the string resource and does two substitutions.
	 */
	public String getString(String key, Object s1, Object s2) {
		return MessageFormat.format(getString(key), new Object[]{s1, s2});
	}

	public IWorkbench getWorkbench() {
		return editorPlugin.getWorkbench();
	}
	/*
	 * public ImageFactory getImageFactory() { return imageFactory; }
	 */
}

Back to the top