Changeset 31995 in osm for applications
- Timestamp:
- 2016-01-17T16:05:35+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/public_transport
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/public_transport/.project
r29661 r31995 11 11 </arguments> 12 12 </buildCommand> 13 <buildCommand> 14 <name>org.sonarlint.eclipse.core.sonarlintBuilder</name> 15 <arguments> 16 </arguments> 17 </buildCommand> 13 18 </buildSpec> 14 19 <natures> 20 <nature>org.sonarlint.eclipse.core.sonarlintNature</nature> 15 21 <nature>org.eclipse.jdt.core.javanature</nature> 16 22 </natures> -
applications/editors/josm/plugins/public_transport/src/public_transport/GTFSImporterDialog.java
r30532 r31995 1 1 package public_transport; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.awt.Frame;7 5 import java.awt.GridBagConstraints; 8 6 import java.awt.GridBagLayout; 9 7 10 8 import javax.swing.JButton; 11 import javax.swing.JComboBox;12 9 import javax.swing.JComponent; 13 import javax.swing.JDialog;14 10 import javax.swing.JLabel; 15 import javax.swing.JList;16 import javax.swing.JOptionPane;17 11 import javax.swing.JPanel; 18 12 import javax.swing.JScrollPane; 19 import javax.swing.JTabbedPane;20 13 import javax.swing.JTable; 21 import javax.swing.JTextField;22 14 import javax.swing.KeyStroke; 23 15 24 import org.openstreetmap.josm.Main; 25 26 public class GTFSImporterDialog 16 public class GTFSImporterDialog extends AbstractImporterDialog<GTFSImporterAction> 27 17 { 28 private JDialog jDialog = null;29 private JTabbedPane tabbedPane = null;30 private JComboBox<TransText> cbStoptype = null;31 private JList tracksList = null;32 private JTextField tfGPSTimeStart = null;33 private JTextField tfStopwatchStart = null;34 private JTextField tfTimeWindow = null;35 private JTextField tfThreshold = null;36 private JTable stoplistTable = null;37 18 private JTable gtfsStopTable = null; 38 private final String[] stoptypes = new String[]{marktr("bus"), marktr("tram"), marktr("light_rail"), marktr("subway"), marktr("rail")};39 19 40 20 public GTFSImporterDialog(GTFSImporterAction controller) 41 21 { 42 Frame frame = JOptionPane.getFrameForComponent(Main.parent); 43 jDialog = new JDialog(frame, tr("Create Stops from GTFS"), false); 44 tabbedPane = new JTabbedPane(); 22 super(controller, tr("Create Stops from GTFS"), "gtfsImporter"); 23 } 24 25 @Override 26 protected void initDialog(GTFSImporterAction controller) { 45 27 JPanel tabSettings = new JPanel(); 46 28 tabbedPane.addTab(tr("Settings"), tabSettings); … … 49 31 tabbedPane.setEnabledAt(0, false); 50 32 tabbedPane.setEnabledAt(1, true); 51 jDialog.add(tabbedPane);52 33 53 34 //Settings Tab … … 68 49 contentPane.add(label); 69 50 70 cbStoptype = new JComboBox<>();71 cbStoptype.setEditable(false);72 for(String type : stoptypes)73 cbStoptype.addItem(new TransText(type));74 cbStoptype.setActionCommand("gtfsImporter.settingsStoptype");75 cbStoptype.addActionListener(controller);76 77 51 layoutCons.gridx = 0; 78 52 layoutCons.gridy = 1; … … 95 69 contentPane.add(label); 96 70 97 tfGPSTimeStart = new JTextField("00:00:00", 15);98 tfGPSTimeStart.setActionCommand("gtfsImporter.settingsGPSTimeStart");99 tfGPSTimeStart.addActionListener(controller);100 101 71 layoutCons.gridx = 0; 102 72 layoutCons.gridy = 3; … … 131 101 contentPane.add(label); 132 102 133 tfStopwatchStart = new JTextField("00:00:00", 15);134 tfStopwatchStart.setActionCommand("gtfsImporter.settingsStopwatchStart");135 tfStopwatchStart.addActionListener(controller);136 137 103 layoutCons.gridx = 0; 138 104 layoutCons.gridy = 5; … … 167 133 contentPane.add(label); 168 134 169 tfTimeWindow = new JTextField("15", 4);170 tfTimeWindow.setActionCommand("gtfsImporter.settingsTimeWindow");171 tfTimeWindow.addActionListener(controller);172 173 135 layoutCons.gridx = 0; 174 136 layoutCons.gridy = 7; … … 201 163 gridbag.setConstraints(label, layoutCons); 202 164 contentPane.add(label); 203 204 tfThreshold = new JTextField("20", 4);205 tfThreshold.setActionCommand("gtfsImporter.settingsThreshold");206 tfThreshold.addActionListener(controller);207 165 208 166 layoutCons.gridx = 0; … … 375 333 gridbag.setConstraints(bDelete, layoutCons); 376 334 contentPane.add(bDelete); 377 378 jDialog.pack();379 jDialog.setLocationRelativeTo(frame);380 }381 382 public void setTrackValid(boolean valid)383 {384 tabbedPane.setEnabledAt(2, valid);385 }386 387 public void setVisible(boolean visible)388 {389 jDialog.setVisible(visible);390 }391 392 public void setSettings393 (String gpsSyncTime, String stopwatchStart,394 double timeWindow, double threshold)395 {396 tfGPSTimeStart.setText(gpsSyncTime);397 tfStopwatchStart.setText(stopwatchStart);398 tfTimeWindow.setText(Double.toString(timeWindow));399 tfThreshold.setText(Double.toString(threshold));400 }401 402 public String getStoptype()403 {404 return ((TransText)cbStoptype.getSelectedItem()).text;405 }406 407 public boolean gpsTimeStartValid()408 {409 if (parseTime(tfGPSTimeStart.getText()) >= 0)410 {411 return true;412 }413 else414 {415 JOptionPane.showMessageDialog416 (null, tr("Can''t parse a time from this string."), tr("Invalid value"),417 JOptionPane.ERROR_MESSAGE);418 return false;419 }420 }421 422 public String getGpsTimeStart()423 {424 return tfGPSTimeStart.getText();425 }426 427 public void setGpsTimeStart(String s)428 {429 tfGPSTimeStart.setText(s);430 }431 432 public boolean stopwatchStartValid()433 {434 if (parseTime(tfStopwatchStart.getText()) >= 0)435 {436 return true;437 }438 else439 {440 JOptionPane.showMessageDialog441 (null, tr("Can''t parse a time from this string."), tr("Invalid value"),442 JOptionPane.ERROR_MESSAGE);443 return false;444 }445 }446 447 public String getStopwatchStart()448 {449 return tfStopwatchStart.getText();450 }451 452 public void setStopwatchStart(String s)453 {454 tfStopwatchStart.setText(s);455 }456 457 public double getTimeWindow()458 {459 return Double.parseDouble(tfTimeWindow.getText());460 }461 462 public double getThreshold()463 {464 return Double.parseDouble(tfThreshold.getText());465 335 } 466 336 … … 477 347 gtfsStopTable.getColumnModel().getColumn(1).setPreferredWidth((int)(width * 0.6)); 478 348 gtfsStopTable.getColumnModel().getColumn(2).setPreferredWidth((int)(width * 0.1)); 479 }480 481 public static double parseTime(String s)482 {483 if ((s.charAt(2) != ':') || (s.charAt(2) != ':')484 || (s.length() < 8))485 return -1;486 int hour = Integer.parseInt(s.substring(0, 2));487 int minute = Integer.parseInt(s.substring(3, 5));488 double second = Double.parseDouble(s.substring(6, s.length()));489 if ((hour < 0) || (hour > 23) || (minute < 0) || (minute > 59)490 || (second < 0) || (second >= 60.0))491 return -1;492 return (second + minute*60 + hour*60*60);493 349 } 494 350 -
applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterDialog.java
r30532 r31995 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Frame;7 6 import java.awt.GridBagConstraints; 8 7 import java.awt.GridBagLayout; … … 13 12 import javax.swing.JComboBox; 14 13 import javax.swing.JComponent; 15 import javax.swing.JDialog;16 14 import javax.swing.JLabel; 17 15 import javax.swing.JList; 18 import javax.swing.JOptionPane;19 16 import javax.swing.JPanel; 20 17 import javax.swing.JScrollPane; 21 import javax.swing.JTabbedPane;22 18 import javax.swing.JTable; 23 import javax.swing.JTextField;24 19 import javax.swing.KeyStroke; 25 20 import javax.swing.ListSelectionModel; … … 27 22 import javax.swing.event.ListSelectionListener; 28 23 29 import org.openstreetmap.josm.Main; 30 31 public class StopImporterDialog 24 public class StopImporterDialog extends AbstractImporterDialog<StopImporterAction> 32 25 { 33 private JDialog jDialog = null;34 private JTabbedPane tabbedPane = null;35 private JComboBox<TransText> cbStoptype = null;36 26 private JList<TrackReference> tracksList = null; 37 private JTextField tfGPSTimeStart = null;38 private JTextField tfStopwatchStart = null;39 private JTextField tfTimeWindow = null;40 private JTextField tfThreshold = null;41 27 private JTable stoplistTable = null; 42 28 private JTable waypointTable = null; 43 29 44 private final String[] stoptypes = new String[]{marktr("bus"), marktr("tram"), marktr("light_rail"), marktr("subway"), marktr("rail")};45 46 30 public StopImporterDialog(StopImporterAction controller) 47 31 { 48 Frame frame = JOptionPane.getFrameForComponent(Main.parent); 49 jDialog = new JDialog(frame, tr("Create Stops from GPX"), false); 50 tabbedPane = new JTabbedPane(); 32 super(controller, tr("Create Stops from GPX"), "stopImporter"); 33 } 34 35 @Override 36 protected void initDialog(StopImporterAction controller) { 51 37 JPanel tabTracks = new JPanel(); 52 38 tabbedPane.addTab(tr("Tracks"), tabTracks); … … 61 47 tabbedPane.setEnabledAt(2, false); 62 48 tabbedPane.setEnabledAt(3, true); 63 jDialog.add(tabbedPane);64 49 65 50 //Tracks Tab … … 114 99 contentPane.add(label); 115 100 116 cbStoptype = new JComboBox<>();117 cbStoptype.setEditable(false);118 for(String type : stoptypes)119 cbStoptype.addItem(new TransText(type));120 cbStoptype.setActionCommand("stopImporter.settingsStoptype");121 cbStoptype.addActionListener(controller);122 123 101 layoutCons.gridx = 0; 124 102 layoutCons.gridy = 1; … … 141 119 contentPane.add(label); 142 120 143 tfGPSTimeStart = new JTextField("00:00:00", 15);144 tfGPSTimeStart.setActionCommand("stopImporter.settingsGPSTimeStart");145 tfGPSTimeStart.addActionListener(controller);146 147 121 layoutCons.gridx = 0; 148 122 layoutCons.gridy = 3; … … 176 150 contentPane.add(label); 177 151 178 tfStopwatchStart = new JTextField("00:00:00", 15);179 tfStopwatchStart.setActionCommand("stopImporter.settingsStopwatchStart");180 tfStopwatchStart.addActionListener(controller);181 182 152 layoutCons.gridx = 0; 183 153 layoutCons.gridy = 5; … … 211 181 contentPane.add(label); 212 182 213 tfTimeWindow = new JTextField("15", 4);214 tfTimeWindow.setActionCommand("stopImporter.settingsTimeWindow");215 tfTimeWindow.addActionListener(controller);216 217 183 layoutCons.gridx = 0; 218 184 layoutCons.gridy = 7; … … 245 211 gridbag.setConstraints(label, layoutCons); 246 212 contentPane.add(label); 247 248 tfThreshold = new JTextField("20", 4);249 tfThreshold.setActionCommand("stopImporter.settingsThreshold");250 tfThreshold.addActionListener(controller);251 213 252 214 layoutCons.gridx = 0; … … 542 504 gridbag.setConstraints(bDelete, layoutCons); 543 505 contentPane.add(bDelete); 544 545 jDialog.pack();546 jDialog.setLocationRelativeTo(frame);547 }548 549 public void setTrackValid(boolean valid)550 {551 tabbedPane.setEnabledAt(2, valid);552 }553 554 public void setVisible(boolean visible)555 {556 jDialog.setVisible(visible);557 }558 559 public void setSettings560 (String gpsSyncTime, String stopwatchStart,561 double timeWindow, double threshold)562 {563 tfGPSTimeStart.setText(gpsSyncTime);564 tfStopwatchStart.setText(stopwatchStart);565 tfTimeWindow.setText(Double.toString(timeWindow));566 tfThreshold.setText(Double.toString(threshold));567 }568 569 public String getStoptype()570 {571 return ((TransText)cbStoptype.getSelectedItem()).text;572 }573 574 public boolean gpsTimeStartValid()575 {576 if (parseTime(tfGPSTimeStart.getText()) >= 0)577 {578 return true;579 }580 else581 {582 JOptionPane.showMessageDialog583 (null, tr("Can''t parse a time from this string."), tr("Invalid value"),584 JOptionPane.ERROR_MESSAGE);585 return false;586 }587 }588 589 public String getGpsTimeStart()590 {591 return tfGPSTimeStart.getText();592 }593 594 public void setGpsTimeStart(String s)595 {596 tfGPSTimeStart.setText(s);597 }598 599 public boolean stopwatchStartValid()600 {601 if (parseTime(tfStopwatchStart.getText()) >= 0)602 {603 return true;604 }605 else606 {607 JOptionPane.showMessageDialog608 (null, tr("Can''t parse a time from this string."), tr("Invalid value"),609 JOptionPane.ERROR_MESSAGE);610 return false;611 }612 }613 614 public String getStopwatchStart()615 {616 return tfStopwatchStart.getText();617 }618 619 public void setStopwatchStart(String s)620 {621 tfStopwatchStart.setText(s);622 }623 624 public double getTimeWindow()625 {626 return Double.parseDouble(tfTimeWindow.getText());627 }628 629 public double getThreshold()630 {631 return Double.parseDouble(tfThreshold.getText());632 506 } 633 507 … … 674 548 } 675 549 676 public static double parseTime(String s)677 {678 if ((s.charAt(2) != ':') || (s.charAt(2) != ':')679 || (s.length() < 8))680 return -1;681 int hour = Integer.parseInt(s.substring(0, 2));682 int minute = Integer.parseInt(s.substring(3, 5));683 double second = Double.parseDouble(s.substring(6, s.length()));684 if ((hour < 0) || (hour > 23) || (minute < 0) || (minute > 59)685 || (second < 0) || (second >= 60.0))686 return -1;687 return (second + minute*60 + hour*60*60);688 }689 690 550 private class TracksLSL implements ListSelectionListener 691 551 { … … 697 557 } 698 558 559 @Override 699 560 public void valueChanged(ListSelectionEvent e) 700 561 {
Note:
See TracChangeset
for help on using the changeset viewer.