01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.gui.commands;
20:
21: import javax.swing.undo.CannotRedoException;
22:
23: import com.jeta.forms.gui.components.ComponentFactory;
24: import com.jeta.forms.gui.form.FormComponent;
25: import com.jgoodies.forms.layout.ColumnSpec;
26:
27: public class InsertColumnCommand extends FormUndoableEdit {
28: /**
29: * @directed
30: */
31: private ColumnSpec m_columnspec;
32:
33: /**
34: * The column index where we are inserting the new column.
35: */
36: private int m_column;
37:
38: /**
39: * Factory used to create the default component for each cell in the new
40: * column.
41: *
42: * @directed
43: */
44: private ComponentFactory m_compfactory;
45:
46: /**
47: * ctor
48: */
49: public InsertColumnCommand(FormComponent form, int column,
50: ColumnSpec columnspec, ComponentFactory factory) {
51: super (form);
52: m_column = column;
53: m_columnspec = columnspec;
54: m_compfactory = factory;
55: }
56:
57: /**
58: * UndoableEdit implementation Override should begin with a call to super.
59: */
60: public void redo() throws CannotRedoException {
61: super .redo();
62: try {
63: getView().insertColumn(m_column, m_columnspec,
64: m_compfactory);
65: } catch (Exception e) {
66: e.printStackTrace();
67: }
68: }
69:
70: /**
71: * UndoableEdit implementation Override should begin with a call to super.
72: */
73: public void undo() throws CannotRedoException {
74: super .undo();
75: try {
76: getView().removeColumn(m_column);
77: } catch (Exception e) {
78: e.printStackTrace();
79: }
80: }
81:
82: public String toString() {
83: return "InsertColumnCommand col: " + m_column;
84: }
85:
86: }
|