Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / internal / registry / ExternalToolMigration.java
index 0a4d892..2a47c79 100644 (file)
@@ -9,29 +9,29 @@ package net.sourceforge.phpdt.externaltools.internal.registry;
  Contributors:
  **********************************************************************/
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
+//import java.io.File;
+//import java.io.FileInputStream;
+//import java.io.FileNotFoundException;
+//import java.io.IOException;
+//import java.io.InputStreamReader;
 import java.util.ArrayList;
-import java.util.HashMap;
+//import java.util.HashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
 
 import net.sourceforge.phpdt.externaltools.model.IExternalToolConstants;
 import net.sourceforge.phpdt.externaltools.model.ToolUtil;
-import net.sourceforge.phpeclipse.externaltools.ExternalToolsPlugin;
+//import net.sourceforge.phpeclipse.externaltools.ExternalToolsPlugin;
 
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
+//import org.eclipse.core.runtime.IPath;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunchConfigurationType;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.XMLMemento;
+//import org.eclipse.ui.IMemento;
+//import org.eclipse.ui.WorkbenchException;
+//import org.eclipse.ui.XMLMemento;
 
 /**
  * Responsible reading an old external tool format and creating and migrating it
@@ -40,15 +40,15 @@ import org.eclipse.ui.XMLMemento;
 public final class ExternalToolMigration {
        //private static final String SEPERATOR = ";"; //$NON-NLS-1$    
 
-       private static final String STATE_FILE_NAME_OLD = "oldexternaltools.xml"; //$NON-NLS-1$
+       //private static final String STATE_FILE_NAME_OLD = "oldexternaltools.xml"; //$NON-NLS-1$
 
-       private static final String STATE_FILE_NAME = "externaltools.xml"; //$NON-NLS-1$
+       //private static final String STATE_FILE_NAME = "externaltools.xml"; //$NON-NLS-1$
 
        //private static final String TAG_EXTERNALTOOLS = "externaltools"; //$NON-NLS-1$
 
-       private static final String TAG_TOOL = "tool"; //$NON-NLS-1$
+       //private static final String TAG_TOOL = "tool"; //$NON-NLS-1$
 
-       private static final String TAG_ENTRY = "entry"; //$NON-NLS-1$
+       //private static final String TAG_ENTRY = "entry"; //$NON-NLS-1$
 
        // private static final String TAG_KEY = "key"; //$NON-NLS-1$
 //     private static final String TAG_VALUE = "value"; //$NON-NLS-1$
@@ -123,7 +123,7 @@ public final class ExternalToolMigration {
 
        private static final String TAG_EXTRA_ATTR = "extraAttribute"; //$NON-NLS-1$
 
-       private static final String TAG_KEY = "key"; //$NON-NLS-1$
+       //private static final String TAG_KEY = "key"; //$NON-NLS-1$
 
        private static final String TAG_VERSION = "version"; //$NON-NLS-1$
 
@@ -158,75 +158,75 @@ public final class ExternalToolMigration {
 //     private static void readIn21Tools() {
 //     }
 
-       public static void readIn20Tools() {
-               boolean migrationSuccessful = true;
-               IPath path = ExternalToolsPlugin.getDefault().getStateLocation();
-               File file = path.append(STATE_FILE_NAME).toFile();
-               if (!file.exists())
-                       return;
-
-               InputStreamReader reader = null;
-               try {
-                       FileInputStream input = new FileInputStream(file);
-                       reader = new InputStreamReader(input, "utf-8"); //$NON-NLS-1$
-                       XMLMemento memento = XMLMemento.createReadRoot(reader);
-
-                       // Get the external tool children element
-                       IMemento[] tools = memento.getChildren(TAG_TOOL);
-                       for (int i = 0; i < tools.length; i++) {
-                               HashMap args = new HashMap();
-                               IMemento[] entries = tools[i].getChildren(TAG_ENTRY);
-                               for (int j = 0; j < entries.length; j++) {
-                                       String key = entries[j].getString(TAG_KEY);
-                                       if (key != null) {
-                                               String value = entries[j].getTextData();
-                                               args.put(key, value);
-                                       }
-                               }
-                               ILaunchConfigurationWorkingCopy config = configFromArgumentMap(args);
-                               if (config != null) {
-                                       try {
-                                               config.doSave();
-                                       } catch (CoreException e) {
-                                               // TODO: Decide what to do when saving fails.
-                                       }
-                               }
-                       }
-               } catch (FileNotFoundException e) {
-                       // Silently ignore this...
-               } catch (IOException e) {
-                       ExternalToolsPlugin.getDefault().log(
-                                       "File I/O error with reading old external tools.", e);
-                       migrationSuccessful = false;
-               } catch (WorkbenchException e) {
-                       ExternalToolsPlugin.getDefault().getLog().log(e.getStatus());
-                       System.err
-                                       .println("Error reading old external tools. See .log file for more details");
-                       migrationSuccessful = false;
-               } finally {
-                       if (reader != null) {
-                               try {
-                                       reader.close();
-                               } catch (IOException e) {
-                                       ExternalToolsPlugin.getDefault().log(
-                                                       "Unable to close external tool old state reader.",
-                                                       e);
-                               }
-                       }
-               }
-
-               if (migrationSuccessful) {
-                       if (!file.renameTo(path.append(STATE_FILE_NAME_OLD).toFile())) {
-                               ExternalToolsPlugin
-                                               .getDefault()
-                                               .log(
-                                                               "Unable to rename old external tool state file. Please rename externaltools.xml to oldexternaltools.xml manually.",
-                                                               null);
-                               System.err
-                                               .println("Unable to rename old external tool state file. Please rename externaltools.xml to oldexternaltools.xml manually.");
-                       }
-               }
-       }
+//     public static void readIn20Tools() {
+//             boolean migrationSuccessful = true;
+//             IPath path = ExternalToolsPlugin.getDefault().getStateLocation();
+//             File file = path.append(STATE_FILE_NAME).toFile();
+//             if (!file.exists())
+//                     return;
+//
+//             InputStreamReader reader = null;
+//             try {
+//                     FileInputStream input = new FileInputStream(file);
+//                     reader = new InputStreamReader(input, "utf-8"); //$NON-NLS-1$
+//                     XMLMemento memento = XMLMemento.createReadRoot(reader);
+//
+//                     // Get the external tool children element
+//                     IMemento[] tools = memento.getChildren(TAG_TOOL);
+//                     for (int i = 0; i < tools.length; i++) {
+//                             HashMap args = new HashMap();
+//                             IMemento[] entries = tools[i].getChildren(TAG_ENTRY);
+//                             for (int j = 0; j < entries.length; j++) {
+//                                     String key = entries[j].getString(TAG_KEY);
+//                                     if (key != null) {
+//                                             String value = entries[j].getTextData();
+//                                             args.put(key, value);
+//                                     }
+//                             }
+//                             ILaunchConfigurationWorkingCopy config = configFromArgumentMap(args);
+//                             if (config != null) {
+//                                     try {
+//                                             config.doSave();
+//                                     } catch (CoreException e) {
+//                                             // TODO: Decide what to do when saving fails.
+//                                     }
+//                             }
+//                     }
+//             } catch (FileNotFoundException e) {
+//                     // Silently ignore this...
+//             } catch (IOException e) {
+//                     ExternalToolsPlugin.getDefault().log(
+//                                     "File I/O error with reading old external tools.", e);
+//                     migrationSuccessful = false;
+//             } catch (WorkbenchException e) {
+//                     ExternalToolsPlugin.getDefault().getLog().log(e.getStatus());
+//                     System.err
+//                                     .println("Error reading old external tools. See .log file for more details");
+//                     migrationSuccessful = false;
+//             } finally {
+//                     if (reader != null) {
+//                             try {
+//                                     reader.close();
+//                             } catch (IOException e) {
+//                                     ExternalToolsPlugin.getDefault().log(
+//                                                     "Unable to close external tool old state reader.",
+//                                                     e);
+//                             }
+//                     }
+//             }
+//
+//             if (migrationSuccessful) {
+//                     if (!file.renameTo(path.append(STATE_FILE_NAME_OLD).toFile())) {
+//                             ExternalToolsPlugin
+//                                             .getDefault()
+//                                             .log(
+//                                                             "Unable to rename old external tool state file. Please rename externaltools.xml to oldexternaltools.xml manually.",
+//                                                             null);
+//                             System.err
+//                                             .println("Unable to rename old external tool state file. Please rename externaltools.xml to oldexternaltools.xml manually.");
+//                     }
+//             }
+//     }
 
        /**
         * Returns a launch configuration working copy from the argument map or
@@ -426,12 +426,12 @@ public final class ExternalToolMigration {
         * Returns the tool name extracted from the given command argument map.
         * Extraction is attempted using 2.0 and 2.1 external tool formats.
         */
-       public static String getNameFromCommandArgs(Map commandArgs) {
-               String name = (String) commandArgs.get(TAG_NAME);
-               if (name == null) {
-                       name = (String) commandArgs.get(TAG_TOOL_NAME);
-               }
-               return name;
-       }
+//     public static String getNameFromCommandArgs(Map commandArgs) {
+//             String name = (String) commandArgs.get(TAG_NAME);
+//             if (name == null) {
+//                     name = (String) commandArgs.get(TAG_TOOL_NAME);
+//             }
+//             return name;
+//     }
 
 }