Changeset 604 for AE/installer2/src/net/oni2/aeinstaller/gui
- Timestamp:
- Jan 12, 2013, 11:48:33 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r603 r604 1 1 package net.oni2.aeinstaller.gui; 2 2 3 import java.io.File; 3 4 import java.util.ArrayList; 4 5 import java.util.List; … … 10 11 import javax.swing.JComboBox; 11 12 import javax.swing.JComponent; 13 import javax.swing.JFileChooser; 12 14 import javax.swing.JFrame; 13 15 import javax.swing.JLabel; … … 22 24 import javax.swing.event.ListSelectionEvent; 23 25 import javax.swing.event.ListSelectionListener; 26 import javax.swing.filechooser.FileFilter; 24 27 import javax.swing.table.TableRowSorter; 25 28 29 import net.oni2.aeinstaller.backend.Paths; 26 30 import net.oni2.aeinstaller.backend.Settings; 27 31 import net.oni2.aeinstaller.backend.Settings.Platform; … … 32 36 import net.oni2.aeinstaller.backend.mods.ModManager; 33 37 import net.oni2.aeinstaller.backend.mods.Type; 38 import net.oni2.aeinstaller.backend.mods.download.ModDownloader; 39 import net.oni2.aeinstaller.backend.mods.download.ModDownloader.State; 40 import net.oni2.aeinstaller.backend.mods.download.ModDownloaderListener; 34 41 import net.oni2.aeinstaller.backend.oni.InstallProgressListener; 35 42 import net.oni2.aeinstaller.backend.oni.Installer; … … 222 229 } 223 230 231 private JFileChooser getConfigOpenSaveDialog(boolean save) { 232 JFileChooser fc = new JFileChooser(); 233 fc.setCurrentDirectory(Paths.getEditionBasePath()); 234 if (save) 235 fc.setDialogType(JFileChooser.SAVE_DIALOG); 236 else 237 fc.setDialogType(JFileChooser.OPEN_DIALOG); 238 fc.setFileSelectionMode(JFileChooser.FILES_ONLY); 239 fc.setFileFilter(new FileFilter() { 240 @Override 241 public String getDescription() { 242 return "XML files"; 243 } 244 245 @Override 246 public boolean accept(File arg0) { 247 return (arg0.isDirectory()) 248 || (arg0.getName().toLowerCase().endsWith(".xml")); 249 } 250 }); 251 fc.setMultiSelectionEnabled(false); 252 return fc; 253 } 254 224 255 @SuppressWarnings("unused") 225 256 private void loadConfig() { 226 // TODO method stub 227 JOptionPane.showMessageDialog(this, "loadConfig", "todo", 228 JOptionPane.INFORMATION_MESSAGE); 257 JFileChooser fc = getConfigOpenSaveDialog(false); 258 int res = fc.showOpenDialog(this); 259 if (res == JFileChooser.APPROVE_OPTION) { 260 if (fc.getSelectedFile().exists()) 261 model.reloadSelection(fc.getSelectedFile()); 262 } 229 263 } 230 264 231 265 @SuppressWarnings("unused") 232 266 private void saveConfig() { 233 // TODO method stub 234 JOptionPane.showMessageDialog(this, "saveConfig", "todo", 235 JOptionPane.INFORMATION_MESSAGE); 267 JFileChooser fc = getConfigOpenSaveDialog(true); 268 int res = fc.showSaveDialog(this); 269 if (res == JFileChooser.APPROVE_OPTION) { 270 File f = fc.getSelectedFile(); 271 if (!f.getName().endsWith(".xml")) 272 f = new File(f.getParentFile(), f.getName() + ".xml"); 273 ModManager.getInstance().saveModSelection(f, 274 model.getSelectedMods()); 275 } 236 276 } 237 277 … … 257 297 @SuppressWarnings("unused") 258 298 private void revertSelection() { 259 // TODO method stub 260 JOptionPane.showMessageDialog(this, "revertSelection", "todo", 261 JOptionPane.INFORMATION_MESSAGE); 299 model.revertSelection(); 262 300 } 263 301 264 302 @DoInBackground(progressMessage = "mandatoryFiles.title", cancelable = false, indeterminateProgress = false) 265 303 private void checkMandatoryFiles(final BackgroundEvent evt) { 266 //TODO 267 System.out.println("Mandatory Tools:"); 304 TreeSet<Mod> mand = new TreeSet<Mod>(); 268 305 for (Mod m : ModManager.getInstance().getMandatoryTools()) { 269 System.out.format(" %05d %15s - Local: %b - Update: %b", m.getPackageNumber(), m.getName(), m.isLocalAvailable(), m.isNewerAvailable()); 270 } 271 System.out.println(); 272 273 System.out.println("Mandatory Mods:"); 306 if (m.isNewerAvailable()) { 307 mand.add(m); 308 } 309 } 274 310 for (Mod m : ModManager.getInstance().getMandatoryMods()) { 275 System.out.format(" %05d %15s - Local: %b - Update: %b", m.getPackageNumber(), m.getName(), m.isLocalAvailable(), m.isNewerAvailable()); 276 } 311 if (m.isNewerAvailable()) { 312 mand.add(m); 313 } 314 } 315 if (mand.size() > 0) { 316 ModDownloader m = new ModDownloader(mand, 317 new ModDownloaderListener() { 318 @Override 319 public void updateStatus(ModDownloader source, 320 State state, int filesDown, int filesTotal, 321 int bytesDown, int bytesTotal) { 322 evt.setProgressEnd(filesTotal); 323 evt.setProgressValue(filesDown); 324 } 325 }); 326 while (!m.isFinished()) { 327 try { 328 Thread.sleep(50); 329 } catch (InterruptedException e) { 330 // TODO Auto-generated catch block 331 e.printStackTrace(); 332 } 333 } 334 } 335 evt.setProgressMessage(bundle.getString("mandatoryToolsInstall.title")); 336 Installer.installTools(ModManager.getInstance().getMandatoryTools()); 277 337 } 278 338 … … 287 347 System.out.println("Install mods:"); 288 348 for (Mod m : mods) { 289 System.out 290 .println(" " + m.getPackageNumber() + ": "+ m.getName());349 System.out.println(" " + m.getPackageNumberString() + ": " 350 + m.getName()); 291 351 } 292 352 -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.properties
r602 r604 47 47 installing.title=Installing mods 48 48 mandatoryFiles.title=Checking for mandatory files 49 mandatoryToolsInstall.title=Installing mandatory tools -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableModel.java
r600 r604 1 1 package net.oni2.aeinstaller.gui.modtable; 2 2 3 import java.io.File; 3 4 import java.util.HashSet; 4 5 import java.util.ResourceBundle; … … 44 45 return mod.getName(); 45 46 case 1: 46 return mod.getPackageNumber ();47 return mod.getPackageNumberString(); 47 48 case 2: 48 49 String type = ""; … … 94 95 return String.class; 95 96 case 1: 96 return Integer.class;97 return String.class; 97 98 case 2: 98 99 return String.class; … … 149 150 items.clear(); 150 151 items.addAll(ModManager.getInstance().getMods()); 152 revertSelection(); 153 } 154 155 /** 156 * Revert the selection to the mods that are currently installed 157 */ 158 public void revertSelection() { 151 159 install.clear(); 152 // TODO check installed153 160 for (int i = 0; i < items.size(); i++) { 154 install.add(i, false); 155 } 161 install.add(i, ModManager.getInstance() 162 .isModInstalled(items.get(i))); 163 } 164 fireTableDataChanged(); 165 } 166 167 /** 168 * Reload the selection after a config was loaded 169 * 170 * @param config 171 * Config to load 172 */ 173 public void reloadSelection(File config) { 174 Vector<Integer> selected = ModManager.getInstance().loadModSelection( 175 config); 176 install.clear(); 177 for (int i = 0; i < items.size(); i++) { 178 install.add(i, selected.contains(items.get(i).getPackageNumber())); 179 } 180 fireTableDataChanged(); 156 181 } 157 182
Note:
See TracChangeset
for help on using the changeset viewer.