Skip to main content
summaryrefslogtreecommitdiffstats
blob: 04a41f6e29bc91fe339d340ba27c65092524de3f (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<%@ jet package="org.eclipse.emf.refactor" class="RefactoringController"
imports="org.eclipse.emf.refactor.henshin.generator.*"%>
<%RefactoringConfigHenshin refactoringConfig = (RefactoringConfigHenshin) argument; %>
/**
 * <copyright>
 * </copyright>
 *
 * $Id: RefactoringControllerHenshin.javajet,v 1.1 2012/11/26 11:49:12 tarendt Exp $
 */
 package <%=refactoringConfig.getPackageName()%>;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.refactor.henshin.runtime.HenshinLtkEmfRefactoringProcessorAdapter;
import org.eclipse.emf.refactor.henshin.runtime.HenshinRunner;
import org.eclipse.emf.refactor.henshin.core.IHenshinController;
import org.eclipse.emf.refactor.henshin.core.IHenshinDataManagement;
import org.eclipse.emf.refactor.common.core.EmfRefactoring;
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;

/**
 * Concrete EMF model refactoring class implementing IHenshinController. 
 * @generated
 */
public final class RefactoringController implements IHenshinController{

	/**
	 * EmfRefactoring supported by the controller.
	 * @generated
	 */
	private EmfRefactoring parent;
	
	/**
	 * DataManagement object of the model refactoring.
	 * @generated
	 */
	private RefactoringDataManagement dataManagement = 
									new RefactoringDataManagement();
									
	/**
	 * Invocation context of the model refactoring.
	 * @generated
	 */								
	private List<EObject> selection = new ArrayList<EObject>();
	
	/**
	 * HenshinRunner that executes Henshin transformations using 
	 * the Henshin interpreter.
	 * @generated
	 */
	private HenshinRunner henshinRunner = 
					new HenshinRunner(new ArrayList<EObject>(0), dataManagement);
	
	/**
	 * Ltk RefactoringProcessor of the model refactoring.
	 * @generated
	 */
	private InternalRefactoringProcessor refactoringProcessor = null;
	
	/**
	 * Gets the EmfRefactoring supported by the controller.
	 * @return EmfRefactoring supported by the controller.
	 * @see org.eclipse.emf.refactor.common.core.IController#getParent()
	 * @generated
	 */
	@Override
	public EmfRefactoring getParent() {
		return this.parent;
	}
	
	/**
	 * Sets the EmfRefactoring supported by the controller.
	 * @param emfRefactoring EmfRefactoring supported by the controller.
	 * @see org.eclipse.emf.refactor.common.core.IController#
	 * setParent(org.eclipse.emf.refactor.common.core.EmfRefactoring)
	 * @generated
	 */
	@Override
	public void setParent(EmfRefactoring emfRefactoring) {
		this.parent = emfRefactoring;
	}
	
	/**
	 * Returns the DataManagement object of the model refactoring.
	 * @return DataManagement object of the model refactoring.
	 * @see org.eclipse.emf.refactor.henshin.core.IHenshinController#
	 * getDataManagementObject()
	 * @generated
	 */
	@Override
	public IHenshinDataManagement getDataManagementObject() {
		return this.dataManagement;
	}
	
	/**
	 * Gets a HenshinRunner that executes Henshin transformations using 
	 * the Henshin interpreter.
	 * @return HenshinRunner that executes Henshin transformations using 
	 * the Henshin interpreter.
	 * @see org.eclipse.emf.refactor.henshin.core.IHenshinController#
	 * getHenshinRunner()
	 * @generated
	 */
	@Override
	public HenshinRunner getHenshinRunner() {
		return this.henshinRunner;
	}

	/**
	 * Returns the ltk RefactoringProcessor of the model refactoring.
	 * @return Ltk RefactoringProcessor of the model refactoring.
	 * @see org.eclipse.emf.refactor.common.core.IController#
	 * getLtkRefactoringProcessor()
	 * @generated
	 */
	@Override
	public RefactoringProcessor getLtkRefactoringProcessor() {
		return this.refactoringProcessor;
	}
	
	/**
	 * Sets the selected EObject (invocation context of the model refactoring).
	 * @param selection Invocation context of the model refactoring.
	 * @see org.eclipse.emf.refactor.common.core.IController#
	 * setSelection(java.util.List)
	 * @generated
	 */
	@Override
	public void setSelection(List<EObject> selection) {
		this.selection = selection;
		this.henshinRunner = new HenshinRunner(this.selection, this.dataManagement);
		this.refactoringProcessor = 
				new InternalRefactoringProcessor(this.selection);
	}	
	
	/**
	 * Returns a Runnable object that executes the model refactoring.
	 * @return Runnable object that executes the model refactoring.
	 * @generated
	 */
	private Runnable applyRefactoring() {
		return new Runnable() {				
			/**
			 * @see java.lang.Runnable#run()
			 * @generated
			 */
			@Override
			public void run() {
				henshinRunner = new HenshinRunner(selection, dataManagement);
				henshinRunner.run();
			}
		};
	}

	/**
	 * Internal class for providing an instance of a LTK RefactoringProcessor 
	 * used for EMF model refactorings using Henshin transformations.	 
	 * @generated
	 */
	public final class InternalRefactoringProcessor extends 
									HenshinLtkEmfRefactoringProcessorAdapter {

		/**
		 * Constructor using the invocation context of the model refactoring.
		 * @param selection Invocation context of the model refactoring.
		 * @generated
		 */
		private InternalRefactoringProcessor(List<EObject> selection){
				super(getParent(), selection, applyRefactoring());				
		}
		
	}

}

Back to the top