Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool CreateSpaceActionListener.java, 1.11,
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Nikolaj B. <nbr...@us...> - 2006-11-16 23:19:33
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21296/src/net/sourceforge/bprocessor/gl/tool Modified Files: CreateSpaceActionListener.java Log Message: Name is now almost gone from spaces, both functional and construction are giving classification when created. And fixed and improved some things with the classification. Index: CreateSpaceActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/CreateSpaceActionListener.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CreateSpaceActionListener.java 14 Oct 2006 23:40:49 -0000 1.11 --- CreateSpaceActionListener.java 16 Nov 2006 23:19:32 -0000 1.12 *************** *** 8,19 **** import net.sourceforge.bprocessor.gui.GUI; ! import javax.swing.JOptionPane; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ! import java.util.Iterator; ! import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Surface; --- 8,25 ---- import net.sourceforge.bprocessor.gui.GUI; + import net.sourceforge.bprocessor.gui.attrview.ClassificationTextAttribute; ! import javax.swing.Box; ! import javax.swing.JButton; ! import javax.swing.JDialog; + import java.awt.Component; + import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ! import java.awt.event.MouseEvent; ! import java.awt.event.MouseListener; + import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Surface; *************** *** 25,29 **** * The create functional space action listener for the domain popupmenu. */ ! public class CreateSpaceActionListener implements ActionListener { /** The logger */ private static Logger log = Logger.getLogger(CreateSpaceActionListener.class); --- 31,35 ---- * The create functional space action listener for the domain popupmenu. */ ! public class CreateSpaceActionListener implements ActionListener, MouseListener { /** The logger */ private static Logger log = Logger.getLogger(CreateSpaceActionListener.class); *************** *** 41,44 **** --- 47,56 ---- private String category; + /** The classification attribute */ + private ClassificationTextAttribute cta; + + /** The dialog window */ + private JDialog dialog; + /** * CreateSpaceActionListener *************** *** 71,141 **** } if (functional) { ! result = JOptionPane.showInputDialog(GUI.getInstance(), ! "Name", ! "Create Functional " + category, ! JOptionPane.QUESTION_MESSAGE); ! } else { ! result = JOptionPane.showInputDialog(GUI.getInstance(), ! "Name", ! "Create Construction " + category, ! JOptionPane.QUESTION_MESSAGE); } if (log.isDebugEnabled()) { log.debug("Input: " + result); } ! Space owner = surface.getOwner(); - if (result != null && !result.trim().equals("")) { - try { - Space space; - if (functional) { - space = owner.createFunctionalSpace(result.trim()); - } else { - space = owner.createConstructionSpace(result.trim()); - } - owner.add(space); - if (front) { - surface.setFrontDomain(space); - } else { - surface.setBackDomain(space); - } - surface.changed(); - Project.getInstance().checkpoint(); - } catch (Exception ex) { - ex.printStackTrace(); - } - } } /** ! * checkName checks if the name entered is not used ! * @param result the name to check for uniqueness ! * @return res a unique and verified name */ ! private String checkName(String result) { ! String res = result; ! boolean used = false; ! Iterator it = Project.getInstance().getSpaces().iterator(); ! while (it.hasNext()) { ! Space current = (Space) it.next(); ! if (current.getName().equals(result)) { ! res = JOptionPane.showInputDialog(GUI.getInstance(), ! "Please enter a unique name", ! "Create Functional " + category, ! JOptionPane.QUESTION_MESSAGE); ! used = true; ! } ! } ! if (used) { ! res = checkName(res); ! } ! return res; } ! } --- 83,212 ---- } + + result = ""; if (functional) { ! dialog = new JDialog(GUI.getInstance(), "Create Functional Space", true); ! cta = new ClassificationTextAttribute( ! new Attribute("Classification", Project.getInstance().getFunctionalClas(), null, 1)); } else { ! dialog = new JDialog(GUI.getInstance(), "Create Construction Space", true); ! cta = new ClassificationTextAttribute( ! new Attribute("Classification", Project.getInstance().getConstructionClas(), null, 1)); } + Container dialogContent = dialog.getContentPane(); + cta.addMouseListener(this); + Box content = Box.createVerticalBox(); + Box fr = Box.createHorizontalBox(); + Box sr = Box.createHorizontalBox(); + fr.add(cta); + JButton ok = new JButton("Ok"); + ok.addActionListener(new MyActionListener()); + JButton cancel = new JButton("Cancel"); + cancel.addActionListener(new MyActionListener()); + sr.add(ok); + sr.add(cancel); + content.add(fr); + content.add(sr); + dialogContent.add(content); + dialog.setSize(200, 80); + dialog.setLocationRelativeTo((Component)e.getSource()); + dialog.show(); + if (log.isDebugEnabled()) { log.debug("Input: " + result); } + } + + /** + * Start editing + * @param event The MouseEvent + */ + public void mouseClicked(MouseEvent event) { + cta.startEditing(); ! } ! ! ! /** ! * Not in use ! * @param event The MouseEvent ! */ ! public void mouseEntered(MouseEvent event) { ! // TODO Auto-generated method stub } /** ! * Not in use ! * @param event The MouseEvent */ ! public void mouseExited(MouseEvent event) { ! // TODO Auto-generated method stub ! } + /** + * Not in use + * @param event The MouseEvent + */ + public void mousePressed(MouseEvent event) { + // TODO Auto-generated method stub + + } + /** + * Not in use + * @param event The MouseEvent + */ + public void mouseReleased(MouseEvent event) { + // TODO Auto-generated method stub + + } ! /** ! * My action listener ! */ ! class MyActionListener implements ActionListener { ! ! /** ! * the action performed event handling ! * @param e is the action event ! */ ! public void actionPerformed(ActionEvent e) { ! String name = ((JButton) e.getSource()).getLabel(); ! if (name.equalsIgnoreCase("Ok")) { ! if (cta.attribute().getClassification() != null) { ! Space owner = surface.getOwner(); ! ! if (cta.attribute().getClassification() != null) { ! try { ! Space space; ! if (functional) { ! space = owner.createFunctionalSpace(cta.attribute().getClassification()); ! } else { ! space = owner.createConstructionSpace(cta.attribute().getClassification()); ! } ! owner.add(space); ! if (front) { ! surface.setFrontDomain(space); ! } else { ! surface.setBackDomain(space); ! } ! surface.changed(); ! Project.getInstance().checkpoint(); ! } catch (Exception ex) { ! ex.printStackTrace(); ! } ! } ! dialog.show(false); ! } ! } ! ! if (name.equalsIgnoreCase("Cancel")) { ! dialog.show(false); ! ! } ! } ! ! } } |