Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9242a18cb2b2d354ea21f3d17f8ef178c8549b68 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
/*******************************************************************************
 * Copyright (c) 2011, 2012 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
 * William Chen (Wind River) - [345384] Provide property pages for remote file system nodes
 * William Chen (Wind River) - [352302]Opening a file in an editor depending on
 *                             the client's permissions.
 *******************************************************************************/
package org.eclipse.tcf.te.tcf.filesystem.core.model;

import java.beans.PropertyChangeEvent;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IFileSystem;
import org.eclipse.tcf.services.IFileSystem.DirEntry;
import org.eclipse.tcf.services.IFileSystem.FileAttrs;
import org.eclipse.tcf.te.core.interfaces.IFilterable;
import org.eclipse.tcf.te.runtime.callback.Callback;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.tcf.core.concurrent.CallbackMonitor;
import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IWindowsFileAttributes;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks.QueryDoneOpenChannel;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.callbacks.RefreshStateDoneOpenChannel;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpTargetFileDigest;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.testers.TargetPropertyTester;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLConnection;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.url.TcfURLStreamHandlerService;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;

/**
 * Representation of a file system tree node.
 * <p>
 * <b>Note:</b> Node construction and child list access is limited to the TCF
 * event dispatch thread.
 */
public final class FSTreeNode extends AbstractTreeNode implements Cloneable, IFilterable {
    // The constant to access the Windows Attributes.
    private static final String KEY_WIN32_ATTRS = "Win32Attrs"; //$NON-NLS-1$

    /**
     * The tree node file system attributes
     */
    public IFileSystem.FileAttrs attr = null;

    /**
     * Create a folder node using the specified parent node, the directory entry
     * and the flag to indicate if it is a root node.
     *
     * @param parentNode The parent node.
     * @param entry The directory entry.
     * @param entryIsRootNode If this folder is root folder.
     */
    public FSTreeNode(FSTreeNode parentNode, DirEntry entry, boolean entryIsRootNode) {
        Assert.isNotNull(entry);
        IFileSystem.FileAttrs attrs = entry.attrs;

        this.attr = attrs;
        this.name = entry.filename;
        if (attrs == null || attrs.isDirectory()) {
            this.type = entryIsRootNode ? "FSRootDirNode" : "FSDirNode"; //$NON-NLS-1$ //$NON-NLS-2$
        } else if (attrs.isFile()) {
            this.type = "FSFileNode"; //$NON-NLS-1$
        }
        this.parent = parentNode;
        this.peerNode = parentNode.peerNode;
        Assert.isTrue(Protocol.isDispatchThread());
    }

