Changeset 23192 in osm for applications/editors/josm/plugins/turnrestrictions/test
- Timestamp:
- 2010-09-15T18:59:53+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/turnrestrictions/test/org/openstreetmap/josm/plugins/turnrestrictions
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/turnrestrictions/test/org/openstreetmap/josm/plugins/turnrestrictions/editor/BasicEditorPanelTest.java
r20586 r23192 15 15 public class BasicEditorPanelTest extends JFrame { 16 16 17 18 19 20 21 22 23 24 25 26 17 private TurnRestrictionEditorModel model; 18 private DataSet ds; 19 20 public BasicEditorPanelTest() { 21 ds = new DataSet(); 22 OsmDataLayer layer =new OsmDataLayer(ds, "test",null); 23 // mock a controler 24 NavigationControler controler = new NavigationControler() { 25 public void gotoAdvancedEditor() { 26 } 27 27 28 29 28 public void gotoBasicEditor() { 29 } 30 30 31 32 } 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 31 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 32 } 33 }; 34 model = new TurnRestrictionEditorModel(layer, controler); 35 36 BasicEditorPanel panel = new BasicEditorPanel(model); 37 38 Container c = getContentPane(); 39 c.setLayout(new BorderLayout()); 40 c.add(panel, BorderLayout.CENTER); 41 setSize(600,600); 42 setDefaultCloseOperation(EXIT_ON_CLOSE); 43 } 44 45 46 static public void main(String args[]) { 47 new BasicEditorPanelTest().setVisible(true); 48 } 49 49 } -
applications/editors/josm/plugins/turnrestrictions/test/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionComboBoxTest.java
r20606 r23192 16 16 */ 17 17 public class TurnRestrictionComboBoxTest extends JFrame { 18 19 20 21 22 23 24 25 26 27 28 18 19 private TurnRestrictionEditorModel model; 20 private DataSet ds = new DataSet(); 21 22 protected void build() { 23 ds = new DataSet(); 24 OsmDataLayer layer =new OsmDataLayer(ds, "test",null); 25 // mock a controler 26 NavigationControler controler = new NavigationControler() { 27 public void gotoAdvancedEditor() { 28 } 29 29 30 31 30 public void gotoBasicEditor() { 31 } 32 32 33 34 } 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 33 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 34 } 35 }; 36 model = new TurnRestrictionEditorModel(layer, controler); 37 38 Container c = getContentPane(); 39 c.setLayout(new GridBagLayout()); 40 GridBagConstraints gc = new GridBagConstraints(); 41 gc.anchor = GridBagConstraints.NORTHWEST; 42 gc.fill = GridBagConstraints.HORIZONTAL; 43 gc.weightx = 1.0; 44 45 TurnRestrictionComboBox cb = new TurnRestrictionComboBox( 46 new TurnRestrictionComboBoxModel(model) 47 ); 48 add(cb, gc); 49 } 50 51 public TurnRestrictionComboBoxTest() { 52 build(); 53 setSize(600,600); 54 setDefaultCloseOperation(EXIT_ON_CLOSE); 55 } 56 57 public static void main(String args[]) { 58 new TurnRestrictionComboBoxTest().setVisible(true); 59 } 60 60 61 61 } -
applications/editors/josm/plugins/turnrestrictions/test/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorTest.java
r20606 r23192 10 10 */ 11 11 public class TurnRestrictionEditorTest extends JFrame { 12 13 14 15 16 17 18 19 20 21 22 23 24 12 13 public TurnRestrictionEditorTest() { 14 setSize(10,10); 15 TurnRestrictionEditor editor = new TurnRestrictionEditor(this, new OsmDataLayer(new DataSet(), "test", null)); 16 editor.setSize(600,600); 17 editor.setVisible(true); 18 19 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 20 } 21 22 static public void main(String args[]) { 23 new TurnRestrictionEditorTest().setVisible(true); 24 } 25 25 } -
applications/editors/josm/plugins/turnrestrictions/test/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorTest.java
r20606 r23192 34 34 */ 35 35 public class TurnRestrictionLegEditorTest extends JFrame { 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 36 37 private JTextArea taTest; 38 private TurnRestrictionLegEditor editor; 39 private TurnRestrictionEditorModel model; 40 private JList lstObjects; 41 private DefaultListModel listModel; 42 private DataSet dataSet; 43 44 45 protected JPanel buildLegEditorPanel() { 46 DataSet ds = new DataSet(); 47 OsmDataLayer layer =new OsmDataLayer(ds, "test",null); 48 // mock a controler 49 NavigationControler controler = new NavigationControler() { 50 public void gotoAdvancedEditor() { 51 } 52 52 53 54 53 public void gotoBasicEditor() { 54 } 55 55 56 57 } 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 56 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 57 } 58 }; 59 JPanel pnl = new JPanel(new GridBagLayout()); 60 GridBagConstraints gc = new GridBagConstraints(); 61 gc.anchor = GridBagConstraints.NORTHWEST; 62 gc.fill = GridBagConstraints.HORIZONTAL; 63 gc.weightx = 0.0; 64 pnl.add(new JLabel("From"), gc); 65 66 gc.weightx = 1.0; 67 gc.gridx = 1; 68 model = new TurnRestrictionEditorModel(layer, controler); 69 dataSet = new DataSet(); 70 model.populate(new Relation()); 71 pnl.add(editor = new TurnRestrictionLegEditor(model, TurnRestrictionLegRole.FROM), gc); 72 73 return pnl; 74 } 75 76 protected JPanel buildObjectListPanel() { 77 JPanel pnl = new JPanel(new BorderLayout()); 78 listModel = new DefaultListModel(); 79 pnl.add(new JScrollPane(lstObjects = new JList(listModel)), BorderLayout.CENTER); 80 lstObjects.setCellRenderer(new OsmPrimitivRenderer()); 81 82 PrimitiveIdListProvider provider = new PrimitiveIdListProvider() { 83 public List<PrimitiveId> getSelectedPrimitiveIds() { 84 List<PrimitiveId> ret = new ArrayList<PrimitiveId>(); 85 int [] sel = lstObjects.getSelectedIndices(); 86 for (int i: sel){ 87 ret.add(((OsmPrimitive)lstObjects.getModel().getElementAt(i)).getPrimitiveId()); 88 } 89 return ret; 90 } 91 }; 92 93 lstObjects.setTransferHandler(new PrimitiveIdListTransferHandler(provider)); 94 lstObjects.setDragEnabled(true); 95 return pnl; 96 } 97 98 protected void build() { 99 Container c = getContentPane(); 100 c.setLayout(new GridBagLayout()); 101 102 GridBagConstraints gc = new GridBagConstraints(); 103 gc.anchor = GridBagConstraints.NORTHWEST; 104 gc.fill = GridBagConstraints.HORIZONTAL; 105 gc.insets = new Insets(20, 0, 20, 0); 106 gc.weightx = 1.0; 107 gc.weighty = 0.0; 108 add(buildLegEditorPanel(), gc); 109 110 gc.gridy = 1; 111 gc.weightx = 1.0; 112 gc.weighty = 1.0; 113 gc.fill = GridBagConstraints.BOTH; 114 add(buildObjectListPanel(), gc); 115 setSize(600,600); 116 } 117 118 protected void initForTest1() { 119 Way w = new Way(1); 120 w.put("name", "way-1"); 121 122 editor.getModel().setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, w); 123 } 124 125 protected void initForTest2() { 126 Way w = new Way(1); 127 w.put("name", "way-1"); 128 dataSet.addPrimitive(w); 129 editor.getModel().setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, w); 130 131 Node n = new Node(new LatLon(1,1)); 132 n.setOsmId(1, 1); 133 n.put("name", "node.1"); 134 dataSet.addPrimitive(n); 135 listModel.addElement(n); 136 137 w = new Way(); 138 w.setOsmId(2,1); 139 w.put("name", "way.1"); 140 dataSet.addPrimitive(w); 141 listModel.addElement(w); 142 143 Relation r = new Relation(); 144 r.setOsmId(3,1); 145 r.put("name", "relation.1"); 146 dataSet.addPrimitive(r); 147 listModel.addElement(r); 148 } 149 149 150 151 152 153 154 155 156 157 150 public TurnRestrictionLegEditorTest(){ 151 build(); 152 initForTest2(); 153 } 154 155 static public void main(String args[]) { 156 new TurnRestrictionLegEditorTest().setVisible(true); 157 } 158 158 } -
applications/editors/josm/plugins/turnrestrictions/test/org/openstreetmap/josm/plugins/turnrestrictions/editor/VehicleExceptionEditorTest.java
r20606 r23192 15 15 */ 16 16 public class VehicleExceptionEditorTest extends JFrame { 17 18 19 20 21 22 23 24 17 TurnRestrictionEditorModel model; 18 OsmDataLayer layer; 19 VehicleExceptionEditor editor; 20 21 protected void build() { 22 Container c = getContentPane(); 23 c.setLayout(new BorderLayout()); 24 layer = new OsmDataLayer(new DataSet(), "test", null); 25 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 26 model = new TurnRestrictionEditorModel(layer, new MockNavigationControler()); 27 editor = new VehicleExceptionEditor(model); 28 c.add(editor, BorderLayout.CENTER); 29 30 model.getTagEditorModel().add(new TagModel("except", "non-standard-value")); 31 } 32 33 public VehicleExceptionEditorTest(){ 34 build(); 35 setDefaultCloseOperation(EXIT_ON_CLOSE); 36 setSize(500,500); 37 } 38 39 public static void main(String args[]){ 40 new VehicleExceptionEditorTest().setVisible(true); 41 } 42 43 static private class MockNavigationControler implements NavigationControler{ 44 44 45 46 47 48 45 public void gotoAdvancedEditor() { 46 // TODO Auto-generated method stub 47 48 } 49 49 50 51 52 53 50 public void gotoBasicEditor() { 51 // TODO Auto-generated method stub 52 53 } 54 54 55 56 57 58 59 55 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 56 // TODO Auto-generated method stub 57 58 } 59 } 60 60 } -
applications/editors/josm/plugins/turnrestrictions/test/org/openstreetmap/josm/plugins/turnrestrictions/editor/ViaListTest.java
r20606 r23192 22 22 */ 23 23 public class ViaListTest extends JFrame{ 24 25 26 27 28 29 30 31 32 33 34 35 36 24 25 private ViaList lstVias; 26 private TurnRestrictionEditorModel model; 27 private JList lstJOSMSelection; 28 29 30 protected void build() { 31 DataSet ds = new DataSet(); 32 OsmDataLayer layer =new OsmDataLayer(ds, "test",null); 33 // mock a controler 34 NavigationControler controler = new NavigationControler() { 35 public void gotoAdvancedEditor() { 36 } 37 37 38 39 38 public void gotoBasicEditor() { 39 } 40 40 41 42 } 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 } 75 76 77 78 79 80 81 82 83 84 85 41 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 42 } 43 }; 44 model = new TurnRestrictionEditorModel(layer, controler); 45 Container c = getContentPane(); 46 47 c.setLayout(new GridBagLayout()); 48 GridBagConstraints gc = new GridBagConstraints(); 49 gc.anchor = GridBagConstraints.NORTHWEST; 50 gc.insets = new Insets(5,5,5,20); 51 gc.fill = GridBagConstraints.BOTH; 52 gc.weightx = 0.5; 53 gc.weighty = 1.0; 54 55 DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); 56 c.add(lstVias = new ViaList(new ViaListModel(model, selectionModel), selectionModel), gc); 57 58 gc.gridx = 1; 59 c.add(lstJOSMSelection = new JList(), gc); 60 61 setSize(600,600); 62 setDefaultCloseOperation(EXIT_ON_CLOSE); 63 } 64 65 protected void initTest1() { 66 DataSet ds = new DataSet(); 67 Relation r = new Relation(); 68 Node n; 69 for (int i = 1; i<10; i++){ 70 n = new Node(new LatLon(i,i)); 71 n.put("name", "node." + i); 72 ds.addPrimitive(n); 73 r.addMember(new RelationMember("via",n)); 74 } 75 model.populate(r); 76 } 77 78 public ViaListTest() { 79 build(); 80 initTest1(); 81 } 82 83 static public void main(String args[]) { 84 new ViaListTest().setVisible(true); 85 } 86 86 } -
applications/editors/josm/plugins/turnrestrictions/test/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesViewTest.java
r20606 r23192 19 19 */ 20 20 public class IssuesViewTest extends JFrame { 21 22 23 24 25 26 27 28 29 21 private IssuesModel model; 22 23 protected void build() { 24 Container c = getContentPane(); 25 c.setLayout(new GridBagLayout()); 26 // mock a controler 27 NavigationControler controler = new NavigationControler() { 28 public void gotoAdvancedEditor() { 29 } 30 30 31 32 31 public void gotoBasicEditor() { 32 } 33 33 34 35 } 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 34 public void gotoBasicEditor(BasicEditorFokusTargets focusTarget) { 35 } 36 }; 37 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "test", null); 38 TurnRestrictionEditorModel editorModel = new TurnRestrictionEditorModel(layer, controler); 39 model = new IssuesModel(editorModel); 40 GridBagConstraints gc = new GridBagConstraints(); 41 gc.anchor = GridBagConstraints.NORTHWEST; 42 gc.fill = GridBagConstraints.BOTH; 43 gc.weightx = 1.0; 44 gc.weighty = 1.0; 45 JScrollPane pane = new JScrollPane(new IssuesView(model)); 46 pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 47 pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 48 c.add(pane, gc); 49 50 List<Issue> issues = new ArrayList<Issue>(); 51 issues.add(new RequiredTagMissingError(model, "type", "restriction")); 52 issues.add(new MissingRestrictionTypeError(model)); 53 model.populate(issues); 54 } 55 56 public IssuesViewTest() { 57 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 58 setSize(400,600); 59 build(); 60 } 61 62 public static void main(String args[]) { 63 new IssuesViewTest().setVisible(true); 64 } 65 65 }
Note:
See TracChangeset
for help on using the changeset viewer.