Changeset 20867 in osm for applications/editors


Ignore:
Timestamp:
2010-04-09T11:15:11+02:00 (14 years ago)
Author:
roland
Message:

Public Transport Plugin: Key accelerators

Location:
applications/editors/josm
Files:
5 edited

Legend:

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

    r20839 r20867  
    2121import java.util.zip.GZIPInputStream;
    2222
     23import javax.swing.AbstractAction;
     24import javax.swing.Action;
    2325import javax.swing.DefaultListModel;
    2426import javax.swing.JButton;
     
    415417        + formatS.format(second));
    416418  }
     419 
     420  public Action getFocusWaypointNameAction()
     421  {
     422    return new FocusWaypointNameAction();
     423  }
     424 
     425  public Action getFocusWaypointShelterAction(String shelter)
     426  {
     427    return new FocusWaypointShelterAction(shelter);
     428  }
     429
     430  public Action getFocusWaypointDeleteAction()
     431  {
     432    return new AbstractAction()
     433    {
     434      public void actionPerformed(ActionEvent e)
     435      {
     436        JTable table = dialog.getWaypointsTable();
     437        int row = table.getEditingRow();
     438        if (row < 0)
     439          return;
     440        table.clearSelection();
     441        table.addRowSelectionInterval(row, row);
     442        Main.main.undoRedo.add
     443            (new WaypointsDisableCommand(StopImporterAction.this));
     444      }
     445    };
     446  }
     447
     448  public Action getFocusTrackStoplistNameAction()
     449  {
     450    return new FocusTrackStoplistNameAction();
     451  }
     452 
     453  public Action getFocusTrackStoplistShelterAction(String shelter)
     454  {
     455    return new FocusTrackStoplistShelterAction(shelter);
     456  }
     457
     458  public Action getFocusStoplistDeleteAction()
     459  {
     460    return new AbstractAction()
     461    {
     462      public void actionPerformed(ActionEvent e)
     463      {
     464        JTable table = dialog.getStoplistTable();
     465        int row = table.getEditingRow();
     466        if (row < 0)
     467          return;
     468        table.clearSelection();
     469        table.addRowSelectionInterval(row, row);
     470        Main.main.undoRedo.add
     471            (new TrackStoplistDeleteCommand(StopImporterAction.this));
     472      }
     473    };
     474  }
     475
     476  private class FocusWaypointNameAction extends AbstractAction
     477  {
     478    public void actionPerformed(ActionEvent e)
     479    {
     480      JTable table = dialog.getWaypointsTable();
     481      showNodesFromTable(table, waypointTM.nodes);
     482      markNodesFromTable(table, waypointTM.nodes);
     483      int row = table.getEditingRow();
     484      if (row < 0)
     485        row = 0;
     486      waypointTM.inEvent = true;
     487      if (table.getCellEditor() != null)
     488      {
     489        if (!table.getCellEditor().stopCellEditing())
     490          table.getCellEditor().cancelCellEditing();
     491      }
     492      table.editCellAt(row, 1);
     493      table.getCellEditor().getTableCellEditorComponent
     494          (table, "", true, row, 1);
     495      waypointTM.inEvent = false;
     496    }
     497  };
     498 
     499  private class FocusWaypointShelterAction extends AbstractAction
     500  {
     501    private String defaultShelter = null;
     502   
     503    public FocusWaypointShelterAction(String defaultShelter)
     504    {
     505      this.defaultShelter = defaultShelter;
     506    }
     507   
     508    public void actionPerformed(ActionEvent e)
     509    {
     510      JTable table = dialog.getWaypointsTable();
     511      showNodesFromTable(table, waypointTM.nodes);
     512      markNodesFromTable(table, waypointTM.nodes);
     513      int row = table.getEditingRow();
     514      if (row < 0)
     515        row = 0;
     516      waypointTM.inEvent = true;
     517      if (table.getCellEditor() != null)
     518      {
     519        if (!table.getCellEditor().stopCellEditing())
     520          table.getCellEditor().cancelCellEditing();
     521      }
     522      table.editCellAt(row, 2);
     523      waypointTM.inEvent = false;
     524      table.getCellEditor().getTableCellEditorComponent
     525          (table, defaultShelter, true, row, 2);
     526    }
     527  };
     528 
     529  private class FocusTrackStoplistNameAction extends AbstractAction
     530  {
     531    public void actionPerformed(ActionEvent e)
     532    {
     533      JTable table = dialog.getStoplistTable();
     534      showNodesFromTable(table, currentTrack.stoplistTM.getNodes());
     535      markNodesFromTable(table, currentTrack.stoplistTM.getNodes());
     536      int row = table.getEditingRow();
     537      if (row < 0)
     538        row = 0;
     539      currentTrack.inEvent = true;
     540      if (table.getCellEditor() != null)
     541      {
     542        if (!table.getCellEditor().stopCellEditing())
     543          table.getCellEditor().cancelCellEditing();
     544      }
     545      table.editCellAt(row, 1);
     546      table.getCellEditor().getTableCellEditorComponent
     547          (table, "", true, row, 1);
     548      currentTrack.inEvent = false;
     549    }
     550  };
     551 
     552  private class FocusTrackStoplistShelterAction extends AbstractAction
     553  {
     554    private String defaultShelter = null;
     555   
     556    public FocusTrackStoplistShelterAction(String defaultShelter)
     557    {
     558      this.defaultShelter = defaultShelter;
     559    }
     560   
     561    public void actionPerformed(ActionEvent e)
     562    {
     563      JTable table = dialog.getStoplistTable();
     564      showNodesFromTable(table, currentTrack.stoplistTM.getNodes());
     565      markNodesFromTable(table, currentTrack.stoplistTM.getNodes());
     566      int row = table.getEditingRow();
     567      if (row < 0)
     568        row = 0;
     569      currentTrack.inEvent = true;
     570      if (table.getCellEditor() != null)
     571      {
     572        if (!table.getCellEditor().stopCellEditing())
     573          table.getCellEditor().cancelCellEditing();
     574      }
     575      table.editCellAt(row, 2);
     576      currentTrack.inEvent = false;
     577      table.getCellEditor().getTableCellEditorComponent
     578          (table, defaultShelter, true, row, 2);
     579    }
     580  };
    417581}
  • applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterDialog.java

    r20839 r20867  
    2525import javax.swing.JButton;
    2626import javax.swing.JComboBox;
     27import javax.swing.JComponent;
    2728import javax.swing.JDialog;
    2829import javax.swing.JFileChooser;
     
    3536import javax.swing.JTable;
    3637import javax.swing.JTextField;
     38import javax.swing.KeyStroke;
    3739import javax.swing.ListSelectionModel;
    3840import javax.swing.event.ListSelectionEvent;
     
    9395     
    9496    //Tracks Tab
    95     Container contentPane = tabTracks;
     97    JPanel contentPane = tabTracks;
    9698    GridBagLayout gridbag = new GridBagLayout();
    9799    GridBagConstraints layoutCons = new GridBagConstraints();
     
    315317    contentPane.add(bSuggestStops);
    316318     
    317       //Stops Tab
     319    //Stops Tab
    318320    contentPane = tabStops;
    319321    gridbag = new GridBagLayout();
    320322    layoutCons = new GridBagConstraints();
    321323    contentPane.setLayout(gridbag);
     324    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     325        (KeyStroke.getKeyStroke("alt N"), "stopImporter.focusName");
     326    contentPane.getActionMap().put
     327        ("stopImporter.focusName", controller.getFocusTrackStoplistNameAction());
     328    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     329        (KeyStroke.getKeyStroke("alt S"), "stopImporter.focusShelterYes");
     330    contentPane.getActionMap().put
     331        ("stopImporter.focusShelterYes",
     332         controller.getFocusTrackStoplistShelterAction("yes"));
     333    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     334        (KeyStroke.getKeyStroke("alt T"), "stopImporter.focusShelterNo");
     335    contentPane.getActionMap().put
     336        ("stopImporter.focusShelterNo",
     337         controller.getFocusTrackStoplistShelterAction("no"));
     338    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     339        (KeyStroke.getKeyStroke("alt U"), "stopImporter.focusShelterImplicit");
     340    contentPane.getActionMap().put
     341        ("stopImporter.focusShelterImplicit",
     342         controller.getFocusTrackStoplistShelterAction("implicit"));
     343    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     344        (KeyStroke.getKeyStroke("alt D"), "stopImporter.stoplistDelete");
     345    contentPane.getActionMap().put
     346        ("stopImporter.stoplistDelete",
     347         controller.getFocusStoplistDeleteAction());
    322348     
    323349    stoplistTable = new JTable();
    324350    JScrollPane tableSP = new JScrollPane(stoplistTable);
    325      
     351   
    326352    layoutCons.gridx = 0;
    327353    layoutCons.gridy = 0;
     
    428454    contentPane.add(bSort);
    429455     
    430       //Waypoints Tab
     456    //Waypoints Tab
    431457    contentPane = tabWaypoints;
    432458    gridbag = new GridBagLayout();
    433459    layoutCons = new GridBagConstraints();
    434460    contentPane.setLayout(gridbag);
     461    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     462        (KeyStroke.getKeyStroke("alt N"), "stopImporter.focusName");
     463    contentPane.getActionMap().put
     464        ("stopImporter.focusName", controller.getFocusWaypointNameAction());
     465    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     466        (KeyStroke.getKeyStroke("alt S"), "stopImporter.focusShelterYes");
     467    contentPane.getActionMap().put
     468        ("stopImporter.focusShelterYes",
     469         controller.getFocusWaypointShelterAction("yes"));
     470    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     471        (KeyStroke.getKeyStroke("alt T"), "stopImporter.focusShelterNo");
     472    contentPane.getActionMap().put
     473        ("stopImporter.focusShelterNo",
     474         controller.getFocusWaypointShelterAction("no"));
     475    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     476        (KeyStroke.getKeyStroke("alt U"), "stopImporter.focusShelterImplicit");
     477    contentPane.getActionMap().put
     478        ("stopImporter.focusShelterImplicit",
     479         controller.getFocusWaypointShelterAction("implicit"));
     480    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
     481        (KeyStroke.getKeyStroke("alt D"), "stopImporter.waypointsDelete");
     482    contentPane.getActionMap().put
     483        ("stopImporter.waypointsDelete",
     484         controller.getFocusWaypointDeleteAction());
    435485     
    436486    waypointTable = new JTable();
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistNameCommand.java

    r20839 r20867  
    4040    this.name = (String)trackref.stoplistTM.getValueAt(workingLine, 1);
    4141    this.shelter = (String)trackref.stoplistTM.getValueAt(workingLine, 2);
     42    if ("".equals(this.shelter))
     43      this.shelter = null;
    4244  }
    4345 
  • applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsNameCommand.java

    r20839 r20867  
    3333    this.shelter = shelter;
    3434    if ("".equals(shelter))
    35       shelter = null;
     35      this.shelter = null;
    3636  }
    3737 
Note: See TracChangeset for help on using the changeset viewer.