Changeset 8505 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2015-06-19T23:18:44+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r8444 r8505 33 33 import javax.swing.BorderFactory; 34 34 import javax.swing.InputMap; 35 import javax.swing.JButton; 35 36 import javax.swing.JComponent; 36 37 import javax.swing.JLabel; … … 56 57 import org.openstreetmap.josm.Main; 57 58 import org.openstreetmap.josm.actions.CopyAction; 59 import org.openstreetmap.josm.actions.ExpertToggleAction; 58 60 import org.openstreetmap.josm.actions.JosmAction; 59 61 import org.openstreetmap.josm.command.AddCommand; … … 114 116 */ 115 117 private JMenuItem windowMenuItem; 118 /** 119 * Button for performing the {@link org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditor.SortBelowAction}. 120 */ 121 private JButton sortBelowButton; 116 122 117 123 /** … … 508 514 memberTableModel.addTableModelListener(sortAction); 509 515 tb.add(sortAction); 516 final SortBelowAction sortBelowAction = new SortBelowAction(); 517 memberTableModel.addTableModelListener(sortBelowAction); 518 memberTableModel.getSelectionModel().addListSelectionListener(sortBelowAction); 519 sortBelowButton = tb.add(sortBelowAction); 510 520 511 521 // -- reverse action … … 603 613 super.setVisible(visible); 604 614 if (visible) { 615 sortBelowButton.setVisible(ExpertToggleAction.isExpert()); 605 616 RelationDialogManager.getRelationDialogManager().positionOnScreen(this); 606 617 if(windowMenuItem == null) { … … 1059 1070 } 1060 1071 1072 class SortBelowAction extends AbstractAction implements TableModelListener, ListSelectionListener { 1073 public SortBelowAction() { 1074 putValue(SMALL_ICON, ImageProvider.get("dialogs", "sort_below")); 1075 putValue(NAME, tr("Sort below")); 1076 putValue(SHORT_DESCRIPTION, tr("Sort the selected relation members and all members below")); 1077 updateEnabledState(); 1078 } 1079 1080 @Override 1081 public void actionPerformed(ActionEvent e) { 1082 memberTableModel.sortBelow(); 1083 } 1084 1085 protected void updateEnabledState() { 1086 setEnabled(memberTableModel.getRowCount() > 0 && !memberTableModel.getSelectionModel().isSelectionEmpty()); 1087 } 1088 1089 @Override 1090 public void tableChanged(TableModelEvent e) { 1091 updateEnabledState(); 1092 } 1093 1094 @Override 1095 public void valueChanged(ListSelectionEvent e) { 1096 updateEnabledState(); 1097 } 1098 } 1099 1061 1100 class ReverseAction extends AbstractAction implements TableModelListener { 1062 1101 public ReverseAction() { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r8413 r8505 718 718 } 719 719 720 /** 721 * Sort the selected relation members and all members below by the way they are linked. 722 */ 723 void sortBelow() { 724 final List<RelationMember> subList = members.subList(getSelectionModel().getMinSelectionIndex(), members.size()); 725 final List<RelationMember> sorted = relationSorter.sortMembers(subList); 726 subList.clear(); 727 subList.addAll(sorted); 728 fireTableDataChanged(); 729 setSelectedMembers(sorted); 730 } 731 720 732 WayConnectionType getWayConnection(int i) { 721 733 if (connectionType == null) {
Note:
See TracChangeset
for help on using the changeset viewer.