Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15104
Added Files:
CreateSpaceActionListener.java
Log Message:
Moved this to no longer be inner class of selecttool
--- NEW FILE: CreateSpaceActionListener.java ---
//---------------------------------------------------------------------------------
// $Id: CreateSpaceActionListener.java,v 1.1 2005/10/27 14:59:46 nordholt Exp $
//
// Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net)
// Released under the Lesser GNU Public License v2.1
//---------------------------------------------------------------------------------
package net.sourceforge.bprocessor.gl.tool;
import net.sourceforge.bprocessor.gui.GUI;
import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import net.sourceforge.bprocessor.model.FunctionalSpace;
import net.sourceforge.bprocessor.model.ConstructionSpace;
import net.sourceforge.bprocessor.model.Domain;
import net.sourceforge.bprocessor.model.Project;
import net.sourceforge.bprocessor.model.Surface;
import net.sourceforge.bprocessor.model.Space;
import org.apache.log4j.Logger;
/**
* The create functional space action listener for the domain popupmenu.
*/
public class CreateSpaceActionListener implements ActionListener {
/** The logger */
private static Logger log = Logger.getLogger(SelectTool.class);
/** The Surface */
private Surface surface;
/** Boolean telling if this is for the front or back of the surface*/
private boolean front;
/** Boolean telling if this is for creating functional or construction spaces*/
private boolean functional;
/**
* CreateSpaceActionListener
* @param surface the surface this listener is associated with
* @param front should be true if this listener is associated with the front-side of the surface
* @param functional should be true this listener is for creating functional spaces. Otherwise
* it will be for construction spaces.
*/
public CreateSpaceActionListener(Surface surface, boolean front, boolean functional) {
this.surface = surface;
this.front = front;
this.functional = functional;
}
/**
* Action performed
* @param e The action event
*/
public void actionPerformed(ActionEvent e) {
String result;
if (functional) {
result = JOptionPane.showInputDialog(GUI.getInstance(),
"Name",
"Create Functional Space",
JOptionPane.QUESTION_MESSAGE);
} else {
result = JOptionPane.showInputDialog(GUI.getInstance(),
"Name",
"Create Construction Space",
JOptionPane.QUESTION_MESSAGE);
}
if (log.isDebugEnabled()) {
log.debug("Input: " + result);
}
if (result != null && !result.trim().equals("")) {
Space space;
if (functional) {
space = new FunctionalSpace(result.trim());
Project.getInstance().intern((FunctionalSpace)space);
} else {
space = new ConstructionSpace(result.trim());
Project.getInstance().intern((ConstructionSpace)space);
}
Domain old;
if (front) {
old = surface.getFrontDomain();
surface.setFrontDomain(space);
} else {
old = surface.getBackDomain();
surface.setBackDomain(space);
}
space.addSurface(surface);
Project.getInstance().update(space);
if (old != null) {
Project.getInstance().update(old);
}
}
}
}
|