Changeset 6960 in josm for trunk/src/org
- Timestamp:
- 2014-04-06T00:31:25+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r6869 r6960 42 42 import javax.swing.JProgressBar; 43 43 import javax.swing.JScrollPane; 44 import javax.swing.JSeparator; 44 45 import javax.swing.Popup; 45 46 import javax.swing.PopupFactory; … … 714 715 } 715 716 717 private class MapStatusPopupMenu extends JPopupMenu { 718 719 private final JMenuItem jumpButton = createActionComponent(Main.main.menu.jumpToAct); 720 721 private final Collection<JCheckBoxMenuItem> somItems = new ArrayList<JCheckBoxMenuItem>(); 722 723 private final JSeparator separator = new JSeparator(); 724 725 private final JMenuItem doNotHide = new JCheckBoxMenuItem(new AbstractAction(tr("Do not hide status bar")) { 726 @Override 727 public void actionPerformed(ActionEvent e) { 728 boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState(); 729 Main.pref.put("statusbar.always-visible", sel); 730 } 731 }); 732 733 public MapStatusPopupMenu() { 734 for (final String key : new TreeSet<String>(NavigatableComponent.SYSTEMS_OF_MEASUREMENT.keySet())) { 735 JCheckBoxMenuItem item = new JCheckBoxMenuItem(new AbstractAction(key) { 736 @Override 737 public void actionPerformed(ActionEvent e) { 738 updateSystemOfMeasurement(key); 739 } 740 }); 741 somItems.add(item); 742 add(item); 743 } 744 745 add(jumpButton); 746 add(separator); 747 add(doNotHide); 748 749 addPopupMenuListener(new PopupMenuListener() { 750 @Override 751 public void popupMenuWillBecomeVisible(PopupMenuEvent e) { 752 Component invoker = ((JPopupMenu)e.getSource()).getInvoker(); 753 jumpButton.setVisible(invoker == latText || invoker == lonText); 754 String currentSOM = ProjectionPreference.PROP_SYSTEM_OF_MEASUREMENT.get();; 755 for (JMenuItem item : somItems) { 756 item.setSelected(item.getText().equals(currentSOM)); 757 item.setVisible(invoker == distText); 758 } 759 separator.setVisible(invoker == distText); 760 doNotHide.setSelected(Main.pref.getBoolean("statusbar.always-visible", true)); 761 } 762 @Override 763 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { 764 // Do nothing 765 } 766 @Override 767 public void popupMenuCanceled(PopupMenuEvent e) { 768 // Do nothing 769 } 770 }); 771 } 772 } 716 773 717 774 /** … … 722 779 this.mv = mapFrame.mapView; 723 780 this.collector = new Collector(mapFrame); 724 781 725 782 // Context menu of status bar 726 setComponentPopupMenu(new JPopupMenu() { 727 JCheckBoxMenuItem doNotHide = new JCheckBoxMenuItem(new AbstractAction(tr("Do not hide status bar")) { 728 @Override public void actionPerformed(ActionEvent e) { 729 boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState(); 730 Main.pref.put("statusbar.always-visible", sel); 731 } 732 }); 733 JMenuItem jumpButton; 734 { 735 jumpButton = add(Main.main.menu.jumpToAct); 736 addPopupMenuListener(new PopupMenuListener() { 737 @Override 738 public void popupMenuWillBecomeVisible(PopupMenuEvent e) { 739 Component invoker = ((JPopupMenu)e.getSource()).getInvoker(); 740 jumpButton.setVisible(invoker == latText || invoker == lonText); 741 doNotHide.setSelected(Main.pref.getBoolean("statusbar.always-visible", true)); 742 } 743 @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {} 744 @Override public void popupMenuCanceled(PopupMenuEvent e) {} 745 }); 746 add(doNotHide); 747 } 748 }); 783 setComponentPopupMenu(new MapStatusPopupMenu()); 749 784 750 785 // also show Jump To dialog on mouse click (except context menu) … … 793 828 add(distText, GBC.std().insets(3,0,0,0)); 794 829 795 distText.addMouseListener(new MouseAdapter() { 796 private final List<String> soms = new ArrayList<String>(new TreeSet<String>(NavigatableComponent.SYSTEMS_OF_MEASUREMENT.keySet())); 797 798 @Override 799 public void mouseClicked(MouseEvent e) { 800 String som = ProjectionPreference.PROP_SYSTEM_OF_MEASUREMENT.get(); 801 String newsom = soms.get((soms.indexOf(som)+1)%soms.size()); 802 NavigatableComponent.setSystemOfMeasurement(newsom); 803 } 804 }); 830 if (Main.pref.getBoolean("statusbar.change-system-of-measurement-on-click", true)) { 831 distText.addMouseListener(new MouseAdapter() { 832 private final List<String> soms = new ArrayList<String>(new TreeSet<String>(NavigatableComponent.SYSTEMS_OF_MEASUREMENT.keySet())); 833 834 @Override 835 public void mouseClicked(MouseEvent e) { 836 if (!e.isPopupTrigger() && e.getButton() == MouseEvent.BUTTON1) { 837 String som = ProjectionPreference.PROP_SYSTEM_OF_MEASUREMENT.get(); 838 String newsom = soms.get((soms.indexOf(som)+1)%soms.size()); 839 updateSystemOfMeasurement(newsom); 840 } 841 } 842 }); 843 } 805 844 806 845 NavigatableComponent.addSoMChangeListener(somListener = new SoMChangeListener() { … … 840 879 thread.start(); 841 880 } 881 882 /** 883 * Updates the system of measurement and displays a notification. 884 * @param newsom The new system of measurement to set 885 * @since 6960 886 */ 887 public void updateSystemOfMeasurement(String newsom) { 888 NavigatableComponent.setSystemOfMeasurement(newsom); 889 if (Main.pref.getBoolean("statusbar.notify.change-system-of-measurement", true)) { 890 new Notification(tr("System of measurement changed to {0}", newsom)) 891 .setDuration(Notification.TIME_SHORT) 892 .show(); 893 } 894 } 842 895 843 896 public JPanel getAnglePanel() { -
trunk/src/org/openstreetmap/josm/gui/NotificationManager.java
r6339 r6960 117 117 Point mapViewPos = SwingUtilities.convertPoint(mv.getParent(), mv.getX(), mv.getY(), Main.parent); 118 118 x = mapViewPos.x + MARGIN; 119 y = mapViewPos.y + mv.getHeight() - size.height - MARGIN;119 y = mapViewPos.y + mv.getHeight() - Main.map.statusLine.getHeight() - size.height - MARGIN; 120 120 } else { 121 121 x = MARGIN;
Note:
See TracChangeset
for help on using the changeset viewer.