/*
This file is part of the software framework JStatCom,
a library for building applications for data based analysis.
Copyright (C) 2000-2005 Markus Kraetzig
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
package com.jstatcom.model;
import javax.swing.JInternalFrame;
import com.jstatcom.project.ProjectState;
import com.jstatcom.project.ProjectStateHandler;
/**
* An internal frame that can be used as top level container for modules in the
* JStatCom framework. It holds the global symbol table for all childs that are
* ModelPanel instances.
*
* @author Markus Kraetzig
*/
public class ModelFrame extends JInternalFrame implements SymbolScope,
ProjectStateHandler {
private SymbolTable symbolTable = null;
/**
* Creates an internal frame wit a null title.
*/
public ModelFrame() {
this(null);
}
/**
* Creates an internal frame with a given title.
*
* @param title
* of the frame
*/
public ModelFrame(String title) {
super(title, true, true, true, true);
setSize(400, 300);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
/*
* addInternalFrameListener(new InternalFrameAdapter() { public void
* internalFrameClosing(InternalFrameEvent e) { int option =
* JOptionPane.showConfirmDialog( TopFrameReference.getTopFrameRef(),
* "Dispose internal frame \"" + getTitle() + "\"?", "Dispose?",
* JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
*
* if (option != JOptionPane.YES_OPTION)
* setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); else
* setDefaultCloseOperation(DISPOSE_ON_CLOSE); } });
*/
}
/**
* Gets the global symbol table for this internal frame and all child
* ModelPanel instances. The instance is created by this
* frame. The name of this symbol table is equal to getTitle.
* If the title is empty, the classname is used instead.
*
* @return a symbol table
*/
public SymbolTable global() {
if (symbolTable == null) {
String title = getTitle();
if (title == null || title.length() < 1)
title = getClass().getName();
symbolTable = new SymbolTable(title, null);
}
return symbolTable;
}
/**
* Gets the local symbol table, which is identical with the global table for
* a ModelFrame.
*
* @return a symbol table
*/
public SymbolTable local() {
return global();
}
/**
* Gets the upper symbol table, which is identical with the global table for
* a ModelFrame.
*
* @return a symbol table
*/
public SymbolTable upper() {
return global();
}
/**
* Empty default implementation that does nothing. Subclasses that take part
* in the project management system should overwrite this class.
*
* @param state
*/
public void setState(ProjectState state) {
}
/**
* Empty default implementation that returns null.
* Subclasses that take part in the project management system should
* overwrite this class.
*
* @return null
*/
public ProjectState getState() {
return null;
}
/**
* Gets the classname as the default ID.
*
* @return classname
*/
public String getID() {
return getClass().getName();
}
}
Ads help maintain this website.