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