Quellcode durchsuchen

fixed NPE when no language is bound

Andreas Mülder vor 12 Jahren
Ursprung
Commit
0a1cef7929

+ 18 - 33
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/StatePropertySection.java

@@ -44,8 +44,7 @@ import com.google.inject.Injector;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class StatePropertySection extends
-		AbstractTwoColumnEditorPropertySection implements ISourceObjectCallback {
+public class StatePropertySection extends AbstractTwoColumnEditorPropertySection implements ISourceObjectCallback {
 
 	private Control txtSpecification;
 	private Control txtName;
@@ -79,8 +78,7 @@ public class StatePropertySection extends
 	}
 
 	protected void createDocumentationControl(Composite rightColumn) {
-		Label lblDocumentation = getToolkit().createLabel(rightColumn,
-				"Documentation: ");
+		Label lblDocumentation = getToolkit().createLabel(rightColumn, "Documentation: ");
 		txtDoc = getToolkit().createText(rightColumn, "", SWT.MULTI);
 		GridDataFactory.fillDefaults().applyTo(lblDocumentation);
 		GridDataFactory.fillDefaults().grab(true, true).applyTo(txtDoc);
@@ -89,26 +87,21 @@ public class StatePropertySection extends
 	protected void createSpecificationControl(final Composite parent) {
 		Injector injector = getInjector(SemanticTarget.StateSpecification);
 		if (injector != null) {
-			txtSpecification = new StyledText(parent, SWT.MULTI | SWT.BORDER
-					| SWT.V_SCROLL | SWT.WRAP);
+			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);
+			createHelpWidget(parent, txtSpecification, HelpContextIds.SC_PROPERTIES_STATE_EXPRESSION);
 		} else {
 			txtSpecification = getToolkit().createText(parent, "", SWT.MULTI);
 		}
-		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize())
-				.applyTo(txtSpecification);
+		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);
-		GridDataFactory.fillDefaults().grab(true, false)
-				.applyTo(orderElementControl);
+		orderElementControl = new OrderElementControl(parent, SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS, this);
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(orderElementControl);
 	}
 
 	protected State getState() {
@@ -124,29 +117,23 @@ public class StatePropertySection extends
 	}
 
 	protected void bindDocumentationControl(EMFDataBindingContext context) {
-		IEMFValueProperty property = EMFEditProperties.value(
-				TransactionUtil.getEditingDomain(eObject),
+		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
 				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION);
-		ISWTObservableValue observe = WidgetProperties.text(
-				new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
+		ISWTObservableValue observe = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
 				txtDoc);
 		context.bindValue(observe, property.observe(eObject));
 	}
 
 	protected void bindSpecificationControl(EMFDataBindingContext context) {
-		IEMFValueProperty specificationProperty = EMFEditProperties.value(
-				TransactionUtil.getEditingDomain(eObject),
+		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,
+		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()
-								.isProposalPopupOpen())
+					protected IStatus doSet(IObservableValue observableValue, Object value) {
+						if (getCompletionProposalAdapter() != null
+								&& !getCompletionProposalAdapter().isProposalPopupOpen())
 							return super.doSet(observableValue, value);
 						return Status.OK_STATUS;
 					}
@@ -154,12 +141,10 @@ public class StatePropertySection extends
 	}
 
 	protected void bindNameControl(EMFDataBindingContext context) {
-		IEMFValueProperty nameProperty = EMFEditProperties.value(
-				TransactionUtil.getEditingDomain(eObject),
+		IEMFValueProperty nameProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
 				BasePackage.Literals.NAMED_ELEMENT__NAME);
-		ISWTObservableValue nameTextProperty = WidgetProperties.text(
-				new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
-				txtName);
+		ISWTObservableValue nameTextProperty = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection })
+				.observe(txtName);
 		context.bindValue(nameTextProperty, nameProperty.observe(eObject));
 	}
 

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

@@ -43,8 +43,7 @@ import com.google.inject.Injector;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class StatechartPropertySection extends
-		AbstractTwoColumnEditorPropertySection implements ISourceObjectCallback {
+public class StatechartPropertySection extends AbstractTwoColumnEditorPropertySection implements ISourceObjectCallback {
 
 	private Control textControl;
 	private Text txtName;
@@ -72,7 +71,7 @@ public class StatechartPropertySection extends
 	protected void createNameControl(Composite parent) {
 		Label lblName = getToolkit().createLabel(parent, "Statechart Name: ");
 		txtName = getToolkit().createText(parent, "");
-		GridDataFactory.fillDefaults().span(2,1).applyTo(lblName);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblName);
 		new Label(parent, SWT.NONE);
 		GridDataFactory.fillDefaults().grab(true, false).applyTo(txtName);
 	}
@@ -80,15 +79,13 @@ public class StatechartPropertySection extends
 	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);
