01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.corext.refactoring.reorg;
11:
12: import java.util.LinkedHashMap;
13: import java.util.Map;
14:
15: /**
16: * Objects of this class can be used as a log to trace the creation of new
17: * destinations during refactorings like move.
18: *
19: * @since 3.3
20: */
21: public final class CreateTargetExecutionLog {
22:
23: private Map fCreations = new LinkedHashMap(2);
24:
25: /**
26: * Returns the element which got created for the given selection.
27: *
28: * @param selection
29: * the selection
30: * @return the created element, or <code>null</code>
31: */
32: public Object getCreatedElement(Object selection) {
33: return fCreations.get(selection);
34: }
35:
36: /**
37: * Returns all created elements.
38: *
39: * @return all created elements
40: */
41: public Object[] getCreatedElements() {
42: return fCreations.values().toArray();
43: }
44:
45: /**
46: * Returns all selected elements.
47: *
48: * @return all selected elements
49: */
50: public Object[] getSelectedElements() {
51: return fCreations.keySet().toArray();
52: }
53:
54: /**
55: * Logs that the given element got created by the refactoring.
56: *
57: * @param selection
58: * the selected object
59: * @param element
60: * the element that got created for the selection
61: */
62: public void markAsCreated(Object selection, Object element) {
63: fCreations.put(selection, element);
64: }
65: }
|