Home » Modeling » GMF (Graphical Modeling Framework) » property with File Browser Dialog
property with File Browser Dialog [message #32636] |
Tue, 29 August 2006 05:05  |
Eclipse User |
|
|
|
Originally posted by: john.watson.yahoo.com
Hi,
I need a property where to store filename. How can I make choose the file
by file browser dialog?
Thanks in advance!
John
|
|
| | | |
Re: property with File Browser Dialog [message #39628 is a reply to message #38768] |
Tue, 05 September 2006 09:58   |
Eclipse User |
|
|
|
Originally posted by: ayalandzhiev.sbnd.net
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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>
>>>
>> < http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>
>>
|
|
|
Re: property with File Browser Dialog [message #40093 is a reply to message #39628] |
Tue, 05 September 2006 18:21   |
Eclipse User |
|
|
|
Originally posted by: khai.n.situvista.com
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.Advan cedPropertySection
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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>>
>>>>
>>> < http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>>
>>>
|
|
|
Re: property with File Browser Dialog [message #41705 is a reply to message #40093] |
Thu, 07 September 2006 07:14   |
Eclipse User |
|
|
|
Originally posted by: ayalandzhiev.sbnd.net
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.Advan cedPropertySection
>
>
> 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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>>>
>>>>>
>>>> < http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>>>
>>>>
|
|
|
Re: property with File Browser Dialog [message #42077 is a reply to message #41705] |
Thu, 07 September 2006 11:45   |
Eclipse User |
|
|
|
Originally posted by: khai.n.situvista.com
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.Advan cedPropertySection
>>
>>
>> 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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>>>>
>>>>>>
>>>>> < http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>>>>
>>>>>
|
|
|
Re: property with File Browser Dialog [message #42509 is a reply to message #42077] |
Fri, 08 September 2006 02:37   |
Eclipse User |
|
|
|
Originally posted by: ayalandzhiev.sbnd.net
Excuse me for my poor description :(. I extend
org.eclipse.gmf.runtime.diagram.ui.properties.sections.Advan cedPropertySection
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.Advan cedPropertySection
>>>
>>>
>>> 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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>>>>>
>>>>>>>
>>>>>> < http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>>>>>
>>>>>>
|
|
|
Re: property with File Browser Dialog [message #43576 is a reply to message #42077] |
Sat, 09 September 2006 15:37   |
Eclipse User |
|
|
|
Originally posted by: john.watson.gmail.com
Hi,
the problem is that in AdapterFactoryProvider#getPropertySource(Object
object) - the object is value which was set for the feature but I need the
feature to build PropertySource. Because if the feature was not set, I'll
get null and will not be able to recognize if I have to use FileBrowser
property source or not.
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.Advan cedPropertySection
>>>
>>>
>>> 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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>>>>>
>>>>>>>
>>>>>>
< http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>>>>>
>>>>>>
|
|
|
Re: property with File Browser Dialog [message #43639 is a reply to message #42509] |
Sat, 09 September 2006 18:38   |
Eclipse User |
|
|
|
Originally posted by: khai.n.situvista.com
Sorry but looking at the GMF code the approach used for EMF as suggested
previously will not work because GMF employs a lot of encapsulation and
dynamic binding of the properties which basically buries the code so
deep that any changes to the normal behavior (using the suggestions
below) seems like major surgery:-(
I'll look into it some more to see if I can figure out a simple way to
modify its normal behavior... but I'm not too optimistic:-(
-- Khai --
Atanas wrote:
> Excuse me for my poor description :(. I extend
> org.eclipse.gmf.runtime.diagram.ui.properties.sections.Advan cedPropertySection
> 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.Advan cedPropertySection
>>>>
>>>>
>>>> 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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>>>>>>
>>>>>>>>
>>>>>>> < http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>>>>>>
>>>>>>>
|
|
|
Re: property with File Browser Dialog (actual solution!!!) [message #44102 is a reply to message #43639] |
Sun, 10 September 2006 19:24   |
Eclipse User |
|
|
|
Originally posted by: khai.n.situvista.com
OK, I have to say sorry for leading you down the wrong path ealier:-(
This is what I have found out by piecing together what was suggested
earlier in this thread and also other postings(including one by Mischael
today)
Starting from just the plain generated code we can do this in 3 easy
steps.
Let's assume you have an application called MyApplication, an element
called MyElement, and a property of MyElement called MyProperty that you
want to override with a custom dialog for the PropertiesView.
Let's start from the bottom up.
1. You need a DialogCellEditor either custom or built-in.
Here's a sample of a custom DialogCellEditor that simply ask for a text
input:
public class CustomDialogCellEditor extends DialogCellEditor {
public CustomDialogCellEditor(Composite parent) {
super(parent);
}
protected Object openDialogBox(Control cellEditorWindow) {
/*
* Here you can instantiate any built-in or custom Dialog you want
*/
InputDialog dialog = new InputDialog(null, "New Value", "Enter
a new value", getValue().toString(), null);
/*
* Only if the user clicks OK in your dialog do you return the
new value otherwise return the original value
*/
return (InputDialog.OK == dialog.open()) ? dialog.getValue():
getValue();
}
}
============================================================ ===========
2. You need a subclass of EMFCompositeSourcePropertyDescriptor which
uses your CustomDialogCellEditor. Here's a sample:
public class CustomPropertyDescriptor extends
EMFCompositeSourcePropertyDescriptor {
public CustomPropertyDescriptor(Object object,
IItemPropertyDescriptor itemPropertyDescriptor, String category) {
super(object, itemPropertyDescriptor, category);
}
protected CellEditor doCreateEditor(Composite composite) {
/*
* The features for your element will be fed in one at a time
* Here you will override just the one(s) you want
*/
if
(MyApplication.eINSTANCE.getMyElement_MyProperty().equals(ge tFeature())) {
return new CustomDialogCellEditor(composite);
}
return super.doCreateEditor(composite);
}
}
============================================================ ========
3. Finally, you need to override createPropertySource() in your
....diagram.providers.MyApplicationPropertyProvider to use your
CustomPropertyDescriptor.
protected ICompositePropertySource createPropertySource(Object object,
IItemPropertySource itemPropertySource) {
/*
* If it's an instance of your element then return your
CustomPropertyDescriptor
*/
if (object instanceof MyElement) {
return new EMFCompositePropertySource(object,
itemPropertySource, "EMF") {
protected IPropertyDescriptor
newPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) {
return new CustomPropertyDescriptor(object,
itemPropertyDescriptor, getCategory());
}
};
}
return super.createPropertySource(object, itemPropertySource);
}
And that should be it; I should have researched into this more
thoroughly before:-(.
-- Khai --
Khai M Nguyen wrote:
> Sorry but looking at the GMF code the approach used for EMF as suggested
> previously will not work because GMF employs a lot of encapsulation and
> dynamic binding of the properties which basically buries the code so
> deep that any changes to the normal behavior (using the suggestions
> below) seems like major surgery:-(
>
> I'll look into it some more to see if I can figure out a simple way to
> modify its normal behavior... but I'm not too optimistic:-(
>
> -- Khai --
>
>
>
> Atanas wrote:
>> Excuse me for my poor description :(. I extend
>> org.eclipse.gmf.runtime.diagram.ui.properties.sections.Advan cedPropertySection
>> 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.Advan cedPropertySection
>>>>>
>>>>>
>>>>> 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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>>>>>>>
>>>>>>>>>
>>>>>>>> < http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>>>>>>>
>>>>>>>>
|
|
| |
Re: property with File Browser Dialog (actual solution!!!) [message #45178 is a reply to message #44102] |
Mon, 11 September 2006 12:20   |
Eclipse User |
|
|
|
Originally posted by: ayalandzhiev.sbnd.net
Thank you very much for help, it works.
Only one little problem is when choose file form dialog and file name
appears in cell I do not know how to clear (delete) name of chosen file
because cell can not be edited.
Khai M Nguyen wrote:
> OK, I have to say sorry for leading you down the wrong path ealier:-(
>
> This is what I have found out by piecing together what was suggested
> earlier in this thread and also other postings(including one by Mischael
> today)
>
> Starting from just the plain generated code we can do this in 3 easy
> steps.
>
> Let's assume you have an application called MyApplication, an element
> called MyElement, and a property of MyElement called MyProperty that you
> want to override with a custom dialog for the PropertiesView.
>
>
> Let's start from the bottom up.
>
> 1. You need a DialogCellEditor either custom or built-in.
>
> Here's a sample of a custom DialogCellEditor that simply ask for a text
> input:
>
> public class CustomDialogCellEditor extends DialogCellEditor {
> public CustomDialogCellEditor(Composite parent) {
> super(parent);
> }
>
> protected Object openDialogBox(Control cellEditorWindow) {
>
> /*
> * Here you can instantiate any built-in or custom Dialog you want
> */
> InputDialog dialog = new InputDialog(null, "New Value", "Enter a
> new value", getValue().toString(), null);
>
> /*
> * Only if the user clicks OK in your dialog do you return the
> new value otherwise return the original value
> */
> return (InputDialog.OK == dialog.open()) ? dialog.getValue():
> getValue();
> }
> }
>
> ============================================================ ===========
>
> 2. You need a subclass of EMFCompositeSourcePropertyDescriptor which
> uses your CustomDialogCellEditor. Here's a sample:
>
> public class CustomPropertyDescriptor extends
> EMFCompositeSourcePropertyDescriptor {
> public CustomPropertyDescriptor(Object object,
> IItemPropertyDescriptor itemPropertyDescriptor, String category) {
> super(object, itemPropertyDescriptor, category);
> }
> protected CellEditor doCreateEditor(Composite composite) {
> /*
> * The features for your element will be fed in one at a time
> * Here you will override just the one(s) you want
> */
> if
> (MyApplication.eINSTANCE.getMyElement_MyProperty().equals(ge tFeature())) {
> return new CustomDialogCellEditor(composite);
> }
> return super.doCreateEditor(composite);
> }
> }
>
>
> ============================================================ ========
> 3. Finally, you need to override createPropertySource() in your
> ....diagram.providers.MyApplicationPropertyProvider to use your
> CustomPropertyDescriptor.
>
>
> protected ICompositePropertySource createPropertySource(Object object,
> IItemPropertySource itemPropertySource) {
> /*
> * If it's an instance of your element then return your
> CustomPropertyDescriptor
> */
> if (object instanceof MyElement) {
> return new EMFCompositePropertySource(object,
> itemPropertySource, "EMF") {
> protected IPropertyDescriptor
> newPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) {
> return new CustomPropertyDescriptor(object,
> itemPropertyDescriptor, getCategory());
> }
> };
> }
> return super.createPropertySource(object, itemPropertySource);
> }
>
>
>
> And that should be it; I should have researched into this more
> thoroughly before:-(.
>
> -- Khai --
>
>
>
>
> Khai M Nguyen wrote:
>> Sorry but looking at the GMF code the approach used for EMF as suggested
>> previously will not work because GMF employs a lot of encapsulation and
>> dynamic binding of the properties which basically buries the code so
>> deep that any changes to the normal behavior (using the suggestions
>> below) seems like major surgery:-(
>>
>> I'll look into it some more to see if I can figure out a simple way to
>> modify its normal behavior... but I'm not too optimistic:-(
>>
>> -- Khai --
>>
>>
>>
>> Atanas wrote:
>>> Excuse me for my poor description :(. I extend
>>> org.eclipse.gmf.runtime.diagram.ui.properties.sections.Advan cedPropertySection
>>> 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.Advan cedPropertySection
>>>>>>
>>>>>>
>>>>>> 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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> < http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>>>>>>>>
>>>>>>>>>
|
|
|
Re: property with File Browser Dialog (actual solution!!!) [message #45489 is a reply to message #45178] |
Mon, 11 September 2006 18:15  |
Eclipse User |
|
|
|
Originally posted by: khai.n.situvista.com
You can right-click on the name (not the value!!) of the property
in the Properties View and choose "Restore Default Value" which will
restore it to being empty if that was your default value.
-- Khai --
Atanas wrote:
> Thank you very much for help, it works.
> Only one little problem is when choose file form dialog and file name
> appears in cell I do not know how to clear (delete) name of chosen file
> because cell can not be edited.
>
>
> Khai M Nguyen wrote:
>> OK, I have to say sorry for leading you down the wrong path ealier:-(
>>
>> This is what I have found out by piecing together what was suggested
>> earlier in this thread and also other postings(including one by Mischael
>> today)
>>
>> Starting from just the plain generated code we can do this in 3 easy
>> steps.
>>
>> Let's assume you have an application called MyApplication, an element
>> called MyElement, and a property of MyElement called MyProperty that you
>> want to override with a custom dialog for the PropertiesView.
>>
>>
>> Let's start from the bottom up.
>>
>> 1. You need a DialogCellEditor either custom or built-in.
>>
>> Here's a sample of a custom DialogCellEditor that simply ask for a text
>> input:
>>
>> public class CustomDialogCellEditor extends DialogCellEditor {
>> public CustomDialogCellEditor(Composite parent) {
>> super(parent);
>> }
>>
>> protected Object openDialogBox(Control cellEditorWindow) {
>>
>> /*
>> * Here you can instantiate any built-in or custom Dialog you
>> want
>> */
>> InputDialog dialog = new InputDialog(null, "New Value", "Enter
>> a new value", getValue().toString(), null);
>>
>> /*
>> * Only if the user clicks OK in your dialog do you return the
>> new value otherwise return the original value
>> */
>> return (InputDialog.OK == dialog.open()) ? dialog.getValue():
>> getValue();
>> }
>> }
>>
>> ============================================================ ===========
>>
>> 2. You need a subclass of EMFCompositeSourcePropertyDescriptor which
>> uses your CustomDialogCellEditor. Here's a sample:
>>
>> public class CustomPropertyDescriptor extends
>> EMFCompositeSourcePropertyDescriptor {
>> public CustomPropertyDescriptor(Object object,
>> IItemPropertyDescriptor itemPropertyDescriptor, String category) {
>> super(object, itemPropertyDescriptor, category);
>> }
>> protected CellEditor doCreateEditor(Composite composite) {
>> /*
>> * The features for your element will be fed in one at a time
>> * Here you will override just the one(s) you want
>> */
>> if
>> (MyApplication.eINSTANCE.getMyElement_MyProperty().equals(ge tFeature()))
>> {
>> return new CustomDialogCellEditor(composite);
>> }
>> return super.doCreateEditor(composite);
>> }
>> }
>>
>>
>> ============================================================ ========
>> 3. Finally, you need to override createPropertySource() in your
>> ....diagram.providers.MyApplicationPropertyProvider to use your
>> CustomPropertyDescriptor.
>>
>>
>> protected ICompositePropertySource createPropertySource(Object object,
>> IItemPropertySource itemPropertySource) {
>> /*
>> * If it's an instance of your element then return your
>> CustomPropertyDescriptor
>> */
>> if (object instanceof MyElement) {
>> return new EMFCompositePropertySource(object,
>> itemPropertySource, "EMF") {
>> protected IPropertyDescriptor
>> newPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) {
>> return new CustomPropertyDescriptor(object,
>> itemPropertyDescriptor, getCategory());
>> }
>> };
>> }
>> return super.createPropertySource(object, itemPropertySource);
>> }
>>
>>
>>
>> And that should be it; I should have researched into this more
>> thoroughly before:-(.
>>
>> -- Khai --
>>
>>
>>
>>
>> Khai M Nguyen wrote:
>>> Sorry but looking at the GMF code the approach used for EMF as suggested
>>> previously will not work because GMF employs a lot of encapsulation and
>>> dynamic binding of the properties which basically buries the code so
>>> deep that any changes to the normal behavior (using the suggestions
>>> below) seems like major surgery:-(
>>>
>>> I'll look into it some more to see if I can figure out a simple way to
>>> modify its normal behavior... but I'm not too optimistic:-(
>>>
>>> -- Khai --
>>>
>>>
>>>
>>> Atanas wrote:
>>>> Excuse me for my poor description :(. I extend
>>>> org.eclipse.gmf.runtime.diagram.ui.properties.sections.Advan cedPropertySection
>>>> 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.Advan cedPropertySection
>>>>>>>
>>>>>>>
>>>>>>> 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+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.tools.emf&wm=wrd&t=News&t=Mail
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> < http://www.eclipse.org/search/search.cgi?q=custom+cell+edito r+file+dialog&cmd=Search%21&form=extended&wf=574 a74&ps=10&m=all&t=5&ul=%2Fnewslists%2Fnews.e clipse.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
>>>>>>>>>>>>
>>>>>>>>>>
|
|
|
Goto Forum:
Current Time: Fri May 09 01:30:00 EDT 2025
Powered by FUDForum. Page generated in 0.06741 seconds
|