Changeset 600 for AE/installer2/src/net/oni2/aeinstaller/gui
- Timestamp:
- Jan 10, 2013, 12:12:01 AM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/gui
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/gui/HTMLLinkLabel.java
r593 r600 55 55 Desktop.getDesktop().browse(e.getURL().toURI()); 56 56 } catch (IOException e1) { 57 // TODO Auto-generated catch block58 57 e1.printStackTrace(); 59 58 } catch (URISyntaxException e1) { 60 // TODO Auto-generated catch block61 59 e1.printStackTrace(); 62 60 } -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r596 r600 1 1 package net.oni2.aeinstaller.gui; 2 2 3 import java.awt.Frame;4 3 import java.util.ArrayList; 5 import java.util.Comparator;6 4 import java.util.List; 7 5 import java.util.ResourceBundle; 8 6 import java.util.TreeMap; 9 7 import java.util.TreeSet; 8 9 import javax.swing.JButton; 10 10 import javax.swing.JComboBox; 11 11 import javax.swing.JComponent; … … 26 26 import net.oni2.aeinstaller.backend.Settings; 27 27 import net.oni2.aeinstaller.backend.Settings.Platform; 28 import net.oni2.aeinstaller.backend.SizeFormatter; 28 29 import net.oni2.aeinstaller.backend.depot.DepotCacheUpdateProgressListener; 29 import net.oni2.aeinstaller.backend.depot.DepotConfig;30 30 import net.oni2.aeinstaller.backend.depot.DepotManager; 31 import net.oni2.aeinstaller.backend.depot.model.NodeMod; 32 import net.oni2.aeinstaller.backend.depot.model.TaxonomyTerm; 33 import net.oni2.aeinstaller.backend.depot.model.TaxonomyVocabulary; 31 import net.oni2.aeinstaller.backend.mods.Mod; 32 import net.oni2.aeinstaller.backend.mods.ModManager; 33 import net.oni2.aeinstaller.backend.mods.Type; 34 import net.oni2.aeinstaller.backend.oni.InstallProgressListener; 35 import net.oni2.aeinstaller.backend.oni.Installer; 34 36 import net.oni2.aeinstaller.gui.about.AboutDialog; 37 import net.oni2.aeinstaller.gui.modtable.DownloadSizeListener; 35 38 import net.oni2.aeinstaller.gui.modtable.ModTableFilter; 36 39 import net.oni2.aeinstaller.gui.modtable.ModTableModel; … … 47 50 * @author Christian Illy 48 51 */ 49 public class MainWin extends JFrame implements ApplicationListener { 52 public class MainWin extends JFrame implements ApplicationListener, 53 DownloadSizeListener { 50 54 private static final long serialVersionUID = -4027395051382659650L; 51 55 … … 63 67 private ModTableModel model; 64 68 private TableRowSorter<ModTableModel> sorter; 69 private JLabel lblDownloadSizeVal; 65 70 66 71 private JLabel lblSubmitterVal; 67 72 private JLabel lblCreatorVal; 68 73 private JLabel lblFilesVal; 69 private JLabel lblIdVal;70 74 private HTMLLinkLabel lblDescriptionVal; 75 76 private JButton btnInstall; 71 77 72 78 /** … … 79 85 80 86 contents.setDividerLocation(400); 81 initTable();82 initModTypeBox();83 87 84 88 if (Settings.getPlatform() == Platform.MACOS) { 85 89 mainMenu.setVisible(false); 86 90 } 91 92 getRootPane().setDefaultButton(btnInstall); 87 93 } 88 94 … … 90 96 cmbModTypes.removeAllItems(); 91 97 92 TaxonomyVocabulary tv = DepotManager.getInstance().getVocabulary( 93 DepotConfig.getVocabularyName_ModType()); 94 if (tv == null) 95 return; 96 97 int vid = tv.getVid(); 98 TreeMap<String, TaxonomyTerm> terms = new TreeMap<String, TaxonomyTerm>(); 99 terms.put(" ", new TaxonomyTerm(-1, vid, "-All-")); 100 for (TaxonomyTerm t : DepotManager.getInstance() 101 .getTaxonomyTermsByVocabulary(vid)) { 102 terms.put(t.getName(), t); 103 } 104 for (TaxonomyTerm t : terms.values()) { 98 TreeMap<String, Type> types = new TreeMap<String, Type>(); 99 for (Type t : ModManager.getInstance().getTypesWithContent()) { 100 types.put(t.getName(), t); 101 } 102 for (Type t : types.values()) { 105 103 cmbModTypes.addItem(t); 106 104 } … … 121 119 int modelRow = tblMods 122 120 .convertRowIndexToModel(viewRow); 123 NodeMod mod = (NodeMod) model.getValueAt(modelRow, 124 -1); 121 Mod mod = (Mod) model.getValueAt(modelRow, -1); 125 122 modSelection(mod); 126 123 } … … 133 130 134 131 model = new ModTableModel(); 132 model.addDownloadSizeListener(this); 135 133 136 134 tblMods.setModel(model); … … 139 137 tblMods.setRowSorter(sorter); 140 138 141 sorter.setRowFilter(new ModTableFilter( -1));139 sorter.setRowFilter(new ModTableFilter(null)); 142 140 143 141 sorter.setSortable(2, false); 144 sorter.setComparator(1, new Comparator<String>() {145 146 @Override147 public int compare(String o1, String o2) {148 int i1 = Integer.parseInt(o1);149 int i2 = Integer.parseInt(o2);150 return i1 - i2;151 }152 });153 142 154 143 List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(); … … 171 160 JOptionPane.QUESTION_MESSAGE); 172 161 return res == JOptionPane.YES_OPTION; 173 }174 175 private boolean closeFrames() {176 System.gc();177 for (Frame f : Frame.getFrames()) {178 if (f != this)179 f.dispose();180 }181 return true;182 162 } 183 163 … … 206 186 } 207 187 }); 208 model.reloadData(); 188 ModManager.getInstance().init(); 189 initTable(); 209 190 initModTypeBox(); 191 210 192 tblMods.setVisible(true); 211 193 DepotManager.getInstance().printStats(); … … 244 226 @SuppressWarnings("unused") 245 227 private void loadConfig() { 246 // TODO Auto-generatedmethod stub228 // TODO method stub 247 229 JOptionPane.showMessageDialog(this, "loadConfig", "todo", 248 230 JOptionPane.INFORMATION_MESSAGE); … … 251 233 @SuppressWarnings("unused") 252 234 private void saveConfig() { 253 // TODO Auto-generatedmethod stub235 // TODO method stub 254 236 JOptionPane.showMessageDialog(this, "saveConfig", "todo", 255 237 JOptionPane.INFORMATION_MESSAGE); 256 238 } 257 239 258 @SuppressWarnings("unused") 259 private void reglobalize() { 260 // TODO Auto-generated method stub 261 JOptionPane.showMessageDialog(this, "reglobalize", "todo", 240 @DoInBackground(progressMessage = "initializingEdition.title", cancelable = false, indeterminateProgress = false) 241 private void reglobalize(final BackgroundEvent evt) { 242 Installer.initializeEdition(new InstallProgressListener() { 243 @Override 244 public void installProgressUpdate(int done, int total, String step) { 245 evt.setProgressEnd(total); 246 evt.setProgressValue(done); 247 evt.setProgressMessage(step); 248 } 249 }); 250 } 251 252 @SuppressWarnings("unused") 253 private void tools() { 254 // TODO method stub 255 JOptionPane.showMessageDialog(this, "tools", "todo", 262 256 JOptionPane.INFORMATION_MESSAGE); 263 257 } … … 265 259 @SuppressWarnings("unused") 266 260 private void revertSelection() { 267 // TODO Auto-generatedmethod stub261 // TODO method stub 268 262 JOptionPane.showMessageDialog(this, "revertSelection", "todo", 269 263 JOptionPane.INFORMATION_MESSAGE); 270 264 } 271 265 272 private void modSelection(NodeMod n) { 266 @DoInBackground(progressMessage = "installing.title", cancelable = false, indeterminateProgress = false) 267 private void install(final BackgroundEvent evt) { 268 TreeSet<Mod> mods = new TreeSet<Mod>(); 269 mods.addAll(ModManager.getInstance().getDefaultMods()); 270 mods.addAll(model.getSelectedMods()); 271 272 System.out.println("Install mods:"); 273 for (Mod m : mods) { 274 System.out 275 .println(" " + m.getPackageNumber() + ": " + m.getName()); 276 } 277 278 Installer.install(mods, new InstallProgressListener() { 279 @Override 280 public void installProgressUpdate(int done, int total, String step) { 281 evt.setProgressEnd(total); 282 evt.setProgressValue(done); 283 evt.setProgressMessage(step); 284 } 285 }); 286 287 // TODO method stub 288 JOptionPane.showMessageDialog(this, "install", "todo", 289 JOptionPane.INFORMATION_MESSAGE); 290 } 291 292 private void modSelection(Mod m) { 273 293 lblSubmitterVal.setText(""); 274 294 lblCreatorVal.setText(""); 275 lblIdVal.setText("");276 295 lblFilesVal.setText(""); 277 296 lblDescriptionVal.setText(""); 278 if (n != null) { 279 lblSubmitterVal.setText(n.getName()); 280 lblCreatorVal.setText(n.getFields().get("creator")); 281 lblIdVal.setText(Integer.toString(n.getNid())); 282 lblFilesVal.setText(Integer.toString(n.getUploads().size())); 283 if (n.getBody() != null) 284 lblDescriptionVal.setText(n.getBody().getSafe_value()); 297 if (m != null) { 298 lblSubmitterVal.setText(m.getName()); 299 lblCreatorVal.setText(m.getCreator()); 300 if (m.getNode() != null) { 301 lblFilesVal.setText(Integer.toString(m.getNode().getUploads() 302 .size())); 303 } 304 lblDescriptionVal.setText(m.getDescription()); 285 305 } 286 306 // TODO … … 289 309 @SuppressWarnings("unused") 290 310 private void modTypeSelection() { 291 T axonomyTerm t = (TaxonomyTerm) cmbModTypes.getSelectedItem();311 Type t = (Type) cmbModTypes.getSelectedItem(); 292 312 if (t != null) 293 sorter.setRowFilter(new ModTableFilter(t .getTid()));313 sorter.setRowFilter(new ModTableFilter(t)); 294 314 else 295 sorter.setRowFilter(new ModTableFilter(-1)); 315 sorter.setRowFilter(new ModTableFilter(null)); 316 } 317 318 @Override 319 public void downloadSizeChanged(int newSize) { 320 lblDownloadSizeVal.setText(SizeFormatter.format(newSize, 2)); 321 } 322 323 @DoInBackground(progressMessage = "initializingEdition.title", cancelable = false, indeterminateProgress = false) 324 private void initialize(final BackgroundEvent evt) { 325 if (!Installer.isEditionInitialized()) { 326 int res = JOptionPane.showConfirmDialog(this, 327 bundle.getString("askInitialize.text"), 328 bundle.getString("askInitialize.title"), 329 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); 330 if (res == JOptionPane.NO_OPTION) { 331 exit(); 332 } else { 333 Installer.initializeEdition(new InstallProgressListener() { 334 @Override 335 public void installProgressUpdate(int done, int total, 336 String step) { 337 evt.setProgressEnd(total); 338 evt.setProgressValue(done); 339 evt.setProgressMessage(step); 340 } 341 }); 342 } 343 } 296 344 } 297 345 … … 323 371 if (askClose()) { 324 372 event.setHandled(true); 325 closeFrames();326 373 saveLocalData(); 327 374 exit(); … … 334 381 public void handleReOpenApplication(ApplicationEvent event) { 335 382 } 383 336 384 } -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.properties
r594 r600 18 18 menu.reglobalize=&Rebuild Core Data 19 19 menu.reglobalizeTooltip=Rebuild Core Data 20 menu.tools=&Manage Tools 21 menu.toolsTooltip=Install/Remove Tools 20 22 21 23 btnRevertSelection.text=Revert selection 22 24 btnRevertSelection.tooltip=Select mods which are currently installed 25 btnInstall.text=&Install 26 btnInstall.tooltip=Install selected mods 23 27 lblModTypes.text=Mod type: 28 lblDownloadSize.text=Size of files to download: 24 29 25 30 lblSubmitter.text=Submitter: 26 31 lblCreator.text=Creator: 27 lblId.text=NodeID:28 32 lblFiles.text=Number of files: 29 33 lblDescription.text=Description: … … 36 40 askClose.title=Confirm close request 37 41 askClose.text=Are you sure you want to close the program? 42 43 askInitialize.title=Initialize Edition 44 askInitialize.text=The Edition is not yet initialized.\nIf you do not initialize now the installer will exit.\nInitialize Edition core now? 45 46 initializingEdition.title=Initializing Edition core 47 installing.title=Installing mods -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.yml
r594 r600 6 6 locationRelativeTo: null 7 7 defaultCloseOperation: doNothingOnClose 8 onWindowOpened: [execDepotUpdate,checkUpdates, focus]9 onWindowClosing: [askClose, closeFrames,saveLocalData,exit]8 onWindowOpened: [execDepotUpdate,checkUpdates,initialize,focus] 9 onWindowClosing: [askClose,saveLocalData,exit] 10 10 iconImage: img.ae 11 11 content: 12 - Action(name=exitAction, text=menu.exit, toolTipText=menu.exitTooltip, icon=img.exit, onAction=[askClose, closeFrames,saveLocalData,exit])12 - Action(name=exitAction, text=menu.exit, toolTipText=menu.exitTooltip, icon=img.exit, onAction=[askClose,saveLocalData,exit]) 13 13 - Action(name=settings, text=menu.settings, toolTipText=menu.settingsTooltip, icon=img.settings, onAction=[showSettings]) 14 14 - Action(name=about, text=menu.about, toolTipText=menu.aboutTooltip, icon=img.about, onAction=[showAbout]) … … 16 16 - Action(name=saveConfig, text=menu.saveConfig, toolTipText=menu.saveConfigTooltip, icon=img.saveFile, onAction=[saveConfig]) 17 17 - Action(name=reglobalize, text=menu.reglobalize, toolTipText=menu.reglobalizeTooltip, icon=img.refresh, onAction=[reglobalize]) 18 - Action(name=tools, text=menu.tools, toolTipText=menu.toolsTooltip, icon=img.tools, onAction=[tools]) 18 19 - JMenuBar: 19 20 - JMenu(name=mainMenu, text=menu.main): … … 26 27 - JSeparator() 27 28 - JMenuItem(action=reglobalize) 28 - JToolBar(name=tools, floatable=false, orientation=0): 29 - JSeparator() 30 - JMenuItem(action=tools) 31 - JToolBar(name=toolbar, floatable=false, orientation=0): 29 32 - JButton(action=exitAction, hideActionText=true) 30 33 - JToolBarSeparator() … … 33 36 - JSplitPane(name=contents, orientation=horizontalSplit, continuousLayout=true): 34 37 - JPanel(name=panMods): 35 - JButton(name=btnRevertSelection, icon=img.undo16, text=btnRevertSelection.text, toolTipText=btnRevertSelection.tooltip, onAction=[revertSelection])36 38 - JLabel(name=lblModTypes, text=lblModTypes.text) 37 39 - JComboBox(name=cmbModTypes, onAction=modTypeSelection) 38 40 - JScrollPane(name=scrollMods, vScrollBar=always, hScrollBar=never): 39 41 JTable(name=tblMods, visible=false) 42 - JButton(name=btnRevertSelection, icon=img.undo16, text=btnRevertSelection.text, toolTipText=btnRevertSelection.tooltip, onAction=[revertSelection]) 43 - JButton(name=btnInstall, icon=img.install, text=btnInstall.text, toolTipText=btnInstall.tooltip, onAction=[install]) 44 - JLabel(name=lblDownloadSize, text=lblDownloadSize.text) 45 - JLabel(name=lblDownloadSizeVal) 40 46 - MigLayout: | 41 47 [grow] 42 btnRevertSelection [min]43 48 lblModTypes<,cmbModTypes [min] 44 49 scrollMods [grow] 50 >btnRevertSelection,btnInstall [min] 51 lblDownloadSize,lblDownloadSizeVal [min] 45 52 - JPanel(name=panInfo): 46 53 - JLabel(name=lblSubmitter, text=lblSubmitter.text) … … 48 55 - JLabel(name=lblCreator, text=lblCreator.text) 49 56 - JLabel(name=lblCreatorVal) 50 - JLabel(name=lblId, text=lblId.text)51 - JLabel(name=lblIdVal)52 57 - JLabel(name=lblFiles, text=lblFiles.text) 53 58 - JLabel(name=lblFilesVal) … … 59 64 >lblSubmitter lblSubmitterVal [min] 60 65 >lblCreator lblCreatorVal [min] 61 >lblId lblIdVal [min]62 66 >lblFiles lblFilesVal [min] 63 67 >^lblDescription scrollDescription [grow] -
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.