KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > localstore > RefreshLocalAliasVisitor


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.core.internal.localstore;
12
13 import org.eclipse.core.filesystem.IFileStore;
14 import org.eclipse.core.internal.resources.Container;
15 import org.eclipse.core.internal.resources.Resource;
16 import org.eclipse.core.resources.IResource;
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.core.runtime.IProgressMonitor;
19
20 /**
21  * Performs a local refresh, and additionally updates all aliases of the
22  * refreshed resource.
23  */

24 public class RefreshLocalAliasVisitor extends RefreshLocalVisitor {
25     public RefreshLocalAliasVisitor(IProgressMonitor monitor) {
26         super(monitor);
27     }
28
29     protected void createResource(UnifiedTreeNode node, Resource target) throws CoreException {
30         super.createResource(node, target);
31         IFileStore store = node.getStore();
32         if (store == null)
33             return;
34         IResource[] aliases = workspace.getAliasManager().computeAliases(target, store);
35         if (aliases != null)
36             for (int i = 0; i < aliases.length; i++)
37                 super.createResource(node, (Resource) aliases[i]);
38     }
39
40     protected void deleteResource(UnifiedTreeNode node, Resource target) throws CoreException {
41         super.deleteResource(node, target);
42         IFileStore store = node.getStore();
43         if (store == null)
44             return;
45         IResource[] aliases = workspace.getAliasManager().computeAliases(target, store);
46         if (aliases != null)
47             for (int i = 0; i < aliases.length; i++)
48                 super.deleteResource(node, (Resource) aliases[i]);
49     }
50
51     protected void resourceChanged(UnifiedTreeNode node, Resource target) {
52         super.resourceChanged(node, target);
53         IFileStore store = node.getStore();
54         if (store == null)
55             return;
56         IResource[] aliases = workspace.getAliasManager().computeAliases(target, store);
57         if (aliases != null)
58             for (int i = 0; i < aliases.length; i++)
59                 super.resourceChanged(node, (Resource) aliases[i]);
60     }
61
62     protected void fileToFolder(UnifiedTreeNode node, Resource target) throws CoreException {
63         super.fileToFolder(node, target);
64         IFileStore store = node.getStore();
65         if (store == null)
66             return;
67         IResource[] aliases = workspace.getAliasManager().computeAliases(target, store);
68         if (aliases != null)
69             for (int i = 0; i < aliases.length; i++)
70                 super.fileToFolder(node, (Resource) aliases[i]);
71     }
72
73     protected void folderToFile(UnifiedTreeNode node, Resource target) throws CoreException {
74         super.folderToFile(node, target);
75         IFileStore store = node.getStore();
76         if (store == null)
77             return;
78         IResource[] aliases = workspace.getAliasManager().computeAliases(target, store);
79         if (aliases != null)
80             for (int i = 0; i < aliases.length; i++)
81                 super.folderToFile(node, (Resource) aliases[i]);
82     }
83
84     protected void refresh(Container parent) throws CoreException {
85         parent.getLocalManager().refresh(parent, IResource.DEPTH_ZERO, true, null);
86     }
87
88 }
89
Popular Tags