/*
 * Smart GWT (GWT for SmartClient)
 * Copyright 2008 and beyond, Isomorphic Software, Inc.
 *
 * Smart GWT is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation.  Smart GWT is also
 * available under typical commercial license terms - see
 * http://smartclient.com/license
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 */
/* sgwtgen */
 
package com.smartgwt.client.util;


import com.smartgwt.client.event.*;
import com.smartgwt.client.core.*;
import com.smartgwt.client.types.*;
import com.smartgwt.client.data.*;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.events.*;
import com.smartgwt.client.browser.window.*;
import com.smartgwt.client.rpc.*;
import com.smartgwt.client.ai.*;
import com.smartgwt.client.callbacks.*;
import com.smartgwt.client.tools.*;
import com.smartgwt.client.bean.*;
import com.smartgwt.client.widgets.*;
import com.smartgwt.client.widgets.ai.*;
import com.smartgwt.client.widgets.events.*;
import com.smartgwt.client.widgets.form.*;
import com.smartgwt.client.widgets.form.validator.*;
import com.smartgwt.client.widgets.form.fields.*;
import com.smartgwt.client.widgets.tile.*;
import com.smartgwt.client.widgets.tile.events.*;
import com.smartgwt.client.widgets.grid.*;
import com.smartgwt.client.widgets.grid.events.*;
import com.smartgwt.client.widgets.chart.*;
import com.smartgwt.client.widgets.layout.*;
import com.smartgwt.client.widgets.layout.events.*;
import com.smartgwt.client.widgets.menu.*;
import com.smartgwt.client.widgets.tour.*;
import com.smartgwt.client.widgets.notify.*;
import com.smartgwt.client.widgets.rte.*;
import com.smartgwt.client.widgets.rte.events.*;
import com.smartgwt.client.widgets.ace.*;
import com.smartgwt.client.widgets.ace.events.*;
import com.smartgwt.client.widgets.tab.*;
import com.smartgwt.client.widgets.toolbar.*;
import com.smartgwt.client.widgets.tree.*;
import com.smartgwt.client.widgets.tree.events.*;
import com.smartgwt.client.widgets.tableview.*;
import com.smartgwt.client.widgets.viewer.*;
import com.smartgwt.client.widgets.calendar.*;
import com.smartgwt.client.widgets.calendar.events.*;
import com.smartgwt.client.widgets.cube.*;
import com.smartgwt.client.widgets.notify.*;
import com.smartgwt.client.widgets.drawing.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.google.gwt.event.shared.*;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.core.client.JavaScriptObject;

import com.smartgwt.client.util.*;
import com.smartgwt.client.util.events.*;
import com.smartgwt.client.util.workflow.*;
import com.smartgwt.client.util.workflow.Process; // required to override java.lang.Process
import com.smartgwt.client.util.tour.*;


