View Javadoc

1   /*
2    *  File: OptimizeRowHeightAction.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.util.action;
12  
13  import org.eclipse.jface.action.Action;
14  
15  import de.jaret.util.ui.table.JaretTable;
16  import de.jaret.util.ui.table.model.IJaretTableSelection;
17  import de.jaret.util.ui.table.model.IRow;
18  
19  /***
20   * Action that registers all selected rows for optimization of their respective heights.
21   * 
22   * @author Peter Kliem
23   * @version $Id: OptimizeRowHeightAction.java 179 2007-01-07 17:37:50Z olk $
24   */
25  public class OptimizeRowHeightAction extends Action {
26      protected JaretTable _table;
27  
28      public OptimizeRowHeightAction(JaretTable table) {
29          _table = table;
30      }
31  
32      @Override
33      public void run() {
34          IJaretTableSelection selection = _table.getSelectionModel().getSelection();
35          if (!selection.isEmpty() && selection.getSelectedRows().size() > 0) {
36              for (IRow row : selection.getSelectedRows()) {
37                  _table.optimizeHeight(row);
38              }
39          }
40      }
41  
42      @Override
43      public String getText() {
44          return "Optimal row height";
45      }
46  }