]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/core refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/CreateCompilationUnitChange.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / core refactoring / org / eclipse / jdt / internal / corext / refactoring / changes / CreateCompilationUnitChange.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 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  *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.refactoring.changes;
12
13 import org.eclipse.jdt.core.ICompilationUnit;
14
15 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
16 import org.eclipse.jdt.internal.corext.refactoring.nls.changes.CreateTextFileChange;
17 import org.eclipse.jdt.internal.corext.util.Messages;
18
19 import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
20
21 public final class CreateCompilationUnitChange extends CreateTextFileChange {
22
23         private final ICompilationUnit fUnit;
24
25         public CreateCompilationUnitChange(ICompilationUnit unit, String source, String encoding) {
26                 super(unit.getResource().getFullPath(), source, encoding, "java"); //$NON-NLS-1$
27                 fUnit= unit;
28         }
29
30         @Override
31         public String getName() {
32                 String cuName= BasicElementLabels.getFileName(fUnit);
33                 String cuContainerName= BasicElementLabels.getPathLabel(fUnit.getParent().getPath(), false);
34                 return Messages.format(RefactoringCoreMessages.CompilationUnitChange_label, new String[] { cuName, cuContainerName });
35         }
36 }