/**
 * The VoiceAssist class provides voice-interaction features by leveraging the browser?s speech  recognition capabilities,
 * typically through the SpeechRecognition or webkitSpeechRecognition  interfaces. At the time of writing, full support is
 * available in Chromium-based browsers  like Chrome and Edge (on desktop). Safari provides partial support through the 
 * webkitSpeechRecognition API.  Firefox does not support speech recognition due to privacy  and security concerns, and
 * some Chromium-based browsers like Brave also omit support due to  their exclusion of Google?s proprietary services. <p>
 * To enable VoiceAssist, call {@link com.smartgwt.client.util.VoiceAssist#enable enable()}, optionally passing the {@link
 * com.smartgwt.client.util.VoiceAssist#voiceKey keyName} you want to use for activation and recording - the default is
 * <code>Control</code>.  Once initialized, VoiceAssist can be activated or deactivated with a triple-tap of the {@link
 * com.smartgwt.client.util.VoiceAssist#voiceKey voiceKey}. <p> When recognition is active, a user may double-tap the
 * <code>voiceKey</code> to begin dictating a value for a focused input control.  Text appears in the input control as the
 * user speaks and the transcription is completed by a subsequent double-tap of the <code>voiceKey</code>, or by remaining
 * silent for a number of seconds. <p> In addition to value-dictation, a user may dictate a command to be issued to the
 * focused component, which may deal with the text itself or forward to an AI for action.  If the focused component doesn't
 * {@link com.smartgwt.client.widgets.Canvas#supportsVoiceCommands support voice-commands} but one of its parents does,
 * that parent will be the focus of your dictated command.  To begin dictating a command, press and hold the
 * <code>voiceKey</code> - while the key remains pressed, the {@link com.smartgwt.client.util.VoiceAssist#recordingProgress
 * recordingProgress()} method is fired with interim text-results as the user speaks. <p> If the user speaks one of the
 * {@link com.smartgwt.client.util.VoiceAssist#cancelPhrases cancelPhrases}, the interim text is discarded and recording is
 * canceled. <p> When the user releases the speech-key, recording is stopped and the final text of the recording is passed
 * to the {@link com.smartgwt.client.widgets.Canvas#doVoiceCommand target component} for action. <p> <b>Note:</b> On {@link
 * com.smartgwt.client.util.Browser#isHandset handset} and {@link com.smartgwt.client.util.Browser#isTablet tablet}
 * devices, the keyboard gestures described above (triple-tap, double-tap, press-and-hold) are not available because
 * virtual keyboards do not fire physical key events for modifier keys.  Call {@link
 * com.smartgwt.client.util.VoiceAssist#setActive setActive()} from a button or other UI element, and use {@link
 * com.smartgwt.client.util.VoiceAssist#startDictatingValue startDictatingValue()} or {@link
 * com.smartgwt.client.util.VoiceAssist#startDictatingCommand startDictatingCommand()} to initiate recording
 * programmatically.
 */
@BeanFactory.FrameworkClass
public class VoiceAssist {


    // ********************* Static Attributes ***********************

    /** 
     * VoiceAssist will stop recording automatically if the user stops speaking for this length of time.  The default is 2
     * seconds.
     *
     * @param autoStopDelay new autoStopDelay.  Default value is 2000.
     */
    public static native void setAutoStopDelay(int autoStopDelay) /*-{
        @com.smartgwt.client.util.JSOHelper::setAttribute(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;I)($wnd.isc.VoiceAssist, "autoStopDelay", autoStopDelay);
    }-*/;


    /** 
     * VoiceAssist will stop recording automatically if the user stops speaking for this length of time.  The default is 2
     * seconds.
     *
     * @return current value of autoStopDelay
     */
    public static native int getAutoStopDelay() /*-{
        var result = $wnd.isc.VoiceAssist.autoStopDelay;
        if (result == null) result = 0;
        return @com.google.gwt.core.client.GWT::isScript()() ? result : result.valueOf();
    }-*/;

    /** 
     * Whether VoiceAssist allows command-dictation, where the user's speech is transcribed and forwarded to a target component
     * (or AI) for execution.  When false, the long-press gesture is ignored and {@link
     * com.smartgwt.client.util.VoiceAssist#startDictatingCommand startDictatingCommand()} is a no-op.
     *
     * @param canDictateCommands new canDictateCommands.  Default value is true.
     */
    public static native void setCanDictateCommands(boolean canDictateCommands) /*-{
        @com.smartgwt.client.util.JSOHelper::setAttribute(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)($wnd.isc.VoiceAssist, "canDictateCommands", canDictateCommands);
    }-*/;


    /** 
     * Whether VoiceAssist allows command-dictation, where the user's speech is transcribed and forwarded to a target component
     * (or AI) for execution.  When false, the long-press gesture is ignored and {@link
     * com.smartgwt.client.util.VoiceAssist#startDictatingCommand startDictatingCommand()} is a no-op.
     *
     * @return current value of canDictateCommands
     */
    public static native boolean getCanDictateCommands() /*-{
        var result = $wnd.isc.VoiceAssist.canDictateCommands;
        if (result == null) result = false;
        return @com.google.gwt.core.client.GWT::isScript()() ? result : result.valueOf();
    }-*/;

