Added API to open smart field proposal chooser

Similar to requestFocus() a form field can now call requestInput(). For
a simple text field requestInput does the same thing as requestFocus,
but a smart fields also opens the proposal chooser. 

215477
diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/AbstractForm.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/AbstractForm.java
index 42644ca..b1ef43d 100644
--- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/AbstractForm.java
+++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/AbstractForm.java
@@ -2611,7 +2611,15 @@
     if (f == null || f.getForm() != this) {
       return;
     }
-    fireRequestFocus(f);
+    fireRequestEvent(FormEvent.TYPE_REQUEST_FOCUS, f);
+  }
+
+  @Override
+  public void requestInput(IFormField f) {
+    if (f == null || f.getForm() != this) {
+      return;
+    }
+    fireRequestEvent(FormEvent.TYPE_REQUEST_INPUT, f);
   }
 
   /**
@@ -2781,9 +2789,9 @@
   }
 
   @SuppressWarnings("bsiRulesDefinition:htmlInString")
-  private void fireRequestFocus(IFormField f) {
+  private void fireRequestEvent(int eventType, IFormField f) {
     try {
-      fireFormEvent(new FormEvent(this, FormEvent.TYPE_REQUEST_FOCUS, f));
+      fireFormEvent(new FormEvent(this, eventType, f));
     }
     catch (RuntimeException | PlatformError e) {
       throw BEANS.get(PlatformExceptionTranslator.class).translate(e)
diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/DefaultFormEventHistory.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/DefaultFormEventHistory.java
index 47c1c4b..ce17d15 100644
--- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/DefaultFormEventHistory.java
+++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/DefaultFormEventHistory.java
@@ -37,6 +37,7 @@
   public void notifyEvent(FormEvent event) {
     switch (event.getType()) {
       case FormEvent.TYPE_REQUEST_FOCUS:
+      case FormEvent.TYPE_REQUEST_INPUT:
       case FormEvent.TYPE_TO_BACK:
       case FormEvent.TYPE_TO_FRONT: {
         addToCache(event.getType(), event);
diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/FormEvent.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/FormEvent.java
index 95c8b29..074dd59 100644
--- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/FormEvent.java
+++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/FormEvent.java
@@ -51,7 +51,11 @@
    * see {@link IFormField#requestFocus()}
    */
   public static final int TYPE_REQUEST_FOCUS = 6020;
-  //next 6030
+  /**
+   * see {@link IFormField#requestInput()}
+   */
+  public static final int TYPE_REQUEST_INPUT = 6030;
+  //next 6040
 
   private final int m_type;
   private final IFormField m_formField;
diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/IForm.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/IForm.java
index 97a2fd8..d098a12 100644
--- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/IForm.java
+++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/IForm.java
@@ -661,9 +661,16 @@
   void setSearchFilter(SearchFilter filter);
 
   /**
-   * Request focus for the field by sending a {@link FormEvent#TYPE_REQUEST_FOCUS} event
+   * Request focus for the field by sending a {@link FormEvent#TYPE_REQUEST_FOCUS} event.
    */
-  void requestFocus(IFormField f);
+  void requestFocus(IFormField field);
+
+  /**
+   * Request input mode for the field by sending a {@link FormEvent#TYPE_REQUEST_INPUT} event. For most fields request
+   * input does the same thing as request focus. But some fields, e.g. the SmartField, may decide to open a popup in
+   * order to get input for the field.
+   */
+  void requestInput(IFormField field);
 
   /**
    * Add a {@link FormListener}. These listeners will be called when the form is activated, closed, discarded, before
diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/AbstractFormField.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/AbstractFormField.java
index ee5fc71..2686207 100644
--- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/AbstractFormField.java
+++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/AbstractFormField.java
@@ -2064,6 +2064,14 @@
   }
 
   @Override
+  public void requestInput() {
+    IForm form = getForm();
+    if (form != null) {
+      form.requestInput(this);
+    }
+  }
+
+  @Override
   public void setPreventInitialFocus(boolean preventInitialFocus) {
     propertySupport.setPropertyBool(PROP_PREVENT_INITIAL_FOCUS, preventInitialFocus);
   }
diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/IFormField.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/IFormField.java
index 194713d..6c9364b 100644
--- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/IFormField.java
+++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/IFormField.java
@@ -560,6 +560,11 @@
   void requestFocus();
 
   /**
+   * Convenience for {@link IForm#requestInput(IFormField)}
+   */
+  void requestInput();
+
+  /**
    * MasterSlave
    */
   IValueField getMasterField();
@@ -1011,4 +1016,5 @@
   void setDisabledStyle(int disabledStyle);
 
   int getDisabledStyle();
+
 }
