r2766 - in trunk: jaxx-demo jaxx-demo/src/main/filters jaxx-demo/src/main/java/jaxx/demo jaxx-demo/src/main/java/jaxx/demo/component/swing jaxx-demo/src/main/resources jaxx-demo/src/main/resources/i18n jaxx-runtime/src/main/java/jaxx/runtime jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor jaxx-runtime/src/main/java/jaxx/runtime/swing/help
Author: tchemit Date: 2014-01-10 17:52:31 +0100 (Fri, 10 Jan 2014) New Revision: 2766 Url: http://nuiton.org/projects/jaxx/repository/revisions/2766 Log: fixes #2999: Can't get the correct component with GetCompopentAtPointVisitor Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoApplicationContext.java trunk/jaxx-demo/src/main/java/jaxx/demo/DemoHelpBroker.java trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.css trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.css trunk/jaxx-demo/src/main/resources/jaxxdemo-help-fr.properties trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/DebugComponentTreeNodeVisitor.java Modified: trunk/jaxx-demo/pom.xml trunk/jaxx-demo/src/main/filters/jaxx-demo.properties trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_en_GB.properties trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_es_ES.properties trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_fr_FR.properties trunk/jaxx-demo/src/main/resources/log4j.properties trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/ComponentTreeNode.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/GetCompopentAtPointVisitor.java trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java Modified: trunk/jaxx-demo/pom.xml =================================================================== --- trunk/jaxx-demo/pom.xml 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/pom.xml 2014-01-10 16:52:31 UTC (rev 2766) @@ -48,7 +48,16 @@ <jaxx.autoImportCss>true</jaxx.autoImportCss> <jaxx.autoRecurseInCss>false</jaxx.autoRecurseInCss> <jaxx.addAutoHandlerUI>true</jaxx.addAutoHandlerUI> + <jaxx.generateHelp>true</jaxx.generateHelp> + <!-- jaxx help configuration --> + <jaxx.helpsetName>tutti</jaxx.helpsetName> + <jaxx.locales>fr</jaxx.locales> + <jaxx.mergeIdsToInput>true</jaxx.mergeIdsToInput> + <jaxx.inputHelpDirectory>src/main/resources</jaxx.inputHelpDirectory> + <jaxx.inputHelpFilenamePrefix>jaxxdemo-help</jaxx.inputHelpFilenamePrefix> + <jaxx.helpBrokerFQN>jaxx.demo.DemoHelpBroker</jaxx.helpBrokerFQN> + <!-- generate license bundled files --> <license.generateBundle>true</license.generateBundle> @@ -231,6 +240,7 @@ <execution> <goals> <goal>generate</goal> + <goal>generate-help-ids</goal> </goals> </execution> </executions> Modified: trunk/jaxx-demo/src/main/filters/jaxx-demo.properties =================================================================== --- trunk/jaxx-demo/src/main/filters/jaxx-demo.properties 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/filters/jaxx-demo.properties 2014-01-10 16:52:31 UTC (rev 2766) @@ -32,3 +32,4 @@ #licence.url=${project.licenses.0.url} application.organisation.name=${project.organization.name} application.organisation.url=${project.organization.url} +application.help.path=http://maven-site.nuiton.org/jaxx/jaxx-demo/help Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoApplicationContext.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoApplicationContext.java (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoApplicationContext.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -0,0 +1,152 @@ +package jaxx.demo; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXUtil; +import jaxx.runtime.context.DefaultApplicationContext; +import jaxx.runtime.context.JAXXContextEntryDef; +import jaxx.runtime.swing.help.JAXXHelpBroker; +import jaxx.runtime.swing.help.JAXXHelpUIHandler; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.InputStream; +import java.net.URI; +import java.util.Properties; + +import static org.nuiton.i18n.I18n._; + +/** + * Created on 1/9/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since XXX + */ +public class DemoApplicationContext extends DefaultApplicationContext implements JAXXHelpUIHandler { + + static final JAXXContextEntryDef<DemoUI> MAIN_UI = + JAXXUtil.newContextEntryDef("MainUI", DemoUI.class); + + /** The singleton instance of the main context */ + private static volatile DemoApplicationContext context; + + /** Logger. */ + private static final Log log = LogFactory.getLog(DemoApplicationContext.class); + + /** + * @return <code>true</code> si le context a été initialisé via la méthode + * {@link #init(DemoConfig)}, <ocde>false</code> autrement. + */ + protected static boolean isInit() { + return context != null; + } + + /** + * Permet l'initialisation du contexte applicatif et positionne + * l'context partagée. + * <p/> + * Note : Cette méthode ne peut être appelée qu'une seule fois. + * + * @param config application config + * @return le context partagée + * @throws IllegalStateException si un contexte applicatif a déja été positionné. + */ + protected static DemoApplicationContext init(DemoConfig config) throws IllegalStateException { + if (isInit()) { + throw new IllegalStateException("there is an already application context registred."); + } + context = new DemoApplicationContext(config); + return context; + } + + /** + * Récupération du contexte applicatif. + * + * @return l'context partagé du contexte. + * @throws IllegalStateException si le contexte n'a pas été initialisé via + * la méthode {@link #init(DemoConfig)} + */ + public static DemoApplicationContext get() throws IllegalStateException { + if (!isInit()) { + throw new IllegalStateException("no application context registred."); + } + return context; + } + + public DemoApplicationContext(DemoConfig config) { + + // share config + setContextValue(config); + + //--------------------------------------------------------------------// + // init help + //--------------------------------------------------------------------// + + // load help mapping + String mappingProperties = "/jaxxdemo-help-fr.properties"; + try { + + InputStream resourceAsStream = + getClass().getResourceAsStream(mappingProperties); + helpMapping = new Properties(); + helpMapping.load(resourceAsStream); + + } catch (Exception eee) { + log.error("Failed to load help mapping file at '" + + mappingProperties + "'", eee); + } + } + + public DemoConfig getConfig() { + return getContextValue(DemoConfig.class); + } + + private Properties helpMapping; + + @Override + public void showHelp(JAXXContext context, JAXXHelpBroker broker, String helpId) { + + if (helpId == null) { + helpId = broker.getDefaultID(); + } + + if (log.isInfoEnabled()) { + log.info("help-id: " + helpId); + } + + String value = (String) helpMapping.get(helpId); + + if (value == null) { + throw new RuntimeException(_("jaxxdemo.context.helpPage.notFound", helpId)); + } + + String helpDirectory = getConfig().getHelpResourceWithLocale(value); + boolean withFragment = helpDirectory.contains("#"); + + String fragment = null; + if (withFragment) { + fragment = StringUtils.substringAfter(helpDirectory, "#"); + helpDirectory = StringUtils.substringBefore(helpDirectory, "#"); + } + + URI resolvedUri = URI.create(helpDirectory); +// try { + + if (withFragment) { + resolvedUri = URI.create(resolvedUri.toString() + "#" + fragment); + } + if (log.isInfoEnabled()) { + log.info("help-uri: " + resolvedUri); + } +// SwingUtil.openLink(resolvedUri); +// } catch (URISyntaxException e) { +// throw new RuntimeException(_("jaxxdemo.context.helpPage.notFound", resolvedUri)); +// } + } + + public DemoUI getMainUI() { + + return MAIN_UI.getContextValue(this); + } + +} Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoApplicationContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -26,7 +26,7 @@ package jaxx.demo; import com.google.common.base.Supplier; -import jaxx.demo.feature.nav.NavDemo; +import jaxx.demo.component.swing.JButtonDemo; import jaxx.runtime.JAXXUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -357,6 +357,17 @@ return applicationConfig.getOption("application.third-party.path"); } + public String getHelpLocation() { + return applicationConfig.getOption("application.help.path"); + } + + public String getHelpResourceWithLocale(String value) { + String result = getHelpLocation() + "/" + + getLocale().getLanguage() + "/" + + value; + return result; + } + ////////////////////////////////////////////////// // Toutes les options disponibles ////////////////////////////////////////////////// @@ -430,7 +441,7 @@ DEMO_PATH( "ui.demo.path", _("jaxxdemo.config.ui.demo.path"), - "jaxxdemo.tree/jaxxdemo.tree.component.jaxx/jaxxdemo.tree.component.jaxx.tree/" + NavDemo.class.getSimpleName(), + "jaxxdemo.tree/jaxxdemo.component.swing/jaxxdemo.component.swing.buttons/" + JButtonDemo.class.getSimpleName(), String.class, false, true); Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoHelpBroker.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoHelpBroker.java (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoHelpBroker.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -0,0 +1,145 @@ +package jaxx.demo; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL: https://svn.forge.codelutin.com/svn/tutti/trunk/tutti-ui-swing/src/main/java... $ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.base.Preconditions; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.awt.visitor.BuildTreeVisitor; +import jaxx.runtime.awt.visitor.ComponentTreeNode; +import jaxx.runtime.awt.visitor.DebugComponentTreeNodeVisitor; +import jaxx.runtime.awt.visitor.GetCompopentAtPointVisitor; +import jaxx.runtime.swing.help.JAXXHelpBroker; +import jaxx.runtime.swing.help.JAXXHelpUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.AbstractButton; +import java.awt.Component; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; + +/** + * Help broker. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.1 + */ +public class DemoHelpBroker extends JAXXHelpBroker { + + /** Logger */ + private static final Log log = LogFactory.getLog(DemoHelpBroker.class); + + public DemoHelpBroker(String defaultID) { + super("tutti", "help", + defaultID, + DemoApplicationContext.get()); + } + + @Override + public void prepareUI(JAXXObject c) { + + Preconditions.checkNotNull(c, "parameter c can not be null!"); + + // l'ui doit avoir un boutton showHelp + AbstractButton help = getShowHelpButton(c); + + if (help != null) { + + // attach context to button + if (log.isDebugEnabled()) { + log.debug("attach context to showhelp button " + c); + } + help.putClientProperty(JAXX_CONTEXT_ENTRY, c); + + // add tracking action + ActionListener listener = getShowHelpAction(); + if (log.isDebugEnabled()) { + log.debug("adding tracking action " + listener); + } + help.addActionListener(listener); + + if (log.isDebugEnabled()) { + log.debug("done for " + c); + } + } + } + + @Override + public String findHelpId(Component comp) { + + if (comp == null) { + comp = DemoApplicationContext.get().getMainUI(); + } + JAXXHelpUI parentContainer = SwingUtil.getParent(comp, JAXXHelpUI.class); + + String result; + if (parentContainer != null && this != parentContainer.getBroker()) { + + JAXXHelpBroker broker = parentContainer.getBroker(); + result = broker.findHelpId(comp); + } else { + result = super.findHelpId(comp); + } + + if (result == null) { + result = "ui.main.menu"; + } + + return result; + } + + @Override + public Component getDeppestComponent(Component mouseComponent, MouseEvent event) { + ComponentTreeNode tree = BuildTreeVisitor.buildTree(mouseComponent); + + DebugComponentTreeNodeVisitor debugTree = new DebugComponentTreeNodeVisitor() { + @Override + public String getMessage(ComponentTreeNode componentTree) { + String message = super.getMessage(componentTree); + Component userObject = componentTree.getUserObject(); + Rectangle rectangle = new Rectangle(userObject.getLocationOnScreen(), userObject.getSize()); + return message + (userObject.isVisible() ? " visible" : "") + " - " + rectangle; + } + }; + + debugTree.setDebug(log.isDebugEnabled()); + + debugTree.parse(tree); + +// Point point = event.getPoint(); + Point point = event.getLocationOnScreen(); + + Component component = GetCompopentAtPointVisitor.get(tree, point); + if (log.isDebugEnabled()) { + log.debug("Component at (" + point + "): " + component); + } + return component; + } + + +} Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoHelpBroker.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2014-01-10 16:52:31 UTC (rev 2766) @@ -26,11 +26,14 @@ <JPanel id='top' abstract='true'> <import> + jaxx.demo.DemoHelpBroker org.nuiton.util.StringUtil </import> <script><![CDATA[ +//protected String getHelpDefaultId() { return "ui.main.menu"; } + protected String[] getSources() { if (DemoPanel.class.equals(getClass())) { return StringUtil.EMPTY_STRING_ARRAY; @@ -56,4 +59,8 @@ ]]> </script> + <String id='helpDefaultId' javaBean='"ui.main.menu"'/> + + <DemoHelpBroker id='broker' constructorParams='getHelpDefaultId()'/> + </JPanel> \ No newline at end of file Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.css =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.css (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.css 2014-01-10 16:52:31 UTC (rev 2766) @@ -0,0 +1,11 @@ +#editorPaneHeader { + _help:{"ui.main.sources.toolbar"}; +} + +#sourceTabs { + _help:{"ui.main.sources.list"}; +} + +#editor { + _help:{"ui.main.sources.editor"}; +} \ No newline at end of file Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2014-01-10 16:52:31 UTC (rev 2766) @@ -23,9 +23,10 @@ #L% --> -<JPanel layout='{new BorderLayout()}'> +<JPanel layout='{new BorderLayout()}' decorator='help'> <import> + jaxx.demo.DemoHelpBroker jaxx.runtime.SwingUtil jaxx.runtime.swing.FontSizor @@ -49,6 +50,8 @@ ]]> </script> + <DemoHelpBroker id='broker' constructorParams='"ui.main.sources"'/> + <Class id='incomingClass' javaBean='null' genericType='?'/> <String id='currentSource' javaBean='null'/> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2014-01-10 16:52:31 UTC (rev 2766) @@ -45,6 +45,7 @@ <DemoTreeHelper id='treeHelper' initializer='getContextValue(DemoTreeHelper.class)'/> + <DemoHelpBroker id='broker' constructorParams='"ui.main.menu"'/> <script><![CDATA[ @@ -86,6 +87,9 @@ onActionPerformed="handler.showAbout(this)"/> </JMenu> + <!-- pour afficher l'aide contextuelle --> + <JButton id='showHelp'/> + </JMenuBar> <JPanel id='mainPane' layout='{new BorderLayout()}'> Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -361,7 +361,7 @@ config.setFullscreen(fullscreen); // rechargement de l'ui - reloadUI(RunDemo.get(), config); + reloadUI(DemoApplicationContext.get(), config); } public void changeLanguage(JAXXContext context, Locale newLocale) { @@ -374,7 +374,7 @@ config.setLocale(newLocale); // rechargement de l'ui - reloadUI(RunDemo.get(), config); + reloadUI(DemoApplicationContext.get(), config); } /** @@ -400,7 +400,7 @@ if (log.isInfoEnabled()) { log.info("will reload ui"); } - DefaultApplicationContext context = RunDemo.get(); + DefaultApplicationContext context = DemoApplicationContext.get(); DemoUI ui = getUI(context); DemoConfig config = ui.getConfig(); reloadUI(context, config); @@ -414,7 +414,7 @@ if (log.isInfoEnabled()) { log.info("will reload appplication"); } - close(RunDemo.get()); + close(DemoApplicationContext.get()); } }; @@ -425,7 +425,7 @@ if (log.isInfoEnabled()) { log.info("will reload log appender"); } - DefaultApplicationContext context = RunDemo.get(); + DefaultApplicationContext context = DemoApplicationContext.get(); DemoUI ui = getUI(context); DemoConfig config = ui.getConfig(); @@ -503,6 +503,11 @@ helper.displayUI(ui, false); } + public void showHelp(DemoUI ui) { + + DemoApplicationContext.get().showHelp(ui, ui.getBroker(), null); + } + public void showHelp(JAXXContext context, String helpId) { log.info(context + " :: " + helpId); // DemoUI mainUI = getUI(context); Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -29,15 +29,14 @@ import jaxx.demo.tree.DemoDataProvider; import jaxx.demo.tree.DemoTreeHelper; import jaxx.runtime.SwingUtil; -import jaxx.runtime.context.DefaultApplicationContext; import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.log.JAXXLog4jUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.decorator.DecoratorProvider; import org.nuiton.i18n.I18n; import org.nuiton.i18n.init.DefaultI18nInitializer; import org.nuiton.util.StringUtil; -import org.nuiton.decorator.DecoratorProvider; import java.util.Arrays; import java.util.Date; @@ -50,9 +49,6 @@ /** Logger */ private static Log log = LogFactory.getLog(RunDemo.class); - /** The singleton instance of the main context */ - protected static volatile DefaultApplicationContext context; - public static void main(String[] args) { long startingTime = System.nanoTime(); @@ -72,16 +68,15 @@ Runtime.getRuntime().addShutdownHook(new ShutdownHook()); + // init config + DemoConfig config = new DemoConfig(args); + // init root context - DefaultApplicationContext rootContext = init(); + DemoApplicationContext rootContext = DemoApplicationContext.init(config); // share a tree helper rootContext.setContextValue(new DemoTreeHelper(new DemoDataProvider())); - // init config - DemoConfig config = new DemoConfig(args); - - // share the config rootContext.setContextValue(config); @@ -131,6 +126,8 @@ log.info(_("jaxxdemo.init.ui.done")); + DemoApplicationContext.MAIN_UI.setContextValue(rootContext, ui); + handler.displayUI(ui, config.getDemoPath().split("/")); } catch (Exception e) { @@ -140,45 +137,6 @@ } } - /** - * @return <code>true</code> si le context a été initialisé via la méthode - * {@link #init()}, <ocde>false</code> autrement. - */ - protected static boolean isInit() { - return context != null; - } - - /** - * Permet l'initialisation du contexte applicatif et positionne - * l'context partagée. - * <p/> - * Note : Cette méthode ne peut être appelée qu'une seule fois. - * - * @return l'context partagée - * @throws IllegalStateException si un contexte applicatif a déja été positionné. - */ - protected static DefaultApplicationContext init() throws IllegalStateException { - if (isInit()) { - throw new IllegalStateException("there is an already application context registred."); - } - context = new DefaultApplicationContext(); - return context; - } - - /** - * Récupération du contexte applicatif. - * - * @return l'context partagé du contexte. - * @throws IllegalStateException si le contexte n'a pas été initialisé via - * la méthode {@link #init()} - */ - public static DefaultApplicationContext get() throws IllegalStateException { - if (!isInit()) { - throw new IllegalStateException("no application context registred."); - } - return context; - } - protected static class ShutdownHook extends Thread { public ShutdownHook() { Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.css =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.css (rev 0) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.css 2014-01-10 16:52:31 UTC (rev 2766) @@ -0,0 +1,11 @@ +#topDemoPanel { + _help:{"ui.component.swing.buttons.JButtonDemo"}; +} + +#simpleButon { + _help:{"ui.component.swing.buttons.JButtonDemo.simpleButon"}; +} + +#fancyButon { + _help:{"ui.component.swing.buttons.JButtonDemo.fancyButon"}; +} \ No newline at end of file Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx =================================================================== --- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2014-01-10 16:52:31 UTC (rev 2766) @@ -23,7 +23,7 @@ #L% --> -<jaxx.demo.DemoPanel> +<jaxx.demo.DemoPanel id='topDemoPanel' decorator='help'> <style> JButton.fancy { foreground: blue; @@ -50,13 +50,15 @@ java.awt.Color </import> + <String id='helpDefaultId' initializer='"ui.component.swing.buttons.JButtonDemo"'/> + <javax.swing.ImageIcon id='pencil' constructorParams='getClass().getResource("/jaxx/demo/images/pencil_black.gif")'/> <VBox horizontalAlignment='center' verticalAlignment='middle'> - <JButton text='Simple Button' + <JButton id='simpleButon' text='Simple Button' onActionPerformed='buttonClicked((JButton) event.getSource())'/> - <JButton text='Fancy Button' styleClass='fancy' icon='{pencil}' + <JButton id='fancyButon' text='Fancy Button' styleClass='fancy' icon='{pencil}' onActionPerformed='buttonClicked((JButton) event.getSource())'/> </VBox> </jaxx.demo.DemoPanel> Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_en_GB.properties =================================================================== --- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_en_GB.properties 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_en_GB.properties 2014-01-10 16:52:31 UTC (rev 2766) @@ -175,6 +175,7 @@ jaxxdemo.action.normalscreen.tip=Change to normal screen mode jaxxdemo.action.remove=Remove jaxxdemo.action.show=show +jaxxdemo.action.showHelp.tip= jaxxdemo.action.showLogs=Show logs jaxxdemo.action.showLogs.mnemonic=S jaxxdemo.action.site=Web site @@ -235,6 +236,7 @@ jaxxdemo.config.ui.locale=Language used in application jaxxdemo.config.ui.logLevel=Log level jaxxdemo.config.ui.logPatternLayout=Log pattern +jaxxdemo.context.helpPage.notFound= jaxxdemo.coordinate.latitude= jaxxdemo.coordinate.latitudeDd= jaxxdemo.coordinate.latitudeDmd= @@ -333,5 +335,6 @@ t0.isSelected()\ &&\ t1.isSelected()= t0.isSelected()\ ||\ t1.isSelected()= t1.isSelected()= +tutti.context.helpPage.notFound= valid= x= Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_es_ES.properties =================================================================== --- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_es_ES.properties 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_es_ES.properties 2014-01-10 16:52:31 UTC (rev 2766) @@ -176,6 +176,7 @@ jaxxdemo.action.normalscreen.tip=Revenir en mode normal jaxxdemo.action.remove=Supprimer jaxxdemo.action.show=Voir +jaxxdemo.action.showHelp.tip= jaxxdemo.action.showLogs= jaxxdemo.action.showLogs.mnemonic= jaxxdemo.action.site=Site internet @@ -236,6 +237,7 @@ jaxxdemo.config.ui.locale=La langue utilisée par l'application jaxxdemo.config.ui.logLevel=Level de log jaxxdemo.config.ui.logPatternLayout=Pattern des log +jaxxdemo.context.helpPage.notFound= jaxxdemo.coordinate.latitude= jaxxdemo.coordinate.latitudeDd= jaxxdemo.coordinate.latitudeDmd= @@ -336,6 +338,7 @@ t0.isSelected()\ &&\ t1.isSelected()= t0.isSelected()\ ||\ t1.isSelected()= t1.isSelected()= +tutti.context.helpPage.notFound= tutti.menu.file.mnemonic= tutti.menu.help.mnemonic= valid=valide Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_fr_FR.properties =================================================================== --- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_fr_FR.properties 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo_fr_FR.properties 2014-01-10 16:52:31 UTC (rev 2766) @@ -175,6 +175,7 @@ jaxxdemo.action.normalscreen.tip=Revenir en mode normal jaxxdemo.action.remove=Supprimer jaxxdemo.action.show=Voir +jaxxdemo.action.showHelp.tip= jaxxdemo.action.showLogs=Afficher les logs jaxxdemo.action.showLogs.mnemonic=l jaxxdemo.action.site=Site internet @@ -235,6 +236,7 @@ jaxxdemo.config.ui.locale=La langue utilisée par l'application jaxxdemo.config.ui.logLevel=Level de log jaxxdemo.config.ui.logPatternLayout=Pattern des log +jaxxdemo.context.helpPage.notFound= jaxxdemo.coordinate.latitude=Latitude jaxxdemo.coordinate.latitudeDd=Latitude (au format DD) jaxxdemo.coordinate.latitudeDmd=Latitude (au format DMD) @@ -328,5 +330,6 @@ t0.isSelected()\ &&\ t1.isSelected()= t0.isSelected()\ ||\ t1.isSelected()= t1.isSelected()= +tutti.context.helpPage.notFound= valid=valide x=x Added: trunk/jaxx-demo/src/main/resources/jaxxdemo-help-fr.properties =================================================================== --- trunk/jaxx-demo/src/main/resources/jaxxdemo-help-fr.properties (rev 0) +++ trunk/jaxx-demo/src/main/resources/jaxxdemo-help-fr.properties 2014-01-10 16:52:31 UTC (rev 2766) @@ -0,0 +1,23 @@ +#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo +#Fri Jan 10 13:44:01 CET 2014 +ui.component.swing.buttons.JButtonDemo= +ui.component.swing.buttons.JButtonDemo.fancyButon= +ui.component.swing.buttons.JButtonDemo.simpleButon= +ui.main.action.showLogs= +ui.main.body.db.view.content= +ui.main.menu= +ui.main.menu.file= +ui.main.menu.file.configuration= +ui.main.menu.file.exit= +ui.main.menu.file.fullscreen= +ui.main.menu.file.leave-fullscreen= +ui.main.menu.file.locale= +ui.main.menu.file.locale.fr= +ui.main.menu.file.locale.uk= +ui.main.menu.help= +ui.main.menu.help.about= +ui.main.menu.help.help= +ui.main.menu.help.site= +ui.main.sources.editor= +ui.main.sources.list= +ui.main.sources.toolbar= Property changes on: trunk/jaxx-demo/src/main/resources/jaxxdemo-help-fr.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jaxx-demo/src/main/resources/log4j.properties =================================================================== --- trunk/jaxx-demo/src/main/resources/log4j.properties 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-demo/src/main/resources/log4j.properties 2014-01-10 16:52:31 UTC (rev 2766) @@ -38,3 +38,4 @@ #log4j.logger.jaxx.runtime.swing.editor.config=INFO #log4j.logger.jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder=DEBUG log4j.logger.org.nuiton=WARN +log4j.logger.jaxx.runtime.swing.help=DEBUG Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -1486,4 +1486,36 @@ return text == null || text.trim().length() == 0 ? defaultValue : text.charAt(0); } + + public static void openLink(URI uri) { + + Desktop desktop = getDesktopForBrowse(); + + try { + + desktop.browse(uri); + } catch (Exception e) { + + throw new RuntimeException( + _("application.error.cannot.open.link", uri), e); + } + } + + public static Desktop getDesktopForBrowse() { + + if (!Desktop.isDesktopSupported()) { + throw new RuntimeException( + _("application.error.desktop.not.supported")); + } + + Desktop desktop = Desktop.getDesktop(); + + if (!desktop.isSupported(Desktop.Action.BROWSE)) { + + throw new RuntimeException( + _("application.error.desktop.browse.not.supported")); + } + + return desktop; + } } Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/ComponentTreeNode.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/ComponentTreeNode.java 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/ComponentTreeNode.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -34,7 +34,7 @@ /** * A node where userObject is a {@link Component}. * <p/> - * If the compoent is a {@link Container}, then his children are the components + * If the component is a {@link Container}, then his children are the components * of the container. * * @author tchemit <chemit@codelutin.com> Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/DebugComponentTreeNodeVisitor.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/DebugComponentTreeNodeVisitor.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/DebugComponentTreeNodeVisitor.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -0,0 +1,89 @@ +package jaxx.runtime.awt.visitor; + +/* + * #%L + * JAXX :: Runtime + * $Id$ + * $HeadURL: http://svn.nuiton.org/svn/jaxx/trunk/jaxx-runtime/src/main/java/jaxx/runtime... $ + * %% + * Copyright (C) 2008 - 2013 CodeLutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.awt.Component; + +/** + * To print a tree node. + * <p/> + * Created on 1/10/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 2.7 + */ +public class DebugComponentTreeNodeVisitor implements ComponentTreeNodeVisitor { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(DebugComponentTreeNodeVisitor.class); + + /** + * Flag to log in debug level (otherwise will be in info level). + */ + protected boolean debug; + + protected int level = 0; + + public void parse(ComponentTreeNode componentTree) { + + sb = new StringBuilder(); + componentTree.visit(this); + + String message = sb.toString(); + if (debug) { + log.debug(message); + } else { + log.info(message); + } + } + + protected StringBuilder sb = new StringBuilder(); + + @Override + public void startNode(ComponentTreeNode componentTree) { + String message = StringUtils.leftPad(" ", 2 * level); + sb.append("\n").append(message).append(getMessage(componentTree)); + level++; + } + + @Override + public void endNode(ComponentTreeNode componentTree) { + level--; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + public String getMessage(ComponentTreeNode componentTree) { + Component userObject = componentTree.getUserObject(); + return userObject.getClass().getSimpleName() + "::" + userObject.getName(); + } +} Property changes on: trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/DebugComponentTreeNodeVisitor.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/GetCompopentAtPointVisitor.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/GetCompopentAtPointVisitor.java 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/awt/visitor/GetCompopentAtPointVisitor.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -30,6 +30,7 @@ import java.awt.Component; import java.awt.Point; +import java.awt.Rectangle; import java.util.List; /** @@ -79,15 +80,24 @@ public void startNode(ComponentTreeNode node) { Component component = node.getUserObject(); - Point point = component.getLocation(); - currentX -= point.x; - currentY -= point.y; + if (!(component.isVisible() && component.isShowing())) { + if (log.isDebugEnabled()) { + log.debug("Skip invisible component: " + + component.getClass().getSimpleName() + "::" + + component.getName()); + } + return; + } // check parent is ok if (node.isRoot() || components.contains(node.getParent())) { - boolean containsPoint = component.contains(currentX, currentY); + Point locationOnScreen = component.getLocationOnScreen(); + Rectangle bounds = component.getBounds(); + bounds.setLocation(locationOnScreen); + boolean containsPoint = bounds.contains(currentX, currentY); + if (containsPoint) { if (log.isDebugEnabled()) { @@ -102,8 +112,5 @@ @Override public void endNode(ComponentTreeNode componentTree) { - Point point = componentTree.getUserObject().getLocation(); - currentX += point.x; - currentY += point.y; } } 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 2014-01-08 18:55:30 UTC (rev 2765) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2014-01-10 16:52:31 UTC (rev 2766) @@ -27,7 +27,9 @@ import com.google.common.base.Preconditions; import jaxx.runtime.JAXXContext; import jaxx.runtime.JAXXObject; -import jaxx.runtime.SwingUtil; +import jaxx.runtime.awt.visitor.BuildTreeVisitor; +import jaxx.runtime.awt.visitor.ComponentTreeNode; +import jaxx.runtime.awt.visitor.GetCompopentAtPointVisitor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -47,6 +49,7 @@ import java.awt.EventQueue; import java.awt.Frame; import java.awt.MenuComponent; +import java.awt.Point; import java.awt.Toolkit; import java.awt.Window; import java.awt.event.ActionEvent; @@ -290,7 +293,16 @@ } protected Component getDeppestComponent(Component mouseComponent, MouseEvent event) { - return SwingUtil.getDeepestObjectAt(mouseComponent, event.getX(), event.getY()); + ComponentTreeNode tree = BuildTreeVisitor.buildTree(mouseComponent); + + Point point = event.getLocationOnScreen(); + + Component component = GetCompopentAtPointVisitor.get(tree, point); + if (log.isDebugEnabled()) { + log.debug("Component at (" + point + "): " + component); + } + return component; +// return SwingUtil.getDeepestObjectAt(mouseComponent, event.getX(), event.getY()); } public String findHelpId(Component comp) {
participants (1)
-
tchemit@users.nuiton.org