Changeset 672 for AE/installer2/src/net/oni2/aeinstaller/gui
- Timestamp:
- Feb 23, 2013, 6:40:47 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r671 r672 44 44 import net.oni2.aeinstaller.backend.Paths; 45 45 import net.oni2.aeinstaller.backend.Settings; 46 import net.oni2.aeinstaller.backend.ToolLauncher; 46 47 import net.oni2.aeinstaller.backend.Settings.Platform; 47 48 import net.oni2.aeinstaller.backend.SizeFormatter; … … 229 230 TreeSet<Package> tools = PackageManager.getInstance() 230 231 .getUpdatableTools(); 231 int size = 0;232 232 JPanel panPackages = new JPanel(new GridLayout(0, 1)); 233 233 execUpdates = new TreeSet<Package>(); 234 234 execUpdates.addAll(mods); 235 235 execUpdates.addAll(tools); 236 final JLabel lblSize = new JLabel("<html>" 237 + String.format( 238 bundle.getString("updatesAvailableSize.text"), 239 SizeFormatter.format(0, 3)) + "</html>"); 240 int size = 0; 236 241 for (final Package m : mods) { 237 242 size += m.getZipSize(); 238 JCheckBox check = new JCheckBox("Mod: " + m.getName()); 243 JCheckBox check = new JCheckBox("Mod: " + m.getName() 244 + " (" + SizeFormatter.format(size, 1) + ")"); 239 245 check.setSelected(true); 240 246 check.addItemListener(new ItemListener() { … … 245 251 else 246 252 execUpdates.remove(m); 253 int s = 0; 254 for (Package p : execUpdates) 255 s += p.getZipSize(); 256 lblSize.setText("<html>" 257 + String.format( 258 bundle.getString("updatesAvailableSize.text"), 259 SizeFormatter.format(s, 3)) 260 + "</html>"); 247 261 } 248 262 }); … … 251 265 for (final Package m : tools) { 252 266 size += m.getZipSize(); 253 JCheckBox check = new JCheckBox("Tool: " + m.getName()); 267 JCheckBox check = new JCheckBox("Tool: " + m.getName() 268 + " (" + SizeFormatter.format(size, 1) + ")"); 254 269 check.setSelected(true); 270 check.addItemListener(new ItemListener() { 271 @Override 272 public void itemStateChanged(ItemEvent e) { 273 if (e.getStateChange() == ItemEvent.SELECTED) 274 execUpdates.add(m); 275 else 276 execUpdates.remove(m); 277 int s = 0; 278 for (Package p : execUpdates) 279 s += p.getZipSize(); 280 lblSize.setText("<html>" 281 + String.format( 282 bundle.getString("updatesAvailableSize.text"), 283 SizeFormatter.format(s, 3)) 284 + "</html>"); 285 } 286 }); 255 287 panPackages.add(check); 256 288 } 289 lblSize.setText("<html>" 290 + String.format( 291 bundle.getString("updatesAvailableSize.text"), 292 SizeFormatter.format(size, 3)) + "</html>"); 257 293 if (size > 0) { 258 294 // Build info dialog content … … 261 297 + bundle.getString("updatesAvailable.text") 262 298 + "</html>"); 263 JLabel lblSize = new JLabel("<html>"264 + String.format(bundle265 .getString("updatesAvailableSize.text"),266 SizeFormatter.format(size, 3)) + "</html>");267 299 packages.add(lblIntro, BorderLayout.NORTH); 268 300 packages.add(panPackages, BorderLayout.CENTER); … … 433 465 } 434 466 toolsMenuItems.clear(); 435 for ( Package m : PackageManager.getInstance().getInstalledTools()) {467 for (final Package m : PackageManager.getInstance().getInstalledTools()) { 436 468 File exe = m.getExeFile(); 437 469 if (exe != null && exe.exists()) { 438 470 JMenuItem item = new JMenuItem(); 439 final Vector<String> params = new Vector<String>();440 if (exe.getName().toLowerCase().endsWith(".jar")) {441 File jre = null;442 if (Settings.getPlatform() == Platform.WIN)443 jre = new File(System.getProperties().getProperty(444 "java.home"), "bin/javaw.exe");445 else446 jre = new File(System.getProperties().getProperty(447 "java.home"), "bin/java");448 params.add(jre.getPath());449 params.add("-jar");450 }451 params.add(exe.getPath());452 final File wd = m.getWorkingDir();453 471 ImageIcon ico = null; 454 472 if (m.getIconFile() != null && m.getIconFile().exists()) { … … 464 482 465 483 @Override 466 public void actionPerformed(ActionEvent e) { 467 AppExecution.execute(params, wd); 484 public void actionPerformed(ActionEvent evt) { 485 try { 486 ToolLauncher.launch(m); 487 } catch (Exception ex) { 488 if (ex.getMessage().contains("JRE")) 489 JOptionPane.showMessageDialog(null, 490 bundle.getString("jreNotFound.text"), 491 bundle.getString("jreNotFound.title"), 492 JOptionPane.ERROR_MESSAGE); 493 if (ex.getMessage().contains(".NET")) 494 JOptionPane.showMessageDialog(null, 495 bundle.getString("dotNetNotFound.text"), 496 bundle.getString("dotNetNotFound.title"), 497 JOptionPane.ERROR_MESSAGE); 498 } 468 499 } 469 500 });
Note:
See TracChangeset
for help on using the changeset viewer.