- Timestamp:
- Dec 29, 2012, 5:01:15 PM (12 years ago)
- Location:
- AE/installer2
- Files:
-
- 5 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/AEInstaller2.java
r591 r592 4 4 import java.io.FileNotFoundException; 5 5 import java.io.PrintStream; 6 import java.util.ResourceBundle; 6 7 7 8 import javax.swing.JFrame; 9 import javax.swing.JOptionPane; 8 10 import javax.swing.JToolBar; 9 11 import javax.swing.SwingUtilities; … … 52 54 new File(Settings.getDepotCacheFilename())); 53 55 54 SwingJavaBuilder.getConfig().addResourceBundle("Images"); 56 ResourceBundle imagesBundle = ResourceBundle 57 .getBundle(AEInstaller2.class.getPackage().getName() 58 + ".Images"); 59 ResourceBundle basicBundle = ResourceBundle 60 .getBundle(AEInstaller2.class.getPackage().getName() 61 + ".AEInstaller"); 62 63 SwingJavaBuilder.getConfig().addResourceBundle(imagesBundle); 64 SwingJavaBuilder.getConfig().addResourceBundle(basicBundle); 55 65 SwingJavaBuilder.getConfig().setMarkInvalidResourceBundleKeys(true); 56 66 SwingJavaBuilder.getConfig().addType("JToolBarSeparator", … … 91 101 + StuffToRefactorLater.verifyRunningDirectory()); 92 102 103 if (!StuffToRefactorLater.verifyRunningDirectory()) { 104 JOptionPane.showMessageDialog(null, 105 basicBundle.getString("invalidPath.text"), 106 basicBundle.getString("invalidPath.title"), 107 JOptionPane.ERROR_MESSAGE); 108 if (!Settings.getDebug()) { 109 return; 110 } 111 } 112 93 113 SwingUtilities.invokeLater(new Runnable() { 94 114 -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotConfig.java
r591 r592 5 5 */ 6 6 public class DepotConfig { 7 /**8 * Type-value of nodes which contain Mods9 */10 public static final String NODETYPE_MOD = "mod";11 7 12 8 /** 13 * Vocabulary name for platform field9 * @return Type-value of nodes which contain Mods 14 10 */ 15 public static final String PLATFORM_VOCAB = "Platform"; 16 /** 17 * Vocabulary name for installtype field 18 */ 19 public static final String INSTALLTYPE_VOCAB = "Install method"; 20 /** 21 * Vocabulary name for modtype field 22 */ 23 public static final String MODTYPE_VOCAB = "Mod type"; 24 25 /** 26 * Taxonomy term name for platform value Win 27 */ 28 public static final String PLATFORM_WIN = "Windows"; 29 /** 30 * Taxonomy term name for platform value Mac 31 */ 32 public static final String PLATFORM_MAC = "Mac OS"; 33 /** 34 * Taxonomy term name for platform value Both 35 */ 36 public static final String PLATFORM_BOTH = "Both"; 11 public static String getNodeType_Mod() { 12 return "mod"; 13 } 37 14 38 15 /** 39 * Taxonomy term name for installtype Package16 * @return Vocabulary name for platform field 40 17 */ 41 public static final String INSTALLTYPE_PACKAGE = "Package"; 18 public static String getVocabularyName_Platform() { 19 return "Platform"; 20 } 21 22 /** 23 * @return Vocabulary name for installtype field 24 */ 25 public static String getVocabularyName_InstallType() { 26 return "Install method"; 27 } 28 29 /** 30 * @return Vocabulary name for modtype field 31 */ 32 public static String getVocabularyName_ModType() { 33 return "Mod type"; 34 } 35 36 /** 37 * @return Taxonomy term name for platform value Win 38 */ 39 public static String getTaxonomyName_Platform_Win() { 40 return "Windows"; 41 } 42 43 /** 44 * @return Taxonomy term name for platform value Mac 45 */ 46 public static String getTaxonomyName_Platform_Mac() { 47 return "Mac OS"; 48 } 49 50 /** 51 * @return Taxonomy term name for platform value Both 52 */ 53 public static String getTaxonomyName_Platform_Both() { 54 return "Both"; 55 } 56 57 /** 58 * @return Taxonomy term name for installtype Package 59 */ 60 public static String getTaxonomyName_InstallType_Package() { 61 return "Package"; 62 } 42 63 } -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotManager.java
r591 r592 174 174 175 175 Node n = null; 176 if (type.equalsIgnoreCase(DepotConfig. NODETYPE_MOD))176 if (type.equalsIgnoreCase(DepotConfig.getNodeType_Mod())) 177 177 n = new NodeMod(jo); 178 178 else … … 196 196 } 197 197 198 vocabId_type = getVocabulary(DepotConfig.MODTYPE_VOCAB).getVid(); 199 vocabId_platform = getVocabulary(DepotConfig.PLATFORM_VOCAB) 200 .getVid(); 201 vocabId_instmethod = getVocabulary(DepotConfig.INSTALLTYPE_VOCAB) 202 .getVid(); 198 vocabId_type = getVocabulary( 199 DepotConfig.getVocabularyName_ModType()).getVid(); 200 vocabId_platform = getVocabulary( 201 DepotConfig.getVocabularyName_Platform()).getVid(); 202 vocabId_instmethod = getVocabulary( 203 DepotConfig.getVocabularyName_InstallType()).getVid(); 203 204 } catch (JSONException e) { 204 205 e.printStackTrace(); … … 289 290 */ 290 291 public Vector<NodeMod> getModPackageNodes() { 291 int packageterm_id = getTaxonomyTerm(DepotConfig.INSTALLTYPE_PACKAGE)292 .getTid();293 294 Vector<Node> files = getNodesByType(DepotConfig.NODETYPE_MOD);295 292 Vector<NodeMod> result = new Vector<NodeMod>(); 293 TaxonomyTerm tt = getTaxonomyTerm(DepotConfig.getTaxonomyName_InstallType_Package()); 294 if (tt == null) 295 return result; 296 297 int packageterm_id = tt.getTid(); 298 299 Vector<Node> files = getNodesByType(DepotConfig.getNodeType_Mod()); 296 300 for (Node n : files) { 297 301 if (n instanceof NodeMod) { … … 316 320 .next(); 317 321 String validPlatform = getTaxonomyTerm(termId).getName(); 318 if (validPlatform.equalsIgnoreCase(DepotConfig. PLATFORM_BOTH))322 if (validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Both())) 319 323 return true; 320 324 321 325 if ((platform == Platform.WIN) || (platform == Platform.LINUX)) 322 return validPlatform.equalsIgnoreCase(DepotConfig. PLATFORM_WIN);326 return validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Win()); 323 327 else if (platform == Platform.MACOS) 324 return validPlatform.equalsIgnoreCase(DepotConfig. PLATFORM_MAC);328 return validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Mac()); 325 329 else 326 330 return false; -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/model/NodeMod.java
r591 r592 32 32 NodeField_Upload up = new NodeField_Upload( 33 33 jUploads.getJSONObject(i)); 34 uploads.add(up); 34 if (up.getDisplay() != 0) { 35 uploads.add(up); 36 } 35 37 } 36 38 } -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r591 r592 11 11 import javax.swing.JComboBox; 12 12 import javax.swing.JFrame; 13 import javax.swing.JOptionPane; 13 import javax.swing.JLabel; 14 import javax.swing.JSplitPane; 14 15 import javax.swing.JTable; 15 16 import javax.swing.ListSelectionModel; 16 17 import javax.swing.RowSorter; 17 import javax.swing.RowSorter.SortKey;18 18 import javax.swing.SortOrder; 19 19 import javax.swing.SwingUtilities; … … 23 23 24 24 import net.oni2.aeinstaller.backend.Settings; 25 import net.oni2.aeinstaller.backend.StuffToRefactorLater;26 25 import net.oni2.aeinstaller.backend.depot.DepotCacheUpdateProgressListener; 27 26 import net.oni2.aeinstaller.backend.depot.DepotConfig; … … 29 28 import net.oni2.aeinstaller.backend.depot.model.NodeMod; 30 29 import net.oni2.aeinstaller.backend.depot.model.TaxonomyTerm; 30 import net.oni2.aeinstaller.backend.depot.model.TaxonomyVocabulary; 31 31 import net.oni2.aeinstaller.gui.modtable.ModTableFilter; 32 32 import net.oni2.aeinstaller.gui.modtable.ModTableModel; … … 41 41 * @author Christian Illy 42 42 */ 43 public class MainWin extends JFrame implements ListSelectionListener{43 public class MainWin extends JFrame { 44 44 private static final long serialVersionUID = -4027395051382659650L; 45 45 … … 48 48 @SuppressWarnings("unused") 49 49 private BuildResult result = SwingJavaBuilder.build(this, bundle); 50 51 private JSplitPane contents; 50 52 51 53 private JComboBox cmbModTypes; … … 53 55 private ModTableModel model; 54 56 private TableRowSorter<ModTableModel> sorter; 57 58 private JLabel lblSubmitterVal; 59 private JLabel lblCreatorVal; 60 private JLabel lblFilesVal; 61 private JLabel lblIdVal; 62 private HTMLLinkLabel lblDescriptionVal; 55 63 56 64 /** … … 61 69 + bundle.getString("version")); 62 70 71 contents.setDividerLocation(400); 63 72 initTable(); 64 73 initModTypeBox(); … … 66 75 67 76 private void initModTypeBox() { 68 int vid = DepotManager.getInstance() 69 .getVocabulary(DepotConfig.MODTYPE_VOCAB).getVid(); 77 cmbModTypes.removeAllItems(); 78 79 TaxonomyVocabulary tv = DepotManager.getInstance().getVocabulary( 80 DepotConfig.getVocabularyName_ModType()); 81 if (tv == null) 82 return; 83 84 int vid = tv.getVid(); 70 85 TreeMap<String, TaxonomyTerm> terms = new TreeMap<String, TaxonomyTerm>(); 71 86 terms.put(" ", new TaxonomyTerm(-1, vid, "-All-")); … … 82 97 private void initTable() { 83 98 tblMods.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 84 tblMods.getSelectionModel().addListSelectionListener(this); 99 tblMods.getSelectionModel().addListSelectionListener( 100 new ListSelectionListener() { 101 102 @Override 103 public void valueChanged(ListSelectionEvent e) { 104 int viewRow = tblMods.getSelectedRow(); 105 if (viewRow < 0) { 106 modSelection(null); 107 } else { 108 int modelRow = tblMods 109 .convertRowIndexToModel(viewRow); 110 NodeMod mod = (NodeMod) model.getValueAt(modelRow, 111 -1); 112 modSelection(mod); 113 } 114 } 115 }); 85 116 86 117 model = new ModTableModel(); … … 127 158 } 128 159 160 @SuppressWarnings("unused") 129 161 private void exit() { 130 162 setVisible(false); … … 137 169 DepotManager.getInstance().saveToFile( 138 170 new File(Settings.getDepotCacheFilename())); 139 }140 141 @SuppressWarnings("unused")142 private boolean validatePath() {143 if (!StuffToRefactorLater.verifyRunningDirectory()) {144 JOptionPane.showMessageDialog(this,145 bundle.getString("invalidPath.text"),146 bundle.getString("invalidPath.title"),147 JOptionPane.ERROR_MESSAGE);148 if (!Settings.getDebug()) {149 exit();150 return false;151 }152 }153 return true;154 171 } 155 172 … … 169 186 }); 170 187 model.reloadData(); 188 initModTypeBox(); 189 tblMods.setVisible(true); 171 190 DepotManager.getInstance().printStats(); 172 191 } catch (Exception e) { … … 199 218 } 200 219 220 private void modSelection(NodeMod n) { 221 lblSubmitterVal.setText(""); 222 lblCreatorVal.setText(""); 223 lblIdVal.setText(""); 224 lblFilesVal.setText(""); 225 lblDescriptionVal.setText(""); 226 if (n != null) { 227 lblSubmitterVal.setText(n.getName()); 228 lblCreatorVal.setText(n.getFields().get("creator")); 229 lblIdVal.setText(Integer.toString(n.getNid())); 230 lblFilesVal.setText(Integer.toString(n.getUploads().size())); 231 if (n.getBody() != null) 232 lblDescriptionVal.setText(n.getBody().getSafe_value()); 233 } 234 // TODO 235 } 236 201 237 @SuppressWarnings("unused") 202 238 private void modTypeSelection() { 203 239 TaxonomyTerm t = (TaxonomyTerm) cmbModTypes.getSelectedItem(); 204 sorter.setRowFilter(new ModTableFilter(t.getTid())); 205 } 206 207 @SuppressWarnings("unused") 208 private void sortAlpha() { 209 SortOrder order = SortOrder.ASCENDING; 210 for (SortKey sk : sorter.getSortKeys()) { 211 if (sk.getColumn() == 0) { 212 if (sk.getSortOrder() == SortOrder.ASCENDING) 213 order = SortOrder.DESCENDING; 214 } 215 } 216 List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(); 217 sortKeys.add(new RowSorter.SortKey(0, order)); 218 sorter.setSortKeys(sortKeys); 219 } 220 221 @SuppressWarnings("unused") 222 private void sortPackageNumber() { 223 SortOrder order = SortOrder.ASCENDING; 224 for (SortKey sk : sorter.getSortKeys()) { 225 if (sk.getColumn() == 1) { 226 if (sk.getSortOrder() == SortOrder.ASCENDING) 227 order = SortOrder.DESCENDING; 228 } 229 } 230 List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(); 231 sortKeys.add(new RowSorter.SortKey(1, order)); 232 sorter.setSortKeys(sortKeys); 233 } 234 235 @Override 236 public void valueChanged(ListSelectionEvent arg0) { 237 int viewRow = tblMods.getSelectedRow(); 238 if (viewRow < 0) 239 // TODO 240 return; 241 int modelRow = tblMods.convertRowIndexToModel(viewRow); 242 NodeMod mod = (NodeMod) model.getValueAt(modelRow, -1); 243 // TODO 240 if (t != null) 241 sorter.setRowFilter(new ModTableFilter(t.getTid())); 242 else 243 sorter.setRowFilter(new ModTableFilter(-1)); 244 244 } 245 245 } -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.properties
r591 r592 12 12 lblModTypes.text=Mod types: 13 13 14 lblSubmitter.text=Submitter: 15 lblCreator.text=Creator: 16 lblId.text=NodeID: 17 lblFiles.text=Number of files: 18 lblDescription.text=Description: 14 19 15 20 updateDepot.title=Updating Mod Depot cache … … 17 22 updatesAvailable.title=Updates available 18 23 updatesAvailable.text=Some mods have newer versions available. 19 20 invalidPath.title=Wrong directory21 invalidPath.text=This program has to be placed in the subfolder Edition/AEInstaller inside a vanilla Oni folder.\nThe full path of the .jar-file has to be:\nOniFolder/Edition/AEInstaller/AEInstaller2.jar -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.yml
r591 r592 6 6 locationRelativeTo: null 7 7 defaultCloseOperation: doNothingOnClose 8 onWindowOpened: [ validatePath,execDepotUpdate,checkUpdates,focus]8 onWindowOpened: [execDepotUpdate,checkUpdates,focus] 9 9 onWindowClosing: [$confirm,closeFrames,saveLocalData,exit] 10 10 iconImage: img.kdt … … 20 20 - JToolBarSeparator() 21 21 - JButton(action=settings, hideActionText=true) 22 - J Panel(name=contents):22 - JSplitPane(name=contents, orientation=horizontalSplit, continuousLayout=true): 23 23 - JPanel(name=panMods): 24 24 - JLabel(name=lblModTypes, text=lblModTypes.text) 25 25 - JComboBox(name=cmbModTypes, onAction=modTypeSelection) 26 26 - JScrollPane(name=scrollMods, vScrollBar=always, hScrollBar=never): 27 JTable(name=tblMods) 28 - JButton(name=btnSortAlpha, onAction=sortAlpha, text=A-Z) 29 - JButton(name=btnSortNumber, onAction=sortPackageNumber, text=0-9) 27 JTable(name=tblMods, visible=false) 30 28 - MigLayout: | 31 29 [grow] 32 30 lblModTypes<,cmbModTypes [min] 33 31 scrollMods [grow] 34 >btnSortAlpha=1<,btnSortNumber=1< [min] 35 - MigLayout: | 36 [pref] 37 panMods [grow] 32 - JPanel(name=panInfo): 33 - JLabel(name=lblSubmitter, text=lblSubmitter.text) 34 - JLabel(name=lblSubmitterVal) 35 - JLabel(name=lblCreator, text=lblCreator.text) 36 - JLabel(name=lblCreatorVal) 37 - JLabel(name=lblId, text=lblId.text) 38 - JLabel(name=lblIdVal) 39 - JLabel(name=lblFiles, text=lblFiles.text) 40 - JLabel(name=lblFilesVal) 41 - JLabel(name=lblDescription, text=lblDescription.text) 42 - JScrollPane(name=scrollDescription, vScrollBar=always, hScrollBar=asNeeded): 43 HTMLLinkLabel(name=lblDescriptionVal) 44 - MigLayout: | 45 [min] [grow] 46 >lblSubmitter lblSubmitterVal [min] 47 >lblCreator lblCreatorVal [min] 48 >lblId lblIdVal [min] 49 >lblFiles lblFilesVal [min] 50 >^lblDescription scrollDescription [grow] 38 51 - MigLayout: 39 52 layoutConstraints: wrap 1 -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableModel.java
r591 r592 46 46 if (vocabModTypeID < 0) { 47 47 vocabModTypeID = DepotManager.getInstance() 48 .getVocabulary(DepotConfig. MODTYPE_VOCAB).getVid();48 .getVocabulary(DepotConfig.getVocabularyName_ModType()).getVid(); 49 49 } 50 50 for (int tid : node.getTaxonomyTerms().get(vocabModTypeID)) { … … 58 58 if (vocabPlatformID < 0) { 59 59 vocabPlatformID = DepotManager.getInstance() 60 .getVocabulary(DepotConfig. PLATFORM_VOCAB).getVid();60 .getVocabulary(DepotConfig.getVocabularyName_Platform()).getVid(); 61 61 } 62 62 int tid = node.getTaxonomyTerms().get(vocabPlatformID) -
AE/installer2/src/net/oni2/aeinstaller/gui/settings/LaFComboModel.java
r591 r592 31 31 items.add(laf); 32 32 33 33 34 String laf = Settings.getInstance().get("lookandfeel", 34 UIManager.get SystemLookAndFeelClassName());35 UIManager.getLookAndFeel().getClass().getName()); 35 36 36 37 if (items.size() > 0) -
AE/installer2/src/net/oni2/aeinstaller/gui/settings/SettingsDialog.java
r591 r592 94 94 95 95 String oldLaf = set.get("lookandfeel", 96 UIManager.get SystemLookAndFeelClassName());96 UIManager.getLookAndFeel().getClass().getName()); 97 97 String newLaf = laFModel.getSelectedClassName(); 98 98
Note:
See TracChangeset
for help on using the changeset viewer.