mail[Wesnoth-commits] r44299 - in /trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin: globalactions/ handlers/ utils/


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

Header


Content

Posted by timotei_cluj on July 18, 2010 - 16:51:
Author: timotei
Date: Sun Jul 18 16:51:34 2010
New Revision: 44299

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44299&view=rev
Log:
eclipse plugin: some minor fixes

Modified:
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/globalactions/MapActions.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/ImportMapHandler.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GameUtils.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/ProjectUtils.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/globalactions/MapActions.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/globalactions/MapActions.java?rev=44299&r1=44298&r2=44299&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/globalactions/MapActions.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/globalactions/MapActions.java
 Sun Jul 18 16:51:34 2010
@@ -14,10 +14,10 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.MessageBox;
 
 import wesnoth_eclipse_plugin.Activator;
 import wesnoth_eclipse_plugin.Logger;
+import wesnoth_eclipse_plugin.utils.GUIUtils;
 import wesnoth_eclipse_plugin.utils.ResourceUtils;
 import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
 
@@ -51,11 +51,8 @@
 
                        if (target.exists())
                        {
-                               MessageBox confirmBox = new 
MessageBox(Activator.getShell(),
-                                               SWT.ICON_QUESTION | SWT.YES | 
SWT.NO);
-                               confirmBox.setMessage("There is already an 
existing map with the same name. Overwrite?");
-
-                               if (confirmBox.open() == SWT.NO)
+                               if (GUIUtils.showMessageBox("There is already 
an existing map with the same name. Overwrite?",
+                                               SWT.ICON_QUESTION | SWT.YES | 
SWT.NO) == SWT.NO)
                                        return;
                        }
 

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/ImportMapHandler.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/ImportMapHandler.java?rev=44299&r1=44298&r2=44299&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/ImportMapHandler.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/ImportMapHandler.java
 Sun Jul 18 16:51:34 2010
@@ -12,11 +12,10 @@
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.MessageBox;
 
-import wesnoth_eclipse_plugin.Activator;
 import wesnoth_eclipse_plugin.Logger;
 import wesnoth_eclipse_plugin.globalactions.MapActions;
+import wesnoth_eclipse_plugin.utils.GUIUtils;
 import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
 
 public class ImportMapHandler extends AbstractHandler
@@ -40,12 +39,10 @@
 
                if (!selectedFolder.getName().equals("maps"))
                {
-                       MessageBox confirmBox = new 
MessageBox(Activator.getShell(),
-                                       SWT.ICON_QUESTION | SWT.YES | SWT.NO);
-                       confirmBox.setMessage("A map should be imported into 
a 'maps' folder. Do you want to proceed?");
-
-                       if (confirmBox.open() == SWT.NO)
-                               return false;
+                       if (GUIUtils.showMessageBox("A map should be imported 
into a 'maps' folder. " +
+                                       "Do you want to proceed?",
+                                       SWT.ICON_QUESTION | SWT.YES | SWT.NO) 
== SWT.NO)
+                       return false;
                }
 
                return (selectedFolder.getName().equals("maps"));

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GameUtils.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GameUtils.java?rev=44299&r1=44298&r2=44299&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GameUtils.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GameUtils.java
 Sun Jul 18 16:51:34 2010
@@ -45,7 +45,8 @@
 
                //TODO: optimize this by checking if file really is a scenario
                if (scenario &&
-                       
!ProjectUtils.isScenarioFile(WorkspaceUtils.getPathRelativeToUserDir(selectedResource)))
+                       !ProjectUtils.isScenarioFile(
+                                       
WorkspaceUtils.getPathRelativeToUserDir(selectedResource)))
                {
                        GUIUtils.showErrorMessageBox("This is not a valid 
scenario file.");
                        return;
@@ -54,7 +55,9 @@
                try
                {
                        String campaignId = 
ProjectUtils.getCampaignID(selectedResource);
-                       String scenarioId = ProjectUtils.getScenarioID(
+                       String scenarioId = null;
+                       if (scenario == true)
+                               ProjectUtils.getScenarioID(
                                        
WorkspaceUtils.getPathRelativeToUserDir(selectedResource));
 
                        if (campaignId == null)
@@ -67,7 +70,7 @@
                        List<String> args = new ArrayList<String>();
                        args.add("-c");
                        args.add(campaignId);
-                       if (scenarioId != null)
+                       if (scenario == true)
                                args.add(scenarioId);
                        startGame(args);
                } catch (Exception e)

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/ProjectUtils.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/ProjectUtils.java?rev=44299&r1=44298&r2=44299&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/ProjectUtils.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/ProjectUtils.java
 Sun Jul 18 16:51:34 2010
@@ -15,11 +15,13 @@
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.SWT;
 
 import wesnoth_eclipse_plugin.Logger;
 
 public class ProjectUtils
 {
+       //TODO: create a simple java wmlparsers in order to get the right 
values
        public static String getPropertyValue(String fileName, String 
propertyName)
        {
                if (fileName == null || propertyName.isEmpty())
@@ -59,8 +61,10 @@
        }
 
        /**
-        * Returns "_main.cfg" location from the specified resource or null 
if it isn't any
+        * Returns "_main.cfg" location relative to user's directory
+        * from the specified resource or null if it isn't any
         * If the resource is a file it won't check for it's name
+        * but will question the user if he really wants to use that file
         * @param resource The resource where to search for '_main.cfg'
         * @return
         */
@@ -86,7 +90,12 @@
 
                if (targetResource == null && resource instanceof IFile)
                {
-                       targetResource = resource;
+                       if (resource.getName().equals("_main.cfg") ||
+                               (!resource.getName().equals("_main.cfg") &&
+                                 GUIUtils.showMessageBox("The file isn't 
named '_main.cfg'. " +
+                                               "Do you still want to open it 
as a campaign file?",
+                                               SWT.YES | SWT.NO | 
SWT.ICON_QUESTION) == SWT.YES))
+                                       targetResource = resource;
                }
                return 
WorkspaceUtils.getPathRelativeToUserDir(targetResource);
        }

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java?rev=44299&r1=44298&r2=44299&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/WorkspaceUtils.java
 Sun Jul 18 16:51:34 2010
@@ -72,7 +72,7 @@
        {
                if (window == null)
                        return null;
-               MyRunnable<IStructuredSelection> runnable = new 
MyRunnable<IStructuredSelection>(null){
+               MyRunnable<IStructuredSelection> runnable = new 
MyRunnable<IStructuredSelection>(){
                        @Override
                        public void run()
                        {




Related Messages


Powered by MHonArc, Updated Sun Jul 18 17:20:12 2010