mail[Wesnoth-commits] r44716 - in /trunk/utils/java/eclipse_plugin: ./ src/wesnoth_eclipse_plugin/ src/wesnoth_eclipse_plugin/jface/ src/wesnoth_e...


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:36 2010
New Revision: 44716

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44716&view=rev
Log:
eclipse plugin: add options for wesnoth addon uploader

Added:
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/jface/RegexStringFieldEditor.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/AddonUploadPreferencePage.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/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=44716&r1=44715&r2=44716&view=diff
==============================================================================
--- trunk/utils/java/eclipse_plugin/plugin.xml (original)
+++ trunk/utils/java/eclipse_plugin/plugin.xml Mon Jul 26 15:29:36 2010
@@ -477,6 +477,12 @@
             id="wml_plugin_preferences.wmltools"
             name="WML Tools">
       </page>
+      <page
+            category="wml_plugin_preferences"
+            
class="wesnoth_eclipse_plugin.preferences.AddonUploadPreferencePage"
+            id="wml_plugin_preferences.addon_upload"
+            name="Addon Uploader">
+      </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=44716&r1=44715&r2=44716&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:36 2010
@@ -29,37 +29,43 @@
                
System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows");
 
        /** Preferences Constants **/
-       public static final String      P_WESNOTH_EXEC_PATH             = 
"wesnoth_exec_path";
-       public static final String      P_WESNOTH_WORKING_DIR   = 
"wesnoth_working_dir";
-       public static final String      P_WESNOTH_WMLTOOLS_DIR  = 
"wesnoth_wmltools_dir";
+       public static final String      P_WESNOTH_EXEC_PATH     = 
"wesnoth_exec_path";
+       public static final String      P_WESNOTH_WORKING_DIR   = 
"wesnoth_working_dir";
+       public static final String      P_WESNOTH_WMLTOOLS_DIR  = 
"wesnoth_wmltools_dir";
 
-       public static final String      P_WESNOTH_USER_DIR              = 
"wesnoth_user_dir";
+       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_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_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";
+       public static final String      P_WMLSCOPE_COLLISIONS   = 
"wmlscope_collisions";
+
+       /** Wesnoth addon uploader preferences */
+       public static final String      P_WAU_PASSWORD          = 
"wau_password";
+       public static final String      P_WAU_VERBOSE           = 
"wau_verbose";
+       public static final String      P_WAU_ADDRESS           = 
"wau_address";
+       public static final String      P_WAU_PORT              = "wau_port";
 
        /** Wizards Constants **/
-       public static final int         WIZ_TextBoxHeight               = 21;
-       public static final int         WIZ_MaxTextBoxesOnPage  = 10;
-       public static final int         WIZ_MaxGroupsOnPage             = 4;
-       public static final int         WIZ_MaxWizardPageHeight = 220;
+       public static final int         WIZ_TextBoxHeight       = 21;
+       public static final int         WIZ_MaxTextBoxesOnPage  = 10;
+       public static final int         WIZ_MaxGroupsOnPage     = 4;
+       public static final int         WIZ_MaxWizardPageHeight = 220;
 
        /** Builder Constants **/
-       public static final String BUIILDER_WESNOTH     = 
"Wesnoth_Eclipse_Plugin.projectBuilder";
-       public static final String BUILDER_XTEXT                = 
XtextProjectHelper.BUILDER_ID;
-       public static final String BUILDER_MARKER_TYPE= 
"Wesnoth_Eclipse_Plugin.configProblem";
+       public static final String BUIILDER_WESNOTH     = 
"Wesnoth_Eclipse_Plugin.projectBuilder";
+       public static final String BUILDER_XTEXT        = 
XtextProjectHelper.BUILDER_ID;
+       public static final String BUILDER_MARKER_TYPE  = 
"Wesnoth_Eclipse_Plugin.configProblem";
 
        /** Nature Constants **/
-       public static final String NATURE_WESNOTH               = 
"Wesnoth_Eclipse_Plugin.wesnothNature";
-       public static final String NATURE_XTEXT         = 
XtextProjectHelper.NATURE_ID;
+       public static final String NATURE_WESNOTH       = 
"Wesnoth_Eclipse_Plugin.wesnothNature";
+       public static final String NATURE_XTEXT         = 
XtextProjectHelper.NATURE_ID;
 
        /** Templates related */
-       public static final String TEMPLATES_FILENAME  = "templatesIndex.txt";
+       public static final String TEMPLATES_FILENAME   = 
"templatesIndex.txt";
 }

Added: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/jface/RegexStringFieldEditor.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/jface/RegexStringFieldEditor.java?rev=44716&view=auto
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/jface/RegexStringFieldEditor.java
 (added)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/jface/RegexStringFieldEditor.java
 Mon Jul 26 15:29:36 2010