    /** 
     * Whether VoiceAssist allows value-dictation, where the user's speech is transcribed into a focused text field.  When
     * false, the voice-assist inline icon is not shown on form items, the double-tap gesture is ignored, and {@link
     * com.smartgwt.client.util.VoiceAssist#startDictatingValue startDictatingValue()} is a no-op.
     *
     * @param canDictateValues new canDictateValues.  Default value is true.
     */
    public static native void setCanDictateValues(boolean canDictateValues) /*-{
        @com.smartgwt.client.util.JSOHelper::setAttribute(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Z)($wnd.isc.VoiceAssist, "canDictateValues", canDictateValues);
    }-*/;


    /** 
     * Whether VoiceAssist allows value-dictation, where the user's speech is transcribed into a focused text field.  When
     * false, the voice-assist inline icon is not shown on form items, the double-tap gesture is ignored, and {@link
     * com.smartgwt.client.util.VoiceAssist#startDictatingValue startDictatingValue()} is a no-op.
     *
     * @return current value of canDictateValues
     */
    public static native boolean getCanDictateValues() /*-{
        var result = $wnd.isc.VoiceAssist.canDictateValues;
        if (result == null) result = false;
        return @com.google.gwt.core.client.GWT::isScript()() ? result : result.valueOf();
    }-*/;

    /** 
     * The BCP 47 language-tag for the language that VoiceAssist expects to interpret.  These  are in the format
     * <i>"language-REGION"</i>, like "en-US" or "fr-FR".  If  unset, VoiceAssist uses the language provided by your browser or
     * OS.
     *
     * @param language new language.  Default value is null.
     */
    public static native void setLanguage(String language) /*-{
        @com.smartgwt.client.util.JSOHelper::setAttribute(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Ljava/lang/String;)($wnd.isc.VoiceAssist, "language", language);
    }-*/;


    /** 
     * The BCP 47 language-tag for the language that VoiceAssist expects to interpret.  These  are in the format
     * <i>"language-REGION"</i>, like "en-US" or "fr-FR".  If  unset, VoiceAssist uses the language provided by your browser or
     * OS.
     *
     * @return current value of language
     */
    public static native String getLanguage() /*-{
        return $wnd.isc.VoiceAssist.language;
    }-*/;

    /** 
     * VoiceAssist will stop recording automatically if the user doesn't speak at all for this length of time.  The default is
     * 3 seconds.
     *
     * @param noSpeechDelay new noSpeechDelay.  Default value is 3000.
     */
    public static native void setNoSpeechDelay(int noSpeechDelay) /*-{
        @com.smartgwt.client.util.JSOHelper::setAttribute(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;I)($wnd.isc.VoiceAssist, "noSpeechDelay", noSpeechDelay);
    }-*/;


    /** 
     * VoiceAssist will stop recording automatically if the user doesn't speak at all for this length of time.  The default is
     * 3 seconds.
     *
     * @return current value of noSpeechDelay
     */
    public static native int getNoSpeechDelay() /*-{
        var result = $wnd.isc.VoiceAssist.noSpeechDelay;
        if (result == null) result = 0;
        return @com.google.gwt.core.client.GWT::isScript()() ? result : result.valueOf();
    }-*/;

    /** 
     * The key that activates and performs VoiceAssist features like value and command dictation.
     *
     * @param voiceKey new voiceKey.  Default value is "Control".
     */
    public static native void setVoiceKey(String voiceKey) /*-{
        @com.smartgwt.client.util.JSOHelper::setAttribute(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Ljava/lang/String;)($wnd.isc.VoiceAssist, "voiceKey", voiceKey);
    }-*/;


    /** 
     * The key that activates and performs VoiceAssist features like value and command dictation.
     *
     * @return current value of voiceKey
     */
    public static native String getVoiceKey() /*-{
        return $wnd.isc.VoiceAssist.voiceKey;
    }-*/;


    // ********************* Static Methods ***********************

	/**
     * Cancels any ongoing recording session (value or command) and discards the transcription.  If value-dictation was in
     * progress, the target item's value is restored to its pre-recording state.
     *
     * @return true if a recording was canceled, false if no recording was   in progress
     */
    public static native boolean cancelRecording() /*-{
        var ret = $wnd.isc.VoiceAssist.cancelRecording();
        return ret == null ? false : ret;
    }-*/;


