Changeset 592 for AE/installer2/src/net/oni2/aeinstaller/gui
- Timestamp:
- Dec 29, 2012, 5:01:15 PM (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/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.