Ejemplo n.º 1
0
        public override void DisplayVisualTree()
        {
            if (!JavaAccNativeMethods._IsWindowsAccessBridgeAvailable)
            {
                JavaAccNativeMethods.LoadJavaAccessBridge();
                JavaAccNativeMethods.Windows_run();
                Trace.WriteLine("Initializing the java dda instance..");
                JavaAccHelperMethods.InitializeJavaAccessBridge(true);
                System.Windows.Forms.Application.DoEvents();
                System.Windows.Forms.Application.DoEvents();
                System.Windows.Forms.Application.DoEvents();
                System.Windows.Forms.Application.DoEvents();
                System.Windows.Forms.Application.DoEvents();
            }
            int vmId = 0;

            System.IntPtr accFromWindow = JavaAccHelperMethods.GetAccFromWindow(rootWindow, out vmId);
            jtvm = new JavaTreeViewModel(new JavaWindow(null, accFromWindow, vmId));
            if (w != null)
            {
                w.Closing -= W_Closing;
                avv        = null;
                w          = null;
            }
            avv = new ApplicationVisualViewer(ApplicationName);
            avv.LoadTree(jtvm);
            w          = new Window();
            w.Closing += W_Closing;
            w.Content  = avv;
            w.Show();
        }
Ejemplo n.º 2
0
 public override void Initialize()
 {
     try
     {
         JavaAccNativeMethods.LoadJavaAccessBridge();
         JavaAccNativeMethods.Windows_run();
         JavaAccNativeMethods._IsWindowsAccessBridgeAvailable = true;
     }
     catch (Exception ex)
     {
         LogWriter.Log(ex);
     }
     try
     {
         int num;
         JavaAccHelperMethods.GetAccFromWindow(rootWindow, out num);
         System.Windows.Forms.Application.DoEvents();
         Trace.WriteLine("Initializing the java dda instance..");
         JavaAccHelperMethods.InitializeJavaAccessBridge(true);
         //this.JavaAccEventListenerInstallTimer = new System.Threading.Timer(new System.Threading.TimerCallback(this.InstallAccEventListener_TimerCallback), null, (int)(-1), 0);
     }
     catch
     {
     }
 }
Ejemplo n.º 3
0
        public override LookupRequestItem GetValue(IUSDAutomationObject automationObject)
        {
            /*
             * <Controls>
             *  <JAccControl name="clickme">
             *      <Path>
             *      <NextName offset = "1">Click Me</NextName>
             *      </Path>
             *  </JAccControl>
             *  <JAccControl name="textbox">
             *      <Path>
             *      <NextRole offset = "0">text</NextRole>
             *      </Path>
             *  </JAccControl>
             * </Controls>
             */

            if (!JavaAccNativeMethods._IsWindowsAccessBridgeAvailable)
            {
                throw new Exception("Java Bridge not available");
            }
            if (!(automationObject is JavaAutomationObject))
            {
                throw new Exception("Invalid automation object");
            }
            string controlValue = String.Empty;

            controlValue = JavaAccHelperMethods.GetValue(((JavaAutomationObject)automationObject).zero, ((JavaAutomationObject)automationObject).vmId);
            return(new LookupRequestItem(((JavaAutomationObject)automationObject).name, controlValue));
        }
Ejemplo n.º 4
0
        public override void SetValue(IUSDAutomationObject automationObject, string value)
        {
            if (!JavaAccNativeMethods._IsWindowsAccessBridgeAvailable)
            {
                throw new Exception("Java Bridge not available");
            }
            if (!(automationObject is JavaAutomationObject))
            {
                throw new Exception("Invalid automation object");
            }

            JavaAccHelperMethods.SetValue(((JavaAutomationObject)automationObject).zero, ((JavaAutomationObject)automationObject).vmId, value);
            System.Windows.Forms.Application.DoEvents();
        }
