- Timestamp:
- 2011-10-02T22:14:54+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r4454 r4484 40 40 41 41 import javax.swing.AbstractAction; 42 import javax.swing.Action; 42 43 import javax.swing.Box; 43 44 import javax.swing.DefaultListCellRenderer; … … 47 48 import javax.swing.JLabel; 48 49 import javax.swing.JList; 50 import javax.swing.JMenuItem; 49 51 import javax.swing.JOptionPane; 50 52 import javax.swing.JPanel; … … 163 165 // button in the upper right corner of this dialog 164 166 public static JPanel pluginHook = new JPanel(); 167 168 private JPopupMenu propertyMenu; 169 private JPopupMenu membershipMenu; 165 170 166 171 private final Map<String, Map<String, Integer>> valueCount = new TreeMap<String, Map<String, Integer>>(); … … 610 615 611 616 // setting up the properties table 617 propertyMenu = new JPopupMenu(); 618 propertyMenu.add(copyValueAction); 619 propertyMenu.add(copyKeyValueAction); 620 propertyMenu.add(copyAllKeyValueAction); 621 propertyMenu.addSeparator(); 622 propertyMenu.add(helpAction); 623 612 624 propertyData.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")}); 613 625 propertyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); … … 620 632 if (row > -1) { 621 633 propertyTable.changeSelection(row, 0, false, false); 622 JPopupMenu menu = new JPopupMenu(); 623 menu.add(copyValueAction); 624 menu.add(copyKeyValueAction); 625 menu.add(copyAllKeyValueAction); 626 menu.addSeparator(); 627 menu.add(helpAction); 628 menu.show(propertyTable, p.x, p.y-3); 634 propertyMenu.show(propertyTable, p.x, p.y-3); 629 635 } 630 636 } … … 658 664 659 665 // setting up the membership table 666 membershipMenu = new JPopupMenu(); 667 membershipMenu.add(new SelectRelationAction(true)); 668 membershipMenu.add(new SelectRelationAction(false)); 669 membershipMenu.add(new SelectRelationMembersAction()); 670 membershipMenu.add(new DownloadIncompleteMembersAction()); 671 membershipMenu.addSeparator(); 672 membershipMenu.add(helpAction); 660 673 661 674 membershipData.setColumnIdentifiers(new String[]{tr("Member Of"),tr("Role"),tr("Position")}); … … 668 681 if (row > -1) { 669 682 membershipTable.changeSelection(row, 0, false, false); 670 JPopupMenu menu = new JPopupMenu();671 683 Relation relation = (Relation)membershipData.getValueAt(row, 0); 672 menu.add(new SelectRelationAction(relation, true)); 673 menu.add(new SelectRelationAction(relation, false)); 674 menu.add(new SelectRelationMembersAction(relation)); 675 menu.add(new DownloadIncompleteMembersAction(relation)); 676 menu.addSeparator(); 677 menu.add(helpAction); 678 menu.show(membershipTable, p.x, p.y-3); 684 for (Component c : membershipMenu.getComponents()) { 685 if (c instanceof JMenuItem) { 686 Action action = ((JMenuItem) c).getAction(); 687 if (action instanceof RelationRelated) { 688 ((RelationRelated)action).setRelation(relation); 689 } 690 } 691 } 692 membershipMenu.show(membershipTable, p.x, p.y-3); 679 693 } 680 694 } … … 1223 1237 } 1224 1238 1225 static class SelectRelationAction extends AbstractAction { 1239 public void addPropertyPopupMenuSeparator() { 1240 propertyMenu.addSeparator(); 1241 } 1242 1243 public JMenuItem addPropertyPopupMenuAction(Action a) { 1244 return propertyMenu.add(a); 1245 } 1246 1247 public void addMembershipPopupMenuSeparator() { 1248 membershipMenu.addSeparator(); 1249 } 1250 1251 public JMenuItem addMembershipPopupMenuAction(Action a) { 1252 return membershipMenu.add(a); 1253 } 1254 1255 public static interface RelationRelated { 1256 public Relation getRelation(); 1257 public void setRelation(Relation relation); 1258 } 1259 1260 static abstract class AbstractRelationAction extends AbstractAction implements RelationRelated { 1261 protected Relation relation; 1262 public Relation getRelation() { 1263 return this.relation; 1264 } 1265 public void setRelation(Relation relation) { 1266 this.relation = relation; 1267 } 1268 } 1269 1270 static class SelectRelationAction extends AbstractRelationAction { 1226 1271 boolean selectionmode; 1227 Relation relation; 1228 public SelectRelationAction(Relation r, boolean select) { 1272 public SelectRelationAction(boolean select) { 1229 1273 selectionmode = select; 1230 relation = r;1231 1274 if(select) { 1232 1275 putValue(NAME, tr("Select relation")); … … 1255 1298 * 1256 1299 */ 1257 class SelectRelationMembersAction extends AbstractAction { 1258 Relation relation; 1259 public SelectRelationMembersAction(Relation r) { 1260 relation = r; 1300 class SelectRelationMembersAction extends AbstractRelationAction { 1301 public SelectRelationMembersAction() { 1261 1302 putValue(SHORT_DESCRIPTION,tr("Select the members of selected relation")); 1262 1303 putValue(SMALL_ICON, ImageProvider.get("selectall")); … … 1276 1317 * 1277 1318 */ 1278 class DownloadIncompleteMembersAction extends AbstractAction { 1279 Relation relation; 1280 public DownloadIncompleteMembersAction(Relation r) { 1281 relation = r; 1319 class DownloadIncompleteMembersAction extends AbstractRelationAction { 1320 public DownloadIncompleteMembersAction() { 1282 1321 putValue(SHORT_DESCRIPTION, tr("Download incomplete members of selected relations")); 1283 1322 putValue(SMALL_ICON, ImageProvider.get("dialogs/relation", "downloadincompleteselected"));
Note:
See TracChangeset
for help on using the changeset viewer.