<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 4/14/2016 9:25 PM, Reto Merz wrote:<br>
    <blockquote cite="mid:570FE08A.9020005@abacus.ch" type="cite">This
      is a small part of our focus/validation framework.
      <br>
      I just try to explain it as simple as possible.
      <br>
      <br>
      javax.swing.InputVerifier gives only access to the source
      component.
      <br>
      <br>
      We need to know the target component.
      <br>
      <br>
      Would it be possible to overload verify(..) (or introduce another
      method) which has the "to"/target component as a argument too?
      <br>
    </blockquote>
    Yes. That is what I will be able to do. Something like:<br>
    <br>
    <meta http-equiv="content-type" content="text/html;
      charset=windows-1252">
      
    <meta http-equiv="content-type" content="text/html;
      charset=windows-1252">
    public boolean verifyTarget(JComponent input) {<br>
          return true;<br>
      }<br>
    <br>
      public boolean shouldYieldFocus(JComponent from, JComponent to) {<br>
        return shouldYieldFocus(from) && verifyTarget(to);<br>
      }<br>
    <br>
    --Semyon<br>
    <br>
    <blockquote cite="mid:570FE08A.9020005@abacus.ch" type="cite">
      <br>
      Thanks
      <br>
      Reto Merz
      <br>
      <br>
      <br>
      On 14.04.2016 16:52, Semyon Sadetsky wrote:
      <br>
      <blockquote type="cite">Thank for explanation.
        <br>
        It seems to me such functionality belongs to the input
        validation domain
        <br>
        and should not be mixed up with the Swing focus transfer
        internals.
        <br>
        Swing has javax.swing.InputVerifier which you could extend and
        set to
        <br>
        each component of your framework. I suppose it would be better
        design
        <br>
        choice for you because it decouples your code from the focus
        transfer
        <br>
        details which may be changed in future JDK releases. While the
        <br>
        javax.swing.InputVerifier functionality will be preserved.
        <br>
        <br>
        --Semyon
        <br>
        <br>
        On 4/14/2016 4:58 PM, Reto Merz wrote:
        <br>
        <blockquote type="cite">Exactly, the target can reject the focus
          transfer (and the source too).
          <br>
          All our UI components support "FocusRequestEnterExit"
          listeners
          <br>
          which has a requestEnter(EnterExitEvent) and
          requestExit(EnterExitEvent) method (among others
          focusGained/focusLost methods).
          <br>
          The EnterExitEvent has a reject() and accept() method.
          <br>
          <br>
          requestEnter is invoked on the target component and
          requestExit on the source component listeners.
          <br>
          The focus is only transferred after all source/target
          listeners have accept it.
          <br>
          This can be used for simple user input validation.
          <br>
          <br>
          It is far more complex because our RIA is ULC based
          (<a class="moz-txt-link-freetext" href="https://ulc.canoo.com/developerzone/technicalconcept.html">https://ulc.canoo.com/developerzone/technicalconcept.html</a>)
          <br>
          which split UI components into client- and server-side half
          objects,
          <br>
          but, basically this is how parts of our focus/validation
          framework works.
          <br>
          <br>
          Open Component#requestFocusInWindow(CausedFocusEvent.Cause)
          does not work
          <br>
          because this allows only conditional invoking
          super.requestFocusInWindow.
          <br>
          At this point it is not yet clear if the focus can be really
          transferred (see isRequestFocusAccepted).
          <br>
          And after super.requestFocusInWindow it is to late because
          <br>
          KeyboardFocusManager.setMostRecentFocusOwner is already
          invoked.
          <br>
          <br>
           From my point of view the best (and easiest to maintain)
          solution is
          <br>
          introducing a isRequestFocusAccepted() method which is invoked
          <br>
          by
          isRequestFocusAccepted(boolean,boolean,CausedFocusEvent.Cause)
          at the end.
          <br>
          So the new isRequestFocusAccepted makes the final decision to
          transfer focus or not.
          <br>
          Furthermore that dont require to make CausedFocusEvent.Cause
          public (which looks a bit creepy).
          <br>
          <br>
          Best Regards
          <br>
          Reto Merz
          <br>
          <br>
          <blockquote type="cite">On 14/04/16 14:49, Semyon Sadetsky
            wrote:
            <br>
            <br>
            Okay... You said the you need to intercept the focus request
            in the place
            <br>
            where the target is set.
            <br>
              From my point of view opening
            <br>
            Component#requestFocusInWindow(CausedFocusEvent.Cause cause)
            <br>
            resolves that.
            <br>
            But it looks like you need extra. What is the final purpose?
            Maybe you want
            <br>
            to reject focus transfer depending on the target?
            <br>
            <br>
            --Semyon
            <br>
            <br>
            On 4/14/2016 3:19 PM, Reto Merz wrote:
            <br>
            <blockquote type="cite">Thanks for your investigation
              Semyon.
              <br>
              <br>
              Make Component#requestFocusInWindow(CausedFocusEvent.Cause
              <br>
            </blockquote>
            cause) public/protected will not help us.
            <br>
            <blockquote type="cite">I can explain it more detailed if
              you want.
              <br>
              <br>
              What would help is to introduce a "protected boolean
              <br>
            </blockquote>
            Component#isRequestFocusAccepted()"
            <br>
            <blockquote type="cite">which is invoked by
              <br>
              <br>
            </blockquote>
