Ignore:
Timestamp:
2010-03-30T16:15:53+02:00 (14 years ago)
Author:
roland
Message:

Public Transport Plugin: Using some Commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterAction.java

    r20741 r20747  
    450450  };
    451451 
    452   private class WaypointTableModel extends DefaultTableModel
     452  public class WaypointTableModel extends DefaultTableModel
    453453      implements TableModelListener
    454454  {
     
    540540    super(tr("Create Stops from GPX ..."), null,
    541541          tr("Create Stops from a GPX file"), null, true);
     542  }
     543
     544  public WaypointTableModel getWaypointTableModel()
     545  {
     546    return waypointTM;
     547  }
     548 
     549  public StopImporterDialog getDialog()
     550  {
     551    return dialog;
    542552  }
    543553
     
    875885    else if ("stopImporter.waypointsAdd".equals(event.getActionCommand()))
    876886    {
    877       if (dialog.getWaypointsTable().getSelectedRowCount() > 0)
    878       {
    879         for (int i = 0; i < waypointTM.getRowCount(); ++i)
    880         {
    881           if ((dialog.getWaypointsTable().isRowSelected(i)) &&
    882                       (waypointTM.nodes.elementAt(i) == null))
    883           {
    884             Node node = createNode(waypointTM.coors.elementAt(i), (String)waypointTM.getValueAt(i, 1));
    885             waypointTM.nodes.set(i, node);
    886             Main.main.getCurrentDataSet().addSelected(waypointTM.nodes.elementAt(i));
    887           }
    888         }
    889       }
    890       else
    891       {
    892         for (int i = 0; i < waypointTM.getRowCount(); ++i)
    893         {
    894           if (waypointTM.nodes.elementAt(i) == null)
    895             Main.main.getCurrentDataSet().addSelected(waypointTM.nodes.elementAt(i));
    896         }
    897       }
     887      Main.main.undoRedo.add(new WaypointsEnableCommand(this));
    898888    }
    899889    else if ("stopImporter.waypointsDelete".equals(event.getActionCommand()))
    900890    {
    901       Vector< Node > toDelete = new Vector< Node >();
    902       for (int i = waypointTM.getRowCount()-1; i >=0; --i)
    903       {
    904         if (dialog.getWaypointsTable().isRowSelected(i))
    905         {
    906           if ((Node)waypointTM.nodes.elementAt(i) != null)
    907             toDelete.add((Node)waypointTM.nodes.elementAt(i));
    908           waypointTM.nodes.set(i, null);
    909         }
    910       }
    911       Command cmd = DeleteCommand.delete
    912           (Main.main.getEditLayer(), toDelete);
    913       if (cmd != null) {
    914         // cmd can be null if the user cancels dialogs DialogCommand displays
    915         Main.main.undoRedo.add(cmd);
    916       }
     891      Main.main.undoRedo.add(new WaypointsDisableCommand(this));
    917892    }
    918893    else if ("stopImporter.settingsStoptype".equals(event.getActionCommand()))
     
    10711046  private Node createNode(LatLon latLon, String name)
    10721047  {
     1048    return createNode(latLon, dialog.getStoptype(), name);
     1049  }
     1050   
     1051  public static Node createNode(LatLon latLon, String type, String name)
     1052  {
    10731053    Node node = new Node(latLon);
    1074     if ("bus".equals(dialog.getStoptype()))
     1054    if ("bus".equals(type))
    10751055      node.put("highway", "bus_stop");
    1076     else if ("tram".equals(dialog.getStoptype()))
     1056    else if ("tram".equals(type))
    10771057      node.put("railway", "tram_stop");
    1078     else if ("light_rail".equals(dialog.getStoptype()))
     1058    else if ("light_rail".equals(type))
    10791059      node.put("railway", "station");
    1080     else if ("subway".equals(dialog.getStoptype()))
     1060    else if ("subway".equals(type))
    10811061      node.put("railway", "station");
    1082     else if ("rail".equals(dialog.getStoptype()))
     1062    else if ("rail".equals(type))
    10831063      node.put("railway", "station");
    10841064    node.put("name", name);
Note: See TracChangeset for help on using the changeset viewer.