mail[Wesnoth-commits] r44714 - in /trunk/utils/java/eclipse_plugin: ./ src/wesnoth_eclipse_plugin/ src/wesnoth_eclipse_plugin/handlers/ src/wesnot...


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

Header


Content

Posted by timotei_cluj on July 26, 2010 - 15:29:
Author: timotei
Date: Mon Jul 26 15:29:06 2010
New Revision: 44714

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44714&view=rev
Log:
eclipse plugin: add preference page for wmltools:
wmlscope, wmllint, wmlindent

Added:
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WMLToolsPreferencePage.java
Modified:
    trunk/utils/java/eclipse_plugin/plugin.xml
    trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Constants.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/Preferences.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WMLTools.java

Modified: trunk/utils/java/eclipse_plugin/plugin.xml
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/plugin.xml?rev=44714&r1=44713&r2=44714&view=diff
==============================================================================
--- trunk/utils/java/eclipse_plugin/plugin.xml (original)
+++ trunk/utils/java/eclipse_plugin/plugin.xml Mon Jul 26 15:29:06 2010
@@ -471,6 +471,12 @@
             id="wml_plugin_preferences"
             name="Wesnoth UMC">
       </page>
+      <page
+            category="wml_plugin_preferences"
+            class="wesnoth_eclipse_plugin.preferences.WMLToolsPreferencePage"
+            id="wml_plugin_preferences.wmltools"
+            name="WML Tools">
+      </page>
    </extension>
    <extension
          point="org.eclipse.core.runtime.preferences">

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Constants.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Constants.java?rev=44714&r1=44713&r2=44714&view=diff
==============================================================================
--- trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Constants.java 
(original)
+++ trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/Constants.java 
Mon Jul 26 15:29:06 2010
@@ -35,6 +35,16 @@
 
        public static final String      P_WESNOTH_USER_DIR              = 
"wesnoth_user_dir";
 
+       /** WML Tools preferences constants **/
+       public static final String      P_WMLINDENT_VERBOSE             = 
"wmlindent_verbose";
+
+       public static final String      P_WMLLINT_DRYRUN                = 
"wmllint_dry_run";
+       public static final String      P_WMLLINT_SPELL_CHECK   = 
"wmllint_spell_check";
+       public static final String      P_WMLLINT_VERBOSE_LEVEL = 
"wmllint_verbose_level";
+
+       public static final String      P_WMLSCOPE_VERBOSE_LEVEL= 
"wmlscope_verbose_level";
+       public static final String      P_WMLSCOPE_COLLISIONS   = 
"wmlscope_collisions";
+
        /** Wizards Constants **/
        public static final int         WIZ_TextBoxHeight               = 21;
        public static final int         WIZ_MaxTextBoxesOnPage  = 10;

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java?rev=44714&r1=44713&r2=44714&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java
 Mon Jul 26 15:29:06 2010
@@ -8,21 +8,9 @@
  
*******************************************************************************/
 package wesnoth_eclipse_plugin.handlers;
 
