From 5976415adb5e7aba5a8bbe9dc5deae9c3d69f59f Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Thu, 19 May 2016 12:47:50 +0200 Subject: [PATCH] Use the VOTableListener to listen for selection events, and remove TODOs. --- src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java | 3 --- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java | 2 +- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java | 1 - src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java | 4 ---- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java | 4 ++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java | 9 +++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java | 4 +++- src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java | 2 +- src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java | 5 ++--- src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java | 12 ++++-------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java | 14 ++------------ src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java | 5 ++--- src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java | 1 - 13 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java index aa0757c..dbc32c1 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java @@ -130,9 +130,6 @@ public class GranuleCtrl { * @throws ParseException If an element can not be parsed (ie., a date). */ public Granule getGranuleFromVOTableRow(int rowId) throws ParseException { - - // TODO: Parse column by column, to avoid compare all column name for each line. - //@noformat Granule g = new Granule(parseString(rowId, GranuleEnum.GRANULE_UID)); g.setGranuleGid(parseString(rowId, GranuleEnum.GRANULE_GID)); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java index 5dfd744..646ecd9 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java @@ -23,7 +23,7 @@ public interface RequestPanelListener { /** * Method called when the used click on the 'Send query' button. - * + * * @param query The query */ void onSendButtonClicked(String query); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java index 5bc6b3f..55f78d5 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java @@ -98,7 +98,6 @@ public class DateRangeField extends ParamField implements TextFieldListener { } catch (@SuppressWarnings("unused") ParseException e) { field.setBackground(Color.PINK); } - // TODO: check if date min < date max } else { field.setBackground(Color.PINK); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java index de837fe..e0b3854 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java @@ -17,7 +17,6 @@ package eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield; import java.awt.Dimension; -import java.util.logging.Logger; import javax.swing.BoxLayout; import javax.swing.JLabel; @@ -41,9 +40,6 @@ public abstract class ParamField extends JPanel { /** The serial version UID. */ private static final long serialVersionUID = 1L; - /** The logger for the class ParamField. */ - protected static final Logger LOGGER = Logger.getLogger(ParamField.class.getName()); - /** The minimum width of the field. */ protected static final int MIN_FIELD_WIDTH = 30; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java index 29e7a59..c0ab63c 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java +++ b/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; import java.awt.Dimension; import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JComboBox; import javax.swing.JTextField; @@ -37,6 +38,9 @@ import eu.omp.irap.vespa.votable.utils.CantSendQueryException; */ public class TargetNameField extends ParamField implements TextFieldListener { + /** The logger for the class TargetNameField. */ + private static final Logger LOGGER = Logger.getLogger(TargetNameField.class.getName()); + /** The serial version UID. */ private static final long serialVersionUID = 1L; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java index 35e6e02..b9eaa1d 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.logging.Logger; import eu.omp.irap.vespa.epntapclient.gui.mainpanel.MainPanelCtrl; import eu.omp.irap.vespa.votable.controller.VOTableController; @@ -29,6 +30,9 @@ import eu.omp.irap.vespa.votable.controller.VOTableController; */ public class ResultPanelCtrl extends VOTableController implements ResultPanelListener { + /** The logger for the class ResultPanelCtrl. */ + private static final Logger LOGGER = Logger.getLogger(ResultPanelCtrl.class.getName()); + /** The controller of the main panel. */ private MainPanelCtrl mainPanelCtrl; @@ -61,4 +65,9 @@ public class ResultPanelCtrl extends VOTableController implements ResultPanelLis public ResultPanelView getView() { return view; } + + @Override + public void onRowSelected(int selectedRow) { + LOGGER.info("Selected row: " + selectedRow); + } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java index 805a180..87ed34d 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java @@ -18,10 +18,12 @@ package eu.omp.irap.vespa.epntapclient.gui.resultpanel; import java.io.File; +import eu.omp.irap.vespa.votable.view.VOTableViewListener; + /** * @author N. Jourdane */ -public interface ResultPanelListener { +public interface ResultPanelListener extends VOTableViewListener { /** * Copy the VOTable to a specified location. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java index d8437e1..d150004 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java @@ -52,7 +52,7 @@ public class ResultPanelView extends VOTableView { * @param listener The listener of the result view. */ public ResultPanelView(ResultPanelListener listener) { - super(); + super(listener); this.listener = listener; buildResultPanel(); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java index 1f28162..d166cd2 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java @@ -47,7 +47,7 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane /** * Constructor of ServicesPanelCtrl - * + * * @param mainPanelCtrl The controller of the main panel. */ public ServicesPanelCtrl(MainPanelCtrl mainPanelCtrl) { @@ -78,9 +78,8 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane return selectedServiceURL; } - /** Update the row selected by the user on the Services Panel. */ @Override - public void onServiceSelected(int selectedServiceRow) { + public void onRowSelected(int selectedServiceRow) { String serviceURL = view.getServiceURL(selectedServiceRow); String tableName = view.getTableName(selectedServiceRow); if (!tableName.equals(selectedTableName)) { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java index c3757bc..58c2e83 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java @@ -16,15 +16,11 @@ package eu.omp.irap.vespa.epntapclient.gui.servicespanel; +import eu.omp.irap.vespa.votable.view.VOTableViewListener; + /** * @author N. Jourdane */ -public interface ServicesPanelListener { - - /** - * When a service is selected on the service panel. - * - * @param selectedService The row number selected in the service panel. - */ - void onServiceSelected(int selectedService); +public interface ServicesPanelListener extends VOTableViewListener { + /* Nothing to listen yet except service selection, listened by VOTableViewListener. */ } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java index 9fc3593..4c2427e 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java @@ -24,8 +24,6 @@ import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import eu.omp.irap.vespa.votable.view.VOTableView; @@ -66,21 +64,13 @@ public class ServicesPanelView extends VOTableView { * @param listener The listener of the services panel. */ public ServicesPanelView(final ServicesPanelListener listener) { - super(); + super(listener); this.listener = listener; buildServicesPanel(); } /** Build the service panel and add the graphical elements on it. */ private void buildServicesPanel() { - getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { - - @Override - public void valueChanged(ListSelectionEvent evt) { - listener.onServiceSelected(getTable().getSelectedRow()); - } - }); - JPanel addServicePanel = new JPanel(); addServicePanel.add(new JLabel("Service URL")); addServicePanel.add(getServiceUrlTextField()); @@ -123,7 +113,7 @@ public class ServicesPanelView extends VOTableView { @Override public void actionPerformed(ActionEvent e) { - listener.onServiceSelected(-1); + listener.onRowSelected(-1); } }); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java index dd172dd..884f414 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java @@ -30,8 +30,8 @@ import eu.omp.irap.vespa.epntapclient.voresource.model.Type; import eu.omp.irap.vespa.epntapclient.votable.model.Table; import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; import eu.omp.irap.vespa.votable.Consts; -import eu.omp.irap.vespa.votable.controller.VOTableException; import eu.omp.irap.vespa.votable.controller.VOTableController; +import eu.omp.irap.vespa.votable.controller.VOTableException; import eu.omp.irap.vespa.votable.utils.StringJoiner; import eu.omp.irap.vespa.votable.votabledata.VOTableData; import eu.omp.irap.vespa.votable.votabledata.VOTableDataParser; @@ -102,7 +102,6 @@ public class ServiceCtrl { service.setReferenceURL((String) data.getCell(i, "reference_url")); service.setCreated((String) data.getCell(i, "created")); service.setUpdated((String) data.getCell(i, "updated")); - // TODO: Convert date format services.add(service); } return services; @@ -181,7 +180,7 @@ public class ServiceCtrl { /** * Convert a date from XMLGregorianCalendar to a string literal. - * + * * @param date The date to convert * @return The serialized date. */ diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java index 465dfb0..83472eb 100644 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java @@ -286,7 +286,6 @@ public class EpnTapConnectionTest { assertEquals(3, data.getNbColumns()); assertEquals(1, data.getNbRows()); - // TODO: Should be return only 2 columns, because keywords do not contains res_subject. assertTrue("Column name access_url not found.", data.isContainingColumnName("access_url")); assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name")); assertTrue("AMDA short_name not found.", -- libgit2 0.21.2