Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java 4.77 KB
1353e182   Nathanael Jourdane   Add minimal eleme...
1
2
3
4
5
/*
 * This file is a part of EpnTAPClient.
 * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
 * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
1e543ea0   Nathanael Jourdane   Code clean-up
6
 *
1353e182   Nathanael Jourdane   Add minimal eleme...
7
8
9
10
11
12
13
14
15
16
17
18
19
 * This program is free software: you can
 * redistribute it and/or modify it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
 * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
 * the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */

package eu.omp.irap.vespa.epntapclient.view;

import java.awt.BorderLayout;
1353e182   Nathanael Jourdane   Add minimal eleme...
20
21
22

import javax.swing.JOptionPane;
import javax.swing.JPanel;
5576be01   Nathanael Jourdane   Make panels resiz...
23
import javax.swing.JSplitPane;
5576be01   Nathanael Jourdane   Make panels resiz...
24

5af53be7   Nathanael Jourdane   Make the applicat...
25
26
27
28
import eu.omp.irap.vespa.epntapclient.view.panels.BottomBarPanel;
import eu.omp.irap.vespa.epntapclient.view.panels.RequestPanel;
import eu.omp.irap.vespa.epntapclient.view.panels.ResultsPanel;
import eu.omp.irap.vespa.epntapclient.view.panels.ServicesPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
29
30
31
import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;

/**
a227a22d   Nathanael Jourdane   Add comments.
32
 * The main view of the application, which manage all the other views.
1e543ea0   Nathanael Jourdane   Code clean-up
33
 *
1353e182   Nathanael Jourdane   Add minimal eleme...
34
35
36
 * @author N. Jourdane
 */
public class EpnTapMainView extends JPanel {
aa2a59ba   Nathanael Jourdane   [coding style] 2 ...
37

1e543ea0   Nathanael Jourdane   Code clean-up
38
39
	/** The serial version UID. */
	private static final long serialVersionUID = 1L;
1353e182   Nathanael Jourdane   Add minimal eleme...
40

1353e182   Nathanael Jourdane   Add minimal eleme...
41
	/** The JPanel where the VOTable results is displayed. */
5af53be7   Nathanael Jourdane   Make the applicat...
42
	private ResultsPanel resultsPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
43
44

	/** The JPanel where the list of services is displayed. */
5af53be7   Nathanael Jourdane   Make the applicat...
45
	private ServicesPanel servicesPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
46

a227a22d   Nathanael Jourdane   Add comments.
47
	/** The JPanel where the user build the query. */
5af53be7   Nathanael Jourdane   Make the applicat...
48
	private RequestPanel requestPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
49

a227a22d   Nathanael Jourdane   Add comments.
50
	/** The status bar. */
5af53be7   Nathanael Jourdane   Make the applicat...
51
	private BottomBarPanel bottomBarPanel;
c57c07b1   Nathanael Jourdane   Add the bottom ba...
52

a227a22d   Nathanael Jourdane   Add comments.
53
	/** The listener of the EpnTapMainView (usually the main controller) */
5af53be7   Nathanael Jourdane   Make the applicat...
54
	private MainViewListener mainViewListener;
4cc84b63   Nathanael Jourdane   Add the possibili...
55

aa2a59ba   Nathanael Jourdane   [coding style] 2 ...
56

a227a22d   Nathanael Jourdane   Add comments.
57
58
	/**
	 * The interface for the main view listener, which listen for events.
1e543ea0   Nathanael Jourdane   Code clean-up
59
	 *
a227a22d   Nathanael Jourdane   Add comments.
60
61
	 * @author N. Jourdane
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
62
	public interface MainViewListener {
4268557f   Nathanael Jourdane   Fix some Sonar is...
63

a227a22d   Nathanael Jourdane   Add comments.
64
65
		/**
		 * When an event is detected on the main view.
1e543ea0   Nathanael Jourdane   Code clean-up
66
		 *
a227a22d   Nathanael Jourdane   Add comments.
67
68
69
		 * @param event The event type. @see Event
		 * @param args The possible arguments which comes with the event (ie. a row number).
		 */
5af53be7   Nathanael Jourdane   Make the applicat...
70
71
		void event(Event event, Object... args);
	}
204e830a   Nathanael Jourdane   Add query paramet...
72

aa2a59ba   Nathanael Jourdane   [coding style] 2 ...
73

