Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 30d68e7cf7d1b978bd93805854753847e9020335 (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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*******************************************************************************
 * Copyright (c) 2015, 2018 Obeo.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors: Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.eef.properties.ui.legacy.internal;

import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.eef.properties.ui.legacy.internal.extension.AbstractRegistryEventListener;
import org.eclipse.eef.properties.ui.legacy.internal.extension.impl.LegacyPropertyContributorRegistry;
import org.eclipse.eef.properties.ui.legacy.internal.extension.impl.LegacyPropertyContributorRegistryEventListener;
import org.eclipse.eef.properties.ui.legacy.internal.extension.impl.LegacyPropertySectionRegistry;
import org.eclipse.eef.properties.ui.legacy.internal.extension.impl.LegacyPropertySectionsRegistryEventListener;
import org.eclipse.eef.properties.ui.legacy.internal.extension.impl.LegacyPropertyTabRegistry;
import org.eclipse.eef.properties.ui.legacy.internal.extension.impl.LegacyPropertyTabsRegistryEventListener;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
import org.osgi.framework.BundleContext;

/**
 * The plugin class of the bundle.
 *
 * @author mbats
 */
public class EEFPropertiesUiLegacyPlugin extends EMFPlugin {

	/**
	 * The identifier of the plugin.
	 */
	public static final String PLUGIN_ID = "org.eclipse.eef.properties.ui.legacy"; //$NON-NLS-1$

	/**
	 * The identifier of the legacuy tabbed properties plugin.
	 */
	public static final String LEGACY_TABBED_PROPERTIES_PLUGIN_ID = "org.eclipse.ui.views.properties.tabbed"; //$NON-NLS-1$

	/**
	 * The sole instance of the plugin.
	 */
	public static final EEFPropertiesUiLegacyPlugin INSTANCE = new EEFPropertiesUiLegacyPlugin();

	/**
	 * The name of the extension point for the tabbed property contributor.
	 */
	private static final String PROPERTY_CONTRIBUTOR_EXTENSION_POINT = "propertyContributor"; //$NON-NLS-1$

	/**
	 * The name of the extension point for the tabbed property sections.
	 */
	private static final String PROPERTY_SECTIONS_EXTENSION_POINT = "propertySections"; //$NON-NLS-1$

	/**
	 * The name of the extension point for the tabbed property tabs.
	 */
	private static final String PROPERTY_TABS_EXTENSION_POINT = "propertyTabs"; //$NON-NLS-1$

	/**
	 * The OSGi related implementation of the plugin.
	 */
	private static Implementation plugin;

	/**
	 * The constructor.
	 */
	public EEFPropertiesUiLegacyPlugin() {
		super(new ResourceLocator[0]);
	}

	/**
	 * {@inheritDoc}
	 *
	 * @see org.eclipse.emf.common.EMFPlugin#getPluginResourceLocator()
	 */
	@Override
	public ResourceLocator getPluginResourceLocator() {
		return plugin;
	}

	/**
	 * Returns the OSGi related implementation.
	 *
	 * @return The OSGi related implementation
	 */
	public static Implementation getImplementation() {
		return plugin;
	}

	/**
	 * This class is used as the bundle activator of the plugin.
	 *
	 * @author mbats
	 */
	public static class Implementation extends EclipsePlugin {

		/**
		 * The registry used to retrieve the property tab descriptor provider.
		 */
		private LegacyPropertyTabRegistry tabbedPropertyTabsRegistry;

		/**
		 * The registry used to retrieve the property section descriptor provider.
		 */
		private LegacyPropertySectionRegistry tabbedPropertySectionsRegistry;

		/**
		 * The registry used to retrieve the property contributor descriptor provider.
		 */
		private LegacyPropertyContributorRegistry tabbedPropertyContributorRegistry;

		/**
		 * The extension registry listener used to populate the registry of tabbed property tabs.
		 */
		private AbstractRegistryEventListener tabbedPropertyTabsListener;

		/**
		 * The extension registry listener used to populate the registry of tabbed property sections.
		 */
		private AbstractRegistryEventListener tabbedPropertySectionsListener;

		/**
		 * The extension registry listener used to populate the registry of tabbed property contributor.
		 */
		private AbstractRegistryEventListener tabbedPropertyContributorListener;

		/**
		 * The constructor.
		 */
		public Implementation() {
			super();

			EEFPropertiesUiLegacyPlugin.plugin = this;
		}

		/**
		 * {@inheritDoc}
		 *
		 * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
		 */
		@Override
		public void start(BundleContext context) throws Exception {
			super.start(context);

			IExtensionRegistry registry = Platform.getExtensionRegistry();

			this.tabbedPropertyContributorRegistry = new LegacyPropertyContributorRegistry();
			this.tabbedPropertyContributorListener = new LegacyPropertyContributorRegistryEventListener(LEGACY_TABBED_PROPERTIES_PLUGIN_ID,
					PROPERTY_CONTRIBUTOR_EXTENSION_POINT, this.tabbedPropertyContributorRegistry);
			registry.addListener(this.tabbedPropertyContributorListener,
					LEGACY_TABBED_PROPERTIES_PLUGIN_ID + '.' + PROPERTY_CONTRIBUTOR_EXTENSION_POINT);
			this.tabbedPropertyContributorListener.readRegistry(registry);

			this.tabbedPropertySectionsRegistry = new LegacyPropertySectionRegistry();
			this.tabbedPropertySectionsListener = new LegacyPropertySectionsRegistryEventListener(LEGACY_TABBED_PROPERTIES_PLUGIN_ID,
					PROPERTY_SECTIONS_EXTENSION_POINT, this.tabbedPropertySectionsRegistry);
			registry.addListener(this.tabbedPropertySectionsListener, LEGACY_TABBED_PROPERTIES_PLUGIN_ID + '.' + PROPERTY_SECTIONS_EXTENSION_POINT);
			this.tabbedPropertySectionsListener.readRegistry(registry);

			this.tabbedPropertyTabsRegistry = new LegacyPropertyTabRegistry();
			this.tabbedPropertyTabsListener = new LegacyPropertyTabsRegistryEventListener(LEGACY_TABBED_PROPERTIES_PLUGIN_ID,
					PROPERTY_TABS_EXTENSION_POINT, this.tabbedPropertyTabsRegistry);
			registry.addListener(this.tabbedPropertyTabsListener, LEGACY_TABBED_PROPERTIES_PLUGIN_ID + '.' + PROPERTY_TABS_EXTENSION_POINT);
			this.tabbedPropertyTabsListener.readRegistry(registry);
		}

		/**
		 * {@inheritDoc}
		 *
		 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
		 */
		@Override
		public void stop(BundleContext context) throws Exception {
			super.stop(context);

			IExtensionRegistry registry = Platform.getExtensionRegistry();

			registry.removeListener(this.tabbedPropertyTabsListener);
			registry.removeListener(this.tabbedPropertySectionsListener);
			registry.removeListener(this.tabbedPropertyContributorListener);
			this.tabbedPropertyTabsListener = null;
			this.tabbedPropertyTabsRegistry.dispose();
			this.tabbedPropertyTabsRegistry = null;
			this.tabbedPropertySectionsListener = null;
			this.tabbedPropertySectionsRegistry = null;
			this.tabbedPropertyContributorListener = null;
			this.tabbedPropertyContributorRegistry = null;
		}

		/**
		 * Return the tabbedPropertyTabsRegistry.
		 *
		 * @return the tabbedPropertyTabsRegistry
		 */
		public LegacyPropertyTabRegistry getTabbedPropertyTabsRegistry() {
			return this.tabbedPropertyTabsRegistry;
		}

		/**
		 * Return the tabbedPropertySectionsRegistry.
		 *
		 * @return the tabbedPropertySectionsRegistry
		 */
		public LegacyPropertySectionRegistry getTabbedPropertySectionsRegistry() {
			return this.tabbedPropertySectionsRegistry;
		}

		/**
		 * Return the tabbedPropertyContributorRegistry.
		 *
		 * @return the tabbedPropertyContributorRegistry
		 */
		public LegacyPropertyContributorRegistry getTabbedPropertyContributorRegistry() {
			return this.tabbedPropertyContributorRegistry;
		}

		/**
		 * Logs an error with the exception and the given message.
		 *
		 * @param message
		 *            The message
		 * @param exception
		 *            The exception
		 */
		public void logError(String message, Exception exception) {
			IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, exception);
			this.getLog().log(status);
		}

		/**
		 * Logs a warning with the exception and the given message.
		 *
		 * @param message
		 *            The message
		 * @param exception
		 *            The exception
		 */
		public void logWarning(String message, Exception exception) {
			IStatus status = new Status(IStatus.WARNING, PLUGIN_ID, message, exception);
			this.getLog().log(status);
		}
	}
}

Back to the top