Browse Source

#358 : DomainRegistry refactored to allow standalone execution (without
eclipse extensions)

Johannes Dicks 10 years ago
parent
commit
bd7f90bdd5

+ 145 - 145
plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/DomainRegistry.java

@@ -1,145 +1,145 @@
-/**
- * Copyright (c) 2015 committers of YAKINDU 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:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.domain.extension;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.osgi.framework.Bundle;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-import org.yakindu.sct.model.sgraph.Statechart;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-/**
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class DomainRegistry {
-
-	private static final String EXTENSION_POINT = "org.yakindu.sct.domain";
-	private static final String DOMAIN_ID = "domainID";
-	private static final String DESCRIPTION = "description";
-	private static final String IMAGE = "image";
-	private static final String NAME = "name";
-	private static final String MODULE_PROVIDER = "domainModuleProvider";
-
-	private DomainRegistry() {
-	}
-
-	private static List<DomainDescriptor> descriptors = null;
-
-	public static final class DomainDescriptor {
-
-		private final IConfigurationElement configElement;
-
-		private Image image;
-
-		private IDomainInjectorProvider injectorProvider;
-
-		DomainDescriptor(IConfigurationElement configElement) {
-			this.configElement = configElement;
-		}
-
-		public String getDomainID() {
-			return configElement.getAttribute(DOMAIN_ID);
-		}
-
-		public String getName() {
-			return configElement.getAttribute(NAME);
-		}
-
-		public String getDescription() {
-			return configElement.getAttribute(DESCRIPTION);
-		}
-
-		public IDomainInjectorProvider getDomainInjectorProvider() {
-			if (injectorProvider == null) {
-				try {
-					injectorProvider = (IDomainInjectorProvider) configElement
-							.createExecutableExtension(MODULE_PROVIDER);
-				} catch (CoreException e) {
-					e.printStackTrace();
-				}
-			}
-			return injectorProvider;
-		}
-
-		public Image getImage() {
-			if (image != null)
-				return image;
-			String path = configElement.getAttribute(IMAGE);
-			if (path == null)
-				return null;
-
-			Bundle extensionBundle = Platform.getBundle(configElement.getContributor().getName());
-			URL entry = extensionBundle.getEntry(path);
-			ImageDescriptor descriptor = ImageDescriptor.createFromURL(entry);
-			image = descriptor.createImage();
-			return image;
-		}
-
-		public IConfigurationElement getConfigElement() {
-			return configElement;
-		}
-
-		public void setImage(Image image) {
-			this.image = image;
-		}
-	}
-
-	public static List<DomainDescriptor> getDomainDescriptors() {
-		if (descriptors == null) {
-			descriptors = new ArrayList<DomainDescriptor>();
-			IConfigurationElement[] configurationElements = Platform.getExtensionRegistry()
-					.getConfigurationElementsFor(EXTENSION_POINT);
-			for (IConfigurationElement iConfigurationElement : configurationElements) {
-				descriptors.add(new DomainDescriptor(iConfigurationElement));
-			}
-		}
-		return descriptors;
-	}
-
-	public static DomainDescriptor getDomainDescriptor(final String id) {
-		final String defaultDomainID = SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral();
-		try {
-			return Iterables.find(getDomainDescriptors(), new Predicate<DomainDescriptor>() {
-				@Override
-				public boolean apply(DomainDescriptor input) {
-					return input.getDomainID().equals(id != null ? id : defaultDomainID);
-				}
-			});
-		} catch (NoSuchElementException e) {
-			if (defaultDomainID.equals(id)) {
-				throw new IllegalArgumentException("No default domain found!");
-			}
-			System.err.println("Could not find domain descriptor for id " + id + " - > using default domain");
-			return getDomainDescriptor(defaultDomainID);
-		}
-	}
-
-	public static DomainDescriptor getDomainDescriptor(EObject object) {
-		EObject rootContainer = EcoreUtil.getRootContainer(object);
-		Assert.isTrue(rootContainer instanceof Statechart);
-		return getDomainDescriptor(((Statechart) rootContainer).getDomainID());
-	}
-}
+/**
+ * Copyright (c) 2015 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.domain.extension;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Bundle;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.Statechart;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class DomainRegistry {
+
+	private static final String EXTENSION_POINT = "org.yakindu.sct.domain";
+	private static final String DOMAIN_ID = "domainID";
+	private static final String DESCRIPTION = "description";
+	private static final String IMAGE = "image";
+	private static final String NAME = "name";
+	private static final String MODULE_PROVIDER = "domainModuleProvider";
+
+	private DomainRegistry() {
+	}
+
+	private static List<IDomainDescriptor> descriptors = null;
+
+	protected static final class ConfigElementDomainDescriptor implements IDomainDescriptor {
+
+		private final IConfigurationElement configElement;
+
+		private Image image;
+
+		private IDomainInjectorProvider injectorProvider;
+
+		ConfigElementDomainDescriptor(IConfigurationElement configElement) {
+			this.configElement = configElement;
+		}
+
+		@Override
+		public String getDomainID() {
+			return configElement.getAttribute(DOMAIN_ID);
+		}
+
+		@Override
+		public String getName() {
+			return configElement.getAttribute(NAME);
+		}
+
+		@Override
+		public String getDescription() {
+			return configElement.getAttribute(DESCRIPTION);
+		}
+
+		@Override
+		public IDomainInjectorProvider getDomainInjectorProvider() {
+			if (injectorProvider == null) {
+				try {
+					injectorProvider = (IDomainInjectorProvider) configElement
+							.createExecutableExtension(MODULE_PROVIDER);
+				} catch (CoreException e) {
+					e.printStackTrace();
+				}
+			}
+			return injectorProvider;
+		}
+
+		@Override
+		public Image getImage() {
+			if (image != null)
+				return image;
+			String path = configElement.getAttribute(IMAGE);
+			if (path == null)
+				return null;
+
+			Bundle extensionBundle = Platform.getBundle(configElement.getContributor().getName());
+			URL entry = extensionBundle.getEntry(path);
+			ImageDescriptor descriptor = ImageDescriptor.createFromURL(entry);
+			image = descriptor.createImage();
+			return image;
+		}
+	}
+
+	public static List<IDomainDescriptor> getDomainDescriptors() {
+		if (descriptors == null) {
+			descriptors = new ArrayList<IDomainDescriptor>();
+
+			if (Platform.isRunning()) {
+				IConfigurationElement[] configurationElements = Platform.getExtensionRegistry()
+						.getConfigurationElementsFor(EXTENSION_POINT);
+				for (IConfigurationElement iConfigurationElement : configurationElements) {
+					descriptors.add(new ConfigElementDomainDescriptor(iConfigurationElement));
+				}
+			}
+		}
+		return descriptors;
+	}
+
+	public static IDomainDescriptor getDomainDescriptor(final String id) {
+		final String defaultDomainID = SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral();
+		try {
+			return Iterables.find(getDomainDescriptors(), new Predicate<IDomainDescriptor>() {
+				@Override
+				public boolean apply(IDomainDescriptor input) {
+					return input.getDomainID().equals(id != null ? id : defaultDomainID);
+				}
+			});
+		} catch (NoSuchElementException e) {
+			if (defaultDomainID.equals(id)) {
+				throw new IllegalArgumentException("No default domain found!");
+			}
+			System.err.println("Could not find domain descriptor for id " + id + " - > using default domain");
+			return getDomainDescriptor(defaultDomainID);
+		}
+	}
+
+	public static IDomainDescriptor getDomainDescriptor(EObject object) {
+		EObject rootContainer = EcoreUtil.getRootContainer(object);
+		Assert.isTrue(rootContainer instanceof Statechart);
+		return getDomainDescriptor(((Statechart) rootContainer).getDomainID());
+	}
+}

+ 17 - 0
plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/IDomainDescriptor.java

@@ -0,0 +1,17 @@
+package org.yakindu.sct.domain.extension;
+
+import org.eclipse.swt.graphics.Image;
+
+public interface IDomainDescriptor {
+
+	String getDomainID();
+
+	String getName();
+
+	String getDescription();
+
+	IDomainInjectorProvider getDomainInjectorProvider();
+
+	Image getImage();
+
+}

+ 67 - 67
plugins/org.yakindu.sct.model.resource/src/org/yakindu/sct/model/resource/SCTResourceFactory.java

@@ -1,67 +1,67 @@
-/**
- * Copyright (c) 2015 committers of YAKINDU 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:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.model.resource;
-
-import java.io.IOException;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.URIConverter;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
-import org.yakindu.sct.domain.extension.DomainRegistry;
-import org.yakindu.sct.domain.extension.DomainRegistry.DomainDescriptor;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-import org.yakindu.sct.model.sgraph.Statechart;
-
-import com.google.inject.Injector;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class SCTResourceFactory extends XMIResourceFactoryImpl {
-
-	@Override
-	public Resource createResource(URI uri) {
-		String domainID = determineDomainID(uri);
-		DomainDescriptor domainDescriptor = DomainRegistry.getDomainDescriptor(domainID);
-		Injector injector = domainDescriptor.getDomainInjectorProvider().getResourceInjector();
-		Resource resource = injector.getInstance(Resource.class);
-		ResourceSet set = new ResourceSetImpl();
-		set.getResources().add(resource);
-		resource.setURI(uri);
-		return resource;
-	}
-
-	protected String determineDomainID(URI uri) {
-		String result = SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral();
-		if (URIConverter.INSTANCE.exists(uri, null)) {
-			XMIResource resource = new XMIResourceImpl(uri);
-			try {
-				resource.load(null);
-				Statechart statechart = (Statechart) EcoreUtil.getObjectByType(resource.getContents(),
-						SGraphPackage.Literals.STATECHART);
-				result = statechart.getDomainID();
-			} catch (IOException e) {
-				e.printStackTrace();
-			} finally {
-				resource.unload();
-			}
-		}
-		return result;
-	}
-}
+/**
+ * Copyright (c) 2015 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.model.resource;
+
+import java.io.IOException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
+import org.yakindu.sct.domain.extension.DomainRegistry;
+import org.yakindu.sct.domain.extension.IDomainDescriptor;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.Statechart;
+
+import com.google.inject.Injector;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class SCTResourceFactory extends XMIResourceFactoryImpl {
+
+	@Override
+	public Resource createResource(URI uri) {
+		String domainID = determineDomainID(uri);
+		IDomainDescriptor domainDescriptor = DomainRegistry.getDomainDescriptor(domainID);
+		Injector injector = domainDescriptor.getDomainInjectorProvider().getResourceInjector();
+		Resource resource = injector.getInstance(Resource.class);
+		ResourceSet set = new ResourceSetImpl();
+		set.getResources().add(resource);
+		resource.setURI(uri);
+		return resource;
+	}
+
+	protected String determineDomainID(URI uri) {
+		String result = SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral();
+		if (URIConverter.INSTANCE.exists(uri, null)) {
+			XMIResource resource = new XMIResourceImpl(uri);
+			try {
+				resource.load(null);
+				Statechart statechart = (Statechart) EcoreUtil.getObjectByType(resource.getContents(),
+						SGraphPackage.Literals.STATECHART);
+				result = statechart.getDomainID();
+			} catch (IOException e) {
+				e.printStackTrace();
+			} finally {
+				resource.unload();
+			}
+		}
+		return result;
+	}
+}

+ 2 - 2
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/AbstractEditorPropertySection.java

@@ -53,7 +53,7 @@ import org.yakindu.base.xtext.utils.jface.viewers.StyledTextXtextAdapter;
 import org.yakindu.base.xtext.utils.jface.viewers.ContextElementAdapter.IContextElementProvider;
 import org.yakindu.base.xtext.utils.jface.viewers.util.ActiveEditorTracker;
 import org.yakindu.sct.domain.extension.DomainRegistry;
-import org.yakindu.sct.domain.extension.DomainRegistry.DomainDescriptor;
+import org.yakindu.sct.domain.extension.IDomainDescriptor;
 import org.yakindu.sct.domain.extension.IDomainInjectorProvider;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Statechart;
@@ -163,7 +163,7 @@ public abstract class AbstractEditorPropertySection extends AbstractModelerPrope
 			domainId = statechart.getDomainID();
 			resource.unload();
 		}
-		DomainDescriptor domainDescriptor = DomainRegistry.getDomainDescriptor(domainId);
+		IDomainDescriptor domainDescriptor = DomainRegistry.getDomainDescriptor(domainId);
 		IDomainInjectorProvider injectorProvider = domainDescriptor.getDomainInjectorProvider();
 		return injectorProvider.getEmbeddedEditorInjector(semanticTarget);
 	}

+ 219 - 219
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/StatechartPropertySection.java

@@ -1,219 +1,219 @@
-/**
- * Copyright (c) 2011 committers of YAKINDU 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:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.ui.editor.propertysheets;
-
-import java.util.List;
-
-import org.eclipse.core.databinding.UpdateValueStrategy;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.databinding.EMFDataBindingContext;
-import org.eclipse.emf.databinding.IEMFValueProperty;
-import org.eclipse.emf.databinding.edit.EMFEditProperties;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.jface.databinding.swt.ISWTObservableValue;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.databinding.viewers.IViewerObservableValue;
-import org.eclipse.jface.databinding.viewers.ViewersObservables;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Text;
-import org.yakindu.base.base.BasePackage;
-import org.yakindu.sct.domain.extension.DomainRegistry;
-import org.yakindu.sct.domain.extension.DomainRegistry.DomainDescriptor;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.ui.editor.propertysheets.OrderElementControl.ISourceObjectCallback;
-import org.yakindu.sct.ui.editor.utils.HelpContextIds;
-
-import com.google.inject.Injector;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class StatechartPropertySection extends AbstractTwoColumnEditorPropertySection implements ISourceObjectCallback {
-
-	private Control textControl;
-	private Text txtName;
-	private OrderElementControl orderElementControl;
-	private Text documentation;
-	private ComboViewer domainCombo;
-
-	@Override
-	protected Layout createLeftColumnLayout() {
-		return new GridLayout(2, false);
-	}
-
-	@Override
-	protected void createLeftColumnControls(Composite leftColumn) {
-		createNameControl(leftColumn);
-		createDomainCombo(leftColumn);
-		createSpecificationControl(leftColumn);
-	}
-
-	protected void createDomainCombo(Composite leftColumn) {
-		Label label = getToolkit().createLabel(leftColumn, "Statechart domain");
-		GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(label);
-		domainCombo = new ComboViewer(leftColumn);
-		GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo());
-		Label spacer = getToolkit().createLabel(leftColumn, "");
-		GridDataFactory.fillDefaults().applyTo(spacer);
-		domainCombo.setContentProvider(new ArrayContentProvider());
-		domainCombo.setLabelProvider(new LabelProvider() {
-			@Override
-			public String getText(Object element) {
-				return ((DomainDescriptor) element).getName();
-			}
-		});
-
-		List<DomainDescriptor> domains = DomainRegistry.getDomainDescriptors();
-		for (DomainDescriptor domainDescriptor : domains) {
-			domainCombo.add(domainDescriptor);
-		}
-		domainCombo.setSelection(new StructuredSelection(DomainRegistry
-				.getDomainDescriptor(SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral())));
-
-	}
-
-	@Override
-	protected void createRightColumnControls(Composite rightColumn) {
-		createDocumentationControl(rightColumn);
-		createRegionsControl(rightColumn);
-
-	}
-
-	protected void createNameControl(Composite parent) {
-		Label lblName = getToolkit().createLabel(parent, "Statechart Name: ");
-		txtName = getToolkit().createText(parent, "");
-		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblName);
-		new Label(parent, SWT.NONE);
-		GridDataFactory.fillDefaults().grab(true, false).applyTo(txtName);
-	}
-
-	protected void createRegionsControl(Composite rightColumn) {
-		Label label = getToolkit().createLabel(rightColumn, "Region Priority:");
-		GridDataFactory.fillDefaults().applyTo(label);
-		orderElementControl = new OrderElementControl(rightColumn, SGraphPackage.Literals.COMPOSITE_ELEMENT__REGIONS,
-				this, "Statechart contains no regions");
-		GridDataFactory.fillDefaults().span(2, 0).grab(true, false).applyTo(orderElementControl);
-	}
-
-	protected void createDocumentationControl(Composite rightColumn) {
-		Label lblDocumentation = getToolkit().createLabel(rightColumn, "Documentation: ");
-		documentation = getToolkit().createText(rightColumn, "", SWT.MULTI);
-		GridDataFactory.fillDefaults().applyTo(lblDocumentation);
-		GridDataFactory.fillDefaults().grab(true, true).applyTo(documentation);
-
-	}
-
-	protected void createSpecificationControl(final Composite parent) {
-		Label lblDocumentation = getToolkit().createLabel(parent, "Statechart Behavior: ");
-		Injector injector = getInjector(Statechart.class.getName());
-		if (injector != null) {
-			textControl = new StyledText(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
-			((StyledText) textControl).setAlwaysShowScrollBars(false);
-			enableXtext(textControl, injector);
-			createHelpWidget(parent, textControl, HelpContextIds.SC_PROPERTIES_STATECHART_EXPRESSION);
-		} else {
-			textControl = getToolkit().createText(parent, "", SWT.MULTI);
-		}
-		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblDocumentation);
-		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(textControl);
-	}
-
-	@Override
-	public void bindModel(EMFDataBindingContext context) {
-		bindNameControl(context);
-		bindDomainCombo(context);
-		bindSpecificationControl(context);
-		bindDocumentationControl(context);
-		orderElementControl.refreshInput();
-	}
-
-	private void bindDomainCombo(EMFDataBindingContext context) {
-		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
-				SGraphPackage.Literals.STATECHART__DOMAIN_ID);
-
-		IViewerObservableValue observeSingleSelection = ViewersObservables.observeSingleSelection(domainCombo);
-		UpdateValueStrategy modelToTarget = new UpdateValueStrategy() {
-			@Override
-			public Object convert(Object value) {
-				return ((DomainDescriptor) value).getDomainID();
-			}
-		};
-		UpdateValueStrategy targetToModel = new UpdateValueStrategy() {
-			@Override
-			public Object convert(Object value) {
-				return DomainRegistry.getDomainDescriptor((String) value);
-			}
-		};
-		context.bindValue(observeSingleSelection, property.observe(eObject), modelToTarget, targetToModel);
-	}
-
-	private void bindDocumentationControl(EMFDataBindingContext context) {
-		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
-				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION);
-		ISWTObservableValue observe = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
-				documentation);
-		context.bindValue(observe, property.observe(eObject));
-	}
-
-	protected void bindSpecificationControl(EMFDataBindingContext context) {
-		IEMFValueProperty modelProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
-				SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
-		ISWTObservableValue uiProperty = WidgetProperties.text(SWT.FocusOut).observe(textControl);
-		context.bindValue(uiProperty, modelProperty.observe(eObject), null, new UpdateValueStrategy() {
-			@Override
-			protected IStatus doSet(IObservableValue observableValue, Object value) {
-				if (getCompletionProposalAdapter() != null && !getCompletionProposalAdapter().isProposalPopupOpen())
-					return super.doSet(observableValue, value);
-				return Status.OK_STATUS;
-			}
-		});
-
-	}
-
-	protected void bindNameControl(EMFDataBindingContext context) {
-		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
-				BasePackage.Literals.NAMED_ELEMENT__NAME);
-		ISWTObservableValue observe = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
-				txtName);
-		context.bindValue(observe, property.observe(eObject));
-	}
-
-	@Override
-	public EObject getEObject() {
-		return super.getEObject();
-	}
-
-	@Override
-	public void dispose() {
-		if (orderElementControl != null) {
-			orderElementControl.dispose();
-		}
-		super.dispose();
-	}
-
-}
+/**
+ * Copyright (c) 2011 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.editor.propertysheets;
+
+import java.util.List;
+
+import org.eclipse.core.databinding.UpdateValueStrategy;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.databinding.EMFDataBindingContext;
+import org.eclipse.emf.databinding.IEMFValueProperty;
+import org.eclipse.emf.databinding.edit.EMFEditProperties;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.jface.databinding.swt.ISWTObservableValue;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.databinding.viewers.IViewerObservableValue;
+import org.eclipse.jface.databinding.viewers.ViewersObservables;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Text;
+import org.yakindu.base.base.BasePackage;
+import org.yakindu.sct.domain.extension.DomainRegistry;
+import org.yakindu.sct.domain.extension.IDomainDescriptor;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.ui.editor.propertysheets.OrderElementControl.ISourceObjectCallback;
+import org.yakindu.sct.ui.editor.utils.HelpContextIds;
+
+import com.google.inject.Injector;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class StatechartPropertySection extends AbstractTwoColumnEditorPropertySection implements ISourceObjectCallback {
+
+	private Control textControl;
+	private Text txtName;
+	private OrderElementControl orderElementControl;
+	private Text documentation;
+	private ComboViewer domainCombo;
+
+	@Override
+	protected Layout createLeftColumnLayout() {
+		return new GridLayout(2, false);
+	}
+
+	@Override
+	protected void createLeftColumnControls(Composite leftColumn) {
+		createNameControl(leftColumn);
+		createDomainCombo(leftColumn);
+		createSpecificationControl(leftColumn);
+	}
+
+	protected void createDomainCombo(Composite leftColumn) {
+		Label label = getToolkit().createLabel(leftColumn, "Statechart domain");
+		GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(label);
+		domainCombo = new ComboViewer(leftColumn);
+		GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo());
+		Label spacer = getToolkit().createLabel(leftColumn, "");
+		GridDataFactory.fillDefaults().applyTo(spacer);
+		domainCombo.setContentProvider(new ArrayContentProvider());
+		domainCombo.setLabelProvider(new LabelProvider() {
+			@Override
+			public String getText(Object element) {
+				return ((IDomainDescriptor) element).getName();
+			}
+		});
+
+		List<IDomainDescriptor> domains = DomainRegistry.getDomainDescriptors();
+		for (IDomainDescriptor domainDescriptor : domains) {
+			domainCombo.add(domainDescriptor);
+		}
+		domainCombo.setSelection(new StructuredSelection(DomainRegistry
+				.getDomainDescriptor(SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral())));
+
+	}
+
+	@Override
+	protected void createRightColumnControls(Composite rightColumn) {
+		createDocumentationControl(rightColumn);
+		createRegionsControl(rightColumn);
+
+	}
+
+	protected void createNameControl(Composite parent) {
+		Label lblName = getToolkit().createLabel(parent, "Statechart Name: ");
+		txtName = getToolkit().createText(parent, "");
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblName);
+		new Label(parent, SWT.NONE);
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(txtName);
+	}
+
+	protected void createRegionsControl(Composite rightColumn) {
+		Label label = getToolkit().createLabel(rightColumn, "Region Priority:");
+		GridDataFactory.fillDefaults().applyTo(label);
+		orderElementControl = new OrderElementControl(rightColumn, SGraphPackage.Literals.COMPOSITE_ELEMENT__REGIONS,
+				this, "Statechart contains no regions");
+		GridDataFactory.fillDefaults().span(2, 0).grab(true, false).applyTo(orderElementControl);
+	}
+
+	protected void createDocumentationControl(Composite rightColumn) {
+		Label lblDocumentation = getToolkit().createLabel(rightColumn, "Documentation: ");
+		documentation = getToolkit().createText(rightColumn, "", SWT.MULTI);
+		GridDataFactory.fillDefaults().applyTo(lblDocumentation);
+		GridDataFactory.fillDefaults().grab(true, true).applyTo(documentation);
+
+	}
+
+	protected void createSpecificationControl(final Composite parent) {
+		Label lblDocumentation = getToolkit().createLabel(parent, "Statechart Behavior: ");
+		Injector injector = getInjector(Statechart.class.getName());
+		if (injector != null) {
+			textControl = new StyledText(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
+			((StyledText) textControl).setAlwaysShowScrollBars(false);
+			enableXtext(textControl, injector);
+			createHelpWidget(parent, textControl, HelpContextIds.SC_PROPERTIES_STATECHART_EXPRESSION);
+		} else {
+			textControl = getToolkit().createText(parent, "", SWT.MULTI);
+		}
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblDocumentation);
+		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(textControl);
+	}
+
+	@Override
+	public void bindModel(EMFDataBindingContext context) {
+		bindNameControl(context);
+		bindDomainCombo(context);
+		bindSpecificationControl(context);
+		bindDocumentationControl(context);
+		orderElementControl.refreshInput();
+	}
+
+	private void bindDomainCombo(EMFDataBindingContext context) {
+		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
+				SGraphPackage.Literals.STATECHART__DOMAIN_ID);
+
+		IViewerObservableValue observeSingleSelection = ViewersObservables.observeSingleSelection(domainCombo);
+		UpdateValueStrategy modelToTarget = new UpdateValueStrategy() {
+			@Override
+			public Object convert(Object value) {
+				return ((IDomainDescriptor) value).getDomainID();
+			}
+		};
+		UpdateValueStrategy targetToModel = new UpdateValueStrategy() {
+			@Override
+			public Object convert(Object value) {
+				return DomainRegistry.getDomainDescriptor((String) value);
+			}
+		};
+		context.bindValue(observeSingleSelection, property.observe(eObject), modelToTarget, targetToModel);
+	}
+
+	private void bindDocumentationControl(EMFDataBindingContext context) {
+		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
+				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION);
+		ISWTObservableValue observe = WidgetProperties.text(new int[]{SWT.FocusOut, SWT.DefaultSelection})
+				.observe(documentation);
+		context.bindValue(observe, property.observe(eObject));
+	}
+
+	protected void bindSpecificationControl(EMFDataBindingContext context) {
+		IEMFValueProperty modelProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
+				SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
+		ISWTObservableValue uiProperty = WidgetProperties.text(SWT.FocusOut).observe(textControl);
+		context.bindValue(uiProperty, modelProperty.observe(eObject), null, new UpdateValueStrategy() {
+			@Override
+			protected IStatus doSet(IObservableValue observableValue, Object value) {
+				if (getCompletionProposalAdapter() != null && !getCompletionProposalAdapter().isProposalPopupOpen())
+					return super.doSet(observableValue, value);
+				return Status.OK_STATUS;
+			}
+		});
+
+	}
+
+	protected void bindNameControl(EMFDataBindingContext context) {
+		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
+				BasePackage.Literals.NAMED_ELEMENT__NAME);
+		ISWTObservableValue observe = WidgetProperties.text(new int[]{SWT.FocusOut, SWT.DefaultSelection})
+				.observe(txtName);
+		context.bindValue(observe, property.observe(eObject));
+	}
+
+	@Override
+	public EObject getEObject() {
+		return super.getEObject();
+	}
+
+	@Override
+	public void dispose() {
+		if (orderElementControl != null) {
+			orderElementControl.dispose();
+		}
+		super.dispose();
+	}
+
+}

+ 118 - 118
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/wizards/DomainWizardPage.java

@@ -1,118 +1,118 @@
-/**
- * Copyright (c) 2015 committers of YAKINDU 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:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.ui.editor.wizards;
-
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.yakindu.sct.domain.extension.DomainRegistry;
-import org.yakindu.sct.domain.extension.DomainRegistry.DomainDescriptor;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class DomainWizardPage extends WizardPage {
-
-	private ComboViewer domainCombo;
-
-	private Label description;
-
-	private Label image;
-
-	protected DomainWizardPage(String pageName) {
-		super(pageName);
-	}
-
-	public void createControl(Composite parent) {
-		final Composite composite = new Composite(parent, SWT.NONE);
-		GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
-		GridLayoutFactory.fillDefaults().applyTo(composite);
-		final Group domainSelectionGroup = new Group(composite, SWT.NONE);
-		domainSelectionGroup.setText("Select the Statechart domain:");
-
-		GridLayoutFactory.fillDefaults().numColumns(2).applyTo(domainSelectionGroup);
-		GridDataFactory.fillDefaults().grab(true, true).applyTo(domainSelectionGroup);
-
-		Label spacer = new Label(domainSelectionGroup, SWT.NONE);
-		GridDataFactory.fillDefaults().span(2, 1).applyTo(spacer);
-
-		image = new Label(domainSelectionGroup, SWT.NONE);
-		GridDataFactory.fillDefaults().grab(false, false).applyTo(image);
-		domainCombo = new ComboViewer(domainSelectionGroup, SWT.READ_ONLY);
-		GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo());
-		domainCombo.setContentProvider(new ArrayContentProvider());
-		domainCombo.setLabelProvider(new LabelProvider() {
-			@Override
-			public String getText(Object element) {
-				return ((DomainDescriptor) element).getName();
-			}
-		});
-		domainCombo.setInput(DomainRegistry.getDomainDescriptors());
-
-		Label spacer2 = new Label(domainSelectionGroup, SWT.NONE);
-		GridDataFactory.fillDefaults().span(2, 1).applyTo(spacer2);
-
-		description = new Label(domainSelectionGroup, SWT.WRAP);
-		GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(description);
-		setControl(composite);
-		domainCombo.addSelectionChangedListener(new ISelectionChangedListener() {
-
-			public void selectionChanged(SelectionChangedEvent event) {
-				DomainDescriptor domain = unwrap(event.getSelection());
-				description.setText(domain.getDescription());
-				image.setImage(domain.getImage());
-				domainSelectionGroup.layout();
-
-			}
-
-		});
-		domainCombo.setSelection(new StructuredSelection(DomainRegistry
-				.getDomainDescriptor(SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral())));
-
-		Link sctLink = new Link(composite, SWT.NONE);
-		sctLink.setText("<a>Get additional Statechart Domain Extensions</a>");
-		sctLink.addSelectionListener(new SelectionListener() {
-			public void widgetSelected(SelectionEvent e) {
-				org.eclipse.swt.program.Program.launch("http://statecharts.org/");
-			}
-
-			public void widgetDefaultSelected(SelectionEvent e) {
-			}
-		});
-	}
-
-	public String getDomainID() {
-		return unwrap(domainCombo.getSelection()).getDomainID();
-	}
-
-	private DomainDescriptor unwrap(ISelection selection) {
-		DomainDescriptor domain = (DomainDescriptor) ((StructuredSelection) selection).getFirstElement();
-		return domain;
-	}
-
-}
+/**
+ * Copyright (c) 2015 committers of YAKINDU 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.editor.wizards;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.yakindu.sct.domain.extension.DomainRegistry;
+import org.yakindu.sct.domain.extension.IDomainDescriptor;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class DomainWizardPage extends WizardPage {
+
+	private ComboViewer domainCombo;
+
+	private Label description;
+
+	private Label image;
+
+	protected DomainWizardPage(String pageName) {
+		super(pageName);
+	}
+
+	public void createControl(Composite parent) {
+		final Composite composite = new Composite(parent, SWT.NONE);
+		GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
+		GridLayoutFactory.fillDefaults().applyTo(composite);
+		final Group domainSelectionGroup = new Group(composite, SWT.NONE);
+		domainSelectionGroup.setText("Select the Statechart domain:");
+
+		GridLayoutFactory.fillDefaults().numColumns(2).applyTo(domainSelectionGroup);
+		GridDataFactory.fillDefaults().grab(true, true).applyTo(domainSelectionGroup);
+
+		Label spacer = new Label(domainSelectionGroup, SWT.NONE);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(spacer);
+
+		image = new Label(domainSelectionGroup, SWT.NONE);
+		GridDataFactory.fillDefaults().grab(false, false).applyTo(image);
+		domainCombo = new ComboViewer(domainSelectionGroup, SWT.READ_ONLY);
+		GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo());
+		domainCombo.setContentProvider(new ArrayContentProvider());
+		domainCombo.setLabelProvider(new LabelProvider() {
+			@Override
+			public String getText(Object element) {
+				return ((IDomainDescriptor) element).getName();
+			}
+		});
+		domainCombo.setInput(DomainRegistry.getDomainDescriptors());
+
+		Label spacer2 = new Label(domainSelectionGroup, SWT.NONE);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(spacer2);
+
+		description = new Label(domainSelectionGroup, SWT.WRAP);
+		GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(description);
+		setControl(composite);
+		domainCombo.addSelectionChangedListener(new ISelectionChangedListener() {
+
+			public void selectionChanged(SelectionChangedEvent event) {
+				IDomainDescriptor domain = unwrap(event.getSelection());
+				description.setText(domain.getDescription());
+				image.setImage(domain.getImage());
+				domainSelectionGroup.layout();
+
+			}
+
+		});
+		domainCombo.setSelection(new StructuredSelection(DomainRegistry
+				.getDomainDescriptor(SGraphPackage.Literals.STATECHART__DOMAIN_ID.getDefaultValueLiteral())));
+
+		Link sctLink = new Link(composite, SWT.NONE);
+		sctLink.setText("<a>Get additional Statechart Domain Extensions</a>");
+		sctLink.addSelectionListener(new SelectionListener() {
+			public void widgetSelected(SelectionEvent e) {
+				org.eclipse.swt.program.Program.launch("http://statecharts.org/");
+			}
+
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+		});
+	}
+
+	public String getDomainID() {
+		return unwrap(domainCombo.getSelection()).getDomainID();
+	}
+
+	private IDomainDescriptor unwrap(ISelection selection) {
+		IDomainDescriptor domain = (IDomainDescriptor) ((StructuredSelection) selection).getFirstElement();
+		return domain;
+	}
+
+}