|
Lines 41-46
Link Here
|
| 41 |
* Kevin Doyle (IBM) - [196582] Deprecated getRemoteObjectIdentifier |
41 |
* Kevin Doyle (IBM) - [196582] Deprecated getRemoteObjectIdentifier |
| 42 |
* Martin Oberhuber (Wind River) - [198650] Fix assertion when restoring workbench state |
42 |
* Martin Oberhuber (Wind River) - [198650] Fix assertion when restoring workbench state |
| 43 |
* Martin Oberhuber (Wind River) - [183176] Fix "widget is disposed" during Platform shutdown |
43 |
* Martin Oberhuber (Wind River) - [183176] Fix "widget is disposed" during Platform shutdown |
|
|
44 |
* David McKnight (IBM) - [204684] CheckExistsJob used for determining if a remote object exists after a query of it's children |
| 44 |
********************************************************************************/ |
45 |
********************************************************************************/ |
| 45 |
|
46 |
|
| 46 |
package org.eclipse.rse.internal.ui.view; |
47 |
package org.eclipse.rse.internal.ui.view; |
|
Lines 5738-5743
Link Here
|
| 5738 |
} |
5739 |
} |
| 5739 |
*/ |
5740 |
*/ |
| 5740 |
|
5741 |
|
|
|
5742 |
/** |
| 5743 |
* For bug 204684: |
| 5744 |
* |
| 5745 |
* Because we don't have an API for ISystemViewElementAdapter.exists()... |
| 5746 |
* This class is used to determine whether an object exists and consequently whether to remove it from the view |
| 5747 |
* after a query comes back with either no children or a SystemMessageObject. We query the parent to determine |
| 5748 |
* whether the remote object exists - in that case we just leave the message as is in the view. In the case where |
| 5749 |
* we detect that the object does not exist, we re-populate the parent node with the new children. |
| 5750 |
*/ |
| 5751 |
public class CheckExistenceJob extends UIJob |
| 5752 |
{ |
| 5753 |
private IAdaptable _remoteObject; |
| 5754 |
private TreeItem _item; |
| 5755 |
public CheckExistenceJob(IAdaptable remoteObject, TreeItem item) |
| 5756 |
{ |
| 5757 |
super("Check existence"); |
| 5758 |
_remoteObject = remoteObject; |
| 5759 |
_item = item; |
| 5760 |
setSystem(true); |
| 5761 |
} |
| 5762 |
|
| 5763 |
public IStatus runInUIThread(IProgressMonitor monitor) |
| 5764 |
{ |
| 5765 |
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)_remoteObject.getAdapter(ISystemViewElementAdapter.class); |
| 5766 |
|
| 5767 |
TreeItem parentItem = _item.getParentItem(); |
| 5768 |
|
| 5769 |
IContextObject context = getContextObject(parentItem); |
| 5770 |
Object[] children = adapter.getChildren(context, monitor); |
| 5771 |
if (contains(children, _remoteObject)) |
| 5772 |
{ |
| 5773 |
// we want to end this so the user sees the error message |
| 5774 |
} |
| 5775 |
else |
| 5776 |
{ |
| 5777 |
// first need to remove the old items |
| 5778 |
TreeItem[] items = parentItem.getItems(); |
| 5779 |
for (int i = 0; i < items.length; i++) { |
| 5780 |
if (items[i].getData() != null) { |
| 5781 |
disassociate(items[i]); |
| 5782 |
items[i].dispose(); |
| 5783 |
} else { |
| 5784 |
items[i].dispose(); |
| 5785 |
} |
| 5786 |
} |
| 5787 |
|
| 5788 |
|
| 5789 |
// we want to propagate the changes to the view |
| 5790 |
add(context.getModelObject(), children); |
| 5791 |
} |
| 5792 |
|
| 5793 |
return Status.OK_STATUS; |
| 5794 |
} |
| 5795 |
|
| 5796 |
private boolean contains(Object[] children, IAdaptable remoteObject) |
| 5797 |
{ |
| 5798 |
for (int i = 0; i < children.length; i++) |
| 5799 |
{ |
| 5800 |
if (children[i] == remoteObject) |
| 5801 |
{ |
| 5802 |
return true; |
| 5803 |
} |
| 5804 |
} |
| 5805 |
return false; |
| 5806 |
} |
| 5807 |
} |
| 5808 |
|
| 5809 |
|
| 5741 |
public void add(Object parentElementOrTreePath, Object[] childElements) { |
5810 |
public void add(Object parentElementOrTreePath, Object[] childElements) { |
| 5742 |
assertElementsNotNull(childElements); |
5811 |
assertElementsNotNull(childElements); |
| 5743 |
|
5812 |
|
|
Lines 5831-5840
Link Here
|
| 5831 |
{ |
5900 |
{ |
| 5832 |
if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath)) |
5901 |
if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath)) |
| 5833 |
{ |
5902 |
{ |
| 5834 |
// refresh the parent |
5903 |
/* |
| 5835 |
Object par = adapter.getParent(parentElementOrTreePath); |
5904 |
|
| 5836 |
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); |
5905 |
// refresh the parent |
| 5837 |
sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null)); |
5906 |
Object par = adapter.getParent(parentElementOrTreePath); |
|
|
5907 |
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); |
| 5908 |
sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null)); |
| 5909 |
|
| 5910 |
*/ |
| 5911 |
|
| 5912 |
// for bug 204684, using this job to determine whether or not the object exists before trying to update |
| 5913 |
CheckExistenceJob job = new CheckExistenceJob((IAdaptable)parentElementOrTreePath, (TreeItem)match); |
| 5914 |
job.schedule(); |
| 5915 |
|
| 5838 |
} |
5916 |
} |
| 5839 |
} |
5917 |
} |
| 5840 |
|
5918 |
|