01: /*
02: * OptimizeColumnWidthAction.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.actions;
13:
14: import java.awt.event.ActionEvent;
15: import workbench.gui.components.TableColumnOptimizer;
16:
17: import workbench.gui.components.WbTable;
18: import workbench.resource.Settings;
19: import workbench.util.WbThread;
20:
21: /**
22: * @author support@sql-workbench.net
23: */
24: public class OptimizeColumnWidthAction extends WbAction {
25: protected WbTable client;
26: protected TableColumnOptimizer optimizer;
27:
28: public OptimizeColumnWidthAction(WbTable aClient) {
29: super ();
30: this .client = aClient;
31: this .optimizer = new TableColumnOptimizer(client);
32: this .setMenuTextByKey("MnuTxtOptimizeCol");
33: }
34:
35: public void executeAction(ActionEvent e) {
36: if (client == null)
37: return;
38: final boolean respectColName = ((e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK)
39: || Settings.getInstance()
40: .getIncludeHeaderInOptimalWidth();
41: final int column = client.getPopupColumnIndex();
42: Thread t = new WbThread("OptimizeCol Thread") {
43: public void run() {
44: optimizer.optimizeColWidth(column, respectColName);
45: }
46: };
47: t.start();
48: }
49: }
|