Commit 53d49e834976c6dafdfa916a5c3cc501ec7a67da

Authored by Nathanael Jourdane
1 parent d0823848
Exists in master

Fix all Eclipse warnings.

src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java
... ... @@ -30,7 +30,7 @@ import eu.omp.irap.vespa.epntapclient.controller.EpnTapController;
30 30 */
31 31 public class EpnTapMainApp {
32 32 /** The logger for the class EpnTapMainApp. */
33   - private static final Logger logger = Logger.getLogger(EpnTapMainApp.class.getName());
  33 + static final Logger logger = Logger.getLogger(EpnTapMainApp.class.getName());
34 34  
35 35 /** Constructor to hide the implicit public one. */
36 36 private EpnTapMainApp() {
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java
... ... @@ -34,22 +34,22 @@ import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException;
34 34 */
35 35 public class EpnTapController implements MainViewListener {
36 36 /** The logger for the class EpnTapController. */
37   - Logger logger = Logger.getLogger(EpnTapController.class.getName());
  37 + private Logger logger = Logger.getLogger(EpnTapController.class.getName());
38 38  
39 39 /** The view of EPN-TAP application. */
40   - EpnTapMainView mainView;
  40 + private EpnTapMainView mainView;
41 41  
42 42 /** The controller of the VOTable displaying the list of services. */
43   - VOTableController servicesController;
  43 + private VOTableController servicesController;
44 44  
45 45 /** The controller of the VOTable displaying the query results. */
46   - VOTableController resultsController;
  46 + private VOTableController resultsController;
47 47  
48 48 /** The name of the table selected by the user on the table list panel. */
49   - String selectedTableName;
  49 + private String selectedTableName;
50 50  
51 51 /** The URL of the service corresponding to the selected table. */
52   - String selectedTableServiceURL;
  52 + private String selectedTableServiceURL;
53 53  
54 54 /**
55 55 * The parameters fields for the request.
... ... @@ -135,22 +135,24 @@ public class EpnTapController implements MainViewListener {
135 135 * @param event
136 136 * @param args
137 137 */
138   - public void event(Event event, Object[] args) {
  138 + @Override
  139 + public void event(Event event, Object... args) {
139 140 logger.info("new event: " + event.toString());
140 141  
141 142 try {
  143 + Object object = args[0];
142 144 switch (event) {
143 145 case serviceSelected:
144   - updateSelected((int) args[0]);
  146 + updateSelected(((Integer) args[0]).intValue());
145 147 break;
146 148 case btnSearchClicked:
147   - sendQuery((String) args[0]);
  149 + sendQuery((String) object);
148 150 break;
149 151 case paramChanged:
150   - updateParameter((String) args[0], args[1]);
  152 + updateParameter((String) object, args[1]);
151 153 break;
152 154 case paramRemoved:
153   - removeParameter((String) args[0]);
  155 + removeParameter((String) object);
154 156 break;
155 157 default:
156 158 logger.warning("Event " + event.toString() + " detected but is not implemented.");
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java
... ... @@ -28,7 +28,8 @@ import eu.omp.irap.vespa.epntapclient.votable.Utils.StringJoiner;
28 28 */
29 29 public final class Queries {
30 30 /** The logger for the class Queries. */
31   - Logger logger = Logger.getLogger(Queries.class.getName());
  31 + @SuppressWarnings("unused")
  32 + private Logger logger = Logger.getLogger(Queries.class.getName());
32 33  
33 34 // AMDA access_url: http://cdpp-epntap.cesr.fr/__system__/tap/run/tap
34 35 // AMDA table name: amdadb.epn_core
... ... @@ -56,14 +57,14 @@ public final class Queries {
56 57 public static String getQuery(String tableName, Map<String, Object> params, int nbRow) {
57 58 StringJoiner addJoin = new StringJoiner(" AND ");
58 59 for (Map.Entry<String, Object> param : params.entrySet()) {
59   - Class paramClass = param.getValue().getClass();
60   - if (paramClass == ArrayList.class) {
  60 + if (param.getValue() instanceof ArrayList) {
61 61 StringJoiner orJoin = new StringJoiner(" OR ");
62   - List<String> possibleValues = ((List<String>) param.getValue());
  62 + @SuppressWarnings("unchecked")
  63 + List<String> possibleValues = (List<String>) param.getValue();
63 64 for (String possibleValue : possibleValues)
64 65 orJoin.add(param.getKey() + " LIKE '" + possibleValue + "'");
65 66 addJoin.add("(" + orJoin + ")");
66   - } else if (paramClass == String.class) {
  67 + } else if (param.getValue() instanceof String) {
67 68 addJoin.add(param.getKey() + " LIKE '" + param.getValue() + "'");
68 69 } else {
69 70 addJoin.add(param.getKey() + " = " + param.getValue().toString());
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java
... ... @@ -34,6 +34,7 @@ import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;
34 34 */
35 35 public class EpnTapMainView extends JPanel {
36 36 /** The logger for the class EpnTapMainView. */
  37 + @SuppressWarnings("unused")
37 38 private static final Logger logger = Logger.getLogger(EpnTapMainView.class.getName());
38 39  
39 40 /** The serial version UID (affected with a random number). */
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java
... ... @@ -47,8 +47,11 @@ import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableConnection;
47 47 import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.SendQueryException;
48 48  
49 49 public abstract class ParamField extends JPanel {
  50 + /** */
  51 + private static final long serialVersionUID = 6025994164004985362L;
  52 +
50 53 /** The logger for the class ParamField. */
51   - private static final Logger logger = Logger.getLogger(ParamField.class.getName());
  54 + static final Logger logger = Logger.getLogger(ParamField.class.getName());
52 55  
53 56 private static final int MIN_FIELD_WIDTH = 30;
54 57 private static final int FIELD_HEIGHT = 20;
... ... @@ -61,7 +64,7 @@ public abstract class ParamField extends JPanel {
61 64 private static final String MIN_SUFFIX = "min";
62 65 private static final String MAX_SUFFIX = "max";
63 66  
64   - protected static EpnTapMainView mainView;
  67 + protected EpnTapMainView mainView;
65 68 protected String paramName;
66 69  
67 70 public ParamField(EpnTapMainView mainView, String paramName) {
... ... @@ -80,6 +83,8 @@ public abstract class ParamField extends JPanel {
80 83 }
81 84  
82 85 public static class StringField extends ParamField implements TextFieldListener {
  86 + /** */
  87 + private static final long serialVersionUID = 24219488975302068L;
83 88 JTextField field;
84 89  
85 90 public StringField(EpnTapMainView mainView, String paramName) {
... ... @@ -89,16 +94,19 @@ public abstract class ParamField extends JPanel {
89 94 this.add(field);
90 95 }
91 96  
92   - public void update(JTextField field) {
93   - if ("".equals(field.getText())) {
  97 + @Override
  98 + public void update(JTextField textField) {
  99 + if ("".equals(textField.getText())) {
94 100 mainView.event(Event.paramChanged, paramName, null);
95 101 } else {
96   - mainView.event(Event.paramChanged, paramName, field.getText());
  102 + mainView.event(Event.paramChanged, paramName, textField.getText());
97 103 }
98 104 }
99 105 }
100 106  
101 107 public static class FloatField extends ParamField implements TextFieldListener {
  108 + /** */
  109 + private static final long serialVersionUID = -1880193152285564590L;
102 110 JTextField field;
103 111  
104 112 public FloatField(EpnTapMainView mainView, String paramName) {
... ... @@ -108,23 +116,26 @@ public abstract class ParamField extends JPanel {
108 116 this.add(field);
109 117 }
110 118  
111   - public void update(JTextField field) {
112   - if ("".equals(field.getText())) {
113   - field.setBackground(Color.WHITE);
  119 + @Override
  120 + public void update(JTextField textField) {
  121 + if ("".equals(textField.getText())) {
  122 + textField.setBackground(Color.WHITE);
114 123 mainView.event(Event.paramRemoved, paramName);
115 124 } else {
116 125 try {
117   - mainView.event(Event.paramChanged, paramName,
118   - Float.parseFloat(field.getText()));
119   - field.setBackground(Color.WHITE);
120   - } catch (NumberFormatException e) {
121   - field.setBackground(Color.PINK);
  126 + float value = Float.parseFloat(textField.getText());
  127 + mainView.event(Event.paramChanged, paramName, value);
  128 + textField.setBackground(Color.WHITE);
  129 + } catch (@SuppressWarnings("unused") NumberFormatException e) {
  130 + textField.setBackground(Color.PINK);
122 131 }
123 132 }
124 133 }
125 134 }
126 135  
127 136 public static class DateRangeField extends ParamField implements TextFieldListener {
  137 + /** */
  138 + private static final long serialVersionUID = -7781309003911514777L;
128 139 JTextField fieldMin;
129 140 JTextField fieldMax;
130 141  
... ... @@ -145,6 +156,7 @@ public abstract class ParamField extends JPanel {
145 156 this.add(fieldMax);
146 157 }
147 158  
  159 + @Override
148 160 public void update(JTextField field) {
149 161 DateFormat df = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH);
150 162 if ("".equals(field.getText())) {
... ... @@ -156,7 +168,7 @@ public abstract class ParamField extends JPanel {
156 168 date = Math.round((date / 86400000.0) + 2440587.5); // to JD
157 169 mainView.event(Event.paramChanged, paramName + field.getName(), date);
158 170 field.setBackground(Color.WHITE);
159   - } catch (ParseException e) {
  171 + } catch (@SuppressWarnings("unused") ParseException e) {
160 172 field.setBackground(Color.PINK);
161 173 }
162 174 // TODO: check if date min < date max
... ... @@ -167,6 +179,8 @@ public abstract class ParamField extends JPanel {
167 179 }
168 180  
169 181 public static class FloatRangeField extends ParamField implements TextFieldListener {
  182 + /** */
  183 + private static final long serialVersionUID = 7923358142882329015L;
170 184 JTextField fieldMin;
171 185 JTextField fieldMax;
172 186  
... ... @@ -183,6 +197,7 @@ public abstract class ParamField extends JPanel {
183 197 this.add(fieldMax);
184 198 }
185 199  
  200 + @Override
186 201 public void update(JTextField field) {
187 202 if ("".equals(field.getText())) {
188 203 field.setBackground(Color.WHITE);
... ... @@ -192,7 +207,7 @@ public abstract class ParamField extends JPanel {
192 207 mainView.event(Event.paramChanged, paramName + field.getName(),
193 208 Float.parseFloat(field.getText()));
194 209 field.setBackground(Color.WHITE);
195   - } catch (NumberFormatException e) {
  210 + } catch (@SuppressWarnings("unused") NumberFormatException e) {
196 211 field.setBackground(Color.PINK);
197 212 }
198 213 }
... ... @@ -200,13 +215,15 @@ public abstract class ParamField extends JPanel {
200 215 }
201 216  
202 217 public static class TargetNameField extends ParamField implements TextFieldListener {
  218 + /** */
  219 + private static final long serialVersionUID = 5136431108894677113L;
203 220 JComboBox<String> comboBox;
204 221 JTextField field;
205 222 String lastContent;
206 223  
207 224 public TargetNameField(EpnTapMainView mainView, String paramName) {
208 225 super(mainView, paramName);
209   - comboBox = new JComboBox();
  226 + comboBox = new JComboBox<>();
210 227 comboBox.setPreferredSize(new Dimension(MIN_FIELD_WIDTH, FIELD_HEIGHT));
211 228  
212 229 comboBox.setEditable(true);
... ... @@ -215,7 +232,7 @@ public abstract class ParamField extends JPanel {
215 232 this.add(comboBox);
216 233 }
217 234  
218   - private String[] getItems(String begining) throws SendQueryException {
  235 + static String[] getItems(String begining) throws SendQueryException {
219 236 StringBuilder resolverResult = null;
220 237 resolverResult = VOTableConnection.sendGet(RESOLVER_URL, "q=\"" + begining + "\"");
221 238 JsonObject root = new JsonParser().parse(resolverResult.toString()).getAsJsonObject();
... ... @@ -256,17 +273,20 @@ public abstract class ParamField extends JPanel {
256 273 }
257 274 };
258 275  
259   - public void update(JTextField field) {
  276 + @Override
  277 + public void update(JTextField textField) {
260 278 SwingUtilities.invokeLater(updateComboBox);
261 279 }
262 280 }
263 281  
264 282 public static class DataProductTypeField extends ParamField {
  283 + /** */
  284 + private static final long serialVersionUID = -6362359909898369750L;
265 285 JComboBox<String> comboBox;
266 286  
267 287 public DataProductTypeField(EpnTapMainView mainView, String paramName) {
268 288 super(mainView, paramName);
269   - comboBox = new JComboBox(getItems().keySet().toArray());
  289 + comboBox = new JComboBox<>((String[]) getItems().keySet().toArray());
270 290 comboBox.setSelectedItem("All");
271 291 comboBox.setPreferredSize(new Dimension(MIN_FIELD_WIDTH, FIELD_HEIGHT));
272 292 comboBox.addActionListener(new ActionListener() {
... ... @@ -278,8 +298,8 @@ public abstract class ParamField extends JPanel {
278 298 this.add(comboBox);
279 299 }
280 300  
281   - private HashMap<String, String> getItems() {
282   - HashMap items = new HashMap<String, String>();
  301 + private static HashMap<String, String> getItems() {
  302 + HashMap<String, String> items = new HashMap<>();
283 303 items.put("All", "all");
284 304 items.put("Image", "im");
285 305 items.put("Spectrum", "sp");
... ... @@ -295,9 +315,9 @@ public abstract class ParamField extends JPanel {
295 315 return items;
296 316 }
297 317  
298   - private void onUpdate() {
  318 + void onUpdate() {
299 319 String key = comboBox.getSelectedItem().toString();
300   - List<String> item = new ArrayList();
  320 + List<String> item = new ArrayList<>();
301 321 item.add(key.replace(" ", "-").toLowerCase());
302 322 item.add(getItems().get(key));
303 323 if ("All".equals(key)) {
... ... @@ -309,11 +329,13 @@ public abstract class ParamField extends JPanel {
309 329 }
310 330  
311 331 public static class TargetClassField extends ParamField {
  332 + /** */
  333 + private static final long serialVersionUID = 6439475087727685080L;
312 334 JComboBox<String> comboBox;
313 335  
314 336 public TargetClassField(EpnTapMainView mainView, String paramName) {
315 337 super(mainView, paramName);
316   - comboBox = new JComboBox(getItems());
  338 + comboBox = new JComboBox<>(getItems());
317 339 comboBox.setPreferredSize(new Dimension(MIN_FIELD_WIDTH, FIELD_HEIGHT));
318 340 comboBox.addActionListener(new ActionListener() {
319 341 @Override
... ... @@ -324,12 +346,12 @@ public abstract class ParamField extends JPanel {
324 346 this.add(comboBox);
325 347 }
326 348  
327   - private String[] getItems() {
  349 + private static String[] getItems() {
328 350 return new String[] { "All", "Comet", "Exoplanet", "Interplanetary medium", "Ring",
329 351 "Sample", "Sky", "Spacecraft", "Spacejunk", "Star" };
330 352 }
331 353  
332   - private void onUpdate() {
  354 + void onUpdate() {
333 355 String value = comboBox.getSelectedItem().toString().replace(" ", "_").toLowerCase();
334 356 if ("All".equals(value)) {
335 357 mainView.event(Event.paramRemoved, paramName);
... ... @@ -345,14 +367,17 @@ public abstract class ParamField extends JPanel {
345 367  
346 368 static void addChangeListener(final TextFieldListener changeListener, final JTextField field) {
347 369 field.getDocument().addDocumentListener(new DocumentListener() {
  370 + @Override
348 371 public void removeUpdate(DocumentEvent de) {
349 372 changeListener.update(field);
350 373 }
351 374  
  375 + @Override
352 376 public void insertUpdate(DocumentEvent de) {
353 377 changeListener.update(field);
354 378 }
355 379  
  380 + @Override
356 381 public void changedUpdate(DocumentEvent de) {
357 382 changeListener.update(field);
358 383 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java
... ... @@ -29,11 +29,20 @@ import eu.omp.irap.vespa.epntapclient.view.EpnTapMainView;
29 29 * @author N. Jourdane
30 30 */
31 31 public class BottomBarPanel extends JPanel {
  32 + /** */
  33 + private static final long serialVersionUID = 8083897308526492902L;
  34 +
32 35 /** The logger for the class BottomBar. */
  36 + @SuppressWarnings("unused")
33 37 private static final Logger logger = Logger.getLogger(BottomBarPanel.class.getName());
34   - JLabel infoLabel;
  38 +
  39 + @SuppressWarnings("unused")
  40 + private EpnTapMainView mainView;
  41 +
  42 + private JLabel infoLabel;
35 43  
36 44 public BottomBarPanel(EpnTapMainView mainView) {
  45 + this.mainView = mainView;
37 46 setLayout(new BorderLayout());
38 47 infoLabel = new JLabel();
39 48 this.add(infoLabel);
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java
... ... @@ -44,6 +44,7 @@ import eu.omp.irap.vespa.epntapclient.view.ParamField.TargetNameField;
44 44 */
45 45 public class RequestPanel extends JPanel implements ActionListener {
46 46 /** The logger for the class RequestView. */
  47 + @SuppressWarnings("unused")
47 48 private static final Logger logger = Logger.getLogger(RequestPanel.class.getName());
48 49  
49 50 /** The serial version UID (affected with a random number). */
... ... @@ -96,7 +97,7 @@ public class RequestPanel extends JPanel implements ActionListener {
96 97 // TODO: new GUI field column to allow the user to select the comparison operator:
97 98 // - if the field is a String: listbox with 'xx', '%xx', 'xx%', and '%xx%'.
98 99 // - if the field is a numeric value: listbox with <, <=, =, =>, >.
99   - paramFields = new ArrayList();
  100 + paramFields = new ArrayList<>();
100 101 paramFields.add(new TargetNameField(mainView, "target_name"));
101 102 paramFields.add(new DateRangeField(mainView, "time_"));
102 103 paramFields.add(new FloatRangeField(mainView, "spectral_range_"));
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java
... ... @@ -30,11 +30,18 @@ import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;
30 30 * @author N. Jourdane
31 31 */
32 32 public class ResultsPanel extends JPanel {
  33 + /** */
  34 + private static final long serialVersionUID = -3387526562625069156L;
  35 +
33 36 /** The logger for the class ResultPanel. */
  37 + @SuppressWarnings("unused")
34 38 private static final Logger logger = Logger.getLogger(ResultsPanel.class.getName());
35 39  
36   - EpnTapMainView mainView;
37   - VOTableView voTableView;
  40 + @SuppressWarnings("unused")
  41 + private EpnTapMainView mainView;
  42 +
  43 + @SuppressWarnings("unused")
  44 + private VOTableView voTableView;
38 45  
39 46 public ResultsPanel(EpnTapMainView mainView, VOTableView voTableView) {
40 47 super();
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java
... ... @@ -33,11 +33,17 @@ import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;
33 33 * @author N. Jourdane
34 34 */
35 35 public class ServicesPanel extends JPanel {
  36 + /** */
  37 + private static final long serialVersionUID = 7850369546415832758L;
  38 +
36 39 /** The logger for the class ServicesView. */
  40 + @SuppressWarnings("unused")
37 41 private static final Logger logger = Logger.getLogger(ServicesPanel.class.getName());
38 42  
39   - EpnTapMainView mainView;
40   - VOTableView voTableView;
  43 + @SuppressWarnings("unused")
  44 + private EpnTapMainView mainView;
  45 +
  46 + private VOTableView voTableView;
41 47  
42 48 public ServicesPanel(final EpnTapMainView mainView, final VOTableView voTableView) {
43 49 super();
... ... @@ -53,6 +59,7 @@ public class ServicesPanel extends JPanel {
53 59 // TODO: Support multi-selection
54 60 voTableView.getTable().getSelectionModel()
55 61 .addListSelectionListener(new ListSelectionListener() {
  62 + @Override
56 63 public void valueChanged(ListSelectionEvent evt) {
57 64 mainView.event(Event.serviceSelected,
58 65 voTableView.getTable().getSelectedRow());
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java
... ... @@ -41,7 +41,7 @@ public class Utils {
41 41  
42 42 public StringJoiner(String separator) {
43 43 this.separator = separator;
44   - this.list = new ArrayList();
  44 + this.list = new ArrayList<>();
45 45 string = "";
46 46 }
47 47  
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java
... ... @@ -33,7 +33,7 @@ import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException;
33 33 */
34 34 public class VOTableApp {
35 35 /** The logger for the class VOTableApp. */
36   - private static final Logger logger = Logger.getLogger(VOTableApp.class.getName());
  36 + static final Logger logger = Logger.getLogger(VOTableApp.class.getName());
37 37  
38 38 /**
39 39 * Main function to start the application as standalone.
... ... @@ -64,6 +64,7 @@ public class VOTableApp {
64 64 voTableControl = new VOTableController(args[0]);
65 65 } catch (VOTableException e) {
66 66 System.console().writer().println("Error: " + e.getMessage());
  67 + return;
67 68 }
68 69 } else if (args.length == 3) {
69 70 voTableControl = new VOTableController(args[0], args[1], args[2]);
... ...