Changeset 657 for AE/installer2/src/net/oni2/aeinstaller/gui/modtable
- Timestamp:
- Jan 29, 2013, 12:43:01 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/gui/modtable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTable.java
r648 r657 19 19 import javax.swing.JComponent; 20 20 import javax.swing.JMenuItem; 21 import javax.swing.JOptionPane; 21 22 import javax.swing.JPopupMenu; 22 23 import javax.swing.JTable; … … 42 43 .getBundle("net.oni2.aeinstaller.localization.ModTable"); 43 44 45 /** 46 * @author Christian Illy 47 */ 48 public enum ETableContentType { 49 /** 50 * Table showing mods 51 */ 52 MODS, 53 /** 54 * Table showing tools 55 */ 56 TOOLS, 57 /** 58 * Table showing core packages 59 */ 60 CORE 61 }; 62 44 63 private HashSet<ModSelectionListener> modSelListeners = new HashSet<ModSelectionListener>(); 45 64 46 65 private ModTableModel model; 47 66 private TableRowSorter<ModTableModel> sorter; 67 68 private ETableContentType contentType = ETableContentType.MODS; 48 69 49 70 /** … … 186 207 */ 187 208 public void setFilter(Type type, int downloadState) { 188 sorter.setRowFilter(new ModTableFilter(type, downloadState)); 209 sorter.setRowFilter(new ModTableFilter(type, downloadState, 210 contentType == ETableContentType.CORE, false)); 189 211 } 190 212 … … 203 225 } 204 226 } 227 } 228 229 /** 230 * Select/Unselect all currently visible items depending on the current 231 * state of selection 232 */ 233 public void unSelectAll() { 234 boolean isAll = true; 235 for (int i = 0; i < getRowCount(); i++) { 236 int modRow = convertRowIndexToModel(i); 237 boolean inst = (Boolean) model.getValueAt(modRow, 0); 238 if (!inst) { 239 isAll = false; 240 break; 241 } 242 } 243 244 for (int i = 0; i < getRowCount(); i++) { 245 int modRow = convertRowIndexToModel(i); 246 model.setValueAt(!isAll, modRow, 0); 247 } 248 invalidate(); 249 repaint(); 205 250 } 206 251 … … 267 312 } 268 313 314 if (mod.isLocalAvailable() 315 && contentType != ETableContentType.CORE) { 316 // Delete package folder item 317 JMenuItem deleteModFolder = new JMenuItem( 318 bundle.getString("deletePackage.text")); 319 deleteModFolder.addActionListener(new ActionListener() { 320 @Override 321 public void actionPerformed(ActionEvent arg0) { 322 if (mod.getNode() == null) { 323 JOptionPane.showMessageDialog( 324 null, 325 bundle.getString("deletePackageLocalOnly.text"), 326 bundle.getString("deletePackageLocalOnly.title"), 327 JOptionPane.INFORMATION_MESSAGE); 328 } else { 329 int res = JOptionPane.showConfirmDialog( 330 null, 331 bundle.getString("deletePackageConfirm.text"), 332 bundle.getString("deletePackageConfirm.title"), 333 JOptionPane.YES_NO_OPTION, 334 JOptionPane.WARNING_MESSAGE); 335 if (res == JOptionPane.YES_OPTION) { 336 mod.deleteLocalPackage(); 337 invalidate(); 338 repaint(); 339 } 340 } 341 } 342 }); 343 popup.add(deleteModFolder); 344 } 345 269 346 if (popup.getSubElements().length > 0) 270 347 popup.show(e.getComponent(), e.getX(), e.getY()); -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableFilter.java
r648 r657 13 13 private int downloadState = 0; 14 14 15 private boolean showCorePackages = false; 16 private boolean showInvalidPlatform = false; 17 15 18 /** 16 19 * @param type … … 18 21 * @param downloadState 19 22 * Show only: 0 = all, 1 = online, 2 = downloaded 23 * @param showCorePackages 24 * Show core packages in table 25 * @param showInvalidPlatform 26 * Show packages not valid on this platform 20 27 */ 21 public ModTableFilter(Type type, int downloadState) { 28 public ModTableFilter(Type type, int downloadState, 29 boolean showCorePackages, boolean showInvalidPlatform) { 22 30 super(); 23 31 this.type = type; 24 32 this.downloadState = downloadState; 33 this.showCorePackages = showCorePackages; 34 this.showInvalidPlatform = showInvalidPlatform; 25 35 } 26 36 … … 28 38 public boolean include( 29 39 RowFilter.Entry<? extends ModTableModel, ? extends Integer> entry) { 30 Package mod = (Package) entry.getModel().getValueAt(entry.getIdentifier(), -1); 31 32 if (mod.isCorePackage()) 40 Package mod = (Package) entry.getModel().getValueAt( 41 entry.getIdentifier(), -1); 42 43 if (mod.isCorePackage() && !showCorePackages) 33 44 return false; 34 45 35 if (!mod.isValidOnPlatform() )46 if (!mod.isValidOnPlatform() && !showInvalidPlatform) 36 47 return false; 37 48 … … 47 58 break; 48 59 } 49 60 50 61 return result; 51 62 } -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableModel.java
r651 r657 60 60 return res; 61 61 case 5: 62 if (mod.getNode() != null) 63 return sdf.format(new Date( 64 mod.getNode().getCreated() * 1000)); 65 else 66 return null; 67 case 6: 62 68 if (mod.getFile() != null) 63 69 return sdf.format(new Date( … … 83 89 return bundle.getString("mod.state"); 84 90 case 5: 91 return bundle.getString("mod.added"); 92 case 6: 85 93 return bundle.getString("mod.date"); 86 94 } … … 95 103 @Override 96 104 public int getColumnCount() { 97 return 6;105 return 7; 98 106 } 99 107 … … 112 120 return String.class; 113 121 case 5: 122 return String.class; 123 case 6: 114 124 return String.class; 115 125 } … … 153 163 break; 154 164 case 5: 155 w = 115; 165 w = 100; 166 col.setPreferredWidth(w); 167 col.setMinWidth(w); 168 col.setMaxWidth(w); 169 break; 170 case 6: 171 w = 100; 156 172 col.setPreferredWidth(w); 157 173 col.setMinWidth(w);
Note:
See TracChangeset
for help on using the changeset viewer.