Lines 406-473
Link Here
|
406 |
} |
406 |
} |
407 |
|
407 |
|
408 |
/** |
408 |
/** |
409 |
* Move existing connections a given number of positions in the same pool. |
409 |
* Move existing hosts a given number of positions in the same pool. |
410 |
* If the delta is negative, they are all moved up by the given amount. If |
410 |
* If the delta is negative, they are all moved up (left) by the given amount. If |
411 |
* positive, they are all moved down by the given amount.<p> |
411 |
* positive, they are all moved down (right) by the given amount.<p> |
412 |
* <ul> |
412 |
* After the move, the pool containing the moved host is committed. |
413 |
* <li>After the move, the pool containing the moved connection is saved to disk. |
413 |
* @param conns an Array of hosts to move. |
414 |
* <li>The connection's alias name must be unique in pool. |
414 |
* @param delta the amount by which to move the hosts |
415 |
* </ul> |
415 |
*/ |
416 |
* <b>TODO PROBLEM: CAN'T RE-ORDER FOLDERS SO CAN WE SUPPORT THIS ACTION?</b> |
416 |
public void moveHosts(IHost conns[], int delta) { |
417 |
* @param conns Array of SystemConnections to move. |
417 |
for (int idx = 0; idx < conns.length; idx++) { |
418 |
* @param delta the amount by which to move the connections |
418 |
moveConnection(conns[idx], delta); |
419 |
*/ |
419 |
} |
420 |
public void moveHosts(IHost conns[], int delta) |
420 |
commit(); |
421 |
{ |
421 |
} |
422 |
int[] oldPositions = new int[conns.length]; |
|
|
423 |
for (int idx=0; idx<conns.length; idx++) |
424 |
oldPositions[idx] = getHostPosition(conns[idx]); |
425 |
if (delta > 0) // moving down, process backwards |
426 |
for (int idx=conns.length-1; idx>=0; idx--) |
427 |
moveConnection(conns[idx], oldPositions[idx]+delta); |
428 |
else |
429 |
for (int idx=0; idx<conns.length; idx++) |
430 |
moveConnection(conns[idx], oldPositions[idx]+delta); |
431 |
|
432 |
commit(); |
433 |
} |
434 |
|
422 |
|
435 |
/** |
423 |
/** |
436 |
* Move one connection to a new location |
424 |
* Move a host to a new location in the host pool. |
437 |
* <b>TODO PROBLEM: CAN'T RE-ORDER FOLDERS SO CAN WE SUPPORT THIS ACTION?</b> |
425 |
* @param host the host to move. If not present then the list is not altered. |
438 |
*/ |
426 |
* @param newPos the amount by which to move the host. If outside the bounds of the list, the list is not altered. |
439 |
private void moveConnection(IHost conn, int newPos) |
427 |
* If 0 then the list is not altered. |
440 |
{ |
428 |
*/ |
441 |
/* |
429 |
private void moveConnection(IHost host, int delta) { |
442 |
* DWD revisit, make sure that connections can be "moved", whatever that means. |
430 |
if (host == null) return; |
443 |
* It appears that connections can be moved up and down in the list which |
431 |
List hostList = getHostList(); |
444 |
* probably provides for some rational for keeping this around. |
432 |
int oldPos = hostList.indexOf(host); |
445 |
*/ |
433 |
if (oldPos < 0) return; |
446 |
// java.util.List connList = getHostList(); |
434 |
if (delta == 0) return; |
447 |
//FIXME connList.move(newPos, conn); |
435 |
int newPos = oldPos + delta; |
448 |
invalidateCache(); |
436 |
if (newPos < 0) return; |
449 |
} |
437 |
if (newPos > hostList.size()) return; |
|
|
438 |
hostList.remove(oldPos); |
439 |
hostList.add(newPos, host); |
440 |
invalidateCache(); |
441 |
} |
450 |
|
442 |
|
451 |
/** |
443 |
/** |
452 |
* Order connections according to user preferences. |
444 |
* Order connections according to user preferences. |
453 |
* Called after restore. |
445 |
* Called after restore. |
454 |
*/ |
446 |
*/ |
455 |
public void orderHosts(String[] names) |
447 |
public void orderHosts(String[] names) { |
456 |
{ |
448 |
List connList = getHostList(); |
457 |
java.util.List connList = getHostList(); |
449 |
IHost[] conns = new IHost[names.length]; |
458 |
IHost[] conns = new IHost[names.length]; |
450 |
for (int idx = 0; idx < conns.length; idx++) { |
459 |
for (int idx=0; idx<conns.length; idx++) |
451 |
conns[idx] = getHost(names[idx]); |
460 |
conns[idx] = getHost(names[idx]); |
452 |
} |
461 |
connList.clear(); |
453 |
connList.clear(); |
462 |
//System.out.println("Ordering connections within pool " + getName() + "..."); |
454 |
for (int idx = 0; idx < conns.length; idx++) { |
463 |
for (int idx=0; idx<conns.length; idx++) |
455 |
connList.add(conns[idx]); |
464 |
{ |
456 |
} |
465 |
connList.add(conns[idx]); |
457 |
invalidateCache(); |
466 |
//System.out.println(" '"+conns[idx].getAliasName()+"'"); |
458 |
} |
467 |
} |
|
|
468 |
//System.out.println(); |
469 |
invalidateCache(); |
470 |
} |
471 |
|
459 |
|
472 |
/** |
460 |
/** |
473 |
* Return the unqualified save file name with the extension .xmi |
461 |
* Return the unqualified save file name with the extension .xmi |