KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > internal > patch > WorkspaceFileDiffResult


1 /*******************************************************************************
2  * Copyright (c) 2007 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.compare.internal.patch;
12
13 import java.util.List JavaDoc;
14
15 import org.eclipse.compare.patch.PatchConfiguration;
16 import org.eclipse.core.resources.*;
17
18 public class WorkspaceFileDiffResult extends FileDiffResult {
19
20     public WorkspaceFileDiffResult(FileDiff diff,
21             PatchConfiguration configuration) {
22         super(diff, configuration);
23     }
24     
25     protected boolean canCreateTarget(IStorage storage) {
26         IProject project = getPatcher().getTargetProject(getDiff());
27         return project != null && project.isAccessible();
28     }
29     
30     protected boolean targetExists(IStorage storage) {
31         IFile file= (IFile)storage;
32         return file != null && file.isAccessible();
33     }
34     
35     protected List JavaDoc getLines(IStorage storage, boolean create) {
36         IFile file= getTargetFile();
37         List JavaDoc lines = Patcher.load(file, create);
38         return lines;
39     }
40
41     protected Patcher getPatcher() {
42         return Patcher.getPatcher(getConfiguration());
43     }
44
45     protected IFile getTargetFile() {
46         return getPatcher().getTargetFile(getDiff());
47     }
48     
49     public void refresh() {
50         refresh(getTargetFile(), null);
51     }
52
53 }
54
Popular Tags