	/**
     * Disables VoiceAssist completely, removing keyboard listeners, deactivating if currently {@link
     * com.smartgwt.client.util.VoiceAssist#active active}, and canceling any in-progress recording.  After calling this
     * method, {@link com.smartgwt.client.util.VoiceAssist#enable enable()} must be called again before VoiceAssist can be
     * reactivated.
     * @see com.smartgwt.client.util.VoiceAssist#setActive
     */
    public static native void disable() /*-{
        $wnd.isc.VoiceAssist.disable();
    }-*/;


	/**
     * Enables the VoiceAssist module by initializing the speech-recognition engine and, on non-mobile browsers, installing
     * keyboard listeners for the {@link com.smartgwt.client.util.VoiceAssist#voiceKey speech-key}.  Once enabled, a user may
     * triple-tap the speech-key to {@link com.smartgwt.client.util.VoiceAssist#setActive activate} VoiceAssist.  On {@link
     * com.smartgwt.client.util.Browser#isHandset handset} and {@link com.smartgwt.client.util.Browser#isTablet tablet}
     * devices, keyboard listeners are skipped (virtual keyboards do not fire physical key events); call {@link
     * com.smartgwt.client.util.VoiceAssist#setActive setActive()} directly from a button or other UI element instead. <p> No
     * intrusive mic/speech probe is performed at enable time.  The probe runs on the first call to {@link
     * com.smartgwt.client.util.VoiceAssist#setActive setActive()}.
     * @see com.smartgwt.client.util.VoiceAssist#setActive
     * @see com.smartgwt.client.util.Browser#checkSpeechRecognition
     */
    public static native void enable() /*-{
        $wnd.isc.VoiceAssist.enable();
    }-*/;

	/**
     * Enables the VoiceAssist module by initializing the speech-recognition engine and, on non-mobile browsers, installing
     * keyboard listeners for the {@link com.smartgwt.client.util.VoiceAssist#voiceKey speech-key}.  Once enabled, a user may
     * triple-tap the speech-key to {@link com.smartgwt.client.util.VoiceAssist#setActive activate} VoiceAssist.  On {@link
     * com.smartgwt.client.util.Browser#isHandset handset} and {@link com.smartgwt.client.util.Browser#isTablet tablet}
     * devices, keyboard listeners are skipped (virtual keyboards do not fire physical key events); call {@link
     * com.smartgwt.client.util.VoiceAssist#setActive setActive()} directly from a button or other UI element instead. <p> No
     * intrusive mic/speech probe is performed at enable time.  The probe runs on the first call to {@link
     * com.smartgwt.client.util.VoiceAssist#setActive setActive()}.
     * @param key optional different key to use for VoiceAssist - use   with care
     * @see com.smartgwt.client.util.VoiceAssist#setActive
     * @see com.smartgwt.client.util.Browser#checkSpeechRecognition
     */
    public static native void enable(String key) /*-{
        $wnd.isc.VoiceAssist.enable(key);
    }-*/;
	

	/**
     * Returns whether VoiceAssist is currently {@link com.smartgwt.client.util.VoiceAssist#active active} for end-user
     * interaction.
     *
     * @return true if VoiceAssist is active
     * @see com.smartgwt.client.util.VoiceAssist#setActive
     */
    public static native boolean getActive() /*-{
        var ret = $wnd.isc.VoiceAssist.getActive();
        return ret == null ? false : ret;
    }-*/;


	/**
     * Returns the current list of {@link com.smartgwt.client.util.VoiceAssist#cancelPhrases cancel phrases}.
     *
     * @return current cancel phrases
     * @see com.smartgwt.client.util.VoiceAssist#cancelPhrases
     */
    public static native String[] getCancelPhrases() /*-{
        var ret = $wnd.isc.VoiceAssist.getCancelPhrases();
        if(ret == null) return null;
        return @com.smartgwt.client.util.ConvertTo::arrayOfString(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
    }-*/;


