View | Details | Raw Unified | Return to bug 233461 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java (-9 / +78 lines)
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;
(-)src/org/eclipse/rse/subsystems/files/core/servicesubsystem/AbstractRemoteFile.java (-1 / +12 lines)
Lines 14-19 Link Here
14
 * Contributors:
14
 * Contributors:
15
 * David McKnight   (IBM)        - [231209] [api][breaking] IRemoteFile.getSystemConnection() should be changed to IRemoteFile.getHost()
15
 * David McKnight   (IBM)        - [231209] [api][breaking] IRemoteFile.getSystemConnection() should be changed to IRemoteFile.getHost()
16
 * Martin Oberhuber (Wind River) - [234726] Update IRemoteFile Javadocs
16
 * Martin Oberhuber (Wind River) - [234726] Update IRemoteFile Javadocs
17
 * David McKnight   (IBM)        - [223461] [Refresh][api] Refresh expanded folder under filter refreshes Filter
17
 *******************************************************************************/
18
 *******************************************************************************/
18
19
19
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
20
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
Lines 199-204 Link Here
199
	{
200
	{
200
		return _hostFile;
201
		return _hostFile;
201
	}
202
	}
202
203
	
204
	/**
205
	 * Replacing the current associated IHostFile with a new one
206
	 * 
207
	 * @param hostFile the new host file 
208
	 * 
209
	 * @since 3.0
210
	 */
211
	public void setHostFile(IHostFile hostFile) {
212
		_hostFile = hostFile;
213
	}
203
214
204
}
215
}
(-)UI/org/eclipse/rse/internal/ui/view/SystemView.java (-40 / +36 lines)
Lines 1357-1362 Link Here
1357
		}
1357
		}
1358
	}
1358
	}
1359
1359
1360
	
1360
	/**
1361
	/**
1361
	 * Clear current selection. Ignore widget disposed message.
1362
	 * Clear current selection. Ignore widget disposed message.
1362
	 */
1363
	 */
Lines 1366-1371 Link Here
1366
		} catch (Exception exc) {
1367
		} catch (Exception exc) {
1367
		}
1368
		}
1368
	}
1369
	}
1370
			
