Blame view

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

6b021d84   Nathanael Jourdane   VOTable view can ...
26
import eu.omp.irap.vespa.epntapclient.controller.EpnTapController;
5af53be7   Nathanael Jourdane   Make the applicat...
27
28
29
30
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...
31
32
33
34
35
36
import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;

/**
 * @author N. Jourdane
 */
public class EpnTapMainView extends JPanel {
5d3c344e   Nathanael Jourdane   Use Java logging ...
37
38
	/** The logger for the class EpnTapMainView. */
	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;

5af53be7   Nathanael Jourdane   Make the applicat...
43
44
45
	/** The main EPN-TAP main controller */
	private EpnTapController controller;

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

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

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

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

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

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

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

	public EpnTapMainView(final EpnTapController controller, VOTableView voTableServicesView,
			VOTableView voTableResultsView) {
4cc84b63   Nathanael Jourdane   Add the possibili...
72
		this.controller = controller;
1353e182   Nathanael Jourdane   Add minimal eleme...
73

5af53be7   Nathanael Jourdane   Make the applicat...
74
75
76
77
		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...
78
		setLayout(new BorderLayout());
43c14591   Nathanael Jourdane   View: Add methods...
79
		buildWindow();
43c14591   Nathanael Jourdane   View: Add methods...
80
	}
1353e182   Nathanael Jourdane   Add minimal eleme...
81

5af53be7   Nathanael Jourdane   Make the applicat...
82
83
	public void addMainViewListener(MainViewListener listener) {
		mainViewListener = listener;
1353e182   Nathanael Jourdane   Add minimal eleme...
84
85
86
87
88
	}

	/**
	 * @return The JPanel where the VOTable results is displayed.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
89
90
	public ResultsPanel getResultsPanel() {
		return resultsPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
91
92
93
	}

	/**
0b616d80   Nathanael Jourdane   Updtate the query...
94
95
	 * @return The JPanel where the GUI elements to make the request are displayed.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
96
97
	public RequestPanel getRequestPanel() {
		return requestPanel;
0b616d80   Nathanael Jourdane   Updtate the query...
98
99
100
	}

	/**
1353e182   Nathanael Jourdane   Add minimal eleme...
101
102
	 * @return The JPanel where the list of services is displayed.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
103
104
	public ServicesPanel getServicesPanel() {
		return servicesPanel;
1353e182   Nathanael Jourdane   Add minimal eleme...
105
106
107
	}

	/**
c57c07b1   Nathanael Jourdane   Add the bottom ba...
108
109
	 * @return The JPanel where the list of services is displayed.
	 */
5af53be7   Nathanael Jourdane   Make the applicat...
110
111
	public BottomBarPanel getBottomBarPanel() {
		return bottomBarPanel;
c57c07b1   Nathanael Jourdane   Add the bottom ba...
112
113
114
	}

	/**
1353e182   Nathanael Jourdane   Add minimal eleme...
115
116
117
	 * Build and fill the GUI.
	 */
	public void buildWindow() {
5af53be7   Nathanael Jourdane   Make the applicat...
118
119
		JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel,
				requestPanel);
5576be01   Nathanael Jourdane   Make panels resiz...
120

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

5af53be7   Nathanael Jourdane   Make the applicat...
123
		JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel);
5576be01   Nathanael Jourdane   Make panels resiz...
124
		add(mainPanel, BorderLayout.CENTER);
5af53be7   Nathanael Jourdane   Make the applicat...
125
		add(bottomBarPanel, BorderLayout.SOUTH);
1353e182   Nathanael Jourdane   Add minimal eleme...
126
127
128
129
130
131
132
133
134
	}

	/**
	 * 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...
135
136
		JOptionPane.showMessageDialog(this, message, title,
				JOptionPane.ERROR_MESSAGE);
1353e182   Nathanael Jourdane   Add minimal eleme...
137
138
	}

5af53be7   Nathanael Jourdane   Make the applicat...
139
140
141
142
	public void event(Event event, Object... args) {
		mainViewListener.event(event, args);
	}

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