[562390] Fixed selection issues in new inplace editor

With this fix the selected element is correctly created now.

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=562390
Change-Id: Idcd1a947c321cc537ee7b114aa29419d4c7a5fc5
Signed-off-by: Alois Zoitl <alois.zoitl@gmx.at>
diff --git a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editors/NewInstanceCellEditor.java b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editors/NewInstanceCellEditor.java
index ee7fd2b..9aec737 100644
--- a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editors/NewInstanceCellEditor.java
+++ b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editors/NewInstanceCellEditor.java
@@ -54,6 +54,7 @@
 	private TableViewer tableViewer;
 	private PaletteFilter paletteFilter;
 	private boolean blockTableSelection = false;
+	private PaletteEntry selectedEntry = null;
 
 	public NewInstanceCellEditor() {
 		super();
@@ -124,8 +125,8 @@
 
 	@Override
 	protected Object doGetValue() {
-		if (tableViewer.getTable().getSelectionIndex() != -1) {
-			return tableViewer.getStructuredSelection().getFirstElement();
+		if (null != selectedEntry) {
+			return selectedEntry;
 		}
 		return super.doGetValue();
 	}
@@ -189,8 +190,8 @@
 				break;
 			case SWT.CR:
 				if (popupShell.isVisible() && (tableViewer.getTable().getSelectionIndex() != -1)) {
-					textControl.setText(
-							((PaletteEntry) tableViewer.getStructuredSelection().getFirstElement()).getLabel());
+					selectedEntry = (PaletteEntry) tableViewer.getStructuredSelection().getFirstElement();
+					textControl.setText(selectedEntry.getLabel());
 				} else {
 					event.doit = false;
 				}
@@ -218,8 +219,7 @@
 	private void selectItemAtIndex(int index) {
 		blockTableSelection = true;
 		Object element = tableViewer.getElementAt(index);
-		tableViewer.setSelection(new StructuredSelection(element));
-		tableViewer.reveal(element);
+		tableViewer.setSelection(new StructuredSelection(element), true);
 		blockTableSelection = false;
 	}