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.form.FormComponent;
24: import com.jgoodies.forms.layout.ColumnSpec;
25:
26: public class EditColumnSpecCommand extends FormUndoableEdit {
27: /**
28: * @directed
29: */
30: private ColumnSpec m_columnspec;
31:
32: private ColumnSpec m_oldspec;
33:
34: /**
35: * The index of the column whose specification we are changing
36: */
37: private int m_col;
38:
39: /**
40: * ctor
41: */
42: public EditColumnSpecCommand(FormComponent form, int col,
43: ColumnSpec colspec, ColumnSpec oldspec) {
44: super (form);
45: m_col = col;
46: m_columnspec = colspec;
47: /**
48: * note that you must create a copy of the oldspec here because the
49: * reference passed to the constructor is probabaly bound to the view
50: * and will change
51: */
52: m_oldspec = new ColumnSpec(oldspec.getDefaultAlignment(),
53: oldspec.getSize(), oldspec.getResizeWeight());
54: }
55:
56: /**
57: * UndoableEdit implementation Override should begin with a call to super.
58: */
59: public void redo() throws CannotRedoException {
60: super .redo();
61: getView().setColumnSpec(m_col, m_columnspec);
62: }
63:
64: /**
65: * UndoableEdit implementation Override should begin with a call to super.
66: */
67: public void undo() throws CannotRedoException {
68: super .undo();
69: if (m_oldspec != null)
70: getView().setColumnSpec(m_col, m_oldspec);
71: }
72:
73: public String toString() {
74: return "EditColumnSpec column: " + m_col + " spec: "
75: + m_columnspec.toString();
76: }
77:
78: }
|