	/**
     * Returns whether VoiceAssist has been {@link com.smartgwt.client.util.VoiceAssist#enabled enabled} by the application
     * developer.
     *
     * @return true if VoiceAssist is enabled
     * @see com.smartgwt.client.util.VoiceAssist#enable
     * @see com.smartgwt.client.util.VoiceAssist#disable
     */
    public static native boolean getEnabled() /*-{
        var ret = $wnd.isc.VoiceAssist.getEnabled();
        return ret == null ? false : ret;
    }-*/;


	/**
     * Returns an {@link com.smartgwt.client.widgets.Img} widget pre-configured to start and stop VoiceAssist recording.  The
     * button can be placed anywhere in the UI (toolbars, tab-bar controls, etc.) to give users a clickable entry point for
     * voice interaction. <p> When clicked, the button determines the recording mode based on the currently focused component. 
     * If a {@link com.smartgwt.client.widgets.form.fields.FormItem} that supports value-dictation is focused, value-dictation
     * begins; otherwise, command-dictation begins.  Recording stops on a second click, or automatically after a period of
     * silence (see {@link com.smartgwt.client.util.VoiceAssist#autoStopDelay autoStopDelay}). <p> If VoiceAssist is not yet
     * {@link com.smartgwt.client.util.VoiceAssist#setActive active} when clicked, the button calls {@link
     * com.smartgwt.client.util.VoiceAssist#setActive setActive()} automatically.  Note that {@link
     * com.smartgwt.client.util.VoiceAssist#enable enable()} must have been called first, otherwise setActive() will log a
     * warning and return without activating. <p> The button is created with <code>canFocus: false</code> so that clicking it
     * does not steal focus from the component whose value or commands are being dictated.
     *
     * @return a live widget wired for VoiceAssist recording
     */
    public static native Img getVoiceAssistButton() /*-{
        var ret = $wnd.isc.VoiceAssist.getVoiceAssistButton();
        return @com.smartgwt.client.widgets.Canvas::getByJSObject(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
    }-*/;

	/**
     * Returns an {@link com.smartgwt.client.widgets.Img} widget pre-configured to start and stop VoiceAssist recording.  The
     * button can be placed anywhere in the UI (toolbars, tab-bar controls, etc.) to give users a clickable entry point for
     * voice interaction. <p> When clicked, the button determines the recording mode based on the currently focused component. 
     * If a {@link com.smartgwt.client.widgets.form.fields.FormItem} that supports value-dictation is focused, value-dictation
     * begins; otherwise, command-dictation begins.  Recording stops on a second click, or automatically after a period of
     * silence (see {@link com.smartgwt.client.util.VoiceAssist#autoStopDelay autoStopDelay}). <p> If VoiceAssist is not yet
     * {@link com.smartgwt.client.util.VoiceAssist#setActive active} when clicked, the button calls {@link
     * com.smartgwt.client.util.VoiceAssist#setActive setActive()} automatically.  Note that {@link
     * com.smartgwt.client.util.VoiceAssist#enable enable()} must have been called first, otherwise setActive() will log a
     * warning and return without activating. <p> The button is created with <code>canFocus: false</code> so that clicking it
     * does not steal focus from the component whose value or commands are being dictated.
     * @param properties optional properties to apply to   the returned Img widget, for example a title or ID
     *
     * @return a live widget wired for VoiceAssist recording
     */
    public static native Img getVoiceAssistButton(Img properties) /*-{
        var ret = $wnd.isc.VoiceAssist.getVoiceAssistButton(properties == null ? null : properties.@com.smartgwt.client.widgets.BaseWidget::getConfig()());
        return @com.smartgwt.client.widgets.Canvas::getByJSObject(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
    }-*/;
	

