mail[Wesnoth-commits] r44583 - in /trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin: preferences/ utils/


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

Header


Content

Posted by timotei_cluj on July 23, 2010 - 16:25:
Author: timotei
Date: Fri Jul 23 16:25:57 2010
New Revision: 44583

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44583&view=rev
Log:
eclipse plugin: computer the working directory directly from the preferences 
page

Modified:
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WesnothEditorPreferencesPage.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GameUtils.java

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WesnothEditorPreferencesPage.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WesnothEditorPreferencesPage.java?rev=44583&r1=44582&r2=44583&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WesnothEditorPreferencesPage.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/preferences/WesnothEditorPreferencesPage.java
 Fri Jul 23 16:25:57 2010
@@ -18,6 +18,8 @@
 import org.eclipse.jface.preference.FieldEditorPreferencePage;
 import org.eclipse.jface.preference.FileFieldEditor;
 import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
@@ -41,6 +43,9 @@
                implements IWorkbenchPreferencePage
 {
        private DirectoryFieldEditor    wmlToolsField_;
+       private DirectoryFieldEditor    wesnothWorkingDirField_;
+       private DirectoryFieldEditor    wesnothUserDirField_;
+       private FileFieldEditor                 wesnothExecutableField_;
        private List<String>                    wmlToolsList_;
 
        public WesnothEditorPreferencesPage() {
@@ -65,15 +70,49 @@
        @Override
        public void createFieldEditors()
        {
-               addField(new FileFieldEditor(Constants.P_WESNOTH_EXEC_PATH,
-                               "Wesnoth executable path:", 
getFieldEditorParent()));
-               addField(new 
DirectoryFieldEditor(Constants.P_WESNOTH_WORKING_DIR,
-                               "Working directory:", 
getFieldEditorParent()));
-               addField(new 
DirectoryFieldEditor(Constants.P_WESNOTH_USER_DIR,
-                               "User data directory:", 
getFieldEditorParent()));
+               wesnothExecutableField_ = new 
FileFieldEditor(Constants.P_WESNOTH_EXEC_PATH,
+                               "Wesnoth executable path:", 
getFieldEditorParent());
+               
wesnothExecutableField_.getTextControl(getFieldEditorParent()).addModifyListener(new
 ModifyListener() {
+                       @Override
+                       public void modifyText(ModifyEvent e)
+                       {
+                               checkState();
+                               if (wesnothWorkingDirField_.getTextControl(
+                                               
getFieldEditorParent()).getText().isEmpty())
+                               {
+                                       String wesnothExec = 
wesnothExecutableField_.getTextControl(getFieldEditorParent()).getText();
+                                       if (!wesnothExec.isEmpty())
+                                       {
+                                               
wesnothWorkingDirField_.getTextControl(getFieldEditorParent()).
+                                                               
setText(wesnothExec.substring(0,
+                                                                             
  wesnothExec.lastIndexOf(new File(wesnothExec).getName()))
+                                                               );
+                                       }
+                               }
+                       }
+               });
+               addField(wesnothExecutableField_);
+
+               ModifyListener stateChecker = new ModifyListener() {
+                       @Override
+                       public void modifyText(ModifyEvent e)
+                       {
+                               checkState();
+                       }
+               };
+
+               wesnothWorkingDirField_ = new 
DirectoryFieldEditor(Constants.P_WESNOTH_WORKING_DIR,
+                               "Working directory:", getFieldEditorParent());
+               addField(wesnothWorkingDirField_);
+
+               wesnothUserDirField_ = new 
DirectoryFieldEditor(Constants.P_WESNOTH_USER_DIR,
+                               "User data directory:", 
getFieldEditorParent());
+               addField(wesnothUserDirField_);
 
                wmlToolsField_ = new 
DirectoryFieldEditor(Constants.P_WESNOTH_WMLTOOLS_DIR,
                                "WML* tools directory:", 
getFieldEditorParent());
+               wmlToolsField_.getTextControl(getFieldEditorParent()).
+                                       addModifyListener(stateChecker);
                addField(wmlToolsField_);
        }
 

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=44583&r1=44582&r2=44583&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
 Fri Jul 23 16:25:57 2010
@@ -8,7 +8,6 @@
  
*******************************************************************************/
 package wesnoth_eclipse_plugin.utils;
 
-import java.io.File;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
@@ -107,13 +106,13 @@
        {
                List<String> args = new ArrayList<String>();
                String wesnothExec = 
Preferences.getString(Constants.P_WESNOTH_EXEC_PATH);
-               if (wesnothExec.isEmpty())
+               String workingDir = 
Preferences.getString(Constants.P_WESNOTH_WORKING_DIR);
+               if (wesnothExec.isEmpty() || workingDir.isEmpty())
                {
                        GUIUtils.showErrorMessageBox("Please set the 
wesnoth's executable path first.");
                        return;
                }
 
-               String workingDir = 
Preferences.getString(Constants.P_WESNOTH_WORKING_DIR);
 
                if (extraArgs != null)
                        args.addAll(extraArgs);
@@ -121,10 +120,6 @@
                // add the user's data directory path
                args.add("--config-dir");
                args.add(Preferences.getString(Constants.P_WESNOTH_USER_DIR));
-
-               if (workingDir.isEmpty())
-                       workingDir = wesnothExec.substring(0,
-                                       wesnothExec.lastIndexOf(new 
File(wesnothExec).getName()));
 
                // we need to add the working dir (backward compatibility)
                args.add(workingDir);




Related Messages


Powered by MHonArc, Updated Fri Jul 23 16:40:14 2010