Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 878ec9fd261cf1049684af86303da5be28e6bd23 (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
/*****************************************************************************
 * Copyright (c) 2012, 2014 CEA LIST 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:
 *  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
 *  Christian W. Damus (CEA) - bug 417409
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;

import org.eclipse.papyrus.infra.gmfdiag.properties.Activator;
import org.eclipse.papyrus.infra.gmfdiag.properties.extension.StyleHandlerManager;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory;

/**
 * A ModelElementFactory for the Appearance property view. Dispatches the
 * creation of ModelElement to the registered StyleHandlerProvider with
 * the highest priority.
 *
 * @author Camille Letavernier
 */
public class AppearanceModelElementFactory implements ModelElementFactory {

	public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
		for (StyleHandlerProvider provider : StyleHandlerManager.instance.getStyleHandlerProviders()) {
			if (provider.isProviderFor(sourceElement)) {
				ModelElement element = provider.createModelElement(sourceElement, context);
				if (element == null) {
					Activator.log.warn("The StyleHandlerProvider " + provider.getClass().getName() + " provided an invalid ModelElement");
				}
				return element;
			}
		}

		Activator.log.warn("No StyleHandlerProvider found for the following object: " + sourceElement);
		return null;
	}

}

Back to the top