Changeset 14337 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
r14153 r14337 7 7 import java.awt.Component; 8 8 import java.awt.Dimension; 9 import java.awt.GraphicsEnvironment;10 9 import java.awt.GridBagLayout; 11 10 import java.awt.event.ActionEvent; … … 263 262 264 263 int v = 1; 265 if (!GraphicsEnvironment.isHeadless()) { 266 // build dialog 267 ExtendedDialog ed = new ExtendedDialog(MainApplication.getMainFrame(), tr("Set track visibility for {0}", layer.getName()), 268 tr("Show all"), tr("Show selected only"), tr("Cancel")); 269 ed.setButtonIcons("eye", "dialogs/filter", "cancel"); 270 ed.setContent(msg, false); 271 ed.setDefaultButton(2); 272 ed.setCancelButton(3); 273 ed.configureContextsensitiveHelp("/Action/ChooseTrackVisibility", true); 274 ed.setRememberWindowGeometry(getClass().getName() + ".geometry", 275 WindowGeometry.centerInWindow(MainApplication.getMainFrame(), new Dimension(1000, 500))); 276 ed.showDialog(); 277 dateFilter.saveInPrefs(); 278 v = ed.getValue(); 279 // cancel for unknown buttons and copy back original settings 280 if (v != 1 && v != 2) { 281 layer.trackVisibility = Arrays.copyOf(trackVisibilityBackup, layer.trackVisibility.length); 282 MainApplication.getMap().repaint(); 283 return; 284 } 264 // build dialog 265 ExtendedDialog ed = new ExtendedDialog(MainApplication.getMainFrame(), tr("Set track visibility for {0}", layer.getName()), 266 tr("Show all"), tr("Show selected only"), tr("Cancel")); 267 ed.setButtonIcons("eye", "dialogs/filter", "cancel"); 268 ed.setContent(msg, false); 269 ed.setDefaultButton(2); 270 ed.setCancelButton(3); 271 ed.configureContextsensitiveHelp("/Action/ChooseTrackVisibility", true); 272 ed.setRememberWindowGeometry(getClass().getName() + ".geometry", 273 WindowGeometry.centerInWindow(MainApplication.getMainFrame(), new Dimension(1000, 500))); 274 ed.showDialog(); 275 dateFilter.saveInPrefs(); 276 v = ed.getValue(); 277 // cancel for unknown buttons and copy back original settings 278 if (v != 1 && v != 2) { 279 layer.trackVisibility = Arrays.copyOf(trackVisibilityBackup, layer.trackVisibility.length); 280 MainApplication.getMap().repaint(); 281 return; 285 282 } 286 283 // set visibility (1 = show all, 2 = filter). If no tracks are selected -
trunk/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java
r14138 r14337 64 64 */ 65 65 public static GpxLayer getMinimalGpxLayer() throws IOException, SAXException { 66 return new GpxLayer(getMinimalGpxData() );66 return new GpxLayer(getMinimalGpxData(), "Bananas"); 67 67 } 68 68 -
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityActionTest.java
r14138 r14337 2 2 package org.openstreetmap.josm.gui.layer.gpx; 3 3 4 import static org.junit.Assert.assertEquals; 5 6 import javax.swing.JLabel; 7 import javax.swing.JPanel; 8 4 9 import org.junit.Rule; 5 10 import org.junit.Test; 11 import org.openstreetmap.josm.gui.ExtendedDialog; 6 12 import org.openstreetmap.josm.gui.layer.GpxLayerTest; 7 13 import org.openstreetmap.josm.testutils.JOSMTestRules; 14 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 8 15 9 16 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 27 34 @Test 28 35 public void testAction() throws Exception { 36 final ExtendedDialogMocker edMocker = new ExtendedDialogMocker() { 37 protected String getString(final ExtendedDialog instance) { 38 return ((JLabel) ((JPanel) this.getContent(instance)).getComponent(2)).getText(); 39 } 40 }; 41 edMocker.getMockResultMap().put( 42 "<html>Select all tracks that you want to be displayed. You can drag select a range of " + 43 "tracks or use CTRL+Click to select specific ones. The map is updated live in the " + 44 "background. Open the URLs by double clicking them.</html>", 45 "Show all" 46 ); 47 29 48 new ChooseTrackVisibilityAction(GpxLayerTest.getMinimalGpxLayer()).actionPerformed(null); 49 50 assertEquals(1, edMocker.getInvocationLog().size()); 51 Object[] invocationLogEntry = edMocker.getInvocationLog().get(0); 52 assertEquals(1, (int) invocationLogEntry[0]); 53 assertEquals("Set track visibility for Bananas", invocationLogEntry[2]); 30 54 } 31 55 }
Note:
See TracChangeset
for help on using the changeset viewer.