Changeset 600
- Timestamp:
- Jan 10, 2013, 12:12:01 AM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller
- Files:
-
- 9 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/AEInstaller.properties
r599 r600 1 1 appname=AE Installer 2 2 appversion=0. 412 appversion=0.50 3 3 4 4 invalidPath.title=Wrong directory -
AE/installer2/src/net/oni2/aeinstaller/AEInstaller2.java
r599 r600 8 8 import java.net.URL; 9 9 import java.util.ResourceBundle; 10 import java.util.TreeSet;11 10 12 11 import javax.imageio.ImageIO; … … 20 19 import net.oni2.aeinstaller.backend.Paths; 21 20 import net.oni2.aeinstaller.backend.Settings; 21 import net.oni2.aeinstaller.backend.Settings.Platform; 22 22 import net.oni2.aeinstaller.backend.SizeFormatter; 23 import net.oni2.aeinstaller.backend.Settings.Platform;24 23 import net.oni2.aeinstaller.backend.StuffToRefactorLater; 25 24 import net.oni2.aeinstaller.backend.depot.DepotManager; 26 import net.oni2.aeinstaller.backend.mods.Mod;27 25 import net.oni2.aeinstaller.backend.oni.Installer; 28 26 import net.oni2.aeinstaller.backend.oni.OniSplit; … … 57 55 app.setApplicationIconImage(img); 58 56 } catch (IOException e) { 59 // TODO Auto-generated catch block60 57 e.printStackTrace(); 61 58 } … … 137 134 System.out.println("Globalized:" + Installer.isEditionInitialized()); 138 135 139 System.out.println("Free space on temp: " + SizeFormatter.format(Paths.getTempPath().getUsableSpace(), 3)); 140 System.out.println("Free space on Jar: " + SizeFormatter.format(Paths.getInstallerPath().getUsableSpace(), 3)); 141 136 System.out 137 .println("Free space on temp: " 138 + SizeFormatter.format(Paths.getTempPath() 139 .getUsableSpace(), 3)); 140 System.out.println("Free space on Jar: " 141 + SizeFormatter.format(Paths.getInstallerPath() 142 .getUsableSpace(), 3)); 143 142 144 if (!StuffToRefactorLater.verifyRunningDirectory()) { 143 145 JOptionPane.showMessageDialog(null, … … 148 150 return; 149 151 } 150 } else {151 Installer.initializeEdition();152 Installer.install(new TreeSet<Mod>());153 152 } 154 153 155 154 SwingUtilities.invokeLater(new Runnable() { 156 157 155 public void run() { 158 156 try { -
AE/installer2/src/net/oni2/aeinstaller/Images.properties
r593 r600 25 25 img.redo=/net/oni2/aeinstaller/images/tango/edit-redo.png 26 26 img.refresh=/net/oni2/aeinstaller/images/tango/view-refresh.png 27 img.tools=/net/oni2/aeinstaller/images/open_icon_library/tools-hammer_and_nails.png 27 28 28 29 img.ae=/net/oni2/aeinstaller/images/AElogo.png 30 img.install=/net/oni2/aeinstaller/images/open_icon_library/run-build-install-root.png -
AE/installer2/src/net/oni2/aeinstaller/backend/Settings.java
r596 r600 10 10 import java.util.Vector; 11 11 12 import net.oni2.aeinstaller.backend.app_launcher.QuickAppExecution;13 12 14 13 import com.thoughtworks.xstream.XStream; … … 112 111 res = QuickAppExecution.execute(cmd); 113 112 } catch (IOException e) { 114 // TODO Auto-generated catch block115 113 e.printStackTrace(); 116 114 } -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotManager.java
r592 r600 18 18 import net.oni2.aeinstaller.backend.depot.model.TaxonomyTerm; 19 19 import net.oni2.aeinstaller.backend.depot.model.TaxonomyVocabulary; 20 import net.oni2.aeinstaller.backend.mods.ECompatiblePlatform; 20 21 import net.oni2.aeinstaller.backend.network.DrupalJSONQuery; 21 22 … … 287 288 288 289 /** 289 * @return Mod-Nodes 290 */ 291 public Vector<NodeMod> getModPackageNodes() { 292 Vector<NodeMod> result = new Vector<NodeMod>(); 293 TaxonomyTerm tt = getTaxonomyTerm(DepotConfig.getTaxonomyName_InstallType_Package()); 294 if (tt == null) 295 return result; 296 297 int packageterm_id = tt.getTid(); 298 290 * Get a node by node id 291 * 292 * @param id 293 * Node id 294 * @return Node 295 */ 296 public Node getNodeById(int id) { 297 return nodes.get(id); 298 } 299 300 /** 301 * Get a Mod-Node by a given package number 302 * 303 * @param packageNumber 304 * Package number to find 305 * @return The Mod-Node or null 306 */ 307 public NodeMod getNodeByPackageNumber(int packageNumber) { 299 308 Vector<Node> files = getNodesByType(DepotConfig.getNodeType_Mod()); 300 309 for (Node n : files) { 301 310 if (n instanceof NodeMod) { 302 311 NodeMod nm = (NodeMod) n; 303 if (nm.getTaxonomyTerms().get(vocabId_instmethod) 304 .contains(packageterm_id)) 312 if (nm.getPackageNumber() == packageNumber) 313 return nm; 314 } 315 } 316 return null; 317 } 318 319 /** 320 * @return Mod-Nodes 321 */ 322 public Vector<NodeMod> getModPackageNodes() { 323 Vector<NodeMod> result = new Vector<NodeMod>(); 324 String instMethName = DepotConfig.getTaxonomyName_InstallType_Package(); 325 326 Vector<Node> files = getNodesByType(DepotConfig.getNodeType_Mod()); 327 for (Node n : files) { 328 if (n instanceof NodeMod) { 329 NodeMod nm = (NodeMod) n; 330 if (nm.getInstallMethod().getName() 331 .equalsIgnoreCase(instMethName)) 305 332 result.add(nm); 306 333 } … … 317 344 */ 318 345 public boolean isModValidOnPlatform(NodeMod node, Settings.Platform platform) { 319 int termId = node.getTaxonomyTerms().get(vocabId_platform).iterator() 320 .next(); 321 String validPlatform = getTaxonomyTerm(termId).getName(); 322 if (validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Both())) 323 return true; 324 325 if ((platform == Platform.WIN) || (platform == Platform.LINUX)) 326 return validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Win()); 327 else if (platform == Platform.MACOS) 328 return validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Mac()); 329 else 330 return false; 346 ECompatiblePlatform plat = node.getPlatform(); 347 switch (plat) { 348 case BOTH: 349 return true; 350 case WIN: 351 return (platform == Platform.WIN) 352 || (platform == Platform.LINUX); 353 case MACOS: 354 return (platform == Platform.MACOS); 355 } 356 return false; 331 357 } 332 358 … … 344 370 */ 345 371 public boolean isModOfType(NodeMod node, HashSet<Integer> type, boolean or) { 346 boolean matching = true; 347 if (or) 348 matching = false; 372 boolean matching = !or; 373 HashSet<TaxonomyTerm> terms = node.getTypes(); 349 374 350 375 for (int t : type) { 351 376 if (or) 352 matching |= node.getTaxonomyTerms().get(vocabId_type) 353 .contains(t); 377 matching |= terms.contains(t); 354 378 else 355 matching &= node.getTaxonomyTerms().get(vocabId_type) 356 .contains(t); 379 matching &= terms.contains(t); 357 380 } 358 381 return matching; 382 } 383 384 /** 385 * @return VocabId of Platform vocabulary 386 */ 387 public int getVocabIdPlatform() { 388 return vocabId_platform; 389 } 390 391 /** 392 * @return VocabId of Install method vocabulary 393 */ 394 public int getVocabIdInstMethod() { 395 return vocabId_instmethod; 396 } 397 398 /** 399 * @return VocabId of Type vocabulary 400 */ 401 public int getVocabIdType() { 402 return vocabId_type; 403 } 404 405 /** 406 * @param id 407 * ID of file to get 408 * @return the file 409 */ 410 public File getFile(int id) { 411 return files.get(id); 359 412 } 360 413 -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/model/NodeMod.java
r592 r600 4 4 import java.util.HashSet; 5 5 import java.util.Vector; 6 7 import net.oni2.aeinstaller.backend.depot.DepotConfig; 8 import net.oni2.aeinstaller.backend.depot.DepotManager; 9 import net.oni2.aeinstaller.backend.mods.ECompatiblePlatform; 6 10 7 11 import org.json.JSONArray; … … 74 78 75 79 /** 76 * @return the taxonomyTerms80 * @return Types 77 81 */ 78 public HashMap<Integer, HashSet<Integer>> getTaxonomyTerms() { 79 return taxonomyTerms; 82 public HashSet<TaxonomyTerm> getTypes() { 83 HashSet<TaxonomyTerm> tt = new HashSet<TaxonomyTerm>(); 84 for (int t : taxonomyTerms.get(DepotManager.getInstance() 85 .getVocabIdType())) { 86 tt.add(DepotManager.getInstance().getTaxonomyTerm(t)); 87 } 88 return tt; 80 89 } 81 90 82 91 /** 83 * @return the fields92 * @return Install method 84 93 */ 85 public HashMap<String, String> getFields() { 86 return fields; 94 public TaxonomyTerm getInstallMethod() { 95 return DepotManager.getInstance().getTaxonomyTerm( 96 taxonomyTerms 97 .get(DepotManager.getInstance().getVocabIdInstMethod()) 98 .iterator().next()); 99 } 100 101 /** 102 * @return Compatible platform 103 */ 104 public ECompatiblePlatform getPlatform() { 105 TaxonomyTerm term = DepotManager.getInstance().getTaxonomyTerm( 106 taxonomyTerms 107 .get(DepotManager.getInstance().getVocabIdPlatform()) 108 .iterator().next()); 109 110 String validPlatform = term.getName(); 111 if (validPlatform.equalsIgnoreCase(DepotConfig 112 .getTaxonomyName_Platform_Both())) 113 return ECompatiblePlatform.BOTH; 114 if (validPlatform.equalsIgnoreCase(DepotConfig 115 .getTaxonomyName_Platform_Win())) 116 return ECompatiblePlatform.WIN; 117 if (validPlatform.equalsIgnoreCase(DepotConfig 118 .getTaxonomyName_Platform_Mac())) 119 return ECompatiblePlatform.MACOS; 120 121 return null; 122 } 123 124 /** 125 * @return Creator of mod 126 */ 127 public String getCreator() { 128 if (fields.get("creator") != null) 129 return fields.get("creator"); 130 else 131 return ""; 132 } 133 134 /** 135 * @return Version of mod 136 */ 137 public String getVersion() { 138 if (fields.get("version") != null) 139 return fields.get("version"); 140 else 141 return ""; 142 } 143 144 /** 145 * @return Package number 146 */ 147 public int getPackageNumber() { 148 return Integer.parseInt(fields.get("package_number")); 87 149 } 88 150 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/Mod.java
r598 r600 1 1 package net.oni2.aeinstaller.backend.mods; 2 2 3 import java.io.BufferedReader; 3 4 import java.io.File; 5 import java.io.FileInputStream; 6 import java.io.FileNotFoundException; 7 import java.io.FilenameFilter; 8 import java.io.IOException; 9 import java.io.InputStreamReader; 10 import java.util.HashSet; 11 12 import net.oni2.aeinstaller.backend.Paths; 13 import net.oni2.aeinstaller.backend.Settings; 14 import net.oni2.aeinstaller.backend.Settings.Platform; 15 import net.oni2.aeinstaller.backend.depot.DepotManager; 16 import net.oni2.aeinstaller.backend.depot.model.NodeMod; 17 import net.oni2.aeinstaller.backend.depot.model.TaxonomyTerm; 4 18 5 19 /** … … 7 21 */ 8 22 public class Mod implements Comparable<Mod> { 9 private double aeVersion; 10 private int node; 11 private int packageNumber; 12 13 public double getAEVersion() { 14 return aeVersion; 15 } 16 23 // TODO: Dependencies/Conflicts 24 25 private String name = ""; 26 private int packageNumber = 0; 27 28 private HashSet<Type> types = new HashSet<Type>(); 29 private ECompatiblePlatform platform = null; 30 private String version = ""; 31 private String creator = ""; 32 private EBSLInstallType bslInstallType = null; 33 private String description = ""; 34 private double aeVersion = 0; 35 private int zipSize = 0; 36 private NodeMod node = null; 37 private net.oni2.aeinstaller.backend.depot.model.File file = null; 38 39 private long localTimestamp = 0; 40 41 /** 42 * Create a new Mod entry from a given Mod-Node 43 * 44 * @param nm 45 * Mod-Node 46 */ 47 public Mod(NodeMod nm) { 48 node = nm; 49 name = nm.getTitle(); 50 packageNumber = nm.getPackageNumber(); 51 for (TaxonomyTerm tt : nm.getTypes()) { 52 Type t = ModManager.getInstance().getTypeByName(tt.getName()); 53 types.add(t); 54 t.addEntry(this); 55 } 56 platform = nm.getPlatform(); 57 version = nm.getVersion(); 58 creator = nm.getCreator(); 59 if (nm.getBody() != null) 60 description = nm.getBody().getSafe_value(); 61 file = DepotManager.getInstance().getFile( 62 nm.getUploads().firstElement().getFid()); 63 zipSize = file.getFilesize(); 64 65 if (isLocalAvailable()) 66 updateLocalData(); 67 } 68 69 /** 70 * Update information for local package existence 71 */ 72 public void updateLocalData() { 73 File config = new File(getLocalPath(), "Mod_Info.cfg"); 74 File timestamp = new File(getLocalPath(), "aei.cfg"); 75 if (config.exists()) { 76 try { 77 FileInputStream fstream = new FileInputStream(config); 78 InputStreamReader isr = new InputStreamReader(fstream); 79 BufferedReader br = new BufferedReader(isr); 80 String strLine; 81 while ((strLine = br.readLine()) != null) { 82 if (strLine.indexOf("->") < 1) 83 continue; 84 if (strLine.indexOf("//") >= 0) 85 strLine = strLine.substring(0, strLine.indexOf("//")); 86 String[] split = strLine.split("->", 2); 87 String sName = split[0].trim(); 88 String sVal = split[1].trim(); 89 if (sName.equalsIgnoreCase("AEInstallVersion")) { 90 aeVersion = Double.parseDouble(sVal); 91 } else if (sName.equalsIgnoreCase("NameOfMod")) { 92 if (node == null) 93 name = sVal; 94 } else if (sName.equalsIgnoreCase("Creator")) { 95 if (node == null) 96 creator = sVal; 97 } else if (sName.equalsIgnoreCase("HasBsl")) { 98 if (sVal.equalsIgnoreCase("addon")) 99 bslInstallType = EBSLInstallType.ADDON; 100 else if (sVal.equalsIgnoreCase("yes")) 101 bslInstallType = EBSLInstallType.NORMAL; 102 else 103 bslInstallType = EBSLInstallType.NONE; 104 } else if (sName.equalsIgnoreCase("ModVersion")) { 105 if (node == null) 106 version = sVal; 107 } else if (sName.equalsIgnoreCase("Readme")) { 108 if (node == null) 109 description = sVal.replaceAll("\\\\n", "<br>"); 110 } 111 } 112 isr.close(); 113 } catch (FileNotFoundException e) { 114 } catch (IOException e) { 115 e.printStackTrace(); 116 } 117 } else { 118 System.err.println("No config found for mod folder: " 119 + getLocalPath().getPath()); 120 } 121 if (timestamp.exists()) { 122 try { 123 FileInputStream fstream = new FileInputStream(timestamp); 124 InputStreamReader isr = new InputStreamReader(fstream); 125 BufferedReader br = new BufferedReader(isr); 126 String ts = br.readLine(); 127 localTimestamp = Long.parseLong(ts); 128 isr.close(); 129 } catch (FileNotFoundException e) { 130 } catch (IOException e) { 131 e.printStackTrace(); 132 } 133 } 134 } 135 136 /** 137 * Create a new Mod entry from the given local mod folder 138 * 139 * @param folder 140 * Mod folder with Mod_Info.cfg 141 */ 142 public Mod(File folder) { 143 packageNumber = Integer.parseInt(folder.getName().substring(0, 5)); 144 updateLocalData(); 145 146 Type t = ModManager.getInstance().getTypeByName("-Local-"); 147 types.add(t); 148 t.addEntry(this); 149 150 platform = ECompatiblePlatform.BOTH; 151 } 152 153 /** 154 * @return has separate paths for win/mac/common or not 155 */ 17 156 public boolean hasSeparatePlatformDirs() { 18 157 return aeVersion >= 2; 19 158 } 20 159 160 /** 161 * @return Path to local mod folder 162 */ 21 163 public File getLocalPath() { 22 // TODO 23 return null; 24 } 25 26 public boolean newerAvailable() { 27 //TODO 28 return false; 29 } 30 31 public boolean localAvailable() { 32 //TODO 33 return false; 34 } 35 164 final String folderStart = String.format("%05d", packageNumber); 165 166 if (Paths.getModsPath().exists()) { 167 for (File f : Paths.getModsPath().listFiles(new FilenameFilter() { 168 @Override 169 public boolean accept(File d, String fn) { 170 return fn.startsWith(folderStart); 171 } 172 })) { 173 return f; 174 } 175 } 176 177 return new File(Paths.getModsPath(), folderStart); 178 } 179 180 /** 181 * @return Is there a newer version on the depot? 182 */ 183 public boolean isNewerAvailable() { 184 if (node != null) 185 return node.getUploads().firstElement().getTimestamp() > localTimestamp; 186 else 187 return false; 188 } 189 190 /** 191 * @return Mod exists within mods folder 192 */ 193 public boolean isLocalAvailable() { 194 return getLocalPath().exists(); 195 } 196 197 /** 198 * @return Name of mod 199 */ 200 public String getName() { 201 return name; 202 } 203 204 /** 205 * @return the package number 206 */ 36 207 public int getPackageNumber() { 37 208 return packageNumber; 209 } 210 211 /** 212 * @return Types of mod 213 */ 214 public HashSet<Type> getTypes() { 215 return types; 216 } 217 218 /** 219 * @return Compatible platforms 220 */ 221 public ECompatiblePlatform getPlatform() { 222 return platform; 223 } 224 225 /** 226 * @return Version of mod 227 */ 228 public String getVersion() { 229 return version; 230 } 231 232 /** 233 * @return Creator of mod 234 */ 235 public String getCreator() { 236 return creator; 237 } 238 239 /** 240 * @return Installation type of BSL files 241 */ 242 public EBSLInstallType getBSLInstallType() { 243 return bslInstallType; 244 } 245 246 /** 247 * @return Description of mod 248 */ 249 public String getDescription() { 250 return description; 251 } 252 253 /** 254 * @return Size of Zip file on Depot 255 */ 256 public int getZipSize() { 257 return zipSize; 258 } 259 260 /** 261 * @return Depot Mod-Node 262 */ 263 public NodeMod getNode() { 264 return node; 265 } 266 267 /** 268 * @return Is a mod that is always installed? 269 */ 270 public boolean isDefaultMod() { 271 return packageNumber < 10000; 272 } 273 274 /** 275 * @return Get the depot file entry 276 */ 277 public net.oni2.aeinstaller.backend.depot.model.File getFile() { 278 return file; 279 } 280 281 @Override 282 public String toString() { 283 return name; 284 } 285 286 /** 287 * @return Is this mod valid on the running platform? 288 */ 289 public boolean validOnPlatform() { 290 ECompatiblePlatform plat = platform; 291 switch (plat) { 292 case BOTH: 293 return true; 294 case MACOS: 295 return (Settings.getPlatform() == Platform.MACOS); 296 case WIN: 297 return (Settings.getPlatform() == Platform.WIN) 298 || (Settings.getPlatform() == Platform.LINUX); 299 } 300 return false; 38 301 } 39 302 -
AE/installer2/src/net/oni2/aeinstaller/backend/network/DrupalJSONQuery.java
r591 r600 59 59 + ".json", data); 60 60 } catch (UnsupportedEncodingException e) { 61 // TODO Auto-generated catch block62 61 e.printStackTrace(); 63 62 } … … 170 169 return jA; 171 170 } catch (JSONException e) { 172 // TODO Auto-generated catch block173 171 e.printStackTrace(); 174 172 } catch (UnsupportedEncodingException e) { 175 // TODO Auto-generated catch block176 173 e.printStackTrace(); 177 174 } catch (IOException e) { 178 // TODO Auto-generated catch block179 175 e.printStackTrace(); 180 176 } finally { … … 185 181 input.close(); 186 182 } catch (IOException e) { 187 // TODO Auto-generated catch block188 183 e.printStackTrace(); 189 184 } -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java
r599 r600 3 3 import java.io.File; 4 4 import java.io.FileFilter; 5 import java.io.FileNotFoundException; 5 6 import java.io.FilenameFilter; 6 7 import java.io.IOException; 8 import java.io.PrintWriter; 9 import java.text.SimpleDateFormat; 10 import java.util.Date; 7 11 import java.util.HashMap; 8 12 import java.util.List; … … 35 39 } 36 40 37 public static void install(TreeSet<Mod> mods) { 41 public static void install(TreeSet<Mod> mods, 42 InstallProgressListener listener) { 43 38 44 Vector<File> folders = new Vector<File>(); 39 45 folders.add(Paths.getVanillaOnisPath()); … … 59 65 } 60 66 61 for (File f : Paths.getModsPath().listFiles()) {62 63 64 65 }66 combineBinaryFiles(folders );67 // for (File f : Paths.getModsPath().listFiles()) { 68 // File oni = new File(f, "oni"); 69 // if (oni.exists()) 70 // folders.add(oni); 71 // } 72 combineBinaryFiles(folders, listener); 67 73 68 74 // TODO: bsl() 69 75 } 70 76 71 private static void combineBinaryFiles(List<File> srcFolders) { 77 private static void combineBinaryFiles(List<File> srcFoldersFiles, 78 InstallProgressListener listener) { 72 79 try { 80 HashMap<String, Vector<File>> levels = new HashMap<String, Vector<File>>(); 81 82 for (File path : srcFoldersFiles) { 83 for (File levelF : path.listFiles()) { 84 String fn = levelF.getName().toLowerCase(); 85 String levelN = null; 86 if (levelF.isDirectory()) { 87 levelN = fn; 88 } else if (fn.endsWith(".dat")) { 89 levelN = fn.substring(0, fn.lastIndexOf('.')); 90 } 91 if (levelN != null) { 92 if (!levels.containsKey(levelN)) 93 levels.put(levelN, new Vector<File>()); 94 levels.get(levelN).add(levelF); 95 } 96 } 97 } 98 99 int totalSteps = 0; 100 int stepsDone = 0; 101 102 for (@SuppressWarnings("unused") 103 String s : levels.keySet()) 104 totalSteps++; 105 106 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 107 108 File logFile = new File(Paths.getInstallerPath(), 109 "Installation.log"); 110 PrintWriter log = null; 111 try { 112 log = new PrintWriter(logFile); 113 } catch (FileNotFoundException e) { 114 e.printStackTrace(); 115 } 116 117 Date start = new Date(); 118 log.println("Installation of mods started at " + sdf.format(start)); 119 120 log.println("Cleaning directories"); 121 listener.installProgressUpdate(stepsDone, totalSteps, 122 "Cleaning up directories"); 123 73 124 createEmptyPath(Paths.getEditionGDF()); 74 HashMap<String, Vector<File>> levels = new HashMap<String, Vector<File>>(); 75 76 for (File path : srcFolders) { 77 for (File levelF : path.listFiles()) { 78 if (!levels.containsKey(levelF.getName().toLowerCase())) 79 levels.put(levelF.getName().toLowerCase(), 80 new Vector<File>()); 81 levels.get(levelF.getName().toLowerCase()).add(levelF); 82 } 83 } 84 125 126 log.println("Importing levels"); 85 127 for (String l : levels.keySet()) { 86 System.out.println("Level " + l);128 log.println("\tLevel " + l); 87 129 for (File f : levels.get(l)) { 88 System.out.println(" " + f.getPath()); 89 90 } 91 92 OniSplit.importLevel(levels.get(l), 130 log.println("\t\t\t" + f.getPath()); 131 } 132 133 Vector<String> res = OniSplit.packLevel(levels.get(l), 93 134 new File(Paths.getEditionGDF(), l + ".dat")); 94 95 System.out.println(); 96 } 135 if (res != null && res.size() > 0) { 136 for (String s : res) 137 log.println("\t\t" + s); 138 } 139 140 log.println(); 141 } 142 143 Date end = new Date(); 144 log.println("Initialization ended at " + sdf.format(end)); 145 log.println("Process took " 146 + ((end.getTime() - start.getTime()) / 1000) + " seconds"); 147 log.close(); 97 148 } catch (IOException e) { 98 149 // TODO Auto-generated catch block … … 103 154 /** 104 155 * Initializes the Edition core 156 * 157 * @param listener 158 * Listener for status updates 105 159 */ 106 public static void initializeEdition( ) {160 public static void initializeEdition(InstallProgressListener listener) { 107 161 File init = new File(Paths.getTempPath(), "init"); 162 163 int totalSteps = 0; 164 int stepsDone = 0; 165 166 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 167 168 for (@SuppressWarnings("unused") 169 File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() { 170 @Override 171 public boolean accept(File dir, String name) { 172 return name.endsWith(".dat"); 173 } 174 })) { 175 totalSteps++; 176 } 177 totalSteps = totalSteps * 2 + 2; 178 108 179 try { 180 File logFile = new File(Paths.getInstallerPath(), 181 "Initialization.log"); 182 PrintWriter log = new PrintWriter(logFile); 183 184 Date start = new Date(); 185 log.println("Initialization of Edition core started at " 186 + sdf.format(start)); 187 log.println("Cleaning directories"); 188 189 listener.installProgressUpdate(stepsDone, totalSteps, 190 "Cleaning up directories"); 109 191 createEmptyPath(Paths.getVanillaOnisPath()); 110 192 createEmptyPath(init); 111 193 File level0Folder = new File(init, "level0_Final"); 112 194 createEmptyPath(level0Folder); 113 File level0FolderVanilla = new File(Paths.getVanillaOnisPath(), 114 "level0_Final");115 createEmptyPath(level0FolderVanilla); 116 createEmptyPath(new File(level0FolderVanilla, "characters"));195 196 stepsDone++; 197 198 log.println("Exporting levels and moving files to level0"); 117 199 118 200 for (File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() { … … 127 209 int levelNumber = Integer.parseInt(fi.findInLine("[0-9]+")); 128 210 211 log.println("\t" + levelName + ":"); 212 log.println("\t\tExporting"); 213 listener.installProgressUpdate(stepsDone, totalSteps, 214 "Exporting vanilla level " + levelNumber); 215 129 216 // Edition/GameDataFolder/level*_Final/ 130 217 File tempLevelFolder = new File(init, levelName); 131 218 132 219 // Export Vanilla-Level-Dat -> Temp/Level 133 OniSplit.export(tempLevelFolder, f); 134 220 Vector<String> res = OniSplit.export(tempLevelFolder, f); 221 if (res != null && res.size() > 0) { 222 for (String s : res) 223 log.println("\t\t\t" + s); 224 } 225 226 log.println("\t\tMoving files"); 135 227 handleFileGlobalisation(tempLevelFolder, level0Folder, 136 level0FolderVanilla, levelNumber); 137 } 228 levelNumber); 229 stepsDone++; 230 log.println(); 231 } 232 233 log.println("Reimporting levels"); 138 234 139 235 for (File f : init.listFiles()) { 140 236 String levelName = f.getName(); 141 237 142 // Edition/AEInstaller/vanilla/level*_Final/ 143 File vanillaFolder = new File(Paths.getVanillaOnisPath(), 144 levelName); 145 vanillaFolder.mkdirs(); 238 log.println("\t" + levelName); 239 listener.installProgressUpdate(stepsDone, totalSteps, 240 "Creating globalized " + levelName); 146 241 147 242 Vector<File> folders = new Vector<File>(); 148 243 folders.add(f); 149 244 150 OniSplit.importLevel(folders, new File(vanillaFolder, levelName 151 + ".oni")); 152 } 153 245 Vector<String> res = OniSplit.importLevel(folders, new File( 246 Paths.getVanillaOnisPath(), levelName + ".dat")); 247 if (res != null && res.size() > 0) { 248 for (String s : res) 249 log.println("\t\t" + s); 250 } 251 252 log.println(); 253 stepsDone++; 254 } 255 256 listener.installProgressUpdate(stepsDone, totalSteps, 257 "Copying basic files"); 154 258 // Copy Oni-configs 155 259 File persistVanilla = new File(Paths.getOniBasePath(), … … 167 271 168 272 // TODO: FileUtils.deleteDirectory(init); 273 Date end = new Date(); 274 log.println("Initialization ended at " + sdf.format(end)); 275 log.println("Process took " 276 + ((end.getTime() - start.getTime()) / 1000) + " seconds"); 277 log.close(); 169 278 } catch (IOException e) { 170 279 e.printStackTrace(); … … 185 294 186 295 private static void handleFileGlobalisation(File tempFolder, 187 File level0Folder, File level0FolderVanilla,int levelNumber) {296 File level0Folder, int levelNumber) { 188 297 // Move AKEV and related files to subfolder so they're not globalized: 189 298 if (levelNumber != 0) { -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/OniSplit.java
r598 r600 8 8 9 9 import net.oni2.aeinstaller.backend.Paths; 10 import net.oni2.aeinstaller.backend.QuickAppExecution; 10 11 import net.oni2.aeinstaller.backend.Settings; 11 12 import net.oni2.aeinstaller.backend.Settings.Architecture; 12 13 import net.oni2.aeinstaller.backend.Settings.Platform; 13 14 import net.oni2.aeinstaller.backend.WinRegistry; 14 import net.oni2.aeinstaller.backend.app_launcher.QuickAppExecution;15 15 16 16 /** … … 83 83 * @param input 84 84 * Dat file 85 */ 86 public static void export(File targetFolder, File input) { 85 * @return OniSplit output 86 */ 87 public static Vector<String> export(File targetFolder, File input) { 87 88 if (!targetFolder.exists()) 88 89 targetFolder.mkdir(); … … 92 93 cmdLine.add(targetFolder.getPath()); 93 94 cmdLine.add(input.getPath()); 94 // System.out.println(cmdLine.toString()); 95 Vector<String> res = null; 96 try { 97 res = QuickAppExecution.execute(cmdLine); 98 } catch (IOException e) { 99 // TODO Auto-generated catch block 100 e.printStackTrace(); 101 } 102 if (res != null) { 103 // check for errors 104 System.out.println(res.toString()); 105 } 95 Vector<String> res = null; 96 try { 97 res = QuickAppExecution.execute(cmdLine); 98 } catch (IOException e) { 99 // TODO Auto-generated catch block 100 e.printStackTrace(); 101 } 102 return res; 106 103 } 107 104 … … 113 110 * @param targetFile 114 111 * Target .dat-file 115 */ 116 public static void importLevel(Vector<File> sourceFolders, File targetFile) { 112 * @return OniSplit output 113 */ 114 public static Vector<String> importLevel(Vector<File> sourceFolders, File targetFile) { 117 115 Vector<String> cmdLine = getProgramInvocation(); 118 116 cmdLine.add(getImportParam()); … … 120 118 cmdLine.add(f.getPath()); 121 119 cmdLine.add(targetFile.getPath()); 122 // System.out.println(cmdLine.toString()); 123 Vector<String> res = null; 124 try { 125 res = QuickAppExecution.execute(cmdLine); 126 } catch (IOException e) { 127 // TODO Auto-generated catch block 128 e.printStackTrace(); 129 } 130 if (res != null) { 131 // check for errors 132 System.out.println(res.toString()); 133 } 120 Vector<String> res = null; 121 try { 122 res = QuickAppExecution.execute(cmdLine); 123 } catch (IOException e) { 124 // TODO Auto-generated catch block 125 e.printStackTrace(); 126 } 127 return res; 128 } 129 130 /** 131 * Pack a level to a .dat-file. More powerful variant which allows 132 * specifying single .oni/.dat files 133 * 134 * @param sourceFoldersFiles 135 * Folders (for recursive .oni import) or files (.dat and single 136 * .oni) to import 137 * @param targetFile 138 * Target .dat-file 139 * @return OniSplit output 140 */ 141 public static Vector<String> packLevel(Vector<File> sourceFoldersFiles, 142 File targetFile) { 143 Vector<String> cmdLine = getProgramInvocation(); 144 cmdLine.add(getPackParam()); 145 cmdLine.add(getPackTypeParam()); 146 cmdLine.add("-out"); 147 cmdLine.add(targetFile.getPath()); 148 for (File f : sourceFoldersFiles) 149 cmdLine.add(f.getPath()); 150 Vector<String> res = null; 151 try { 152 res = QuickAppExecution.execute(cmdLine); 153 } catch (IOException e) { 154 // TODO Auto-generated catch block 155 e.printStackTrace(); 156 } 157 return res; 134 158 } 135 159 … … 144 168 * @param moveParameter 145 169 * e.g. overwrite, delete 146 */ 147 public static void move(File targetFolder, String input, 170 * @return OniSplit output 171 */ 172 public static Vector<String> move(File targetFolder, String input, 148 173 String moveParameter) { 149 174 if (!targetFolder.exists()) … … 162 187 e.printStackTrace(); 163 188 } 164 if (res != null && res.size() > 0) { 165 // TODO: errors 166 System.out.println(res.toString()); 167 } 189 return res; 168 190 } 169 191 … … 175 197 } 176 198 199 private static String getPackParam() { 200 return "pack"; 201 } 202 203 private static String getPackTypeParam() { 204 if (Settings.getPlatform() == Platform.MACOS) 205 return "-type:macintel"; 206 else 207 return "-type:pc"; 208 } 209 177 210 private static Vector<String> getProgramInvocation() { 178 211 Vector<String> res = new Vector<String>(); 179 212 if (Settings.getPlatform() != Platform.WIN) 180 213 res.add("mono"); 181 res.add(new File(Paths.getInstallerPath(), "Onisplit.exe").getPath()); 214 res.add(new File(new File(Paths.getEditionBasePath(), "Tools"), 215 "Onisplit.exe").getPath()); 182 216 return res; 183 217 } -
AE/installer2/src/net/oni2/aeinstaller/gui/HTMLLinkLabel.java
r593 r600 55 55 Desktop.getDesktop().browse(e.getURL().toURI()); 56 56 } catch (IOException e1) { 57 // TODO Auto-generated catch block58 57 e1.printStackTrace(); 59 58 } catch (URISyntaxException e1) { 60 // TODO Auto-generated catch block61 59 e1.printStackTrace(); 62 60 } -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r596 r600 1 1 package net.oni2.aeinstaller.gui; 2 2 3 import java.awt.Frame;4 3 import java.util.ArrayList; 5 import java.util.Comparator;6 4 import java.util.List; 7 5 import java.util.ResourceBundle; 8 6 import java.util.TreeMap; 9 7 import java.util.TreeSet; 8 9 import javax.swing.JButton; 10 10 import javax.swing.JComboBox; 11 11 import javax.swing.JComponent; … … 26 26 import net.oni2.aeinstaller.backend.Settings; 27 27 import net.oni2.aeinstaller.backend.Settings.Platform; 28 import net.oni2.aeinstaller.backend.SizeFormatter; 28 29 import net.oni2.aeinstaller.backend.depot.DepotCacheUpdateProgressListener; 29 import net.oni2.aeinstaller.backend.depot.DepotConfig;30 30 import net.oni2.aeinstaller.backend.depot.DepotManager; 31 import net.oni2.aeinstaller.backend.depot.model.NodeMod; 32 import net.oni2.aeinstaller.backend.depot.model.TaxonomyTerm; 33 import net.oni2.aeinstaller.backend.depot.model.TaxonomyVocabulary; 31 import net.oni2.aeinstaller.backend.mods.Mod; 32 import net.oni2.aeinstaller.backend.mods.ModManager; 33 import net.oni2.aeinstaller.backend.mods.Type; 34 import net.oni2.aeinstaller.backend.oni.InstallProgressListener; 35 import net.oni2.aeinstaller.backend.oni.Installer; 34 36 import net.oni2.aeinstaller.gui.about.AboutDialog; 37 import net.oni2.aeinstaller.gui.modtable.DownloadSizeListener; 35 38 import net.oni2.aeinstaller.gui.modtable.ModTableFilter; 36 39 import net.oni2.aeinstaller.gui.modtable.ModTableModel; … … 47 50 * @author Christian Illy 48 51 */ 49 public class MainWin extends JFrame implements ApplicationListener { 52 public class MainWin extends JFrame implements ApplicationListener, 53 DownloadSizeListener { 50 54 private static final long serialVersionUID = -4027395051382659650L; 51 55 … … 63 67 private ModTableModel model; 64 68 private TableRowSorter<ModTableModel> sorter; 69 private JLabel lblDownloadSizeVal; 65 70 66 71 private JLabel lblSubmitterVal; 67 72 private JLabel lblCreatorVal; 68 73 private JLabel lblFilesVal; 69 private JLabel lblIdVal;70 74 private HTMLLinkLabel lblDescriptionVal; 75 76 private JButton btnInstall; 71 77 72 78 /** … … 79 85 80 86 contents.setDividerLocation(400); 81 initTable();82 initModTypeBox();83 87 84 88 if (Settings.getPlatform() == Platform.MACOS) { 85 89 mainMenu.setVisible(false); 86 90 } 91 92 getRootPane().setDefaultButton(btnInstall); 87 93 } 88 94 … … 90 96 cmbModTypes.removeAllItems(); 91 97 92 TaxonomyVocabulary tv = DepotManager.getInstance().getVocabulary( 93 DepotConfig.getVocabularyName_ModType()); 94 if (tv == null) 95 return; 96 97 int vid = tv.getVid(); 98 TreeMap<String, TaxonomyTerm> terms = new TreeMap<String, TaxonomyTerm>(); 99 terms.put(" ", new TaxonomyTerm(-1, vid, "-All-")); 100 for (TaxonomyTerm t : DepotManager.getInstance() 101 .getTaxonomyTermsByVocabulary(vid)) { 102 terms.put(t.getName(), t); 103 } 104 for (TaxonomyTerm t : terms.values()) { 98 TreeMap<String, Type> types = new TreeMap<String, Type>(); 99 for (Type t : ModManager.getInstance().getTypesWithContent()) { 100 types.put(t.getName(), t); 101 } 102 for (Type t : types.values()) { 105 103 cmbModTypes.addItem(t); 106 104 } … … 121 119 int modelRow = tblMods 122 120 .convertRowIndexToModel(viewRow); 123 NodeMod mod = (NodeMod) model.getValueAt(modelRow, 124 -1); 121 Mod mod = (Mod) model.getValueAt(modelRow, -1); 125 122 modSelection(mod); 126 123 } … … 133 130 134 131 model = new ModTableModel(); 132 model.addDownloadSizeListener(this); 135 133 136 134 tblMods.setModel(model); … … 139 137 tblMods.setRowSorter(sorter); 140 138 141 sorter.setRowFilter(new ModTableFilter( -1));139 sorter.setRowFilter(new ModTableFilter(null)); 142 140 143 141 sorter.setSortable(2, false); 144 sorter.setComparator(1, new Comparator<String>() {145 146 @Override147 public int compare(String o1, String o2) {148 int i1 = Integer.parseInt(o1);149 int i2 = Integer.parseInt(o2);150 return i1 - i2;151 }152 });153 142 154 143 List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(); … … 171 160 JOptionPane.QUESTION_MESSAGE); 172 161 return res == JOptionPane.YES_OPTION; 173 }174 175 private boolean closeFrames() {176 System.gc();177 for (Frame f : Frame.getFrames()) {178 if (f != this)179 f.dispose();180 }181 return true;182 162 } 183 163 … … 206 186 } 207 187 }); 208 model.reloadData(); 188 ModManager.getInstance().init(); 189 initTable(); 209 190 initModTypeBox(); 191 210 192 tblMods.setVisible(true); 211 193 DepotManager.getInstance().printStats(); … … 244 226 @SuppressWarnings("unused") 245 227 private void loadConfig() { 246 // TODO Auto-generatedmethod stub228 // TODO method stub 247 229 JOptionPane.showMessageDialog(this, "loadConfig", "todo", 248 230 JOptionPane.INFORMATION_MESSAGE); … … 251 233 @SuppressWarnings("unused") 252 234 private void saveConfig() { 253 // TODO Auto-generatedmethod stub235 // TODO method stub 254 236 JOptionPane.showMessageDialog(this, "saveConfig", "todo", 255 237 JOptionPane.INFORMATION_MESSAGE); 256 238 } 257 239 258 @SuppressWarnings("unused") 259 private void reglobalize() { 260 // TODO Auto-generated method stub 261 JOptionPane.showMessageDialog(this, "reglobalize", "todo", 240 @DoInBackground(progressMessage = "initializingEdition.title", cancelable = false, indeterminateProgress = false) 241 private void reglobalize(final BackgroundEvent evt) { 242 Installer.initializeEdition(new InstallProgressListener() { 243 @Override 244 public void installProgressUpdate(int done, int total, String step) { 245 evt.setProgressEnd(total); 246 evt.setProgressValue(done); 247 evt.setProgressMessage(step); 248 } 249 }); 250 } 251 252 @SuppressWarnings("unused") 253 private void tools() { 254 // TODO method stub 255 JOptionPane.showMessageDialog(this, "tools", "todo", 262 256 JOptionPane.INFORMATION_MESSAGE); 263 257 } … … 265 259 @SuppressWarnings("unused") 266 260 private void revertSelection() { 267 // TODO Auto-generatedmethod stub261 // TODO method stub 268 262 JOptionPane.showMessageDialog(this, "revertSelection", "todo", 269 263 JOptionPane.INFORMATION_MESSAGE); 270 264 } 271 265 272 private void modSelection(NodeMod n) { 266 @DoInBackground(progressMessage = "installing.title", cancelable = false, indeterminateProgress = false) 267 private void install(final BackgroundEvent evt) { 268 TreeSet<Mod> mods = new TreeSet<Mod>(); 269 mods.addAll(ModManager.getInstance().getDefaultMods()); 270 mods.addAll(model.getSelectedMods()); 271 272 System.out.println("Install mods:"); 273 for (Mod m : mods) { 274 System.out 275 .println(" " + m.getPackageNumber() + ": " + m.getName()); 276 } 277 278 Installer.install(mods, new InstallProgressListener() { 279 @Override 280 public void installProgressUpdate(int done, int total, String step) { 281 evt.setProgressEnd(total); 282 evt.setProgressValue(done); 283 evt.setProgressMessage(step); 284 } 285 }); 286 287 // TODO method stub 288 JOptionPane.showMessageDialog(this, "install", "todo", 289 JOptionPane.INFORMATION_MESSAGE); 290 } 291 292 private void modSelection(Mod m) { 273 293 lblSubmitterVal.setText(""); 274 294 lblCreatorVal.setText(""); 275 lblIdVal.setText("");276 295 lblFilesVal.setText(""); 277 296 lblDescriptionVal.setText(""); 278 if (n != null) { 279 lblSubmitterVal.setText(n.getName()); 280 lblCreatorVal.setText(n.getFields().get("creator")); 281 lblIdVal.setText(Integer.toString(n.getNid())); 282 lblFilesVal.setText(Integer.toString(n.getUploads().size())); 283 if (n.getBody() != null) 284 lblDescriptionVal.setText(n.getBody().getSafe_value()); 297 if (m != null) { 298 lblSubmitterVal.setText(m.getName()); 299 lblCreatorVal.setText(m.getCreator()); 300 if (m.getNode() != null) { 301 lblFilesVal.setText(Integer.toString(m.getNode().getUploads() 302 .size())); 303 } 304 lblDescriptionVal.setText(m.getDescription()); 285 305 } 286 306 // TODO … … 289 309 @SuppressWarnings("unused") 290 310 private void modTypeSelection() { 291 T axonomyTerm t = (TaxonomyTerm) cmbModTypes.getSelectedItem();311 Type t = (Type) cmbModTypes.getSelectedItem(); 292 312 if (t != null) 293 sorter.setRowFilter(new ModTableFilter(t .getTid()));313 sorter.setRowFilter(new ModTableFilter(t)); 294 314 else 295 sorter.setRowFilter(new ModTableFilter(-1)); 315 sorter.setRowFilter(new ModTableFilter(null)); 316 } 317 318 @Override 319 public void downloadSizeChanged(int newSize) { 320 lblDownloadSizeVal.setText(SizeFormatter.format(newSize, 2)); 321 } 322 323 @DoInBackground(progressMessage = "initializingEdition.title", cancelable = false, indeterminateProgress = false) 324 private void initialize(final BackgroundEvent evt) { 325 if (!Installer.isEditionInitialized()) { 326 int res = JOptionPane.showConfirmDialog(this, 327 bundle.getString("askInitialize.text"), 328 bundle.getString("askInitialize.title"), 329 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); 330 if (res == JOptionPane.NO_OPTION) { 331 exit(); 332 } else { 333 Installer.initializeEdition(new InstallProgressListener() { 334 @Override 335 public void installProgressUpdate(int done, int total, 336 String step) { 337 evt.setProgressEnd(total); 338 evt.setProgressValue(done); 339 evt.setProgressMessage(step); 340 } 341 }); 342 } 343 } 296 344 } 297 345 … … 323 371 if (askClose()) { 324 372 event.setHandled(true); 325 closeFrames();326 373 saveLocalData(); 327 374 exit(); … … 334 381 public void handleReOpenApplication(ApplicationEvent event) { 335 382 } 383 336 384 } -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.properties
r594 r600 18 18 menu.reglobalize=&Rebuild Core Data 19 19 menu.reglobalizeTooltip=Rebuild Core Data 20 menu.tools=&Manage Tools 21 menu.toolsTooltip=Install/Remove Tools 20 22 21 23 btnRevertSelection.text=Revert selection 22 24 btnRevertSelection.tooltip=Select mods which are currently installed 25 btnInstall.text=&Install 26 btnInstall.tooltip=Install selected mods 23 27 lblModTypes.text=Mod type: 28 lblDownloadSize.text=Size of files to download: 24 29 25 30 lblSubmitter.text=Submitter: 26 31 lblCreator.text=Creator: 27 lblId.text=NodeID:28 32 lblFiles.text=Number of files: 29 33 lblDescription.text=Description: … … 36 40 askClose.title=Confirm close request 37 41 askClose.text=Are you sure you want to close the program? 42 43 askInitialize.title=Initialize Edition 44 askInitialize.text=The Edition is not yet initialized.\nIf you do not initialize now the installer will exit.\nInitialize Edition core now? 45 46 initializingEdition.title=Initializing Edition core 47 installing.title=Installing mods -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.yml
r594 r600 6 6 locationRelativeTo: null 7 7 defaultCloseOperation: doNothingOnClose 8 onWindowOpened: [execDepotUpdate,checkUpdates, focus]9 onWindowClosing: [askClose, closeFrames,saveLocalData,exit]8 onWindowOpened: [execDepotUpdate,checkUpdates,initialize,focus] 9 onWindowClosing: [askClose,saveLocalData,exit] 10 10 iconImage: img.ae 11 11 content: 12 - Action(name=exitAction, text=menu.exit, toolTipText=menu.exitTooltip, icon=img.exit, onAction=[askClose, closeFrames,saveLocalData,exit])12 - Action(name=exitAction, text=menu.exit, toolTipText=menu.exitTooltip, icon=img.exit, onAction=[askClose,saveLocalData,exit]) 13 13 - Action(name=settings, text=menu.settings, toolTipText=menu.settingsTooltip, icon=img.settings, onAction=[showSettings]) 14 14 - Action(name=about, text=menu.about, toolTipText=menu.aboutTooltip, icon=img.about, onAction=[showAbout]) … … 16 16 - Action(name=saveConfig, text=menu.saveConfig, toolTipText=menu.saveConfigTooltip, icon=img.saveFile, onAction=[saveConfig]) 17 17 - Action(name=reglobalize, text=menu.reglobalize, toolTipText=menu.reglobalizeTooltip, icon=img.refresh, onAction=[reglobalize]) 18 - Action(name=tools, text=menu.tools, toolTipText=menu.toolsTooltip, icon=img.tools, onAction=[tools]) 18 19 - JMenuBar: 19 20 - JMenu(name=mainMenu, text=menu.main): … … 26 27 - JSeparator() 27 28 - JMenuItem(action=reglobalize) 28 - JToolBar(name=tools, floatable=false, orientation=0): 29 - JSeparator() 30 - JMenuItem(action=tools) 31 - JToolBar(name=toolbar, floatable=false, orientation=0): 29 32 - JButton(action=exitAction, hideActionText=true) 30 33 - JToolBarSeparator() … … 33 36 - JSplitPane(name=contents, orientation=horizontalSplit, continuousLayout=true): 34 37 - JPanel(name=panMods): 35 - JButton(name=btnRevertSelection, icon=img.undo16, text=btnRevertSelection.text, toolTipText=btnRevertSelection.tooltip, onAction=[revertSelection])36 38 - JLabel(name=lblModTypes, text=lblModTypes.text) 37 39 - JComboBox(name=cmbModTypes, onAction=modTypeSelection) 38 40 - JScrollPane(name=scrollMods, vScrollBar=always, hScrollBar=never): 39 41 JTable(name=tblMods, visible=false) 42 - JButton(name=btnRevertSelection, icon=img.undo16, text=btnRevertSelection.text, toolTipText=btnRevertSelection.tooltip, onAction=[revertSelection]) 43 - JButton(name=btnInstall, icon=img.install, text=btnInstall.text, toolTipText=btnInstall.tooltip, onAction=[install]) 44 - JLabel(name=lblDownloadSize, text=lblDownloadSize.text) 45 - JLabel(name=lblDownloadSizeVal) 40 46 - MigLayout: | 41 47 [grow] 42 btnRevertSelection [min]43 48 lblModTypes<,cmbModTypes [min] 44 49 scrollMods [grow] 50 >btnRevertSelection,btnInstall [min] 51 lblDownloadSize,lblDownloadSizeVal [min] 45 52 - JPanel(name=panInfo): 46 53 - JLabel(name=lblSubmitter, text=lblSubmitter.text) … … 48 55 - JLabel(name=lblCreator, text=lblCreator.text) 49 56 - JLabel(name=lblCreatorVal) 50 - JLabel(name=lblId, text=lblId.text)51 - JLabel(name=lblIdVal)52 57 - JLabel(name=lblFiles, text=lblFiles.text) 53 58 - JLabel(name=lblFilesVal) … … 59 64 >lblSubmitter lblSubmitterVal [min] 60 65 >lblCreator lblCreatorVal [min] 61 >lblId lblIdVal [min]62 66 >lblFiles lblFilesVal [min] 63 67 >^lblDescription scrollDescription [grow] -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableFilter.java
r591 r600 1 1 package net.oni2.aeinstaller.gui.modtable; 2 3 import java.util.HashSet;4 2 5 3 import javax.swing.RowFilter; 6 4 7 import net.oni2.aeinstaller.backend.Settings; 8 import net.oni2.aeinstaller.backend.depot.DepotManager; 9 import net.oni2.aeinstaller.backend.depot.model.NodeMod; 5 import net.oni2.aeinstaller.backend.mods.Mod; 6 import net.oni2.aeinstaller.backend.mods.Type; 10 7 11 8 /** … … 13 10 */ 14 11 public class ModTableFilter extends RowFilter<ModTableModel, Integer> { 15 int type = -1;12 Type type = null; 16 13 17 14 /** 18 15 * @param type 19 * Type of mods to show ( -1for all)16 * Type of mods to show (null for all) 20 17 */ 21 public ModTableFilter( inttype) {18 public ModTableFilter(Type type) { 22 19 super(); 23 20 this.type = type; … … 26 23 @Override 27 24 public boolean include( 28 javax.swing.RowFilter.Entry<? extends ModTableModel, ? extends Integer> entry) { 29 NodeMod mod = (NodeMod) entry.getModel().getValueAt( 30 entry.getIdentifier(), -1); 25 RowFilter.Entry<? extends ModTableModel, ? extends Integer> entry) { 26 Mod mod = (Mod) entry.getModel().getValueAt(entry.getIdentifier(), -1); 31 27 32 if (!DepotManager.getInstance().isModValidOnPlatform(mod, 33 Settings.getPlatform())) 28 if (mod.isDefaultMod()) 34 29 return false; 35 30 36 if (type < 0) 31 if (!mod.validOnPlatform()) 32 return false; 33 34 if (type == null) 37 35 return true; 38 36 39 HashSet<Integer> types = new HashSet<Integer>(); 40 types.add(type); 41 return DepotManager.getInstance().isModOfType(mod, types, false); 37 return mod.getTypes().contains(type); 42 38 } 43 39 } -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableModel.java
r593 r600 1 1 package net.oni2.aeinstaller.gui.modtable; 2 2 3 import java.util.HashSet; 3 4 import java.util.ResourceBundle; 5 import java.util.TreeSet; 4 6 import java.util.Vector; 5 7 … … 7 9 import javax.swing.table.TableColumn; 8 10 9 import net.oni2.aeinstaller.backend. depot.DepotConfig;10 import net.oni2.aeinstaller.backend. depot.DepotManager;11 import net.oni2.aeinstaller.backend. depot.model.NodeMod;11 import net.oni2.aeinstaller.backend.mods.Mod; 12 import net.oni2.aeinstaller.backend.mods.ModManager; 13 import net.oni2.aeinstaller.backend.mods.Type; 12 14 13 15 /** … … 21 23 .getName()); 22 24 23 private Vector< NodeMod> items;24 private Vector<Boolean> install ;25 private int vocabModTypeID = -1; 26 private int vocabPlatformID = -1;25 private Vector<Mod> items = new Vector<Mod>(); 26 private Vector<Boolean> install = new Vector<Boolean>(); 27 28 private HashSet<DownloadSizeListener> listeners = new HashSet<DownloadSizeListener>(); 27 29 28 30 /** … … 35 37 @Override 36 38 public Object getValueAt(int row, int col) { 37 NodeMod node= items.get(row);39 Mod mod = items.get(row); 38 40 switch (col) { 39 41 case -1: 40 return node;41 case 0: 42 return node.getTitle();43 case 1: 44 return node.getFields().get("package_number");42 return mod; 43 case 0: 44 return mod.getName(); 45 case 1: 46 return mod.getPackageNumber(); 45 47 case 2: 46 48 String type = ""; 47 if (vocabModTypeID < 0) { 48 vocabModTypeID = DepotManager 49 .getInstance() 50 .getVocabulary( 51 DepotConfig.getVocabularyName_ModType()) 52 .getVid(); 53 } 54 for (int tid : node.getTaxonomyTerms().get(vocabModTypeID)) { 49 for (Type t : mod.getTypes()) { 55 50 if (type.length() > 0) 56 51 type += ", "; 57 type += DepotManager.getInstance().getTaxonomyTerm(tid) 58 .getName(); 52 type += t.getName(); 59 53 } 60 54 return type; 61 55 case 3: 62 if (vocabPlatformID < 0) { 63 vocabPlatformID = DepotManager 64 .getInstance() 65 .getVocabulary( 66 DepotConfig.getVocabularyName_Platform()) 67 .getVid(); 68 } 69 int tid = node.getTaxonomyTerms().get(vocabPlatformID) 70 .iterator().next(); 71 return DepotManager.getInstance().getTaxonomyTerm(tid) 72 .getName(); 56 return mod.getPlatform().toString(); 73 57 case 4: 74 58 return install.get(row); … … 163 147 */ 164 148 public void reloadData() { 165 items = DepotManager.getInstance().getModPackageNodes(); 166 install = new Vector<Boolean>(); 149 items.clear(); 150 items.addAll(ModManager.getInstance().getMods()); 151 install.clear(); 167 152 // TODO check installed 168 153 for (int i = 0; i < items.size(); i++) { … … 176 161 * @return Items 177 162 */ 178 public Vector< NodeMod> getItems() {163 public Vector<Mod> getItems() { 179 164 return items; 165 } 166 167 /** 168 * @return Mods selected for installation 169 */ 170 public TreeSet<Mod> getSelectedMods() { 171 TreeSet<Mod> res = new TreeSet<Mod>(); 172 for (int i = 0; i < items.size(); i++) { 173 if (install.get(i)) 174 res.add(items.get(i)); 175 } 176 return res; 180 177 } 181 178 … … 190 187 if (columnIndex == 4) { 191 188 install.set(rowIndex, (Boolean) aValue); 192 } 189 190 int size = 0; 191 for (int i = 0; i < items.size(); i++) { 192 if (install.get(i)) { 193 Mod m = items.get(i); 194 if (!m.isLocalAvailable() || m.isNewerAvailable()) 195 size += m.getZipSize(); 196 } 197 } 198 for (DownloadSizeListener dsl : listeners) 199 dsl.downloadSizeChanged(size); 200 } 201 } 202 203 /** 204 * @param lis 205 * Listener to receive download size changed events 206 */ 207 public void addDownloadSizeListener(DownloadSizeListener lis) { 208 listeners.add(lis); 209 } 210 211 /** 212 * @param lis 213 * Listener to no longer receive download size changed events 214 */ 215 public void removeDownloadSizeListener(DownloadSizeListener lis) { 216 listeners.remove(lis); 193 217 } 194 218
Note:
See TracChangeset
for help on using the changeset viewer.