1353e182   Nathanael Jourdane   Add minimal eleme...
74
	/**
a227a22d   Nathanael Jourdane   Add comments.
75
	 * The main view constructor, which create all the panels.
1e543ea0   Nathanael Jourdane   Code clean-up
76
	 *
a227a22d   Nathanael Jourdane   Add comments.
77
78
	 * @param voTableServicesView The view to put in the services panel, built by ServicesController
	 * @param voTableResultsView The view to put in the results panel, built by ResultsController.
1353e182   Nathanael Jourdane   Add minimal eleme...
79
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
80

a8594a14   Nathanael Jourdane   [VOTable] Throw e...
81
	public EpnTapMainView(VOTableView voTableServicesView, VOTableView voTableResultsView) {
1e543ea0   Nathanael Jourdane   Code clean-up
82
83
84
85
		servicesPanel = new ServicesPanel(this, voTableServicesView);
		resultsPanel = new ResultsPanel(this, voTableResultsView);
		requestPanel = new RequestPanel(this);
		bottomBarPanel = new BottomBarPanel(this);
43c14591   Nathanael Jourdane   View: Add methods...
86
		buildWindow();
43c14591   Nathanael Jourdane   View: Add methods...
87
	}
1353e182   Nathanael Jourdane   Add minimal eleme...
88

a227a22d   Nathanael Jourdane   Add comments.
89
90
	/**
	 * Add a listener for the main view.
1e543ea0   Nathanael Jourdane   Code clean-up
91
	 *
a227a22d   Nathanael Jourdane   Add comments.
92
93
	 * @param listener A MainViewListener.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
94
95
	public void addMainViewListener(MainViewListener listener) {
		mainViewListener = listener;
1353e182   Nathanael Jourdane   Add minimal eleme...
96
97
98
	}

	/**
a227a22d   Nathanael Jourdane   Add comments.
99
	 * @return The JPanel where the VOTable result is displayed.
1353e182   Nathanael Jourdane   Add minimal eleme...
100
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
101
102
	public ResultsPanel getResultsPanel() {
		return resultsPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
103
104
105
	}

	/**
a227a22d   Nathanael Jourdane   Add comments.
106
	 * @return The JPanel containing the GUI elements to build the query.
0b616d80   Nathanael Jourdane   Updtate the query...
107
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
108
109
	public RequestPanel getRequestPanel() {
		return requestPanel;
0b616d80   Nathanael Jourdane   Updtate the query...
110
111
112
	}

	/**
1353e182   Nathanael Jourdane   Add minimal eleme...
113
114
	 * @return The JPanel where the list of services is displayed.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
115
116
	public ServicesPanel getServicesPanel() {
		return servicesPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
117
118
119
	}

	/**
a227a22d   Nathanael Jourdane   Add comments.
120
	 * @return The status bar.
c57c07b1   Nathanael Jourdane   Add the bottom ba...
121
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
122
123
	public BottomBarPanel getBottomBarPanel() {
		return bottomBarPanel;
c57c07b1   Nathanael Jourdane   Add the bottom ba...
124
125
126
	}

	/**
1353e182   Nathanael Jourdane   Add minimal eleme...
127
128
129
	 * Build and fill the GUI.
	 */
	public void buildWindow() {
a227a22d   Nathanael Jourdane   Add comments.
130
131
		setLayout(new BorderLayout());

5af53be7   Nathanael Jourdane   Make the applicat...
132
133
		JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel,
				requestPanel);
5576be01   Nathanael Jourdane   Make panels resiz...
134

5af53be7   Nathanael Jourdane   Make the applicat...
135
		JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel);
5576be01   Nathanael Jourdane   Make panels resiz...
136
		add(mainPanel, BorderLayout.CENTER);
5af53be7   Nathanael Jourdane   Make the applicat...
137
		add(bottomBarPanel, BorderLayout.SOUTH);
1353e182   Nathanael Jourdane   Add minimal eleme...
138
139
140
	}

	/**
a227a22d   Nathanael Jourdane   Add comments.
141
	 * Display an error message. Usually used each time an error happens.
1353e182   Nathanael Jourdane   Add minimal eleme...
142
143
144
145
146
	 *
	 * @param title The title of the error.
	 * @param message The message of the error.
	 */
	public void displayError(String title, String message) {
4cc84b63   Nathanael Jourdane   Add the possibili...
147
148
		JOptionPane.showMessageDialog(this, message, title,
				JOptionPane.ERROR_MESSAGE);
1353e182   Nathanael Jourdane   Add minimal eleme...
149
150
	}

a227a22d   Nathanael Jourdane   Add comments.
151
152
	/**
	 * Get an event and send it to the listener of the main view.
1e543ea0   Nathanael Jourdane   Code clean-up
153
	 *
a227a22d   Nathanael Jourdane   Add comments.
154
155
156
	 * @param event The event type. @see Event
	 * @param args The possible arguments which comes with the event (ie. a row number).
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
157
158
159
160
	public void event(Event event, Object... args) {
		mainViewListener.event(event, args);
	}

1353e182   Nathanael Jourdane   Add minimal eleme...
161
}