Changeset 634
- Timestamp:
- Jan 19, 2013, 12:58:17 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller
- Files:
-
- 3 added
- 3 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/AEInstaller.properties
r633 r634 1 1 appname=AE Installer 2 2 appversion=0.92 a2 appversion=0.92b -
AE/installer2/src/net/oni2/aeinstaller/AEInstaller2.java
r633 r634 74 74 if (!debug) { 75 75 try { 76 System.setOut(new PrintStream(new File(Paths.getPrefsPath(),77 "aei_output.log")) );78 System.set Err(new PrintStream(new File(Paths.getPrefsPath(),79 "aei_error.log")));76 PrintStream ps = new PrintStream(new File(Paths.getPrefsPath(), 77 "aei_output.log")); 78 System.setOut(ps); 79 System.setErr(ps); 80 80 } catch (FileNotFoundException e1) { 81 81 e1.printStackTrace(); … … 123 123 JFrame.setDefaultLookAndFeelDecorated(true); 124 124 125 System.out.println(basicBundle.getString("appname") + " " + basicBundle.getString("appversion")); 125 126 System.out.println("JarPath: " + Paths.getInstallerPath()); 126 127 System.out.println("PrefsPath: " + Paths.getPrefsPath()); … … 143 144 + SizeFormatter.format(Paths.getInstallerPath() 144 145 .getUsableSpace(), 3)); 146 System.out.println(); 145 147 146 148 if (!OniSplit.isDotNETInstalled()) { … … 161 163 dlUrl = "http://www.go-mono.com/mono-downloads/download.html"; 162 164 } 163 hll.setText(startupBundle.getString("dotNetMissing.text").replaceAll( 164 "%1", String.format("<a href=\"%s\">%s</a>", dlUrl, dlUrl))); 165 hll.setText(startupBundle 166 .getString("dotNetMissing.text") 167 .replaceAll( 168 "%1", 169 String.format("<a href=\"%s\">%s</a>", dlUrl, dlUrl))); 165 170 JOptionPane.showMessageDialog(null, hll, 166 171 startupBundle.getString("dotNetMissing.title"), -
AE/installer2/src/net/oni2/aeinstaller/DepotPackageCheck.java
r603 r634 4 4 import java.util.HashSet; 5 5 6 import net.oni2.aeinstaller.backend.depot.DepotCacheUpdateProgressListener;7 6 import net.oni2.aeinstaller.backend.depot.DepotConfig; 8 7 import net.oni2.aeinstaller.backend.depot.DepotManager; … … 21 20 public static void main(String[] args) { 22 21 System.out.println("Reading Depot data:"); 23 DepotManager.getInstance().updateInformation(false, 24 new DepotCacheUpdateProgressListener() { 25 26 @Override 27 public void cacheUpdateProgress(String stepName, 28 int current, int total) { 29 System.out.format("%50s", ""); 30 System.out.format("\rStep %2d / %2d - %s", current, 31 total, stepName); 32 } 33 }); 22 DepotManager.getInstance().updateInformation(false); 34 23 System.out.println("\nReading done"); 35 24 System.out.println(); -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotManager.java
r633 r634 1 1 package net.oni2.aeinstaller.backend.depot; 2 2 3 import java.io.BufferedReader; 3 4 import java.io.FileInputStream; 4 5 import java.io.FileNotFoundException; 5 6 import java.io.FileOutputStream; 6 7 import java.io.IOException; 8 import java.io.InputStreamReader; 7 9 import java.io.UnsupportedEncodingException; 8 10 import java.net.UnknownHostException; 11 import java.util.Enumeration; 9 12 import java.util.HashMap; 10 13 import java.util.HashSet; 11 14 import java.util.Vector; 12 15 import java.util.zip.ZipEntry; 16 import java.util.zip.ZipFile; 17 18 import net.oni2.aeinstaller.backend.Paths; 13 19 import net.oni2.aeinstaller.backend.Settings; 14 20 import net.oni2.aeinstaller.backend.Settings.Platform; … … 21 27 import net.oni2.aeinstaller.backend.depot.model.TaxonomyVocabulary; 22 28 import net.oni2.aeinstaller.backend.mods.ECompatiblePlatform; 23 import net.oni2.aeinstaller.backend.network. DrupalJSONQuery;29 import net.oni2.aeinstaller.backend.network.FileDownloader; 24 30 25 31 import org.apache.http.HttpResponse; … … 64 70 * @param forceRefreshAll 65 71 * Force refreshing all data, even if it seems to be cached 66 * @param listener 67 * Listener for update status 68 */ 69 public void updateInformation(boolean forceRefreshAll, 70 DepotCacheUpdateProgressListener listener) { 72 */ 73 public void updateInformation(boolean forceRefreshAll) { 71 74 taxonomyTerms.clear(); 72 75 taxonomyVocabulary.clear(); … … 77 80 78 81 try { 79 JSONArray ja; 80 JSONObject jo; 81 82 ja = DrupalJSONQuery 83 .executeQuery("http://mods.oni2.net/jsoncache/vocabulary.json"); 84 for (int i = 0; i < ja.length(); i++) { 85 jo = ja.getJSONObject(i); 86 TaxonomyVocabulary tv = new TaxonomyVocabulary(jo); 87 taxonomyVocabulary.put(tv.getVid(), tv); 82 java.io.File zipName = new java.io.File(Paths.getDownloadPath(), 83 "jsoncache.zip"); 84 FileDownloader fd = new FileDownloader(DepotConfig.getDepotUrl() 85 + "jsoncache/jsoncache.zip", zipName); 86 fd.start(); 87 while (fd.getState() != net.oni2.aeinstaller.backend.network.FileDownloader.EState.FINISHED) { 88 Thread.sleep(50); 88 89 } 89 90 90 ja = DrupalJSONQuery 91 .executeQuery("http://mods.oni2.net/jsoncache/terms.json"); 92 for (int i = 0; i < ja.length(); i++) { 93 jo = ja.getJSONObject(i); 94 TaxonomyTerm tt = new TaxonomyTerm(jo); 95 taxonomyTerms.put(tt.getTid(), tt); 96 } 97 98 ja = DrupalJSONQuery 99 .executeQuery("http://mods.oni2.net/jsoncache/nodes.json"); 100 for (int i = 0; i < ja.length(); i++) { 101 jo = ja.getJSONObject(i); 102 103 int nid = jo.getInt("nid"); 104 String type = jo.getString("type"); 105 106 Node n = null; 107 if (type.equalsIgnoreCase(DepotConfig.getNodeType_Mod())) 108 n = new NodeMod(jo); 109 else 110 n = new Node(jo); 111 112 nodes.put(nid, n); 113 if (!nodesByType.containsKey(type)) 114 nodesByType.put(type, new HashMap<Integer, Node>()); 115 nodesByType.get(type).put(nid, n); 116 } 117 118 ja = DrupalJSONQuery 119 .executeQuery("http://mods.oni2.net/jsoncache/files.json"); 120 for (int i = 0; i < ja.length(); i++) { 121 jo = ja.getJSONObject(i); 122 123 int fid = jo.getInt("fid"); 124 125 File f = new File(jo); 126 files.put(fid, f); 91 ZipFile zf = null; 92 try { 93 zf = new ZipFile(zipName); 94 for (Enumeration<? extends ZipEntry> e = zf.entries(); e 95 .hasMoreElements();) { 96 ZipEntry ze = e.nextElement(); 97 if (!ze.isDirectory()) { 98 BufferedReader input = new BufferedReader( 99 new InputStreamReader(zf.getInputStream(ze))); 100 StringBuffer json = new StringBuffer(); 101 102 char data[] = new char[1024]; 103 int dataRead; 104 while ((dataRead = input.read(data, 0, 1024)) != -1) { 105 json.append(data, 0, dataRead); 106 } 107 108 if (ze.getName().toLowerCase().contains("vocabulary")) 109 initVocabulary(new JSONArray(json.toString())); 110 if (ze.getName().toLowerCase().contains("terms")) 111 initTerms(new JSONArray(json.toString())); 112 if (ze.getName().toLowerCase().contains("nodes")) 113 initNodes(new JSONArray(json.toString())); 114 if (ze.getName().toLowerCase().contains("files")) 115 initFiles(new JSONArray(json.toString())); 116 } 117 } 118 } finally { 119 if (zf != null) 120 zf.close(); 121 zipName.delete(); 127 122 } 128 123 … … 135 130 } catch (JSONException e) { 136 131 e.printStackTrace(); 137 } catch (Exception e) { 138 System.err.println(e.getMessage()); 139 e.printStackTrace(); 132 } catch (IOException e1) { 133 e1.printStackTrace(); 134 } catch (InterruptedException e) { 135 e.printStackTrace(); 136 } 137 } 138 139 private void initFiles(JSONArray ja) throws JSONException { 140 JSONObject jo; 141 142 for (int i = 0; i < ja.length(); i++) { 143 jo = ja.getJSONObject(i); 144 145 int fid = jo.getInt("fid"); 146 147 File f = new File(jo); 148 files.put(fid, f); 149 } 150 } 151 152 private void initNodes(JSONArray ja) throws JSONException { 153 JSONObject jo; 154 155 for (int i = 0; i < ja.length(); i++) { 156 jo = ja.getJSONObject(i); 157 158 int nid = jo.getInt("nid"); 159 String type = jo.getString("type"); 160 161 Node n = null; 162 if (type.equalsIgnoreCase(DepotConfig.getNodeType_Mod())) 163 n = new NodeMod(jo); 164 else 165 n = new Node(jo); 166 167 nodes.put(nid, n); 168 if (!nodesByType.containsKey(type)) 169 nodesByType.put(type, new HashMap<Integer, Node>()); 170 nodesByType.get(type).put(nid, n); 171 } 172 } 173 174 private void initTerms(JSONArray ja) throws JSONException { 175 JSONObject jo; 176 177 for (int i = 0; i < ja.length(); i++) { 178 jo = ja.getJSONObject(i); 179 TaxonomyTerm tt = new TaxonomyTerm(jo); 180 taxonomyTerms.put(tt.getTid(), tt); 181 } 182 } 183 184 private void initVocabulary(JSONArray ja) throws JSONException { 185 JSONObject jo; 186 187 for (int i = 0; i < ja.length(); i++) { 188 jo = ja.getJSONObject(i); 189 TaxonomyVocabulary tv = new TaxonomyVocabulary(jo); 190 taxonomyVocabulary.put(tv.getVid(), tv); 140 191 } 141 192 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/download/ModDownload.java
r624 r634 8 8 import net.oni2.aeinstaller.backend.Paths; 9 9 import net.oni2.aeinstaller.backend.mods.Mod; 10 import net.oni2.aeinstaller.backend.mods.unpack.UnpackListener; 11 import net.oni2.aeinstaller.backend.mods.unpack.Unpacker; 10 12 import net.oni2.aeinstaller.backend.network.FileDownloadListener; 11 13 import net.oni2.aeinstaller.backend.network.FileDownloader; 12 14 import net.oni2.aeinstaller.backend.network.FileDownloader.EState; 13 import net.oni2.aeinstaller.backend.unpack.UnpackListener;14 import net.oni2.aeinstaller.backend.unpack.Unpacker;15 15 16 16 /** … … 75 75 try { 76 76 downloader = new FileDownloader(mod.getFile().getUri_full(), 77 zipFile .getPath());77 zipFile); 78 78 downloader.addListener(this); 79 79 unpacker = new Unpacker(zipFile, targetFolder, this); … … 166 166 @Override 167 167 public void statusUpdate(Unpacker source, 168 net.oni2.aeinstaller.backend. unpack.Unpacker.EState state) {168 net.oni2.aeinstaller.backend.mods.unpack.Unpacker.EState state) { 169 169 switch (state) { 170 170 case INIT: -
AE/installer2/src/net/oni2/aeinstaller/backend/network/FileDownloader.java
r619 r634 61 61 * If url could not be opened 62 62 */ 63 public FileDownloader(String url, Stringtarget) throws IOException {63 public FileDownloader(String url, File target) throws IOException { 64 64 this.url = new URL(url); 65 this.target = new File(target);65 this.target = target; 66 66 67 67 URLConnection connection = this.url.openConnection(); … … 130 130 target.delete(); 131 131 } 132 } 133 134 /** 135 * @return current state 136 */ 137 public EState getState() { 138 return state; 132 139 } 133 140 -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r633 r634 10 10 import java.io.IOException; 11 11 import java.net.URL; 12 import java.util.Date; 12 13 import java.util.HashMap; 13 14 import java.util.HashSet; … … 42 43 import net.oni2.aeinstaller.backend.Settings.Platform; 43 44 import net.oni2.aeinstaller.backend.SizeFormatter; 44 import net.oni2.aeinstaller.backend.depot.DepotCacheUpdateProgressListener;45 45 import net.oni2.aeinstaller.backend.depot.DepotManager; 46 46 import net.oni2.aeinstaller.backend.mods.Mod; … … 165 165 private void execDepotUpdate(final BackgroundEvent evt) { 166 166 if (!Settings.getInstance().isOfflineMode()) { 167 long start = new Date().getTime(); 168 167 169 try { 168 DepotManager.getInstance().updateInformation(false, 169 new DepotCacheUpdateProgressListener() { 170 171 @Override 172 public void cacheUpdateProgress(String stepName, 173 int current, int total) { 174 evt.setProgressEnd(total); 175 evt.setProgressValue(current); 176 evt.setProgressMessage(stepName); 177 } 178 }); 170 DepotManager.getInstance().updateInformation(false); 179 171 } catch (Exception e) { 180 172 e.printStackTrace(); 181 173 } 174 175 System.out.println("Took: " + (new Date().getTime() - start) 176 + " msec"); 182 177 } 183 178
Note:
See TracChangeset
for help on using the changeset viewer.