Changeset 13210 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
- Timestamp:
- 2017-12-17T15:37:11+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r12846 r13210 13 13 import java.util.Collection; 14 14 import java.util.Collections; 15 import java.util.EnumSet; 15 16 import java.util.HashSet; 16 17 import java.util.List; … … 29 30 import javax.swing.KeyStroke; 30 31 import javax.swing.ListSelectionModel; 32 import javax.swing.event.PopupMenuEvent; 33 import javax.swing.event.PopupMenuListener; 31 34 32 35 import org.openstreetmap.josm.Main; 33 36 import org.openstreetmap.josm.actions.ExpertToggleAction; 37 import org.openstreetmap.josm.actions.OsmPrimitiveAction; 34 38 import org.openstreetmap.josm.actions.relation.AddSelectionToRelations; 35 39 import org.openstreetmap.josm.actions.relation.DeleteRelationsAction; … … 38 42 import org.openstreetmap.josm.actions.relation.DuplicateRelationAction; 39 43 import org.openstreetmap.josm.actions.relation.EditRelationAction; 44 import org.openstreetmap.josm.actions.relation.ExportRelationToGpxAction; 45 import org.openstreetmap.josm.actions.relation.ExportRelationToGpxAction.Mode; 40 46 import org.openstreetmap.josm.actions.relation.RecentRelationsAction; 41 47 import org.openstreetmap.josm.actions.relation.SelectMembersAction; … … 122 128 private transient JMenuItem addSelectionToRelationMenuItem; 123 129 130 /** export relation to GPX track action */ 131 private final ExportRelationToGpxAction exportRelationFromFirstAction = 132 new ExportRelationToGpxAction(EnumSet.of(Mode.FROM_FIRST_MEMBER, Mode.TO_FILE)); 133 private final ExportRelationToGpxAction exportRelationFromLastAction = 134 new ExportRelationToGpxAction(EnumSet.of(Mode.FROM_LAST_MEMBER, Mode.TO_FILE)); 135 private final ExportRelationToGpxAction exportRelationFromFirstToLayerAction = 136 new ExportRelationToGpxAction(EnumSet.of(Mode.FROM_FIRST_MEMBER, Mode.TO_LAYER)); 137 private final ExportRelationToGpxAction exportRelationFromLastToLayerAction = 138 new ExportRelationToGpxAction(EnumSet.of(Mode.FROM_LAST_MEMBER, Mode.TO_LAYER)); 139 124 140 private final transient HighlightHelper highlightHelper = new HighlightHelper(); 125 141 private final boolean highlightEnabled = Config.getPref().getBoolean("draw.target-highlight", true); … … 603 619 604 620 private void setupPopupMenuHandler() { 621 List<JMenuItem> checkDisabled = new ArrayList<>(); 605 622 606 623 // -- select action … … 612 629 popupMenuHandler.addAction(addMembersToSelectionAction); 613 630 631 // -- download members action 614 632 popupMenuHandler.addSeparator(); 615 // -- download members action616 633 popupMenuHandler.addAction(downloadMembersAction); 617 618 // -- download incomplete members action619 634 popupMenuHandler.addAction(downloadSelectedIncompleteMembersAction); 635 636 // -- export relation to gpx action 637 popupMenuHandler.addSeparator(); 638 checkDisabled.add(popupMenuHandler.addAction(exportRelationFromFirstAction)); 639 checkDisabled.add(popupMenuHandler.addAction(exportRelationFromLastAction)); 640 popupMenuHandler.addSeparator(); 641 checkDisabled.add(popupMenuHandler.addAction(exportRelationFromFirstToLayerAction)); 642 checkDisabled.add(popupMenuHandler.addAction(exportRelationFromLastToLayerAction)); 620 643 621 644 popupMenuHandler.addSeparator(); … … 625 648 626 649 addSelectionToRelationMenuItem = popupMenuHandler.addAction(addSelectionToRelations); 650 651 popupMenuHandler.addListener(new PopupMenuListener() { 652 @Override 653 public void popupMenuWillBecomeVisible(PopupMenuEvent e) { 654 for (JMenuItem mi: checkDisabled) { 655 mi.setVisible(((OsmPrimitiveAction) mi.getAction()).isEnabled()); 656 657 Component sep = popupMenu.getComponent( 658 Math.max(0, popupMenu.getComponentIndex(mi)-1)); 659 if (!(sep instanceof JMenuItem)) { 660 sep.setVisible(mi.isVisible()); 661 } 662 } 663 } 664 665 @Override 666 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { 667 } 668 669 @Override 670 public void popupMenuCanceled(PopupMenuEvent e) { 671 } 672 }); 627 673 } 628 674
Note:
See TracChangeset
for help on using the changeset viewer.