View Javadoc

1   /*
2    *  File: DefaultFillDragStrategy.java 
3    *  Copyright (c) 2004-2007  Peter Kliem (Peter.Kliem@jaret.de)
4    *  A commercial license is available, see http://www.jaret.de.
5    *
6    * All rights reserved. This program and the accompanying materials
7    * are made available under the terms of the Common Public License v1.0
8    * which accompanies this distribution, and is available at
9    * http://www.eclipse.org/legal/cpl-v10.html
10   */
11  package de.jaret.util.ui.table.strategies;
12  
13  import java.util.List;
14  
15  import de.jaret.util.ui.table.JaretTable;
16  import de.jaret.util.ui.table.model.IJaretTableCell;
17  
18  /***
19   * Defaut implementation of a fill drag strategy: simply copy the content.
20   * 
21   * @author Peter Kliem
22   * @version $Id: DefaultFillDragStrategy.java 394 2007-05-01 10:51:25Z olk $
23   */
24  public class DefaultFillDragStrategy implements IFillDragStrategy {
25  
26      /***
27       * {@inheritDoc}
28       */
29      public void doFill(JaretTable table, IJaretTableCell firstCell, List<IJaretTableCell> cells) {
30          Object value = firstCell.getColumn().getValue(firstCell.getRow());
31          for (IJaretTableCell cell : cells) {
32              // check whether destination cell is editable
33              if (table.getTableModel().isEditable(cell.getRow(), cell.getColumn())) {
34                  try {
35                      cell.getColumn().setValue(cell.getRow(), value);
36                  } catch (Exception e) {
37                      // whatever happens -- ignore it
38                  }
39              }
40          }
41      }
42  
43  }