Diff for /FM2SQL/Attic/TableComponent.java between versions 1.1 and 1.5

version 1.1, 2003/12/05 11:46:39 version 1.5, 2004/03/23 11:57:06
Line 1 Line 1
   /*
    * TableComponent.java -- GUI Table class
    * Filemake to SQL Converter 
    * Copyright (C) 2004 Robert Gordesch (rogo@mpiwg-berlin.mpg.de
    * This program 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.  Please read license.txt for the full details. A copy of
    * the GPL may be found at http://www.gnu.org/copyleft/lgpl.html  You should
    * have received a copy of the GNU General Public License along with this
    * program; if not, write to the Free Software Foundation, Inc., 59 Temple
    * Place, Suite 330, Boston, MA 02111-1307 USA  Created on 15.09.2003 by
    * rogo  
    */
 import javax.swing.*;  import javax.swing.*;
 import java.awt.event.*;  import java.awt.event.*;
   
Line 151  public class TableComponent extends JPan Line 165  public class TableComponent extends JPan
             {              {
         tableComp.row=row;          tableComp.row=row;
         boolean value=false;          boolean value=false;
                 if(getColumnClass(column)==ArrayList.class||getColumnClass(column)==JComboBox.class||getColumnClass(column)== SQLCommand.class)           if (getColumnClass(column) == ArrayList.class || getColumnClass(column) == JComboBox.class || getColumnClass(column) == SQLCommand.class || getColumnClass(column) == IDComboBox.class)
                 value=true;                  value=true;
                 //System.out.println("tried to edit at row "+row+" column "+column+" "+value);                   //System.out.println("tried to edit at row "+row+" column "+column+" "+value); 
                                                                                                                           
Line 334  public class TableComponent extends JPan Line 348  public class TableComponent extends JPan
   }    }
   public void sizeToFit(int windowWidth, int windowHeight)    public void sizeToFit(int windowWidth, int windowHeight)
   {    {
     table.setAutoResizeMode(table.AUTO_RESIZE_LAST_COLUMN);      //table.setAutoResizeMode(table.AUTO_RESIZE_LAST_COLUMN);
   
     TableColumnModel model = table.getColumnModel();      TableColumnModel model = table.getColumnModel();
     Dimension d2 = getPreferredSize();      Dimension d2 = getPreferredSize();
Line 393  public class TableComponent extends JPan Line 407  public class TableComponent extends JPan
             //tableModel.fireTableCellUpdated(row,column);              //tableModel.fireTableCellUpdated(row,column);
              if(box.getModel().getSize()>0)               if(box.getModel().getSize()>0)
              return boxValue;               return boxValue;
          else return null;        else
           return null;
           
          }           }
   
          public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)           public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
          {           {
             boxValue = (value != null) ? (JComboBox) value : null;              boxValue = (value != null) ? (JComboBox) value : null;
             this.row=row;this.column=column;        this.row = row;
       if(boxValue!=null) box.setModel(boxValue.getModel());        this.column = column;
       else return null;        if (boxValue != null)
           box.setModel(boxValue.getModel());
         else
           return null;
         return box;          return box;
          }           }
   
