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

Collapse All | Expand All

(-)model/org/eclipse/rse/ui/internal/model/SystemRegistry.java (-69 / +19 lines)
Lines 33-43 Link Here
33
 * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
33
 * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
34
 * Xuan Chen        (IBM)        - [194838] Move the code for comparing two objects by absolute name to a common location
34
 * Xuan Chen        (IBM)        - [194838] Move the code for comparing two objects by absolute name to a common location
35
 * David McKnight   (IBM)        - [165674] Sort subsystem configurations to be in deterministic order
35
 * David McKnight   (IBM)        - [165674] Sort subsystem configurations to be in deterministic order
36
 * Martin Oberhuber (Wind River) - [165674] Sort subsystem configurations by Id rather than name
36
 ********************************************************************************/
37
 ********************************************************************************/
37
38
38
package org.eclipse.rse.ui.internal.model;
39
package org.eclipse.rse.ui.internal.model;
39
import java.util.ArrayList;
40
import java.util.ArrayList;
40
import java.util.Arrays;
41
import java.util.Arrays;
42
import java.util.Comparator;
41
import java.util.Iterator;
43
import java.util.Iterator;
42
import java.util.List;
44
import java.util.List;
43
import java.util.Vector;
45
import java.util.Vector;
Lines 258-266 Link Here
258
	 */
260
	 */
259
	public void setSubSystemConfigurationProxies(ISubSystemConfigurationProxy[] proxies)
261
	public void setSubSystemConfigurationProxies(ISubSystemConfigurationProxy[] proxies)
260
	{
262
	{
261
		subsystemConfigurationProxies = proxies;
263
		//[165674]: Sort proxies by ID in order to get deterministic results
262
		//for (int idx=0; idx<proxies.length; idx++)
264
		//on all getSubSystemConfiguration*() queries
263
		// proxies[idx].setLogFile(logFile);
265
		ISubSystemConfigurationProxy[] newProxies = (ISubSystemConfigurationProxy[])proxies.clone();
266
		Arrays.sort(newProxies, new Comparator(){
267
			public int compare(Object o1, Object o2) {
268
				String t1 = ((ISubSystemConfigurationProxy) o1).getId();
269
				String t2 = ((ISubSystemConfigurationProxy) o2).getId();
270
				return t1.compareTo(t2);
271
			}
272
		});
273
		//for (int idx=0; idx<newProxies.length; idx++)
274
		// newProxies[idx].setLogFile(logFile);
275
		subsystemConfigurationProxies = newProxies;
264
	}
276
	}
265
	/**
277
	/**
266
	 * Public method to retrieve list of subsystem factory proxies registered by extension points.
278
	 * Public method to retrieve list of subsystem factory proxies registered by extension points.
Lines 308-317 Link Here
308
320
309
321
310
322
311
	/**
323
	/*
312
	 * Return all subsystem factories which support the given system type.
324
	 * (non-Javadoc)
313
	 * If the type is null, returns all.
325
	 * @see org.eclipse.rse.core.model.ISystemRegistry#getSubSystemConfigurationsBySystemType(org.eclipse.rse.core.IRSESystemType, boolean)
314
	 * 
315
	 */
326
	 */
316
	public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, boolean filterDuplicateServiceSubSystemFactories)
327
	public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, boolean filterDuplicateServiceSubSystemFactories)
317
	{
328
	{
Lines 360-387 Link Here
360
								
371
								
361
								v.addElement(ssFactory);
372
								v.addElement(ssFactory);
362
							}
373
							}
363
							else // for 165674 - fix the order to be deterministic
364
							{					
365
								// replace with this one if this is first alphabetically
366
								// find the current one
367
								for (int i = 0; i < v.size(); i++)
368
								{
369
									if (v.get(i) instanceof IServiceSubSystemConfiguration)
370
									{		
371
										IServiceSubSystemConfiguration addedConfig = (IServiceSubSystemConfiguration)v.get(i);
372
										if (addedConfig.getServiceType() == serviceType)
373
										{
374
											if (serviceFactory.getName().compareTo(addedConfig.getName()) <= 0)
375
											{
376
												v.remove(addedConfig);
377
												v.add(serviceFactory);
378
											}											
374
											}											
379
										}
380
									}
381
								}
382
						
383
							}
384
						}
385
						else
375
						else
386
						{
376
						{
387
							v.addElement(ssFactory);
377
							v.addElement(ssFactory);
Lines 390-439 Link Here
390
				}
380
				}
391
			}
381
			}
392
		}
382
		}
393
		
383
		ISubSystemConfiguration[] factories = (ISubSystemConfiguration[])v.toArray(new ISubSystemConfiguration[v.size()]);
394
		v = sortConfigurations(v);
395
		ISubSystemConfiguration[] factories = new ISubSystemConfiguration[v.size()];
396
		
397
		for (int idx = 0; idx < v.size(); idx++)
398
			factories[idx] = (ISubSystemConfiguration) v.elementAt(idx);
399
		return factories;
384
		return factories;
400
	}
385
	}
401
	
386
	
402
	private Vector sortConfigurations(Vector v)
403
	{
404
		Vector sorted = new Vector(v.size());
405
		while (v.size() > 0)
406
		{
407
			ISubSystemConfiguration first = firstConfiguration(v);
408
			sorted.add(first);
409
			v.remove(first);
410
		}
411
		return sorted;
412
	}
413
	
414
	private ISubSystemConfiguration firstConfiguration(Vector v)
415
	{
416
		ISubSystemConfiguration first = null;
417
		for (int i = 0; i < v.size(); i++)
418
		{
419
			ISubSystemConfiguration next = (ISubSystemConfiguration)v.get(i);
420
			if (first == null)
421
			{
422
				first = next;
423
			}
424
			else
425
			{
426
				String name1 = first.getName();
427
				String name2 = next.getName();
428
				if (name2.compareTo(name1) <= 0)
429
				{
430
					first = next;
431
				}
432
			}
433
		}
434
		return first;
435
	}
436
	
437
387
438
	// ----------------------------
388
	// ----------------------------
439
	// USER PREFERENCE METHODS...
389
	// USER PREFERENCE METHODS...
(-)src/org/eclipse/rse/core/model/ISystemRegistry.java (-3 / +3 lines)
Lines 97-108 Link Here
97
	public ISubSystemConfiguration getSubSystemConfiguration(String id);
97
	public ISubSystemConfiguration getSubSystemConfiguration(String id);
98
98
99
	/**
99
	/**
100
	 * Return all subsystem factories which support the given system type.
100
	 * Return all subsystem configurations which support the given system type.
101
	 * If the type is null, returns all.
101
	 * If the type is null, returns all.
102
	 * @param systemType system type to filter
102
	 * @param systemType system type to filter
103
	 * @param filterDuplicateServiceSubSystemFactories set false by default
103
	 * @param filterDuplicateServiceSubSystemConfigurations set false by default
104
	 */
104
	 */
105
	public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, boolean filterDuplicateServiceSubSystemFactories);
105
	public ISubSystemConfiguration[] getSubSystemConfigurationsBySystemType(IRSESystemType systemType, boolean filterDuplicateServiceSubSystemConfigurations);
106
	
106
	
107
	// ----------------------------------
107
	// ----------------------------------
108
	// SYSTEMVIEWINPUTPROVIDER METHODS...
108
	// SYSTEMVIEWINPUTPROVIDER METHODS...

Return to bug 165674