Changeset 659
- Timestamp:
- Jan 29, 2013, 4:53:39 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/AEInstaller.properties
r657 r659 1 1 appname=AE Installer 2 2 appversion=0.99 i2 appversion=0.99j -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTable.java
r658 r659 16 16 import java.util.ResourceBundle; 17 17 import java.util.TreeSet; 18 18 import java.util.Vector; 19 20 import javax.swing.JCheckBoxMenuItem; 19 21 import javax.swing.JComponent; 20 22 import javax.swing.JMenuItem; … … 28 30 import javax.swing.event.ListSelectionEvent; 29 31 import javax.swing.event.RowSorterEvent; 32 import javax.swing.table.JTableHeader; 33 import javax.swing.table.TableColumn; 34 import javax.swing.table.TableColumnModel; 30 35 import javax.swing.table.TableRowSorter; 31 36 … … 107 112 model.setColumnConstraints(i, getColumnModel().getColumn(i)); 108 113 } 114 115 getTableHeader().addMouseListener(new HeaderMouseEventHandler()); 109 116 110 117 if (contentType != ETableContentType.MODS) { … … 392 399 } 393 400 } 401 402 private class HeaderMouseEventHandler extends MouseAdapter { 403 private Vector<TableColumn> columns = new Vector<TableColumn>(); 404 private TableColumnModel tcm = getColumnModel(); 405 406 public HeaderMouseEventHandler() { 407 super(); 408 409 for (int i = 1; i < tcm.getColumnCount(); i++) { 410 columns.add(tcm.getColumn(i)); 411 } 412 413 for (int i = 1; i < columns.size(); i++) { 414 TableColumn tc = columns.get(i); 415 if (!Settings.getInstance().get( 416 String.format("modShowColumn%02d", tc.getModelIndex()), 417 true)) 418 tcm.removeColumn(tc); 419 } 420 } 421 422 private TableColumn getColumn(String name) { 423 for (TableColumn tc : columns) { 424 if (tc.getHeaderValue().equals(name)) { 425 return tc; 426 } 427 } 428 return null; 429 } 430 431 private int headerContains(TableColumn tc) { 432 for (int col = 0; col < tcm.getColumnCount(); col++) { 433 if (tcm.getColumn(col).equals(tc)) 434 return col; 435 } 436 return -1; 437 } 438 439 private void mouseEventProcessing(MouseEvent e) { 440 if (e.isPopupTrigger() && e.getComponent() instanceof JTableHeader) { 441 JPopupMenu popup = new JPopupMenu(); 442 443 ActionListener al = new ActionListener() { 444 @Override 445 public void actionPerformed(ActionEvent e) { 446 JCheckBoxMenuItem itm = (JCheckBoxMenuItem) e 447 .getSource(); 448 TableColumn col = getColumn(itm.getText()); 449 if (itm.isSelected()) { 450 tcm.addColumn(col); 451 for (int i = columns.indexOf(col) - 1; i >= 0; i--) { 452 int pos = headerContains(columns.get(i)); 453 if (pos >= 0) { 454 tcm.moveColumn(tcm.getColumnCount() - 1, 455 pos + 1); 456 break; 457 } 458 } 459 } else { 460 tcm.removeColumn(col); 461 } 462 Settings.getInstance().put( 463 String.format("modShowColumn%02d", 464 col.getModelIndex()), itm.isSelected()); 465 } 466 }; 467 468 for (int i = 1; i < columns.size(); i++) { 469 JCheckBoxMenuItem itm = new JCheckBoxMenuItem( 470 (String) columns.get(i).getHeaderValue()); 471 itm.setSelected(headerContains(columns.get(i)) >= 0); 472 473 itm.addActionListener(al); 474 popup.add(itm); 475 } 476 477 if (popup.getSubElements().length > 0) 478 popup.show(e.getComponent(), e.getX(), e.getY()); 479 } 480 } 481 482 @Override 483 public void mousePressed(MouseEvent e) { 484 mouseEventProcessing(e); 485 } 486 487 @Override 488 public void mouseReleased(MouseEvent e) { 489 mouseEventProcessing(e); 490 } 491 } 492 394 493 }
Note:
See TracChangeset
for help on using the changeset viewer.