Browse Source

Unload depending resources2 (#2148)

Thomas Kutz 7 years ago
parent
commit
8a8eae9382

+ 9 - 0
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/util/ContextElementAdapter.java

@@ -34,6 +34,15 @@ public class ContextElementAdapter extends AdapterImpl {
 		this.provider = provider;
 	}
 
+	public ContextElementAdapter(EObject eObject) {
+		this.provider = new IContextElementProvider() {
+			@Override
+			public EObject getContextObject() {
+				return eObject;
+			}
+		};
+	}
+
 	@Override
 	public boolean isAdapterForType(Object type) {
 		return type == ContextElementAdapter.class;

+ 54 - 20
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/SharedEditingDomainFactory.java

@@ -11,6 +11,9 @@
 package org.yakindu.sct.model.stext.scoping;
 
 import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
@@ -20,15 +23,15 @@ import org.eclipse.core.resources.IResourceDelta;
 import org.eclipse.core.resources.IResourceDeltaVisitor;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.notify.Adapter;
 import org.eclipse.emf.common.util.EList;
 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.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
 import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
 import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory;
-import org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
 import org.yakindu.sct.model.sgraph.resource.AbstractSCTResource;
 
 /**
@@ -64,16 +67,15 @@ public class SharedEditingDomainFactory extends DiagramEditingDomainFactory
 
 	protected void setup(TransactionalEditingDomain editingDomain) {
 		editingDomain.setID(DOMAIN_ID);
-		replaceCrossReferenceAdapterWithNonResolvingAdapter(editingDomain);
 		new WorkspaceSynchronizer(editingDomain, new WorkspaceSynchronizer.Delegate() {
 
 			public boolean handleResourceDeleted(Resource resource) {
-				resource.unload();
+				unloadWithReferences(resource);
 				return true;
 			}
 
 			public boolean handleResourceMoved(Resource resource, URI newURI) {
-				resource.unload();
+				unloadWithReferences(resource);
 				return true;
 			}
 
@@ -83,7 +85,7 @@ public class SharedEditingDomainFactory extends DiagramEditingDomainFactory
 					// underlying the currently opened editor
 					return true;
 				}
-				resource.unload();
+				unloadWithReferences(resource);
 				try {
 					resource.load(resource.getResourceSet().getLoadOptions());
 				} catch (IOException e) {
@@ -96,7 +98,7 @@ public class SharedEditingDomainFactory extends DiagramEditingDomainFactory
 				// nothing to dispose (especially as I am shared)
 			}
 		});
-
+		
 		ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {
 			@Override
 			public void resourceChanged(IResourceChangeEvent event) {
@@ -115,7 +117,7 @@ public class SharedEditingDomainFactory extends DiagramEditingDomainFactory
 												false);
 										if (existingResource != null
 												&& !(existingResource instanceof AbstractSCTResource))
-											existingResource.unload();
+											unloadWithReferences(existingResource);
 
 									}
 								}
@@ -129,23 +131,55 @@ public class SharedEditingDomainFactory extends DiagramEditingDomainFactory
 			}
 		});
 	}
+	protected void unloadWithReferences(Resource resource) {
+		TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resource);
+		try {
+			editingDomain.runExclusive(new Runnable() {
+				@Override
+				public void run() {
+					Set<Resource> resourcesToUnload = new HashSet<>();
+					collectTransitiveReferences(resource, resourcesToUnload);
+					resourcesToUnload.add(resource);
+					
+					collectResourcesWithErrors(resource, resourcesToUnload);
+					
+					for (Resource current : resourcesToUnload) {
+						if (current instanceof AbstractSCTResource || !current.getURI().isPlatform())
+							continue;
+						current.unload();
+					}
+				}
 
-	protected void replaceCrossReferenceAdapterWithNonResolvingAdapter(final TransactionalEditingDomain domain) {
-		final CrossReferenceAdapter adapter = getCrossReferenceAdapter(domain);
-		if (null != adapter) {
-			adapter.unsetTarget(domain.getResourceSet());
-			domain.getResourceSet().eAdapters().remove(adapter);
-			domain.getResourceSet().eAdapters().add(new CrossReferenceAdapter(false));
+			});
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	protected void collectResourcesWithErrors(Resource resource, Set<Resource> resourcesToUnload) {
+		for (Resource currentResource : resource.getResourceSet().getResources()) {
+			if (currentResource.getErrors().size() > 0) {
+				collectTransitiveReferences(currentResource, resourcesToUnload);
+				resourcesToUnload.add(currentResource);
+			}
 		}
 	}
 
-	protected CrossReferenceAdapter getCrossReferenceAdapter(final TransactionalEditingDomain domain) {
-		final EList<Adapter> eAdapters = domain.getResourceSet().eAdapters();
-		for (final Adapter adapter : eAdapters) {
-			if (adapter instanceof CrossReferenceAdapter) {
-				return (CrossReferenceAdapter) adapter;
+	@SuppressWarnings("unchecked")
+	protected void collectTransitiveReferences(Resource resource, Set<Resource> references) {
+		EList<Resource> resources = resource.getResourceSet().getResources();
+		for (Resource currentResource : resources) {
+			final Collection<Resource> allImports = EMFCoreUtil.getImports(currentResource);
+			for (Resource currentImport : allImports) {
+				if (currentImport == resource) {
+					if (!references.contains(currentResource)) {
+						references.add(currentResource);
+						collectTransitiveReferences(currentResource, references);
+					}
+				}
 			}
 		}
-		return null;
 	}
+
+	
 }

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

@@ -114,7 +114,7 @@ public abstract class AbstractEditorPropertySection extends AbstractModelerPrope
 
 	protected void enableXtext(Control styledText, Injector injector) {
 		final StyledTextXtextAdapter xtextAdapter = new StyledTextXtextAdapter(injector);
-		xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters().add(new ContextElementAdapter(this));
+		xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters().add(new ContextElementAdapter(getEObject()));
 		xtextAdapter.adapt((StyledText) styledText);
 
 		initContextMenu(styledText);

+ 166 - 158
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/StatePropertySection.java

@@ -1,158 +1,166 @@
-/**
- * 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 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.layout.GridDataFactory;
-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.yakindu.base.base.BasePackage;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-import org.yakindu.sct.model.sgraph.State;
-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 StatePropertySection extends AbstractTwoColumnEditorPropertySection implements ISourceObjectCallback {
-
-	private Control txtSpecification;
-	private Control txtName;
-
-	private OrderElementControl orderElementControl;
-
-	@Override
-	protected Layout createLeftColumnLayout() {
-		return new GridLayout(2, false);
-	}
-
-	@Override
-	protected void createLeftColumnControls(Composite leftColumn) {
-		createNameControl(leftColumn);
-		createSpecificationControl(leftColumn);
-	}
-
-	@Override
-	protected void createRightColumnControls(Composite rightColumn) {
-		createDocumentationControl(rightColumn);
-		createTransitionsControl(rightColumn);
-	}
-
-	protected Control doCreateNameControl(Composite parent) {
-		return getToolkit().createText(parent, "");
-	}
-
-	protected Control getNameControl() {
-		return this.txtName;
-	}
-
-	protected void createNameControl(final Composite parent) {
-		Label lblName = getToolkit().createLabel(parent, "State Name: ");
-		txtName = doCreateNameControl(parent);
-		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblName);
-		new Label(parent, SWT.NONE);
-		GridDataFactory.fillDefaults().grab(true, false).applyTo(txtName);
-	}
-
-	protected void createSpecificationControl(final Composite parent) {
-		Label lblDocumentation = getToolkit().createLabel(parent, "State Behavior: ");
-		Injector injector = getInjector(State.class.getName());
-		if (injector != null) {
-			txtSpecification = new StyledText(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
-			((StyledText) txtSpecification).setAlwaysShowScrollBars(false);
-			enableXtext(txtSpecification, injector);
-			createHelpWidget(parent, txtSpecification, HelpContextIds.SC_PROPERTIES_STATE_EXPRESSION);
-		} else {
-			txtSpecification = getToolkit().createText(parent, "", SWT.MULTI);
-		}
-		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblDocumentation);
-		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(txtSpecification);
-	}
-
-	protected void createTransitionsControl(Composite parent) {
-		Label label = getToolkit().createLabel(parent, "Transition Priority:");
-		GridDataFactory.fillDefaults().applyTo(label);
-		orderElementControl = new OrderElementControl(parent, SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS, this,
-				"State has no outgoing transitions");
-		GridDataFactory.fillDefaults().grab(true, false).applyTo(orderElementControl);
-	}
-
-	protected State getState() {
-		return (State) eObject;
-	}
-
-	@Override
-	public void bindModel(EMFDataBindingContext context) {
-		bindNameControl(context);
-		bindSpecificationControl(context);
-		bindDocumentationControl(context);
-		orderElementControl.refreshInput();
-	}
-
-	protected 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 specificationProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
-				SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
-		ISWTObservableValue specificationTextProperty = WidgetProperties.text(SWT.FocusOut).observe(txtSpecification);
-		context.bindValue(specificationTextProperty, specificationProperty.observe(eObject), null,
-				new UpdateValueStrategy() {
-					@Override
-					protected IStatus doSet(IObservableValue observableValue, Object value) {
-						if (getCompletionProposalAdapter() == null) {
-							return super.doSet(observableValue, value);
-						} else if (!getCompletionProposalAdapter().isProposalPopupOpen())
-							return super.doSet(observableValue, value);
-						return Status.OK_STATUS;
-					}
-				});
-	}
-
-	protected void bindNameControl(EMFDataBindingContext context) {
-		IEMFValueProperty nameProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
-				BasePackage.Literals.NAMED_ELEMENT__NAME);
-		ISWTObservableValue nameTextProperty = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection })
-				.observe(txtName);
-		context.bindValue(nameTextProperty, nameProperty.observe(eObject));
-	}
-
-	@Override
-	public EObject getEObject() {
-		return super.getEObject();
-	}
-
-}
+/**
+ * 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 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.layout.GridDataFactory;
+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.yakindu.base.base.BasePackage;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.State;
+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 StatePropertySection extends AbstractTwoColumnEditorPropertySection implements ISourceObjectCallback {
+
+	private Control txtSpecification;
+	private Control txtName;
+
+	private OrderElementControl orderElementControl;
+
+	@Override
+	protected Layout createLeftColumnLayout() {
+		return new GridLayout(2, false);
+	}
+
+	@Override
+	protected void createLeftColumnControls(Composite leftColumn) {
+		createNameControl(leftColumn);
+		createSpecificationControl(leftColumn);
+	}
+
+	@Override
+	protected void createRightColumnControls(Composite rightColumn) {
+		createDocumentationControl(rightColumn);
+		createTransitionsControl(rightColumn);
+	}
+
+	protected Control doCreateNameControl(Composite parent) {
+		return getToolkit().createText(parent, "");
+	}
+
+	protected Control getNameControl() {
+		return this.txtName;
+	}
+
+	protected void createNameControl(final Composite parent) {
+		Label lblName = getToolkit().createLabel(parent, "State Name: ");
+		txtName = doCreateNameControl(parent);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblName);
+		new Label(parent, SWT.NONE);
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(txtName);
+	}
+
+	protected void createSpecificationControl(final Composite parent) {
+		Label lblDocumentation = getToolkit().createLabel(parent, "State Behavior: ");
+		Injector injector = getInjector(State.class.getName());
+		if (injector != null) {
+			txtSpecification = new StyledText(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
+			((StyledText) txtSpecification).setAlwaysShowScrollBars(false);
+			createHelpWidget(parent, txtSpecification, HelpContextIds.SC_PROPERTIES_STATE_EXPRESSION);
+		} else {
+			txtSpecification = getToolkit().createText(parent, "", SWT.MULTI);
+		}
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblDocumentation);
+		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(txtSpecification);
+	}
+
+	@Override
+	protected void setEObject(EObject object) {
+		super.setEObject(object);
+		Injector injector = getInjector(State.class.getName());
+		if (injector != null) {
+			enableXtext(txtSpecification, injector);
+		}
+	}
+
+	protected void createTransitionsControl(Composite parent) {
+		Label label = getToolkit().createLabel(parent, "Transition Priority:");
+		GridDataFactory.fillDefaults().applyTo(label);
+		orderElementControl = new OrderElementControl(parent, SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS, this,
+				"State has no outgoing transitions");
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(orderElementControl);
+	}
+
+	protected State getState() {
+		return (State) eObject;
+	}
+
+	@Override
+	public void bindModel(EMFDataBindingContext context) {
+		bindNameControl(context);
+		bindSpecificationControl(context);
+		bindDocumentationControl(context);
+		orderElementControl.refreshInput();
+	}
+
+	protected 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 specificationProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
+				SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
+		ISWTObservableValue specificationTextProperty = WidgetProperties.text(SWT.FocusOut).observe(txtSpecification);
+		context.bindValue(specificationTextProperty, specificationProperty.observe(eObject), null,
+				new UpdateValueStrategy() {
+					@Override
+					protected IStatus doSet(IObservableValue observableValue, Object value) {
+						if (getCompletionProposalAdapter() == null) {
+							return super.doSet(observableValue, value);
+						} else if (!getCompletionProposalAdapter().isProposalPopupOpen())
+							return super.doSet(observableValue, value);
+						return Status.OK_STATUS;
+					}
+				});
+	}
+
+	protected void bindNameControl(EMFDataBindingContext context) {
+		IEMFValueProperty nameProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
+				BasePackage.Literals.NAMED_ELEMENT__NAME);
+		ISWTObservableValue nameTextProperty = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection })
+				.observe(txtName);
+		context.bindValue(nameTextProperty, nameProperty.observe(eObject));
+	}
+
+	@Override
+	public EObject getEObject() {
+		return super.getEObject();
+	}
+
+}

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

@@ -127,7 +127,6 @@ public class StatechartPropertySection extends AbstractTwoColumnEditorPropertySe
 		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);
@@ -136,6 +135,15 @@ public class StatechartPropertySection extends AbstractTwoColumnEditorPropertySe
 		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(textControl);
 	}
 
+	@Override
+	protected void setEObject(EObject object) {
+		super.setEObject(object);
+		Injector injector = getInjector(Statechart.class.getName());
+		if (injector != null) {
+			enableXtext(textControl, injector);
+		}
+	}
+
 	@Override
 	public void bindModel(EMFDataBindingContext context) {
 		bindNameControl(context);
@@ -168,7 +176,7 @@ public class StatechartPropertySection extends AbstractTwoColumnEditorPropertySe
 	protected 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})
+		ISWTObservableValue observe = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection })
 				.observe(documentation);
 		context.bindValue(observe, property.observe(eObject));
 	}
@@ -191,7 +199,7 @@ public class StatechartPropertySection extends AbstractTwoColumnEditorPropertySe
 	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})
+		ISWTObservableValue observe = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection })
 				.observe(txtName);
 		context.bindValue(observe, property.observe(eObject));
 	}

+ 113 - 103
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/TransitionPropertySection.java

@@ -1,103 +1,113 @@
-/**
- * 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 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.transaction.util.TransactionUtil;
-import org.eclipse.jface.databinding.swt.ISWTObservableValue;
-import org.eclipse.jface.databinding.swt.WidgetProperties;
-import org.eclipse.jface.layout.GridDataFactory;
-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.yakindu.base.base.BasePackage;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-import org.yakindu.sct.model.sgraph.Transition;
-import org.yakindu.sct.ui.editor.utils.HelpContextIds;
-
-import com.google.inject.Injector;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class TransitionPropertySection extends AbstractTwoColumnEditorPropertySection {
-
-	private Control textControl;
-
-	@Override
-	protected Layout createLeftColumnLayout() {
-		return new GridLayout(2, false);
-	}
-
-	@Override
-	protected void createLeftColumnControls(Composite parent) {
-		Label lblExpression = getToolkit().createLabel(parent, "Expression: ");
-		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblExpression);
-
-		Injector injector = getInjector(Transition.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_TRANSITION_EXPRESSION);
-		} else {
-			textControl = getToolkit().createText(parent, "", SWT.MULTI);
-		}
-		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(textControl);
-	}
-
-	@Override
-	protected void createRightColumnControls(Composite parent) {
-	    createDocumentationControl(parent);
-	}
-	
-	@Override
-	protected void createDocumentationControl(Composite parent) {
-        Label lblDocumentation = getToolkit().createLabel(parent, "Documentation: ");
-        documentation = getToolkit().createText(parent, "", SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
-        GridDataFactory.fillDefaults().span(2, 1).applyTo(lblDocumentation);
-        GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).minSize(100, documentation.getLineHeight() * 3).applyTo(documentation);
-	}
-
-	@Override
-	public void bindModel(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;
-			}
-		});
-
-		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));
-
-	}
-}
+/**
+ * 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 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.layout.GridDataFactory;
+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.yakindu.base.base.BasePackage;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.ui.editor.utils.HelpContextIds;
+
+import com.google.inject.Injector;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class TransitionPropertySection extends AbstractTwoColumnEditorPropertySection {
+
+	private Control textControl;
+
+	@Override
+	protected Layout createLeftColumnLayout() {
+		return new GridLayout(2, false);
+	}
+
+	@Override
+	protected void createLeftColumnControls(Composite parent) {
+		Label lblExpression = getToolkit().createLabel(parent, "Expression: ");
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblExpression);
+
+		Injector injector = getInjector(Transition.class.getName());
+		if (injector != null) {
+			textControl = new StyledText(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
+			((StyledText) textControl).setAlwaysShowScrollBars(false);
+			createHelpWidget(parent, textControl, HelpContextIds.SC_PROPERTIES_TRANSITION_EXPRESSION);
+		} else {
+			textControl = getToolkit().createText(parent, "", SWT.MULTI);
+		}
+		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(textControl);
+	}
+
+	@Override
+	protected void setEObject(EObject object) {
+		super.setEObject(object);
+		Injector injector = getInjector(Transition.class.getName());
+		if (injector != null) {
+			enableXtext(textControl, injector);
+		}
+	}
+
+	@Override
+	protected void createRightColumnControls(Composite parent) {
+		createDocumentationControl(parent);
+	}
+
+	@Override
+	protected void createDocumentationControl(Composite parent) {
+		Label lblDocumentation = getToolkit().createLabel(parent, "Documentation: ");
+		documentation = getToolkit().createText(parent, "", SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.WRAP);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblDocumentation);
+		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize())
+				.minSize(100, documentation.getLineHeight() * 3).applyTo(documentation);
+	}
+
+	@Override
+	public void bindModel(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;
+			}
+		});
+
+		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));
+
+	}
+}