1371
1369
1372
1370
	/**
1373
	/**
1371
	 * Returns the implementation of ISystemViewElementAdapter for the given
1374
	 * Returns the implementation of ISystemViewElementAdapter for the given
Lines 2226-2231 Link Here
2226
			case ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE:
2229
			case ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE:
2227
				if (debug) logDebugMsg("SV event: EVENT_REFRESH_REMOTE: src = " + src); //$NON-NLS-1$
2230
				if (debug) logDebugMsg("SV event: EVENT_REFRESH_REMOTE: src = " + src); //$NON-NLS-1$
2228
				
2231
				
2232
				// Fake expanded is set to the item for the src object if the object is in a collapsed state and
2233
				// resides directly under a filter.  The item is artificially expanded in order to allow 
2234
				// refreshRemoteObject() to go through with a query of the item.  After the query is kicked off, 
2235
				// fakeExpanded is contracted in order to retain the original tree expand state.
2236
				TreeItem fakeExpanded = null;
2229
				
2237
				
2230
				ISystemViewElementAdapter adapter = getViewAdapter(src);
2238
				ISystemViewElementAdapter adapter = getViewAdapter(src);
2231
				if (adapter != null)
2239
				if (adapter != null)
Lines 2233-2249 Link Here
2233
					// we need to refresh filters
2241
					// we need to refresh filters
2234
					ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
2242
					ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
2235
					
2243
					
2244
					// if this is a filter reference, we just need to refresh it
2245
					if (src instanceof ISystemFilterReference)
2246
					{
2247
						refresh(src);
2248
						break;
2249
					}
2250
					
2251
					// need to find filter references contain this object
2236
		        	List filterReferences = sr.findFilterReferencesFor(src, adapter.getSubSystem(src), false);
2252
		        	List filterReferences = sr.findFilterReferencesFor(src, adapter.getSubSystem(src), false);
2237
		        	// if filters reference this resource we need them refreshed
2238
		        	for (int f = 0; f < filterReferences.size(); f++)
2239
		        	{
2240
		        		ISystemFilterReference ref = (ISystemFilterReference)filterReferences.get(f);
2241
		        		if (!ref.isStale())
2242
		        		{
2243
		        			ref.markStale(true);
2244
		        			smartRefresh(ref, true);
2245
		        		}
2246
		        	}	
2247
		        	
2253
		        	
2248
					// first, find out if src is a container or not
2254
					// first, find out if src is a container or not
2249
					// if it's a container, just pass into refreshRemoteObject
2255
					// if it's a container, just pass into refreshRemoteObject
Lines 2280-2324 Link Here
2280
									TreeItem[] titems = titem.getItems();
2286
									TreeItem[] titems = titem.getItems();
2281
									if (titems.length >  0 && !titem.getExpanded())
2287
									if (titems.length >  0 && !titem.getExpanded())
2282
									{
2288
									{
2283
										src = adapter.getParent(src);
2289
										
2284
									}
2290
										// if filterReferences is not empty, then this is contained directly under a filter
2285
								}
2291
										if (filterReferences.size() > 0){
2286
									
2292
											// the item is artificially expanded in order to allow the query to go through in
2287
								/* old code - issue in 196662
2293
											// refreshRemoteObject()
2288
								String key = adapter.getAbsoluteName(src);
2294
											titem.setExpanded(true);
2289
								if (key != null)
2295
											
2290
								{
2296
											// we set this so that after calling refreshRemoteObject(), the item can be re-collapsed
2291
									try
2297
											fakeExpanded = titem;
2292
									{
2298
										}
2293
										Object srcParent = adapter.getParent(src); // get parent before we query 
2299
										else {
2294
										                                           // because if after query src doesn't exist, 
2300
											src = adapter.getParent(src);
2295
																			  	   // we can't get parent
2296
										if (srcParent != null)
2297
										{	
2298
											src = ss.getObjectWithAbsoluteName(key);
2299
											hasChildren = adapter.hasChildren((IAdaptable)src);
2300
											if (!hasChildren)
2301
											{
2302
												// make the src the parent of the src
2303
												src = srcParent;
2304
											}
2305
										}
2301
										}
2306
									}
2307
									catch (Exception e)
2308
									{
2309
										e.printStackTrace();
2310
									}
2302
									}
2311
								}
2303
								}
2312
								*/
2313
							}
2304
							}
2314
						}
2305
						}
2315
					}
2306
					}
2316
				}
2307
				}
2317
				
2308
				
2318
				refreshRemoteObject(src, parent, originatedHere);
2309
				refreshRemoteObject(src, parent, originatedHere);
2319
		
2310
				if (fakeExpanded != null)
2320
	        		
2311
					fakeExpanded.setExpanded(false);
2321
	        	
2312
	        			        	
2322
				break;
2313
				break;
2323
			case ISystemResourceChangeEvents.EVENT_SELECT_REMOTE:
2314
			case ISystemResourceChangeEvents.EVENT_SELECT_REMOTE:
2324
				if (debug) logDebugMsg("SV event: EVENT_SELECT_REMOTE: src = " + src); //$NON-NLS-1$
2315
				if (debug) logDebugMsg("SV event: EVENT_SELECT_REMOTE: src = " + src); //$NON-NLS-1$
Lines 6383-6386 Link Here
6383
		}		
6374
		}		
6384
	}
6375
	}
6385
	
6376
	
6377
	/** commented out - this is workaround for performance problem
6378
	protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
6379
		//System.out.println("handleLableProviderChanged");
6380
	}*/
6381
	
6386
}
6382
}

Return to bug 233461