Properties view -- again. [message #442613] |
Wed, 18 January 2006 02:38  |
Eclipse User |
|
|
|
Hi,
All the views in my RCP application publish selection events using
getSite().setSelectionProvider(viewer);
Only certain objects in certain views should show properties. The
properties view will render a selected object if the selected object
implements IAdaptable that returns an IPropertySource. If the selected
view does not implement IAdaptable and/or return an IPropertySource,
then the Properties view shows blank.
So my question is: How do I make the properties view render the
properties of only those objects that implement IAdaptable which return
an IPropertySource ?
--
Ketan Padegaonkar
|
|
|
|
|
|
Re: Properties view -- again. [message #445016 is a reply to message #443082] |
Sun, 26 February 2006 07:19  |
Eclipse User |
|
|
|
Hi,
i lately had the same Problem. What i basically did to solved it, was to
override the Default Properties view and write my own selection Changed
listener which in case there is no PropertySource available for the
current selection uses the last shown selection. I did this like this:
public class MyPropertySheet extends PropertySheet
{
private static ISelection lastSelection = null;
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection)
{
/* First we check if the current selection Provides an
* IPropertySource if so we provide it as current selection
*/
if (selection instanceof IStructuredSelection){
IStructuredSelection sel = (IStructuredSelection)selection;
if (sel.getFirstElement() instanceof IAdaptable)
{
IAdaptable adapter = (IAdaptable)sel.getFirstElement();
if (adapter.getAdapter(IPropertySource.class) != null)
{
super.selectionChanged(part, selection);
lastSelection = selection;
return;
}
}
}
super.selectionChanged(part, lastSelection);
}
}
For this new View i used the same id used for the original Property
Sheet view. By doing this the original view is replaced by my new view.
Regards
Andreas
Ketan Padegaonkar schrieb:
>
>
> Nick Edgar wrote:
>> > If the selected view does not implement IAdaptable and/or return an
>> IPropertySource,
>> > then the Properties view shows blank
>>
>> I think you meant:
>> > If the selected object does not implement...
>>
>> With this correction, what you wrote is an accurate description of how
>> the Properties view works (at least for the default property sheet
>> page -- it's possible for the view/editor to provide a custom property
>> sheet page by handling getAdapter(IPropertySheetPage.class)).
>>
>> I'm unclear on what the problem is. Are you saying you don't want the
>> Properties view to get blanked out if you select an object that does
>> not provide an IPropertySource?
>
> The above corrections and your interpretation of my problem is correct:
> I do not want the Properties view to get blanked if I select an object
> that does not provide an IPropertySource.
>
|
|
|
Powered by
FUDForum. Page generated in 0.08215 seconds