Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/gui/EpnTapMainView.java 4.53 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
	 * 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() {

		servicesPanel
				.setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
		servicesPanel.setMinimumSize(
				new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));
		resultsPanel
				.setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH + GUIDim.RIGHT_PANEL_WIDTH,
						GUIDim.BOTTOM_PANEL_HEIGHT));
		resultsPanel.setMinimumSize(
				new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH,
						GUIDim.BOTTOM_PANEL_MIN_HEIGHT));

		requestPanel
				.setPreferredSize(new Dimension(GUIDim.RIGHT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
		requestPanel.setMinimumSize(
				new Dimension(GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));

		// bottomBarPanel.setPreferredSize
		// bottomBarPanel.setMinimumSize
	}

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

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

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

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

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

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