Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: f1b2ee08ab6f5a3d0181d030af4805889d42d9b2 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2002, 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<LINK REL="STYLESHEET" HREF="../../book.css" TYPE="text/css">
<title>RSESamplesPlugin Class</title>
</head>

<body>
<h1>RSESamplesPlugin Class</h1>
<pre><samp>
package samples;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
import org.osgi.framework.BundleContext;

import samples.subsystems.DeveloperSubSystemConfigurationAdapterFactory;

/**
 * The activator class controls the plug-in life cycle
 */
public class RSESamplesPlugin extends SystemBasePlugin  {

	//The shared instance.
	private static RSESamplesPlugin plugin;

	//Resource bundle.
	private ResourceBundle resourceBundle;
	private static SystemMessageFile messageFile = null;
	
	/**
	 * The constructor.
	 */
	public RSESamplesPlugin() {
		super();
		plugin = this;
	}

	/**
	 * This method is called upon plug-in activation
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		messageFile = getMessageFile("rseSamplesMessages.xml"); //$NON-NLS-1$

		IAdapterManager manager = Platform.getAdapterManager();
		samples.model.DeveloperAdapterFactory factory = new samples.model.DeveloperAdapterFactory();
		manager.registerAdapters(factory, samples.model.TeamResource.class);
		manager.registerAdapters(factory, samples.model.DeveloperResource.class);

	    DeveloperSubSystemConfigurationAdapterFactory sscaf = new DeveloperSubSystemConfigurationAdapterFactory();
	    sscaf.registerWithManager(manager);

	}

	/**
	 * This method is called when the plug-in is stopped
	 */
	public void stop(BundleContext context) throws Exception {
		super.stop(context);
		plugin = null;
		resourceBundle = null;
	}

	/**
	 * Returns the shared instance.
	 */
	public static RSESamplesPlugin getDefault() {
		return plugin;
	}

	/**
	 * Returns the workspace instance.
	 */
	public static IWorkspace getWorkspace() {
		return ResourcesPlugin.getWorkspace();
	}

	/**
	 * Returns the string from the plugin's resource bundle,
	 * or 'key' if not found.
	 */
	public static String getResourceString(String key) {
		ResourceBundle bundle= RSESamplesPlugin.getDefault().getResourceBundle();
		try {
			return (bundle != null) ? bundle.getString(key) : key;
		} catch (MissingResourceException e) {
			return key;
		}
	}

	/**
	 * Returns the plugin's resource bundle,
	 */
	public ResourceBundle getResourceBundle() {
		try {
			if (resourceBundle == null)
				resourceBundle = ResourceBundle.getBundle("samples.rseSamplesResources");
		} catch (MissingResourceException x) {
			resourceBundle = null;
		}
		return resourceBundle;
	}

	/**
	 * @see AbstractUIPlugin#initializeDefaultPreferences
	 */
	//protected void initializeDefaultPreferences(IPreferenceStore store) 
	//{
	//	super.initializeDefaultPreferences(store);
	//	//RSESamplesPreferencePage.initDefaults(store);
	//}
	
	/**
	 * Initialize the image registry by declaring all of the required graphics.
	 */
	protected void initializeImageRegistry()
	{
		String path = getIconPath();
		putImageInRegistry("ICON_ID_TEAM", path + "team.gif");
		putImageInRegistry("ICON_ID_DEVELOPER", path + "developer.gif");
		putImageInRegistry("ICON_ID_TEAMFILTER", path + "teamFilter.gif");
		putImageInRegistry("ICON_ID_DEVELOPERFILTER", path + "developerFilter.gif");
	}

	/**
	 * Load a message file for this plugin.
	 * @param messageFileName - the name of the message xml file. Will look for it in this plugin's install folder.
	 * @return a message file object containing the parsed contents of the message file, or null if not found.
	 */
    public SystemMessageFile getMessageFile(String messageFileName)
    {
       return loadMessageFile(getBundle(), messageFileName);  	
    }	

	/**
	 * Return our message file
	 */
	public static SystemMessageFile getPluginMessageFile()
	{
		return messageFile;
	}  

	/**
	 * Retrieve a message from this plugin's message file
	 */
	public static SystemMessage getPluginMessage(String msgId)
	{
		return getMessage(messageFile, msgId);
	}
}
</samp></pre>
</p>
</body>
</html>

Back to the top