    /**
     * Constructor.
     */
    public FSTreeNode() {
        Assert.isTrue(Protocol.isDispatchThread());
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#clone()
     */
    @Override
    public Object clone() {
        if (Protocol.isDispatchThread()) {
            FSTreeNode clone = new FSTreeNode();
            clone.childrenQueried = childrenQueried;
            clone.childrenQueryRunning = childrenQueryRunning;
            clone.name = name;
            clone.parent = parent;
            clone.peerNode = peerNode;
            clone.type = type;
            if (attr != null) {
                Map<String, Object> attributes = new HashMap<String, Object>(attr.attributes);
                clone.attr = new IFileSystem.FileAttrs(attr.flags, attr.size, attr.uid, attr.gid, attr.permissions, attr.atime, attr.mtime, attributes);
            } else {
                clone.attr = null;
            }
            return clone;
        }
        final Object[] objects = new Object[1];
        Protocol.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                objects[0] = FSTreeNode.this.clone();
            }
        });
        return objects[0];
    }

    /**
     * Change the file/folder's write permission.
     * @param b true if the agent is granted with its write permission.
     */
    public void setWritable(boolean b) {
        UserAccount account = getUserAccount(peerNode);
        if (account != null && attr != null) {
            int bit;
            if (attr.uid == account.getEUID()) {
                bit = IFileSystem.S_IWUSR;
            } else if (attr.gid == account.getEGID()) {
                bit = IFileSystem.S_IWGRP;
            } else {
                bit = IFileSystem.S_IWOTH;
            }
            int permissions = attr.permissions;
            setPermissions(b ? (permissions | bit):(permissions & ~ bit));
        }
    }

    /**
     * Set the file's permissions.
     * @param permissions The new permissions.
     */
    public void setPermissions(int permissions) {
        attr = new IFileSystem.FileAttrs(attr.flags, attr.size, attr.uid, attr.gid, permissions, attr.atime, attr.mtime, attr.attributes);
    }

    /**
     * Returns the children outside of TCF thread.
     *
     * @return The children list.
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<FSTreeNode> getChildren() {
        return (List<FSTreeNode>) super.getChildren();
    }

    /**
     * Return if the node is a Windows file/folder node.
     *
     * @return true if it is a Windows node, or else false.
     */
    public boolean isWindowsNode() {
        if (attr != null && attr.attributes != null) {
            return attr.attributes.containsKey(KEY_WIN32_ATTRS);
        }
        if (peerNode != null) {
            String OSName = TargetPropertyTester.getOSName(peerNode);
            if(OSName != null){
                return OSName.startsWith("Windows"); //$NON-NLS-1$
            }
        }
        synchronized (children) {
            if (!children.isEmpty()) {
                for (AbstractTreeNode treeNode : children) {
                    FSTreeNode node = (FSTreeNode) treeNode;
                    if(node.hasOSInfo()) {
                        return node.isWindowsNode();
                    }
                }
            }
        }
        if(parent != null) {
            return ((FSTreeNode)parent).isWindowsNode();
        }
        return false;
    }

    /**
     * If this node has OS information.
     *
     * @return true if it has.
     */
    private boolean hasOSInfo() {
        return attr != null && attr.attributes != null ||
            peerNode != null && TargetPropertyTester.getOSName(peerNode)!= null;
    }

    /**
     * Return if the node is a file.
     *
     * @return true if it is a file, or else false.
     */
    public boolean isFile() {
        if (attr != null) {
            return attr.isFile();
        }
        if (type != null)
        {
            return type.equals("FSFileNode"); //$NON-NLS-1$
        }
        return false;
    }

    /**
     * Return if the node is a directory.
     *
     * @return true if it is a directory, or else false.
     */
    public boolean isDirectory() {
        if (attr != null) {
            return attr.isDirectory();
        }
        if (type != null)
        {
            return type.endsWith("DirNode"); //$NON-NLS-1$
        }
        return false;
    }

    /**
     * Return if the attribute specified by the mask bit is turned on.
     *
     * @param bit
     *            The attribute's mask bit.
     * @return true if it is on, or else false.
     */
    public boolean isWin32AttrOn(int bit) {
        if (attr != null && attr.attributes.get(KEY_WIN32_ATTRS) instanceof Integer) {
            Integer win32Attrs = (Integer) attr.attributes.get(KEY_WIN32_ATTRS);
            return (win32Attrs.intValue() & bit) != 0;
        }
        return false;
    }

    /**
     * Set the attribute specified by the mask bit to on or off.
     * @param bit The attribute's mask bit.
     * @param on The flag if the bit should be turned on or off.
     */
    public void setWin32Attr(int bit, boolean on) {
        if (attr != null && attr.attributes.get(KEY_WIN32_ATTRS) instanceof Integer) {
            int win32attr = ((Integer) attr.attributes.get(KEY_WIN32_ATTRS)).intValue();
            win32attr = on ? (win32attr | bit) : (win32attr & ~bit);
            attr.attributes.put(KEY_WIN32_ATTRS, Integer.valueOf(win32attr));
        }
    }

    /**
     * Get the file's win32 attributes.
     * @return The file's win32 attributes.
     */
    public int getWin32Attrs() {
        if (attr != null && attr.attributes.get(KEY_WIN32_ATTRS) instanceof Integer) {
            return ((Integer) attr.attributes.get(KEY_WIN32_ATTRS)).intValue();
        }
        return 0;
    }

    /**
     * Return if this file/folder is hidden.
     *
     * @return true if it is hidden, or else false.
     */
    public boolean isHidden() {
        return isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_HIDDEN);
    }

    /**
     * Set the file/folder hidden attribute's value.
     * @param hidden The new value.
     */
    public void setHidden(boolean hidden) {
        setWin32Attr(IWindowsFileAttributes.FILE_ATTRIBUTE_HIDDEN, hidden);
    }

    /**
     * Return if this file/folder is read-only.
     *
     * @return true if it is read-only, or else false.
     */
    public boolean isReadOnly() {
        return isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_READONLY);
    }

    /**
     * Set the file/folder read-only attribute's value.
     * @param readOnly The new value.
     */
    public void setReadOnly(boolean readOnly) {
        setWin32Attr(IWindowsFileAttributes.FILE_ATTRIBUTE_READONLY, readOnly);
    }

    /**
     * Get the location of a file/folder node using the format of the file
     * system's platform.
     *
     * @param parentNode
     *            The file/folder node.
     * @return The location of the file/folder.
     */
    public String getLocation() {
        return getLocation(false);
    }

    /**
     * Get the location of a file/folder.
     *
     * @param cross
     *            If the format is cross-platform.
     * @return The path to the file/folder.
     */
    public String getLocation(boolean cross) {
        if(isRoot()) {
            if(cross) {
                if(isWindowsNode()) {
                    return name.substring(0, name.length() - 1) + "/"; //$NON-NLS-1$
                }
            }
            return name;
        }
        String pLoc = getParent().getLocation(cross);
        if(getParent().isRoot()) {
            return pLoc + name;
        }
        String pathSep = (!cross && isWindowsNode()) ? "\\" : "/"; //$NON-NLS-1$ //$NON-NLS-2$
        return pLoc + pathSep + name;
    }

    /**
     * Get the URL of the file or folder. The URL's format is created in the
     * following way: tcf:/<TCF_AGENT_ID>/remote/path/to/the/resource... See
     * {@link TcfURLConnection#TcfURLConnection(URL)}
     *
     * @see TcfURLStreamHandlerService#parseURL(URL, String, int, int)
     * @see #getLocationURI()
     * @return The URL of the file/folder.
     */
    public URL getLocationURL() {
        try {
            String id = peerNode.getPeerId();
            String path = getLocation(true);
            String location = TcfURLConnection.PROTOCOL_SCHEMA + ":/" + id + (path.startsWith("/") ? path : "/" + path); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            return new URL(location);
        } catch (MalformedURLException e) {
            assert false;
            return null;
        }
    }

    /**
     * Get the URI of the file or folder. The URI's format is created in the
     * following way: tcf:/<TCF_AGENT_ID>/remote/path/to/the/resource...
     *
     * @return The URI of the file/folder.
     */
    public URI getLocationURI() {
        try {
            String id = peerNode.getPeerId();
            String path = getEncodedURIPath();
            String location = TcfURLConnection.PROTOCOL_SCHEMA + ":/" + id + (path.startsWith("/") ? path : "/" + path); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            return new URI(location);
        }
        catch (URISyntaxException e) {
            assert false;
            return null;
        }
    }

    /**
     * Encode each segment of the path to a URI compatible name,
     * and get the URI encoded path.
     *
     * @return The encoded path which is URI compatible.
     */
    private String getEncodedURIPath() {
        if(isRoot()) {
            if(isWindowsNode()) {
                return name.substring(0, name.length() - 1) + "/"; //$NON-NLS-1$
            }
            return name;
        }
        final AtomicReference<String> ref = new AtomicReference<String>();
        SafeRunner.run(new ISafeRunnable(){
            @Override
            public void handleException(Throwable exception) {
                // Ignore on purpose
            }
            @Override
            public void run() throws Exception {
                ref.set(URLEncoder.encode(name, "UTF-8")); //$NON-NLS-1$
            }});
        String segment = ref.get();
        String pLoc = getParent().getEncodedURIPath();
        if(getParent().isRoot()) {
            return pLoc + segment;
        }
        return pLoc + "/" + segment; //$NON-NLS-1$
    }

    /**
     * If this node is a root node.
     *
     * @return true if this node is a root node.
     */
    public boolean isRoot() {
        return type != null && type.equals("FSRootDirNode"); //$NON-NLS-1$
    }

    /**
     * If this node is the system root.
     *
     * @return true if this node is the system root.
     */
    @Override
    public boolean isSystemRoot() {
        return type != null && type.equals("FSRootNode"); //$NON-NLS-1$
    }

    /**
     * If this file is readable.
     *
     * @return true if it is readable.
     */
    public boolean isReadable() {
        UserAccount account = getUserAccount(peerNode);
        if (account != null && attr != null) {
            if (attr.uid == account.getEUID()) {
                return (attr.permissions & IFileSystem.S_IRUSR) != 0;
            } else if (attr.gid == account.getEGID()) {
                return (attr.permissions & IFileSystem.S_IRGRP) != 0;
            } else {
                return (attr.permissions & IFileSystem.S_IROTH) != 0;
            }
        }
        return false;
    }

    /**
     * If the agent is the owner of this file/folder.
     *
     * @return true if the agent is the owner of this file/folder.
     */
    public boolean isAgentOwner() {
        UserAccount account = getUserAccount(peerNode);
        if (account != null && attr != null) {
            return attr.uid == account.getEUID();
        }
        return false;
    }

    /**
     * If this file is writable.
     *
     * @return true if it is writable.
     */
    public boolean isWritable() {
        UserAccount account = getUserAccount(peerNode);
        if (account != null && attr != null) {
            if (attr.uid == account.getEUID()) {
                return (attr.permissions & IFileSystem.S_IWUSR) != 0;
            } else if (attr.gid == account.getEGID()) {
                return (attr.permissions & IFileSystem.S_IWGRP) != 0;
            } else {
                return (attr.permissions & IFileSystem.S_IWOTH) != 0;
            }
        }
        return false;
    }

    /**
     * If this file is executable.
     *
     * @return true if it is executable.
     */
    public boolean isExecutable() {
        UserAccount account = getUserAccount(peerNode);
        if (account != null && attr != null) {
            if (attr.uid == account.getEUID()) {
                return (attr.permissions & IFileSystem.S_IXUSR) != 0;
            } else if (attr.gid == account.getEGID()) {
                return (attr.permissions & IFileSystem.S_IXGRP) != 0;
            } else {
                return (attr.permissions & IFileSystem.S_IXOTH) != 0;
            }
        }
        return false;
    }

    /**
     * Test if this file is a windows system file.
     *
     * @return true if it is a windows system file.
     */
    public boolean isSystem() {
        return !isRoot() && isWindowsNode() && isWin32AttrOn(IWindowsFileAttributes.FILE_ATTRIBUTE_SYSTEM);
    }

    /**
     * Get the type label of the file for displaying purpose.
     *
     * @return The type label text.
     */
    public String getFileType() {
        if (isRoot()) {
            return Messages.FSTreeNode_TypeLocalDisk;
        }
        if (isDirectory()) {
            return Messages.FSTreeNode_TypeFileFolder;
        }
        if (isSystem()) {
            return Messages.FSTreeNode_TypeSystemFile;
        }
        IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(name);
        if (contentType != null) {
            return contentType.getName();
        }
        int lastDot = name.lastIndexOf("."); //$NON-NLS-1$
        if (lastDot == -1) {
            return Messages.FSTreeNode_TypeUnknownFile;
        }
        return name.substring(lastDot + 1).toUpperCase() + " " + Messages.FSTreeNode_TypeFile; //$NON-NLS-1$
    }

    /**
     * Set the file's attributes and trigger property change event.
     *
     * @param attrs The new attributes.
     */
    public void setAttributes(FileAttrs attrs) {
        FileAttrs oldAttrs = this.attr;
        this.attr = attrs;
        if (attrs != oldAttrs) {
            firePropertyChange(new PropertyChangeEvent(this, "attributes", oldAttrs, attrs)); //$NON-NLS-1$
        }
    }

    /**
     * Get the local file's state of the specified tree node. The local file must exist
     * before calling this method to get its state.
     *
     * @param node The tree node whose local file state is going to retrieved.
     * @return The tree node's latest cache state.
     */
    public CacheState getCacheState() {
        File file = CacheManager.getCacheFile(this);
        if (!file.exists()) {
            return CacheState.consistent;
        }
        FileState digest = PersistenceManager.getInstance().getFileDigest(this);
        return digest.getCacheState();
    }

    /**
     * Set the file's new name and trigger property change event.
     *
     * @param name The new name.
     */
    public void setName(String name) {
        String oldName = this.name;
        this.name = name;
        if(name == null && oldName != null || name != null && !name.equals(oldName)) {
            firePropertyChange(new PropertyChangeEvent(this, "name", oldName, name)); //$NON-NLS-1$
        }
    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode#doCreateRefreshDoneOpenChannel(org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
     */
    @Override
    protected DoneOpenChannel doCreateRefreshDoneOpenChannel(final ICallback callback) {
        final FileState digest = PersistenceManager.getInstance().getFileDigest(this);
        ICallback cb = new Callback(){
            @Override
            protected void internalDone(Object caller, IStatus status) {
                if (status.isOK() && caller instanceof OpTargetFileDigest) {
                    digest.updateTargetDigest(((OpTargetFileDigest) caller).getDigest());
                }
                if (callback != null) {
                    callback.done(caller, status);
                }
            }
        };
        return new RefreshStateDoneOpenChannel(this, cb);
    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode#doCreateQueryDoneOpenChannel()
     */
    @Override
    protected DoneOpenChannel doCreateQueryDoneOpenChannel(ICallback callback) {
        return new QueryDoneOpenChannel(this, callback);
    }

//    /**
//     * Override the queryChildren to refresh the second level children upon expanding.
//     */
//    @Override
//    public void queryChildren() {
//        queryChildren(new Callback(){
//            @Override
//            protected void internalDone(Object caller, IStatus status) {
//                refreshChildren();
//            }
//        });
//    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode#getParent()
     */
    @Override
    public FSTreeNode getParent() {
        return (FSTreeNode) parent;
    }

    /*
     * (non-Javadoc)
     * @see org.eclipse.tcf.te.tcf.filesystem.core.model.AbstractTreeNode#refreshChildren()
     */
    @Override
    public void refreshChildren(ICallback callback) {
        List<FSTreeNode> children = getChildren();
        if(!children.isEmpty()) {
            ICallback proxy = new Callback(callback){
                @Override
                protected void internalDone(Object caller, IStatus status) {
                    queryDone();
                }
            };
            final CallbackMonitor monitor = new CallbackMonitor(proxy);
            for(FSTreeNode child : children) {
                if((child.isRoot() || child.isDirectory()) && !child.childrenQueried && !child.childrenQueryRunning) {
                    monitor.lock(child.uniqueId);
                }
            }
            for(FSTreeNode child : children) {
                if((child.isRoot() || child.isDirectory()) && !child.childrenQueried && !child.childrenQueryRunning) {
                    final UUID uuid = child.uniqueId;
                    child.queryChildren(new Callback(){
                        @Override
                        protected void internalDone(Object caller, IStatus status) {
                            monitor.unlock(uuid, status);
                        }
                    });
                }
            }
        }
        else {
            if (callback != null) callback.done(this, Status.OK_STATUS);
        }
    }
}

Back to the top