@@ -1,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010 by Timotei Dolean <timotei21@xxxxxxxxx>
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ 
*******************************************************************************/
+package wesnoth_eclipse_plugin.jface;
+
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.widgets.Composite;
+
+public class RegexStringFieldEditor extends StringFieldEditor
+{
+       protected String regex_;
+       protected String errorMessage_;
+
+       /**
+        * An regex matcher string field editor.
+        * @param regex The regex to match this textbox's string
+        * @param errorMessage The message to show as error when field's text
+        * doesn't match the regex
+        */
+       public RegexStringFieldEditor(String name, String labelText,
+                       String regex, String errorMessage, Composite parent)
+       {
+               super(name,labelText,parent);
+               regex_ = regex;
+               errorMessage_ = errorMessage;
+       }
+
+       @Override
+       protected boolean checkState()
+       {
+               if (regex_ == null)
+                       return true;
+               boolean matches = getTextControl().getText().matches(regex_);
+               setErrorMessage(matches == false ? errorMessage_ : null);
+               showErrorMessage();
+               return matches;
+       }
+}

Added: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/AddonUploadPreferencePage.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/AddonUploadPreferencePage.java?rev=44716&view=auto
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/AddonUploadPreferencePage.java
 (added)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/AddonUploadPreferencePage.java
 Mon Jul 26 15:29:36 2010
@@ -1,0 +1,72 @@
+package wesnoth_eclipse_plugin.preferences;
+
+import java.util.HashMap;
+import java.util.Map.Entry;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.StringFieldEditor;
+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;
+import wesnoth_eclipse_plugin.jface.RegexStringFieldEditor;
+
+public class AddonUploadPreferencePage extends FieldEditorPreferencePage 
implements
+               IWorkbenchPreferencePage
+{
+       HashMap<String, String> ports_;
+
+       public AddonUploadPreferencePage()
+       {
+               super(GRID);
+               ports_ = new HashMap<String, String>();
+               ports_.put("15002", "1.9.x");
+               ports_.put("15001", "1.8.x");
+               ports_.put("15003", "1.6.x");
+               ports_.put("15005", "1.4.x");
+               ports_.put("15004", "trunk");
+
+               
setPreferenceStore(Activator.getDefault().getPreferenceStore());
+               setDescription("Addon uploader preferences");
+       }
+
+       @Override
+       protected void createFieldEditors()
+       {
+               addField(new StringFieldEditor(Constants.P_WAU_PASSWORD,
+                               "Password (stored in plain text)", 
getFieldEditorParent()));
+               addField(new BooleanFieldEditor(Constants.P_WAU_VERBOSE,
+                               "Verbose", 1, getFieldEditorParent()));
+
+               addField(new RegexStringFieldEditor(Constants.P_WAU_ADDRESS,
+                               "Address", "[^:]*",
+                               "The address must not contain any port number 
as its set below.",
+                               getFieldEditorParent()));
+
+               StringBuilder ports = new StringBuilder();
+               StringBuilder portsRegex = new StringBuilder();
+               portsRegex.append("(");
+               for (Entry<String, String> item : ports_.entrySet())
+               {
+                       portsRegex.append(item.getKey() + "|");
+                       ports.append(String.format("\t%s - %s\n", 
item.getKey(), item.getValue()));
+               }
+               portsRegex.deleteCharAt(portsRegex.length() - 1);
+               portsRegex.append(")*");
+
+               System.out.println(portsRegex.toString());
+               addField(new RegexStringFieldEditor(Constants.P_WAU_PORT,
+                               "Port", portsRegex.toString(),
+                               "Invalid port number", 
getFieldEditorParent()));
+               addField(new LabelFieldEditor("Ports available by wesnoth's 
version:\n" +
+                               ports.toString(), getFieldEditorParent()));
+       }
+
+       @Override
+       public void init(IWorkbench workbench)
+       {
+       }
+}

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=44716&r1=44715&r2=44716&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:36 2010
@@ -37,6 +37,12 @@
 
                store.setDefault(Constants.P_WMLSCOPE_VERBOSE_LEVEL, 0);
                store.setDefault(Constants.P_WMLSCOPE_COLLISIONS, true);
+
+               // upload manager
+               store.setDefault(Constants.P_WAU_PASSWORD, "");
+               store.setDefault(Constants.P_WAU_VERBOSE, false);
+               store.setDefault(Constants.P_WAU_ADDRESS, 
"add-ons.wesnoth.org");
+               store.setDefault(Constants.P_WAU_PORT, 15002);
        }
 
        /**

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=44716&r1=44715&r2=44716&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:36 2010
@@ -366,6 +366,21 @@
                List<String> arguments = new ArrayList<String>();
                arguments.add(wmllintFile.getAbsolutePath());
 
+               if 
(!Preferences.getString(Constants.P_WAU_PASSWORD).isEmpty())
+               {
+                       arguments.add("-P");
+                       
arguments.add(Preferences.getString(Constants.P_WAU_PASSWORD));
+               }
+
+               if (Preferences.getBool(Constants.P_WAU_VERBOSE) == true)
+                       arguments.add("-V");
+
+               arguments.add("-a");
+               arguments.add(Preferences.getString(Constants.P_WAU_ADDRESS));
+
+               arguments.add("-p");
+               arguments.add(Preferences.getString(Constants.P_WAU_PORT));
+
                arguments.add("-u");
                arguments.add(containerPath);
                return runPythonScript(arguments, null, stdout,stderr);




Related Messages


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