Subversion Repositories wimsdev

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.     Sketch Elements: Chemistry molecular diagram drawing tool.
  3.    
  4.     (c) 2008 Dr. Alex M. Clark
  5.    
  6.     Released as GNUware, under the Gnu Public License (GPL)
  7.    
  8.     See www.gnu.org for details.
  9. */
  10.  
  11. package WIMSchem.ds;
  12.  
  13. import WIMSchem.*;
  14.  
  15. import java.util.*;
  16. import java.awt.*;
  17. import java.awt.event.*;
  18. import javax.swing.*;
  19. import javax.swing.table.*;
  20. import javax.swing.event.*;
  21.  
  22. /*
  23.     Editor window for the molecule contained within a datasheet cell
  24. */
  25.  
  26. public class EditWindow extends JFrame implements SaveListener, WindowListener, CellEditorListener
  27. {
  28.     private MainPanel mainPanel;
  29.     private DataTableModel model;
  30.     private TableMoleculeEditor edcell;
  31.    
  32.     private boolean hardkill=false;
  33.  
  34.     public EditWindow(Molecule mol,DataTableModel model,TableMoleculeEditor edcell)
  35.     {
  36.         super("WIMSchem - Cell Edit");
  37.         this.model=model;
  38.         this.edcell=edcell;
  39.  
  40.         setFocusableWindowState(true);
  41.  
  42.         // application
  43.        
  44.         JFrame.setDefaultLookAndFeelDecorated(false);
  45.         setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  46.  
  47.         // main panel
  48.  
  49.         mainPanel=new MainPanel(null,MainPanel.MODE_SLAVE,this);
  50.         mainPanel.setMolecule(mol);
  51.         mainPanel.setSaveListener(this);
  52.  
  53.         getContentPane().setLayout(new BorderLayout());
  54.         getContentPane().add(mainPanel,BorderLayout.CENTER);
  55.         pack();
  56.  
  57.         setIconImage(mainPanel.mainIcon.getImage());
  58.        
  59.         addWindowListener(this);
  60.     }
  61.    
  62.     public void saveMolecule(Molecule mol)
  63.     {
  64.         edcell.setMolecule(mainPanel.molData().clone());
  65.     }    
  66.  
  67.     public void editingCanceled(ChangeEvent e)
  68.     {
  69.         hardkill=true;
  70.         dispose();
  71.     }
  72.     public void editingStopped(ChangeEvent e)
  73.     {
  74.         hardkill=true;
  75.         dispose();
  76.     }
  77.  
  78.     public void windowActivated(WindowEvent e) {}
  79.     public void windowClosed(WindowEvent e)
  80.     {
  81.         if (!hardkill)
  82.         {
  83.             edcell.stopCellEditing();
  84.         }
  85.     }
  86.     public void windowClosing(WindowEvent e) {}
  87.     public void windowDeactivated(WindowEvent e) {}
  88.     public void windowDeiconified(WindowEvent e) {}
  89.     public void windowIconified(WindowEvent e) {}
  90.     public void windowOpened(WindowEvent e) {}
  91. }
  92.