Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java 4.96 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;
5d3c344e   Nathanael Jourdane   Use Java logging ...
20
import java.util.logging.Logger;
1353e182   Nathanael Jourdane   Add minimal eleme...
21
22
23

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

5af53be7   Nathanael Jourdane   Make the applicat...
26
27
28
29
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...
30
31
32
import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;

/**
a227a22d   Nathanael Jourdane   Add comments.
33
 * The main view of the application, which manage all the other views.
1e543ea0   Nathanael Jourdane   Code clean-up
34
 *
1353e182   Nathanael Jourdane   Add minimal eleme...
35
36
37
 * @author N. Jourdane
 */
public class EpnTapMainView extends JPanel {
5d3c344e   Nathanael Jourdane   Use Java logging ...
38
	/** The logger for the class EpnTapMainView. */
53d49e83   Nathanael Jourdane   Fix all Eclipse w...
39
	@SuppressWarnings("unused")
5d3c344e   Nathanael Jourdane   Use Java logging ...
40
	private static final Logger logger = Logger.getLogger(EpnTapMainView.class.getName());
5576be01   Nathanael Jourdane   Make panels resiz...
41

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

1353e182   Nathanael Jourdane   Add minimal eleme...
45
	/** The JPanel where the VOTable results is displayed. */
5af53be7   Nathanael Jourdane   Make the applicat...
46
	private ResultsPanel resultsPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
47
48

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

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

a227a22d   Nathanael Jourdane   Add comments.
54
	/** The status bar. */
5af53be7   Nathanael Jourdane   Make the applicat...
55
	private BottomBarPanel bottomBarPanel;
c57c07b1   Nathanael Jourdane   Add the bottom ba...
56

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

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

a227a22d   Nathanael Jourdane   Add comments.
67
68
		/**
		 * When an event is detected on the main view.
1e543ea0   Nathanael Jourdane   Code clean-up
69
		 *
a227a22d   Nathanael Jourdane   Add comments.
70
71
72
		 * @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...
73
74
		void event(Event event, Object... args);
	}
204e830a   Nathanael Jourdane   Add query paramet...
75

1353e182   Nathanael Jourdane   Add minimal eleme...
76
	/**
a227a22d   Nathanael Jourdane   Add comments.
77
	 * The main view constructor, which create all the panels.
1e543ea0   Nathanael Jourdane   Code clean-up
78
	 *
a227a22d   Nathanael Jourdane   Add comments.
79
80
	 * @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...
81
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
82

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

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

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

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

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

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

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

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

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

	/**
a227a22d   Nathanael Jourdane   Add comments.
143
	 * Display an error message. Usually used each time an error happens.
1353e182   Nathanael Jourdane   Add minimal eleme...
144
145
146
147
148
	 *
	 * @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...
149
150
		JOptionPane.showMessageDialog(this, message, title,
				JOptionPane.ERROR_MESSAGE);
1353e182   Nathanael Jourdane   Add minimal eleme...
151
152
	}

a227a22d   Nathanael Jourdane   Add comments.
153
154
	/**
	 * Get an event and send it to the listener of the main view.
1e543ea0   Nathanael Jourdane   Code clean-up
155
	 *
a227a22d   Nathanael Jourdane   Add comments.
156
157
158
	 * @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...
159
160
161
162
	public void event(Event event, Object... args) {
		mainViewListener.event(event, args);
	}

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