Bug 430809
resize key column after editing
resize key column when provider adds row instead of when handler adds
row (allows for resizing during init, and handles forms with multiple
instances of editor on different tabs)
no need to check for minimum width when packing

Change-Id: Ia58ec1810c68a3ca2611a5a1c88327020168bcee
Signed-off-by: Steven Spungin <steven@spungin.tv>
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java
index 9c73ca4..6775e46 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/ControlFactory.java
@@ -8,7 +8,7 @@
  * Contributors:
  *     Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
  *     Dirk Fauth <dirk.fauth@googlemail.com> - Bug 426986
- *     Steven Spungin <steven@spungin.tv> - Bug 430660, 430664
+ *     Steven Spungin <steven@spungin.tv> - Bug 430660, 430664, Bug 430809
  ******************************************************************************/
 package org.eclipse.e4.tools.emf.ui.internal.common.component;
 
@@ -17,7 +17,9 @@
 import java.util.Map.Entry;
 import org.eclipse.core.databinding.Binding;
 import org.eclipse.core.databinding.UpdateValueStrategy;
+import org.eclipse.core.databinding.observable.list.IListChangeListener;
 import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.list.ListChangeEvent;
 import org.eclipse.core.databinding.observable.map.IObservableMap;
 import org.eclipse.core.databinding.observable.value.IObservableValue;
 import org.eclipse.core.databinding.observable.value.IValueChangeListener;
@@ -99,7 +101,6 @@
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.Text;
 
 public class ControlFactory {
@@ -220,6 +221,7 @@
 				if (cmd.canExecute()) {
 					editor.getEditingDomain().getCommandStack().execute(cmd);
 					tableviewer.refresh();
+					tableviewer.getTable().getColumn(0).pack();
 				}
 			}
 
@@ -284,7 +286,15 @@
 		});
 
 		IEMFEditListProperty prop = EMFEditProperties.list(editor.getEditingDomain(), feature);
-		tableviewer.setInput(prop.observeDetail(editor.getMaster()));
+		IObservableList observableList = prop.observeDetail(editor.getMaster());
+		tableviewer.setInput(observableList);
+		observableList.addListChangeListener(new IListChangeListener() {
+
+			@Override
+			public void handleListChange(ListChangeEvent event) {
+				tableviewer.getTable().getColumn(0).pack();
+			}
+		});
 
 		final Composite buttonComp = new Composite(parent, SWT.NONE);
 		buttonComp.setLayoutData(new GridData(GridData.FILL, GridData.END, false, false));
@@ -341,15 +351,6 @@
 								editor.getEditingDomain().getCommandStack().execute(cmd);
 								super.okPressed();
 							}
-
-							// pack the first column
-							if (tableviewer.getTable().getColumns().length > 0) {
-								TableColumn tableColumn = tableviewer.getTable().getColumns()[0];
-								tableColumn.pack();
-								if (tableColumn.getWidth() < 20) {
-									tableColumn.setWidth(20);
-								}
-							}
 						}
 					}
 				};