/*
* Jacareto Copyright (c) 2002-2005
* Applied Computer Science Research Group, Darmstadt University of
* Technology, Institute of Mathematics & Computer Science,
* Ludwigsburg University of Education, and Computer Based
* Learning Research Group, Aachen University. All rights reserved.
*
* Jacareto 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 2 of the License, or (at your option) any later version.
*
* Jacareto 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 Jacareto; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
package jacareto.cleverphl.gui;
import jacareto.cleverphl.CleverPHL;
import jacareto.cleverphl.session.Session;
import jacareto.cleverphl.session.SessionEvent;
import jacareto.cleverphl.session.SessionListEvent;
import jacareto.cleverphl.session.SessionListListener;
import jacareto.cleverphl.session.SessionListener;
import jacareto.system.Language;
import java.awt.BorderLayout;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JToolBar;
/**
* The main frame of CleverPHL.
*
* @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
* @version 1.02
*/
public class CleverPHLMainFrame extends CleverPHLFrame implements WindowListener,
SessionListListener, SessionListener {
/** The sessions pane. */
private SessionPane sessionsPane;
/** The toolbar. */
private JToolBar toolBar;
/** The sidebar. */
private ManipulationToolBar manipulationToolBar;
/** Whether or not the close operation causes an exit. */
private boolean isExitOnClose;
/** The language instance. */
private Language language;
/**
* Creates a new frame.
*
* @param cleverPHL the CleverPHL instance
*/
public CleverPHLMainFrame (CleverPHL cleverPHL) {
super(cleverPHL, "CleverPHL.MainFrame", null);
language = cleverPHL.getLanguage ();
setTitle (language.getString ("CleverPHL.MainFrame.Title"));
addWindowListener (this);
createMenu ("CleverPHL.Menu.MainFrame.MenuBar");
//setLocation (0, 0);
//setToPreferredSize (850, 500);
// The sessions pane
sessionsPane = new SessionPane(cleverPHL);
// The toolbar
toolBar = new JToolBar();
createToolBar (toolBar, "CleverPHL.ToolBar.MainFrame");
// The sidebar
manipulationToolBar = new ManipulationToolBar(cleverPHL.getEnvironment (),
JToolBar.VERTICAL, getCleverPHLMenuBar ());
getContentPane ().setLayout (new BorderLayout());
getContentPane ().add (toolBar, BorderLayout.NORTH);
getContentPane ().add (sessionsPane, BorderLayout.CENTER);
getContentPane ().add (manipulationToolBar, BorderLayout.WEST);
setDefaultCloseOperation (DO_NOTHING_ON_CLOSE);
cleverPHL.getSessionList ().addSessionListListener (this);
setExitOnClose (true);
getMenuState ().setState (MenuState.NO_SESSION);
}
/**
* Specifies whether or not the closing operation causes an exit.
*
* @param isExitOnClose set to true if window should close on exit
*/
public void setExitOnClose (boolean isExitOnClose) {
this.isExitOnClose = isExitOnClose;
}
/**
* Returns the session pane.
*
* @return SessionPane
*/
public SessionPane getSessionPane () {
return sessionsPane;
}
/**
* Does nothing.
*
* @param w WindowEvent
*/
public void windowActivated (WindowEvent w) {
}
/**
* Does nothing.
*
* @param w WindowEvent
*/
public void windowClosed (WindowEvent w) {
}
/**
* Does nothing.
*
* @param w WindowEvent
*/
public void windowDeactivated (WindowEvent w) {
}
/**
* Does nothing.
*
* @param w WindowEvent
*/
public void windowDeiconified (WindowEvent w) {
}
/**
* Does nothing.
*
* @param w WindowEvent
*/
public void windowIconified (WindowEvent w) {
}
/**
* Does nothing.
*
* @param w WindowEvent
*/
public void windowOpened (WindowEvent w) {
}
/**
* Exits the system.
*
* @param w WindowEvent
*/
public void windowClosing (WindowEvent w) {
if (isExitOnClose) {
cleverPHL.exit ();
}
}
/**
* Called when the session list has changed.
*
* @param event SessionEvent
*/
public void sessionListChanged (SessionListEvent event) {
Session session = event.getSession ();
if (event.getID () == SessionListEvent.SESSION_ADDED) {
session.addSessionListener (this);
} else if (event.getID () == SessionListEvent.SESSION_REMOVED) {
session.removeSessionListener (this);
setTitle (language.getString ("CleverPHL.MainFrame.Title"));
} else if (event.getID () == SessionListEvent.NEW_ACTUAL_SESSION) {
setTitle (language.getString ("CleverPHL.MainFrame.Title") + " - [" +
session.getName () + "]");
manipulationToolBar.setManipulationManagement (session.getManipulationManagement ());
}
}
/**
* Called when a session has been changed.
*
* @param event SessionEvent
*/
public void sessionStateChanged (SessionEvent event) {
Session session = event.getSession ();
switch (event.getID ()) {
case SessionEvent.NAME_CHANGED:
setTitle (language.getString ("CleverPHL.MainFrame.Title") + " - [" +
session.getName () + "]");
break;
}
}
}
|