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 9c44635..9fc3593 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 @@ -34,15 +34,28 @@ import eu.omp.irap.vespa.votable.view.VOTableView; */ public class ServicesPanelView extends VOTableView { + /** */ + private static final int TABLE_NAME_COLUMN_POSITION = 4; + + /** */ + private static final int SERVICE_URL_COLUMN_POSITION = 1; + /** The serial version UID. */ private static final long serialVersionUID = 1L; + /** The listener of the services panel view. */ ServicesPanelListener listener; + /** + * The button which update the query based on the table name textField and the service URL + * textField. + */ private JButton serviceButton; + /** The text field to manually set the service URL. */ private JTextField serviceUrlTextField; + /** The text field to manually set the service table name. */ private JTextField tableNameTextField; @@ -50,15 +63,15 @@ public class ServicesPanelView extends VOTableView { * Method constructor which customize the services panel, but don't build it from scratch since * VOTableView is already created by ServicesController. Add also the JTable listener. * - * @param mainView The main view of the application. - * @param voTableView The generic view of the VOTable panel. + * @param listener The listener of the services panel. */ - public ServicesPanelView(final ServicesPanelListener viewListener) { + public ServicesPanelView(final ServicesPanelListener listener) { super(); - this.listener = viewListener; + this.listener = listener; buildServicesPanel(); } + /** Build the service panel and add the graphical elements on it. */ private void buildServicesPanel() { getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @@ -68,10 +81,6 @@ public class ServicesPanelView extends VOTableView { } }); - add(buildAddServicePanel(), BorderLayout.SOUTH); - } - - private JPanel buildAddServicePanel() { JPanel addServicePanel = new JPanel(); addServicePanel.add(new JLabel("Service URL")); addServicePanel.add(getServiceUrlTextField()); @@ -79,17 +88,33 @@ public class ServicesPanelView extends VOTableView { addServicePanel.add(getTableNameTextField()); addServicePanel.add(getServiceButton()); - return addServicePanel; + add(addServicePanel, BorderLayout.SOUTH); } + /** + * Returns the field to set a custom table name. Create it if doesn't exist. + * + * @return The table name JTextField. + */ private JTextField getTableNameTextField() { return tableNameTextField == null ? new JTextField(10) : tableNameTextField; } + /** + * Returns the field to set a custom service URL. Create it if doesn't exist. + * + * @return The service URL JTextField. + */ private JTextField getServiceUrlTextField() { return serviceUrlTextField == null ? new JTextField(10) : serviceUrlTextField; } + /** + * Returns the button which update the query based on the table name textField and the service + * URL textField. Create it if doesn't exist. + * + * @return The JButton to set the custom service, create it if doesn't exist. + */ private JButton getServiceButton() { if (serviceButton == null) { serviceButton = new JButton("Set service"); @@ -113,7 +138,7 @@ public class ServicesPanelView extends VOTableView { if (row == -1) { return serviceUrlTextField.getText(); } - return (String) getValueAt(5, row); + return (String) getValueAt(SERVICE_URL_COLUMN_POSITION, row); } /** @@ -124,6 +149,6 @@ public class ServicesPanelView extends VOTableView { if (row == -1) { return tableNameTextField.getText(); } - return (String) getValueAt(2, row); + return (String) getValueAt(TABLE_NAME_COLUMN_POSITION, row); } } -- libgit2 0.21.2