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.RowSpec;
25:
26: public class EditRowSpecCommand extends FormUndoableEdit {
27: /**
28: * @directed
29: */
30: private RowSpec m_rowspec;
31:
32: private RowSpec m_oldspec;
33:
34: /**
35: * The index of the row to insert
36: */
37: private int m_row;
38:
39: /**
40: * ctor
41: */
42: public EditRowSpecCommand(FormComponent form, int row,
43: RowSpec rowspec, RowSpec oldspec) {
44: super (form);
45: m_row = row;
46: m_rowspec = rowspec;
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 RowSpec(oldspec.getDefaultAlignment(), oldspec
53: .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().setRowSpec(m_row, m_rowspec);
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().setRowSpec(m_row, m_oldspec);
71: }
72:
73: public String toString() {
74: return "EditRowSpec row: " + m_row + " spec: "
75: + m_rowspec.toString();
76: }
77:
78: }
|