diff --git a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/smartfield2/SmartField2ContentAssistAdapter.java b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/smartfield2/SmartField2ContentAssistAdapter.java
index d489613..fc96e92 100644
--- a/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/smartfield2/SmartField2ContentAssistAdapter.java
+++ b/org.eclipse.scout.rt.client/src/main/java/org/eclipse/scout/rt/client/ui/form/fields/smartfield2/SmartField2ContentAssistAdapter.java
@@ -558,6 +558,11 @@
   }
 
   @Override
+  public void requestInput() {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
   public IValueField getMasterField() {
     throw new UnsupportedOperationException();
   }
diff --git a/org.eclipse.scout.rt.ui.html/src/main/java/org/eclipse/scout/rt/ui/html/json/form/JsonForm.java b/org.eclipse.scout.rt.ui.html/src/main/java/org/eclipse/scout/rt/ui/html/json/form/JsonForm.java
index 4ea86e6..05f9ca5 100644
--- a/org.eclipse.scout.rt.ui.html/src/main/java/org/eclipse/scout/rt/ui/html/json/form/JsonForm.java
+++ b/org.eclipse.scout.rt.ui.html/src/main/java/org/eclipse/scout/rt/ui/html/json/form/JsonForm.java
@@ -16,7 +16,6 @@
 import org.eclipse.scout.rt.client.ui.form.FormEvent;
 import org.eclipse.scout.rt.client.ui.form.FormListener;
 import org.eclipse.scout.rt.client.ui.form.IForm;
-import org.eclipse.scout.rt.client.ui.form.fields.IFormField;
 import org.eclipse.scout.rt.platform.status.IStatus;
 import org.eclipse.scout.rt.platform.util.Assertions;
 import org.eclipse.scout.rt.ui.html.IUiSession;
@@ -53,6 +52,7 @@
 
   public static final String EVENT_FORM_CLOSING = "formClosing";
   public static final String EVENT_REQUEST_FOCUS = "requestFocus";
+  public static final String EVENT_REQUEST_INPUT = "requestInput";
 
   private final IDesktop m_desktop;
   private FormListener m_formListener;
@@ -154,6 +154,8 @@
     attachGlobalAdapters(m_desktop.getDialogs(getModel(), false));
     attachGlobalAdapters(m_desktop.getMessageBoxes(getModel()));
     attachGlobalAdapters(m_desktop.getFileChoosers(getModel()));
+
+    addInitialInputEvent();
   }
 
   @Override
@@ -194,24 +196,48 @@
     return json;
   }
 
