Changeset 600 for AE/installer2/src/net/oni2/aeinstaller/gui/modtable
- Timestamp:
- Jan 10, 2013, 12:12:01 AM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/gui/modtable
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.