Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java 4.27 KB
1353e182   Nathanael Jourdane   Add minimal eleme...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * 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.
 * 
 * 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
33
34
35
import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;

/**
 * @author N. Jourdane
 */
public class EpnTapMainView extends JPanel {
5d3c344e   Nathanael Jourdane   Use Java logging ...
36
	/** The logger for the class EpnTapMainView. */
53d49e83   Nathanael Jourdane   Fix all Eclipse w...
37
	@SuppressWarnings("unused")
5d3c344e   Nathanael Jourdane   Use Java logging ...
38
	private static final Logger logger = Logger.getLogger(EpnTapMainView.class.getName());
5576be01   Nathanael Jourdane   Make panels resiz...
39

1353e182   Nathanael Jourdane   Add minimal eleme...
40
41
42
	/** The serial version UID (affected with a random number). */
	private static final long serialVersionUID = -1233290271099283814L;

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

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

4a03be16   Nathanael Jourdane   Put queryArea in ...
49
	/** The JPanel where the user put requests. */
5af53be7   Nathanael Jourdane   Make the applicat...
50
	private RequestPanel requestPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
51

c57c07b1   Nathanael Jourdane   Add the bottom ba...
52
	/** The JPanel where the user put requests. */
5af53be7   Nathanael Jourdane   Make the applicat...
53
	private BottomBarPanel bottomBarPanel;
c57c07b1   Nathanael Jourdane   Add the bottom ba...
54

5af53be7   Nathanael Jourdane   Make the applicat...
55
	private MainViewListener mainViewListener;
4cc84b63   Nathanael Jourdane   Add the possibili...
56

5af53be7   Nathanael Jourdane   Make the applicat...
57
58
59
	public interface MainViewListener {
		void event(Event event, Object... args);
	}
204e830a   Nathanael Jourdane   Add query paramet...
60

1353e182   Nathanael Jourdane   Add minimal eleme...
61
	/**
5af53be7   Nathanael Jourdane   Make the applicat...
62
	 * The constructor of the view. TODO: controlleur = écouteur de la vue
6b021d84   Nathanael Jourdane   VOTable view can ...
63
64
	 * 
	 * @param controller The EPN-TAP controller, allowing the EPN-TAP view to send events.
1353e182   Nathanael Jourdane   Add minimal eleme...
65
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
66

a8594a14   Nathanael Jourdane   [VOTable] Throw e...
67
	public EpnTapMainView(VOTableView voTableServicesView, VOTableView voTableResultsView) {
5af53be7   Nathanael Jourdane   Make the applicat...
68
69
70
71
		this.servicesPanel = new ServicesPanel(this, voTableServicesView);
		this.resultsPanel = new ResultsPanel(this, voTableResultsView);
		this.requestPanel = new RequestPanel(this);
		this.bottomBarPanel = new BottomBarPanel(this);
5576be01   Nathanael Jourdane   Make panels resiz...
72
		setLayout(new BorderLayout());
43c14591   Nathanael Jourdane   View: Add methods...
73
		buildWindow();
43c14591   Nathanael Jourdane   View: Add methods...
74
	}
1353e182   Nathanael Jourdane   Add minimal eleme...
75

5af53be7   Nathanael Jourdane   Make the applicat...
76
77
	public void addMainViewListener(MainViewListener listener) {
		mainViewListener = listener;
1353e182   Nathanael Jourdane   Add minimal eleme...
78
79
80
81
82
	}

	/**
	 * @return The JPanel where the VOTable results is displayed.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
83
84
	public ResultsPanel getResultsPanel() {
		return resultsPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
85
86
87
	}

	/**
0b616d80   Nathanael Jourdane   Updtate the query...
88
89
	 * @return The JPanel where the GUI elements to make the request are displayed.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
90
91
	public RequestPanel getRequestPanel() {
		return requestPanel;
0b616d80   Nathanael Jourdane   Updtate the query...
92
93
94
	}

	/**
1353e182   Nathanael Jourdane   Add minimal eleme...
95
96
	 * @return The JPanel where the list of services is displayed.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
97
98
	public ServicesPanel getServicesPanel() {
		return servicesPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
99
100
101
	}

	/**
c57c07b1   Nathanael Jourdane   Add the bottom ba...
102
103
	 * @return The JPanel where the list of services is displayed.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
104
105
	public BottomBarPanel getBottomBarPanel() {
		return bottomBarPanel;
c57c07b1   Nathanael Jourdane   Add the bottom ba...
106
107
108
	}

	/**
1353e182   Nathanael Jourdane   Add minimal eleme...
109
110
111
	 * Build and fill the GUI.
	 */
	public void buildWindow() {
5af53be7   Nathanael Jourdane   Make the applicat...
112
113
		JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel,
				requestPanel);
5576be01   Nathanael Jourdane   Make panels resiz...
114

204e830a   Nathanael Jourdane   Add query paramet...
115
		// TODO: put requestView inside a JScrollPane.
5576be01   Nathanael Jourdane   Make panels resiz...
116

5af53be7   Nathanael Jourdane   Make the applicat...
117
		JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel);
5576be01   Nathanael Jourdane   Make panels resiz...
118
		add(mainPanel, BorderLayout.CENTER);
5af53be7   Nathanael Jourdane   Make the applicat...
119
		add(bottomBarPanel, BorderLayout.SOUTH);
1353e182   Nathanael Jourdane   Add minimal eleme...
120
121
122
123
124
125
126
127
128
	}

	/**
	 * Display an error.
	 *
	 * @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...
129
130
		JOptionPane.showMessageDialog(this, message, title,
				JOptionPane.ERROR_MESSAGE);
1353e182   Nathanael Jourdane   Add minimal eleme...
131
132
	}

5af53be7   Nathanael Jourdane   Make the applicat...
133
134
135
136
	public void event(Event event, Object... args) {
		mainViewListener.event(event, args);
	}

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