View Javadoc

1   /*
2    * $Id$
3    *
4    * The contents of this file are subject to the Mozilla Public License 
5    * Version 1.1 (the "License"); you may not use this file except in 
6    * compliance with the License. You may obtain a copy of the License at 
7    * http://www.mozilla.org/MPL/ 
8    *
9    * Software distributed under the License is distributed on an "AS IS" basis, 
10   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
11   * for the specific language governing rights and limitations under the License.
12   *
13   * The Original Code is XML Hammer code. (org.xmlhammer.*)
14   *
15   * The Initial Developer of the Original Code is Edwin Dankert. Portions created 
16   * by the Initial Developer are Copyright (C) 2005 - 2006 the Initial Developer. 
17   * All Rights Reserved.
18   *
19   * Contributor(s): Edwin Dankert <edankert@gmail.com>
20   */
21  package org.xmlhammer.gui.util;
22  
23  import javax.swing.JCheckBox;
24  import javax.swing.undo.AbstractUndoableEdit;
25  
26  import org.xmlhammer.gui.Page;
27  
28  public class UndoableCheckBoxEdit extends AbstractUndoableEdit {
29      private static final long serialVersionUID = 8615885869967750791L;
30  
31      private boolean selected = false;
32      private Page page = null;
33      private JCheckBox check = null;
34      
35      public UndoableCheckBoxEdit(Page page, JCheckBox check, boolean selected) {
36          super();
37          
38          this.page = page;
39          this.check = check;
40          this.selected = selected;
41      }
42  
43      public void undo() {
44          super.undo();
45  
46          page.getProjectView().getOverviewPanel().selectNode(page);
47          check.requestFocusInWindow();
48          check.setSelected(!selected);
49      }
50  
51      public void redo() {
52          super.redo();
53  
54          page.getProjectView().getOverviewPanel().selectNode(page);
55          check.requestFocusInWindow();
56          check.setSelected(selected);
57      }
58      
59      public String getUndoPresentationName() {
60          return "";
61      }
62  
63      public String getRedoPresentationName() {
64          return "";
65      }
66  
67  }