	/**
     * Returns a {@link com.smartgwt.client.widgets.form.fields.FormItemIcon} properties object configured for VoiceAssist
     * value-dictation.  The returned object merges {@link com.smartgwt.client.util.VoiceAssist#voiceAssistIcon
     * voiceAssistIcon} defaults, then <code>voiceAssistIconProperties</code>, then any supplied <code>properties</code>
     * argument, so all three customization levels are reflected. <p> This is the same icon configuration used internally when
     * {@link com.smartgwt.client.widgets.form.fields.FormItem#getShowVoiceAssistIcon FormItem.showVoiceAssistIcon} is enabled.
     * Use this method to retrieve the config for manual inclusion in a custom item's {@link
     * com.smartgwt.client.widgets.form.fields.FormItem#getIcons FormItem.icons} array.
     *
     * @return icon properties for VoiceAssist
     * @see com.smartgwt.client.util.VoiceAssist#voiceAssistIcon
     */
    public static native FormItemIcon getVoiceAssistIcon() /*-{
        var ret = $wnd.isc.VoiceAssist.getVoiceAssistIcon();
        if(ret == null) return null;
        return @com.smartgwt.client.widgets.form.fields.FormItemIcon::getOrCreateRef(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
    }-*/;

	/**
     * Returns a {@link com.smartgwt.client.widgets.form.fields.FormItemIcon} properties object configured for VoiceAssist
     * value-dictation.  The returned object merges {@link com.smartgwt.client.util.VoiceAssist#voiceAssistIcon
     * voiceAssistIcon} defaults, then <code>voiceAssistIconProperties</code>, then any supplied <code>properties</code>
     * argument, so all three customization levels are reflected. <p> This is the same icon configuration used internally when
     * {@link com.smartgwt.client.widgets.form.fields.FormItem#getShowVoiceAssistIcon FormItem.showVoiceAssistIcon} is enabled.
     * Use this method to retrieve the config for manual inclusion in a custom item's {@link
     * com.smartgwt.client.widgets.form.fields.FormItem#getIcons FormItem.icons} array.
     * @param properties additional properties to apply   to the icon, overriding both defaults and properties
     *
     * @return icon properties for VoiceAssist
     * @see com.smartgwt.client.util.VoiceAssist#voiceAssistIcon
     */
    public static native FormItemIcon getVoiceAssistIcon(FormItemIcon properties) /*-{
        var ret = $wnd.isc.VoiceAssist.getVoiceAssistIcon(properties == null ? null : properties.@com.smartgwt.client.core.DataClass::getJsObj()());
        if(ret == null) return null;
        return @com.smartgwt.client.widgets.form.fields.FormItemIcon::getOrCreateRef(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
    }-*/;
	

	/**
     * Event fired with interim text-results as the user speaks.
     * @param text the latest text-results for an on-going recording
     */
    public static native void recordingProgress(String text) /*-{
        $wnd.isc.VoiceAssist.recordingProgress(text);
    }-*/;


	/**
     * Sets whether VoiceAssist is active.  When active, the dictation methods ({@link
     * com.smartgwt.client.util.VoiceAssist#startDictatingValue startDictatingValue()}, {@link
     * com.smartgwt.client.util.VoiceAssist#startDictatingCommand startDictatingCommand()}) become operational, subject to
     * {@link com.smartgwt.client.util.VoiceAssist#canDictateValues canDictateValues} and {@link
     * com.smartgwt.client.util.VoiceAssist#canDictateCommands canDictateCommands}.  Voice-assist icons appear on applicable
     * {@link com.smartgwt.client.widgets.form.fields.FormItem FormItems} if {@link
     * com.smartgwt.client.util.VoiceAssist#canDictateValues canDictateValues} is true.  When set to false, any in-progress
     * recording is stopped and icons are hidden. <p> On the first call with <code>true</code>, {@link
     * com.smartgwt.client.util.Browser#checkSpeechRecognition Browser.checkSpeechRecognition()} runs a brief probe to verify
     * mic access and speech-service connectivity.  If the probe fails, VoiceAssist shows an explanatory message and does not
     * become active.  Subsequent calls skip the probe and use the cached result. <p> {@link
     * com.smartgwt.client.util.VoiceAssist#enable enable()} must be called before this method can activate VoiceAssist. If
     * <code>enable()</code> has not been called, this method logs a warning and returns without activating. <p> On non-mobile
     * devices, this method is called internally when the user triple-taps the {@link
     * com.smartgwt.client.util.VoiceAssist#voiceKey speech-key} (toggling the active state).  On {@link
     * com.smartgwt.client.util.Browser#isHandset handset} and {@link com.smartgwt.client.util.Browser#isTablet tablet}
     * devices, call it directly from a button or other UI element.
     * @param active true to activate, false to deactivate
     * @see com.smartgwt.client.util.VoiceAssist#enable
     */
    public static native void setActive(boolean active) /*-{
        $wnd.isc.VoiceAssist.setActive(active);
    }-*/;

