Changeset 23190 in osm for applications/editors/josm/plugins/waypoint_search/src
- Timestamp:
- 2010-09-15T18:54:18+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch
- Files:
-
- 3 edited
-
Engine.java (modified) (1 diff)
-
SelectWaypointDialog.java (modified) (3 diffs)
-
WaypointSearchPlugin.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/Engine.java
r22661 r23190 9 9 10 10 public class Engine { 11 12 public List<Marker> searchGpxWaypoints(String waypointSearchPattern) {13 List<Marker> returnList = new ArrayList<Marker>();14 if (gpxLayersExist()) {15 //Loop over marker (waypoint) layers.. it could be more than one16 for (Iterator<MarkerLayer> layerIterator = Main.map.mapView.getLayersOfType(MarkerLayer.class).iterator(); layerIterator.hasNext();) {17 //loop over each marker (waypoint)18 for (Iterator<Marker> markerIterator = layerIterator.next().data.iterator(); markerIterator.hasNext();) {19 Marker marker = markerIterator.next();20 if (Pattern.matches(".*\\Q"+waypointSearchPattern.toLowerCase()+"\\E.*", marker.getText().toLowerCase())) {21 returnList.add(marker);22 }23 } 24 }25 }26 return returnList;27 } 28 29 30 31 11 12 public List<Marker> searchGpxWaypoints(String waypointSearchPattern) { 13 List<Marker> returnList = new ArrayList<Marker>(); 14 if (gpxLayersExist()) { 15 //Loop over marker (waypoint) layers.. it could be more than one 16 for (Iterator<MarkerLayer> layerIterator = Main.map.mapView.getLayersOfType(MarkerLayer.class).iterator(); layerIterator.hasNext();) { 17 //loop over each marker (waypoint) 18 for (Iterator<Marker> markerIterator = layerIterator.next().data.iterator(); markerIterator.hasNext();) { 19 Marker marker = markerIterator.next(); 20 if (Pattern.matches(".*\\Q"+waypointSearchPattern.toLowerCase()+"\\E.*", marker.getText().toLowerCase())) { 21 returnList.add(marker); 22 } 23 } 24 } 25 } 26 return returnList; 27 } 28 29 30 31 32 32 33 34 35 33 34 35 36 36 public boolean gpxLayersExist() { 37 boolean rv = false;38 if (Main.map != null) {39 if (Main.map.mapView.hasLayers()) {40 if (Main.map.mapView.getLayersOfType(MarkerLayer.class).size()>0) {41 rv = true;42 }43 }44 }45 return rv;37 boolean rv = false; 38 if (Main.map != null) { 39 if (Main.map.mapView.hasLayers()) { 40 if (Main.map.mapView.getLayersOfType(MarkerLayer.class).size()>0) { 41 rv = true; 42 } 43 } 44 } 45 return rv; 46 46 } 47 48 49 47 48 49 50 50 } -
applications/editors/josm/plugins/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/SelectWaypointDialog.java
r23180 r23190 20 20 public class SelectWaypointDialog extends ToggleDialog implements KeyListener, MouseListener { 21 21 22 private JTextField searchPattern = new JTextField(20);23 private DefaultListModel listModel = new DefaultListModel();24 private JList searchResult = new JList(listModel);25 private List<Marker> SearchResultObjectCache = new ArrayList<Marker>();26 private boolean first_time_search = true;27 private Engine engine = new Engine();28 29 30 public SelectWaypointDialog(String name, String iconName, String tooltip,31 Shortcut shortcut, int preferredHeight) {32 super(name, iconName, tooltip, shortcut, preferredHeight);33 build();34 }35 22 private JTextField searchPattern = new JTextField(20); 23 private DefaultListModel listModel = new DefaultListModel(); 24 private JList searchResult = new JList(listModel); 25 private List<Marker> SearchResultObjectCache = new ArrayList<Marker>(); 26 private boolean first_time_search = true; 27 private Engine engine = new Engine(); 28 29 30 public SelectWaypointDialog(String name, String iconName, String tooltip, 31 Shortcut shortcut, int preferredHeight) { 32 super(name, iconName, tooltip, shortcut, preferredHeight); 33 build(); 34 } 35 36 36 37 37 protected void build() { 38 //add panel - all the gui of the plugin goes in here39 JPanel panel = new JPanel(new BorderLayout());40 41 //search field42 searchPattern.setText(tr("Enter search expression here.."));43 searchPattern.addKeyListener(this);44 searchPattern.addMouseListener(this);45 panel.add(searchPattern,BorderLayout.NORTH);46 47 //add result table48 searchResult.setLayoutOrientation(JList.VERTICAL);49 searchResult.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);50 searchResult.addMouseListener(this);51 JScrollPane scrollPane = new JScrollPane(searchResult);52 scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);53 panel.add(scrollPane,BorderLayout.CENTER);54 55 //add label56 JLabel label = new JLabel(tr("Select waypoint to move map"));57 panel.add(label,BorderLayout.SOUTH);58 59 //add panel to JOSM gui60 add(panel,BorderLayout.CENTER);38 //add panel - all the gui of the plugin goes in here 39 JPanel panel = new JPanel(new BorderLayout()); 40 41 //search field 42 searchPattern.setText(tr("Enter search expression here..")); 43 searchPattern.addKeyListener(this); 44 searchPattern.addMouseListener(this); 45 panel.add(searchPattern,BorderLayout.NORTH); 46 47 //add result table 48 searchResult.setLayoutOrientation(JList.VERTICAL); 49 searchResult.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 50 searchResult.addMouseListener(this); 51 JScrollPane scrollPane = new JScrollPane(searchResult); 52 scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 53 panel.add(scrollPane,BorderLayout.CENTER); 54 55 //add label 56 JLabel label = new JLabel(tr("Select waypoint to move map")); 57 panel.add(label,BorderLayout.SOUTH); 58 59 //add panel to JOSM gui 60 add(panel,BorderLayout.CENTER); 61 61 } 62 62 … … 78 78 79 79 80 @Override81 public void keyPressed(KeyEvent arg0) {82 // TODO Auto-generated method stub83 }80 @Override 81 public void keyPressed(KeyEvent arg0) { 82 // TODO Auto-generated method stub 83 } 84 84 85 85 86 @Override87 public void keyReleased(KeyEvent arg0) {88 // TODO Auto-generated method stub89 updateSearchResults();90 }86 @Override 87 public void keyReleased(KeyEvent arg0) { 88 // TODO Auto-generated method stub 89 updateSearchResults(); 90 } 91 91 92 92 … … 97 97 98 98 99 @Override100 public void mouseClicked(MouseEvent e) {101 if (e.getSource()==searchResult) {102 //click on the search result box103 Marker marker = SearchResultObjectCache.get(searchResult.getSelectedIndex());104 Main.map.mapView.zoomTo(marker.getCoor());105 } else {106 //click on the text field (input search expression)107 }108 }99 @Override 100 public void mouseClicked(MouseEvent e) { 101 if (e.getSource()==searchResult) { 102 //click on the search result box 103 Marker marker = SearchResultObjectCache.get(searchResult.getSelectedIndex()); 104 Main.map.mapView.zoomTo(marker.getCoor()); 105 } else { 106 //click on the text field (input search expression) 107 } 108 } 109 109 110 110 111 @Override112 public void mouseEntered(MouseEvent arg0) {113 // TODO Auto-generated method stub114 115 }111 @Override 112 public void mouseEntered(MouseEvent arg0) { 113 // TODO Auto-generated method stub 114 115 } 116 116 117 117 118 @Override119 public void mouseExited(MouseEvent arg0) {120 // TODO Auto-generated method stub121 122 }118 @Override 119 public void mouseExited(MouseEvent arg0) { 120 // TODO Auto-generated method stub 121 122 } 123 123 124 124 125 @Override126 public void mousePressed(MouseEvent arg0) {127 if (searchPattern.getSelectedText()==null) {128 searchPattern.selectAll();129 }130 131 }125 @Override 126 public void mousePressed(MouseEvent arg0) { 127 if (searchPattern.getSelectedText()==null) { 128 searchPattern.selectAll(); 129 } 130 131 } 132 132 133 133 134 @Override135 public void mouseReleased(MouseEvent arg0) {136 // TODO Auto-generated method stub137 138 }134 @Override 135 public void mouseReleased(MouseEvent arg0) { 136 // TODO Auto-generated method stub 137 138 } 139 139 } -
applications/editors/josm/plugins/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/WaypointSearchPlugin.java
r23180 r23190 10 10 11 11 public class WaypointSearchPlugin extends Plugin implements LayerChangeListener { 12 /**12 /** 13 13 * Will be invoked by JOSM to bootstrap the plugin 14 14 * 15 15 * @param info information about the plugin and its local installation 16 16 */ 17 private Engine engine = new Engine();18 private SelectWaypointDialog waypointDialog = new SelectWaypointDialog(tr("Waypoint search"), "ToolbarIcon", tr("Search after waypoint. Click and move the map view to the waypoint."), null, 100);19 17 private Engine engine = new Engine(); 18 private SelectWaypointDialog waypointDialog = new SelectWaypointDialog(tr("Waypoint search"), "ToolbarIcon", tr("Search after waypoint. Click and move the map view to the waypoint."), null, 100); 19 20 20 public WaypointSearchPlugin(PluginInformation info) { 21 21 super(info); … … 23 23 } 24 24 25 @Override26 public void activeLayerChange(Layer oldLayer, Layer newLayer) {27 // TODO Auto-generated method stub28 29 }25 @Override 26 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 27 // TODO Auto-generated method stub 28 29 } 30 30 31 31 … … 44 44 45 45 46 @Override47 public void layerRemoved(Layer oldLayer) {48 if (!engine.gpxLayersExist()) {49 waypointDialog.updateSearchResults();50 } 51 }46 @Override 47 public void layerRemoved(Layer oldLayer) { 48 if (!engine.gpxLayersExist()) { 49 waypointDialog.updateSearchResults(); 50 } 51 } 52 52 53 53 }
Note:
See TracChangeset
for help on using the changeset viewer.