Component#isRequestFocusAccepted(boolean,boolean,CausedFocusEvent.
            <br>
            Caus
            <br>
            <blockquote type="cite">e) after the
              "Component.requestFocusController.acceptRequestFocus"
              <br>
              statement (and only if acceptRequestFocus has returned
              true).
              <br>
              <br>
              This way you also don't have to make
              CausedFocusEvent.Cause public.
              <br>
              <br>
              Best Regards
              <br>
              Reto Merz
              <br>
              <br>
              On 14/04/16 13:09, Semyon Sadetsky wrote:
              <br>
              <br>
              The FocusTraversalPolicy can be obtained using public API.
              It may give you
              <br>
            </blockquote>
            the target. But I believe this is not what you would like to
            do...
            <br>
            <blockquote type="cite">It seem sensible to make
              <br>
            </blockquote>
            Component#requestFocusInWindow(CausedFocusEvent.Cause cause)
            <br>
            public. Will it be enough for you?
            <br>
            <blockquote type="cite">I could start to implement this
              right after the 8080395 push.
              <br>
              <br>
              --Semyon
              <br>
              <br>
              On 4/14/2016 12:30 PM, Reto Merz wrote:
              <br>
              Hello Semyon,
              <br>
              <br>
              We need to know the target component: "which component
              will be
              <br>
            </blockquote>
            focused".
            <br>
            <blockquote type="cite">Target component means the component
              which should be "really"
              <br>
            </blockquote>
            focused,
            <br>
            <blockquote type="cite">so this can only be known after all
              the FocusCycle / FocusTraversalPolicy
              <br>
            </blockquote>
            logic has processed.
            <br>
            <blockquote type="cite">DefaultKeyboardFocusManager
              <br>
            </blockquote>
            focusNextComponent/focusPreviousComponent
            <br>
            <blockquote type="cite">provides only the source component.
              Not the target.
              <br>
              <br>
              The second argument of
              RequestFocusController#acceptRequestFocus is
              <br>
            </blockquote>
            the "real" target component.
            <br>
            <blockquote type="cite">We use only this argument in our
              custom RequestFocusController
              <br>
            </blockquote>
            implementation.
            <br>
            <blockquote type="cite">Thanks
              <br>
              Reto Merz
              <br>
              <br>
              On 14/04/16 08:31, Semyon Sadetsky wrote:
              <br>
              Hi Reto,
              <br>
              <br>
              It is unlikely that AWTAccessor API may be opened. It
              gives access to
              <br>
            </blockquote>
            internal undocumented methods not to even mention that those
            methods
            <br>
            have private and package accesses.
            <br>
            <blockquote type="cite">As I understand you need the way to
              intercept focus transfer initiated by a
              <br>
            </blockquote>
            traversal key. Why to subclass the
            DefaultKeyboardFocusManager to
            <br>
            override its focusNextComponent/ focusPreviousComponent
            methods?
            <br>
            <blockquote type="cite">--Semyon
              <br>
              <br>
              On 4/12/2016 2:37 PM, Reto Merz wrote:
              <br>
              Hello Alexandr,
              <br>
              <br>
              Basically we need to detect and intercept focus changes.
              <br>
              <br>
              java.awt.Component allows to override this methods:
              <br>
              requestFocus()
              <br>
              requestFocus(boolean)
              <br>
              requestFocusInWindow()
              <br>
              requestFocusInWindow(boolean)
              <br>
              <br>
              requestFocus() is only invoked when the component is
              focused by a mouse
              <br>
            </blockquote>
            click.
            <br>
            <blockquote type="cite">But no requestFocus* method is
              invoked when a FocusTraversalPolicy is
              <br>
              involed (f. e. the user press TAB to focus next
              component).
              <br>
              <br>
              sun.awt.RequestFocusController#acceptRequestFocus is
              invoked in both
              <br>
            </blockquote>
            cases.
            <br>
            <blockquote type="cite">Attached a demo to reproduce it:
              <br>
              - if TextField is focused by a mouse click "requestFocus"
              and
              <br>
              "acceptRequestFocus" is logged
              <br>
              - if TextField is focused by TAB only "acceptRequestFocus"
              is logged
              <br>
              <br>
              Some more notes about the test program:
              <br>
              ComponentAccessorDelegator delegates all calls to the
              original
              <br>
            </blockquote>
            ComponentAccessor implementation.
            <br>
            <blockquote type="cite">Only
              ComponentAccessor#setRequestFocusController is changed to
              keep
              <br>
            </blockquote>
            our RequestFocusController implementation.
            <br>
            <blockquote type="cite">I have just filled a RFE
              onhttp://bugreport.java.com/bugreport
              <br>
              <br>
              Thanks
              <br>
              Reto Merz
              <br>
              <br>
              <br>
              On 11/04/16 21:02, Alexander Scherbatiy wrote:
              <br>
                 Hello Reto,
              <br>
              <br>
                 Could you provide use cases which illustrate tasks the
              requested API is
              <br>
            </blockquote>
            intended to solve in your application?
            <br>
            <blockquote type="cite">   Please, also create a request in
              the bug system
              <br>
              <a class="moz-txt-link-freetext" href="http://bugreport.java.com/bugreport">http://bugreport.java.com/bugreport</a>
              <br>
              <br>
                 Thanks,
              <br>
              Alexandr.
              <br>
              <br>
              On 11/04/16 12:26, Alexander Scherbatiy wrote:
              <br>
              <br>
                 Resending the request to awt-dev alias.
              <br>
              <br>
                 Thanks,
              <br>
                 Alexandr.
              <br>
              <br>
              On 4/4/2016 4:54 PM, Reto Merz wrote:
              <br>
              Hello,
              <br>
              <br>
              Jigsaw will disallow access to internal packages.
              <br>
              We have written a complex validation and focus management
              <br>
              implementation for our closed-source RIA and maintain it
              since JRE
              <br>
              1.4.
              <br>
              <br>
              For this we use some internal API. We have a custom
              implementation of
              <br>
              these interfaces:
              <br>
              <br>
              sun.awt.RequestFocusController
              <br>
              sun.awt.AWTAccessor.ComponentAccessor
              <br>
              <br>
              And use this getter and setter:
              <br>
              <br>
              <br>
            </blockquote>
sun.awt.AWTAccessor#setComponentAccessor(AWTAccessor.ComponentAc
            <br>
            cesso
            <br>
            <blockquote type="cite">r)
              <br>
              sun.awt.AWTAccessor#getComponentAccessor()
              <br>
              <br>
            </blockquote>
sun.awt.AWTAccessor.ComponentAccessor#setRequestFocusController(Req
            <br>
            ue
            <br>
            <blockquote type="cite">stFocusController)
              <br>
              <br>
              <br>
              Please make this API public.
              <br>
              <br>
              Furthermore we need to call
              <br>
              java.awt.Component#revalidateSynchronously().
              <br>
              We do this with reflection. It would be nice to have a
              public API for
              <br>
              this.
              <br>
              Maybe a new static method on AWTAccessor:
              <br>
              AWTAccessor.revalidateSynchronously(Component)
              <br>
              <br>
              Best Regards
              <br>
              Reto Merz
              <br>
              <br>
              <br>
              <br>
              <br>
              <br>
              <br>
              <br>
            </blockquote>
          </blockquote>
          <br>
        </blockquote>
        <br>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>