View Javadoc

1   /*
2    * Copyright 1999-2006 Faculty of Mathematics, Physics and Informatics, Comenius
3    * University, Bratislava. This file is protected by the Mozilla Public License
4    * version 1.1 (the License); you may not use this file except in compliance
5    * with the License. You may obtain a copy of the License at
6    * http://euromath2.sourceforge.net/license.html Unless required by applicable
7    * law or agreed to in writing, software distributed under the License is
8    * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9    * KIND, either express or implied. See the License for the specific language
10   * governing permissions and limitations under the License.
11   */
12  package sk.uniba.euromath.editor.xmlEditor.commands;
13  
14  import sk.baka.ikslibs.interval.DOMIntervalSet;
15  import sk.uniba.euromath.document.XMLAccess;
16  import sk.uniba.euromath.editor.selections.IDOMSelectionProvider;
17  import sk.uniba.euromath.editor.textEditor.CaretManager;
18  import sk.uniba.euromath.editor.textEditor.Direction;
19  
20  /***
21   * @author Tomáš Studva 21.8.2006
22   */
23  public class DeleteSelectionCommand extends DeleteDOMIntervalSetCommand {
24  
25          private final IDOMSelectionProvider selectionProvider;
26  
27          /***
28           * Constructor.
29           */
30          public DeleteSelectionCommand(XMLAccess xmlAccess,
31                          CaretManager caretManager, Direction direction,
32                          int caretMovement,
33                          IDOMSelectionProvider selectionProvider) {
34                  super(selectionProvider.getDOMSelection(), xmlAccess,
35                                  caretManager, direction, caretMovement);
36                  this.selectionProvider = selectionProvider;
37          }
38  
39          /***
40           * Constructor.
41           * 
42           */
43          public DeleteSelectionCommand(XMLAccess xmlAccess,
44                          CaretManager caretManager,
45                          IDOMSelectionProvider selectionProvider) {
46                  super(selectionProvider.getDOMSelection(), xmlAccess,
47                                  caretManager);
48                  this.selectionProvider = selectionProvider;
49          }
50  
51          @Override
52          public void execute() {
53                  this.selectionProvider.setSelection(new DOMIntervalSet());
54                  super.execute();
55          }
56  
57          @Override
58          public void undo() {
59                  super.undo();
60                  this.selectionProvider.setSelection(this.toDelete);
61          }
62  
63          @Override
64          public void redo() {
65                  this.selectionProvider.setSelection(new DOMIntervalSet());
66                  super.redo();
67          }
68  }