/[classpath]/classpath/javax/swing/DefaultCellEditor.java
ViewVC logotype

Diff of /classpath/javax/swing/DefaultCellEditor.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4.2.3 by gnu_andrew, Tue Aug 2 20:12:36 2005 UTC revision 1.4.2.4 by gnu_andrew, Tue Aug 16 16:22:38 2005 UTC
# Line 43  import java.awt.event.ActionEvent; Line 43  import java.awt.event.ActionEvent;
43  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
44  import java.awt.event.ItemEvent;  import java.awt.event.ItemEvent;
45  import java.awt.event.ItemListener;  import java.awt.event.ItemListener;
46    import java.awt.event.MouseEvent;
47  import java.io.Serializable;  import java.io.Serializable;
48  import java.util.EventObject;  import java.util.EventObject;
49    
50    import javax.swing.JTable;
51    import javax.swing.JTextField;
52    import javax.swing.event.CellEditorListener;
53  import javax.swing.table.TableCellEditor;  import javax.swing.table.TableCellEditor;
54  import javax.swing.tree.TreeCellEditor;  import javax.swing.tree.TreeCellEditor;
55    
# Line 91  public class DefaultCellEditor Line 95  public class DefaultCellEditor
95       *       *
96       * @param event TODO       * @param event TODO
97       */       */
98      public void setValue(Object event)      public void setValue(Object value)
99      {      {
100          // TODO: should be setting the value in the editorComp
101          this.value = value;
102      }      }
103    
104     /**     /**
# Line 102  public class DefaultCellEditor Line 108  public class DefaultCellEditor
108       */       */
109      public Object getCellEditorValue()      public Object getCellEditorValue()
110      {      {
111        return null; // TODO        // TODO: should be getting the updated value from the editorComp
112          return value;
113      } // getCellEditorValue()      } // getCellEditorValue()
114    
115      /**      /**
# Line 114  public class DefaultCellEditor Line 121  public class DefaultCellEditor
121       */       */
122      public boolean isCellEditable(EventObject event)      public boolean isCellEditable(EventObject event)
123      {      {
124        return false; // TODO        if (!(event instanceof MouseEvent))
125            return true;
126    
127          //Todo: if the right number of clicks has occured, return true;
128          return false;
129      } // isCellEditable()      } // isCellEditable()
130    
131      /**      /**
# Line 126  public class DefaultCellEditor Line 137  public class DefaultCellEditor
137       */       */
138      public boolean shouldSelectCell(EventObject event)      public boolean shouldSelectCell(EventObject event)
139      {      {
140        return false; // TODO        // return true to indicate that the editing cell may be selected
141          return true;
142      } // shouldSelectCell()      } // shouldSelectCell()
143    
144      /**      /**
# Line 136  public class DefaultCellEditor Line 148  public class DefaultCellEditor
148       */       */
149      public boolean stopCellEditing()      public boolean stopCellEditing()
150      {      {
151        return false; // TODO        fireEditingStopped();
152          return true;
153      } // stopCellEditing()      } // stopCellEditing()
154    
155      /**      /**
# Line 144  public class DefaultCellEditor Line 157  public class DefaultCellEditor
157       */       */
158      public void cancelCellEditing()      public void cancelCellEditing()
159      {      {
160        // TODO        fireEditingCanceled();
161      } // cancelCellEditing()      } // cancelCellEditing()
162    
163      /**      /**
# Line 156  public class DefaultCellEditor Line 169  public class DefaultCellEditor
169       */       */
170      public boolean startCellEditing(EventObject event)      public boolean startCellEditing(EventObject event)
171      {      {
172        return false; // TODO        // return true to indicate that editing has begun
173          return true;
174      } // startCellEditing()      } // startCellEditing()
175    
176      /**      /**
# Line 166  public class DefaultCellEditor Line 180  public class DefaultCellEditor
180       */       */
181      public void actionPerformed(ActionEvent event)      public void actionPerformed(ActionEvent event)
182      {      {
183        // TODO        stopCellEditing();
184      } // actionPerformed()      } // actionPerformed()
185    
186      /**      /**
# Line 176  public class DefaultCellEditor Line 190  public class DefaultCellEditor
190       */       */
191      public void itemStateChanged(ItemEvent event)      public void itemStateChanged(ItemEvent event)
192      {      {
193        // TODO        stopCellEditing();
194      } // itemStateChanged()      } // itemStateChanged()
195    
196        void fireEditingStopped()
197        {
198          CellEditorListener[] listeners = getCellEditorListeners();
199          for (int index = 0; index < listeners.length; index++)
200            listeners[index].editingStopped(changeEvent);
201          
202        }
203        
204        void fireEditingCanceled()
205        {
206          CellEditorListener[] listeners = getCellEditorListeners();
207          for (int index = 0; index < listeners.length; index++)
208            listeners[index].editingCanceled(changeEvent);
209        }
210    } // EditorDelegate    } // EditorDelegate
211    
212          /**          /**
# Line 203  public class DefaultCellEditor Line 231  public class DefaultCellEditor
231     */     */
232    public DefaultCellEditor(JTextField textfield)    public DefaultCellEditor(JTextField textfield)
233    {    {
234      // TODO      editorComponent = textfield;
235        clickCountToStart = 2;
236    } // DefaultCellEditor()    } // DefaultCellEditor()
237    
238    /**    /**
# Line 213  public class DefaultCellEditor Line 242  public class DefaultCellEditor
242     */     */
243    public DefaultCellEditor(JCheckBox checkbox)    public DefaultCellEditor(JCheckBox checkbox)
244    {    {
245      // TODO      editorComponent = checkbox;
246        clickCountToStart = 1;
247    } // DefaultCellEditor()    } // DefaultCellEditor()
248    
249    /**    /**
# Line 223  public class DefaultCellEditor Line 253  public class DefaultCellEditor
253     */     */
254    public DefaultCellEditor(JComboBox combobox)    public DefaultCellEditor(JComboBox combobox)
255    {    {
256      // TODO      editorComponent = combobox;
257        clickCountToStart = 1;
258    } // DefaultCellEditor()    } // DefaultCellEditor()
259    
260    /**    /**
# Line 233  public class DefaultCellEditor Line 264  public class DefaultCellEditor
264     */     */
265    public Component getComponent()    public Component getComponent()
266    {    {
267      return null; // TODO      return editorComponent;
268    } // getComponent()    } // getComponent()
269    
270    /**    /**
# Line 243  public class DefaultCellEditor Line 274  public class DefaultCellEditor
274     */     */
275    public int getClickCountToStart()    public int getClickCountToStart()
276    {    {
277      return 0; // TODO      return clickCountToStart;
278    } // getClickCountToStart()    } // getClickCountToStart()
279    
280    /**    /**
# Line 253  public class DefaultCellEditor Line 284  public class DefaultCellEditor
284     */     */
285    public void setClickCountToStart(int count)    public void setClickCountToStart(int count)
286    {    {
287      // TODO      clickCountToStart = count;
288    } // setClickCountToStart()    } // setClickCountToStart()
289    
290    /**    /**
# Line 263  public class DefaultCellEditor Line 294  public class DefaultCellEditor
294     */     */
295    public Object getCellEditorValue()    public Object getCellEditorValue()
296    {    {
297      return null; // TODO      return delegate.getCellEditorValue();
298    } // getCellEditorValue()    } // getCellEditorValue()
299    
300    /**    /**
# Line 275  public class DefaultCellEditor Line 306  public class DefaultCellEditor
306     */     */
307    public boolean isCellEditable(EventObject event)    public boolean isCellEditable(EventObject event)
308    {    {
309      return false; // TODO      return delegate.isCellEditable(event);
310    } // isCellEditable()    } // isCellEditable()
311    
312    /**    /**
# Line 287  public class DefaultCellEditor Line 318  public class DefaultCellEditor
318     */     */
319    public boolean shouldSelectCell(EventObject event)    public boolean shouldSelectCell(EventObject event)
320    {    {
321      return false; // TODO      return delegate.shouldSelectCell(event);
322    } // shouldSelectCell()    } // shouldSelectCell()
323    
324    /**    /**
# Line 297  public class DefaultCellEditor Line 328  public class DefaultCellEditor
328     */     */
329    public boolean stopCellEditing()    public boolean stopCellEditing()
330    {    {
331      return false; // TODO      return delegate.stopCellEditing();
332    } // stopCellEditing()    } // stopCellEditing()
333    
334    /**    /**
# Line 305  public class DefaultCellEditor Line 336  public class DefaultCellEditor
336     */     */
337    public void cancelCellEditing()    public void cancelCellEditing()
338    {    {
339      // TODO      delegate.cancelCellEditing();
340    } // cancelCellEditing()    } // cancelCellEditing()
341    
342    /**    /**
# Line 339  public class DefaultCellEditor Line 370  public class DefaultCellEditor
370     *     *
371     * @returns Component     * @returns Component
372     */     */
373    public Component getTableCellEditorComponent(JTable tree, Object value,    public Component getTableCellEditorComponent(JTable table, Object value,
374                                                 boolean isSelected, int row,                                                 boolean isSelected, int row,
375                                                 int column)                                                 int column)
376    {    {
377      return null; // TODO      // NOTE: as specified by Sun, we don't call new() everytime, we return
378        // editorComponent on each call to getTableCellEditorComponent or
379        // getTreeCellEditorComponent.  However, currently JTextFields have a
380        // problem with getting rid of old text, so without calling new() there
381        // are some strange results.  If you edit more than one cell in the table
382        // text from previously edited cells may unexpectedly show up in the
383        // cell you are currently editing.  This will be fixed automatically
384        // when JTextField is fixed.
385        if (editorComponent instanceof JTextField)
386          {
387            ((JTextField)editorComponent).setText(value.toString());
388            delegate = new EditorDelegate();
389            ((JTextField)editorComponent).addActionListener(delegate);
390          }
391        else
392          {
393            // TODO
394          }
395        return editorComponent;
396    } // getTableCellEditorComponent()    } // getTableCellEditorComponent()
397    
398    
399  }  }

Legend:
Removed from v.1.4.2.3  
changed lines
  Added in v.1.4.2.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26