Line 478  public class TableComponent extends JPan Line 496  public class TableComponent extends JPan
       CellEditorListener listener=table;        CellEditorListener listener=table;
       JLabel label = new JLabel();        JLabel label = new JLabel();
       int x=0,y=0;        int x=0,y=0;
       String copy="";boolean removeCalled=true;      String copy = "";
       boolean removeCalled = true;
       public SQLCommandEditor()        public SQLCommandEditor()
       {        {
    //     super(new JCheckBox());     //     super(new JCheckBox());
         //this.list = list;          //this.list = list;
         editor.getDocument().addDocumentListener(new DocumentListener() {        editor.getDocument().addDocumentListener(new DocumentListener()
         {
   
         public void insertUpdate(DocumentEvent e)          public void insertUpdate(DocumentEvent e)
         {          {
Line 512  public class TableComponent extends JPan Line 532  public class TableComponent extends JPan
         }          }
               
       });        });
       table.addMouseListener(new MouseAdapter() {        table.addMouseListener(new MouseAdapter()
         {
       public void mouseEntered(MouseEvent e)         public void mouseEntered(MouseEvent e) 
       {        {
         if(true) return;            if (true)
               return;
         //System.out.println(e);          //System.out.println(e);
         x = e.getX();          x = e.getX();
         y = e.getY();          y = e.getY();
Line 525  public class TableComponent extends JPan Line 547  public class TableComponent extends JPan
                   
         if(window!=null)          if(window!=null)
         {          {
         if(!window.isVisible()) return;              if (!window.isVisible())
                 return;
                     
         }else return;            } else
               return;
         if(row!=table.getEditingRow()||col!=table.getEditingColumn())          if(row!=table.getEditingRow()||col!=table.getEditingColumn())
         if (listener != null)          if (listener != null)
         {                  {        
Line 543  public class TableComponent extends JPan Line 567  public class TableComponent extends JPan
             y = e.getY();              y = e.getY();
                           
             if(window!=null)              if(window!=null)
             if(!window.isVisible()) return;              if (!window.isVisible())
                 return;
           
             int row = table.rowAtPoint(new Point(x,y));              int row = table.rowAtPoint(new Point(x,y));
             int col = table.columnAtPoint(new Point(x,y));              int col = table.columnAtPoint(new Point(x,y));
Line 556  public class TableComponent extends JPan Line 581  public class TableComponent extends JPan
             }              }
           }            }
           
       public void mouseExited(MouseEvent e) {          public void mouseExited(MouseEvent e)
           {
       //  System.out.println(e);        //  System.out.println(e);
             
       }        }
Line 600  public class TableComponent extends JPan Line 626  public class TableComponent extends JPan
  //      if(label.isShowing())   //      if(label.isShowing())
  //      System.out.println( label.getLocationOnScreen());   //      System.out.println( label.getLocationOnScreen());
           
   
       Dimension dimEditor = editor.getPreferredSize();        Dimension dimEditor = editor.getPreferredSize();
       if (dimEditor.width < 260)        if (dimEditor.width < 260)
         dimEditor.width = 260;          dimEditor.width = 260;
       window.setSize((dimEditor.width < 280) ? dimEditor.width + 20 : 280, (dimEditor.height > 50) ? 200 : 60);        window.setSize((dimEditor.width < 280) ? dimEditor.width + 20 : 280, (dimEditor.height > 50) ? 200 : 70);
       TableColumnModel model = table.getColumnModel();        TableColumnModel model = table.getColumnModel();
       int offset_x = 0, offset_y = 0;        int offset_x = 0, offset_y = 0;
       for (int i = 0; i <= column; ++i)        for (int i = 0; i <= column; ++i)
Line 679  public class TableComponent extends JPan Line 704  public class TableComponent extends JPan
       
     }      }
   
   
   class ArrayListEditor implements TableCellEditor    class ArrayListEditor implements TableCellEditor
   {    {
     JList list = new JList();      JList list = new JList();
Line 693  public class TableComponent extends JPan Line 717  public class TableComponent extends JPan
     {      {
  //     super(new JCheckBox());   //     super(new JCheckBox());
       //this.list = list;        //this.list = list;
       table.addMouseListener(new MouseAdapter() {        table.addMouseListener(new MouseAdapter()
         {
          public void mouseEntered(MouseEvent e)            public void mouseEntered(MouseEvent e) 
          {           {
           // if(true) return;            // if(true) return;
Line 706  public class TableComponent extends JPan Line 731  public class TableComponent extends JPan
                   
            if(window!=null)             if(window!=null)
            {             {
              if(!window.isVisible()) return;              if (!window.isVisible())
                 return;
                           
            } else return;            } else
               return;
                       
            if(row!=table.getEditingRow()||col!=table.getEditingColumn())             if(row!=table.getEditingRow()||col!=table.getEditingColumn())
            if (listener != null)             if (listener != null)
Line 725  public class TableComponent extends JPan Line 752  public class TableComponent extends JPan
                y = e.getY();                 y = e.getY();
                           
                if(window!=null)                 if(window!=null)
                if(!window.isVisible()) return;              if (!window.isVisible())
                 return;
           
                int row = table.rowAtPoint(new Point(x,y));                 int row = table.rowAtPoint(new Point(x,y));
                int col = table.columnAtPoint(new Point(x,y));                 int col = table.columnAtPoint(new Point(x,y));
Line 738  public class TableComponent extends JPan Line 766  public class TableComponent extends JPan
                }                 }
              }               }
           
          public void mouseExited(MouseEvent e) {          public void mouseExited(MouseEvent e)
           {
          //  System.out.println(e);           //  System.out.println(e);
             
          }           }
Line 794  public class TableComponent extends JPan Line 823  public class TableComponent extends JPan
     //      if(label.isShowing())      //      if(label.isShowing())
     //      System.out.println( label.getLocationOnScreen());      //      System.out.println( label.getLocationOnScreen());
           
   
         Dimension dimEditor = pane.getPreferredSize();          Dimension dimEditor = pane.getPreferredSize();
         window.setSize((dimEditor.width<250) ? dimEditor.width+20:250,(dimEditor.height>50) ? 200:50);          window.setSize((dimEditor.width<250) ? dimEditor.width+20:250,(dimEditor.height>50) ? 200:50);
         TableColumnModel model = table.getColumnModel();          TableColumnModel model = table.getColumnModel();
Line 872  public class TableComponent extends JPan Line 900  public class TableComponent extends JPan
     JLabel label = new JLabel();      JLabel label = new JLabel();
     DefaultListModel model=new DefaultListModel();      DefaultListModel model=new DefaultListModel();
      JScrollPane listScroller=new JScrollPane(list);       JScrollPane listScroller=new JScrollPane(list);
       Color noIDColor=new Color(50,50,200);
         
     public VectorCellRenderer()      public VectorCellRenderer()
     {      {
Line 883  public class TableComponent extends JPan Line 912  public class TableComponent extends JPan
     public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)      public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
     {      {
             box = (JComboBox) value ;              box = (JComboBox) value ;
             if(box==null) return null;//label.setText("");        if (box == null)
             else          return null; //label.setText("");
             if(box.getSelectedItem()!=null)        else if (box.getSelectedItem() != null)
             {              {
             String text=box.getSelectedItem().toString();              String text=box.getSelectedItem().toString();
             if(text=="")              if(text=="")
             {               { 
             if (box instanceof IDComboBox)
             {
               text = "\"no  ID\"";
               label.setForeground(noIDColor);
             } else
             {
                 text="\"no Layout\"";                  text="\"no Layout\"";
               label.setForeground(Color.red);                label.setForeground(Color.red);
             }
           } else
           {
             if (box instanceof IDComboBox)
               label.setForeground(Color.darkGray);
                               
             }else  label.setForeground(Color.blue);             else
               label.setForeground(Color.blue);
           }
             label.setText(text);              label.setText(text);
   
             }        } else
       else label.setText("");          label.setText("");
         return label;          return label;
     }      }
   
Line 1072  return label; Line 1114  return label;
       return command;        return command;
     }      }
   }    }
     public static class IDComboBox extends JComboBox
     {
       public IDComboBox(Vector vec)
       {
         super(vec);
       }
   
 }  }
   
   }
   

Removed from v.1.1  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>