Commit 5976415adb5e7aba5a8bbe9dc5deae9c3d69f59f

Authored by Nathanael Jourdane
1 parent 6b128e20
Exists in master

Use the VOTableListener to listen for selection events, and remove TODOs.

src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java
... ... @@ -130,9 +130,6 @@ public class GranuleCtrl {
130 130 * @throws ParseException If an element can not be parsed (ie., a date).
131 131 */
132 132 public Granule getGranuleFromVOTableRow(int rowId) throws ParseException {
133   -
134   - // TODO: Parse column by column, to avoid compare all column name for each line.
135   -
136 133 //@noformat
137 134 Granule g = new Granule(parseString(rowId, GranuleEnum.GRANULE_UID));
138 135 g.setGranuleGid(parseString(rowId, GranuleEnum.GRANULE_GID));
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java
... ... @@ -23,7 +23,7 @@ public interface RequestPanelListener {
23 23  
24 24 /**
25 25 * Method called when the used click on the 'Send query' button.
26   - *
  26 + *
27 27 * @param query The query
28 28 */
29 29 void onSendButtonClicked(String query);
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java
... ... @@ -98,7 +98,6 @@ public class DateRangeField extends ParamField implements TextFieldListener {
98 98 } catch (@SuppressWarnings("unused") ParseException e) {
99 99 field.setBackground(Color.PINK);
100 100 }
101   - // TODO: check if date min < date max
102 101 } else {
103 102 field.setBackground(Color.PINK);
104 103 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java
... ... @@ -17,7 +17,6 @@
17 17 package eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield;
18 18  
19 19 import java.awt.Dimension;
20   -import java.util.logging.Logger;
21 20  
22 21 import javax.swing.BoxLayout;
23 22 import javax.swing.JLabel;
... ... @@ -41,9 +40,6 @@ public abstract class ParamField extends JPanel {
41 40 /** The serial version UID. */
42 41 private static final long serialVersionUID = 1L;
43 42  
44   - /** The logger for the class ParamField. */
45   - protected static final Logger LOGGER = Logger.getLogger(ParamField.class.getName());
46   -
47 43 /** The minimum width of the field. */
48 44 protected static final int MIN_FIELD_WIDTH = 30;
49 45  
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java
... ... @@ -18,6 +18,7 @@ package eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield;
18 18  
19 19 import java.awt.Dimension;
20 20 import java.util.logging.Level;
  21 +import java.util.logging.Logger;
21 22  
22 23 import javax.swing.JComboBox;
23 24 import javax.swing.JTextField;
... ... @@ -37,6 +38,9 @@ import eu.omp.irap.vespa.votable.utils.CantSendQueryException;
37 38 */
38 39 public class TargetNameField extends ParamField implements TextFieldListener {
39 40  
  41 + /** The logger for the class TargetNameField. */
  42 + private static final Logger LOGGER = Logger.getLogger(TargetNameField.class.getName());
  43 +
40 44 /** The serial version UID. */
41 45 private static final long serialVersionUID = 1L;
42 46  
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java
... ... @@ -20,6 +20,7 @@ import java.io.File;
20 20 import java.io.IOException;
21 21 import java.nio.file.Files;
22 22 import java.nio.file.Paths;
  23 +import java.util.logging.Logger;
23 24  
24 25 import eu.omp.irap.vespa.epntapclient.gui.mainpanel.MainPanelCtrl;
25 26 import eu.omp.irap.vespa.votable.controller.VOTableController;
... ... @@ -29,6 +30,9 @@ import eu.omp.irap.vespa.votable.controller.VOTableController;
29 30 */
30 31 public class ResultPanelCtrl extends VOTableController implements ResultPanelListener {
31 32  
  33 + /** The logger for the class ResultPanelCtrl. */
  34 + private static final Logger LOGGER = Logger.getLogger(ResultPanelCtrl.class.getName());
  35 +
32 36 /** The controller of the main panel. */
33 37 private MainPanelCtrl mainPanelCtrl;
34 38  
... ... @@ -61,4 +65,9 @@ public class ResultPanelCtrl extends VOTableController implements ResultPanelLis
61 65 public ResultPanelView getView() {
62 66 return view;
63 67 }
  68 +
  69 + @Override
  70 + public void onRowSelected(int selectedRow) {
  71 + LOGGER.info("Selected row: " + selectedRow);
  72 + }
64 73 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java
... ... @@ -18,10 +18,12 @@ package eu.omp.irap.vespa.epntapclient.gui.resultpanel;
18 18  
19 19 import java.io.File;
20 20  
  21 +import eu.omp.irap.vespa.votable.view.VOTableViewListener;
  22 +
21 23 /**
22 24 * @author N. Jourdane
23 25 */
24   -public interface ResultPanelListener {
  26 +public interface ResultPanelListener extends VOTableViewListener {
25 27  
26 28 /**
27 29 * Copy the VOTable to a specified location.
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java
... ... @@ -52,7 +52,7 @@ public class ResultPanelView extends VOTableView {
52 52 * @param listener The listener of the result view.
53 53 */
54 54 public ResultPanelView(ResultPanelListener listener) {
55   - super();
  55 + super(listener);
56 56 this.listener = listener;
57 57 buildResultPanel();
58 58 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java
... ... @@ -47,7 +47,7 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane
47 47  
48 48 /**
49 49 * Constructor of ServicesPanelCtrl
50   - *
  50 + *
51 51 * @param mainPanelCtrl The controller of the main panel.
52 52 */
53 53 public ServicesPanelCtrl(MainPanelCtrl mainPanelCtrl) {
... ... @@ -78,9 +78,8 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane
78 78 return selectedServiceURL;
79 79 }
80 80  
81   - /** Update the row selected by the user on the Services Panel. */
82 81 @Override
83   - public void onServiceSelected(int selectedServiceRow) {
  82 + public void onRowSelected(int selectedServiceRow) {
84 83 String serviceURL = view.getServiceURL(selectedServiceRow);
85 84 String tableName = view.getTableName(selectedServiceRow);
86 85 if (!tableName.equals(selectedTableName)) {
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java
... ... @@ -16,15 +16,11 @@
16 16  
17 17 package eu.omp.irap.vespa.epntapclient.gui.servicespanel;
18 18  
  19 +import eu.omp.irap.vespa.votable.view.VOTableViewListener;
  20 +
19 21 /**
20 22 * @author N. Jourdane
21 23 */
22   -public interface ServicesPanelListener {
23   -
24   - /**
25   - * When a service is selected on the service panel.
26   - *
27   - * @param selectedService The row number selected in the service panel.
28   - */
29   - void onServiceSelected(int selectedService);
  24 +public interface ServicesPanelListener extends VOTableViewListener {
  25 + /* Nothing to listen yet except service selection, listened by VOTableViewListener. */
30 26 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java
... ... @@ -24,8 +24,6 @@ import javax.swing.JButton;
24 24 import javax.swing.JLabel;
25 25 import javax.swing.JPanel;
26 26 import javax.swing.JTextField;
27   -import javax.swing.event.ListSelectionEvent;
28   -import javax.swing.event.ListSelectionListener;
29 27  
30 28 import eu.omp.irap.vespa.votable.view.VOTableView;
31 29  
... ... @@ -66,21 +64,13 @@ public class ServicesPanelView extends VOTableView {
66 64 * @param listener The listener of the services panel.
67 65 */
68 66 public ServicesPanelView(final ServicesPanelListener listener) {
69   - super();
  67 + super(listener);
70 68 this.listener = listener;
71 69 buildServicesPanel();
72 70 }
73 71  
74 72 /** Build the service panel and add the graphical elements on it. */
75 73 private void buildServicesPanel() {
76   - getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
77   -
78   - @Override
79   - public void valueChanged(ListSelectionEvent evt) {
80   - listener.onServiceSelected(getTable().getSelectedRow());
81   - }
82   - });
83   -
84 74 JPanel addServicePanel = new JPanel();
85 75 addServicePanel.add(new JLabel("Service URL"));
86 76 addServicePanel.add(getServiceUrlTextField());
... ... @@ -123,7 +113,7 @@ public class ServicesPanelView extends VOTableView {
123 113  
124 114 @Override
125 115 public void actionPerformed(ActionEvent e) {
126   - listener.onServiceSelected(-1);
  116 + listener.onRowSelected(-1);
127 117 }
128 118 });
129 119 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java
... ... @@ -30,8 +30,8 @@ import eu.omp.irap.vespa.epntapclient.voresource.model.Type;
30 30 import eu.omp.irap.vespa.epntapclient.votable.model.Table;
31 31 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
32 32 import eu.omp.irap.vespa.votable.Consts;
33   -import eu.omp.irap.vespa.votable.controller.VOTableException;
34 33 import eu.omp.irap.vespa.votable.controller.VOTableController;
  34 +import eu.omp.irap.vespa.votable.controller.VOTableException;
35 35 import eu.omp.irap.vespa.votable.utils.StringJoiner;
36 36 import eu.omp.irap.vespa.votable.votabledata.VOTableData;
37 37 import eu.omp.irap.vespa.votable.votabledata.VOTableDataParser;
... ... @@ -102,7 +102,6 @@ public class ServiceCtrl {
102 102 service.setReferenceURL((String) data.getCell(i, "reference_url"));
103 103 service.setCreated((String) data.getCell(i, "created"));
104 104 service.setUpdated((String) data.getCell(i, "updated"));
105   - // TODO: Convert date format
106 105 services.add(service);
107 106 }
108 107 return services;
... ... @@ -181,7 +180,7 @@ public class ServiceCtrl {
181 180  
182 181 /**
183 182 * Convert a date from XMLGregorianCalendar to a string literal.
184   - *
  183 + *
185 184 * @param date The date to convert
186 185 * @return The serialized date.
187 186 */
... ...
src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java
... ... @@ -286,7 +286,6 @@ public class EpnTapConnectionTest {
286 286  
287 287 assertEquals(3, data.getNbColumns());
288 288 assertEquals(1, data.getNbRows());
289   - // TODO: Should be return only 2 columns, because keywords do not contains res_subject.
290 289 assertTrue("Column name access_url not found.", data.isContainingColumnName("access_url"));
291 290 assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name"));
292 291 assertTrue("AMDA short_name not found.",
... ...