Commit 58a466aacc6cdb7a12c15448c37e5387ee53b42c
1 parent
6f25e39e
Exists in
master
Use ResultPanelCtrl to manage the result view.
Showing
6 changed files
with
56 additions
and
73 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelCtrl.java
... | ... | @@ -16,10 +16,6 @@ |
16 | 16 | |
17 | 17 | package eu.omp.irap.vespa.epntapclient.gui.mainPanel; |
18 | 18 | |
19 | -import java.io.File; | |
20 | -import java.io.IOException; | |
21 | -import java.nio.file.Files; | |
22 | -import java.nio.file.Paths; | |
23 | 19 | import java.util.logging.Level; |
24 | 20 | import java.util.logging.Logger; |
25 | 21 | |
... | ... | @@ -27,14 +23,14 @@ import javax.swing.JOptionPane; |
27 | 23 | |
28 | 24 | import eu.omp.irap.vespa.epntapclient.EpnTapController; |
29 | 25 | import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelCtrl; |
26 | +import eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultPanelCtrl; | |
30 | 27 | import eu.omp.irap.vespa.epntapclient.gui.servicespanel.ServicesPanelCtrl; |
31 | 28 | import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; |
32 | -import eu.omp.irap.vespa.votable.controller.VOTableController; | |
33 | 29 | |
34 | 30 | /** |
35 | 31 | * @author N. Jourdane |
36 | 32 | */ |
37 | -public class MainPanelCtrl extends EpnTapController implements ViewListener { | |
33 | +public class MainPanelCtrl extends EpnTapController { | |
38 | 34 | |
39 | 35 | /** The logger for the class GUIController. */ |
40 | 36 | private static final Logger logger = Logger.getLogger(MainPanelCtrl.class.getName()); |
... | ... | @@ -43,22 +39,18 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { |
43 | 39 | |
44 | 40 | private ServicesPanelCtrl servicesPanelCtrl; |
45 | 41 | |
46 | - private VOTableController resultPanelCtrl; | |
42 | + private ResultPanelCtrl resultPanelCtrl; | |
47 | 43 | |
48 | - private MainPanelView mainView; | |
49 | - | |
50 | - private String voTablePath; | |
51 | - | |
52 | - // TODO: à déplacer dans ServicePanelCtrl | |
44 | + private MainPanelView view; | |
53 | 45 | |
54 | 46 | private int nbMaxResult = 10; |
55 | 47 | |
56 | 48 | |
57 | 49 | public MainPanelCtrl() { |
58 | 50 | servicesPanelCtrl = new ServicesPanelCtrl(this); |
59 | - resultPanelCtrl = new VOTableController(); | |
51 | + resultPanelCtrl = new ResultPanelCtrl(this); | |
60 | 52 | requestPanelCtrl = new RequestPanelCtrl(this); |
61 | - mainView = new MainPanelView(this); | |
53 | + view = new MainPanelView(this); | |
62 | 54 | } |
63 | 55 | |
64 | 56 | @Override |
... | ... | @@ -68,7 +60,7 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { |
68 | 60 | } catch (CantGetVOTableException e) { |
69 | 61 | displayError("Can not get services.", e); |
70 | 62 | } |
71 | - mainView.getServicesPanel().fillTable(servicesPanelCtrl.getVOTableData()); | |
63 | + view.getServicesPanel().fillTable(servicesPanelCtrl.getVOTableData()); | |
72 | 64 | } |
73 | 65 | |
74 | 66 | public void sendQuery(String query) { |
... | ... | @@ -76,8 +68,7 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { |
76 | 68 | logger.info("Sending query: " + query + " on " + serviceURL); |
77 | 69 | try { |
78 | 70 | resultPanelCtrl.updateVOTable(serviceURL, query); |
79 | - voTablePath = resultPanelCtrl.getVOTablePath(); | |
80 | - mainView.getResultsPanel().fillTable(resultPanelCtrl.getVOTableData()); | |
71 | + view.getResultsPanel().fillTable(resultPanelCtrl.getVOTableData()); | |
81 | 72 | } catch (CantGetVOTableException e) { |
82 | 73 | displayError("Can not send the query.", e); |
83 | 74 | MainPanelCtrl.logger.log(Level.WARNING, "Can not send query.", e); |
... | ... | @@ -92,27 +83,18 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { |
92 | 83 | return servicesPanelCtrl; |
93 | 84 | } |
94 | 85 | |
86 | + public ResultPanelCtrl getResultPanelCtrl() { | |
87 | + return resultPanelCtrl; | |
88 | + } | |
89 | + | |
95 | 90 | public MainPanelView getView() { |
96 | - return mainView; | |
91 | + return view; | |
97 | 92 | } |
98 | 93 | |
99 | 94 | @Override |
100 | 95 | public void displayError(String message, Exception e) { |
101 | 96 | logger.log(Level.SEVERE, message, e); |
102 | - JOptionPane.showMessageDialog(mainView, e.getMessage(), message, JOptionPane.ERROR_MESSAGE); | |
103 | - } | |
104 | - | |
105 | - /** Copy the VOTable to a specified location. */ | |
106 | - @Override | |
107 | - public void onDownloadButtonClicked(File outputFile) { | |
108 | - try { | |
109 | - Files.copy(Paths.get(voTablePath), Paths.get(outputFile.getAbsolutePath())); | |
110 | - } catch (IOException e) { | |
111 | - // TODO create exception | |
112 | - mainView.displayError("Can not save the file.", | |
113 | - "Check that you can write on the specified directory."); | |
114 | - MainPanelCtrl.logger.log(Level.WARNING, "Can not save the file.", e); | |
115 | - } | |
97 | + JOptionPane.showMessageDialog(view, e.getMessage(), message, JOptionPane.ERROR_MESSAGE); | |
116 | 98 | } |
117 | 99 | |
118 | 100 | /** | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelView.java
... | ... | @@ -56,7 +56,7 @@ public class MainPanelView extends JPanel { |
56 | 56 | |
57 | 57 | public MainPanelView(MainPanelCtrl mainPanelCtrl) { |
58 | 58 | servicesPanel = mainPanelCtrl.getServicePanelCtrl().getView(); |
59 | - resultPanel = new ResultPanelView(mainPanelCtrl); | |
59 | + resultPanel = mainPanelCtrl.getResultPanelCtrl().getView(); | |
60 | 60 | requestPanel = mainPanelCtrl.getRequestPanelCtrl().getView(); |
61 | 61 | buildMainView(); |
62 | 62 | } | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/ViewListener.java deleted
... | ... | @@ -1,36 +0,0 @@ |
1 | -/* | |
2 | - * This file is a part of EpnTAPClient. | |
3 | - * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. | |
4 | - * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 | |
5 | - * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. | |
6 | - * | |
7 | - * This program is free software: you can | |
8 | - * redistribute it and/or modify it under the terms of the GNU General Public License as published | |
9 | - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later | |
10 | - * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY | |
11 | - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
12 | - * PURPOSE. See the GNU General Public License for more details. You should have received a copy of | |
13 | - * the GNU General Public License along with this program. If not, see | |
14 | - * <http://www.gnu.org/licenses/>. | |
15 | - */ | |
16 | - | |
17 | -package eu.omp.irap.vespa.epntapclient.gui.mainPanel; | |
18 | - | |
19 | -import java.io.File; | |
20 | - | |
21 | -/** | |
22 | - * The interface for the main view listener, which listen for GUI events in the view, implemented by | |
23 | - * the controller. | |
24 | - * | |
25 | - * @author N. Jourdane | |
26 | - */ | |
27 | -public interface ViewListener { | |
28 | - | |
29 | - /** | |
30 | - * When the `Download VOTable` button is clicked. | |
31 | - * | |
32 | - * @param outputFile The file to copy the VOTable. | |
33 | - */ | |
34 | - void onDownloadButtonClicked(File outputFile); | |
35 | - | |
36 | -} |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java
... | ... | @@ -16,13 +16,50 @@ |
16 | 16 | |
17 | 17 | package eu.omp.irap.vespa.epntapclient.gui.resultpanel; |
18 | 18 | |
19 | +import java.io.File; | |
20 | +import java.io.IOException; | |
21 | +import java.nio.file.Files; | |
22 | +import java.nio.file.Paths; | |
23 | +import java.util.logging.Level; | |
19 | 24 | import java.util.logging.Logger; |
20 | 25 | |
26 | +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.MainPanelCtrl; | |
27 | +import eu.omp.irap.vespa.votable.controller.VOTableController; | |
28 | + | |
21 | 29 | /** |
22 | 30 | * @author N. Jourdane |
23 | 31 | */ |
24 | -public class ResultPanelCtrl { | |
32 | +public class ResultPanelCtrl extends VOTableController implements ResultPanelListener { | |
25 | 33 | |
26 | 34 | /** The logger for the class ResultPanelCtrl. */ |
27 | 35 | private static final Logger logger = Logger.getLogger(ResultPanelCtrl.class.getName()); |
36 | + | |
37 | + private MainPanelCtrl mainPanelCtrl; | |
38 | + | |
39 | + private ResultPanelView view; | |
40 | + | |
41 | + | |
42 | + public ResultPanelCtrl(MainPanelCtrl mainPanelCtrl) { | |
43 | + this.mainPanelCtrl = mainPanelCtrl; | |
44 | + view = new ResultPanelView(this); | |
45 | + } | |
46 | + | |
47 | + /* | |
48 | + * @see | |
49 | + * eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultPanelListener#onDownloadButtonClicked( | |
50 | + * java.io.File) | |
51 | + */ | |
52 | + @Override | |
53 | + public void onDownloadButtonClicked(File file) { | |
54 | + try { | |
55 | + Files.copy(Paths.get(voTablePath), Paths.get(file.getAbsolutePath())); | |
56 | + } catch (IOException e) { | |
57 | + mainPanelCtrl.displayError("Can not save the file.", e); | |
58 | + logger.log(Level.WARNING, "Can not save the file.", e); | |
59 | + } | |
60 | + } | |
61 | + | |
62 | + public ResultPanelView getView() { | |
63 | + return view; | |
64 | + } | |
28 | 65 | } | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java
... | ... | @@ -25,7 +25,6 @@ import javax.swing.JFileChooser; |
25 | 25 | import javax.swing.JLabel; |
26 | 26 | import javax.swing.JPanel; |
27 | 27 | |
28 | -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; | |
29 | 28 | import eu.omp.irap.vespa.votable.view.VOTableView; |
30 | 29 | |
31 | 30 | /** |
... | ... | @@ -36,7 +35,7 @@ public class ResultPanelView extends VOTableView { |
36 | 35 | /** The serial version UID. */ |
37 | 36 | private static final long serialVersionUID = 1L; |
38 | 37 | |
39 | - ViewListener viewListener; | |
38 | + ResultPanelListener viewListener; | |
40 | 39 | |
41 | 40 | /** A label to display several informations (aka. status bar). */ |
42 | 41 | private JLabel infoLabel; |
... | ... | @@ -51,7 +50,7 @@ public class ResultPanelView extends VOTableView { |
51 | 50 | * @param mainView The main view of the application. |
52 | 51 | * @param voTableView The generic view of the VOTable panel. |
53 | 52 | */ |
54 | - public ResultPanelView(ViewListener viewListener) { | |
53 | + public ResultPanelView(ResultPanelListener viewListener) { | |
55 | 54 | super(); |
56 | 55 | this.viewListener = viewListener; |
57 | 56 | buildResultPanel(); | ... | ... |