Ejemplo n.º 5
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    JavaAccHelperMethods.ReleaseObject(zero, vmId);
                    System.Windows.Forms.Application.DoEvents();
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Ejemplo n.º 6
0
        public override void Execute(IUSDAutomationObject automationObject, string action)
        {
            if (!JavaAccNativeMethods._IsWindowsAccessBridgeAvailable)
            {
                throw new Exception("Java Bridge not available");
            }
            if (!(automationObject is JavaAutomationObject))
            {
                throw new Exception("Invalid automation object");
            }

            int failure;

            JavaAccHelperMethods.DoAction(((JavaAutomationObject)automationObject).zero, out failure, ((JavaAutomationObject)automationObject).vmId, false, action);
            System.Windows.Forms.Application.DoEvents();
        }
 static JavaAccEventListener()
 {
     try
     {
         Trace.WriteLine("Loading java event listener..");
         System.AppDomain.CurrentDomain.DomainUnload += new System.EventHandler(JavaAccEventListener.CurrentDomain_DomainUnload);
         Trace.WriteLine("Initializing java event handlers..");
         SetJavaEventHandlers();
         SetAccEventHandlers();
         SetEventHandlers();
     }
     catch (System.Exception exception)
     {
         if (!JavaAccHelperMethods.IsJavaAccException(exception) || !JavaAccHelperMethods.IsJavaAccExceptionMaskable(exception))
         {
             throw new Uii.HostedApplicationToolkit.DataDrivenAdapter.DataDrivenAdapterException("Java listener init failed", exception);
         }
     }
 }