-		GridDataFactory.fillDefaults().span(2, 0).grab(true, false)
-				.applyTo(orderElementControl);
+		orderElementControl = new OrderElementControl(rightColumn, SGraphPackage.Literals.COMPOSITE_ELEMENT__REGIONS,
+				this);
+		GridDataFactory.fillDefaults().span(2, 0).grab(true, false).applyTo(orderElementControl);
 	}
 
 	protected void createDocumentationControl(Composite rightColumn) {
-		Label lblDocumentation = getToolkit().createLabel(rightColumn,
-				"Documentation: ");
+		Label lblDocumentation = getToolkit().createLabel(rightColumn, "Documentation: ");
 		documentation = getToolkit().createText(rightColumn, "", SWT.MULTI);
 		GridDataFactory.fillDefaults().applyTo(lblDocumentation);
 		GridDataFactory.fillDefaults().grab(true, true).applyTo(documentation);
@@ -96,20 +93,17 @@ public class StatechartPropertySection extends
 	}
 
 	protected void createSpecificationControl(final Composite parent) {
-		
+
 		Injector injector = getInjector(SemanticTarget.StatechartSpecification);
 		if (injector != null) {
-			textControl = new StyledText(parent, SWT.MULTI | SWT.BORDER
-					| SWT.V_SCROLL | SWT.WRAP);
+			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);
+			createHelpWidget(parent, textControl, HelpContextIds.SC_PROPERTIES_STATECHART_EXPRESSION);
 		} else {
 			textControl = getToolkit().createText(parent, "", SWT.MULTI);
 		}
-		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize())
-				.applyTo(textControl);
+		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(textControl);
 	}
 
 	@Override
@@ -121,41 +115,32 @@ public class StatechartPropertySection extends
 	}
 
 	private void bindDocumentationControl(EMFDataBindingContext context) {
-		IEMFValueProperty property = EMFEditProperties.value(
-				TransactionUtil.getEditingDomain(eObject),
+		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
 				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION);
-		ISWTObservableValue observe = WidgetProperties.text(
-				new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
+		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),
+		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()
-								.isProposalPopupOpen())
-							return super.doSet(observableValue, value);
-						return Status.OK_STATUS;
-					}
-				});
+		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),
+		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
 				BasePackage.Literals.NAMED_ELEMENT__NAME);
-		ISWTObservableValue observe = WidgetProperties.text(
-				new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
+		ISWTObservableValue observe = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
 				txtName);
 		context.bindValue(observe, property.observe(eObject));
 	}

+ 17 - 30
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/TransitionPropertySection.java

@@ -41,8 +41,7 @@ import com.google.inject.Injector;
  * @author andreas muelder - Initial contribution and API
  * 
  */
-public class TransitionPropertySection extends
-		AbstractTwoColumnEditorPropertySection {
+public class TransitionPropertySection extends AbstractTwoColumnEditorPropertySection {
 
 	private Control textControl;
 	private Text txtDoc;
@@ -58,23 +57,19 @@ public class TransitionPropertySection extends
 
 		Injector injector = getInjector(SemanticTarget.TransitionSpecification);
 		if (injector != null) {
-			textControl = new StyledText(parent, SWT.MULTI | SWT.BORDER
-					| SWT.V_SCROLL | SWT.WRAP);
+			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);
+			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);
+		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize()).applyTo(textControl);
 	}
 
 	@Override
 	protected void createRightColumnControls(Composite parent) {
-		Label lblDocumentation = getToolkit().createLabel(parent,
-				"Documentation: ");
+		Label lblDocumentation = getToolkit().createLabel(parent, "Documentation: ");
 		txtDoc = getToolkit().createText(parent, "", SWT.MULTI);
 		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblDocumentation);
 		GridDataFactory.fillDefaults().grab(true, true).applyTo(txtDoc);
@@ -82,31 +77,23 @@ public class TransitionPropertySection extends
 
 	@Override
 	public void bindModel(EMFDataBindingContext context) {
-		IEMFValueProperty modelProperty = EMFEditProperties.value(
-				TransactionUtil.getEditingDomain(eObject),
+		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()
-								.isProposalPopupOpen())
-							return super.doSet(observableValue, value);
-						return Status.OK_STATUS;
-					}
-				});
+		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),
+		IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject),
 				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION);
-		ISWTObservableValue observe = WidgetProperties.text(
-				new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
+		ISWTObservableValue observe = WidgetProperties.text(new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
 				txtDoc);
 		context.bindValue(observe, property.observe(eObject));
 
 	}
-
 }