Commit 8ac245d4623536431d5d33a6c2846bc363dba2c0
1 parent
2e350611
Exists in
master
bugFix: Wrong column position in services table.
Showing
1 changed file
with
36 additions
and
11 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java
@@ -34,15 +34,28 @@ import eu.omp.irap.vespa.votable.view.VOTableView; | @@ -34,15 +34,28 @@ import eu.omp.irap.vespa.votable.view.VOTableView; | ||
34 | */ | 34 | */ |
35 | public class ServicesPanelView extends VOTableView { | 35 | public class ServicesPanelView extends VOTableView { |
36 | 36 | ||
37 | + /** */ | ||
38 | + private static final int TABLE_NAME_COLUMN_POSITION = 4; | ||
39 | + | ||
40 | + /** */ | ||
41 | + private static final int SERVICE_URL_COLUMN_POSITION = 1; | ||
42 | + | ||
37 | /** The serial version UID. */ | 43 | /** The serial version UID. */ |
38 | private static final long serialVersionUID = 1L; | 44 | private static final long serialVersionUID = 1L; |
39 | 45 | ||
46 | + /** The listener of the services panel view. */ | ||
40 | ServicesPanelListener listener; | 47 | ServicesPanelListener listener; |
41 | 48 | ||
49 | + /** | ||
50 | + * The button which update the query based on the table name textField and the service URL | ||
51 | + * textField. | ||
52 | + */ | ||
42 | private JButton serviceButton; | 53 | private JButton serviceButton; |
43 | 54 | ||
55 | + /** The text field to manually set the service URL. */ | ||
44 | private JTextField serviceUrlTextField; | 56 | private JTextField serviceUrlTextField; |
45 | 57 | ||
58 | + /** The text field to manually set the service table name. */ | ||
46 | private JTextField tableNameTextField; | 59 | private JTextField tableNameTextField; |
47 | 60 | ||
48 | 61 | ||
@@ -50,15 +63,15 @@ public class ServicesPanelView extends VOTableView { | @@ -50,15 +63,15 @@ public class ServicesPanelView extends VOTableView { | ||
50 | * Method constructor which customize the services panel, but don't build it from scratch since | 63 | * Method constructor which customize the services panel, but don't build it from scratch since |
51 | * VOTableView is already created by ServicesController. Add also the JTable listener. | 64 | * VOTableView is already created by ServicesController. Add also the JTable listener. |
52 | * | 65 | * |
53 | - * @param mainView The main view of the application. | ||
54 | - * @param voTableView The generic view of the VOTable panel. | 66 | + * @param listener The listener of the services panel. |
55 | */ | 67 | */ |
56 | - public ServicesPanelView(final ServicesPanelListener viewListener) { | 68 | + public ServicesPanelView(final ServicesPanelListener listener) { |
57 | super(); | 69 | super(); |
58 | - this.listener = viewListener; | 70 | + this.listener = listener; |
59 | buildServicesPanel(); | 71 | buildServicesPanel(); |
60 | } | 72 | } |
61 | 73 | ||
74 | + /** Build the service panel and add the graphical elements on it. */ | ||
62 | private void buildServicesPanel() { | 75 | private void buildServicesPanel() { |
63 | getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { | 76 | getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { |
64 | 77 | ||
@@ -68,10 +81,6 @@ public class ServicesPanelView extends VOTableView { | @@ -68,10 +81,6 @@ public class ServicesPanelView extends VOTableView { | ||
68 | } | 81 | } |
69 | }); | 82 | }); |
70 | 83 | ||
71 | - add(buildAddServicePanel(), BorderLayout.SOUTH); | ||
72 | - } | ||
73 | - | ||
74 | - private JPanel buildAddServicePanel() { | ||
75 | JPanel addServicePanel = new JPanel(); | 84 | JPanel addServicePanel = new JPanel(); |
76 | addServicePanel.add(new JLabel("Service URL")); | 85 | addServicePanel.add(new JLabel("Service URL")); |
77 | addServicePanel.add(getServiceUrlTextField()); | 86 | addServicePanel.add(getServiceUrlTextField()); |
@@ -79,17 +88,33 @@ public class ServicesPanelView extends VOTableView { | @@ -79,17 +88,33 @@ public class ServicesPanelView extends VOTableView { | ||
79 | addServicePanel.add(getTableNameTextField()); | 88 | addServicePanel.add(getTableNameTextField()); |
80 | addServicePanel.add(getServiceButton()); | 89 | addServicePanel.add(getServiceButton()); |
81 | 90 | ||
82 | - return addServicePanel; | 91 | + add(addServicePanel, BorderLayout.SOUTH); |
83 | } | 92 | } |
84 | 93 | ||
94 | + /** | ||
95 | + * Returns the field to set a custom table name. Create it if doesn't exist. | ||
96 | + * | ||
97 | + * @return The table name JTextField. | ||
98 | + */ | ||
85 | private JTextField getTableNameTextField() { | 99 | private JTextField getTableNameTextField() { |
86 | return tableNameTextField == null ? new JTextField(10) : tableNameTextField; | 100 | return tableNameTextField == null ? new JTextField(10) : tableNameTextField; |
87 | } | 101 | } |
88 | 102 | ||
103 | + /** | ||
104 | + * Returns the field to set a custom service URL. Create it if doesn't exist. | ||
105 | + * | ||
106 | + * @return The service URL JTextField. | ||
107 | + */ | ||
89 | private JTextField getServiceUrlTextField() { | 108 | private JTextField getServiceUrlTextField() { |
90 | return serviceUrlTextField == null ? new JTextField(10) : serviceUrlTextField; | 109 | return serviceUrlTextField == null ? new JTextField(10) : serviceUrlTextField; |
91 | } | 110 | } |
92 | 111 | ||
112 | + /** | ||
113 | + * Returns the button which update the query based on the table name textField and the service | ||
114 | + * URL textField. Create it if doesn't exist. | ||
115 | + * | ||
116 | + * @return The JButton to set the custom service, create it if doesn't exist. | ||
117 | + */ | ||
93 | private JButton getServiceButton() { | 118 | private JButton getServiceButton() { |
94 | if (serviceButton == null) { | 119 | if (serviceButton == null) { |
95 | serviceButton = new JButton("Set service"); | 120 | serviceButton = new JButton("Set service"); |
@@ -113,7 +138,7 @@ public class ServicesPanelView extends VOTableView { | @@ -113,7 +138,7 @@ public class ServicesPanelView extends VOTableView { | ||
113 | if (row == -1) { | 138 | if (row == -1) { |
114 | return serviceUrlTextField.getText(); | 139 | return serviceUrlTextField.getText(); |
115 | } | 140 | } |
116 | - return (String) getValueAt(5, row); | 141 | + return (String) getValueAt(SERVICE_URL_COLUMN_POSITION, row); |
117 | } | 142 | } |
118 | 143 | ||
119 | /** | 144 | /** |
@@ -124,6 +149,6 @@ public class ServicesPanelView extends VOTableView { | @@ -124,6 +149,6 @@ public class ServicesPanelView extends VOTableView { | ||
124 | if (row == -1) { | 149 | if (row == -1) { |
125 | return tableNameTextField.getText(); | 150 | return tableNameTextField.getText(); |
126 | } | 151 | } |
127 | - return (String) getValueAt(2, row); | 152 | + return (String) getValueAt(TABLE_NAME_COLUMN_POSITION, row); |
128 | } | 153 | } |
129 | } | 154 | } |