blob: 11f398cf74964090863eba4be47c4c44f7729a8e (
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
|
/*****************************************************************************
* Copyright (c) 2012 Cedric Dumoulin.
*
*
* 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:
* Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.undocontext;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.emf.commands.core.command.EditingDomainUndoContext;
import org.eclipse.papyrus.infra.core.services.IServiceFactory;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
/**
* Service Factory used to create the {@link IUndoContext} used by all editors and views associated to
* a model (or {@link ServicesRegistry}).
* The {@link IUndoContext} can be retrieved from the {@link ServicesRegistry}.
*
* @author Cedric Dumoulin
*
*/
public class UndoContextServiceFactory implements IServiceFactory {
/**
* Undo context used to have the same undo context in all Papyrus related views and editors.
*/
private EditingDomainUndoContext undoContext;
/**
*
* @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry)
*
* @param servicesRegistry
* @throws ServiceException
*/
public void init(ServicesRegistry servicesRegistry) throws ServiceException {
// Lookup TransactionalEditingDomain
TransactionalEditingDomain transactionalEditingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(servicesRegistry);
// Create the undoContext
undoContext = new EditingDomainUndoContext(transactionalEditingDomain);
}
/**
* Do nothing
* @see org.eclipse.papyrus.infra.core.services.IService#startService()
*
* @throws ServiceException
*/
public void startService() throws ServiceException {
}
/**
* Do nothing
* @see org.eclipse.papyrus.infra.core.services.IService#disposeService()
*
* @throws ServiceException
*/
public void disposeService() throws ServiceException {
}
/**
*
* @see org.eclipse.papyrus.infra.core.services.IServiceFactory#createServiceInstance()
*
* @return
* @throws ServiceException
*/
public Object createServiceInstance() throws ServiceException {
return undoContext;
}
}
|