Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » IStructuredSelection
IStructuredSelection [message #8945] Thu, 21 May 2009 21:51 Go to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Hi,

I constantly find myself writing this code:

if (selection instanceof IStructuredSelection) {
if (((IStructuredSelection)
selection).getFirstElement().getClass().equals(clazz)) {
return ((IStructuredSelection) selection).getFirstElement();
}
}

Is there a utility class available for ISelection and subordinates?

Thanks in advance and best regards,

Wim Jongman
http://www.remainsoftware.com
http://www.industrial-tsi.com
Re: IStructuredSelection [message #8987 is a reply to message #8945] Fri, 22 May 2009 01:39 Go to previous messageGo to next message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
Hi Wim,

Not that I know of. We have quite an elegant (IMO) solution in e4, but that
probably does not count. ;-)

A good first step towards a common solution is to build one yourself, in
your code, that works for your use cases. Then, once you have enough
confidence in the API, you could contribute it back through Bugzilla.

Boris

"Wim Jongman" <wim.jongman@remainsoftware.com> wrote in message
news:gv4ick$7v0$1@build.eclipse.org...
> Hi,
>
> I constantly find myself writing this code:
>
> if (selection instanceof IStructuredSelection) {
> if (((IStructuredSelection)
> selection).getFirstElement().getClass().equals(clazz)) {
> return ((IStructuredSelection) selection).getFirstElement();
> }
> }
>
> Is there a utility class available for ISelection and subordinates?
>
> Thanks in advance and best regards,
>
> Wim Jongman
> http://www.remainsoftware.com
> http://www.industrial-tsi.com
Re: IStructuredSelection [message #9007 is a reply to message #8987] Fri, 22 May 2009 12:17 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Hi Boris,

Thanks for your help. I already started a SelectionUtil class and if i'm
happy with it I wil do as you suggested. I'm curious about the e4 solution.
Have not seen e4 yet, but if I can find it I will give it a spin today.

--
Best Regards,

Wim Jongman
http://www.remainsoftware.com
http://www.industrial-tsi.com


"Boris Bokowski" <Boris_Bokowski@ca.ibm.com> wrote in message
news:gv4vo8$juq$1@build.eclipse.org...
> Hi Wim,
>
> Not that I know of. We have quite an elegant (IMO) solution in e4, but
> that probably does not count. ;-)
>
> A good first step towards a common solution is to build one yourself, in
> your code, that works for your use cases. Then, once you have enough
> confidence in the API, you could contribute it back through Bugzilla.
>
> Boris
>
> "Wim Jongman" <wim.jongman@remainsoftware.com> wrote in message
> news:gv4ick$7v0$1@build.eclipse.org...
>> Hi,
>>
>> I constantly find myself writing this code:
>>
>> if (selection instanceof IStructuredSelection) {
>> if (((IStructuredSelection)
>> selection).getFirstElement().getClass().equals(clazz)) {
>> return ((IStructuredSelection) selection).getFirstElement();
>> }
>> }
>>
>> Is there a utility class available for ISelection and subordinates?
>>
>> Thanks in advance and best regards,
>>
>> Wim Jongman
>> http://www.remainsoftware.com
>> http://www.industrial-tsi.com
>
>
Re: IStructuredSelection [message #9026 is a reply to message #9007] Fri, 22 May 2009 12:45 Go to previous message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
Hi Wim,

The solution for this in e4 is maybe not that easy to find... have a look at
the class "ExifTable" which implements the view displaying Exif data for
images. The idea is that the code that unwraps a selection should be outside
of the views, all you do is implement a method setInput(DomainObject o),
which will be called when there is an "input" of that type available for the
view.

Boris

"Wim Jongman" <wim.jongman@remainsoftware.com> wrote in message
news:gv655h$elh$1@build.eclipse.org...
> Hi Boris,
>
> Thanks for your help. I already started a SelectionUtil class and if i'm
> happy with it I wil do as you suggested. I'm curious about the e4
> solution. Have not seen e4 yet, but if I can find it I will give it a spin
> today.
>
> --
> Best Regards,
>
> Wim Jongman
> http://www.remainsoftware.com
> http://www.industrial-tsi.com
>
>
> "Boris Bokowski" <Boris_Bokowski@ca.ibm.com> wrote in message
> news:gv4vo8$juq$1@build.eclipse.org...
>> Hi Wim,
>>
>> Not that I know of. We have quite an elegant (IMO) solution in e4, but
>> that probably does not count. ;-)
>>
>> A good first step towards a common solution is to build one yourself, in
>> your code, that works for your use cases. Then, once you have enough
>> confidence in the API, you could contribute it back through Bugzilla.
>>
>> Boris
>>
>> "Wim Jongman" <wim.jongman@remainsoftware.com> wrote in message
>> news:gv4ick$7v0$1@build.eclipse.org...
>>> Hi,
>>>
>>> I constantly find myself writing this code:
>>>
>>> if (selection instanceof IStructuredSelection) {
>>> if (((IStructuredSelection)
>>> selection).getFirstElement().getClass().equals(clazz)) {
>>> return ((IStructuredSelection) selection).getFirstElement();
>>> }
>>> }
>>>
>>> Is there a utility class available for ISelection and subordinates?
>>>
>>> Thanks in advance and best regards,
>>>
>>> Wim Jongman
>>> http://www.remainsoftware.com
>>> http://www.industrial-tsi.com
>>
>>
>
Previous Topic:Opening A View Programatically
Next Topic:Strange toolbar
Goto Forum:
  


Current Time: Fri Apr 26 11:29:26 GMT 2024

Powered by FUDForum. Page generated in 0.04163 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top