[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.gmf] Re: property with File Browser Dialog
|
Excuse me for my poor description :(. I extend
org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection
method getPropertySourceProvider().
Then make my custom CustomAdapterFactoryProvider to return
CustomPropertySource in case if I have File.class to return Property
Descriptor - ColorPropertyDescriptor.
The problem is when I create with "ColorPropertyDescriptor(object,
"Property Name"); " and here I can not get "Property Name" because in
object I have only value (description for type of property) for example
: if you have property in "Advanced" section with name - "Font Style"
and user choose value for this property - "normal" and this property
appears in category - "EMF" then object which I get from
"getPropertySource(Object object)" contains only value "normal" and
there is no way to get name -"Font Style" and category - "EMF".
This is the all code :
---------------------------------------------------------------------------------
public class CustomAdvancedPropertySection extends AdvancedPropertySection {
protected IPropertySourceProvider getPropertySourceProvider() {
return new CustomAdapterFactoryProvider();
}
}
final class CustomAdapterFactoryProvider extends
PropertiesServiceAdapterFactory
{
@Override
public IPropertySource getPropertySource(Object object) {
if (object instanceof Color.class) {
return new CustomPropertySource(object);
} else
return super.getPropertySource(object);
}
}
final class CustomPropertySource implements IPropertySource
{
// Property Descriptors
static protected IPropertyDescriptor[] propertyDescriptors = new
IPropertyDescriptor[1];
private Object object;
public CustomPropertySource(Object object)
{
this.object = object;
}
public Object getEditableValue() {
// TODO Auto-generated method stub
return object;
}
public IPropertyDescriptor[] getPropertyDescriptors() {
ColorPropertyDescriptor descriptor;
descriptor = new ColorPropertyDescriptor(object, "Property Name");
//descriptor.setCategory("EMF"); //Hardcoded
propertyDescriptors[0] = descriptor;
return propertyDescriptors;
}
public Object getPropertyValue(Object id) {
// TODO Auto-generated method stub
return null;
}
public boolean isPropertySet(Object id) {
// TODO Auto-generated method stub
return false;
}
public void resetPropertyValue(Object id) {
// TODO Auto-generated method stub
}
public void setPropertyValue(Object id, Object value) {
// TODO Auto-generated method stub
}
}
Thank you in advance !!!
Regards Atanas.
Khai M Nguyen wrote:
Hi, Atanas, I don't understand what you are asking:-(
Maybe it will help if you describe a little more on what you have done,
and more specifically in which class/classes are the 2 methods below;
these methods are found all over the place so which one are you
referring to?.
-- Khai --
Atanas wrote:
Thanks Khai, I use your advise and now I can change Property
Descriptors, but I have a problem because the object in
"IPropertySource getPropertySource(Object object)" represents value of
property in sheet property page (for example object of type Integer or
other depends of type value) and later in section :
"public IPropertyDescriptor[] getPropertyDescriptors() {
ColorPropertyDescriptor descriptor;
descriptor = new ColorPropertyDescriptor(object,
PropertyName); ",
and I can not get the name of the property and category !!
I do not know how to do it.
Regards, Atanas.
Khai M Nguyen wrote:
This is a bit of a stretch because I haven't implemented any of this but
this is what I think you'd need to do for the GMF Properties View.
GMF uses tabbed sheets and sections... in your case specifically
org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection
It's this class that you would need to extend and override; the method
getPropertySourceProvider() is where you would return your custom
provider.
The rest of the information mentioned earlier in this thread should
still be applicable.
Additionally you would have to override the contribution in the
plugin.xml to use your 'custom' AdvancedPropertySection.
There is a thread in this same newsgroup under "Adding underline and
strikethrough in appereance" where I'd posted some suggestions on how to
override the default contributions.
Hopes this help.
-- Khai --
Atanas wrote:
I have the same problem,
John did you find some solution to problem ?
Regards,
Atanas.
Ed Merks wrote:
John,
That's sounds like a GMF question I don't know the answer to...
John Watson wrote:
Hi Ed,
Thank you for the link. I tryed to use some of the solutions but
it didn't help me very much.
For example:
The editor has this:
propertySheetPage.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
so you can override the the content provider to create a derived
property source:
protected IPropertySource createPropertySource(Object object,
IItemPropertySource itemPropertySource)
{
return new PropertySource(object, itemPropertySource);
}
and you can override the property source to create a derived property
descriptor:
protected IPropertyDescriptor
createPropertyDescriptor(IItemPropertyDescriptor
itemPropertyDescriptor)
{
return new PropertyDescriptor(object, itemPropertyDescriptor);
}
And there you can implement whatever logic you want to produce
alternative cell editors in whatever situations they would be
appropriate.
I change the propertySheetPage.setPropertySourceProviderto use my
own class (new CustomAdapterFactoryContentProvider(adapterFactory));
But it's not called from Diagram. I noticed that GMF uses
%Model%PropertyProvider extends GenericEMFPropertiesProvider
and only the addImagePropertyDescriptor
{itemPropertyDescriptors.add(..)} from ItemProvider
and I don't know how to chnage that method to achieve the desired
result
Ed Merks wrote:
John,
Try searching the EMF newsgroup like this:
http://www.eclipse.org/search/search.cgi?q=custom+cell+editor+file+dialog&cmd=Search%21&form=extended&wf=574a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.eclipse.tools.emf&wm=wrd&t=News&t=Mail
<http://www.eclipse.org/search/search.cgi?q=custom+cell+editor+file+dialog&cmd=Search%21&form=extended&wf=574a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.eclipse.tools.emf&wm=wrd&t=News&t=Mail>
John Watson wrote:
Hi,
I need a property where to store filename. How can I make choose
the file by file browser dialog?
Thanks in advance!
John