Lines 17-22
Link Here
|
17 |
* Kevin Doyle (IBM) - [189150] _selectionFlagsUpdated reset after clear action performed |
17 |
* Kevin Doyle (IBM) - [189150] _selectionFlagsUpdated reset after clear action performed |
18 |
* Kevin Doyle (IBM) - [195537] Use Hashlookup and ElementComparer |
18 |
* Kevin Doyle (IBM) - [195537] Use Hashlookup and ElementComparer |
19 |
* Kevin Doyle (IBM) - [189423] Scratchpad not completely updated after Delete. |
19 |
* Kevin Doyle (IBM) - [189423] Scratchpad not completely updated after Delete. |
|
|
20 |
* Kevin Doyle (IBM) - [193151] Scratchpad not updated on Move |
20 |
********************************************************************************/ |
21 |
********************************************************************************/ |
21 |
|
22 |
|
22 |
package org.eclipse.rse.internal.ui.view.scratchpad; |
23 |
package org.eclipse.rse.internal.ui.view.scratchpad; |
Lines 94-107
Link Here
|
94 |
import org.eclipse.rse.ui.view.ISystemSelectAllTarget; |
95 |
import org.eclipse.rse.ui.view.ISystemSelectAllTarget; |
95 |
import org.eclipse.rse.ui.view.ISystemViewElementAdapter; |
96 |
import org.eclipse.rse.ui.view.ISystemViewElementAdapter; |
96 |
import org.eclipse.rse.ui.view.SystemAdapterHelpers; |
97 |
import org.eclipse.rse.ui.view.SystemAdapterHelpers; |
97 |
import org.eclipse.swt.SWT; |
|
|
98 |
import org.eclipse.swt.custom.BusyIndicator; |
98 |
import org.eclipse.swt.custom.BusyIndicator; |
99 |
import org.eclipse.swt.dnd.DND; |
99 |
import org.eclipse.swt.dnd.DND; |
100 |
import org.eclipse.swt.dnd.FileTransfer; |
100 |
import org.eclipse.swt.dnd.FileTransfer; |
101 |
import org.eclipse.swt.dnd.TextTransfer; |
101 |
import org.eclipse.swt.dnd.TextTransfer; |
102 |
import org.eclipse.swt.dnd.Transfer; |
102 |
import org.eclipse.swt.dnd.Transfer; |
103 |
import org.eclipse.swt.events.KeyAdapter; |
|
|
104 |
import org.eclipse.swt.events.KeyEvent; |
105 |
import org.eclipse.swt.events.MouseAdapter; |
103 |
import org.eclipse.swt.events.MouseAdapter; |
106 |
import org.eclipse.swt.events.MouseEvent; |
104 |
import org.eclipse.swt.events.MouseEvent; |
107 |
import org.eclipse.swt.widgets.Composite; |
105 |
import org.eclipse.swt.widgets.Composite; |
Lines 176-181
Link Here
|
176 |
private static final int LEFT_BUTTON = 1; |
174 |
private static final int LEFT_BUTTON = 1; |
177 |
private int mouseButtonPressed = LEFT_BUTTON; |
175 |
private int mouseButtonPressed = LEFT_BUTTON; |
178 |
|
176 |
|
|
|
177 |
public boolean debugRemote = false; |
178 |
|
179 |
/** |
179 |
/** |
180 |
* Constructor for the table view |
180 |
* Constructor for the table view |
181 |
* |
181 |
* |
Lines 457-463
Link Here
|
457 |
// -------------------------- |
457 |
// -------------------------- |
458 |
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED : |
458 |
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED : |
459 |
{ |
459 |
{ |
460 |
internalRefresh(remoteResourceParent); |
460 |
// Since all creation operations can only be done on the same parent |
|
|
461 |
// we only need to handle refreshing of the parent |
462 |
// Must handle String's as Move operation create event passes us Strings |
463 |
if (remoteResourceParent instanceof String) |
464 |
{ |
465 |
Item item = findFirstRemoteItemReference((String) remoteResourceParent, null, null); |
466 |
if (item != null) |
467 |
internalRefresh(item.getData()); |
468 |
} |
469 |
else |
470 |
{ |
471 |
internalRefresh(remoteResourceParent); |
472 |
} |
461 |
} |
473 |
} |
462 |
break; |
474 |
break; |
463 |
|
475 |
|
Lines 466-485
Link Here
|
466 |
// -------------------------- |
478 |
// -------------------------- |
467 |
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED : |
479 |
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED : |
468 |
{ |
480 |
{ |
469 |
// check if remoteResource is a root in Scratchpad and if so remove it |
481 |
if (remoteResourceNames != null) |
470 |
SystemScratchpad scratchpad = SystemRegistryUI.getInstance().getSystemScratchPad(); |
482 |
{ |
471 |
if (scratchpad.contains(remoteResource)) |
483 |
for (int i = 0; i < remoteResourceNames.size(); i++) |
472 |
scratchpad.removeChild(remoteResource); |
484 |
{ |
473 |
|
485 |
deleteRemoteObject(remoteResourceNames.get(i)); |
474 |
// find all references to the remote resource and remove them |
486 |
} |
475 |
Widget[] widgets = findItems(remoteResource); |
487 |
} |
476 |
for (int i = 0; i < widgets.length; i++) |
488 |
else |
477 |
{ |
489 |
{ |
478 |
if (widgets[i] instanceof TreeItem) |
490 |
deleteRemoteObject(remoteResource); |
479 |
{ |
491 |
} |
480 |
remove(getTreePathFromItem((TreeItem) widgets[i])); |
|
|
481 |
} |
482 |
} |
483 |
|
492 |
|
484 |
/* |
493 |
/* |
485 |
{ |
494 |
{ |
Lines 1569-1572
Link Here
|
1569 |
} |
1578 |
} |
1570 |
super.add(parentElementOrTreePath, childElements); |
1579 |
super.add(parentElementOrTreePath, childElements); |
1571 |
} |
1580 |
} |
|
|
1581 |
|
1582 |
/** |
1583 |
* Delete all occurrences of a given remote object |
1584 |
*/ |
1585 |
protected void deleteRemoteObject(Object deleteObject) |
1586 |
{ |
1587 |
// If deleteObject is a string find it's tree item and get it's data as thats what's |
1588 |
// stored inside the SystemScratchpad |
1589 |
if (deleteObject instanceof String) |
1590 |
{ |
1591 |
Item item = findFirstRemoteItemReference((String) deleteObject,null,null); |
1592 |
if (item == null) |
1593 |
return; |
1594 |
else |
1595 |
deleteObject = item.getData(); |
1596 |
} |
1597 |
|
1598 |
// check if remoteResource is a root in Scratchpad and if so remove it |
1599 |
SystemScratchpad scratchpad = SystemRegistryUI.getInstance().getSystemScratchPad(); |
1600 |
if (scratchpad.contains(deleteObject)) |
1601 |
scratchpad.removeChild(deleteObject); |
1602 |
|
1603 |
// find all references to the remote resource and remove them |
1604 |
Widget[] widgets = findItems(deleteObject); |
1605 |
for (int i = 0; i < widgets.length; i++) |
1606 |
{ |
1607 |
if (widgets[i] instanceof TreeItem) |
1608 |
{ |
1609 |
remove(getTreePathFromItem((TreeItem) widgets[i])); |
1610 |
} |
1611 |
} |
1612 |
|
1613 |
} |
1614 |
|
1615 |
//TODO: |
1616 |
// ---------------------------------------------------------------- |
1617 |
// Functions Below are pure copies of the ones from SystemView |
1618 |
// and as such should be moved to a common location |
1619 |
// or with 3.0 remove all need for Recursive methods - Preferred |
1620 |
// ---------------------------------------------------------------- |
1621 |
|
1622 |
/** |
1623 |
* Find the first binary-match or name-match of remote object, given its absolute name. |
1624 |
* @param remoteObjectName The absolute name of the remote object to find. |
1625 |
* @param subsystem The subsystem of the remote object to find. Optional. |
1626 |
* @param parentItem The parent item at which to start the search. Optional. |
1627 |
* @return TreeItem hit if found |
1628 |
*/ |
1629 |
public Item findFirstRemoteItemReference(String remoteObjectName, ISubSystem subsystem, Item parentItem) { |
1630 |
//List matches = new Vector(); |
1631 |
Item match = null; |
1632 |
if (parentItem == null) |
1633 |
//findAllRemoteItemReferences(remoteObjectName, null, subsystem, matches); |
1634 |
match = internalFindFirstRemoteItemReference(remoteObjectName, null, subsystem); |
1635 |
else { |
1636 |
|
1637 |
//recursiveFindAllRemoteItemReferences(parentItem, remoteObjectName, null, subsystem, matches); |
1638 |
match = recursiveFindFirstRemoteItemReference(parentItem, remoteObjectName, null, subsystem); |
1639 |
} |
1640 |
//if (matches.size() > 0) |
1641 |
// return (Item)matches.elementAt(0); |
1642 |
//else |
1643 |
// return null; |
1644 |
return match; |
1645 |
} |
1646 |
|
1647 |
/** |
1648 |
* Recursively tries to find the first occurrence of a given remote object, starting at the tree root. |
1649 |
* Optionally scoped to a specific subsystem. |
1650 |
* Since the object memory object for a remote object is not dependable we call getAbsoluteName() |
1651 |
* on the adapter to do the comparisons. |
1652 |
* <p> |
1653 |
* This overload takes a string and a subsystem. |
1654 |
* |
1655 |
* @param searchString the absolute name of the remote object to which we want to find a tree item which references it. |
1656 |
* @param elementObject the actual remote element to find, for binary matching |
1657 |
* @param subsystem optional subsystem to search within |
1658 |
* @return TreeItem hit if found |
1659 |
*/ |
1660 |
protected Item internalFindFirstRemoteItemReference(String searchString, Object elementObject, ISubSystem subsystem) { |
1661 |
Item[] roots = getTree().getItems(); |
1662 |
if ((roots == null) || (roots.length == 0)) return null; |
1663 |
|
1664 |
// use map first |
1665 |
Item match = mappedFindFirstRemoteItemReference(elementObject); |
1666 |
|
1667 |
for (int idx = 0; (match == null) && (idx < roots.length); idx++) { |
1668 |
//System.out.println("recursiveFindFirstRemoteItemReference(parentItem, remoteObjectName, remoteObject, subsystem)"); |
1669 |
match = recursiveFindFirstRemoteItemReference(roots[idx], searchString, elementObject, subsystem); |
1670 |
} |
1671 |
|
1672 |
return match; |
1673 |
} |
1674 |
|
1675 |
protected Item mappedFindFirstRemoteItemReference(Object elementObject) |
1676 |
{ |
1677 |
return (Item)findItem(elementObject); |
1678 |
} |
1679 |
|
1680 |
/** |
1681 |
* Recursively tries to find the first references to a remote object. |
1682 |
* This search is restricted to the given subsystem, if given. |
1683 |
* @param parent the parent item at which to start the search. |
1684 |
* @param elementName the absolute name of the remote element to find |
1685 |
* @param elementObject the actual remote element to find, for binary matching |
1686 |
* @param subsystem optional subsystem to search within |
1687 |
* @return TreeItem match if found, null if not found. |
1688 |
*/ |
1689 |
protected Item recursiveFindFirstRemoteItemReference(Item parent, String elementName, Object elementObject, ISubSystem subsystem) { |
1690 |
Object rawData = parent.getData(); |
1691 |
ISystemViewElementAdapter remoteAdapter = null; |
1692 |
// ---------------------------- |
1693 |
// what are we looking at here? |
1694 |
// ---------------------------- |
1695 |
if (rawData != null) remoteAdapter = getViewAdapter(rawData); |
1696 |
// ----------------------------------------------------------------------- |
1697 |
// if this is a remote object, test if it is the one we are looking for... |
1698 |
// ----------------------------------------------------------------------- |
1699 |
if (remoteAdapter != null) { |
1700 |
// first test for binary match |
1701 |
if (elementObject == rawData) { |
1702 |
if (debugRemote) System.out.println("Remote item binary match found"); //$NON-NLS-1$ |
1703 |
return parent; // return the match |
1704 |
} |
1705 |
// now test for absolute name match |
1706 |
String fqn = remoteAdapter.getAbsoluteName(rawData); |
1707 |
if (debugRemote) System.out.println("TESTING FINDFIRST: '" + fqn + "' vs '" + elementName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
1708 |
if ((fqn != null) && fqn.equals(elementName)) { |
1709 |
if ((subsystem != null) && (subsystem == remoteAdapter.getSubSystem(rawData))) { |
1710 |
if (debugRemote) System.out.println("Remote item name match found and subsystems matched"); //$NON-NLS-1$ |
1711 |
return parent; // return the match |
1712 |
} else if (subsystem == null) { |
1713 |
if (debugRemote) System.out.println("Remote item name match found and subsystem null"); //$NON-NLS-1$ |
1714 |
return parent; |
1715 |
} else if (debugRemote) System.out.println("Remote item name match found but subsystem mismatch"); //$NON-NLS-1$ |
1716 |
} |
1717 |
} |
1718 |
// ------------------------------------------------------------------------- |
1719 |
// if we have been given a subsystem to restrict to, that is a hint to us... |
1720 |
// ------------------------------------------------------------------------- |
1721 |
else if ((rawData != null) && (subsystem != null)) // test for hints we are in the wrong place |
1722 |
{ |
1723 |
// if we are currently visiting a subsystem, and that subsystem is not from the same |
1724 |
// factory, then we can assume the remote object occurrences we are looking for are |
1725 |
// not to be found within this branch... |
1726 |
if ((rawData instanceof ISubSystem) && (rawData != subsystem)) { |
1727 |
return null; // they don't match, so don't bother checking the kids |
1728 |
} |
1729 |
// if we are currently visiting a connection, and that connection's hostname is not the same |
1730 |
// as that of our given subsystem, then we can assume the remote object occurrences we are |
1731 |
// looking for are not to be found within this branch... |
1732 |
else if ((rawData instanceof IHost) && !((IHost) rawData).getHostName().equals(subsystem.getHost().getHostName())) { |
1733 |
return null; // they don't match, so don't bother checking the kids |
1734 |
} |
1735 |
} |
1736 |
// recurse over children |
1737 |
Item[] items = getChildren(parent); |
1738 |
Item match = null; |
1739 |
for (int i = 0; (match == null) && (i < items.length); i++) { |
1740 |
if (!items[i].isDisposed()) match = recursiveFindFirstRemoteItemReference(items[i], elementName, elementObject, subsystem); |
1741 |
} |
1742 |
return match; |
1743 |
} |
1572 |
} |
1744 |
} |