Ejemplo n.º 8
0
        /*
         *
         *
         * private string AccControl(OperationType op, string controlName, string controlValue)
         * {
         *  int vmId = 0;
         *  System.IntPtr zero = System.IntPtr.Zero;
         * //    try
         * //    {
         * //        int num2;
         * //        switch (op)
         * //        {
         * //            case OperationType.FindControl:
         * //                zero = this.FindAccObj(controlName, out vmId, false);
         * //                if (zero.Equals((System.IntPtr)System.IntPtr.Zero))
         * //                {
         * //                    return bool.FalseString;
         * //                }
         * //                return bool.TrueString;
         *
         * //            case OperationType.GetControlValue:
         * //                zero = this.FindAccObj(controlName, out vmId, true);
         * //                return JavaAccHelperMethods.GetValue(zero, vmId);
         *
         * //            case OperationType.SetControlValue:
         * //                zero = this.FindAccObj(controlName, out vmId, true);
         * //                JavaAccHelperMethods.SetValue(zero, vmId, controlValue);
         * //                return null;
         *
         * //            case OperationType.ExecuteControlAction:
         * //                zero = this.FindAccObj(controlName, out vmId, true);
         * //                if (!System.Threading.Thread.CurrentThread.CurrentCulture.Name.StartsWith(JavaDataDrivenAdapterConstants.FRENCH_CULTURE_TEXT, System.StringComparison.OrdinalIgnoreCase))
         * //                {
         * //                    break;
         * //                }
         * //                JavaAccHelperMethods.DoAction(zero, out num2, vmId, false, JavaDataDrivenAdapterConstants.FRENCH_DEFAULT_ACTION_NAME);
         * //                goto Label_00D6;
         *
         * //            default:
         * //                goto Label_00E4;
         * //        }
         * //        JavaAccHelperMethods.DoAction(zero, out num2, vmId, true, string.Empty);
         * //    Label_00D6:
         * //        return null;
         * //    }
         * //    finally
         * //    {
         * //        JavaAccHelperMethods.ReleaseObject(zero, vmId);
         * //    }
         * //Label_00E4:
         *  return null;
         * }
         *
         * private string AccHyperlink(OperationType op, string controlName, string controlValue)
         * {
         *  int vmId = 0;
         *  System.IntPtr zero = System.IntPtr.Zero;
         *  //try
         *  //{
         *  //    switch (op)
         *  //    {
         *  //        case OperationType.FindControl:
         *  //            zero = this.FindAccObj(controlName, out vmId, false);
         *  //            if (zero.Equals((System.IntPtr)System.IntPtr.Zero))
         *  //            {
         *  //                return bool.FalseString;
         *  //            }
         *  //            return bool.TrueString;
         *
         *  //        case OperationType.GetControlValue:
         *  //            zero = this.FindAccObj(controlName, out vmId, true);
         *  //            return JavaAccHelperMethods.GetAccHyperlink(zero, vmId);
         *
         *  //        case OperationType.SetControlValue:
         *  //            zero = this.FindAccObj(controlName, out vmId, true);
         *  //            JavaAccHelperMethods.ActivateAccHyperlink(zero, vmId);
         *  //            return null;
         *
         *  //        case OperationType.ExecuteControlAction:
         *  //            int num2;
         *  //            zero = this.FindAccObj(controlName, out vmId, true);
         *  //            if (!JavaAccHelperMethods.DoAction(zero, out num2, vmId, true, string.Empty))
         *  //            {
         *  //                return bool.FalseString;
         *  //            }
         *  //            return bool.TrueString;
         *  //    }
         *  //}
         *  //finally
         *  //{
         *  //    JavaAccHelperMethods.ReleaseObject(zero, vmId);
         *  //}
         *  return null;
         * }
         *
         * private string AccSelector(OperationType op, string controlName, string controlValue)
         * {
         *  int vmId = 0;
         *  System.IntPtr zero = System.IntPtr.Zero;
         *  //try
         *  //{
         *  //    switch (op)
         *  //    {
         *  //        case OperationType.FindControl:
         *  //            zero = this.FindAccObj(controlName, out vmId, false);
         *  //            if (zero.Equals((System.IntPtr)System.IntPtr.Zero))
         *  //            {
         *  //                return bool.FalseString;
         *  //            }
         *  //            return bool.TrueString;
         *
         *  //        case OperationType.GetControlValue:
         *  //            zero = this.FindAccObj(controlName, out vmId, true);
         *  //            return JavaAccHelperMethods.GetAccSelectionName(zero, vmId);
         *
         *  //        case OperationType.SetControlValue:
         *  //            zero = this.FindAccObj(controlName, out vmId, true);
         *  //            JavaAccHelperMethods.SetAccSelection(zero, vmId, controlValue);
         *  //            return null;
         *
         *  //        case OperationType.ExecuteControlAction:
         *  //            int num2;
         *  //            zero = this.FindAccObj(controlName, out vmId, true);
         *  //            JavaAccHelperMethods.DoAction(zero, out num2, vmId, false, JavaDataDrivenAdapterConstants.TOGGLE_POPUP_ACTION_NAME);
         *  //            return null;
         *  //    }
         *  //}
         *  //catch (System.ArgumentException)
         *  //{
         *  //    throw new DataDrivenAdapterException("Incorrect control value format");
         *  //}
         *  //finally
         *  //{
         *  //    JavaAccHelperMethods.ReleaseObject(zero, vmId);
         *  //}
         *  return null;
         * }
         *
         * private string AccTable(OperationType op, string controlName, string controlValue)
         * {
         *  int vmId = 0;
         *  System.IntPtr zero = System.IntPtr.Zero;
         *  //try
         *  //{
         *  //    switch (op)
         *  //    {
         *  //        case OperationType.FindControl:
         *  //            zero = this.FindAccObj(controlName, out vmId, false);
         *  //            if (zero.Equals((System.IntPtr)System.IntPtr.Zero))
         *  //            {
         *  //                return bool.FalseString;
         *  //            }
         *  //            return bool.TrueString;
         *
         *  //        case OperationType.GetControlValue:
         *  //            zero = this.FindAccObj(controlName, out vmId, true);
         *  //            return JavaAccHelperMethods.GetAccTableCellValue(zero, vmId, controlValue);
         *
         *  //        case OperationType.SetControlValue:
         *  //            zero = this.FindAccObj(controlName, out vmId, true);
         *  //            JavaAccHelperMethods.SetAccTableCellValue(zero, vmId, controlName, controlValue);
         *  //            return null;
         *  //    }
         *  //}
         *  //catch (System.ArgumentException)
         *  //{
         *  //    throw new DataDrivenAdapterException("Incorrect control value format");
         *  //}
         *  //finally
         *  //{
         *  //    JavaAccHelperMethods.ReleaseObject(zero, vmId);
         *  //}
         *  return null;
         * }
         *
         * private string AccTree(OperationType op, string controlName, string controlValue)
         * {
         *  int vmId = 0;
         *  System.IntPtr zero = System.IntPtr.Zero;
         *  //try
         *  //{
         *  //    switch (op)
         *  //    {
         *  //        case OperationType.FindControl:
         *  //            zero = this.FindAccObj(controlName, out vmId);
         *  //            if (zero.Equals((System.IntPtr)System.IntPtr.Zero))
         *  //            {
         *  //                return bool.FalseString;
         *  //            }
         *  //            return bool.TrueString;
         *
         *  //        case OperationType.GetControlValue:
         *  //            zero = this.FindAccObj(controlName, out vmId);
         *  //            return JavaAccHelperMethods.GetAccSelectionName(zero, vmId);
         *
         *  //        case OperationType.SetControlValue:
         *  //            zero = this.FindAccObj(controlName, out vmId);
         *  //            JavaAccHelperMethods.SetAccSelection(zero, vmId, controlValue);
         *  //            return null;
         *
         *  //        case OperationType.ExecuteControlAction:
         *  //            int num2;
         *  //            zero = this.FindAccObj(controlName, out vmId);
         *  //            JavaAccHelperMethods.DoAction(zero, out num2, vmId, false, JavaDataDrivenAdapterConstants.TOGGLE_EXPAND_ACTION_NAME);
         *  //            return null;
         *  //    }
         *  //}
         *  //catch (System.ArgumentException)
         *  //{
         *  //    throw new DataDrivenAdapterException("Incorrect control value format");
         *  //}
         *  //finally
         *  //{
         *  //    JavaAccHelperMethods.ReleaseObject(zero, vmId);
         *  //}
         *  return null;
         * }
         */
        protected System.IntPtr JavaFindAccObj(string controlName, out int vmId, string controlXml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(controlXml);
            XmlNode firstDescendentUnderControlConfig = doc.SelectSingleNode("//Path");

            if (firstDescendentUnderControlConfig == null)
            {
                throw new DataDrivenAdapterException(OperationType.FindControl, controlName, "No Path element found");
            }
            //if (_NeedToCallWindowsRun)
            //{
            //    JavaAccNativeMethods.Windows_run();
            //    _NeedToCallWindowsRun = false;
            //    System.Windows.Forms.Application.DoEvents();
            //}
            System.IntPtr accFromWindow = JavaAccHelperMethods.GetAccFromWindow(rootWindow, out vmId);
            string        defaultValue  = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();

            for (XmlNode node2 = firstDescendentUnderControlConfig.FirstChild; node2 != null; node2 = node2.NextSibling)
            {
                int  num;
                int  num2;
                bool flag;
                switch (node2.Name)
                {
                case "FindWindow":
                    accFromWindow = JavaAccHelperMethods.GetAccFromWindow(this.FindWindowFromControlName(controlName, true), out vmId);
                    break;

                case "Next":
                case "NextName":
                    num  = GetAttributeValue(node2, "match", 1);
                    num2 = GetAttributeValue(node2, "offset", 0);
                    flag = false;
                    if (GetAttributeValue(node2, "culture", defaultValue).Equals(defaultValue, System.StringComparison.OrdinalIgnoreCase))
                    {
                        if (num <= 0)
                        {
                            accFromWindow = System.IntPtr.Zero;
                        }
                        else
                        {
                            accFromWindow = JavaAccHelperMethods.GetNextChildByName(node2.InnerText, ref num, num2, ref flag, accFromWindow, vmId);
                        }
                    }
                    break;

                case "NextRole":
                    num  = GetAttributeValue(node2, "match", 1);
                    num2 = GetAttributeValue(node2, "offset", 0);
                    flag = false;
                    if (GetAttributeValue(node2, "culture", defaultValue).Equals(defaultValue, System.StringComparison.OrdinalIgnoreCase))
                    {
                        if (num <= 0)
                        {
                            accFromWindow = System.IntPtr.Zero;
                        }
                        else
                        {
                            accFromWindow = JavaAccHelperMethods.GetNextChildByRole(node2.InnerText, ref num, num2, ref flag, accFromWindow, vmId);
                        }
                    }
                    break;

                default:
                    throw new DataDrivenAdapterException("Unsupported path element");
                }
                if (accFromWindow.Equals((System.IntPtr)System.IntPtr.Zero))
                {
                    break;
                }
            }
            if (accFromWindow.Equals((System.IntPtr)System.IntPtr.Zero))
            {
                throw new DataDrivenAdapterException("Unable to find control on UI");
            }
            //this.KnownControls.RegisterControl(controlName, accFromWindow, vmId);
            return(accFromWindow);
        }
        private static void FireEvent <T>(System.IntPtr source, string eventName, System.IntPtr jEvent, int vmId, T oldObject, T newObject)
        {
            System.Type type = null;
            try
            {
                if (JavaControlChanged != null)
                {
                    if (eventName.Equals(JavaDataDrivenAdapterConstants.PropertyStateChangedEventName, System.StringComparison.OrdinalIgnoreCase))
                    {
                        switch (JavaAccHelperMethods.GetRoleID(source, vmId))
                        {
                        case 1:
                            FireCheckBoxEvents <T>(source, vmId, oldObject, newObject);
                            break;

                        case 2:
                            FireRadioButtonEvents <T>(source, vmId, oldObject, newObject);
                            break;

                        case 5:
                            FireTreeNodeEvents <T>(source, vmId, oldObject, newObject);
                            break;
                        }
                    }
                    else if (eventName.Equals(JavaDataDrivenAdapterConstants.MousePressedEventName, System.StringComparison.OrdinalIgnoreCase))
                    {
                        if (JavaAccHelperMethods.GetRoleID(source, vmId) == 0)
                        {
                            FireControlChangedEvent(source, vmId, JavaDataDrivenAdapterConstants.ButtonPressedEventName);
                        }
                    }
                    else if (eventName.Equals(JavaDataDrivenAdapterConstants.MouseReleasedEventName, System.StringComparison.OrdinalIgnoreCase))
                    {
                        if (JavaAccHelperMethods.GetRoleID(source, vmId) == 0)
                        {
                            FireControlChangedEvent(source, vmId, JavaDataDrivenAdapterConstants.ButtonReleasedEventName);
                        }
                    }
                    else if ((eventName.Equals(JavaDataDrivenAdapterConstants.GotFocusEventName, System.StringComparison.OrdinalIgnoreCase) || eventName.Equals(JavaDataDrivenAdapterConstants.LostFocusEventName, System.StringComparison.OrdinalIgnoreCase)) || ((eventName.Equals(JavaDataDrivenAdapterConstants.MenuSelectedEventName, System.StringComparison.OrdinalIgnoreCase) || eventName.Equals(JavaDataDrivenAdapterConstants.MenuDeSelectedEventName, System.StringComparison.OrdinalIgnoreCase)) || eventName.Equals(JavaDataDrivenAdapterConstants.MenuCanceledEventName, System.StringComparison.OrdinalIgnoreCase)))
                    {
                        FireControlChangedEvent(source, vmId, eventName);
                    }
                }
                if (JavaAccEventOccurred != null)
                {
                    type = (oldObject == null) ? typeof(object) : oldObject.GetType();
                    FireAccEvent <T>(source, eventName, vmId, type, oldObject, newObject);
                }
            }
            catch (System.Exception exception)
            {
                if (!JavaAccHelperMethods.IsJavaAccException(exception) || !JavaAccHelperMethods.IsJavaAccExceptionMaskable(exception))
                {
                    Trace.WriteLine("An error occurred while listening to java events..");
                }
            }
            finally
            {
                JavaAccHelperMethods.ReleaseObject(source, vmId);
                JavaAccHelperMethods.ReleaseObject(jEvent, vmId);
                if (((System.IntPtr)source).GetType().Equals(type))
                {
                    object obj2 = oldObject;
                    object obj3 = newObject;
                    JavaAccHelperMethods.ReleaseObject((System.IntPtr)((System.IntPtr)obj2), vmId);
                    JavaAccHelperMethods.ReleaseObject((System.IntPtr)((System.IntPtr)obj3), vmId);
                }
            }
        }