	/**
     * Sets whether VoiceAssist is active.  When active, the dictation methods ({@link
     * com.smartgwt.client.util.VoiceAssist#startDictatingValue startDictatingValue()}, {@link
     * com.smartgwt.client.util.VoiceAssist#startDictatingCommand startDictatingCommand()}) become operational, subject to
     * {@link com.smartgwt.client.util.VoiceAssist#canDictateValues canDictateValues} and {@link
     * com.smartgwt.client.util.VoiceAssist#canDictateCommands canDictateCommands}.  Voice-assist icons appear on applicable
     * {@link com.smartgwt.client.widgets.form.fields.FormItem FormItems} if {@link
     * com.smartgwt.client.util.VoiceAssist#canDictateValues canDictateValues} is true.  When set to false, any in-progress
     * recording is stopped and icons are hidden. <p> On the first call with <code>true</code>, {@link
     * com.smartgwt.client.util.Browser#checkSpeechRecognition Browser.checkSpeechRecognition()} runs a brief probe to verify
     * mic access and speech-service connectivity.  If the probe fails, VoiceAssist shows an explanatory message and does not
     * become active.  Subsequent calls skip the probe and use the cached result. <p> {@link
     * com.smartgwt.client.util.VoiceAssist#enable enable()} must be called before this method can activate VoiceAssist. If
     * <code>enable()</code> has not been called, this method logs a warning and returns without activating. <p> On non-mobile
     * devices, this method is called internally when the user triple-taps the {@link
     * com.smartgwt.client.util.VoiceAssist#voiceKey speech-key} (toggling the active state).  On {@link
     * com.smartgwt.client.util.Browser#isHandset handset} and {@link com.smartgwt.client.util.Browser#isTablet tablet}
     * devices, call it directly from a button or other UI element.
     * @param active true to activate, false to deactivate
     * @param callback optional callback fired when the activation or   deactivation is complete.  Because the first activation involves an
     * asynchronous   speech-recognition probe, callers that need to know when VoiceAssist is actually   ready should pass a
     * callback rather than assuming synchronous completion.  The   callback receives a single boolean argument: true if
     * VoiceAssist is now in the   requested state, false if activation failed (mic denied, speech service blocked,   etc.).
     * See {@link com.smartgwt.client.docs.Callback Callback}
     * @see com.smartgwt.client.util.VoiceAssist#enable
     */
    public static native void setActive(boolean active, String callback) /*-{
        $wnd.isc.VoiceAssist.setActive(active, callback);
    }-*/;
	

	/**
     * Sets the list of {@link com.smartgwt.client.util.VoiceAssist#cancelPhrases cancel phrases} that will abort an ongoing
     * recording when spoken.
     * @param cancelPhrases new cancel phrases
     * @see com.smartgwt.client.util.VoiceAssist#cancelPhrases
     */
    public static native void setCancelPhrases(String[] cancelPhrases) /*-{
        $wnd.isc.VoiceAssist.setCancelPhrases(@com.smartgwt.client.util.JSOHelper::convertToJavaScriptArray([Ljava/lang/Object;)(cancelPhrases));
    }-*/;


