Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/gui/EpnTapMainView.java 4.46 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
 * 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/>.
 */

6dd0d332   Nathanael Jourdane   The controller do...
17
package eu.omp.irap.vespa.epntapclient.gui;
1353e182   Nathanael Jourdane   Add minimal eleme...
18
19

import java.awt.BorderLayout;
6dd0d332   Nathanael Jourdane   The controller do...
20
import java.awt.Dimension;
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

6dd0d332   Nathanael Jourdane   The controller do...
26
27
28
29
import eu.omp.irap.vespa.epntapclient.gui.panels.BottomBarPanel;
import eu.omp.irap.vespa.epntapclient.gui.panels.RequestPanel;
import eu.omp.irap.vespa.epntapclient.gui.panels.ResultsPanel;
import eu.omp.irap.vespa.epntapclient.gui.panels.ServicesPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
30
31

/**
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

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

1353e182   Nathanael Jourdane   Add minimal eleme...
54
	/**
a227a22d   Nathanael Jourdane   Add comments.
55
	 * The main view constructor, which create all the panels.
1e543ea0   Nathanael Jourdane   Code clean-up
56
	 *
a227a22d   Nathanael Jourdane   Add comments.
57
58
	 * @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...
59
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
60

6dd0d332   Nathanael Jourdane   The controller do...
61
62
63
	public EpnTapMainView(ViewListener viewListener) {
		servicesPanel = new ServicesPanel(viewListener);
		resultsPanel = new ResultsPanel(viewListener);
0f1bce56   Nathanael Jourdane   Use a listerner i...
64
65
		requestPanel = new RequestPanel(viewListener);
		bottomBarPanel = new BottomBarPanel(viewListener);
4ce406a8   Nathanael Jourdane   Add build() class...
66
		buildMainView();
43c14591   Nathanael Jourdane   View: Add methods...
67
	}
1353e182   Nathanael Jourdane   Add minimal eleme...
68

a227a22d   Nathanael Jourdane   Add comments.
69
	/**
6dd0d332   Nathanael Jourdane   The controller do...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
	 * Build and fill the GUI.
	 */
	private void buildMainView() {
		setLayout(new BorderLayout());

		JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel,
				requestPanel);
		JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel);

		add(mainPanel, BorderLayout.CENTER);
		add(bottomBarPanel, BorderLayout.SOUTH);

		setSizes();
	}

	private void setSizes() {
3bb7f0aa   Nathanael Jourdane   Improve GUI
86
87
		servicesPanel.setPreferredSize(
				new Dimension(GUIDim.LEFT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
6dd0d332   Nathanael Jourdane   The controller do...
88
89
		servicesPanel.setMinimumSize(
				new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));
6dd0d332   Nathanael Jourdane   The controller do...
90

3bb7f0aa   Nathanael Jourdane   Improve GUI
91
92
		requestPanel.setPreferredSize(
				new Dimension(GUIDim.RIGHT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
6dd0d332   Nathanael Jourdane   The controller do...
93
94
95
		requestPanel.setMinimumSize(
				new Dimension(GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));

3bb7f0aa   Nathanael Jourdane   Improve GUI
96
97
98
99
100
101
		resultsPanel.setPreferredSize(
				new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH,
						GUIDim.BOTTOM_PANEL_HEIGHT));
		resultsPanel.setMinimumSize(
				new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH,
						GUIDim.BOTTOM_PANEL_MIN_HEIGHT));
6dd0d332   Nathanael Jourdane   The controller do...
102
103
104
	}

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

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

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

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

	/**
a227a22d   Nathanael Jourdane   Add comments.
133
	 * Display an error message. Usually used each time an error happens.
1353e182   Nathanael Jourdane   Add minimal eleme...
134
135
136
137
138
	 *
	 * @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...
139
140
		JOptionPane.showMessageDialog(this, message, title,
				JOptionPane.ERROR_MESSAGE);
1353e182   Nathanael Jourdane   Add minimal eleme...
141
142
	}

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