-import java.io.StringReader;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.xml.sax.InputSource;
-
-import wesnoth_eclipse_plugin.utils.ExternalToolInvoker;
-import wesnoth_eclipse_plugin.utils.WMLSaxHandler;
-import wesnoth_eclipse_plugin.utils.WMLTools;
-import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
 
 /**
  * Here it goes testing stuff in the plugin ( For DEBUG ONLY!)
@@ -33,24 +21,24 @@
        @Override
        public Object execute(ExecutionEvent event) throws ExecutionException
        {
-               IFile sel = WorkspaceUtils.getSelectedFile();
-               if (sel == null)
-                       return null;
-               ExternalToolInvoker parser = 
WMLTools.runWMLParser2(sel.getLocation().toOSString());
-               parser.waitForTool();
-               ///System.out.println(parser.getOutputContent());
-               try
-               {
-                       SAXParser saxparser = 
SAXParserFactory.newInstance().newSAXParser();
-                       WMLSaxHandler handler = new WMLSaxHandler();
-                       saxparser.parse(new InputSource(new 
StringReader(parser.getOutputContent())), handler);
-
-//                     GUIUtils.showInfoMessageBox("AA: ");
-               }
-               catch (Exception e)
-               {
-                       e.printStackTrace();
-               }
+//             IFile sel = WorkspaceUtils.getSelectedFile();
+//             if (sel == null)
+//                     return null;
+//             ExternalToolInvoker parser = 
WMLTools.runWMLParser2(sel.getLocation().toOSString());
+//             parser.waitForTool();
+//             ///System.out.println(parser.getOutputContent());
+//             try
+//             {
+//                     SAXParser saxparser = 
SAXParserFactory.newInstance().newSAXParser();
+//                     WMLSaxHandler handler = new WMLSaxHandler();
+//                     saxparser.parse(new InputSource(new 
StringReader(parser.getOutputContent())), handler);
+//
+////                   GUIUtils.showInfoMessageBox("AA: ");
+//             }
+//             catch (Exception e)
+//             {
+//                     e.printStackTrace();
+//             }
 //             try
 //             {
 //                     MessageConsole con = GUIUtils.createConsole("BB", 
null, true);

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/Preferences.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/Preferences.java?rev=44714&r1=44713&r2=44714&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/Preferences.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/Preferences.java
 Mon Jul 26 15:29:06 2010
@@ -22,10 +22,21 @@
        @Override
        public void initializeDefaultPreferences() {
                IPreferenceStore store = 
Activator.getDefault().getPreferenceStore();
+               // general settings
                store.setDefault(Constants.P_WESNOTH_EXEC_PATH, "");
                store.setDefault(Constants.P_WESNOTH_WORKING_DIR, "");
                store.setDefault(Constants.P_WESNOTH_USER_DIR, "");
                store.setDefault(Constants.P_WESNOTH_WMLTOOLS_DIR, "");
+
+               // wml tools
+               store.setDefault(Constants.P_WMLINDENT_VERBOSE, true);
+
+               store.setDefault(Constants.P_WMLLINT_DRYRUN, true);
+               store.setDefault(Constants.P_WMLLINT_SPELL_CHECK, false);
+               store.setDefault(Constants.P_WMLLINT_VERBOSE_LEVEL, 0);
+
+               store.setDefault(Constants.P_WMLSCOPE_VERBOSE_LEVEL, 0);
+               store.setDefault(Constants.P_WMLSCOPE_COLLISIONS, true);
        }
 
        /**
@@ -53,4 +64,12 @@
        {
                return getPreferences().getInt(prefName);
        }
+       /**
+        * Returns the contents of the specified preference as a boolean
+        * or false if there is no such preference set
+        */
+       public static boolean getBool(String prefName)
+       {
+               return getPreferences().getBoolean(prefName);
+       }
 }

Added: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WMLToolsPreferencePage.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WMLToolsPreferencePage.java?rev=44714&view=auto
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WMLToolsPreferencePage.java
 (added)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WMLToolsPreferencePage.java
 Mon Jul 26 15:29:06 2010
