mail[Wesnoth-commits] r44170 - in /trunk/utils/java/eclipse_plugin: ./ src/wesnoth_eclipse_plugin/action/ src/wesnoth_eclipse_plugin/utils/


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

Header


Content

Posted by timotei_cluj on July 15, 2010 - 10:25:
Author: timotei
Date: Thu Jul 15 10:25:00 2010
New Revision: 44170

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44170&view=rev
Log:
eclipse plugin: add "upload addon" menu entry for containers

Added:
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/UploadAddon.java
Modified:
    trunk/utils/java/eclipse_plugin/plugin.xml
    
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=44170&r1=44169&r2=44170&view=diff
==============================================================================
--- trunk/utils/java/eclipse_plugin/plugin.xml (original)
+++ trunk/utils/java/eclipse_plugin/plugin.xml Thu Jul 15 10:25:00 2010
@@ -28,7 +28,7 @@
    <extension
          point="org.eclipse.ui.popupMenus">
       <objectContribution
-            adaptable="true"
+            adaptable="false"
             objectClass="org.eclipse.core.resources.IProject"
             nameFilter="*"
             id="plugin.projectContributions">
@@ -70,7 +70,7 @@
          </action>
       </objectContribution>
       <objectContribution
-            adaptable="true"
+            adaptable="false"
             id="plugin.mapContributions"
             nameFilter="*maps*"
             objectClass="org.eclipse.core.resources.IFolder">
@@ -165,6 +165,19 @@
                id="action.cfg.wmlindent"
                label="Run &quot;wmlindent&quot; on this file"
                menubarPath="plugin.wmltoolsCfgMenu/wmltoolsCfgMenuMarker">
+         </action>
+      </objectContribution>
+      <objectContribution
+            adaptable="false"
+            id="plugin.containerContributions"
+            nameFilter="*"
+            objectClass="org.eclipse.core.resources.IContainer">
+         <action
+               class="wesnoth_eclipse_plugin.action.UploadAddon"
+               icon="icons/wesnoth-icon_16.png"
+               id="action.container.addonUpload"
+               label="Upload Add-on"
+               menubarPath="_wesnoth">
          </action>
       </objectContribution>
    </extension>

Added: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/UploadAddon.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/UploadAddon.java?rev=44170&view=auto
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/UploadAddon.java
 (added)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/action/UploadAddon.java
 Thu Jul 15 10:25:00 2010
@@ -1,0 +1,61 @@
+/**
+ * @author Timotei Dolean
+ */
+package wesnoth_eclipse_plugin.action;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import wesnoth_eclipse_plugin.Activator;
+import wesnoth_eclipse_plugin.utils.WMLTools;
+import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
+
+public class UploadAddon implements IObjectActionDelegate
+{
+       public UploadAddon() {
+       }
+
+       @Override
+       public void run(IAction action)
+       {
+               final String fullPath = 
WorkspaceUtils.getSelectedResource().getLocation().toOSString();
+               ProgressMonitorDialog dialog = new 
ProgressMonitorDialog(Activator.getShell());
+               try
+               {
+                       dialog.run(false, false, new IRunnableWithProgress() {
+                               @Override
+                               public void run(IProgressMonitor monitor)
+                                               throws 
InvocationTargetException, InterruptedException
+                               {
+                                       monitor.beginTask("Uploading 
addon...", 50);
+                                       monitor.worked(10);
+                                       
WMLTools.runWesnothAddonManager(fullPath, true, false);
+                                       monitor.worked(40);
+                                       monitor.done();
+                               }
+                       });
+               } catch (InvocationTargetException e)
+               {
+                       e.printStackTrace();
+               } catch (InterruptedException e)
+               {
+               }
+       }
+
+       @Override
+       public void selectionChanged(IAction action, ISelection selection)
+       {
+       }
+
+       @Override
+       public void setActivePart(IAction action, IWorkbenchPart targetPart)
+       {
+       }
+}

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=44170&r1=44169&r2=44170&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
 Thu Jul 15 10:25:00 2010
@@ -31,7 +31,7 @@
         * @param useThread whether the tool should be runned in a new thread 
or not
         */
        public static String runWMLIndent(String resourcePath, String stdin,
-                                               boolean dryrun, boolean 
writeToConsole, boolean useThread)
+                       boolean dryrun, boolean writeToConsole, boolean 
useThread)
        {
                if (!checkPrerequisites(null, "wmlindent")) // wmlindent only 
check first
                        return null;
@@ -111,7 +111,7 @@
                arguments.add(resourcePath);
 
                return ExternalToolInvoker.launchTool("python", arguments, 
Constants.TI_SHOW_OUTPUT | Constants.TI_SHOW_OUTPUT_USER,
-                                       useThread);
+                               useThread);
        }
 
        /**
@@ -126,19 +126,27 @@
        {
                if (wmlTool != null)
                {
+                       if 
(Preferences.getString(Constants.P_WESNOTH_WMLTOOLS_DIR).equals(""))
+                       {
+                               GUIUtils.showMessageBox("Please set the 
wmltools directory in the " +
+                                               "preferences before you use 
this feature.");
+                               return false;
+                       }
                        File wmlToolFile = new 
File(Preferences.getString(Constants.P_WESNOTH_WMLTOOLS_DIR) +
                                        Path.SEPARATOR + wmlTool);
 
                        if (!wmlToolFile.exists())
                        {
-                               
GUIUtils.showMessageBox(WorkspaceUtils.getWorkbenchWindow(),
-                                               "Please set the wmltools 
directory in the preferences before you use this feature.");
+                               GUIUtils.showMessageBox(String.format("The 
file %s was not found",
+                                               wmlToolFile));
                                return false;
                        }
                }
-               if (filePath != null &&
-                               (filePath.isEmpty() || !new 
File(filePath).exists()))
+               if (filePath != null && (filePath.isEmpty() || !new 
File(filePath).exists()))
+               {
+                       GUIUtils.showMessageBox("");
                        return false;
+               }
 
                return true;
        }
@@ -198,4 +206,20 @@
                }
                return result;
        }
+
+       public static String runWesnothAddonManager(String containerPath,
+                       boolean writeToConsole, boolean useThread)
+       {
+               if (!checkPrerequisites(containerPath, 
"wesnoth_addon_manager"))
+                       return null;
+
+               File wmllintFile = new 
File(Preferences.getString(Constants.P_WESNOTH_WMLTOOLS_DIR)
+                               + "/wesnoth_addon_manager");
+               List<String> arguments = new ArrayList<String>();
+               arguments.add(wmllintFile.getAbsolutePath());
+
+               arguments.add("-u");
+               arguments.add(containerPath);
+               return runPythonScript(arguments, null, useThread, 
writeToConsole, "Uploading result: ");
+       }
 }




Related Messages


Powered by MHonArc, Updated Thu Jul 15 10:40:11 2010