mail[Wesnoth-commits] r44472 - /trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/WesnothProjectReport.java


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

Header


Content

Posted by timotei_cluj on July 21, 2010 - 00:05:
Author: timotei
Date: Wed Jul 21 00:05:33 2010
New Revision: 44472

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44472&view=rev
Log:
eclipse plugin: enable the project report to be done on 'user addons' project 
too

Modified:
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/WesnothProjectReport.java

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/WesnothProjectReport.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/WesnothProjectReport.java?rev=44472&r1=44471&r2=44472&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/WesnothProjectReport.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/WesnothProjectReport.java
 Wed Jul 21 00:05:33 2010
@@ -10,10 +10,9 @@
 
 import java.io.File;
 
-import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.swt.SWT;
 
 import wesnoth_eclipse_plugin.utils.GUIUtils;
 import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
@@ -23,7 +22,6 @@
        @Override
        public void run(IAction action)
        {
-               //TODO: store project specific info in the '.wesnoth' file
                IProject project = WorkspaceUtils.getSelectedProject();
                if (project == null)
                {
@@ -31,23 +29,45 @@
                        return;
                }
 
+               String simpleReport = "";
+               if (project.getName().equals("User Addons"))
+               {
+                       File projRoot = new 
File(project.getLocation().toOSString());
+                       for (File container : projRoot.listFiles())
+                       {
+                               if (!(container.isDirectory()))
+                                       continue;
+                               simpleReport += container.getName() + ":\n";
+                               simpleReport += 
getReportForContainer(project.getFolder(container.getName()));
+                       }
+               }
+               else
+                       simpleReport = getReportForContainer(project);
+               GUIUtils.showInfoMessageBox(simpleReport);
+       }
+
+       /**
+        * Gets the report for specified container (sceanarios, maps, units)
+        * @param container
+        * @return
+        */
+       private String getReportForContainer(IContainer container)
+       {
                int[] statistics = new int[3];
-               IFolder scenariosFolder = project.getFolder("scenarios");
+
+               File scenariosFolder = new 
File(container.getLocation().toOSString() + "/scenarios");
                if (scenariosFolder.exists())
-                       statistics[0] = new 
File(scenariosFolder.getLocation().toOSString()).listFiles().length;
+                       statistics[0] = scenariosFolder.listFiles().length;
 
-               IFolder mapsFolder = project.getFolder("maps");
+               File mapsFolder =  new 
File(container.getLocation().toOSString() + "/maps");
                if (mapsFolder.exists())
-                       statistics[1] = new 
File(mapsFolder.getLocation().toOSString()).listFiles().length;
+                       statistics[1] = mapsFolder.listFiles().length;
 
-               IFolder unitsFolder = project.getFolder("units");
+               File unitsFolder =  new 
File(container.getLocation().toOSString() + "/units");
                if (unitsFolder.exists())
-                       statistics[2] = new 
File(unitsFolder.getLocation().toOSString()).listFiles().length;
+                       statistics[2] = unitsFolder.listFiles().length;
 
-               String simpleReport = String.format("Scenarios: %d \nMaps: %d 
\nUnits: %d",
-                                statistics[0],statistics[1], statistics[2]);
-
-               GUIUtils.showMessageBox(WorkspaceUtils.getWorkbenchWindow(), 
simpleReport,
-                               SWT.ICON_INFORMATION);
+               return String.format(" - Scenarios: %d \n - Maps: %d \n - 
Units: %d\n",
+                               statistics[0],statistics[1], statistics[2]);
        }
 }




Related Messages


Powered by MHonArc, Updated Wed Jul 21 00:20:13 2010