Changeset 6146 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2013-08-14T02:34:42+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java
r6084 r6146 51 51 * A UI component for resolving conflicts in two lists of entries of type T. 52 52 * 53 * @param Tthe type of the entries53 * @param <T> the type of the entries 54 54 * @see ListMergeModel 55 55 */ … … 413 413 } 414 414 415 /** 416 * Constructs a new {@code ListMerger}. 417 * @param model 418 */ 415 419 public ListMerger(ListMergeModel<T> model) { 416 420 this.model = model; … … 421 425 422 426 /** 427 * Base class of all other Copy* inner classes. 428 */ 429 abstract class CopyAction extends AbstractAction implements ListSelectionListener { 430 431 protected CopyAction(String icon_name, String action_name, String short_description) { 432 ImageIcon icon = ImageProvider.get("dialogs/conflict", icon_name+".png"); 433 putValue(Action.SMALL_ICON, icon); 434 if (icon == null) { 435 putValue(Action.NAME, action_name); 436 } 437 putValue(Action.SHORT_DESCRIPTION, short_description); 438 setEnabled(false); 439 } 440 } 441 442 /** 423 443 * Action for copying selected nodes in the list of my nodes to the list of merged 424 444 * nodes. Inserts the nodes at the beginning of the list of merged nodes. 425 *426 445 */ 427 class CopyStartLeftAction extends AbstractAction implements ListSelectionListener{446 class CopyStartLeftAction extends CopyAction { 428 447 429 448 public CopyStartLeftAction() { 430 ImageIcon icon = ImageProvider.get("dialogs/conflict", "copystartleft.png"); 431 putValue(Action.SMALL_ICON, icon); 432 if (icon == null) { 433 putValue(Action.NAME, tr("> top")); 434 } 435 putValue(Action.SHORT_DESCRIPTION, tr("Copy my selected nodes to the start of the merged node list")); 436 setEnabled(false); 437 } 438 439 @Override 440 public void actionPerformed(ActionEvent arg0) { 441 int [] rows = myEntriesTable.getSelectedRows(); 442 model.copyMyToTop(rows); 449 super("copystartleft", tr("> top"), tr("Copy my selected nodes to the start of the merged node list")); 450 } 451 452 @Override 453 public void actionPerformed(ActionEvent e) { 454 model.copyMyToTop(myEntriesTable.getSelectedRows()); 443 455 } 444 456 … … 452 464 * Action for copying selected nodes in the list of my nodes to the list of merged 453 465 * nodes. Inserts the nodes at the end of the list of merged nodes. 454 *455 466 */ 456 class CopyEndLeftAction extends AbstractAction implements ListSelectionListener{467 class CopyEndLeftAction extends CopyAction { 457 468 458 469 public CopyEndLeftAction() { 459 ImageIcon icon = ImageProvider.get("dialogs/conflict", "copyendleft.png"); 460 putValue(Action.SMALL_ICON, icon); 461 if (icon == null) { 462 putValue(Action.NAME, tr("> bottom")); 463 } 464 putValue(Action.SHORT_DESCRIPTION, tr("Copy my selected elements to the end of the list of merged elements.")); 465 setEnabled(false); 466 } 467 468 @Override 469 public void actionPerformed(ActionEvent arg0) { 470 int [] rows = myEntriesTable.getSelectedRows(); 471 model.copyMyToEnd(rows); 470 super("copyendleft", tr("> bottom"), tr("Copy my selected elements to the end of the list of merged elements.")); 471 } 472 473 @Override 474 public void actionPerformed(ActionEvent e) { 475 model.copyMyToEnd(myEntriesTable.getSelectedRows()); 472 476 } 473 477 … … 481 485 * Action for copying selected nodes in the list of my nodes to the list of merged 482 486 * nodes. Inserts the nodes before the first selected row in the list of merged nodes. 483 *484 487 */ 485 class CopyBeforeCurrentLeftAction extends AbstractAction implements ListSelectionListener{488 class CopyBeforeCurrentLeftAction extends CopyAction { 486 489 487 490 public CopyBeforeCurrentLeftAction() { 488 ImageIcon icon = ImageProvider.get("dialogs/conflict", "copybeforecurrentleft.png"); 489 putValue(Action.SMALL_ICON, icon); 490 if (icon == null) { 491 putValue(Action.NAME, "> before"); 492 } 493 putValue(Action.SHORT_DESCRIPTION, tr("Copy my selected elements before the first selected element in the list of merged elements.")); 494 setEnabled(false); 495 } 496 497 @Override 498 public void actionPerformed(ActionEvent arg0) { 499 int [] myRows = myEntriesTable.getSelectedRows(); 491 super("copybeforecurrentleft", tr("> before"), 492 tr("Copy my selected elements before the first selected element in the list of merged elements.")); 493 } 494 495 @Override 496 public void actionPerformed(ActionEvent e) { 500 497 int [] mergedRows = mergedEntriesTable.getSelectedRows(); 501 498 if (mergedRows == null || mergedRows.length == 0) 502 499 return; 500 int [] myRows = myEntriesTable.getSelectedRows(); 503 501 int current = mergedRows[0]; 504 502 model.copyMyBeforeCurrent(myRows, current); … … 509 507 setEnabled( 510 508 !myEntriesTable.getSelectionModel().isSelectionEmpty() 511 && ! 509 && !mergedEntriesTable.getSelectionModel().isSelectionEmpty() 512 510 ); 513 511 } … … 517 515 * Action for copying selected nodes in the list of my nodes to the list of merged 518 516 * nodes. Inserts the nodes after the first selected row in the list of merged nodes. 519 *520 517 */ 521 class CopyAfterCurrentLeftAction extends AbstractAction implements ListSelectionListener{518 class CopyAfterCurrentLeftAction extends CopyAction { 522 519 523 520 public CopyAfterCurrentLeftAction() { 524 ImageIcon icon = ImageProvider.get("dialogs/conflict", "copyaftercurrentleft.png"); 525 putValue(Action.SMALL_ICON, icon); 526 if (icon == null) { 527 putValue(Action.NAME, "> after"); 528 } 529 putValue(Action.SHORT_DESCRIPTION, tr("Copy my selected elements after the first selected element in the list of merged elements.")); 530 setEnabled(false); 531 } 532 533 @Override 534 public void actionPerformed(ActionEvent arg0) { 535 int [] myRows = myEntriesTable.getSelectedRows(); 521 super("copyaftercurrentleft", tr("> after"), 522 tr("Copy my selected elements after the first selected element in the list of merged elements.")); 523 } 524 525 @Override 526 public void actionPerformed(ActionEvent e) { 536 527 int [] mergedRows = mergedEntriesTable.getSelectedRows(); 537 528 if (mergedRows == null || mergedRows.length == 0) 538 529 return; 530 int [] myRows = myEntriesTable.getSelectedRows(); 539 531 int current = mergedRows[0]; 540 532 model.copyMyAfterCurrent(myRows, current); … … 545 537 setEnabled( 546 538 !myEntriesTable.getSelectionModel().isSelectionEmpty() 547 && ! 539 && !mergedEntriesTable.getSelectionModel().isSelectionEmpty() 548 540 ); 549 541 } 550 542 } 551 543 552 class CopyStartRightAction extends AbstractAction implements ListSelectionListener{544 class CopyStartRightAction extends CopyAction { 553 545 554 546 public CopyStartRightAction() { 555 ImageIcon icon = ImageProvider.get("dialogs/conflict", "copystartright.png"); 556 putValue(Action.SMALL_ICON, icon); 557 if (icon == null) { 558 putValue(Action.NAME, "< top"); 559 } 560 putValue(Action.SHORT_DESCRIPTION, tr("Copy their selected element to the start of the list of merged elements.")); 561 setEnabled(false); 562 } 563 564 @Override 565 public void actionPerformed(ActionEvent arg0) { 566 int [] rows = theirEntriesTable.getSelectedRows(); 567 model.copyTheirToTop(rows); 547 super("copystartright", tr("< top"), tr("Copy their selected element to the start of the list of merged elements.")); 548 } 549 550 @Override 551 public void actionPerformed(ActionEvent e) { 552 model.copyTheirToTop(theirEntriesTable.getSelectedRows()); 568 553 } 569 554 … … 574 559 } 575 560 576 class CopyEndRightAction extends AbstractAction implements ListSelectionListener{561 class CopyEndRightAction extends CopyAction { 577 562 578 563 public CopyEndRightAction() { 579 ImageIcon icon = ImageProvider.get("dialogs/conflict", "copyendright.png"); 580 putValue(Action.SMALL_ICON, icon); 581 if (icon == null) { 582 putValue(Action.NAME, "< bottom"); 583 } 584 putValue(Action.SHORT_DESCRIPTION, tr("Copy their selected elements to the end of the list of merged elements.")); 585 setEnabled(false); 564 super("copyendright", tr("< bottom"), tr("Copy their selected elements to the end of the list of merged elements.")); 586 565 } 587 566 588 567 @Override 589 568 public void actionPerformed(ActionEvent arg0) { 590 int [] rows = theirEntriesTable.getSelectedRows(); 591 model.copyTheirToEnd(rows); 569 model.copyTheirToEnd(theirEntriesTable.getSelectedRows()); 592 570 } 593 571 … … 598 576 } 599 577 600 class CopyBeforeCurrentRightAction extends AbstractAction implements ListSelectionListener{578 class CopyBeforeCurrentRightAction extends CopyAction { 601 579 602 580 public CopyBeforeCurrentRightAction() { 603 ImageIcon icon = ImageProvider.get("dialogs/conflict", "copybeforecurrentright.png"); 604 putValue(Action.SMALL_ICON, icon); 605 if (icon == null) { 606 putValue(Action.NAME, "< before"); 607 } 608 putValue(Action.SHORT_DESCRIPTION, tr("Copy their selected elements before the first selected element in the list of merged elements.")); 609 setEnabled(false); 610 } 611 612 @Override 613 public void actionPerformed(ActionEvent arg0) { 614 int [] myRows = theirEntriesTable.getSelectedRows(); 581 super("copybeforecurrentright", tr("< before"), 582 tr("Copy their selected elements before the first selected element in the list of merged elements.")); 583 } 584 585 @Override 586 public void actionPerformed(ActionEvent e) { 615 587 int [] mergedRows = mergedEntriesTable.getSelectedRows(); 616 588 if (mergedRows == null || mergedRows.length == 0) 617 589 return; 590 int [] myRows = theirEntriesTable.getSelectedRows(); 618 591 int current = mergedRows[0]; 619 592 model.copyTheirBeforeCurrent(myRows, current); … … 624 597 setEnabled( 625 598 !theirEntriesTable.getSelectionModel().isSelectionEmpty() 626 && ! 599 && !mergedEntriesTable.getSelectionModel().isSelectionEmpty() 627 600 ); 628 601 } 629 602 } 630 603 631 class CopyAfterCurrentRightAction extends AbstractAction implements ListSelectionListener{604 class CopyAfterCurrentRightAction extends CopyAction { 632 605 633 606 public CopyAfterCurrentRightAction() { 634 ImageIcon icon = ImageProvider.get("dialogs/conflict", "copyaftercurrentright.png"); 635 putValue(Action.SMALL_ICON, icon); 636 if (icon == null) { 637 putValue(Action.NAME, "< after"); 638 } 639 putValue(Action.SHORT_DESCRIPTION, tr("Copy their selected element after the first selected element in the list of merged elements")); 640 setEnabled(false); 641 } 642 643 @Override 644 public void actionPerformed(ActionEvent arg0) { 645 int [] myRows = theirEntriesTable.getSelectedRows(); 607 super("copyaftercurrentright", tr("< after"), 608 tr("Copy their selected element after the first selected element in the list of merged elements")); 609 } 610 611 @Override 612 public void actionPerformed(ActionEvent e) { 646 613 int [] mergedRows = mergedEntriesTable.getSelectedRows(); 647 614 if (mergedRows == null || mergedRows.length == 0) 648 615 return; 616 int [] myRows = theirEntriesTable.getSelectedRows(); 649 617 int current = mergedRows[0]; 650 618 model.copyTheirAfterCurrent(myRows, current); … … 655 623 setEnabled( 656 624 !theirEntriesTable.getSelectionModel().isSelectionEmpty() 657 && ! 625 && !mergedEntriesTable.getSelectionModel().isSelectionEmpty() 658 626 ); 659 627 }
Note:
See TracChangeset
for help on using the changeset viewer.