Mercurial > projects > dwt2
comparison org.eclipse.core.commands/src/org/eclipse/core/commands/operations/OperationHistoryFactory.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2005 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.core.commands.operations.OperationHistoryFactory; | |
14 | |
15 import org.eclipse.core.commands.operations.IOperationHistory; | |
16 import org.eclipse.core.commands.operations.DefaultOperationHistory; | |
17 | |
18 import java.lang.all; | |
19 | |
20 /** | |
21 * <p> | |
22 * This class is used to maintain the instance of the operation history that | |
23 * should be used by classes that access the undo or redo history and add | |
24 * undoable operations to the history. | |
25 * | |
26 * <p> | |
27 * It is intended that an application can create an operation history appropriate | |
28 * for its needs and set it into this class. Otherwise, a default operation history | |
29 * will be created. The operation history may only be set one time. All classes that | |
30 * access an operations history use this class to obtain the correct instance. | |
31 * | |
32 * @since 3.1 | |
33 */ | |
34 public final class OperationHistoryFactory { | |
35 | |
36 private static IOperationHistory operationHistory; | |
37 | |
38 /** | |
39 * Return the operation history to be used for managing undoable operations. | |
40 * | |
41 * @return the operation history to be used for executing, undoing, and | |
42 * redoing operations. | |
43 */ | |
44 public static IOperationHistory getOperationHistory() { | |
45 if (operationHistory is null) { | |
46 operationHistory = new DefaultOperationHistory(); | |
47 } | |
48 return operationHistory; | |
49 } | |
50 | |
51 /** | |
52 * Set the operation history to be used for managing undoable operations. | |
53 * This method may only be called one time, and must be called before any | |
54 * request to get the history. Attempts to set the operation history will | |
55 * be ignored after it has been already set, or after a default one has | |
56 * been created. | |
57 * | |
58 * @param history | |
59 * the operation history to be used for executing, undoing, and | |
60 * redoing operations. | |
61 */ | |
62 public static void setOperationHistory(IOperationHistory history) { | |
63 // If one has already been set or created, ignore this request. | |
64 if (operationHistory is null) { | |
65 operationHistory = history; | |
66 } | |
67 } | |
68 | |
69 private this() { | |
70 // may not be instantiated | |
71 } | |
72 | |
73 } |