Changeset 33362 in osm for applications/editors/josm
- Timestamp:
- 2017-06-01T12:16:44+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/PTAssistantPlugin.java
r33346 r33362 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.pt_assistant; 3 4 import java.util.ArrayList; 5 import java.util.List; 3 6 4 7 import javax.swing.JMenuItem; … … 6 9 7 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.osm.Relation; 8 12 import org.openstreetmap.josm.data.validation.OsmValidator; 9 13 import org.openstreetmap.josm.gui.IconToggleButton; … … 14 18 import org.openstreetmap.josm.plugins.PluginInformation; 15 19 import org.openstreetmap.josm.plugins.pt_assistant.actions.AddStopPositionAction; 20 import org.openstreetmap.josm.plugins.pt_assistant.actions.EditHighlightedRelationsAction; 16 21 import org.openstreetmap.josm.plugins.pt_assistant.actions.RepeatLastFixAction; 17 22 import org.openstreetmap.josm.plugins.pt_assistant.data.PTRouteSegment; … … 33 38 private static PTRouteSegment lastFix; 34 39 40 /* list of relation currently highlighted by the layer */ 41 private static List<Relation> highlightedRelations; 42 35 43 /* item of the Tools menu for repeating the last fix */ 36 44 private static JMenuItem repeatLastFixMenu; 45 46 /* edit the currently highlighted relations */ 47 private static JMenuItem editHighlightedRelationsMenu; 37 48 38 49 /** … … 48 59 OsmValidator.addTest(PTAssistantValidatorTest.class); 49 60 61 highlightedRelations = new ArrayList<>(); 50 62 RepeatLastFixAction repeatLastFixAction = new RepeatLastFixAction(); 63 EditHighlightedRelationsAction editHighlightedRelationsAction = new EditHighlightedRelationsAction(); 51 64 repeatLastFixMenu = MainMenu.add(Main.main.menu.toolsMenu, repeatLastFixAction, false); 65 editHighlightedRelationsMenu = MainMenu.add(Main.main.menu.toolsMenu, editHighlightedRelationsAction, false); 52 66 } 53 67 … … 59 73 if (oldFrame == null && newFrame != null) { 60 74 repeatLastFixMenu.setEnabled(false); 75 editHighlightedRelationsMenu.setEnabled(false); 61 76 Main.map.addMapMode(new IconToggleButton(new AddStopPositionAction())); 62 77 } else if (oldFrame != null && newFrame == null) { 63 78 repeatLastFixMenu.setEnabled(false); 79 editHighlightedRelationsMenu.setEnabled(false); 64 80 } 65 81 } … … 103 119 } 104 120 121 public static List<Relation> getHighlightedRelations() { 122 return new ArrayList<>(highlightedRelations); 123 } 124 125 public static void addHighlightedRelation(Relation highlightedRelation) { 126 highlightedRelations.add(highlightedRelation); 127 if(!editHighlightedRelationsMenu.isEnabled()) { 128 SwingUtilities.invokeLater(new Runnable() { 129 @Override 130 public void run() { 131 editHighlightedRelationsMenu.setEnabled(true); 132 } 133 }); 134 } 135 136 } 137 138 public static void clearHighlightedRelations() { 139 highlightedRelations.clear(); 140 SwingUtilities.invokeLater(new Runnable() { 141 @Override 142 public void run() { 143 editHighlightedRelationsMenu.setEnabled(false); 144 } 145 }); 146 } 105 147 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java
r33345 r33362 33 33 import org.openstreetmap.josm.gui.layer.LayerPositionStrategy; 34 34 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 35 import org.openstreetmap.josm.plugins.pt_assistant.PTAssistantPlugin; 35 36 import org.openstreetmap.josm.plugins.pt_assistant.data.PTWay; 36 37 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; … … 265 266 event.scheduleRemoval(Collections.singleton(this)); 266 267 267 if(event.getRemovedLayer() == this) 268 if(event.getRemovedLayer() == this) { 268 269 PTAssistantLayerManager.PTLM.resetLayer(); 270 PTAssistantPlugin.clearHighlightedRelations(); 271 } 269 272 } 270 273 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayerManager.java
r33345 r33362 8 8 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 9 9 import org.openstreetmap.josm.data.osm.Relation; 10 import org.openstreetmap.josm.plugins.pt_assistant.PTAssistantPlugin; 10 11 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 11 12 … … 40 41 routes.add(primitive); 41 42 } 42 43 43 } 44 44 } … … 46 46 if (!routes.isEmpty()) { 47 47 getLayer().setPrimitives(routes); 48 PTAssistantPlugin.clearHighlightedRelations(); 49 for(OsmPrimitive primitive : routes) 50 PTAssistantPlugin.addHighlightedRelation((Relation) primitive); 48 51 } 49 50 52 } 51 53 }
Note:
See TracChangeset
for help on using the changeset viewer.