Lines 18-23
Link Here
|
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 |
* Kevin Doyle (IBM) - [193151] Scratchpad not updated on Move |
|
|
21 |
* Kevin Doyle (IBM) - [189421] Scratchpad not updated after Rename |
21 |
********************************************************************************/ |
22 |
********************************************************************************/ |
22 |
|
23 |
|
23 |
package org.eclipse.rse.internal.ui.view.scratchpad; |
24 |
package org.eclipse.rse.internal.ui.view.scratchpad; |
Lines 40-45
Link Here
|
40 |
import org.eclipse.jface.action.MenuManager; |
41 |
import org.eclipse.jface.action.MenuManager; |
41 |
import org.eclipse.jface.action.Separator; |
42 |
import org.eclipse.jface.action.Separator; |
42 |
import org.eclipse.jface.viewers.DecoratingLabelProvider; |
43 |
import org.eclipse.jface.viewers.DecoratingLabelProvider; |
|
|
44 |
import org.eclipse.jface.viewers.IBasicPropertyConstants; |
43 |
import org.eclipse.jface.viewers.ISelection; |
45 |
import org.eclipse.jface.viewers.ISelection; |
44 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
46 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
45 |
import org.eclipse.jface.viewers.ISelectionProvider; |
47 |
import org.eclipse.jface.viewers.ISelectionProvider; |
Lines 47-53
Link Here
|
47 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
49 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
48 |
import org.eclipse.jface.viewers.StructuredSelection; |
50 |
import org.eclipse.jface.viewers.StructuredSelection; |
49 |
import org.eclipse.jface.viewers.TableLayout; |
51 |
import org.eclipse.jface.viewers.TableLayout; |
50 |
import org.eclipse.jface.viewers.TreeViewer; |
|
|
51 |
import org.eclipse.jface.window.SameShellProvider; |
52 |
import org.eclipse.jface.window.SameShellProvider; |
52 |
import org.eclipse.rse.core.RSECorePlugin; |
53 |
import org.eclipse.rse.core.RSECorePlugin; |
53 |
import org.eclipse.rse.core.events.ISystemRemoteChangeEvent; |
54 |
import org.eclipse.rse.core.events.ISystemRemoteChangeEvent; |
Lines 59-66
Link Here
|
59 |
import org.eclipse.rse.core.filters.ISystemFilter; |
60 |
import org.eclipse.rse.core.filters.ISystemFilter; |
60 |
import org.eclipse.rse.core.filters.ISystemFilterReference; |
61 |
import org.eclipse.rse.core.filters.ISystemFilterReference; |
61 |
import org.eclipse.rse.core.model.IHost; |
62 |
import org.eclipse.rse.core.model.IHost; |
|
|
63 |
import org.eclipse.rse.core.model.ISystemContainer; |
62 |
import org.eclipse.rse.core.model.ISystemRegistry; |
64 |
import org.eclipse.rse.core.model.ISystemRegistry; |
63 |
import org.eclipse.rse.core.references.IRSEBaseReferencingObject; |
65 |
import org.eclipse.rse.core.references.IRSEBaseReferencingObject; |
|
|
66 |
import org.eclipse.rse.core.subsystems.IRemoteObjectIdentifier; |
64 |
import org.eclipse.rse.core.subsystems.ISubSystem; |
67 |
import org.eclipse.rse.core.subsystems.ISubSystem; |
65 |
import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction; |
68 |
import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction; |
66 |
import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction; |
69 |
import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction; |
Lines 69-74
Link Here
|
69 |
import org.eclipse.rse.internal.ui.actions.SystemShowInTableAction; |
72 |
import org.eclipse.rse.internal.ui.actions.SystemShowInTableAction; |
70 |
import org.eclipse.rse.internal.ui.actions.SystemSubMenuManager; |
73 |
import org.eclipse.rse.internal.ui.actions.SystemSubMenuManager; |
71 |
import org.eclipse.rse.internal.ui.view.ElementComparer; |
74 |
import org.eclipse.rse.internal.ui.view.ElementComparer; |
|
|
75 |
import org.eclipse.rse.internal.ui.view.SafeTreeViewer; |
72 |
import org.eclipse.rse.internal.ui.view.SystemView; |
76 |
import org.eclipse.rse.internal.ui.view.SystemView; |
73 |
import org.eclipse.rse.internal.ui.view.SystemViewDataDragAdapter; |
77 |
import org.eclipse.rse.internal.ui.view.SystemViewDataDragAdapter; |
74 |
import org.eclipse.rse.internal.ui.view.SystemViewDataDropAdapter; |
78 |
import org.eclipse.rse.internal.ui.view.SystemViewDataDropAdapter; |
Lines 126-132
Link Here
|
126 |
public class SystemScratchpadView |
130 |
public class SystemScratchpadView |
127 |
// TODO change TreeViewer to ScratchpadViewer when Eclipse fixes SWT viewer |
131 |
// TODO change TreeViewer to ScratchpadViewer when Eclipse fixes SWT viewer |
128 |
// extends ScratchpadViewer |
132 |
// extends ScratchpadViewer |
129 |
extends TreeViewer |
133 |
extends SafeTreeViewer |
130 |
implements IMenuListener, ISystemDeleteTarget, |
134 |
implements IMenuListener, ISystemDeleteTarget, |
131 |
ISystemRenameTarget, ISystemSelectAllTarget, ISystemShellProvider, |
135 |
ISystemRenameTarget, ISystemSelectAllTarget, ISystemShellProvider, |
132 |
ISystemResourceChangeListener, ISystemRemoteChangeListener, |
136 |
ISystemResourceChangeListener, ISystemRemoteChangeListener, |
Lines 347-354
Link Here
|
347 |
} |
351 |
} |
348 |
break; |
352 |
break; |
349 |
case ISystemResourceChangeEvents.EVENT_REFRESH: |
353 |
case ISystemResourceChangeEvents.EVENT_REFRESH: |
|
|
354 |
case ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE: |
350 |
{ |
355 |
{ |
351 |
internalRefresh(parent); |
356 |
internalRefresh(child); |
352 |
} |
357 |
} |
353 |
break; |
358 |
break; |
354 |
case ISystemResourceChangeEvents.EVENT_REFRESH_SELECTED: |
359 |
case ISystemResourceChangeEvents.EVENT_REFRESH_SELECTED: |
Lines 537-554
Link Here
|
537 |
// -------------------------- |
542 |
// -------------------------- |
538 |
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED : |
543 |
case ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED : |
539 |
{ |
544 |
{ |
540 |
Object child = event.getResource(); |
545 |
renameRemoteObject(remoteResource, event.getOldName()); |
541 |
|
|
|
542 |
if (provider != null) |
543 |
{ |
544 |
Widget widget = findItem(child); |
545 |
if (widget != null) |
546 |
{ |
547 |
widget.setData(child); |
548 |
updateItem(widget, child); |
549 |
return; |
550 |
} |
551 |
} |
552 |
} |
546 |
} |
553 |
|
547 |
|
554 |
break; |
548 |
break; |
Lines 1612-1617
Link Here
|
1612 |
|
1606 |
|
1613 |
} |
1607 |
} |
1614 |
|
1608 |
|
|
|
1609 |
/** |
1610 |
* Rename a remote object. |
1611 |
*/ |
1612 |
protected void renameRemoteObject(Object renameObject, String oldElementName) { |
1613 |
String[] properties = new String[1]; |
1614 |
properties[0] = IBasicPropertyConstants.P_TEXT; |
1615 |
List matches = new Vector(); |
1616 |
ISubSystem subsystem = null; |
1617 |
String newElementName = ""; //$NON-NLS-1$ |
1618 |
Object refreshObject = null; |
1619 |
|
1620 |
// Try to determine the new element name/subsystem to help improve performance when searching for objects |
1621 |
if (renameObject instanceof String) { |
1622 |
newElementName = (String) renameObject; |
1623 |
} else { |
1624 |
ISystemViewElementAdapter rmtAdapter = getViewAdapter(renameObject); |
1625 |
if (rmtAdapter != null) { |
1626 |
subsystem = rmtAdapter.getSubSystem(renameObject); |
1627 |
newElementName = rmtAdapter.getName(renameObject); |
1628 |
} |
1629 |
} |
1630 |
|
1631 |
findAllRemoteItemReferences(oldElementName, renameObject, subsystem, matches); |
1632 |
|
1633 |
// Go through all the matches and update the properties |
1634 |
for (int i = 0; i < matches.size(); i++) { |
1635 |
Item item = (Item) matches.get(i); |
1636 |
if (item != null && !item.isDisposed()) { |
1637 |
Object data = item.getData(); |
1638 |
|
1639 |
if (data != null) { |
1640 |
ISystemRemoteElementAdapter remoteAdapter = (ISystemRemoteElementAdapter)((IAdaptable)data).getAdapter(ISystemRemoteElementAdapter.class); |
1641 |
|
1642 |
if (remoteAdapter != null && data != renameObject) |
1643 |
{ |
1644 |
remoteAdapter.refreshRemoteObject(data, renameObject); |
1645 |
} |
1646 |
item.setText(newElementName); |
1647 |
internalUpdate(item, data, properties); |
1648 |
|
1649 |
if (refreshObject == null) { |
1650 |
refreshObject = data; |
1651 |
} |
1652 |
|
1653 |
} |
1654 |
} |
1655 |
} |
1656 |
|
1657 |
if (refreshObject != null) { |
1658 |
// Update the Scratchpad Model |
1659 |
SystemRegistryUI.getInstance().getSystemScratchPad().replace(oldElementName, refreshObject); |
1660 |
|
1661 |
// FTP/SSH require a new listing of files otherwise they will |
1662 |
// display the old file names. |
1663 |
// We can't depend on SystemView to do the refresh as it does it in a |
1664 |
// deferred job and we don't know when that is done or what |
1665 |
// order the listeners are in. |
1666 |
if (refreshObject instanceof ISystemContainer) { |
1667 |
((ISystemContainer) refreshObject).markStale(true); |
1668 |
} |
1669 |
internalRefresh(refreshObject); |
1670 |
} |
1671 |
} |
1672 |
|
1615 |
//TODO: |
1673 |
//TODO: |
1616 |
// ---------------------------------------------------------------- |
1674 |
// ---------------------------------------------------------------- |
1617 |
// Functions Below are pure copies of the ones from SystemView |
1675 |
// Functions Below are pure copies of the ones from SystemView |
Lines 1741-1744
Link Here
|
1741 |
} |
1799 |
} |
1742 |
return match; |
1800 |
return match; |
1743 |
} |
1801 |
} |
|
|
1802 |
|
1803 |
/** |
1804 |
* Recursively tries to find all occurrences of a given remote object, starting at the tree root. |
1805 |
* Since the object memory object for a remote object is not dependable we call getAbsoluteName() |
1806 |
* on the adapter to do the comparisons. |
1807 |
* <p> |
1808 |
* TODO: This method should not return any invalid matches, i.e. remote objects |
1809 |
* that do match the String identifier but have been deleted already. Because the |
1810 |
* same remote object can appear in multiple contexts in the RSE Tree, a single |
1811 |
* remote object identifier String may evaluate to multiple different matches |
1812 |
* to fill into the matches argument. All those context object matches, however, |
1813 |
* reference the same real-world model objects due to the constraint that |
1814 |
* {@link IRemoteObjectIdentifier} uniquely identifies a remote object. |
1815 |
* <p> |
1816 |
* This overload takes a string and a subsystem. |
1817 |
* |
1818 |
* @param searchString the absolute name of the remote object to which |
1819 |
* we want to find a tree item which references it. |
1820 |
* @param elementObject the actual remote element to find, for binary matching |
1821 |
* @param subsystem optional subsystem to search within |
1822 |
* @param matches the List to populate with hits (TreeItem objects), |
1823 |
* or <code>null</code> to get a new List created and returned |
1824 |
* @return the List populated with hits, or <code>null</code> if |
1825 |
* <code>null</code> was passed as matches to populate and no matches |
1826 |
* were found. |
1827 |
*/ |
1828 |
protected List findAllRemoteItemReferences(String searchString, Object elementObject, ISubSystem subsystem, List matches) { |
1829 |
Tree tree = getTree(); |
1830 |
Item[] roots = tree.getItems(); |
1831 |
if (roots == null) return matches; |
1832 |
if (matches == null) |
1833 |
matches = new Vector(); |
1834 |
|
1835 |
boolean foundExact = false; |
1836 |
for (int idx = 0; idx < roots.length; idx++){ |
1837 |
if (recursiveFindExactMatches((TreeItem)roots[idx], elementObject, subsystem, matches)){ |
1838 |
foundExact = true; |
1839 |
} |
1840 |
} |
1841 |
|
1842 |
if (!foundExact) |
1843 |
{ |
1844 |
for (int idx = 0; idx < roots.length; idx++){ |
1845 |
matches = recursiveFindAllRemoteItemReferences(roots[idx], searchString, elementObject, subsystem, matches); |
1846 |
} |
1847 |
} |
1848 |
|
1849 |
return matches; |
1850 |
} |
1851 |
|
1852 |
private boolean recursiveFindExactMatches(TreeItem root, Object elementObject, ISubSystem subsystem, List matches) |
1853 |
{ |
1854 |
boolean foundSomething = false; |
1855 |
Object data = root.getData(); |
1856 |
if (data == elementObject) |
1857 |
{ |
1858 |
matches.add(root); |
1859 |
foundSomething = true; |
1860 |
} |
1861 |
if (subsystem != null){ |
1862 |
if (data instanceof ISubSystem){ |
1863 |
if (data != subsystem) |
1864 |
return false; |
1865 |
} |
1866 |
else if (data instanceof IHost){ |
1867 |
if (subsystem.getHost() != data) |
1868 |
return false; |
1869 |
} |
1870 |
} |
1871 |
|
1872 |
TreeItem[] children = root.getItems(); |
1873 |
for (int i = 0; i < children.length; i++) |
1874 |
{ |
1875 |
if (recursiveFindExactMatches(children[i], elementObject, subsystem, matches)) |
1876 |
{ |
1877 |
foundSomething = true; |
1878 |
} |
1879 |
} |
1880 |
return foundSomething; |
1881 |
} |
1882 |
|
1883 |
protected boolean mappedFindAllRemoteItemReferences(Object elementObject, List occurrences) |
1884 |
{ |
1885 |
Widget[] items = findItems(elementObject); |
1886 |
if (items.length > 0) |
1887 |
{ |
1888 |
for (int i = 0; i < items.length; i++) |
1889 |
{ |
1890 |
occurrences.add(items[i]); |
1891 |
} |
1892 |
return true; |
1893 |
} |
1894 |
|
1895 |
return false; |
1896 |
} |
1897 |
|
1898 |
/** |
1899 |
* Recursively tries to find all references to a remote object. |
1900 |
* @param parent the parent item at which to start the search. |
1901 |
* @param elementName the absolute name of the remote element to find |
1902 |
* @param elementObject the actual remote element to find, for binary matching |
1903 |
* @param subsystem optional subsystem to search within |
1904 |
* @param occurrences the List to populate with hits. Must not be <code>null</code> |
1905 |
* @return the given List populated with hits |
1906 |
*/ |
1907 |
protected List recursiveFindAllRemoteItemReferences(Item parent, String elementName, Object elementObject, ISubSystem subsystem, List occurrences) { |
1908 |
Object rawData = parent.getData(); |
1909 |
ISystemViewElementAdapter remoteAdapter = null; |
1910 |
// ---------------------------- |
1911 |
// what are we looking at here? |
1912 |
// ---------------------------- |
1913 |
if (rawData != null) remoteAdapter = getViewAdapter(rawData); |
1914 |
// ----------------------------------------------------------------------- |
1915 |
// if this is a remote object, test if it is the one we are looking for... |
1916 |
// ----------------------------------------------------------------------- |
1917 |
if (remoteAdapter != null) { |
1918 |
// first test for binary match |
1919 |
if (elementObject == rawData) { |
1920 |
occurrences.add(parent); // found a match! |
1921 |
if (debugRemote) System.out.println("Find All: Remote item binary match found"); //$NON-NLS-1$ |
1922 |
return occurrences; // no point in checking the kids |
1923 |
} |
1924 |
// now test for absolute name match |
1925 |
String fqn = remoteAdapter.getAbsoluteName(rawData); |
1926 |
if (debugRemote) System.out.println("TESTING FINDALL: '" + fqn + "' vs '" + elementName + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
1927 |
if ((fqn != null) && fqn.equals(elementName)) { |
1928 |
occurrences.add(parent); // found a match! |
1929 |
if (debugRemote) System.out.println("...and remote item name match found"); //$NON-NLS-1$ |
1930 |
return occurrences; // no point in checking the kids |
1931 |
} |
1932 |
} |
1933 |
// ------------------------------------------------------------------------- |
1934 |
// if we have been given a subsystem to restrict to, that is a hint to us... |
1935 |
// ------------------------------------------------------------------------- |
1936 |
else if ((rawData != null) && (subsystem != null)) // test for hints we are in the wrong place |
1937 |
{ |
1938 |
// if we are currently visiting a subsystem, and that subsystem is not from the same |
1939 |
// factory, then we can assume the remote object occurrences we are looking for are |
1940 |
// not to be found within this branch... |
1941 |
if ((rawData instanceof ISubSystem) && (((ISubSystem) rawData).getSubSystemConfiguration() != subsystem.getSubSystemConfiguration())) { |
1942 |
return occurrences; // they don't match, so don't bother checking the kids |
1943 |
} |
1944 |
// if we are currently visiting a connection, and that connection's hostname is not the same |
1945 |
// as that of our given subsystem, then we can assume the remote object occurrences we are |
1946 |
// looking for are not to be found within this branch... |
1947 |
else if ((rawData instanceof IHost) && (!((IHost) rawData).getHostName().equals(subsystem.getHost().getHostName()))) { |
1948 |
return occurrences; // they don't match, so don't bother checking the kids |
1949 |
} |
1950 |
} |
1951 |
// recurse over children |
1952 |
Item[] items = getChildren(parent); |
1953 |
for (int i = 0; (i < items.length); i++) { |
1954 |
|
1955 |
if (!items[i].isDisposed()) occurrences = recursiveFindAllRemoteItemReferences(items[i], elementName, elementObject, subsystem, occurrences); |
1956 |
} |
1957 |
return occurrences; |
1958 |
} |
1744 |
} |
1959 |
} |