Author: tchemit Date: 2013-03-17 19:28:51 +0100 (Sun, 17 Mar 2013) New Revision: 2629 Url: http://nuiton.org/projects/jaxx/repository/revisions/2629 Log: fixes #2602: [JAXXHelper] Improve api Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2013-03-15 11:55:51 UTC (rev 2628) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2013-03-17 18:28:51 UTC (rev 2629) @@ -262,7 +262,7 @@ if (log.isDebugEnabled()) { log.debug("component traking " + comp.getName() + " : " + comp.getClass().getName()); } - comp = SwingUtil.getDeepestObjectAt(comp, event.getX(), event.getY()); + comp = getDeppestComponent(comp, event); if (log.isDebugEnabled()) { log.debug("deepest component " + comp.getName() + " : " + comp.getClass().getName()); } @@ -279,47 +279,6 @@ String helpID = findHelpId(comp); showHelp(context, helpID); } - - public String findHelpId(Component comp) { - String helpID = CSH.getHelpIDString(comp); - if (defaultID.equals(helpID)) { - String id = cache.get(comp); - // on verifie qu'on est bien sur sur le bon id - if (helpID.equals(id)) { - // ok - return helpID; - } - if (log.isDebugEnabled()) { - log.debug("will try to find better id for comp : " + comp.getName()); - } - // on est pas sur le bon id - // on recherche parmis les parents - helpID = findExtactHelpId(comp); - } - if (log.isInfoEnabled()) { - log.info("helpID " + helpID + " for comp " + comp.getName() + " : " + comp.getClass().getName()); - } - return helpID; - } - - protected String findExtactHelpId(Component comp) { - Container parent = comp.getParent(); - while (parent != null) { - String id = cache.get(parent); - if (id == null) { - // ce container n'a pas d'id - // on va directement sur le parent - parent = parent.getParent(); - continue; - } - // le parent possède un id - // on utilise cet id - return id; - } - // on a pas trouve d'id - // on retourne l'id par defaut - return defaultID; - } } protected AbstractButton getShowHelpButton(JAXXObject c) { @@ -330,6 +289,51 @@ return new ShowHelpForTrackedComponentAction(); } + protected Component getDeppestComponent(Component mouseComponent, MouseEvent event) { + return SwingUtil.getDeepestObjectAt2(mouseComponent, event.getX(), event.getY()); + } + + public String findHelpId(Component comp) { + String helpID = CSH.getHelpIDString(comp); + if (defaultID.equals(helpID)) { + String id = cache.get(comp); + // on verifie qu'on est bien sur sur le bon id + if (helpID.equals(id)) { + // ok + return helpID; + } + if (log.isDebugEnabled()) { + log.debug("will try to find better id for comp : " + comp.getName()); + } + // on est pas sur le bon id + // on recherche parmis les parents + helpID = findExtactHelpId(comp); + } + if (log.isInfoEnabled()) { + log.info("helpID " + helpID + " for comp " + comp.getName() + " : " + comp.getClass().getName()); + } + return helpID; + } + + protected String findExtactHelpId(Component comp) { + Container parent = comp.getParent(); + while (parent != null) { + String id = cache.get(parent); + if (id == null) { + // ce container n'a pas d'id + // on va directement sur le parent + parent = parent.getParent(); + continue; + } + // le parent possède un id + // on utilise cet id + return id; + } + // on a pas trouve d'id + // on retourne l'id par defaut + return defaultID; + } + //------------------------------------------------------------------------- //--- Copy CSH code but with accessible modifiers and little improvments //------------------------------------------------------------------------- @@ -584,7 +588,7 @@ return null; } - private static void dispatchEvent(AWTEvent event) { + protected static void dispatchEvent(AWTEvent event) { Object src = event.getSource(); if (event instanceof ActiveEvent) { // This could become the sole method of dispatching in time.
participants (1)
-
tchemit@users.nuiton.org