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.ComponentConstraints;
24: import com.jeta.forms.gui.form.FormComponent;
25: import com.jeta.forms.gui.form.GridComponent;
26: import com.jeta.forms.gui.form.ReadOnlyConstraints;
27:
28: /**
29: * Command that sets the CellConstraints for a component in the view
30: *
31: * @author Jeff Tassin
32: */
33: public class SetConstraintsCommand extends FormUndoableEdit {
34: /**
35: * The grid component whose constraints we will set
36: */
37: private GridComponent m_gc;
38:
39: /**
40: * The cell constraints to set
41: */
42: private ComponentConstraints m_cc;
43:
44: /**
45: * The old constraints.
46: */
47: private ComponentConstraints m_old_cc;
48:
49: /**
50: * ctor
51: */
52: public SetConstraintsCommand(FormComponent form, GridComponent gc,
53: ComponentConstraints cc) {
54: super (form);
55: m_gc = gc;
56: m_cc = cc;
57: m_old_cc = new ReadOnlyConstraints(gc.getConstraints());
58: }
59:
60: /**
61: * UndoableEdit implementation Override should begin with a call to super.
62: */
63: public void redo() throws CannotRedoException {
64: super .redo();
65: getView().setConstraints(m_gc, m_cc);
66: }
67:
68: /**
69: * UndoableEdit implementation Override should begin with a call to super.
70: */
71: public void undo() throws CannotRedoException {
72: super .undo();
73: getView().setConstraints(m_gc, m_old_cc);
74: }
75:
76: public String toString() {
77: return "SetConstraintsCommand col: " + m_gc.getColumn()
78: + " row: " + m_gc.getRow() + " constraints: "
79: + m_cc.createCellConstraints().toString();
80: }
81: }
|