Skip to main content
summaryrefslogtreecommitdiffstats
blob: 80351ba5e55fbdff0b8571385ea07dc5a2202d96 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*******************************************************************************
 * Copyright (c) 2001, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Jens Lukowski/Innoopract - initial renaming/restructuring
 *     
 *******************************************************************************/
package org.eclipse.wst.sse.core.internal.undo;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;

public interface IStructuredTextUndoManager {

	/**
	 * Begin recording undo transactions.
	 */
	void beginRecording(Object requester);

	/**
	 * Begin recording undo transactions.
	 */
	void beginRecording(Object requester, int cursorPosition, int selectionLength);

	/**
	 * Begin recording undo transactions.
	 */
	void beginRecording(Object requester, String label);

	/**
	 * Begin recording undo transactions.
	 */
	void beginRecording(Object requester, String label, int cursorPosition, int selectionLength);

	/**
	 * Begin recording undo transactions.
	 */
	void beginRecording(Object requester, String label, String description);

	/**
	 * Begin recording undo transactions.
	 */
	void beginRecording(Object requester, String label, String description, int cursorPosition, int selectionLength);

	/**
	 * Connect the mediator to the undo manager.
	 */
	void connect(IDocumentSelectionMediator mediator);

	/**
	 * Disable undo management.
	 */
	void disableUndoManagement();

	/**
	 * Disconnect the mediator from the undo manager.
	 */
	void disconnect(IDocumentSelectionMediator mediator);

	/**
	 * Enable undo management.
	 */
	void enableUndoManagement();

	/**
	 * End recording undo transactions.
	 */
	void endRecording(Object requester);

	/**
	 * End recording undo transactions.
	 */
	void endRecording(Object requester, int cursorPosition, int selectionLength);

	/**
	 * <p>
	 * Normally, the undo manager can figure out the best times when to end a
	 * pending command and begin a new one ... to the structure of a structued
	 * document. There are times, however, when clients may wish to override
	 * those algorithms and end one earlier than normal. The one known case is
	 * for multipage editors. If a user is on one page, and type '123' as
	 * attribute value, then click around to other parts of page, or different
	 * pages, then return to '123|' and type 456, then "undo" they typically
	 * expect the undo to just undo what they just typed, the 456, not the
	 * whole attribute value.
	 * <p>
	 * If there is no pending command, the request is ignored.
	 */
	public void forceEndOfPendingCommand(Object requester, int currentPosition, int length);

	/**
	 * Some clients need to do complicated things with undo stack. Plus, in
	 * some cases, if clients setCommandStack temporarily, they have
	 * reponsibility to set back to original one when finished.
	 */
	public CommandStack getCommandStack();

	/**
	 * Get the redo command even if it's not committed yet.
	 */
	Command getRedoCommand();

	/**
	 * Get the undo command even if it's not committed yet.
	 */
	Command getUndoCommand();

	/**
	 * Redo the last command in the undo manager.
	 */
	void redo();

	/**
	 * Redo the last command in the undo manager and notify the requester
	 * about the new selection.
	 */
	void redo(IDocumentSelectionMediator requester);

	/**
	 * Returns whether at least one text change can be repeated. A text change
	 * can be repeated only if it was executed and rolled back.
	 * 
	 * @return <code>true</code> if at least on text change can be repeated
	 */
	boolean redoable();

	/**
	 * Set the command stack.
	 */
	void setCommandStack(CommandStack commandStack);

	/**
	 * Undo the last command in the undo manager.
	 */
	void undo();

	/**
	 * Undo the last command in the undo manager and notify the requester
	 * about the new selection.
	 */
	void undo(IDocumentSelectionMediator requester);

	/**
	 * Returns whether at least one text change can be rolled back.
	 * 
	 * @return <code>true</code> if at least one text change can be rolled
	 *         back
	 */
	boolean undoable();
}

Back to the top