Home » Modeling » GMF (Graphical Modeling Framework) » Custom Celleditor in gmf TWO
|
Re: Custom Celleditor in gmf TWO [message #160824 is a reply to message #160731] |
Fri, 16 November 2007 07:31 |
Eclipse User |
|
|
|
Originally posted by: marsha.rohrer.swisscom.com
Hi,
I'm not sure if this helps you because I don't use custom tabs but I
integrated a custom cell editor with GMF 2.0
In your XXXPropertySection#getPropertySource() create a new instance of
your CustomizedPropertySource. The createPropertySoruce() method of this
CostomizedProtpertySource returns a CustomizedPropertyDescriptor. The
method createPropertyEcitor() will then create your customized celleditor.
Hope that helps.
Regards,
Marsha
Here the code of my CustomizedPropertyDescritpor:
public class CustomizedPropertyDescriptor extends PropertyDescriptor {
public CustomizedPropertyDescriptor(Object object,
IItemPropertyDescriptor itemPropertyDescriptor) {
super(object, itemPropertyDescriptor);
}
public CellEditor createPropertyEditor(Composite composite) {
CellEditor result = super.createPropertyEditor(composite);
if (result == null)
return result;
EClassifier eType = ((EStructuralFeature) itemPropertyDescriptor
.getFeature(object)).getEType();
if (object instanceof Activity) {
if (eType instanceof EDataType) {
EDataType eDataType = (EDataType) eType;
if (eDataType.getInstanceClass() == String.class) {
result = new ExtendedDialogCellEditor(composite,
getEditLabelProvider()) {
protected Object openDialogBox(Control cellEditorWindow) {
ActivitySelectionDialog dialog = new ActivitySelectionDialog(
cellEditorWindow.getShell(),
cellEditorWindow.getParent());
dialog.create();
if (dialog.open() == Window.OK) {
Object dialogResult = dialog.getResult()[0];
if (dialogResult instanceof ActivityFunctionWrapper) {
ActivityFunctionWrapper wrap = (ActivityFunctionWrapper)
dialogResult;
String res = wrap.getActivity()
.getActivityName()
+ ":"
+ wrap.getFunction()
.getFunctionName();
return res;
}
return null;
}
return null;
}
};
}
}
}
if (object instanceof Flow) {
if (eType instanceof EDataType) {
EDataType eDataType = (EDataType) eType;
if (eDataType.getInstanceClass() == String.class) {
result = new ExtendedDialogCellEditor(composite,
getEditLabelProvider()) {
protected Object openDialogBox(Control cellEditorWindow) {
FlowSelectionDialog dialog = new FlowSelectionDialog(
cellEditorWindow.getShell());
dialog.create();
if (dialog.open() == Window.OK) {
Object dialogResult = dialog.getResult()[0];
if (dialogResult instanceof FlowReference) {
FlowReference flow = (FlowReference) dialogResult;
String res = flow.getFlowName() + ":"
+ flow.getVersion();
return res;
}
return null;
}
return null;
}
};
}
}
}
return result;
}
}
Paolo Russian wrote:
> It's weeks I'm trying with all the example fragments I found, all of the
> answers on this forum about customizing celleditors under gmf2 but no one
> worked.
> Is there a way to replace the celleditor or not in gmf2, in my custom tabs?
> Please have the merci not to answer "use search button", there is nothing
> but info working good but only on old gmf1.
|
|
|
Re: Custom Celleditor in gmf TWO [message #160856 is a reply to message #160824] |
Fri, 16 November 2007 10:28 |
paolo russian Messages: 81 Registered: July 2009 |
Member |
|
|
Marsha wrote:
> Hi,
> I'm not sure if this helps you because I don't use custom tabs but I
> integrated a custom cell editor with GMF 2.0
> In your XXXPropertySection#getPropertySource() create a new instance of
> your CustomizedPropertySource. The createPropertySoruce() method of this
> CostomizedProtpertySource returns a CustomizedPropertyDescriptor. The
> method createPropertyEcitor() will then create your customized celleditor.
> Hope that helps.
> Regards,
> Marsha
> Here the code of my CustomizedPropertyDescritpor:
> public class CustomizedPropertyDescriptor extends PropertyDescriptor {
> public CustomizedPropertyDescriptor(Object object,
> IItemPropertyDescriptor itemPropertyDescriptor) {
> super(object, itemPropertyDescriptor);
> }
> public CellEditor createPropertyEditor(Composite composite) {
> CellEditor result = super.createPropertyEditor(composite);
> if (result == null)
> return result;
> EClassifier eType = ((EStructuralFeature) itemPropertyDescriptor
> .getFeature(object)).getEType();
> if (object instanceof Activity) {
> if (eType instanceof EDataType) {
> EDataType eDataType = (EDataType) eType;
> if (eDataType.getInstanceClass() == String.class) {
> result = new ExtendedDialogCellEditor(composite,
> getEditLabelProvider()) {
> protected Object openDialogBox(Control cellEditorWindow) {
> ActivitySelectionDialog dialog = new ActivitySelectionDialog(
> cellEditorWindow.getShell(),
> cellEditorWindow.getParent());
> dialog.create();
> if (dialog.open() == Window.OK) {
> Object dialogResult = dialog.getResult()[0];
> if (dialogResult instanceof ActivityFunctionWrapper) {
> ActivityFunctionWrapper wrap = (ActivityFunctionWrapper)
> dialogResult;
> String res = wrap.getActivity()
> .getActivityName()
> + ":"
> + wrap.getFunction()
> .getFunctionName();
> return res;
> }
> return null;
> }
> return null;
> }
> };
> }
> }
> }
> if (object instanceof Flow) {
> if (eType instanceof EDataType) {
> EDataType eDataType = (EDataType) eType;
> if (eDataType.getInstanceClass() == String.class) {
> result = new ExtendedDialogCellEditor(composite,
> getEditLabelProvider()) {
> protected Object openDialogBox(Control cellEditorWindow) {
> FlowSelectionDialog dialog = new FlowSelectionDialog(
> cellEditorWindow.getShell());
> dialog.create();
> if (dialog.open() == Window.OK) {
> Object dialogResult = dialog.getResult()[0];
> if (dialogResult instanceof FlowReference) {
> FlowReference flow = (FlowReference) dialogResult;
> String res = flow.getFlowName() + ":"
> + flow.getVersion();
> return res;
> }
> return null;
> }
> return null;
> }
> };
> }
> }
> }
> return result;
> }
> }
> Paolo Russian wrote:
>> It's weeks I'm trying with all the example fragments I found, all of the
>> answers on this forum about customizing celleditors under gmf2 but no one
>> worked.
>> Is there a way to replace the celleditor or not in gmf2, in my custom tabs?
>> Please have the merci not to answer "use search button", there is nothing
>> but info working good but only on old gmf1.
hi! this will be useful, however, how do I hook this
new CustomizedPropertySource(object, ips);
in my
(XXX.diagram.components.sheet.) JunkPropertySection?
this method has this getpropertysource (generated)
/**
* @generated
*/
public IPropertySource getPropertySource(Object object) {
if (object instanceof IPropertySource) {
return (IPropertySource) object;
}
AdapterFactory af = getAdapterFactory(object);
if (af != null) {
IItemPropertySource ips = (IItemPropertySource) af.adapt(object,
IItemPropertySource.class);
if (ips != null) {
return new PropertySource(object, ips);
}
}
if (object instanceof IAdaptable) {
return (IPropertySource) ((IAdaptable) object)
.getAdapter(IPropertySource.class);
}
return null;
}
I'm triying to inserting my overrides but they are not read. because if I
replace up there the line:
return new PropertySource(object, ips);
with
return new CustomizedPropertySource(object, ips);
(and I provide a whatever code for CustomizedPropertySource) the
autogenerated code does not include any "createPropertySoruce", and if I
insert it by hand, won't be read. As I try to scramble a bit to force it
to start, I only mess up with constructors parameters missing or not
compatible.
So, what code did you do to link your ComponentPropertySection.java to
your CustomizedPropertyDescriptor.java??
Thanks
|
|
|
Re: Custom Celleditor in gmf TWO [message #161978 is a reply to message #160856] |
Thu, 22 November 2007 06:36 |
Eclipse User |
|
|
|
Originally posted by: marsha.rohrer.swisscom.com
Paolo Russian wrote:
> Marsha wrote:
>> Hi,
>> I'm not sure if this helps you because I don't use custom tabs but I
>> integrated a custom cell editor with GMF 2.0
>> In your XXXPropertySection#getPropertySource() create a new instance of
>> your CustomizedPropertySource. The createPropertySoruce() method of this
>> CostomizedProtpertySource returns a CustomizedPropertyDescriptor. The
>> method createPropertyEcitor() will then create your customized celleditor.
>> Hope that helps.
>> Regards,
>> Marsha
>> Here the code of my CustomizedPropertyDescritpor:
>> public class CustomizedPropertyDescriptor extends PropertyDescriptor {
>> public CustomizedPropertyDescriptor(Object object,
>> IItemPropertyDescriptor itemPropertyDescriptor) {
>> super(object, itemPropertyDescriptor);
>> }
>> public CellEditor createPropertyEditor(Composite composite) {
>> CellEditor result = super.createPropertyEditor(composite);
>> if (result == null)
>> return result;
>> EClassifier eType = ((EStructuralFeature) itemPropertyDescriptor
>> .getFeature(object)).getEType();
>> if (object instanceof Activity) {
>> if (eType instanceof EDataType) {
>> EDataType eDataType = (EDataType) eType;
>> if (eDataType.getInstanceClass() == String.class) {
>> result = new ExtendedDialogCellEditor(composite,
>> getEditLabelProvider()) {
>> protected Object openDialogBox(Control cellEditorWindow) {
>> ActivitySelectionDialog dialog = new ActivitySelectionDialog(
>> cellEditorWindow.getShell(),
>> cellEditorWindow.getParent());
>> dialog.create();
>> if (dialog.open() == Window.OK) {
>> Object dialogResult = dialog.getResult()[0];
>> if (dialogResult instanceof ActivityFunctionWrapper) {
>> ActivityFunctionWrapper wrap = (ActivityFunctionWrapper)
>> dialogResult;
>> String res = wrap.getActivity()
>> .getActivityName()
>> + ":"
>> + wrap.getFunction()
>> .getFunctionName();
>> return res;
>> }
>> return null;
>> }
>> return null;
>> }
>> };
>> }
>> }
>> }
>> if (object instanceof Flow) {
>> if (eType instanceof EDataType) {
>> EDataType eDataType = (EDataType) eType;
>> if (eDataType.getInstanceClass() == String.class) {
>> result = new ExtendedDialogCellEditor(composite,
>> getEditLabelProvider()) {
>> protected Object openDialogBox(Control cellEditorWindow) {
>> FlowSelectionDialog dialog = new FlowSelectionDialog(
>> cellEditorWindow.getShell());
>> dialog.create();
>> if (dialog.open() == Window.OK) {
>> Object dialogResult = dialog.getResult()[0];
>> if (dialogResult instanceof FlowReference) {
>> FlowReference flow = (FlowReference) dialogResult;
>> String res = flow.getFlowName() + ":"
>> + flow.getVersion();
>> return res;
>> }
>> return null;
>> }
>> return null;
>> }
>> };
>> }
>> }
>> }
>> return result;
>> }
>> }
>> Paolo Russian wrote:
>>> It's weeks I'm trying with all the example fragments I found, all of the
>>> answers on this forum about customizing celleditors under gmf2 but no one
>>> worked.
>>> Is there a way to replace the celleditor or not in gmf2, in my custom tabs?
>>> Please have the merci not to answer "use search button", there is nothing
>>> but info working good but only on old gmf1.
> hi! this will be useful, however, how do I hook this
> new CustomizedPropertySource(object, ips);
> in my
> (XXX.diagram.components.sheet.) JunkPropertySection?
> this method has this getpropertysource (generated)
> /**
> * @generated
> */
> public IPropertySource getPropertySource(Object object) {
> if (object instanceof IPropertySource) {
> return (IPropertySource) object;
> }
> AdapterFactory af = getAdapterFactory(object);
> if (af != null) {
> IItemPropertySource ips = (IItemPropertySource) af.adapt(object,
> IItemPropertySource.class);
> if (ips != null) {
> return new PropertySource(object, ips);
> }
> }
> if (object instanceof IAdaptable) {
> return (IPropertySource) ((IAdaptable) object)
> .getAdapter(IPropertySource.class);
> }
> return null;
> }
> I'm triying to inserting my overrides but they are not read. because if I
> replace up there the line:
> return new PropertySource(object, ips);
> with
> return new CustomizedPropertySource(object, ips);
> (and I provide a whatever code for CustomizedPropertySource) the
> autogenerated code does not include any "createPropertySoruce", and if I
> insert it by hand, won't be read. As I try to scramble a bit to force it
> to start, I only mess up with constructors parameters missing or not
> compatible.
> So, what code did you do to link your ComponentPropertySection.java to
> your CustomizedPropertyDescriptor.java??
> Thanks
Hi Paolo,
You are right. In your XXXPropertySection#getPropertySource() you just
have to return your CustomizedPropertySource instead of the PropertySource:
public IPropertySource getPropertySource(Object object) {
if (object instanceof IPropertySource) {
return (IPropertySource) object;
}
AdapterFactory af = getAdapterFactory(object);
if (af != null) {
IItemPropertySource ips = (IItemPropertySource) af.adapt(object,
IItemPropertySource.class);
if (ips != null) {
//customization
//return new PropertySource(object, ips);
return new CustomizedPropertySource(object, ips);
//customization end
}
}
if (object instanceof IAdaptable) {
return (IPropertySource) ((IAdaptable) object)
.getAdapter(IPropertySource.class);
}
return null;
}
In your CustomizedPropertySource you need to override the
createPropertyDescriptor() method which returns your
CustomizedPropertyDescriptor():
public class CustomizedPropertySource extends PropertySource {
public CustomizedPropertySource(Object object,
IItemPropertySource itemPropertySource) {
super(object, itemPropertySource);
}
protected IPropertyDescriptor createPropertyDescriptor(
IItemPropertyDescriptor itemPropertyDescriptor) {
return new CustomizedPropertyDescriptor(object,
itemPropertyDescriptor);
}
}
You can find a copy of my CustomizedPropertyDescriptor in my first post.
Like this it should work, at least it does in my case.
Cheers,
Marsha
|
|
|
Goto Forum:
Current Time: Thu Apr 25 01:50:03 GMT 2024
Powered by FUDForum. Page generated in 0.04683 seconds
|