Bug 194838 - Move the code for comparing two objects by absolute name to a common location
Summary: Move the code for comparing two objects by absolute name to a common location
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 2.0.1   Edit
Assignee: David McKnight CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks: 195537
  Show dependency tree
 
Reported: 2007-06-28 16:53 EDT by Xuan Chen CLA
Modified: 2011-05-25 07:51 EDT (History)
1 user (show)

See Also:


Attachments
fix for bug 194838 (8.76 KB, patch)
2007-07-08 02:18 EDT, Xuan Chen CLA
mober.at+eclipse: iplog+
Details | Diff
Fix the NPE reported by Kevin (2.20 KB, patch)
2007-07-09 11:35 EDT, Xuan Chen CLA
mober.at+eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xuan Chen CLA 2007-06-28 16:53:38 EDT
Comparing two objects by
absolute name is an operation that's supposedly needed more frequently. We
should put it in a common location, at least "internal" for 2.0.1 if not API
for 3.0.
Comment 1 Xuan Chen CLA 2007-06-28 16:55:58 EDT
This is created because of bug 192716.

The comparison code should be in the patch of that bug.
Comment 2 Martin Oberhuber CLA 2007-06-29 05:33:18 EDT
Dave what do you think would be a good common place for comparing two objects by absolute name?
Comment 3 David McKnight CLA 2007-07-04 13:02:29 EDT
I would think that SystemRegistry would be an appropriate place, although it's interface, ISystemRegistry is public.  Would it make sense to put it in the implementation without the interface initially (i.e. for 2.0.1)?
Comment 4 Martin Oberhuber CLA 2007-07-04 13:11:38 EDT
Hm... the SystemRegistry is so filled with functionality already... also, the SystemRegistry implementation should be non-UI eventually, and if I'm not mistaken the compare code will need ISystemViewElementAdapter which is UI (though it might also work with IRemoteObjectIdentifier which is non-UI).

I had first thought about SystemAdapterHelpers, but perhaps keeping everything non-UI is indeed the better solution, is this possible?
Comment 5 David McKnight CLA 2007-07-04 13:27:58 EDT
Hmm.. I guess the adapters would be the most obvious way to do the comparison since we don't provide any other extension that allows new model objects to provide info about themselves.  IRemoteObjectIdentifier has the right API for this but not all objects use it.  SystemAdapterHelpers is really just there to help returning appropriate adapters for objects so it wouldn't seem like the ideal place.  I was thinking of system registry because it's got some related functionality such as getRemoteResourceAbsoluteName() and getAbsoluteNameForSubSystem().
Comment 6 Martin Oberhuber CLA 2007-07-04 13:30:01 EDT
Ok, then let's put it in the SystemRegistry impl, next to the methods you mentioned and provided that we can do it with non-UI dependencies only.

I think that IRemoteObjectIdentifier should be sufficient because ISystemViewElementAdapter (ultimately) derives from IRemoteObjectIdentifier.
Comment 7 Martin Oberhuber CLA 2007-07-06 07:45:05 EDT
See also bug #195537 asking for moving the ElementComparer out of the SystemView -- this could perhaps also make use of a utility class for comparing objects by absolute name
Comment 8 Xuan Chen CLA 2007-07-08 02:18:28 EDT
Created attachment 73269 [details]
fix for bug 194838

Move the comparison code to SystemRegistry.

. Since there is no getSubSystem() method in IRemoteObjectIdentifier, so use ISystemDragDropAdapter instead (which is not in a UI package).
. Since no API change in ISystemRegistry interface, we need to cast the resullt of RSECorePlugin.getTheSystemRegistry() to SystemRegistry so that the new method could be called.

Legal Message: I, Xuan Chen, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 9 David McKnight CLA 2007-07-09 09:18:54 EDT
I've put Xuan's changes in cvs.  Thanks Xuan!
Comment 10 Kevin Doyle CLA 2007-07-09 09:55:31 EDT
This leads to NPE's b/c of:

String subSystemId = getAbsoluteNameForSubSystem(subSystem); where subSystem is null.  
Comment 11 David McKnight CLA 2007-07-09 10:11:56 EDT
I just noticed this problem too.  If you use a host as the input to the view this can be hit when an event comes in.
Comment 12 Martin Oberhuber CLA 2007-07-09 10:51:32 EDT
(In reply to comment #8)
Thanks for the patch. I'm not too fond of using ISystemDragDropAdapter but I can see there is currently no way around it. I filed bug #195836 asking for an API change in 3.0 to push getSubSystem() up into IRemoteObjectIdentifier, where I think it belongs.
Comment 13 Xuan Chen CLA 2007-07-09 11:35:11 EDT
Created attachment 73338 [details]
Fix the NPE reported by Kevin

Legal Message: I, Xuan Chen, declare that I developed attached code from
scratch, without referencing any 3rd party materials except material licensed
under the EPL. I am authorized by my employer, IBM Canada Ltd. to make this
contribution under the EPL.
Comment 14 David McKnight CLA 2007-07-09 11:49:36 EDT
I've committed the update for this.
Comment 15 Martin Oberhuber CLA 2007-07-09 12:14:10 EDT
Please don't forget to add the "contributed" keyword as soon as a patch from a non-committer is checked in to CVS. Thanks!
Comment 16 David McKnight CLA 2007-07-09 12:16:42 EDT
oops...I gotta get into this habit!
Comment 17 Martin Oberhuber CLA 2007-07-10 07:23:57 EDT
The Change is good.

Just one little word of caution: When the SystemRegistry implementation is eventually moved from UI to a non-UI plugin, access to the "internal" method isSameObjectByAbsoluteName() will require opening access to the plugins that need it via the x-internal clause. Or, since this can only happen in the 3.0 stream, add public API for the isSameObjectByAbsoluteName() method.
Comment 18 Xuan Chen CLA 2007-11-09 01:14:02 EST
This problem is fixed.