/* * This file is part of the Remote Sensor Actuator Interface (ReSAI). * * Copyright(c) Andreas Kipp, Frederic Siepmann * http://opensource.cit-ec.de/projects/resai * * This file may be licensed under the terms of of the * GNU Lesser General Public License Version 3 (the ``LGPL''), * or (at your option) any later version. * * Software distributed under the License is distributed * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the LGPL for the specific language * governing rights and limitations. * * You should have received a copy of the LGPL along with this * program. If not, go to http://www.gnu.org/licenses/lgpl.html * or write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The development of this software was supported by the * Excellence Cluster EXC 277 Cognitive Interaction Technology. * The Excellence Cluster EXC 277 is a grant of the Deutsche * Forschungsgemeinschaft (DFG) in the context of the German * Excellence Initiative. * */ /** * Overview GUI. * * @author akipp */ package de.unibi.airobots.resaijavaclient.gui; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.util.Observable; import java.util.Observer; import javax.swing.BoxLayout; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import de.unibi.airobots.resaijavaclient.communicaton.Communicator; import de.unibi.airobots.resaijavaclient.constants.Constants; import de.unibi.airobots.resaijavaclient.gui.panels.BeaconPanel; import de.unibi.airobots.resaijavaclient.gui.panels.ComponentPanel; import de.unibi.airobots.resaijavaclient.gui.panels.ErrorPanel; import de.unibi.airobots.resaijavaclient.gui.panels.LogoutPanel; import de.unibi.airobots.resaijavaclient.gui.panels.StatusPanel; public class Overview extends Observable implements Observer, WindowListener { private JFrame overview = new JFrame("Overview"); private Communicator com; private BeaconPanel beaconPanel; private LogoutPanel logoutPanel; private ErrorPanel ep; private ComponentPanel cp; private TabHolder tabHolder = new TabHolder(); private StatusPanel statusPanel = new StatusPanel(); public Overview(Communicator communicator) { com = communicator; com.addObserver(this); beaconPanel = new BeaconPanel(com); ep = new ErrorPanel(com); cp = new ComponentPanel(com); logoutPanel = new LogoutPanel(com); tabHolder.add("Status", statusPanel); com.addObserver(beaconPanel); com.addObserver(statusPanel); // CREATE GUI Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); JPanel statusPane = new JPanel(); statusPane.setLayout(new BoxLayout(statusPane, BoxLayout.LINE_AXIS)); statusPane.add(cp); statusPane.add(ep); JPanel lowerPane = new JPanel(); lowerPane.setLayout(new BoxLayout(lowerPane, BoxLayout.LINE_AXIS)); lowerPane.add(beaconPanel, BorderLayout.SOUTH); lowerPane.add(logoutPanel, BorderLayout.SOUTH); Container pane = overview.getContentPane(); pane.setLayout(new BoxLayout(pane, BoxLayout.PAGE_AXIS)); pane.add(tabHolder, BorderLayout.CENTER); pane.add(statusPane, BorderLayout.CENTER); pane.add(lowerPane, BorderLayout.SOUTH); overview.addWindowListener(this); //overview.setMinimumSize(new Dimension(1024, 800)); overview.pack(); overview.setLocation((int) dim.getWidth() / 2 - overview.getSize().width / 2, (int) dim.getHeight() / 2 - overview.getSize().height / 2); overview.setVisible(true); overview.setDefaultCloseOperation( JDialog.DO_NOTHING_ON_CLOSE); } private int logout() { if (JOptionPane.showConfirmDialog(null, "Disconnect from ReSAI?", "Logout", JOptionPane.OK_CANCEL_OPTION) == 0) { setChanged(); notifyObservers(Constants.DISCONNECT); System.exit(0); } return -1; } @Override public void update(Observable o, Object arg) { } public TabHolder getTabHolder() { return tabHolder; } @Override public void windowOpened(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowClosing(WindowEvent e) { logout(); } @Override public void windowClosed(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowIconified(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowDeiconified(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowActivated(WindowEvent e) { // TODO Auto-generated method stub } @Override public void windowDeactivated(WindowEvent e) { // TODO Auto-generated method stub } }