@@ -1,0 +1,53 @@
+package wesnoth_eclipse_plugin.preferences;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.ScaleFieldEditor;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.xtext.ui.editor.preferences.fields.LabelFieldEditor;
+
+import wesnoth_eclipse_plugin.Activator;
+import wesnoth_eclipse_plugin.Constants;
+
+public class WMLToolsPreferencePage extends FieldEditorPreferencePage 
implements
+               IWorkbenchPreferencePage
+{
+       public WMLToolsPreferencePage()
+       {
+               super(GRID);
+
+               
setPreferenceStore(Activator.getDefault().getPreferenceStore());
+               setDescription("WML Tools preferences");
+       }
+
+       @Override
+       protected void createFieldEditors()
+       {
+               addField(new LabelFieldEditor("WMLINDENT:", 
getFieldEditorParent()));
+               addField(new 
BooleanFieldEditor(Constants.P_WMLINDENT_VERBOSE, "Verbose Output", 1,
+                               getFieldEditorParent()));
+               addField(new LabelFieldEditor("", getFieldEditorParent()));
+
+               addField(new LabelFieldEditor("WMLSCOPE:", 
getFieldEditorParent()));
+               addField(new 
ScaleFieldEditor(Constants.P_WMLSCOPE_VERBOSE_LEVEL, "Verbose level:",
+                               getFieldEditorParent(), 0, 2, 1, 1));
+               addField(new 
BooleanFieldEditor(Constants.P_WMLSCOPE_COLLISIONS, "Report collisions", 1,
+                               getFieldEditorParent()));
+               addField(new LabelFieldEditor("", getFieldEditorParent()));
+
+               addField(new LabelFieldEditor("WMLLINT:", 
getFieldEditorParent()));
+               addField(new BooleanFieldEditor(Constants.P_WMLLINT_DRYRUN, 
"Dry run", 1,
+                               getFieldEditorParent()));
+               addField(new 
BooleanFieldEditor(Constants.P_WMLLINT_SPELL_CHECK, "Spell check", 1,
+                               getFieldEditorParent()));
+               addField(new 
ScaleFieldEditor(Constants.P_WMLLINT_VERBOSE_LEVEL, "Verbose level:",
+                               getFieldEditorParent(), 0, 3, 1, 1));
+               addField(new LabelFieldEditor("", getFieldEditorParent()));
+       }
+
+       @Override
+       public void init(IWorkbench workbench)
+       {
+       }
+}

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WMLTools.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WMLTools.java?rev=44714&r1=44713&r2=44714&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WMLTools.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WMLTools.java
 Mon Jul 26 15:29:06 2010
@@ -59,7 +59,11 @@
 
                        if (dryrun)
                                arguments.add("--dryrun");
-                       arguments.add("--verbose");
+                       if 
(Preferences.getBool(Constants.P_WMLINDENT_VERBOSE))
+                       {
+                               arguments.add("-v");
+                               arguments.add("-v");
+                       }
                        arguments.add(resourcePath);
                }
                return runPythonScript(arguments, stdin,stdout,stderr);
@@ -135,10 +139,19 @@
                List<String> arguments = new ArrayList<String>();
 
                arguments.add(wmllintFile.getAbsolutePath());
-               if (dryrun)
+
+               int verboseLevel = 
Preferences.getInt(Constants.P_WMLLINT_VERBOSE_LEVEL);
+               for(int i=1; i <= verboseLevel; i++)
+                       arguments.add("-v");
+
+               if (verboseLevel <= 1)
+                       arguments.add("--progress");
+
+               if (dryrun || Preferences.getBool(Constants.P_WMLLINT_DRYRUN) 
== true)
                        arguments.add("--dryrun");
-               arguments.add("--progress");
-               arguments.add("--nospellcheck");
+
+               if (Preferences.getBool(Constants.P_WMLLINT_SPELL_CHECK) == 
false)
+                       arguments.add("--nospellcheck");
 
                // add default core directory
                
arguments.add(Preferences.getString(Constants.P_WESNOTH_WORKING_DIR) +
@@ -179,9 +192,20 @@
                List<String> arguments = new ArrayList<String>();
 
                arguments.add(wmlscopeFile.getAbsolutePath());
-               //arguments.add("-w");
-               //arguments.add("2");
-               arguments.add("--progress");
+               int verboseLevel = 
Preferences.getInt(Constants.P_WMLSCOPE_VERBOSE_LEVEL);
+
+               if (verboseLevel == 0)
+                       arguments.add("--progress");
+               else
+               {
+                       arguments.add("-w");
+                       arguments.add(String.valueOf(verboseLevel));
+               }
+
+               if (Preferences.getBool(Constants.P_WMLSCOPE_COLLISIONS) == 
true)
+                       arguments.add("--collisions");
+
+               arguments.add("--crossreference");
 
                // add default core directory
                
arguments.add(Preferences.getString(Constants.P_WESNOTH_WORKING_DIR) +




Related Messages


Powered by MHonArc, Updated Mon Jul 26 15:40:14 2010