From: <sno...@us...> - 2013-09-23 18:01:59
|
Revision: 105 http://sourceforge.net/p/openrpg/svn/105 Author: snowdog_ Date: 2013-09-23 18:01:57 +0000 (Mon, 23 Sep 2013) Log Message: ----------- Added initialize method to BaseModule for code clarity Modified Paths: -------------- trunk/src/openrpg2/common/module/BaseModule.java trunk/src/openrpg2/server/core/modules/clientlist/ClientList.java Modified: trunk/src/openrpg2/common/module/BaseModule.java =================================================================== --- trunk/src/openrpg2/common/module/BaseModule.java 2013-09-23 02:22:54 UTC (rev 104) +++ trunk/src/openrpg2/common/module/BaseModule.java 2013-09-23 18:01:57 UTC (rev 105) @@ -75,10 +75,22 @@ */ public void register(ModuleCommunicator mc){ modCom = mc; //hooks module to module manager + initialize(); doRegistration(); } /** + * The initialize method allows a module to do operations post module load + * but before registration is done. This is particularly useful when + * GUI components interact with the ModuleCommunicator indirectly. While + * technically speaking these kind of operations can be done at the top of + * the doRegistration method the initialize method makes the code a bit clearer + * by separating module initialization code from the module registration code. + * <i>Overriding this method is optional</i> + */ + protected void initialize(){} + + /** * This method handles registration tasks that relate to the overseeing ModuleCommunicator object. * These tasks generally include registering message handlers and informing the ModuleCommunicator of a * modules abilities and external interests. Modified: trunk/src/openrpg2/server/core/modules/clientlist/ClientList.java =================================================================== --- trunk/src/openrpg2/server/core/modules/clientlist/ClientList.java 2013-09-23 02:22:54 UTC (rev 104) +++ trunk/src/openrpg2/server/core/modules/clientlist/ClientList.java 2013-09-23 18:01:57 UTC (rev 105) @@ -43,10 +43,6 @@ public ClientList(){ this.setModuleAuthor("Snowdog"); this.setModuleShortDescription("Client List for Server"); - - buildGUI(); - - log.info("Module Instanced."); } private void buildGUI(){ @@ -60,6 +56,12 @@ table.setFillsViewportHeight(false); panel.add(sp, BorderLayout.CENTER); } + + @Override + protected void initialize(){ + this.dataSource = new ClientListTableModel(this.modCom); + buildGUI(); + } @Override protected void doRegistration() { @@ -70,7 +72,7 @@ @Override public void activate(){ - this.dataSource = new ClientListTableModel(this.modCom); + } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |