KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > util > Changes


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.util;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.List JavaDoc;
15
16 import org.eclipse.core.runtime.IAdaptable;
17
18 import org.eclipse.core.resources.IFile;
19
20 import org.eclipse.ltk.core.refactoring.Change;
21 import org.eclipse.ltk.core.refactoring.CompositeChange;
22
23
24 public class Changes {
25
26     public static IFile[] getModifiedFiles(Change[] changes) {
27         List JavaDoc result= new ArrayList JavaDoc();
28         getModifiedFiles(result, changes);
29         return (IFile[]) result.toArray(new IFile[result.size()]);
30     }
31
32     private static void getModifiedFiles(List JavaDoc result, Change[] changes) {
33         for (int i= 0; i < changes.length; i++) {
34             Change change= changes[i];
35             Object JavaDoc modifiedElement= change.getModifiedElement();
36             if (modifiedElement instanceof IAdaptable) {
37                 IFile file= (IFile)((IAdaptable)modifiedElement).getAdapter(IFile.class);
38                 if (file != null)
39                     result.add(file);
40             }
41             if (change instanceof CompositeChange) {
42                 getModifiedFiles(result, ((CompositeChange)change).getChildren());
43             }
44         }
45     }
46 }
47
Popular Tags