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.changes;
11:
12: import org.eclipse.core.runtime.Assert;
13:
14: import org.eclipse.ltk.core.refactoring.Change;
15: import org.eclipse.ltk.core.refactoring.ChangeDescriptor;
16: import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
17: import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
18:
19: import org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor;
20:
21: import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
22:
23: /**
24: * Dynamic validation state change with support for refactoring descriptors.
25: *
26: * @since 3.2
27: */
28: public final class DynamicValidationRefactoringChange extends
29: DynamicValidationStateChange {
30:
31: /** The refactoring descriptor */
32: private final RefactoringDescriptor fDescriptor;
33:
34: /**
35: * Creates a new dynamic validation refactoring change.
36: *
37: * @param descriptor
38: * the refactoring descriptor
39: * @param name
40: * the name of the change
41: */
42: public DynamicValidationRefactoringChange(
43: final JavaRefactoringDescriptor descriptor,
44: final String name) {
45: super (name);
46: Assert.isNotNull(descriptor);
47: fDescriptor = descriptor;
48: }
49:
50: /**
51: * Creates a new dynamic validation refactoring change.
52: *
53: * @param descriptor
54: * the refactoring descriptor
55: * @param name
56: * the name of the change
57: * @param changes
58: * the changes
59: */
60: public DynamicValidationRefactoringChange(
61: final JavaRefactoringDescriptor descriptor,
62: final String name, final Change[] changes) {
63: super (name, changes);
64: Assert.isNotNull(descriptor);
65: Assert
66: .isTrue(
67: !descriptor.validateDescriptor()
68: .hasFatalError(),
69: RefactoringCoreMessages.DynamicValidationRefactoringChange_fatal_error);
70: fDescriptor = descriptor;
71: }
72:
73: /**
74: * {@inheritDoc}
75: */
76: public ChangeDescriptor getDescriptor() {
77: return new RefactoringChangeDescriptor(fDescriptor);
78: }
79: }
|