Legacy Table fixes: Added nullchecks when table dmr gets invalid during runtime
diff --git a/bundles/org.eclipse.emf.ecp.view.table.model/src/org/eclipse/emf/ecp/view/spi/table/model/impl/VTableDomainModelReferenceImpl.java b/bundles/org.eclipse.emf.ecp.view.table.model/src/org/eclipse/emf/ecp/view/spi/table/model/impl/VTableDomainModelReferenceImpl.java
index 6b7538d..25ed387 100644
--- a/bundles/org.eclipse.emf.ecp.view.table.model/src/org/eclipse/emf/ecp/view/spi/table/model/impl/VTableDomainModelReferenceImpl.java
+++ b/bundles/org.eclipse.emf.ecp.view.table.model/src/org/eclipse/emf/ecp/view/spi/table/model/impl/VTableDomainModelReferenceImpl.java
@@ -58,8 +58,7 @@
* @generated
*/
public class VTableDomainModelReferenceImpl extends VFeaturePathDomainModelReferenceImpl implements
- VTableDomainModelReference
-{
+ VTableDomainModelReference {
/**
* The cached value of the '{@link #getColumnDomainModelReferences() <em>Column Domain Model References</em>}'
* containment reference list.
@@ -76,7 +75,7 @@
* The cached value of the '{@link #getDomainModelReference() <em>Domain Model Reference</em>}' containment
* reference.
* <!-- begin-user-doc -->
- *
+ *
* @since 1.5
* <!-- end-user-doc -->
*
@@ -94,8 +93,7 @@
*
* @generated
*/
- protected VTableDomainModelReferenceImpl()
- {
+ protected VTableDomainModelReferenceImpl() {
super();
}
@@ -106,8 +104,7 @@
* @generated
*/
@Override
- protected EClass eStaticClass()
- {
+ protected EClass eStaticClass() {
return VTablePackage.Literals.TABLE_DOMAIN_MODEL_REFERENCE;
}
@@ -118,10 +115,8 @@
* @generated
*/
@Override
- public EList<VDomainModelReference> getColumnDomainModelReferences()
- {
- if (columnDomainModelReferences == null)
- {
+ public EList<VDomainModelReference> getColumnDomainModelReferences() {
+ if (columnDomainModelReferences == null) {
columnDomainModelReferences = new EObjectContainmentEList<VDomainModelReference>(
VDomainModelReference.class, this,
VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__COLUMN_DOMAIN_MODEL_REFERENCES);
@@ -131,33 +126,30 @@
/**
* <!-- begin-user-doc -->
- *
+ *
* @since 1.5
* <!-- end-user-doc -->
*
* @generated
*/
@Override
- public VDomainModelReference getDomainModelReference()
- {
+ public VDomainModelReference getDomainModelReference() {
return domainModelReference;
}
/**
* <!-- begin-user-doc -->
- *
+ *
* @since 1.5
* <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetDomainModelReference(VDomainModelReference newDomainModelReference,
- NotificationChain msgs)
- {
+ NotificationChain msgs) {
final VDomainModelReference oldDomainModelReference = domainModelReference;
domainModelReference = newDomainModelReference;
- if (eNotificationRequired())
- {
+ if (eNotificationRequired()) {
final ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__DOMAIN_MODEL_REFERENCE, oldDomainModelReference,
newDomainModelReference);
@@ -172,17 +164,15 @@
/**
* <!-- begin-user-doc -->
- *
+ *
* @since 1.5
* <!-- end-user-doc -->
*
* @generated
*/
@Override
- public void setDomainModelReference(VDomainModelReference newDomainModelReference)
- {
- if (newDomainModelReference != domainModelReference)
- {
+ public void setDomainModelReference(VDomainModelReference newDomainModelReference) {
+ if (newDomainModelReference != domainModelReference) {
NotificationChain msgs = null;
if (domainModelReference != null) {
msgs = ((InternalEObject) domainModelReference).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
@@ -196,8 +186,7 @@
if (msgs != null) {
msgs.dispatch();
}
- }
- else if (eNotificationRequired()) {
+ } else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET,
VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__DOMAIN_MODEL_REFERENCE, newDomainModelReference,
newDomainModelReference));
@@ -211,10 +200,8 @@
* @generated
*/
@Override
- public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
- {
- switch (featureID)
- {
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
case VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__COLUMN_DOMAIN_MODEL_REFERENCES:
return ((InternalEList<?>) getColumnDomainModelReferences()).basicRemove(otherEnd, msgs);
case VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__DOMAIN_MODEL_REFERENCE:
@@ -230,10 +217,8 @@
* @generated
*/
@Override
- public Object eGet(int featureID, boolean resolve, boolean coreType)
- {
- switch (featureID)
- {
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
case VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__COLUMN_DOMAIN_MODEL_REFERENCES:
return getColumnDomainModelReferences();
case VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__DOMAIN_MODEL_REFERENCE:
@@ -250,10 +235,8 @@
*/
@SuppressWarnings("unchecked")
@Override
- public void eSet(int featureID, Object newValue)
- {
- switch (featureID)
- {
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
case VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__COLUMN_DOMAIN_MODEL_REFERENCES:
getColumnDomainModelReferences().clear();
getColumnDomainModelReferences().addAll((Collection<? extends VDomainModelReference>) newValue);
@@ -272,10 +255,8 @@
* @generated
*/
@Override
- public void eUnset(int featureID)
- {
- switch (featureID)
- {
+ public void eUnset(int featureID) {
+ switch (featureID) {
case VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__COLUMN_DOMAIN_MODEL_REFERENCES:
getColumnDomainModelReferences().clear();
return;
@@ -293,10 +274,8 @@
* @generated
*/
@Override
- public boolean eIsSet(int featureID)
- {
- switch (featureID)
- {
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
case VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__COLUMN_DOMAIN_MODEL_REFERENCES:
return columnDomainModelReferences != null && !columnDomainModelReferences.isEmpty();
case VTablePackage.TABLE_DOMAIN_MODEL_REFERENCE__DOMAIN_MODEL_REFERENCE:
@@ -374,13 +353,11 @@
Setting result = null;
if (returnedElements == 0) {
result = ((InternalEObject) lastResolvedEObject).eSetting(listFeature);
- }
- else {
+ } else {
final Iterator<Setting> iterator = resolvedColumns.get(returnedElements - 1).getIterator();
if (iterator.hasNext()) {
result = iterator.next();
- }
- else {
+ } else {
throw new NoSuchElementException(String.format(
"The iterator has %1$s but %2$s already has been returned!", numElems, returnedElements)); //$NON-NLS-1$
}
@@ -434,8 +411,7 @@
EStructuralFeature result = null;
if (0 == counter) {
result = listFeature;
- }
- else {
+ } else {
result = getColumnDomainModelReferences().get(counter - 1).getEStructuralFeatureIterator().next();
}
@@ -476,6 +452,9 @@
}
@SuppressWarnings("unchecked")
final List<EObject> eObjects = (List<EObject>) lastResolvedEObject.eGet(feature);
+ if (eObjects == null) {
+ return false;
+ }
for (final EObject eObject : eObjects) {
for (final VDomainModelReference columnReference : getColumnDomainModelReferences()) {
final VDomainModelReference copy = EcoreUtil.copy(columnReference);
diff --git a/bundles/org.eclipse.emf.ecp.view.table.ui.swt/src/org/eclipse/emf/ecp/view/spi/table/swt/TableControlSWTRenderer.java b/bundles/org.eclipse.emf.ecp.view.table.ui.swt/src/org/eclipse/emf/ecp/view/spi/table/swt/TableControlSWTRenderer.java
index e16ca03..097c7d3 100644
--- a/bundles/org.eclipse.emf.ecp.view.table.ui.swt/src/org/eclipse/emf/ecp/view/spi/table/swt/TableControlSWTRenderer.java
+++ b/bundles/org.eclipse.emf.ecp.view.table.ui.swt/src/org/eclipse/emf/ecp/view/spi/table/swt/TableControlSWTRenderer.java
@@ -619,7 +619,8 @@
LocalizationServiceHelper.getString(getClass(), MessageKeys.TableControl_RemoveSelected), instanceName));
final List<?> containments = (List<?>) mainSetting.get(true);
- if (containments.size() <= mainSetting.getEStructuralFeature().getLowerBound()) {
+
+ if (containments == null || containments.size() <= mainSetting.getEStructuralFeature().getLowerBound()) {
removeButton.setEnabled(false);
}
return removeButton;
@@ -634,7 +635,7 @@
LocalizationServiceHelper.getString(getClass(), MessageKeys.TableControl_AddInstanceOf), instanceName));
final List<?> containments = (List<?>) mainSetting.get(true);
- if (mainSetting.getEStructuralFeature().getUpperBound() != -1
+ if (containments == null || mainSetting.getEStructuralFeature().getUpperBound() != -1
&& containments.size() >= mainSetting.getEStructuralFeature().getUpperBound()) {
addButton.setEnabled(false);
}
@@ -760,7 +761,7 @@
validationIcon.setToolTipText(ECPTooltipModifierHelper.modifyString(getVElement().getDiagnostic()
.getMessage(), null));
final Collection<?> collection = (Collection<?>) mainSetting.get(true);
- if (!collection.isEmpty()) {
+ if (collection != null && !collection.isEmpty()) {
for (final Object object : collection) {
tableViewer.update(object, null);
}