mail[Wesnoth-commits] r43825 - in /trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin: Activator.java wizards/TemplateProvider.java


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by timotei_cluj on July 01, 2010 - 23:48:
Author: timotei
Date: Thu Jul  1 23:48:41 2010
New Revision: 43825

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43825&view=rev
Log:
eclipse plugin: lazy loading the templates

Modified:
    trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Activator.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/TemplateProvider.java

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Activator.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Activator.java?rev=43825&r1=43824&r2=43825&view=diff
==============================================================================
--- trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Activator.java 
(original)
+++ trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Activator.java 
Thu Jul  1 23:48:41 2010
@@ -4,8 +4,6 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
-
-import wesnoth_eclipse_plugin.wizards.TemplateProvider;
 
 /**
  * The activator class controls the plug-in life cycle
@@ -36,7 +34,6 @@
        {
                super.start(context);
                plugin = this;
-               TemplateProvider.getInstance().loadTemplates();
        }
 
        /*

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/TemplateProvider.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/TemplateProvider.java?rev=43825&r1=43824&r2=43825&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/TemplateProvider.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/wizards/TemplateProvider.java
 Thu Jul  1 23:48:41 2010
@@ -14,7 +14,6 @@
 
 public class TemplateProvider
 {
-
        private static TemplateProvider                 instance_;
        private final HashMap<String, String>   templates_      = new 
HashMap<String, String>();
 
@@ -23,6 +22,7 @@
                if (instance_ == null)
                {
                        instance_ = new TemplateProvider();
+                       instance_.loadTemplates();
                }
                return instance_;
        }
@@ -40,8 +40,8 @@
                {
                        Logger.print("reading templates...");
 
-                       Logger.print(this.pluginFullPath_ + 
this.templatesFile);
-                       BufferedReader reader = new BufferedReader(new 
FileReader(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()
 + this.templatesFile));
+                       Logger.print(pluginFullPath_ + templatesFile);
+                       BufferedReader reader = new BufferedReader(new 
FileReader(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()
 + templatesFile));
                        BufferedReader tmpReader;
                        String line, tmpLine, content;
 
@@ -64,14 +64,14 @@
 
                                content = "";
 
-                               if (new File(this.pluginFullPath_ + 
tokensStrings[1]).exists())
+                               if (new File(pluginFullPath_ + 
tokensStrings[1]).exists())
                                {
-                                       tmpReader = new BufferedReader(new 
FileReader(this.pluginFullPath_ + tokensStrings[1]));
+                                       tmpReader = new BufferedReader(new 
FileReader(pluginFullPath_ + tokensStrings[1]));
                                        while ((tmpLine = 
tmpReader.readLine()) != null)
                                        {
                                                content += tmpLine + '\n';
                                        }
-                                       this.templates_.put(tokensStrings[0], 
content);
+                                       templates_.put(tokensStrings[0], 
content);
                                        // 
System.out.println(String.format("read %s with content: 
%s\n",tokensStrings[0],content));
                                        tmpReader.close();
                                }
@@ -121,8 +121,8 @@
 
        public String getTemplate(String name)
        {
-               if (this.templates_.get(name) == null)
+               if (templates_.get(name) == null)
                        return "";
-               return this.templates_.get(name);
+               return templates_.get(name);
        }
 }




Related Messages


Powered by MHonArc, Updated Fri Jul 02 00:00:06 2010