Changeset 604 for AE/installer2/src/net/oni2
- Timestamp:
- Jan 12, 2013, 11:48:33 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller
- Files:
-
- 8 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/AEInstaller.properties
r602 r604 1 1 appname=AE Installer 2 2 appversion=0. 552 appversion=0.62 3 3 4 4 invalidPath.title=Wrong directory -
AE/installer2/src/net/oni2/aeinstaller/backend/Settings.java
r600 r604 66 66 67 67 private boolean printNamesNotInMap = false; 68 68 69 69 /** 70 70 * Get the singleton instance -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotConfig.java
r602 r604 61 61 return "Package"; 62 62 } 63 63 64 64 /** 65 65 * @return Taxonomy term name for modtype Tool … … 68 68 return "Tool"; 69 69 } 70 71 /** 72 * @return First package number that's not a mandatory tool/mod. Everything 73 * below is considered mandatory 74 */ 75 public static int getMandatoryLimit() { 76 return 8000; 77 } 70 78 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/Mod.java
r603 r604 13 13 import net.oni2.aeinstaller.backend.Settings; 14 14 import net.oni2.aeinstaller.backend.Settings.Platform; 15 import net.oni2.aeinstaller.backend.depot.DepotConfig; 15 16 import net.oni2.aeinstaller.backend.depot.DepotManager; 16 17 import net.oni2.aeinstaller.backend.depot.model.NodeMod; … … 21 22 */ 22 23 public class Mod implements Comparable<Mod> { 23 // TODO: Dependencies/Conflicts24 25 24 private String name = ""; 26 25 private int packageNumber = 0; … … 76 75 public void updateLocalData() { 77 76 File config = new File(getLocalPath(), "Mod_Info.cfg"); 78 File timestamp= new File(getLocalPath(), "aei.cfg");77 File aeicfg = new File(getLocalPath(), "aei.cfg"); 79 78 if (config.exists()) { 80 79 try { … … 112 111 if (node == null) 113 112 description = sVal.replaceAll("\\\\n", "<br>"); 113 } else if (sName.equalsIgnoreCase("Depends")) { 114 String[] depsS = sVal.split(","); 115 for (String s : depsS) { 116 try { 117 int dep = Integer.parseInt(s); 118 dependencies.add(dep); 119 } catch (NumberFormatException e) { 120 System.err 121 .format("Mod %05d does contain a non-number dependency: '%s'\n", 122 packageNumber, s); 123 } 124 } 125 } else if (sName.equalsIgnoreCase("Conflicts")) { 126 String[] confS = sVal.split(","); 127 for (String s : confS) { 128 try { 129 int conf = Integer.parseInt(s); 130 conflicts.add(conf); 131 } catch (NumberFormatException e) { 132 System.err 133 .format("Mod %05d does contain a non-number dependency: '%s'\n", 134 packageNumber, s); 135 } 136 } 114 137 } 115 138 } … … 123 146 + getLocalPath().getPath()); 124 147 } 125 if ( timestamp.exists()) {148 if (aeicfg.exists()) { 126 149 try { 127 FileInputStream fstream = new FileInputStream( timestamp);150 FileInputStream fstream = new FileInputStream(aeicfg); 128 151 InputStreamReader isr = new InputStreamReader(fstream); 129 152 BufferedReader br = new BufferedReader(isr); 130 String ts = br.readLine(); 131 localTimestamp = Long.parseLong(ts); 153 String strLine; 154 while ((strLine = br.readLine()) != null) { 155 if (strLine.indexOf("->") < 1) 156 continue; 157 if (strLine.indexOf("//") >= 0) 158 strLine = strLine.substring(0, strLine.indexOf("//")); 159 String[] split = strLine.split("->", 2); 160 String sName = split[0].trim(); 161 String sVal = split[1].trim(); 162 if (sName.equalsIgnoreCase("Timestamp")) { 163 localTimestamp = Long.parseLong(sVal); 164 } 165 } 132 166 isr.close(); 133 167 } catch (FileNotFoundException e) { … … 214 248 215 249 /** 250 * @return the package number as 5 digit string 251 */ 252 public String getPackageNumberString() { 253 return String.format("%05d", packageNumber); 254 } 255 256 /** 216 257 * @return Types of mod 217 258 */ … … 266 307 */ 267 308 public boolean isMandatoryMod() { 268 return packageNumber < 10000;309 return packageNumber < DepotConfig.getMandatoryLimit(); 269 310 } 270 311 -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/ModManager.java
r603 r604 3 3 import java.io.File; 4 4 import java.io.FileFilter; 5 import java.io.FileInputStream; 6 import java.io.FileNotFoundException; 7 import java.io.FileOutputStream; 8 import java.io.IOException; 5 9 import java.util.Collection; 6 10 import java.util.HashMap; … … 9 13 import java.util.Vector; 10 14 15 import com.thoughtworks.xstream.XStream; 16 import com.thoughtworks.xstream.io.xml.StaxDriver; 17 11 18 import net.oni2.aeinstaller.backend.Paths; 12 19 import net.oni2.aeinstaller.backend.depot.DepotManager; 13 20 import net.oni2.aeinstaller.backend.depot.model.NodeMod; 14 21 import net.oni2.aeinstaller.backend.depot.model.TaxonomyTerm; 22 import net.oni2.aeinstaller.backend.oni.Installer; 15 23 16 24 /** … … 18 26 */ 19 27 public class ModManager { 20 // Download mods21 // Update mods22 23 28 private static ModManager instance = new ModManager(); 24 29 … … 26 31 private HashMap<Integer, Mod> mods = new HashMap<Integer, Mod>(); 27 32 private HashMap<Integer, Mod> tools = new HashMap<Integer, Mod>(); 33 34 private Vector<Integer> currentlyInstalled = new Vector<Integer>(); 35 36 /** 37 * @param f 38 * Mod selection file 39 * @return Mod selection 40 */ 41 @SuppressWarnings("unchecked") 42 public Vector<Integer> loadModSelection(File f) { 43 Vector<Integer> res = new Vector<Integer>(); 44 try { 45 FileInputStream fis = new FileInputStream(f); 46 XStream xs = new XStream(new StaxDriver()); 47 Object obj = xs.fromXML(fis); 48 if (obj instanceof Vector<?>) 49 res = (Vector<Integer>) obj; 50 fis.close(); 51 } catch (FileNotFoundException e) { 52 e.printStackTrace(); 53 } catch (IOException e) { 54 e.printStackTrace(); 55 } 56 return res; 57 } 58 59 /** 60 * @param f 61 * Mod selection file 62 * @param mods 63 * Selected mods 64 */ 65 public void saveModSelection(File f, TreeSet<Mod> mods) { 66 try { 67 Vector<Integer> installed = new Vector<Integer>(); 68 for (Mod m : mods) { 69 installed.add(m.getPackageNumber()); 70 } 71 FileOutputStream fos = new FileOutputStream(f); 72 XStream xs = new XStream(new StaxDriver()); 73 xs.toXML(installed, fos); 74 fos.close(); 75 } catch (FileNotFoundException e) { 76 e.printStackTrace(); 77 } catch (IOException e) { 78 e.printStackTrace(); 79 } 80 } 28 81 29 82 /** … … 69 122 mods.put(m.getPackageNumber(), m); 70 123 } 71 } 72 73 public void refreshLocalMods() {74 // TODO: evtl nur private e.g. als listener für downloads?124 125 currentlyInstalled = Installer.getInstalledMods(); 126 if (currentlyInstalled == null) 127 currentlyInstalled = new Vector<Integer>(); 75 128 } 76 129 … … 108 161 * @return Mods which are always installed 109 162 */ 110 public Collection<Mod> getMandatoryMods() {111 Vector<Mod> res = new Vector<Mod>();163 public TreeSet<Mod> getMandatoryMods() { 164 TreeSet<Mod> res = new TreeSet<Mod>(); 112 165 for (Mod m : mods.values()) { 113 166 if (m.isMandatoryMod()) … … 116 169 return res; 117 170 } 118 171 119 172 /** 120 173 * @return Collection of tools … … 123 176 return tools.values(); 124 177 } 125 178 126 179 /** 127 180 * @return Tools which are always installed 128 181 */ 129 public Collection<Mod> getMandatoryTools() {130 Vector<Mod> res = new Vector<Mod>();182 public TreeSet<Mod> getMandatoryTools() { 183 TreeSet<Mod> res = new TreeSet<Mod>(); 131 184 for (Mod m : tools.values()) { 132 185 if (m.isMandatoryMod()) … … 201 254 } 202 255 256 /** 257 * @param m 258 * Mod to check 259 * @return Is mod installed? 260 */ 261 public boolean isModInstalled(Mod m) { 262 return currentlyInstalled.contains(m.getPackageNumber()); 263 } 203 264 } -
AE/installer2/src/net/oni2/aeinstaller/backend/network/FileDownloader.java
r591 r604 94 94 t.start(); 95 95 state = EState.RUNNING; 96 updateStatus(downloaded, size); 96 97 } 97 98 } … … 107 108 else 108 109 state = EState.RUNNING; 110 updateStatus(downloaded, size); 109 111 } 110 112 } … … 114 116 */ 115 117 public synchronized void stop() { 116 state = EState.INTERRUPTED; 117 try { 118 t.join(); 119 } catch (InterruptedException e) { 120 // TODO Auto-generated catch block 121 e.printStackTrace(); 122 } 123 updateStatus(0, 1); 124 t = null; 125 if (target.exists()) 126 target.delete(); 118 if (state != EState.FINISHED) { 119 state = EState.INTERRUPTED; 120 if (t != null) { 121 try { 122 t.join(); 123 } catch (InterruptedException e) { 124 // TODO Auto-generated catch block 125 e.printStackTrace(); 126 } 127 t = null; 128 } 129 updateStatus(0, 1); 130 if (target.exists()) 131 target.delete(); 132 } 127 133 } 128 134 … … 147 153 e1.printStackTrace(); 148 154 state = EState.ERROR; 155 updateStatus(downloaded, fileLength); 149 156 return; 150 157 } 151 158 152 while (downloaded < fileLength) { 153 switch (state) { 154 case ERROR: 155 updateStatus(downloaded, fileLength); 156 return; 157 case PAUSED: 158 try { 159 Thread.sleep(100); 160 } catch (InterruptedException e) { 161 e.printStackTrace(); 162 } 163 break; 164 case INTERRUPTED: 165 return; 166 case RUNNING: 167 BufferedInputStream input = null; 168 try { 169 URLConnection connection = url.openConnection(); 170 if (downloaded == 0) { 171 connection.connect(); 172 strLastModified = connection 173 .getHeaderField("Last-Modified"); 174 strEtag = connection.getHeaderField("ETag"); 175 fileLength = connection.getContentLength(); 176 } else { 177 connection.setRequestProperty("Range", "bytes=" 178 + downloaded + "-"); 179 if (strEtag != null) 180 connection.setRequestProperty("If-Range", 181 strEtag); 182 else 183 connection.setRequestProperty("If-Range", 184 strLastModified); 185 connection.connect(); 159 try { 160 while (downloaded < fileLength) { 161 switch (state) { 162 case ERROR: 163 updateStatus(downloaded, fileLength); 164 return; 165 case PAUSED: 166 try { 167 Thread.sleep(100); 168 } catch (InterruptedException e) { 169 e.printStackTrace(); 186 170 } 187 188 // Setup streams and buffers. 189 input = new BufferedInputStream( 190 connection.getInputStream(), 8192); 191 if (downloaded > 0) 192 outFile.seek(downloaded); 193 byte data[] = new byte[1024]; 194 195 // Download file. 196 int dataRead = 0; 197 int i = 0; 198 while (((dataRead = input.read(data, 0, 1024)) != -1) 199 && (state == EState.RUNNING)) { 200 outFile.write(data, 0, dataRead); 201 downloaded += dataRead; 202 if (downloaded >= fileLength) 203 break; 204 205 i++; 206 if ((i % 10) == 0) 207 updateStatus(downloaded, fileLength); 171 break; 172 case INTERRUPTED: 173 return; 174 case RUNNING: 175 BufferedInputStream input = null; 176 try { 177 URLConnection connection = url.openConnection(); 178 if (downloaded == 0) { 179 connection.connect(); 180 strLastModified = connection 181 .getHeaderField("Last-Modified"); 182 strEtag = connection.getHeaderField("ETag"); 183 fileLength = connection.getContentLength(); 184 } else { 185 connection.setRequestProperty("Range", "bytes=" 186 + downloaded + "-"); 187 if (strEtag != null) 188 connection.setRequestProperty("If-Range", 189 strEtag); 190 else 191 connection.setRequestProperty("If-Range", 192 strLastModified); 193 connection.connect(); 194 } 195 196 // Setup streams and buffers. 197 input = new BufferedInputStream( 198 connection.getInputStream(), 8192); 199 if (downloaded > 0) 200 outFile.seek(downloaded); 201 byte data[] = new byte[1024]; 202 203 // Download file. 204 int dataRead = 0; 205 int i = 0; 206 while (((dataRead = input.read(data, 0, 1024)) != -1) 207 && (state == EState.RUNNING)) { 208 outFile.write(data, 0, dataRead); 209 downloaded += dataRead; 210 if (downloaded >= fileLength) 211 break; 212 213 i++; 214 if ((i % 10) == 0) 215 updateStatus(downloaded, fileLength); 216 } 217 input.close(); 218 } catch (IOException e) { 219 // TODO Auto-generated catch block 220 e.printStackTrace(); 221 try { 222 if (input != null) 223 input.close(); 224 } catch (IOException e2) { 225 e2.printStackTrace(); 226 } 208 227 } 209 input.close(); 210 } catch (IOException e) { 211 // TODO Auto-generated catch block 212 e.printStackTrace(); 213 try { 214 if (input != null) 215 input.close(); 216 } catch (IOException e2) { 217 e2.printStackTrace(); 218 } 219 } 220 break; 221 default: 222 break; 228 break; 229 default: 230 break; 231 } 223 232 } 224 } 225 226 try {227 // Close streams.228 outFile.close();229 } catch (IOException e) {230 e.printStackTrace();233 } finally { 234 try { 235 // Close streams. 236 outFile.close(); 237 } catch (IOException e) { 238 e.printStackTrace(); 239 } 231 240 } 232 241 -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java
r603 r604 19 19 import net.oni2.aeinstaller.backend.Settings.Platform; 20 20 import net.oni2.aeinstaller.backend.mods.Mod; 21 import net.oni2.aeinstaller.backend.mods.ModManager; 21 22 22 23 import org.apache.commons.io.FileUtils; … … 39 40 } 40 41 42 /** 43 * @return list of currently installed mods 44 */ 45 public static Vector<Integer> getInstalledMods() { 46 File installCfg = new File(Paths.getEditionGDF(), "installed_mods.xml"); 47 return ModManager.getInstance().loadModSelection(installCfg); 48 } 49 50 /** 51 * @param tools 52 * Tools to install 53 */ 54 public static void installTools(TreeSet<Mod> tools) { 55 for (Mod m : tools) { 56 File plain = new File(m.getLocalPath(), "plain"); 57 if (plain.exists()) { 58 if (m.hasSeparatePlatformDirs()) { 59 File plainCommon = new File(plain, "common"); 60 File plainMac = new File(plain, "mac_only"); 61 File plainWin = new File(plain, "win_only"); 62 if (plainCommon.exists()) 63 copyToolsFiles(plainCommon); 64 if (Settings.getPlatform() == Platform.MACOS 65 && plainMac.exists()) 66 copyToolsFiles(plainMac); 67 else if (plainWin.exists()) 68 copyToolsFiles(plainWin); 69 } else { 70 copyToolsFiles(plain); 71 } 72 } 73 } 74 } 75 76 /** 77 * @param tools 78 * Tools to uninstall 79 */ 80 public static void uninstallTools(TreeSet<Mod> tools) { 81 // TODO: implement this! 82 } 83 84 private static void copyToolsFiles(File srcFolder) { 85 for (File f : srcFolder.listFiles()) { 86 try { 87 if (f.isDirectory()) 88 FileUtils.copyDirectoryToDirectory(f, 89 Paths.getEditionBasePath()); 90 else 91 FileUtils 92 .copyFileToDirectory(f, Paths.getEditionBasePath()); 93 } catch (IOException e) { 94 // TODO Auto-generated catch block 95 e.printStackTrace(); 96 } 97 } 98 } 41 99 /** 42 100 * Install the given set of mods … … 49 107 public static void install(TreeSet<Mod> mods, 50 108 InstallProgressListener listener) { 109 try { 110 createEmptyPath(Paths.getEditionGDF()); 111 } catch (IOException e) { 112 e.printStackTrace(); 113 } 114 115 File installCfg = new File(Paths.getEditionGDF(), "installed_mods.xml"); 116 ModManager.getInstance().saveModSelection(installCfg, mods); 117 51 118 Vector<File> folders = new Vector<File>(); 52 119 folders.add(Paths.getVanillaOnisPath()); … … 79 146 private static void combineBinaryFiles(List<File> srcFoldersFiles, 80 147 InstallProgressListener listener) { 148 HashMap<String, Vector<File>> levels = new HashMap<String, Vector<File>>(); 149 150 for (File path : srcFoldersFiles) { 151 for (File levelF : path.listFiles()) { 152 String fn = levelF.getName().toLowerCase(); 153 String levelN = null; 154 if (levelF.isDirectory()) { 155 levelN = fn; 156 } else if (fn.endsWith(".dat")) { 157 levelN = fn.substring(0, fn.lastIndexOf('.')); 158 } 159 if (levelN != null) { 160 if (!levels.containsKey(levelN)) 161 levels.put(levelN, new Vector<File>()); 162 levels.get(levelN).add(levelF); 163 } 164 } 165 } 166 167 int totalSteps = 0; 168 int stepsDone = 0; 169 170 for (@SuppressWarnings("unused") 171 String s : levels.keySet()) 172 totalSteps++; 173 174 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 175 176 File logFile = new File(Paths.getInstallerPath(), "Installation.log"); 177 PrintWriter log = null; 81 178 try { 82 HashMap<String, Vector<File>> levels = new HashMap<String, Vector<File>>(); 83 84 for (File path : srcFoldersFiles) { 85 for (File levelF : path.listFiles()) { 86 String fn = levelF.getName().toLowerCase(); 87 String levelN = null; 88 if (levelF.isDirectory()) { 89 levelN = fn; 90 } else if (fn.endsWith(".dat")) { 91 levelN = fn.substring(0, fn.lastIndexOf('.')); 92 } 93 if (levelN != null) { 94 if (!levels.containsKey(levelN)) 95 levels.put(levelN, new Vector<File>()); 96 levels.get(levelN).add(levelF); 97 } 98 } 99 } 100 101 int totalSteps = 0; 102 int stepsDone = 0; 103 104 for (@SuppressWarnings("unused") 105 String s : levels.keySet()) 106 totalSteps++; 107 108 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 109 110 File logFile = new File(Paths.getInstallerPath(), 111 "Installation.log"); 112 PrintWriter log = null; 113 try { 114 log = new PrintWriter(logFile); 115 } catch (FileNotFoundException e) { 116 e.printStackTrace(); 117 } 118 119 Date start = new Date(); 120 log.println("Installation of mods started at " + sdf.format(start)); 121 122 log.println("Cleaning directories"); 179 log = new PrintWriter(logFile); 180 } catch (FileNotFoundException e) { 181 e.printStackTrace(); 182 } 183 184 Date start = new Date(); 185 log.println("Installation of mods started at " + sdf.format(start)); 186 187 log.println("Importing levels"); 188 for (String l : levels.keySet()) { 189 log.println("\tLevel " + l); 123 190 listener.installProgressUpdate(stepsDone, totalSteps, 124 "Cleaning up directories"); 125 126 createEmptyPath(Paths.getEditionGDF()); 127 128 log.println("Importing levels"); 129 for (String l : levels.keySet()) { 130 log.println("\tLevel " + l); 131 for (File f : levels.get(l)) { 132 log.println("\t\t\t" + f.getPath()); 133 } 134 135 Vector<String> res = OniSplit.packLevel(levels.get(l), 136 new File(Paths.getEditionGDF(), l + ".dat")); 137 if (res != null && res.size() > 0) { 138 for (String s : res) 139 log.println("\t\t" + s); 140 } 141 142 log.println(); 143 } 144 145 Date end = new Date(); 146 log.println("Initialization ended at " + sdf.format(end)); 147 log.println("Process took " 148 + ((end.getTime() - start.getTime()) / 1000) + " seconds"); 149 log.close(); 150 } catch (IOException e) { 151 // TODO Auto-generated catch block 152 e.printStackTrace(); 153 } 191 "Installing level " + l); 192 for (File f : levels.get(l)) { 193 log.println("\t\t\t" + f.getPath()); 194 } 195 196 Vector<String> res = OniSplit.packLevel(levels.get(l), new File( 197 Paths.getEditionGDF(), l + ".dat")); 198 if (res != null && res.size() > 0) { 199 for (String s : res) 200 log.println("\t\t" + s); 201 } 202 203 log.println(); 204 } 205 206 Date end = new Date(); 207 log.println("Initialization ended at " + sdf.format(end)); 208 log.println("Process took " 209 + ((end.getTime() - start.getTime()) / 1000) + " seconds"); 210 log.close(); 154 211 } 155 212 … … 273 330 274 331 FileUtils.deleteDirectory(init); 275 332 276 333 Date end = new Date(); 277 334 log.println("Initialization ended at " + sdf.format(end)); … … 387 444 388 445 /** 389 * Verify that the Edition is within a subfolder to vanilla Oni (..../Oni/Edition/AEInstaller) 446 * Verify that the Edition is within a subfolder to vanilla Oni 447 * (..../Oni/Edition/AEInstaller) 448 * 390 449 * @return true if GDF can be found in the parent's parent-path 391 450 */ 392 451 public static boolean verifyRunningDirectory() { 393 return Paths.getVanillaGDF().exists() && Paths.getVanillaGDF().isDirectory(); 452 return Paths.getVanillaGDF().exists() 453 && Paths.getVanillaGDF().isDirectory(); 394 454 } 395 455 } -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r603 r604 1 1 package net.oni2.aeinstaller.gui; 2 2 3 import java.io.File; 3 4 import java.util.ArrayList; 4 5 import java.util.List; … … 10 11 import javax.swing.JComboBox; 11 12 import javax.swing.JComponent; 13 import javax.swing.JFileChooser; 12 14 import javax.swing.JFrame; 13 15 import javax.swing.JLabel; … … 22 24 import javax.swing.event.ListSelectionEvent; 23 25 import javax.swing.event.ListSelectionListener; 26 import javax.swing.filechooser.FileFilter; 24 27 import javax.swing.table.TableRowSorter; 25 28 29 import net.oni2.aeinstaller.backend.Paths; 26 30 import net.oni2.aeinstaller.backend.Settings; 27 31 import net.oni2.aeinstaller.backend.Settings.Platform; … … 32 36 import net.oni2.aeinstaller.backend.mods.ModManager; 33 37 import net.oni2.aeinstaller.backend.mods.Type; 38 import net.oni2.aeinstaller.backend.mods.download.ModDownloader; 39 import net.oni2.aeinstaller.backend.mods.download.ModDownloader.State; 40 import net.oni2.aeinstaller.backend.mods.download.ModDownloaderListener; 34 41 import net.oni2.aeinstaller.backend.oni.InstallProgressListener; 35 42 import net.oni2.aeinstaller.backend.oni.Installer; … … 222 229 } 223 230 231 private JFileChooser getConfigOpenSaveDialog(boolean save) { 232 JFileChooser fc = new JFileChooser(); 233 fc.setCurrentDirectory(Paths.getEditionBasePath()); 234 if (save) 235 fc.setDialogType(JFileChooser.SAVE_DIALOG); 236 else 237 fc.setDialogType(JFileChooser.OPEN_DIALOG); 238 fc.setFileSelectionMode(JFileChooser.FILES_ONLY); 239 fc.setFileFilter(new FileFilter() { 240 @Override 241 public String getDescription() { 242 return "XML files"; 243 } 244 245 @Override 246 public boolean accept(File arg0) { 247 return (arg0.isDirectory()) 248 || (arg0.getName().toLowerCase().endsWith(".xml")); 249 } 250 }); 251 fc.setMultiSelectionEnabled(false); 252 return fc; 253 } 254 224 255 @SuppressWarnings("unused") 225 256 private void loadConfig() { 226 // TODO method stub 227 JOptionPane.showMessageDialog(this, "loadConfig", "todo", 228 JOptionPane.INFORMATION_MESSAGE); 257 JFileChooser fc = getConfigOpenSaveDialog(false); 258 int res = fc.showOpenDialog(this); 259 if (res == JFileChooser.APPROVE_OPTION) { 260 if (fc.getSelectedFile().exists()) 261 model.reloadSelection(fc.getSelectedFile()); 262 } 229 263 } 230 264 231 265 @SuppressWarnings("unused") 232 266 private void saveConfig() { 233 // TODO method stub 234 JOptionPane.showMessageDialog(this, "saveConfig", "todo", 235 JOptionPane.INFORMATION_MESSAGE); 267 JFileChooser fc = getConfigOpenSaveDialog(true); 268 int res = fc.showSaveDialog(this); 269 if (res == JFileChooser.APPROVE_OPTION) { 270 File f = fc.getSelectedFile(); 271 if (!f.getName().endsWith(".xml")) 272 f = new File(f.getParentFile(), f.getName() + ".xml"); 273 ModManager.getInstance().saveModSelection(f, 274 model.getSelectedMods()); 275 } 236 276 } 237 277 … … 257 297 @SuppressWarnings("unused") 258 298 private void revertSelection() { 259 // TODO method stub 260 JOptionPane.showMessageDialog(this, "revertSelection", "todo", 261 JOptionPane.INFORMATION_MESSAGE); 299 model.revertSelection(); 262 300 } 263 301 264 302 @DoInBackground(progressMessage = "mandatoryFiles.title", cancelable = false, indeterminateProgress = false) 265 303 private void checkMandatoryFiles(final BackgroundEvent evt) { 266 //TODO 267 System.out.println("Mandatory Tools:"); 304 TreeSet<Mod> mand = new TreeSet<Mod>(); 268 305 for (Mod m : ModManager.getInstance().getMandatoryTools()) { 269 System.out.format(" %05d %15s - Local: %b - Update: %b", m.getPackageNumber(), m.getName(), m.isLocalAvailable(), m.isNewerAvailable()); 270 } 271 System.out.println(); 272 273 System.out.println("Mandatory Mods:"); 306 if (m.isNewerAvailable()) { 307 mand.add(m); 308 } 309 } 274 310 for (Mod m : ModManager.getInstance().getMandatoryMods()) { 275 System.out.format(" %05d %15s - Local: %b - Update: %b", m.getPackageNumber(), m.getName(), m.isLocalAvailable(), m.isNewerAvailable()); 276 } 311 if (m.isNewerAvailable()) { 312 mand.add(m); 313 } 314 } 315 if (mand.size() > 0) { 316 ModDownloader m = new ModDownloader(mand, 317 new ModDownloaderListener() { 318 @Override 319 public void updateStatus(ModDownloader source, 320 State state, int filesDown, int filesTotal, 321 int bytesDown, int bytesTotal) { 322 evt.setProgressEnd(filesTotal); 323 evt.setProgressValue(filesDown); 324 } 325 }); 326 while (!m.isFinished()) { 327 try { 328 Thread.sleep(50); 329 } catch (InterruptedException e) { 330 // TODO Auto-generated catch block 331 e.printStackTrace(); 332 } 333 } 334 } 335 evt.setProgressMessage(bundle.getString("mandatoryToolsInstall.title")); 336 Installer.installTools(ModManager.getInstance().getMandatoryTools()); 277 337 } 278 338 … … 287 347 System.out.println("Install mods:"); 288 348 for (Mod m : mods) { 289 System.out 290 .println(" " + m.getPackageNumber() + ": "+ m.getName());349 System.out.println(" " + m.getPackageNumberString() + ": " 350 + m.getName()); 291 351 } 292 352 -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.properties
r602 r604 47 47 installing.title=Installing mods 48 48 mandatoryFiles.title=Checking for mandatory files 49 mandatoryToolsInstall.title=Installing mandatory tools -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableModel.java
r600 r604 1 1 package net.oni2.aeinstaller.gui.modtable; 2 2 3 import java.io.File; 3 4 import java.util.HashSet; 4 5 import java.util.ResourceBundle; … … 44 45 return mod.getName(); 45 46 case 1: 46 return mod.getPackageNumber ();47 return mod.getPackageNumberString(); 47 48 case 2: 48 49 String type = ""; … … 94 95 return String.class; 95 96 case 1: 96 return Integer.class;97 return String.class; 97 98 case 2: 98 99 return String.class; … … 149 150 items.clear(); 150 151 items.addAll(ModManager.getInstance().getMods()); 152 revertSelection(); 153 } 154 155 /** 156 * Revert the selection to the mods that are currently installed 157 */ 158 public void revertSelection() { 151 159 install.clear(); 152 // TODO check installed153 160 for (int i = 0; i < items.size(); i++) { 154 install.add(i, false); 155 } 161 install.add(i, ModManager.getInstance() 162 .isModInstalled(items.get(i))); 163 } 164 fireTableDataChanged(); 165 } 166 167 /** 168 * Reload the selection after a config was loaded 169 * 170 * @param config 171 * Config to load 172 */ 173 public void reloadSelection(File config) { 174 Vector<Integer> selected = ModManager.getInstance().loadModSelection( 175 config); 176 install.clear(); 177 for (int i = 0; i < items.size(); i++) { 178 install.add(i, selected.contains(items.get(i).getPackageNumber())); 179 } 180 fireTableDataChanged(); 156 181 } 157 182
Note:
See TracChangeset
for help on using the changeset viewer.