Lines 423-429
Link Here
|
423 |
RemoteFileContext context = getDefaultContext(); |
423 |
RemoteFileContext context = getDefaultContext(); |
424 |
|
424 |
|
425 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); |
425 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); |
426 |
|
426 |
List filteredList = new ArrayList(); |
|
|
427 |
|
428 |
IHostFile newParent = null; |
429 |
|
427 |
// caching |
430 |
// caching |
428 |
for (int i = 0; i < parents.length; i++) |
431 |
for (int i = 0; i < parents.length; i++) |
429 |
{ |
432 |
{ |
Lines 441-455
Link Here
|
441 |
if (parentPath.equals(childParentPath)) |
444 |
if (parentPath.equals(childParentPath)) |
442 |
{ |
445 |
{ |
443 |
underParent.add(child); |
446 |
underParent.add(child); |
|
|
447 |
filteredList.add(child); |
448 |
} |
449 |
else if (parentPath.equals(child.getAbsolutePath())) // child is the parent - used for optimized update |
450 |
{ |
451 |
newParent = child.getHostFile(); |
452 |
|
453 |
// don't add to the filteredList |
444 |
} |
454 |
} |
445 |
} |
455 |
} |
446 |
if (underParent.size() > 0) |
456 |
if (underParent.size() > 0) |
447 |
{ |
457 |
{ |
448 |
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray()); |
458 |
IRemoteFile[] qresults = (IRemoteFile[])underParent.toArray(new IRemoteFile[underParent.size()]); |
|
|
459 |
|
460 |
// update the remote file |
461 |
updateRemoteFile(parent, newParent, monitor); |
462 |
|
463 |
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); |
449 |
} |
464 |
} |
450 |
} |
465 |
} |
451 |
|
466 |
|
452 |
return farr; |
467 |
return (IRemoteFile[])filteredList.toArray(new IRemoteFile[filteredList.size()]); |
453 |
} |
468 |
} |
454 |
|
469 |
|
455 |
|
470 |
|
Lines 469-474
Link Here
|
469 |
parentPaths[i] = parents[i].getAbsolutePath(); |
484 |
parentPaths[i] = parents[i].getAbsolutePath(); |
470 |
} |
485 |
} |
471 |
|
486 |
|
|
|
487 |
|
472 |
List hostFiles = new ArrayList(10); |
488 |
List hostFiles = new ArrayList(10); |
473 |
getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor); |
489 |
getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor); |
474 |
IHostFile[] results = new IHostFile[hostFiles.size()]; |
490 |
IHostFile[] results = new IHostFile[hostFiles.size()]; |
Lines 476-482
Link Here
|
476 |
RemoteFileContext context = getDefaultContext(); |
492 |
RemoteFileContext context = getDefaultContext(); |
477 |
|
493 |
|
478 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); |
494 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results); |
479 |
|
495 |
List filteredList = new ArrayList(); |
|
|
496 |
|
497 |
IHostFile newParent = null; |
498 |
|
480 |
// caching |
499 |
// caching |
481 |
for (int i = 0; i < parents.length; i++) |
500 |
for (int i = 0; i < parents.length; i++) |
482 |
{ |
501 |
{ |
Lines 495-508
Link Here
|
495 |
{ |
514 |
{ |
496 |
underParent.add(child); |
515 |
underParent.add(child); |
497 |
} |
516 |
} |
|
|
517 |
else if (parentPath.equals(child.getAbsolutePath())) // child is the parent - used for optimized update |
518 |
{ |
519 |
newParent = child.getHostFile(); |
520 |
|
521 |
// don't add to the filteredList |
522 |
} |
498 |
} |
523 |
} |
499 |
if (underParent.size() > 0) |
524 |
if (underParent.size() > 0) |
500 |
{ |
525 |
{ |
501 |
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray()); |
526 |
IRemoteFile[] qresults = (IRemoteFile[])underParent.toArray(new IRemoteFile[underParent.size()]); |
|
|
527 |
|
528 |
// update the remote file |
529 |
updateRemoteFile(parent, newParent, monitor); |
530 |
|
531 |
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults); |
502 |
} |
532 |
} |
503 |
} |
533 |
} |
504 |
|
534 |
|
505 |
return farr; |
535 |
return (IRemoteFile[])filteredList.toArray(new IRemoteFile[filteredList.size()]); |
506 |
} |
536 |
} |
507 |
|
537 |
|
508 |
|
538 |
|
Lines 535-551
Link Here
|
535 |
IStatus.INFO, msgTxt); |
565 |
IStatus.INFO, msgTxt); |
536 |
throw new SystemMessageException(msg); |
566 |
throw new SystemMessageException(msg); |
537 |
} |
567 |
} |
538 |
|
568 |
|
539 |
IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); |
569 |
IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); |
540 |
|
570 |
List filteredResults = new ArrayList(); |
|
|
571 |
IHostFile newHostParent = null; |
572 |
// look for the file that doesn't have parent as it's parent path |
573 |
// to determine whether we have an updated parent in the results |
574 |
for (int i = 0; i < results.length; i++){ |
575 |
IHostFile result = results[i]; |
576 |
if (!result.getParentPath().equals(parentPath)){ |
577 |
newHostParent = result; // the child is the same as the parent |
578 |
// keep the parent out of the results |
579 |
} |
580 |
else { |
581 |
filteredResults.add(result); |
582 |
} |
583 |
} |
584 |
|
585 |
results = (IHostFile[])filteredResults.toArray(new IHostFile[filteredResults.size()]); |
586 |
|
587 |
updateRemoteFile(parent, newHostParent, monitor); |
588 |
|
541 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
589 |
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); |
542 |
if (parent != null) |
590 |
if (parent != null) |
543 |
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); |
591 |
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); |
544 |
return farr; |
592 |
return farr; |
545 |
} |
593 |
} |
546 |
|
594 |
|
|
|
595 |
|
596 |
|
597 |
private void updateRemoteFile(IRemoteFile parent, IHostFile newHostParent, IProgressMonitor monitor) throws SystemMessageException |
598 |
{ |
599 |
// now newHostParent file passed in so we'll assume it wasn't returned and explicitly get it |
600 |
if (newHostParent == null){ |
601 |
String parentParentPath = parent.getParentPath(); |
602 |
if (parentParentPath == null){ |
603 |
parentParentPath = ""; //$NON-NLS-1$ |
604 |
} |
605 |
newHostParent = getFileService().getFile(parentParentPath, parent.getName(), monitor); |
606 |
} |
607 |
|
608 |
if (newHostParent != null){ |
609 |
IHostFile oldHostParent = parent.getHostFile(); |
610 |
if (!newHostParent.equals(oldHostParent)){ |
611 |
((AbstractRemoteFile)parent).setHostFile(newHostParent); |
612 |
parent.markStale(false); |
613 |
} |
614 |
} |
615 |
} |
547 |
|
616 |
|
548 |
|
617 |
|
549 |
public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException |
618 |
public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException |
550 |
{ |
619 |
{ |
551 |
IHostFile[] roots = null; |
620 |
IHostFile[] roots = null; |