-  public void setInitialFocusProperty(JSONObject json) {
-    //check for request focus events in history
-    IEventHistory<FormEvent> h = getModel().getEventHistory();
-    if (h != null) {
-      for (FormEvent e : h.getRecentEvents()) {
-        if (e.getType() == FormEvent.TYPE_REQUEST_FOCUS) {
-          IJsonAdapter<?> formFieldAdapter = JsonAdapterUtility.findChildAdapter(this, e.getFormField());
-          if (formFieldAdapter == null) {
-            LOG.error("Cannot handle requestFocus event, because adapter for {} could not be resolved in {}", e.getFormField(), this);
-            return;
-          }
+  protected void addInitialInputEvent() {
+    FormEvent event = findRecentRequestEvent(FormEvent.TYPE_REQUEST_INPUT);
+    if (event != null) {
+      handleModelRequestEvent(event, true);
+    }
+  }
 
-          putProperty(json, PROP_INITIAL_FOCUS, formFieldAdapter.getId());
-        }
+  // TODO [7.0] BSH Try to replace PROP_INITIAL_FOCUS by protected EVENT_REQUEST_FOCUS (but check "initialFocusEnabled")
+  protected void setInitialFocusProperty(JSONObject json) {
+    FormEvent event = findRecentRequestEvent(FormEvent.TYPE_REQUEST_FOCUS);
+    if (event != null) {
+      IJsonAdapter<?> childAdapter = findChildAdapter(event);
+      if (childAdapter != null) {
+        putProperty(json, PROP_INITIAL_FOCUS, childAdapter.getId());
       }
     }
   }
 
+  protected IJsonAdapter<?> findChildAdapter(FormEvent event) {
+    IJsonAdapter<?> childAdapter = JsonAdapterUtility.findChildAdapter(this, event.getFormField());
+    if (childAdapter == null) {
+      LOG.error("Cannot handle form-event {}, because adapter for {} could not be resolved in {}",
+          event.getType(), event.getFormField(), this);
+    }
+    return childAdapter;
+  }
+
+  protected FormEvent findRecentRequestEvent(int eventType) {
+    IEventHistory<FormEvent> history = getModel().getEventHistory();
+    if (history == null) {
+      return null;
+    }
+    FormEvent event = null;
+    for (FormEvent event0 : history.getRecentEvents()) {
+      if (event0.getType() == eventType) {
+        event = event0;
+        break;
+      }
+    }
+    return event;
+  }
+
   protected String displayHintToJson(int displayHint) {
     switch (displayHint) {
       case IForm.DISPLAY_HINT_DIALOG:
@@ -232,7 +258,8 @@
         handleModelFormClosed(event.getForm());
         break;
       case FormEvent.TYPE_REQUEST_FOCUS:
-        handleModelRequestFocus(event.getFormField());
+      case FormEvent.TYPE_REQUEST_INPUT:
+        handleModelRequestEvent(event, false);
         break;
       default:
         // NOP
@@ -256,17 +283,27 @@
     getUiSession().sendDisposeAdapterEvent(this);
   }
 
-  protected void handleModelRequestFocus(IFormField formField) {
-    IJsonAdapter<?> formFieldAdapter = JsonAdapterUtility.findChildAdapter(this, formField);
-    if (formFieldAdapter == null) {
-      LOG.error("Cannot handle requestFocus event, because adapter for {} could not be resolved in {}", formField, this);
-      return;
+  protected void handleModelRequestEvent(FormEvent event, boolean protect) {
+    IJsonAdapter<?> childAdapter = findChildAdapter(event);
+    if (childAdapter != null) {
+      JSONObject json = new JSONObject();
+      putProperty(json, PROP_FORM_FIELD, childAdapter.getId());
+      JsonEvent jsonEvent = addActionEvent(getRequestEventName(event.getType()), json);
+      if (protect) {
+        jsonEvent.protect();
+      }
     }
+  }
 
-    JSONObject jsonEvent = new JSONObject();
-    putProperty(jsonEvent, PROP_FORM_FIELD, formFieldAdapter.getId());
-    // TODO [7.0] BSH Try to replace PROP_INITIAL_FOCUS by protected EVENT_REQUEST_FOCUS (but check "initialFocusEnabled")
-    addActionEvent(EVENT_REQUEST_FOCUS, jsonEvent);
+  protected String getRequestEventName(int eventType) {
+    switch (eventType) {
+      case FormEvent.TYPE_REQUEST_FOCUS:
+        return EVENT_REQUEST_FOCUS;
+      case FormEvent.TYPE_REQUEST_INPUT:
+        return EVENT_REQUEST_INPUT;
+      default:
+        throw new IllegalArgumentException("Unsupported event type");
+    }
   }
 
   @Override
diff --git a/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/FormAdapter.js b/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/FormAdapter.js
index 3b12b7c..a4edc0b 100644
--- a/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/FormAdapter.js
+++ b/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/FormAdapter.js
@@ -40,13 +40,19 @@
 
 scout.FormAdapter.prototype.onModelAction = function(event) {
   if (event.type === 'requestFocus') {
-    this._onRequestFocus(event.formField);
+    this._onRequestFocus(event);
+  } else if (event.type === 'requestInput') {
+    this._onRequestInput(event);
   } else {
     scout.FormAdapter.parent.prototype.onModelAction.call(this, event);
   }
 };
 
-scout.FormAdapter.prototype._onRequestFocus = function(formFieldId) {
-  var formField = this.session.getOrCreateWidget(formFieldId, this.widget);
-  formField.focus();
+scout.FormAdapter.prototype._onRequestFocus = function(event) {
+  this.session.getOrCreateWidget(event.formField, this.widget).focus();
 };
+
+scout.FormAdapter.prototype._onRequestInput = function(event) {
+  this.session.getOrCreateWidget(event.formField, this.widget).requestInput();
+};
+
diff --git a/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/fields/FormField.js b/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/fields/FormField.js
index 7decb07..9101050 100644
--- a/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/fields/FormField.js
+++ b/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/fields/FormField.js
@@ -1125,3 +1125,7 @@
 scout.FormField.prototype._updateEmpty = function() {
   // NOP
 };
+
+scout.FormField.prototype.requestInput = function() {
+  this.focus();
+};
diff --git a/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/fields/smartfield2/SmartField2.js b/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/fields/smartfield2/SmartField2.js
index baf6a96..5a22a79 100644
--- a/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/fields/smartfield2/SmartField2.js
+++ b/org.eclipse.scout.rt.ui.html/src/main/js/scout/form/fields/smartfield2/SmartField2.js
@@ -1296,3 +1296,10 @@
 
   this._clearLookupStatus();
 };
+
+scout.SmartField2.prototype.requestInput = function() {
+  if (this.enabledComputed && this.rendered) {
+    this.focus();
+    this.openPopup();
+  }
+};