Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: samples/total/client/UndoableAction.dart

Issue 10635015: Delete proxy and total samples, which have bit-rotted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/total/client/UndoStack.dart ('k') | samples/total/client/Value.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * The [UndoableAction] interface must be implemented by classes that store undo /redo data for
7 * the [GeneralCommand] class and its subclasses.
8 */
9 interface UndoableAction {
10 /**
11 * Undo the effect of the action on the given spreadsheet.
12 */
13 void undoAction(Spreadsheet spreadsheet);
14 }
15
16 /**
17 * The [CellAction class] represents an action on a cell at a given location.
18 */
19 class CellAction implements UndoableAction {
20 // The location of the cell that has changed
21 RowCol _rowCol;
22
23 CellAction(this._rowCol) {}
24
25 // Apply does nothing
26 void undoAction(Spreadsheet spreadsheet) {}
27 }
28
29 /**
30 * A class to hold a change to the content of a [Cell].
31 */
32 class CellContentAction extends CellAction {
33 // The old content
34 CellContent _originalContent;
35
36 CellContentAction(RowCol rowCol, this._originalContent) : super(rowCol) {}
37
38 void undoAction(Spreadsheet spreadsheet) {
39 spreadsheet.setCellContent(_rowCol, _originalContent);
40 }
41 }
42
43 /**
44 * A class to hold a change to the style of a [Cell].
45 */
46 class CellStyleAction extends CellAction {
47 // The old style
48 Style _originalStyle;
49
50 CellStyleAction(RowCol rowCol, this._originalStyle) : super(rowCol) {}
51
52 void undoAction(Spreadsheet spreadsheet) {
53 if (_originalStyle == null) {
54 Cell c = spreadsheet.getCell(_rowCol);
55 if (c != null) {
56 spreadsheet.setCellStyle(_rowCol, null);
57 }
58 } else {
59 spreadsheet.setCellStyle(_rowCol, _originalStyle);
60 }
61 }
62 }
63
64 /**
65 * A class to hold a change to a row, column or entire sheet.
66 */
67 class RowColAction implements UndoableAction {
68 // The index of the row or column that has changed
69 int _index;
70
71 // One of Spreadsheet.ROW, Spreadsheet.COL, or Spreadsheet.SHEET.
72 int _rowOrCol;
73
74 RowColAction(this._index, this._rowOrCol) {}
75
76 // Apply does nothing
77 void undoAction(Spreadsheet spreadsheet) {}
78 }
79
80 /**
81 * A class to hold a change to a row, column or spreadsheet style
82 */
83 class RowColStyleAction extends RowColAction {
84 // The original style before the delta is applied
85 RowColStyle _originalStyle;
86
87 RowColStyleAction(int index, int rowOrCol, this._originalStyle) : super(index, rowOrCol) {}
88
89 void undoAction(Spreadsheet spreadsheet) {
90 if (_rowOrCol == Spreadsheet.ROW) {
91 spreadsheet.setRowStyle(_index, _originalStyle);
92 } else if (_rowOrCol == Spreadsheet.COL) {
93 spreadsheet.setColumnStyle(_index, _originalStyle);
94 } else {
95 spreadsheet.setSheetStyle(_originalStyle);
96 }
97 }
98 }
OLDNEW
« no previous file with comments | « samples/total/client/UndoStack.dart ('k') | samples/total/client/Value.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698