blob: fbff0f23bc0c44eb402d017bb2702e04476403ee (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/*******************************************************************************
* Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.internal.operations;
/**
* The file operation class to create the root node in the file system of Target Explorer.
*/
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.IFileSystem;
import org.eclipse.tcf.services.IFileSystem.DirEntry;
import org.eclipse.tcf.services.IFileSystem.FileSystemException;
import org.eclipse.tcf.te.tcf.core.Tcf;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFChannelException;
import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
/**
* The operation to refresh the root of the file system.
*/
public class OpRefreshRoots extends Operation {
/* default */FSTreeNode root;
/**
* Create an instance using the peer model.
*
* @param peerModel The peer model.
*/
public OpRefreshRoots(FSTreeNode root) {
this.root = root;
}
/*
* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
super.run(monitor);
IChannel channel = null;
try {
channel = openChannel(root.peerNode.getPeer());
IFileSystem service = getBlockingFileSystem(channel);
if (service != null) {
root.queryStarted();
service.roots(new IFileSystem.DoneRoots() {
@Override
public void doneRoots(IToken token, FileSystemException error, DirEntry[] entries) {
if (error == null) {
for (DirEntry entry : entries) {
FSTreeNode node = new FSTreeNode(root, entry, true);
root.addChild(node);
}
}
}
});
// Reset the children query markers
root.queryDone();
}
}
catch(TCFChannelException e) {
throw new InvocationTargetException(e);
}
finally {
if (channel != null) Tcf.getChannelManager().closeChannel(channel);
}
}
}
|