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 | 34 | */ |
35 | 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 | 43 | /** The serial version UID. */ |
38 | 44 | private static final long serialVersionUID = 1L; |
39 | 45 | |
46 | + /** The listener of the services panel view. */ | |
40 | 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 | 53 | private JButton serviceButton; |
43 | 54 | |
55 | + /** The text field to manually set the service URL. */ | |
44 | 56 | private JTextField serviceUrlTextField; |
45 | 57 | |
58 | + /** The text field to manually set the service table name. */ | |
46 | 59 | private JTextField tableNameTextField; |
47 | 60 | |
48 | 61 | |
... | ... | @@ -50,15 +63,15 @@ public class ServicesPanelView extends VOTableView { |
50 | 63 | * Method constructor which customize the services panel, but don't build it from scratch since |
51 | 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 | 69 | super(); |
58 | - this.listener = viewListener; | |
70 | + this.listener = listener; | |
59 | 71 | buildServicesPanel(); |
60 | 72 | } |
61 | 73 | |
74 | + /** Build the service panel and add the graphical elements on it. */ | |
62 | 75 | private void buildServicesPanel() { |
63 | 76 | getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { |
64 | 77 | |
... | ... | @@ -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 | 84 | JPanel addServicePanel = new JPanel(); |
76 | 85 | addServicePanel.add(new JLabel("Service URL")); |
77 | 86 | addServicePanel.add(getServiceUrlTextField()); |
... | ... | @@ -79,17 +88,33 @@ public class ServicesPanelView extends VOTableView { |
79 | 88 | addServicePanel.add(getTableNameTextField()); |
80 | 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 | 99 | private JTextField getTableNameTextField() { |
86 | 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 | 108 | private JTextField getServiceUrlTextField() { |
90 | 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 | 118 | private JButton getServiceButton() { |
94 | 119 | if (serviceButton == null) { |
95 | 120 | serviceButton = new JButton("Set service"); |
... | ... | @@ -113,7 +138,7 @@ public class ServicesPanelView extends VOTableView { |
113 | 138 | if (row == -1) { |
114 | 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 | 149 | if (row == -1) { |
125 | 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 | } | ... | ... |