Ticket #6629: coloringPrefsAndLocal.patch
File coloringPrefsAndLocal.patch, 7.0 KB (added by , 13 years ago) |
---|
-
org/openstreetmap/josm/gui/layer/GpxLayer.java
1406 1406 1407 1407 @Override 1408 1408 public void actionPerformed(ActionEvent e) { 1409 GPXSettingsPanel panel=new GPXSettingsPanel(getName()); 1409 boolean hasLocal = false, hasNonlocal = false; 1410 for (Layer layer : layers) { 1411 if (layer instanceof GpxLayer) { 1412 if (((GpxLayer) layer).isLocalFile) hasLocal = true; 1413 else hasNonlocal = true; 1414 } 1415 } 1416 System.out.println(hasLocal+"--"+hasNonlocal); 1417 GPXSettingsPanel panel=new GPXSettingsPanel(getName(), hasLocal, hasNonlocal); 1418 1410 1419 int answer = JOptionPane.showConfirmDialog(Main.parent, panel, 1411 1420 tr("Customize track drawing"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); 1412 1421 if (answer == JOptionPane.CANCEL_OPTION || answer == JOptionPane.CLOSED_OPTION) return; 1413 1422 for(Layer layer : layers) { 1414 1423 // save preferences for all layers 1415 panel.savePreferences(layer.getName()); 1424 boolean f=false; 1425 if (layer instanceof GpxLayer) f=((GpxLayer)layer).isLocalFile; 1426 panel.savePreferences(layer.getName(),f); 1416 1427 } 1417 1428 Main.map.repaint(); 1418 1429 } -
org/openstreetmap/josm/gui/preferences/GPXSettingsPanel.java
48 48 private JComboBox waypointLabel = new JComboBox(new String[] {tr("Auto"), /* gpx data field name */ trc("gpx_field", "Name"), 49 49 /* gpx data field name */ trc("gpx_field", "Desc(ription)"), tr("Both"), tr("None")}); 50 50 private String layerName; 51 private boolean local; // flag to display LocalOnly checkbox 52 private boolean nonlocal; // flag to display AllLines checkbox 51 53 52 public GPXSettingsPanel(String layerName ) {54 public GPXSettingsPanel(String layerName, boolean local, boolean nonlocal) { 53 55 super(new GridBagLayout()); 56 this.local=local; this.nonlocal=nonlocal; 54 57 this.layerName = "layer "+layerName; 55 58 initComponents(); 56 59 loadPreferences(); … … 59 62 public GPXSettingsPanel() { 60 63 super(new GridBagLayout()); 61 64 initComponents(); 65 local=false; nonlocal=false; 62 66 loadPreferences(); // preferences -> controls 63 67 } 68 64 69 private void initComponents() { 65 70 setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 66 71 … … 80 85 add(new JLabel(tr("Draw lines between raw GPS points")), GBC.eol().insets(20,0,0,0)); 81 86 if (layerName!=null) add(drawRawGpsLinesGlobal, GBC.eol().insets(40,0,0,0)); 82 87 add(drawRawGpsLinesNone, GBC.eol().insets(40,0,0,0)); 83 add(drawRawGpsLinesLocal, GBC.eol().insets(40,0,0,0));84 add(drawRawGpsLinesAll, GBC.eol().insets(40,0,0,0));88 if (layerName==null || local) add(drawRawGpsLinesLocal, GBC.eol().insets(40,0,0,0)); 89 if (layerName==null || nonlocal) add(drawRawGpsLinesAll, GBC.eol().insets(40,0,0,0)); 85 90 86 91 drawRawGpsLinesActionListener = new ActionListener(){ 87 92 public void actionPerformed(ActionEvent e) { … … 200 205 public void loadPreferences () { 201 206 makeAutoMarkers.setSelected(Main.pref.getBoolean("marker.makeautomarkers", true)); 202 207 if(layerName!=null && !Main.pref.hasKey("draw.rawgps.lines."+layerName) 203 && !Main.pref.hasKey("draw.rawgps.lines.local "+layerName)){208 && !Main.pref.hasKey("draw.rawgps.lines.local."+layerName)){ 204 209 // no line preferences for layer is found 205 210 drawRawGpsLinesGlobal.setSelected(true); 206 211 } else { … … 253 258 * Save preferences from UI controls for specified layer 254 259 * if layerName==null, global preferences are written 255 260 */ 256 public boolean savePreferences (String layerName ) {261 public boolean savePreferences (String layerName, boolean locLayer) { 257 262 String layerNameDot = ".layer "+layerName; 263 if (layerName==null) layerNameDot=""; 258 264 Main.pref.put("marker.makeautomarkers"+layerNameDot, makeAutoMarkers.isSelected()); 259 265 if (drawRawGpsLinesGlobal.isSelected()) { 260 Main.pref.put("draw.rawgps.lines" +layerNameDot, null);261 Main.pref.put("draw.rawgps. lines.local"+layerNameDot, null);262 Main.pref.put("draw.rawgps. max-line-length"+layerNameDot, null);263 Main.pref.put("draw.rawgps.max-line-length.local" +layerNameDot, null);266 Main.pref.put("draw.rawgps.lines" + layerNameDot, null); 267 Main.pref.put("draw.rawgps.max-line-length" + layerNameDot, null); 268 Main.pref.put("draw.rawgps.lines.local" + layerNameDot, null); 269 Main.pref.put("draw.rawgps.max-line-length.local" + layerNameDot, null); 264 270 Main.pref.put("draw.rawgps.lines.force"+layerNameDot, null); 265 271 Main.pref.put("draw.rawgps.direction"+layerNameDot, null); 266 272 Main.pref.put("draw.rawgps.alternatedirection"+layerNameDot, null); 267 273 Main.pref.put("draw.rawgps.min-arrow-distance"+layerNameDot, null); 268 274 } else { 269 Main.pref.put("draw.rawgps.lines"+layerNameDot, drawRawGpsLinesAll.isSelected()); 270 Main.pref.put("draw.rawgps.lines.local"+layerNameDot, drawRawGpsLinesAll.isSelected() || drawRawGpsLinesLocal.isSelected()); 271 Main.pref.put("draw.rawgps.max-line-length"+layerNameDot, drawRawGpsMaxLineLength.getText()); 272 Main.pref.put("draw.rawgps.max-line-length.local"+layerNameDot, drawRawGpsMaxLineLengthLocal.getText()); 275 if (layerName==null || !locLayer) { 276 Main.pref.put("draw.rawgps.lines" + layerNameDot, drawRawGpsLinesAll.isSelected()); 277 Main.pref.put("draw.rawgps.max-line-length" + layerNameDot, drawRawGpsMaxLineLength.getText()); 278 } 279 if (layerName==null || locLayer) { 280 Main.pref.put("draw.rawgps.lines.local" + layerNameDot, drawRawGpsLinesAll.isSelected() || drawRawGpsLinesLocal.isSelected()); 281 Main.pref.put("draw.rawgps.max-line-length.local" + layerNameDot, drawRawGpsMaxLineLengthLocal.getText()); 282 } 273 283 Main.pref.put("draw.rawgps.lines.force"+layerNameDot, forceRawGpsLines.isSelected()); 274 284 Main.pref.put("draw.rawgps.direction"+layerNameDot, drawGpsArrows.isSelected()); 275 285 Main.pref.put("draw.rawgps.alternatedirection"+layerNameDot, drawGpsArrowsFast.isSelected()); … … 307 317 * Save preferences from UI controls for initial layer or globally 308 318 */ 309 319 public void savePreferences() { 310 savePreferences(null );320 savePreferences(null, false); 311 321 } 312 322 }