Commits

Dmytro Kovalchuk committed 85253fa Draft

Swing-API improvements

  • Participants
  • Parent commits 74521ff

Comments (0)

Files changed (1)

File swing-api/src/main/java/net/anatolich/cstitch/ui/editor/tools/package-info.java

 
 /**
  * Editor tools together with abstract tool classes.
+ * 
+ * <h1>Registration of tools</h1>
+ * In order to register new editor tool in your module you need to do one small 
+ * configuration trick. Tool can be registered via {@link ToolsService#registerTool} call.
+ * The problem is how to get tool service during application initialization. To do this 
+ * you need to create custom ToolIjector class. ToolInjector uses constructor 
+ * injected with implementation of tools service. So injector can register tools 
+ * your module provides to system. In order to activate tool injector you need 
+ * to describe it in module configuration as eager singleton bean. Here is the code:
+ * <code><pre>
+ * // ToolsInjector
+ * class ToolsInjector {
+ *   
+ *   &#064;Inject
+ *   ToolsInjector(ToolsService service) {
+ *      service.registerTool(new MyTool());     
+ *   }
+ * }
+ * 
+ * // Module configuration
+ * class ModuleConfiguration extends AbstractModule {
+ *  
+ *   &#064;Override
+ *   protected void configure() {
+ *       bind(ToolsInjector.class).asEagerSingleton();
+ *   }
+ * }
+ * 
+ * </pre></code>
+ * 
  */
 package net.anatolich.cstitch.ui.editor.tools;