1
2
3
4
5
6
7
8
9
10
11 package de.jaret.util.ui.table.util.action;
12
13 import java.util.HashMap;
14 import java.util.Map;
15
16 import org.eclipse.jface.action.Action;
17
18 import de.jaret.util.ui.table.JaretTable;
19
20 /***
21 * Utility ActionFactory for the jaret table, producing actions for some common tasks to accomodate on a jaret table.
22 *
23 * @author Peter Kliem
24 * @version $Id: JaretTableActionFactory.java 179 2007-01-07 17:37:50Z olk $
25 */
26 public class JaretTableActionFactory {
27 /***
28 * Constant denoting the configure columns action.
29 */
30 public static final String ACTION_CONFIGURECOLUMNS = "jarettable.configurecolumns";
31 public static final String ACTION_OPTROWHEIGHT = "jarettable.optimizerowheigth";
32 public static final String ACTION_OPTALLROWHEIGHTS = "jarettable.optimizeallrowheights";
33
34 protected Map<String, Action> _actionMap;
35
36 public Action createStdAction(JaretTable table, String name) {
37 if (_actionMap == null) {
38 _actionMap = new HashMap<String, Action>();
39 }
40 Action result = _actionMap.get(name);
41 if (result != null) {
42 return result;
43 }
44 if (name.equals(ACTION_CONFIGURECOLUMNS)) {
45 result = new ConfigureColumnsAction(table);
46 } else if (name.equals(ACTION_OPTROWHEIGHT)) {
47 result = new OptimizeRowHeightAction(table);
48 } else if (name.equals(ACTION_OPTALLROWHEIGHTS)) {
49 result = new OptimizeAllRowHeightsAction(table);
50 } else if (name.equals("s")) {
51 result = null;
52 }
53
54 if (result != null) {
55 _actionMap.put(name, result);
56 }
57 return result;
58 }
59
60 }