Skip to main content
summaryrefslogtreecommitdiffstats
blob: 502a8c291e730e0d8d5039d63bff6ffd9c35742a (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
/*****************************************************************************
 * Copyright (c) 2008 CEA LIST.
 *
 *
 * 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:
 *  Cedric Dumoulin  Cedric.dumoulin@lifl.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.ui.multidiagram.actionbarcontributor;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.papyrus.infra.core.extension.BadNameExtensionException;
import org.eclipse.papyrus.infra.core.extension.ExtensionException;
import org.eclipse.papyrus.infra.core.extension.ExtensionUtils;
import org.eclipse.ui.part.EditorActionBarContributor;

/**
 * A factory used to create ActionBarContributor object from Eclipse extensions
 * points elements.
 *
 * @author Cedric Dumoulin
 * @auhtor Patrick Tessier
 * @since 1.2
 */
public class ActionBarContributorExtensionFactory extends ExtensionUtils {

	/** singleton eINSTANCE of this class */
	public final static ActionBarContributorExtensionFactory eINSTANCE = new ActionBarContributorExtensionFactory();

	/** constant for the editor diagram **/
	public final static String EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT = "" + "actionBarContributor";

	/** constant for the attribute factoryClass **/
	public final static String CONTEXTCLASS_ATTRIBUTE = "implementingClass";

	/** constant for the attribute contextId **/
	public final static String ID_ATTRIBUTE = "id";

	/**
	 * @return the eINSTANCE
	 */
	public static ActionBarContributorExtensionFactory getInstance() {
		return eINSTANCE;
	}

	/**
	 * Create a ContextDescriptor instance corresponding to the
	 * ConfigurationElement.
	 *
	 * @param element
	 *            an {@link IConfigurationElement} see eclipse extension point
	 * @return a ContextDescriptor structure that contains information to the
	 *         diagram context
	 * @throws BadNameExtensionException
	 **/
	public ActionBarContributorDescriptor createActionBarContributorDescriptor(IConfigurationElement element) throws ExtensionException {
		ActionBarContributorDescriptor res;

		checkTagName(element, EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT);

		res = new ActionBarContributorDescriptor();
		res.contextClass = (Class<EditorActionBarContributor>) parseClass(element, CONTEXTCLASS_ATTRIBUTE, EDITOR_ACTIONBARCONTRIBUTOR_EXTENSIONPOINT);
		res.contextId = element.getAttribute(ID_ATTRIBUTE);

		return res;
	}

}

Back to the top