Dmytro Kovalchuk avatar Dmytro Kovalchuk committed 85253fa Draft

Swing-API improvements

Comments (0)

Files changed (1)

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;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.