Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How to set properties in Properties View ?
How to set properties in Properties View ? [message #299418] Thu, 16 February 2006 11:47 Go to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Dear developers,
i like to connect objects to the properties view.
When i select an object (with the Mouse etc.) the attributes (changes allowed) should appear in the view . I know i have to implement IPropertySource but i don't know how i can connect it to the properties view.

Thanks in advance
Re: How to set properties in Properties View ? [message #299419 is a reply to message #299418] Thu, 16 February 2006 11:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------070206090405080004010309
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Marcel,

EMF's generated editors do it like this:

public Object getAdapter(Class key)
{
if (key.equals(IContentOutlinePage.class))
{
return getContentOutlinePage();
}
* else if (key.equals(IPropertySheetPage.class))**
{
return getPropertySheetPage();
}*
else if (key.equals(IGotoMarker.class))
{
return this;
}
else
{
return super.getAdapter(key);
}
}

public IPropertySheetPage getPropertySheetPage()
{
if (propertySheetPage == null)
{
propertySheetPage =
new ExtendedPropertySheetPage(editingDomain)
{
public void setSelectionToViewer(List selection)
{
EcoreEditor.this.setSelectionToViewer(selection);
EcoreEditor.this.setFocus();
}

public void setActionBars(IActionBars actionBars)
{
super.setActionBars(actionBars);
getActionBarContributor().shareGlobalActions(this,
actionBars);
}
};
* propertySheetPage.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));*
}

return propertySheetPage;
}


Marcel wrote:
> Dear developers,
> i like to connect objects to the properties view.
> When i select an object (with the Mouse etc.) the attributes (changes allowed) should appear in the view . I know i have to implement IPropertySource but i don't know how i can connect it to the properties view.
>
> Thanks in advance
>


--------------070206090405080004010309
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Marcel,<br>
<br>
EMF's generated editors do it like this:<br>
<blockquote><small>&nbsp; public Object getAdapter(Class key)</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; if (key.equals(IContentOutlinePage.class))</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return getContentOutlinePage();</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;<b>&nbsp;&nbsp; else if (key.equals(IPropertySheetPage.class))</b></small><b><br >
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return getPropertySheetPage();</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small></b><br>
<small>&nbsp;&nbsp;&nbsp; else if (key.equals(IGotoMarker.class))</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this;</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; else</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return super.getAdapter(key);</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp; }</small><br>
</blockquote>
<blockquote><small>&nbsp; public IPropertySheetPage getPropertySheetPage()</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; if (propertySheetPage == null)</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; propertySheetPage =</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; new ExtendedPropertySheetPage(editingDomain)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public void setSelectionToViewer(List selection)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EcoreEditor.this.setSelectionToViewer(selection);</small><br >
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EcoreEditor.this.setFocus();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public void setActionBars(IActionBars actionBars)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super.setActionBars(actionBars);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getActionBarContributor().shareGlobalActions(this,
actionBars);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; };</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b > propertySheetPage.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));</b></small ><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<br>
<small>&nbsp;&nbsp;&nbsp; return propertySheetPage;</small><br>
<small>&nbsp; }</small><br>
</blockquote>
<br>
Marcel wrote:
<blockquote
cite="mid32602395.1140108467612.JavaMail.root@cp1.javalobby.org"
type="cite">
<pre wrap="">Dear developers,
i like to connect objects to the properties view.
When i select an object (with the Mouse etc.) the attributes (changes allowed) should appear in the view . I know i have to implement IPropertySource but i don't know how i can connect it to the properties view.

Thanks in advance
</pre>
</blockquote>
<br>
</body>
</html>

--------------070206090405080004010309--
Re: How to set properties in Properties View ? [message #299427 is a reply to message #299419] Thu, 16 February 2006 13:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

If you don't need a special (your own) property sheet page, then all you
need to do is for your selected object (these are the objects that show
up in your editor/view as the ISelection) needs to implement IAdaptable
and do:

public Object getAdapter(Class key) {
if (key == IPropertySource.class) {
return new YourPropertySource(this);
} else
...
}


This will then work with the default property sheet page if you don't
require any special processing other than what IPropertySource can do.
--
Thanks,
Rich Kulp
Re: How to set properties in Properties View ? [message #299428 is a reply to message #299418] Thu, 16 February 2006 13:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Your class needs to implement IAdaptable, and you have to provide a mechanism that when asked for an instance of IPRopertySource, that you return an implementation that can connect you. Often, it will look like:

public MyClass implements Adaptable, IPropertySource {
  public Object getAdapter(Class clazz) {
    if (clazz == IPropertySource.class) {
       return this;
    }
    return null;
  }
}


However, your class doesn't have to implement IPropertySource. It can return another class (say, an anonymous or named inner class) that does the work.

Ultimately it boils down to calls in the IPropertySource that look like getObject(String property) or some such. You just need to have a nested if looking for the name of the property and converting it into a real value.
Re: How to set properties in Properties View ? [message #299448 is a reply to message #299418] Fri, 17 February 2006 03:33 Go to previous message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Thank you all for the answers !
Always a great help !
Previous Topic:Preprocessor plugin for Java
Next Topic:how to export plugin
Goto Forum:
  


Current Time: Wed Jul 23 17:39:24 EDT 2025

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

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

Back to the top