	/**
     * Begins command-dictation.  VoiceAssist locates a target component by walking up the parent chain from the currently
     * focused widget, looking for one that supports voice commands (see <code>supportsVoiceCommands()</code>).  The user's
     * speech is transcribed and forwarded to the target for execution. <p> Recording stops automatically after a period of
     * silence (see {@link com.smartgwt.client.util.VoiceAssist#autoStopDelay autoStopDelay}), or can be stopped explicitly via
     * {@link com.smartgwt.client.util.VoiceAssist#stopDictatingCommand stopDictatingCommand()}.  The user can also say a
     * {@link com.smartgwt.client.util.VoiceAssist#cancelPhrases cancel phrase} to discard the transcription. <p> Has no effect
     * if VoiceAssist is not {@link com.smartgwt.client.util.VoiceAssist#active active}, if {@link
     * com.smartgwt.client.util.VoiceAssist#canDictateCommands canDictateCommands} is false, or if a recording is already in
     * progress.
     * @see com.smartgwt.client.util.VoiceAssist#stopDictatingCommand
     * @see com.smartgwt.client.util.VoiceAssist#canDictateCommands
     * @see com.smartgwt.client.util.VoiceAssist#cancelRecording
     */
    public static native void startDictatingCommand() /*-{
        $wnd.isc.VoiceAssist.startDictatingCommand();
    }-*/;


	/**
     * Begins value-dictation for the currently focused {@link com.smartgwt.client.widgets.form.fields.FormItem}.  VoiceAssist
     * locates the focused item via {@link com.smartgwt.client.util.EventHandler}; if the focused item supports value-dictation
     * (currently {@link com.smartgwt.client.widgets.form.fields.TextItem} and {@link
     * com.smartgwt.client.widgets.form.fields.TextAreaItem}), the user's speech is transcribed and applied as the item's
     * value. <p> Recording stops automatically after a period of silence (see {@link
     * com.smartgwt.client.util.VoiceAssist#autoStopDelay autoStopDelay}), or can be stopped explicitly via {@link
     * com.smartgwt.client.util.VoiceAssist#stopDictatingValue stopDictatingValue()}.  The user can also say a {@link
     * com.smartgwt.client.util.VoiceAssist#cancelPhrases cancel phrase} to discard the transcription. <p> Has no effect if
     * VoiceAssist is not {@link com.smartgwt.client.util.VoiceAssist#active active}, if {@link
     * com.smartgwt.client.util.VoiceAssist#canDictateValues canDictateValues} is false, if no focused item supports
     * value-dictation, or if a recording is already in progress.
     * @see com.smartgwt.client.util.VoiceAssist#stopDictatingValue
     * @see com.smartgwt.client.util.VoiceAssist#canDictateValues
     * @see com.smartgwt.client.util.VoiceAssist#cancelRecording
     */
    public static native void startDictatingValue() /*-{
        $wnd.isc.VoiceAssist.startDictatingValue();
    }-*/;


	/**
     * Stops an ongoing command-dictation session normally, forwarding the transcribed text to the target component for
     * execution.  Has no effect if command-dictation is not currently in progress.
     * @see com.smartgwt.client.util.VoiceAssist#startDictatingCommand
     * @see com.smartgwt.client.util.VoiceAssist#cancelRecording
     */
    public static native void stopDictatingCommand() /*-{
        $wnd.isc.VoiceAssist.stopDictatingCommand();
    }-*/;


	/**
     * Stops an ongoing value-dictation session normally, applying the transcribed text to the target {@link
     * com.smartgwt.client.widgets.form.fields.FormItem}.  Has no effect if value-dictation is not currently in progress.
     * @see com.smartgwt.client.util.VoiceAssist#startDictatingValue
     * @see com.smartgwt.client.util.VoiceAssist#cancelRecording
     */
    public static native void stopDictatingValue() /*-{
        $wnd.isc.VoiceAssist.stopDictatingValue();
    }-*/;


	/**
     * Stops any ongoing recording session (value or command) normally, applying the transcribed text.  For value-dictation,
     * the text is set as the item's value; for command-dictation, the text is forwarded to the target component for execution.
     *
     * @return true if a recording was stopped, false if no recording was   in progress
     */
    public static native boolean stopRecording() /*-{
        var ret = $wnd.isc.VoiceAssist.stopRecording();
        return ret == null ? false : ret;
    }-*/;


    // ***********************************************************

}
